import{_ as N}from"./DocsButton.vue_vue_type_script_setup_true_lang.a3da320f.js";import{C as D}from"./ContentLayout.16882285.js";import{f as R,F as P,s as x}from"./FilesNavigator.af685f1b.js";import{a as B}from"./asyncComputed.9c066391.js";import{d as U,e3 as z,g as S,o as k,c as A,w as u,a as w,b as l,az as f,u as d,d6 as T,O as V,d4 as G,eF as H,eG as M,Q as E}from"./index.56a4aa2e.js";import{C as i}from"./gateway.03a16684.js";import"./columns.1a209a57.js";import"./popupNotifcation.2b90a8f1.js";import"./ant-design.495703a7.js";import"./string.c8a67ded.js";import"./PhFolder.vue.164d7697.js";import"./record.1426f0e6.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]="598cdf1c-04e6-4a8b-93df-c9fb13907b3a",s._sentryDebugIdIdentifier="sentry-dbid-598cdf1c-04e6-4a8b-93df-c9fb13907b3a")}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,a){const r={"Content-Type":"multipart/form-data"},c=new File([new Blob(a?[a]:[])],R(e));return i.post(`projects/${this.projectId}/files/upload?path=${encodeURIComponent(e)}`,c,r)}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,a){return i.patch(`projects/${this.projectId}/files?path=${encodeURIComponent(e)}&newPath=${encodeURIComponent(a)}`,{})}}const L=s=>(H("data-v-b9ae801f"),s=s(),M(),s),O={class:"files-layout"},Q=L(()=>w("br",null,null,-1)),q=U({__name:"Files",setup(s){const a=z().params.projectId,r=h.fromProjectId(a),{loading:c,result:m,refetch:_}=B(()=>r.list()),y=n=>n.reduce((o,t)=>{var I,b;const $=t.type==="file"?[]:(b=(I=t.children)==null?void 0:I.map(p=>p.path.split("/")))!=null?b:[],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 r.upload(t,o),await _()}function C(n){const o=n.join("/");return r.download(o)}function v(n){const o=n.join("/");return r.delete(o)}return(n,o)=>(k(),A(D,null,{default:u(()=>[w("div",O,[l(d(T),null,{default:u(()=>[f("Files")]),_:1}),l(d(G),null,{default:u(()=>[f(" Here you can upload, download and delete files in your persistent dir."),Q,f(" Files can be used in your scripts. "),l(N,{path:"cloud/files"}),V(n.$slots,"description",{},void 0,!0)]),_:3}),l(P,{files:j.value,loading:d(c),separator:"/",onCreate:g,onDownload:C,onDelete:v,onRefetch:d(_)},null,8,["files","loading","onRefetch"])])]),_:3}))}});const re=E(q,[["__scopeId","data-v-b9ae801f"]]);export{re as default};
//# sourceMappingURL=Files.e76c1fff.js.map
