@marimo-team/frontend 0.20.3-dev89 → 0.20.3-dev91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{cell-editor-B05zgqpc.js → cell-editor-D8xaLLzF.js} +1 -1
- package/dist/assets/{command-palette-Dy_ePPb-.js → command-palette-BkMYWFHq.js} +1 -1
- package/dist/assets/{edit-page-CX7DCA4M.js → edit-page-DXQa188q.js} +3 -3
- package/dist/assets/{index-CRsKr5CB.js → index-BAp5idqc.js} +2 -2
- package/dist/assets/layout-DQyAaEMt.js +5 -0
- package/dist/assets/{panels-CKmNYbiF.js → panels-CeS0F13O.js} +1 -1
- package/dist/assets/{run-page-yn4JEZ_r.js → run-page-8S9mxjlL.js} +1 -1
- package/dist/assets/{scratchpad-panel-BmBKvZA7.js → scratchpad-panel-DzOWeiXN.js} +1 -1
- package/dist/assets/{useNotebookActions-P1v5BUET.js → useNotebookActions-CGdPh6jF.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/components/editor/output/console/ConsoleOutput.tsx +28 -12
- package/src/components/editor/output/console/__tests__/ConsoleOutput.test.tsx +150 -8
- package/src/hooks/useInputHistory.ts +1 -1
- package/dist/assets/layout-DKgHttkT.js +0 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as J}from"./chunk-LvLJmgfZ.js";import{u as K}from"./useEvent-WUlsM6MC.js";import{t as G}from"./react-Bj1aDYRI.js";import{T as H,ai as ee,x as te}from"./cells-DVXjWBHI.js";import"./react-dom-CSu739Rf.js";import{t as Y}from"./compiler-runtime-B3qBwwSJ.js";import"./tooltip-BrjpohcK.js";import{t as re}from"./context-aware-panel-D7EEtBgI.js";import{n as $}from"./constants-CdR60lKM.js";import{S as se,d as oe}from"./config-vle9v48l.js";import{t as ae}from"./jsx-runtime-CP2fAiZX.js";import{n as ie,t as q}from"./button-BmOH9agK.js";import{t as le}from"./cn-d_A4rA-x.js";import"./dist-DUY6xZX8.js";import{Y as M,w as me}from"./JsonOutput-DgTX3wDl.js";import"./cjs-CVt8hZ5L.js";import"./main-Cmx6WhDY.js";import"./useNonce-BY4jV7Yb.js";import{r as ne}from"./requests-DZy_SQ_v.js";import"./layout-DKgHttkT.js";import{l as ce}from"./state-O2Ife70c.js";import{r as de}from"./download-CNypwy8-.js";import"./markdown-renderer-BF7gphWI.js";import{t as pe}from"./copy-CAR4dOiD.js";import{t as he}from"./download-BG-iMGgV.js";import{i as fe,l as xe,n as be,r as Q,t as ye,u as je}from"./panels-CKmNYbiF.js";import{t as ue}from"./spinner-Cg6xI4rq.js";import"./dist-DRM_TtJV.js";import"./dist-CLn8560E.js";import"./dist-4go66rGa.js";import"./dist-C_w6Go0g.js";import"./dist-D3d3ioNg.js";import{t as ge}from"./use-toast-BtZldTi5.js";import{t as ke}from"./session-BQVN1Kxg.js";import"./Combination-BM4eSgxb.js";import"./purify.es-DFAhPV1y.js";import"./dates-BL9QfUQ0.js";import{a as _e,c as Ne,l as we,n as ve,r as Se,t as Ce}from"./dialog-DxCG9U2G.js";import"./popover-2GpKY98n.js";import{t as ze}from"./share-XjNIMk98.js";import"./vega-loader.browser-xq8miGHn.js";import"./defaultLocale-DPBdGRrH.js";import"./defaultLocale-Lfi0pexn.js";import{t as Ie}from"./copy-hG3KkB-h.js";import{a as Pe}from"./cell-link-zwx6SduJ.js";import"./chunk-5FQGJX7Z-C3tg8qpb.js";import"./katex-0Z75JF53.js";import"./html-to-image-Din4blht.js";import"./esm-DYDEu0Nq.js";import{n as Te,t as Ae}from"./react-resizable-panels.browser.esm-RgA6v8U3.js";import"./name-cell-input-EJb1YnST.js";import{t as Ee}from"./marimo-icons-B0iaQddz.js";import"./ws-Sb1KIggW.js";import"./dist-DBYXupB9.js";import"./dist-CW4ZrmuX.js";import"./dist-DvNh3ph0.js";import"./dist-DrewQ3CS.js";import"./dist-BML9Do7x.js";import"./dist-DWi0RsIc.js";import"./dist-pzEKEf2L.js";import"./dist-CX4tr6LY.js";import"./dist-DkUBUEhC.js";import"./esm-B2VsGmJs.js";var Re=Y(),Be=J(G(),1),t=J(ae(),1);const We=o=>{let e=(0,Re.c)(25),{appConfig:s}=o,{setCells:r}=H(),{sendComponentValues:y}=ne(),c;e[0]===y?c=e[1]:(c=()=>(Q.INSTANCE.start(y),Le),e[0]=y,e[1]=c);let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=[],e[2]=a):a=e[2],(0,Be.useEffect)(c,a);let i;e[3]===Symbol.for("react.memo_cache_sentinel")?(i=ke(),e[3]=i):i=e[3];let j;e[4]===r?j=e[5]:(j={autoInstantiate:!0,setCells:r,sessionId:i},e[4]=r,e[5]=j);let{connection:l}=be(j),N=K(te),u;e[6]===l.state?u=e[7]:(u=oe(l.state),e[6]=l.state,e[7]=u);let x=u,d;e[8]!==s||e[9]!==x?(d=()=>x?(0,t.jsxs)(me,{milliseconds:2e3,fallback:null,children:[(0,t.jsx)(ue,{className:"mx-auto"}),(0,t.jsx)("p",{className:"text-center text-sm text-muted-foreground mt-2",children:"Connecting..."})]}):(0,t.jsx)(fe,{appConfig:s,mode:"read"}),e[8]=s,e[9]=x,e[10]=d):d=e[10];let b=d,m;e:{if(typeof window>"u"){m=null;break e}let f,n;if(e[11]===Symbol.for("react.memo_cache_sentinel")){if(n=new URL(window.location.href),!n.searchParams.has("file")){m=null;break e}n.searchParams.delete("file"),f=n.searchParams.toString(),e[11]=f,e[12]=n,e[13]=m}else f=e[11],n=e[12],m=e[13];let w=f;m=w?`${n.pathname}?${w}`:n.pathname}let g=m,v=s.width,k;e[14]===Symbol.for("react.memo_cache_sentinel")?(k=g&&(0,t.jsx)("div",{className:"flex items-center px-6 pt-4 sm:-mt-8",children:(0,t.jsxs)("a",{href:g,"aria-label":"Back to gallery",className:le(ie({variant:"text",size:"sm"}),"gap-2 px-0 text-muted-foreground hover:text-foreground"),children:[(0,t.jsx)(ce,{className:"size-4","aria-hidden":!0}),(0,t.jsx)("span",{children:"Back"})]})}),e[14]=k):k=e[14];let p;e[15]===l?p=e[16]:(p=(0,t.jsx)(je,{connection:l,className:"sm:pt-8",children:k}),e[15]=l,e[16]=p);let h;e[17]===b?h=e[18]:(h=b(),e[17]=b,e[18]=h);let _;return e[19]!==s.width||e[20]!==l||e[21]!==N||e[22]!==p||e[23]!==h?(_=(0,t.jsxs)(xe,{connection:l,isRunning:N,width:v,children:[p,h]}),e[19]=s.width,e[20]=l,e[21]=N,e[22]=p,e[23]=h,e[24]=_):_=e[24],_};function Le(){Q.INSTANCE.stop()}var X=Y();const Oe=()=>{let o=(0,X.c)(3),e=K(ee);if(!M()||!e)return null;let s;o[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsxs)("span",{children:["Static"," ",(0,t.jsx)("a",{href:$.githubPage,target:"_blank",className:"text-(--sky-11) font-medium underline",children:"marimo"})," ","notebook - Run or edit for full interactivity"]}),o[0]=s):s=o[0];let r;return o[1]===e?r=o[2]:(r=(0,t.jsxs)("div",{className:"px-4 py-2 bg-(--sky-2) border-b border-(--sky-7) text-(--sky-11) flex justify-between items-center gap-4 print:hidden text-sm","data-testid":"static-notebook-banner",children:[s,(0,t.jsx)("span",{className:"shrink-0",children:(0,t.jsx)(Ue,{code:e})})]}),o[1]=e,o[2]=r),r};var Ue=o=>{let e=(0,X.c)(78),{code:s}=o,r=Pe()||"notebook.py",y=r.lastIndexOf("/");y!==-1&&(r=r.slice(y+1));let c=window.location.href,a,i,j,l,N,u,x,d,b,m,g,v,k,p,h,_,f,n,w;if(e[0]!==s||e[1]!==r){let F=ze({code:s});l=Ce,e[21]===Symbol.for("react.memo_cache_sentinel")?(g=(0,t.jsx)(we,{asChild:!0,children:(0,t.jsx)(q,{"data-testid":"static-notebook-dialog-trigger",variant:"outline",size:"xs",children:"Run or Edit"})}),e[21]=g):g=e[21],j=ve,i=_e,e[22]===r?m=e[23]:(m=(0,t.jsx)(Ne,{children:r}),e[22]=r,e[23]=m),a=Se,u="pt-3 text-left space-y-3",e[24]===Symbol.for("react.memo_cache_sentinel")?(x=(0,t.jsxs)("p",{children:["This is a static"," ",(0,t.jsx)("a",{href:$.githubPage,target:"_blank",className:"text-(--sky-11) hover:underline font-medium",children:"marimo"})," ","notebook. To run interactively:"]}),e[24]=x):x=e[24];let V;e[25]===Symbol.for("react.memo_cache_sentinel")?(V=(0,t.jsx)("br",{}),e[25]=V):V=e[25],e[26]===r?d=e[27]:(d=(0,t.jsx)("div",{className:"rounded-lg p-3 border bg-(--sky-2) border-(--sky-7)",children:(0,t.jsxs)("div",{className:"font-mono text-(--sky-11) leading-relaxed",children:["pip install marimo",V,"marimo edit ",r]})}),e[26]=r,e[27]=d),e[28]===Symbol.for("react.memo_cache_sentinel")?(b=!c.endsWith(".html")&&(0,t.jsxs)("div",{className:"rounded-lg p-3 border bg-(--sky-2) border-(--sky-7)",children:[(0,t.jsx)("div",{className:"text-sm text-(--sky-12) mb-1",children:"Or run directly from URL:"}),(0,t.jsxs)("div",{className:"font-mono text-(--sky-11) break-all",children:["marimo edit ",window.location.href]})]}),e[28]=b):b=e[28],w="pt-3 border-t border-(--sky-7)",_="text-sm text-(--sky-12) mb-2",e[29]===Symbol.for("react.memo_cache_sentinel")?(f=(0,t.jsx)("strong",{children:"Try in browser with WebAssembly:"}),e[29]=f):f=e[29],n=" ",N=F,v="_blank",k="text-(--sky-11) hover:underline break-all",p="noreferrer",h=F.slice(0,50),e[0]=s,e[1]=r,e[2]=a,e[3]=i,e[4]=j,e[5]=l,e[6]=N,e[7]=u,e[8]=x,e[9]=d,e[10]=b,e[11]=m,e[12]=g,e[13]=v,e[14]=k,e[15]=p,e[16]=h,e[17]=_,e[18]=f,e[19]=n,e[20]=w}else a=e[2],i=e[3],j=e[4],l=e[5],N=e[6],u=e[7],x=e[8],d=e[9],b=e[10],m=e[11],g=e[12],v=e[13],k=e[14],p=e[15],h=e[16],_=e[17],f=e[18],n=e[19],w=e[20];let S;e[30]!==N||e[31]!==v||e[32]!==k||e[33]!==p||e[34]!==h?(S=(0,t.jsxs)("a",{href:N,target:v,className:k,rel:p,children:[h,"..."]}),e[30]=N,e[31]=v,e[32]=k,e[33]=p,e[34]=h,e[35]=S):S=e[35];let C;e[36]!==S||e[37]!==_||e[38]!==f||e[39]!==n?(C=(0,t.jsxs)("p",{className:_,children:[f,n,S]}),e[36]=S,e[37]=_,e[38]=f,e[39]=n,e[40]=C):C=e[40];let L;e[41]===Symbol.for("react.memo_cache_sentinel")?(L=(0,t.jsx)("p",{className:"text-sm text-(--sky-12)",children:"Note: WebAssembly may not work for all notebooks. Additionally, some dependencies may not be available in the browser."}),e[41]=L):L=e[41];let z;e[42]!==C||e[43]!==w?(z=(0,t.jsxs)("div",{className:w,children:[C,L]}),e[42]=C,e[43]=w,e[44]=z):z=e[44];let I;e[45]!==a||e[46]!==u||e[47]!==x||e[48]!==d||e[49]!==b||e[50]!==z?(I=(0,t.jsxs)(a,{className:u,children:[x,d,b,z]}),e[45]=a,e[46]=u,e[47]=x,e[48]=d,e[49]=b,e[50]=z,e[51]=I):I=e[51];let P;e[52]!==i||e[53]!==m||e[54]!==I?(P=(0,t.jsxs)(i,{children:[m,I]}),e[52]=i,e[53]=m,e[54]=I,e[55]=P):P=e[55];let T;e[56]===s?T=e[57]:(T=async()=>{await Ie(s),ge({title:"Copied to clipboard"})},e[56]=s,e[57]=T);let O;e[58]===Symbol.for("react.memo_cache_sentinel")?(O=(0,t.jsx)(pe,{className:"w-3 h-3 mr-2"}),e[58]=O):O=e[58];let A;e[59]===T?A=e[60]:(A=(0,t.jsxs)(q,{"data-testid":"copy-static-notebook-dialog-button",variant:"outline",size:"sm",onClick:T,children:[O,"Copy code"]}),e[59]=T,e[60]=A);let E;e[61]!==s||e[62]!==r?(E=()=>{de(new Blob([s],{type:"text/plain"}),r)},e[61]=s,e[62]=r,e[63]=E):E=e[63];let U;e[64]===Symbol.for("react.memo_cache_sentinel")?(U=(0,t.jsx)(he,{className:"w-3 h-3 mr-2"}),e[64]=U):U=e[64];let R;e[65]===E?R=e[66]:(R=(0,t.jsxs)(q,{"data-testid":"download-static-notebook-dialog-button",variant:"outline",size:"sm",onClick:E,children:[U,"Download"]}),e[65]=E,e[66]=R);let B;e[67]!==A||e[68]!==R?(B=(0,t.jsxs)("div",{className:"flex gap-3 pt-2",children:[A,R]}),e[67]=A,e[68]=R,e[69]=B):B=e[69];let W;e[70]!==j||e[71]!==P||e[72]!==B?(W=(0,t.jsxs)(j,{children:[P,B]}),e[70]=j,e[71]=P,e[72]=B,e[73]=W):W=e[73];let D;return e[74]!==l||e[75]!==g||e[76]!==W?(D=(0,t.jsxs)(l,{children:[g,W]}),e[74]=l,e[75]=g,e[76]=W,e[77]=D):D=e[77],D},Z=Y(),De=se()||M(),Ve=o=>{let e=(0,Z.c)(9),s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)(Oe,{}),e[0]=s):s=e[0];let r;e[1]===o.appConfig?r=e[2]:(r=(0,t.jsx)(We,{appConfig:o.appConfig}),e[1]=o.appConfig,e[2]=r);let y;e[3]===Symbol.for("react.memo_cache_sentinel")?(y=De&&(0,t.jsx)(Ye,{}),e[3]=y):y=e[3];let c;e[4]===r?c=e[5]:(c=(0,t.jsxs)(Ae,{children:[s,r,y]}),e[4]=r,e[5]=c);let a;e[6]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)(re,{}),e[6]=a):a=e[6];let i;return e[7]===c?i=e[8]:(i=(0,t.jsx)(ye,{children:(0,t.jsxs)(Te,{direction:"horizontal",autoSaveId:"marimo:chrome:v1:run1",children:[c,a]})}),e[7]=c,e[8]=i),i},Ye=()=>{let o=(0,Z.c)(1),e;return o[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)("div",{className:"fixed bottom-0 right-0 z-50","data-testid":"watermark",children:(0,t.jsxs)("a",{href:$.githubPage,target:"_blank",className:"text-sm text-(--grass-11) font-bold tracking-wide transition-colors bg-(--grass-4) hover:bg-(--grass-5) border-t border-l border-(--grass-8) px-3 py-1 rounded-tl-md flex items-center gap-2",children:[(0,t.jsx)("span",{children:"made with marimo"}),(0,t.jsx)(Ee,{className:"h-4 w-auto"})]})}),o[0]=e):e=o[0],e},$e=Ve;export{$e as default};
|
|
1
|
+
import{s as J}from"./chunk-LvLJmgfZ.js";import{u as K}from"./useEvent-WUlsM6MC.js";import{t as G}from"./react-Bj1aDYRI.js";import{T as H,ai as ee,x as te}from"./cells-DVXjWBHI.js";import"./react-dom-CSu739Rf.js";import{t as Y}from"./compiler-runtime-B3qBwwSJ.js";import"./tooltip-BrjpohcK.js";import{t as re}from"./context-aware-panel-D7EEtBgI.js";import{n as $}from"./constants-CdR60lKM.js";import{S as se,d as oe}from"./config-vle9v48l.js";import{t as ae}from"./jsx-runtime-CP2fAiZX.js";import{n as ie,t as q}from"./button-BmOH9agK.js";import{t as le}from"./cn-d_A4rA-x.js";import"./dist-DUY6xZX8.js";import{Y as M,w as me}from"./JsonOutput-DgTX3wDl.js";import"./cjs-CVt8hZ5L.js";import"./main-Cmx6WhDY.js";import"./useNonce-BY4jV7Yb.js";import{r as ne}from"./requests-DZy_SQ_v.js";import"./layout-DQyAaEMt.js";import{l as ce}from"./state-O2Ife70c.js";import{r as de}from"./download-CNypwy8-.js";import"./markdown-renderer-BF7gphWI.js";import{t as pe}from"./copy-CAR4dOiD.js";import{t as he}from"./download-BG-iMGgV.js";import{i as fe,l as xe,n as be,r as Q,t as ye,u as je}from"./panels-CeS0F13O.js";import{t as ue}from"./spinner-Cg6xI4rq.js";import"./dist-DRM_TtJV.js";import"./dist-CLn8560E.js";import"./dist-4go66rGa.js";import"./dist-C_w6Go0g.js";import"./dist-D3d3ioNg.js";import{t as ge}from"./use-toast-BtZldTi5.js";import{t as ke}from"./session-BQVN1Kxg.js";import"./Combination-BM4eSgxb.js";import"./purify.es-DFAhPV1y.js";import"./dates-BL9QfUQ0.js";import{a as _e,c as Ne,l as we,n as ve,r as Se,t as Ce}from"./dialog-DxCG9U2G.js";import"./popover-2GpKY98n.js";import{t as ze}from"./share-XjNIMk98.js";import"./vega-loader.browser-xq8miGHn.js";import"./defaultLocale-DPBdGRrH.js";import"./defaultLocale-Lfi0pexn.js";import{t as Ie}from"./copy-hG3KkB-h.js";import{a as Pe}from"./cell-link-zwx6SduJ.js";import"./chunk-5FQGJX7Z-C3tg8qpb.js";import"./katex-0Z75JF53.js";import"./html-to-image-Din4blht.js";import"./esm-DYDEu0Nq.js";import{n as Te,t as Ae}from"./react-resizable-panels.browser.esm-RgA6v8U3.js";import"./name-cell-input-EJb1YnST.js";import{t as Ee}from"./marimo-icons-B0iaQddz.js";import"./ws-Sb1KIggW.js";import"./dist-DBYXupB9.js";import"./dist-CW4ZrmuX.js";import"./dist-DvNh3ph0.js";import"./dist-DrewQ3CS.js";import"./dist-BML9Do7x.js";import"./dist-DWi0RsIc.js";import"./dist-pzEKEf2L.js";import"./dist-CX4tr6LY.js";import"./dist-DkUBUEhC.js";import"./esm-B2VsGmJs.js";var Re=Y(),Be=J(G(),1),t=J(ae(),1);const We=o=>{let e=(0,Re.c)(25),{appConfig:s}=o,{setCells:r}=H(),{sendComponentValues:y}=ne(),c;e[0]===y?c=e[1]:(c=()=>(Q.INSTANCE.start(y),Le),e[0]=y,e[1]=c);let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=[],e[2]=a):a=e[2],(0,Be.useEffect)(c,a);let i;e[3]===Symbol.for("react.memo_cache_sentinel")?(i=ke(),e[3]=i):i=e[3];let j;e[4]===r?j=e[5]:(j={autoInstantiate:!0,setCells:r,sessionId:i},e[4]=r,e[5]=j);let{connection:l}=be(j),N=K(te),u;e[6]===l.state?u=e[7]:(u=oe(l.state),e[6]=l.state,e[7]=u);let x=u,d;e[8]!==s||e[9]!==x?(d=()=>x?(0,t.jsxs)(me,{milliseconds:2e3,fallback:null,children:[(0,t.jsx)(ue,{className:"mx-auto"}),(0,t.jsx)("p",{className:"text-center text-sm text-muted-foreground mt-2",children:"Connecting..."})]}):(0,t.jsx)(fe,{appConfig:s,mode:"read"}),e[8]=s,e[9]=x,e[10]=d):d=e[10];let b=d,m;e:{if(typeof window>"u"){m=null;break e}let f,n;if(e[11]===Symbol.for("react.memo_cache_sentinel")){if(n=new URL(window.location.href),!n.searchParams.has("file")){m=null;break e}n.searchParams.delete("file"),f=n.searchParams.toString(),e[11]=f,e[12]=n,e[13]=m}else f=e[11],n=e[12],m=e[13];let w=f;m=w?`${n.pathname}?${w}`:n.pathname}let g=m,v=s.width,k;e[14]===Symbol.for("react.memo_cache_sentinel")?(k=g&&(0,t.jsx)("div",{className:"flex items-center px-6 pt-4 sm:-mt-8",children:(0,t.jsxs)("a",{href:g,"aria-label":"Back to gallery",className:le(ie({variant:"text",size:"sm"}),"gap-2 px-0 text-muted-foreground hover:text-foreground"),children:[(0,t.jsx)(ce,{className:"size-4","aria-hidden":!0}),(0,t.jsx)("span",{children:"Back"})]})}),e[14]=k):k=e[14];let p;e[15]===l?p=e[16]:(p=(0,t.jsx)(je,{connection:l,className:"sm:pt-8",children:k}),e[15]=l,e[16]=p);let h;e[17]===b?h=e[18]:(h=b(),e[17]=b,e[18]=h);let _;return e[19]!==s.width||e[20]!==l||e[21]!==N||e[22]!==p||e[23]!==h?(_=(0,t.jsxs)(xe,{connection:l,isRunning:N,width:v,children:[p,h]}),e[19]=s.width,e[20]=l,e[21]=N,e[22]=p,e[23]=h,e[24]=_):_=e[24],_};function Le(){Q.INSTANCE.stop()}var X=Y();const Oe=()=>{let o=(0,X.c)(3),e=K(ee);if(!M()||!e)return null;let s;o[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsxs)("span",{children:["Static"," ",(0,t.jsx)("a",{href:$.githubPage,target:"_blank",className:"text-(--sky-11) font-medium underline",children:"marimo"})," ","notebook - Run or edit for full interactivity"]}),o[0]=s):s=o[0];let r;return o[1]===e?r=o[2]:(r=(0,t.jsxs)("div",{className:"px-4 py-2 bg-(--sky-2) border-b border-(--sky-7) text-(--sky-11) flex justify-between items-center gap-4 print:hidden text-sm","data-testid":"static-notebook-banner",children:[s,(0,t.jsx)("span",{className:"shrink-0",children:(0,t.jsx)(Ue,{code:e})})]}),o[1]=e,o[2]=r),r};var Ue=o=>{let e=(0,X.c)(78),{code:s}=o,r=Pe()||"notebook.py",y=r.lastIndexOf("/");y!==-1&&(r=r.slice(y+1));let c=window.location.href,a,i,j,l,N,u,x,d,b,m,g,v,k,p,h,_,f,n,w;if(e[0]!==s||e[1]!==r){let F=ze({code:s});l=Ce,e[21]===Symbol.for("react.memo_cache_sentinel")?(g=(0,t.jsx)(we,{asChild:!0,children:(0,t.jsx)(q,{"data-testid":"static-notebook-dialog-trigger",variant:"outline",size:"xs",children:"Run or Edit"})}),e[21]=g):g=e[21],j=ve,i=_e,e[22]===r?m=e[23]:(m=(0,t.jsx)(Ne,{children:r}),e[22]=r,e[23]=m),a=Se,u="pt-3 text-left space-y-3",e[24]===Symbol.for("react.memo_cache_sentinel")?(x=(0,t.jsxs)("p",{children:["This is a static"," ",(0,t.jsx)("a",{href:$.githubPage,target:"_blank",className:"text-(--sky-11) hover:underline font-medium",children:"marimo"})," ","notebook. To run interactively:"]}),e[24]=x):x=e[24];let V;e[25]===Symbol.for("react.memo_cache_sentinel")?(V=(0,t.jsx)("br",{}),e[25]=V):V=e[25],e[26]===r?d=e[27]:(d=(0,t.jsx)("div",{className:"rounded-lg p-3 border bg-(--sky-2) border-(--sky-7)",children:(0,t.jsxs)("div",{className:"font-mono text-(--sky-11) leading-relaxed",children:["pip install marimo",V,"marimo edit ",r]})}),e[26]=r,e[27]=d),e[28]===Symbol.for("react.memo_cache_sentinel")?(b=!c.endsWith(".html")&&(0,t.jsxs)("div",{className:"rounded-lg p-3 border bg-(--sky-2) border-(--sky-7)",children:[(0,t.jsx)("div",{className:"text-sm text-(--sky-12) mb-1",children:"Or run directly from URL:"}),(0,t.jsxs)("div",{className:"font-mono text-(--sky-11) break-all",children:["marimo edit ",window.location.href]})]}),e[28]=b):b=e[28],w="pt-3 border-t border-(--sky-7)",_="text-sm text-(--sky-12) mb-2",e[29]===Symbol.for("react.memo_cache_sentinel")?(f=(0,t.jsx)("strong",{children:"Try in browser with WebAssembly:"}),e[29]=f):f=e[29],n=" ",N=F,v="_blank",k="text-(--sky-11) hover:underline break-all",p="noreferrer",h=F.slice(0,50),e[0]=s,e[1]=r,e[2]=a,e[3]=i,e[4]=j,e[5]=l,e[6]=N,e[7]=u,e[8]=x,e[9]=d,e[10]=b,e[11]=m,e[12]=g,e[13]=v,e[14]=k,e[15]=p,e[16]=h,e[17]=_,e[18]=f,e[19]=n,e[20]=w}else a=e[2],i=e[3],j=e[4],l=e[5],N=e[6],u=e[7],x=e[8],d=e[9],b=e[10],m=e[11],g=e[12],v=e[13],k=e[14],p=e[15],h=e[16],_=e[17],f=e[18],n=e[19],w=e[20];let S;e[30]!==N||e[31]!==v||e[32]!==k||e[33]!==p||e[34]!==h?(S=(0,t.jsxs)("a",{href:N,target:v,className:k,rel:p,children:[h,"..."]}),e[30]=N,e[31]=v,e[32]=k,e[33]=p,e[34]=h,e[35]=S):S=e[35];let C;e[36]!==S||e[37]!==_||e[38]!==f||e[39]!==n?(C=(0,t.jsxs)("p",{className:_,children:[f,n,S]}),e[36]=S,e[37]=_,e[38]=f,e[39]=n,e[40]=C):C=e[40];let L;e[41]===Symbol.for("react.memo_cache_sentinel")?(L=(0,t.jsx)("p",{className:"text-sm text-(--sky-12)",children:"Note: WebAssembly may not work for all notebooks. Additionally, some dependencies may not be available in the browser."}),e[41]=L):L=e[41];let z;e[42]!==C||e[43]!==w?(z=(0,t.jsxs)("div",{className:w,children:[C,L]}),e[42]=C,e[43]=w,e[44]=z):z=e[44];let I;e[45]!==a||e[46]!==u||e[47]!==x||e[48]!==d||e[49]!==b||e[50]!==z?(I=(0,t.jsxs)(a,{className:u,children:[x,d,b,z]}),e[45]=a,e[46]=u,e[47]=x,e[48]=d,e[49]=b,e[50]=z,e[51]=I):I=e[51];let P;e[52]!==i||e[53]!==m||e[54]!==I?(P=(0,t.jsxs)(i,{children:[m,I]}),e[52]=i,e[53]=m,e[54]=I,e[55]=P):P=e[55];let T;e[56]===s?T=e[57]:(T=async()=>{await Ie(s),ge({title:"Copied to clipboard"})},e[56]=s,e[57]=T);let O;e[58]===Symbol.for("react.memo_cache_sentinel")?(O=(0,t.jsx)(pe,{className:"w-3 h-3 mr-2"}),e[58]=O):O=e[58];let A;e[59]===T?A=e[60]:(A=(0,t.jsxs)(q,{"data-testid":"copy-static-notebook-dialog-button",variant:"outline",size:"sm",onClick:T,children:[O,"Copy code"]}),e[59]=T,e[60]=A);let E;e[61]!==s||e[62]!==r?(E=()=>{de(new Blob([s],{type:"text/plain"}),r)},e[61]=s,e[62]=r,e[63]=E):E=e[63];let U;e[64]===Symbol.for("react.memo_cache_sentinel")?(U=(0,t.jsx)(he,{className:"w-3 h-3 mr-2"}),e[64]=U):U=e[64];let R;e[65]===E?R=e[66]:(R=(0,t.jsxs)(q,{"data-testid":"download-static-notebook-dialog-button",variant:"outline",size:"sm",onClick:E,children:[U,"Download"]}),e[65]=E,e[66]=R);let B;e[67]!==A||e[68]!==R?(B=(0,t.jsxs)("div",{className:"flex gap-3 pt-2",children:[A,R]}),e[67]=A,e[68]=R,e[69]=B):B=e[69];let W;e[70]!==j||e[71]!==P||e[72]!==B?(W=(0,t.jsxs)(j,{children:[P,B]}),e[70]=j,e[71]=P,e[72]=B,e[73]=W):W=e[73];let D;return e[74]!==l||e[75]!==g||e[76]!==W?(D=(0,t.jsxs)(l,{children:[g,W]}),e[74]=l,e[75]=g,e[76]=W,e[77]=D):D=e[77],D},Z=Y(),De=se()||M(),Ve=o=>{let e=(0,Z.c)(9),s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)(Oe,{}),e[0]=s):s=e[0];let r;e[1]===o.appConfig?r=e[2]:(r=(0,t.jsx)(We,{appConfig:o.appConfig}),e[1]=o.appConfig,e[2]=r);let y;e[3]===Symbol.for("react.memo_cache_sentinel")?(y=De&&(0,t.jsx)(Ye,{}),e[3]=y):y=e[3];let c;e[4]===r?c=e[5]:(c=(0,t.jsxs)(Ae,{children:[s,r,y]}),e[4]=r,e[5]=c);let a;e[6]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)(re,{}),e[6]=a):a=e[6];let i;return e[7]===c?i=e[8]:(i=(0,t.jsx)(ye,{children:(0,t.jsxs)(Te,{direction:"horizontal",autoSaveId:"marimo:chrome:v1:run1",children:[c,a]})}),e[7]=c,e[8]=i),i},Ye=()=>{let o=(0,Z.c)(1),e;return o[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)("div",{className:"fixed bottom-0 right-0 z-50","data-testid":"watermark",children:(0,t.jsxs)("a",{href:$.githubPage,target:"_blank",className:"text-sm text-(--grass-11) font-bold tracking-wide transition-colors bg-(--grass-4) hover:bg-(--grass-5) border-t border-l border-(--grass-8) px-3 py-1 rounded-tl-md flex items-center gap-2",children:[(0,t.jsx)("span",{children:"made with marimo"}),(0,t.jsx)(Ee,{className:"h-4 w-auto"})]})}),o[0]=e):e=o[0],e},$e=Ve;export{$e as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as oe}from"./chunk-LvLJmgfZ.js";import{d as be,l as ye,n as T,p as ae,u as we}from"./useEvent-WUlsM6MC.js";import{t as Ne}from"./react-Bj1aDYRI.js";import{P as ke,T as ze,_i as Ce,kn as Se,li as Ae,vi as n,__tla as Oe}from"./cells-DVXjWBHI.js";import"./react-dom-CSu739Rf.js";import{t as se}from"./compiler-runtime-B3qBwwSJ.js";import"./tooltip-BrjpohcK.js";import{h as ie}from"./useEventListener-CjXriKgk.js";import{y as Ie}from"./utils-CORJ8yYa.js";import{t as Pe}from"./constants-CdR60lKM.js";import{t as Le}from"./jsx-runtime-CP2fAiZX.js";import{t as z}from"./button-BmOH9agK.js";import{t as le}from"./cn-d_A4rA-x.js";import"./dist-DUY6xZX8.js";import{n as Me,__tla as Ee}from"./JsonOutput-DgTX3wDl.js";import"./cjs-CVt8hZ5L.js";import"./main-Cmx6WhDY.js";import"./useNonce-BY4jV7Yb.js";import{r as Re}from"./requests-DZy_SQ_v.js";import{t as me}from"./createLucideIcon-BvP5LBIs.js";import{d as De,__tla as He}from"./layout-
|
|
1
|
+
import{s as oe}from"./chunk-LvLJmgfZ.js";import{d as be,l as ye,n as T,p as ae,u as we}from"./useEvent-WUlsM6MC.js";import{t as Ne}from"./react-Bj1aDYRI.js";import{P as ke,T as ze,_i as Ce,kn as Se,li as Ae,vi as n,__tla as Oe}from"./cells-DVXjWBHI.js";import"./react-dom-CSu739Rf.js";import{t as se}from"./compiler-runtime-B3qBwwSJ.js";import"./tooltip-BrjpohcK.js";import{h as ie}from"./useEventListener-CjXriKgk.js";import{y as Ie}from"./utils-CORJ8yYa.js";import{t as Pe}from"./constants-CdR60lKM.js";import{t as Le}from"./jsx-runtime-CP2fAiZX.js";import{t as z}from"./button-BmOH9agK.js";import{t as le}from"./cn-d_A4rA-x.js";import"./dist-DUY6xZX8.js";import{n as Me,__tla as Ee}from"./JsonOutput-DgTX3wDl.js";import"./cjs-CVt8hZ5L.js";import"./main-Cmx6WhDY.js";import"./useNonce-BY4jV7Yb.js";import{r as Re}from"./requests-DZy_SQ_v.js";import{t as me}from"./createLucideIcon-BvP5LBIs.js";import{d as De,__tla as He}from"./layout-DQyAaEMt.js";import{n as Te,t as Ve,__tla as qe}from"./LazyAnyLanguageCodeMirror-BuxbbXY6.js";import"./download-CNypwy8-.js";import"./markdown-renderer-BF7gphWI.js";import{u as Ge}from"./toDate-DDAiY7kz.js";import{t as Ue,__tla as Be}from"./cell-editor-D8xaLLzF.js";import{t as Fe}from"./spinner-Cg6xI4rq.js";import{t as Je}from"./play-Cb6tYyv-.js";import"./dist-DRM_TtJV.js";import"./dist-CLn8560E.js";import"./dist-4go66rGa.js";import"./dist-C_w6Go0g.js";import"./dist-D3d3ioNg.js";import"./session-BQVN1Kxg.js";import{r as Ke}from"./useTheme-0tqyqYah.js";import"./Combination-BM4eSgxb.js";import{t as C}from"./tooltip-D7xdZcKW.js";import"./purify.es-DFAhPV1y.js";import"./dates-BL9QfUQ0.js";import"./popover-2GpKY98n.js";import"./vega-loader.browser-xq8miGHn.js";import"./defaultLocale-DPBdGRrH.js";import"./defaultLocale-Lfi0pexn.js";import{__tla as Qe}from"./chunk-5FQGJX7Z-C3tg8qpb.js";import"./katex-0Z75JF53.js";import"./html-to-image-Din4blht.js";import{o as We}from"./focus-C2gi0jxY.js";import{a as Xe}from"./renderShortcut-CMdaUbHS.js";import"./esm-DYDEu0Nq.js";import{n as Ye,r as Ze,t as ne}from"./react-resizable-panels.browser.esm-RgA6v8U3.js";import"./name-cell-input-EJb1YnST.js";import{n as $e,r as et}from"./panel-context-ICWm_stq.js";import{__tla as tt}from"./loro_wasm_bg-DNKZeVyM.js";import"./ws-Sb1KIggW.js";import"./useInterval-C2RcswPt.js";import"./dist-DBYXupB9.js";import"./dist-CW4ZrmuX.js";import"./dist-DvNh3ph0.js";import"./dist-DrewQ3CS.js";import"./dist-BML9Do7x.js";import"./dist-DWi0RsIc.js";import"./dist-pzEKEf2L.js";import"./dist-CX4tr6LY.js";import"./dist-DkUBUEhC.js";import"./esm-B2VsGmJs.js";import{t as rt}from"./kiosk-mode-DfDMBGIM.js";let ce,ot=Promise.all([(()=>{try{return Oe}catch{}})(),(()=>{try{return Ee}catch{}})(),(()=>{try{return He}catch{}})(),(()=>{try{return qe}catch{}})(),(()=>{try{return Be}catch{}})(),(()=>{try{return Qe}catch{}})(),(()=>{try{return tt}catch{}})()]).then(async()=>{var de=me("eraser",[["path",{d:"M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21",key:"g5wo59"}],["path",{d:"m5.082 11.09 8.828 8.828",key:"1wx5vj"}]]),pe=me("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]),he=se(),V=oe(Ne(),1),ue=15;const q=Ae("marimo:scratchpadHistory:v1",[],Se),fe=ae(!1),xe=ae(null,(e,s,i)=>{if(i=i.trim(),!i)return;let m=e(q);s(q,[i,...m.filter(c=>c!==i)].slice(0,ue))});var t=oe(Le(),1),_e={hide_code:!1,disabled:!1};const ve=()=>{var re;let e=(0,he.c)(60),s=ke(),[i]=Ie(),{theme:m}=Ke(),c=(0,V.useRef)(null),G=We(),{createNewCell:U,updateCellCode:d}=ze(),{sendRunScratchpad:p}=Re(),S=$e(),B=et(),l=s.cellRuntime[n],F=l==null?void 0:l.output,A=l==null?void 0:l.status,J=l==null?void 0:l.consoleOutputs,r=((re=s.cellData.__scratch__)==null?void 0:re.code)??"",K=be(xe),[a,h]=ye(fe),u=we(q),O;e[0]!==K||e[1]!==r||e[2]!==p?(O=()=>{p({code:r}),K(r)},e[0]=K,e[1]=r,e[2]=p,e[3]=O):O=e[3];let f=T(O),I;e[4]!==r||e[5]!==U||e[6]!==G?(I=()=>{r.trim()&&U({code:r,before:!1,cellId:G??"__end__"})},e[4]=r,e[5]=U,e[6]=G,e[7]=I):I=e[7];let Q=T(I),P;e[8]!==p||e[9]!==d?(P=()=>{d({cellId:n,code:"",formattingChange:!1}),p({code:""});let o=c.current;o&&o.dispatch({changes:{from:0,to:o.state.doc.length,insert:""}})},e[8]=p,e[9]=d,e[10]=P):P=e[10];let W=T(P),L;e[11]!==h||e[12]!==d?(L=o=>{h(!1),d({cellId:n,code:o,formattingChange:!1});let k=c.current;k&&k.dispatch({changes:{from:0,to:k.state.doc.length,insert:o}})},e[11]=h,e[12]=d,e[13]=L):L=e[13];let X=T(L),[Y,ge]=(0,V.useState)(),M;e[14]!==X||e[15]!==u||e[16]!==a||e[17]!==m?(M=()=>a?(0,t.jsx)("div",{className:"absolute inset-0 z-100 bg-background p-3 border-none overflow-auto",children:(0,t.jsx)("div",{className:"overflow-auto flex flex-col gap-3",children:u.map((o,k)=>(0,t.jsx)("div",{className:"border rounded-md hover:shadow-sm cursor-pointer hover:border-input overflow-hidden",onClick:()=>X(o),children:(0,t.jsx)(V.Suspense,{children:(0,t.jsx)(Ve,{language:"python",theme:m,basicSetup:{highlightActiveLine:!1,highlightActiveLineGutter:!1},value:o.trim(),editable:!1,readOnly:!0})})},k))})}):null,e[14]=X,e[15]=u,e[16]=a,e[17]=m,e[18]=M):M=e[18];let Z=M,E;e[19]!==W||e[20]!==Q||e[21]!==f||e[22]!==u.length||e[23]!==a||e[24]!==h||e[25]!==A?(E=()=>(0,t.jsxs)("div",{className:"flex items-center shrink-0 border-b",children:[(0,t.jsx)(C,{content:Xe("cell.run"),children:(0,t.jsx)(z,{"data-testid":"scratchpad-run-button",onClick:f,disabled:a,variant:"text",size:"xs",children:(0,t.jsx)(Je,{color:"var(--grass-11)",size:16})})}),(0,t.jsx)(C,{content:"Clear code and outputs",children:(0,t.jsx)(z,{disabled:a,size:"xs",variant:"text",onClick:W,children:(0,t.jsx)(de,{size:16})})}),(0,t.jsx)(rt,{children:(0,t.jsx)(C,{content:"Insert code",children:(0,t.jsx)(z,{disabled:a,size:"xs",variant:"text",onClick:Q,children:(0,t.jsx)(Te,{size:16})})})}),(A==="running"||A==="queued")&&(0,t.jsx)(Fe,{className:"inline",size:"small"}),(0,t.jsx)("div",{className:"flex-1"}),(0,t.jsx)(C,{content:"Toggle history",children:(0,t.jsx)(z,{size:"xs",variant:"text",className:le(a&&"bg-(--sky-3) rounded-none"),onClick:()=>h(!a),disabled:u.length===0,children:(0,t.jsx)(pe,{size:16})})}),(0,t.jsx)(C,{content:(0,t.jsx)("span",{className:"block max-w-prose",children:"Use this scratchpad to experiment with code without restrictions on variable names. Variables defined here aren't saved to notebook memory, and the code is not saved in the notebook file."}),children:(0,t.jsx)(z,{size:"xs",variant:"text",children:(0,t.jsx)(Ge,{size:16})})})]}),e[19]=W,e[20]=Q,e[21]=f,e[22]=u.length,e[23]=a,e[24]=h,e[25]=A,e[26]=E):E=e[26];let $=E,je=S==="vertical",R;e[27]===Symbol.for("react.memo_cache_sentinel")?(R=Ce.create(n),e[27]=R):R=e[27];let x;e[28]===$?x=e[29]:(x=$(),e[28]=$,e[29]=x);let D;e[30]===Symbol.for("react.memo_cache_sentinel")?(D=o=>{c.current=o},e[30]=D):D=e[30];let _;e[31]!==r||e[32]!==f||e[33]!==Y||e[34]!==m||e[35]!==i?(_=(0,t.jsx)("div",{className:"flex-1 overflow-auto",children:(0,t.jsx)(Ue,{theme:m,showPlaceholder:!1,id:n,code:r,config:_e,status:"idle",serializedEditorState:null,runCell:f,userConfig:i,editorViewRef:c,setEditorView:D,hidden:!1,showHiddenCode:ie.NOOP,languageAdapter:Y,setLanguageAdapter:ge})}),e[31]=r,e[32]=f,e[33]=Y,e[34]=m,e[35]=i,e[36]=_):_=e[36];let v;e[37]===Z?v=e[38]:(v=Z(),e[37]=Z,e[38]=v);let g;e[39]!==v||e[40]!==x||e[41]!==_?(g=(0,t.jsx)(ne,{defaultSize:40,minSize:20,maxSize:70,children:(0,t.jsxs)("div",{className:"h-full flex flex-col overflow-hidden relative",children:[x,_,v]})}),e[39]=v,e[40]=x,e[41]=_,e[42]=g):g=e[42];let ee=je?"h-1":"w-1",j;e[43]===ee?j=e[44]:(j=le("bg-border hover:bg-primary/50 transition-colors",ee),e[43]=ee,e[44]=j);let b;e[45]===j?b=e[46]:(b=(0,t.jsx)(Ze,{className:j}),e[45]=j,e[46]=b);let y;e[47]===F?y=e[48]:(y=(0,t.jsx)("div",{className:"flex-1 overflow-auto",children:(0,t.jsx)(Me,{allowExpand:!1,output:F,className:Pe.outputArea,cellId:n,stale:!1,loading:!1})}),e[47]=F,e[48]=y);let w;e[49]===J?w=e[50]:(w=(0,t.jsx)("div",{className:"overflow-auto shrink-0 max-h-[50%]",children:(0,t.jsx)(De,{consoleOutputs:J,className:"overflow-auto",stale:!1,cellName:"_",onSubmitDebugger:ie.NOOP,cellId:n,debuggerActive:!1})}),e[49]=J,e[50]=w);let N;e[51]!==y||e[52]!==w?(N=(0,t.jsx)(ne,{defaultSize:60,minSize:20,children:(0,t.jsxs)("div",{className:"h-full flex flex-col divide-y overflow-hidden",children:[y,w]})}),e[51]=y,e[52]=w,e[53]=N):N=e[53];let H;return e[54]!==S||e[55]!==B||e[56]!==g||e[57]!==b||e[58]!==N?(H=(0,t.jsx)("div",{className:"flex flex-col h-full overflow-hidden",id:R,children:(0,t.jsxs)(Ye,{direction:S,className:"h-full",children:[g,b,N]},B)}),e[54]=S,e[55]=B,e[56]=g,e[57]=b,e[58]=N,e[59]=H):H=e[59],H};let te;te=se(),ce=()=>{let e=(0,te.c)(1),s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)(ve,{}),e[0]=s):s=e[0],s}});export{ot as __tla,ce as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as pe}from"./chunk-LvLJmgfZ.js";import{d as I,l as Ue,p as Ye,u as ae}from"./useEvent-WUlsM6MC.js";import{t as $e}from"./react-Bj1aDYRI.js";import{Cn as Ge,En as me,Gt as Ke,Nr as Je,Sn as Xe,T as ue,_ as Ze,_i as oe,ar as Qe,cr as et,dt as fe,h as ye,lt as tt,pr as at,pt as ot,rr as nt,t as it,ut as lt,xn as st}from"./cells-DVXjWBHI.js";import{t as W}from"./compiler-runtime-B3qBwwSJ.js";import{n as rt}from"./assertNever-Dw9aFN4h.js";import{s as be}from"./useLifecycle-BDXC6oVR.js";import{n as dt}from"./add-database-form-VCKMmUc7.js";import{n as ct,x as ht}from"./ai-model-dropdown-D0ZKojfQ.js";import{c as xe,m as L}from"./useEventListener-CjXriKgk.js";import{y as pt}from"./utils-CORJ8yYa.js";import{n as _,t as ke}from"./constants-CdR60lKM.js";import{S as we,h as mt,x as ut}from"./config-vle9v48l.js";import{t as ft}from"./jsx-runtime-CP2fAiZX.js";import{r as yt,t as ne}from"./button-BmOH9agK.js";import{r as T}from"./requests-DZy_SQ_v.js";import{t as h}from"./createLucideIcon-BvP5LBIs.js";import{a as ge,f as bt,i as je,m as xt,p as ve,u as Ce}from"./layout-DKgHttkT.js";import{t as ze}from"./check-BnZGcuDh.js";import{c as kt,d as Me,n as wt,o as gt,r as We,t as jt}from"./download-CNypwy8-.js";import{f as vt}from"./maps-8VTEe-0T.js";import{r as Ct}from"./useCellActionButton-DLoBXBqS.js";import{t as zt}from"./copy-CAR4dOiD.js";import{t as Mt}from"./download-BG-iMGgV.js";import{t as Wt}from"./eye-off-DgTL09j7.js";import{t as _t}from"./file-plus-corner-BRwJx0yp.js";import{t as ie}from"./file-DVwc11C3.js";import{i as St,n as Dt,r as At,t as Nt}from"./youtube-C6LYzJHy.js";import{t as Et}from"./globe-B68kre4p.js";import{n as Pt,t as It}from"./square-BQ6pR0y3.js";import{t as Lt}from"./image-DJi6ovcV.js";import{t as Tt}from"./link-BMKs5Gz_.js";import{r as Ht}from"./input-CRB-lq4Q.js";import{t as qt}from"./settings-DuNjGb99.js";import{y as Rt}from"./textarea-BUCOcONS.js";import{t as C}from"./use-toast-BtZldTi5.js";import{n as _e,t as Ft}from"./paths-BVwhPRFT.js";import{o as Vt}from"./session-BQVN1Kxg.js";import{a as Bt,c as Ot,i as Ut,n as Yt,r as $t,s as Gt,t as Kt}from"./select-DjvQ3a3F.js";import{t as Jt}from"./tooltip-D7xdZcKW.js";import{o as Xt}from"./alert-dialog-DNI_v2jv.js";import{a as Zt,c as Qt,i as ea,n as ta,r as aa}from"./dialog-DxCG9U2G.js";import{n as le}from"./ImperativeModal-Upm6NvJ2.js";import{r as oa,t as na}from"./share-XjNIMk98.js";import{t as K}from"./copy-hG3KkB-h.js";import{a as ia}from"./cell-link-zwx6SduJ.js";import{a as Se}from"./renderShortcut-CMdaUbHS.js";import{t as la}from"./icons-CHolxgW2.js";import{t as sa}from"./links-DJ5XP9fV.js";import{t as De}from"./types-D4wsSrXa.js";var ra=h("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),da=h("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),Ae=h("clipboard-copy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]),Ne=h("command",[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]]),Ee=h("diamond-plus",[["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0z",key:"1ey20j"}],["path",{d:"M8 12h8",key:"1wcyev"}]]),ca=h("fast-forward",[["path",{d:"M12 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 12 18z",key:"b19h5q"}],["path",{d:"M2 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 2 18z",key:"h7h5ge"}]]),ha=h("files",[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]]),pa=h("keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]),Pe=h("layout-template",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]),ma=h("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]),ua=h("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),Ie=h("presentation",[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]]),fa=h("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),ya=h("square-power",[["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M7.998 9.003a5 5 0 1 0 8-.005",key:"1pek45"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]),Le=h("undo-2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]),Te=W(),se=pe($e(),1),a=pe(ft(),1),J="https://static.marimo.app";const ba=e=>{let t=(0,Te.c)(25),{onClose:n}=e,[o,l]=(0,se.useState)(""),{exportAsHTML:r}=T(),s=`${o}-${Math.random().toString(36).slice(2,6)}`,i=`${J}/static/${s}`,d;t[0]!==r||t[1]!==n||t[2]!==s?(d=async v=>{v.preventDefault(),n();let D=await r({download:!1,includeCode:!0,files:bt.INSTANCE.filenames()}),z=C({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${J}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:D,path:s})}).catch(()=>{z.dismiss(),C({title:"Error uploading static page",description:(0,a.jsxs)("div",{children:["Please try again later. If the problem persists, please file a bug report on"," ",(0,a.jsx)("a",{href:_.issuesPage,target:"_blank",className:"underline",children:"GitHub"}),"."]})})}),z.dismiss(),C({title:"Static page uploaded!",description:(0,a.jsxs)("div",{children:["The URL has been copied to your clipboard.",(0,a.jsx)("br",{}),"You can share it with anyone."]})})},t[0]=r,t[1]=n,t[2]=s,t[3]=d):d=t[3];let p;t[4]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsx)(Qt,{children:"Share static notebook"}),t[4]=p):p=t[4];let w;t[5]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsxs)(Zt,{children:[p,(0,a.jsxs)(aa,{children:["You can publish a static, non-interactive version of this notebook to the public web. We will create a link for you that lives on"," ",(0,a.jsx)("a",{href:J,target:"_blank",children:J}),"."]})]}),t[5]=w):w=t[5];let g;t[6]===Symbol.for("react.memo_cache_sentinel")?(g=v=>{l(v.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,""))},t[6]=g):g=t[6];let u;t[7]===o?u=t[8]:(u=(0,a.jsx)(Ht,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:g,required:!0,autoComplete:"off"}),t[7]=o,t[8]=u);let f;t[9]===i?f=t[10]:(f=(0,a.jsxs)("div",{className:"font-semibold text-sm text-muted-foreground gap-2 flex flex-col",children:["Anyone will be able to access your notebook at this URL:",(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(xa,{text:i}),(0,a.jsx)("span",{className:"text-primary",children:i})]})]}),t[9]=i,t[10]=f);let y;t[11]!==u||t[12]!==f?(y=(0,a.jsxs)("div",{className:"flex flex-col gap-6 py-4",children:[u,f]}),t[11]=u,t[12]=f,t[13]=y):y=t[13];let b;t[14]===n?b=t[15]:(b=(0,a.jsx)(ne,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),t[14]=n,t[15]=b);let x;t[16]===i?x=t[17]:(x=(0,a.jsx)(ne,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await K(i)},children:"Create"}),t[16]=i,t[17]=x);let k;t[18]!==b||t[19]!==x?(k=(0,a.jsxs)(ea,{children:[b,x]}),t[18]=b,t[19]=x,t[20]=k):k=t[20];let j;return t[21]!==d||t[22]!==k||t[23]!==y?(j=(0,a.jsx)(ta,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:d,children:[w,y,k]})}),t[21]=d,t[22]=k,t[23]=y,t[24]=j):j=t[24],j};var xa=e=>{let t=(0,Te.c)(8),[n,o]=se.useState(!1),l;t[0]===e.text?l=t[1]:(l=yt.stopPropagation(async p=>{p.preventDefault(),await K(e.text),o(!0),setTimeout(()=>o(!1),2e3)}),t[0]=e.text,t[1]=l);let r=l,s;t[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(zt,{size:14,strokeWidth:1.5}),t[2]=s):s=t[2];let i;t[3]===r?i=t[4]:(i=(0,a.jsx)(ne,{"data-testid":"copy-static-notebook-url-button",onClick:r,size:"xs",variant:"secondary",children:s}),t[3]=r,t[4]=i);let d;return t[5]!==n||t[6]!==i?(d=(0,a.jsx)(Jt,{content:"Copied!",open:n,children:i}),t[5]=n,t[6]=i,t[7]=d):d=t[7],d},ka=W();function wa(){let e=document.getElementsByClassName(ke.outputArea);for(let t of e){let n=t.getBoundingClientRect();if(n.bottom>0&&n.top<window.innerHeight){let o=oe.findElement(t);if(!o){L.warn("Could not find HTMLCellId for visible output area",t);continue}return{cellId:oe.parse(o.id)}}}return L.warn("No visible output area found for scroll anchor"),null}function ga(e){if(!e){L.warn("No scroll anchor provided to restore scroll position");return}let t=document.getElementById(oe.create(e.cellId));if(!t){L.warn("Could not find cell element to restore scroll position",e.cellId);return}if(!t.querySelector(`.${ke.outputArea}`)){L.warn("Could not find output area to restore scroll position",e.cellId);return}t.scrollIntoView({block:"start",behavior:"auto"})}function He(){let e=(0,ka.c)(2),t=I(fe),n;return e[0]===t?n=e[1]:(n=()=>{let o=wa();t(l=>({mode:lt(l.mode),cellAnchor:(o==null?void 0:o.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{ga(o)})})},e[0]=t,e[1]=n),n}const qe=Ye(!1);var ja=W();const va=()=>{let e=(0,ja.c)(7),{selectedLayout:t}=ge(),{setLayoutView:n}=je();if(we()&&!me("wasm_layouts"))return null;let o;e[0]===n?o=e[1]:(o=i=>n(i),e[0]=n,e[1]=o);let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=(0,a.jsx)(Gt,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(Ot,{placeholder:"Select a view"})}),e[2]=l):l=e[2];let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)(Yt,{children:(0,a.jsxs)($t,{children:[(0,a.jsx)(Bt,{children:"View as"}),De.map(za)]})}),e[3]=r):r=e[3];let s;return e[4]!==t||e[5]!==o?(s=(0,a.jsxs)(Kt,{"data-testid":"layout-select",value:t,onValueChange:o,children:[l,r]}),e[4]=t,e[5]=o,e[6]=s):s=e[6],s};function Ca(e){return(0,a.jsx)(Re(e),{className:"h-4 w-4"})}function Re(e){switch(e){case"vertical":return ma;case"grid":return At;case"slides":return Ie;default:return rt(e),It}}function Fe(e){return be(e)}function za(e){return(0,a.jsx)(Ut,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[Ca(e),(0,a.jsx)("span",{children:Fe(e)})]})},e)}async function Ma(e){let{filename:t,preset:n,downloadPDF:o}=e;await o({filename:t,webpdf:!0,preset:n,includeInputs:!1,rasterServer:"live"})}var Wa=W();function _a(e){let t=(0,Wa.c)(5),{openPrompt:n,closeModal:o}=le(),{sendCopy:l}=T(),r;return t[0]!==o||t[1]!==n||t[2]!==l||t[3]!==e?(r=()=>{if(!e)return null;let s=Ft.guessDeliminator(e);n({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${_e.basename(e)}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:i=>{let d=s.join(_e.dirname(e),i);l({source:e,destination:d}).then(()=>{o(),C({title:"Notebook copied",description:"A copy of the notebook has been created."}),sa(d)})}})},t[0]=o,t[1]=n,t[2]=l,t[3]=e,t[4]=r):r=t[4],r}const Sa=()=>{let{updateCellConfig:e}=ue(),{saveCellConfig:t}=T();return(0,se.useCallback)(async()=>{let n=new Ke,o=ye(),l=o.cellIds.inOrderIds,r={};for(let i of l){if(o.cellData[i]===void 0)continue;let{code:d,config:p}=o.cellData[i];p.hide_code||n.isSupported(d)&&(r[i]={hide_code:!0})}let s=xe.entries(r);if(s.length!==0){await t({configs:r});for(let[i,d]of s)e({cellId:i,config:d})}},[e])};var Da=W();function Ve(){let e=(0,Da.c)(4),{openConfirm:t}=le(),n=I(mt),{sendRestart:o}=T(),l;return e[0]!==t||e[1]!==o||e[2]!==n?(l=()=>{t({title:"Restart Kernel",description:"This will restart the Python kernel. You'll lose all data that's in memory. You will also lose any unsaved changes, so make sure to save your work before restarting.",variant:"destructive",confirmAction:(0,a.jsx)(Xt,{onClick:async()=>{n({state:ut.CLOSING}),await o(),oa()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=o,e[2]=n,e[3]=l):l=e[3],l}var Aa=W(),S=e=>{e==null||e.preventDefault(),e==null||e.stopPropagation()};function Na(){var ce,he;let e=(0,Aa.c)(42),t=ia(),{openModal:n,closeModal:o}=le(),{toggleApplication:l}=st(),{selectedPanel:r}=Xe(),[s]=Ue(fe),i=ae(tt),d=Sa(),[p]=pt(),{updateCellConfig:w,undoDeleteCell:g,clearAllCellOutputs:u,addSetupCellIfDoesntExist:f,collapseAllCells:y,expandAllCells:b}=ue(),x=Ve(),k=ot(),j=_a(t),v=I(qe),D=I(ct),z=I(ht),{exportAsMarkdown:X,readCode:A,saveCellConfig:Z}=T(),Q=ae(Ze),ee=ae(it),{selectedLayout:H}=ge(),{setLayoutView:te}=je(),q=He(),R=((ce=p.sharing)==null?void 0:ce.html)??!0,F=((he=p.sharing)==null?void 0:he.wasm)??!0,V;e[0]===Symbol.for("react.memo_cache_sentinel")?(V=me("server_side_pdf_export"),e[0]=V):V=e[0];let N=V,E=N||s.mode==="present",B=H==="slides",Be=Ja,de=Ka,O;e[1]===t?O=e[2]:(O=async c=>{let{preset:m,title:P}=c;if(!t){re();return}await kt(P,async()=>{await Ma({filename:t,preset:m,downloadPDF:wt})})},e[1]=t,e[2]=O);let U=O,Y;e[3]===Symbol.for("react.memo_cache_sentinel")?(Y=(0,a.jsx)(Mt,{size:14,strokeWidth:1.5}),e[3]=Y):Y=e[3];let $;e[4]===Symbol.for("react.memo_cache_sentinel")?($=(0,a.jsx)(ve,{size:14,strokeWidth:1.5}),e[4]=$):$=e[4];let M;e[5]===t?M=e[6]:(M=async()=>{if(!t){re();return}await Ce({filename:t,includeCode:!0})},e[5]=t,e[6]=M);let G;return e[7]!==f||e[8]!==ee||e[9]!==u||e[10]!==o||e[11]!==y||e[12]!==j||e[13]!==U||e[14]!==b||e[15]!==X||e[16]!==t||e[17]!==Q||e[18]!==d||e[19]!==B||e[20]!==i||e[21]!==n||e[22]!==E||e[23]!==A||e[24]!==x||e[25]!==k||e[26]!==Z||e[27]!==H||e[28]!==r||e[29]!==v||e[30]!==z||e[31]!==te||e[32]!==D||e[33]!==R||e[34]!==F||e[35]!==M||e[36]!==l||e[37]!==q||e[38]!==g||e[39]!==w||e[40]!==s.mode?(G=[{icon:Y,label:"Download",handle:S,dropdown:[{icon:$,label:"Download as HTML",handle:M},{icon:(0,a.jsx)(ve,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{if(!t){re();return}await Ce({filename:t,includeCode:!1})}},{icon:(0,a.jsx)(la,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{let c=await X({download:!1});We(new Blob([c],{type:"text/plain"}),Me.toMarkdown(document.title))}},{icon:(0,a.jsx)(xt,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let c=await A();We(new Blob([c.contents],{type:"text/plain"}),Me.toPY(document.title))}},{divider:!0,icon:(0,a.jsx)(Lt,{size:14,strokeWidth:1.5}),label:"Download as PNG",disabled:s.mode!=="present",tooltip:s.mode==="present"?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",Se("global.hideCode",!1)]}),handle:Ga},{divider:!0,icon:(0,a.jsx)(ie,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:S,disabled:!E&&!N,dropdown:[{icon:(0,a.jsx)(ie,{size:14,strokeWidth:1.5}),label:"Document Layout",rightElement:de(!B),disabled:!E,tooltip:E?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",Se("global.hideCode",!1)]}),handle:async()=>{if(N){await U({preset:"document",title:"Downloading Document PDF..."});return}let c=new Event("export-beforeprint"),m=new Event("export-afterprint");(function(){window.dispatchEvent(c),setTimeout($a,0),setTimeout(()=>window.dispatchEvent(m),0)})()}},{icon:(0,a.jsx)(ie,{size:14,strokeWidth:1.5}),label:"Slides Layout",rightElement:de(B),disabled:!N,tooltip:N?void 0:(0,a.jsx)("span",{children:"Requires Better PDF Export in Settings > Experimental."}),handle:async()=>{await U({preset:"slides",title:"Downloading Slides PDF..."})}}]}]},{icon:(0,a.jsx)(fa,{size:14,strokeWidth:1.5}),label:"Share",handle:S,hidden:!R&&!F,dropdown:[{icon:(0,a.jsx)(Et,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!R,handle:async()=>{n((0,a.jsx)(ba,{onClose:o}))}},{icon:(0,a.jsx)(Tt,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!F,handle:async()=>{await K(na({code:(await A()).contents})),C({title:"Copied",description:"Link copied to clipboard."})}}]},{icon:(0,a.jsx)(ua,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:S,dropdown:Ge.flatMap(c=>{let{type:m,Icon:P,hidden:Oe}=c;return Oe?[]:{label:be(m),rightElement:Be(r===m),icon:(0,a.jsx)(P,{size:14,strokeWidth:1.5}),handle:()=>l(m)}})},{icon:(0,a.jsx)(Ie,{size:14,strokeWidth:1.5}),label:"Present as",handle:S,dropdown:[{icon:s.mode==="present"?(0,a.jsx)(Rt,{size:14,strokeWidth:1.5}):(0,a.jsx)(Pe,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{q()}},...De.map((c,m)=>{let P=Re(c);return{divider:m===0,label:Fe(c),icon:(0,a.jsx)(P,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:H===c&&(0,a.jsx)(ze,{size:14})}),handle:()=>{te(c),s.mode==="edit"&&q()}}})]},{icon:(0,a.jsx)(ha,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!t||we(),handle:j},{icon:(0,a.jsx)(Ae,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!t,handle:async()=>{await K((await A()).contents),C({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(Ct,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!Q||i,handle:async()=>{let c=Je(ye());await Z({configs:xe.fromEntries(c.map(Ya))});for(let m of c)w({cellId:m,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)(Ee,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{f({})}},{icon:(0,a.jsx)(Qe,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n((0,a.jsx)(dt,{onClose:o}))}},{icon:(0,a.jsx)(Le,{size:14,strokeWidth:1.5}),label:"Undo cell deletion",hidden:!ee||i,handle:()=>{g()}},{icon:(0,a.jsx)(ya,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:x},{icon:(0,a.jsx)(ca,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{k()}},{icon:(0,a.jsx)(et,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{u()}},{icon:(0,a.jsx)(Wt,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:d,redundant:!0},{icon:(0,a.jsx)(da,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:y,redundant:!0},{icon:(0,a.jsx)(ra,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:b,redundant:!0},{divider:!0,icon:(0,a.jsx)(Ne,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>v(Ua)},{icon:(0,a.jsx)(pa,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>z(Oa)},{icon:(0,a.jsx)(qt,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>D(Ba),redundant:!0},{icon:(0,a.jsx)(vt,{size:14,strokeWidth:1.5}),label:"Resources",handle:S,dropdown:[{icon:(0,a.jsx)(at,{size:14,strokeWidth:1.5}),label:"Documentation",handle:Va},{icon:(0,a.jsx)(St,{size:14,strokeWidth:1.5}),label:"GitHub",handle:Fa},{icon:(0,a.jsx)(Dt,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:Ra},{icon:(0,a.jsx)(Nt,{size:14,strokeWidth:1.5}),label:"YouTube",handle:qa},{icon:(0,a.jsx)(nt,{size:14,strokeWidth:1.5}),label:"Changelog",handle:Ha}]},{divider:!0,icon:(0,a.jsx)(Pt,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:Ta},{icon:(0,a.jsx)(_t,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:La}].filter(Ia).map(Ea),e[7]=f,e[8]=ee,e[9]=u,e[10]=o,e[11]=y,e[12]=j,e[13]=U,e[14]=b,e[15]=X,e[16]=t,e[17]=Q,e[18]=d,e[19]=B,e[20]=i,e[21]=n,e[22]=E,e[23]=A,e[24]=x,e[25]=k,e[26]=Z,e[27]=H,e[28]=r,e[29]=v,e[30]=z,e[31]=te,e[32]=D,e[33]=R,e[34]=F,e[35]=M,e[36]=l,e[37]=q,e[38]=g,e[39]=w,e[40]=s.mode,e[41]=G):G=e[41],G}function Ea(e){return e.dropdown?{...e,dropdown:e.dropdown.filter(Pa)}:e}function Pa(e){return!e.hidden}function Ia(e){return!e.hidden}function La(){let e=Vt();window.open(e,"_blank")}function Ta(){let e=document.baseURI.split("?")[0];window.open(e,"_self")}function Ha(){window.open(_.releasesPage,"_blank")}function qa(){window.open(_.youtube,"_blank")}function Ra(){window.open(_.discordLink,"_blank")}function Fa(){window.open(_.githubPage,"_blank")}function Va(){window.open(_.docsPage,"_blank")}function Ba(e){return!e}function Oa(e){return!e}function Ua(e){return!e}function Ya(e){return[e,{disabled:!1}]}function $a(){return window.print()}async function Ga(){let e=document.getElementById("App");e&&await gt({element:e,filename:document.title,prepare:jt})}function Ka(e){return e?(0,a.jsx)("span",{className:"ml-3 shrink-0 rounded-full border border-emerald-200 bg-emerald-50 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-emerald-700",children:"Recommended"}):null}function Ja(e){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:e&&(0,a.jsx)(ze,{size:14})})}function re(){C({title:"Error",description:"Notebooks must be named to be exported.",variant:"danger"})}export{He as a,Ee as c,qe as i,Ne as l,Ve as n,Le as o,va as r,Pe as s,Na as t,Ae as u};
|
|
1
|
+
import{s as pe}from"./chunk-LvLJmgfZ.js";import{d as I,l as Ue,p as Ye,u as ae}from"./useEvent-WUlsM6MC.js";import{t as $e}from"./react-Bj1aDYRI.js";import{Cn as Ge,En as me,Gt as Ke,Nr as Je,Sn as Xe,T as ue,_ as Ze,_i as oe,ar as Qe,cr as et,dt as fe,h as ye,lt as tt,pr as at,pt as ot,rr as nt,t as it,ut as lt,xn as st}from"./cells-DVXjWBHI.js";import{t as W}from"./compiler-runtime-B3qBwwSJ.js";import{n as rt}from"./assertNever-Dw9aFN4h.js";import{s as be}from"./useLifecycle-BDXC6oVR.js";import{n as dt}from"./add-database-form-VCKMmUc7.js";import{n as ct,x as ht}from"./ai-model-dropdown-D0ZKojfQ.js";import{c as xe,m as L}from"./useEventListener-CjXriKgk.js";import{y as pt}from"./utils-CORJ8yYa.js";import{n as _,t as ke}from"./constants-CdR60lKM.js";import{S as we,h as mt,x as ut}from"./config-vle9v48l.js";import{t as ft}from"./jsx-runtime-CP2fAiZX.js";import{r as yt,t as ne}from"./button-BmOH9agK.js";import{r as T}from"./requests-DZy_SQ_v.js";import{t as h}from"./createLucideIcon-BvP5LBIs.js";import{a as ge,f as bt,i as je,m as xt,p as ve,u as Ce}from"./layout-DQyAaEMt.js";import{t as ze}from"./check-BnZGcuDh.js";import{c as kt,d as Me,n as wt,o as gt,r as We,t as jt}from"./download-CNypwy8-.js";import{f as vt}from"./maps-8VTEe-0T.js";import{r as Ct}from"./useCellActionButton-DLoBXBqS.js";import{t as zt}from"./copy-CAR4dOiD.js";import{t as Mt}from"./download-BG-iMGgV.js";import{t as Wt}from"./eye-off-DgTL09j7.js";import{t as _t}from"./file-plus-corner-BRwJx0yp.js";import{t as ie}from"./file-DVwc11C3.js";import{i as St,n as Dt,r as At,t as Nt}from"./youtube-C6LYzJHy.js";import{t as Et}from"./globe-B68kre4p.js";import{n as Pt,t as It}from"./square-BQ6pR0y3.js";import{t as Lt}from"./image-DJi6ovcV.js";import{t as Tt}from"./link-BMKs5Gz_.js";import{r as Ht}from"./input-CRB-lq4Q.js";import{t as qt}from"./settings-DuNjGb99.js";import{y as Rt}from"./textarea-BUCOcONS.js";import{t as C}from"./use-toast-BtZldTi5.js";import{n as _e,t as Ft}from"./paths-BVwhPRFT.js";import{o as Vt}from"./session-BQVN1Kxg.js";import{a as Bt,c as Ot,i as Ut,n as Yt,r as $t,s as Gt,t as Kt}from"./select-DjvQ3a3F.js";import{t as Jt}from"./tooltip-D7xdZcKW.js";import{o as Xt}from"./alert-dialog-DNI_v2jv.js";import{a as Zt,c as Qt,i as ea,n as ta,r as aa}from"./dialog-DxCG9U2G.js";import{n as le}from"./ImperativeModal-Upm6NvJ2.js";import{r as oa,t as na}from"./share-XjNIMk98.js";import{t as K}from"./copy-hG3KkB-h.js";import{a as ia}from"./cell-link-zwx6SduJ.js";import{a as Se}from"./renderShortcut-CMdaUbHS.js";import{t as la}from"./icons-CHolxgW2.js";import{t as sa}from"./links-DJ5XP9fV.js";import{t as De}from"./types-D4wsSrXa.js";var ra=h("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),da=h("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),Ae=h("clipboard-copy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]),Ne=h("command",[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]]),Ee=h("diamond-plus",[["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0z",key:"1ey20j"}],["path",{d:"M8 12h8",key:"1wcyev"}]]),ca=h("fast-forward",[["path",{d:"M12 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 12 18z",key:"b19h5q"}],["path",{d:"M2 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 2 18z",key:"h7h5ge"}]]),ha=h("files",[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]]),pa=h("keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]),Pe=h("layout-template",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]),ma=h("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]),ua=h("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),Ie=h("presentation",[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]]),fa=h("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),ya=h("square-power",[["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M7.998 9.003a5 5 0 1 0 8-.005",key:"1pek45"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]),Le=h("undo-2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]),Te=W(),se=pe($e(),1),a=pe(ft(),1),J="https://static.marimo.app";const ba=e=>{let t=(0,Te.c)(25),{onClose:n}=e,[o,l]=(0,se.useState)(""),{exportAsHTML:r}=T(),s=`${o}-${Math.random().toString(36).slice(2,6)}`,i=`${J}/static/${s}`,d;t[0]!==r||t[1]!==n||t[2]!==s?(d=async v=>{v.preventDefault(),n();let D=await r({download:!1,includeCode:!0,files:bt.INSTANCE.filenames()}),z=C({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${J}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:D,path:s})}).catch(()=>{z.dismiss(),C({title:"Error uploading static page",description:(0,a.jsxs)("div",{children:["Please try again later. If the problem persists, please file a bug report on"," ",(0,a.jsx)("a",{href:_.issuesPage,target:"_blank",className:"underline",children:"GitHub"}),"."]})})}),z.dismiss(),C({title:"Static page uploaded!",description:(0,a.jsxs)("div",{children:["The URL has been copied to your clipboard.",(0,a.jsx)("br",{}),"You can share it with anyone."]})})},t[0]=r,t[1]=n,t[2]=s,t[3]=d):d=t[3];let p;t[4]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsx)(Qt,{children:"Share static notebook"}),t[4]=p):p=t[4];let w;t[5]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsxs)(Zt,{children:[p,(0,a.jsxs)(aa,{children:["You can publish a static, non-interactive version of this notebook to the public web. We will create a link for you that lives on"," ",(0,a.jsx)("a",{href:J,target:"_blank",children:J}),"."]})]}),t[5]=w):w=t[5];let g;t[6]===Symbol.for("react.memo_cache_sentinel")?(g=v=>{l(v.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,""))},t[6]=g):g=t[6];let u;t[7]===o?u=t[8]:(u=(0,a.jsx)(Ht,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:g,required:!0,autoComplete:"off"}),t[7]=o,t[8]=u);let f;t[9]===i?f=t[10]:(f=(0,a.jsxs)("div",{className:"font-semibold text-sm text-muted-foreground gap-2 flex flex-col",children:["Anyone will be able to access your notebook at this URL:",(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(xa,{text:i}),(0,a.jsx)("span",{className:"text-primary",children:i})]})]}),t[9]=i,t[10]=f);let y;t[11]!==u||t[12]!==f?(y=(0,a.jsxs)("div",{className:"flex flex-col gap-6 py-4",children:[u,f]}),t[11]=u,t[12]=f,t[13]=y):y=t[13];let b;t[14]===n?b=t[15]:(b=(0,a.jsx)(ne,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),t[14]=n,t[15]=b);let x;t[16]===i?x=t[17]:(x=(0,a.jsx)(ne,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await K(i)},children:"Create"}),t[16]=i,t[17]=x);let k;t[18]!==b||t[19]!==x?(k=(0,a.jsxs)(ea,{children:[b,x]}),t[18]=b,t[19]=x,t[20]=k):k=t[20];let j;return t[21]!==d||t[22]!==k||t[23]!==y?(j=(0,a.jsx)(ta,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:d,children:[w,y,k]})}),t[21]=d,t[22]=k,t[23]=y,t[24]=j):j=t[24],j};var xa=e=>{let t=(0,Te.c)(8),[n,o]=se.useState(!1),l;t[0]===e.text?l=t[1]:(l=yt.stopPropagation(async p=>{p.preventDefault(),await K(e.text),o(!0),setTimeout(()=>o(!1),2e3)}),t[0]=e.text,t[1]=l);let r=l,s;t[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(zt,{size:14,strokeWidth:1.5}),t[2]=s):s=t[2];let i;t[3]===r?i=t[4]:(i=(0,a.jsx)(ne,{"data-testid":"copy-static-notebook-url-button",onClick:r,size:"xs",variant:"secondary",children:s}),t[3]=r,t[4]=i);let d;return t[5]!==n||t[6]!==i?(d=(0,a.jsx)(Jt,{content:"Copied!",open:n,children:i}),t[5]=n,t[6]=i,t[7]=d):d=t[7],d},ka=W();function wa(){let e=document.getElementsByClassName(ke.outputArea);for(let t of e){let n=t.getBoundingClientRect();if(n.bottom>0&&n.top<window.innerHeight){let o=oe.findElement(t);if(!o){L.warn("Could not find HTMLCellId for visible output area",t);continue}return{cellId:oe.parse(o.id)}}}return L.warn("No visible output area found for scroll anchor"),null}function ga(e){if(!e){L.warn("No scroll anchor provided to restore scroll position");return}let t=document.getElementById(oe.create(e.cellId));if(!t){L.warn("Could not find cell element to restore scroll position",e.cellId);return}if(!t.querySelector(`.${ke.outputArea}`)){L.warn("Could not find output area to restore scroll position",e.cellId);return}t.scrollIntoView({block:"start",behavior:"auto"})}function He(){let e=(0,ka.c)(2),t=I(fe),n;return e[0]===t?n=e[1]:(n=()=>{let o=wa();t(l=>({mode:lt(l.mode),cellAnchor:(o==null?void 0:o.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{ga(o)})})},e[0]=t,e[1]=n),n}const qe=Ye(!1);var ja=W();const va=()=>{let e=(0,ja.c)(7),{selectedLayout:t}=ge(),{setLayoutView:n}=je();if(we()&&!me("wasm_layouts"))return null;let o;e[0]===n?o=e[1]:(o=i=>n(i),e[0]=n,e[1]=o);let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=(0,a.jsx)(Gt,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(Ot,{placeholder:"Select a view"})}),e[2]=l):l=e[2];let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)(Yt,{children:(0,a.jsxs)($t,{children:[(0,a.jsx)(Bt,{children:"View as"}),De.map(za)]})}),e[3]=r):r=e[3];let s;return e[4]!==t||e[5]!==o?(s=(0,a.jsxs)(Kt,{"data-testid":"layout-select",value:t,onValueChange:o,children:[l,r]}),e[4]=t,e[5]=o,e[6]=s):s=e[6],s};function Ca(e){return(0,a.jsx)(Re(e),{className:"h-4 w-4"})}function Re(e){switch(e){case"vertical":return ma;case"grid":return At;case"slides":return Ie;default:return rt(e),It}}function Fe(e){return be(e)}function za(e){return(0,a.jsx)(Ut,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[Ca(e),(0,a.jsx)("span",{children:Fe(e)})]})},e)}async function Ma(e){let{filename:t,preset:n,downloadPDF:o}=e;await o({filename:t,webpdf:!0,preset:n,includeInputs:!1,rasterServer:"live"})}var Wa=W();function _a(e){let t=(0,Wa.c)(5),{openPrompt:n,closeModal:o}=le(),{sendCopy:l}=T(),r;return t[0]!==o||t[1]!==n||t[2]!==l||t[3]!==e?(r=()=>{if(!e)return null;let s=Ft.guessDeliminator(e);n({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${_e.basename(e)}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:i=>{let d=s.join(_e.dirname(e),i);l({source:e,destination:d}).then(()=>{o(),C({title:"Notebook copied",description:"A copy of the notebook has been created."}),sa(d)})}})},t[0]=o,t[1]=n,t[2]=l,t[3]=e,t[4]=r):r=t[4],r}const Sa=()=>{let{updateCellConfig:e}=ue(),{saveCellConfig:t}=T();return(0,se.useCallback)(async()=>{let n=new Ke,o=ye(),l=o.cellIds.inOrderIds,r={};for(let i of l){if(o.cellData[i]===void 0)continue;let{code:d,config:p}=o.cellData[i];p.hide_code||n.isSupported(d)&&(r[i]={hide_code:!0})}let s=xe.entries(r);if(s.length!==0){await t({configs:r});for(let[i,d]of s)e({cellId:i,config:d})}},[e])};var Da=W();function Ve(){let e=(0,Da.c)(4),{openConfirm:t}=le(),n=I(mt),{sendRestart:o}=T(),l;return e[0]!==t||e[1]!==o||e[2]!==n?(l=()=>{t({title:"Restart Kernel",description:"This will restart the Python kernel. You'll lose all data that's in memory. You will also lose any unsaved changes, so make sure to save your work before restarting.",variant:"destructive",confirmAction:(0,a.jsx)(Xt,{onClick:async()=>{n({state:ut.CLOSING}),await o(),oa()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=o,e[2]=n,e[3]=l):l=e[3],l}var Aa=W(),S=e=>{e==null||e.preventDefault(),e==null||e.stopPropagation()};function Na(){var ce,he;let e=(0,Aa.c)(42),t=ia(),{openModal:n,closeModal:o}=le(),{toggleApplication:l}=st(),{selectedPanel:r}=Xe(),[s]=Ue(fe),i=ae(tt),d=Sa(),[p]=pt(),{updateCellConfig:w,undoDeleteCell:g,clearAllCellOutputs:u,addSetupCellIfDoesntExist:f,collapseAllCells:y,expandAllCells:b}=ue(),x=Ve(),k=ot(),j=_a(t),v=I(qe),D=I(ct),z=I(ht),{exportAsMarkdown:X,readCode:A,saveCellConfig:Z}=T(),Q=ae(Ze),ee=ae(it),{selectedLayout:H}=ge(),{setLayoutView:te}=je(),q=He(),R=((ce=p.sharing)==null?void 0:ce.html)??!0,F=((he=p.sharing)==null?void 0:he.wasm)??!0,V;e[0]===Symbol.for("react.memo_cache_sentinel")?(V=me("server_side_pdf_export"),e[0]=V):V=e[0];let N=V,E=N||s.mode==="present",B=H==="slides",Be=Ja,de=Ka,O;e[1]===t?O=e[2]:(O=async c=>{let{preset:m,title:P}=c;if(!t){re();return}await kt(P,async()=>{await Ma({filename:t,preset:m,downloadPDF:wt})})},e[1]=t,e[2]=O);let U=O,Y;e[3]===Symbol.for("react.memo_cache_sentinel")?(Y=(0,a.jsx)(Mt,{size:14,strokeWidth:1.5}),e[3]=Y):Y=e[3];let $;e[4]===Symbol.for("react.memo_cache_sentinel")?($=(0,a.jsx)(ve,{size:14,strokeWidth:1.5}),e[4]=$):$=e[4];let M;e[5]===t?M=e[6]:(M=async()=>{if(!t){re();return}await Ce({filename:t,includeCode:!0})},e[5]=t,e[6]=M);let G;return e[7]!==f||e[8]!==ee||e[9]!==u||e[10]!==o||e[11]!==y||e[12]!==j||e[13]!==U||e[14]!==b||e[15]!==X||e[16]!==t||e[17]!==Q||e[18]!==d||e[19]!==B||e[20]!==i||e[21]!==n||e[22]!==E||e[23]!==A||e[24]!==x||e[25]!==k||e[26]!==Z||e[27]!==H||e[28]!==r||e[29]!==v||e[30]!==z||e[31]!==te||e[32]!==D||e[33]!==R||e[34]!==F||e[35]!==M||e[36]!==l||e[37]!==q||e[38]!==g||e[39]!==w||e[40]!==s.mode?(G=[{icon:Y,label:"Download",handle:S,dropdown:[{icon:$,label:"Download as HTML",handle:M},{icon:(0,a.jsx)(ve,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{if(!t){re();return}await Ce({filename:t,includeCode:!1})}},{icon:(0,a.jsx)(la,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{let c=await X({download:!1});We(new Blob([c],{type:"text/plain"}),Me.toMarkdown(document.title))}},{icon:(0,a.jsx)(xt,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let c=await A();We(new Blob([c.contents],{type:"text/plain"}),Me.toPY(document.title))}},{divider:!0,icon:(0,a.jsx)(Lt,{size:14,strokeWidth:1.5}),label:"Download as PNG",disabled:s.mode!=="present",tooltip:s.mode==="present"?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",Se("global.hideCode",!1)]}),handle:Ga},{divider:!0,icon:(0,a.jsx)(ie,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:S,disabled:!E&&!N,dropdown:[{icon:(0,a.jsx)(ie,{size:14,strokeWidth:1.5}),label:"Document Layout",rightElement:de(!B),disabled:!E,tooltip:E?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",Se("global.hideCode",!1)]}),handle:async()=>{if(N){await U({preset:"document",title:"Downloading Document PDF..."});return}let c=new Event("export-beforeprint"),m=new Event("export-afterprint");(function(){window.dispatchEvent(c),setTimeout($a,0),setTimeout(()=>window.dispatchEvent(m),0)})()}},{icon:(0,a.jsx)(ie,{size:14,strokeWidth:1.5}),label:"Slides Layout",rightElement:de(B),disabled:!N,tooltip:N?void 0:(0,a.jsx)("span",{children:"Requires Better PDF Export in Settings > Experimental."}),handle:async()=>{await U({preset:"slides",title:"Downloading Slides PDF..."})}}]}]},{icon:(0,a.jsx)(fa,{size:14,strokeWidth:1.5}),label:"Share",handle:S,hidden:!R&&!F,dropdown:[{icon:(0,a.jsx)(Et,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!R,handle:async()=>{n((0,a.jsx)(ba,{onClose:o}))}},{icon:(0,a.jsx)(Tt,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!F,handle:async()=>{await K(na({code:(await A()).contents})),C({title:"Copied",description:"Link copied to clipboard."})}}]},{icon:(0,a.jsx)(ua,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:S,dropdown:Ge.flatMap(c=>{let{type:m,Icon:P,hidden:Oe}=c;return Oe?[]:{label:be(m),rightElement:Be(r===m),icon:(0,a.jsx)(P,{size:14,strokeWidth:1.5}),handle:()=>l(m)}})},{icon:(0,a.jsx)(Ie,{size:14,strokeWidth:1.5}),label:"Present as",handle:S,dropdown:[{icon:s.mode==="present"?(0,a.jsx)(Rt,{size:14,strokeWidth:1.5}):(0,a.jsx)(Pe,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{q()}},...De.map((c,m)=>{let P=Re(c);return{divider:m===0,label:Fe(c),icon:(0,a.jsx)(P,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:H===c&&(0,a.jsx)(ze,{size:14})}),handle:()=>{te(c),s.mode==="edit"&&q()}}})]},{icon:(0,a.jsx)(ha,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!t||we(),handle:j},{icon:(0,a.jsx)(Ae,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!t,handle:async()=>{await K((await A()).contents),C({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(Ct,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!Q||i,handle:async()=>{let c=Je(ye());await Z({configs:xe.fromEntries(c.map(Ya))});for(let m of c)w({cellId:m,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)(Ee,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{f({})}},{icon:(0,a.jsx)(Qe,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n((0,a.jsx)(dt,{onClose:o}))}},{icon:(0,a.jsx)(Le,{size:14,strokeWidth:1.5}),label:"Undo cell deletion",hidden:!ee||i,handle:()=>{g()}},{icon:(0,a.jsx)(ya,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:x},{icon:(0,a.jsx)(ca,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{k()}},{icon:(0,a.jsx)(et,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{u()}},{icon:(0,a.jsx)(Wt,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:d,redundant:!0},{icon:(0,a.jsx)(da,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:y,redundant:!0},{icon:(0,a.jsx)(ra,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:b,redundant:!0},{divider:!0,icon:(0,a.jsx)(Ne,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>v(Ua)},{icon:(0,a.jsx)(pa,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>z(Oa)},{icon:(0,a.jsx)(qt,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>D(Ba),redundant:!0},{icon:(0,a.jsx)(vt,{size:14,strokeWidth:1.5}),label:"Resources",handle:S,dropdown:[{icon:(0,a.jsx)(at,{size:14,strokeWidth:1.5}),label:"Documentation",handle:Va},{icon:(0,a.jsx)(St,{size:14,strokeWidth:1.5}),label:"GitHub",handle:Fa},{icon:(0,a.jsx)(Dt,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:Ra},{icon:(0,a.jsx)(Nt,{size:14,strokeWidth:1.5}),label:"YouTube",handle:qa},{icon:(0,a.jsx)(nt,{size:14,strokeWidth:1.5}),label:"Changelog",handle:Ha}]},{divider:!0,icon:(0,a.jsx)(Pt,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:Ta},{icon:(0,a.jsx)(_t,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:La}].filter(Ia).map(Ea),e[7]=f,e[8]=ee,e[9]=u,e[10]=o,e[11]=y,e[12]=j,e[13]=U,e[14]=b,e[15]=X,e[16]=t,e[17]=Q,e[18]=d,e[19]=B,e[20]=i,e[21]=n,e[22]=E,e[23]=A,e[24]=x,e[25]=k,e[26]=Z,e[27]=H,e[28]=r,e[29]=v,e[30]=z,e[31]=te,e[32]=D,e[33]=R,e[34]=F,e[35]=M,e[36]=l,e[37]=q,e[38]=g,e[39]=w,e[40]=s.mode,e[41]=G):G=e[41],G}function Ea(e){return e.dropdown?{...e,dropdown:e.dropdown.filter(Pa)}:e}function Pa(e){return!e.hidden}function Ia(e){return!e.hidden}function La(){let e=Vt();window.open(e,"_blank")}function Ta(){let e=document.baseURI.split("?")[0];window.open(e,"_self")}function Ha(){window.open(_.releasesPage,"_blank")}function qa(){window.open(_.youtube,"_blank")}function Ra(){window.open(_.discordLink,"_blank")}function Fa(){window.open(_.githubPage,"_blank")}function Va(){window.open(_.docsPage,"_blank")}function Ba(e){return!e}function Oa(e){return!e}function Ua(e){return!e}function Ya(e){return[e,{disabled:!1}]}function $a(){return window.print()}async function Ga(){let e=document.getElementById("App");e&&await gt({element:e,filename:document.title,prepare:jt})}function Ka(e){return e?(0,a.jsx)("span",{className:"ml-3 shrink-0 rounded-full border border-emerald-200 bg-emerald-50 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-emerald-700",children:"Recommended"}):null}function Ja(e){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:e&&(0,a.jsx)(ze,{size:14})})}function re(){C({title:"Error",description:"Notebooks must be named to be exported.",variant:"danger"})}export{He as a,Ee as c,qe as i,Ne as l,Ve as n,Le as o,va as r,Pe as s,Na as t,Ae as u};
|
package/dist/index.html
CHANGED
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
<marimo-server-token data-token="{{ server_token }}" hidden></marimo-server-token>
|
|
67
67
|
<!-- /TODO -->
|
|
68
68
|
<title>{{ title }}</title>
|
|
69
|
-
<script type="module" crossorigin src="./assets/index-
|
|
69
|
+
<script type="module" crossorigin src="./assets/index-BAp5idqc.js"></script>
|
|
70
70
|
<link rel="modulepreload" crossorigin href="./assets/preload-helper-y72bE5iF.js">
|
|
71
71
|
<link rel="modulepreload" crossorigin href="./assets/clsx-A78R3nYl.js">
|
|
72
72
|
<link rel="modulepreload" crossorigin href="./assets/cn-d_A4rA-x.js">
|
package/package.json
CHANGED
|
@@ -18,7 +18,10 @@ import { isInternalCellName } from "@/core/cells/names";
|
|
|
18
18
|
import { useExpandedConsoleOutput } from "@/core/cells/outputs";
|
|
19
19
|
import type { WithResponse } from "@/core/cells/types";
|
|
20
20
|
import type { OutputMessage } from "@/core/kernel/messages";
|
|
21
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
type UseInputHistoryReturn,
|
|
23
|
+
useInputHistory,
|
|
24
|
+
} from "@/hooks/useInputHistory";
|
|
22
25
|
import { useOverflowDetection } from "@/hooks/useOverflowDetection";
|
|
23
26
|
import { useSelectAllContent } from "@/hooks/useSelectAllContent";
|
|
24
27
|
import { cn } from "@/utils/cn";
|
|
@@ -54,6 +57,11 @@ const ConsoleOutputInternal = (props: Props): React.ReactNode => {
|
|
|
54
57
|
const ref = React.useRef<HTMLDivElement>(null);
|
|
55
58
|
const { wrapText, setWrapText } = useWrapText();
|
|
56
59
|
const [isExpanded, setIsExpanded] = useExpandedConsoleOutput(props.cellId);
|
|
60
|
+
const [stdinValue, setStdinValue] = React.useState("");
|
|
61
|
+
const inputHistory = useInputHistory({
|
|
62
|
+
value: stdinValue,
|
|
63
|
+
setValue: setStdinValue,
|
|
64
|
+
});
|
|
57
65
|
const {
|
|
58
66
|
consoleOutputs,
|
|
59
67
|
stale,
|
|
@@ -210,6 +218,9 @@ const ConsoleOutputInternal = (props: Props): React.ReactNode => {
|
|
|
210
218
|
isPassword={isPassword}
|
|
211
219
|
onSubmit={(text) => onSubmitDebugger(text, originalIdx)}
|
|
212
220
|
onClear={onClear}
|
|
221
|
+
value={stdinValue}
|
|
222
|
+
setValue={setStdinValue}
|
|
223
|
+
inputHistory={inputHistory}
|
|
213
224
|
/>
|
|
214
225
|
);
|
|
215
226
|
}
|
|
@@ -249,25 +260,32 @@ const StdInput = (props: {
|
|
|
249
260
|
onSubmit: (text: string) => void;
|
|
250
261
|
onClear?: () => void;
|
|
251
262
|
output: string;
|
|
252
|
-
response?: string;
|
|
253
263
|
isPdb: boolean;
|
|
254
264
|
isPassword?: boolean;
|
|
265
|
+
value: string;
|
|
266
|
+
setValue: (value: string) => void;
|
|
267
|
+
inputHistory: UseInputHistoryReturn;
|
|
255
268
|
}) => {
|
|
256
|
-
const
|
|
257
|
-
|
|
258
|
-
const { navigateUp, navigateDown, addToHistory } = useInputHistory({
|
|
269
|
+
const {
|
|
259
270
|
value,
|
|
260
271
|
setValue,
|
|
261
|
-
|
|
272
|
+
inputHistory,
|
|
273
|
+
output,
|
|
274
|
+
isPassword,
|
|
275
|
+
isPdb,
|
|
276
|
+
onSubmit,
|
|
277
|
+
onClear,
|
|
278
|
+
} = props;
|
|
279
|
+
const { navigateUp, navigateDown, addToHistory } = inputHistory;
|
|
262
280
|
|
|
263
281
|
return (
|
|
264
282
|
<div className="flex gap-2 items-center pt-2">
|
|
265
|
-
{renderText(
|
|
283
|
+
{renderText(output)}
|
|
266
284
|
<Input
|
|
267
285
|
data-testid="console-input"
|
|
268
286
|
// This is used in <StdinBlockingAlert> to find the input
|
|
269
287
|
data-stdin-blocking={true}
|
|
270
|
-
type={
|
|
288
|
+
type={isPassword ? "password" : "text"}
|
|
271
289
|
autoComplete="off"
|
|
272
290
|
autoFocus={true}
|
|
273
291
|
value={value}
|
|
@@ -292,7 +310,7 @@ const StdInput = (props: {
|
|
|
292
310
|
if (e.key === "Enter" && !e.shiftKey) {
|
|
293
311
|
if (value) {
|
|
294
312
|
addToHistory(value);
|
|
295
|
-
|
|
313
|
+
onSubmit(value);
|
|
296
314
|
setValue("");
|
|
297
315
|
}
|
|
298
316
|
e.preventDefault();
|
|
@@ -306,9 +324,7 @@ const StdInput = (props: {
|
|
|
306
324
|
}
|
|
307
325
|
}}
|
|
308
326
|
/>
|
|
309
|
-
{
|
|
310
|
-
<DebuggerControls onSubmit={props.onSubmit} onClear={props.onClear} />
|
|
311
|
-
)}
|
|
327
|
+
{isPdb && <DebuggerControls onSubmit={onSubmit} onClear={onClear} />}
|
|
312
328
|
</div>
|
|
313
329
|
);
|
|
314
330
|
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
|
-
import { render, screen } from "@testing-library/react";
|
|
4
|
-
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { fireEvent, render, screen } from "@testing-library/react";
|
|
4
|
+
import { describe, expect, it, vi } from "vitest";
|
|
5
5
|
import { TooltipProvider } from "@/components/ui/tooltip";
|
|
6
6
|
import type { CellId } from "@/core/cells/ids";
|
|
7
|
+
import type { WithResponse } from "@/core/cells/types";
|
|
7
8
|
import type { OutputMessage } from "@/core/kernel/messages";
|
|
8
9
|
import { ConsoleOutput } from "../ConsoleOutput";
|
|
9
10
|
|
|
@@ -20,6 +21,10 @@ global.ResizeObserver = class ResizeObserver {
|
|
|
20
21
|
}
|
|
21
22
|
};
|
|
22
23
|
|
|
24
|
+
const renderWithProvider = (ui: React.ReactElement) => {
|
|
25
|
+
return render(<TooltipProvider>{ui}</TooltipProvider>);
|
|
26
|
+
};
|
|
27
|
+
|
|
23
28
|
describe("ConsoleOutput integration", () => {
|
|
24
29
|
const createOutput = (data: string, channel = "stdout"): OutputMessage => ({
|
|
25
30
|
channel: channel as "stdout" | "stderr",
|
|
@@ -31,7 +36,7 @@ describe("ConsoleOutput integration", () => {
|
|
|
31
36
|
const defaultProps = {
|
|
32
37
|
cellId: "cell-1" as CellId,
|
|
33
38
|
cellName: "test_cell",
|
|
34
|
-
consoleOutputs: [],
|
|
39
|
+
consoleOutputs: [] as WithResponse<OutputMessage>[],
|
|
35
40
|
stale: false,
|
|
36
41
|
debuggerActive: false,
|
|
37
42
|
onSubmitDebugger: () => {
|
|
@@ -50,14 +55,151 @@ describe("ConsoleOutput integration", () => {
|
|
|
50
55
|
],
|
|
51
56
|
};
|
|
52
57
|
|
|
53
|
-
|
|
54
|
-
<TooltipProvider>
|
|
55
|
-
<ConsoleOutput {...props} />
|
|
56
|
-
</TooltipProvider>,
|
|
57
|
-
);
|
|
58
|
+
renderWithProvider(<ConsoleOutput {...props} />);
|
|
58
59
|
|
|
59
60
|
const link = screen.getByRole("link", { name: "https://marimo.io" });
|
|
60
61
|
expect(link).toBeInTheDocument();
|
|
61
62
|
expect(link).toHaveAttribute("href", "https://marimo.io");
|
|
62
63
|
});
|
|
63
64
|
});
|
|
65
|
+
|
|
66
|
+
describe("ConsoleOutput pdb history", () => {
|
|
67
|
+
const defaultProps = {
|
|
68
|
+
cellId: "cell-1" as CellId,
|
|
69
|
+
cellName: "test_cell",
|
|
70
|
+
consoleOutputs: [] as WithResponse<OutputMessage>[],
|
|
71
|
+
stale: false,
|
|
72
|
+
debuggerActive: false,
|
|
73
|
+
onSubmitDebugger: vi.fn(),
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const stdinPrompt = (
|
|
77
|
+
data: string,
|
|
78
|
+
response?: string,
|
|
79
|
+
): WithResponse<OutputMessage> => ({
|
|
80
|
+
channel: "stdin" as const,
|
|
81
|
+
mimetype: "text/plain",
|
|
82
|
+
data,
|
|
83
|
+
timestamp: 0,
|
|
84
|
+
response,
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("should persist command history across StdInput remounts", () => {
|
|
88
|
+
// Initial state: pdb prompt waiting for input
|
|
89
|
+
const outputs1: WithResponse<OutputMessage>[] = [stdinPrompt("(Pdb) ")];
|
|
90
|
+
|
|
91
|
+
const onSubmitDebugger = vi.fn();
|
|
92
|
+
const { rerender } = renderWithProvider(
|
|
93
|
+
<ConsoleOutput
|
|
94
|
+
{...defaultProps}
|
|
95
|
+
consoleOutputs={outputs1}
|
|
96
|
+
onSubmitDebugger={onSubmitDebugger}
|
|
97
|
+
/>,
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
const input = screen.getByTestId("console-input");
|
|
101
|
+
|
|
102
|
+
// Type "next" and submit
|
|
103
|
+
fireEvent.change(input, { target: { value: "next" } });
|
|
104
|
+
fireEvent.keyDown(input, { key: "Enter" });
|
|
105
|
+
|
|
106
|
+
expect(onSubmitDebugger).toHaveBeenCalledWith("next", 0);
|
|
107
|
+
|
|
108
|
+
// Simulate server response: old stdin gets a response, new stdin prompt appears
|
|
109
|
+
const outputs2: WithResponse<OutputMessage>[] = [
|
|
110
|
+
stdinPrompt("(Pdb) ", "next"),
|
|
111
|
+
stdinPrompt("(Pdb) "),
|
|
112
|
+
];
|
|
113
|
+
|
|
114
|
+
rerender(
|
|
115
|
+
<TooltipProvider>
|
|
116
|
+
<ConsoleOutput
|
|
117
|
+
{...defaultProps}
|
|
118
|
+
consoleOutputs={outputs2}
|
|
119
|
+
onSubmitDebugger={onSubmitDebugger}
|
|
120
|
+
/>
|
|
121
|
+
</TooltipProvider>,
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
// New StdInput mounted — press ArrowUp to recall previous command
|
|
125
|
+
const newInput = screen.getByTestId("console-input");
|
|
126
|
+
fireEvent.keyDown(newInput, { key: "ArrowUp" });
|
|
127
|
+
|
|
128
|
+
expect(newInput).toHaveValue("next");
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it("should navigate through multiple history entries across remounts", () => {
|
|
132
|
+
const onSubmitDebugger = vi.fn();
|
|
133
|
+
|
|
134
|
+
// First prompt
|
|
135
|
+
const outputs1: WithResponse<OutputMessage>[] = [stdinPrompt("(Pdb) ")];
|
|
136
|
+
|
|
137
|
+
const { rerender } = renderWithProvider(
|
|
138
|
+
<ConsoleOutput
|
|
139
|
+
{...defaultProps}
|
|
140
|
+
consoleOutputs={outputs1}
|
|
141
|
+
onSubmitDebugger={onSubmitDebugger}
|
|
142
|
+
/>,
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
// Submit "step"
|
|
146
|
+
let input = screen.getByTestId("console-input");
|
|
147
|
+
fireEvent.change(input, { target: { value: "step" } });
|
|
148
|
+
fireEvent.keyDown(input, { key: "Enter" });
|
|
149
|
+
|
|
150
|
+
// Second prompt
|
|
151
|
+
const outputs2: WithResponse<OutputMessage>[] = [
|
|
152
|
+
stdinPrompt("(Pdb) ", "step"),
|
|
153
|
+
stdinPrompt("(Pdb) "),
|
|
154
|
+
];
|
|
155
|
+
|
|
156
|
+
rerender(
|
|
157
|
+
<TooltipProvider>
|
|
158
|
+
<ConsoleOutput
|
|
159
|
+
{...defaultProps}
|
|
160
|
+
consoleOutputs={outputs2}
|
|
161
|
+
onSubmitDebugger={onSubmitDebugger}
|
|
162
|
+
/>
|
|
163
|
+
</TooltipProvider>,
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
// Submit "print(x)"
|
|
167
|
+
input = screen.getByTestId("console-input");
|
|
168
|
+
fireEvent.change(input, { target: { value: "print(x)" } });
|
|
169
|
+
fireEvent.keyDown(input, { key: "Enter" });
|
|
170
|
+
|
|
171
|
+
// Third prompt
|
|
172
|
+
const outputs3: WithResponse<OutputMessage>[] = [
|
|
173
|
+
stdinPrompt("(Pdb) ", "step"),
|
|
174
|
+
stdinPrompt("(Pdb) ", "print(x)"),
|
|
175
|
+
stdinPrompt("(Pdb) "),
|
|
176
|
+
];
|
|
177
|
+
|
|
178
|
+
rerender(
|
|
179
|
+
<TooltipProvider>
|
|
180
|
+
<ConsoleOutput
|
|
181
|
+
{...defaultProps}
|
|
182
|
+
consoleOutputs={outputs3}
|
|
183
|
+
onSubmitDebugger={onSubmitDebugger}
|
|
184
|
+
/>
|
|
185
|
+
</TooltipProvider>,
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
// ArrowUp should show most recent command first
|
|
189
|
+
input = screen.getByTestId("console-input");
|
|
190
|
+
fireEvent.keyDown(input, { key: "ArrowUp" });
|
|
191
|
+
expect(input).toHaveValue("print(x)");
|
|
192
|
+
|
|
193
|
+
// ArrowUp again should show older command
|
|
194
|
+
fireEvent.keyDown(input, { key: "ArrowUp" });
|
|
195
|
+
expect(input).toHaveValue("step");
|
|
196
|
+
|
|
197
|
+
// ArrowDown should go back to "print(x)"
|
|
198
|
+
fireEvent.keyDown(input, { key: "ArrowDown" });
|
|
199
|
+
expect(input).toHaveValue("print(x)");
|
|
200
|
+
|
|
201
|
+
// ArrowDown again should return to empty input
|
|
202
|
+
fireEvent.keyDown(input, { key: "ArrowDown" });
|
|
203
|
+
expect(input).toHaveValue("");
|
|
204
|
+
});
|
|
205
|
+
});
|