@marimo-team/frontend 0.20.5-dev17 → 0.20.5-dev19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- var Pt=Object.defineProperty;var Dt=(t,e,s)=>e in t?Pt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var B=(t,e,s)=>Dt(t,typeof e!="symbol"?e+"":e,s);import{s as Me}from"./chunk-LvLJmgfZ.js";import{i as zt,l as he,n as T,p as Re,u as se}from"./useEvent-WUlsM6MC.js";import{t as Ot}from"./react-Bj1aDYRI.js";import{En as Mt,T as Rt,kn as $e,si as $t,ui as Ae,ur as At}from"./cells-BLS3X4Af.js";import"./react-dom-CSu739Rf.js";import{t as te}from"./compiler-runtime-B3qBwwSJ.js";import"./tooltip-Mz5m-WBI.js";import{i as Ee,r as Et,t as Ie}from"./add-connection-dialog-CmJm_APe.js";import{h as It,m as ge}from"./useEventListener-CTPW4ELK.js";import{t as Lt}from"./invariant-awXiPaF0.js";import{p as Tt,u as Le}from"./utils-D6N4h71e.js";import{S as me}from"./config-CEhpfPsm.js";import{t as Bt}from"./jsx-runtime-CP2fAiZX.js";import{n as Vt,t as $}from"./button-B_BBklax.js";import{t as q}from"./cn-d_A4rA-x.js";import{St as Ht}from"./dist-Dr9qtoId.js";import{a as Ut,i as Te,o as pe}from"./JsonOutput-CHgq3R6J.js";import"./cjs-CVt8hZ5L.js";import"./main-Cmx6WhDY.js";import"./useNonce-BY4jV7Yb.js";import{n as qt,r as je}from"./requests-DZy_SQ_v.js";import{t as ae}from"./createLucideIcon-BvP5LBIs.js";import{a as Be,i as Ve,l as He,n as fe,o as Wt,r as Kt,s as ye,t as Yt}from"./state-BI4WmvIs.js";import{n as Zt}from"./LazyAnyLanguageCodeMirror-B11pcXh7.js";import{t as Gt}from"./x-yqLqiq5Q.js";import{c as Jt,i as ve,r as Ue}from"./download-dbepOsRi.js";import{f as be}from"./maps-BLIeOscV.js";import{n as Qt}from"./markdown-renderer-rEsmEgLk.js";import{u as Xt}from"./toDate-DDAiY7kz.js";import{a as M,c as ne,p as qe,r as We,t as Ke}from"./dropdown-menu-C8nocIkm.js";import{t as we}from"./copy-CAR4dOiD.js";import{t as Ne}from"./download-BG-iMGgV.js";import{t as ea}from"./eye-off-DgTL09j7.js";import{a as ta,i as Ye,n as Ze,r as aa,t as sa}from"./file-icons-DN9ij4Wl.js";import{t as Ge}from"./file-plus-corner-BRwJx0yp.js";import{t as Je}from"./file-DVwc11C3.js";import{n as ke,t as na}from"./spinner-Dt4SmUsI.js";import{t as Qe}from"./plus-C9B_qWUi.js";import{t as Xe}from"./refresh-cw-fLeDriQe.js";import{t as ra}from"./save-C91FTnFa.js";import{t as ia}from"./trash-2-CrA4LwJ2.js";import{t as la}from"./triangle-alert-CzmxsxFO.js";import{i as oa,n as ca,t as da}from"./es-DgeOOQmd.js";import"./dist-Jp_4M-Ei.js";import"./dist-Cf47zp7b.js";import"./dist-Bagw3W9X.js";import"./dist-t1vdhOX_.js";import"./dist-D3OoaVQX.js";import{t as E}from"./use-toast-Hc8CXlvz.js";import{t as Fe}from"./paths-D2lG83Oh.js";import"./session--x-9D3HE.js";import"./Combination-CvuTtFZA.js";import{t as A}from"./tooltip-CSN_sVIP.js";import"./purify.es-BBn8CPhf.js";import"./dates-DbMtViXe.js";import{o as ha}from"./alert-dialog-7IgjDQnl.js";import{t as et}from"./context-CRApIvpB.js";import"./popover-BoqMUhMK.js";import{n as tt}from"./ImperativeModal-CPUoA52T.js";import{r as ma}from"./errors-0IrrdfSG.js";import{n as pa}from"./blob-DgooIGjS.js";import"./vega-loader.browser-BJ9oKrvH.js";import"./defaultLocale-CuYNS33t.js";import"./defaultLocale-CGfP-Ye3.js";import{t as re}from"./copy-BxX1HhLi.js";import{t as fa}from"./copy-icon-C7DYKLrA.js";import{n as xa}from"./multi-map-DNuS4OLr.js";import{a as ua,i as ga,n as Ce,r as ja,t as ya}from"./tree-DFAMcRzN.js";import{n as va,t as ba}from"./alert-Bs8tbZo_.js";import{n as at}from"./error-banner-DC7kSyWN.js";import{n as Se}from"./useAsyncData-CI3ntihq.js";import{a as wa,o as st,t as Na,u as ka}from"./command-CQd7U1fL.js";import"./chunk-5FQGJX7Z-Cyze_Wbx.js";import"./katex-FSdXOW5Y.js";import"./html-to-image-Fz0aHtSN.js";import{o as Fa}from"./focus-YYacdzxP.js";import{a as Ca}from"./renderShortcut-D-zdqWZr.js";import{t as Sa}from"./bundle.esm-_LzfhNmX.js";import{a as _a,c as nt,d as _e,l as rt,u as it}from"./components-BnwE0U6X.js";import{t as Pa}from"./empty-state-DFr2pZOz.js";import{t as Pe}from"./formatting-B5u5A8vd.js";import{a as Da,i as za,n as lt,r as ot,t as ct}from"./components-8Q-wOvzt.js";import{n as dt,t as Oa}from"./marimo-icons-BDAuIiW5.js";import{t as Ma}from"./links-DwLHiCvK.js";var Ra=ae("copy-minus",[["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),ht=ae("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),mt=ae("list-tree",[["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"M3 10a2 2 0 0 0 2 2h3",key:"1npucw"}],["path",{d:"M3 5v12a2 2 0 0 0 2 2h3",key:"x1gjn2"}]]),$a=ae("pen-line",[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]),Aa=ae("square-play",[["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["path",{d:"M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z",key:"kmsa83"}]]),pt=ae("view",[["path",{d:"M21 17v2a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-2",key:"mrq65r"}],["path",{d:"M21 7V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2",key:"be3xqs"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M18.944 12.33a1 1 0 0 0 0-.66 7.5 7.5 0 0 0-13.888 0 1 1 0 0 0 0 .66 7.5 7.5 0 0 0 13.888 0",key:"11ak4c"}]]),z=Me(Ot(),1),Ea=te(),a=Me(Bt(),1);const ft=t=>{let e=(0,Ea.c)(17),{filename:s,filenameIcon:r,onBack:i,onRefresh:n,onDownload:l,actions:c}=t,p;e[0]===i?p=e[1]:(p=i&&(0,a.jsx)(A,{content:"Back to file list",children:(0,a.jsx)($,{variant:"text",size:"xs",onClick:i,children:(0,a.jsx)(He,{className:"h-4 w-4"})})}),e[0]=i,e[1]=p);let o;e[2]!==s||e[3]!==r?(o=s?(0,a.jsxs)("span",{className:"flex items-center gap-1.5 flex-1 min-w-0 text-xs font-semibold truncate",children:[r,s]}):(0,a.jsx)("span",{className:"flex-1"}),e[2]=s,e[3]=r,e[4]=o):o=e[4];let x;e[5]===n?x=e[6]:(x=n&&(0,a.jsx)(A,{content:"Refresh",children:(0,a.jsx)($,{variant:"text",size:"xs",onClick:n,children:(0,a.jsx)(Xe,{className:"h-3.5 w-3.5"})})}),e[5]=n,e[6]=x);let f;e[7]===l?f=e[8]:(f=l&&(0,a.jsx)(A,{content:"Download",children:(0,a.jsx)($,{variant:"text",size:"xs",onClick:l,children:(0,a.jsx)(Ne,{className:"h-3.5 w-3.5"})})}),e[7]=l,e[8]=f);let j;e[9]!==c||e[10]!==x||e[11]!==f?(j=(0,a.jsxs)("div",{className:"flex items-center gap-0.5 shrink-0",children:[x,c,f]}),e[9]=c,e[10]=x,e[11]=f,e[12]=j):j=e[12];let u;return e[13]!==p||e[14]!==o||e[15]!==j?(u=(0,a.jsxs)("div",{className:"flex items-center shrink-0 border-b px-1 gap-1",children:[p,o,j]}),e[13]=p,e[14]=o,e[15]=j,e[16]=u):u=e[16],u};var Ia=100*1024*1024;function La(t){let e=t.endsWith("/")?t.slice(0,-1):t,s=e.split("/");return s[s.length-1]||e}const Ta=({entry:t,namespace:e,onBack:s})=>{let{locale:r}=et(),i=La(t.path),n=t.mimeType||"text/plain",l=pe(n),c=l&&t.size>Ia&&t.size>0,{data:p,isPending:o,error:x,refetch:f}=Se(async()=>{if(c)return null;let g=await ye.request({namespace:e,path:t.path,preview:!l});if(g.error)throw Error(g.error);if(!g.url)throw Error("No URL returned");if(l)return{type:"media",url:g.url};let d=await fetch(g.url);if(!d.ok)throw Error(`Failed to fetch preview: ${d.statusText}`);return{type:"text",content:await d.text()}},[e,t.path,l,c]),j=(0,z.useCallback)(async()=>{try{let g=await ye.request({namespace:e,path:t.path});if(g.error){E({title:"Download failed",description:g.error,variant:"danger"});return}g.url&&ve(g.url,g.filename??i)}catch(g){ge.error("Failed to download storage entry",g),E({title:"Download failed",description:String(g),variant:"danger"})}},[e,t.path,i]),u=(0,a.jsx)(ft,{filename:i,filenameIcon:Ye(i),onBack:s,onDownload:j}),h=({includeMime:g=!1})=>(0,a.jsxs)("div",{className:"grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 p-4 text-xs",children:[(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"Path"}),(0,a.jsxs)("div",{className:"truncate flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"font-mono text-[11px]",children:t.path}),(0,a.jsx)(fa,{value:t.path,className:"h-3 w-3"})]}),g&&(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"Type"}),g&&(0,a.jsx)("span",{children:n}),t.size>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"Size"}),(0,a.jsx)("span",{children:Pe(t.size,r)})]}),t.lastModified!=null&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"Modified"}),(0,a.jsx)("span",{children:new Date(t.lastModified*1e3).toLocaleString()})]})]});return c?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[u,h({includeMime:!0}),(0,a.jsxs)("div",{className:"px-4 pb-4 text-xs text-muted-foreground italic",children:["File is too large to preview (",Pe(t.size,r),")."]})]}):o?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[u,h({}),(0,a.jsxs)("div",{className:"flex-1 flex items-center justify-center gap-2 text-xs text-muted-foreground min-h-24",children:[(0,a.jsx)(ke,{className:"h-4 w-4 animate-spin"}),"Loading preview..."]})]}):x?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[u,h({includeMime:!0}),(0,a.jsxs)("div",{className:"px-4 pb-4 text-xs text-destructive",children:["Failed to load preview: ",x.message]}),(0,a.jsx)("div",{className:"px-4 pb-4",children:(0,a.jsxs)($,{variant:"secondary",size:"xs",onClick:f,children:[(0,a.jsx)(Xe,{className:"h-3 w-3 mr-1"}),"Retry"]})})]}):p?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[u,h({}),(0,a.jsx)(Te,{mimeType:n,contents:p.type==="text"?p.content:void 0,mediaSource:p.type==="media"?{url:p.url}:void 0})]}):(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[u,h({includeMime:!0}),(0,a.jsxs)("div",{className:"p-4 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,a.jsx)(Je,{className:"h-4 w-4"}),"Preview not available for this file type."]})]})};var De=te(),Ba=16;function H(t){return{paddingLeft:t*Ba}}function Va(t,e){return new Date(t*1e3).toLocaleDateString(e,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function xt(t){let e=t.endsWith("/")?t.slice(0,-1):t,s=e.split("/");return s[s.length-1]||e}function ze(t,e,s,r){let i=s.toLowerCase();if(xt(t.path).toLowerCase().includes(i))return!0;if(t.kind==="directory"){let n=r.get(Be(e,t.path));if(n)return n.some(l=>ze(l,e,s,r))}return!1}function ut(t,e,s,r){return s.trim()?t.filter(i=>ze(i,e,s,r)):t}var Ha=t=>{let e=(0,De.c)(34),{namespace:s,protocol:r,rootPath:i,prefix:n,depth:l,locale:c,searchValue:p,onOpenFile:o}=t,{entriesByPath:x}=fe(),{entries:f,isPending:j,error:u}=Ve(s,n);if(j){let d;e[0]===l?d=e[1]:(d=H(l),e[0]=l,e[1]=d);let y;e[2]===Symbol.for("react.memo_cache_sentinel")?(y=(0,a.jsx)(ke,{className:"h-3 w-3 animate-spin"}),e[2]=y):y=e[2];let k;return e[3]===d?k=e[4]:(k=(0,a.jsxs)("div",{className:"flex items-center gap-1.5 py-1 text-xs text-muted-foreground",style:d,children:[y,"Loading..."]}),e[3]=d,e[4]=k),k}if(u){let d;e[5]===l?d=e[6]:(d=H(l),e[5]=l,e[6]=d);let y;return e[7]!==u.message||e[8]!==d?(y=(0,a.jsxs)("div",{className:"py-1 text-xs text-destructive",style:d,children:["Failed to load: ",u.message]}),e[7]=u.message,e[8]=d,e[9]=y):y=e[9],y}if(f.length===0){let d;e[10]===l?d=e[11]:(d=H(l),e[10]=l,e[11]=d);let y;return e[12]===d?y=e[13]:(y=(0,a.jsx)("div",{className:"py-1 text-xs text-muted-foreground italic",style:d,children:"Empty"}),e[12]=d,e[13]=y),y}let h;if(e[14]!==f||e[15]!==l||e[16]!==x||e[17]!==c||e[18]!==s||e[19]!==o||e[20]!==r||e[21]!==i||e[22]!==p){let d=ut(f,s,p,x),y;e[24]!==l||e[25]!==c||e[26]!==s||e[27]!==o||e[28]!==r||e[29]!==i||e[30]!==p?(y=k=>(0,a.jsx)(gt,{entry:k,namespace:s,protocol:r,rootPath:i,depth:l,locale:c,searchValue:p,onOpenFile:o},k.path),e[24]=l,e[25]=c,e[26]=s,e[27]=o,e[28]=r,e[29]=i,e[30]=p,e[31]=y):y=e[31],h=d.map(y),e[14]=f,e[15]=l,e[16]=x,e[17]=c,e[18]=s,e[19]=o,e[20]=r,e[21]=i,e[22]=p,e[23]=h}else h=e[23];let g;return e[32]===h?g=e[33]:(g=(0,a.jsx)(a.Fragment,{children:h}),e[32]=h,e[33]=g),g},gt=({entry:t,namespace:e,protocol:s,rootPath:r,depth:i,locale:n,searchValue:l,onOpenFile:c})=>{var k;let[p,o]=(0,z.useState)(!1),{entriesByPath:x}=fe(),f=t.kind==="directory",j=xt(t.path),u=!!l.trim(),h=f&&u&&j.toLowerCase().includes(l.trim().toLowerCase()),g=f&&u&&!!((k=x.get(Be(e,t.path)))!=null&&k.some(v=>ze(v,e,l,x))),d=p||g,y=(0,z.useCallback)(async()=>{try{let v=await ye.request({namespace:e,path:t.path});if(v.error){E({title:"Download failed",description:v.error,variant:"danger"});return}v.url&&ve(v.url,v.filename??"download")}catch(v){ge.error("Failed to download storage entry",v),E({title:"Download failed",description:String(v),variant:"danger"})}},[e,t.path]);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(st,{className:q("text-xs flex items-center gap-1.5 cursor-pointer rounded-none group h-6.5",f&&"font-medium"),style:H(i),value:`${e}:${t.path}`,onSelect:()=>{f?o(!d):c({entry:t,namespace:e})},children:[f?(0,a.jsx)(_e,{isExpanded:d,className:"h-3 w-3"}):(0,a.jsx)("span",{className:"w-3 shrink-0"}),f?(0,a.jsx)(ta,{className:q("h-3.5 w-3.5 shrink-0",Ze.directory)}):Ye(j),(0,a.jsx)("span",{className:"truncate flex-1 text-left",children:j}),(0,a.jsxs)("div",{className:"flex items-center",children:[t.size>0&&(0,a.jsx)("span",{className:"text-[10px] text-muted-foreground pr-2 opacity-0 group-hover:opacity-100 transition-opacity tabular-nums",children:Pe(t.size,n)}),t.lastModified!=null&&(0,a.jsx)(A,{content:`Last modified: ${new Date(t.lastModified*1e3).toLocaleString()}`,children:(0,a.jsx)("span",{className:"text-[10px] text-muted-foreground pr-1 opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap",children:Va(t.lastModified,n)})}),(0,a.jsxs)(Ke,{children:[(0,a.jsx)(qe,{asChild:!0,children:(0,a.jsx)(rt,{iconClassName:"h-3 w-3",onClick:v=>v.stopPropagation()})}),(0,a.jsxs)(We,{align:"end",onClick:v=>v.stopPropagation(),onCloseAutoFocus:v=>v.preventDefault(),children:[!f&&(0,a.jsxs)(M,{onSelect:()=>c({entry:t,namespace:e}),children:[(0,a.jsx)(pt,{className:"h-3.5 w-3.5 mr-2"}),"View"]}),(0,a.jsxs)(M,{onSelect:async()=>{await re(Wt(s,r,t.path).toString()),E({title:"Copied to clipboard"})},children:[(0,a.jsx)(we,{className:nt}),"Copy URL"]}),!f&&(0,a.jsxs)(M,{onSelect:()=>y(),children:[(0,a.jsx)(Ne,{className:"h-3.5 w-3.5 mr-2"}),"Download"]})]})]})]})]}),f&&d&&(0,a.jsx)(Ha,{namespace:e,protocol:s,rootPath:r,prefix:t.path,depth:i+1,locale:n,searchValue:h?"":l,onOpenFile:c})]})},Ua=t=>{let e=(0,De.c)(42),{namespace:s,locale:r,searchValue:i,onOpenFile:n}=t,[l,c]=(0,z.useState)(!0),{entriesByPath:p}=fe(),{clearNamespaceCache:o}=Kt(),x=s.name??s.displayName,{entries:f,isPending:j,error:u,refetch:h}=Ve(x),g;e[0]!==o||e[1]!==x||e[2]!==h?(g=v=>{v.stopPropagation(),o(x),h()},e[0]=o,e[1]=x,e[2]=h,e[3]=g):g=e[3];let d=g,y=j?s.storageEntries:f,k;if(e[4]!==y||e[5]!==p||e[6]!==u||e[7]!==d||e[8]!==l||e[9]!==j||e[10]!==r||e[11]!==s.displayName||e[12]!==s.name||e[13]!==s.protocol||e[14]!==s.rootPath||e[15]!==x||e[16]!==n||e[17]!==i){let v=ut(y,x,i,p),b;e[19]===l?b=e[20]:(b=()=>c(!l),e[19]=l,e[20]=b);let w;e[21]===l?w=e[22]:(w=(0,a.jsx)(_e,{isExpanded:l,className:"h-3 w-3"}),e[21]=l,e[22]=w);let m;e[23]===s.protocol?m=e[24]:(m=(0,a.jsx)(Et,{protocol:s.protocol}),e[23]=s.protocol,e[24]=m);let N;e[25]===s.displayName?N=e[26]:(N=(0,a.jsx)("span",{children:s.displayName}),e[25]=s.displayName,e[26]=N);let _;e[27]===s.name?_=e[28]:(_=s.name&&(0,a.jsxs)("span",{className:"text-xs text-muted-foreground font-normal",children:["(",(0,a.jsx)(Da,{variableName:s.name}),")"]}),e[27]=s.name,e[28]=_);let C;e[29]===d?C=e[30]:(C=(0,a.jsx)(it,{onClick:d,tooltip:"Refresh storage connection",className:"p-0",iconClassName:"h-3 w-3"}),e[29]=d,e[30]=C);let P=s.rootPath||"(root)",S;e[31]===P?S=e[32]:(S=(0,a.jsx)("span",{className:"text-[10px] text-muted-foreground font-normal tabular-nums ml-auto",children:P}),e[31]=P,e[32]=S);let D;e[33]!==s.name||e[34]!==S||e[35]!==b||e[36]!==w||e[37]!==m||e[38]!==N||e[39]!==_||e[40]!==C?(D=(0,a.jsxs)(st,{value:s.name,onSelect:b,className:"flex flex-row font-semibold h-7 text-xs gap-1.5 bg-(--slate-2) text-muted-foreground rounded-none",children:[w,m,N,_,C,S]}),e[33]=s.name,e[34]=S,e[35]=b,e[36]=w,e[37]=m,e[38]=N,e[39]=_,e[40]=C,e[41]=D):D=e[41],k=(0,a.jsxs)(a.Fragment,{children:[D,l&&(0,a.jsxs)(a.Fragment,{children:[j&&y.length===0&&(0,a.jsxs)("div",{className:"flex items-center gap-1.5 py-1 text-xs text-muted-foreground",style:H(1),children:[(0,a.jsx)(ke,{className:"h-3 w-3 animate-spin"}),"Loading..."]}),u&&y.length===0&&(0,a.jsx)(_a,{error:u,style:H(1),className:"py-1 text-xs h-auto",showIcon:!1}),!j&&y.length===0&&!u&&(0,a.jsx)("div",{className:"py-1 text-xs text-muted-foreground italic",style:H(1),children:"No entries"}),i&&v.length===0&&y.length>0&&(0,a.jsx)("div",{className:"py-1 text-xs text-muted-foreground italic",style:H(1),children:"No matches"}),v.map(L=>(0,a.jsx)(gt,{entry:L,namespace:x,protocol:s.protocol,rootPath:s.rootPath,depth:1,locale:r,searchValue:i,onOpenFile:n},L.path))]})]}),e[4]=y,e[5]=p,e[6]=u,e[7]=d,e[8]=l,e[9]=j,e[10]=r,e[11]=s.displayName,e[12]=s.name,e[13]=s.protocol,e[14]=s.rootPath,e[15]=x,e[16]=n,e[17]=i,e[18]=k}else k=e[18];return k};const qa=()=>{let t=(0,De.c)(31),{namespaces:e}=fe(),{locale:s}=et(),[r,i]=(0,z.useState)(""),[n,l]=(0,z.useState)(null),c=!!r.trim();if(e.length===0){let b;t[0]===Symbol.for("react.memo_cache_sentinel")?(b=(0,a.jsxs)("span",{children:["Create an Obstore or fsspec connection in your notebook. See the"," ",(0,a.jsx)("a",{className:"text-link",href:"https://docs.marimo.io/guides/working_with_data/remote_storage/#quick-start",target:"_blank",rel:"noopener noreferrer",children:"docs"}),"."]}),t[0]=b):b=t[0];let w;return t[1]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsx)(Pa,{title:"No storage connected",description:b,action:(0,a.jsx)(Ie,{defaultTab:"storage",children:(0,a.jsxs)($,{variant:"outline",size:"sm",children:["Add remote storage",(0,a.jsx)(Qe,{className:"h-4 w-4 ml-2"})]})}),icon:(0,a.jsx)(Ee,{className:"h-8 w-8"})}),t[1]=w):w=t[1],w}let p;t[2]===n?p=t[3]:(p=n&&(0,a.jsx)(Ta,{entry:n.entry,namespace:n.namespace,onBack:()=>l(null)}),t[2]=n,t[3]=p);let o=n&&"hidden",x;t[4]===o?x=t[5]:(x=q("border-b bg-background rounded-none h-full pb-10 overflow-auto outline-hidden scrollbar-thin",o),t[4]=o,t[5]=x);let f;t[6]===r?f=t[7]:(f=(0,a.jsx)(wa,{placeholder:"Search entries...",className:"h-6 m-1",value:r,onValueChange:i,rootClassName:"flex-1 border-b-0"}),t[6]=r,t[7]=f);let j;t[8]===c?j=t[9]:(j=c&&(0,a.jsx)($,{variant:"text",size:"xs",className:"float-right border-none px-2 m-0 h-full",onClick:()=>i(""),children:(0,a.jsx)(Gt,{className:"h-4 w-4"})}),t[8]=c,t[9]=j);let u;t[10]===Symbol.for("react.memo_cache_sentinel")?(u=(0,a.jsx)(A,{content:"Filters loaded entries only. Expand directories to include their contents in the search.",delayDuration:200,children:(0,a.jsx)(Xt,{className:"h-3.5 w-3.5 shrink-0 cursor-help text-muted-foreground hover:text-foreground mr-2"})}),t[10]=u):u=t[10];let h;t[11]===Symbol.for("react.memo_cache_sentinel")?(h=(0,a.jsx)(Ie,{defaultTab:"storage",children:(0,a.jsx)($,{variant:"ghost",size:"sm",className:"px-2 border-0 border-l border-muted-background rounded-none focus-visible:ring-0 focus-visible:ring-offset-0",children:(0,a.jsx)(Qe,{className:"h-4 w-4"})})}),t[11]=h):h=t[11];let g;t[12]!==f||t[13]!==j?(g=(0,a.jsxs)("div",{className:"flex items-center w-full border-b",children:[f,j,u,h]}),t[12]=f,t[13]=j,t[14]=g):g=t[14];let d;if(t[15]!==s||t[16]!==e||t[17]!==r){let b;t[19]!==s||t[20]!==r?(b=w=>(0,a.jsx)(Ua,{namespace:w,locale:s,searchValue:r,onOpenFile:l},w.name??w.displayName),t[19]=s,t[20]=r,t[21]=b):b=t[21],d=e.map(b),t[15]=s,t[16]=e,t[17]=r,t[18]=d}else d=t[18];let y;t[22]===d?y=t[23]:(y=(0,a.jsx)(ka,{className:"flex flex-col",children:d}),t[22]=d,t[23]=y);let k;t[24]!==x||t[25]!==g||t[26]!==y?(k=(0,a.jsxs)(Na,{className:x,shouldFilter:!1,children:[g,y]}),t[24]=x,t[25]=g,t[26]=y,t[27]=k):k=t[27];let v;return t[28]!==p||t[29]!==k?(v=(0,a.jsxs)("div",{className:"h-full flex flex-col",children:[p,k]}),t[28]=p,t[29]=k,t[30]=v):v=t[30],v};var jt=te(),yt=(0,z.createContext)(null);function Wa(){return(0,z.useContext)(yt)??void 0}var Ka=t=>{let e=(0,jt.c)(3),{children:s}=t,r=ga(),i;return e[0]!==s||e[1]!==r?(i=(0,a.jsx)(yt.Provider,{value:r,children:s}),e[0]=s,e[1]=r,e[2]=i):i=e[2],i};const Ya=t=>{let e=(0,jt.c)(5),{children:s}=t,[r,i]=(0,z.useState)(null),n;e[0]!==s||e[1]!==r?(n=r&&(0,a.jsx)(ua,{backend:ja,options:{rootElement:r},children:(0,a.jsx)(Ka,{children:s})}),e[0]=s,e[1]=r,e[2]=n):n=e[2];let l;return e[3]===n?l=e[4]:(l=(0,a.jsx)("div",{ref:i,className:"contents",children:n}),e[3]=n,e[4]=l),l};var Oe=new Map;const Za=({file:t,onOpenNotebook:e})=>{let{sendFileDetails:s,sendUpdateFile:r}=je(),i=se(Tt),n=se(Le),l=se($t),[c,p]=(0,z.useState)(""),{data:o,isPending:x,error:f,setData:j,refetch:u}=Se(async()=>{let m=await s({path:t.path}),N=m.contents||"";return p(Oe.get(t.path)||N),m},[t.path]),h=async()=>{c!==(o==null?void 0:o.contents)&&await r({path:t.path,contents:c}).then(m=>{m.success&&(j(N=>({...N,contents:c})),p(c))})},g=(0,z.useRef)(c);if(g.current=c,(0,z.useEffect)(()=>()=>{if(!(o!=null&&o.contents))return;let m=g.current;m===o.contents?Oe.delete(t.path):Oe.set(t.path,m)},[t.path,o==null?void 0:o.contents]),f)return(0,a.jsx)(at,{error:f});if(x||!o)return null;let d=o.mimeType||"text/plain",y=d in Ut,k=l&&o.file.isMarimoFile&&(t.path===l||t.path.endsWith(`/${l}`));if(!o.contents&&!y)return(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-2 p-6",children:[(0,a.jsx)("div",{className:"font-bold text-muted-foreground",children:"Name"}),(0,a.jsx)("div",{children:o.file.name}),(0,a.jsx)("div",{className:"font-bold text-muted-foreground",children:"Type"}),(0,a.jsx)("div",{children:d})]});let v=(0,a.jsx)(ft,{filename:o.file.name,onRefresh:u,onDownload:n?void 0:()=>{if(pe(d)){ve(Qt(o.contents,d),o.file.name);return}Ue(new Blob([o.contents||c],{type:d}),o.file.name)},actions:(0,a.jsxs)(a.Fragment,{children:[t.isMarimoFile&&!me()&&(0,a.jsx)(A,{content:"Open notebook",children:(0,a.jsx)($,{variant:"text",size:"xs",onClick:m=>e(m),children:(0,a.jsx)(be,{className:"h-3.5 w-3.5"})})}),!pe(d)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(A,{content:"Copy contents to clipboard",children:(0,a.jsx)($,{variant:"text",size:"xs",onClick:async()=>{await re(c)},children:(0,a.jsx)(we,{className:"h-3.5 w-3.5"})})}),(0,a.jsx)(A,{content:Ca("global.save"),children:(0,a.jsx)($,{variant:"text",size:"xs",onClick:h,disabled:c===o.contents,children:(0,a.jsx)(ra,{className:"h-3.5 w-3.5"})})})]})]})}),b=pe(d),w=!b&&d!=="text/csv";return(0,a.jsxs)(a.Fragment,{children:[v,w&&k&&(0,a.jsxs)(ba,{variant:"warning",className:"rounded-none",children:[(0,a.jsx)(la,{className:"h-4 w-4"}),(0,a.jsx)(va,{children:"Editing the notebook file directly while running in marimo's editor may cause unintended changes. Please use with caution."})]}),(0,a.jsx)(Te,{mimeType:d,contents:b?void 0:w?c:o.contents??void 0,mediaSource:b?{base64:o.contents,mime:d}:void 0,readOnly:!w,onChange:p,extensions:[Ht.of([{key:i.getHotkey("global.save").key,stopPropagation:!0,run:()=>c===o.contents?!1:(h(),!0)}])]})]})};var Ga=class{constructor(t){B(this,"delegate",new Ce([]));B(this,"rootPath","");B(this,"onChange",It.NOOP);B(this,"path",new Fe("/"));B(this,"initialize",async t=>{if(this.onChange=t,this.delegate.data.length===0)try{let e=await this.callbacks.listFiles({path:this.rootPath});this.delegate=new Ce(e.files),this.rootPath=e.root,this.path=Fe.guessDeliminator(e.root)}catch(e){E({title:"Failed",description:ma(e)})}this.onChange(this.delegate.data)});B(this,"refreshAll",async t=>{let e=[this.rootPath,...t.map(r=>{var i;return(i=this.delegate.find(r))==null?void 0:i.data.path})].filter(Boolean),s=await Promise.all(e.map(r=>this.callbacks.listFiles({path:r}).catch(()=>({files:[]}))));for(let[r,i]of e.entries()){let n=s[r];i===this.rootPath?this.delegate=new Ce(n.files):this.delegate.update({id:i,changes:{children:n.files}})}this.onChange(this.delegate.data)});B(this,"relativeFromRoot",t=>{let e=this.rootPath.endsWith(this.path.deliminator)?this.rootPath:`${this.rootPath}${this.path.deliminator}`;return t.startsWith(e)?t.slice(e.length):t});B(this,"handleResponse",t=>t.success?t:(E({title:"Failed",description:t.message}),null));this.callbacks=t}async expand(t){let e=this.delegate.find(t);if(!e||!e.data.isDirectory)return!1;if(e.children&&e.children.length>0)return!0;let s=await this.callbacks.listFiles({path:e.data.path});return this.delegate.update({id:t,changes:{children:s.files}}),this.onChange(this.delegate.data),!0}async rename(t,e){let s=this.delegate.find(t);if(!s)return;let r=s.data.path,i=this.path.join(this.path.dirname(r),e);await this.callbacks.renameFileOrFolder({path:r,newPath:i}).then(this.handleResponse),this.delegate.update({id:t,changes:{name:e,path:i}}),this.onChange(this.delegate.data),await this.refreshAll([i])}async move(t,e){var r;let s=e?((r=this.delegate.find(e))==null?void 0:r.data.path)??e:this.rootPath;await Promise.all(t.map(i=>{this.delegate.move({id:i,parentId:e,index:0});let n=this.delegate.find(i);if(!n)return Promise.resolve();let l=this.path.join(s,this.path.basename(n.data.path));return this.delegate.update({id:i,changes:{path:l}}),this.callbacks.renameFileOrFolder({path:n.data.path,newPath:l}).then(this.handleResponse)})),this.onChange(this.delegate.data),await this.refreshAll([s])}async createFile(t,e,s="file"){var n;let r=e?((n=this.delegate.find(e))==null?void 0:n.data.path)??e:this.rootPath,i=await this.callbacks.createFileOrFolder({path:r,type:s,name:t}).then(this.handleResponse);i!=null&&i.info&&(this.delegate.create({parentId:e,index:0,data:i.info}),this.onChange(this.delegate.data),await this.refreshAll([r]))}async createFolder(t,e){var i;let s=e?((i=this.delegate.find(e))==null?void 0:i.data.path)??e:this.rootPath,r=await this.callbacks.createFileOrFolder({path:s,type:"directory",name:t}).then(this.handleResponse);r!=null&&r.info&&(this.delegate.create({parentId:e,index:0,data:r.info}),this.onChange(this.delegate.data),await this.refreshAll([s]))}async delete(t){let e=this.delegate.find(t);e&&(await this.callbacks.deleteFileOrFolder({path:e.data.path}).then(this.handleResponse),this.delegate.drop({id:t}),this.onChange(this.delegate.data))}};const vt=Re(t=>{let e=t(qt);return Lt(e,"no requestClientAtom set"),new Ga({listFiles:e.sendListFiles,createFileOrFolder:e.sendCreateFileOrFolder,deleteFileOrFolder:e.sendDeleteFileOrFolder,renameFileOrFolder:e.sendRenameFileOrFolder})}),Ja=Re({});async function Qa(){await zt.get(vt).refreshAll([])}var U=" ";const bt={directory:t=>`os.listdir("${t}")`,python:t=>`with open("${t}", "r") as _f:
1
+ var Pt=Object.defineProperty;var Dt=(t,e,s)=>e in t?Pt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var B=(t,e,s)=>Dt(t,typeof e!="symbol"?e+"":e,s);import{s as Me}from"./chunk-LvLJmgfZ.js";import{i as zt,l as he,n as T,p as Re,u as se}from"./useEvent-WUlsM6MC.js";import{t as Ot}from"./react-Bj1aDYRI.js";import{En as Mt,T as Rt,kn as $e,si as $t,ui as Ae,ur as At}from"./cells-BLS3X4Af.js";import"./react-dom-CSu739Rf.js";import{t as te}from"./compiler-runtime-B3qBwwSJ.js";import"./tooltip-Mz5m-WBI.js";import{i as Ee,r as Et,t as Ie}from"./add-connection-dialog-CmJm_APe.js";import{h as It,m as ge}from"./useEventListener-CTPW4ELK.js";import{t as Lt}from"./invariant-awXiPaF0.js";import{p as Tt,u as Le}from"./utils-D6N4h71e.js";import{S as me}from"./config-CEhpfPsm.js";import{t as Bt}from"./jsx-runtime-CP2fAiZX.js";import{n as Vt,t as $}from"./button-B_BBklax.js";import{t as q}from"./cn-d_A4rA-x.js";import{St as Ht}from"./dist-Dr9qtoId.js";import{a as Ut,i as Te,o as pe}from"./JsonOutput-CHgq3R6J.js";import"./cjs-CVt8hZ5L.js";import"./main-Cmx6WhDY.js";import"./useNonce-BY4jV7Yb.js";import{n as qt,r as je}from"./requests-DZy_SQ_v.js";import{t as ae}from"./createLucideIcon-BvP5LBIs.js";import{a as Be,i as Ve,l as He,n as fe,o as Wt,r as Kt,s as ye,t as Yt}from"./state-BI4WmvIs.js";import{n as Zt}from"./LazyAnyLanguageCodeMirror-B11pcXh7.js";import{t as Gt}from"./x-yqLqiq5Q.js";import{c as Jt,i as ve,r as Ue}from"./download-dbepOsRi.js";import{f as be}from"./maps-BLIeOscV.js";import{n as Qt}from"./markdown-renderer-rEsmEgLk.js";import{u as Xt}from"./toDate-DDAiY7kz.js";import{a as M,c as ne,p as qe,r as We,t as Ke}from"./dropdown-menu-C8nocIkm.js";import{t as we}from"./copy-CAR4dOiD.js";import{t as Ne}from"./download-BG-iMGgV.js";import{t as ea}from"./eye-off-DgTL09j7.js";import{a as ta,i as Ye,n as Ze,r as aa,t as sa}from"./file-icons-DN9ij4Wl.js";import{t as Ge}from"./file-plus-corner-BRwJx0yp.js";import{t as Je}from"./file-DVwc11C3.js";import{n as ke,t as na}from"./spinner-Dt4SmUsI.js";import{t as Qe}from"./plus-C9B_qWUi.js";import{t as Xe}from"./refresh-cw-fLeDriQe.js";import{t as ra}from"./save-C91FTnFa.js";import{t as ia}from"./trash-2-CrA4LwJ2.js";import{t as la}from"./triangle-alert-CzmxsxFO.js";import{i as oa,n as ca,t as da}from"./es-DgeOOQmd.js";import"./dist-Jp_4M-Ei.js";import"./dist-Cf47zp7b.js";import"./dist-Bagw3W9X.js";import"./dist-t1vdhOX_.js";import"./dist-D3OoaVQX.js";import{t as E}from"./use-toast-Hc8CXlvz.js";import{t as Fe}from"./paths-D2lG83Oh.js";import"./session--x-9D3HE.js";import"./Combination-CvuTtFZA.js";import{t as A}from"./tooltip-CSN_sVIP.js";import"./purify.es-BBn8CPhf.js";import"./dates-DbMtViXe.js";import{o as ha}from"./alert-dialog-7IgjDQnl.js";import{t as et}from"./context-CRApIvpB.js";import"./popover-BoqMUhMK.js";import{n as tt}from"./ImperativeModal-CPUoA52T.js";import{r as ma}from"./errors-0IrrdfSG.js";import{n as pa}from"./blob-DgooIGjS.js";import"./vega-loader.browser-BJ9oKrvH.js";import"./defaultLocale-CuYNS33t.js";import"./defaultLocale-CGfP-Ye3.js";import{t as re}from"./copy-BxX1HhLi.js";import{t as fa}from"./copy-icon-C7DYKLrA.js";import{n as xa}from"./multi-map-DNuS4OLr.js";import{a as ua,i as ga,n as Ce,r as ja,t as ya}from"./tree-DFAMcRzN.js";import{n as va,t as ba}from"./alert-Bs8tbZo_.js";import{n as at}from"./error-banner-DC7kSyWN.js";import{n as Se}from"./useAsyncData-CI3ntihq.js";import{a as wa,o as st,t as Na,u as ka}from"./command-CQd7U1fL.js";import"./chunk-5FQGJX7Z-Cyze_Wbx.js";import"./katex-FSdXOW5Y.js";import"./html-to-image-Fz0aHtSN.js";import{o as Fa}from"./focus-YYacdzxP.js";import{a as Ca}from"./renderShortcut-D-zdqWZr.js";import{t as Sa}from"./bundle.esm-_LzfhNmX.js";import{a as _a,c as nt,d as _e,l as rt,u as it}from"./components-BnwE0U6X.js";import{t as Pa}from"./empty-state-DFr2pZOz.js";import{t as Pe}from"./formatting-B5u5A8vd.js";import{a as Da,i as za,n as lt,r as ot,t as ct}from"./components-8Q-wOvzt.js";import{n as dt,t as Oa}from"./marimo-icons-BmYE_Rrf.js";import{t as Ma}from"./links-DwLHiCvK.js";var Ra=ae("copy-minus",[["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),ht=ae("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),mt=ae("list-tree",[["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"M3 10a2 2 0 0 0 2 2h3",key:"1npucw"}],["path",{d:"M3 5v12a2 2 0 0 0 2 2h3",key:"x1gjn2"}]]),$a=ae("pen-line",[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]),Aa=ae("square-play",[["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["path",{d:"M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z",key:"kmsa83"}]]),pt=ae("view",[["path",{d:"M21 17v2a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-2",key:"mrq65r"}],["path",{d:"M21 7V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2",key:"be3xqs"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M18.944 12.33a1 1 0 0 0 0-.66 7.5 7.5 0 0 0-13.888 0 1 1 0 0 0 0 .66 7.5 7.5 0 0 0 13.888 0",key:"11ak4c"}]]),z=Me(Ot(),1),Ea=te(),a=Me(Bt(),1);const ft=t=>{let e=(0,Ea.c)(17),{filename:s,filenameIcon:r,onBack:i,onRefresh:n,onDownload:l,actions:c}=t,p;e[0]===i?p=e[1]:(p=i&&(0,a.jsx)(A,{content:"Back to file list",children:(0,a.jsx)($,{variant:"text",size:"xs",onClick:i,children:(0,a.jsx)(He,{className:"h-4 w-4"})})}),e[0]=i,e[1]=p);let o;e[2]!==s||e[3]!==r?(o=s?(0,a.jsxs)("span",{className:"flex items-center gap-1.5 flex-1 min-w-0 text-xs font-semibold truncate",children:[r,s]}):(0,a.jsx)("span",{className:"flex-1"}),e[2]=s,e[3]=r,e[4]=o):o=e[4];let x;e[5]===n?x=e[6]:(x=n&&(0,a.jsx)(A,{content:"Refresh",children:(0,a.jsx)($,{variant:"text",size:"xs",onClick:n,children:(0,a.jsx)(Xe,{className:"h-3.5 w-3.5"})})}),e[5]=n,e[6]=x);let f;e[7]===l?f=e[8]:(f=l&&(0,a.jsx)(A,{content:"Download",children:(0,a.jsx)($,{variant:"text",size:"xs",onClick:l,children:(0,a.jsx)(Ne,{className:"h-3.5 w-3.5"})})}),e[7]=l,e[8]=f);let j;e[9]!==c||e[10]!==x||e[11]!==f?(j=(0,a.jsxs)("div",{className:"flex items-center gap-0.5 shrink-0",children:[x,c,f]}),e[9]=c,e[10]=x,e[11]=f,e[12]=j):j=e[12];let u;return e[13]!==p||e[14]!==o||e[15]!==j?(u=(0,a.jsxs)("div",{className:"flex items-center shrink-0 border-b px-1 gap-1",children:[p,o,j]}),e[13]=p,e[14]=o,e[15]=j,e[16]=u):u=e[16],u};var Ia=100*1024*1024;function La(t){let e=t.endsWith("/")?t.slice(0,-1):t,s=e.split("/");return s[s.length-1]||e}const Ta=({entry:t,namespace:e,onBack:s})=>{let{locale:r}=et(),i=La(t.path),n=t.mimeType||"text/plain",l=pe(n),c=l&&t.size>Ia&&t.size>0,{data:p,isPending:o,error:x,refetch:f}=Se(async()=>{if(c)return null;let g=await ye.request({namespace:e,path:t.path,preview:!l});if(g.error)throw Error(g.error);if(!g.url)throw Error("No URL returned");if(l)return{type:"media",url:g.url};let d=await fetch(g.url);if(!d.ok)throw Error(`Failed to fetch preview: ${d.statusText}`);return{type:"text",content:await d.text()}},[e,t.path,l,c]),j=(0,z.useCallback)(async()=>{try{let g=await ye.request({namespace:e,path:t.path});if(g.error){E({title:"Download failed",description:g.error,variant:"danger"});return}g.url&&ve(g.url,g.filename??i)}catch(g){ge.error("Failed to download storage entry",g),E({title:"Download failed",description:String(g),variant:"danger"})}},[e,t.path,i]),u=(0,a.jsx)(ft,{filename:i,filenameIcon:Ye(i),onBack:s,onDownload:j}),h=({includeMime:g=!1})=>(0,a.jsxs)("div",{className:"grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 p-4 text-xs",children:[(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"Path"}),(0,a.jsxs)("div",{className:"truncate flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"font-mono text-[11px]",children:t.path}),(0,a.jsx)(fa,{value:t.path,className:"h-3 w-3"})]}),g&&(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"Type"}),g&&(0,a.jsx)("span",{children:n}),t.size>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"Size"}),(0,a.jsx)("span",{children:Pe(t.size,r)})]}),t.lastModified!=null&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"Modified"}),(0,a.jsx)("span",{children:new Date(t.lastModified*1e3).toLocaleString()})]})]});return c?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[u,h({includeMime:!0}),(0,a.jsxs)("div",{className:"px-4 pb-4 text-xs text-muted-foreground italic",children:["File is too large to preview (",Pe(t.size,r),")."]})]}):o?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[u,h({}),(0,a.jsxs)("div",{className:"flex-1 flex items-center justify-center gap-2 text-xs text-muted-foreground min-h-24",children:[(0,a.jsx)(ke,{className:"h-4 w-4 animate-spin"}),"Loading preview..."]})]}):x?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[u,h({includeMime:!0}),(0,a.jsxs)("div",{className:"px-4 pb-4 text-xs text-destructive",children:["Failed to load preview: ",x.message]}),(0,a.jsx)("div",{className:"px-4 pb-4",children:(0,a.jsxs)($,{variant:"secondary",size:"xs",onClick:f,children:[(0,a.jsx)(Xe,{className:"h-3 w-3 mr-1"}),"Retry"]})})]}):p?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[u,h({}),(0,a.jsx)(Te,{mimeType:n,contents:p.type==="text"?p.content:void 0,mediaSource:p.type==="media"?{url:p.url}:void 0})]}):(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[u,h({includeMime:!0}),(0,a.jsxs)("div",{className:"p-4 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,a.jsx)(Je,{className:"h-4 w-4"}),"Preview not available for this file type."]})]})};var De=te(),Ba=16;function H(t){return{paddingLeft:t*Ba}}function Va(t,e){return new Date(t*1e3).toLocaleDateString(e,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function xt(t){let e=t.endsWith("/")?t.slice(0,-1):t,s=e.split("/");return s[s.length-1]||e}function ze(t,e,s,r){let i=s.toLowerCase();if(xt(t.path).toLowerCase().includes(i))return!0;if(t.kind==="directory"){let n=r.get(Be(e,t.path));if(n)return n.some(l=>ze(l,e,s,r))}return!1}function ut(t,e,s,r){return s.trim()?t.filter(i=>ze(i,e,s,r)):t}var Ha=t=>{let e=(0,De.c)(34),{namespace:s,protocol:r,rootPath:i,prefix:n,depth:l,locale:c,searchValue:p,onOpenFile:o}=t,{entriesByPath:x}=fe(),{entries:f,isPending:j,error:u}=Ve(s,n);if(j){let d;e[0]===l?d=e[1]:(d=H(l),e[0]=l,e[1]=d);let y;e[2]===Symbol.for("react.memo_cache_sentinel")?(y=(0,a.jsx)(ke,{className:"h-3 w-3 animate-spin"}),e[2]=y):y=e[2];let k;return e[3]===d?k=e[4]:(k=(0,a.jsxs)("div",{className:"flex items-center gap-1.5 py-1 text-xs text-muted-foreground",style:d,children:[y,"Loading..."]}),e[3]=d,e[4]=k),k}if(u){let d;e[5]===l?d=e[6]:(d=H(l),e[5]=l,e[6]=d);let y;return e[7]!==u.message||e[8]!==d?(y=(0,a.jsxs)("div",{className:"py-1 text-xs text-destructive",style:d,children:["Failed to load: ",u.message]}),e[7]=u.message,e[8]=d,e[9]=y):y=e[9],y}if(f.length===0){let d;e[10]===l?d=e[11]:(d=H(l),e[10]=l,e[11]=d);let y;return e[12]===d?y=e[13]:(y=(0,a.jsx)("div",{className:"py-1 text-xs text-muted-foreground italic",style:d,children:"Empty"}),e[12]=d,e[13]=y),y}let h;if(e[14]!==f||e[15]!==l||e[16]!==x||e[17]!==c||e[18]!==s||e[19]!==o||e[20]!==r||e[21]!==i||e[22]!==p){let d=ut(f,s,p,x),y;e[24]!==l||e[25]!==c||e[26]!==s||e[27]!==o||e[28]!==r||e[29]!==i||e[30]!==p?(y=k=>(0,a.jsx)(gt,{entry:k,namespace:s,protocol:r,rootPath:i,depth:l,locale:c,searchValue:p,onOpenFile:o},k.path),e[24]=l,e[25]=c,e[26]=s,e[27]=o,e[28]=r,e[29]=i,e[30]=p,e[31]=y):y=e[31],h=d.map(y),e[14]=f,e[15]=l,e[16]=x,e[17]=c,e[18]=s,e[19]=o,e[20]=r,e[21]=i,e[22]=p,e[23]=h}else h=e[23];let g;return e[32]===h?g=e[33]:(g=(0,a.jsx)(a.Fragment,{children:h}),e[32]=h,e[33]=g),g},gt=({entry:t,namespace:e,protocol:s,rootPath:r,depth:i,locale:n,searchValue:l,onOpenFile:c})=>{var k;let[p,o]=(0,z.useState)(!1),{entriesByPath:x}=fe(),f=t.kind==="directory",j=xt(t.path),u=!!l.trim(),h=f&&u&&j.toLowerCase().includes(l.trim().toLowerCase()),g=f&&u&&!!((k=x.get(Be(e,t.path)))!=null&&k.some(v=>ze(v,e,l,x))),d=p||g,y=(0,z.useCallback)(async()=>{try{let v=await ye.request({namespace:e,path:t.path});if(v.error){E({title:"Download failed",description:v.error,variant:"danger"});return}v.url&&ve(v.url,v.filename??"download")}catch(v){ge.error("Failed to download storage entry",v),E({title:"Download failed",description:String(v),variant:"danger"})}},[e,t.path]);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(st,{className:q("text-xs flex items-center gap-1.5 cursor-pointer rounded-none group h-6.5",f&&"font-medium"),style:H(i),value:`${e}:${t.path}`,onSelect:()=>{f?o(!d):c({entry:t,namespace:e})},children:[f?(0,a.jsx)(_e,{isExpanded:d,className:"h-3 w-3"}):(0,a.jsx)("span",{className:"w-3 shrink-0"}),f?(0,a.jsx)(ta,{className:q("h-3.5 w-3.5 shrink-0",Ze.directory)}):Ye(j),(0,a.jsx)("span",{className:"truncate flex-1 text-left",children:j}),(0,a.jsxs)("div",{className:"flex items-center",children:[t.size>0&&(0,a.jsx)("span",{className:"text-[10px] text-muted-foreground pr-2 opacity-0 group-hover:opacity-100 transition-opacity tabular-nums",children:Pe(t.size,n)}),t.lastModified!=null&&(0,a.jsx)(A,{content:`Last modified: ${new Date(t.lastModified*1e3).toLocaleString()}`,children:(0,a.jsx)("span",{className:"text-[10px] text-muted-foreground pr-1 opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap",children:Va(t.lastModified,n)})}),(0,a.jsxs)(Ke,{children:[(0,a.jsx)(qe,{asChild:!0,children:(0,a.jsx)(rt,{iconClassName:"h-3 w-3",onClick:v=>v.stopPropagation()})}),(0,a.jsxs)(We,{align:"end",onClick:v=>v.stopPropagation(),onCloseAutoFocus:v=>v.preventDefault(),children:[!f&&(0,a.jsxs)(M,{onSelect:()=>c({entry:t,namespace:e}),children:[(0,a.jsx)(pt,{className:"h-3.5 w-3.5 mr-2"}),"View"]}),(0,a.jsxs)(M,{onSelect:async()=>{await re(Wt(s,r,t.path).toString()),E({title:"Copied to clipboard"})},children:[(0,a.jsx)(we,{className:nt}),"Copy URL"]}),!f&&(0,a.jsxs)(M,{onSelect:()=>y(),children:[(0,a.jsx)(Ne,{className:"h-3.5 w-3.5 mr-2"}),"Download"]})]})]})]})]}),f&&d&&(0,a.jsx)(Ha,{namespace:e,protocol:s,rootPath:r,prefix:t.path,depth:i+1,locale:n,searchValue:h?"":l,onOpenFile:c})]})},Ua=t=>{let e=(0,De.c)(42),{namespace:s,locale:r,searchValue:i,onOpenFile:n}=t,[l,c]=(0,z.useState)(!0),{entriesByPath:p}=fe(),{clearNamespaceCache:o}=Kt(),x=s.name??s.displayName,{entries:f,isPending:j,error:u,refetch:h}=Ve(x),g;e[0]!==o||e[1]!==x||e[2]!==h?(g=v=>{v.stopPropagation(),o(x),h()},e[0]=o,e[1]=x,e[2]=h,e[3]=g):g=e[3];let d=g,y=j?s.storageEntries:f,k;if(e[4]!==y||e[5]!==p||e[6]!==u||e[7]!==d||e[8]!==l||e[9]!==j||e[10]!==r||e[11]!==s.displayName||e[12]!==s.name||e[13]!==s.protocol||e[14]!==s.rootPath||e[15]!==x||e[16]!==n||e[17]!==i){let v=ut(y,x,i,p),b;e[19]===l?b=e[20]:(b=()=>c(!l),e[19]=l,e[20]=b);let w;e[21]===l?w=e[22]:(w=(0,a.jsx)(_e,{isExpanded:l,className:"h-3 w-3"}),e[21]=l,e[22]=w);let m;e[23]===s.protocol?m=e[24]:(m=(0,a.jsx)(Et,{protocol:s.protocol}),e[23]=s.protocol,e[24]=m);let N;e[25]===s.displayName?N=e[26]:(N=(0,a.jsx)("span",{children:s.displayName}),e[25]=s.displayName,e[26]=N);let _;e[27]===s.name?_=e[28]:(_=s.name&&(0,a.jsxs)("span",{className:"text-xs text-muted-foreground font-normal",children:["(",(0,a.jsx)(Da,{variableName:s.name}),")"]}),e[27]=s.name,e[28]=_);let C;e[29]===d?C=e[30]:(C=(0,a.jsx)(it,{onClick:d,tooltip:"Refresh storage connection",className:"p-0",iconClassName:"h-3 w-3"}),e[29]=d,e[30]=C);let P=s.rootPath||"(root)",S;e[31]===P?S=e[32]:(S=(0,a.jsx)("span",{className:"text-[10px] text-muted-foreground font-normal tabular-nums ml-auto",children:P}),e[31]=P,e[32]=S);let D;e[33]!==s.name||e[34]!==S||e[35]!==b||e[36]!==w||e[37]!==m||e[38]!==N||e[39]!==_||e[40]!==C?(D=(0,a.jsxs)(st,{value:s.name,onSelect:b,className:"flex flex-row font-semibold h-7 text-xs gap-1.5 bg-(--slate-2) text-muted-foreground rounded-none",children:[w,m,N,_,C,S]}),e[33]=s.name,e[34]=S,e[35]=b,e[36]=w,e[37]=m,e[38]=N,e[39]=_,e[40]=C,e[41]=D):D=e[41],k=(0,a.jsxs)(a.Fragment,{children:[D,l&&(0,a.jsxs)(a.Fragment,{children:[j&&y.length===0&&(0,a.jsxs)("div",{className:"flex items-center gap-1.5 py-1 text-xs text-muted-foreground",style:H(1),children:[(0,a.jsx)(ke,{className:"h-3 w-3 animate-spin"}),"Loading..."]}),u&&y.length===0&&(0,a.jsx)(_a,{error:u,style:H(1),className:"py-1 text-xs h-auto",showIcon:!1}),!j&&y.length===0&&!u&&(0,a.jsx)("div",{className:"py-1 text-xs text-muted-foreground italic",style:H(1),children:"No entries"}),i&&v.length===0&&y.length>0&&(0,a.jsx)("div",{className:"py-1 text-xs text-muted-foreground italic",style:H(1),children:"No matches"}),v.map(L=>(0,a.jsx)(gt,{entry:L,namespace:x,protocol:s.protocol,rootPath:s.rootPath,depth:1,locale:r,searchValue:i,onOpenFile:n},L.path))]})]}),e[4]=y,e[5]=p,e[6]=u,e[7]=d,e[8]=l,e[9]=j,e[10]=r,e[11]=s.displayName,e[12]=s.name,e[13]=s.protocol,e[14]=s.rootPath,e[15]=x,e[16]=n,e[17]=i,e[18]=k}else k=e[18];return k};const qa=()=>{let t=(0,De.c)(31),{namespaces:e}=fe(),{locale:s}=et(),[r,i]=(0,z.useState)(""),[n,l]=(0,z.useState)(null),c=!!r.trim();if(e.length===0){let b;t[0]===Symbol.for("react.memo_cache_sentinel")?(b=(0,a.jsxs)("span",{children:["Create an Obstore or fsspec connection in your notebook. See the"," ",(0,a.jsx)("a",{className:"text-link",href:"https://docs.marimo.io/guides/working_with_data/remote_storage/#quick-start",target:"_blank",rel:"noopener noreferrer",children:"docs"}),"."]}),t[0]=b):b=t[0];let w;return t[1]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsx)(Pa,{title:"No storage connected",description:b,action:(0,a.jsx)(Ie,{defaultTab:"storage",children:(0,a.jsxs)($,{variant:"outline",size:"sm",children:["Add remote storage",(0,a.jsx)(Qe,{className:"h-4 w-4 ml-2"})]})}),icon:(0,a.jsx)(Ee,{className:"h-8 w-8"})}),t[1]=w):w=t[1],w}let p;t[2]===n?p=t[3]:(p=n&&(0,a.jsx)(Ta,{entry:n.entry,namespace:n.namespace,onBack:()=>l(null)}),t[2]=n,t[3]=p);let o=n&&"hidden",x;t[4]===o?x=t[5]:(x=q("border-b bg-background rounded-none h-full pb-10 overflow-auto outline-hidden scrollbar-thin",o),t[4]=o,t[5]=x);let f;t[6]===r?f=t[7]:(f=(0,a.jsx)(wa,{placeholder:"Search entries...",className:"h-6 m-1",value:r,onValueChange:i,rootClassName:"flex-1 border-b-0"}),t[6]=r,t[7]=f);let j;t[8]===c?j=t[9]:(j=c&&(0,a.jsx)($,{variant:"text",size:"xs",className:"float-right border-none px-2 m-0 h-full",onClick:()=>i(""),children:(0,a.jsx)(Gt,{className:"h-4 w-4"})}),t[8]=c,t[9]=j);let u;t[10]===Symbol.for("react.memo_cache_sentinel")?(u=(0,a.jsx)(A,{content:"Filters loaded entries only. Expand directories to include their contents in the search.",delayDuration:200,children:(0,a.jsx)(Xt,{className:"h-3.5 w-3.5 shrink-0 cursor-help text-muted-foreground hover:text-foreground mr-2"})}),t[10]=u):u=t[10];let h;t[11]===Symbol.for("react.memo_cache_sentinel")?(h=(0,a.jsx)(Ie,{defaultTab:"storage",children:(0,a.jsx)($,{variant:"ghost",size:"sm",className:"px-2 border-0 border-l border-muted-background rounded-none focus-visible:ring-0 focus-visible:ring-offset-0",children:(0,a.jsx)(Qe,{className:"h-4 w-4"})})}),t[11]=h):h=t[11];let g;t[12]!==f||t[13]!==j?(g=(0,a.jsxs)("div",{className:"flex items-center w-full border-b",children:[f,j,u,h]}),t[12]=f,t[13]=j,t[14]=g):g=t[14];let d;if(t[15]!==s||t[16]!==e||t[17]!==r){let b;t[19]!==s||t[20]!==r?(b=w=>(0,a.jsx)(Ua,{namespace:w,locale:s,searchValue:r,onOpenFile:l},w.name??w.displayName),t[19]=s,t[20]=r,t[21]=b):b=t[21],d=e.map(b),t[15]=s,t[16]=e,t[17]=r,t[18]=d}else d=t[18];let y;t[22]===d?y=t[23]:(y=(0,a.jsx)(ka,{className:"flex flex-col",children:d}),t[22]=d,t[23]=y);let k;t[24]!==x||t[25]!==g||t[26]!==y?(k=(0,a.jsxs)(Na,{className:x,shouldFilter:!1,children:[g,y]}),t[24]=x,t[25]=g,t[26]=y,t[27]=k):k=t[27];let v;return t[28]!==p||t[29]!==k?(v=(0,a.jsxs)("div",{className:"h-full flex flex-col",children:[p,k]}),t[28]=p,t[29]=k,t[30]=v):v=t[30],v};var jt=te(),yt=(0,z.createContext)(null);function Wa(){return(0,z.useContext)(yt)??void 0}var Ka=t=>{let e=(0,jt.c)(3),{children:s}=t,r=ga(),i;return e[0]!==s||e[1]!==r?(i=(0,a.jsx)(yt.Provider,{value:r,children:s}),e[0]=s,e[1]=r,e[2]=i):i=e[2],i};const Ya=t=>{let e=(0,jt.c)(5),{children:s}=t,[r,i]=(0,z.useState)(null),n;e[0]!==s||e[1]!==r?(n=r&&(0,a.jsx)(ua,{backend:ja,options:{rootElement:r},children:(0,a.jsx)(Ka,{children:s})}),e[0]=s,e[1]=r,e[2]=n):n=e[2];let l;return e[3]===n?l=e[4]:(l=(0,a.jsx)("div",{ref:i,className:"contents",children:n}),e[3]=n,e[4]=l),l};var Oe=new Map;const Za=({file:t,onOpenNotebook:e})=>{let{sendFileDetails:s,sendUpdateFile:r}=je(),i=se(Tt),n=se(Le),l=se($t),[c,p]=(0,z.useState)(""),{data:o,isPending:x,error:f,setData:j,refetch:u}=Se(async()=>{let m=await s({path:t.path}),N=m.contents||"";return p(Oe.get(t.path)||N),m},[t.path]),h=async()=>{c!==(o==null?void 0:o.contents)&&await r({path:t.path,contents:c}).then(m=>{m.success&&(j(N=>({...N,contents:c})),p(c))})},g=(0,z.useRef)(c);if(g.current=c,(0,z.useEffect)(()=>()=>{if(!(o!=null&&o.contents))return;let m=g.current;m===o.contents?Oe.delete(t.path):Oe.set(t.path,m)},[t.path,o==null?void 0:o.contents]),f)return(0,a.jsx)(at,{error:f});if(x||!o)return null;let d=o.mimeType||"text/plain",y=d in Ut,k=l&&o.file.isMarimoFile&&(t.path===l||t.path.endsWith(`/${l}`));if(!o.contents&&!y)return(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-2 p-6",children:[(0,a.jsx)("div",{className:"font-bold text-muted-foreground",children:"Name"}),(0,a.jsx)("div",{children:o.file.name}),(0,a.jsx)("div",{className:"font-bold text-muted-foreground",children:"Type"}),(0,a.jsx)("div",{children:d})]});let v=(0,a.jsx)(ft,{filename:o.file.name,onRefresh:u,onDownload:n?void 0:()=>{if(pe(d)){ve(Qt(o.contents,d),o.file.name);return}Ue(new Blob([o.contents||c],{type:d}),o.file.name)},actions:(0,a.jsxs)(a.Fragment,{children:[t.isMarimoFile&&!me()&&(0,a.jsx)(A,{content:"Open notebook",children:(0,a.jsx)($,{variant:"text",size:"xs",onClick:m=>e(m),children:(0,a.jsx)(be,{className:"h-3.5 w-3.5"})})}),!pe(d)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(A,{content:"Copy contents to clipboard",children:(0,a.jsx)($,{variant:"text",size:"xs",onClick:async()=>{await re(c)},children:(0,a.jsx)(we,{className:"h-3.5 w-3.5"})})}),(0,a.jsx)(A,{content:Ca("global.save"),children:(0,a.jsx)($,{variant:"text",size:"xs",onClick:h,disabled:c===o.contents,children:(0,a.jsx)(ra,{className:"h-3.5 w-3.5"})})})]})]})}),b=pe(d),w=!b&&d!=="text/csv";return(0,a.jsxs)(a.Fragment,{children:[v,w&&k&&(0,a.jsxs)(ba,{variant:"warning",className:"rounded-none",children:[(0,a.jsx)(la,{className:"h-4 w-4"}),(0,a.jsx)(va,{children:"Editing the notebook file directly while running in marimo's editor may cause unintended changes. Please use with caution."})]}),(0,a.jsx)(Te,{mimeType:d,contents:b?void 0:w?c:o.contents??void 0,mediaSource:b?{base64:o.contents,mime:d}:void 0,readOnly:!w,onChange:p,extensions:[Ht.of([{key:i.getHotkey("global.save").key,stopPropagation:!0,run:()=>c===o.contents?!1:(h(),!0)}])]})]})};var Ga=class{constructor(t){B(this,"delegate",new Ce([]));B(this,"rootPath","");B(this,"onChange",It.NOOP);B(this,"path",new Fe("/"));B(this,"initialize",async t=>{if(this.onChange=t,this.delegate.data.length===0)try{let e=await this.callbacks.listFiles({path:this.rootPath});this.delegate=new Ce(e.files),this.rootPath=e.root,this.path=Fe.guessDeliminator(e.root)}catch(e){E({title:"Failed",description:ma(e)})}this.onChange(this.delegate.data)});B(this,"refreshAll",async t=>{let e=[this.rootPath,...t.map(r=>{var i;return(i=this.delegate.find(r))==null?void 0:i.data.path})].filter(Boolean),s=await Promise.all(e.map(r=>this.callbacks.listFiles({path:r}).catch(()=>({files:[]}))));for(let[r,i]of e.entries()){let n=s[r];i===this.rootPath?this.delegate=new Ce(n.files):this.delegate.update({id:i,changes:{children:n.files}})}this.onChange(this.delegate.data)});B(this,"relativeFromRoot",t=>{let e=this.rootPath.endsWith(this.path.deliminator)?this.rootPath:`${this.rootPath}${this.path.deliminator}`;return t.startsWith(e)?t.slice(e.length):t});B(this,"handleResponse",t=>t.success?t:(E({title:"Failed",description:t.message}),null));this.callbacks=t}async expand(t){let e=this.delegate.find(t);if(!e||!e.data.isDirectory)return!1;if(e.children&&e.children.length>0)return!0;let s=await this.callbacks.listFiles({path:e.data.path});return this.delegate.update({id:t,changes:{children:s.files}}),this.onChange(this.delegate.data),!0}async rename(t,e){let s=this.delegate.find(t);if(!s)return;let r=s.data.path,i=this.path.join(this.path.dirname(r),e);await this.callbacks.renameFileOrFolder({path:r,newPath:i}).then(this.handleResponse),this.delegate.update({id:t,changes:{name:e,path:i}}),this.onChange(this.delegate.data),await this.refreshAll([i])}async move(t,e){var r;let s=e?((r=this.delegate.find(e))==null?void 0:r.data.path)??e:this.rootPath;await Promise.all(t.map(i=>{this.delegate.move({id:i,parentId:e,index:0});let n=this.delegate.find(i);if(!n)return Promise.resolve();let l=this.path.join(s,this.path.basename(n.data.path));return this.delegate.update({id:i,changes:{path:l}}),this.callbacks.renameFileOrFolder({path:n.data.path,newPath:l}).then(this.handleResponse)})),this.onChange(this.delegate.data),await this.refreshAll([s])}async createFile(t,e,s="file"){var n;let r=e?((n=this.delegate.find(e))==null?void 0:n.data.path)??e:this.rootPath,i=await this.callbacks.createFileOrFolder({path:r,type:s,name:t}).then(this.handleResponse);i!=null&&i.info&&(this.delegate.create({parentId:e,index:0,data:i.info}),this.onChange(this.delegate.data),await this.refreshAll([r]))}async createFolder(t,e){var i;let s=e?((i=this.delegate.find(e))==null?void 0:i.data.path)??e:this.rootPath,r=await this.callbacks.createFileOrFolder({path:s,type:"directory",name:t}).then(this.handleResponse);r!=null&&r.info&&(this.delegate.create({parentId:e,index:0,data:r.info}),this.onChange(this.delegate.data),await this.refreshAll([s]))}async delete(t){let e=this.delegate.find(t);e&&(await this.callbacks.deleteFileOrFolder({path:e.data.path}).then(this.handleResponse),this.delegate.drop({id:t}),this.onChange(this.delegate.data))}};const vt=Re(t=>{let e=t(qt);return Lt(e,"no requestClientAtom set"),new Ga({listFiles:e.sendListFiles,createFileOrFolder:e.sendCreateFileOrFolder,deleteFileOrFolder:e.sendDeleteFileOrFolder,renameFileOrFolder:e.sendRenameFileOrFolder})}),Ja=Re({});async function Qa(){await zt.get(vt).refreshAll([])}var U=" ";const bt={directory:t=>`os.listdir("${t}")`,python:t=>`with open("${t}", "r") as _f:
2
2
  ${U}...
3
3
  `,json:t=>`with open("${t}", "r") as _f:
4
4
  ${U}_data = json.load(_f)