@marimo-team/frontend 0.19.10-dev35 → 0.19.10-dev39

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 (28) hide show
  1. package/dist/assets/JsonOutput-CZpjHc50.js +46 -0
  2. package/dist/assets/{agent-panel-DrhcPPKF.js → agent-panel-vT94Mpn2.js} +1 -1
  3. package/dist/assets/{cell-editor-B-wR_JRR.js → cell-editor-8s2G7FD2.js} +1 -1
  4. package/dist/assets/{column-preview-DFroYRmp.js → column-preview-CPvYaDNg.js} +1 -1
  5. package/dist/assets/{command-palette-Dt2DT2AT.js → command-palette-CENytI3Y.js} +1 -1
  6. package/dist/assets/{edit-page-D8-gDPT2.js → edit-page-Cxg7v5-V.js} +3 -3
  7. package/dist/assets/{file-explorer-panel-CAtnXwC4.js → file-explorer-panel-Bu9K_P9d.js} +1 -1
  8. package/dist/assets/{hooks-DW6SBMlZ.js → hooks-DSgfibiE.js} +1 -1
  9. package/dist/assets/{index-855KJEhm.js → index-B43TGwHL.js} +17 -17
  10. package/dist/assets/{layout-Bv1HRnh6.js → layout-C91DpyBS.js} +1 -1
  11. package/dist/assets/{panels-DGXXeSZl.js → panels-Dx4knZNw.js} +1 -1
  12. package/dist/assets/{run-page-CTcZo7xh.js → run-page-CMS44SX5.js} +1 -1
  13. package/dist/assets/{scratchpad-panel-2TxCLFo3.js → scratchpad-panel-vqg3jZ3X.js} +1 -1
  14. package/dist/assets/{session-panel-WAp0J0nc.js → session-panel-pkllmhqQ.js} +1 -1
  15. package/dist/assets/{useNotebookActions-CztwRVhn.js → useNotebookActions-BiCGf528.js} +1 -1
  16. package/dist/assets/utilities.esm-CqG5UDNh.js +3 -0
  17. package/dist/index.html +4 -4
  18. package/package.json +1 -1
  19. package/src/components/data-table/TableActions.tsx +8 -1
  20. package/src/components/data-table/data-table.tsx +2 -0
  21. package/src/components/data-table/download-actions.tsx +6 -1
  22. package/src/core/wasm/__tests__/store.test.ts +33 -0
  23. package/src/core/wasm/bridge.ts +2 -1
  24. package/src/core/wasm/store.ts +13 -1
  25. package/src/plugins/impl/DataTablePlugin.tsx +4 -0
  26. package/src/plugins/impl/data-frames/DataFramePlugin.tsx +4 -0
  27. package/dist/assets/JsonOutput-BYZnEjkl.js +0 -46
  28. package/dist/assets/utilities.esm-CwjMWc5G.js +0 -3
@@ -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{Xr as Ve,Yn as Le,gn as Ue,qr as Ke,w as Ye}from"./cells-DG7rjkOQ.js";import"./react-dom-CSu739Rf.js";import{t as ie}from"./compiler-runtime-B3qBwwSJ.js";import"./tooltip-DxKBXCGp.js";import{d as Ge,f as Xe}from"./hotkeys-BHHWjLlp.js";import{t as Ze}from"./invariant-CAG_dYON.js";import{p as Je,u as ve}from"./utils-YqBXNpsM.js";import{S as re}from"./config-Q0O7_stz.js";import{t as Qe}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-DxWb3aMV.js";import{a as it,c as rt,i as nt,o as st,s as lt}from"./JsonOutput-BYZnEjkl.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 K}from"./createLucideIcon-BCdY6lG5.js";import{t as dt}from"./arrow-left-VDC1u5rq.js";import{n as ct,t as ht}from"./LazyAnyLanguageCodeMirror-BTO7DS3k.js";import{r as mt}from"./x-ZP5cObgf.js";import{i as pt,r as be}from"./download-B6duieQs.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-CnImn_qm.js";import{a as S,c as Y,p as ut,r as jt,t as gt}from"./dropdown-menu-ldcmQvIV.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-Cggdh96K.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-DDsWrxuJ.js";import{t as Dt}from"./triangle-alert-CebQ7XwA.js";import{i as Pt,n as _t,t as Ot}from"./es-BYgU_srD.js";import"./dist-MyTWYTLd.js";import"./dist-LUpffRIq.js";import"./dist-PzrizfuL.js";import"./dist-BNkRH34W.js";import"./dist-maX8rbyb.js";import{t as W}from"./use-toast-BDYuj3zG.js";import{t as fe}from"./paths-BzSgteR-.js";import"./session-BOFn9QrD.js";import{r as zt}from"./useTheme-DQozhcp1.js";import"./Combination-BAEdC-rz.js";import{t as M}from"./tooltip-CMQz28hC.js";import"./dates-CrvjILe3.js";import{o as Mt}from"./alert-dialog-BW4srmS0.js";import"./popover-CH1FzjxU.js";import{n as Ne}from"./ImperativeModal-BNN1HA7x.js";import{r as Rt}from"./errors-TZBmrJmc.js";import{n as At}from"./blob-D-eV0cU3.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 Wt,i as It,n as xe,r as Et,t as Ht}from"./tree-B--q0-tu.js";import{n as Tt,t as Bt}from"./alert-BOoN6gJ1.js";import{n as Se}from"./error-banner-B9ts0mNl.js";import{n as De}from"./useAsyncData-BMGLSTg8.js";import"./chunk-5FQGJX7Z-DPlx2kjA.js";import"./katex-CDLTCvjQ.js";import"./html-to-image-BXhYNOMC.js";import{o as qt}from"./focus-n0WPxeOV.js";import{a as $t}from"./renderShortcut-BckyRbYt.js";import{t as Vt}from"./bundle.esm-i_UbZC0w.js";import{t as Lt}from"./links-DWIqY1l5.js";import{t as Ut}from"./icon-32x32-DH9kM4Sh.js";import{t as G}from"./Inputs-GV-aQbOR.js";var Kt=K("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=K("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=K("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"}]]),Yt=K("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"}]]),Gt=K("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"}]]),Xt=K("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(Qe(),1),ze=(0,F.createContext)(null);function Zt(){return(0,F.useContext)(ze)??void 0}var Jt=t=>{let e=(0,Oe.c)(3),{children:i}=t,n=It(),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 Qt=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)(Wt,{backend:Et,options:{rootElement:n},children:(0,a.jsx)(Jt,{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(Je),d=ae(ve),f=ae(Ke),[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)(G,{size:"small",onClick:c,children:(0,a.jsx)(Ct,{})})}),t.isMarimoFile&&!re()&&(0,a.jsx)(M,{content:"Open notebook",children:(0,a.jsx)(G,{size:"small",onClick:o=>e(o),children:(0,a.jsx)(pe,{})})}),!d&&(0,a.jsx)(M,{content:"Download",children:(0,a.jsx)(G,{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)(G,{size:"small",onClick:async()=>{await ne(h)},children:(0,a.jsx)(we,{})})}),(0,a.jsx)(M,{content:$t("global.save"),children:(0,a.jsx)(G,{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)(Bt,{variant:"warning",className:"rounded-none",children:[(0,a.jsx)(Dt,{className:"h-4 w-4"}),(0,a.jsx)(Tt,{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",Xe.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 At(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){Ge.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 X=ie(),ma=Ve("marimo:showHiddenFiles",!0,Ue,{getOnInit:!0}),We=F.createContext(null);const pa=t=>{let e=(0,X.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),J;e[18]!==f||e[19]!==u?(J=Ee(f,u),e[18]=f,e[19]=u,e[20]=J):J=e[20];let oe=J;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 Q;e[48]===Symbol.for("react.memo_cache_sentinel")?(Q=p=>{let w=p[0];w&&(w.data.isDirectory||l(w.data))},e[48]=Q):Q=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)(Ht,{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:Q,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,X.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)(Kt,{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,X.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,X.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}=Ye(),v=qt(),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)(Xt,{...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)(Y,{})]}),(0,a.jsxs)(S,{onSelect:()=>t.edit(),children:[(0,a.jsx)(Yt,{...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)(Y,{}),(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)(Le,{...o}),"Copy snippet for reading file"]}),t.data.isMarimoFile&&!re()&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Y,{}),(0,a.jsxs)(S,{onSelect:y,children:[(0,a.jsx)(Gt,{...o}),"Open notebook"]})]}),(0,a.jsx)(Y,{}),!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)(Y,{})]}),(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,X.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)(Qt,{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{Xr as Ve,Yn as Le,gn as Ue,qr as Ke,w as Ye}from"./cells-DG7rjkOQ.js";import"./react-dom-CSu739Rf.js";import{t as ie}from"./compiler-runtime-B3qBwwSJ.js";import"./tooltip-DxKBXCGp.js";import{d as Ge,f as Xe}from"./hotkeys-BHHWjLlp.js";import{t as Ze}from"./invariant-CAG_dYON.js";import{p as Je,u as ve}from"./utils-YqBXNpsM.js";import{S as re}from"./config-Q0O7_stz.js";import{t as Qe}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-DxWb3aMV.js";import{a as it,c as rt,i as nt,o as st,s as lt}from"./JsonOutput-CZpjHc50.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 K}from"./createLucideIcon-BCdY6lG5.js";import{t as dt}from"./arrow-left-VDC1u5rq.js";import{n as ct,t as ht}from"./LazyAnyLanguageCodeMirror-BTO7DS3k.js";import{r as mt}from"./x-ZP5cObgf.js";import{i as pt,r as be}from"./download-B6duieQs.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-CnImn_qm.js";import{a as S,c as Y,p as ut,r as jt,t as gt}from"./dropdown-menu-ldcmQvIV.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-Cggdh96K.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-DDsWrxuJ.js";import{t as Dt}from"./triangle-alert-CebQ7XwA.js";import{i as Pt,n as _t,t as Ot}from"./es-BYgU_srD.js";import"./dist-MyTWYTLd.js";import"./dist-LUpffRIq.js";import"./dist-PzrizfuL.js";import"./dist-BNkRH34W.js";import"./dist-maX8rbyb.js";import{t as W}from"./use-toast-BDYuj3zG.js";import{t as fe}from"./paths-BzSgteR-.js";import"./session-BOFn9QrD.js";import{r as zt}from"./useTheme-DQozhcp1.js";import"./Combination-BAEdC-rz.js";import{t as M}from"./tooltip-CMQz28hC.js";import"./dates-CrvjILe3.js";import{o as Mt}from"./alert-dialog-BW4srmS0.js";import"./popover-CH1FzjxU.js";import{n as Ne}from"./ImperativeModal-BNN1HA7x.js";import{r as Rt}from"./errors-TZBmrJmc.js";import{n as At}from"./blob-D-eV0cU3.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 Wt,i as It,n as xe,r as Et,t as Ht}from"./tree-B--q0-tu.js";import{n as Tt,t as Bt}from"./alert-BOoN6gJ1.js";import{n as Se}from"./error-banner-B9ts0mNl.js";import{n as De}from"./useAsyncData-BMGLSTg8.js";import"./chunk-5FQGJX7Z-DPlx2kjA.js";import"./katex-CDLTCvjQ.js";import"./html-to-image-BXhYNOMC.js";import{o as qt}from"./focus-n0WPxeOV.js";import{a as $t}from"./renderShortcut-BckyRbYt.js";import{t as Vt}from"./bundle.esm-i_UbZC0w.js";import{t as Lt}from"./links-DWIqY1l5.js";import{t as Ut}from"./icon-32x32-DH9kM4Sh.js";import{t as G}from"./Inputs-GV-aQbOR.js";var Kt=K("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=K("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=K("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"}]]),Yt=K("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"}]]),Gt=K("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"}]]),Xt=K("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(Qe(),1),ze=(0,F.createContext)(null);function Zt(){return(0,F.useContext)(ze)??void 0}var Jt=t=>{let e=(0,Oe.c)(3),{children:i}=t,n=It(),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 Qt=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)(Wt,{backend:Et,options:{rootElement:n},children:(0,a.jsx)(Jt,{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(Je),d=ae(ve),f=ae(Ke),[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)(G,{size:"small",onClick:c,children:(0,a.jsx)(Ct,{})})}),t.isMarimoFile&&!re()&&(0,a.jsx)(M,{content:"Open notebook",children:(0,a.jsx)(G,{size:"small",onClick:o=>e(o),children:(0,a.jsx)(pe,{})})}),!d&&(0,a.jsx)(M,{content:"Download",children:(0,a.jsx)(G,{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)(G,{size:"small",onClick:async()=>{await ne(h)},children:(0,a.jsx)(we,{})})}),(0,a.jsx)(M,{content:$t("global.save"),children:(0,a.jsx)(G,{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)(Bt,{variant:"warning",className:"rounded-none",children:[(0,a.jsx)(Dt,{className:"h-4 w-4"}),(0,a.jsx)(Tt,{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",Xe.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 At(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){Ge.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 X=ie(),ma=Ve("marimo:showHiddenFiles",!0,Ue,{getOnInit:!0}),We=F.createContext(null);const pa=t=>{let e=(0,X.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),J;e[18]!==f||e[19]!==u?(J=Ee(f,u),e[18]=f,e[19]=u,e[20]=J):J=e[20];let oe=J;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 Q;e[48]===Symbol.for("react.memo_cache_sentinel")?(Q=p=>{let w=p[0];w&&(w.data.isDirectory||l(w.data))},e[48]=Q):Q=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)(Ht,{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:Q,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,X.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)(Kt,{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,X.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,X.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}=Ye(),v=qt(),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)(Xt,{...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)(Y,{})]}),(0,a.jsxs)(S,{onSelect:()=>t.edit(),children:[(0,a.jsx)(Yt,{...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)(Y,{}),(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)(Le,{...o}),"Copy snippet for reading file"]}),t.data.isMarimoFile&&!re()&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Y,{}),(0,a.jsxs)(S,{onSelect:y,children:[(0,a.jsx)(Gt,{...o}),"Open notebook"]})]}),(0,a.jsx)(Y,{}),!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)(Y,{})]}),(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,X.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)(Qt,{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 +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-DG7rjkOQ.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-Q0O7_stz.js";import{r as z}from"./requests-B4FYHTZl.js";import{f as D}from"./layout-Bv1HRnh6.js";import{s as $,u as B}from"./download-B6duieQs.js";import{t as H}from"./Deferred-DxQeE5uh.js";import{t as L}from"./use-toast-BDYuj3zG.js";import{t as x}from"./useInterval-B-PjgTm9.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-DG7rjkOQ.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-Q0O7_stz.js";import{r as z}from"./requests-B4FYHTZl.js";import{f as D}from"./layout-C91DpyBS.js";import{s as $,u as B}from"./download-B6duieQs.js";import{t as H}from"./Deferred-DxQeE5uh.js";import{t as L}from"./use-toast-BDYuj3zG.js";import{t as x}from"./useInterval-B-PjgTm9.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};