import"./jwt-decode.esm.7c9b757c.js";import{k as i}from"./router.95e6e4b6.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="5d620a78-cf99-49b9-b2a2-f2f1c44fd42d",t._sentryDebugIdIdentifier="sentry-dbid-5d620a78-cf99-49b9-b2a2-f2f1c44fd42d")}catch{}})();function m(t){var e;return(e=t.split(/\/|\\/).pop())!=null?e:""}function b(t){return[".png",".svg",".jpg",".jpeg",".ico",".webp"].some(e=>t.endsWith(e))}const d=5*1024*1024,p={"image/png":[".png"],"image/jpeg":[".jpg",".jpeg"],"image/gif":[".gif"],"image/webp":[".webp"],"application/pdf":[".pdf"],"text/plain":[".txt"],"text/csv":[".csv"],"text/markdown":[".md"],"application/json":[".json"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":[".xlsx"],"application/vnd.ms-excel":[".xls"]},v=()=>Object.values(p).flat(),g=t=>Object.keys(p).includes(t),y=t=>{const e=t.lastIndexOf(".");return e===-1?"":t.substring(e).toLowerCase()},u=t=>{const e=y(t);if(!e)return null;for(const[o,n]of Object.entries(p))if(n.includes(e))return o;return null},w=t=>u(t)!==null,j=t=>{if(t.size>d)return{valid:!1,error:`File size exceeds ${I(d)} limit`};const e=t.type&&g(t.type),o=w(t.name);return!e&&!o?{valid:!1,error:"Unsupported file type"}:{valid:!0}},h=t=>new Promise((e,o)=>{const n=new FileReader;n.readAsDataURL(t),n.onload=()=>{const r=n.result.split(",")[1];e(r)},n.onerror=s=>o(s)}),S=async t=>{const e=j(t);if(!e.valid)throw new Error(e.error);const o=await h(t),n=t.type||u(t.name)||"application/octet-stream";return{fileName:t.name,fileContent:o,fileSize:t.size,mimeType:n}},I=t=>{if(t===0)return"0 Bytes";const e=1024,o=["Bytes","KB","MB","GB"],n=Math.floor(Math.log(t)/Math.log(e));return Math.round(t/Math.pow(e,n)*100)/100+" "+o[n]};class f{constructor(e){this.projectId=e}static fromProjectId(e){return new f(e)}async list(e,o,n,s){const r=new URLSearchParams;r.set("limit",e.toString()),r.set("offset",o.toString()),n&&n.trim()&&r.set("search",n.trim()),s&&s.trim()&&r.set("path",s.trim());const a=r.toString(),c=`projects/${this.projectId}/files?${a}`,l=await i.get(c);return{items:l.items,totalCount:l.totalCount}}async upload(e,o,n){const s={"Content-Type":"multipart/form-data"},r=new File([o||new Uint8Array],m(e)),a=n?"&overwrite=true":"",c=`projects/${this.projectId}/files/upload?path=${encodeURIComponent(e)}${a}`;return i.post(c,r,s)}async download(e){return i.getBlob(`projects/${this.projectId}/files/download?path=${encodeURIComponent(e)}`)}async delete(e){return i.delete(`projects/${this.projectId}/files?path=${encodeURIComponent(e)}`)}async move(e,o){return i.post(`projects/${this.projectId}/files/move`,{path:e,newPath:o})}async createFolder(e){return i.post(`projects/${this.projectId}/files/create-folder`,{path:e})}}export{f as F,v as g,b as i,S as p};
//# sourceMappingURL=file.ea417f0a.js.map
