@marimo-team/frontend 0.19.8-dev18 → 0.19.8-dev21

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.
Files changed (31) hide show
  1. package/dist/assets/{JsonOutput-BSoo6rnn.js → JsonOutput-DsO4felE.js} +1 -1
  2. package/dist/assets/MarimoErrorOutput-DrTj9k_Z.js +7 -0
  3. package/dist/assets/{add-cell-with-ai-BN_m4VjP.js → add-cell-with-ai-CPu9tI-Q.js} +1 -1
  4. package/dist/assets/{agent-panel-CbBdQTaH.js → agent-panel-Dbh-hMbm.js} +1 -1
  5. package/dist/assets/{ai-model-dropdown-Bfoz25CZ.js → ai-model-dropdown-CODXtvnr.js} +4 -4
  6. package/dist/assets/{app-config-button-CrXbU4T9.js → app-config-button-BGuwQV5R.js} +1 -1
  7. package/dist/assets/{cell-editor-BAqUkTV8.js → cell-editor-BpkNlmop.js} +1 -1
  8. package/dist/assets/{chat-display-CKRYf3fp.js → chat-display-BnUDaREA.js} +1 -1
  9. package/dist/assets/{chat-panel-CYVu9MUa.js → chat-panel-BpDjUlzW.js} +1 -1
  10. package/dist/assets/{column-preview-DtEv_bAg.js → column-preview-Bz3KIcIX.js} +1 -1
  11. package/dist/assets/{command-palette-A_nn_y2h.js → command-palette-D8q355Sm.js} +1 -1
  12. package/dist/assets/{edit-page-COE4a7-G.js → edit-page-e6xxDbUd.js} +3 -3
  13. package/dist/assets/{error-panel-B1n50cDF.js → error-panel-BMcWP1VH.js} +1 -1
  14. package/dist/assets/{file-explorer-panel-Ctq6A5l_.js → file-explorer-panel-th-ny103.js} +1 -1
  15. package/dist/assets/{home-page-CyLRJEZg.js → home-page-Bgzw3IP3.js} +1 -1
  16. package/dist/assets/{hooks-DfBLwtVf.js → hooks-B_N-kbrq.js} +1 -1
  17. package/dist/assets/{index-Ud-15Gp2.js → index-U7La6ZBB.js} +3 -3
  18. package/dist/assets/{layout-DFhAD73H.js → layout-D7NLGhPa.js} +1 -1
  19. package/dist/assets/{packages-panel-BMqAMJxC.js → packages-panel-DsF1uf9X.js} +1 -1
  20. package/dist/assets/{panels-BPRD9NT1.js → panels-aWY9-L83.js} +1 -1
  21. package/dist/assets/{run-page-CPt0ml4p.js → run-page-DQU-eaKQ.js} +1 -1
  22. package/dist/assets/{scratchpad-panel-DJdZVxe5.js → scratchpad-panel-N4QLTtHb.js} +1 -1
  23. package/dist/assets/{session-panel-Bqe3Jmko.js → session-panel-Cof-5_26.js} +1 -1
  24. package/dist/assets/{useNotebookActions-DY_TVOaP.js → useNotebookActions-BEKXbrFJ.js} +1 -1
  25. package/dist/assets/{utilities.esm-D1YtU9uV.js → utilities.esm-AIy-_q0N.js} +1 -1
  26. package/dist/index.html +8 -8
  27. package/package.json +1 -1
  28. package/src/components/app-config/ai-config.tsx +11 -2
  29. package/src/utils/__tests__/url-parser.test.ts +22 -0
  30. package/src/utils/url-parser.ts +1 -1
  31. package/dist/assets/MarimoErrorOutput-CAX5i2GE.js +0 -7
@@ -1 +1 @@
1
- import{s as i}from"./chunk-LvLJmgfZ.js";import"./useEvent-BhXAndur.js";import{t as l}from"./react-Bj1aDYRI.js";import{D as a}from"./cells-DbD2lYze.js";import"./react-dom-CSu739Rf.js";import{t as s}from"./compiler-runtime-B3qBwwSJ.js";import{t as c}from"./jsx-runtime-ZmTK25f3.js";import"./dist-DBwNzi3C.js";import"./cjs-CH5Rj0g8.js";import"./main-U5Goe76G.js";import"./useNonce-CS26E0hA.js";import{t as d}from"./createLucideIcon-BCdY6lG5.js";import{t as h}from"./MarimoErrorOutput-CAX5i2GE.js";import"./dist-Cayq-K1c.js";import"./dist-TiFCI16_.js";import"./dist-BIKFl48f.js";import"./dist-B0VqT_4z.js";import"./dist-BYyu59D8.js";import"./session-fBtIbMpB.js";import"./Combination-izwufzWe.js";import{n as f}from"./cell-link-BoOn0OpK.js";import{t as n}from"./empty-state-DrmGF88A.js";var x=d("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"}]]),y=s();l();var r=i(c(),1),k=()=>{let t=(0,y.c)(5),e=a();if(e.length===0){let p;return t[0]===Symbol.for("react.memo_cache_sentinel")?(p=(0,r.jsx)(n,{title:"No errors!",icon:(0,r.jsx)(x,{})}),t[0]=p):p=t[0],p}let o;t[1]===e?o=t[2]:(o=e.map(u),t[1]=e,t[2]=o);let m;return t[3]===o?m=t[4]:(m=(0,r.jsx)("div",{className:"flex flex-col h-full overflow-auto",children:o}),t[3]=o,t[4]=m),m};function u(t){return(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs font-mono font-semibold bg-muted border-y px-2 py-1",children:(0,r.jsx)(f,{cellId:t.cellId})}),(0,r.jsx)("div",{className:"px-2",children:(0,r.jsx)(h,{errors:t.output.data,cellId:t.cellId},t.cellId)},t.cellId)]},t.cellId)}export{k as default};
1
+ import{s as i}from"./chunk-LvLJmgfZ.js";import"./useEvent-BhXAndur.js";import{t as l}from"./react-Bj1aDYRI.js";import{D as a}from"./cells-DbD2lYze.js";import"./react-dom-CSu739Rf.js";import{t as s}from"./compiler-runtime-B3qBwwSJ.js";import{t as c}from"./jsx-runtime-ZmTK25f3.js";import"./dist-DBwNzi3C.js";import"./cjs-CH5Rj0g8.js";import"./main-U5Goe76G.js";import"./useNonce-CS26E0hA.js";import{t as d}from"./createLucideIcon-BCdY6lG5.js";import{t as h}from"./MarimoErrorOutput-DrTj9k_Z.js";import"./dist-Cayq-K1c.js";import"./dist-TiFCI16_.js";import"./dist-BIKFl48f.js";import"./dist-B0VqT_4z.js";import"./dist-BYyu59D8.js";import"./session-fBtIbMpB.js";import"./Combination-izwufzWe.js";import{n as f}from"./cell-link-BoOn0OpK.js";import{t as n}from"./empty-state-DrmGF88A.js";var x=d("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"}]]),y=s();l();var r=i(c(),1),k=()=>{let t=(0,y.c)(5),e=a();if(e.length===0){let p;return t[0]===Symbol.for("react.memo_cache_sentinel")?(p=(0,r.jsx)(n,{title:"No errors!",icon:(0,r.jsx)(x,{})}),t[0]=p):p=t[0],p}let o;t[1]===e?o=t[2]:(o=e.map(u),t[1]=e,t[2]=o);let m;return t[3]===o?m=t[4]:(m=(0,r.jsx)("div",{className:"flex flex-col h-full overflow-auto",children:o}),t[3]=o,t[4]=m),m};function u(t){return(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs font-mono font-semibold bg-muted border-y px-2 py-1",children:(0,r.jsx)(f,{cellId:t.cellId})}),(0,r.jsx)("div",{className:"px-2",children:(0,r.jsx)(h,{errors:t.output.data,cellId:t.cellId},t.cellId)},t.cellId)]},t.cellId)}export{k as default};
@@ -1 +1 @@
1
- var Te=Object.defineProperty;var Be=(t,e,i)=>e in t?Te(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var R=(t,e,i)=>Be(t,typeof e!="symbol"?e+"":e,i);import{s as ge}from"./chunk-LvLJmgfZ.js";import{i as qe,l as ce,n as A,p as ye,u as ae}from"./useEvent-BhXAndur.js";import{t as $e}from"./react-Bj1aDYRI.js";import{Gr as Ve,Jr as Le,mn as Ue,qn as Ge,w as Ke}from"./cells-DbD2lYze.js";import"./react-dom-CSu739Rf.js";import{t as ie}from"./compiler-runtime-B3qBwwSJ.js";import"./tooltip-DxKBXCGp.js";import{d as Je,f as Ye}from"./hotkeys-BHHWjLlp.js";import{t as Ze}from"./invariant-CAG_dYON.js";import{p as Qe,u as ve}from"./utils-YqBXNpsM.js";import{S as re}from"./config-D2-Bw6QC.js";import{t as Xe}from"./jsx-runtime-ZmTK25f3.js";import{n as et,t as I}from"./button-CZ3Cs4qb.js";import{t as he}from"./cn-BKtXLv3a.js";import{St as tt,at}from"./dist-DBwNzi3C.js";import{a as it,c as rt,i as nt,o as st,s as lt}from"./JsonOutput-BSoo6rnn.js";import"./cjs-CH5Rj0g8.js";import"./main-U5Goe76G.js";import"./useNonce-CS26E0hA.js";import{n as ot,r as me}from"./requests-B4FYHTZl.js";import{t as G}from"./createLucideIcon-BCdY6lG5.js";import{t as dt}from"./arrow-left-VDC1u5rq.js";import{n as ct,t as ht}from"./LazyAnyLanguageCodeMirror-CQP8KZWO.js";import{r as mt}from"./x-ZP5cObgf.js";import{i as pt,r as be}from"./download-CmdFQXRz.js";import{t as ft}from"./chevron-right--18M_6o9.js";import{f as pe}from"./maps-D2_Mq1pZ.js";import{n as xt}from"./markdown-renderer-D8AmLSIR.js";import{a as S,c as K,p as ut,r as jt,t as gt}from"./dropdown-menu-BUgFWmX1.js";import{t as we}from"./copy-D-8y6iMN.js";import{t as ke}from"./download-Dg7clfkc.js";import{t as yt}from"./ellipsis-vertical-J1F7_WS9.js";import{t as vt}from"./eye-off-AK_9uodG.js";import{n as Fe,r as bt,t as wt}from"./types-7nV0hgXj.js";import{t as Ce}from"./file-plus-corner-CvAy4H5W.js";import{t as kt}from"./spinner-DA8-7wQv.js";import{t as Ft}from"./refresh-ccw-DN_xCV6A.js";import{t as Ct}from"./refresh-cw-Dx8TEWFP.js";import{t as Nt}from"./save-DZodxFnE.js";import{t as St}from"./trash-2-B8SQYdQq.js";import{t as Dt}from"./triangle-alert-U93NZYDl.js";import{i as Pt,n as _t,t as Ot}from"./es-CerBf9Z6.js";import"./dist-Cayq-K1c.js";import"./dist-TiFCI16_.js";import"./dist-BIKFl48f.js";import"./dist-B0VqT_4z.js";import"./dist-BYyu59D8.js";import{t as W}from"./use-toast-T0_cQDma.js";import{t as fe}from"./paths-Dfii2bN8.js";import"./session-fBtIbMpB.js";import{r as zt}from"./useTheme-CTORu22_.js";import"./Combination-izwufzWe.js";import{t as M}from"./tooltip-C_WgOOcZ.js";import"./dates-CT5PUuFo.js";import{o as Mt}from"./alert-dialog-Ctz24SMn.js";import"./popover-B-131r4d.js";import{n as Ne}from"./ImperativeModal-DZr52ffu.js";import{r as Rt}from"./errors-CPlNr33a.js";import"./vega-loader.browser-DXARUlxo.js";import"./defaultLocale-JieDVWC_.js";import"./defaultLocale-BLne0bXb.js";import{t as ne}from"./copy-DHrHayPa.js";import"./purify.es-DZrAQFIu.js";import{a as At,i as Wt,n as xe,r as It,t as Et}from"./tree-B8r7cwRm.js";import{n as Ht,t as Tt}from"./alert-BOoN6gJ1.js";import{n as Se}from"./error-banner-Dlrzo_Ay.js";import{n as De}from"./useAsyncData-BMGLSTg8.js";import"./chunk-5FQGJX7Z-CwvgJCug.js";import"./katex-CDLTCvjQ.js";import"./html-to-image-DrmKVKna.js";import{o as Bt}from"./focus-BEf2RhRf.js";import{a as qt}from"./renderShortcut-B1jzzLJw.js";import{n as $t}from"./blob-t6qcPM7K.js";import{t as Vt}from"./bundle.esm-CBAPjfrh.js";import{t as Lt}from"./links-DgZx-VxW.js";import{t as Ut}from"./icon-32x32-XIbzzdoo.js";import{t as J}from"./Inputs-CbenuziM.js";var Gt=G("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"}]]),Pe=G("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"}]]),_e=G("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"}]]),Kt=G("pen-line",[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]),Jt=G("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"}]]),Yt=G("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"}]]),Oe=ie(),F=ge($e(),1),a=ge(Xe(),1),ze=(0,F.createContext)(null);function Zt(){return(0,F.useContext)(ze)??void 0}var Qt=t=>{let e=(0,Oe.c)(3),{children:i}=t,n=Wt(),s;return e[0]!==i||e[1]!==n?(s=(0,a.jsx)(ze.Provider,{value:n,children:i}),e[0]=i,e[1]=n,e[2]=s):s=e[2],s};const Xt=t=>{let e=(0,Oe.c)(5),{children:i}=t,[n,s]=(0,F.useState)(null),r;e[0]!==i||e[1]!==n?(r=n&&(0,a.jsx)(At,{backend:It,options:{rootElement:n},children:(0,a.jsx)(Qt,{children:i})}),e[0]=i,e[1]=n,e[2]=r):r=e[2];let d;return e[3]===r?d=e[4]:(d=(0,a.jsx)("div",{ref:s,className:"contents",children:r}),e[3]=r,e[4]=d),d};var ue=new Map;const ea=({file:t,onOpenNotebook:e})=>{let{theme:i}=zt(),{sendFileDetails:n,sendUpdateFile:s}=me(),r=ae(Qe),d=ae(ve),f=ae(Ve),[h,m]=(0,F.useState)(""),{data:l,isPending:u,error:v,setData:g,refetch:c}=De(async()=>{let o=await n({path:t.path}),j=o.contents||"";return m(ue.get(t.path)||j),o},[t.path]),y=async()=>{h!==(l==null?void 0:l.contents)&&await s({path:t.path,contents:h}).then(o=>{o.success&&(g(j=>({...j,contents:h})),m(h))})},C=(0,F.useRef)(h);if(C.current=h,(0,F.useEffect)(()=>()=>{if(!(l!=null&&l.contents))return;let o=C.current;o===l.contents?ue.delete(t.path):ue.set(t.path,o)},[t.path,l==null?void 0:l.contents]),v)return(0,a.jsx)(Se,{error:v});if(u||!l)return null;let x=l.mimeType||"text/plain",D=x in je,k=f&&l.file.isMarimoFile&&(t.path===f||t.path.endsWith(`/${f}`));if(!l.contents&&!D)return(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-2 p-6",children:[(0,a.jsx)("div",{className:"font-bold text-muted-foreground",children:"Name"}),(0,a.jsx)("div",{children:l.file.name}),(0,a.jsx)("div",{className:"font-bold text-muted-foreground",children:"Type"}),(0,a.jsx)("div",{children:x})]});let b=(0,a.jsxs)("div",{className:"text-xs text-muted-foreground p-1 flex justify-end gap-2 border-b",children:[(0,a.jsx)(M,{content:"Refresh",children:(0,a.jsx)(J,{size:"small",onClick:c,children:(0,a.jsx)(Ct,{})})}),t.isMarimoFile&&!re()&&(0,a.jsx)(M,{content:"Open notebook",children:(0,a.jsx)(J,{size:"small",onClick:o=>e(o),children:(0,a.jsx)(pe,{})})}),!d&&(0,a.jsx)(M,{content:"Download",children:(0,a.jsx)(J,{size:"small",onClick:()=>{if(Me(x)){pt(xt(l.contents,x),l.file.name);return}be(new Blob([l.contents||h],{type:x}),l.file.name)},children:(0,a.jsx)(ke,{})})}),!Me(x)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(M,{content:"Copy contents to clipboard",children:(0,a.jsx)(J,{size:"small",onClick:async()=>{await ne(h)},children:(0,a.jsx)(we,{})})}),(0,a.jsx)(M,{content:qt("global.save"),children:(0,a.jsx)(J,{size:"small",color:h===l.contents?void 0:"green",onClick:y,disabled:h===l.contents,children:(0,a.jsx)(Nt,{})})})]})]});return x.startsWith("image/")?(0,a.jsxs)(a.Fragment,{children:[b,(0,a.jsx)("div",{className:"flex-1 overflow-hidden flex flex-col",children:(0,a.jsx)(st,{base64:l.contents,mime:x})})]}):x==="text/csv"&&l.contents?(0,a.jsxs)(a.Fragment,{children:[b,(0,a.jsx)("div",{className:"flex-1 overflow-hidden flex flex-col",children:(0,a.jsx)(it,{contents:l.contents})})]}):x.startsWith("audio/")?(0,a.jsxs)(a.Fragment,{children:[b,(0,a.jsx)("div",{className:"flex-1 overflow-hidden flex flex-col",children:(0,a.jsx)(nt,{base64:l.contents,mime:x})})]}):x.startsWith("video/")?(0,a.jsxs)(a.Fragment,{children:[b,(0,a.jsx)("div",{className:"flex-1 overflow-hidden flex flex-col",children:(0,a.jsx)(rt,{base64:l.contents,mime:x})})]}):x.startsWith("application/pdf")?(0,a.jsxs)(a.Fragment,{children:[b,(0,a.jsx)("div",{className:"flex-1 overflow-hidden flex flex-col",children:(0,a.jsx)(lt,{base64:l.contents,mime:x})})]}):(0,a.jsxs)(a.Fragment,{children:[b,k&&(0,a.jsxs)(Tt,{variant:"warning",className:"rounded-none",children:[(0,a.jsx)(Dt,{className:"h-4 w-4"}),(0,a.jsx)(Ht,{children:"Editing the notebook file directly while running in marimo's editor may cause unintended changes. Please use with caution."})]}),(0,a.jsx)("div",{className:"flex-1 overflow-auto",children:(0,a.jsx)(F.Suspense,{children:(0,a.jsx)(ht,{theme:i==="dark"?"dark":"light",language:je[x]||je.default,className:"border-b",extensions:[at.lineWrapping,tt.of([{key:r.getHotkey("global.save").key,stopPropagation:!0,run:()=>h===l.contents?!1:(y(),!0)}])],value:h,onChange:m})})})]})};var Me=t=>t?t.startsWith("image/")||t.startsWith("audio/")||t.startsWith("video/")||t.startsWith("application/pdf"):!1,je={"application/javascript":"javascript","text/markdown":"markdown","text/html":"html","text/css":"css","text/x-python":"python","application/json":"json","application/xml":"xml","text/x-yaml":"yaml","text/csv":"markdown","text/plain":"markdown",default:"markdown"},ta=class{constructor(t){R(this,"delegate",new xe([]));R(this,"rootPath","");R(this,"onChange",Ye.NOOP);R(this,"path",new fe("/"));R(this,"initialize",async t=>{if(this.onChange=t,this.delegate.data.length===0)try{let e=await this.callbacks.listFiles({path:this.rootPath});this.delegate=new xe(e.files),this.rootPath=e.root,this.path=fe.guessDeliminator(e.root)}catch(e){W({title:"Failed",description:Rt(e)})}this.onChange(this.delegate.data)});R(this,"refreshAll",async t=>{let e=[this.rootPath,...t.map(n=>{var s;return(s=this.delegate.find(n))==null?void 0:s.data.path})].filter(Boolean),i=await Promise.all(e.map(n=>this.callbacks.listFiles({path:n}).catch(()=>({files:[]}))));for(let[n,s]of e.entries()){let r=i[n];s===this.rootPath?this.delegate=new xe(r.files):this.delegate.update({id:s,changes:{children:r.files}})}this.onChange(this.delegate.data)});R(this,"relativeFromRoot",t=>{let e=this.rootPath.endsWith(this.path.deliminator)?this.rootPath:`${this.rootPath}${this.path.deliminator}`;return t.startsWith(e)?t.slice(e.length):t});R(this,"handleResponse",t=>t.success?t:(W({title:"Failed",description:t.message}),null));this.callbacks=t}async expand(t){let e=this.delegate.find(t);if(!e||!e.data.isDirectory)return!1;if(e.children&&e.children.length>0)return!0;let i=await this.callbacks.listFiles({path:e.data.path});return this.delegate.update({id:t,changes:{children:i.files}}),this.onChange(this.delegate.data),!0}async rename(t,e){let i=this.delegate.find(t);if(!i)return;let n=i.data.path,s=this.path.join(this.path.dirname(n),e);await this.callbacks.renameFileOrFolder({path:n,newPath:s}).then(this.handleResponse),this.delegate.update({id:t,changes:{name:e,path:s}}),this.onChange(this.delegate.data),await this.refreshAll([s])}async move(t,e){var n;let i=e?((n=this.delegate.find(e))==null?void 0:n.data.path)??e:this.rootPath;await Promise.all(t.map(s=>{this.delegate.move({id:s,parentId:e,index:0});let r=this.delegate.find(s);if(!r)return Promise.resolve();let d=this.path.join(i,this.path.basename(r.data.path));return this.delegate.update({id:s,changes:{path:d}}),this.callbacks.renameFileOrFolder({path:r.data.path,newPath:d}).then(this.handleResponse)})),this.onChange(this.delegate.data),await this.refreshAll([i])}async createFile(t,e){var s;let i=e?((s=this.delegate.find(e))==null?void 0:s.data.path)??e:this.rootPath,n=await this.callbacks.createFileOrFolder({path:i,type:"file",name:t}).then(this.handleResponse);n!=null&&n.info&&(this.delegate.create({parentId:e,index:0,data:n.info}),this.onChange(this.delegate.data),await this.refreshAll([i]))}async createFolder(t,e){var s;let i=e?((s=this.delegate.find(e))==null?void 0:s.data.path)??e:this.rootPath,n=await this.callbacks.createFileOrFolder({path:i,type:"directory",name:t}).then(this.handleResponse);n!=null&&n.info&&(this.delegate.create({parentId:e,index:0,data:n.info}),this.onChange(this.delegate.data),await this.refreshAll([i]))}async delete(t){let e=this.delegate.find(t);e&&(await this.callbacks.deleteFileOrFolder({path:e.data.path}).then(this.handleResponse),this.delegate.drop({id:t}),this.onChange(this.delegate.data))}};const Re=ye(t=>{let e=t(ot);return Ze(e,"no requestClientAtom set"),new ta({listFiles:e.sendListFiles,createFileOrFolder:e.sendCreateFileOrFolder,deleteFileOrFolder:e.sendDeleteFileOrFolder,renameFileOrFolder:e.sendRenameFileOrFolder})}),aa=ye({});async function ia(){await qe.get(Re).refreshAll([])}var ra=ie(),na=1024*1024*100;function Ae(t){let e=(0,ra.c)(7),i;e[0]===t?i=e[1]:(i=t===void 0?{}:t,e[0]=t,e[1]=i);let n=i,{sendCreateFileOrFolder:s}=me(),r;e[2]===s?r=e[3]:(r=async f=>{for(let h of f){let m=ha(ca(h)),l="";m&&(l=fe.guessDeliminator(m).dirname(m));let u=(await $t(h)).split(",")[1];await s({path:l,type:"file",name:h.name,contents:u})}await ia()},e[2]=s,e[3]=r);let d;return e[4]!==n||e[5]!==r?(d={multiple:!0,maxSize:na,onError:da,onDropRejected:sa,onDrop:r,...n},e[4]=n,e[5]=r,e[6]=d):d=e[6],Ot(d)}function sa(t){W({title:"File upload failed",description:(0,a.jsx)("div",{className:"flex flex-col gap-1",children:t.map(la)}),variant:"danger"})}function la(t){return(0,a.jsxs)("div",{children:[t.file.name," (",t.errors.map(oa).join(", "),")"]},t.file.name)}function oa(t){return t.message}function da(t){Je.error(t),W({title:"File upload failed",description:t.message,variant:"danger"})}function ca(t){if(t.webkitRelativePath)return t.webkitRelativePath;if("path"in t&&typeof t.path=="string")return t.path;if("relativePath"in t&&typeof t.relativePath=="string")return t.relativePath}function ha(t){if(t)return t.replace(/^\/+/,"")}var Y=ie(),ma=Le("marimo:showHiddenFiles",!0,Ue,{getOnInit:!0}),We=F.createContext(null);const pa=t=>{let e=(0,Y.c)(68),{height:i}=t,n=(0,F.useRef)(null),s=Zt(),[r]=ce(Re),d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=[],e[0]=d):d=e[0];let[f,h]=(0,F.useState)(d),[m,l]=(0,F.useState)(null),[u,v]=ce(ma),{openPrompt:g}=Ne(),[c,y]=ce(aa),C;e[1]===r?C=e[2]:(C=()=>r.initialize(h),e[1]=r,e[2]=C);let x;e[3]===Symbol.for("react.memo_cache_sentinel")?(x=[],e[3]=x):x=e[3];let{isPending:D,error:k}=De(C,x),b;e[4]!==c||e[5]!==r?(b=()=>{r.refreshAll(Object.keys(c).filter(p=>c[p]))},e[4]=c,e[5]=r,e[6]=b):b=e[6];let o=A(b),j;e[7]!==v||e[8]!==u?(j=()=>{v(!u)},e[7]=v,e[8]=u,e[9]=j):j=e[9];let P=A(j),_;e[10]!==g||e[11]!==r?(_=async()=>{g({title:"Folder name",onConfirm:async p=>{r.createFolder(p,null)}})},e[10]=g,e[11]=r,e[12]=_):_=e[12];let N=A(_),O;e[13]!==g||e[14]!==r?(O=async()=>{g({title:"File name",onConfirm:async p=>{r.createFile(p,null)}})},e[13]=g,e[14]=r,e[15]=O):O=e[15];let se=A(O),Z;e[16]===y?Z=e[17]:(Z=()=>{var p;(p=n.current)==null||p.closeAll(),y({})},e[16]=y,e[17]=Z);let le=A(Z),Q;e[18]!==f||e[19]!==u?(Q=Ee(f,u),e[18]=f,e[19]=u,e[20]=Q):Q=e[20];let oe=Q;if(D){let p;return e[21]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsx)(kt,{size:"medium",centered:!0}),e[21]=p):p=e[21],p}if(k){let p;return e[22]===k?p=e[23]:(p=(0,a.jsx)(Se,{error:k}),e[22]=k,e[23]=p),p}if(m){let p;e[24]===Symbol.for("react.memo_cache_sentinel")?(p=()=>l(null),e[24]=p):p=e[24];let w;e[25]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsx)(I,{onClick:p,"data-testid":"file-explorer-back-button",variant:"text",size:"xs",className:"mb-0",children:(0,a.jsx)(dt,{size:16})}),e[25]=w):w=e[25];let z;e[26]===m.name?z=e[27]:(z=(0,a.jsxs)("div",{className:"flex items-center pl-1 pr-3 shrink-0 border-b justify-between",children:[w,(0,a.jsx)("span",{className:"font-bold",children:m.name})]}),e[26]=m.name,e[27]=z);let L;e[28]!==m.path||e[29]!==r?(L=He=>Ie(He,r.relativeFromRoot(m.path)),e[28]=m.path,e[29]=r,e[30]=L):L=e[30];let U;e[31]!==m||e[32]!==L?(U=(0,a.jsx)(F.Suspense,{children:(0,a.jsx)(ea,{onOpenNotebook:L,file:m})}),e[31]=m,e[32]=L,e[33]=U):U=e[33];let te;return e[34]!==z||e[35]!==U?(te=(0,a.jsxs)(a.Fragment,{children:[z,U]}),e[34]=z,e[35]=U,e[36]=te):te=e[36],te}let E;e[37]!==le||e[38]!==se||e[39]!==N||e[40]!==P||e[41]!==o||e[42]!==r?(E=(0,a.jsx)(xa,{onRefresh:o,onHidden:P,onCreateFile:se,onCreateFolder:N,onCollapseAll:le,tree:r}),e[37]=le,e[38]=se,e[39]=N,e[40]=P,e[41]=o,e[42]=r,e[43]=E):E=e[43];let de=i-33,H,T,B;e[44]===r?(H=e[45],T=e[46],B=e[47]):(H=async p=>{let{ids:w}=p;for(let z of w)await r.delete(z)},T=async p=>{let{id:w,name:z}=p;await r.rename(w,z)},B=async p=>{let{dragIds:w,parentId:z}=p;await r.move(w,z)},e[44]=r,e[45]=H,e[46]=T,e[47]=B);let X;e[48]===Symbol.for("react.memo_cache_sentinel")?(X=p=>{let w=p[0];w&&(w.data.isDirectory||l(w.data))},e[48]=X):X=e[48];let q;e[49]!==c||e[50]!==y||e[51]!==r?(q=async p=>{if(await r.expand(p)){let w=c[p]??!1;y({...c,[p]:!w})}},e[49]=c,e[50]=y,e[51]=r,e[52]=q):q=e[52];let $;e[53]!==s||e[54]!==c||e[55]!==de||e[56]!==H||e[57]!==T||e[58]!==B||e[59]!==q||e[60]!==oe?($=(0,a.jsx)(Et,{width:"100%",ref:n,height:de,className:"h-full",data:oe,initialOpenState:c,openByDefault:!1,dndManager:s,renderCursor:ba,disableDrop:wa,onDelete:H,onRename:T,onMove:B,onSelect:X,onToggle:q,padding:15,rowHeight:30,indent:fa,overscanCount:1e3,disableMultiSelection:!0,children:ga}),e[53]=s,e[54]=c,e[55]=de,e[56]=H,e[57]=T,e[58]=B,e[59]=q,e[60]=oe,e[61]=$):$=e[61];let V;e[62]!==$||e[63]!==r?(V=(0,a.jsx)(We,{value:r,children:$}),e[62]=$,e[63]=r,e[64]=V):V=e[64];let ee;return e[65]!==E||e[66]!==V?(ee=(0,a.jsxs)(a.Fragment,{children:[E,V]}),e[65]=E,e[66]=V,e[67]=ee):ee=e[67],ee};var fa=15,xa=t=>{let e=(0,Y.c)(34),{onRefresh:i,onHidden:n,onCreateFile:s,onCreateFolder:r,onCollapseAll:d}=t,f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f={noDrag:!0,noDragEventsBubbling:!0},e[0]=f):f=e[0];let{getRootProps:h,getInputProps:m}=Ae(f),l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=(0,a.jsx)(Ce,{size:16}),e[1]=l):l=e[1];let u;e[2]===s?u=e[3]:(u=(0,a.jsx)(M,{content:"Add file",children:(0,a.jsx)(I,{"data-testid":"file-explorer-add-file-button",onClick:s,variant:"text",size:"xs",children:l})}),e[2]=s,e[3]=u);let v;e[4]===Symbol.for("react.memo_cache_sentinel")?(v=(0,a.jsx)(Pe,{size:16}),e[4]=v):v=e[4];let g;e[5]===r?g=e[6]:(g=(0,a.jsx)(M,{content:"Add folder",children:(0,a.jsx)(I,{"data-testid":"file-explorer-add-folder-button",onClick:r,variant:"text",size:"xs",children:v})}),e[5]=r,e[6]=g);let c;e[7]===h?c=e[8]:(c=h({}),e[7]=h,e[8]=c);let y,C;e[9]===Symbol.for("react.memo_cache_sentinel")?(y=et({variant:"text",size:"xs"}),C=(0,a.jsx)(Pt,{size:16}),e[9]=y,e[10]=C):(y=e[9],C=e[10]);let x;e[11]===c?x=e[12]:(x=(0,a.jsx)(M,{content:"Upload file",children:(0,a.jsx)("button",{"data-testid":"file-explorer-upload-button",...c,className:y,children:C})}),e[11]=c,e[12]=x);let D;e[13]===m?D=e[14]:(D=m({}),e[13]=m,e[14]=D);let k;e[15]===D?k=e[16]:(k=(0,a.jsx)("input",{...D,type:"file"}),e[15]=D,e[16]=k);let b;e[17]===Symbol.for("react.memo_cache_sentinel")?(b=(0,a.jsx)(Ft,{size:16}),e[17]=b):b=e[17];let o;e[18]===i?o=e[19]:(o=(0,a.jsx)(M,{content:"Refresh",children:(0,a.jsx)(I,{"data-testid":"file-explorer-refresh-button",onClick:i,variant:"text",size:"xs",children:b})}),e[18]=i,e[19]=o);let j;e[20]===Symbol.for("react.memo_cache_sentinel")?(j=(0,a.jsx)(vt,{size:16}),e[20]=j):j=e[20];let P;e[21]===n?P=e[22]:(P=(0,a.jsx)(M,{content:"Toggle hidden files",children:(0,a.jsx)(I,{"data-testid":"file-explorer-hidden-files-button",onClick:n,variant:"text",size:"xs",children:j})}),e[21]=n,e[22]=P);let _;e[23]===Symbol.for("react.memo_cache_sentinel")?(_=(0,a.jsx)(Gt,{size:16}),e[23]=_):_=e[23];let N;e[24]===d?N=e[25]:(N=(0,a.jsx)(M,{content:"Collapse all folders",children:(0,a.jsx)(I,{"data-testid":"file-explorer-collapse-button",onClick:d,variant:"text",size:"xs",children:_})}),e[24]=d,e[25]=N);let O;return e[26]!==k||e[27]!==o||e[28]!==P||e[29]!==N||e[30]!==u||e[31]!==g||e[32]!==x?(O=(0,a.jsxs)("div",{className:"flex items-center justify-end px-2 shrink-0 border-b",children:[u,g,x,k,o,P,N]}),e[26]=k,e[27]=o,e[28]=P,e[29]=N,e[30]=u,e[31]=g,e[32]=x,e[33]=O):O=e[33],O},ua=t=>{let e=(0,Y.c)(9),{node:i,onOpenMarimoFile:n}=t,s;e[0]===i?s=e[1]:(s=f=>{i.data.isDirectory||(f.stopPropagation(),i.select())},e[0]=i,e[1]=s);let r;e[2]!==i.data.isMarimoFile||e[3]!==n?(r=i.data.isMarimoFile&&!re()&&(0,a.jsxs)("span",{className:"shrink-0 ml-2 text-sm hidden group-hover:inline hover:underline",onClick:n,children:["open ",(0,a.jsx)(pe,{className:"inline ml-1",size:12})]}),e[2]=i.data.isMarimoFile,e[3]=n,e[4]=r):r=e[4];let d;return e[5]!==i.data.name||e[6]!==s||e[7]!==r?(d=(0,a.jsxs)("span",{className:"flex-1 overflow-hidden text-ellipsis",onClick:s,children:[i.data.name,r]}),e[5]=i.data.name,e[6]=s,e[7]=r,e[8]=d):d=e[8],d},ja=t=>{let e=(0,Y.c)(10),{node:i}=t,n=(0,F.useRef)(null),s,r;e[0]===i.data.name?(s=e[1],r=e[2]):(s=()=>{var m,l;(m=n.current)==null||m.focus(),(l=n.current)==null||l.setSelectionRange(0,i.data.name.lastIndexOf("."))},r=[i.data.name],e[0]=i.data.name,e[1]=s,e[2]=r),(0,F.useEffect)(s,r);let d,f;e[3]===i?(d=e[4],f=e[5]):(d=()=>i.reset(),f=m=>{m.key==="Escape"&&i.reset(),m.key==="Enter"&&i.submit(m.currentTarget.value)},e[3]=i,e[4]=d,e[5]=f);let h;return e[6]!==i.data.name||e[7]!==d||e[8]!==f?(h=(0,a.jsx)("input",{ref:n,className:"flex-1 bg-transparent border border-border text-muted-foreground",defaultValue:i.data.name,onClick:ka,onBlur:d,onKeyDown:f}),e[6]=i.data.name,e[7]=d,e[8]=f,e[9]=h):h=e[9],h},ga=({node:t,style:e,dragHandle:i})=>{let{openFile:n,sendCreateFileOrFolder:s,sendFileDetails:r}=me(),d=ae(ve),f=t.data.isDirectory?"directory":bt(t.data.name),h=wt[f],{openConfirm:m,openPrompt:l}=Ne(),{createNewCell:u}=Ke(),v=Bt(),g=o=>{u({code:o,before:!1,cellId:v??"__end__"})},c=(0,F.use)(We),y=async o=>{Ie(o,c?c.relativeFromRoot(t.data.path):t.data.path)},C=async o=>{o.stopPropagation(),o.preventDefault(),m({title:"Delete file",description:`Are you sure you want to delete ${t.data.name}?`,confirmAction:(0,a.jsx)(Mt,{onClick:async()=>{await t.tree.delete(t.id)},"aria-label":"Confirm",children:"Delete"})})},x=A(async()=>{t.open(),l({title:"Folder name",onConfirm:async o=>{c==null||c.createFolder(o,t.id)}})}),D=A(async()=>{t.open(),l({title:"File name",onConfirm:async o=>{c==null||c.createFile(o,t.id)}})}),k=A(async()=>{var _;if(!c||t.data.isDirectory)return;let[o,j]=_t(t.data.name),P=`${o}_copy${j}`;try{let N=await r({path:t.data.path}),O=((_=t.parent)==null?void 0:_.data.path)||"";await s({path:O,type:"file",name:P,contents:N.contents?btoa(N.contents):void 0}),await c.refreshAll([O])}catch{W({title:"Failed to duplicate file",description:"Unable to create a duplicate of the file",variant:"danger"})}}),b=()=>{let o={size:14,strokeWidth:1.5,className:"mr-2"};return(0,a.jsxs)(jt,{align:"end",className:"print:hidden w-[220px]",onClick:j=>j.stopPropagation(),onCloseAutoFocus:j=>j.preventDefault(),children:[!t.data.isDirectory&&(0,a.jsxs)(S,{onSelect:()=>t.select(),children:[(0,a.jsx)(Yt,{...o}),"Open file"]}),!t.data.isDirectory&&!re()&&(0,a.jsxs)(S,{onSelect:()=>{n({path:t.data.path})},children:[(0,a.jsx)(pe,{...o}),"Open file in external editor"]}),t.data.isDirectory&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(S,{onSelect:()=>D(),children:[(0,a.jsx)(Ce,{...o}),"Create file"]}),(0,a.jsxs)(S,{onSelect:()=>x(),children:[(0,a.jsx)(Pe,{...o}),"Create folder"]}),(0,a.jsx)(K,{})]}),(0,a.jsxs)(S,{onSelect:()=>t.edit(),children:[(0,a.jsx)(Kt,{...o}),"Rename"]}),!t.data.isDirectory&&(0,a.jsxs)(S,{onSelect:k,children:[(0,a.jsx)(we,{...o}),"Duplicate"]}),(0,a.jsxs)(S,{onSelect:async()=>{await ne(t.data.path),W({title:"Copied to clipboard"})},children:[(0,a.jsx)(_e,{...o}),"Copy path"]}),c&&(0,a.jsxs)(S,{onSelect:async()=>{await ne(c.relativeFromRoot(t.data.path)),W({title:"Copied to clipboard"})},children:[(0,a.jsx)(_e,{...o}),"Copy relative path"]}),(0,a.jsx)(K,{}),(0,a.jsxs)(S,{onSelect:()=>{let{path:j}=t.data;g(Fe[f](j))},children:[(0,a.jsx)(ct,{...o}),"Insert snippet for reading file"]}),(0,a.jsxs)(S,{onSelect:async()=>{W({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:j}=t.data;await ne(Fe[f](j))},children:[(0,a.jsx)(Ge,{...o}),"Copy snippet for reading file"]}),t.data.isMarimoFile&&!re()&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(K,{}),(0,a.jsxs)(S,{onSelect:y,children:[(0,a.jsx)(Jt,{...o}),"Open notebook"]})]}),(0,a.jsx)(K,{}),!t.data.isDirectory&&!d&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(S,{onSelect:async()=>{let j=(await r({path:t.data.path})).contents||"";be(new Blob([j]),t.data.name)},children:[(0,a.jsx)(ke,{...o}),"Download"]}),(0,a.jsx)(K,{})]}),(0,a.jsxs)(S,{onSelect:C,variant:"danger",children:[(0,a.jsx)(St,{...o}),"Delete"]})]})};return(0,a.jsxs)("div",{style:e,ref:i,className:he("flex items-center cursor-pointer ml-1 text-muted-foreground whitespace-nowrap group"),draggable:!0,onClick:o=>{o.stopPropagation(),t.data.isDirectory&&t.toggle()},children:[(0,a.jsx)(ya,{node:t}),(0,a.jsxs)("span",{className:he("flex items-center pl-1 py-1 cursor-pointer hover:bg-accent/50 hover:text-accent-foreground rounded-l flex-1 overflow-hidden group",t.willReceiveDrop&&t.data.isDirectory&&"bg-accent/80 hover:bg-accent/80 text-accent-foreground"),children:[t.data.isMarimoFile?(0,a.jsx)("img",{src:Ut,className:"w-5 h-5 shrink-0 mr-2 filter grayscale",alt:"Marimo"}):(0,a.jsx)(h,{className:"w-5 h-5 shrink-0 mr-2",strokeWidth:1.5}),t.isEditing?(0,a.jsx)(ja,{node:t}):(0,a.jsx)(ua,{node:t,onOpenMarimoFile:y}),(0,a.jsxs)(gt,{modal:!1,children:[(0,a.jsx)(ut,{asChild:!0,tabIndex:-1,onClick:o=>o.stopPropagation(),children:(0,a.jsx)(I,{"data-testid":"file-explorer-more-button",variant:"text",tabIndex:-1,size:"xs",className:"mb-0","aria-label":"More options",children:(0,a.jsx)(yt,{strokeWidth:2,className:"w-5 h-5 hidden group-hover:block"})})}),b()]})]})]})},ya=t=>{let e=(0,Y.c)(3),{node:i}=t;if(!i.data.isDirectory){let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)("span",{className:"w-5 h-5 shrink-0"}),e[0]=s):s=e[0],s}let n;return e[1]===i.isOpen?n=e[2]:(n=i.isOpen?(0,a.jsx)(mt,{className:"w-5 h-5 shrink-0"}):(0,a.jsx)(ft,{className:"w-5 h-5 shrink-0"}),e[1]=i.isOpen,e[2]=n),n};function Ie(t,e){t.stopPropagation(),t.preventDefault(),Lt(e)}function Ee(t,e){if(e)return t;let i=[];for(let n of t){if(va(n.name))continue;let s=n;if(n.children){let r=Ee(n.children,e);r!==n.children&&(s={...n,children:r})}i.push(s)}return i}function va(t){return!!t.startsWith(".")}function ba(){return null}function wa(t){let{parentNode:e}=t;return!e.data.isDirectory}function ka(t){return t.stopPropagation()}var Fa=ie(),Ca=()=>{let t=(0,Fa.c)(20),{ref:e,height:i}=Vt(),n=i===void 0?1:i,s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s={noClick:!0,noKeyboard:!0},t[0]=s):s=t[0];let{getRootProps:r,getInputProps:d,isDragActive:f}=Ae(s),h;t[1]===r?h=t[2]:(h=r(),t[1]=r,t[2]=h);let m;t[3]===Symbol.for("react.memo_cache_sentinel")?(m=he("flex flex-col flex-1 overflow-hidden relative"),t[3]=m):m=t[3];let l;t[4]===d?l=t[5]:(l=d(),t[4]=d,t[5]=l);let u;t[6]===l?u=t[7]:(u=(0,a.jsx)("input",{...l}),t[6]=l,t[7]=u);let v;t[8]===f?v=t[9]:(v=f&&(0,a.jsx)("div",{className:"absolute inset-0 flex items-center uppercase justify-center text-xl font-bold text-primary/90 bg-accent/85 z-10 border-2 border-dashed border-primary/90 rounded-lg pointer-events-none",children:"Drop files here"}),t[8]=f,t[9]=v);let g;t[10]===n?g=t[11]:(g=(0,a.jsx)(pa,{height:n}),t[10]=n,t[11]=g);let c;t[12]!==e||t[13]!==g?(c=(0,a.jsx)("div",{ref:e,className:"flex flex-col flex-1 overflow-hidden",children:g}),t[12]=e,t[13]=g,t[14]=c):c=t[14];let y;return t[15]!==h||t[16]!==u||t[17]!==v||t[18]!==c?(y=(0,a.jsx)(Xt,{children:(0,a.jsxs)("div",{...h,className:m,children:[u,v,c]})}),t[15]=h,t[16]=u,t[17]=v,t[18]=c,t[19]=y):y=t[19],y};export{Ca as default};
1
+ var Te=Object.defineProperty;var Be=(t,e,i)=>e in t?Te(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var R=(t,e,i)=>Be(t,typeof e!="symbol"?e+"":e,i);import{s as ge}from"./chunk-LvLJmgfZ.js";import{i as qe,l as ce,n as A,p as ye,u as ae}from"./useEvent-BhXAndur.js";import{t as $e}from"./react-Bj1aDYRI.js";import{Gr as Ve,Jr as Le,mn as Ue,qn as Ge,w as Ke}from"./cells-DbD2lYze.js";import"./react-dom-CSu739Rf.js";import{t as ie}from"./compiler-runtime-B3qBwwSJ.js";import"./tooltip-DxKBXCGp.js";import{d as Je,f as Ye}from"./hotkeys-BHHWjLlp.js";import{t as Ze}from"./invariant-CAG_dYON.js";import{p as Qe,u as ve}from"./utils-YqBXNpsM.js";import{S as re}from"./config-D2-Bw6QC.js";import{t as Xe}from"./jsx-runtime-ZmTK25f3.js";import{n as et,t as I}from"./button-CZ3Cs4qb.js";import{t as he}from"./cn-BKtXLv3a.js";import{St as tt,at}from"./dist-DBwNzi3C.js";import{a as it,c as rt,i as nt,o as st,s as lt}from"./JsonOutput-DsO4felE.js";import"./cjs-CH5Rj0g8.js";import"./main-U5Goe76G.js";import"./useNonce-CS26E0hA.js";import{n as ot,r as me}from"./requests-B4FYHTZl.js";import{t as G}from"./createLucideIcon-BCdY6lG5.js";import{t as dt}from"./arrow-left-VDC1u5rq.js";import{n as ct,t as ht}from"./LazyAnyLanguageCodeMirror-CQP8KZWO.js";import{r as mt}from"./x-ZP5cObgf.js";import{i as pt,r as be}from"./download-CmdFQXRz.js";import{t as ft}from"./chevron-right--18M_6o9.js";import{f as pe}from"./maps-D2_Mq1pZ.js";import{n as xt}from"./markdown-renderer-D8AmLSIR.js";import{a as S,c as K,p as ut,r as jt,t as gt}from"./dropdown-menu-BUgFWmX1.js";import{t as we}from"./copy-D-8y6iMN.js";import{t as ke}from"./download-Dg7clfkc.js";import{t as yt}from"./ellipsis-vertical-J1F7_WS9.js";import{t as vt}from"./eye-off-AK_9uodG.js";import{n as Fe,r as bt,t as wt}from"./types-7nV0hgXj.js";import{t as Ce}from"./file-plus-corner-CvAy4H5W.js";import{t as kt}from"./spinner-DA8-7wQv.js";import{t as Ft}from"./refresh-ccw-DN_xCV6A.js";import{t as Ct}from"./refresh-cw-Dx8TEWFP.js";import{t as Nt}from"./save-DZodxFnE.js";import{t as St}from"./trash-2-B8SQYdQq.js";import{t as Dt}from"./triangle-alert-U93NZYDl.js";import{i as Pt,n as _t,t as Ot}from"./es-CerBf9Z6.js";import"./dist-Cayq-K1c.js";import"./dist-TiFCI16_.js";import"./dist-BIKFl48f.js";import"./dist-B0VqT_4z.js";import"./dist-BYyu59D8.js";import{t as W}from"./use-toast-T0_cQDma.js";import{t as fe}from"./paths-Dfii2bN8.js";import"./session-fBtIbMpB.js";import{r as zt}from"./useTheme-CTORu22_.js";import"./Combination-izwufzWe.js";import{t as M}from"./tooltip-C_WgOOcZ.js";import"./dates-CT5PUuFo.js";import{o as Mt}from"./alert-dialog-Ctz24SMn.js";import"./popover-B-131r4d.js";import{n as Ne}from"./ImperativeModal-DZr52ffu.js";import{r as Rt}from"./errors-CPlNr33a.js";import"./vega-loader.browser-DXARUlxo.js";import"./defaultLocale-JieDVWC_.js";import"./defaultLocale-BLne0bXb.js";import{t as ne}from"./copy-DHrHayPa.js";import"./purify.es-DZrAQFIu.js";import{a as At,i as Wt,n as xe,r as It,t as Et}from"./tree-B8r7cwRm.js";import{n as Ht,t as Tt}from"./alert-BOoN6gJ1.js";import{n as Se}from"./error-banner-Dlrzo_Ay.js";import{n as De}from"./useAsyncData-BMGLSTg8.js";import"./chunk-5FQGJX7Z-CwvgJCug.js";import"./katex-CDLTCvjQ.js";import"./html-to-image-DrmKVKna.js";import{o as Bt}from"./focus-BEf2RhRf.js";import{a as qt}from"./renderShortcut-B1jzzLJw.js";import{n as $t}from"./blob-t6qcPM7K.js";import{t as Vt}from"./bundle.esm-CBAPjfrh.js";import{t as Lt}from"./links-DgZx-VxW.js";import{t as Ut}from"./icon-32x32-XIbzzdoo.js";import{t as J}from"./Inputs-CbenuziM.js";var Gt=G("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"}]]),Pe=G("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"}]]),_e=G("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"}]]),Kt=G("pen-line",[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]),Jt=G("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"}]]),Yt=G("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"}]]),Oe=ie(),F=ge($e(),1),a=ge(Xe(),1),ze=(0,F.createContext)(null);function Zt(){return(0,F.useContext)(ze)??void 0}var Qt=t=>{let e=(0,Oe.c)(3),{children:i}=t,n=Wt(),s;return e[0]!==i||e[1]!==n?(s=(0,a.jsx)(ze.Provider,{value:n,children:i}),e[0]=i,e[1]=n,e[2]=s):s=e[2],s};const Xt=t=>{let e=(0,Oe.c)(5),{children:i}=t,[n,s]=(0,F.useState)(null),r;e[0]!==i||e[1]!==n?(r=n&&(0,a.jsx)(At,{backend:It,options:{rootElement:n},children:(0,a.jsx)(Qt,{children:i})}),e[0]=i,e[1]=n,e[2]=r):r=e[2];let d;return e[3]===r?d=e[4]:(d=(0,a.jsx)("div",{ref:s,className:"contents",children:r}),e[3]=r,e[4]=d),d};var ue=new Map;const ea=({file:t,onOpenNotebook:e})=>{let{theme:i}=zt(),{sendFileDetails:n,sendUpdateFile:s}=me(),r=ae(Qe),d=ae(ve),f=ae(Ve),[h,m]=(0,F.useState)(""),{data:l,isPending:u,error:v,setData:g,refetch:c}=De(async()=>{let o=await n({path:t.path}),j=o.contents||"";return m(ue.get(t.path)||j),o},[t.path]),y=async()=>{h!==(l==null?void 0:l.contents)&&await s({path:t.path,contents:h}).then(o=>{o.success&&(g(j=>({...j,contents:h})),m(h))})},C=(0,F.useRef)(h);if(C.current=h,(0,F.useEffect)(()=>()=>{if(!(l!=null&&l.contents))return;let o=C.current;o===l.contents?ue.delete(t.path):ue.set(t.path,o)},[t.path,l==null?void 0:l.contents]),v)return(0,a.jsx)(Se,{error:v});if(u||!l)return null;let x=l.mimeType||"text/plain",D=x in je,k=f&&l.file.isMarimoFile&&(t.path===f||t.path.endsWith(`/${f}`));if(!l.contents&&!D)return(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-2 p-6",children:[(0,a.jsx)("div",{className:"font-bold text-muted-foreground",children:"Name"}),(0,a.jsx)("div",{children:l.file.name}),(0,a.jsx)("div",{className:"font-bold text-muted-foreground",children:"Type"}),(0,a.jsx)("div",{children:x})]});let b=(0,a.jsxs)("div",{className:"text-xs text-muted-foreground p-1 flex justify-end gap-2 border-b",children:[(0,a.jsx)(M,{content:"Refresh",children:(0,a.jsx)(J,{size:"small",onClick:c,children:(0,a.jsx)(Ct,{})})}),t.isMarimoFile&&!re()&&(0,a.jsx)(M,{content:"Open notebook",children:(0,a.jsx)(J,{size:"small",onClick:o=>e(o),children:(0,a.jsx)(pe,{})})}),!d&&(0,a.jsx)(M,{content:"Download",children:(0,a.jsx)(J,{size:"small",onClick:()=>{if(Me(x)){pt(xt(l.contents,x),l.file.name);return}be(new Blob([l.contents||h],{type:x}),l.file.name)},children:(0,a.jsx)(ke,{})})}),!Me(x)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(M,{content:"Copy contents to clipboard",children:(0,a.jsx)(J,{size:"small",onClick:async()=>{await ne(h)},children:(0,a.jsx)(we,{})})}),(0,a.jsx)(M,{content:qt("global.save"),children:(0,a.jsx)(J,{size:"small",color:h===l.contents?void 0:"green",onClick:y,disabled:h===l.contents,children:(0,a.jsx)(Nt,{})})})]})]});return x.startsWith("image/")?(0,a.jsxs)(a.Fragment,{children:[b,(0,a.jsx)("div",{className:"flex-1 overflow-hidden flex flex-col",children:(0,a.jsx)(st,{base64:l.contents,mime:x})})]}):x==="text/csv"&&l.contents?(0,a.jsxs)(a.Fragment,{children:[b,(0,a.jsx)("div",{className:"flex-1 overflow-hidden flex flex-col",children:(0,a.jsx)(it,{contents:l.contents})})]}):x.startsWith("audio/")?(0,a.jsxs)(a.Fragment,{children:[b,(0,a.jsx)("div",{className:"flex-1 overflow-hidden flex flex-col",children:(0,a.jsx)(nt,{base64:l.contents,mime:x})})]}):x.startsWith("video/")?(0,a.jsxs)(a.Fragment,{children:[b,(0,a.jsx)("div",{className:"flex-1 overflow-hidden flex flex-col",children:(0,a.jsx)(rt,{base64:l.contents,mime:x})})]}):x.startsWith("application/pdf")?(0,a.jsxs)(a.Fragment,{children:[b,(0,a.jsx)("div",{className:"flex-1 overflow-hidden flex flex-col",children:(0,a.jsx)(lt,{base64:l.contents,mime:x})})]}):(0,a.jsxs)(a.Fragment,{children:[b,k&&(0,a.jsxs)(Tt,{variant:"warning",className:"rounded-none",children:[(0,a.jsx)(Dt,{className:"h-4 w-4"}),(0,a.jsx)(Ht,{children:"Editing the notebook file directly while running in marimo's editor may cause unintended changes. Please use with caution."})]}),(0,a.jsx)("div",{className:"flex-1 overflow-auto",children:(0,a.jsx)(F.Suspense,{children:(0,a.jsx)(ht,{theme:i==="dark"?"dark":"light",language:je[x]||je.default,className:"border-b",extensions:[at.lineWrapping,tt.of([{key:r.getHotkey("global.save").key,stopPropagation:!0,run:()=>h===l.contents?!1:(y(),!0)}])],value:h,onChange:m})})})]})};var Me=t=>t?t.startsWith("image/")||t.startsWith("audio/")||t.startsWith("video/")||t.startsWith("application/pdf"):!1,je={"application/javascript":"javascript","text/markdown":"markdown","text/html":"html","text/css":"css","text/x-python":"python","application/json":"json","application/xml":"xml","text/x-yaml":"yaml","text/csv":"markdown","text/plain":"markdown",default:"markdown"},ta=class{constructor(t){R(this,"delegate",new xe([]));R(this,"rootPath","");R(this,"onChange",Ye.NOOP);R(this,"path",new fe("/"));R(this,"initialize",async t=>{if(this.onChange=t,this.delegate.data.length===0)try{let e=await this.callbacks.listFiles({path:this.rootPath});this.delegate=new xe(e.files),this.rootPath=e.root,this.path=fe.guessDeliminator(e.root)}catch(e){W({title:"Failed",description:Rt(e)})}this.onChange(this.delegate.data)});R(this,"refreshAll",async t=>{let e=[this.rootPath,...t.map(n=>{var s;return(s=this.delegate.find(n))==null?void 0:s.data.path})].filter(Boolean),i=await Promise.all(e.map(n=>this.callbacks.listFiles({path:n}).catch(()=>({files:[]}))));for(let[n,s]of e.entries()){let r=i[n];s===this.rootPath?this.delegate=new xe(r.files):this.delegate.update({id:s,changes:{children:r.files}})}this.onChange(this.delegate.data)});R(this,"relativeFromRoot",t=>{let e=this.rootPath.endsWith(this.path.deliminator)?this.rootPath:`${this.rootPath}${this.path.deliminator}`;return t.startsWith(e)?t.slice(e.length):t});R(this,"handleResponse",t=>t.success?t:(W({title:"Failed",description:t.message}),null));this.callbacks=t}async expand(t){let e=this.delegate.find(t);if(!e||!e.data.isDirectory)return!1;if(e.children&&e.children.length>0)return!0;let i=await this.callbacks.listFiles({path:e.data.path});return this.delegate.update({id:t,changes:{children:i.files}}),this.onChange(this.delegate.data),!0}async rename(t,e){let i=this.delegate.find(t);if(!i)return;let n=i.data.path,s=this.path.join(this.path.dirname(n),e);await this.callbacks.renameFileOrFolder({path:n,newPath:s}).then(this.handleResponse),this.delegate.update({id:t,changes:{name:e,path:s}}),this.onChange(this.delegate.data),await this.refreshAll([s])}async move(t,e){var n;let i=e?((n=this.delegate.find(e))==null?void 0:n.data.path)??e:this.rootPath;await Promise.all(t.map(s=>{this.delegate.move({id:s,parentId:e,index:0});let r=this.delegate.find(s);if(!r)return Promise.resolve();let d=this.path.join(i,this.path.basename(r.data.path));return this.delegate.update({id:s,changes:{path:d}}),this.callbacks.renameFileOrFolder({path:r.data.path,newPath:d}).then(this.handleResponse)})),this.onChange(this.delegate.data),await this.refreshAll([i])}async createFile(t,e){var s;let i=e?((s=this.delegate.find(e))==null?void 0:s.data.path)??e:this.rootPath,n=await this.callbacks.createFileOrFolder({path:i,type:"file",name:t}).then(this.handleResponse);n!=null&&n.info&&(this.delegate.create({parentId:e,index:0,data:n.info}),this.onChange(this.delegate.data),await this.refreshAll([i]))}async createFolder(t,e){var s;let i=e?((s=this.delegate.find(e))==null?void 0:s.data.path)??e:this.rootPath,n=await this.callbacks.createFileOrFolder({path:i,type:"directory",name:t}).then(this.handleResponse);n!=null&&n.info&&(this.delegate.create({parentId:e,index:0,data:n.info}),this.onChange(this.delegate.data),await this.refreshAll([i]))}async delete(t){let e=this.delegate.find(t);e&&(await this.callbacks.deleteFileOrFolder({path:e.data.path}).then(this.handleResponse),this.delegate.drop({id:t}),this.onChange(this.delegate.data))}};const Re=ye(t=>{let e=t(ot);return Ze(e,"no requestClientAtom set"),new ta({listFiles:e.sendListFiles,createFileOrFolder:e.sendCreateFileOrFolder,deleteFileOrFolder:e.sendDeleteFileOrFolder,renameFileOrFolder:e.sendRenameFileOrFolder})}),aa=ye({});async function ia(){await qe.get(Re).refreshAll([])}var ra=ie(),na=1024*1024*100;function Ae(t){let e=(0,ra.c)(7),i;e[0]===t?i=e[1]:(i=t===void 0?{}:t,e[0]=t,e[1]=i);let n=i,{sendCreateFileOrFolder:s}=me(),r;e[2]===s?r=e[3]:(r=async f=>{for(let h of f){let m=ha(ca(h)),l="";m&&(l=fe.guessDeliminator(m).dirname(m));let u=(await $t(h)).split(",")[1];await s({path:l,type:"file",name:h.name,contents:u})}await ia()},e[2]=s,e[3]=r);let d;return e[4]!==n||e[5]!==r?(d={multiple:!0,maxSize:na,onError:da,onDropRejected:sa,onDrop:r,...n},e[4]=n,e[5]=r,e[6]=d):d=e[6],Ot(d)}function sa(t){W({title:"File upload failed",description:(0,a.jsx)("div",{className:"flex flex-col gap-1",children:t.map(la)}),variant:"danger"})}function la(t){return(0,a.jsxs)("div",{children:[t.file.name," (",t.errors.map(oa).join(", "),")"]},t.file.name)}function oa(t){return t.message}function da(t){Je.error(t),W({title:"File upload failed",description:t.message,variant:"danger"})}function ca(t){if(t.webkitRelativePath)return t.webkitRelativePath;if("path"in t&&typeof t.path=="string")return t.path;if("relativePath"in t&&typeof t.relativePath=="string")return t.relativePath}function ha(t){if(t)return t.replace(/^\/+/,"")}var Y=ie(),ma=Le("marimo:showHiddenFiles",!0,Ue,{getOnInit:!0}),We=F.createContext(null);const pa=t=>{let e=(0,Y.c)(68),{height:i}=t,n=(0,F.useRef)(null),s=Zt(),[r]=ce(Re),d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=[],e[0]=d):d=e[0];let[f,h]=(0,F.useState)(d),[m,l]=(0,F.useState)(null),[u,v]=ce(ma),{openPrompt:g}=Ne(),[c,y]=ce(aa),C;e[1]===r?C=e[2]:(C=()=>r.initialize(h),e[1]=r,e[2]=C);let x;e[3]===Symbol.for("react.memo_cache_sentinel")?(x=[],e[3]=x):x=e[3];let{isPending:D,error:k}=De(C,x),b;e[4]!==c||e[5]!==r?(b=()=>{r.refreshAll(Object.keys(c).filter(p=>c[p]))},e[4]=c,e[5]=r,e[6]=b):b=e[6];let o=A(b),j;e[7]!==v||e[8]!==u?(j=()=>{v(!u)},e[7]=v,e[8]=u,e[9]=j):j=e[9];let P=A(j),_;e[10]!==g||e[11]!==r?(_=async()=>{g({title:"Folder name",onConfirm:async p=>{r.createFolder(p,null)}})},e[10]=g,e[11]=r,e[12]=_):_=e[12];let N=A(_),O;e[13]!==g||e[14]!==r?(O=async()=>{g({title:"File name",onConfirm:async p=>{r.createFile(p,null)}})},e[13]=g,e[14]=r,e[15]=O):O=e[15];let se=A(O),Z;e[16]===y?Z=e[17]:(Z=()=>{var p;(p=n.current)==null||p.closeAll(),y({})},e[16]=y,e[17]=Z);let le=A(Z),Q;e[18]!==f||e[19]!==u?(Q=Ee(f,u),e[18]=f,e[19]=u,e[20]=Q):Q=e[20];let oe=Q;if(D){let p;return e[21]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsx)(kt,{size:"medium",centered:!0}),e[21]=p):p=e[21],p}if(k){let p;return e[22]===k?p=e[23]:(p=(0,a.jsx)(Se,{error:k}),e[22]=k,e[23]=p),p}if(m){let p;e[24]===Symbol.for("react.memo_cache_sentinel")?(p=()=>l(null),e[24]=p):p=e[24];let w;e[25]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsx)(I,{onClick:p,"data-testid":"file-explorer-back-button",variant:"text",size:"xs",className:"mb-0",children:(0,a.jsx)(dt,{size:16})}),e[25]=w):w=e[25];let z;e[26]===m.name?z=e[27]:(z=(0,a.jsxs)("div",{className:"flex items-center pl-1 pr-3 shrink-0 border-b justify-between",children:[w,(0,a.jsx)("span",{className:"font-bold",children:m.name})]}),e[26]=m.name,e[27]=z);let L;e[28]!==m.path||e[29]!==r?(L=He=>Ie(He,r.relativeFromRoot(m.path)),e[28]=m.path,e[29]=r,e[30]=L):L=e[30];let U;e[31]!==m||e[32]!==L?(U=(0,a.jsx)(F.Suspense,{children:(0,a.jsx)(ea,{onOpenNotebook:L,file:m})}),e[31]=m,e[32]=L,e[33]=U):U=e[33];let te;return e[34]!==z||e[35]!==U?(te=(0,a.jsxs)(a.Fragment,{children:[z,U]}),e[34]=z,e[35]=U,e[36]=te):te=e[36],te}let E;e[37]!==le||e[38]!==se||e[39]!==N||e[40]!==P||e[41]!==o||e[42]!==r?(E=(0,a.jsx)(xa,{onRefresh:o,onHidden:P,onCreateFile:se,onCreateFolder:N,onCollapseAll:le,tree:r}),e[37]=le,e[38]=se,e[39]=N,e[40]=P,e[41]=o,e[42]=r,e[43]=E):E=e[43];let de=i-33,H,T,B;e[44]===r?(H=e[45],T=e[46],B=e[47]):(H=async p=>{let{ids:w}=p;for(let z of w)await r.delete(z)},T=async p=>{let{id:w,name:z}=p;await r.rename(w,z)},B=async p=>{let{dragIds:w,parentId:z}=p;await r.move(w,z)},e[44]=r,e[45]=H,e[46]=T,e[47]=B);let X;e[48]===Symbol.for("react.memo_cache_sentinel")?(X=p=>{let w=p[0];w&&(w.data.isDirectory||l(w.data))},e[48]=X):X=e[48];let q;e[49]!==c||e[50]!==y||e[51]!==r?(q=async p=>{if(await r.expand(p)){let w=c[p]??!1;y({...c,[p]:!w})}},e[49]=c,e[50]=y,e[51]=r,e[52]=q):q=e[52];let $;e[53]!==s||e[54]!==c||e[55]!==de||e[56]!==H||e[57]!==T||e[58]!==B||e[59]!==q||e[60]!==oe?($=(0,a.jsx)(Et,{width:"100%",ref:n,height:de,className:"h-full",data:oe,initialOpenState:c,openByDefault:!1,dndManager:s,renderCursor:ba,disableDrop:wa,onDelete:H,onRename:T,onMove:B,onSelect:X,onToggle:q,padding:15,rowHeight:30,indent:fa,overscanCount:1e3,disableMultiSelection:!0,children:ga}),e[53]=s,e[54]=c,e[55]=de,e[56]=H,e[57]=T,e[58]=B,e[59]=q,e[60]=oe,e[61]=$):$=e[61];let V;e[62]!==$||e[63]!==r?(V=(0,a.jsx)(We,{value:r,children:$}),e[62]=$,e[63]=r,e[64]=V):V=e[64];let ee;return e[65]!==E||e[66]!==V?(ee=(0,a.jsxs)(a.Fragment,{children:[E,V]}),e[65]=E,e[66]=V,e[67]=ee):ee=e[67],ee};var fa=15,xa=t=>{let e=(0,Y.c)(34),{onRefresh:i,onHidden:n,onCreateFile:s,onCreateFolder:r,onCollapseAll:d}=t,f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f={noDrag:!0,noDragEventsBubbling:!0},e[0]=f):f=e[0];let{getRootProps:h,getInputProps:m}=Ae(f),l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=(0,a.jsx)(Ce,{size:16}),e[1]=l):l=e[1];let u;e[2]===s?u=e[3]:(u=(0,a.jsx)(M,{content:"Add file",children:(0,a.jsx)(I,{"data-testid":"file-explorer-add-file-button",onClick:s,variant:"text",size:"xs",children:l})}),e[2]=s,e[3]=u);let v;e[4]===Symbol.for("react.memo_cache_sentinel")?(v=(0,a.jsx)(Pe,{size:16}),e[4]=v):v=e[4];let g;e[5]===r?g=e[6]:(g=(0,a.jsx)(M,{content:"Add folder",children:(0,a.jsx)(I,{"data-testid":"file-explorer-add-folder-button",onClick:r,variant:"text",size:"xs",children:v})}),e[5]=r,e[6]=g);let c;e[7]===h?c=e[8]:(c=h({}),e[7]=h,e[8]=c);let y,C;e[9]===Symbol.for("react.memo_cache_sentinel")?(y=et({variant:"text",size:"xs"}),C=(0,a.jsx)(Pt,{size:16}),e[9]=y,e[10]=C):(y=e[9],C=e[10]);let x;e[11]===c?x=e[12]:(x=(0,a.jsx)(M,{content:"Upload file",children:(0,a.jsx)("button",{"data-testid":"file-explorer-upload-button",...c,className:y,children:C})}),e[11]=c,e[12]=x);let D;e[13]===m?D=e[14]:(D=m({}),e[13]=m,e[14]=D);let k;e[15]===D?k=e[16]:(k=(0,a.jsx)("input",{...D,type:"file"}),e[15]=D,e[16]=k);let b;e[17]===Symbol.for("react.memo_cache_sentinel")?(b=(0,a.jsx)(Ft,{size:16}),e[17]=b):b=e[17];let o;e[18]===i?o=e[19]:(o=(0,a.jsx)(M,{content:"Refresh",children:(0,a.jsx)(I,{"data-testid":"file-explorer-refresh-button",onClick:i,variant:"text",size:"xs",children:b})}),e[18]=i,e[19]=o);let j;e[20]===Symbol.for("react.memo_cache_sentinel")?(j=(0,a.jsx)(vt,{size:16}),e[20]=j):j=e[20];let P;e[21]===n?P=e[22]:(P=(0,a.jsx)(M,{content:"Toggle hidden files",children:(0,a.jsx)(I,{"data-testid":"file-explorer-hidden-files-button",onClick:n,variant:"text",size:"xs",children:j})}),e[21]=n,e[22]=P);let _;e[23]===Symbol.for("react.memo_cache_sentinel")?(_=(0,a.jsx)(Gt,{size:16}),e[23]=_):_=e[23];let N;e[24]===d?N=e[25]:(N=(0,a.jsx)(M,{content:"Collapse all folders",children:(0,a.jsx)(I,{"data-testid":"file-explorer-collapse-button",onClick:d,variant:"text",size:"xs",children:_})}),e[24]=d,e[25]=N);let O;return e[26]!==k||e[27]!==o||e[28]!==P||e[29]!==N||e[30]!==u||e[31]!==g||e[32]!==x?(O=(0,a.jsxs)("div",{className:"flex items-center justify-end px-2 shrink-0 border-b",children:[u,g,x,k,o,P,N]}),e[26]=k,e[27]=o,e[28]=P,e[29]=N,e[30]=u,e[31]=g,e[32]=x,e[33]=O):O=e[33],O},ua=t=>{let e=(0,Y.c)(9),{node:i,onOpenMarimoFile:n}=t,s;e[0]===i?s=e[1]:(s=f=>{i.data.isDirectory||(f.stopPropagation(),i.select())},e[0]=i,e[1]=s);let r;e[2]!==i.data.isMarimoFile||e[3]!==n?(r=i.data.isMarimoFile&&!re()&&(0,a.jsxs)("span",{className:"shrink-0 ml-2 text-sm hidden group-hover:inline hover:underline",onClick:n,children:["open ",(0,a.jsx)(pe,{className:"inline ml-1",size:12})]}),e[2]=i.data.isMarimoFile,e[3]=n,e[4]=r):r=e[4];let d;return e[5]!==i.data.name||e[6]!==s||e[7]!==r?(d=(0,a.jsxs)("span",{className:"flex-1 overflow-hidden text-ellipsis",onClick:s,children:[i.data.name,r]}),e[5]=i.data.name,e[6]=s,e[7]=r,e[8]=d):d=e[8],d},ja=t=>{let e=(0,Y.c)(10),{node:i}=t,n=(0,F.useRef)(null),s,r;e[0]===i.data.name?(s=e[1],r=e[2]):(s=()=>{var m,l;(m=n.current)==null||m.focus(),(l=n.current)==null||l.setSelectionRange(0,i.data.name.lastIndexOf("."))},r=[i.data.name],e[0]=i.data.name,e[1]=s,e[2]=r),(0,F.useEffect)(s,r);let d,f;e[3]===i?(d=e[4],f=e[5]):(d=()=>i.reset(),f=m=>{m.key==="Escape"&&i.reset(),m.key==="Enter"&&i.submit(m.currentTarget.value)},e[3]=i,e[4]=d,e[5]=f);let h;return e[6]!==i.data.name||e[7]!==d||e[8]!==f?(h=(0,a.jsx)("input",{ref:n,className:"flex-1 bg-transparent border border-border text-muted-foreground",defaultValue:i.data.name,onClick:ka,onBlur:d,onKeyDown:f}),e[6]=i.data.name,e[7]=d,e[8]=f,e[9]=h):h=e[9],h},ga=({node:t,style:e,dragHandle:i})=>{let{openFile:n,sendCreateFileOrFolder:s,sendFileDetails:r}=me(),d=ae(ve),f=t.data.isDirectory?"directory":bt(t.data.name),h=wt[f],{openConfirm:m,openPrompt:l}=Ne(),{createNewCell:u}=Ke(),v=Bt(),g=o=>{u({code:o,before:!1,cellId:v??"__end__"})},c=(0,F.use)(We),y=async o=>{Ie(o,c?c.relativeFromRoot(t.data.path):t.data.path)},C=async o=>{o.stopPropagation(),o.preventDefault(),m({title:"Delete file",description:`Are you sure you want to delete ${t.data.name}?`,confirmAction:(0,a.jsx)(Mt,{onClick:async()=>{await t.tree.delete(t.id)},"aria-label":"Confirm",children:"Delete"})})},x=A(async()=>{t.open(),l({title:"Folder name",onConfirm:async o=>{c==null||c.createFolder(o,t.id)}})}),D=A(async()=>{t.open(),l({title:"File name",onConfirm:async o=>{c==null||c.createFile(o,t.id)}})}),k=A(async()=>{var _;if(!c||t.data.isDirectory)return;let[o,j]=_t(t.data.name),P=`${o}_copy${j}`;try{let N=await r({path:t.data.path}),O=((_=t.parent)==null?void 0:_.data.path)||"";await s({path:O,type:"file",name:P,contents:N.contents?btoa(N.contents):void 0}),await c.refreshAll([O])}catch{W({title:"Failed to duplicate file",description:"Unable to create a duplicate of the file",variant:"danger"})}}),b=()=>{let o={size:14,strokeWidth:1.5,className:"mr-2"};return(0,a.jsxs)(jt,{align:"end",className:"print:hidden w-[220px]",onClick:j=>j.stopPropagation(),onCloseAutoFocus:j=>j.preventDefault(),children:[!t.data.isDirectory&&(0,a.jsxs)(S,{onSelect:()=>t.select(),children:[(0,a.jsx)(Yt,{...o}),"Open file"]}),!t.data.isDirectory&&!re()&&(0,a.jsxs)(S,{onSelect:()=>{n({path:t.data.path})},children:[(0,a.jsx)(pe,{...o}),"Open file in external editor"]}),t.data.isDirectory&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(S,{onSelect:()=>D(),children:[(0,a.jsx)(Ce,{...o}),"Create file"]}),(0,a.jsxs)(S,{onSelect:()=>x(),children:[(0,a.jsx)(Pe,{...o}),"Create folder"]}),(0,a.jsx)(K,{})]}),(0,a.jsxs)(S,{onSelect:()=>t.edit(),children:[(0,a.jsx)(Kt,{...o}),"Rename"]}),!t.data.isDirectory&&(0,a.jsxs)(S,{onSelect:k,children:[(0,a.jsx)(we,{...o}),"Duplicate"]}),(0,a.jsxs)(S,{onSelect:async()=>{await ne(t.data.path),W({title:"Copied to clipboard"})},children:[(0,a.jsx)(_e,{...o}),"Copy path"]}),c&&(0,a.jsxs)(S,{onSelect:async()=>{await ne(c.relativeFromRoot(t.data.path)),W({title:"Copied to clipboard"})},children:[(0,a.jsx)(_e,{...o}),"Copy relative path"]}),(0,a.jsx)(K,{}),(0,a.jsxs)(S,{onSelect:()=>{let{path:j}=t.data;g(Fe[f](j))},children:[(0,a.jsx)(ct,{...o}),"Insert snippet for reading file"]}),(0,a.jsxs)(S,{onSelect:async()=>{W({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:j}=t.data;await ne(Fe[f](j))},children:[(0,a.jsx)(Ge,{...o}),"Copy snippet for reading file"]}),t.data.isMarimoFile&&!re()&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(K,{}),(0,a.jsxs)(S,{onSelect:y,children:[(0,a.jsx)(Jt,{...o}),"Open notebook"]})]}),(0,a.jsx)(K,{}),!t.data.isDirectory&&!d&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(S,{onSelect:async()=>{let j=(await r({path:t.data.path})).contents||"";be(new Blob([j]),t.data.name)},children:[(0,a.jsx)(ke,{...o}),"Download"]}),(0,a.jsx)(K,{})]}),(0,a.jsxs)(S,{onSelect:C,variant:"danger",children:[(0,a.jsx)(St,{...o}),"Delete"]})]})};return(0,a.jsxs)("div",{style:e,ref:i,className:he("flex items-center cursor-pointer ml-1 text-muted-foreground whitespace-nowrap group"),draggable:!0,onClick:o=>{o.stopPropagation(),t.data.isDirectory&&t.toggle()},children:[(0,a.jsx)(ya,{node:t}),(0,a.jsxs)("span",{className:he("flex items-center pl-1 py-1 cursor-pointer hover:bg-accent/50 hover:text-accent-foreground rounded-l flex-1 overflow-hidden group",t.willReceiveDrop&&t.data.isDirectory&&"bg-accent/80 hover:bg-accent/80 text-accent-foreground"),children:[t.data.isMarimoFile?(0,a.jsx)("img",{src:Ut,className:"w-5 h-5 shrink-0 mr-2 filter grayscale",alt:"Marimo"}):(0,a.jsx)(h,{className:"w-5 h-5 shrink-0 mr-2",strokeWidth:1.5}),t.isEditing?(0,a.jsx)(ja,{node:t}):(0,a.jsx)(ua,{node:t,onOpenMarimoFile:y}),(0,a.jsxs)(gt,{modal:!1,children:[(0,a.jsx)(ut,{asChild:!0,tabIndex:-1,onClick:o=>o.stopPropagation(),children:(0,a.jsx)(I,{"data-testid":"file-explorer-more-button",variant:"text",tabIndex:-1,size:"xs",className:"mb-0","aria-label":"More options",children:(0,a.jsx)(yt,{strokeWidth:2,className:"w-5 h-5 hidden group-hover:block"})})}),b()]})]})]})},ya=t=>{let e=(0,Y.c)(3),{node:i}=t;if(!i.data.isDirectory){let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)("span",{className:"w-5 h-5 shrink-0"}),e[0]=s):s=e[0],s}let n;return e[1]===i.isOpen?n=e[2]:(n=i.isOpen?(0,a.jsx)(mt,{className:"w-5 h-5 shrink-0"}):(0,a.jsx)(ft,{className:"w-5 h-5 shrink-0"}),e[1]=i.isOpen,e[2]=n),n};function Ie(t,e){t.stopPropagation(),t.preventDefault(),Lt(e)}function Ee(t,e){if(e)return t;let i=[];for(let n of t){if(va(n.name))continue;let s=n;if(n.children){let r=Ee(n.children,e);r!==n.children&&(s={...n,children:r})}i.push(s)}return i}function va(t){return!!t.startsWith(".")}function ba(){return null}function wa(t){let{parentNode:e}=t;return!e.data.isDirectory}function ka(t){return t.stopPropagation()}var Fa=ie(),Ca=()=>{let t=(0,Fa.c)(20),{ref:e,height:i}=Vt(),n=i===void 0?1:i,s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s={noClick:!0,noKeyboard:!0},t[0]=s):s=t[0];let{getRootProps:r,getInputProps:d,isDragActive:f}=Ae(s),h;t[1]===r?h=t[2]:(h=r(),t[1]=r,t[2]=h);let m;t[3]===Symbol.for("react.memo_cache_sentinel")?(m=he("flex flex-col flex-1 overflow-hidden relative"),t[3]=m):m=t[3];let l;t[4]===d?l=t[5]:(l=d(),t[4]=d,t[5]=l);let u;t[6]===l?u=t[7]:(u=(0,a.jsx)("input",{...l}),t[6]=l,t[7]=u);let v;t[8]===f?v=t[9]:(v=f&&(0,a.jsx)("div",{className:"absolute inset-0 flex items-center uppercase justify-center text-xl font-bold text-primary/90 bg-accent/85 z-10 border-2 border-dashed border-primary/90 rounded-lg pointer-events-none",children:"Drop files here"}),t[8]=f,t[9]=v);let g;t[10]===n?g=t[11]:(g=(0,a.jsx)(pa,{height:n}),t[10]=n,t[11]=g);let c;t[12]!==e||t[13]!==g?(c=(0,a.jsx)("div",{ref:e,className:"flex flex-col flex-1 overflow-hidden",children:g}),t[12]=e,t[13]=g,t[14]=c):c=t[14];let y;return t[15]!==h||t[16]!==u||t[17]!==v||t[18]!==c?(y=(0,a.jsx)(Xt,{children:(0,a.jsxs)("div",{...h,className:m,children:[u,v,c]})}),t[15]=h,t[16]=u,t[17]=v,t[18]=c,t[19]=y):y=t[19],y};export{Ca as default};
@@ -1,4 +1,4 @@
1
- import{s as K}from"./chunk-LvLJmgfZ.js";import{d as xe,l as ee}from"./useEvent-BhXAndur.js";import{t as ge}from"./react-Bj1aDYRI.js";import{Bn as te,Hn as ye,Jr as re,St as je,Wn as be,Xn as ve,Zn as we,mn as ae,ui as ke}from"./cells-DbD2lYze.js";import"./react-dom-CSu739Rf.js";import{t as oe}from"./compiler-runtime-B3qBwwSJ.js";import{a as Ne,f as _e}from"./hotkeys-BHHWjLlp.js";import{n as A}from"./constants-B6Cb__3x.js";import{t as Se}from"./ErrorBoundary-B9Ifj8Jf.js";import{t as ze}from"./jsx-runtime-ZmTK25f3.js";import{t as E}from"./button-CZ3Cs4qb.js";import{t as Ce}from"./cn-BKtXLv3a.js";import"./dist-DBwNzi3C.js";import"./cjs-CH5Rj0g8.js";import"./main-U5Goe76G.js";import"./useNonce-CS26E0hA.js";import{r as U}from"./requests-B4FYHTZl.js";import{t as W}from"./createLucideIcon-BCdY6lG5.js";import{t as Me}from"./chart-no-axes-column-qvVRjhv1.js";import{r as Ie}from"./x-ZP5cObgf.js";import{t as De}from"./chevron-right--18M_6o9.js";import{f as Y,p as Pe,r as Oe,t as se}from"./maps-D2_Mq1pZ.js";import{t as Te}from"./circle-play-EowqxNIC.js";import{a as Re,p as Ae,r as We,t as Fe}from"./dropdown-menu-BUgFWmX1.js";import{r as Le,t as He}from"./types-7nV0hgXj.js";import{t as $e}from"./file-Ch78NKWp.js";import{i as Ee,n as Ue,r as Ve,t as Be}from"./youtube--tNPNRy6.js";import{t as Je}from"./link-DxicfMbs.js";import{t as q}from"./spinner-DA8-7wQv.js";import{n as Ye,r as qe,t as Ge}from"./app-config-button-CrXbU4T9.js";import{t as Qe}from"./refresh-ccw-DN_xCV6A.js";import{lt as Xe,r as Ze}from"./input-DHHmNa19.js";import"./dist-Cayq-K1c.js";import"./dist-TiFCI16_.js";import"./dist-BIKFl48f.js";import"./dist-B0VqT_4z.js";import"./dist-BYyu59D8.js";import{t as Ke}from"./use-toast-T0_cQDma.js";import{n as ie}from"./paths-Dfii2bN8.js";import{c as le,n as et,o as tt,t as rt}from"./session-fBtIbMpB.js";import"./Combination-izwufzWe.js";import{t as at}from"./tooltip-C_WgOOcZ.js";import{i as ot}from"./dates-CT5PUuFo.js";import{o as st}from"./alert-dialog-Ctz24SMn.js";import{t as it}from"./context-Ga_vV5mE.js";import"./popover-B-131r4d.js";import{n as lt}from"./ImperativeModal-DZr52ffu.js";import{r as nt}from"./errors-CPlNr33a.js";import{t as ct}from"./tree-B8r7cwRm.js";import{t as ne}from"./error-banner-Dlrzo_Ay.js";import{n as G,t as mt}from"./useAsyncData-BMGLSTg8.js";import{t as dt}from"./label-C9wP7Kp2.js";import{t as Q}from"./icons-DjR3qLG_.js";import{t as ht}from"./links-DgZx-VxW.js";import"./Inputs-CbenuziM.js";import{t as pt}from"./useInterval-BNfubus2.js";var ft=W("book-open",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]),ut=W("book-text",[["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:"M8 11h8",key:"vwpz6n"}],["path",{d:"M8 7h6",key:"1f0q6e"}]]),xt=W("graduation-cap",[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]]),gt=W("orbit",[["path",{d:"M20.341 6.484A10 10 0 0 1 10.266 21.85",key:"1enhxb"}],["path",{d:"M3.659 17.516A10 10 0 0 1 13.74 2.152",key:"1crzgf"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["circle",{cx:"19",cy:"5",r:"2",key:"mhkx31"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}]]),yt=W("panels-top-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]]),T=K(ge(),1),X=oe(),a=K(ze(),1),jt={intro:["Introduction",ft,"Get started with marimo basics"],dataflow:["Dataflow",we,"Learn how cells interact with each other"],ui:["UI Elements",yt,"Create interactive UI components"],markdown:["Markdown",te,"Format text with parameterized markdown"],plots:["Plots",Me,"Create interactive visualizations"],sql:["SQL",ye,"Query databases directly in marimo"],layout:["Layout",Ve,"Customize the layout of your cells' output"],fileformat:["File format",$e,"Understand marimo's pure-Python file format"],"for-jupyter-users":["For Jupyter users",gt,"Transiting from Jupyter to marimo"],"markdown-format":["Markdown format",Q,"Using marimo to edit markdown files"]};const bt=()=>{let e=(0,X.c)(6),{openTutorial:t}=U(),r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)(xt,{className:"w-4 h-4 mr-2"}),e[0]=r):r=e[0];let s;e[1]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(Ae,{asChild:!0,children:(0,a.jsxs)(E,{"data-testid":"open-tutorial-button",size:"xs",variant:"outline",children:[r,"Tutorials",(0,a.jsx)(Oe,{className:"w-3 h-3 ml-1"})]})}),e[1]=s):s=e[1];let o;e[2]===t?o=e[3]:(o=Ne.entries(jt).map(i=>{let[m,d]=i,[c,h,p]=d;return(0,a.jsxs)(Re,{onSelect:async()=>{let n=await t({tutorialId:m});n&&ht(n.path)},children:[(0,a.jsx)(h,{strokeWidth:1.5,className:"w-4 h-4 mr-3 self-start mt-1.5 text-muted-foreground"}),(0,a.jsx)("div",{className:"flex items-center",children:(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsx)("span",{children:c}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground pr-1",children:p})]})})]},m)}),e[2]=t,e[3]=o);let l;return e[4]===o?l=e[5]:(l=(0,a.jsxs)(Fe,{children:[s,(0,a.jsx)(We,{side:"bottom",align:"end",className:"print:hidden",children:o})]}),e[4]=o,e[5]=l),l};var vt=[{title:"Documentation",description:"Official marimo documentation and API reference",icon:ve,url:A.docsPage},{title:"GitHub",description:"View source code, report issues, or contribute",icon:Ee,url:A.githubPage},{title:"Community",description:"Join the marimo Discord community",icon:Ue,url:A.discordLink},{title:"YouTube",description:"Watch tutorials and demos",icon:Be,url:A.youtube},{title:"Changelog",description:"See what's new in marimo",icon:te,url:A.releasesPage}];const wt=()=>{let e=(0,X.c)(2),t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,a.jsx)(V,{Icon:Je,children:"Resources"}),e[0]=t):t=e[0];let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[t,(0,a.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:vt.map(kt)})]}),e[1]=r):r=e[1],r},V=e=>{let t=(0,X.c)(8),{Icon:r,control:s,children:o}=e,l;t[0]===r?l=t[1]:(l=(0,a.jsx)(r,{className:"h-5 w-5"}),t[0]=r,t[1]=l);let i;t[2]!==o||t[3]!==l?(i=(0,a.jsxs)("h2",{className:"flex items-center gap-2 text-xl font-semibold text-muted-foreground select-none",children:[l,o]}),t[2]=o,t[3]=l,t[4]=i):i=t[4];let m;return t[5]!==s||t[6]!==i?(m=(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[i,s]}),t[5]=s,t[6]=i,t[7]=m):m=t[7],m};function kt(e){return(0,a.jsxs)("a",{href:e.url,target:"_blank",className:"flex items-start gap-3 py-3 px-3 rounded-lg border hover:bg-accent/20 transition-colors shadow-xs",children:[(0,a.jsx)(e.icon,{className:"w-5 h-5 mt-1.5 text-primary"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"font-medium",children:e.title}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:e.description})]})]},e.title)}const ce=T.createContext({runningNotebooks:new Map,setRunningNotebooks:_e.NOOP}),me=T.createContext(""),Nt=re("marimo:home:include-markdown",!1,ae,{getOnInit:!0}),de=re("marimo:home:expanded-folders",{},ae,{getOnInit:!0});var P=oe();function he(e){return`${rt()}-${encodeURIComponent(e)}`}var _t=()=>{let e=(0,P.c)(56),[t,r]=(0,T.useState)(0),{getRecentFiles:s,getRunningNotebooks:o}=U(),l;e[0]===s?l=e[1]:(l=()=>s(),e[0]=s,e[1]=l);let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=[],e[2]=i):i=e[2];let m=G(l,i),d,c;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{r(Tt)},c={delayMs:1e4,whenVisible:!0},e[3]=d,e[4]=c):(d=e[3],c=e[4]),pt(d,c);let h;e[5]===o?h=e[6]:(h=async()=>{let R=await o();return se.keyBy(R.files,Rt)},e[5]=o,e[6]=h);let p;e[7]===t?p=e[8]:(p=[t],e[7]=t,e[8]=p);let n=G(h,p),f,x,u,g,w,y,b,v,k,N,_,z,S;if(e[9]!==m||e[10]!==n){k=Symbol.for("react.early_return_sentinel");e:{let R=mt(m,n);if(R.error)throw R.error;let Z=R.data;if(!Z){let $;e[24]===Symbol.for("react.memo_cache_sentinel")?($=(0,a.jsx)(q,{centered:!0,size:"xlarge"}),e[24]=$):$=e[24],k=$;break e}let[ue,B]=Z;g=ue,u=T.Suspense,x=ce,b={runningNotebooks:B,setRunningNotebooks:n.setData};let L,H;e[25]===Symbol.for("react.memo_cache_sentinel")?(L=(0,a.jsx)(bt,{}),H=(0,a.jsx)(Ge,{showAppConfig:!1}),e[25]=L,e[26]=H):(L=e[25],H=e[26]);let J=`This will shutdown the notebook server and terminate all running notebooks (${B.size}). You'll lose all data that's in memory.`;e[27]===J?v=e[28]:(v=(0,a.jsxs)("div",{className:"absolute top-3 right-5 flex gap-3 z-50",children:[L,H,(0,a.jsx)(Ye,{description:J})]}),e[27]=J,e[28]=v),z="flex flex-col gap-6 max-w-6xl container pt-5 pb-20 z-10",e[29]===Symbol.for("react.memo_cache_sentinel")?(S=(0,a.jsx)("img",{src:"logo.png",alt:"marimo logo",className:"w-48 mb-2"}),w=(0,a.jsx)(Pt,{}),y=(0,a.jsx)(wt,{}),e[29]=w,e[30]=y,e[31]=S):(w=e[29],y=e[30],S=e[31]),f=pe,e[32]===Symbol.for("react.memo_cache_sentinel")?(N=(0,a.jsx)(V,{Icon:Te,children:"Running notebooks"}),e[32]=N):N=e[32],_=[...B.values()]}e[9]=m,e[10]=n,e[11]=f,e[12]=x,e[13]=u,e[14]=g,e[15]=w,e[16]=y,e[17]=b,e[18]=v,e[19]=k,e[20]=N,e[21]=_,e[22]=z,e[23]=S}else f=e[11],x=e[12],u=e[13],g=e[14],w=e[15],y=e[16],b=e[17],v=e[18],k=e[19],N=e[20],_=e[21],z=e[22],S=e[23];if(k!==Symbol.for("react.early_return_sentinel"))return k;let C;e[33]!==f||e[34]!==N||e[35]!==_?(C=(0,a.jsx)(f,{header:N,files:_}),e[33]=f,e[34]=N,e[35]=_,e[36]=C):C=e[36];let I;e[37]===Symbol.for("react.memo_cache_sentinel")?(I=(0,a.jsx)(V,{Icon:be,children:"Recent notebooks"}),e[37]=I):I=e[37];let M;e[38]===g.files?M=e[39]:(M=(0,a.jsx)(pe,{header:I,files:g.files}),e[38]=g.files,e[39]=M);let O;e[40]===Symbol.for("react.memo_cache_sentinel")?(O=(0,a.jsx)(Se,{children:(0,a.jsx)(St,{})}),e[40]=O):O=e[40];let j;e[41]!==w||e[42]!==y||e[43]!==C||e[44]!==M||e[45]!==z||e[46]!==S?(j=(0,a.jsxs)("div",{className:z,children:[S,w,y,C,M,O]}),e[41]=w,e[42]=y,e[43]=C,e[44]=M,e[45]=z,e[46]=S,e[47]=j):j=e[47];let D;e[48]!==x||e[49]!==b||e[50]!==v||e[51]!==j?(D=(0,a.jsxs)(x,{value:b,children:[v,j]}),e[48]=x,e[49]=b,e[50]=v,e[51]=j,e[52]=D):D=e[52];let F;return e[53]!==u||e[54]!==D?(F=(0,a.jsx)(u,{children:D}),e[53]=u,e[54]=D,e[55]=F):F=e[55],F},St=()=>{let e=(0,P.c)(48),{getWorkspaceFiles:t}=U(),[r,s]=ee(Nt),[o,l]=(0,T.useState)(""),i;e[0]!==t||e[1]!==r?(i=()=>t({includeMarkdown:r}),e[0]=t,e[1]=r,e[2]=i):i=e[2];let m;e[3]===r?m=e[4]:(m=[r],e[3]=r,e[4]=m);let{isPending:d,data:c,error:h,isFetching:p,refetch:n}=G(i,m);if(d){let j;return e[5]===Symbol.for("react.memo_cache_sentinel")?(j=(0,a.jsx)(q,{centered:!0,size:"xlarge",className:"mt-6"}),e[5]=j):j=e[5],j}if(h){let j;e[6]===h?j=e[7]:(j=nt(h),e[6]=h,e[7]=j);let D;return e[8]===j?D=e[9]:(D=(0,a.jsx)(ne,{kind:"danger",className:"rounded p-4",children:j}),e[8]=j,e[9]=D),D}let f;e[10]!==c.fileCount||e[11]!==c.hasMore?(f=c.hasMore&&(0,a.jsxs)(ne,{kind:"warn",className:"rounded p-4",children:["Showing first ",c.fileCount," files. Your workspace has more files."]}),e[10]=c.fileCount,e[11]=c.hasMore,e[12]=f):f=e[12];let x,u;e[13]===Symbol.for("react.memo_cache_sentinel")?(x=(0,a.jsx)(Xe,{size:13}),u=j=>l(j.target.value),e[13]=x,e[14]=u):(x=e[13],u=e[14]);let g;e[15]===o?g=e[16]:(g=(0,a.jsx)(Ze,{id:"search",value:o,icon:x,onChange:u,placeholder:"Search",className:"mb-0 border-border"}),e[15]=o,e[16]=g);let w;e[17]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsx)(zt,{}),e[17]=w):w=e[17];let y;e[18]===s?y=e[19]:(y=j=>s(!!j),e[18]=s,e[19]=y);let b;e[20]!==r||e[21]!==y?(b=(0,a.jsx)(je,{"data-testid":"include-markdown-checkbox",id:"include-markdown",checked:r,onCheckedChange:y}),e[20]=r,e[21]=y,e[22]=b):b=e[22];let v;e[23]===Symbol.for("react.memo_cache_sentinel")?(v=(0,a.jsx)(dt,{htmlFor:"include-markdown",children:"Include markdown"}),e[23]=v):v=e[23];let k;e[24]!==g||e[25]!==b?(k=(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[g,w,b,v]}),e[24]=g,e[25]=b,e[26]=k):k=e[26];let N;e[27]===n?N=e[28]:(N=()=>n(),e[27]=n,e[28]=N);let _;e[29]===Symbol.for("react.memo_cache_sentinel")?(_=(0,a.jsx)(Qe,{className:"w-4 h-4"}),e[29]=_):_=e[29];let z;e[30]===N?z=e[31]:(z=(0,a.jsx)(E,{variant:"text",size:"icon",className:"w-4 h-4 ml-1 p-0 opacity-70 hover:opacity-100",onClick:N,"aria-label":"Refresh workspace",children:_}),e[30]=N,e[31]=z);let S;e[32]===p?S=e[33]:(S=p&&(0,a.jsx)(q,{size:"small"}),e[32]=p,e[33]=S);let C;e[34]!==k||e[35]!==z||e[36]!==S?(C=(0,a.jsxs)(V,{Icon:ut,control:k,children:["Workspace",z,S]}),e[34]=k,e[35]=z,e[36]=S,e[37]=C):C=e[37];let I;e[38]!==o||e[39]!==c.files?(I=(0,a.jsx)("div",{className:"flex flex-col divide-y divide-(--slate-3) border rounded overflow-hidden max-h-192 overflow-y-auto shadow-sm bg-background",children:(0,a.jsx)(Ct,{searchText:o,files:c.files})}),e[38]=o,e[39]=c.files,e[40]=I):I=e[40];let M;e[41]!==C||e[42]!==I||e[43]!==f?(M=(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[f,C,I]}),e[41]=C,e[42]=I,e[43]=f,e[44]=M):M=e[44];let O;return e[45]!==M||e[46]!==c.root?(O=(0,a.jsx)(me,{value:c.root,children:M}),e[45]=M,e[46]=c.root,e[47]=O):O=e[47],O},zt=()=>{let e=(0,P.c)(5),t=xe(de),r;e[0]===t?r=e[1]:(r=()=>{t({})},e[0]=t,e[1]=r);let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(Pe,{className:"w-4 h-4 mr-1"}),e[2]=s):s=e[2];let o;return e[3]===r?o=e[4]:(o=(0,a.jsxs)(E,{variant:"text",size:"sm",className:"h-fit hidden sm:flex",onClick:r,children:[s,"Collapse all"]}),e[3]=r,e[4]=o),o},Ct=e=>{let t=(0,P.c)(12),{files:r,searchText:s}=e,[o,l]=ee(de),i=Object.keys(o).length===0,m=(0,T.useRef)(void 0),d,c;if(t[0]===i?(d=t[1],c=t[2]):(d=()=>{var n;i&&((n=m.current)==null||n.closeAll())},c=[i],t[0]=i,t[1]=d,t[2]=c),(0,T.useEffect)(d,c),r.length===0){let n;return t[3]===Symbol.for("react.memo_cache_sentinel")?(n=(0,a.jsx)("div",{className:"flex flex-col px-5 py-10 items-center justify-center",children:(0,a.jsx)("p",{className:"text-center text-muted-foreground",children:"No files in this workspace"})}),t[3]=n):n=t[3],n}let h;t[4]!==o||t[5]!==l?(h=async n=>{let f=o[n]??!1;l({...o,[n]:!f})},t[4]=o,t[5]=l,t[6]=h):h=t[6];let p;return t[7]!==r||t[8]!==o||t[9]!==s||t[10]!==h?(p=(0,a.jsx)(ct,{ref:m,width:"100%",height:500,searchTerm:s,className:"h-full",idAccessor:At,data:r,openByDefault:!1,initialOpenState:o,onToggle:h,padding:5,rowHeight:35,indent:15,overscanCount:1e3,renderCursor:Wt,disableDrop:!0,disableDrag:!0,disableEdit:!0,disableMultiSelection:!0,children:Mt}),t[7]=r,t[8]=o,t[9]=s,t[10]=h,t[11]=p):p=t[11],p},Mt=e=>{let t=(0,P.c)(19),{node:r,style:s}=e,o=He[r.data.isDirectory?"directory":Le(r.data.name)],l;t[0]===o?l=t[1]:(l=(0,a.jsx)(o,{className:"w-5 h-5 shrink-0",strokeWidth:1.5}),t[0]=o,t[1]=l);let i=l,m=(0,T.use)(me),d;t[2]!==i||t[3]!==r.data.isDirectory||t[4]!==r.data.name||t[5]!==r.data.path||t[6]!==m?(d=()=>{if(r.data.isDirectory)return(0,a.jsxs)("span",{className:"flex items-center pl-1 cursor-pointer hover:bg-accent/50 hover:text-accent-foreground rounded-l flex-1 overflow-hidden h-full pr-3 gap-2",children:[i,r.data.name]});let u=r.data.path.startsWith(m)&&ie.isAbsolute(r.data.path)?ie.rest(r.data.path,m):r.data.path,g=u.endsWith(".md")||u.endsWith(".qmd");return(0,a.jsxs)("a",{className:"flex items-center pl-1 cursor-pointer hover:bg-accent/50 hover:text-accent-foreground rounded-l flex-1 overflow-hidden h-full pr-3 gap-2",href:le(`?file=${u}`).toString(),target:he(u),children:[i,(0,a.jsxs)("span",{className:"flex-1 overflow-hidden text-ellipsis",children:[r.data.name,g&&(0,a.jsx)(Q,{className:"ml-2 inline opacity-80"})]}),(0,a.jsx)(fe,{filePath:u}),(0,a.jsx)(Y,{size:20,className:"group-hover:opacity-100 opacity-0 text-primary"})]})},t[2]=i,t[3]=r.data.isDirectory,t[4]=r.data.name,t[5]=r.data.path,t[6]=m,t[7]=d):d=t[7];let c=d,h;t[8]===Symbol.for("react.memo_cache_sentinel")?(h=Ce("flex items-center cursor-pointer ml-1 text-muted-foreground whitespace-nowrap group h-full"),t[8]=h):h=t[8];let p,n;t[9]===r?(p=t[10],n=t[11]):(p=u=>{u.stopPropagation(),r.data.isDirectory&&r.toggle()},n=(0,a.jsx)(It,{node:r}),t[9]=r,t[10]=p,t[11]=n);let f;t[12]===c?f=t[13]:(f=c(),t[12]=c,t[13]=f);let x;return t[14]!==s||t[15]!==p||t[16]!==n||t[17]!==f?(x=(0,a.jsxs)("div",{style:s,className:h,onClick:p,children:[n,f]}),t[14]=s,t[15]=p,t[16]=n,t[17]=f,t[18]=x):x=t[18],x},It=e=>{let t=(0,P.c)(3),{node:r}=e;if(!r.data.isDirectory){let o;return t[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,a.jsx)("span",{className:"w-5 h-5 shrink-0"}),t[0]=o):o=t[0],o}let s;return t[1]===r.isOpen?s=t[2]:(s=r.isOpen?(0,a.jsx)(Ie,{className:"w-5 h-5 shrink-0"}):(0,a.jsx)(De,{className:"w-5 h-5 shrink-0"}),t[1]=r.isOpen,t[2]=s),s},pe=e=>{let t=(0,P.c)(7),{header:r,files:s}=e;if(s.length===0)return null;let o;t[0]===s?o=t[1]:(o=s.map(Ft),t[0]=s,t[1]=o);let l;t[2]===o?l=t[3]:(l=(0,a.jsx)("div",{className:"flex flex-col divide-y divide-(--slate-3) border rounded overflow-hidden max-h-192 overflow-y-auto shadow-sm bg-background",children:o}),t[2]=o,t[3]=l);let i;return t[4]!==r||t[5]!==l?(i=(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[r,l]}),t[4]=r,t[5]=l,t[6]=i):i=t[6],i},Dt=e=>{let t=(0,P.c)(41),{file:r}=e,{locale:s}=it(),o;t[0]===r.path?o=t[1]:(o=et(r.path),t[0]=r.path,t[1]=o);let l=o,i,m,d,c;if(t[2]!==r.initializationId||t[3]!==r.path||t[4]!==l){let N=le(l?`?file=${r.initializationId}&session_id=${r.path}`:`?file=${r.path}`),_;t[9]===r.path?_=t[10]:(_=r.path.endsWith(".md"),t[9]=r.path,t[10]=_),i=_,m="py-1.5 px-4 hover:bg-(--blue-2) hover:text-primary transition-all duration-300 cursor-pointer group relative flex gap-4 items-center",d=r.path,c=N.toString(),t[2]=r.initializationId,t[3]=r.path,t[4]=l,t[5]=i,t[6]=m,t[7]=d,t[8]=c}else i=t[5],m=t[6],d=t[7],c=t[8];let h=r.initializationId||r.path,p;t[11]===h?p=t[12]:(p=he(h),t[11]=h,t[12]=p);let n;t[13]===i?n=t[14]:(n=i&&(0,a.jsx)("span",{className:"opacity-80",children:(0,a.jsx)(Q,{})}),t[13]=i,t[14]=n);let f;t[15]!==r.name||t[16]!==n?(f=(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[r.name,n]}),t[15]=r.name,t[16]=n,t[17]=f):f=t[17];let x;t[18]===r.path?x=t[19]:(x=(0,a.jsx)("p",{title:r.path,className:"text-sm text-muted-foreground overflow-hidden whitespace-nowrap text-ellipsis",children:r.path}),t[18]=r.path,t[19]=x);let u;t[20]!==f||t[21]!==x?(u=(0,a.jsxs)("div",{className:"flex flex-col justify-between flex-1",children:[f,x]}),t[20]=f,t[21]=x,t[22]=u):u=t[22];let g;t[23]===r.path?g=t[24]:(g=(0,a.jsx)("div",{children:(0,a.jsx)(fe,{filePath:r.path})}),t[23]=r.path,t[24]=g);let w;t[25]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsx)(Y,{size:20,className:"group-hover:opacity-100 opacity-0 transition-all duration-300 text-primary"}),t[25]=w):w=t[25];let y;t[26]===g?y=t[27]:(y=(0,a.jsxs)("div",{className:"flex gap-3 items-center",children:[g,w]}),t[26]=g,t[27]=y);let b;t[28]!==r.lastModified||t[29]!==s?(b=!!r.lastModified&&(0,a.jsx)("div",{className:"text-xs text-muted-foreground opacity-80",children:ot(r.lastModified*1e3,s)}),t[28]=r.lastModified,t[29]=s,t[30]=b):b=t[30];let v;t[31]!==y||t[32]!==b?(v=(0,a.jsxs)("div",{className:"flex flex-col gap-1 items-end",children:[y,b]}),t[31]=y,t[32]=b,t[33]=v):v=t[33];let k;return t[34]!==u||t[35]!==v||t[36]!==m||t[37]!==d||t[38]!==c||t[39]!==p?(k=(0,a.jsxs)("a",{className:m,href:c,target:p,children:[u,v]},d),t[34]=u,t[35]=v,t[36]=m,t[37]=d,t[38]=c,t[39]=p,t[40]=k):k=t[40],k},fe=e=>{let t=(0,P.c)(10),{filePath:r}=e,{openConfirm:s,closeModal:o}=lt(),{shutdownSession:l}=U(),{runningNotebooks:i,setRunningNotebooks:m}=(0,T.use)(ce);if(!i.has(r))return null;let d;t[0]!==o||t[1]!==r||t[2]!==s||t[3]!==i||t[4]!==m||t[5]!==l?(d=p=>{p.stopPropagation(),p.preventDefault(),s({title:"Shutdown",description:"This will terminate the Python kernel. You'll lose all data that's in memory.",variant:"destructive",confirmAction:(0,a.jsx)(st,{onClick:()=>{let n=i.get(r);ke(n==null?void 0:n.sessionId),l({sessionId:n.sessionId}).then(f=>{m(se.keyBy(f.files,Lt))}),o(),Ke({description:"Notebook has been shutdown."})},"aria-label":"Confirm Shutdown",children:"Shutdown"})})},t[0]=o,t[1]=r,t[2]=s,t[3]=i,t[4]=m,t[5]=l,t[6]=d):d=t[6];let c;t[7]===Symbol.for("react.memo_cache_sentinel")?(c=(0,a.jsx)(qe,{size:14}),t[7]=c):c=t[7];let h;return t[8]===d?h=t[9]:(h=(0,a.jsx)(at,{content:"Shutdown",children:(0,a.jsx)(E,{size:"icon",variant:"outline",className:"opacity-80 hover:opacity-100 hover:bg-accent text-destructive border-destructive hover:border-destructive hover:text-destructive bg-background hover:bg-(--red-1)",onClick:d,children:c})}),t[8]=d,t[9]=h),h},Pt=()=>{let e=(0,P.c)(3),t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=tt(),e[0]=t):t=e[0];let r=t,s;e[1]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Create a new notebook"}),e[1]=s):s=e[1];let o;return e[2]===Symbol.for("react.memo_cache_sentinel")?(o=(0,a.jsxs)("a",{className:`relative rounded-lg p-6 group
1
+ import{s as K}from"./chunk-LvLJmgfZ.js";import{d as xe,l as ee}from"./useEvent-BhXAndur.js";import{t as ge}from"./react-Bj1aDYRI.js";import{Bn as te,Hn as ye,Jr as re,St as je,Wn as be,Xn as ve,Zn as we,mn as ae,ui as ke}from"./cells-DbD2lYze.js";import"./react-dom-CSu739Rf.js";import{t as oe}from"./compiler-runtime-B3qBwwSJ.js";import{a as Ne,f as _e}from"./hotkeys-BHHWjLlp.js";import{n as A}from"./constants-B6Cb__3x.js";import{t as Se}from"./ErrorBoundary-B9Ifj8Jf.js";import{t as ze}from"./jsx-runtime-ZmTK25f3.js";import{t as E}from"./button-CZ3Cs4qb.js";import{t as Ce}from"./cn-BKtXLv3a.js";import"./dist-DBwNzi3C.js";import"./cjs-CH5Rj0g8.js";import"./main-U5Goe76G.js";import"./useNonce-CS26E0hA.js";import{r as U}from"./requests-B4FYHTZl.js";import{t as W}from"./createLucideIcon-BCdY6lG5.js";import{t as Me}from"./chart-no-axes-column-qvVRjhv1.js";import{r as Ie}from"./x-ZP5cObgf.js";import{t as De}from"./chevron-right--18M_6o9.js";import{f as Y,p as Pe,r as Oe,t as se}from"./maps-D2_Mq1pZ.js";import{t as Te}from"./circle-play-EowqxNIC.js";import{a as Re,p as Ae,r as We,t as Fe}from"./dropdown-menu-BUgFWmX1.js";import{r as Le,t as He}from"./types-7nV0hgXj.js";import{t as $e}from"./file-Ch78NKWp.js";import{i as Ee,n as Ue,r as Ve,t as Be}from"./youtube--tNPNRy6.js";import{t as Je}from"./link-DxicfMbs.js";import{t as q}from"./spinner-DA8-7wQv.js";import{n as Ye,r as qe,t as Ge}from"./app-config-button-BGuwQV5R.js";import{t as Qe}from"./refresh-ccw-DN_xCV6A.js";import{lt as Xe,r as Ze}from"./input-DHHmNa19.js";import"./dist-Cayq-K1c.js";import"./dist-TiFCI16_.js";import"./dist-BIKFl48f.js";import"./dist-B0VqT_4z.js";import"./dist-BYyu59D8.js";import{t as Ke}from"./use-toast-T0_cQDma.js";import{n as ie}from"./paths-Dfii2bN8.js";import{c as le,n as et,o as tt,t as rt}from"./session-fBtIbMpB.js";import"./Combination-izwufzWe.js";import{t as at}from"./tooltip-C_WgOOcZ.js";import{i as ot}from"./dates-CT5PUuFo.js";import{o as st}from"./alert-dialog-Ctz24SMn.js";import{t as it}from"./context-Ga_vV5mE.js";import"./popover-B-131r4d.js";import{n as lt}from"./ImperativeModal-DZr52ffu.js";import{r as nt}from"./errors-CPlNr33a.js";import{t as ct}from"./tree-B8r7cwRm.js";import{t as ne}from"./error-banner-Dlrzo_Ay.js";import{n as G,t as mt}from"./useAsyncData-BMGLSTg8.js";import{t as dt}from"./label-C9wP7Kp2.js";import{t as Q}from"./icons-DjR3qLG_.js";import{t as ht}from"./links-DgZx-VxW.js";import"./Inputs-CbenuziM.js";import{t as pt}from"./useInterval-BNfubus2.js";var ft=W("book-open",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]),ut=W("book-text",[["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:"M8 11h8",key:"vwpz6n"}],["path",{d:"M8 7h6",key:"1f0q6e"}]]),xt=W("graduation-cap",[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]]),gt=W("orbit",[["path",{d:"M20.341 6.484A10 10 0 0 1 10.266 21.85",key:"1enhxb"}],["path",{d:"M3.659 17.516A10 10 0 0 1 13.74 2.152",key:"1crzgf"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["circle",{cx:"19",cy:"5",r:"2",key:"mhkx31"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}]]),yt=W("panels-top-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]]),T=K(ge(),1),X=oe(),a=K(ze(),1),jt={intro:["Introduction",ft,"Get started with marimo basics"],dataflow:["Dataflow",we,"Learn how cells interact with each other"],ui:["UI Elements",yt,"Create interactive UI components"],markdown:["Markdown",te,"Format text with parameterized markdown"],plots:["Plots",Me,"Create interactive visualizations"],sql:["SQL",ye,"Query databases directly in marimo"],layout:["Layout",Ve,"Customize the layout of your cells' output"],fileformat:["File format",$e,"Understand marimo's pure-Python file format"],"for-jupyter-users":["For Jupyter users",gt,"Transiting from Jupyter to marimo"],"markdown-format":["Markdown format",Q,"Using marimo to edit markdown files"]};const bt=()=>{let e=(0,X.c)(6),{openTutorial:t}=U(),r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)(xt,{className:"w-4 h-4 mr-2"}),e[0]=r):r=e[0];let s;e[1]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(Ae,{asChild:!0,children:(0,a.jsxs)(E,{"data-testid":"open-tutorial-button",size:"xs",variant:"outline",children:[r,"Tutorials",(0,a.jsx)(Oe,{className:"w-3 h-3 ml-1"})]})}),e[1]=s):s=e[1];let o;e[2]===t?o=e[3]:(o=Ne.entries(jt).map(i=>{let[m,d]=i,[c,h,p]=d;return(0,a.jsxs)(Re,{onSelect:async()=>{let n=await t({tutorialId:m});n&&ht(n.path)},children:[(0,a.jsx)(h,{strokeWidth:1.5,className:"w-4 h-4 mr-3 self-start mt-1.5 text-muted-foreground"}),(0,a.jsx)("div",{className:"flex items-center",children:(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsx)("span",{children:c}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground pr-1",children:p})]})})]},m)}),e[2]=t,e[3]=o);let l;return e[4]===o?l=e[5]:(l=(0,a.jsxs)(Fe,{children:[s,(0,a.jsx)(We,{side:"bottom",align:"end",className:"print:hidden",children:o})]}),e[4]=o,e[5]=l),l};var vt=[{title:"Documentation",description:"Official marimo documentation and API reference",icon:ve,url:A.docsPage},{title:"GitHub",description:"View source code, report issues, or contribute",icon:Ee,url:A.githubPage},{title:"Community",description:"Join the marimo Discord community",icon:Ue,url:A.discordLink},{title:"YouTube",description:"Watch tutorials and demos",icon:Be,url:A.youtube},{title:"Changelog",description:"See what's new in marimo",icon:te,url:A.releasesPage}];const wt=()=>{let e=(0,X.c)(2),t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,a.jsx)(V,{Icon:Je,children:"Resources"}),e[0]=t):t=e[0];let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[t,(0,a.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:vt.map(kt)})]}),e[1]=r):r=e[1],r},V=e=>{let t=(0,X.c)(8),{Icon:r,control:s,children:o}=e,l;t[0]===r?l=t[1]:(l=(0,a.jsx)(r,{className:"h-5 w-5"}),t[0]=r,t[1]=l);let i;t[2]!==o||t[3]!==l?(i=(0,a.jsxs)("h2",{className:"flex items-center gap-2 text-xl font-semibold text-muted-foreground select-none",children:[l,o]}),t[2]=o,t[3]=l,t[4]=i):i=t[4];let m;return t[5]!==s||t[6]!==i?(m=(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[i,s]}),t[5]=s,t[6]=i,t[7]=m):m=t[7],m};function kt(e){return(0,a.jsxs)("a",{href:e.url,target:"_blank",className:"flex items-start gap-3 py-3 px-3 rounded-lg border hover:bg-accent/20 transition-colors shadow-xs",children:[(0,a.jsx)(e.icon,{className:"w-5 h-5 mt-1.5 text-primary"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"font-medium",children:e.title}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:e.description})]})]},e.title)}const ce=T.createContext({runningNotebooks:new Map,setRunningNotebooks:_e.NOOP}),me=T.createContext(""),Nt=re("marimo:home:include-markdown",!1,ae,{getOnInit:!0}),de=re("marimo:home:expanded-folders",{},ae,{getOnInit:!0});var P=oe();function he(e){return`${rt()}-${encodeURIComponent(e)}`}var _t=()=>{let e=(0,P.c)(56),[t,r]=(0,T.useState)(0),{getRecentFiles:s,getRunningNotebooks:o}=U(),l;e[0]===s?l=e[1]:(l=()=>s(),e[0]=s,e[1]=l);let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=[],e[2]=i):i=e[2];let m=G(l,i),d,c;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{r(Tt)},c={delayMs:1e4,whenVisible:!0},e[3]=d,e[4]=c):(d=e[3],c=e[4]),pt(d,c);let h;e[5]===o?h=e[6]:(h=async()=>{let R=await o();return se.keyBy(R.files,Rt)},e[5]=o,e[6]=h);let p;e[7]===t?p=e[8]:(p=[t],e[7]=t,e[8]=p);let n=G(h,p),f,x,u,g,w,y,b,v,k,N,_,z,S;if(e[9]!==m||e[10]!==n){k=Symbol.for("react.early_return_sentinel");e:{let R=mt(m,n);if(R.error)throw R.error;let Z=R.data;if(!Z){let $;e[24]===Symbol.for("react.memo_cache_sentinel")?($=(0,a.jsx)(q,{centered:!0,size:"xlarge"}),e[24]=$):$=e[24],k=$;break e}let[ue,B]=Z;g=ue,u=T.Suspense,x=ce,b={runningNotebooks:B,setRunningNotebooks:n.setData};let L,H;e[25]===Symbol.for("react.memo_cache_sentinel")?(L=(0,a.jsx)(bt,{}),H=(0,a.jsx)(Ge,{showAppConfig:!1}),e[25]=L,e[26]=H):(L=e[25],H=e[26]);let J=`This will shutdown the notebook server and terminate all running notebooks (${B.size}). You'll lose all data that's in memory.`;e[27]===J?v=e[28]:(v=(0,a.jsxs)("div",{className:"absolute top-3 right-5 flex gap-3 z-50",children:[L,H,(0,a.jsx)(Ye,{description:J})]}),e[27]=J,e[28]=v),z="flex flex-col gap-6 max-w-6xl container pt-5 pb-20 z-10",e[29]===Symbol.for("react.memo_cache_sentinel")?(S=(0,a.jsx)("img",{src:"logo.png",alt:"marimo logo",className:"w-48 mb-2"}),w=(0,a.jsx)(Pt,{}),y=(0,a.jsx)(wt,{}),e[29]=w,e[30]=y,e[31]=S):(w=e[29],y=e[30],S=e[31]),f=pe,e[32]===Symbol.for("react.memo_cache_sentinel")?(N=(0,a.jsx)(V,{Icon:Te,children:"Running notebooks"}),e[32]=N):N=e[32],_=[...B.values()]}e[9]=m,e[10]=n,e[11]=f,e[12]=x,e[13]=u,e[14]=g,e[15]=w,e[16]=y,e[17]=b,e[18]=v,e[19]=k,e[20]=N,e[21]=_,e[22]=z,e[23]=S}else f=e[11],x=e[12],u=e[13],g=e[14],w=e[15],y=e[16],b=e[17],v=e[18],k=e[19],N=e[20],_=e[21],z=e[22],S=e[23];if(k!==Symbol.for("react.early_return_sentinel"))return k;let C;e[33]!==f||e[34]!==N||e[35]!==_?(C=(0,a.jsx)(f,{header:N,files:_}),e[33]=f,e[34]=N,e[35]=_,e[36]=C):C=e[36];let I;e[37]===Symbol.for("react.memo_cache_sentinel")?(I=(0,a.jsx)(V,{Icon:be,children:"Recent notebooks"}),e[37]=I):I=e[37];let M;e[38]===g.files?M=e[39]:(M=(0,a.jsx)(pe,{header:I,files:g.files}),e[38]=g.files,e[39]=M);let O;e[40]===Symbol.for("react.memo_cache_sentinel")?(O=(0,a.jsx)(Se,{children:(0,a.jsx)(St,{})}),e[40]=O):O=e[40];let j;e[41]!==w||e[42]!==y||e[43]!==C||e[44]!==M||e[45]!==z||e[46]!==S?(j=(0,a.jsxs)("div",{className:z,children:[S,w,y,C,M,O]}),e[41]=w,e[42]=y,e[43]=C,e[44]=M,e[45]=z,e[46]=S,e[47]=j):j=e[47];let D;e[48]!==x||e[49]!==b||e[50]!==v||e[51]!==j?(D=(0,a.jsxs)(x,{value:b,children:[v,j]}),e[48]=x,e[49]=b,e[50]=v,e[51]=j,e[52]=D):D=e[52];let F;return e[53]!==u||e[54]!==D?(F=(0,a.jsx)(u,{children:D}),e[53]=u,e[54]=D,e[55]=F):F=e[55],F},St=()=>{let e=(0,P.c)(48),{getWorkspaceFiles:t}=U(),[r,s]=ee(Nt),[o,l]=(0,T.useState)(""),i;e[0]!==t||e[1]!==r?(i=()=>t({includeMarkdown:r}),e[0]=t,e[1]=r,e[2]=i):i=e[2];let m;e[3]===r?m=e[4]:(m=[r],e[3]=r,e[4]=m);let{isPending:d,data:c,error:h,isFetching:p,refetch:n}=G(i,m);if(d){let j;return e[5]===Symbol.for("react.memo_cache_sentinel")?(j=(0,a.jsx)(q,{centered:!0,size:"xlarge",className:"mt-6"}),e[5]=j):j=e[5],j}if(h){let j;e[6]===h?j=e[7]:(j=nt(h),e[6]=h,e[7]=j);let D;return e[8]===j?D=e[9]:(D=(0,a.jsx)(ne,{kind:"danger",className:"rounded p-4",children:j}),e[8]=j,e[9]=D),D}let f;e[10]!==c.fileCount||e[11]!==c.hasMore?(f=c.hasMore&&(0,a.jsxs)(ne,{kind:"warn",className:"rounded p-4",children:["Showing first ",c.fileCount," files. Your workspace has more files."]}),e[10]=c.fileCount,e[11]=c.hasMore,e[12]=f):f=e[12];let x,u;e[13]===Symbol.for("react.memo_cache_sentinel")?(x=(0,a.jsx)(Xe,{size:13}),u=j=>l(j.target.value),e[13]=x,e[14]=u):(x=e[13],u=e[14]);let g;e[15]===o?g=e[16]:(g=(0,a.jsx)(Ze,{id:"search",value:o,icon:x,onChange:u,placeholder:"Search",className:"mb-0 border-border"}),e[15]=o,e[16]=g);let w;e[17]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsx)(zt,{}),e[17]=w):w=e[17];let y;e[18]===s?y=e[19]:(y=j=>s(!!j),e[18]=s,e[19]=y);let b;e[20]!==r||e[21]!==y?(b=(0,a.jsx)(je,{"data-testid":"include-markdown-checkbox",id:"include-markdown",checked:r,onCheckedChange:y}),e[20]=r,e[21]=y,e[22]=b):b=e[22];let v;e[23]===Symbol.for("react.memo_cache_sentinel")?(v=(0,a.jsx)(dt,{htmlFor:"include-markdown",children:"Include markdown"}),e[23]=v):v=e[23];let k;e[24]!==g||e[25]!==b?(k=(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[g,w,b,v]}),e[24]=g,e[25]=b,e[26]=k):k=e[26];let N;e[27]===n?N=e[28]:(N=()=>n(),e[27]=n,e[28]=N);let _;e[29]===Symbol.for("react.memo_cache_sentinel")?(_=(0,a.jsx)(Qe,{className:"w-4 h-4"}),e[29]=_):_=e[29];let z;e[30]===N?z=e[31]:(z=(0,a.jsx)(E,{variant:"text",size:"icon",className:"w-4 h-4 ml-1 p-0 opacity-70 hover:opacity-100",onClick:N,"aria-label":"Refresh workspace",children:_}),e[30]=N,e[31]=z);let S;e[32]===p?S=e[33]:(S=p&&(0,a.jsx)(q,{size:"small"}),e[32]=p,e[33]=S);let C;e[34]!==k||e[35]!==z||e[36]!==S?(C=(0,a.jsxs)(V,{Icon:ut,control:k,children:["Workspace",z,S]}),e[34]=k,e[35]=z,e[36]=S,e[37]=C):C=e[37];let I;e[38]!==o||e[39]!==c.files?(I=(0,a.jsx)("div",{className:"flex flex-col divide-y divide-(--slate-3) border rounded overflow-hidden max-h-192 overflow-y-auto shadow-sm bg-background",children:(0,a.jsx)(Ct,{searchText:o,files:c.files})}),e[38]=o,e[39]=c.files,e[40]=I):I=e[40];let M;e[41]!==C||e[42]!==I||e[43]!==f?(M=(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[f,C,I]}),e[41]=C,e[42]=I,e[43]=f,e[44]=M):M=e[44];let O;return e[45]!==M||e[46]!==c.root?(O=(0,a.jsx)(me,{value:c.root,children:M}),e[45]=M,e[46]=c.root,e[47]=O):O=e[47],O},zt=()=>{let e=(0,P.c)(5),t=xe(de),r;e[0]===t?r=e[1]:(r=()=>{t({})},e[0]=t,e[1]=r);let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(Pe,{className:"w-4 h-4 mr-1"}),e[2]=s):s=e[2];let o;return e[3]===r?o=e[4]:(o=(0,a.jsxs)(E,{variant:"text",size:"sm",className:"h-fit hidden sm:flex",onClick:r,children:[s,"Collapse all"]}),e[3]=r,e[4]=o),o},Ct=e=>{let t=(0,P.c)(12),{files:r,searchText:s}=e,[o,l]=ee(de),i=Object.keys(o).length===0,m=(0,T.useRef)(void 0),d,c;if(t[0]===i?(d=t[1],c=t[2]):(d=()=>{var n;i&&((n=m.current)==null||n.closeAll())},c=[i],t[0]=i,t[1]=d,t[2]=c),(0,T.useEffect)(d,c),r.length===0){let n;return t[3]===Symbol.for("react.memo_cache_sentinel")?(n=(0,a.jsx)("div",{className:"flex flex-col px-5 py-10 items-center justify-center",children:(0,a.jsx)("p",{className:"text-center text-muted-foreground",children:"No files in this workspace"})}),t[3]=n):n=t[3],n}let h;t[4]!==o||t[5]!==l?(h=async n=>{let f=o[n]??!1;l({...o,[n]:!f})},t[4]=o,t[5]=l,t[6]=h):h=t[6];let p;return t[7]!==r||t[8]!==o||t[9]!==s||t[10]!==h?(p=(0,a.jsx)(ct,{ref:m,width:"100%",height:500,searchTerm:s,className:"h-full",idAccessor:At,data:r,openByDefault:!1,initialOpenState:o,onToggle:h,padding:5,rowHeight:35,indent:15,overscanCount:1e3,renderCursor:Wt,disableDrop:!0,disableDrag:!0,disableEdit:!0,disableMultiSelection:!0,children:Mt}),t[7]=r,t[8]=o,t[9]=s,t[10]=h,t[11]=p):p=t[11],p},Mt=e=>{let t=(0,P.c)(19),{node:r,style:s}=e,o=He[r.data.isDirectory?"directory":Le(r.data.name)],l;t[0]===o?l=t[1]:(l=(0,a.jsx)(o,{className:"w-5 h-5 shrink-0",strokeWidth:1.5}),t[0]=o,t[1]=l);let i=l,m=(0,T.use)(me),d;t[2]!==i||t[3]!==r.data.isDirectory||t[4]!==r.data.name||t[5]!==r.data.path||t[6]!==m?(d=()=>{if(r.data.isDirectory)return(0,a.jsxs)("span",{className:"flex items-center pl-1 cursor-pointer hover:bg-accent/50 hover:text-accent-foreground rounded-l flex-1 overflow-hidden h-full pr-3 gap-2",children:[i,r.data.name]});let u=r.data.path.startsWith(m)&&ie.isAbsolute(r.data.path)?ie.rest(r.data.path,m):r.data.path,g=u.endsWith(".md")||u.endsWith(".qmd");return(0,a.jsxs)("a",{className:"flex items-center pl-1 cursor-pointer hover:bg-accent/50 hover:text-accent-foreground rounded-l flex-1 overflow-hidden h-full pr-3 gap-2",href:le(`?file=${u}`).toString(),target:he(u),children:[i,(0,a.jsxs)("span",{className:"flex-1 overflow-hidden text-ellipsis",children:[r.data.name,g&&(0,a.jsx)(Q,{className:"ml-2 inline opacity-80"})]}),(0,a.jsx)(fe,{filePath:u}),(0,a.jsx)(Y,{size:20,className:"group-hover:opacity-100 opacity-0 text-primary"})]})},t[2]=i,t[3]=r.data.isDirectory,t[4]=r.data.name,t[5]=r.data.path,t[6]=m,t[7]=d):d=t[7];let c=d,h;t[8]===Symbol.for("react.memo_cache_sentinel")?(h=Ce("flex items-center cursor-pointer ml-1 text-muted-foreground whitespace-nowrap group h-full"),t[8]=h):h=t[8];let p,n;t[9]===r?(p=t[10],n=t[11]):(p=u=>{u.stopPropagation(),r.data.isDirectory&&r.toggle()},n=(0,a.jsx)(It,{node:r}),t[9]=r,t[10]=p,t[11]=n);let f;t[12]===c?f=t[13]:(f=c(),t[12]=c,t[13]=f);let x;return t[14]!==s||t[15]!==p||t[16]!==n||t[17]!==f?(x=(0,a.jsxs)("div",{style:s,className:h,onClick:p,children:[n,f]}),t[14]=s,t[15]=p,t[16]=n,t[17]=f,t[18]=x):x=t[18],x},It=e=>{let t=(0,P.c)(3),{node:r}=e;if(!r.data.isDirectory){let o;return t[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,a.jsx)("span",{className:"w-5 h-5 shrink-0"}),t[0]=o):o=t[0],o}let s;return t[1]===r.isOpen?s=t[2]:(s=r.isOpen?(0,a.jsx)(Ie,{className:"w-5 h-5 shrink-0"}):(0,a.jsx)(De,{className:"w-5 h-5 shrink-0"}),t[1]=r.isOpen,t[2]=s),s},pe=e=>{let t=(0,P.c)(7),{header:r,files:s}=e;if(s.length===0)return null;let o;t[0]===s?o=t[1]:(o=s.map(Ft),t[0]=s,t[1]=o);let l;t[2]===o?l=t[3]:(l=(0,a.jsx)("div",{className:"flex flex-col divide-y divide-(--slate-3) border rounded overflow-hidden max-h-192 overflow-y-auto shadow-sm bg-background",children:o}),t[2]=o,t[3]=l);let i;return t[4]!==r||t[5]!==l?(i=(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[r,l]}),t[4]=r,t[5]=l,t[6]=i):i=t[6],i},Dt=e=>{let t=(0,P.c)(41),{file:r}=e,{locale:s}=it(),o;t[0]===r.path?o=t[1]:(o=et(r.path),t[0]=r.path,t[1]=o);let l=o,i,m,d,c;if(t[2]!==r.initializationId||t[3]!==r.path||t[4]!==l){let N=le(l?`?file=${r.initializationId}&session_id=${r.path}`:`?file=${r.path}`),_;t[9]===r.path?_=t[10]:(_=r.path.endsWith(".md"),t[9]=r.path,t[10]=_),i=_,m="py-1.5 px-4 hover:bg-(--blue-2) hover:text-primary transition-all duration-300 cursor-pointer group relative flex gap-4 items-center",d=r.path,c=N.toString(),t[2]=r.initializationId,t[3]=r.path,t[4]=l,t[5]=i,t[6]=m,t[7]=d,t[8]=c}else i=t[5],m=t[6],d=t[7],c=t[8];let h=r.initializationId||r.path,p;t[11]===h?p=t[12]:(p=he(h),t[11]=h,t[12]=p);let n;t[13]===i?n=t[14]:(n=i&&(0,a.jsx)("span",{className:"opacity-80",children:(0,a.jsx)(Q,{})}),t[13]=i,t[14]=n);let f;t[15]!==r.name||t[16]!==n?(f=(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[r.name,n]}),t[15]=r.name,t[16]=n,t[17]=f):f=t[17];let x;t[18]===r.path?x=t[19]:(x=(0,a.jsx)("p",{title:r.path,className:"text-sm text-muted-foreground overflow-hidden whitespace-nowrap text-ellipsis",children:r.path}),t[18]=r.path,t[19]=x);let u;t[20]!==f||t[21]!==x?(u=(0,a.jsxs)("div",{className:"flex flex-col justify-between flex-1",children:[f,x]}),t[20]=f,t[21]=x,t[22]=u):u=t[22];let g;t[23]===r.path?g=t[24]:(g=(0,a.jsx)("div",{children:(0,a.jsx)(fe,{filePath:r.path})}),t[23]=r.path,t[24]=g);let w;t[25]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsx)(Y,{size:20,className:"group-hover:opacity-100 opacity-0 transition-all duration-300 text-primary"}),t[25]=w):w=t[25];let y;t[26]===g?y=t[27]:(y=(0,a.jsxs)("div",{className:"flex gap-3 items-center",children:[g,w]}),t[26]=g,t[27]=y);let b;t[28]!==r.lastModified||t[29]!==s?(b=!!r.lastModified&&(0,a.jsx)("div",{className:"text-xs text-muted-foreground opacity-80",children:ot(r.lastModified*1e3,s)}),t[28]=r.lastModified,t[29]=s,t[30]=b):b=t[30];let v;t[31]!==y||t[32]!==b?(v=(0,a.jsxs)("div",{className:"flex flex-col gap-1 items-end",children:[y,b]}),t[31]=y,t[32]=b,t[33]=v):v=t[33];let k;return t[34]!==u||t[35]!==v||t[36]!==m||t[37]!==d||t[38]!==c||t[39]!==p?(k=(0,a.jsxs)("a",{className:m,href:c,target:p,children:[u,v]},d),t[34]=u,t[35]=v,t[36]=m,t[37]=d,t[38]=c,t[39]=p,t[40]=k):k=t[40],k},fe=e=>{let t=(0,P.c)(10),{filePath:r}=e,{openConfirm:s,closeModal:o}=lt(),{shutdownSession:l}=U(),{runningNotebooks:i,setRunningNotebooks:m}=(0,T.use)(ce);if(!i.has(r))return null;let d;t[0]!==o||t[1]!==r||t[2]!==s||t[3]!==i||t[4]!==m||t[5]!==l?(d=p=>{p.stopPropagation(),p.preventDefault(),s({title:"Shutdown",description:"This will terminate the Python kernel. You'll lose all data that's in memory.",variant:"destructive",confirmAction:(0,a.jsx)(st,{onClick:()=>{let n=i.get(r);ke(n==null?void 0:n.sessionId),l({sessionId:n.sessionId}).then(f=>{m(se.keyBy(f.files,Lt))}),o(),Ke({description:"Notebook has been shutdown."})},"aria-label":"Confirm Shutdown",children:"Shutdown"})})},t[0]=o,t[1]=r,t[2]=s,t[3]=i,t[4]=m,t[5]=l,t[6]=d):d=t[6];let c;t[7]===Symbol.for("react.memo_cache_sentinel")?(c=(0,a.jsx)(qe,{size:14}),t[7]=c):c=t[7];let h;return t[8]===d?h=t[9]:(h=(0,a.jsx)(at,{content:"Shutdown",children:(0,a.jsx)(E,{size:"icon",variant:"outline",className:"opacity-80 hover:opacity-100 hover:bg-accent text-destructive border-destructive hover:border-destructive hover:text-destructive bg-background hover:bg-(--red-1)",onClick:d,children:c})}),t[8]=d,t[9]=h),h},Pt=()=>{let e=(0,P.c)(3),t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=tt(),e[0]=t):t=e[0];let r=t,s;e[1]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Create a new notebook"}),e[1]=s):s=e[1];let o;return e[2]===Symbol.for("react.memo_cache_sentinel")?(o=(0,a.jsxs)("a",{className:`relative rounded-lg p-6 group
2
2
  text-primary hover:bg-(--blue-2) shadow-md-solid shadow-accent border bg-(--blue-1)
3
3
  transition-all duration-300 cursor-pointer
4
4
  `,href:r,target:"_blank",rel:"noreferrer",children:[s,(0,a.jsx)("div",{className:"group-hover:opacity-100 opacity-0 absolute right-5 top-0 bottom-0 rounded-lg flex items-center justify-center transition-all duration-300",children:(0,a.jsx)(Y,{size:24})})]}),e[2]=o):o=e[2],o},Ot=_t;function Tt(e){return e+1}function Rt(e){return e.path}function At(e){return e.path}function Wt(){return null}function Ft(e){return(0,a.jsx)(Dt,{file:e},e.path)}function Lt(e){return e.path}export{Ot as default};
@@ -1 +1 @@
1
- var O=Object.defineProperty;var V=(t,e,i)=>e in t?O(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var b=(t,e,i)=>V(t,typeof e!="symbol"?e+"":e,i);import{u as I}from"./useEvent-BhXAndur.js";import{o as j}from"./cells-DbD2lYze.js";import{t as T}from"./compiler-runtime-B3qBwwSJ.js";import{a as k,d as E}from"./hotkeys-BHHWjLlp.js";import{i as N}from"./utils-YqBXNpsM.js";import{h as P,x as _}from"./config-D2-Bw6QC.js";import{r as z}from"./requests-B4FYHTZl.js";import{f as D}from"./layout-DFhAD73H.js";import{s as $,u as B}from"./download-CmdFQXRz.js";import{t as H}from"./Deferred-CrO5-0RA.js";import{t as L}from"./use-toast-T0_cQDma.js";import{t as x}from"./useInterval-BNfubus2.js";var R=class{constructor(){b(this,"capturedInputs",new Map);b(this,"inFlight",new Map)}cancelEntry(t){t.controller.abort(),t.deferred.status==="pending"&&t.deferred.resolve(void 0)}needsCapture(t,e){if(this.capturedInputs.get(t)===e)return!1;let i=this.inFlight.get(t);return!(i&&i.inputValue===e)}waitForInFlight(t,e){let i=this.inFlight.get(t);return i&&i.inputValue===e?i.deferred.promise:null}startCapture(t,e){let i=this.inFlight.get(t);i&&this.cancelEntry(i);let n=new AbortController,l=new H,u={controller:n,inputValue:e,deferred:l};return this.inFlight.set(t,u),{signal:n.signal,markCaptured:p=>{this.inFlight.get(t)===u&&(l.resolve(p),this.capturedInputs.set(t,e),this.inFlight.delete(t))},markFailed:()=>{this.inFlight.get(t)===u&&(l.resolve(void 0),this.inFlight.delete(t))}}}prune(t){for(let e of this.capturedInputs.keys())t.has(e)||this.capturedInputs.delete(e);for(let[e,i]of this.inFlight)t.has(e)||(this.cancelEntry(i),this.inFlight.delete(e))}get isCapturing(){return this.inFlight.size>0}abort(){for(let t of this.inFlight.values())this.cancelEntry(t);this.inFlight.clear()}reset(){this.abort(),this.capturedInputs.clear()}},Y=T(),M=5e3;function q(){let t=(0,Y.c)(14),e=I(N),{state:i}=I(P),n=e.auto_download.includes("markdown"),l=e.auto_download.includes("html"),u=e.auto_download.includes("ipynb"),p=i===_.OPEN,m=!n||!p,d=!l||!p,h=!u||!p,{autoExportAsHTML:a,autoExportAsIPYNB:s,autoExportAsMarkdown:r,updateCellOutputs:o}=z(),c=S(),f;t[0]===r?f=t[1]:(f=async()=>{await r({download:!1})},t[0]=r,t[1]=f);let g;t[2]===m?g=t[3]:(g={delayMs:M,whenVisible:!0,disabled:m},t[2]=m,t[3]=g),x(f,g);let w;t[4]===a?w=t[5]:(w=async()=>{await a({download:!1,includeCode:!0,files:D.INSTANCE.filenames()})},t[4]=a,t[5]=w);let v;t[6]===d?v=t[7]:(v={delayMs:M,whenVisible:!0,disabled:d},t[6]=d,t[7]=v),x(w,v);let F;t[8]!==s||t[9]!==c||t[10]!==o?(F=async()=>{await A({takeScreenshots:()=>c({progress:B.indeterminate()}),updateCellOutputs:o}),await s({download:!1})},t[8]=s,t[9]=c,t[10]=o,t[11]=F):F=t[11];let y;t[12]===h?y=t[13]:(y={delayMs:M,whenVisible:!0,disabled:h,skipIfRunning:!0},t[12]=h,t[13]=y),x(F,y)}var G=new Set(["text/html","application/vnd.vegalite.v5+json","application/vnd.vega.v5+json","application/vnd.vegalite.v6+json","application/vnd.vega.v6+json"]);const C=new R;function S(){let t=I(j);return async e=>{var d,h;let{progress:i}=e,n=new Set(k.keys(t));C.prune(n);let l=[],u=[];for(let[a,s]of k.entries(t)){let r=(d=s.output)==null?void 0:d.data;if((h=s.output)!=null&&h.mimetype&&G.has(s.output.mimetype)&&r)if(C.needsCapture(a,r))l.push([a,r]);else{let o=C.waitForInFlight(a,r);o&&u.push({cellId:a,promise:o})}}if(l.length===0&&u.length===0)return{};l.length>0&&i.addTotal(l.length);let p={};for(let[a,s]of l){let r=C.startCapture(a,s);try{let o=await $(a);if(r.signal.aborted)continue;if(!o){E.error(`Failed to capture screenshot for cell ${a}`),r.markFailed();continue}let c=["image/png",o];p[a]=c,r.markCaptured(c)}catch(o){E.error(`Error screenshotting cell ${a}:`,o),r.markFailed()}finally{i.increment(1)}}let m=await Promise.allSettled(u.map(({promise:a})=>a));for(let[a,{cellId:s}]of u.entries()){let r=m[a];r.status==="fulfilled"&&r.value&&(p[s]=r.value)}return p}}async function A(t){let{takeScreenshots:e,updateCellOutputs:i}=t;try{let n=await e();k.size(n)>0&&await i({cellIdsToOutput:n})}catch(n){E.error("Error updating cell outputs with screenshots:",n),L({title:"Failed to capture cell outputs",description:"Some outputs may not appear in the PDF. Continuing with export.",variant:"danger"})}}export{q as n,S as r,A as t};
1
+ var O=Object.defineProperty;var V=(t,e,i)=>e in t?O(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var b=(t,e,i)=>V(t,typeof e!="symbol"?e+"":e,i);import{u as I}from"./useEvent-BhXAndur.js";import{o as j}from"./cells-DbD2lYze.js";import{t as T}from"./compiler-runtime-B3qBwwSJ.js";import{a as k,d as E}from"./hotkeys-BHHWjLlp.js";import{i as N}from"./utils-YqBXNpsM.js";import{h as P,x as _}from"./config-D2-Bw6QC.js";import{r as z}from"./requests-B4FYHTZl.js";import{f as D}from"./layout-D7NLGhPa.js";import{s as $,u as B}from"./download-CmdFQXRz.js";import{t as H}from"./Deferred-CrO5-0RA.js";import{t as L}from"./use-toast-T0_cQDma.js";import{t as x}from"./useInterval-BNfubus2.js";var R=class{constructor(){b(this,"capturedInputs",new Map);b(this,"inFlight",new Map)}cancelEntry(t){t.controller.abort(),t.deferred.status==="pending"&&t.deferred.resolve(void 0)}needsCapture(t,e){if(this.capturedInputs.get(t)===e)return!1;let i=this.inFlight.get(t);return!(i&&i.inputValue===e)}waitForInFlight(t,e){let i=this.inFlight.get(t);return i&&i.inputValue===e?i.deferred.promise:null}startCapture(t,e){let i=this.inFlight.get(t);i&&this.cancelEntry(i);let n=new AbortController,l=new H,u={controller:n,inputValue:e,deferred:l};return this.inFlight.set(t,u),{signal:n.signal,markCaptured:p=>{this.inFlight.get(t)===u&&(l.resolve(p),this.capturedInputs.set(t,e),this.inFlight.delete(t))},markFailed:()=>{this.inFlight.get(t)===u&&(l.resolve(void 0),this.inFlight.delete(t))}}}prune(t){for(let e of this.capturedInputs.keys())t.has(e)||this.capturedInputs.delete(e);for(let[e,i]of this.inFlight)t.has(e)||(this.cancelEntry(i),this.inFlight.delete(e))}get isCapturing(){return this.inFlight.size>0}abort(){for(let t of this.inFlight.values())this.cancelEntry(t);this.inFlight.clear()}reset(){this.abort(),this.capturedInputs.clear()}},Y=T(),M=5e3;function q(){let t=(0,Y.c)(14),e=I(N),{state:i}=I(P),n=e.auto_download.includes("markdown"),l=e.auto_download.includes("html"),u=e.auto_download.includes("ipynb"),p=i===_.OPEN,m=!n||!p,d=!l||!p,h=!u||!p,{autoExportAsHTML:a,autoExportAsIPYNB:s,autoExportAsMarkdown:r,updateCellOutputs:o}=z(),c=S(),f;t[0]===r?f=t[1]:(f=async()=>{await r({download:!1})},t[0]=r,t[1]=f);let g;t[2]===m?g=t[3]:(g={delayMs:M,whenVisible:!0,disabled:m},t[2]=m,t[3]=g),x(f,g);let w;t[4]===a?w=t[5]:(w=async()=>{await a({download:!1,includeCode:!0,files:D.INSTANCE.filenames()})},t[4]=a,t[5]=w);let v;t[6]===d?v=t[7]:(v={delayMs:M,whenVisible:!0,disabled:d},t[6]=d,t[7]=v),x(w,v);let F;t[8]!==s||t[9]!==c||t[10]!==o?(F=async()=>{await A({takeScreenshots:()=>c({progress:B.indeterminate()}),updateCellOutputs:o}),await s({download:!1})},t[8]=s,t[9]=c,t[10]=o,t[11]=F):F=t[11];let y;t[12]===h?y=t[13]:(y={delayMs:M,whenVisible:!0,disabled:h,skipIfRunning:!0},t[12]=h,t[13]=y),x(F,y)}var G=new Set(["text/html","application/vnd.vegalite.v5+json","application/vnd.vega.v5+json","application/vnd.vegalite.v6+json","application/vnd.vega.v6+json"]);const C=new R;function S(){let t=I(j);return async e=>{var d,h;let{progress:i}=e,n=new Set(k.keys(t));C.prune(n);let l=[],u=[];for(let[a,s]of k.entries(t)){let r=(d=s.output)==null?void 0:d.data;if((h=s.output)!=null&&h.mimetype&&G.has(s.output.mimetype)&&r)if(C.needsCapture(a,r))l.push([a,r]);else{let o=C.waitForInFlight(a,r);o&&u.push({cellId:a,promise:o})}}if(l.length===0&&u.length===0)return{};l.length>0&&i.addTotal(l.length);let p={};for(let[a,s]of l){let r=C.startCapture(a,s);try{let o=await $(a);if(r.signal.aborted)continue;if(!o){E.error(`Failed to capture screenshot for cell ${a}`),r.markFailed();continue}let c=["image/png",o];p[a]=c,r.markCaptured(c)}catch(o){E.error(`Error screenshotting cell ${a}:`,o),r.markFailed()}finally{i.increment(1)}}let m=await Promise.allSettled(u.map(({promise:a})=>a));for(let[a,{cellId:s}]of u.entries()){let r=m[a];r.status==="fulfilled"&&r.value&&(p[s]=r.value)}return p}}async function A(t){let{takeScreenshots:e,updateCellOutputs:i}=t;try{let n=await e();k.size(n)>0&&await i({cellIdsToOutput:n})}catch(n){E.error("Error updating cell outputs with screenshots:",n),L({title:"Failed to capture cell outputs",description:"Some outputs may not appear in the PDF. Continuing with export.",variant:"danger"})}}export{q as n,S as r,A as t};