import{_ as N}from"./DocsButton.vue_vue_type_script_setup_true_lang.3a6d45c1.js";import{C as D}from"./ContentLayout.c509f1dd.js";import{f as P,F as R,s as x}from"./FilesNavigator.1ca2e56c.js";import{a as B}from"./asyncComputed.c1514d75.js";import{d as U,e4 as z,g as S,c as k,w as u,o as A,a as b,b as l,az as f,u as c,d6 as T,O as V,d4 as H,eP as M,eQ as Q,Q as E}from"./index.fd66f361.js";import{C as i}from"./gateway.c8676992.js";import"./columns.a93ffaa0.js";import"./popupNotifcation.45eb3465.js";import"./ant-design.01b4eef9.js";import"./string.973cdadd.js";import"./PhDotsThree.vue.cae130ab.js";import"./PhFolder.vue.a4dd1c07.js";import"./record.8d6523fc.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[e]="790ec3e3-7193-4fdb-8968-2c26633ab2c4",s._sentryDebugIdIdentifier="sentry-dbid-790ec3e3-7193-4fdb-8968-2c26633ab2c4")}catch{}})();class h{constructor(e){this.projectId=e}static fromProjectId(e){return new h(e)}async list(){return i.get(`projects/${this.projectId}/files`)}async upload(e,r){const a={"Content-Type":"multipart/form-data"},d=new File([new Blob(r?[r]:[])],P(e));return i.post(`projects/${this.projectId}/files/upload?path=${encodeURIComponent(e)}`,d,a)}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,r){return i.patch(`projects/${this.projectId}/files?path=${encodeURIComponent(e)}&newPath=${encodeURIComponent(r)}`,{})}}const G=s=>(M("data-v-4b0cf5fc"),s=s(),Q(),s),L={class:"files-layout"},O=G(()=>b("br",null,null,-1)),q=U({__name:"Files",setup(s){const r=z().params.projectId,a=h.fromProjectId(r),{loading:d,result:m,refetch:_}=B(()=>a.list()),y=n=>n.reduce((o,t)=>{var I,w;const $=t.type==="file"?[]:(w=(I=t.children)==null?void 0:I.map(p=>p.path.split("/")))!=null?w:[],F={pathParts:t.path.split("/"),size:t.type==="file"?x(t.size):0,lastModified:t.date,type:t.type,children:$};if(o.push(F),t.type==="directory"&&t.children&&t.children.length>0){const p=y(t.children);o.push(...p)}return o},[]),j=S(()=>m.value?y(m.value):[]);async function g(n,o){const t=n.join("/");await a.upload(t,o),await _()}function C(n){const o=n.join("/");return a.download(o)}function v(n){const o=n.join("/");return a.delete(o)}return(n,o)=>(A(),k(D,null,{default:u(()=>[b("div",L,[l(c(T),null,{default:u(()=>[f("Files")]),_:1}),l(c(H),null,{default:u(()=>[f(" Here you can upload, download and delete files in your persistent dir."),O,f(" Files can be used in your scripts. "),l(N,{path:"tools/files"}),V(n.$slots,"description",{},void 0,!0)]),_:3}),l(R,{files:j.value,loading:c(d),separator:"/",onCreate:g,onDownload:C,onDelete:v,onRefetch:c(_)},null,8,["files","loading","onRefetch"])])]),_:3}))}});const ie=E(q,[["__scopeId","data-v-4b0cf5fc"]]);export{ie as default};
//# sourceMappingURL=Files.9ea3dc7e.js.map
