import{h as u,j as m,g as F}from"./codemirror-core-DIzFijqu.js";import{_ as h}from"./react-dom-C0IJc3nR.js";import{s as r}from"./index-CjmGjyN8.js";function k(s){const e=u.useRef(null);return u.useImperativeHandle(s,()=>e.current),e}var O=s=>m.jsx("svg",{"aria-hidden":"true",fill:"none",focusable:"false",height:"1em",role:"presentation",viewBox:"0 0 24 24",width:"1em",...s,children:m.jsx("path",{d:"M15.5 19l-7-7 7-7",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5"})}),c={exports:{}},p,y;function R(){if(y)return p;y=1;var s="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return p=s,p}var d,w;function T(){if(w)return d;w=1;var s=R();function e(){}function a(){}return a.resetWarningCache=e,d=function(){function t(i,U,C,P,D,b){if(b!==s){var l=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw l.name="Invariant Violation",l}}t.isRequired=t;function n(){return t}var o={array:t,bigint:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:n,element:t,elementType:t,instanceOf:n,node:t,objectOf:n,oneOf:n,oneOfType:n,shape:n,exact:n,checkPropTypes:a,resetWarningCache:e};return o.PropTypes=o,o},d}var f;function v(){return f||(f=1,c.exports=T()()),c.exports}var g=v();const S=F(g);class j{static async listFiles(e="/"){const{data:a}=await r.get(`/File/list?path=${encodeURIComponent(e)}`);return a.data}static async listDirectories(e="/"){const{data:a}=await r.get(`/File/list?path=${encodeURIComponent(e)}&onlyDirectory=true`);return a.data}static async createDirectory(e){const{data:a}=await r.post("/File/mkdir",{path:e});return a.data}static async delete(e){const{data:a}=await r.post("/File/delete",{path:e});return a.data}static async readFile(e){const{data:a}=await r.get(`/File/read?path=${encodeURIComponent(e)}`);return a.data}static async writeFile(e,a){const{data:t}=await r.post("/File/write",{path:e,content:a});return t.data}static async createFile(e){const{data:a}=await r.post("/File/create",{path:e});return a.data}static async batchDelete(e){const{data:a}=await r.post("/File/batchDelete",{paths:e});return a.data}static async rename(e,a){const{data:t}=await r.post("/File/rename",{oldPath:e,newPath:a});return t.data}static async move(e,a){const{data:t}=await r.post("/File/move",{sourcePath:e,targetPath:a});return t.data}static async batchMove(e){const{data:a}=await r.post("/File/batchMove",{items:e});return a.data}static download(e){const a=`/File/download?path=${encodeURIComponent(e)}`;h.promise(r.post(a,void 0,{responseType:"blob"}).catch(t=>{throw console.error(t),new Error("下载失败")}),{loading:"正在下载文件...",success:"下载成功",error:"下载失败"}).then(t=>{const n=window.URL.createObjectURL(new Blob([t.data])),o=document.createElement("a");o.href=n;let i=e.split("/").pop()||"";e.split(".").length===1&&(i+=".zip"),o.setAttribute("download",i),document.body.appendChild(o),o.click(),document.body.removeChild(o)}).catch(t=>{console.error(t)})}static async batchDownload(e){h.promise(r.post("/File/batchDownload",{paths:e},{responseType:"blob"}).catch(t=>{throw console.error(t),new Error("下载失败")}),{loading:"正在下载文件...",success:"下载成功",error:"下载失败"}).then(t=>{const n=window.URL.createObjectURL(new Blob([t.data])),o=document.createElement("a");o.href=n,o.setAttribute("download","files.zip"),document.body.appendChild(o),o.click(),document.body.removeChild(o)}).catch(t=>{console.error(t)})}static async downloadToURL(e){const a=`/File/download?path=${encodeURIComponent(e)}`,t=await r.post(a,void 0,{responseType:"blob"});return window.URL.createObjectURL(new Blob([t.data]))}static async upload(e,a){const t=new FormData;a.forEach(o=>{t.append("files",o)});const{data:n}=await r.post(`/File/upload?path=${encodeURIComponent(e)}`,t,{headers:{"Content-Type":"multipart/form-data"}});return n.data}static async uploadWebUIFont(e){const a=new FormData;a.append("file",e);const{data:t}=await r.post("/File/font/upload/webui",a,{headers:{"Content-Type":"multipart/form-data"}});return t.data}static async deleteWebUIFont(){const{data:e}=await r.post("/File/font/delete/webui");return e.data}}export{O as C,j as F,S as P,k as u};
