@marimo-team/frontend 0.25.3-dev80 → 0.25.3-dev82
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/{CellStatus-cD3S0wEA.js → CellStatus-DXroYLOP.js} +1 -1
- package/dist/assets/{ErrorBoundary-DJhsFCsX.js → ErrorBoundary-DaQ9THH_.js} +2 -2
- package/dist/assets/{JsonOutput-Pm6OCP3J.js → JsonOutput-VxzHyItt.js} +1 -1
- package/dist/assets/{MarimoErrorOutput-DlEjLCZ-.js → MarimoErrorOutput-D-hLaDA-.js} +1 -1
- package/dist/assets/{RenderHTML-CfQ6i3QV.js → RenderHTML-DjOEZL25.js} +1 -1
- package/dist/assets/{RunButton-DvuvkgrG.js → RunButton-CuhNTo5_.js} +1 -1
- package/dist/assets/{add-cell-with-ai-By51zSlC.js → add-cell-with-ai-BbVntTh7.js} +1 -1
- package/dist/assets/{add-connection-dialog-D7EYSraq.js → add-connection-dialog-Qf63aKV6.js} +1 -1
- package/dist/assets/{agent-panel-aCWa3Yai.js → agent-panel-DMOfF3qF.js} +1 -1
- package/dist/assets/{ai-model-dropdown-bwTRyFn4.js → ai-model-dropdown-B15l0R62.js} +2 -2
- package/dist/assets/{app-config-button-DGhsM0xw.js → app-config-button-BIMB8qjD.js} +1 -1
- package/dist/assets/{blob-e6VlOmQP.js → blob-De9GR2s6.js} +1 -1
- package/dist/assets/{cell-editor-M8dEnDzk.js → cell-editor-Di0cSFhC.js} +32 -11
- package/dist/assets/{cell-link-DFqfW-Ym.js → cell-link-DR3W2HC7.js} +1 -1
- package/dist/assets/{cells-T9_Y4Jlv.js → cells-styV7IX8.js} +6 -6
- package/dist/assets/{chat-display-DXn2Yrjr.js → chat-display-BzdYdN39.js} +1 -1
- package/dist/assets/{chat-panel-D3iUyZId.js → chat-panel-De3YzkSF.js} +1 -1
- package/dist/assets/{chat-ui-YuJtv3UJ.js → chat-ui-NTNapdtP.js} +1 -1
- package/dist/assets/{code-visibility-CV3S4xuf.js → code-visibility-csc3tgA0.js} +1 -1
- package/dist/assets/{column-preview-C6uXRJry.js → column-preview-DkH-oD8f.js} +1 -1
- package/dist/assets/{command-palette-CGNUQdgW.js → command-palette-Dg_xstl0.js} +1 -1
- package/dist/assets/{common-DeeLgjWQ.js → common-D7VAS6rd.js} +1 -1
- package/dist/assets/{components-DyAF3_Nf.js → components-CNmvC781.js} +1 -1
- package/dist/assets/config-BQT0uYUo.js +1 -0
- package/dist/assets/{config-CjQ4WJnJ.js → config-BbRbT9Ww.js} +1 -1
- package/dist/assets/{datasource-gqFgG9Qd.js → datasource-C3yfeDa2.js} +1 -1
- package/dist/assets/{dependency-graph-panel-B3T9kSTs.js → dependency-graph-panel-CjoA6L0w.js} +1 -1
- package/dist/assets/{documentation-panel-BBpGbT-f.js → documentation-panel-DHWFOiG1.js} +1 -1
- package/dist/assets/{download-C8Gw-D0Y.js → download-BrCpRZKN.js} +1 -1
- package/dist/assets/{edit-page-CBftLPze.js → edit-page-BPMo_x-T.js} +4 -4
- package/dist/assets/{error-entries-uyqOG5tg.js → error-entries-BkEAmmnD.js} +1 -1
- package/dist/assets/{error-panel-Cli5zPWi.js → error-panel-BhTfPA_i.js} +1 -1
- package/dist/assets/feedback-button-BAcClv7c.js +1 -0
- package/dist/assets/{feedback-button-CvrwBGr7.js → feedback-button-D9InK87G.js} +1 -1
- package/dist/assets/{file-explorer-panel-BSU5ultY.js → file-explorer-panel-BSd_ZbUC.js} +1 -1
- package/dist/assets/{file-name-input-CDrRlIiX.js → file-name-input-RHURglL_.js} +1 -1
- package/dist/assets/{floating-outline-GQD9km0W.js → floating-outline-Cm49rYYe.js} +1 -1
- package/dist/assets/{gallery-page-B-5H1fEt.js → gallery-page-DdMdOtdv.js} +1 -1
- package/dist/assets/{glide-data-editor-B1kpoetH.js → glide-data-editor-eiSlEUyR.js} +1 -1
- package/dist/assets/{home-page-3qsPTb4v.js → home-page-DwWvBB0R.js} +1 -1
- package/dist/assets/{hooks-BrFYiTJS.js → hooks-CHeUZHPp.js} +1 -1
- package/dist/assets/{index-D0IWODMU.js → index-DckSn2w6.js} +8 -8
- package/dist/assets/{layout-CGC8ajpe.js → layout-_lp06T0C.js} +3 -3
- package/dist/assets/{logs-panel-CdUc5vtA.js → logs-panel-CAAk72Gb.js} +1 -1
- package/dist/assets/{markdown-renderer-pKc_bFac.js → markdown-renderer-CAyCgogC.js} +1 -1
- package/dist/assets/{name-cell-input-csH3Cy54.js → name-cell-input-DA8hU9XT.js} +1 -1
- package/dist/assets/{outline-panel-DhsHYTuo.js → outline-panel-Cc5oQ4LL.js} +1 -1
- package/dist/assets/{packages-panel-BtkXVz3L.js → packages-panel-DTfKez6I.js} +1 -1
- package/dist/assets/{panel-accordion-state-Bco6nsUI.js → panel-accordion-state-BZHex38W.js} +1 -1
- package/dist/assets/panels-DU-SaRHy.js +105 -0
- package/dist/assets/{process-output-B2-bT4cq.js → process-output-CrDc_O1D.js} +1 -1
- package/dist/assets/{readonly-code-display-Dsp6vWPh.js → readonly-code-display-BR-_jUj8.js} +1 -1
- package/dist/assets/{readonly-python-code-B81AjzXM.js → readonly-python-code-D7jcy9ds.js} +1 -1
- package/dist/assets/{reveal-component-Cxo3hLGA.js → reveal-component-eLftBwOe.js} +1 -1
- package/dist/assets/{run-page-CLP1s8uX.js → run-page-mURyATDJ.js} +1 -1
- package/dist/assets/{runtime-details-state-CznIe40L.js → runtime-details-state-hb7A1jgR.js} +1 -1
- package/dist/assets/{scratchpad-panel-yHIW63VQ.js → scratchpad-panel-B_gEnoqj.js} +1 -1
- package/dist/assets/{session-panel-C7-wmZhc.js → session-panel-DmDjaPsN.js} +1 -1
- package/dist/assets/{snippets-panel-BARpOPyS.js → snippets-panel-o9KL5jMi.js} +1 -1
- package/dist/assets/state-BkAqJoW7.js +3 -0
- package/dist/assets/{state-Bye6rCo4.js → state-Os7LSUUZ.js} +1 -1
- package/dist/assets/{terminal-Bhcn_y1N.js → terminal-BI85khrS.js} +1 -1
- package/dist/assets/{tracing-DDohxo24.js → tracing-AsNGuDsh.js} +1 -1
- package/dist/assets/{tracing-panel-DYhGDAo5.js → tracing-panel-CBcmea6L.js} +2 -2
- package/dist/assets/{tree-actions-Cb-nUK1F.js → tree-actions-Cx5EDpA6.js} +1 -1
- package/dist/assets/{useAddCell-Bielffe0.js → useAddCell-uJJYtgwa.js} +1 -1
- package/dist/assets/{useBoolean-CMgj9hnq.js → useBoolean-8wlrTeus.js} +1 -1
- package/dist/assets/{useCellActionButton-DAcQhse_.js → useCellActionButton-CmQ-OcPa.js} +1 -1
- package/dist/assets/{useDeleteCell-BV4VemCv.js → useDeleteCell-CXgOCDqY.js} +1 -1
- package/dist/assets/{useDependencyPanelTab-PtXIVh53.js → useDependencyPanelTab-Ch6gm7uM.js} +1 -1
- package/dist/assets/{useInstallPackage-C7neMPwh.js → useInstallPackage-CYQoMdMQ.js} +1 -1
- package/dist/assets/{useNotebookActions-DZBB98fP.js → useNotebookActions-DGShHZ_1.js} +1 -1
- package/dist/assets/{useRunCells-BFeZMi7f.js → useRunCells-DAfDmOMC.js} +1 -1
- package/dist/assets/{useSplitCell-DllkNFke.js → useSplitCell-NLULgcq7.js} +1 -1
- package/dist/assets/{vega-component-D7JFthDD.js → vega-component-BKJU3uaB.js} +1 -1
- package/dist/index.html +24 -24
- package/package.json +1 -1
- package/src/core/host/AGENTS.md +6 -5
- package/src/core/host/__tests__/notebook-client.test.ts +368 -350
- package/src/core/host/connection.ts +1 -40
- package/src/core/host/notebook-client.ts +129 -186
- package/src/core/wasm/bridge.ts +0 -8
- package/src/core/websocket/__tests__/connection-state.test.ts +0 -12
- package/src/core/websocket/__tests__/useNotebookClient.hook.test.tsx +133 -59
- package/src/core/websocket/__tests__/useNotebookSession.hook.test.tsx +152 -250
- package/src/core/websocket/connection-state.ts +0 -10
- package/src/core/websocket/transports/__tests__/notebook.test.ts +502 -0
- package/src/core/websocket/transports/notebook.ts +213 -0
- package/src/core/websocket/useNotebookClient.ts +28 -17
- package/dist/assets/config-DzdxZb17.js +0 -1
- package/dist/assets/feedback-button-DknbRCN_.js +0 -1
- package/dist/assets/panels-D1i80TGn.js +0 -107
- package/dist/assets/state-BRYi026f.js +0 -3
- package/dist/assets/ws-BXWY541V.js +0 -22
- package/src/core/host/__tests__/events.test.ts +0 -49
- package/src/core/host/events.ts +0 -68
- package/src/core/websocket/__tests__/createConnectionTransport.test.ts +0 -49
- package/src/core/websocket/transports/__tests__/basic.test.ts +0 -275
- package/src/core/websocket/transports/__tests__/sse.test.ts +0 -352
- package/src/core/websocket/transports/__tests__/transport.test.ts +0 -308
- package/src/core/websocket/transports/__tests__/ws.test.ts +0 -125
- package/src/core/websocket/transports/basic.ts +0 -102
- package/src/core/websocket/transports/create.ts +0 -31
- package/src/core/websocket/transports/sse.ts +0 -320
- package/src/core/websocket/transports/transport.ts +0 -50
- package/src/core/websocket/transports/ws.ts +0 -98
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{In as e,Z as t,b as n,fa as r,ma as i,pa as a}from"./cells-
|
|
1
|
+
import{In as e,Z as t,b as n,fa as r,ma as i,pa as a}from"./cells-styV7IX8.js";import{i as o}from"./strings-C25fhMR_.js";function s(e){if(a(e.mimetype)){if(!Array.isArray(e.data))return null;let t=e.data.filter(e=>!e.type.includes(`ancestor`));return t.length===0?null:{errorData:t}}return i(e.mimetype)?typeof e.data!=`string`||e.data.length===0?null:{errorData:[],tracebackHtml:e.data}:null}function c(e){return e.some(e=>`traceback`in e&&e.traceback)}function l(e){let t=e?.find(e=>i(e.mimetype));if(!(!t||typeof t.data!=`string`||t.data.length===0))return t.data}function u(e,t){if(e.tracebackHtml)return e.tracebackHtml;if(!c(e.errorData))return l(t)}function d(t){let{cellIds:i,cellRuntime:a,cellData:o}=t.get(n),c=[];for(let[t,n]of i.inOrderIds.entries()){let i=a[n],l=i.output;if(!l||!r(l.mimetype))continue;let d=s(l);if(!d)continue;let f=e(o[n].name,t),p=o[n].lastCodeRun??o[n].code;c.push({cellId:n,cellName:f,cellCode:p,errorData:d.errorData,tracebackHtml:u(d,i.consoleOutputs)})}return c}function f(e){return e.type===`setup-refs`?`The setup cell cannot have references`:e.type===`cycle`?`This cell is in a cycle`:e.type===`multiple-defs`?`The variable '${e.name}' was defined by another cell`:e.type===`import-star`||e.type===`ancestor-stopped`||e.type===`ancestor-prevented`||e.type===`exception`||e.type===`strict-exception`?e.msg:e.type===`interruption`?`This cell was interrupted and needs to be re-run`:e.type===`syntax`||e.type===`unknown`||e.type===`sql-error`?e.msg:e.type===`internal`?e.msg||`An internal error occurred`:(o(e),`Unknown error`)}function p(e){let n=f(e);return`traceback`in e&&e.traceback&&(n+=`\n\nTraceback:\n${t(e.traceback)}`),n}function m(e){let n=[e.cellName];return e.tracebackHtml&&n.push(t(e.tracebackHtml)),e.errorData.length>0&&n.push(e.errorData.map(p).join(`
|
|
2
2
|
|
|
3
3
|
`)),n.join(`
|
|
4
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime-B0Z9INg1.js";import{t as e}from"./react-DVplv7_D.js";import{A as t}from"./cells-
|
|
1
|
+
import"./rolldown-runtime-B0Z9INg1.js";import{t as e}from"./react-DVplv7_D.js";import{A as t}from"./cells-styV7IX8.js";import{t as n}from"./compiler-runtime-BrajqUja.js";import{t as r}from"./jsx-runtime-B74pBk57.js";import{t as i}from"./createLucideIcon-DfJ2oMlA.js";import{t as a}from"./MarimoErrorOutput-D-hLaDA-.js";import{n as o}from"./cell-link-DR3W2HC7.js";import{t as s}from"./empty-state-BaCKb7o3.js";var c=i(`party-popper`,[[`path`,{d:`M5.8 11.3 2 22l10.7-3.79`,key:`gwxi1d`}],[`path`,{d:`M4 3h.01`,key:`1vcuye`}],[`path`,{d:`M22 8h.01`,key:`1mrtc2`}],[`path`,{d:`M15 2h.01`,key:`1cjtqr`}],[`path`,{d:`M22 20h.01`,key:`1mrys2`}],[`path`,{d:`m22 2-2.24.75a2.9 2.9 0 0 0-1.96 3.12c.1.86-.57 1.63-1.45 1.63h-.38c-.86 0-1.6.6-1.76 1.44L14 10`,key:`hbicv8`}],[`path`,{d:`m22 13-.82-.33c-.86-.34-1.82.2-1.98 1.11c-.11.7-.72 1.22-1.43 1.22H17`,key:`1i94pl`}],[`path`,{d:`m11 2 .33.82c.34.86-.2 1.82-1.11 1.98C9.52 4.9 9 5.52 9 6.23V7`,key:`1cofks`}],[`path`,{d:`M11 13c1.93 1.93 2.83 4.17 2 5-.83.83-3.07-.07-5-2-1.93-1.93-2.83-4.17-2-5 .83-.83 3.07.07 5 2Z`,key:`4kbmks`}]]),l=n();e();var u=r(),d=()=>{let e=(0,l.c)(5),n=t();if(n.length===0){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,u.jsx)(s,{title:`No errors!`,icon:(0,u.jsx)(c,{})}),e[0]=t):t=e[0],t}let r;e[1]===n?r=e[2]:(r=n.map(f),e[1]=n,e[2]=r);let i;return e[3]===r?i=e[4]:(i=(0,u.jsx)(`div`,{className:`flex flex-col h-full overflow-auto`,children:r}),e[3]=r,e[4]=i),i};function f(e){return(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`div`,{className:`text-xs font-mono font-semibold bg-muted border-y px-2 py-1`,children:(0,u.jsx)(o,{cellId:e.cellId})}),(0,u.jsx)(`div`,{className:`px-2`,children:(0,u.jsx)(a,{errors:e.output.data,code:e.output.code,cellId:e.cellId},e.cellId)},e.cellId)]},e.cellId)}export{d as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./feedback-button-D9InK87G.js";export{e as FeedbackModal};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{l as t,r as n}from"./useEvent-Dfcbgjhg.js";import{t as r}from"./react-DVplv7_D.js";import{Bn as i,Pa as a,b as o,za as s}from"./cells-
|
|
1
|
+
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{l as t,r as n}from"./useEvent-Dfcbgjhg.js";import{t as r}from"./react-DVplv7_D.js";import{Bn as i,Pa as a,b as o,za as s}from"./cells-styV7IX8.js";import{t as c}from"./compiler-runtime-BrajqUja.js";import{n as l}from"./useEventListener-CjDeLqFC.js";import{r as u}from"./utils-B4K466FK.js";import{T as d,_ as f}from"./config-BQT0uYUo.js";import{c as p}from"./state-DaWgt-rn.js";import{t as m}from"./cn-ldLVeaqm.js";import{t as h}from"./jsx-runtime-B74pBk57.js";import{t as ee}from"./button-D8gVKwe-.js";import{t as te}from"./external-link-UrX9KO36.js";import{b as g}from"./write-secret-modal-7DzehGyr.js";import{Qt as ne,Xt as re,Yt as ie,tn as ae}from"./input-BZdRe7pb.js";import{t as oe}from"./triangle-alert-DmIqR8sY.js";import{t as se}from"./copy-icon-8-a5vovc.js";import{t as _}from"./strings-C25fhMR_.js";import{n as ce}from"./requests-lt0JK8Jt.js";import{n as le}from"./useAsyncData-DhhdOGGd.js";import{i as ue,n as de}from"./error-entries-BkEAmmnD.js";import{t as v}from"./skeleton-Cqh4O9g1.js";import{t as fe}from"./code-visibility-csc3tgA0.js";var y=e(r(),1),b=c(),x=h();function pe(e,t){return{...e,Binaries:{...e.Binaries,Browser:t}}}function me(e,t,n,r){return{marimo:e,Locale:n||void 0,Binaries:{Browser:t},"Environment Collection Error":r}}function S(e,t){let n=Math.max(2,...Array.from(t.matchAll(/`+/g),e=>e[0].length)),r="`".repeat(n+1);return`${r}${e}\n${t}\n${r}`}function he(e,t){let n=e.includes(`?`)?`&`:`?`,r=[],i=e,a=0;for(let[e,o]of Object.entries(t)){if(o.length===0)continue;let t=`${e}=${encodeURIComponent(o)}`,s=`${i}${a===0?n:`&`}${t}`;if(s.length>6e3){r.push(e);continue}i=s,a+=1}return{url:i,omitted:r}}function C(e,t){return[`<details>`,`<summary>${_.htmlEscape(e)??``}</summary>`,``,t,``,`</details>`].join(`
|
|
2
2
|
`)}function ge(e){return C(`Environment`,S(`json`,JSON.stringify(e,null,2)))}function _e(e){return C(`Errors`,S(`text`,e.map(de).join(`
|
|
3
3
|
|
|
4
4
|
---
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{c as t,f as n,l as r,t as i}from"./useEvent-Dfcbgjhg.js";import{t as a}from"./react-DVplv7_D.js";import{Cn as o,Ct as s,D as c,Et as l,Qr as u,Rt as d,St as f,Tt as p,_n as m,bt as h,fn as g,gn as _,lo as v,wt as y,xt as b,yt as x,za as S}from"./cells-T9_Y4Jlv.js";import{t as C}from"./react-dom-_LrxgvjW.js";import{t as w}from"./compiler-runtime-BrajqUja.js";import{f as T,h as E}from"./config-DGX7JYor.js";import{g as D}from"./useEventListener-CjDeLqFC.js";import{t as O}from"./invariant-Ci2dTZ72.js";import{r as k}from"./config-CjQ4WJnJ.js";import{N as A,k as j,r as M}from"./config-DzdxZb17.js";import{t as N}from"./cn-ldLVeaqm.js";import{t as P}from"./jsx-runtime-B74pBk57.js";import{o as F}from"./alert-dialog-C-sWmKva.js";import{a as I,c as L,p as R,r as z,t as B}from"./dropdown-menu-DS6umAnH.js";import{Ft as V,a as H,g as U,i as W,o as ee,s as G}from"./JsonOutput-Pm6OCP3J.js";import{c as te,n as ne,r as re}from"./download-C8Gw-D0Y.js";import{t as K}from"./tooltip-CkGm8X7m.js";import{t as q}from"./button-D8gVKwe-.js";import{t as J}from"./createLucideIcon-DfJ2oMlA.js";import{n as Y,t as X}from"./paths-bkIFVj8h.js";import{t as ie}from"./arrow-left-BaPN-xbg.js";import{n as ae}from"./LazyAnyLanguageCodeMirror-BPYE76jR.js";import{r as oe}from"./useNumberFormatter-D7O_26UI.js";import{a as se,i as ce,n as le,r as ue,t as de}from"./tree-actions-Cb-nUK1F.js";import{a as fe}from"./markdown-renderer-pKc_bFac.js";import{s as pe}from"./toDate-DOj9Q6uC.js";import{t as me}from"./copy-Djr5m5ac.js";import{t as he}from"./external-link-UrX9KO36.js";import{a as ge,i as _e,n as ve,r as ye,t as be}from"./file-icons-CdJgUy-I.js";import{t as xe}from"./file-BPBVl9pl.js";import{n as Se,t as Ce}from"./components-DrU8dOzy.js";import{b as we}from"./write-secret-modal-7DzehGyr.js";import{n as Te,t as Ee}from"./spinner-DyNE-o8o.js";import{a as De,c as Oe,d as ke,f as Ae,i as je,l as Me,m as Ne,n as Pe,p as Fe,r as Ie,t as Le,u as Re}from"./file-name-input-CDrRlIiX.js";import{t as ze}from"./refresh-cw-Qw1f8Jhy.js";import{t as Be}from"./save-Dgoim6QF.js";import{a as Ve}from"./input-BZdRe7pb.js";import{t as He}from"./triangle-alert-DmIqR8sY.js";import{n as Ue,t as We}from"./es-N9SHpmG7.js";import{n as Ge}from"./copy-KlhazlhB.js";import{t as Ke}from"./use-toast-Wu434mLr.js";import{t as qe}from"./copy-icon-8-a5vovc.js";import{Et as Je}from"./dist-Cny7_yZb.js";import{n as Ye,r as Xe,t as Ze}from"./requests-lt0JK8Jt.js";import{t as Qe}from"./I18nProvider-Cg2I_s1_.js";import{t as $e}from"./useDebounce-k9QTpQ9-.js";import{n as et}from"./useAsyncData-DhhdOGGd.js";import{t as tt}from"./blob-e6VlOmQP.js";import{a as nt}from"./errors-CNsgAw6m.js";import{n as rt,t as it}from"./alert-DTaqCu_d.js";import{n as at}from"./error-banner-B5kzVf_0.js";import{a as ot}from"./renderShortcut-H60uiHBp.js";import{t as st}from"./bundle.esm-D3tw5rqW.js";import{t as ct}from"./useAddCell-Bielffe0.js";import{n as lt}from"./pathUtils-DPmlLd-r.js";import{n as ut}from"./semaphore-BjoL5P0h.js";import{t as dt}from"./empty-state-BaCKb7o3.js";import{t as ft}from"./formatting-uom1es4b.js";import{a as pt,i as mt,n as ht,o as gt,r as _t,s as vt,t as yt}from"./components-DyAF3_Nf.js";import{n as bt,t as xt}from"./marimo-icons-CqliHyTr.js";import{t as St}from"./links-CXcpNIM0.js";import{n as Ct}from"./panel-accordion-state-Bco6nsUI.js";var wt=J(`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`}]]),Tt=J(`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`}]]),Et=J(`file-plus-corner`,[[`path`,{d:`M11.35 22H6a2 2 0 0 1-2-2V4a2 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 8v5.35`,key:`17jvcc`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M14 19h6`,key:`bvotb8`}],[`path`,{d:`M17 16v6`,key:`18yu1i`}]]),Dt=J(`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`}]]),Ot=J(`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`}]]),kt=J(`folder-root`,[[`path`,{d:`M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z`,key:`1fr9dc`}],[`circle`,{cx:`12`,cy:`13`,r:`2`,key:`1c1ljs`}],[`path`,{d:`M12 15v5`,key:`11xva1`}]]),At=J(`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`}]]),jt=J(`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`}]]),Mt=J(`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=e(a(),1),Q=w(),$=P(),Nt=e=>{let t=(0,Q.c)(17),{filename:n,filenameIcon:r,onBack:i,onRefresh:a,onDownload:o,actions:s}=e,c;t[0]===i?c=t[1]:(c=i&&(0,$.jsx)(K,{content:`Back to file list`,children:(0,$.jsx)(q,{variant:`text`,size:`xs`,onClick:i,children:(0,$.jsx)(ie,{className:`h-4 w-4`})})}),t[0]=i,t[1]=c);let l;t[2]!==n||t[3]!==r?(l=n?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5 flex-1 min-w-0 text-xs font-semibold truncate`,children:[r,n]}):(0,$.jsx)(`span`,{className:`flex-1`}),t[2]=n,t[3]=r,t[4]=l):l=t[4];let u;t[5]===a?u=t[6]:(u=a&&(0,$.jsx)(K,{content:`Refresh`,children:(0,$.jsx)(q,{variant:`text`,size:`xs`,onClick:a,children:(0,$.jsx)(ze,{className:`h-3.5 w-3.5`})})}),t[5]=a,t[6]=u);let d;t[7]===o?d=t[8]:(d=o&&(0,$.jsx)(K,{content:`Download`,children:(0,$.jsx)(q,{variant:`text`,size:`xs`,onClick:o,children:(0,$.jsx)(V,{className:`h-3.5 w-3.5`})})}),t[7]=o,t[8]=d);let f;t[9]!==s||t[10]!==u||t[11]!==d?(f=(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[u,s,d]}),t[9]=s,t[10]=u,t[11]=d,t[12]=f):f=t[12];let p;return t[13]!==c||t[14]!==l||t[15]!==f?(p=(0,$.jsxs)(`div`,{className:`flex items-center shrink-0 border-b px-1 gap-1`,children:[c,l,f]}),t[13]=c,t[14]=l,t[15]=f,t[16]=p):p=t[16],p},Pt=new Set([`http`,`file`,`in-memory`]);function Ft(e){return JSON.stringify(e).slice(1,-1)}var It=new Set([`datasets`,`spaces`,`buckets`]);function Lt(e){let t=e.split(`/`).filter(Boolean);return t[0]===`datasets`&&t.length>=4?{repoType:`dataset`,repoId:`${t[1]}/${t[2]}`,filename:t.slice(3).join(`/`)}:t[0]===`spaces`&&t.length>=4?{repoType:`space`,repoId:`${t[1]}/${t[2]}`,filename:t.slice(3).join(`/`)}:t.length>=3&&!It.has(t[0])?{repoType:`model`,repoId:`${t[0]}/${t[1]}`,filename:t.slice(2).join(`/`)}:null}function Rt(e){return`from huggingface_hub import hf_hub_download\n\nlocal_path = hf_hub_download(\n repo_id="${Ft(e.repoId)}",\n filename="${Ft(e.filename)}",\n repo_type="${Ft(e.repoType)}",\n)`}var zt=[{id:`read-file`,label:`Insert read snippet`,icon:wt,getCode:e=>{if(e.entry.kind===`directory`)return null;let t=Ft(e.entry.path);if(e.backendType===`huggingface`){let t=Lt(e.entry.path);return t?`${Rt(t)}\n\nwith open(local_path, "rb") as f:\n _data = f.read()\n_data`:null}return e.backendType===`obstore`?`_data = ${e.variableName}.get("${t}").bytes()\n_data`:`_data = ${e.variableName}.cat_file("${t}")\n_data`}},{id:`download-file`,label:`Insert download snippet`,icon:Dt,getCode:e=>{if(e.entry.kind===`directory`)return null;let t=Ft(e.entry.path);if(e.backendType===`huggingface`){let t=Lt(e.entry.path);return t?`${Rt(t)}\nlocal_path`:null}if(e.backendType===`obstore`)return Pt.has(e.protocol)?null:`from datetime import timedelta\nfrom obstore import sign\n\nsigned_url = sign(\n ${e.variableName}, "GET", "${t}",\n expires_in=timedelta(hours=1),\n)\nsigned_url`;let n=Ft(e.entry.path.split(`/`).pop()||`download`);return`${e.variableName}.get("${t}", "${n}")`}}],Bt=104857600;function Vt(e){let t=e.endsWith(`/`)?e.slice(0,-1):e,n=t.split(`/`);return n[n.length-1]||t}var Ht=e=>{let t=(0,Q.c)(83),{entry:n,namespace:r,protocol:i,backendType:a,onBack:o}=e,{locale:s}=Qe(),c=ct(),u;t[0]===n.path?u=t[1]:(u=Vt(n.path),t[0]=n.path,t[1]=u);let d=u,f=n.mimeType||`text/plain`,p;t[2]===f?p=t[3]:(p=G(f),t[2]=f,t[3]=p);let m=p,h=m&&n.size>Bt&&n.size>0,g,_;t[4]!==n.path||t[5]!==m||t[6]!==r||t[7]!==h?(g=async()=>{if(h)return null;let e=await l.request({namespace:r,path:n.path,preview:!m});if(e.error)throw Error(e.error);if(!e.url)throw Error(`No URL returned`);if(m)return{type:`media`,url:e.url};let t=await fetch(e.url);if(!t.ok)throw Error(`Failed to fetch preview: ${t.statusText}`);return{type:`text`,content:await t.text()}},_=[r,n.path,m,h],t[4]=n.path,t[5]=m,t[6]=r,t[7]=h,t[8]=g,t[9]=_):(g=t[8],_=t[9]);let{data:v,isPending:y,error:b,refetch:x}=et(g,_),S;t[10]!==n.path||t[11]!==d||t[12]!==r?(S=async()=>{try{let e=await l.request({namespace:r,path:n.path});if(e.error){Ke({title:`Download failed`,description:e.error,variant:`danger`});return}e.url&&re(e.url,e.filename??d)}catch(e){let t=e;D.error(`Failed to download storage entry`,t),Ke({title:`Download failed`,description:String(t),variant:`danger`})}},t[10]=n.path,t[11]=d,t[12]=r,t[13]=S):S=t[13];let C=S,w;t[14]!==c||t[15]!==a||t[16]!==n||t[17]!==r||t[18]!==i?(w=zt.map(e=>{let t=e.getCode({variableName:r,protocol:i,entry:n,backendType:a});if(t===null)return null;let o=e.icon;return(0,$.jsx)(K,{content:e.label,children:(0,$.jsx)(q,{variant:`text`,size:`xs`,onClick:()=>c(t),"aria-label":e.label,children:(0,$.jsx)(o,{className:`h-3.5 w-3.5`})})},e.id)}),t[14]=c,t[15]=a,t[16]=n,t[17]=r,t[18]=i,t[19]=w):w=t[19];let T=w,E;t[20]===d?E=t[21]:(E=_e(d),t[20]=d,t[21]=E);let O;t[22]!==C||t[23]!==d||t[24]!==o||t[25]!==T||t[26]!==E?(O=(0,$.jsx)(Nt,{filename:d,filenameIcon:E,onBack:o,onDownload:C,actions:T}),t[22]=C,t[23]=d,t[24]=o,t[25]=T,t[26]=E,t[27]=O):O=t[27];let k=O,A;t[28]!==n.lastModified||t[29]!==n.path||t[30]!==n.size||t[31]!==s||t[32]!==f?(A=e=>{let{includeMime:t}=e,r=t!==void 0&&t;return(0,$.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 p-4 text-xs`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground font-medium`,children:`Path`}),(0,$.jsxs)(`div`,{className:`truncate flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`font-mono text-[11px]`,children:n.path}),(0,$.jsx)(qe,{value:n.path,className:`h-3 w-3`})]}),r&&(0,$.jsx)(`span`,{className:`text-muted-foreground font-medium`,children:`Type`}),r&&(0,$.jsx)(`span`,{children:f}),n.size>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-muted-foreground font-medium`,children:`Size`}),(0,$.jsx)(`span`,{children:ft(n.size,s)})]}),n.lastModified!=null&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-muted-foreground font-medium`,children:`Modified`}),(0,$.jsx)(`span`,{children:new Date(n.lastModified*1e3).toLocaleString()})]})]})},t[28]=n.lastModified,t[29]=n.path,t[30]=n.size,t[31]=s,t[32]=f,t[33]=A):A=t[33];let j=A;if(h){let e;t[34]===j?e=t[35]:(e=j({includeMime:!0}),t[34]=j,t[35]=e);let r;t[36]!==n.size||t[37]!==s?(r=ft(n.size,s),t[36]=n.size,t[37]=s,t[38]=r):r=t[38];let i;t[39]===r?i=t[40]:(i=(0,$.jsxs)(`div`,{className:`px-4 pb-4 text-xs text-muted-foreground italic`,children:[`File is too large to preview (`,r,`).`]}),t[39]=r,t[40]=i);let a;return t[41]!==k||t[42]!==e||t[43]!==i?(a=(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[k,e,i]}),t[41]=k,t[42]=e,t[43]=i,t[44]=a):a=t[44],a}if(y){let e;t[45]===j?e=t[46]:(e=j({}),t[45]=j,t[46]=e);let n;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`flex-1 flex items-center justify-center gap-2 text-xs text-muted-foreground min-h-24`,children:[(0,$.jsx)(Te,{className:`h-4 w-4 animate-spin`}),`Loading preview...`]}),t[47]=n):n=t[47];let r;return t[48]!==k||t[49]!==e?(r=(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[k,e,n]}),t[48]=k,t[49]=e,t[50]=r):r=t[50],r}if(b){let e;t[51]===j?e=t[52]:(e=j({includeMime:!0}),t[51]=j,t[52]=e);let n;t[53]===b.message?n=t[54]:(n=(0,$.jsxs)(`div`,{className:`px-4 pb-4 text-xs text-destructive`,children:[`Failed to load preview: `,b.message]}),t[53]=b.message,t[54]=n);let r;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(ze,{className:`h-3 w-3 mr-1`}),t[55]=r):r=t[55];let i;t[56]===x?i=t[57]:(i=(0,$.jsx)(`div`,{className:`px-4 pb-4`,children:(0,$.jsxs)(q,{variant:`secondary`,size:`xs`,onClick:x,children:[r,`Retry`]})}),t[56]=x,t[57]=i);let a;return t[58]!==k||t[59]!==e||t[60]!==n||t[61]!==i?(a=(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[k,e,n,i]}),t[58]=k,t[59]=e,t[60]=n,t[61]=i,t[62]=a):a=t[62],a}if(v){let e;t[63]===j?e=t[64]:(e=j({}),t[63]=j,t[64]=e);let n=v.type===`text`?v.content:void 0,r;t[65]!==v.type||t[66]!==v.url?(r=v.type===`media`?{url:v.url}:void 0,t[65]=v.type,t[66]=v.url,t[67]=r):r=t[67];let i;t[68]!==f||t[69]!==d||t[70]!==n||t[71]!==r?(i=(0,$.jsx)(W,{mimeType:f,filename:d,contents:n,mediaSource:r}),t[68]=f,t[69]=d,t[70]=n,t[71]=r,t[72]=i):i=t[72];let a;return t[73]!==k||t[74]!==e||t[75]!==i?(a=(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[k,e,i]}),t[73]=k,t[74]=e,t[75]=i,t[76]=a):a=t[76],a}let M;t[77]===j?M=t[78]:(M=j({includeMime:!0}),t[77]=j,t[78]=M);let N;t[79]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsxs)(`div`,{className:`p-4 flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(xe,{className:`h-4 w-4`}),`Preview not available for this file type.`]}),t[79]=N):N=t[79];let P;return t[80]!==k||t[81]!==M?(P=(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[k,M,N]}),t[80]=k,t[81]=M,t[82]=P):P=t[82],P},Ut=16;function Wt(e){return{paddingLeft:e*Ut}}function Gt(e,t){return new Date(e*1e3).toLocaleDateString(t,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function Kt(e){let t=e.endsWith(`/`)?e.slice(0,-1):e,n=t.split(`/`);return n[n.length-1]||t}function qt(e){return e.endsWith(`/`)?e:`${e}/`}function Jt(e,t){let n=e.metadata?.id;return typeof n==`string`&&n.length>0?n:`${e.path}::${t}`}function Yt(e,{namespace:t,searchValue:n,entriesByPath:r}){let i=n.trim().toLowerCase(),a=e.path.toLowerCase();if(Kt(e.path).toLowerCase().includes(i)||a.includes(i))return!0;if(e.kind===`directory`){let i=r.get(p(t,qt(e.path)));if(i)return i.some(e=>Yt(e,{namespace:t,searchValue:n,entriesByPath:r}))}return!1}function Xt(e,t){return t.searchValue.trim()?e.filter(e=>Yt(e,t)):e}var Zt=5;function Qt(e){return{query:e,status:`idle`}}function $t(e){return e.status===`idle`||e.status===`error`||e.status===`capped`}function en(e,t,n){return t.get(e)===void 0||n.get(e)?.nextPageToken!=null}function tn({hasSearch:e,hasLoadedMatches:t,isPending:n,remoteSearch:r,searchKey:i,entriesByPath:a,pageMetadataByPath:o}){return!e||t||n||!$t(r)?!1:en(i,a,o)}function nn(e){let t=e.trim(),n=t.lastIndexOf(`/`);return n===-1?``:t.slice(0,n+1)}function rn(e,t){let n=t.trim().toLowerCase();return!n||e.path.toLowerCase().includes(n)||Kt(e.path).toLowerCase().includes(n)}var an=e=>{let t=(0,Q.c)(15),{depth:n,isLoading:r,error:i,onLoadMore:a}=e,o;t[0]===n?o=t[1]:(o=Wt(n),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=r&&(0,$.jsx)(Te,{className:`h-3 w-3 mr-1 animate-spin`}),t[2]=r,t[3]=s);let c=r?`Loading...`:`Load more`,l;t[4]!==r||t[5]!==a||t[6]!==s||t[7]!==c?(l=(0,$.jsxs)(q,{variant:`text`,size:`xs`,className:`h-6 px-0 hover:text-blue-600`,disabled:r,onClick:a,children:[s,c]}),t[4]=r,t[5]=a,t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===i?u=t[10]:(u=i&&(0,$.jsxs)(`span`,{className:`ml-2 text-destructive`,children:[`Failed to load: `,i.message]}),t[9]=i,t[10]=u);let d;return t[11]!==o||t[12]!==l||t[13]!==u?(d=(0,$.jsxs)(`div`,{className:`py-px text-xs`,style:o,children:[l,u]}),t[11]=o,t[12]=l,t[13]=u,t[14]=d):d=t[14],d},on=e=>{let t=(0,Q.c)(44),{namespace:n,protocol:r,rootPath:i,backendType:a,prefix:o,depth:c,locale:l,searchValue:u,onOpenFile:d}=e,{entriesByPath:f}=b(),{entries:p,isPending:m,error:h,hasMore:g,loadMore:_,isLoadingMore:v,loadMoreError:y}=s(n,o);if(m){let e;t[0]===c?e=t[1]:(e=Wt(c),t[0]=c,t[1]=e);let n;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(Te,{className:`h-3 w-3 animate-spin`}),t[2]=n):n=t[2];let r;return t[3]===e?r=t[4]:(r=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 py-1 text-xs text-muted-foreground`,style:e,children:[n,`Loading...`]}),t[3]=e,t[4]=r),r}if(h){let e;t[5]===c?e=t[6]:(e=Wt(c),t[5]=c,t[6]=e);let n;return t[7]!==h.message||t[8]!==e?(n=(0,$.jsxs)(`div`,{className:`py-1 text-xs text-destructive`,style:e,children:[`Failed to load: `,h.message]}),t[7]=h.message,t[8]=e,t[9]=n):n=t[9],n}if(p.length===0){let e;t[10]===c?e=t[11]:(e=Wt(c),t[10]=c,t[11]=e);let n;return t[12]===e?n=t[13]:(n=(0,$.jsx)(`div`,{className:`py-1 text-xs text-muted-foreground italic`,style:e,children:`Empty`}),t[12]=e,t[13]=n),n}let x;if(t[14]!==a||t[15]!==p||t[16]!==c||t[17]!==f||t[18]!==l||t[19]!==n||t[20]!==d||t[21]!==r||t[22]!==i||t[23]!==u){let e=Xt(p,{namespace:n,searchValue:u,entriesByPath:f}),o;t[25]!==a||t[26]!==p||t[27]!==c||t[28]!==l||t[29]!==n||t[30]!==d||t[31]!==r||t[32]!==i||t[33]!==u?(o=e=>{let t=Jt(e,p.indexOf(e));return(0,$.jsx)(sn,{rowKey:t,entry:e,namespace:n,protocol:r,rootPath:i,backendType:a,depth:c,locale:l,searchValue:u,onOpenFile:d},t)},t[25]=a,t[26]=p,t[27]=c,t[28]=l,t[29]=n,t[30]=d,t[31]=r,t[32]=i,t[33]=u,t[34]=o):o=t[34],x=e.map(o),t[14]=a,t[15]=p,t[16]=c,t[17]=f,t[18]=l,t[19]=n,t[20]=d,t[21]=r,t[22]=i,t[23]=u,t[24]=x}else x=t[24];let S;t[35]!==c||t[36]!==g||t[37]!==v||t[38]!==_||t[39]!==y?(S=g&&(0,$.jsx)(an,{depth:c,isLoading:v,error:y,onLoadMore:_}),t[35]=c,t[36]=g,t[37]=v,t[38]=_,t[39]=y,t[40]=S):S=t[40];let C;return t[41]!==x||t[42]!==S?(C=(0,$.jsxs)($.Fragment,{children:[x,S]}),t[41]=x,t[42]=S,t[43]=C):C=t[43],C},sn=e=>{let t=(0,Q.c)(115),{entry:n,rowKey:r,namespace:i,protocol:a,rootPath:o,backendType:s,depth:c,locale:u,searchValue:d,onOpenFile:f}=e,[h,g]=(0,Z.useState)(!1),{entriesByPath:_}=b(),v=ct(),y=n.kind===`directory`,x,S,C,w,T,E,O,k,A,j,M;if(t[0]!==s||t[1]!==c||t[2]!==_||t[3]!==n||t[4]!==y||t[5]!==h||t[6]!==i||t[7]!==f||t[8]!==a||t[9]!==r||t[10]!==d){w=Kt(n.path);let e;t[22]===d?e=t[23]:(e=d.trim(),t[22]=d,t[23]=e);let o=!!e;T=y&&o&&w.toLowerCase().includes(d.trim().toLowerCase());let u;t[24]!==_||t[25]!==n.path||t[26]!==o||t[27]!==y||t[28]!==i||t[29]!==d?(u=y&&o&&!!_.get(p(i,qt(n.path)))?.some(e=>Yt(e,{namespace:i,searchValue:d,entriesByPath:_})),t[24]=_,t[25]=n.path,t[26]=o,t[27]=y,t[28]=i,t[29]=d,t[30]=u):u=t[30],S=h||u;let v;t[31]!==n.path||t[32]!==i?(v=async()=>{try{let e=await l.request({namespace:i,path:n.path});if(e.error){Ke({title:`Download failed`,description:e.error,variant:`danger`});return}e.url&&re(e.url,e.filename??`download`)}catch(e){let t=e;D.error(`Failed to download storage entry`,t),Ke({title:`Download failed`,description:String(t),variant:`danger`})}},t[31]=n.path,t[32]=i,t[33]=v):v=t[33],C=v,x=m;let b=y&&`font-medium`;t[34]===b?E=t[35]:(E=N(`text-xs flex items-center gap-1.5 cursor-pointer rounded-none group h-6.5`,b),t[34]=b,t[35]=E),t[36]===c?O=t[37]:(O=Wt(c),t[36]=c,t[37]=O),k=`${i}:${r}`,t[38]!==s||t[39]!==S||t[40]!==n||t[41]!==y||t[42]!==i||t[43]!==f||t[44]!==a?(A=()=>{y?g(!S):f({entry:n,namespace:i,protocol:a,backendType:s})},t[38]=s,t[39]=S,t[40]=n,t[41]=y,t[42]=i,t[43]=f,t[44]=a,t[45]=A):A=t[45],t[46]!==S||t[47]!==y?(j=y?(0,$.jsx)(ce,{isExpanded:S,className:`h-3 w-3`}):(0,$.jsx)(`span`,{className:`w-3 shrink-0`}),t[46]=S,t[47]=y,t[48]=j):j=t[48],M=y?(0,$.jsx)(ge,{className:N(`h-3.5 w-3.5 shrink-0`,ve.directory)}):_e(w),t[0]=s,t[1]=c,t[2]=_,t[3]=n,t[4]=y,t[5]=h,t[6]=i,t[7]=f,t[8]=a,t[9]=r,t[10]=d,t[11]=x,t[12]=S,t[13]=C,t[14]=w,t[15]=T,t[16]=E,t[17]=O,t[18]=k,t[19]=A,t[20]=j,t[21]=M}else x=t[11],S=t[12],C=t[13],w=t[14],T=t[15],E=t[16],O=t[17],k=t[18],A=t[19],j=t[20],M=t[21];let P;t[49]===w?P=t[50]:(P=(0,$.jsx)(`span`,{className:`truncate flex-1 text-left`,children:w}),t[49]=w,t[50]=P);let F;t[51]!==n.size||t[52]!==u?(F=n.size>0&&(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground pr-2 tabular-nums`,children:ft(n.size,u)}),t[51]=n.size,t[52]=u,t[53]=F):F=t[53];let H;t[54]!==n.lastModified||t[55]!==u?(H=n.lastModified!=null&&(0,$.jsx)(K,{content:`Last modified: ${new Date(n.lastModified*1e3).toLocaleString()}`,children:(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground pr-1 whitespace-nowrap`,children:Gt(n.lastModified,u)})}),t[54]=n.lastModified,t[55]=u,t[56]=H):H=t[56];let U;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(le,{iconClassName:`h-3 w-3`,onClick:un})}),t[57]=U):U=t[57];let W;t[58]!==s||t[59]!==n||t[60]!==y||t[61]!==i||t[62]!==f||t[63]!==a?(W=!y&&(0,$.jsxs)(I,{onSelect:()=>f({entry:n,namespace:i,protocol:a,backendType:s}),children:[(0,$.jsx)(Mt,{className:`h-3.5 w-3.5 mr-2`}),`View`]}),t[58]=s,t[59]=n,t[60]=y,t[61]=i,t[62]=f,t[63]=a,t[64]=W):W=t[64];let ee;t[65]===n.path?ee=t[66]:(ee=async()=>{await Ge(n.path),Ke({title:`Copied to clipboard`})},t[65]=n.path,t[66]=ee);let G;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,$.jsx)(me,{className:de}),t[67]=G):G=t[67];let te;t[68]===ee?te=t[69]:(te=(0,$.jsxs)(I,{onSelect:ee,children:[G,`Copy path`]}),t[68]=ee,t[69]=te);let ne;t[70]!==C||t[71]!==y?(ne=!y&&(0,$.jsxs)(I,{onSelect:()=>C(),children:[(0,$.jsx)(V,{className:`h-3.5 w-3.5 mr-2`}),`Download`]}),t[70]=C,t[71]=y,t[72]=ne):ne=t[72];let q;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,$.jsx)(L,{}),t[73]=q):q=t[73];let J;t[74]!==v||t[75]!==s||t[76]!==n||t[77]!==i||t[78]!==a?(J=zt.map(e=>{let t=e.getCode({variableName:i,protocol:a,entry:n,backendType:s});if(t===null)return null;let r=e.icon;return(0,$.jsxs)(I,{onSelect:()=>v(t),children:[(0,$.jsx)(r,{className:de}),e.label]},e.id)}),t[74]=v,t[75]=s,t[76]=n,t[77]=i,t[78]=a,t[79]=J):J=t[79];let Y;t[80]!==W||t[81]!==te||t[82]!==ne||t[83]!==J?(Y=(0,$.jsxs)(B,{children:[U,(0,$.jsxs)(z,{align:`end`,onClick:dn,onCloseAutoFocus:fn,children:[W,te,ne,q,J]})]}),t[80]=W,t[81]=te,t[82]=ne,t[83]=J,t[84]=Y):Y=t[84];let X;t[85]!==Y||t[86]!==F||t[87]!==H?(X=(0,$.jsxs)(`div`,{className:`flex items-center`,children:[F,H,Y]}),t[85]=Y,t[86]=F,t[87]=H,t[88]=X):X=t[88];let ie;t[89]!==x||t[90]!==E||t[91]!==X||t[92]!==O||t[93]!==k||t[94]!==A||t[95]!==j||t[96]!==M||t[97]!==P?(ie=(0,$.jsxs)(x,{className:E,style:O,value:k,onSelect:A,children:[j,M,P,X]}),t[89]=x,t[90]=E,t[91]=X,t[92]=O,t[93]=k,t[94]=A,t[95]=j,t[96]=M,t[97]=P,t[98]=ie):ie=t[98];let ae;t[99]!==s||t[100]!==c||t[101]!==S||t[102]!==n.path||t[103]!==y||t[104]!==u||t[105]!==i||t[106]!==f||t[107]!==a||t[108]!==o||t[109]!==d||t[110]!==T?(ae=y&&S&&(0,$.jsx)(on,{namespace:i,protocol:a,rootPath:o,backendType:s,prefix:qt(n.path),depth:c+1,locale:u,searchValue:T?``:d,onOpenFile:f}),t[99]=s,t[100]=c,t[101]=S,t[102]=n.path,t[103]=y,t[104]=u,t[105]=i,t[106]=f,t[107]=a,t[108]=o,t[109]=d,t[110]=T,t[111]=ae):ae=t[111];let oe;return t[112]!==ie||t[113]!==ae?(oe=(0,$.jsxs)($.Fragment,{children:[ie,ae]}),t[112]=ie,t[113]=ae,t[114]=oe):oe=t[114],oe},cn=e=>{let t=(0,Q.c)(66),{namespace:n,locale:r,searchValue:i,remoteSearch:a,onContinueRemoteSearch:o,onOpenFile:c}=e,[l,u]=(0,Z.useState)(!0),{entriesByPath:d,pageMetadataByPath:h}=b(),{clearNamespaceCache:g}=f(),_=n.name??n.displayName,{entries:v,isPending:y,error:x,hasMore:S,loadMore:C,isLoadingMore:w,loadMoreError:T,refetch:E}=s(_),D;t[0]!==g||t[1]!==_||t[2]!==E?(D=e=>{e.stopPropagation(),g(_),E()},t[0]=g,t[1]=_,t[2]=E,t[3]=D):D=t[3];let O=D,k=y?n.storageEntries:v,A;if(t[4]!==k||t[5]!==d||t[6]!==x||t[7]!==O||t[8]!==S||t[9]!==l||t[10]!==w||t[11]!==y||t[12]!==C||t[13]!==T||t[14]!==r||t[15]!==n.backendType||t[16]!==n.displayName||t[17]!==n.name||t[18]!==n.protocol||t[19]!==n.rootPath||t[20]!==_||t[21]!==o||t[22]!==c||t[23]!==h||t[24]!==a||t[25]!==i){let e=Xt(k,{namespace:_,searchValue:i,entriesByPath:d}),s=nn(i),f=p(_,s),g=s===``?[]:d.get(f)??[],v=Xt(g,{namespace:_,searchValue:i,entriesByPath:d}),b;t[27]===i?b=t[28]:(b=i.trim(),t[27]=i,t[28]=b);let E=!!b,D=e.length>0||v.length>0,j=s!==``&&tn({hasSearch:E,hasLoadedMatches:D,isPending:y,remoteSearch:a,searchKey:f,entriesByPath:d,pageMetadataByPath:h}),M=E&&e.length===0,N;bb0:{if(y&&k.length===0){let e;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(Te,{className:`h-3 w-3 animate-spin`}),`Loading...`]}),t[29]=e):e=t[29],N=e;break bb0}if(a.status===`searching`){let e;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(Te,{className:`h-3 w-3 animate-spin`}),`Searching more entries...`]}),t[30]=e):e=t[30],N=e;break bb0}if(a.status===`error`){let e;t[31]===a.error.message?e=t[32]:(e=(0,$.jsxs)(`span`,{className:`text-destructive`,children:[`Search failed: `,a.error.message]}),t[31]=a.error.message,t[32]=e),N=e;break bb0}if(a.status===`capped`){let e;t[33]===o?e=t[34]:(e=(0,$.jsx)(q,{variant:`text`,size:`xs`,className:`h-5 px-0 text-xs hover:text-blue-600`,onClick:o,children:`Continue searching`}),t[33]=o,t[34]=e);let n;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`span`,{className:`text-[10px]`,children:`(or press Enter)`}),t[35]=n):n=t[35];let r;t[36]===e?r=t[37]:(r=(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Searched more entries.`,e,n]}),t[36]=e,t[37]=r),N=r;break bb0}if(a.status===`exhausted`&&!D){N=`No matches`;break bb0}if(!E&&!y&&k.length===0){N=`No entries`;break bb0}if(j){let e;t[38]===o?e=t[39]:(e=(0,$.jsx)(q,{variant:`text`,size:`xs`,className:`h-5 px-0 text-xs hover:text-blue-600`,onClick:o,children:`Search more entries`}),t[38]=o,t[39]=e);let n;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`span`,{className:`text-[10px]`,children:`(or press Enter)`}),t[40]=n):n=t[40];let r;t[41]===e?r=t[42]:(r=(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`No loaded matches.`,e,n]}),t[41]=e,t[42]=r),N=r;break bb0}if(E&&!D&&k.length>0){N=`No matches`;break bb0}N=null}let P=N,F;t[43]===l?F=t[44]:(F=()=>u(!l),t[43]=l,t[44]=F);let I;t[45]===l?I=t[46]:(I=(0,$.jsx)(ce,{isExpanded:l,className:`h-3 w-3`}),t[45]=l,t[46]=I);let L;t[47]===n.protocol?L=t[48]:(L=(0,$.jsx)(Ce,{protocol:n.protocol}),t[47]=n.protocol,t[48]=L);let R;t[49]===n.displayName?R=t[50]:(R=(0,$.jsx)(`span`,{children:n.displayName}),t[49]=n.displayName,t[50]=R);let z;t[51]===n.name?z=t[52]:(z=n.name&&(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground font-normal`,children:[`(`,(0,$.jsx)(vt,{variableName:n.name}),`)`]}),t[51]=n.name,t[52]=z);let B;t[53]===O?B=t[54]:(B=(0,$.jsx)(ue,{onClick:O,tooltip:`Refresh storage connection`,className:`p-0`,iconClassName:`h-3 w-3`}),t[53]=O,t[54]=B);let V=n.rootPath||`(root)`,H;t[55]===V?H=t[56]:(H=(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground font-normal tabular-nums ml-auto`,children:V}),t[55]=V,t[56]=H);let W;t[57]!==n.name||t[58]!==B||t[59]!==H||t[60]!==F||t[61]!==I||t[62]!==L||t[63]!==R||t[64]!==z?(W=(0,$.jsxs)(m,{value:n.name,onSelect:F,className:`flex flex-row font-semibold h-7 text-xs gap-1.5 bg-(--slate-2) text-muted-foreground rounded-none`,children:[I,L,R,z,B,H]}),t[57]=n.name,t[58]=B,t[59]=H,t[60]=F,t[61]=I,t[62]=L,t[63]=R,t[64]=z,t[65]=W):W=t[65],A=(0,$.jsxs)($.Fragment,{children:[W,l&&(0,$.jsxs)($.Fragment,{children:[x&&k.length===0&&(0,$.jsx)(U,{error:x,style:Wt(1),className:`py-1 text-xs h-auto overflow-auto max-h-32 items-start`,showIcon:!1}),!x&&P&&(0,$.jsx)(`div`,{className:`py-1 text-xs text-muted-foreground italic`,style:Wt(1),children:P}),e.map(e=>{let t=Jt(e,k.indexOf(e));return(0,$.jsx)(sn,{rowKey:t,entry:e,namespace:_,protocol:n.protocol,rootPath:n.rootPath,backendType:n.backendType,depth:1,locale:r,searchValue:i,onOpenFile:c},t)}),M&&v.map(e=>{let t=Jt(e,g.indexOf(e));return(0,$.jsx)(sn,{rowKey:`remote-search:${t}`,entry:e,namespace:_,protocol:n.protocol,rootPath:n.rootPath,backendType:n.backendType,depth:1,locale:r,searchValue:i,onOpenFile:c},`remote-search:${t}`)}),S&&!j&&(0,$.jsx)(an,{depth:1,isLoading:w,error:T,onLoadMore:C})]})]}),t[4]=k,t[5]=d,t[6]=x,t[7]=O,t[8]=S,t[9]=l,t[10]=w,t[11]=y,t[12]=C,t[13]=T,t[14]=r,t[15]=n.backendType,t[16]=n.displayName,t[17]=n.name,t[18]=n.protocol,t[19]=n.rootPath,t[20]=_,t[21]=o,t[22]=c,t[23]=h,t[24]=a,t[25]=i,t[26]=A}else A=t[26];return A},ln=()=>{let e=(0,Q.c)(63),{namespaces:t,entriesByPath:n,pageMetadataByPath:r}=b(),{locale:i}=Qe(),[a,s]=(0,Z.useState)(``),c;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(c={},e[0]=c):c=e[0];let[l,u]=(0,Z.useState)(c),[d,f]=(0,Z.useState)(null),m=y(),h;e[1]===a?h=e[2]:(h=a.trim(),e[1]=a,e[2]=h);let v=!!h,x;e[3]===a?x=e[4]:(x=a.trim(),e[3]=a,e[4]=x);let S=x,C;e[5]!==S||e[6]!==l?(C=e=>{let t=l[e];return t?.query===S?t:Qt(S)},e[5]=S,e[6]=l,e[7]=C):C=e[7];let w=C,T;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(T=(e,t)=>{u(n=>({...n,[e]:t}))},e[8]=T):T=e[8];let E=T,D;e[9]!==S||e[10]!==n||e[11]!==r||e[12]!==w?(D=e=>{if(!S)return!1;let t=e.name??e.displayName,i=nn(S);if(i===``||!$t(w(t))||Xt(n.get(p(t,``))??e.storageEntries,{namespace:t,searchValue:S,entriesByPath:n}).length>0)return!1;let a=p(t,i);return Xt(n.get(a)??[],{namespace:t,searchValue:S,entriesByPath:n}).length>0?!1:en(a,n,r)},e[9]=S,e[10]=n,e[11]=r,e[12]=w,e[13]=D):D=e[13];let O=D,k;e[14]!==O||e[15]!==S||e[16]!==n||e[17]!==m||e[18]!==r?(k=async e=>{if(!O(e))return;let t=S,i=e.name??e.displayName,a=nn(t),o=p(i,a),s=n.get(o),c=r.get(o)?.nextPageToken??null,l=s!==void 0;E(i,{query:t,status:`searching`});try{for(let e=0;e<Zt;e++){let e=!l||c!==null,n=[];if(e){let e=await m({namespace:i,prefix:a,pageToken:c,append:l});n=e.entries,c=e.next_page_token??null,l=!0}if((e?n:s??[]).some(e=>rn(e,t))){E(i,{query:t,status:`found`});return}if(c===null){E(i,{query:t,status:`exhausted`});return}}E(i,{query:t,status:`capped`})}catch(e){let n=e;E(i,{query:t,status:`error`,error:n instanceof Error?n:Error(String(n))})}},e[14]=O,e[15]=S,e[16]=n,e[17]=m,e[18]=r,e[19]=k):k=e[19];let A=k,j;e[20]!==O||e[21]!==A||e[22]!==t?(j=()=>{let e=t.filter(O);for(let t of e)A(t)},e[20]=O,e[21]=A,e[22]=t,e[23]=j):j=e[23];let M=j;if(t.length===0){let t;return e[24]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(dt,{title:`No storage connected`,description:(0,$.jsxs)(`span`,{children:[`Create an obstore or fsspec connection in your notebook. See the`,` `,(0,$.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`}),`.`]}),action:(0,$.jsx)(gt,{group:`storage`,label:`Add remote storage`,variant:`outline`,size:`sm`}),icon:(0,$.jsx)(Se,{className:`h-8 w-8`})}),e[24]=t):t=e[24],t}let P;e[25]===d?P=e[26]:(P=d&&(0,$.jsx)(Ht,{entry:d.entry,namespace:d.namespace,protocol:d.protocol,backendType:d.backendType,onBack:()=>f(null)}),e[25]=d,e[26]=P);let F=d&&`hidden`,I;e[27]===F?I=e[28]:(I=N(`border-b bg-background rounded-none h-full pb-10 overflow-auto outline-hidden scrollbar-thin`,F),e[27]=F,e[28]=I);let L;e[29]!==O||e[30]!==M||e[31]!==t?(L=e=>{e.key===`Enter`&&t.some(O)&&(e.preventDefault(),M())},e[29]=O,e[30]=M,e[31]=t,e[32]=L):L=e[32];let R;e[33]!==a||e[34]!==L?(R=(0,$.jsx)(_,{placeholder:`Search entries...`,className:`h-6 m-1`,value:a,onValueChange:s,onKeyDown:L,rootClassName:`flex-1 border-b-0`}),e[33]=a,e[34]=L,e[35]=R):R=e[35];let z;e[36]===v?z=e[37]:(z=v&&(0,$.jsx)(q,{variant:`text`,size:`xs`,className:`float-right border-none px-2 m-0 h-full`,onClick:()=>s(``),children:(0,$.jsx)(oe,{className:`h-4 w-4`})}),e[36]=v,e[37]=z);let B,V;e[38]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(K,{content:`Search by file name within loaded entries, or by prefix (e.g. 'folder/x') for backend search. Press Enter to fetch more results.`,delayDuration:200,children:(0,$.jsx)(pe,{className:`h-3.5 w-3.5 shrink-0 cursor-help text-muted-foreground hover:text-foreground mr-2`})}),V=(0,$.jsx)(gt,{group:`storage`,label:`Add remote storage`,compact:!0,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`}),e[38]=B,e[39]=V):(B=e[38],V=e[39]);let H;e[40]!==R||e[41]!==z?(H=(0,$.jsxs)(`div`,{className:`flex items-center w-full border-b`,children:[R,z,B,V]}),e[40]=R,e[41]=z,e[42]=H):H=e[42];let U;if(e[43]!==A||e[44]!==i||e[45]!==t||e[46]!==w||e[47]!==a){let n;e[49]!==A||e[50]!==i||e[51]!==w||e[52]!==a?(n=e=>{let t=e.name??e.displayName;return(0,$.jsx)(cn,{namespace:e,locale:i,searchValue:a,remoteSearch:w(t),onContinueRemoteSearch:()=>void A(e),onOpenFile:f},t)},e[49]=A,e[50]=i,e[51]=w,e[52]=a,e[53]=n):n=e[53],U=t.map(n),e[43]=A,e[44]=i,e[45]=t,e[46]=w,e[47]=a,e[48]=U}else U=e[48];let W;e[54]===U?W=e[55]:(W=(0,$.jsx)(o,{className:`flex flex-col`,children:U}),e[54]=U,e[55]=W);let ee;e[56]!==I||e[57]!==H||e[58]!==W?(ee=(0,$.jsxs)(g,{className:I,shouldFilter:!1,children:[H,W]}),e[56]=I,e[57]=H,e[58]=W,e[59]=ee):ee=e[59];let G;return e[60]!==ee||e[61]!==P?(G=(0,$.jsxs)(`div`,{className:`h-full flex flex-col`,children:[P,ee]}),e[60]=ee,e[61]=P,e[62]=G):G=e[62],G};function un(e){return e.stopPropagation()}function dn(e){return e.stopPropagation()}function fn(e){return e.preventDefault()}var pn=(0,Z.createContext)(null);function mn(){return(0,Z.useContext)(pn)??void 0}var hn=e=>{let t=(0,Q.c)(3),{children:n}=e,r=Fe(),i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(pn.Provider,{value:r,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i},gn=e=>{let t=(0,Q.c)(5),{children:n}=e,[r,i]=(0,Z.useState)(null),a;t[0]!==n||t[1]!==r?(a=r&&(0,$.jsx)(Ne,{backend:ke,options:{rootElement:r},children:(0,$.jsx)(hn,{children:n})}),t[0]=n,t[1]=r,t[2]=a):a=t[2];let o;return t[3]===a?o=t[4]:(o=(0,$.jsx)(`div`,{ref:i,className:`contents`,children:a}),t[3]=a,t[4]=o),o},_n=e(C(),1),vn=200;function yn({query:e,tree:t,showHiddenFiles:n}){let{sendSearchFiles:r}=Xe(),i=$e(e,300),a=(0,Z.useRef)(null),[o,s]=(0,Z.useState)(0),c=(0,Z.useCallback)(()=>s(e=>e+1),[]),l=(0,Z.useMemo)(()=>({query:e,tree:t,showHiddenFiles:n,revision:o,sendSearchFiles:r}),[e,t,n,o,r]),[u,d]=(0,Z.useState)();return(0,Z.useEffect)(()=>{let{query:e,tree:t,showHiddenFiles:n,sendSearchFiles:r}=l,o=!1;if(!e||e!==i)return;let s=(a.current??Promise.resolve()).then(async()=>{let i=new Map,a=!1,s=0,c=t.getRoots();for(let t of c){if(o)return;try{let o=await r({query:e,path:t.path,includeFiles:!0,includeDirectories:!0,includeHidden:n,depth:20,limit:vn});a||=o.files.length>=vn;for(let e of o.files){let n=i.get(e.path);n&&(!t.isPrimary||n.isPrimaryRoot)||i.set(e.path,{...e,id:Me(t.path,e.path),children:[],isRoot:!1,rootPath:t.path,isPrimaryRoot:t.isPrimary})}}catch{s+=1}}if(!o){if(c.length>0&&s===c.length){d({requestIdentity:l,state:{status:`error`,query:e,error:Error(`Could not search any root`)}});return}let t=t=>{let n=t.name.toLowerCase(),r=e.toLowerCase();return n===r?0:n.startsWith(r)?1:2},n=[...i.values()].toSorted((e,n)=>t(e)-t(n)||e.name.localeCompare(n.name));d({requestIdentity:l,state:{status:`success`,isPartial:s>0,query:e,files:n.slice(0,vn),hasMore:a||n.length>vn}})}});return a.current=s.catch(t=>{o||d({requestIdentity:l,state:{status:`error`,query:e,error:t}})}),()=>{o=!0}},[i,l]),e?e!==i||u?.requestIdentity!==l?{state:{status:`loading`,query:e},refetch:c}:{state:u.state,refetch:c}:{state:{status:`idle`},refetch:c}}function bn(e,t){let n=(0,Q.c)(7),r=e.tree,i=(0,Z.useRef)(null),a,o;n[0]!==t||n[1]!==e.data.isDirectory||n[2]!==e.id||n[3]!==e.isOpen||n[4]!==r?(a=()=>{if(!t){i.current=null;return}if(!e.data.isDirectory||e.isOpen||i.current===e.id)return;let n=window.setTimeout(()=>{i.current=e.id,r.open(e.id)},600);return()=>window.clearTimeout(n)},o=[t,e.data.isDirectory,e.isOpen,e.id,r],n[0]=t,n[1]=e.data.isDirectory,n[2]=e.id,n[3]=e.isOpen,n[4]=r,n[5]=a,n[6]=o):(a=n[5],o=n[6]),(0,Z.useEffect)(a,o)}async function xn(e,t){if(!A()){let n=M().formatNavigableHttpURL(`api/files/download`,new URLSearchParams({path:e}));re(n.toString(),t);return}let n=await Ze().sendFileDetails({path:e});if(n.isBase64&&n.contents){let e=tt(fe(n.contents,n.mimeType||`application/octet-stream`));ne(e,t)}else ne(new Blob([n.contents||``],{type:n.mimeType||`application/octet-stream`}),t)}var Sn=e=>{let t=(0,Q.c)(21),{file:n,mimeType:r,message:i,onDownload:a}=e,{locale:o}=Qe(),s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(`span`,{className:`text-muted-foreground font-medium`,children:`Path`}),t[0]=s):s=t[0];let c;t[1]===n.path?c=t[2]:(c=(0,$.jsx)(`span`,{className:`font-mono text-xs break-all`,children:n.path}),t[1]=n.path,t[2]=c);let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`span`,{className:`text-muted-foreground font-medium`,children:`Type`}),t[3]=l):l=t[3];let u;t[4]===r?u=t[5]:(u=(0,$.jsx)(`span`,{children:r}),t[4]=r,t[5]=u);let d;t[6]!==n.size||t[7]!==o?(d=n.size!=null&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-muted-foreground font-medium`,children:`Size`}),(0,$.jsx)(`span`,{children:ft(n.size,o)})]}),t[6]=n.size,t[7]=o,t[8]=d):d=t[8];let f;t[9]!==c||t[10]!==u||t[11]!==d?(f=(0,$.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr] gap-x-4 gap-y-2`,children:[s,c,l,u,d]}),t[9]=c,t[10]=u,t[11]=d,t[12]=f):f=t[12];let p;t[13]===i?p=t[14]:(p=(0,$.jsx)(`div`,{className:`mt-4 text-muted-foreground italic`,children:i}),t[13]=i,t[14]=p);let m;t[15]===a?m=t[16]:(m=a&&(0,$.jsxs)(q,{variant:`outline`,size:`sm`,className:`mt-4`,onClick:a,children:[(0,$.jsx)(V,{className:`h-3.5 w-3.5 mr-2`}),`Download`]}),t[15]=a,t[16]=m);let h;return t[17]!==f||t[18]!==p||t[19]!==m?(h=(0,$.jsxs)(`div`,{className:`p-4 text-sm`,children:[f,p,m]}),t[17]=f,t[18]=p,t[19]=m,t[20]=h):h=t[20],h};function Cn(e,t){let n=e||`text/plain`;return G(n)?`media`:t?`unsupported`:n===`text/csv`?`csv`:n.startsWith(`text/`)||n!=="default"&&n in H||e==null?`text`:`unsupported`}var wn=10485760,Tn=new Map,En=e=>{let t=(0,Q.c)(91),{file:n,onOpenNotebook:i}=e,{sendFileDetails:a,sendUpdateFile:o}=Xe(),s=r(E),c=r(T),l=r(S),[u,d]=(0,Z.useState)(``),f;t[0]!==n.path||t[1]!==a?(f=async()=>{let e=await a({path:n.path,maxBytes:wn}),t=Cn(e.mimeType,e.isBase64);if(!e.isTooLarge&&t===`text`){let t=e.contents||``;d(Tn.get(n.path)??t)}return e},t[0]=n.path,t[1]=a,t[2]=f):f=t[2];let p;t[3]===n.path?p=t[4]:(p=[n.path],t[3]=n.path,t[4]=p);let{data:m,isPending:h,error:g,setData:_,refetch:v}=et(f,p),y;t[5]!==m?.contents||t[6]!==n.path||t[7]!==u||t[8]!==o||t[9]!==_?(y=async()=>{u!==m?.contents&&await o({path:n.path,contents:u}).then(e=>{e.success&&(_(e=>({...e,contents:u})),d(u))})},t[5]=m?.contents,t[6]=n.path,t[7]=u,t[8]=o,t[9]=_,t[10]=y):y=t[10];let b=y,x=(0,Z.useRef)(u),C,w;t[11]===u?(C=t[12],w=t[13]):(C=()=>{x.current=u},w=[u],t[11]=u,t[12]=C,t[13]=w),(0,Z.useLayoutEffect)(C,w);let D;t[14]!==m||t[15]!==n.path?(D=()=>()=>{if(m?.contents==null||m.isTooLarge||Cn(m.mimeType,m.isBase64)!==`text`)return;let e=x.current;e===m.contents?Tn.delete(n.path):Tn.set(n.path,e)},t[14]=m,t[15]=n.path,t[16]=D):D=t[16];let O=m?.contents,k=m?.isTooLarge,j=m?.mimeType,M=m?.isBase64,N;if(t[17]!==n.path||t[18]!==M||t[19]!==O||t[20]!==k||t[21]!==j?(N=[n.path,O,k,j,M],t[17]=n.path,t[18]=M,t[19]=O,t[20]=k,t[21]=j,t[22]=N):N=t[22],(0,Z.useEffect)(D,N),g){let e;return t[23]===g?e=t[24]:(e=(0,$.jsx)(at,{error:g}),t[23]=g,t[24]=e),e}if(h||!m)return null;let P=m.mimeType||`text/plain`,F;t[25]!==m.isBase64||t[26]!==m.mimeType?(F=Cn(m.mimeType,m.isBase64),t[25]=m.isBase64,t[26]=m.mimeType,t[27]=F):F=t[27];let I=F,L=I===`text`,R=I===`csv`,z=I===`media`,B;t[28]!==l||t[29]!==m.file.isMarimoFile||t[30]!==n.path?(B=l&&m.file.isMarimoFile&&(n.path===l||n.path.endsWith(`/${l}`)),t[28]=l,t[29]=m.file.isMarimoFile,t[30]=n.path,t[31]=B):B=t[31];let V=B,H;t[32]!==m.file.name||t[33]!==n.path?(H=async()=>{await xn(n.path,m.file.name)},t[32]=m.file.name,t[33]=n.path,t[34]=H):H=t[34];let U=H,G;if(t[35]!==m.contents||t[36]!==b||t[37]!==s||t[38]!==u){let e;t[40]!==m.contents||t[41]!==b||t[42]!==u?(e=()=>u!==m.contents&&(b(),!0),t[40]=m.contents,t[41]=b,t[42]=u,t[43]=e):e=t[43],G=Je.of([{key:s.getHotkey(`global.save`).key,stopPropagation:!0,run:e}]),t[35]=m.contents,t[36]=b,t[37]=s,t[38]=u,t[39]=G}else G=t[39];let te=G,ne=c?void 0:U,re;t[44]!==m.file.isMarimoFile||t[45]!==i?(re=m.file.isMarimoFile&&i&&!A()&&(0,$.jsx)(K,{content:`Open notebook`,children:(0,$.jsx)(q,{variant:`text`,size:`xs`,"aria-label":`Open notebook`,onClick:e=>i(e),children:(0,$.jsx)(he,{className:`h-3.5 w-3.5`})})}),t[44]=m.file.isMarimoFile,t[45]=i,t[46]=re):re=t[46];let J;t[47]!==m.contents||t[48]!==b||t[49]!==u||t[50]!==L?(J=L&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{content:`Copy contents to clipboard`,children:(0,$.jsx)(q,{variant:`text`,size:`xs`,onClick:async()=>{await Ge(u)},children:(0,$.jsx)(me,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(K,{content:ot(`global.save`),children:(0,$.jsx)(q,{variant:`text`,size:`xs`,onClick:b,disabled:u===m.contents,children:(0,$.jsx)(Be,{className:`h-3.5 w-3.5`})})})]}),t[47]=m.contents,t[48]=b,t[49]=u,t[50]=L,t[51]=J):J=t[51];let Y;t[52]!==re||t[53]!==J?(Y=(0,$.jsxs)($.Fragment,{children:[re,J]}),t[52]=re,t[53]=J,t[54]=Y):Y=t[54];let X;t[55]!==m.file.name||t[56]!==v||t[57]!==ne||t[58]!==Y?(X=(0,$.jsx)(Nt,{filename:m.file.name,onRefresh:v,onDownload:ne,actions:Y}),t[55]=m.file.name,t[56]=v,t[57]=ne,t[58]=Y,t[59]=X):X=t[59];let ie=X;if(m.isTooLarge||I===`unsupported`){let e=m.isTooLarge?`File is too large to preview.`:`This file type cannot be previewed.`,n=c?void 0:U,r;t[60]!==m.file||t[61]!==P||t[62]!==e||t[63]!==n?(r=(0,$.jsx)(Sn,{file:m.file,mimeType:P,message:e,onDownload:n}),t[60]=m.file,t[61]=P,t[62]=e,t[63]=n,t[64]=r):r=t[64];let i;return t[65]!==ie||t[66]!==r?(i=(0,$.jsxs)($.Fragment,{children:[ie,r]}),t[65]=ie,t[66]=r,t[67]=i):i=t[67],i}let ae;t[68]!==V||t[69]!==L?(ae=L&&V&&(0,$.jsxs)(it,{variant:`warning`,className:`rounded-none`,children:[(0,$.jsx)(He,{className:`h-4 w-4`}),(0,$.jsx)(rt,{children:`Editing the notebook file directly while running in marimo's editor may cause unintended changes. Please use with caution.`})]}),t[68]=V,t[69]=L,t[70]=ae):ae=t[70];let oe=ae,se;t[71]!==m.contents||t[72]!==m.isBase64||t[73]!==z||t[74]!==P?(se=z&&m.contents?ee({contents:m.contents,mimeType:P,isBase64:m.isBase64??!1}):void 0,t[71]=m.contents,t[72]=m.isBase64,t[73]=z,t[74]=P,t[75]=se):se=t[75];let ce=se,le=L?u:R?m.contents??void 0:void 0,ue=!L,de=L?d:void 0,fe;t[76]!==L||t[77]!==te?(fe=L?[te]:[],t[76]=L,t[77]=te,t[78]=fe):fe=t[78];let pe;t[79]!==m.file.name||t[80]!==ce||t[81]!==P||t[82]!==le||t[83]!==ue||t[84]!==de||t[85]!==fe?(pe=(0,$.jsx)(W,{mimeType:P,filename:m.file.name,contents:le,mediaSource:ce,readOnly:ue,onChange:de,extensions:fe}),t[79]=m.file.name,t[80]=ce,t[81]=P,t[82]=le,t[83]=ue,t[84]=de,t[85]=fe,t[86]=pe):pe=t[86];let ge;return t[87]!==ie||t[88]!==pe||t[89]!==oe?(ge=(0,$.jsxs)($.Fragment,{children:[ie,oe,pe]}),t[87]=ie,t[88]=pe,t[89]=oe,t[90]=ge):ge=t[90],ge};function Dn({node:e,attrs:t,innerRef:n,children:r,ariaLabel:i=e.data.name}){return(0,$.jsx)(`div`,{...t,ref:n,"aria-label":i,"aria-expanded":e.isInternal?e.isOpen:void 0,onFocus:n=>{n.stopPropagation(),t.onFocus?.(n),n.target===n.currentTarget&&!e.isFocused&&e.focus()},onClick:n=>{t.onClick?t.onClick(n):e.select(),n.defaultPrevented||n.currentTarget.focus({preventScroll:!0})},children:r})}function On(e){let t=(0,Q.c)(25),{treeRef:n,search:r,height:i,onReveal:a}=e,o=mn(),{state:s,refetch:c}=r;if(s.status===`idle`)return null;if(s.status===`error`){let e;return t[0]===c?e=t[1]:(e=(0,$.jsxs)(`div`,{role:`alert`,className:`px-3 py-2 text-sm`,children:[`Could not search files.`,` `,(0,$.jsx)(`button`,{type:`button`,className:`underline`,onClick:c,children:`Retry`})]}),t[0]=c,t[1]=e),e}if(s.status===`loading`){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 px-3 py-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(Ee,{size:`small`}),`Searching files…`]}),t[2]=e):e=t[2],e}let{files:l,hasMore:u,isPartial:d}=s,f=l.length,p;t[3]===n?p=t[4]:(p=e=>{e.key===`Enter`&&e.target instanceof HTMLElement&&e.target.closest(`[role="tree"]`)&&(e.preventDefault(),e.stopPropagation(),n.current?.focusedNode?.activate())},t[3]=n,t[4]=p);let m;t[5]!==d||t[6]!==c?(m=d&&(0,$.jsxs)(`div`,{role:`alert`,className:`px-3 py-2 text-xs text-muted-foreground`,children:[`Some locations could not be searched.`,` `,(0,$.jsx)(`button`,{type:`button`,className:`underline`,onClick:c,children:`Retry`})]}),t[5]=d,t[6]=c,t[7]=m):m=t[7];let h=l.length?`${f} ${f===1?`match`:`matches`}`:`No matching files or folders.`,g=u&&` · Refine your search for more results.`,_;t[8]!==h||t[9]!==g?(_=(0,$.jsxs)(`p`,{role:`status`,className:`px-3 py-2 text-xs text-muted-foreground`,children:[h,g]}),t[8]=h,t[9]=g,t[10]=_):_=t[10];let v=Math.max(0,i-48-(d?48:0)),y;t[11]===a?y=t[12]:(y=e=>{a(e.data)},t[11]=a,t[12]=y);let b;t[13]!==o||t[14]!==l||t[15]!==v||t[16]!==y||t[17]!==n?(b=(0,$.jsx)(Re,{ref:n,data:l,childrenAccessor:kn,width:`100%`,height:v,rowHeight:48,overscanCount:8,dndManager:o,disableDrag:!0,disableDrop:!0,disableEdit:!0,disableMultiSelection:!0,selectionFollowsFocus:!0,rowClassName:`outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring`,renderRow:An,onActivate:y,children:jn}),t[13]=o,t[14]=l,t[15]=v,t[16]=y,t[17]=n,t[18]=b):b=t[18];let x;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(`p`,{className:`px-3 text-xs text-muted-foreground`,children:`Enter or double-click to open · Esc to clear`}),t[19]=x):x=t[19];let S;return t[20]!==p||t[21]!==m||t[22]!==_||t[23]!==b?(S=(0,$.jsxs)(`div`,{onKeyDownCapture:p,children:[m,_,b,x]}),t[20]=p,t[21]=m,t[22]=_,t[23]=b,t[24]=S):S=t[24],S}function kn(){return null}function An(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(Dn,{...e,ariaLabel:e.node.data.path}),t[0]=e,t[1]=n),n}function jn(e){let t=(0,Q.c)(19),{node:n}=e,r=n.data.isDirectory?ge:xe,i=n.isSelected&&`bg-accent/60`,a;t[0]===i?a=t[1]:(a=N(`flex h-full items-start gap-2.5 px-3 py-1 cursor-pointer hover:bg-accent/50`,i),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=e=>{e.stopPropagation(),n.activate()},t[2]=n,t[3]=o);let s;t[4]===r?s=t[5]:(s=(0,$.jsx)(r,{className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`}),t[4]=r,t[5]=s);let c;t[6]===n.data.name?c=t[7]:(c=(0,$.jsx)(`div`,{className:`truncate text-sm leading-5`,children:n.data.name}),t[6]=n.data.name,t[7]=c);let l;t[8]===n.data.path?l=t[9]:(l=(0,$.jsx)(`div`,{className:`truncate text-xs leading-4 text-muted-foreground`,children:n.data.path}),t[8]=n.data.path,t[9]=l);let u;t[10]!==c||t[11]!==l?(u=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[c,l]}),t[10]=c,t[11]=l,t[12]=u):u=t[12];let d;return t[13]!==n.data.path||t[14]!==a||t[15]!==o||t[16]!==s||t[17]!==u?(d=(0,$.jsxs)(`div`,{className:a,onDoubleClick:o,title:n.data.path,children:[s,u]}),t[13]=n.data.path,t[14]=a,t[15]=o,t[16]=s,t[17]=u,t[18]=d):d=t[18],d}function Mn(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=e.node.data.isDirectory?(0,$.jsx)(Nn,{...e}):(0,$.jsx)(Dn,{...e}),t[0]=e,t[1]=n),n}function Nn(e){let t=(0,Q.c)(15),{node:n}=e,r=n.tree,i=(0,Z.useRef)(null),a;t[0]!==n||t[1]!==r?(a=()=>({accept:`NODE`,canDrop:()=>r.canDrop(),collect:Pn,hover:()=>{(r.state.dnd.parentId!==n.id||r.state.dnd.index!==null)&&r.dispatch({type:`DND_HOVERING`,parentId:n.id,index:null}),r.canDrop()||r.hideCursor()},drop:()=>{r.canDrop()&&(r.props.onMove?.({dragIds:r.state.dnd.dragIds,dragNodes:r.dragNodes,parentId:n.id,parentNode:n,index:0}),r.open(n.id))}}),t[0]=n,t[1]=r,t[2]=a):a=t[2];let o;t[3]!==n.id||t[4]!==r?(o=[r,n.id],t[3]=n.id,t[4]=r,t[5]=o):o=t[5];let[s,c]=Ae(a,o),{isHovering:l}=s;bn(n,l);let u,d;t[6]!==n.isEditing||t[7]!==n.isFocused?(u=()=>{n.isFocused&&!n.isEditing&&i.current?.focus({preventScroll:!0})},d=[n.isFocused,n.isEditing],t[6]=n.isEditing,t[7]=n.isFocused,t[8]=u,t[9]=d):(u=t[8],d=t[9]),(0,Z.useEffect)(u,d);let f;t[10]===c?f=t[11]:(f=e=>{i.current=e,c(e)},t[10]=c,t[11]=f);let p;return t[12]!==e||t[13]!==f?(p=(0,$.jsx)(Dn,{...e,innerRef:f}),t[12]=e,t[13]=f,t[14]=p):p=t[14],p}function Pn(e){return{isHovering:e.isOver({shallow:!0})&&e.canDrop()}}var Fn=n(e=>{let t=e(Ye);return O(t,`no requestClientAtom set`),new Oe({getRoots:t.getFileRoots,listFiles:t.sendListFiles,createFileOrFolder:t.sendCreateFileOrFolder,deleteFileOrFolder:t.sendDeleteFileOrFolder,copyFileOrFolder:t.sendCopyFileOrFolder,renameFileOrFolder:t.sendRenameFileOrFolder})}),In=n({}),Ln=` `,Rn={directory:e=>`os.listdir("${e}")`,python:e=>`with open("${e}", "r") as _f:\n${Ln}...\n`,json:e=>`with open("${e}", "r") as _f:\n${Ln}_data = json.load(_f)\n`,code:e=>`with open("${e}", "r") as _f:\n${Ln}...\n`,text:e=>`with open("${e}", "r") as _f:\n${Ln}...\n`,image:e=>`mo.image("${e}")`,audio:e=>`mo.audio("${e}")`,video:e=>`mo.video("${e}")`,pdf:e=>`with open("${e}", "rb") as _f:\n${Ln}...\n`,zip:e=>`with open("${e}", "rb") as _f:\n${Ln}...\n`,data:e=>`with open("${e}", "r") as _f:\n${Ln}...\n`,unknown:e=>`with open("${e}", "r") as _f:\n${Ln}...\n`},zn=104857600,Bn=5,Vn=`data-file-explorer-directory-path`;function Hn(e){let{destinationPath:t,getDestinationLabel:n=e=>e,onUploadStart:r,refreshDestination:i,...a}=e,{sendCreateFileOrFolder:o}=Xe();return We({multiple:!0,maxSize:zn,...a,onError:e=>{D.error(e),Ke({title:`File upload failed`,description:e.message,variant:`danger`})},onDropRejected:e=>{Ke({title:`File upload failed`,description:(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,children:e.map(e=>(0,$.jsxs)(`div`,{children:[e.file.name,` (`,e.errors.map(e=>e.message).join(`, `),`)`]},e.file.name))}),variant:`danger`})},onDrop:async(e,a,s)=>{if(e.length===0)return;let c=typeof t==`function`?t(s):t,l=n(c),u=e.length===1?`Uploading file to ${l}...`:`Uploading files to ${l}...`;r?.(c,e);let d;try{d=await te(u,async t=>(t.addTotal(e.length),Un({files:e,destinationPath:c,createFile:o,onFileProcessed:()=>t.increment(1)})))}catch{await i(c);return}await i(c),Kn(d,l)}})}async function Un({files:e,destinationPath:t,createFile:n,onFileProcessed:r}){let i=await ut(e,Bn,async e=>{try{return{file:e,response:await n({path:Wn({destinationPath:t,filePath:Jn(qn(e))}),type:`file`,name:e.name,file:e})}}catch(t){return{file:e,response:{success:!1,message:nt(t)}}}finally{r?.()}});return{successful:i.filter(({response:e})=>e.success),failed:i.filter(({response:e})=>!e.success)}}function Wn({destinationPath:e,filePath:t}){if(!t)return e;if(Y.isAbsolute(t))throw Error(`Upload path must be relative: ${t}`);let n=t.split(/[\\/]+/).slice(0,-1).filter(Boolean);if(n.includes(`..`))throw Error(`Upload path cannot contain parent traversal: ${t}`);let r=n.filter(e=>e!==`.`);if(r.length===0)return e;let i=X.guessDeliminator(e),a=r.join(i.deliminator);return i.join(e,a)}function Gn(e,t){return e instanceof Element&&e.closest(`[${Vn}]`)?.getAttribute(Vn)||t}function Kn(e,t){let n=e.successful.length+e.failed.length;if(e.failed.length>0){let r;r=e.successful.length===0?n===1?`File upload failed`:`Files failed to upload`:`${e.successful.length} of ${n} files uploaded`,Ke({title:r,description:(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`div`,{children:[`Destination: `,t,`.`]}),e.failed.map(({file:e,response:t},n)=>(0,$.jsxs)(`div`,{children:[e.name,`:`,` `,t.message||`The server rejected the upload.`]},`${e.name}-${n}`))]}),variant:`danger`});return}let r=e.successful.filter(({file:e,response:t})=>t.info?.name&&t.info.name!==e.name);Ke({title:n===1?`File uploaded`:`${n} files uploaded`,description:r.length===0?`Uploaded to ${t}.`:(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`div`,{children:[`Uploaded to `,t,`.`]}),r.map(({file:e,response:t},n)=>(0,$.jsxs)(`div`,{children:[e.name,` was saved as `,t.info?.name,`.`]},`${e.name}-${n}`))]})})}function qn(e){if(e.webkitRelativePath)return e.webkitRelativePath;if(`path`in e&&typeof e.path==`string`)return e.path;if(`relativePath`in e&&typeof e.relativePath==`string`)return e.relativePath}function Jn(e){if(e)return e.replace(/^\/+/,``)}var Yn=j(`marimo:showHiddenFiles`,!0,u,{getOnInit:!0}),Xn=Z.createContext(null),Zn=e=>{let n=(0,Q.c)(157),{height:r,externalDropDestinationPath:a}=e,o=a===void 0?null:a,s=(0,Z.useRef)(null),c=(0,Z.useRef)(null),l=(0,Z.useRef)(null),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(null),m=mn(),[h]=t(Fn),g;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=[],n[0]=g):g=n[0];let[_,v]=(0,Z.useState)(g),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(null),[C,w]=t(Yn),T;n[1]===u?T=n[2]:(T=u.trim(),n[1]=u,n[2]=T);let E;n[3]!==C||n[4]!==T||n[5]!==h?(E={query:T,tree:h,showHiddenFiles:C},n[3]=C,n[4]=T,n[5]=h,n[6]=E):E=n[6];let D=yn(E),[O,k]=t(In),A;n[7]===h?A=n[8]:(A=e=>h.refreshPath(e),n[7]=h,n[8]=A);let j=i(A),M=(0,Z.useRef)(``),N;n[9]===Symbol.for(`react.memo_cache_sentinel`)?(N=()=>M.current,n[9]=N):N=n[9];let P;n[10]===h?P=n[11]:(P=e=>ir(h,e),n[10]=h,n[11]=P);let I;n[12]!==j||n[13]!==P?(I={noClick:!0,noDrag:!0,noKeyboard:!0,destinationPath:N,getDestinationLabel:P,refreshDestination:j},n[12]=j,n[13]=P,n[14]=I):I=n[14];let{getInputProps:L,open:R}=Hn(I),z;n[15]===R?z=n[16]:(z=e=>{M.current=e,R()},n[15]=R,n[16]=z);let B=i(z),{openPrompt:V,openConfirm:H}=we(),U;n[17]===h?U=n[18]:(U=()=>h.initialize(v),n[17]=h,n[18]=U);let W;n[19]===Symbol.for(`react.memo_cache_sentinel`)?(W=[],n[19]=W):W=n[19];let{isPending:ee,error:G}=et(U,W),te;n[20]!==O||n[21]!==D||n[22]!==h?(te=async()=>{await h.refreshAll(Object.keys(O).filter(e=>O[e])),D.refetch()},n[20]=O,n[21]=D,n[22]=h,n[23]=te):te=n[23];let ne=i(te),re;n[24]!==w||n[25]!==C?(re=()=>{w(!C)},n[24]=w,n[25]=C,n[26]=re):re=n[26];let K=i(re),J;n[27]!==V||n[28]!==x?.id||n[29]!==h?(J=async()=>{V({title:`Folder name`,onConfirm:async e=>{h.createFolder(e,x?.id??null)}})},n[27]=V,n[28]=x?.id,n[29]=h,n[30]=J):J=n[30];let Y=i(J),X;n[31]!==V||n[32]!==x?.id||n[33]!==h?(X=async()=>{V({title:`File name`,onConfirm:async e=>{h.createFile({name:e,parentId:x?.id??null})}})},n[31]=V,n[32]=x?.id,n[33]=h,n[34]=X):X=n[34];let ae=i(X),se;n[35]!==V||n[36]!==x?.id||n[37]!==h?(se=async()=>{V({title:`Notebook name`,onConfirm:async e=>{h.createFile({name:e,parentId:x?.id??null,type:`notebook`})}})},n[35]=V,n[36]=x?.id,n[37]=h,n[38]=se):se=n[38];let ce=i(se),le;n[39]===k?le=n[40]:(le=()=>{s.current?.closeAll(),k({})},n[39]=k,n[40]=le);let ue=i(le),de;n[41]!==_||n[42]!==C?(de=ar(_,C),n[41]=_,n[42]=C,n[43]=de):de=n[43];let fe=de,pe=x?.id;pe===void 0||sr(fe,pe)||S(null);let me;n[44]!==o||n[45]!==B||n[46]!==h?(me={tree:h,uploadFiles:B,externalDropDestinationPath:o},n[44]=o,n[45]=B,n[46]=h,n[47]=me):me=n[47];let he=me,ge;n[48]!==y||n[49]!==u||n[50]!==f?(ge=()=>{if(f&&!y){let e=u.trim()?c.current:s.current;e?.openParents(f),e?.select(f);let t=e?.get(f);t?.data.isDirectory&&t.open(),p(null)}},n[48]=y,n[49]=u,n[50]=f,n[51]=ge):ge=n[51];let _e;n[52]!==_||n[53]!==y||n[54]!==u||n[55]!==f?(_e=[f,u,y,_],n[52]=_,n[53]=y,n[54]=u,n[55]=f,n[56]=_e):_e=n[56],Z.useEffect(ge,_e);let ve;n[57]===h?ve=n[58]:(ve=async e=>{if(!e.isDirectory){b(e);return}await h.reveal(e)&&(d(``),p(e.id))},n[57]=h,n[58]=ve);let ye=ve,be;n[59]===u?be=n[60]:(be=e=>{if((e.ctrlKey||e.metaKey)&&e.key===`f`){e.preventDefault(),e.stopPropagation(),l.current?.focus(),l.current?.select();return}if(e.key===`Escape`&&u){e.preventDefault(),e.stopPropagation(),d(``),l.current?.focus();return}let t=e.target instanceof Element?e.target.getAttribute(`role`):null;if(u.trim()||t!==`treeitem`&&t!==`tree`)return;let n=s.current?.focusedNode;!n||s.current?.isEditing||(e.key===`Enter`?(e.preventDefault(),e.stopPropagation(),n.data.isDirectory?n.toggle():n.activate()):e.key===`F2`&&!n.data.isRoot?(e.preventDefault(),e.stopPropagation(),n.edit()):(e.key===`Delete`||e.key===`Backspace`)&&(e.preventDefault(),e.stopPropagation(),n.data.isRoot||n.tree.delete(n.id)))},n[59]=u,n[60]=be);let xe=be;if(ee){let e;return n[61]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ee,{size:`medium`,centered:!0}),n[61]=e):e=n[61],e}if(G){let e;return n[62]===G?e=n[63]:(e=(0,$.jsx)(at,{error:G}),n[62]=G,n[63]=e),e}let Se;n[64]!==y||n[65]!==h?(Se=y?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center pl-1 pr-3 shrink-0 border-b justify-between`,children:[(0,$.jsx)(q,{autoFocus:!0,"aria-label":`Back to files`,onClick:()=>{p(y.id),b(null)},"data-testid":`file-explorer-back-button`,variant:`text`,size:`xs`,className:`mb-0`,children:(0,$.jsx)(ie,{size:16})}),(0,$.jsx)(`span`,{className:`font-bold`,children:y.name})]}),(0,$.jsx)(Z.Suspense,{children:(0,$.jsx)(En,{onOpenNotebook:h.isPrimaryNode(y)?e=>{let t=h.getPrimaryRelativePath(y.path);t!==null&&rr(e,t)}:void 0,file:y})})]}):null,n[64]=y,n[65]=h,n[66]=Se):Se=n[66];let Ce=Se,Te=!!y,De;n[67]===L?De=n[68]:(De=L(),n[67]=L,n[68]=De);let Oe;n[69]===De?Oe=n[70]:(Oe=(0,$.jsx)(`input`,{"data-testid":`file-explorer-upload-input`,...De}),n[69]=De,n[70]=Oe);let ke;n[71]!==x?.path||n[72]!==h?(ke=x?.path??h.getPrimaryRootPath(),n[71]=x?.path,n[72]=h,n[73]=ke):ke=n[73];let Ae;n[74]!==x?.path||n[75]!==h?(Ae=x?.path??h.getPrimaryRootPath(),n[74]=x?.path,n[75]=h,n[76]=Ae):Ae=n[76];let je;n[77]!==Ae||n[78]!==h?(je=ir(h,Ae),n[77]=Ae,n[78]=h,n[79]=je):je=n[79];let Me;n[80]!==ue||n[81]!==ae||n[82]!==Y||n[83]!==ce||n[84]!==K||n[85]!==ne||n[86]!==B||n[87]!==C||n[88]!==ke||n[89]!==je?(Me=(0,$.jsx)($n,{onRefresh:ne,onHidden:K,showHiddenFiles:C,onCreateFile:ae,onCreateNotebook:ce,onCreateFolder:Y,onCollapseAll:ue,uploadDestinationPath:ke,uploadDestinationLabel:je,onUpload:B}),n[80]=ue,n[81]=ae,n[82]=Y,n[83]=ce,n[84]=K,n[85]=ne,n[86]=B,n[87]=C,n[88]=ke,n[89]=je,n[90]=Me):Me=n[90];let Ne;n[91]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=e=>d(e.target.value),n[91]=Ne):Ne=n[91];let Pe;n[92]===u?Pe=n[93]:(Pe=e=>{let t=u.trim()?c.current:s.current;e.key===`ArrowDown`?(e.preventDefault(),t?.focus(t.firstNode)):e.key===`Enter`&&u.trim()&&(e.preventDefault(),t?.firstNode?.activate())},n[92]=u,n[93]=Pe);let Fe;n[94]!==u||n[95]!==Pe?(Fe=(0,$.jsx)(Ve,{ref:l,className:`rounded-none pr-6 focus-visible:outline-1 focus-visible:outline-ring/50`,clearable:!1,"aria-label":`Search files and folders`,placeholder:`Search`,title:`Search names in all configured roots, up to 20 folders deep. Generated directories such as node_modules and .git are excluded.`,value:u,onChange:Ne,onKeyDown:Pe}),n[94]=u,n[95]=Pe,n[96]=Fe):Fe=n[96];let Ie;n[97]===u?Ie=n[98]:(Ie=u&&(0,$.jsx)(q,{variant:`text`,size:`icon`,className:`absolute right-3 top-1/2 h-5 w-5 -translate-y-1/2`,"aria-label":`Clear search`,onClick:()=>{d(``),l.current?.focus()},children:(0,$.jsx)(oe,{className:`h-3 w-3`})}),n[97]=u,n[98]=Ie);let Le;n[99]!==Fe||n[100]!==Ie?(Le=(0,$.jsxs)(`div`,{className:`relative -mt-1`,children:[Fe,Ie]}),n[99]=Fe,n[100]=Ie,n[101]=Le):Le=n[101];let ze;n[102]!==Me||n[103]!==Le?(ze=(0,$.jsxs)(`div`,{children:[Me,Le]}),n[102]=Me,n[103]=Le,n[104]=ze):ze=n[104];let Be;n[105]===u?Be=n[106]:(Be=u.trim(),n[105]=u,n[106]=Be);let He=!Be,Ue=Math.max(0,r-63),We;n[107]!==ye||n[108]!==D||n[109]!==Ue?(We=(0,$.jsx)(On,{treeRef:c,search:D,height:Ue,onReveal:ye}),n[107]=ye,n[108]=D,n[109]=Ue,n[110]=We):We=n[110];let Ge;n[111]!==He||n[112]!==We?(Ge=(0,$.jsx)(`div`,{hidden:He,children:We}),n[111]=He,n[112]=We,n[113]=Ge):Ge=n[113];let Ke;n[114]===u?Ke=n[115]:(Ke=u.trim(),n[114]=u,n[115]=Ke);let qe=!!Ke,Je=Math.max(0,r-63),Ye;n[116]===Symbol.for(`react.memo_cache_sentinel`)?(Ye=e=>(0,$.jsx)(cr,{...e,tree:s.current}),n[116]=Ye):Ye=n[116];let Xe;n[117]!==H||n[118]!==h?(Xe=async e=>{let{ids:t}=e;H({title:`Delete file`,description:`Are you sure you want to delete the selected file or folder?`,confirmAction:(0,$.jsx)(F,{onClick:async()=>{for(let e of t)await h.delete(e)},children:`Delete`})})},n[117]=H,n[118]=h,n[119]=Xe):Xe=n[119];let Ze,Qe;n[120]===h?(Ze=n[121],Qe=n[122]):(Ze=async e=>{let{id:t,name:n}=e;await h.rename(t,n)},Qe=async e=>{let{dragIds:t,parentId:n}=e;await h.move(t,n)},n[120]=h,n[121]=Ze,n[122]=Qe);let $e,tt;n[123]===Symbol.for(`react.memo_cache_sentinel`)?($e=e=>{let t=e[0];if(!t){S(null);return}if(t.data.isDirectory){S({id:t.id,path:t.data.path});return}S(null)},tt=e=>{e.data.isDirectory||b(e.data)},n[123]=$e,n[124]=tt):($e=n[123],tt=n[124]);let nt;n[125]!==O||n[126]!==k||n[127]!==h?(nt=async e=>{if(!(s.current?.isOpen(e)??!(O[e]??!1))){k(t=>({...t,[e]:!1}));return}let t=await h.expand(e);t||s.current?.close(e);let n=t&&(s.current?.isOpen(e)??!1);k(t=>({...t,[e]:n}))},n[125]=O,n[126]=k,n[127]=h,n[128]=nt):nt=n[128];let rt;n[129]!==m||n[130]!==O||n[131]!==Je||n[132]!==Xe||n[133]!==Ze||n[134]!==Qe||n[135]!==nt||n[136]!==fe?(rt=(0,$.jsx)(Re,{width:`100%`,ref:s,height:Je,className:`h-full`,data:fe,childrenAccessor:lr,selectionFollowsFocus:!0,rowClassName:`outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring`,renderRow:Mn,renderDragPreview:Ye,disableEdit:ur,initialOpenState:O,openByDefault:!1,dndManager:m,renderCursor:dr,disableDrag:fr,disableDrop:mr,onDelete:Xe,onRename:Ze,onMove:Qe,onSelect:$e,onActivate:tt,onToggle:nt,padding:15,rowHeight:30,indent:Qn,overscanCount:8,disableMultiSelection:!0,children:tr}),n[129]=m,n[130]=O,n[131]=Je,n[132]=Xe,n[133]=Ze,n[134]=Qe,n[135]=nt,n[136]=fe,n[137]=rt):rt=n[137];let it;n[138]!==he||n[139]!==rt?(it=(0,$.jsx)(Xn,{value:he,children:rt}),n[138]=he,n[139]=rt,n[140]=it):it=n[140];let ot;n[141]===fe.length?ot=n[142]:(ot=!fe.length&&(0,$.jsx)(`p`,{role:`status`,className:`absolute top-2 left-3 text-sm text-muted-foreground`,children:`No visible files.`}),n[141]=fe.length,n[142]=ot);let st;n[143]!==qe||n[144]!==it||n[145]!==ot?(st=(0,$.jsxs)(`div`,{hidden:qe,className:`relative`,children:[it,ot]}),n[143]=qe,n[144]=it,n[145]=ot,n[146]=st):st=n[146];let ct;n[147]!==xe||n[148]!==Te||n[149]!==Oe||n[150]!==ze||n[151]!==Ge||n[152]!==st?(ct=(0,$.jsxs)(`div`,{hidden:Te,onKeyDownCapture:xe,children:[Oe,ze,Ge,st]}),n[147]=xe,n[148]=Te,n[149]=Oe,n[150]=ze,n[151]=Ge,n[152]=st,n[153]=ct):ct=n[153];let lt;return n[154]!==Ce||n[155]!==ct?(lt=(0,$.jsxs)($.Fragment,{children:[Ce,ct]}),n[154]=Ce,n[155]=ct,n[156]=lt):lt=n[156],lt},Qn=15,$n=e=>{let t=(0,Q.c)(35),{onRefresh:n,onHidden:r,showHiddenFiles:i,onCreateFile:a,onCreateNotebook:o,onCreateFolder:s,onCollapseAll:c,uploadDestinationPath:l,uploadDestinationLabel:u,onUpload:d}=e,f=`Upload files to ${u}`,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(bt,{size:16}),t[0]=p):p=t[0];let m;t[1]===o?m=t[2]:(m=(0,$.jsx)(K,{content:`Add notebook`,children:(0,$.jsx)(q,{"data-testid":`file-explorer-add-notebook-button`,onClick:o,variant:`text`,size:`xs`,children:p})}),t[1]=o,t[2]=m);let h;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(Et,{size:16}),t[3]=h):h=t[3];let g;t[4]===a?g=t[5]:(g=(0,$.jsx)(K,{content:`Add file`,children:(0,$.jsx)(q,{"data-testid":`file-explorer-add-file-button`,onClick:a,variant:`text`,size:`xs`,children:h})}),t[4]=a,t[5]=g);let _;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(Ot,{size:16}),t[6]=_):_=t[6];let v;t[7]===s?v=t[8]:(v=(0,$.jsx)(K,{content:`Add folder`,children:(0,$.jsx)(q,{"data-testid":`file-explorer-add-folder-button`,onClick:s,variant:`text`,size:`xs`,children:_})}),t[7]=s,t[8]=v);let y;t[9]!==d||t[10]!==l?(y=()=>d(l),t[9]=d,t[10]=l,t[11]=y):y=t[11];let b;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(Ue,{size:16}),t[12]=b):b=t[12];let x;t[13]!==y||t[14]!==f?(x=(0,$.jsx)(q,{"data-testid":`file-explorer-upload-button`,"aria-label":f,onClick:y,variant:`text`,size:`xs`,children:b}),t[13]=y,t[14]=f,t[15]=x):x=t[15];let S;t[16]!==x||t[17]!==f?(S=(0,$.jsx)(K,{content:f,children:x}),t[16]=x,t[17]=f,t[18]=S):S=t[18];let C;t[19]===n?C=t[20]:(C=(0,$.jsx)(ue,{"data-testid":`file-explorer-refresh-button`,onClick:n}),t[19]=n,t[20]=C);let w;t[21]!==r||t[22]!==i?(w=(0,$.jsx)(se,{"data-testid":`file-explorer-hidden-files-button`,isVisible:i,onToggle:r,showTooltip:`Show hidden files`,hideTooltip:`Hide hidden files`}),t[21]=r,t[22]=i,t[23]=w):w=t[23];let T;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(Tt,{size:16}),t[24]=T):T=t[24];let E;t[25]===c?E=t[26]:(E=(0,$.jsx)(K,{content:`Collapse all folders`,children:(0,$.jsx)(q,{"data-testid":`file-explorer-collapse-button`,onClick:c,variant:`text`,size:`xs`,children:T})}),t[25]=c,t[26]=E);let D;return t[27]!==S||t[28]!==C||t[29]!==w||t[30]!==E||t[31]!==m||t[32]!==g||t[33]!==v?(D=(0,$.jsxs)(`div`,{className:`flex items-center justify-end px-2 shrink-0`,children:[m,g,v,S,C,w,E]}),t[27]=S,t[28]=C,t[29]=w,t[30]=E,t[31]=m,t[32]=g,t[33]=v,t[34]=D):D=t[34],D},er=e=>{let t=(0,Q.c)(11),{node:n,onOpenMarimoFile:r}=e,i;t[0]!==n.data.isMarimoFile||t[1]!==n.data.isPrimaryRoot||t[2]!==r?(i=n.data.isMarimoFile&&n.data.isPrimaryRoot&&!A()&&(0,$.jsxs)(`span`,{"data-testid":`file-explorer-open-marimo-button`,className:`shrink-0 ml-2 text-sm hidden group-hover:inline hover:underline`,onClick:r,children:[`open `,(0,$.jsx)(he,{className:`inline ml-1`,size:12})]}),t[0]=n.data.isMarimoFile,t[1]=n.data.isPrimaryRoot,t[2]=r,t[3]=i):i=t[3];let a;t[4]!==n.data.name||t[5]!==i?(a=(0,$.jsxs)(`span`,{className:`flex-1 overflow-hidden text-ellipsis`,children:[n.data.name,i]}),t[4]=n.data.name,t[5]=i,t[6]=a):a=t[6];let o=a,s;return t[7]!==o||t[8]!==n.data.isRoot||t[9]!==n.data.path?(s=n.data.isRoot?(0,$.jsx)(K,{content:n.data.path,children:o}):o,t[7]=o,t[8]=n.data.isRoot,t[9]=n.data.path,t[10]=s):s=t[10],s},tr=e=>{let t=(0,Q.c)(123),{node:n,style:a,dragHandle:o}=e,{openFile:s}=Xe(),l=r(T),u;t[0]!==n.data.isDirectory||t[1]!==n.data.name?(u=n.data.isDirectory?`directory`:ye(n.data.name),t[0]=n.data.isDirectory,t[1]=n.data.name,t[2]=u):u=t[2];let f=u,p=be[f],{openPrompt:m}=we(),{createNewCell:h}=c(),g=d(),_;t[3]!==h||t[4]!==g?(_=e=>{h({code:e,before:!1,cellId:g??`__end__`})},t[3]=h,t[4]=g,t[5]=_):_=t[5];let y=_,b=(0,Z.use)(Xn),x=b?.tree,S=n.data.isDirectory&&b?.externalDropDestinationPath===n.data.path;bn(n,S);let C;t[6]!==n.data.path||t[7]!==x?(C=async e=>{let t=x?.getPrimaryRelativePath(n.data.path);t!=null&&rr(e,t)},t[6]=n.data.path,t[7]=x,t[8]=C):C=t[8];let w=C,E;t[9]!==n.id||t[10]!==n.tree?(E=async e=>{e.stopPropagation(),e.preventDefault(),await n.tree.delete(n.id)},t[9]=n.id,t[10]=n.tree,t[11]=E):E=t[11];let D=E,O;t[12]!==n||t[13]!==m||t[14]!==x?(O=async()=>{n.open(),m({title:`Folder name`,onConfirm:async e=>{x?.createFolder(e,n.id)}})},t[12]=n,t[13]=m,t[14]=x,t[15]=O):O=t[15];let k=i(O),j;t[16]!==n||t[17]!==m||t[18]!==x?(j=async()=>{n.open(),m({title:`File name`,onConfirm:async e=>{x?.createFile({name:e,parentId:n.id})}})},t[16]=n,t[17]=m,t[18]=x,t[19]=j):j=t[19];let M=i(j),P;t[20]!==n||t[21]!==m||t[22]!==x?(P=async()=>{n.open(),m({title:`Notebook name`,onConfirm:async e=>{x?.createFile({name:e,parentId:n.id,type:`notebook`})}})},t[20]=n,t[21]=m,t[22]=x,t[23]=P):P=t[23];let F=i(P),R;t[24]!==n.data.name||t[25]!==n.id||t[26]!==x?(R=async()=>{x&&await x.copy(n.id,lt(n.data.name))},t[24]=n.data.name,t[25]=n.id,t[26]=x,t[27]=R):R=t[27];let z=i(R),B;t[28]!==n.data.isDirectory||t[29]!==n.data.path?(B=n.data.isDirectory?{[Vn]:n.data.path}:{},t[28]=n.data.isDirectory,t[29]=n.data.path,t[30]=B):B=t[30];let H;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(H=N(`relative flex h-full items-center cursor-pointer ml-1 text-muted-foreground whitespace-nowrap group`),t[31]=H):H=t[31];let U=!n.data.isRoot,W,ee;t[32]===n?(W=t[33],ee=t[34]):(W=()=>{n.data.isDirectory&&n.toggle()},ee=e=>{e.stopPropagation(),n.data.isDirectory||n.activate()},t[32]=n,t[33]=W,t[34]=ee);let G;t[35]===n.level?G=t[36]:(G=Array.from({length:n.level},hr),t[35]=n.level,t[36]=G);let te;t[37]===n?te=t[38]:(te=(0,$.jsx)(nr,{node:n}),t[37]=n,t[38]=te);let ne;t[39]!==n.data.isDirectory||t[40]!==n.tree||t[41]!==n.willReceiveDrop?(ne=n.willReceiveDrop&&n.tree.canDrop()&&n.data.isDirectory&&`bg-primary/15 hover:bg-primary/15 text-accent-foreground`,t[39]=n.data.isDirectory,t[40]=n.tree,t[41]=n.willReceiveDrop,t[42]=ne):ne=t[42];let re=n.isSelected&&`bg-accent/60 hover:bg-accent/60 text-accent-foreground`,K=S&&`bg-primary/15 hover:bg-primary/15 text-accent-foreground`,q;t[43]!==ne||t[44]!==re||t[45]!==K?(q=N(`flex items-center pl-1 py-1 cursor-pointer hover:bg-accent/50 hover:text-accent-foreground rounded-l flex-1 overflow-hidden group`,ne,re,K),t[43]=ne,t[44]=re,t[45]=K,t[46]=q):q=t[46];let J;t[47]!==p||t[48]!==f||t[49]!==n.data.isMarimoFile||t[50]!==n.data.isRoot?(J=n.data.isRoot?(0,$.jsx)(kt,{className:`w-4 h-4 shrink-0 mr-2 text-primary`,strokeWidth:1.5}):n.data.isMarimoFile?(0,$.jsx)(xt,{className:`w-4 h-4 shrink-0 mr-2`,strokeWidth:1.5}):(0,$.jsx)(p,{className:N(`w-4 h-4 shrink-0 mr-2`,ve[f]),strokeWidth:1.5}),t[47]=p,t[48]=f,t[49]=n.data.isMarimoFile,t[50]=n.data.isRoot,t[51]=J):J=t[51];let Y;t[52]!==w||t[53]!==n?(Y=n.isEditing?(0,$.jsx)(Le,{node:n}):(0,$.jsx)(er,{node:n,onOpenMarimoFile:w}),t[52]=w,t[53]=n,t[54]=Y):Y=t[54];let X;t[55]===n?X=t[56]:(X=!n.data.isDirectory&&(0,$.jsxs)(I,{onSelect:()=>n.activate(),"data-testid":`file-explorer-open-file-menu-item`,children:[(0,$.jsx)(Mt,{className:`h-3.5 w-3.5 mr-2`}),`Open file`]}),t[55]=n,t[56]=X);let ie;t[57]!==n.data.isDirectory||t[58]!==n.data.path||t[59]!==s?(ie=!n.data.isDirectory&&!A()&&(0,$.jsxs)(I,{onSelect:()=>{s({path:n.data.path})},"data-testid":`file-explorer-open-external-menu-item`,children:[(0,$.jsx)(he,{className:`h-3.5 w-3.5 mr-2`}),`Open file in external editor`]}),t[57]=n.data.isDirectory,t[58]=n.data.path,t[59]=s,t[60]=ie):ie=t[60];let oe;t[61]!==b||t[62]!==M||t[63]!==k||t[64]!==F||t[65]!==n.data.isDirectory||t[66]!==n.data.path?(oe=n.data.isDirectory&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(I,{onSelect:()=>F(),"data-testid":`file-explorer-create-notebook-menu-item`,children:[(0,$.jsx)(bt,{className:`h-3.5 w-3.5 mr-2`}),`Create notebook`]}),(0,$.jsxs)(I,{onSelect:()=>M(),"data-testid":`file-explorer-create-file-menu-item`,children:[(0,$.jsx)(Et,{className:`h-3.5 w-3.5 mr-2`}),`Create file`]}),(0,$.jsxs)(I,{onSelect:()=>k(),"data-testid":`file-explorer-create-folder-menu-item`,children:[(0,$.jsx)(Ot,{className:`h-3.5 w-3.5 mr-2`}),`Create folder`]}),(0,$.jsxs)(I,{onSelect:()=>b?.uploadFiles(n.data.path),"data-testid":`file-explorer-upload-files-menu-item`,children:[(0,$.jsx)(Ue,{className:`h-3.5 w-3.5 mr-2`}),`Upload files here`]}),(0,$.jsx)(L,{})]}),t[61]=b,t[62]=M,t[63]=k,t[64]=F,t[65]=n.data.isDirectory,t[66]=n.data.path,t[67]=oe):oe=t[67];let se;t[68]!==z||t[69]!==n?(se=!n.data.isRoot&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(De,{onSelect:()=>n.edit(),testId:`file-explorer-rename-menu-item`}),(0,$.jsx)(Ie,{onSelect:z,testId:`file-explorer-duplicate-menu-item`})]}),t[68]=z,t[69]=n,t[70]=se):se=t[70];let ce;t[71]===n.data.path?ce=t[72]:(ce=async()=>{await Ge(n.data.path),Ke({title:`Copied to clipboard`})},t[71]=n.data.path,t[72]=ce);let le;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,$.jsx)(At,{className:de}),t[73]=le):le=t[73];let ue;t[74]===ce?ue=t[75]:(ue=(0,$.jsxs)(I,{onSelect:ce,"data-testid":`file-explorer-copy-path-menu-item`,children:[le,`Copy path`]}),t[74]=ce,t[75]=ue);let fe;t[76]!==n.data.isPrimaryRoot||t[77]!==n.data.isRoot||t[78]!==n.data.path||t[79]!==x?(fe=x&&n.data.isPrimaryRoot&&!n.data.isRoot&&(0,$.jsxs)(I,{onSelect:async()=>{let e=x.getPrimaryRelativePath(n.data.path);e!==null&&(await Ge(e),Ke({title:`Copied to clipboard`}))},"data-testid":`file-explorer-copy-relative-path-menu-item`,children:[(0,$.jsx)(At,{className:`h-3.5 w-3.5 mr-2`}),`Copy relative path`]}),t[76]=n.data.isPrimaryRoot,t[77]=n.data.isRoot,t[78]=n.data.path,t[79]=x,t[80]=fe):fe=t[80];let pe;t[81]!==f||t[82]!==y||t[83]!==n.data?(pe=!n.data.isRoot&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(L,{}),(0,$.jsxs)(I,{onSelect:()=>{let{path:e}=n.data,t=Rn[f](e);y(t)},"data-testid":`file-explorer-insert-snippet-menu-item`,children:[(0,$.jsx)(ae,{className:`h-3.5 w-3.5 mr-2`}),`Insert snippet for reading file`]}),(0,$.jsxs)(I,{onSelect:async()=>{Ke({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:e}=n.data,t=Rn[f](e);await Ge(t)},"data-testid":`file-explorer-copy-snippet-menu-item`,children:[(0,$.jsx)(v,{className:`h-3.5 w-3.5 mr-2`}),`Copy snippet for reading file`]})]}),t[81]=f,t[82]=y,t[83]=n.data,t[84]=pe):pe=t[84];let me;t[85]!==w||t[86]!==n.data.isMarimoFile||t[87]!==n.data.isPrimaryRoot?(me=n.data.isMarimoFile&&n.data.isPrimaryRoot&&!A()&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(L,{}),(0,$.jsxs)(I,{onSelect:w,"data-testid":`file-explorer-open-notebook-menu-item`,children:[(0,$.jsx)(jt,{className:`h-3.5 w-3.5 mr-2`}),`Open notebook`]})]}),t[85]=w,t[86]=n.data.isMarimoFile,t[87]=n.data.isPrimaryRoot,t[88]=me):me=t[88];let ge;t[89]!==l||t[90]!==n.data.isDirectory||t[91]!==n.data.name||t[92]!==n.data.path?(ge=!n.data.isDirectory&&!l&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(L,{}),(0,$.jsxs)(I,{onSelect:async()=>{await xn(n.data.path,n.data.name)},"data-testid":`file-explorer-download-menu-item`,children:[(0,$.jsx)(V,{className:`h-3.5 w-3.5 mr-2`}),`Download`]})]}),t[89]=l,t[90]=n.data.isDirectory,t[91]=n.data.name,t[92]=n.data.path,t[93]=ge):ge=t[93];let _e;t[94]!==D||t[95]!==n.data.isRoot?(_e=!n.data.isRoot&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(L,{}),(0,$.jsx)(Pe,{onSelect:D,testId:`file-explorer-delete-menu-item`})]}),t[94]=D,t[95]=n.data.isRoot,t[96]=_e):_e=t[96];let xe;t[97]!==X||t[98]!==ie||t[99]!==oe||t[100]!==se||t[101]!==ue||t[102]!==fe||t[103]!==pe||t[104]!==me||t[105]!==ge||t[106]!==_e?(xe=(0,$.jsxs)(je,{testId:`file-explorer-more-button`,iconClassName:`w-5 h-5`,children:[X,ie,oe,se,ue,fe,pe,me,ge,_e]}),t[97]=X,t[98]=ie,t[99]=oe,t[100]=se,t[101]=ue,t[102]=fe,t[103]=pe,t[104]=me,t[105]=ge,t[106]=_e,t[107]=xe):xe=t[107];let Se;t[108]!==q||t[109]!==J||t[110]!==Y||t[111]!==xe?(Se=(0,$.jsxs)(`span`,{className:q,children:[J,Y,xe]}),t[108]=q,t[109]=J,t[110]=Y,t[111]=xe,t[112]=Se):Se=t[112];let Ce;return t[113]!==o||t[114]!==a||t[115]!==U||t[116]!==W||t[117]!==ee||t[118]!==G||t[119]!==te||t[120]!==Se||t[121]!==B?(Ce=(0,$.jsxs)(`div`,{style:a,ref:o,...B,className:H,draggable:U,onClick:W,onDoubleClick:ee,children:[G,te,Se]}),t[113]=o,t[114]=a,t[115]=U,t[116]=W,t[117]=ee,t[118]=G,t[119]=te,t[120]=Se,t[121]=B,t[122]=Ce):Ce=t[122],Ce},nr=e=>{let t=(0,Q.c)(6),{node:n}=e;if(!n.data.isDirectory){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`w-4 h-4 shrink-0`}),t[0]=e):e=t[0],e}if(n.data.loadState===`loading`){let e=`Loading ${n.data.name}`,r;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(Ee,{size:`small`}),t[1]=r):r=t[1];let i;return t[2]===e?i=t[3]:(i=(0,$.jsx)(`span`,{role:`status`,"aria-label":e,className:`w-4 h-4 shrink-0`,children:r}),t[2]=e,t[3]=i),i}let r;return t[4]===n.isOpen?r=t[5]:(r=(0,$.jsx)(ce,{isExpanded:n.isOpen,className:`w-4 h-4`}),t[4]=n.isOpen,t[5]=r),r};function rr(e,t){e.stopPropagation(),e.preventDefault(),St(t)}function ir(e,t){return e.getDisplayPath(t)}function ar(e,t){if(t)return e;let n=[];for(let r of e){if(!r.isRoot&&or(r.name))continue;let e=r;if(r.children){let n=ar(r.children,t);n!==r.children&&(e={...r,children:n})}n.push(e)}return n}function or(e){return!!e.startsWith(`.`)}function sr(e,t){return e.some(e=>e.id===t||(e.children?sr(e.children,t):!1))}function cr(e){let t=(0,Q.c)(22),{mouse:n,id:r,isDragging:i,tree:a}=e,o,s,c;if(t[0]!==r||t[1]!==i||t[2]!==n||t[3]!==a){c=Symbol.for(`react.early_return_sentinel`);bb0:{if(o=a?.get(r),!i||!n||!o){c=null;break bb0}s=o.data.isDirectory?`directory`:ye(o.data.name)}t[0]=r,t[1]=i,t[2]=n,t[3]=a,t[4]=o,t[5]=s,t[6]=c}else o=t[4],s=t[5],c=t[6];if(c!==Symbol.for(`react.early_return_sentinel`))return c;let l=s,u=be[l],d=`translate3d(${n.x+12}px, ${n.y+12}px, 0)`,f;t[7]===d?f=t[8]:(f={transform:d},t[7]=d,t[8]=f);let p=ve[l],m;t[9]===p?m=t[10]:(m=N(`h-4 w-4 shrink-0`,p),t[9]=p,t[10]=m);let h;t[11]!==u||t[12]!==m?(h=(0,$.jsx)(u,{className:m}),t[11]=u,t[12]=m,t[13]=h):h=t[13];let g;t[14]===o.data.name?g=t[15]:(g=(0,$.jsx)(`span`,{className:`truncate`,children:o.data.name}),t[14]=o.data.name,t[15]=g);let _;t[16]!==h||t[17]!==g?(_=(0,$.jsxs)(`div`,{className:`flex max-w-72 items-center gap-2 rounded-md border border-border bg-popover px-3 py-2 text-sm text-popover-foreground shadow-md`,children:[h,g]}),t[16]=h,t[17]=g,t[18]=_):_=t[18];let v;return t[19]!==f||t[20]!==_?(v=(0,_n.createPortal)((0,$.jsx)(`div`,{className:`pointer-events-none fixed left-0 top-0 z-[1000] opacity-[0.85]`,style:f,children:_}),document.body),t[19]=f,t[20]=_,t[21]=v):v=t[21],v}function lr(e){return e.isDirectory?e.children:null}function ur(e){return e.isRoot}function dr(){return null}function fr(e){return e.isRoot}function pr(e){return e.data.isRoot}function mr(e){let{parentNode:t,dragNodes:n}=e;return n.some(pr)||(t?!t.data.isDirectory:!1)}function hr(e,t){return(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-0 border-l border-border`,style:{left:t*Qn+8}},t)}var gr=e=>{let t=(0,Q.c)(44),{height:n}=e,i=r(Fn),[a,o]=(0,Z.useState)(null),s;t[0]===i?s=t[1]:(s=e=>_r(e,i.getPrimaryRootPath()),t[0]=i,t[1]=s);let c=s,l;t[2]===i?l=t[3]:(l=e=>i.refreshPath(e),t[2]=i,t[3]=l);let u=l,d;t[4]===i?d=t[5]:(d=e=>ir(i,e),t[4]=i,t[5]=d);let f,p;t[6]===c?(f=t[7],p=t[8]):(f=e=>o(c(e)),p=e=>o(c(e)),t[6]=c,t[7]=f,t[8]=p);let m,h;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>o(null),h=()=>o(null),t[9]=m,t[10]=h):(m=t[9],h=t[10]);let g;t[11]!==c||t[12]!==u||t[13]!==d||t[14]!==f||t[15]!==p?(g={noClick:!0,noKeyboard:!0,destinationPath:c,getDestinationLabel:d,refreshDestination:u,onDragEnter:f,onDragOver:p,onDragLeave:m,onUploadStart:h},t[11]=c,t[12]=u,t[13]=d,t[14]=f,t[15]=p,t[16]=g):g=t[16];let{getRootProps:_,getInputProps:v,isDragActive:y}=Hn(g),b;t[17]!==a||t[18]!==i?(b=a??i.getPrimaryRootPath(),t[17]=a,t[18]=i,t[19]=b):b=t[19];let x=b,S;t[20]!==x||t[21]!==i?(S=ir(i,x),t[20]=x,t[21]=i,t[22]=S):S=t[22];let C=S,w;t[23]===_?w=t[24]:(w=_(),t[23]=_,t[24]=w);let T;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(T=N(`flex flex-col overflow-hidden relative`),t[25]=T):T=t[25];let E;t[26]===n?E=t[27]:(E={height:n},t[26]=n,t[27]=E);let D;t[28]===v?D=t[29]:(D=v(),t[28]=v,t[29]=D);let O;t[30]===D?O=t[31]:(O=(0,$.jsx)(`input`,{...D}),t[30]=D,t[31]=O);let k;t[32]!==C||t[33]!==y?(k=y&&(0,$.jsx)(`div`,{className:`absolute inset-0 flex items-start justify-center pt-3 bg-accent/20 z-10 border-2 border-dashed border-primary/90 rounded-lg pointer-events-none`,children:(0,$.jsxs)(`span`,{className:`px-3 py-1.5 rounded-md bg-background/95 border shadow-sm text-sm font-semibold text-primary`,children:[`Drop files into `,C]})}),t[32]=C,t[33]=y,t[34]=k):k=t[34];let A=y?x:null,j;t[35]!==n||t[36]!==A?(j=(0,$.jsx)(Zn,{height:n,externalDropDestinationPath:A}),t[35]=n,t[36]=A,t[37]=j):j=t[37];let M;return t[38]!==w||t[39]!==E||t[40]!==O||t[41]!==k||t[42]!==j?(M=(0,$.jsx)(gn,{children:(0,$.jsxs)(`div`,{...w,className:T,style:E,children:[O,k,j]})}),t[38]=w,t[39]=E,t[40]=O,t[41]=k,t[42]=j,t[43]=M):M=t[43],M};function _r(e,t){return Array.isArray(e)?t:Gn(e.target,t)}var vr=()=>{let e=(0,Q.c)(40),{ref:n,height:i}=st(),a=i===void 0?500:i,[o,s]=t(Ct),c=r(h).length,l=x(`storage`),u;bb0:{if(!o.hasUserInteracted&&c>0){if(o.openSections.includes(`remote-storage`)){u=o.openSections;break bb0}let t;e[0]===o.openSections?t=e[1]:(t=[...o.openSections,`remote-storage`],e[0]=o.openSections,e[1]=t),u=t;break bb0}u=o.openSections}let d=u,f;e[2]===s?f=e[3]:(f=e=>{s({openSections:e,hasUserInteracted:!0})},e[2]=s,e[3]=f);let p=f,m=a-66,g;e[4]===d?g=e[5]:(g=d.includes(`remote-storage`),e[4]=d,e[5]=g);let _=g,v=l.length>0,y;e[6]!==d||e[7]!==_?(y=_&&d.includes(`files`),e[6]=d,e[7]=_,e[8]=y):y=e[8];let b=y,S;e[9]!==m||e[10]!==b?(S=b?Math.round(m*.4):m,e[9]=m,e[10]=b,e[11]=S):S=e[11];let C=S,w=Math.max(200,b?m-C:m),T;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(Se,{className:`w-4 h-4`}),e[12]=T):T=e[12];let E;e[13]===c?E=e[14]:(E=c>0&&(0,$.jsx)(pt,{children:c}),e[13]=c,e[14]=E);let D;e[15]!==l.length||e[16]!==v?(D=v&&(0,$.jsx)(yt,{count:l.length,type:`storage`}),e[15]=l.length,e[16]=v,e[17]=D):D=e[17];let O;e[18]!==E||e[19]!==D?(O=(0,$.jsxs)(mt,{children:[T,` Remote storage`,E,D]}),e[18]=E,e[19]=D,e[20]=O):O=e[20];let A;e[21]===C?A=e[22]:(A={maxHeight:C},e[21]=C,e[22]=A);let j;e[23]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(ln,{}),e[23]=j):j=e[23];let M;e[24]===A?M=e[25]:(M=(0,$.jsx)(ht,{className:`overflow-auto`,style:A,children:j}),e[24]=A,e[25]=M);let N;e[26]!==M||e[27]!==O?(N=(0,$.jsxs)(_t,{value:`remote-storage`,children:[O,M]}),e[26]=M,e[27]=O,e[28]=N):N=e[28];let P;e[29]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsxs)(mt,{children:[(0,$.jsx)(xe,{className:`w-4 h-4`}),`Files`]}),e[29]=P):P=e[29];let F;e[30]===w?F=e[31]:(F=(0,$.jsxs)(_t,{value:`files`,children:[P,(0,$.jsx)(ht,{children:(0,$.jsx)(gr,{height:w})})]}),e[30]=w,e[31]=F);let I;e[32]!==p||e[33]!==d||e[34]!==N||e[35]!==F?(I=(0,$.jsxs)(k,{type:`multiple`,value:d,onValueChange:p,children:[N,F]}),e[32]=p,e[33]=d,e[34]=N,e[35]=F,e[36]=I):I=e[36];let L;return e[37]!==n||e[38]!==I?(L=(0,$.jsx)(`div`,{ref:n,className:`h-full overflow-auto`,children:I}),e[37]=n,e[38]=I,e[39]=L):L=e[39],L};export{vr as default,_r as getUploadDestinationForEvent};
|
|
1
|
+
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{c as t,f as n,l as r,t as i}from"./useEvent-Dfcbgjhg.js";import{t as a}from"./react-DVplv7_D.js";import{Cn as o,Ct as s,D as c,Et as l,Qr as u,Rt as d,St as f,Tt as p,_n as m,bt as h,fn as g,gn as _,lo as v,wt as y,xt as b,yt as x,za as S}from"./cells-styV7IX8.js";import{t as C}from"./react-dom-_LrxgvjW.js";import{t as w}from"./compiler-runtime-BrajqUja.js";import{f as T,h as E}from"./config-DGX7JYor.js";import{g as D}from"./useEventListener-CjDeLqFC.js";import{t as O}from"./invariant-Ci2dTZ72.js";import{r as k}from"./config-BbRbT9Ww.js";import{M as A,O as j,r as M}from"./config-BQT0uYUo.js";import{t as N}from"./cn-ldLVeaqm.js";import{t as P}from"./jsx-runtime-B74pBk57.js";import{o as F}from"./alert-dialog-C-sWmKva.js";import{a as I,c as L,p as R,r as z,t as B}from"./dropdown-menu-DS6umAnH.js";import{Ft as V,a as H,g as U,i as W,o as ee,s as G}from"./JsonOutput-VxzHyItt.js";import{c as te,n as ne,r as re}from"./download-BrCpRZKN.js";import{t as K}from"./tooltip-CkGm8X7m.js";import{t as q}from"./button-D8gVKwe-.js";import{t as J}from"./createLucideIcon-DfJ2oMlA.js";import{n as Y,t as X}from"./paths-bkIFVj8h.js";import{t as ie}from"./arrow-left-BaPN-xbg.js";import{n as ae}from"./LazyAnyLanguageCodeMirror-BPYE76jR.js";import{r as oe}from"./useNumberFormatter-D7O_26UI.js";import{a as se,i as ce,n as le,r as ue,t as de}from"./tree-actions-Cx5EDpA6.js";import{a as fe}from"./markdown-renderer-CAyCgogC.js";import{s as pe}from"./toDate-DOj9Q6uC.js";import{t as me}from"./copy-Djr5m5ac.js";import{t as he}from"./external-link-UrX9KO36.js";import{a as ge,i as _e,n as ve,r as ye,t as be}from"./file-icons-CdJgUy-I.js";import{t as xe}from"./file-BPBVl9pl.js";import{n as Se,t as Ce}from"./components-DrU8dOzy.js";import{b as we}from"./write-secret-modal-7DzehGyr.js";import{n as Te,t as Ee}from"./spinner-DyNE-o8o.js";import{a as De,c as Oe,d as ke,f as Ae,i as je,l as Me,m as Ne,n as Pe,p as Fe,r as Ie,t as Le,u as Re}from"./file-name-input-RHURglL_.js";import{t as ze}from"./refresh-cw-Qw1f8Jhy.js";import{t as Be}from"./save-Dgoim6QF.js";import{a as Ve}from"./input-BZdRe7pb.js";import{t as He}from"./triangle-alert-DmIqR8sY.js";import{n as Ue,t as We}from"./es-N9SHpmG7.js";import{n as Ge}from"./copy-KlhazlhB.js";import{t as Ke}from"./use-toast-Wu434mLr.js";import{t as qe}from"./copy-icon-8-a5vovc.js";import{Et as Je}from"./dist-Cny7_yZb.js";import{n as Ye,r as Xe,t as Ze}from"./requests-lt0JK8Jt.js";import{t as Qe}from"./I18nProvider-Cg2I_s1_.js";import{t as $e}from"./useDebounce-k9QTpQ9-.js";import{n as et}from"./useAsyncData-DhhdOGGd.js";import{t as tt}from"./blob-De9GR2s6.js";import{a as nt}from"./errors-CNsgAw6m.js";import{n as rt,t as it}from"./alert-DTaqCu_d.js";import{n as at}from"./error-banner-B5kzVf_0.js";import{a as ot}from"./renderShortcut-H60uiHBp.js";import{t as st}from"./bundle.esm-D3tw5rqW.js";import{t as ct}from"./useAddCell-uJJYtgwa.js";import{n as lt}from"./pathUtils-DPmlLd-r.js";import{n as ut}from"./semaphore-BjoL5P0h.js";import{t as dt}from"./empty-state-BaCKb7o3.js";import{t as ft}from"./formatting-uom1es4b.js";import{a as pt,i as mt,n as ht,o as gt,r as _t,s as vt,t as yt}from"./components-CNmvC781.js";import{n as bt,t as xt}from"./marimo-icons-CqliHyTr.js";import{t as St}from"./links-CXcpNIM0.js";import{n as Ct}from"./panel-accordion-state-BZHex38W.js";var wt=J(`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`}]]),Tt=J(`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`}]]),Et=J(`file-plus-corner`,[[`path`,{d:`M11.35 22H6a2 2 0 0 1-2-2V4a2 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 8v5.35`,key:`17jvcc`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M14 19h6`,key:`bvotb8`}],[`path`,{d:`M17 16v6`,key:`18yu1i`}]]),Dt=J(`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`}]]),Ot=J(`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`}]]),kt=J(`folder-root`,[[`path`,{d:`M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z`,key:`1fr9dc`}],[`circle`,{cx:`12`,cy:`13`,r:`2`,key:`1c1ljs`}],[`path`,{d:`M12 15v5`,key:`11xva1`}]]),At=J(`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`}]]),jt=J(`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`}]]),Mt=J(`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=e(a(),1),Q=w(),$=P(),Nt=e=>{let t=(0,Q.c)(17),{filename:n,filenameIcon:r,onBack:i,onRefresh:a,onDownload:o,actions:s}=e,c;t[0]===i?c=t[1]:(c=i&&(0,$.jsx)(K,{content:`Back to file list`,children:(0,$.jsx)(q,{variant:`text`,size:`xs`,onClick:i,children:(0,$.jsx)(ie,{className:`h-4 w-4`})})}),t[0]=i,t[1]=c);let l;t[2]!==n||t[3]!==r?(l=n?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5 flex-1 min-w-0 text-xs font-semibold truncate`,children:[r,n]}):(0,$.jsx)(`span`,{className:`flex-1`}),t[2]=n,t[3]=r,t[4]=l):l=t[4];let u;t[5]===a?u=t[6]:(u=a&&(0,$.jsx)(K,{content:`Refresh`,children:(0,$.jsx)(q,{variant:`text`,size:`xs`,onClick:a,children:(0,$.jsx)(ze,{className:`h-3.5 w-3.5`})})}),t[5]=a,t[6]=u);let d;t[7]===o?d=t[8]:(d=o&&(0,$.jsx)(K,{content:`Download`,children:(0,$.jsx)(q,{variant:`text`,size:`xs`,onClick:o,children:(0,$.jsx)(V,{className:`h-3.5 w-3.5`})})}),t[7]=o,t[8]=d);let f;t[9]!==s||t[10]!==u||t[11]!==d?(f=(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[u,s,d]}),t[9]=s,t[10]=u,t[11]=d,t[12]=f):f=t[12];let p;return t[13]!==c||t[14]!==l||t[15]!==f?(p=(0,$.jsxs)(`div`,{className:`flex items-center shrink-0 border-b px-1 gap-1`,children:[c,l,f]}),t[13]=c,t[14]=l,t[15]=f,t[16]=p):p=t[16],p},Pt=new Set([`http`,`file`,`in-memory`]);function Ft(e){return JSON.stringify(e).slice(1,-1)}var It=new Set([`datasets`,`spaces`,`buckets`]);function Lt(e){let t=e.split(`/`).filter(Boolean);return t[0]===`datasets`&&t.length>=4?{repoType:`dataset`,repoId:`${t[1]}/${t[2]}`,filename:t.slice(3).join(`/`)}:t[0]===`spaces`&&t.length>=4?{repoType:`space`,repoId:`${t[1]}/${t[2]}`,filename:t.slice(3).join(`/`)}:t.length>=3&&!It.has(t[0])?{repoType:`model`,repoId:`${t[0]}/${t[1]}`,filename:t.slice(2).join(`/`)}:null}function Rt(e){return`from huggingface_hub import hf_hub_download\n\nlocal_path = hf_hub_download(\n repo_id="${Ft(e.repoId)}",\n filename="${Ft(e.filename)}",\n repo_type="${Ft(e.repoType)}",\n)`}var zt=[{id:`read-file`,label:`Insert read snippet`,icon:wt,getCode:e=>{if(e.entry.kind===`directory`)return null;let t=Ft(e.entry.path);if(e.backendType===`huggingface`){let t=Lt(e.entry.path);return t?`${Rt(t)}\n\nwith open(local_path, "rb") as f:\n _data = f.read()\n_data`:null}return e.backendType===`obstore`?`_data = ${e.variableName}.get("${t}").bytes()\n_data`:`_data = ${e.variableName}.cat_file("${t}")\n_data`}},{id:`download-file`,label:`Insert download snippet`,icon:Dt,getCode:e=>{if(e.entry.kind===`directory`)return null;let t=Ft(e.entry.path);if(e.backendType===`huggingface`){let t=Lt(e.entry.path);return t?`${Rt(t)}\nlocal_path`:null}if(e.backendType===`obstore`)return Pt.has(e.protocol)?null:`from datetime import timedelta\nfrom obstore import sign\n\nsigned_url = sign(\n ${e.variableName}, "GET", "${t}",\n expires_in=timedelta(hours=1),\n)\nsigned_url`;let n=Ft(e.entry.path.split(`/`).pop()||`download`);return`${e.variableName}.get("${t}", "${n}")`}}],Bt=104857600;function Vt(e){let t=e.endsWith(`/`)?e.slice(0,-1):e,n=t.split(`/`);return n[n.length-1]||t}var Ht=e=>{let t=(0,Q.c)(83),{entry:n,namespace:r,protocol:i,backendType:a,onBack:o}=e,{locale:s}=Qe(),c=ct(),u;t[0]===n.path?u=t[1]:(u=Vt(n.path),t[0]=n.path,t[1]=u);let d=u,f=n.mimeType||`text/plain`,p;t[2]===f?p=t[3]:(p=G(f),t[2]=f,t[3]=p);let m=p,h=m&&n.size>Bt&&n.size>0,g,_;t[4]!==n.path||t[5]!==m||t[6]!==r||t[7]!==h?(g=async()=>{if(h)return null;let e=await l.request({namespace:r,path:n.path,preview:!m});if(e.error)throw Error(e.error);if(!e.url)throw Error(`No URL returned`);if(m)return{type:`media`,url:e.url};let t=await fetch(e.url);if(!t.ok)throw Error(`Failed to fetch preview: ${t.statusText}`);return{type:`text`,content:await t.text()}},_=[r,n.path,m,h],t[4]=n.path,t[5]=m,t[6]=r,t[7]=h,t[8]=g,t[9]=_):(g=t[8],_=t[9]);let{data:v,isPending:y,error:b,refetch:x}=et(g,_),S;t[10]!==n.path||t[11]!==d||t[12]!==r?(S=async()=>{try{let e=await l.request({namespace:r,path:n.path});if(e.error){Ke({title:`Download failed`,description:e.error,variant:`danger`});return}e.url&&re(e.url,e.filename??d)}catch(e){let t=e;D.error(`Failed to download storage entry`,t),Ke({title:`Download failed`,description:String(t),variant:`danger`})}},t[10]=n.path,t[11]=d,t[12]=r,t[13]=S):S=t[13];let C=S,w;t[14]!==c||t[15]!==a||t[16]!==n||t[17]!==r||t[18]!==i?(w=zt.map(e=>{let t=e.getCode({variableName:r,protocol:i,entry:n,backendType:a});if(t===null)return null;let o=e.icon;return(0,$.jsx)(K,{content:e.label,children:(0,$.jsx)(q,{variant:`text`,size:`xs`,onClick:()=>c(t),"aria-label":e.label,children:(0,$.jsx)(o,{className:`h-3.5 w-3.5`})})},e.id)}),t[14]=c,t[15]=a,t[16]=n,t[17]=r,t[18]=i,t[19]=w):w=t[19];let T=w,E;t[20]===d?E=t[21]:(E=_e(d),t[20]=d,t[21]=E);let O;t[22]!==C||t[23]!==d||t[24]!==o||t[25]!==T||t[26]!==E?(O=(0,$.jsx)(Nt,{filename:d,filenameIcon:E,onBack:o,onDownload:C,actions:T}),t[22]=C,t[23]=d,t[24]=o,t[25]=T,t[26]=E,t[27]=O):O=t[27];let k=O,A;t[28]!==n.lastModified||t[29]!==n.path||t[30]!==n.size||t[31]!==s||t[32]!==f?(A=e=>{let{includeMime:t}=e,r=t!==void 0&&t;return(0,$.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 p-4 text-xs`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground font-medium`,children:`Path`}),(0,$.jsxs)(`div`,{className:`truncate flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`font-mono text-[11px]`,children:n.path}),(0,$.jsx)(qe,{value:n.path,className:`h-3 w-3`})]}),r&&(0,$.jsx)(`span`,{className:`text-muted-foreground font-medium`,children:`Type`}),r&&(0,$.jsx)(`span`,{children:f}),n.size>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-muted-foreground font-medium`,children:`Size`}),(0,$.jsx)(`span`,{children:ft(n.size,s)})]}),n.lastModified!=null&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-muted-foreground font-medium`,children:`Modified`}),(0,$.jsx)(`span`,{children:new Date(n.lastModified*1e3).toLocaleString()})]})]})},t[28]=n.lastModified,t[29]=n.path,t[30]=n.size,t[31]=s,t[32]=f,t[33]=A):A=t[33];let j=A;if(h){let e;t[34]===j?e=t[35]:(e=j({includeMime:!0}),t[34]=j,t[35]=e);let r;t[36]!==n.size||t[37]!==s?(r=ft(n.size,s),t[36]=n.size,t[37]=s,t[38]=r):r=t[38];let i;t[39]===r?i=t[40]:(i=(0,$.jsxs)(`div`,{className:`px-4 pb-4 text-xs text-muted-foreground italic`,children:[`File is too large to preview (`,r,`).`]}),t[39]=r,t[40]=i);let a;return t[41]!==k||t[42]!==e||t[43]!==i?(a=(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[k,e,i]}),t[41]=k,t[42]=e,t[43]=i,t[44]=a):a=t[44],a}if(y){let e;t[45]===j?e=t[46]:(e=j({}),t[45]=j,t[46]=e);let n;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`flex-1 flex items-center justify-center gap-2 text-xs text-muted-foreground min-h-24`,children:[(0,$.jsx)(Te,{className:`h-4 w-4 animate-spin`}),`Loading preview...`]}),t[47]=n):n=t[47];let r;return t[48]!==k||t[49]!==e?(r=(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[k,e,n]}),t[48]=k,t[49]=e,t[50]=r):r=t[50],r}if(b){let e;t[51]===j?e=t[52]:(e=j({includeMime:!0}),t[51]=j,t[52]=e);let n;t[53]===b.message?n=t[54]:(n=(0,$.jsxs)(`div`,{className:`px-4 pb-4 text-xs text-destructive`,children:[`Failed to load preview: `,b.message]}),t[53]=b.message,t[54]=n);let r;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(ze,{className:`h-3 w-3 mr-1`}),t[55]=r):r=t[55];let i;t[56]===x?i=t[57]:(i=(0,$.jsx)(`div`,{className:`px-4 pb-4`,children:(0,$.jsxs)(q,{variant:`secondary`,size:`xs`,onClick:x,children:[r,`Retry`]})}),t[56]=x,t[57]=i);let a;return t[58]!==k||t[59]!==e||t[60]!==n||t[61]!==i?(a=(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[k,e,n,i]}),t[58]=k,t[59]=e,t[60]=n,t[61]=i,t[62]=a):a=t[62],a}if(v){let e;t[63]===j?e=t[64]:(e=j({}),t[63]=j,t[64]=e);let n=v.type===`text`?v.content:void 0,r;t[65]!==v.type||t[66]!==v.url?(r=v.type===`media`?{url:v.url}:void 0,t[65]=v.type,t[66]=v.url,t[67]=r):r=t[67];let i;t[68]!==f||t[69]!==d||t[70]!==n||t[71]!==r?(i=(0,$.jsx)(W,{mimeType:f,filename:d,contents:n,mediaSource:r}),t[68]=f,t[69]=d,t[70]=n,t[71]=r,t[72]=i):i=t[72];let a;return t[73]!==k||t[74]!==e||t[75]!==i?(a=(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[k,e,i]}),t[73]=k,t[74]=e,t[75]=i,t[76]=a):a=t[76],a}let M;t[77]===j?M=t[78]:(M=j({includeMime:!0}),t[77]=j,t[78]=M);let N;t[79]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsxs)(`div`,{className:`p-4 flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(xe,{className:`h-4 w-4`}),`Preview not available for this file type.`]}),t[79]=N):N=t[79];let P;return t[80]!==k||t[81]!==M?(P=(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[k,M,N]}),t[80]=k,t[81]=M,t[82]=P):P=t[82],P},Ut=16;function Wt(e){return{paddingLeft:e*Ut}}function Gt(e,t){return new Date(e*1e3).toLocaleDateString(t,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function Kt(e){let t=e.endsWith(`/`)?e.slice(0,-1):e,n=t.split(`/`);return n[n.length-1]||t}function qt(e){return e.endsWith(`/`)?e:`${e}/`}function Jt(e,t){let n=e.metadata?.id;return typeof n==`string`&&n.length>0?n:`${e.path}::${t}`}function Yt(e,{namespace:t,searchValue:n,entriesByPath:r}){let i=n.trim().toLowerCase(),a=e.path.toLowerCase();if(Kt(e.path).toLowerCase().includes(i)||a.includes(i))return!0;if(e.kind===`directory`){let i=r.get(p(t,qt(e.path)));if(i)return i.some(e=>Yt(e,{namespace:t,searchValue:n,entriesByPath:r}))}return!1}function Xt(e,t){return t.searchValue.trim()?e.filter(e=>Yt(e,t)):e}var Zt=5;function Qt(e){return{query:e,status:`idle`}}function $t(e){return e.status===`idle`||e.status===`error`||e.status===`capped`}function en(e,t,n){return t.get(e)===void 0||n.get(e)?.nextPageToken!=null}function tn({hasSearch:e,hasLoadedMatches:t,isPending:n,remoteSearch:r,searchKey:i,entriesByPath:a,pageMetadataByPath:o}){return!e||t||n||!$t(r)?!1:en(i,a,o)}function nn(e){let t=e.trim(),n=t.lastIndexOf(`/`);return n===-1?``:t.slice(0,n+1)}function rn(e,t){let n=t.trim().toLowerCase();return!n||e.path.toLowerCase().includes(n)||Kt(e.path).toLowerCase().includes(n)}var an=e=>{let t=(0,Q.c)(15),{depth:n,isLoading:r,error:i,onLoadMore:a}=e,o;t[0]===n?o=t[1]:(o=Wt(n),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=r&&(0,$.jsx)(Te,{className:`h-3 w-3 mr-1 animate-spin`}),t[2]=r,t[3]=s);let c=r?`Loading...`:`Load more`,l;t[4]!==r||t[5]!==a||t[6]!==s||t[7]!==c?(l=(0,$.jsxs)(q,{variant:`text`,size:`xs`,className:`h-6 px-0 hover:text-blue-600`,disabled:r,onClick:a,children:[s,c]}),t[4]=r,t[5]=a,t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===i?u=t[10]:(u=i&&(0,$.jsxs)(`span`,{className:`ml-2 text-destructive`,children:[`Failed to load: `,i.message]}),t[9]=i,t[10]=u);let d;return t[11]!==o||t[12]!==l||t[13]!==u?(d=(0,$.jsxs)(`div`,{className:`py-px text-xs`,style:o,children:[l,u]}),t[11]=o,t[12]=l,t[13]=u,t[14]=d):d=t[14],d},on=e=>{let t=(0,Q.c)(44),{namespace:n,protocol:r,rootPath:i,backendType:a,prefix:o,depth:c,locale:l,searchValue:u,onOpenFile:d}=e,{entriesByPath:f}=b(),{entries:p,isPending:m,error:h,hasMore:g,loadMore:_,isLoadingMore:v,loadMoreError:y}=s(n,o);if(m){let e;t[0]===c?e=t[1]:(e=Wt(c),t[0]=c,t[1]=e);let n;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(Te,{className:`h-3 w-3 animate-spin`}),t[2]=n):n=t[2];let r;return t[3]===e?r=t[4]:(r=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 py-1 text-xs text-muted-foreground`,style:e,children:[n,`Loading...`]}),t[3]=e,t[4]=r),r}if(h){let e;t[5]===c?e=t[6]:(e=Wt(c),t[5]=c,t[6]=e);let n;return t[7]!==h.message||t[8]!==e?(n=(0,$.jsxs)(`div`,{className:`py-1 text-xs text-destructive`,style:e,children:[`Failed to load: `,h.message]}),t[7]=h.message,t[8]=e,t[9]=n):n=t[9],n}if(p.length===0){let e;t[10]===c?e=t[11]:(e=Wt(c),t[10]=c,t[11]=e);let n;return t[12]===e?n=t[13]:(n=(0,$.jsx)(`div`,{className:`py-1 text-xs text-muted-foreground italic`,style:e,children:`Empty`}),t[12]=e,t[13]=n),n}let x;if(t[14]!==a||t[15]!==p||t[16]!==c||t[17]!==f||t[18]!==l||t[19]!==n||t[20]!==d||t[21]!==r||t[22]!==i||t[23]!==u){let e=Xt(p,{namespace:n,searchValue:u,entriesByPath:f}),o;t[25]!==a||t[26]!==p||t[27]!==c||t[28]!==l||t[29]!==n||t[30]!==d||t[31]!==r||t[32]!==i||t[33]!==u?(o=e=>{let t=Jt(e,p.indexOf(e));return(0,$.jsx)(sn,{rowKey:t,entry:e,namespace:n,protocol:r,rootPath:i,backendType:a,depth:c,locale:l,searchValue:u,onOpenFile:d},t)},t[25]=a,t[26]=p,t[27]=c,t[28]=l,t[29]=n,t[30]=d,t[31]=r,t[32]=i,t[33]=u,t[34]=o):o=t[34],x=e.map(o),t[14]=a,t[15]=p,t[16]=c,t[17]=f,t[18]=l,t[19]=n,t[20]=d,t[21]=r,t[22]=i,t[23]=u,t[24]=x}else x=t[24];let S;t[35]!==c||t[36]!==g||t[37]!==v||t[38]!==_||t[39]!==y?(S=g&&(0,$.jsx)(an,{depth:c,isLoading:v,error:y,onLoadMore:_}),t[35]=c,t[36]=g,t[37]=v,t[38]=_,t[39]=y,t[40]=S):S=t[40];let C;return t[41]!==x||t[42]!==S?(C=(0,$.jsxs)($.Fragment,{children:[x,S]}),t[41]=x,t[42]=S,t[43]=C):C=t[43],C},sn=e=>{let t=(0,Q.c)(115),{entry:n,rowKey:r,namespace:i,protocol:a,rootPath:o,backendType:s,depth:c,locale:u,searchValue:d,onOpenFile:f}=e,[h,g]=(0,Z.useState)(!1),{entriesByPath:_}=b(),v=ct(),y=n.kind===`directory`,x,S,C,w,T,E,O,k,A,j,M;if(t[0]!==s||t[1]!==c||t[2]!==_||t[3]!==n||t[4]!==y||t[5]!==h||t[6]!==i||t[7]!==f||t[8]!==a||t[9]!==r||t[10]!==d){w=Kt(n.path);let e;t[22]===d?e=t[23]:(e=d.trim(),t[22]=d,t[23]=e);let o=!!e;T=y&&o&&w.toLowerCase().includes(d.trim().toLowerCase());let u;t[24]!==_||t[25]!==n.path||t[26]!==o||t[27]!==y||t[28]!==i||t[29]!==d?(u=y&&o&&!!_.get(p(i,qt(n.path)))?.some(e=>Yt(e,{namespace:i,searchValue:d,entriesByPath:_})),t[24]=_,t[25]=n.path,t[26]=o,t[27]=y,t[28]=i,t[29]=d,t[30]=u):u=t[30],S=h||u;let v;t[31]!==n.path||t[32]!==i?(v=async()=>{try{let e=await l.request({namespace:i,path:n.path});if(e.error){Ke({title:`Download failed`,description:e.error,variant:`danger`});return}e.url&&re(e.url,e.filename??`download`)}catch(e){let t=e;D.error(`Failed to download storage entry`,t),Ke({title:`Download failed`,description:String(t),variant:`danger`})}},t[31]=n.path,t[32]=i,t[33]=v):v=t[33],C=v,x=m;let b=y&&`font-medium`;t[34]===b?E=t[35]:(E=N(`text-xs flex items-center gap-1.5 cursor-pointer rounded-none group h-6.5`,b),t[34]=b,t[35]=E),t[36]===c?O=t[37]:(O=Wt(c),t[36]=c,t[37]=O),k=`${i}:${r}`,t[38]!==s||t[39]!==S||t[40]!==n||t[41]!==y||t[42]!==i||t[43]!==f||t[44]!==a?(A=()=>{y?g(!S):f({entry:n,namespace:i,protocol:a,backendType:s})},t[38]=s,t[39]=S,t[40]=n,t[41]=y,t[42]=i,t[43]=f,t[44]=a,t[45]=A):A=t[45],t[46]!==S||t[47]!==y?(j=y?(0,$.jsx)(ce,{isExpanded:S,className:`h-3 w-3`}):(0,$.jsx)(`span`,{className:`w-3 shrink-0`}),t[46]=S,t[47]=y,t[48]=j):j=t[48],M=y?(0,$.jsx)(ge,{className:N(`h-3.5 w-3.5 shrink-0`,ve.directory)}):_e(w),t[0]=s,t[1]=c,t[2]=_,t[3]=n,t[4]=y,t[5]=h,t[6]=i,t[7]=f,t[8]=a,t[9]=r,t[10]=d,t[11]=x,t[12]=S,t[13]=C,t[14]=w,t[15]=T,t[16]=E,t[17]=O,t[18]=k,t[19]=A,t[20]=j,t[21]=M}else x=t[11],S=t[12],C=t[13],w=t[14],T=t[15],E=t[16],O=t[17],k=t[18],A=t[19],j=t[20],M=t[21];let P;t[49]===w?P=t[50]:(P=(0,$.jsx)(`span`,{className:`truncate flex-1 text-left`,children:w}),t[49]=w,t[50]=P);let F;t[51]!==n.size||t[52]!==u?(F=n.size>0&&(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground pr-2 tabular-nums`,children:ft(n.size,u)}),t[51]=n.size,t[52]=u,t[53]=F):F=t[53];let H;t[54]!==n.lastModified||t[55]!==u?(H=n.lastModified!=null&&(0,$.jsx)(K,{content:`Last modified: ${new Date(n.lastModified*1e3).toLocaleString()}`,children:(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground pr-1 whitespace-nowrap`,children:Gt(n.lastModified,u)})}),t[54]=n.lastModified,t[55]=u,t[56]=H):H=t[56];let U;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(le,{iconClassName:`h-3 w-3`,onClick:un})}),t[57]=U):U=t[57];let W;t[58]!==s||t[59]!==n||t[60]!==y||t[61]!==i||t[62]!==f||t[63]!==a?(W=!y&&(0,$.jsxs)(I,{onSelect:()=>f({entry:n,namespace:i,protocol:a,backendType:s}),children:[(0,$.jsx)(Mt,{className:`h-3.5 w-3.5 mr-2`}),`View`]}),t[58]=s,t[59]=n,t[60]=y,t[61]=i,t[62]=f,t[63]=a,t[64]=W):W=t[64];let ee;t[65]===n.path?ee=t[66]:(ee=async()=>{await Ge(n.path),Ke({title:`Copied to clipboard`})},t[65]=n.path,t[66]=ee);let G;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,$.jsx)(me,{className:de}),t[67]=G):G=t[67];let te;t[68]===ee?te=t[69]:(te=(0,$.jsxs)(I,{onSelect:ee,children:[G,`Copy path`]}),t[68]=ee,t[69]=te);let ne;t[70]!==C||t[71]!==y?(ne=!y&&(0,$.jsxs)(I,{onSelect:()=>C(),children:[(0,$.jsx)(V,{className:`h-3.5 w-3.5 mr-2`}),`Download`]}),t[70]=C,t[71]=y,t[72]=ne):ne=t[72];let q;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,$.jsx)(L,{}),t[73]=q):q=t[73];let J;t[74]!==v||t[75]!==s||t[76]!==n||t[77]!==i||t[78]!==a?(J=zt.map(e=>{let t=e.getCode({variableName:i,protocol:a,entry:n,backendType:s});if(t===null)return null;let r=e.icon;return(0,$.jsxs)(I,{onSelect:()=>v(t),children:[(0,$.jsx)(r,{className:de}),e.label]},e.id)}),t[74]=v,t[75]=s,t[76]=n,t[77]=i,t[78]=a,t[79]=J):J=t[79];let Y;t[80]!==W||t[81]!==te||t[82]!==ne||t[83]!==J?(Y=(0,$.jsxs)(B,{children:[U,(0,$.jsxs)(z,{align:`end`,onClick:dn,onCloseAutoFocus:fn,children:[W,te,ne,q,J]})]}),t[80]=W,t[81]=te,t[82]=ne,t[83]=J,t[84]=Y):Y=t[84];let X;t[85]!==Y||t[86]!==F||t[87]!==H?(X=(0,$.jsxs)(`div`,{className:`flex items-center`,children:[F,H,Y]}),t[85]=Y,t[86]=F,t[87]=H,t[88]=X):X=t[88];let ie;t[89]!==x||t[90]!==E||t[91]!==X||t[92]!==O||t[93]!==k||t[94]!==A||t[95]!==j||t[96]!==M||t[97]!==P?(ie=(0,$.jsxs)(x,{className:E,style:O,value:k,onSelect:A,children:[j,M,P,X]}),t[89]=x,t[90]=E,t[91]=X,t[92]=O,t[93]=k,t[94]=A,t[95]=j,t[96]=M,t[97]=P,t[98]=ie):ie=t[98];let ae;t[99]!==s||t[100]!==c||t[101]!==S||t[102]!==n.path||t[103]!==y||t[104]!==u||t[105]!==i||t[106]!==f||t[107]!==a||t[108]!==o||t[109]!==d||t[110]!==T?(ae=y&&S&&(0,$.jsx)(on,{namespace:i,protocol:a,rootPath:o,backendType:s,prefix:qt(n.path),depth:c+1,locale:u,searchValue:T?``:d,onOpenFile:f}),t[99]=s,t[100]=c,t[101]=S,t[102]=n.path,t[103]=y,t[104]=u,t[105]=i,t[106]=f,t[107]=a,t[108]=o,t[109]=d,t[110]=T,t[111]=ae):ae=t[111];let oe;return t[112]!==ie||t[113]!==ae?(oe=(0,$.jsxs)($.Fragment,{children:[ie,ae]}),t[112]=ie,t[113]=ae,t[114]=oe):oe=t[114],oe},cn=e=>{let t=(0,Q.c)(66),{namespace:n,locale:r,searchValue:i,remoteSearch:a,onContinueRemoteSearch:o,onOpenFile:c}=e,[l,u]=(0,Z.useState)(!0),{entriesByPath:d,pageMetadataByPath:h}=b(),{clearNamespaceCache:g}=f(),_=n.name??n.displayName,{entries:v,isPending:y,error:x,hasMore:S,loadMore:C,isLoadingMore:w,loadMoreError:T,refetch:E}=s(_),D;t[0]!==g||t[1]!==_||t[2]!==E?(D=e=>{e.stopPropagation(),g(_),E()},t[0]=g,t[1]=_,t[2]=E,t[3]=D):D=t[3];let O=D,k=y?n.storageEntries:v,A;if(t[4]!==k||t[5]!==d||t[6]!==x||t[7]!==O||t[8]!==S||t[9]!==l||t[10]!==w||t[11]!==y||t[12]!==C||t[13]!==T||t[14]!==r||t[15]!==n.backendType||t[16]!==n.displayName||t[17]!==n.name||t[18]!==n.protocol||t[19]!==n.rootPath||t[20]!==_||t[21]!==o||t[22]!==c||t[23]!==h||t[24]!==a||t[25]!==i){let e=Xt(k,{namespace:_,searchValue:i,entriesByPath:d}),s=nn(i),f=p(_,s),g=s===``?[]:d.get(f)??[],v=Xt(g,{namespace:_,searchValue:i,entriesByPath:d}),b;t[27]===i?b=t[28]:(b=i.trim(),t[27]=i,t[28]=b);let E=!!b,D=e.length>0||v.length>0,j=s!==``&&tn({hasSearch:E,hasLoadedMatches:D,isPending:y,remoteSearch:a,searchKey:f,entriesByPath:d,pageMetadataByPath:h}),M=E&&e.length===0,N;bb0:{if(y&&k.length===0){let e;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(Te,{className:`h-3 w-3 animate-spin`}),`Loading...`]}),t[29]=e):e=t[29],N=e;break bb0}if(a.status===`searching`){let e;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(Te,{className:`h-3 w-3 animate-spin`}),`Searching more entries...`]}),t[30]=e):e=t[30],N=e;break bb0}if(a.status===`error`){let e;t[31]===a.error.message?e=t[32]:(e=(0,$.jsxs)(`span`,{className:`text-destructive`,children:[`Search failed: `,a.error.message]}),t[31]=a.error.message,t[32]=e),N=e;break bb0}if(a.status===`capped`){let e;t[33]===o?e=t[34]:(e=(0,$.jsx)(q,{variant:`text`,size:`xs`,className:`h-5 px-0 text-xs hover:text-blue-600`,onClick:o,children:`Continue searching`}),t[33]=o,t[34]=e);let n;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`span`,{className:`text-[10px]`,children:`(or press Enter)`}),t[35]=n):n=t[35];let r;t[36]===e?r=t[37]:(r=(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Searched more entries.`,e,n]}),t[36]=e,t[37]=r),N=r;break bb0}if(a.status===`exhausted`&&!D){N=`No matches`;break bb0}if(!E&&!y&&k.length===0){N=`No entries`;break bb0}if(j){let e;t[38]===o?e=t[39]:(e=(0,$.jsx)(q,{variant:`text`,size:`xs`,className:`h-5 px-0 text-xs hover:text-blue-600`,onClick:o,children:`Search more entries`}),t[38]=o,t[39]=e);let n;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`span`,{className:`text-[10px]`,children:`(or press Enter)`}),t[40]=n):n=t[40];let r;t[41]===e?r=t[42]:(r=(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`No loaded matches.`,e,n]}),t[41]=e,t[42]=r),N=r;break bb0}if(E&&!D&&k.length>0){N=`No matches`;break bb0}N=null}let P=N,F;t[43]===l?F=t[44]:(F=()=>u(!l),t[43]=l,t[44]=F);let I;t[45]===l?I=t[46]:(I=(0,$.jsx)(ce,{isExpanded:l,className:`h-3 w-3`}),t[45]=l,t[46]=I);let L;t[47]===n.protocol?L=t[48]:(L=(0,$.jsx)(Ce,{protocol:n.protocol}),t[47]=n.protocol,t[48]=L);let R;t[49]===n.displayName?R=t[50]:(R=(0,$.jsx)(`span`,{children:n.displayName}),t[49]=n.displayName,t[50]=R);let z;t[51]===n.name?z=t[52]:(z=n.name&&(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground font-normal`,children:[`(`,(0,$.jsx)(vt,{variableName:n.name}),`)`]}),t[51]=n.name,t[52]=z);let B;t[53]===O?B=t[54]:(B=(0,$.jsx)(ue,{onClick:O,tooltip:`Refresh storage connection`,className:`p-0`,iconClassName:`h-3 w-3`}),t[53]=O,t[54]=B);let V=n.rootPath||`(root)`,H;t[55]===V?H=t[56]:(H=(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground font-normal tabular-nums ml-auto`,children:V}),t[55]=V,t[56]=H);let W;t[57]!==n.name||t[58]!==B||t[59]!==H||t[60]!==F||t[61]!==I||t[62]!==L||t[63]!==R||t[64]!==z?(W=(0,$.jsxs)(m,{value:n.name,onSelect:F,className:`flex flex-row font-semibold h-7 text-xs gap-1.5 bg-(--slate-2) text-muted-foreground rounded-none`,children:[I,L,R,z,B,H]}),t[57]=n.name,t[58]=B,t[59]=H,t[60]=F,t[61]=I,t[62]=L,t[63]=R,t[64]=z,t[65]=W):W=t[65],A=(0,$.jsxs)($.Fragment,{children:[W,l&&(0,$.jsxs)($.Fragment,{children:[x&&k.length===0&&(0,$.jsx)(U,{error:x,style:Wt(1),className:`py-1 text-xs h-auto overflow-auto max-h-32 items-start`,showIcon:!1}),!x&&P&&(0,$.jsx)(`div`,{className:`py-1 text-xs text-muted-foreground italic`,style:Wt(1),children:P}),e.map(e=>{let t=Jt(e,k.indexOf(e));return(0,$.jsx)(sn,{rowKey:t,entry:e,namespace:_,protocol:n.protocol,rootPath:n.rootPath,backendType:n.backendType,depth:1,locale:r,searchValue:i,onOpenFile:c},t)}),M&&v.map(e=>{let t=Jt(e,g.indexOf(e));return(0,$.jsx)(sn,{rowKey:`remote-search:${t}`,entry:e,namespace:_,protocol:n.protocol,rootPath:n.rootPath,backendType:n.backendType,depth:1,locale:r,searchValue:i,onOpenFile:c},`remote-search:${t}`)}),S&&!j&&(0,$.jsx)(an,{depth:1,isLoading:w,error:T,onLoadMore:C})]})]}),t[4]=k,t[5]=d,t[6]=x,t[7]=O,t[8]=S,t[9]=l,t[10]=w,t[11]=y,t[12]=C,t[13]=T,t[14]=r,t[15]=n.backendType,t[16]=n.displayName,t[17]=n.name,t[18]=n.protocol,t[19]=n.rootPath,t[20]=_,t[21]=o,t[22]=c,t[23]=h,t[24]=a,t[25]=i,t[26]=A}else A=t[26];return A},ln=()=>{let e=(0,Q.c)(63),{namespaces:t,entriesByPath:n,pageMetadataByPath:r}=b(),{locale:i}=Qe(),[a,s]=(0,Z.useState)(``),c;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(c={},e[0]=c):c=e[0];let[l,u]=(0,Z.useState)(c),[d,f]=(0,Z.useState)(null),m=y(),h;e[1]===a?h=e[2]:(h=a.trim(),e[1]=a,e[2]=h);let v=!!h,x;e[3]===a?x=e[4]:(x=a.trim(),e[3]=a,e[4]=x);let S=x,C;e[5]!==S||e[6]!==l?(C=e=>{let t=l[e];return t?.query===S?t:Qt(S)},e[5]=S,e[6]=l,e[7]=C):C=e[7];let w=C,T;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(T=(e,t)=>{u(n=>({...n,[e]:t}))},e[8]=T):T=e[8];let E=T,D;e[9]!==S||e[10]!==n||e[11]!==r||e[12]!==w?(D=e=>{if(!S)return!1;let t=e.name??e.displayName,i=nn(S);if(i===``||!$t(w(t))||Xt(n.get(p(t,``))??e.storageEntries,{namespace:t,searchValue:S,entriesByPath:n}).length>0)return!1;let a=p(t,i);return Xt(n.get(a)??[],{namespace:t,searchValue:S,entriesByPath:n}).length>0?!1:en(a,n,r)},e[9]=S,e[10]=n,e[11]=r,e[12]=w,e[13]=D):D=e[13];let O=D,k;e[14]!==O||e[15]!==S||e[16]!==n||e[17]!==m||e[18]!==r?(k=async e=>{if(!O(e))return;let t=S,i=e.name??e.displayName,a=nn(t),o=p(i,a),s=n.get(o),c=r.get(o)?.nextPageToken??null,l=s!==void 0;E(i,{query:t,status:`searching`});try{for(let e=0;e<Zt;e++){let e=!l||c!==null,n=[];if(e){let e=await m({namespace:i,prefix:a,pageToken:c,append:l});n=e.entries,c=e.next_page_token??null,l=!0}if((e?n:s??[]).some(e=>rn(e,t))){E(i,{query:t,status:`found`});return}if(c===null){E(i,{query:t,status:`exhausted`});return}}E(i,{query:t,status:`capped`})}catch(e){let n=e;E(i,{query:t,status:`error`,error:n instanceof Error?n:Error(String(n))})}},e[14]=O,e[15]=S,e[16]=n,e[17]=m,e[18]=r,e[19]=k):k=e[19];let A=k,j;e[20]!==O||e[21]!==A||e[22]!==t?(j=()=>{let e=t.filter(O);for(let t of e)A(t)},e[20]=O,e[21]=A,e[22]=t,e[23]=j):j=e[23];let M=j;if(t.length===0){let t;return e[24]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(dt,{title:`No storage connected`,description:(0,$.jsxs)(`span`,{children:[`Create an obstore or fsspec connection in your notebook. See the`,` `,(0,$.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`}),`.`]}),action:(0,$.jsx)(gt,{group:`storage`,label:`Add remote storage`,variant:`outline`,size:`sm`}),icon:(0,$.jsx)(Se,{className:`h-8 w-8`})}),e[24]=t):t=e[24],t}let P;e[25]===d?P=e[26]:(P=d&&(0,$.jsx)(Ht,{entry:d.entry,namespace:d.namespace,protocol:d.protocol,backendType:d.backendType,onBack:()=>f(null)}),e[25]=d,e[26]=P);let F=d&&`hidden`,I;e[27]===F?I=e[28]:(I=N(`border-b bg-background rounded-none h-full pb-10 overflow-auto outline-hidden scrollbar-thin`,F),e[27]=F,e[28]=I);let L;e[29]!==O||e[30]!==M||e[31]!==t?(L=e=>{e.key===`Enter`&&t.some(O)&&(e.preventDefault(),M())},e[29]=O,e[30]=M,e[31]=t,e[32]=L):L=e[32];let R;e[33]!==a||e[34]!==L?(R=(0,$.jsx)(_,{placeholder:`Search entries...`,className:`h-6 m-1`,value:a,onValueChange:s,onKeyDown:L,rootClassName:`flex-1 border-b-0`}),e[33]=a,e[34]=L,e[35]=R):R=e[35];let z;e[36]===v?z=e[37]:(z=v&&(0,$.jsx)(q,{variant:`text`,size:`xs`,className:`float-right border-none px-2 m-0 h-full`,onClick:()=>s(``),children:(0,$.jsx)(oe,{className:`h-4 w-4`})}),e[36]=v,e[37]=z);let B,V;e[38]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(K,{content:`Search by file name within loaded entries, or by prefix (e.g. 'folder/x') for backend search. Press Enter to fetch more results.`,delayDuration:200,children:(0,$.jsx)(pe,{className:`h-3.5 w-3.5 shrink-0 cursor-help text-muted-foreground hover:text-foreground mr-2`})}),V=(0,$.jsx)(gt,{group:`storage`,label:`Add remote storage`,compact:!0,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`}),e[38]=B,e[39]=V):(B=e[38],V=e[39]);let H;e[40]!==R||e[41]!==z?(H=(0,$.jsxs)(`div`,{className:`flex items-center w-full border-b`,children:[R,z,B,V]}),e[40]=R,e[41]=z,e[42]=H):H=e[42];let U;if(e[43]!==A||e[44]!==i||e[45]!==t||e[46]!==w||e[47]!==a){let n;e[49]!==A||e[50]!==i||e[51]!==w||e[52]!==a?(n=e=>{let t=e.name??e.displayName;return(0,$.jsx)(cn,{namespace:e,locale:i,searchValue:a,remoteSearch:w(t),onContinueRemoteSearch:()=>void A(e),onOpenFile:f},t)},e[49]=A,e[50]=i,e[51]=w,e[52]=a,e[53]=n):n=e[53],U=t.map(n),e[43]=A,e[44]=i,e[45]=t,e[46]=w,e[47]=a,e[48]=U}else U=e[48];let W;e[54]===U?W=e[55]:(W=(0,$.jsx)(o,{className:`flex flex-col`,children:U}),e[54]=U,e[55]=W);let ee;e[56]!==I||e[57]!==H||e[58]!==W?(ee=(0,$.jsxs)(g,{className:I,shouldFilter:!1,children:[H,W]}),e[56]=I,e[57]=H,e[58]=W,e[59]=ee):ee=e[59];let G;return e[60]!==ee||e[61]!==P?(G=(0,$.jsxs)(`div`,{className:`h-full flex flex-col`,children:[P,ee]}),e[60]=ee,e[61]=P,e[62]=G):G=e[62],G};function un(e){return e.stopPropagation()}function dn(e){return e.stopPropagation()}function fn(e){return e.preventDefault()}var pn=(0,Z.createContext)(null);function mn(){return(0,Z.useContext)(pn)??void 0}var hn=e=>{let t=(0,Q.c)(3),{children:n}=e,r=Fe(),i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(pn.Provider,{value:r,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i},gn=e=>{let t=(0,Q.c)(5),{children:n}=e,[r,i]=(0,Z.useState)(null),a;t[0]!==n||t[1]!==r?(a=r&&(0,$.jsx)(Ne,{backend:ke,options:{rootElement:r},children:(0,$.jsx)(hn,{children:n})}),t[0]=n,t[1]=r,t[2]=a):a=t[2];let o;return t[3]===a?o=t[4]:(o=(0,$.jsx)(`div`,{ref:i,className:`contents`,children:a}),t[3]=a,t[4]=o),o},_n=e(C(),1),vn=200;function yn({query:e,tree:t,showHiddenFiles:n}){let{sendSearchFiles:r}=Xe(),i=$e(e,300),a=(0,Z.useRef)(null),[o,s]=(0,Z.useState)(0),c=(0,Z.useCallback)(()=>s(e=>e+1),[]),l=(0,Z.useMemo)(()=>({query:e,tree:t,showHiddenFiles:n,revision:o,sendSearchFiles:r}),[e,t,n,o,r]),[u,d]=(0,Z.useState)();return(0,Z.useEffect)(()=>{let{query:e,tree:t,showHiddenFiles:n,sendSearchFiles:r}=l,o=!1;if(!e||e!==i)return;let s=(a.current??Promise.resolve()).then(async()=>{let i=new Map,a=!1,s=0,c=t.getRoots();for(let t of c){if(o)return;try{let o=await r({query:e,path:t.path,includeFiles:!0,includeDirectories:!0,includeHidden:n,depth:20,limit:vn});a||=o.files.length>=vn;for(let e of o.files){let n=i.get(e.path);n&&(!t.isPrimary||n.isPrimaryRoot)||i.set(e.path,{...e,id:Me(t.path,e.path),children:[],isRoot:!1,rootPath:t.path,isPrimaryRoot:t.isPrimary})}}catch{s+=1}}if(!o){if(c.length>0&&s===c.length){d({requestIdentity:l,state:{status:`error`,query:e,error:Error(`Could not search any root`)}});return}let t=t=>{let n=t.name.toLowerCase(),r=e.toLowerCase();return n===r?0:n.startsWith(r)?1:2},n=[...i.values()].toSorted((e,n)=>t(e)-t(n)||e.name.localeCompare(n.name));d({requestIdentity:l,state:{status:`success`,isPartial:s>0,query:e,files:n.slice(0,vn),hasMore:a||n.length>vn}})}});return a.current=s.catch(t=>{o||d({requestIdentity:l,state:{status:`error`,query:e,error:t}})}),()=>{o=!0}},[i,l]),e?e!==i||u?.requestIdentity!==l?{state:{status:`loading`,query:e},refetch:c}:{state:u.state,refetch:c}:{state:{status:`idle`},refetch:c}}function bn(e,t){let n=(0,Q.c)(7),r=e.tree,i=(0,Z.useRef)(null),a,o;n[0]!==t||n[1]!==e.data.isDirectory||n[2]!==e.id||n[3]!==e.isOpen||n[4]!==r?(a=()=>{if(!t){i.current=null;return}if(!e.data.isDirectory||e.isOpen||i.current===e.id)return;let n=window.setTimeout(()=>{i.current=e.id,r.open(e.id)},600);return()=>window.clearTimeout(n)},o=[t,e.data.isDirectory,e.isOpen,e.id,r],n[0]=t,n[1]=e.data.isDirectory,n[2]=e.id,n[3]=e.isOpen,n[4]=r,n[5]=a,n[6]=o):(a=n[5],o=n[6]),(0,Z.useEffect)(a,o)}async function xn(e,t){if(!A()){let n=M().formatNavigableHttpURL(`api/files/download`,new URLSearchParams({path:e}));re(n.toString(),t);return}let n=await Ze().sendFileDetails({path:e});if(n.isBase64&&n.contents){let e=tt(fe(n.contents,n.mimeType||`application/octet-stream`));ne(e,t)}else ne(new Blob([n.contents||``],{type:n.mimeType||`application/octet-stream`}),t)}var Sn=e=>{let t=(0,Q.c)(21),{file:n,mimeType:r,message:i,onDownload:a}=e,{locale:o}=Qe(),s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(`span`,{className:`text-muted-foreground font-medium`,children:`Path`}),t[0]=s):s=t[0];let c;t[1]===n.path?c=t[2]:(c=(0,$.jsx)(`span`,{className:`font-mono text-xs break-all`,children:n.path}),t[1]=n.path,t[2]=c);let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`span`,{className:`text-muted-foreground font-medium`,children:`Type`}),t[3]=l):l=t[3];let u;t[4]===r?u=t[5]:(u=(0,$.jsx)(`span`,{children:r}),t[4]=r,t[5]=u);let d;t[6]!==n.size||t[7]!==o?(d=n.size!=null&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-muted-foreground font-medium`,children:`Size`}),(0,$.jsx)(`span`,{children:ft(n.size,o)})]}),t[6]=n.size,t[7]=o,t[8]=d):d=t[8];let f;t[9]!==c||t[10]!==u||t[11]!==d?(f=(0,$.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr] gap-x-4 gap-y-2`,children:[s,c,l,u,d]}),t[9]=c,t[10]=u,t[11]=d,t[12]=f):f=t[12];let p;t[13]===i?p=t[14]:(p=(0,$.jsx)(`div`,{className:`mt-4 text-muted-foreground italic`,children:i}),t[13]=i,t[14]=p);let m;t[15]===a?m=t[16]:(m=a&&(0,$.jsxs)(q,{variant:`outline`,size:`sm`,className:`mt-4`,onClick:a,children:[(0,$.jsx)(V,{className:`h-3.5 w-3.5 mr-2`}),`Download`]}),t[15]=a,t[16]=m);let h;return t[17]!==f||t[18]!==p||t[19]!==m?(h=(0,$.jsxs)(`div`,{className:`p-4 text-sm`,children:[f,p,m]}),t[17]=f,t[18]=p,t[19]=m,t[20]=h):h=t[20],h};function Cn(e,t){let n=e||`text/plain`;return G(n)?`media`:t?`unsupported`:n===`text/csv`?`csv`:n.startsWith(`text/`)||n!=="default"&&n in H||e==null?`text`:`unsupported`}var wn=10485760,Tn=new Map,En=e=>{let t=(0,Q.c)(91),{file:n,onOpenNotebook:i}=e,{sendFileDetails:a,sendUpdateFile:o}=Xe(),s=r(E),c=r(T),l=r(S),[u,d]=(0,Z.useState)(``),f;t[0]!==n.path||t[1]!==a?(f=async()=>{let e=await a({path:n.path,maxBytes:wn}),t=Cn(e.mimeType,e.isBase64);if(!e.isTooLarge&&t===`text`){let t=e.contents||``;d(Tn.get(n.path)??t)}return e},t[0]=n.path,t[1]=a,t[2]=f):f=t[2];let p;t[3]===n.path?p=t[4]:(p=[n.path],t[3]=n.path,t[4]=p);let{data:m,isPending:h,error:g,setData:_,refetch:v}=et(f,p),y;t[5]!==m?.contents||t[6]!==n.path||t[7]!==u||t[8]!==o||t[9]!==_?(y=async()=>{u!==m?.contents&&await o({path:n.path,contents:u}).then(e=>{e.success&&(_(e=>({...e,contents:u})),d(u))})},t[5]=m?.contents,t[6]=n.path,t[7]=u,t[8]=o,t[9]=_,t[10]=y):y=t[10];let b=y,x=(0,Z.useRef)(u),C,w;t[11]===u?(C=t[12],w=t[13]):(C=()=>{x.current=u},w=[u],t[11]=u,t[12]=C,t[13]=w),(0,Z.useLayoutEffect)(C,w);let D;t[14]!==m||t[15]!==n.path?(D=()=>()=>{if(m?.contents==null||m.isTooLarge||Cn(m.mimeType,m.isBase64)!==`text`)return;let e=x.current;e===m.contents?Tn.delete(n.path):Tn.set(n.path,e)},t[14]=m,t[15]=n.path,t[16]=D):D=t[16];let O=m?.contents,k=m?.isTooLarge,j=m?.mimeType,M=m?.isBase64,N;if(t[17]!==n.path||t[18]!==M||t[19]!==O||t[20]!==k||t[21]!==j?(N=[n.path,O,k,j,M],t[17]=n.path,t[18]=M,t[19]=O,t[20]=k,t[21]=j,t[22]=N):N=t[22],(0,Z.useEffect)(D,N),g){let e;return t[23]===g?e=t[24]:(e=(0,$.jsx)(at,{error:g}),t[23]=g,t[24]=e),e}if(h||!m)return null;let P=m.mimeType||`text/plain`,F;t[25]!==m.isBase64||t[26]!==m.mimeType?(F=Cn(m.mimeType,m.isBase64),t[25]=m.isBase64,t[26]=m.mimeType,t[27]=F):F=t[27];let I=F,L=I===`text`,R=I===`csv`,z=I===`media`,B;t[28]!==l||t[29]!==m.file.isMarimoFile||t[30]!==n.path?(B=l&&m.file.isMarimoFile&&(n.path===l||n.path.endsWith(`/${l}`)),t[28]=l,t[29]=m.file.isMarimoFile,t[30]=n.path,t[31]=B):B=t[31];let V=B,H;t[32]!==m.file.name||t[33]!==n.path?(H=async()=>{await xn(n.path,m.file.name)},t[32]=m.file.name,t[33]=n.path,t[34]=H):H=t[34];let U=H,G;if(t[35]!==m.contents||t[36]!==b||t[37]!==s||t[38]!==u){let e;t[40]!==m.contents||t[41]!==b||t[42]!==u?(e=()=>u!==m.contents&&(b(),!0),t[40]=m.contents,t[41]=b,t[42]=u,t[43]=e):e=t[43],G=Je.of([{key:s.getHotkey(`global.save`).key,stopPropagation:!0,run:e}]),t[35]=m.contents,t[36]=b,t[37]=s,t[38]=u,t[39]=G}else G=t[39];let te=G,ne=c?void 0:U,re;t[44]!==m.file.isMarimoFile||t[45]!==i?(re=m.file.isMarimoFile&&i&&!A()&&(0,$.jsx)(K,{content:`Open notebook`,children:(0,$.jsx)(q,{variant:`text`,size:`xs`,"aria-label":`Open notebook`,onClick:e=>i(e),children:(0,$.jsx)(he,{className:`h-3.5 w-3.5`})})}),t[44]=m.file.isMarimoFile,t[45]=i,t[46]=re):re=t[46];let J;t[47]!==m.contents||t[48]!==b||t[49]!==u||t[50]!==L?(J=L&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{content:`Copy contents to clipboard`,children:(0,$.jsx)(q,{variant:`text`,size:`xs`,onClick:async()=>{await Ge(u)},children:(0,$.jsx)(me,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(K,{content:ot(`global.save`),children:(0,$.jsx)(q,{variant:`text`,size:`xs`,onClick:b,disabled:u===m.contents,children:(0,$.jsx)(Be,{className:`h-3.5 w-3.5`})})})]}),t[47]=m.contents,t[48]=b,t[49]=u,t[50]=L,t[51]=J):J=t[51];let Y;t[52]!==re||t[53]!==J?(Y=(0,$.jsxs)($.Fragment,{children:[re,J]}),t[52]=re,t[53]=J,t[54]=Y):Y=t[54];let X;t[55]!==m.file.name||t[56]!==v||t[57]!==ne||t[58]!==Y?(X=(0,$.jsx)(Nt,{filename:m.file.name,onRefresh:v,onDownload:ne,actions:Y}),t[55]=m.file.name,t[56]=v,t[57]=ne,t[58]=Y,t[59]=X):X=t[59];let ie=X;if(m.isTooLarge||I===`unsupported`){let e=m.isTooLarge?`File is too large to preview.`:`This file type cannot be previewed.`,n=c?void 0:U,r;t[60]!==m.file||t[61]!==P||t[62]!==e||t[63]!==n?(r=(0,$.jsx)(Sn,{file:m.file,mimeType:P,message:e,onDownload:n}),t[60]=m.file,t[61]=P,t[62]=e,t[63]=n,t[64]=r):r=t[64];let i;return t[65]!==ie||t[66]!==r?(i=(0,$.jsxs)($.Fragment,{children:[ie,r]}),t[65]=ie,t[66]=r,t[67]=i):i=t[67],i}let ae;t[68]!==V||t[69]!==L?(ae=L&&V&&(0,$.jsxs)(it,{variant:`warning`,className:`rounded-none`,children:[(0,$.jsx)(He,{className:`h-4 w-4`}),(0,$.jsx)(rt,{children:`Editing the notebook file directly while running in marimo's editor may cause unintended changes. Please use with caution.`})]}),t[68]=V,t[69]=L,t[70]=ae):ae=t[70];let oe=ae,se;t[71]!==m.contents||t[72]!==m.isBase64||t[73]!==z||t[74]!==P?(se=z&&m.contents?ee({contents:m.contents,mimeType:P,isBase64:m.isBase64??!1}):void 0,t[71]=m.contents,t[72]=m.isBase64,t[73]=z,t[74]=P,t[75]=se):se=t[75];let ce=se,le=L?u:R?m.contents??void 0:void 0,ue=!L,de=L?d:void 0,fe;t[76]!==L||t[77]!==te?(fe=L?[te]:[],t[76]=L,t[77]=te,t[78]=fe):fe=t[78];let pe;t[79]!==m.file.name||t[80]!==ce||t[81]!==P||t[82]!==le||t[83]!==ue||t[84]!==de||t[85]!==fe?(pe=(0,$.jsx)(W,{mimeType:P,filename:m.file.name,contents:le,mediaSource:ce,readOnly:ue,onChange:de,extensions:fe}),t[79]=m.file.name,t[80]=ce,t[81]=P,t[82]=le,t[83]=ue,t[84]=de,t[85]=fe,t[86]=pe):pe=t[86];let ge;return t[87]!==ie||t[88]!==pe||t[89]!==oe?(ge=(0,$.jsxs)($.Fragment,{children:[ie,oe,pe]}),t[87]=ie,t[88]=pe,t[89]=oe,t[90]=ge):ge=t[90],ge};function Dn({node:e,attrs:t,innerRef:n,children:r,ariaLabel:i=e.data.name}){return(0,$.jsx)(`div`,{...t,ref:n,"aria-label":i,"aria-expanded":e.isInternal?e.isOpen:void 0,onFocus:n=>{n.stopPropagation(),t.onFocus?.(n),n.target===n.currentTarget&&!e.isFocused&&e.focus()},onClick:n=>{t.onClick?t.onClick(n):e.select(),n.defaultPrevented||n.currentTarget.focus({preventScroll:!0})},children:r})}function On(e){let t=(0,Q.c)(25),{treeRef:n,search:r,height:i,onReveal:a}=e,o=mn(),{state:s,refetch:c}=r;if(s.status===`idle`)return null;if(s.status===`error`){let e;return t[0]===c?e=t[1]:(e=(0,$.jsxs)(`div`,{role:`alert`,className:`px-3 py-2 text-sm`,children:[`Could not search files.`,` `,(0,$.jsx)(`button`,{type:`button`,className:`underline`,onClick:c,children:`Retry`})]}),t[0]=c,t[1]=e),e}if(s.status===`loading`){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 px-3 py-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(Ee,{size:`small`}),`Searching files…`]}),t[2]=e):e=t[2],e}let{files:l,hasMore:u,isPartial:d}=s,f=l.length,p;t[3]===n?p=t[4]:(p=e=>{e.key===`Enter`&&e.target instanceof HTMLElement&&e.target.closest(`[role="tree"]`)&&(e.preventDefault(),e.stopPropagation(),n.current?.focusedNode?.activate())},t[3]=n,t[4]=p);let m;t[5]!==d||t[6]!==c?(m=d&&(0,$.jsxs)(`div`,{role:`alert`,className:`px-3 py-2 text-xs text-muted-foreground`,children:[`Some locations could not be searched.`,` `,(0,$.jsx)(`button`,{type:`button`,className:`underline`,onClick:c,children:`Retry`})]}),t[5]=d,t[6]=c,t[7]=m):m=t[7];let h=l.length?`${f} ${f===1?`match`:`matches`}`:`No matching files or folders.`,g=u&&` · Refine your search for more results.`,_;t[8]!==h||t[9]!==g?(_=(0,$.jsxs)(`p`,{role:`status`,className:`px-3 py-2 text-xs text-muted-foreground`,children:[h,g]}),t[8]=h,t[9]=g,t[10]=_):_=t[10];let v=Math.max(0,i-48-(d?48:0)),y;t[11]===a?y=t[12]:(y=e=>{a(e.data)},t[11]=a,t[12]=y);let b;t[13]!==o||t[14]!==l||t[15]!==v||t[16]!==y||t[17]!==n?(b=(0,$.jsx)(Re,{ref:n,data:l,childrenAccessor:kn,width:`100%`,height:v,rowHeight:48,overscanCount:8,dndManager:o,disableDrag:!0,disableDrop:!0,disableEdit:!0,disableMultiSelection:!0,selectionFollowsFocus:!0,rowClassName:`outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring`,renderRow:An,onActivate:y,children:jn}),t[13]=o,t[14]=l,t[15]=v,t[16]=y,t[17]=n,t[18]=b):b=t[18];let x;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(`p`,{className:`px-3 text-xs text-muted-foreground`,children:`Enter or double-click to open · Esc to clear`}),t[19]=x):x=t[19];let S;return t[20]!==p||t[21]!==m||t[22]!==_||t[23]!==b?(S=(0,$.jsxs)(`div`,{onKeyDownCapture:p,children:[m,_,b,x]}),t[20]=p,t[21]=m,t[22]=_,t[23]=b,t[24]=S):S=t[24],S}function kn(){return null}function An(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(Dn,{...e,ariaLabel:e.node.data.path}),t[0]=e,t[1]=n),n}function jn(e){let t=(0,Q.c)(19),{node:n}=e,r=n.data.isDirectory?ge:xe,i=n.isSelected&&`bg-accent/60`,a;t[0]===i?a=t[1]:(a=N(`flex h-full items-start gap-2.5 px-3 py-1 cursor-pointer hover:bg-accent/50`,i),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=e=>{e.stopPropagation(),n.activate()},t[2]=n,t[3]=o);let s;t[4]===r?s=t[5]:(s=(0,$.jsx)(r,{className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`}),t[4]=r,t[5]=s);let c;t[6]===n.data.name?c=t[7]:(c=(0,$.jsx)(`div`,{className:`truncate text-sm leading-5`,children:n.data.name}),t[6]=n.data.name,t[7]=c);let l;t[8]===n.data.path?l=t[9]:(l=(0,$.jsx)(`div`,{className:`truncate text-xs leading-4 text-muted-foreground`,children:n.data.path}),t[8]=n.data.path,t[9]=l);let u;t[10]!==c||t[11]!==l?(u=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[c,l]}),t[10]=c,t[11]=l,t[12]=u):u=t[12];let d;return t[13]!==n.data.path||t[14]!==a||t[15]!==o||t[16]!==s||t[17]!==u?(d=(0,$.jsxs)(`div`,{className:a,onDoubleClick:o,title:n.data.path,children:[s,u]}),t[13]=n.data.path,t[14]=a,t[15]=o,t[16]=s,t[17]=u,t[18]=d):d=t[18],d}function Mn(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=e.node.data.isDirectory?(0,$.jsx)(Nn,{...e}):(0,$.jsx)(Dn,{...e}),t[0]=e,t[1]=n),n}function Nn(e){let t=(0,Q.c)(15),{node:n}=e,r=n.tree,i=(0,Z.useRef)(null),a;t[0]!==n||t[1]!==r?(a=()=>({accept:`NODE`,canDrop:()=>r.canDrop(),collect:Pn,hover:()=>{(r.state.dnd.parentId!==n.id||r.state.dnd.index!==null)&&r.dispatch({type:`DND_HOVERING`,parentId:n.id,index:null}),r.canDrop()||r.hideCursor()},drop:()=>{r.canDrop()&&(r.props.onMove?.({dragIds:r.state.dnd.dragIds,dragNodes:r.dragNodes,parentId:n.id,parentNode:n,index:0}),r.open(n.id))}}),t[0]=n,t[1]=r,t[2]=a):a=t[2];let o;t[3]!==n.id||t[4]!==r?(o=[r,n.id],t[3]=n.id,t[4]=r,t[5]=o):o=t[5];let[s,c]=Ae(a,o),{isHovering:l}=s;bn(n,l);let u,d;t[6]!==n.isEditing||t[7]!==n.isFocused?(u=()=>{n.isFocused&&!n.isEditing&&i.current?.focus({preventScroll:!0})},d=[n.isFocused,n.isEditing],t[6]=n.isEditing,t[7]=n.isFocused,t[8]=u,t[9]=d):(u=t[8],d=t[9]),(0,Z.useEffect)(u,d);let f;t[10]===c?f=t[11]:(f=e=>{i.current=e,c(e)},t[10]=c,t[11]=f);let p;return t[12]!==e||t[13]!==f?(p=(0,$.jsx)(Dn,{...e,innerRef:f}),t[12]=e,t[13]=f,t[14]=p):p=t[14],p}function Pn(e){return{isHovering:e.isOver({shallow:!0})&&e.canDrop()}}var Fn=n(e=>{let t=e(Ye);return O(t,`no requestClientAtom set`),new Oe({getRoots:t.getFileRoots,listFiles:t.sendListFiles,createFileOrFolder:t.sendCreateFileOrFolder,deleteFileOrFolder:t.sendDeleteFileOrFolder,copyFileOrFolder:t.sendCopyFileOrFolder,renameFileOrFolder:t.sendRenameFileOrFolder})}),In=n({}),Ln=` `,Rn={directory:e=>`os.listdir("${e}")`,python:e=>`with open("${e}", "r") as _f:\n${Ln}...\n`,json:e=>`with open("${e}", "r") as _f:\n${Ln}_data = json.load(_f)\n`,code:e=>`with open("${e}", "r") as _f:\n${Ln}...\n`,text:e=>`with open("${e}", "r") as _f:\n${Ln}...\n`,image:e=>`mo.image("${e}")`,audio:e=>`mo.audio("${e}")`,video:e=>`mo.video("${e}")`,pdf:e=>`with open("${e}", "rb") as _f:\n${Ln}...\n`,zip:e=>`with open("${e}", "rb") as _f:\n${Ln}...\n`,data:e=>`with open("${e}", "r") as _f:\n${Ln}...\n`,unknown:e=>`with open("${e}", "r") as _f:\n${Ln}...\n`},zn=104857600,Bn=5,Vn=`data-file-explorer-directory-path`;function Hn(e){let{destinationPath:t,getDestinationLabel:n=e=>e,onUploadStart:r,refreshDestination:i,...a}=e,{sendCreateFileOrFolder:o}=Xe();return We({multiple:!0,maxSize:zn,...a,onError:e=>{D.error(e),Ke({title:`File upload failed`,description:e.message,variant:`danger`})},onDropRejected:e=>{Ke({title:`File upload failed`,description:(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,children:e.map(e=>(0,$.jsxs)(`div`,{children:[e.file.name,` (`,e.errors.map(e=>e.message).join(`, `),`)`]},e.file.name))}),variant:`danger`})},onDrop:async(e,a,s)=>{if(e.length===0)return;let c=typeof t==`function`?t(s):t,l=n(c),u=e.length===1?`Uploading file to ${l}...`:`Uploading files to ${l}...`;r?.(c,e);let d;try{d=await te(u,async t=>(t.addTotal(e.length),Un({files:e,destinationPath:c,createFile:o,onFileProcessed:()=>t.increment(1)})))}catch{await i(c);return}await i(c),Kn(d,l)}})}async function Un({files:e,destinationPath:t,createFile:n,onFileProcessed:r}){let i=await ut(e,Bn,async e=>{try{return{file:e,response:await n({path:Wn({destinationPath:t,filePath:Jn(qn(e))}),type:`file`,name:e.name,file:e})}}catch(t){return{file:e,response:{success:!1,message:nt(t)}}}finally{r?.()}});return{successful:i.filter(({response:e})=>e.success),failed:i.filter(({response:e})=>!e.success)}}function Wn({destinationPath:e,filePath:t}){if(!t)return e;if(Y.isAbsolute(t))throw Error(`Upload path must be relative: ${t}`);let n=t.split(/[\\/]+/).slice(0,-1).filter(Boolean);if(n.includes(`..`))throw Error(`Upload path cannot contain parent traversal: ${t}`);let r=n.filter(e=>e!==`.`);if(r.length===0)return e;let i=X.guessDeliminator(e),a=r.join(i.deliminator);return i.join(e,a)}function Gn(e,t){return e instanceof Element&&e.closest(`[${Vn}]`)?.getAttribute(Vn)||t}function Kn(e,t){let n=e.successful.length+e.failed.length;if(e.failed.length>0){let r;r=e.successful.length===0?n===1?`File upload failed`:`Files failed to upload`:`${e.successful.length} of ${n} files uploaded`,Ke({title:r,description:(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`div`,{children:[`Destination: `,t,`.`]}),e.failed.map(({file:e,response:t},n)=>(0,$.jsxs)(`div`,{children:[e.name,`:`,` `,t.message||`The server rejected the upload.`]},`${e.name}-${n}`))]}),variant:`danger`});return}let r=e.successful.filter(({file:e,response:t})=>t.info?.name&&t.info.name!==e.name);Ke({title:n===1?`File uploaded`:`${n} files uploaded`,description:r.length===0?`Uploaded to ${t}.`:(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`div`,{children:[`Uploaded to `,t,`.`]}),r.map(({file:e,response:t},n)=>(0,$.jsxs)(`div`,{children:[e.name,` was saved as `,t.info?.name,`.`]},`${e.name}-${n}`))]})})}function qn(e){if(e.webkitRelativePath)return e.webkitRelativePath;if(`path`in e&&typeof e.path==`string`)return e.path;if(`relativePath`in e&&typeof e.relativePath==`string`)return e.relativePath}function Jn(e){if(e)return e.replace(/^\/+/,``)}var Yn=j(`marimo:showHiddenFiles`,!0,u,{getOnInit:!0}),Xn=Z.createContext(null),Zn=e=>{let n=(0,Q.c)(157),{height:r,externalDropDestinationPath:a}=e,o=a===void 0?null:a,s=(0,Z.useRef)(null),c=(0,Z.useRef)(null),l=(0,Z.useRef)(null),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(null),m=mn(),[h]=t(Fn),g;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=[],n[0]=g):g=n[0];let[_,v]=(0,Z.useState)(g),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(null),[C,w]=t(Yn),T;n[1]===u?T=n[2]:(T=u.trim(),n[1]=u,n[2]=T);let E;n[3]!==C||n[4]!==T||n[5]!==h?(E={query:T,tree:h,showHiddenFiles:C},n[3]=C,n[4]=T,n[5]=h,n[6]=E):E=n[6];let D=yn(E),[O,k]=t(In),A;n[7]===h?A=n[8]:(A=e=>h.refreshPath(e),n[7]=h,n[8]=A);let j=i(A),M=(0,Z.useRef)(``),N;n[9]===Symbol.for(`react.memo_cache_sentinel`)?(N=()=>M.current,n[9]=N):N=n[9];let P;n[10]===h?P=n[11]:(P=e=>ir(h,e),n[10]=h,n[11]=P);let I;n[12]!==j||n[13]!==P?(I={noClick:!0,noDrag:!0,noKeyboard:!0,destinationPath:N,getDestinationLabel:P,refreshDestination:j},n[12]=j,n[13]=P,n[14]=I):I=n[14];let{getInputProps:L,open:R}=Hn(I),z;n[15]===R?z=n[16]:(z=e=>{M.current=e,R()},n[15]=R,n[16]=z);let B=i(z),{openPrompt:V,openConfirm:H}=we(),U;n[17]===h?U=n[18]:(U=()=>h.initialize(v),n[17]=h,n[18]=U);let W;n[19]===Symbol.for(`react.memo_cache_sentinel`)?(W=[],n[19]=W):W=n[19];let{isPending:ee,error:G}=et(U,W),te;n[20]!==O||n[21]!==D||n[22]!==h?(te=async()=>{await h.refreshAll(Object.keys(O).filter(e=>O[e])),D.refetch()},n[20]=O,n[21]=D,n[22]=h,n[23]=te):te=n[23];let ne=i(te),re;n[24]!==w||n[25]!==C?(re=()=>{w(!C)},n[24]=w,n[25]=C,n[26]=re):re=n[26];let K=i(re),J;n[27]!==V||n[28]!==x?.id||n[29]!==h?(J=async()=>{V({title:`Folder name`,onConfirm:async e=>{h.createFolder(e,x?.id??null)}})},n[27]=V,n[28]=x?.id,n[29]=h,n[30]=J):J=n[30];let Y=i(J),X;n[31]!==V||n[32]!==x?.id||n[33]!==h?(X=async()=>{V({title:`File name`,onConfirm:async e=>{h.createFile({name:e,parentId:x?.id??null})}})},n[31]=V,n[32]=x?.id,n[33]=h,n[34]=X):X=n[34];let ae=i(X),se;n[35]!==V||n[36]!==x?.id||n[37]!==h?(se=async()=>{V({title:`Notebook name`,onConfirm:async e=>{h.createFile({name:e,parentId:x?.id??null,type:`notebook`})}})},n[35]=V,n[36]=x?.id,n[37]=h,n[38]=se):se=n[38];let ce=i(se),le;n[39]===k?le=n[40]:(le=()=>{s.current?.closeAll(),k({})},n[39]=k,n[40]=le);let ue=i(le),de;n[41]!==_||n[42]!==C?(de=ar(_,C),n[41]=_,n[42]=C,n[43]=de):de=n[43];let fe=de,pe=x?.id;pe===void 0||sr(fe,pe)||S(null);let me;n[44]!==o||n[45]!==B||n[46]!==h?(me={tree:h,uploadFiles:B,externalDropDestinationPath:o},n[44]=o,n[45]=B,n[46]=h,n[47]=me):me=n[47];let he=me,ge;n[48]!==y||n[49]!==u||n[50]!==f?(ge=()=>{if(f&&!y){let e=u.trim()?c.current:s.current;e?.openParents(f),e?.select(f);let t=e?.get(f);t?.data.isDirectory&&t.open(),p(null)}},n[48]=y,n[49]=u,n[50]=f,n[51]=ge):ge=n[51];let _e;n[52]!==_||n[53]!==y||n[54]!==u||n[55]!==f?(_e=[f,u,y,_],n[52]=_,n[53]=y,n[54]=u,n[55]=f,n[56]=_e):_e=n[56],Z.useEffect(ge,_e);let ve;n[57]===h?ve=n[58]:(ve=async e=>{if(!e.isDirectory){b(e);return}await h.reveal(e)&&(d(``),p(e.id))},n[57]=h,n[58]=ve);let ye=ve,be;n[59]===u?be=n[60]:(be=e=>{if((e.ctrlKey||e.metaKey)&&e.key===`f`){e.preventDefault(),e.stopPropagation(),l.current?.focus(),l.current?.select();return}if(e.key===`Escape`&&u){e.preventDefault(),e.stopPropagation(),d(``),l.current?.focus();return}let t=e.target instanceof Element?e.target.getAttribute(`role`):null;if(u.trim()||t!==`treeitem`&&t!==`tree`)return;let n=s.current?.focusedNode;!n||s.current?.isEditing||(e.key===`Enter`?(e.preventDefault(),e.stopPropagation(),n.data.isDirectory?n.toggle():n.activate()):e.key===`F2`&&!n.data.isRoot?(e.preventDefault(),e.stopPropagation(),n.edit()):(e.key===`Delete`||e.key===`Backspace`)&&(e.preventDefault(),e.stopPropagation(),n.data.isRoot||n.tree.delete(n.id)))},n[59]=u,n[60]=be);let xe=be;if(ee){let e;return n[61]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ee,{size:`medium`,centered:!0}),n[61]=e):e=n[61],e}if(G){let e;return n[62]===G?e=n[63]:(e=(0,$.jsx)(at,{error:G}),n[62]=G,n[63]=e),e}let Se;n[64]!==y||n[65]!==h?(Se=y?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center pl-1 pr-3 shrink-0 border-b justify-between`,children:[(0,$.jsx)(q,{autoFocus:!0,"aria-label":`Back to files`,onClick:()=>{p(y.id),b(null)},"data-testid":`file-explorer-back-button`,variant:`text`,size:`xs`,className:`mb-0`,children:(0,$.jsx)(ie,{size:16})}),(0,$.jsx)(`span`,{className:`font-bold`,children:y.name})]}),(0,$.jsx)(Z.Suspense,{children:(0,$.jsx)(En,{onOpenNotebook:h.isPrimaryNode(y)?e=>{let t=h.getPrimaryRelativePath(y.path);t!==null&&rr(e,t)}:void 0,file:y})})]}):null,n[64]=y,n[65]=h,n[66]=Se):Se=n[66];let Ce=Se,Te=!!y,De;n[67]===L?De=n[68]:(De=L(),n[67]=L,n[68]=De);let Oe;n[69]===De?Oe=n[70]:(Oe=(0,$.jsx)(`input`,{"data-testid":`file-explorer-upload-input`,...De}),n[69]=De,n[70]=Oe);let ke;n[71]!==x?.path||n[72]!==h?(ke=x?.path??h.getPrimaryRootPath(),n[71]=x?.path,n[72]=h,n[73]=ke):ke=n[73];let Ae;n[74]!==x?.path||n[75]!==h?(Ae=x?.path??h.getPrimaryRootPath(),n[74]=x?.path,n[75]=h,n[76]=Ae):Ae=n[76];let je;n[77]!==Ae||n[78]!==h?(je=ir(h,Ae),n[77]=Ae,n[78]=h,n[79]=je):je=n[79];let Me;n[80]!==ue||n[81]!==ae||n[82]!==Y||n[83]!==ce||n[84]!==K||n[85]!==ne||n[86]!==B||n[87]!==C||n[88]!==ke||n[89]!==je?(Me=(0,$.jsx)($n,{onRefresh:ne,onHidden:K,showHiddenFiles:C,onCreateFile:ae,onCreateNotebook:ce,onCreateFolder:Y,onCollapseAll:ue,uploadDestinationPath:ke,uploadDestinationLabel:je,onUpload:B}),n[80]=ue,n[81]=ae,n[82]=Y,n[83]=ce,n[84]=K,n[85]=ne,n[86]=B,n[87]=C,n[88]=ke,n[89]=je,n[90]=Me):Me=n[90];let Ne;n[91]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=e=>d(e.target.value),n[91]=Ne):Ne=n[91];let Pe;n[92]===u?Pe=n[93]:(Pe=e=>{let t=u.trim()?c.current:s.current;e.key===`ArrowDown`?(e.preventDefault(),t?.focus(t.firstNode)):e.key===`Enter`&&u.trim()&&(e.preventDefault(),t?.firstNode?.activate())},n[92]=u,n[93]=Pe);let Fe;n[94]!==u||n[95]!==Pe?(Fe=(0,$.jsx)(Ve,{ref:l,className:`rounded-none pr-6 focus-visible:outline-1 focus-visible:outline-ring/50`,clearable:!1,"aria-label":`Search files and folders`,placeholder:`Search`,title:`Search names in all configured roots, up to 20 folders deep. Generated directories such as node_modules and .git are excluded.`,value:u,onChange:Ne,onKeyDown:Pe}),n[94]=u,n[95]=Pe,n[96]=Fe):Fe=n[96];let Ie;n[97]===u?Ie=n[98]:(Ie=u&&(0,$.jsx)(q,{variant:`text`,size:`icon`,className:`absolute right-3 top-1/2 h-5 w-5 -translate-y-1/2`,"aria-label":`Clear search`,onClick:()=>{d(``),l.current?.focus()},children:(0,$.jsx)(oe,{className:`h-3 w-3`})}),n[97]=u,n[98]=Ie);let Le;n[99]!==Fe||n[100]!==Ie?(Le=(0,$.jsxs)(`div`,{className:`relative -mt-1`,children:[Fe,Ie]}),n[99]=Fe,n[100]=Ie,n[101]=Le):Le=n[101];let ze;n[102]!==Me||n[103]!==Le?(ze=(0,$.jsxs)(`div`,{children:[Me,Le]}),n[102]=Me,n[103]=Le,n[104]=ze):ze=n[104];let Be;n[105]===u?Be=n[106]:(Be=u.trim(),n[105]=u,n[106]=Be);let He=!Be,Ue=Math.max(0,r-63),We;n[107]!==ye||n[108]!==D||n[109]!==Ue?(We=(0,$.jsx)(On,{treeRef:c,search:D,height:Ue,onReveal:ye}),n[107]=ye,n[108]=D,n[109]=Ue,n[110]=We):We=n[110];let Ge;n[111]!==He||n[112]!==We?(Ge=(0,$.jsx)(`div`,{hidden:He,children:We}),n[111]=He,n[112]=We,n[113]=Ge):Ge=n[113];let Ke;n[114]===u?Ke=n[115]:(Ke=u.trim(),n[114]=u,n[115]=Ke);let qe=!!Ke,Je=Math.max(0,r-63),Ye;n[116]===Symbol.for(`react.memo_cache_sentinel`)?(Ye=e=>(0,$.jsx)(cr,{...e,tree:s.current}),n[116]=Ye):Ye=n[116];let Xe;n[117]!==H||n[118]!==h?(Xe=async e=>{let{ids:t}=e;H({title:`Delete file`,description:`Are you sure you want to delete the selected file or folder?`,confirmAction:(0,$.jsx)(F,{onClick:async()=>{for(let e of t)await h.delete(e)},children:`Delete`})})},n[117]=H,n[118]=h,n[119]=Xe):Xe=n[119];let Ze,Qe;n[120]===h?(Ze=n[121],Qe=n[122]):(Ze=async e=>{let{id:t,name:n}=e;await h.rename(t,n)},Qe=async e=>{let{dragIds:t,parentId:n}=e;await h.move(t,n)},n[120]=h,n[121]=Ze,n[122]=Qe);let $e,tt;n[123]===Symbol.for(`react.memo_cache_sentinel`)?($e=e=>{let t=e[0];if(!t){S(null);return}if(t.data.isDirectory){S({id:t.id,path:t.data.path});return}S(null)},tt=e=>{e.data.isDirectory||b(e.data)},n[123]=$e,n[124]=tt):($e=n[123],tt=n[124]);let nt;n[125]!==O||n[126]!==k||n[127]!==h?(nt=async e=>{if(!(s.current?.isOpen(e)??!(O[e]??!1))){k(t=>({...t,[e]:!1}));return}let t=await h.expand(e);t||s.current?.close(e);let n=t&&(s.current?.isOpen(e)??!1);k(t=>({...t,[e]:n}))},n[125]=O,n[126]=k,n[127]=h,n[128]=nt):nt=n[128];let rt;n[129]!==m||n[130]!==O||n[131]!==Je||n[132]!==Xe||n[133]!==Ze||n[134]!==Qe||n[135]!==nt||n[136]!==fe?(rt=(0,$.jsx)(Re,{width:`100%`,ref:s,height:Je,className:`h-full`,data:fe,childrenAccessor:lr,selectionFollowsFocus:!0,rowClassName:`outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring`,renderRow:Mn,renderDragPreview:Ye,disableEdit:ur,initialOpenState:O,openByDefault:!1,dndManager:m,renderCursor:dr,disableDrag:fr,disableDrop:mr,onDelete:Xe,onRename:Ze,onMove:Qe,onSelect:$e,onActivate:tt,onToggle:nt,padding:15,rowHeight:30,indent:Qn,overscanCount:8,disableMultiSelection:!0,children:tr}),n[129]=m,n[130]=O,n[131]=Je,n[132]=Xe,n[133]=Ze,n[134]=Qe,n[135]=nt,n[136]=fe,n[137]=rt):rt=n[137];let it;n[138]!==he||n[139]!==rt?(it=(0,$.jsx)(Xn,{value:he,children:rt}),n[138]=he,n[139]=rt,n[140]=it):it=n[140];let ot;n[141]===fe.length?ot=n[142]:(ot=!fe.length&&(0,$.jsx)(`p`,{role:`status`,className:`absolute top-2 left-3 text-sm text-muted-foreground`,children:`No visible files.`}),n[141]=fe.length,n[142]=ot);let st;n[143]!==qe||n[144]!==it||n[145]!==ot?(st=(0,$.jsxs)(`div`,{hidden:qe,className:`relative`,children:[it,ot]}),n[143]=qe,n[144]=it,n[145]=ot,n[146]=st):st=n[146];let ct;n[147]!==xe||n[148]!==Te||n[149]!==Oe||n[150]!==ze||n[151]!==Ge||n[152]!==st?(ct=(0,$.jsxs)(`div`,{hidden:Te,onKeyDownCapture:xe,children:[Oe,ze,Ge,st]}),n[147]=xe,n[148]=Te,n[149]=Oe,n[150]=ze,n[151]=Ge,n[152]=st,n[153]=ct):ct=n[153];let lt;return n[154]!==Ce||n[155]!==ct?(lt=(0,$.jsxs)($.Fragment,{children:[Ce,ct]}),n[154]=Ce,n[155]=ct,n[156]=lt):lt=n[156],lt},Qn=15,$n=e=>{let t=(0,Q.c)(35),{onRefresh:n,onHidden:r,showHiddenFiles:i,onCreateFile:a,onCreateNotebook:o,onCreateFolder:s,onCollapseAll:c,uploadDestinationPath:l,uploadDestinationLabel:u,onUpload:d}=e,f=`Upload files to ${u}`,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(bt,{size:16}),t[0]=p):p=t[0];let m;t[1]===o?m=t[2]:(m=(0,$.jsx)(K,{content:`Add notebook`,children:(0,$.jsx)(q,{"data-testid":`file-explorer-add-notebook-button`,onClick:o,variant:`text`,size:`xs`,children:p})}),t[1]=o,t[2]=m);let h;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(Et,{size:16}),t[3]=h):h=t[3];let g;t[4]===a?g=t[5]:(g=(0,$.jsx)(K,{content:`Add file`,children:(0,$.jsx)(q,{"data-testid":`file-explorer-add-file-button`,onClick:a,variant:`text`,size:`xs`,children:h})}),t[4]=a,t[5]=g);let _;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(Ot,{size:16}),t[6]=_):_=t[6];let v;t[7]===s?v=t[8]:(v=(0,$.jsx)(K,{content:`Add folder`,children:(0,$.jsx)(q,{"data-testid":`file-explorer-add-folder-button`,onClick:s,variant:`text`,size:`xs`,children:_})}),t[7]=s,t[8]=v);let y;t[9]!==d||t[10]!==l?(y=()=>d(l),t[9]=d,t[10]=l,t[11]=y):y=t[11];let b;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(Ue,{size:16}),t[12]=b):b=t[12];let x;t[13]!==y||t[14]!==f?(x=(0,$.jsx)(q,{"data-testid":`file-explorer-upload-button`,"aria-label":f,onClick:y,variant:`text`,size:`xs`,children:b}),t[13]=y,t[14]=f,t[15]=x):x=t[15];let S;t[16]!==x||t[17]!==f?(S=(0,$.jsx)(K,{content:f,children:x}),t[16]=x,t[17]=f,t[18]=S):S=t[18];let C;t[19]===n?C=t[20]:(C=(0,$.jsx)(ue,{"data-testid":`file-explorer-refresh-button`,onClick:n}),t[19]=n,t[20]=C);let w;t[21]!==r||t[22]!==i?(w=(0,$.jsx)(se,{"data-testid":`file-explorer-hidden-files-button`,isVisible:i,onToggle:r,showTooltip:`Show hidden files`,hideTooltip:`Hide hidden files`}),t[21]=r,t[22]=i,t[23]=w):w=t[23];let T;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(Tt,{size:16}),t[24]=T):T=t[24];let E;t[25]===c?E=t[26]:(E=(0,$.jsx)(K,{content:`Collapse all folders`,children:(0,$.jsx)(q,{"data-testid":`file-explorer-collapse-button`,onClick:c,variant:`text`,size:`xs`,children:T})}),t[25]=c,t[26]=E);let D;return t[27]!==S||t[28]!==C||t[29]!==w||t[30]!==E||t[31]!==m||t[32]!==g||t[33]!==v?(D=(0,$.jsxs)(`div`,{className:`flex items-center justify-end px-2 shrink-0`,children:[m,g,v,S,C,w,E]}),t[27]=S,t[28]=C,t[29]=w,t[30]=E,t[31]=m,t[32]=g,t[33]=v,t[34]=D):D=t[34],D},er=e=>{let t=(0,Q.c)(11),{node:n,onOpenMarimoFile:r}=e,i;t[0]!==n.data.isMarimoFile||t[1]!==n.data.isPrimaryRoot||t[2]!==r?(i=n.data.isMarimoFile&&n.data.isPrimaryRoot&&!A()&&(0,$.jsxs)(`span`,{"data-testid":`file-explorer-open-marimo-button`,className:`shrink-0 ml-2 text-sm hidden group-hover:inline hover:underline`,onClick:r,children:[`open `,(0,$.jsx)(he,{className:`inline ml-1`,size:12})]}),t[0]=n.data.isMarimoFile,t[1]=n.data.isPrimaryRoot,t[2]=r,t[3]=i):i=t[3];let a;t[4]!==n.data.name||t[5]!==i?(a=(0,$.jsxs)(`span`,{className:`flex-1 overflow-hidden text-ellipsis`,children:[n.data.name,i]}),t[4]=n.data.name,t[5]=i,t[6]=a):a=t[6];let o=a,s;return t[7]!==o||t[8]!==n.data.isRoot||t[9]!==n.data.path?(s=n.data.isRoot?(0,$.jsx)(K,{content:n.data.path,children:o}):o,t[7]=o,t[8]=n.data.isRoot,t[9]=n.data.path,t[10]=s):s=t[10],s},tr=e=>{let t=(0,Q.c)(123),{node:n,style:a,dragHandle:o}=e,{openFile:s}=Xe(),l=r(T),u;t[0]!==n.data.isDirectory||t[1]!==n.data.name?(u=n.data.isDirectory?`directory`:ye(n.data.name),t[0]=n.data.isDirectory,t[1]=n.data.name,t[2]=u):u=t[2];let f=u,p=be[f],{openPrompt:m}=we(),{createNewCell:h}=c(),g=d(),_;t[3]!==h||t[4]!==g?(_=e=>{h({code:e,before:!1,cellId:g??`__end__`})},t[3]=h,t[4]=g,t[5]=_):_=t[5];let y=_,b=(0,Z.use)(Xn),x=b?.tree,S=n.data.isDirectory&&b?.externalDropDestinationPath===n.data.path;bn(n,S);let C;t[6]!==n.data.path||t[7]!==x?(C=async e=>{let t=x?.getPrimaryRelativePath(n.data.path);t!=null&&rr(e,t)},t[6]=n.data.path,t[7]=x,t[8]=C):C=t[8];let w=C,E;t[9]!==n.id||t[10]!==n.tree?(E=async e=>{e.stopPropagation(),e.preventDefault(),await n.tree.delete(n.id)},t[9]=n.id,t[10]=n.tree,t[11]=E):E=t[11];let D=E,O;t[12]!==n||t[13]!==m||t[14]!==x?(O=async()=>{n.open(),m({title:`Folder name`,onConfirm:async e=>{x?.createFolder(e,n.id)}})},t[12]=n,t[13]=m,t[14]=x,t[15]=O):O=t[15];let k=i(O),j;t[16]!==n||t[17]!==m||t[18]!==x?(j=async()=>{n.open(),m({title:`File name`,onConfirm:async e=>{x?.createFile({name:e,parentId:n.id})}})},t[16]=n,t[17]=m,t[18]=x,t[19]=j):j=t[19];let M=i(j),P;t[20]!==n||t[21]!==m||t[22]!==x?(P=async()=>{n.open(),m({title:`Notebook name`,onConfirm:async e=>{x?.createFile({name:e,parentId:n.id,type:`notebook`})}})},t[20]=n,t[21]=m,t[22]=x,t[23]=P):P=t[23];let F=i(P),R;t[24]!==n.data.name||t[25]!==n.id||t[26]!==x?(R=async()=>{x&&await x.copy(n.id,lt(n.data.name))},t[24]=n.data.name,t[25]=n.id,t[26]=x,t[27]=R):R=t[27];let z=i(R),B;t[28]!==n.data.isDirectory||t[29]!==n.data.path?(B=n.data.isDirectory?{[Vn]:n.data.path}:{},t[28]=n.data.isDirectory,t[29]=n.data.path,t[30]=B):B=t[30];let H;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(H=N(`relative flex h-full items-center cursor-pointer ml-1 text-muted-foreground whitespace-nowrap group`),t[31]=H):H=t[31];let U=!n.data.isRoot,W,ee;t[32]===n?(W=t[33],ee=t[34]):(W=()=>{n.data.isDirectory&&n.toggle()},ee=e=>{e.stopPropagation(),n.data.isDirectory||n.activate()},t[32]=n,t[33]=W,t[34]=ee);let G;t[35]===n.level?G=t[36]:(G=Array.from({length:n.level},hr),t[35]=n.level,t[36]=G);let te;t[37]===n?te=t[38]:(te=(0,$.jsx)(nr,{node:n}),t[37]=n,t[38]=te);let ne;t[39]!==n.data.isDirectory||t[40]!==n.tree||t[41]!==n.willReceiveDrop?(ne=n.willReceiveDrop&&n.tree.canDrop()&&n.data.isDirectory&&`bg-primary/15 hover:bg-primary/15 text-accent-foreground`,t[39]=n.data.isDirectory,t[40]=n.tree,t[41]=n.willReceiveDrop,t[42]=ne):ne=t[42];let re=n.isSelected&&`bg-accent/60 hover:bg-accent/60 text-accent-foreground`,K=S&&`bg-primary/15 hover:bg-primary/15 text-accent-foreground`,q;t[43]!==ne||t[44]!==re||t[45]!==K?(q=N(`flex items-center pl-1 py-1 cursor-pointer hover:bg-accent/50 hover:text-accent-foreground rounded-l flex-1 overflow-hidden group`,ne,re,K),t[43]=ne,t[44]=re,t[45]=K,t[46]=q):q=t[46];let J;t[47]!==p||t[48]!==f||t[49]!==n.data.isMarimoFile||t[50]!==n.data.isRoot?(J=n.data.isRoot?(0,$.jsx)(kt,{className:`w-4 h-4 shrink-0 mr-2 text-primary`,strokeWidth:1.5}):n.data.isMarimoFile?(0,$.jsx)(xt,{className:`w-4 h-4 shrink-0 mr-2`,strokeWidth:1.5}):(0,$.jsx)(p,{className:N(`w-4 h-4 shrink-0 mr-2`,ve[f]),strokeWidth:1.5}),t[47]=p,t[48]=f,t[49]=n.data.isMarimoFile,t[50]=n.data.isRoot,t[51]=J):J=t[51];let Y;t[52]!==w||t[53]!==n?(Y=n.isEditing?(0,$.jsx)(Le,{node:n}):(0,$.jsx)(er,{node:n,onOpenMarimoFile:w}),t[52]=w,t[53]=n,t[54]=Y):Y=t[54];let X;t[55]===n?X=t[56]:(X=!n.data.isDirectory&&(0,$.jsxs)(I,{onSelect:()=>n.activate(),"data-testid":`file-explorer-open-file-menu-item`,children:[(0,$.jsx)(Mt,{className:`h-3.5 w-3.5 mr-2`}),`Open file`]}),t[55]=n,t[56]=X);let ie;t[57]!==n.data.isDirectory||t[58]!==n.data.path||t[59]!==s?(ie=!n.data.isDirectory&&!A()&&(0,$.jsxs)(I,{onSelect:()=>{s({path:n.data.path})},"data-testid":`file-explorer-open-external-menu-item`,children:[(0,$.jsx)(he,{className:`h-3.5 w-3.5 mr-2`}),`Open file in external editor`]}),t[57]=n.data.isDirectory,t[58]=n.data.path,t[59]=s,t[60]=ie):ie=t[60];let oe;t[61]!==b||t[62]!==M||t[63]!==k||t[64]!==F||t[65]!==n.data.isDirectory||t[66]!==n.data.path?(oe=n.data.isDirectory&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(I,{onSelect:()=>F(),"data-testid":`file-explorer-create-notebook-menu-item`,children:[(0,$.jsx)(bt,{className:`h-3.5 w-3.5 mr-2`}),`Create notebook`]}),(0,$.jsxs)(I,{onSelect:()=>M(),"data-testid":`file-explorer-create-file-menu-item`,children:[(0,$.jsx)(Et,{className:`h-3.5 w-3.5 mr-2`}),`Create file`]}),(0,$.jsxs)(I,{onSelect:()=>k(),"data-testid":`file-explorer-create-folder-menu-item`,children:[(0,$.jsx)(Ot,{className:`h-3.5 w-3.5 mr-2`}),`Create folder`]}),(0,$.jsxs)(I,{onSelect:()=>b?.uploadFiles(n.data.path),"data-testid":`file-explorer-upload-files-menu-item`,children:[(0,$.jsx)(Ue,{className:`h-3.5 w-3.5 mr-2`}),`Upload files here`]}),(0,$.jsx)(L,{})]}),t[61]=b,t[62]=M,t[63]=k,t[64]=F,t[65]=n.data.isDirectory,t[66]=n.data.path,t[67]=oe):oe=t[67];let se;t[68]!==z||t[69]!==n?(se=!n.data.isRoot&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(De,{onSelect:()=>n.edit(),testId:`file-explorer-rename-menu-item`}),(0,$.jsx)(Ie,{onSelect:z,testId:`file-explorer-duplicate-menu-item`})]}),t[68]=z,t[69]=n,t[70]=se):se=t[70];let ce;t[71]===n.data.path?ce=t[72]:(ce=async()=>{await Ge(n.data.path),Ke({title:`Copied to clipboard`})},t[71]=n.data.path,t[72]=ce);let le;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,$.jsx)(At,{className:de}),t[73]=le):le=t[73];let ue;t[74]===ce?ue=t[75]:(ue=(0,$.jsxs)(I,{onSelect:ce,"data-testid":`file-explorer-copy-path-menu-item`,children:[le,`Copy path`]}),t[74]=ce,t[75]=ue);let fe;t[76]!==n.data.isPrimaryRoot||t[77]!==n.data.isRoot||t[78]!==n.data.path||t[79]!==x?(fe=x&&n.data.isPrimaryRoot&&!n.data.isRoot&&(0,$.jsxs)(I,{onSelect:async()=>{let e=x.getPrimaryRelativePath(n.data.path);e!==null&&(await Ge(e),Ke({title:`Copied to clipboard`}))},"data-testid":`file-explorer-copy-relative-path-menu-item`,children:[(0,$.jsx)(At,{className:`h-3.5 w-3.5 mr-2`}),`Copy relative path`]}),t[76]=n.data.isPrimaryRoot,t[77]=n.data.isRoot,t[78]=n.data.path,t[79]=x,t[80]=fe):fe=t[80];let pe;t[81]!==f||t[82]!==y||t[83]!==n.data?(pe=!n.data.isRoot&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(L,{}),(0,$.jsxs)(I,{onSelect:()=>{let{path:e}=n.data,t=Rn[f](e);y(t)},"data-testid":`file-explorer-insert-snippet-menu-item`,children:[(0,$.jsx)(ae,{className:`h-3.5 w-3.5 mr-2`}),`Insert snippet for reading file`]}),(0,$.jsxs)(I,{onSelect:async()=>{Ke({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:e}=n.data,t=Rn[f](e);await Ge(t)},"data-testid":`file-explorer-copy-snippet-menu-item`,children:[(0,$.jsx)(v,{className:`h-3.5 w-3.5 mr-2`}),`Copy snippet for reading file`]})]}),t[81]=f,t[82]=y,t[83]=n.data,t[84]=pe):pe=t[84];let me;t[85]!==w||t[86]!==n.data.isMarimoFile||t[87]!==n.data.isPrimaryRoot?(me=n.data.isMarimoFile&&n.data.isPrimaryRoot&&!A()&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(L,{}),(0,$.jsxs)(I,{onSelect:w,"data-testid":`file-explorer-open-notebook-menu-item`,children:[(0,$.jsx)(jt,{className:`h-3.5 w-3.5 mr-2`}),`Open notebook`]})]}),t[85]=w,t[86]=n.data.isMarimoFile,t[87]=n.data.isPrimaryRoot,t[88]=me):me=t[88];let ge;t[89]!==l||t[90]!==n.data.isDirectory||t[91]!==n.data.name||t[92]!==n.data.path?(ge=!n.data.isDirectory&&!l&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(L,{}),(0,$.jsxs)(I,{onSelect:async()=>{await xn(n.data.path,n.data.name)},"data-testid":`file-explorer-download-menu-item`,children:[(0,$.jsx)(V,{className:`h-3.5 w-3.5 mr-2`}),`Download`]})]}),t[89]=l,t[90]=n.data.isDirectory,t[91]=n.data.name,t[92]=n.data.path,t[93]=ge):ge=t[93];let _e;t[94]!==D||t[95]!==n.data.isRoot?(_e=!n.data.isRoot&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(L,{}),(0,$.jsx)(Pe,{onSelect:D,testId:`file-explorer-delete-menu-item`})]}),t[94]=D,t[95]=n.data.isRoot,t[96]=_e):_e=t[96];let xe;t[97]!==X||t[98]!==ie||t[99]!==oe||t[100]!==se||t[101]!==ue||t[102]!==fe||t[103]!==pe||t[104]!==me||t[105]!==ge||t[106]!==_e?(xe=(0,$.jsxs)(je,{testId:`file-explorer-more-button`,iconClassName:`w-5 h-5`,children:[X,ie,oe,se,ue,fe,pe,me,ge,_e]}),t[97]=X,t[98]=ie,t[99]=oe,t[100]=se,t[101]=ue,t[102]=fe,t[103]=pe,t[104]=me,t[105]=ge,t[106]=_e,t[107]=xe):xe=t[107];let Se;t[108]!==q||t[109]!==J||t[110]!==Y||t[111]!==xe?(Se=(0,$.jsxs)(`span`,{className:q,children:[J,Y,xe]}),t[108]=q,t[109]=J,t[110]=Y,t[111]=xe,t[112]=Se):Se=t[112];let Ce;return t[113]!==o||t[114]!==a||t[115]!==U||t[116]!==W||t[117]!==ee||t[118]!==G||t[119]!==te||t[120]!==Se||t[121]!==B?(Ce=(0,$.jsxs)(`div`,{style:a,ref:o,...B,className:H,draggable:U,onClick:W,onDoubleClick:ee,children:[G,te,Se]}),t[113]=o,t[114]=a,t[115]=U,t[116]=W,t[117]=ee,t[118]=G,t[119]=te,t[120]=Se,t[121]=B,t[122]=Ce):Ce=t[122],Ce},nr=e=>{let t=(0,Q.c)(6),{node:n}=e;if(!n.data.isDirectory){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`w-4 h-4 shrink-0`}),t[0]=e):e=t[0],e}if(n.data.loadState===`loading`){let e=`Loading ${n.data.name}`,r;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(Ee,{size:`small`}),t[1]=r):r=t[1];let i;return t[2]===e?i=t[3]:(i=(0,$.jsx)(`span`,{role:`status`,"aria-label":e,className:`w-4 h-4 shrink-0`,children:r}),t[2]=e,t[3]=i),i}let r;return t[4]===n.isOpen?r=t[5]:(r=(0,$.jsx)(ce,{isExpanded:n.isOpen,className:`w-4 h-4`}),t[4]=n.isOpen,t[5]=r),r};function rr(e,t){e.stopPropagation(),e.preventDefault(),St(t)}function ir(e,t){return e.getDisplayPath(t)}function ar(e,t){if(t)return e;let n=[];for(let r of e){if(!r.isRoot&&or(r.name))continue;let e=r;if(r.children){let n=ar(r.children,t);n!==r.children&&(e={...r,children:n})}n.push(e)}return n}function or(e){return!!e.startsWith(`.`)}function sr(e,t){return e.some(e=>e.id===t||(e.children?sr(e.children,t):!1))}function cr(e){let t=(0,Q.c)(22),{mouse:n,id:r,isDragging:i,tree:a}=e,o,s,c;if(t[0]!==r||t[1]!==i||t[2]!==n||t[3]!==a){c=Symbol.for(`react.early_return_sentinel`);bb0:{if(o=a?.get(r),!i||!n||!o){c=null;break bb0}s=o.data.isDirectory?`directory`:ye(o.data.name)}t[0]=r,t[1]=i,t[2]=n,t[3]=a,t[4]=o,t[5]=s,t[6]=c}else o=t[4],s=t[5],c=t[6];if(c!==Symbol.for(`react.early_return_sentinel`))return c;let l=s,u=be[l],d=`translate3d(${n.x+12}px, ${n.y+12}px, 0)`,f;t[7]===d?f=t[8]:(f={transform:d},t[7]=d,t[8]=f);let p=ve[l],m;t[9]===p?m=t[10]:(m=N(`h-4 w-4 shrink-0`,p),t[9]=p,t[10]=m);let h;t[11]!==u||t[12]!==m?(h=(0,$.jsx)(u,{className:m}),t[11]=u,t[12]=m,t[13]=h):h=t[13];let g;t[14]===o.data.name?g=t[15]:(g=(0,$.jsx)(`span`,{className:`truncate`,children:o.data.name}),t[14]=o.data.name,t[15]=g);let _;t[16]!==h||t[17]!==g?(_=(0,$.jsxs)(`div`,{className:`flex max-w-72 items-center gap-2 rounded-md border border-border bg-popover px-3 py-2 text-sm text-popover-foreground shadow-md`,children:[h,g]}),t[16]=h,t[17]=g,t[18]=_):_=t[18];let v;return t[19]!==f||t[20]!==_?(v=(0,_n.createPortal)((0,$.jsx)(`div`,{className:`pointer-events-none fixed left-0 top-0 z-[1000] opacity-[0.85]`,style:f,children:_}),document.body),t[19]=f,t[20]=_,t[21]=v):v=t[21],v}function lr(e){return e.isDirectory?e.children:null}function ur(e){return e.isRoot}function dr(){return null}function fr(e){return e.isRoot}function pr(e){return e.data.isRoot}function mr(e){let{parentNode:t,dragNodes:n}=e;return n.some(pr)||(t?!t.data.isDirectory:!1)}function hr(e,t){return(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-0 border-l border-border`,style:{left:t*Qn+8}},t)}var gr=e=>{let t=(0,Q.c)(44),{height:n}=e,i=r(Fn),[a,o]=(0,Z.useState)(null),s;t[0]===i?s=t[1]:(s=e=>_r(e,i.getPrimaryRootPath()),t[0]=i,t[1]=s);let c=s,l;t[2]===i?l=t[3]:(l=e=>i.refreshPath(e),t[2]=i,t[3]=l);let u=l,d;t[4]===i?d=t[5]:(d=e=>ir(i,e),t[4]=i,t[5]=d);let f,p;t[6]===c?(f=t[7],p=t[8]):(f=e=>o(c(e)),p=e=>o(c(e)),t[6]=c,t[7]=f,t[8]=p);let m,h;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>o(null),h=()=>o(null),t[9]=m,t[10]=h):(m=t[9],h=t[10]);let g;t[11]!==c||t[12]!==u||t[13]!==d||t[14]!==f||t[15]!==p?(g={noClick:!0,noKeyboard:!0,destinationPath:c,getDestinationLabel:d,refreshDestination:u,onDragEnter:f,onDragOver:p,onDragLeave:m,onUploadStart:h},t[11]=c,t[12]=u,t[13]=d,t[14]=f,t[15]=p,t[16]=g):g=t[16];let{getRootProps:_,getInputProps:v,isDragActive:y}=Hn(g),b;t[17]!==a||t[18]!==i?(b=a??i.getPrimaryRootPath(),t[17]=a,t[18]=i,t[19]=b):b=t[19];let x=b,S;t[20]!==x||t[21]!==i?(S=ir(i,x),t[20]=x,t[21]=i,t[22]=S):S=t[22];let C=S,w;t[23]===_?w=t[24]:(w=_(),t[23]=_,t[24]=w);let T;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(T=N(`flex flex-col overflow-hidden relative`),t[25]=T):T=t[25];let E;t[26]===n?E=t[27]:(E={height:n},t[26]=n,t[27]=E);let D;t[28]===v?D=t[29]:(D=v(),t[28]=v,t[29]=D);let O;t[30]===D?O=t[31]:(O=(0,$.jsx)(`input`,{...D}),t[30]=D,t[31]=O);let k;t[32]!==C||t[33]!==y?(k=y&&(0,$.jsx)(`div`,{className:`absolute inset-0 flex items-start justify-center pt-3 bg-accent/20 z-10 border-2 border-dashed border-primary/90 rounded-lg pointer-events-none`,children:(0,$.jsxs)(`span`,{className:`px-3 py-1.5 rounded-md bg-background/95 border shadow-sm text-sm font-semibold text-primary`,children:[`Drop files into `,C]})}),t[32]=C,t[33]=y,t[34]=k):k=t[34];let A=y?x:null,j;t[35]!==n||t[36]!==A?(j=(0,$.jsx)(Zn,{height:n,externalDropDestinationPath:A}),t[35]=n,t[36]=A,t[37]=j):j=t[37];let M;return t[38]!==w||t[39]!==E||t[40]!==O||t[41]!==k||t[42]!==j?(M=(0,$.jsx)(gn,{children:(0,$.jsxs)(`div`,{...w,className:T,style:E,children:[O,k,j]})}),t[38]=w,t[39]=E,t[40]=O,t[41]=k,t[42]=j,t[43]=M):M=t[43],M};function _r(e,t){return Array.isArray(e)?t:Gn(e.target,t)}var vr=()=>{let e=(0,Q.c)(40),{ref:n,height:i}=st(),a=i===void 0?500:i,[o,s]=t(Ct),c=r(h).length,l=x(`storage`),u;bb0:{if(!o.hasUserInteracted&&c>0){if(o.openSections.includes(`remote-storage`)){u=o.openSections;break bb0}let t;e[0]===o.openSections?t=e[1]:(t=[...o.openSections,`remote-storage`],e[0]=o.openSections,e[1]=t),u=t;break bb0}u=o.openSections}let d=u,f;e[2]===s?f=e[3]:(f=e=>{s({openSections:e,hasUserInteracted:!0})},e[2]=s,e[3]=f);let p=f,m=a-66,g;e[4]===d?g=e[5]:(g=d.includes(`remote-storage`),e[4]=d,e[5]=g);let _=g,v=l.length>0,y;e[6]!==d||e[7]!==_?(y=_&&d.includes(`files`),e[6]=d,e[7]=_,e[8]=y):y=e[8];let b=y,S;e[9]!==m||e[10]!==b?(S=b?Math.round(m*.4):m,e[9]=m,e[10]=b,e[11]=S):S=e[11];let C=S,w=Math.max(200,b?m-C:m),T;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(Se,{className:`w-4 h-4`}),e[12]=T):T=e[12];let E;e[13]===c?E=e[14]:(E=c>0&&(0,$.jsx)(pt,{children:c}),e[13]=c,e[14]=E);let D;e[15]!==l.length||e[16]!==v?(D=v&&(0,$.jsx)(yt,{count:l.length,type:`storage`}),e[15]=l.length,e[16]=v,e[17]=D):D=e[17];let O;e[18]!==E||e[19]!==D?(O=(0,$.jsxs)(mt,{children:[T,` Remote storage`,E,D]}),e[18]=E,e[19]=D,e[20]=O):O=e[20];let A;e[21]===C?A=e[22]:(A={maxHeight:C},e[21]=C,e[22]=A);let j;e[23]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(ln,{}),e[23]=j):j=e[23];let M;e[24]===A?M=e[25]:(M=(0,$.jsx)(ht,{className:`overflow-auto`,style:A,children:j}),e[24]=A,e[25]=M);let N;e[26]!==M||e[27]!==O?(N=(0,$.jsxs)(_t,{value:`remote-storage`,children:[O,M]}),e[26]=M,e[27]=O,e[28]=N):N=e[28];let P;e[29]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsxs)(mt,{children:[(0,$.jsx)(xe,{className:`w-4 h-4`}),`Files`]}),e[29]=P):P=e[29];let F;e[30]===w?F=e[31]:(F=(0,$.jsxs)(_t,{value:`files`,children:[P,(0,$.jsx)(ht,{children:(0,$.jsx)(gr,{height:w})})]}),e[30]=w,e[31]=F);let I;e[32]!==p||e[33]!==d||e[34]!==N||e[35]!==F?(I=(0,$.jsxs)(k,{type:`multiple`,value:d,onValueChange:p,children:[N,F]}),e[32]=p,e[33]=d,e[34]=N,e[35]=F,e[36]=I):I=e[36];let L;return e[37]!==n||e[38]!==I?(L=(0,$.jsx)(`div`,{ref:n,className:`h-full overflow-auto`,children:I}),e[37]=n,e[38]=I,e[39]=L):L=e[39],L};export{vr as default,_r as getUploadDestinationForEvent};
|