@marimo-team/frontend 0.21.2-dev58 → 0.21.2-dev59
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.
- package/dist/assets/{edit-page-DKTQKmQY.js → edit-page-CxaQclsT.js} +2 -2
- package/dist/assets/file-explorer-panel-CrD6YkZ_.js +26 -0
- package/dist/assets/{index-DC6PpQWW.js → index-BrQynBQn.js} +2 -2
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/components/editor/file-tree/file-explorer.tsx +16 -2
- package/src/components/editor/file-tree/file-viewer.tsx +17 -3
- package/dist/assets/file-explorer-panel-PTcIZ1Da.js +0 -26
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var $t=Object.defineProperty;var Tt=(t,e,n)=>e in t?$t(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var L=(t,e,n)=>Tt(t,typeof e!="symbol"?e+"":e,n);import{s as Ae}from"./chunk-LvLJmgfZ.js";import{i as Rt,l as me,n as B,p as Ee,u as se}from"./useEvent-O0nX5vok.js";import{t as At}from"./react-Bj1aDYRI.js";import{E as Et,Sn as It,Tn as Ie,cr as Bt,li as Be,oi as Lt}from"./cells-DiVpbkA6.js";import"./react-dom-CSu739Rf.js";import{t as ae}from"./compiler-runtime-B3qBwwSJ.js";import"./utils-DnNnBV1N.js";import{i as Le,r as Vt,t as Ve}from"./add-connection-dialog-BvzGJCV7.js";import{h as Ht,m as ye}from"./useEventListener-Dy81QR4n.js";import{t as Ut}from"./invariant-CQUIhlu2.js";import{p as qt,u as He}from"./utils-tNbLd14P.js";import{S as he}from"./config-DqxNMQDN.js";import{t as Wt}from"./jsx-runtime-icT_Ltz2.js";import{n as Kt,t as $}from"./button-Ej3vmCIF.js";import{t as W}from"./cn-BoaCR37F.js";import{St as Gt}from"./dist-B_cxg-E4.js";import{a as Jt,i as Ue,o as pe}from"./JsonOutput-bhD4i0Fm.js";import"./cjs-BU2qXMKx.js";import"./main-DrBRErTM.js";import"./useNonce-BtW-rR_1.js";import{n as Yt,r as je}from"./requests-Bgjtqo_1.js";import{t as H}from"./createLucideIcon-Cm-Z7dYr.js";import{a as qe,c as We,i as Ke,n as fe,o as be,r as Zt,t as Qt}from"./state-Dxl7WjW3.js";import{n as Xt}from"./LazyAnyLanguageCodeMirror-C58z97yX.js";import{t as ea}from"./x-CdLP7-v3.js";import{c as ta,i as ve,r as xe}from"./download-UmTPygP7.js";import{f as we}from"./maps-DQsjfyTy.js";import{n as Ne}from"./markdown-renderer-nMv2xwHt.js";import{u as aa}from"./toDate-Cfp9W_O9.js";import{a as O,c as ne,p as Ge,r as Je,t as Ye}from"./dropdown-menu-BehqiLFL.js";import{t as ke}from"./copy-D6N1-xc1.js";import{t as Ce}from"./download-nLboiTtW.js";import{t as na}from"./eye-off-CF3GmvXV.js";import{a as sa,i as Ze,n as Qe,r as ra,t as ia}from"./file-icons-BTQcwa4T.js";import{t as Xe}from"./file-plus-corner-ks__N1mr.js";import{t as et}from"./file-C-yMeaec.js";import{n as Fe,t as la}from"./spinner-pCogyRyo.js";import{t as tt}from"./plus-DJ99CUbx.js";import{t as at}from"./refresh-cw-Dg9tCj4k.js";import{t as oa}from"./save-CUdcv5qm.js";import{t as ca}from"./trash-2-Bc_J7TQO.js";import{t as da}from"./triangle-alert-CzLrbLGN.js";import{i as ma,n as ha,t as pa}from"./es-DKHH3Swu.js";import"./dist-C6ohaMKU.js";import"./dist-BatEf-0f.js";import"./dist-Dm11d0_A.js";import"./dist-BF9S272t.js";import"./dist-Bk1itfBD.js";import{t as A}from"./use-toast-BtZldTi5.js";import{t as _e}from"./paths-BVwhPRFT.js";import"./session-CByuQ-M-.js";import"./Combination-CSPK4t6z.js";import{t as R}from"./tooltip-CR_izE8Q.js";import"./purify.es-Cf8RQecB.js";import"./dates-CTqMeMGY.js";import{o as fa}from"./alert-dialog-Baw3WWPa.js";import{t as nt}from"./context-CqNy_uER.js";import"./popover-BzqPa2Au.js";import{n as st}from"./ImperativeModal-C5ZzjCQG.js";import{r as xa}from"./errors-iwK4b4VF.js";import{n as ua,t as rt}from"./blob-C3EfaMOb.js";import"./vega-loader.browser-xq8miGHn.js";import"./defaultLocale-DPBdGRrH.js";import"./defaultLocale-Lfi0pexn.js";import{n as re}from"./copy-CcUDATFX.js";import{t as ga}from"./copy-icon-WvgZ60QO.js";import{n as ya}from"./multi-map-0vmox9BD.js";import{a as ja,i as ba,n as Se,r as va,t as wa}from"./tree-Duf22i7P.js";import{n as Na,t as ka}from"./alert-NjVFesQm.js";import{n as it}from"./error-banner-BYG94WiL.js";import{n as Pe}from"./useAsyncData-D-z1U8-c.js";import{a as Ca,o as lt,t as Fa,u as _a}from"./command-B9VNhm0p.js";import"./chunk-5FQGJX7Z-BSe8eGYF.js";import"./katex-FSdXOW5Y.js";import"./html-to-image-CRCamxYo.js";import{o as Sa}from"./focus-BRTg8M44.js";import{a as Pa}from"./renderShortcut-DG5sXSxr.js";import{t as Da}from"./bundle.esm-_LzfhNmX.js";import{t as ot}from"./useAddCell-fzJF_CdR.js";import{a as za,c as De,d as ze,l as ct,u as dt}from"./components-CUetByBv.js";import{t as Ma}from"./empty-state-BBWqzODS.js";import{t as Me}from"./formatting-DBrNlcJ6.js";import{a as Oa,i as $a,n as mt,r as ht,t as pt}from"./components-BouDP-tv.js";import{n as ft,t as Ta}from"./marimo-icons-Cb4NA8Cp.js";import{t as Ra}from"./links-Bfp-iNRX.js";var Aa=H("book-plus",[["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]),Ea=H("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"}]]),Ia=H("file-symlink",[["path",{d:"M4 11V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h7",key:"huwfnr"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m10 18 3-3-3-3",key:"18f6ys"}]]),xt=H("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"}]]),ut=H("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"}]]),Ba=H("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"}]]),La=H("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"}]]),gt=H("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=Ae(At(),1),Va=ae(),a=Ae(Wt(),1);const yt=t=>{let e=(0,Va.c)(17),{filename:n,filenameIcon:i,onBack:r,onRefresh:s,onDownload:c,actions:o}=t,m;e[0]===r?m=e[1]:(m=r&&(0,a.jsx)(R,{content:"Back to file list",children:(0,a.jsx)($,{variant:"text",size:"xs",onClick:r,children:(0,a.jsx)(We,{className:"h-4 w-4"})})}),e[0]=r,e[1]=m);let l;e[2]!==n||e[3]!==i?(l=n?(0,a.jsxs)("span",{className:"flex items-center gap-1.5 flex-1 min-w-0 text-xs font-semibold truncate",children:[i,n]}):(0,a.jsx)("span",{className:"flex-1"}),e[2]=n,e[3]=i,e[4]=l):l=e[4];let f;e[5]===s?f=e[6]:(f=s&&(0,a.jsx)(R,{content:"Refresh",children:(0,a.jsx)($,{variant:"text",size:"xs",onClick:s,children:(0,a.jsx)(at,{className:"h-3.5 w-3.5"})})}),e[5]=s,e[6]=f);let x;e[7]===c?x=e[8]:(x=c&&(0,a.jsx)(R,{content:"Download",children:(0,a.jsx)($,{variant:"text",size:"xs",onClick:c,children:(0,a.jsx)(Ce,{className:"h-3.5 w-3.5"})})}),e[7]=c,e[8]=x);let j;e[9]!==o||e[10]!==f||e[11]!==x?(j=(0,a.jsxs)("div",{className:"flex items-center gap-0.5 shrink-0",children:[f,o,x]}),e[9]=o,e[10]=f,e[11]=x,e[12]=j):j=e[12];let g;return e[13]!==m||e[14]!==l||e[15]!==j?(g=(0,a.jsxs)("div",{className:"flex items-center shrink-0 border-b px-1 gap-1",children:[m,l,j]}),e[13]=m,e[14]=l,e[15]=j,e[16]=g):g=e[16],g};var Ha=new Set(["http","file","in-memory"]);function Oe(t){return JSON.stringify(t).slice(1,-1)}const jt=[{id:"read-file",label:"Insert read snippet",icon:Aa,getCode:t=>{if(t.entry.kind==="directory")return null;let e=Oe(t.entry.path);return t.backendType==="obstore"?`_data = ${t.variableName}.get("${e}").bytes()
|
|
2
|
+
_data`:`_data = ${t.variableName}.cat_file("${e}")
|
|
3
|
+
_data`}},{id:"download-file",label:"Insert download snippet",icon:Ia,getCode:t=>{if(t.entry.kind==="directory")return null;let e=Oe(t.entry.path);if(t.backendType==="obstore")return Ha.has(t.protocol)?null:`from datetime import timedelta
|
|
4
|
+
from obstore import sign
|
|
5
|
+
|
|
6
|
+
signed_url = sign(
|
|
7
|
+
${t.variableName}, "GET", "${e}",
|
|
8
|
+
expires_in=timedelta(hours=1),
|
|
9
|
+
)
|
|
10
|
+
signed_url`;let n=Oe(t.entry.path.split("/").pop()||"download");return`${t.variableName}.get("${e}", "${n}")`}}];var Ua=100*1024*1024;function qa(t){let e=t.endsWith("/")?t.slice(0,-1):t,n=e.split("/");return n[n.length-1]||e}const Wa=({entry:t,namespace:e,protocol:n,backendType:i,onBack:r})=>{let{locale:s}=nt(),c=ot(),o=qa(t.path),m=t.mimeType||"text/plain",l=pe(m),f=l&&t.size>Ua&&t.size>0,{data:x,isPending:j,error:g,refetch:h}=Pe(async()=>{if(f)return null;let y=await be.request({namespace:e,path:t.path,preview:!l});if(y.error)throw Error(y.error);if(!y.url)throw Error("No URL returned");if(l)return{type:"media",url:y.url};let w=await fetch(y.url);if(!w.ok)throw Error(`Failed to fetch preview: ${w.statusText}`);return{type:"text",content:await w.text()}},[e,t.path,l,f]),N=(0,z.useCallback)(async()=>{try{let y=await be.request({namespace:e,path:t.path});if(y.error){A({title:"Download failed",description:y.error,variant:"danger"});return}y.url&&ve(y.url,y.filename??o)}catch(y){ye.error("Failed to download storage entry",y),A({title:"Download failed",description:String(y),variant:"danger"})}},[e,t.path,o]),v=jt.map(y=>{let w=y.getCode({variableName:e,protocol:n,entry:t,backendType:i});if(w===null)return null;let u=y.icon;return(0,a.jsx)(R,{content:y.label,children:(0,a.jsx)($,{variant:"text",size:"xs",onClick:()=>c(w),"aria-label":y.label,children:(0,a.jsx)(u,{className:"h-3.5 w-3.5"})})},y.id)}),p=(0,a.jsx)(yt,{filename:o,filenameIcon:Ze(o),onBack:r,onDownload:N,actions:v}),b=({includeMime:y=!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)(ga,{value:t.path,className:"h-3 w-3"})]}),y&&(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"Type"}),y&&(0,a.jsx)("span",{children:m}),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:Me(t.size,s)})]}),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 f?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[p,b({includeMime:!0}),(0,a.jsxs)("div",{className:"px-4 pb-4 text-xs text-muted-foreground italic",children:["File is too large to preview (",Me(t.size,s),")."]})]}):j?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[p,b({}),(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)(Fe,{className:"h-4 w-4 animate-spin"}),"Loading preview..."]})]}):g?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[p,b({includeMime:!0}),(0,a.jsxs)("div",{className:"px-4 pb-4 text-xs text-destructive",children:["Failed to load preview: ",g.message]}),(0,a.jsx)("div",{className:"px-4 pb-4",children:(0,a.jsxs)($,{variant:"secondary",size:"xs",onClick:h,children:[(0,a.jsx)(at,{className:"h-3 w-3 mr-1"}),"Retry"]})})]}):x?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[p,b({}),(0,a.jsx)(Ue,{mimeType:m,contents:x.type==="text"?x.content:void 0,mediaSource:x.type==="media"?{url:x.url}:void 0})]}):(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[p,b({includeMime:!0}),(0,a.jsxs)("div",{className:"p-4 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,a.jsx)(et,{className:"h-4 w-4"}),"Preview not available for this file type."]})]})};var $e=ae(),Ka=16;function U(t){return{paddingLeft:t*Ka}}function Ga(t,e){return new Date(t*1e3).toLocaleDateString(e,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function bt(t){let e=t.endsWith("/")?t.slice(0,-1):t,n=e.split("/");return n[n.length-1]||e}function Te(t,e,n,i){let r=n.toLowerCase();if(bt(t.path).toLowerCase().includes(r))return!0;if(t.kind==="directory"){let s=i.get(qe(e,t.path));if(s)return s.some(c=>Te(c,e,n,i))}return!1}function vt(t,e,n,i){return n.trim()?t.filter(r=>Te(r,e,n,i)):t}var Ja=t=>{let e=(0,$e.c)(36),{namespace:n,protocol:i,rootPath:r,backendType:s,prefix:c,depth:o,locale:m,searchValue:l,onOpenFile:f}=t,{entriesByPath:x}=fe(),{entries:j,isPending:g,error:h}=Ke(n,c);if(g){let p;e[0]===o?p=e[1]:(p=U(o),e[0]=o,e[1]=p);let b;e[2]===Symbol.for("react.memo_cache_sentinel")?(b=(0,a.jsx)(Fe,{className:"h-3 w-3 animate-spin"}),e[2]=b):b=e[2];let y;return e[3]===p?y=e[4]:(y=(0,a.jsxs)("div",{className:"flex items-center gap-1.5 py-1 text-xs text-muted-foreground",style:p,children:[b,"Loading..."]}),e[3]=p,e[4]=y),y}if(h){let p;e[5]===o?p=e[6]:(p=U(o),e[5]=o,e[6]=p);let b;return e[7]!==h.message||e[8]!==p?(b=(0,a.jsxs)("div",{className:"py-1 text-xs text-destructive",style:p,children:["Failed to load: ",h.message]}),e[7]=h.message,e[8]=p,e[9]=b):b=e[9],b}if(j.length===0){let p;e[10]===o?p=e[11]:(p=U(o),e[10]=o,e[11]=p);let b;return e[12]===p?b=e[13]:(b=(0,a.jsx)("div",{className:"py-1 text-xs text-muted-foreground italic",style:p,children:"Empty"}),e[12]=p,e[13]=b),b}let N;if(e[14]!==s||e[15]!==j||e[16]!==o||e[17]!==x||e[18]!==m||e[19]!==n||e[20]!==f||e[21]!==i||e[22]!==r||e[23]!==l){let p=vt(j,n,l,x),b;e[25]!==s||e[26]!==o||e[27]!==m||e[28]!==n||e[29]!==f||e[30]!==i||e[31]!==r||e[32]!==l?(b=y=>(0,a.jsx)(wt,{entry:y,namespace:n,protocol:i,rootPath:r,backendType:s,depth:o,locale:m,searchValue:l,onOpenFile:f},y.path),e[25]=s,e[26]=o,e[27]=m,e[28]=n,e[29]=f,e[30]=i,e[31]=r,e[32]=l,e[33]=b):b=e[33],N=p.map(b),e[14]=s,e[15]=j,e[16]=o,e[17]=x,e[18]=m,e[19]=n,e[20]=f,e[21]=i,e[22]=r,e[23]=l,e[24]=N}else N=e[24];let v;return e[34]===N?v=e[35]:(v=(0,a.jsx)(a.Fragment,{children:N}),e[34]=N,e[35]=v),v},wt=({entry:t,namespace:e,protocol:n,rootPath:i,backendType:r,depth:s,locale:c,searchValue:o,onOpenFile:m})=>{var w;let[l,f]=(0,z.useState)(!1),{entriesByPath:x}=fe(),j=ot(),g=t.kind==="directory",h=bt(t.path),N=!!o.trim(),v=g&&N&&h.toLowerCase().includes(o.trim().toLowerCase()),p=g&&N&&!!((w=x.get(qe(e,t.path)))!=null&&w.some(u=>Te(u,e,o,x))),b=l||p,y=(0,z.useCallback)(async()=>{try{let u=await be.request({namespace:e,path:t.path});if(u.error){A({title:"Download failed",description:u.error,variant:"danger"});return}u.url&&ve(u.url,u.filename??"download")}catch(u){ye.error("Failed to download storage entry",u),A({title:"Download failed",description:String(u),variant:"danger"})}},[e,t.path]);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(lt,{className:W("text-xs flex items-center gap-1.5 cursor-pointer rounded-none group h-6.5",g&&"font-medium"),style:U(s),value:`${e}:${t.path}`,onSelect:()=>{g?f(!b):m({entry:t,namespace:e,protocol:n,backendType:r})},children:[g?(0,a.jsx)(ze,{isExpanded:b,className:"h-3 w-3"}):(0,a.jsx)("span",{className:"w-3 shrink-0"}),g?(0,a.jsx)(sa,{className:W("h-3.5 w-3.5 shrink-0",Qe.directory)}):Ze(h),(0,a.jsx)("span",{className:"truncate flex-1 text-left",children:h}),(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:Me(t.size,c)}),t.lastModified!=null&&(0,a.jsx)(R,{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:Ga(t.lastModified,c)})}),(0,a.jsxs)(Ye,{children:[(0,a.jsx)(Ge,{asChild:!0,children:(0,a.jsx)(ct,{iconClassName:"h-3 w-3",onClick:u=>u.stopPropagation()})}),(0,a.jsxs)(Je,{align:"end",onClick:u=>u.stopPropagation(),onCloseAutoFocus:u=>u.preventDefault(),children:[!g&&(0,a.jsxs)(O,{onSelect:()=>m({entry:t,namespace:e,protocol:n,backendType:r}),children:[(0,a.jsx)(gt,{className:"h-3.5 w-3.5 mr-2"}),"View"]}),(0,a.jsxs)(O,{onSelect:async()=>{await re(t.path),A({title:"Copied to clipboard"})},children:[(0,a.jsx)(ke,{className:De}),"Copy path"]}),!g&&(0,a.jsxs)(O,{onSelect:()=>y(),children:[(0,a.jsx)(Ce,{className:"h-3.5 w-3.5 mr-2"}),"Download"]}),(0,a.jsx)(ne,{}),jt.map(u=>{let d=u.getCode({variableName:e,protocol:n,entry:t,backendType:r});if(d===null)return null;let k=u.icon;return(0,a.jsxs)(O,{onSelect:()=>j(d),children:[(0,a.jsx)(k,{className:De}),u.label]},u.id)})]})]})]})]}),g&&b&&(0,a.jsx)(Ja,{namespace:e,protocol:n,rootPath:i,backendType:r,prefix:t.path,depth:s+1,locale:c,searchValue:v?"":o,onOpenFile:m})]})},Ya=t=>{let e=(0,$e.c)(43),{namespace:n,locale:i,searchValue:r,onOpenFile:s}=t,[c,o]=(0,z.useState)(!0),{entriesByPath:m}=fe(),{clearNamespaceCache:l}=Zt(),f=n.name??n.displayName,{entries:x,isPending:j,error:g,refetch:h}=Ke(f),N;e[0]!==l||e[1]!==f||e[2]!==h?(N=y=>{y.stopPropagation(),l(f),h()},e[0]=l,e[1]=f,e[2]=h,e[3]=N):N=e[3];let v=N,p=j?n.storageEntries:x,b;if(e[4]!==p||e[5]!==m||e[6]!==g||e[7]!==v||e[8]!==c||e[9]!==j||e[10]!==i||e[11]!==n.backendType||e[12]!==n.displayName||e[13]!==n.name||e[14]!==n.protocol||e[15]!==n.rootPath||e[16]!==f||e[17]!==s||e[18]!==r){let y=vt(p,f,r,m),w;e[20]===c?w=e[21]:(w=()=>o(!c),e[20]=c,e[21]=w);let u;e[22]===c?u=e[23]:(u=(0,a.jsx)(ze,{isExpanded:c,className:"h-3 w-3"}),e[22]=c,e[23]=u);let d;e[24]===n.protocol?d=e[25]:(d=(0,a.jsx)(Vt,{protocol:n.protocol}),e[24]=n.protocol,e[25]=d);let k;e[26]===n.displayName?k=e[27]:(k=(0,a.jsx)("span",{children:n.displayName}),e[26]=n.displayName,e[27]=k);let S;e[28]===n.name?S=e[29]:(S=n.name&&(0,a.jsxs)("span",{className:"text-xs text-muted-foreground font-normal",children:["(",(0,a.jsx)(Oa,{variableName:n.name}),")"]}),e[28]=n.name,e[29]=S);let F;e[30]===v?F=e[31]:(F=(0,a.jsx)(dt,{onClick:v,tooltip:"Refresh storage connection",className:"p-0",iconClassName:"h-3 w-3"}),e[30]=v,e[31]=F);let P=n.rootPath||"(root)",_;e[32]===P?_=e[33]:(_=(0,a.jsx)("span",{className:"text-[10px] text-muted-foreground font-normal tabular-nums ml-auto",children:P}),e[32]=P,e[33]=_);let D;e[34]!==n.name||e[35]!==_||e[36]!==w||e[37]!==u||e[38]!==d||e[39]!==k||e[40]!==S||e[41]!==F?(D=(0,a.jsxs)(lt,{value:n.name,onSelect:w,className:"flex flex-row font-semibold h-7 text-xs gap-1.5 bg-(--slate-2) text-muted-foreground rounded-none",children:[u,d,k,S,F,_]}),e[34]=n.name,e[35]=_,e[36]=w,e[37]=u,e[38]=d,e[39]=k,e[40]=S,e[41]=F,e[42]=D):D=e[42],b=(0,a.jsxs)(a.Fragment,{children:[D,c&&(0,a.jsxs)(a.Fragment,{children:[j&&p.length===0&&(0,a.jsxs)("div",{className:"flex items-center gap-1.5 py-1 text-xs text-muted-foreground",style:U(1),children:[(0,a.jsx)(Fe,{className:"h-3 w-3 animate-spin"}),"Loading..."]}),g&&p.length===0&&(0,a.jsx)(za,{error:g,style:U(1),className:"py-1 text-xs h-auto overflow-auto max-h-32 items-start",showIcon:!1}),!j&&p.length===0&&!g&&(0,a.jsx)("div",{className:"py-1 text-xs text-muted-foreground italic",style:U(1),children:"No entries"}),r&&y.length===0&&p.length>0&&(0,a.jsx)("div",{className:"py-1 text-xs text-muted-foreground italic",style:U(1),children:"No matches"}),y.map(I=>(0,a.jsx)(wt,{entry:I,namespace:f,protocol:n.protocol,rootPath:n.rootPath,backendType:n.backendType,depth:1,locale:i,searchValue:r,onOpenFile:s},I.path))]})]}),e[4]=p,e[5]=m,e[6]=g,e[7]=v,e[8]=c,e[9]=j,e[10]=i,e[11]=n.backendType,e[12]=n.displayName,e[13]=n.name,e[14]=n.protocol,e[15]=n.rootPath,e[16]=f,e[17]=s,e[18]=r,e[19]=b}else b=e[19];return b};const Za=()=>{let t=(0,$e.c)(31),{namespaces:e}=fe(),{locale:n}=nt(),[i,r]=(0,z.useState)(""),[s,c]=(0,z.useState)(null),o=!!i.trim();if(e.length===0){let w;t[0]===Symbol.for("react.memo_cache_sentinel")?(w=(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]=w):w=t[0];let u;return t[1]===Symbol.for("react.memo_cache_sentinel")?(u=(0,a.jsx)(Ma,{title:"No storage connected",description:w,action:(0,a.jsx)(Ve,{defaultTab:"storage",children:(0,a.jsxs)($,{variant:"outline",size:"sm",children:["Add remote storage",(0,a.jsx)(tt,{className:"h-4 w-4 ml-2"})]})}),icon:(0,a.jsx)(Le,{className:"h-8 w-8"})}),t[1]=u):u=t[1],u}let m;t[2]===s?m=t[3]:(m=s&&(0,a.jsx)(Wa,{entry:s.entry,namespace:s.namespace,protocol:s.protocol,backendType:s.backendType,onBack:()=>c(null)}),t[2]=s,t[3]=m);let l=s&&"hidden",f;t[4]===l?f=t[5]:(f=W("border-b bg-background rounded-none h-full pb-10 overflow-auto outline-hidden scrollbar-thin",l),t[4]=l,t[5]=f);let x;t[6]===i?x=t[7]:(x=(0,a.jsx)(Ca,{placeholder:"Search entries...",className:"h-6 m-1",value:i,onValueChange:r,rootClassName:"flex-1 border-b-0"}),t[6]=i,t[7]=x);let j;t[8]===o?j=t[9]:(j=o&&(0,a.jsx)($,{variant:"text",size:"xs",className:"float-right border-none px-2 m-0 h-full",onClick:()=>r(""),children:(0,a.jsx)(ea,{className:"h-4 w-4"})}),t[8]=o,t[9]=j);let g;t[10]===Symbol.for("react.memo_cache_sentinel")?(g=(0,a.jsx)(R,{content:"Filters loaded entries only. Expand directories to include their contents in the search.",delayDuration:200,children:(0,a.jsx)(aa,{className:"h-3.5 w-3.5 shrink-0 cursor-help text-muted-foreground hover:text-foreground mr-2"})}),t[10]=g):g=t[10];let h;t[11]===Symbol.for("react.memo_cache_sentinel")?(h=(0,a.jsx)(Ve,{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)(tt,{className:"h-4 w-4"})})}),t[11]=h):h=t[11];let N;t[12]!==x||t[13]!==j?(N=(0,a.jsxs)("div",{className:"flex items-center w-full border-b",children:[x,j,g,h]}),t[12]=x,t[13]=j,t[14]=N):N=t[14];let v;if(t[15]!==n||t[16]!==e||t[17]!==i){let w;t[19]!==n||t[20]!==i?(w=u=>(0,a.jsx)(Ya,{namespace:u,locale:n,searchValue:i,onOpenFile:c},u.name??u.displayName),t[19]=n,t[20]=i,t[21]=w):w=t[21],v=e.map(w),t[15]=n,t[16]=e,t[17]=i,t[18]=v}else v=t[18];let p;t[22]===v?p=t[23]:(p=(0,a.jsx)(_a,{className:"flex flex-col",children:v}),t[22]=v,t[23]=p);let b;t[24]!==f||t[25]!==N||t[26]!==p?(b=(0,a.jsxs)(Fa,{className:f,shouldFilter:!1,children:[N,p]}),t[24]=f,t[25]=N,t[26]=p,t[27]=b):b=t[27];let y;return t[28]!==m||t[29]!==b?(y=(0,a.jsxs)("div",{className:"h-full flex flex-col",children:[m,b]}),t[28]=m,t[29]=b,t[30]=y):y=t[30],y};var Nt=ae(),kt=(0,z.createContext)(null);function Qa(){return(0,z.useContext)(kt)??void 0}var Xa=t=>{let e=(0,Nt.c)(3),{children:n}=t,i=ba(),r;return e[0]!==n||e[1]!==i?(r=(0,a.jsx)(kt.Provider,{value:i,children:n}),e[0]=n,e[1]=i,e[2]=r):r=e[2],r};const en=t=>{let e=(0,Nt.c)(5),{children:n}=t,[i,r]=(0,z.useState)(null),s;e[0]!==n||e[1]!==i?(s=i&&(0,a.jsx)(ja,{backend:va,options:{rootElement:i},children:(0,a.jsx)(Xa,{children:n})}),e[0]=n,e[1]=i,e[2]=s):s=e[2];let c;return e[3]===s?c=e[4]:(c=(0,a.jsx)("div",{ref:r,className:"contents",children:s}),e[3]=s,e[4]=c),c};var Re=new Map;const tn=({file:t,onOpenNotebook:e})=>{let{sendFileDetails:n,sendUpdateFile:i}=je(),r=se(qt),s=se(He),c=se(Lt),[o,m]=(0,z.useState)(""),{data:l,isPending:f,error:x,setData:j,refetch:g}=Pe(async()=>{let d=await n({path:t.path}),k=d.contents||"";return m(Re.get(t.path)||k),d},[t.path]),h=async()=>{o!==(l==null?void 0:l.contents)&&await i({path:t.path,contents:o}).then(d=>{d.success&&(j(k=>({...k,contents:o})),m(o))})},N=(0,z.useRef)(o);if(N.current=o,(0,z.useEffect)(()=>()=>{if(!(l!=null&&l.contents))return;let d=N.current;d===l.contents?Re.delete(t.path):Re.set(t.path,d)},[t.path,l==null?void 0:l.contents]),x)return(0,a.jsx)(it,{error:x});if(f||!l)return null;let v=l.mimeType||"text/plain",p=v in Jt,b=c&&l.file.isMarimoFile&&(t.path===c||t.path.endsWith(`/${c}`));if(!l.contents&&!p)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:l.file.name}),(0,a.jsx)("div",{className:"font-bold text-muted-foreground",children:"Type"}),(0,a.jsx)("div",{children:v})]});let y=(0,a.jsx)(yt,{filename:l.file.name,onRefresh:g,onDownload:s?void 0:()=>{if(l.isBase64&&l.contents){pe(v)?ve(Ne(l.contents,v),l.file.name):xe(rt(Ne(l.contents,l.mimeType||"application/octet-stream")),l.file.name);return}xe(new Blob([l.contents||o],{type:v}),l.file.name)},actions:(0,a.jsxs)(a.Fragment,{children:[t.isMarimoFile&&!he()&&(0,a.jsx)(R,{content:"Open notebook",children:(0,a.jsx)($,{variant:"text",size:"xs",onClick:d=>e(d),children:(0,a.jsx)(we,{className:"h-3.5 w-3.5"})})}),!pe(v)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(R,{content:"Copy contents to clipboard",children:(0,a.jsx)($,{variant:"text",size:"xs",onClick:async()=>{await re(o)},children:(0,a.jsx)(ke,{className:"h-3.5 w-3.5"})})}),(0,a.jsx)(R,{content:Pa("global.save"),children:(0,a.jsx)($,{variant:"text",size:"xs",onClick:h,disabled:o===l.contents,children:(0,a.jsx)(oa,{className:"h-3.5 w-3.5"})})})]})]})}),w=pe(v),u=!w&&v!=="text/csv";return(0,a.jsxs)(a.Fragment,{children:[y,u&&b&&(0,a.jsxs)(ka,{variant:"warning",className:"rounded-none",children:[(0,a.jsx)(da,{className:"h-4 w-4"}),(0,a.jsx)(Na,{children:"Editing the notebook file directly while running in marimo's editor may cause unintended changes. Please use with caution."})]}),(0,a.jsx)(Ue,{mimeType:v,contents:w?void 0:u?o:l.contents??void 0,mediaSource:w?{base64:l.contents,mime:v}:void 0,readOnly:!u,onChange:m,extensions:[Gt.of([{key:r.getHotkey("global.save").key,stopPropagation:!0,run:()=>o===l.contents?!1:(h(),!0)}])]})]})};var an=class{constructor(t){L(this,"delegate",new Se([]));L(this,"rootPath","");L(this,"onChange",Ht.NOOP);L(this,"path",new _e("/"));L(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 Se(e.files),this.rootPath=e.root,this.path=_e.guessDeliminator(e.root)}catch(e){A({title:"Failed",description:xa(e)})}this.onChange(this.delegate.data)});L(this,"refreshAll",async t=>{let e=[this.rootPath,...t.map(i=>{var r;return(r=this.delegate.find(i))==null?void 0:r.data.path})].filter(Boolean),n=await Promise.all(e.map(i=>this.callbacks.listFiles({path:i}).catch(()=>({files:[]}))));for(let[i,r]of e.entries()){let s=n[i];r===this.rootPath?this.delegate=new Se(s.files):this.delegate.update({id:r,changes:{children:s.files}})}this.onChange(this.delegate.data)});L(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});L(this,"handleResponse",t=>t.success?t:(A({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 n=await this.callbacks.listFiles({path:e.data.path});return this.delegate.update({id:t,changes:{children:n.files}}),this.onChange(this.delegate.data),!0}async rename(t,e){let n=this.delegate.find(t);if(!n)return;let i=n.data.path,r=this.path.join(this.path.dirname(i),e);await this.callbacks.renameFileOrFolder({path:i,newPath:r}).then(this.handleResponse),this.delegate.update({id:t,changes:{name:e,path:r}}),this.onChange(this.delegate.data),await this.refreshAll([r])}async move(t,e){var i;let n=e?((i=this.delegate.find(e))==null?void 0:i.data.path)??e:this.rootPath;await Promise.all(t.map(r=>{this.delegate.move({id:r,parentId:e,index:0});let s=this.delegate.find(r);if(!s)return Promise.resolve();let c=this.path.join(n,this.path.basename(s.data.path));return this.delegate.update({id:r,changes:{path:c}}),this.callbacks.renameFileOrFolder({path:s.data.path,newPath:c}).then(this.handleResponse)})),this.onChange(this.delegate.data),await this.refreshAll([n])}async createFile(t,e,n="file"){var s;let i=e?((s=this.delegate.find(e))==null?void 0:s.data.path)??e:this.rootPath,r=await this.callbacks.createFileOrFolder({path:i,type:n,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([i]))}async createFolder(t,e){var r;let n=e?((r=this.delegate.find(e))==null?void 0:r.data.path)??e:this.rootPath,i=await this.callbacks.createFileOrFolder({path:n,type:"directory",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([n]))}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 Ct=Ee(t=>{let e=t(Yt);return Ut(e,"no requestClientAtom set"),new an({listFiles:e.sendListFiles,createFileOrFolder:e.sendCreateFileOrFolder,deleteFileOrFolder:e.sendDeleteFileOrFolder,renameFileOrFolder:e.sendRenameFileOrFolder})}),nn=Ee({});async function sn(){await Rt.get(Ct).refreshAll([])}var q=" ";const Ft={directory:t=>`os.listdir("${t}")`,python:t=>`with open("${t}", "r") as _f:
|
|
11
|
+
${q}...
|
|
12
|
+
`,json:t=>`with open("${t}", "r") as _f:
|
|
13
|
+
${q}_data = json.load(_f)
|
|
14
|
+
`,code:t=>`with open("${t}", "r") as _f:
|
|
15
|
+
${q}...
|
|
16
|
+
`,text:t=>`with open("${t}", "r") as _f:
|
|
17
|
+
${q}...
|
|
18
|
+
`,image:t=>`mo.image("${t}")`,audio:t=>`mo.audio("${t}")`,video:t=>`mo.video("${t}")`,pdf:t=>`with open("${t}", "rb") as _f:
|
|
19
|
+
${q}...
|
|
20
|
+
`,zip:t=>`with open("${t}", "rb") as _f:
|
|
21
|
+
${q}...
|
|
22
|
+
`,data:t=>`with open("${t}", "r") as _f:
|
|
23
|
+
${q}...
|
|
24
|
+
`,unknown:t=>`with open("${t}", "r") as _f:
|
|
25
|
+
${q}...
|
|
26
|
+
`};var rn=ae(),ln=1024*1024*100;function _t(t){let e=(0,rn.c)(7),n;e[0]===t?n=e[1]:(n=t===void 0?{}:t,e[0]=t,e[1]=n);let i=n,{sendCreateFileOrFolder:r}=je(),s;e[2]===r?s=e[3]:(s=async o=>{if(o.length===0)return;let m=o.length===1;await ta(m?"Uploading file...":"Uploading files...",async l=>{l.addTotal(o.length);for(let f of o){let x=pn(hn(f)),j="";x&&(j=_e.guessDeliminator(x).dirname(x));let g=(await ua(f)).split(",")[1];await r({path:j,type:"file",name:f.name,contents:g}),l.increment(1)}await sn()},{title:m?"File uploaded":`${o.length} files uploaded`})},e[2]=r,e[3]=s);let c;return e[4]!==i||e[5]!==s?(c={multiple:!0,maxSize:ln,onError:mn,onDropRejected:on,onDrop:s,...i},e[4]=i,e[5]=s,e[6]=c):c=e[6],pa(c)}function on(t){A({title:"File upload failed",description:(0,a.jsx)("div",{className:"flex flex-col gap-1",children:t.map(cn)}),variant:"danger"})}function cn(t){return(0,a.jsxs)("div",{children:[t.file.name," (",t.errors.map(dn).join(", "),")"]},t.file.name)}function dn(t){return t.message}function mn(t){ye.error(t),A({title:"File upload failed",description:t.message,variant:"danger"})}function hn(t){if(t.webkitRelativePath)return t.webkitRelativePath;if("path"in t&&typeof t.path=="string")return t.path;if("relativePath"in t&&typeof t.relativePath=="string")return t.relativePath}function pn(t){if(t)return t.replace(/^\/+/,"")}var ie=ae(),fn=Be("marimo:showHiddenFiles",!0,Ie,{getOnInit:!0}),St=z.createContext(null);const xn=t=>{let e=(0,ie.c)(72),{height:n}=t,i=(0,z.useRef)(null),r=Qa(),[s]=me(Ct),c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=[],e[0]=c):c=e[0];let[o,m]=(0,z.useState)(c),[l,f]=(0,z.useState)(null),[x,j]=me(fn),{openPrompt:g}=st(),[h,N]=me(nn),v;e[1]===s?v=e[2]:(v=()=>s.initialize(m),e[1]=s,e[2]=v);let p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p=[],e[3]=p):p=e[3];let{isPending:b,error:y}=Pe(v,p),w;e[4]!==h||e[5]!==s?(w=()=>s.refreshAll(Object.keys(h).filter(C=>h[C])),e[4]=h,e[5]=s,e[6]=w):w=e[6];let u=B(w),d;e[7]!==j||e[8]!==x?(d=()=>{j(!x)},e[7]=j,e[8]=x,e[9]=d):d=e[9];let k=B(d),S;e[10]!==g||e[11]!==s?(S=async()=>{g({title:"Folder name",onConfirm:async C=>{s.createFolder(C,null)}})},e[10]=g,e[11]=s,e[12]=S):S=e[12];let F=B(S),P;e[13]!==g||e[14]!==s?(P=async()=>{g({title:"File name",onConfirm:async C=>{s.createFile(C,null)}})},e[13]=g,e[14]=s,e[15]=P):P=e[15];let _=B(P),D;e[16]!==g||e[17]!==s?(D=async()=>{g({title:"Notebook name",onConfirm:async C=>{s.createFile(C,null,"notebook")}})},e[16]=g,e[17]=s,e[18]=D):D=e[18];let I=B(D),M;e[19]===N?M=e[20]:(M=()=>{var C;(C=i.current)==null||C.closeAll(),N({})},e[19]=N,e[20]=M);let V=B(M),le;e[21]!==o||e[22]!==x?(le=Dt(o,x),e[21]=o,e[22]=x,e[23]=le):le=e[23];let ue=le;if(b){let C;return e[24]===Symbol.for("react.memo_cache_sentinel")?(C=(0,a.jsx)(la,{size:"medium",centered:!0}),e[24]=C):C=e[24],C}if(y){let C;return e[25]===y?C=e[26]:(C=(0,a.jsx)(it,{error:y}),e[25]=y,e[26]=C),C}if(l){let C;e[27]===Symbol.for("react.memo_cache_sentinel")?(C=()=>f(null),e[27]=C):C=e[27];let T;e[28]===Symbol.for("react.memo_cache_sentinel")?(T=(0,a.jsx)($,{onClick:C,"data-testid":"file-explorer-back-button",variant:"text",size:"xs",className:"mb-0",children:(0,a.jsx)(We,{size:16})}),e[28]=T):T=e[28];let E;e[29]===l.name?E=e[30]:(E=(0,a.jsxs)("div",{className:"flex items-center pl-1 pr-3 shrink-0 border-b justify-between",children:[T,(0,a.jsx)("span",{className:"font-bold",children:l.name})]}),e[29]=l.name,e[30]=E);let ee;e[31]!==l.path||e[32]!==s?(ee=Ot=>Pt(Ot,s.relativeFromRoot(l.path)),e[31]=l.path,e[32]=s,e[33]=ee):ee=e[33];let te;e[34]!==l||e[35]!==ee?(te=(0,a.jsx)(z.Suspense,{children:(0,a.jsx)(tn,{onOpenNotebook:ee,file:l})}),e[34]=l,e[35]=ee,e[36]=te):te=e[36];let de;return e[37]!==E||e[38]!==te?(de=(0,a.jsxs)(a.Fragment,{children:[E,te]}),e[37]=E,e[38]=te,e[39]=de):de=e[39],de}let K;e[40]!==V||e[41]!==_||e[42]!==F||e[43]!==I||e[44]!==k||e[45]!==u||e[46]!==s?(K=(0,a.jsx)(gn,{onRefresh:u,onHidden:k,onCreateFile:_,onCreateNotebook:I,onCreateFolder:F,onCollapseAll:V,tree:s}),e[40]=V,e[41]=_,e[42]=F,e[43]=I,e[44]=k,e[45]=u,e[46]=s,e[47]=K):K=e[47];let ge=n-33,G,J,Y;e[48]===s?(G=e[49],J=e[50],Y=e[51]):(G=async C=>{let{ids:T}=C;for(let E of T)await s.delete(E)},J=async C=>{let{id:T,name:E}=C;await s.rename(T,E)},Y=async C=>{let{dragIds:T,parentId:E}=C;await s.move(T,E)},e[48]=s,e[49]=G,e[50]=J,e[51]=Y);let oe;e[52]===Symbol.for("react.memo_cache_sentinel")?(oe=C=>{let T=C[0];T&&(T.data.isDirectory||f(T.data))},e[52]=oe):oe=e[52];let Z;e[53]!==h||e[54]!==N||e[55]!==s?(Z=async C=>{if(await s.expand(C)){let T=h[C]??!1;N({...h,[C]:!T})}},e[53]=h,e[54]=N,e[55]=s,e[56]=Z):Z=e[56];let Q;e[57]!==r||e[58]!==h||e[59]!==ge||e[60]!==G||e[61]!==J||e[62]!==Y||e[63]!==Z||e[64]!==ue?(Q=(0,a.jsx)(wa,{width:"100%",ref:i,height:ge,className:"h-full",data:ue,initialOpenState:h,openByDefault:!1,dndManager:r,renderCursor:Nn,disableDrop:kn,onDelete:G,onRename:J,onMove:Y,onSelect:oe,onToggle:Z,padding:15,rowHeight:30,indent:un,overscanCount:1e3,disableMultiSelection:!0,children:bn}),e[57]=r,e[58]=h,e[59]=ge,e[60]=G,e[61]=J,e[62]=Y,e[63]=Z,e[64]=ue,e[65]=Q):Q=e[65];let X;e[66]!==Q||e[67]!==s?(X=(0,a.jsx)(St,{value:s,children:Q}),e[66]=Q,e[67]=s,e[68]=X):X=e[68];let ce;return e[69]!==K||e[70]!==X?(ce=(0,a.jsxs)(a.Fragment,{children:[K,X]}),e[69]=K,e[70]=X,e[71]=ce):ce=e[71],ce};var un=15,gn=t=>{let e=(0,ie.c)(37),{onRefresh:n,onHidden:i,onCreateFile:r,onCreateNotebook:s,onCreateFolder:c,onCollapseAll:o}=t,m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m={noDrag:!0,noDragEventsBubbling:!0},e[0]=m):m=e[0];let{getRootProps:l,getInputProps:f}=_t(m),x;e[1]===Symbol.for("react.memo_cache_sentinel")?(x=(0,a.jsx)(ft,{size:16}),e[1]=x):x=e[1];let j;e[2]===s?j=e[3]:(j=(0,a.jsx)(R,{content:"Add notebook",children:(0,a.jsx)($,{"data-testid":"file-explorer-add-notebook-button",onClick:s,variant:"text",size:"xs",children:x})}),e[2]=s,e[3]=j);let g;e[4]===Symbol.for("react.memo_cache_sentinel")?(g=(0,a.jsx)(Xe,{size:16}),e[4]=g):g=e[4];let h;e[5]===r?h=e[6]:(h=(0,a.jsx)(R,{content:"Add file",children:(0,a.jsx)($,{"data-testid":"file-explorer-add-file-button",onClick:r,variant:"text",size:"xs",children:g})}),e[5]=r,e[6]=h);let N;e[7]===Symbol.for("react.memo_cache_sentinel")?(N=(0,a.jsx)(xt,{size:16}),e[7]=N):N=e[7];let v;e[8]===c?v=e[9]:(v=(0,a.jsx)(R,{content:"Add folder",children:(0,a.jsx)($,{"data-testid":"file-explorer-add-folder-button",onClick:c,variant:"text",size:"xs",children:N})}),e[8]=c,e[9]=v);let p;e[10]===l?p=e[11]:(p=l({}),e[10]=l,e[11]=p);let b,y;e[12]===Symbol.for("react.memo_cache_sentinel")?(y=Kt({variant:"text",size:"xs"}),b=(0,a.jsx)(ma,{size:16}),e[12]=b,e[13]=y):(b=e[12],y=e[13]);let w;e[14]===p?w=e[15]:(w=(0,a.jsx)(R,{content:"Upload file",children:(0,a.jsx)("button",{"data-testid":"file-explorer-upload-button",...p,className:y,children:b})}),e[14]=p,e[15]=w);let u;e[16]===f?u=e[17]:(u=f({}),e[16]=f,e[17]=u);let d;e[18]===u?d=e[19]:(d=(0,a.jsx)("input",{...u,type:"file"}),e[18]=u,e[19]=d);let k;e[20]===n?k=e[21]:(k=(0,a.jsx)(dt,{"data-testid":"file-explorer-refresh-button",onClick:n}),e[20]=n,e[21]=k);let S;e[22]===Symbol.for("react.memo_cache_sentinel")?(S=(0,a.jsx)(na,{size:16}),e[22]=S):S=e[22];let F;e[23]===i?F=e[24]:(F=(0,a.jsx)(R,{content:"Toggle hidden files",children:(0,a.jsx)($,{"data-testid":"file-explorer-hidden-files-button",onClick:i,variant:"text",size:"xs",children:S})}),e[23]=i,e[24]=F);let P;e[25]===Symbol.for("react.memo_cache_sentinel")?(P=(0,a.jsx)(Ea,{size:16}),e[25]=P):P=e[25];let _;e[26]===o?_=e[27]:(_=(0,a.jsx)(R,{content:"Collapse all folders",children:(0,a.jsx)($,{"data-testid":"file-explorer-collapse-button",onClick:o,variant:"text",size:"xs",children:P})}),e[26]=o,e[27]=_);let D;return e[28]!==w||e[29]!==d||e[30]!==k||e[31]!==F||e[32]!==_||e[33]!==j||e[34]!==h||e[35]!==v?(D=(0,a.jsxs)("div",{className:"flex items-center justify-end px-2 shrink-0 border-b",children:[j,h,v,w,d,k,F,_]}),e[28]=w,e[29]=d,e[30]=k,e[31]=F,e[32]=_,e[33]=j,e[34]=h,e[35]=v,e[36]=D):D=e[36],D},yn=t=>{let e=(0,ie.c)(9),{node:n,onOpenMarimoFile:i}=t,r;e[0]===n?r=e[1]:(r=o=>{n.data.isDirectory||(o.stopPropagation(),n.select())},e[0]=n,e[1]=r);let s;e[2]!==n.data.isMarimoFile||e[3]!==i?(s=n.data.isMarimoFile&&!he()&&(0,a.jsxs)("span",{className:"shrink-0 ml-2 text-sm hidden group-hover:inline hover:underline",onClick:i,children:["open ",(0,a.jsx)(we,{className:"inline ml-1",size:12})]}),e[2]=n.data.isMarimoFile,e[3]=i,e[4]=s):s=e[4];let c;return e[5]!==n.data.name||e[6]!==r||e[7]!==s?(c=(0,a.jsxs)("span",{className:"flex-1 overflow-hidden text-ellipsis",onClick:r,children:[n.data.name,s]}),e[5]=n.data.name,e[6]=r,e[7]=s,e[8]=c):c=e[8],c},jn=t=>{let e=(0,ie.c)(10),{node:n}=t,i=(0,z.useRef)(null),r,s;e[0]===n.data.name?(r=e[1],s=e[2]):(r=()=>{var l,f;(l=i.current)==null||l.focus(),(f=i.current)==null||f.setSelectionRange(0,n.data.name.lastIndexOf("."))},s=[n.data.name],e[0]=n.data.name,e[1]=r,e[2]=s),(0,z.useEffect)(r,s);let c,o;e[3]===n?(c=e[4],o=e[5]):(c=()=>n.reset(),o=l=>{l.key==="Escape"&&n.reset(),l.key==="Enter"&&n.submit(l.currentTarget.value)},e[3]=n,e[4]=c,e[5]=o);let m;return e[6]!==n.data.name||e[7]!==c||e[8]!==o?(m=(0,a.jsx)("input",{ref:i,className:"flex-1 bg-transparent border border-border text-muted-foreground",defaultValue:n.data.name,onClick:Cn,onBlur:c,onKeyDown:o}),e[6]=n.data.name,e[7]=c,e[8]=o,e[9]=m):m=e[9],m},bn=({node:t,style:e,dragHandle:n})=>{let{openFile:i,sendCreateFileOrFolder:r,sendFileDetails:s}=je(),c=se(He),o=t.data.isDirectory?"directory":ra(t.data.name),m=ia[o],{openConfirm:l,openPrompt:f}=st(),{createNewCell:x}=Et(),j=Sa(),g=d=>{x({code:d,before:!1,cellId:j??"__end__"})},h=(0,z.use)(St),N=async d=>{Pt(d,h?h.relativeFromRoot(t.data.path):t.data.path)},v=async d=>{d.stopPropagation(),d.preventDefault(),l({title:"Delete file",description:`Are you sure you want to delete ${t.data.name}?`,confirmAction:(0,a.jsx)(fa,{onClick:async()=>{await t.tree.delete(t.id)},"aria-label":"Confirm",children:"Delete"})})},p=B(async()=>{t.open(),f({title:"Folder name",onConfirm:async d=>{h==null||h.createFolder(d,t.id)}})}),b=B(async()=>{t.open(),f({title:"File name",onConfirm:async d=>{h==null||h.createFile(d,t.id)}})}),y=B(async()=>{t.open(),f({title:"Notebook name",onConfirm:async d=>{h==null||h.createFile(d,t.id,"notebook")}})}),w=B(async()=>{var F;if(!h||t.data.isDirectory)return;let[d,k]=ha(t.data.name),S=`${d}_copy${k}`;try{let P=await s({path:t.data.path}),_=((F=t.parent)==null?void 0:F.data.path)||"";await r({path:_,type:"file",name:S,contents:P.contents?btoa(P.contents):void 0}),await h.refreshAll([_])}catch{A({title:"Failed to duplicate file",description:"Unable to create a duplicate of the file",variant:"danger"})}}),u=()=>{let d=De;return(0,a.jsxs)(Je,{align:"end",className:"print:hidden w-[220px]",onClick:k=>k.stopPropagation(),onCloseAutoFocus:k=>k.preventDefault(),children:[!t.data.isDirectory&&(0,a.jsxs)(O,{onSelect:()=>t.select(),children:[(0,a.jsx)(gt,{className:d}),"Open file"]}),!t.data.isDirectory&&!he()&&(0,a.jsxs)(O,{onSelect:()=>{i({path:t.data.path})},children:[(0,a.jsx)(we,{className:d}),"Open file in external editor"]}),t.data.isDirectory&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(O,{onSelect:()=>y(),children:[(0,a.jsx)(ft,{className:d}),"Create notebook"]}),(0,a.jsxs)(O,{onSelect:()=>b(),children:[(0,a.jsx)(Xe,{className:d}),"Create file"]}),(0,a.jsxs)(O,{onSelect:()=>p(),children:[(0,a.jsx)(xt,{className:d}),"Create folder"]}),(0,a.jsx)(ne,{})]}),(0,a.jsxs)(O,{onSelect:()=>t.edit(),children:[(0,a.jsx)(Ba,{className:d}),"Rename"]}),!t.data.isDirectory&&(0,a.jsxs)(O,{onSelect:w,children:[(0,a.jsx)(ke,{className:d}),"Duplicate"]}),(0,a.jsxs)(O,{onSelect:async()=>{await re(t.data.path),A({title:"Copied to clipboard"})},children:[(0,a.jsx)(ut,{className:d}),"Copy path"]}),h&&(0,a.jsxs)(O,{onSelect:async()=>{await re(h.relativeFromRoot(t.data.path)),A({title:"Copied to clipboard"})},children:[(0,a.jsx)(ut,{className:d}),"Copy relative path"]}),(0,a.jsx)(ne,{}),(0,a.jsxs)(O,{onSelect:()=>{let{path:k}=t.data;g(Ft[o](k))},children:[(0,a.jsx)(Xt,{className:d}),"Insert snippet for reading file"]}),(0,a.jsxs)(O,{onSelect:async()=>{A({title:"Copied to clipboard",description:"Code to open the file has been copied to your clipboard. You can also drag and drop this file into the editor"});let{path:k}=t.data;await re(Ft[o](k))},children:[(0,a.jsx)(Bt,{className:d}),"Copy snippet for reading file"]}),t.data.isMarimoFile&&!he()&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ne,{}),(0,a.jsxs)(O,{onSelect:N,children:[(0,a.jsx)(La,{className:d}),"Open notebook"]})]}),(0,a.jsx)(ne,{}),!t.data.isDirectory&&!c&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(O,{onSelect:async()=>{let k=await s({path:t.data.path});k.isBase64&&k.contents?xe(rt(Ne(k.contents,k.mimeType||"application/octet-stream")),t.data.name):xe(new Blob([k.contents||""]),t.data.name)},children:[(0,a.jsx)(Ce,{className:d}),"Download"]}),(0,a.jsx)(ne,{})]}),(0,a.jsxs)(O,{onSelect:v,variant:"danger",children:[(0,a.jsx)(ca,{className:d}),"Delete"]})]})};return(0,a.jsxs)("div",{style:e,ref:n,className:W("flex items-center cursor-pointer ml-1 text-muted-foreground whitespace-nowrap group"),draggable:!0,onClick:d=>{d.stopPropagation(),t.data.isDirectory&&t.toggle()},children:[(0,a.jsx)(vn,{node:t}),(0,a.jsxs)("span",{className:W("flex items-center pl-1 py-1 cursor-pointer hover:bg-accent/50 hover:text-accent-foreground rounded-l flex-1 overflow-hidden group",t.willReceiveDrop&&t.data.isDirectory&&"bg-accent/80 hover:bg-accent/80 text-accent-foreground"),children:[t.data.isMarimoFile?(0,a.jsx)(Ta,{className:"w-5 h-5 shrink-0 mr-2",strokeWidth:1.5}):(0,a.jsx)(m,{className:W("w-5 h-5 shrink-0 mr-2",Qe[o]),strokeWidth:1.5}),t.isEditing?(0,a.jsx)(jn,{node:t}):(0,a.jsx)(yn,{node:t,onOpenMarimoFile:N}),(0,a.jsxs)(Ye,{modal:!1,children:[(0,a.jsx)(Ge,{asChild:!0,tabIndex:-1,onClick:d=>d.stopPropagation(),children:(0,a.jsx)(ct,{"data-testid":"file-explorer-more-button",iconClassName:"w-5 h-5"})}),u()]})]})]})},vn=t=>{let e=(0,ie.c)(3),{node:n}=t;if(!n.data.isDirectory){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)("span",{className:"w-4 h-4 shrink-0"}),e[0]=r):r=e[0],r}let i;return e[1]===n.isOpen?i=e[2]:(i=(0,a.jsx)(ze,{isExpanded:n.isOpen,className:"w-4 h-4"}),e[1]=n.isOpen,e[2]=i),i};function Pt(t,e){t.stopPropagation(),t.preventDefault(),Ra(e)}function Dt(t,e){if(e)return t;let n=[];for(let i of t){if(wn(i.name))continue;let r=i;if(i.children){let s=Dt(i.children,e);s!==i.children&&(r={...i,children:s})}n.push(r)}return n}function wn(t){return!!t.startsWith(".")}function Nn(){return null}function kn(t){let{parentNode:e}=t;return!e.data.isDirectory}function Cn(t){return t.stopPropagation()}var zt=ae(),Fn=Be("marimo:file-explorer-panel:state",{openSections:["files"],hasUserInteracted:!1},Ie),Mt=t=>{let e=(0,zt.c)(20),{height:n}=t,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={noClick:!0,noKeyboard:!0},e[0]=i):i=e[0];let{getRootProps:r,getInputProps:s,isDragActive:c}=_t(i),o;e[1]===r?o=e[2]:(o=r(),e[1]=r,e[2]=o);let m;e[3]===Symbol.for("react.memo_cache_sentinel")?(m=W("flex flex-col overflow-hidden relative"),e[3]=m):m=e[3];let l;e[4]===n?l=e[5]:(l={height:n},e[4]=n,e[5]=l);let f;e[6]===s?f=e[7]:(f=s(),e[6]=s,e[7]=f);let x;e[8]===f?x=e[9]:(x=(0,a.jsx)("input",{...f}),e[8]=f,e[9]=x);let j;e[10]===c?j=e[11]:(j=c&&(0,a.jsx)("div",{className:"absolute inset-0 flex items-center uppercase justify-center text-xl font-bold text-primary/90 bg-accent/85 z-10 border-2 border-dashed border-primary/90 rounded-lg pointer-events-none",children:"Drop files here"}),e[10]=c,e[11]=j);let g;e[12]===n?g=e[13]:(g=(0,a.jsx)(xn,{height:n}),e[12]=n,e[13]=g);let h;return e[14]!==o||e[15]!==l||e[16]!==x||e[17]!==j||e[18]!==g?(h=(0,a.jsx)(en,{children:(0,a.jsxs)("div",{...o,className:m,style:l,children:[x,j,g]})}),e[14]=o,e[15]=l,e[16]=x,e[17]=j,e[18]=g,e[19]=h):h=e[19],h},_n=33,Sn=()=>{let t=(0,zt.c)(41),{ref:e,height:n}=Da(),i=n===void 0?500:n,[r,s]=me(Fn),c=se(Qt).length,o;e:{if(!r.hasUserInteracted&&c>0){if(r.openSections.includes("remote-storage")){o=r.openSections;break e}let M;t[0]===r.openSections?M=t[1]:(M=[...r.openSections,"remote-storage"],t[0]=r.openSections,t[1]=M),o=M;break e}o=r.openSections}let m=o,l;t[2]===s?l=t[3]:(l=M=>{s({openSections:M,hasUserInteracted:!0})},t[2]=s,t[3]=l);let f=l,x=i-_n*2,j;t[4]===m?j=t[5]:(j=m.includes("remote-storage"),t[4]=m,t[5]=j);let g=j,h;t[6]!==m||t[7]!==g?(h=g&&m.includes("files"),t[6]=m,t[7]=g,t[8]=h):h=t[8];let N=h,v;t[9]!==x||t[10]!==N?(v=N?Math.round(x*.4):x,t[9]=x,t[10]=N,t[11]=v):v=t[11];let p=v,b=Math.max(200,N?x-p:x);if(!It("storage_inspector")){let M;t[12]===i?M=t[13]:(M=(0,a.jsx)(Mt,{height:i}),t[12]=i,t[13]=M);let V;return t[14]!==e||t[15]!==M?(V=(0,a.jsx)("div",{ref:e,className:"h-full overflow-auto",children:M}),t[14]=e,t[15]=M,t[16]=V):V=t[16],V}let y;t[17]===Symbol.for("react.memo_cache_sentinel")?(y=(0,a.jsx)(Le,{className:"w-4 h-4"}),t[17]=y):y=t[17];let w;t[18]===c?w=t[19]:(w=c>0&&(0,a.jsx)($a,{children:c}),t[18]=c,t[19]=w);let u;t[20]===w?u=t[21]:(u=(0,a.jsxs)(ht,{children:[y," Remote storage",w]}),t[20]=w,t[21]=u);let d;t[22]===p?d=t[23]:(d={maxHeight:p},t[22]=p,t[23]=d);let k;t[24]===Symbol.for("react.memo_cache_sentinel")?(k=(0,a.jsx)(Za,{}),t[24]=k):k=t[24];let S;t[25]===d?S=t[26]:(S=(0,a.jsx)(pt,{className:"overflow-auto",style:d,children:k}),t[25]=d,t[26]=S);let F;t[27]!==S||t[28]!==u?(F=(0,a.jsxs)(mt,{value:"remote-storage",children:[u,S]}),t[27]=S,t[28]=u,t[29]=F):F=t[29];let P;t[30]===Symbol.for("react.memo_cache_sentinel")?(P=(0,a.jsxs)(ht,{children:[(0,a.jsx)(et,{className:"w-4 h-4"}),"Files"]}),t[30]=P):P=t[30];let _;t[31]===b?_=t[32]:(_=(0,a.jsxs)(mt,{value:"files",children:[P,(0,a.jsx)(pt,{children:(0,a.jsx)(Mt,{height:b})})]}),t[31]=b,t[32]=_);let D;t[33]!==f||t[34]!==m||t[35]!==F||t[36]!==_?(D=(0,a.jsxs)(ya,{type:"multiple",value:m,onValueChange:f,children:[F,_]}),t[33]=f,t[34]=m,t[35]=F,t[36]=_,t[37]=D):D=t[37];let I;return t[38]!==e||t[39]!==D?(I=(0,a.jsx)("div",{ref:e,className:"h-full overflow-auto",children:D}),t[38]=e,t[39]=D,t[40]=I):I=t[40],I};export{Sn as default};
|