@marimo-team/frontend 0.19.7-dev31 → 0.19.7-dev33
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/{JsonOutput-CaYsBlIL.js → JsonOutput-Dw_ZIGoz.js} +1 -1
- package/dist/assets/{add-cell-with-ai-DGWXuion.js → add-cell-with-ai-BHgqYu8P.js} +1 -1
- package/dist/assets/{agent-panel-C_CZ3wsS.js → agent-panel-BOEtQvcD.js} +1 -1
- package/dist/assets/{cell-editor-DrfE1YS-.js → cell-editor-Bed2HJRi.js} +1 -1
- package/dist/assets/{chat-display-BIHBJe4Q.js → chat-display-B0625p01.js} +1 -1
- package/dist/assets/{chat-panel-C4V8R2vf.js → chat-panel-CkHdco_X.js} +1 -1
- package/dist/assets/{column-preview-DfgAxcnz.js → column-preview-YJ759JhT.js} +1 -1
- package/dist/assets/{command-palette-D4dxpptj.js → command-palette-c1vQwlGd.js} +1 -1
- package/dist/assets/{dependency-graph-panel-BbRSXJOA.js → dependency-graph-panel-BWvUSpJI.js} +1 -1
- package/dist/assets/{download-Cphyle83.js → download-vBVDTXQk.js} +2 -2
- package/dist/assets/{edit-page-BiEfjNLG.js → edit-page-D-_8Dpee.js} +3 -3
- package/dist/assets/{file-explorer-panel-Dkqk7q5V.js → file-explorer-panel-Bhrg_Wb0.js} +1 -1
- package/dist/assets/hooks-CPM5R4f-.js +1 -0
- package/dist/assets/html-to-image-Cdx1xsbU.js +2 -0
- package/dist/assets/{index-0-J_BSHl.js → index-DL0FpFYQ.js} +3 -3
- package/dist/assets/index-DmMvDRRC.css +2 -0
- package/dist/assets/{layout-BJ9AHITN.js → layout-C50dPCAb.js} +1 -1
- package/dist/assets/{markdown-renderer-aprG4bjs.js → markdown-renderer-DSY-ElEE.js} +1 -1
- package/dist/assets/{panels-DDBrdHNH.js → panels-H0GWZM90.js} +1 -1
- package/dist/assets/{readonly-python-code-BwtDUnWb.js → readonly-python-code-B1UBDfCT.js} +1 -1
- package/dist/assets/{run-page-BS9QQKCJ.js → run-page-CiOYN_zF.js} +1 -1
- package/dist/assets/{scratchpad-panel-_4qqJHnW.js → scratchpad-panel-BiE33kLt.js} +1 -1
- package/dist/assets/{session-panel-sueNTZq5.js → session-panel-DCRBt85z.js} +1 -1
- package/dist/assets/{useAddCell-B7_Lgd-h.js → useAddCell-M6_IuI4C.js} +1 -1
- package/dist/assets/{useCellActionButton-BxQHrbUZ.js → useCellActionButton-Ddy42rre.js} +1 -1
- package/dist/assets/{useDependencyPanelTab-oTszzY42.js → useDependencyPanelTab-RSRpRVKD.js} +1 -1
- package/dist/assets/{useNotebookActions-DFKZ18Bu.js → useNotebookActions-C1MxSBln.js} +1 -1
- package/dist/assets/{utilities.esm-BeoTGe8r.js → utilities.esm-BsBOP1QQ.js} +1 -1
- package/dist/index.html +12 -12
- package/package.json +1 -1
- package/src/components/editor/actions/useNotebookActions.tsx +2 -2
- package/src/core/export/__tests__/hooks.test.ts +72 -33
- package/src/core/export/hooks.ts +17 -8
- package/src/utils/__tests__/download.test.tsx +18 -18
- package/src/utils/download.ts +9 -11
- package/src/utils/html-to-image.ts +139 -0
- package/dist/assets/hooks-COmcm0X5.js +0 -1
- package/dist/assets/html-to-image-DiZMGN_d.js +0 -2
- package/dist/assets/index-DHsXOI_M.css +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as U}from"./chunk-LvLJmgfZ.js";import{d as Y,l as Z,n as V,p as $,u as ee}from"./useEvent-DO6uJBas.js";import{t as te}from"./react-BGmjiNul.js";import{U as le,gt as re}from"./cells-Mf-pdsEh.js";import{t as B}from"./compiler-runtime-DeeZ7FnK.js";import{t as se}from"./jsx-runtime-ZmTK25f3.js";import{t as ae}from"./cn-BKtXLv3a.js";import{t as ne}from"./createLucideIcon-CnW3RofX.js";import{t as oe}from"./useCellActionButton-
|
|
1
|
+
import{s as U}from"./chunk-LvLJmgfZ.js";import{d as Y,l as Z,n as V,p as $,u as ee}from"./useEvent-DO6uJBas.js";import{t as te}from"./react-BGmjiNul.js";import{U as le,gt as re}from"./cells-Mf-pdsEh.js";import{t as B}from"./compiler-runtime-DeeZ7FnK.js";import{t as se}from"./jsx-runtime-ZmTK25f3.js";import{t as ae}from"./cn-BKtXLv3a.js";import{t as ne}from"./createLucideIcon-CnW3RofX.js";import{t as oe}from"./useCellActionButton-Ddy42rre.js";import{a as ie,n as ce,o as me,t as de}from"./tooltip-CEc2ajau.js";import{d as he}from"./alert-dialog-DwQffb13.js";import{i as G,r as pe,t as J}from"./popover-D16ZremR.js";import{a as fe,c as ue,i as xe,o as je,r as be,t as ye,u as ve}from"./command-BmWAYrdT.js";import{n as ge}from"./focus-ay4g-SB6.js";import{a as Ne,i as we}from"./renderShortcut-DHc-p-_c.js";var ke=ne("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),K=B(),p=U(te(),1),t=U(se(),1);const L=p.memo(p.forwardRef((n,l)=>{let e=(0,K.c)(46),{children:r,showTooltip:m,...d}=n,f=m===void 0?!0:m,[h,o]=(0,p.useState)(!1),k;e[0]===o?k=e[1]:(k=()=>o(!1),e[0]=o,e[1]=k);let X=k,A=(0,p.useRef)(null),u=oe({cell:d,closePopover:X}),F=he(),C;e[2]===Symbol.for("react.memo_cache_sentinel")?(C=()=>{le(()=>{A.current&&A.current.scrollIntoView({behavior:"auto",block:"nearest"})})},e[2]=C):C=e[2];let H=V(C),S;e[3]!==H||e[4]!==o?(S=s=>{o(c=>{let w=typeof s=="function"?s(c):s;return w&&H(),w})},e[3]=H,e[4]=o,e[5]=S):S=e[5];let i=V(S),_;e[6]===i?_=e[7]:(_=()=>({toggle:()=>i(Ce)}),e[6]=i,e[7]=_),(0,p.useImperativeHandle)(l,_);let M=pe,O=ye,R=fe,q=re(d.cellId),x;e[8]!==R||e[9]!==q?(x=(0,t.jsx)(R,{placeholder:"Search actions...",className:"h-6 m-1",...q}),e[8]=R,e[9]=q,e[10]=x):x=e[10];let I;e[11]===Symbol.for("react.memo_cache_sentinel")?(I=(0,t.jsx)(be,{children:"No results"}),e[11]=I):I=e[11];let j;if(e[12]!==u||e[13]!==o){let s;e[15]!==u.length||e[16]!==o?(s=(c,w)=>(0,t.jsxs)(p.Fragment,{children:[(0,t.jsx)(xe,{children:c.map(a=>{if(a.redundant)return null;let E=(0,t.jsxs)("div",{className:"flex items-center flex-1",children:[a.icon&&(0,t.jsx)("div",{className:"mr-2 w-5 text-muted-foreground",children:a.icon}),(0,t.jsx)("div",{className:"flex-1",children:a.label}),(0,t.jsxs)("div",{className:"shrink-0 text-sm",children:[a.hotkey&&we(a.hotkey),a.rightElement]})]});return a.tooltip&&(E=(0,t.jsx)(de,{content:a.tooltip,delayDuration:100,children:E})),(0,t.jsx)(je,{className:ae(a.disabled&&"opacity-50!"),onSelect:()=>{a.disableClick||a.disabled||(a.handle(),o(!1))},variant:a.variant,children:E},a.label)})},w),w<u.length-1&&(0,t.jsx)(ue,{})]},w),e[15]=u.length,e[16]=o,e[17]=s):s=e[17],j=u.map(s),e[12]=u,e[13]=o,e[14]=j}else j=e[14];let b;e[18]===j?b=e[19]:(b=(0,t.jsxs)(ve,{children:[I,j]}),e[18]=j,e[19]=b);let y;e[20]!==O||e[21]!==x||e[22]!==b?(y=(0,t.jsxs)(O,{children:[x,b]}),e[20]=O,e[21]=x,e[22]=b,e[23]=y):y=e[23];let T;e[24]!==M||e[25]!==F||e[26]!==y?(T=(0,t.jsx)(M,{className:"w-[300px] p-0 pt-1 overflow-auto",scrollable:!0,...F,children:y}),e[24]=M,e[25]=F,e[26]=y,e[27]=T):T=e[27];let v=T;if(!f){let s;e[28]===r?s=e[29]:(s=(0,t.jsx)(G,{asChild:!0,children:r}),e[28]=r,e[29]=s);let c;return e[30]!==v||e[31]!==i||e[32]!==h||e[33]!==s?(c=(0,t.jsxs)(J,{open:h,onOpenChange:i,children:[s,v]}),e[30]=v,e[31]=i,e[32]=h,e[33]=s,e[34]=c):c=e[34],c}let D;e[35]===Symbol.for("react.memo_cache_sentinel")?(D=(0,t.jsx)(ce,{tabIndex:-1,children:Ne("cell.cellActions")}),e[35]=D):D=e[35];let z=!h&&D,g;e[36]===r?g=e[37]:(g=(0,t.jsx)(me,{ref:A,children:(0,t.jsx)(G,{className:"flex",children:r})}),e[36]=r,e[37]=g);let N;e[38]!==z||e[39]!==g?(N=(0,t.jsxs)(ie,{delayDuration:200,disableHoverableContent:!0,children:[z,g]}),e[38]=z,e[39]=g,e[40]=N):N=e[40];let P;return e[41]!==v||e[42]!==i||e[43]!==h||e[44]!==N?(P=(0,t.jsxs)(J,{open:h,onOpenChange:i,children:[N,v]}),e[41]=v,e[42]=i,e[43]=h,e[44]=N,e[45]=P):P=e[45],P})),Q=p.memo(n=>{let l=(0,K.c)(5),{children:e,cellId:r}=n,m;l[0]===r?m=l[1]:(m=ge(r),l[0]=r,l[1]=m);let d=ee(m);if(!d)return null;let f;return l[2]!==e||l[3]!==d?(f=(0,t.jsx)(L,{showTooltip:!1,...d,children:e}),l[2]=e,l[3]=d,l[4]=f):f=l[4],f});Q.displayName="ConnectionCellActionsDropdown";function Ce(n){return!n}var Se=B();const W=$("minimap");function _e(){let n=(0,Se.c)(3),[l,e]=Z(W),r;return n[0]!==l||n[1]!==e?(r={dependencyPanelTab:l,setDependencyPanelTab:e},n[0]=l,n[1]=e,n[2]=r):r=n[2],r}function Ie(){return Y(W)}export{ke as a,Q as i,Ie as n,L as r,_e as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as de}from"./chunk-LvLJmgfZ.js";import{d as D,l as Oe,p as Be,u as ee}from"./useEvent-DO6uJBas.js";import{t as $e}from"./react-BGmjiNul.js";import{$n as Ue,Gn as Ye,Jn as Fe,Rt as Ge,Un as Je,ai as te,dn as Ke,g as Xe,hn as ce,jt as Ze,ln as Qe,m as he,t as et,un as tt,w as pe,yr as at,zt as me}from"./cells-Mf-pdsEh.js";import{t as W}from"./compiler-runtime-DeeZ7FnK.js";import{n as ot}from"./assertNever-CBU83Y6o.js";import{s as ue}from"./useLifecycle-D35CBukS.js";import{n as nt}from"./add-database-form-DAMSmPZS.js";import{n as it,x as lt}from"./ai-model-dropdown-DxImvtE1.js";import{a as fe,d as P}from"./hotkeys-BHHWjLlp.js";import{y as st}from"./utils-DXvhzCGS.js";import{n as _,t as ye}from"./constants-B6Cb__3x.js";import{A as rt,f as dt,j as ke,w as ct}from"./config-CIrPQIbt.js";import{t as ht}from"./jsx-runtime-ZmTK25f3.js";import{r as pt,t as ae}from"./button-YC1gW_kJ.js";import{r as I}from"./requests-BsVD4CdD.js";import{t as h}from"./createLucideIcon-CnW3RofX.js";import{a as be,f as mt,i as xe,m as ut,p as we,u as ge}from"./layout-BJ9AHITN.js";import{t as je}from"./check-DdfN0k2d.js";import{a as ft,c as yt,i as kt,n as bt,r as xt,s as wt,t as gt}from"./select-V5IdpNiR.js";import{a as jt,n as ve,s as vt,t as Ct,u as Ce}from"./download-Cphyle83.js";import{f as zt}from"./maps-t9yNKYA8.js";import{r as Mt}from"./useCellActionButton-BxQHrbUZ.js";import{t as Wt}from"./copy-CQ15EONK.js";import{t as _t}from"./download-B9SUL40m.js";import{t as At}from"./eye-off-BhExYOph.js";import{t as St}from"./file-plus-corner-Da9I6dgU.js";import{t as Nt}from"./file-Cs1JbsV6.js";import{i as Dt,n as Pt,r as It,t as Et}from"./youtube-8p26v8EM.js";import{n as Tt,t as Ht}from"./house-DhFkiXz7.js";import{n as Lt}from"./play-BPIh-ZEU.js";import{t as qt}from"./link-BsTPF7B0.js";import{r as Rt}from"./input-pAun1m1X.js";import{t as Vt}from"./settings-DOXWMfVd.js";import{y as Ot}from"./textarea-Ddtm_ohJ.js";import{t as Bt}from"./square-C8Tw_XXG.js";import{t as C}from"./use-toast-rmUWldD_.js";import{t as $t}from"./tooltip-CEc2ajau.js";import{a as ze,i as Ut,r as Yt}from"./mode-TsexQOfl.js";import{o as Ft}from"./alert-dialog-DwQffb13.js";import{a as Gt,c as Jt,i as Kt,n as Xt,r as Zt}from"./dialog-CxGKN4C_.js";import{n as oe}from"./ImperativeModal-CUbWEBci.js";import{r as Qt,t as ea}from"./share-CbPtIlnM.js";import{t as $}from"./copy-Bv2DBpIS.js";import{r as ta}from"./useRunCells-BgXbioPv.js";import{a as aa}from"./cell-link-a1r84hCk.js";import{a as Me}from"./renderShortcut-DHc-p-_c.js";import{t as oa}from"./icons-BhEXrzsb.js";import{t as na}from"./links-C-GGaW8R.js";import{r as ia,t as la}from"./hooks-COmcm0X5.js";import{t as We}from"./types-z6Sk3JCV.js";var sa=h("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),ra=h("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),_e=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"}]]),Ae=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"}]]),Se=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"}]]),da=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"}]]),ca=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"}]]),ha=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"}]]),Ne=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"}]]),pa=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"}]]),ma=h("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),De=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"}]]),ua=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"}]]),fa=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"}]]),Pe=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"}]]),Ie=W(),ne=de($e(),1),a=de(ht(),1),U="https://static.marimo.app";const ya=e=>{let t=(0,Ie.c)(25),{onClose:n}=e,[o,l]=(0,ne.useState)(""),{exportAsHTML:r}=I(),s=`${o}-${Math.random().toString(36).slice(2,6)}`,i=`${U}/static/${s}`,d;t[0]!==r||t[1]!==n||t[2]!==s?(d=async v=>{v.preventDefault(),n();let A=await r({download:!1,includeCode:!0,files:mt.INSTANCE.filenames()}),z=C({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${U}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:A,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)(Jt,{children:"Share static notebook"}),t[4]=p):p=t[4];let w;t[5]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsxs)(Gt,{children:[p,(0,a.jsxs)(Zt,{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:U,target:"_blank",children:U}),"."]})]}),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 m;t[7]===o?m=t[8]:(m=(0,a.jsx)(Rt,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:g,required:!0,autoComplete:"off"}),t[7]=o,t[8]=m);let u;t[9]===i?u=t[10]:(u=(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)(ka,{text:i}),(0,a.jsx)("span",{className:"text-primary",children:i})]})]}),t[9]=i,t[10]=u);let f;t[11]!==m||t[12]!==u?(f=(0,a.jsxs)("div",{className:"flex flex-col gap-6 py-4",children:[m,u]}),t[11]=m,t[12]=u,t[13]=f):f=t[13];let y;t[14]===n?y=t[15]:(y=(0,a.jsx)(ae,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),t[14]=n,t[15]=y);let k;t[16]===i?k=t[17]:(k=(0,a.jsx)(ae,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await $(i)},children:"Create"}),t[16]=i,t[17]=k);let b;t[18]!==y||t[19]!==k?(b=(0,a.jsxs)(Kt,{children:[y,k]}),t[18]=y,t[19]=k,t[20]=b):b=t[20];let j;return t[21]!==d||t[22]!==b||t[23]!==f?(j=(0,a.jsx)(Xt,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:d,children:[w,f,b]})}),t[21]=d,t[22]=b,t[23]=f,t[24]=j):j=t[24],j};var ka=e=>{let t=(0,Ie.c)(8),[n,o]=ne.useState(!1),l;t[0]===e.text?l=t[1]:(l=pt.stopPropagation(async p=>{p.preventDefault(),await $(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)(Wt,{size:14,strokeWidth:1.5}),t[2]=s):s=t[2];let i;t[3]===r?i=t[4]:(i=(0,a.jsx)(ae,{"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)($t,{content:"Copied!",open:n,children:i}),t[5]=n,t[6]=i,t[7]=d):d=t[7],d},ba=W();function xa(){let e=document.getElementsByClassName(ye.outputArea);for(let t of e){let n=t.getBoundingClientRect();if(n.bottom>0&&n.top<window.innerHeight){let o=te.findElement(t);if(!o){P.warn("Could not find HTMLCellId for visible output area",t);continue}return{cellId:te.parse(o.id)}}}return P.warn("No visible output area found for scroll anchor"),null}function wa(e){if(!e){P.warn("No scroll anchor provided to restore scroll position");return}let t=document.getElementById(te.create(e.cellId));if(!t){P.warn("Could not find cell element to restore scroll position",e.cellId);return}if(!t.querySelector(`.${ye.outputArea}`)){P.warn("Could not find output area to restore scroll position",e.cellId);return}t.scrollIntoView({block:"start",behavior:"auto"})}function Ee(){let e=(0,ba.c)(2),t=D(ze),n;return e[0]===t?n=e[1]:(n=()=>{let o=xa();t(l=>({mode:Ut(l.mode),cellAnchor:(o==null?void 0:o.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{wa(o)})})},e[0]=t,e[1]=n),n}const Te=Be(!1);var ga=W();const ja=()=>{let e=(0,ga.c)(7),{selectedLayout:t}=be(),{setLayoutView:n}=xe();if(ke()&&!ce("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)(wt,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(yt,{placeholder:"Select a view"})}),e[2]=l):l=e[2];let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)(bt,{children:(0,a.jsxs)(xt,{children:[(0,a.jsx)(ft,{children:"View as"}),We.map(Ca)]})}),e[3]=r):r=e[3];let s;return e[4]!==t||e[5]!==o?(s=(0,a.jsxs)(gt,{"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 va(e){return(0,a.jsx)(He(e),{className:"h-4 w-4"})}function He(e){switch(e){case"vertical":return pa;case"grid":return It;case"slides":return De;default:return ot(e),Bt}}function Le(e){return ue(e)}function Ca(e){return(0,a.jsx)(kt,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[va(e),(0,a.jsx)("span",{children:Le(e)})]})},e)}var za=W();function Ma(e){let t=(0,za.c)(5),{openPrompt:n,closeModal:o}=oe(),{sendCopy:l}=I(),r;return t[0]!==o||t[1]!==n||t[2]!==l||t[3]!==e?(r=()=>{if(!e)return null;let s=Ge.guessDeliminator(e);n({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${me.basename(e)}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:i=>{let d=s.join(me.dirname(e),i);l({source:e,destination:d}).then(()=>{o(),C({title:"Notebook copied",description:"A copy of the notebook has been created."}),na(d)})}})},t[0]=o,t[1]=n,t[2]=l,t[3]=e,t[4]=r):r=t[4],r}const Wa=()=>{let{updateCellConfig:e}=pe(),{saveCellConfig:t}=I();return(0,ne.useCallback)(async()=>{let n=new Ze,o=he(),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=fe.entries(r);if(s.length!==0){await t({configs:r});for(let[i,d]of s)e({cellId:i,config:d})}},[e])};var _a=W();function qe(){let e=(0,_a.c)(4),{openConfirm:t}=oe(),n=D(ct),{sendRestart:o}=I(),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)(Ft,{onClick:async()=>{n({state:rt.CLOSING}),await o(),Qt()},"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(),E=e=>{e==null||e.preventDefault(),e==null||e.stopPropagation()};function Sa(){var se,re;let e=(0,Aa.c)(40),t=aa(),{openModal:n,closeModal:o}=oe(),{toggleApplication:l}=Qe(),{selectedPanel:r}=tt(),[s]=Oe(ze),i=ee(Yt),d=Wa(),[p]=st(),{updateCellConfig:w,undoDeleteCell:g,clearAllCellOutputs:m,addSetupCellIfDoesntExist:u,collapseAllCells:f,expandAllCells:y}=pe(),k=qe(),b=ta(),j=Ma(t),v=D(Te),A=D(it),z=D(lt),{exportAsMarkdown:Y,readCode:S,saveCellConfig:F,updateCellOutputs:G}=I(),J=ee(Xe),K=ee(et),{selectedLayout:X}=be(),{setLayoutView:Z}=xe(),T=Ee(),Q=ia(),H=((se=p.sharing)==null?void 0:se.html)??!0,L=((re=p.sharing)==null?void 0:re.wasm)??!0,q;e[0]===Symbol.for("react.memo_cache_sentinel")?(q=ce("server_side_pdf_export"),e[0]=q):q=e[0];let le=q,R=le||s.mode==="present",Re=Fa,V;e[1]===Symbol.for("react.memo_cache_sentinel")?(V=(0,a.jsx)(_t,{size:14,strokeWidth:1.5}),e[1]=V):V=e[1];let O;e[2]===Symbol.for("react.memo_cache_sentinel")?(O=(0,a.jsx)(we,{size:14,strokeWidth:1.5}),e[2]=O):O=e[2];let M;e[3]===t?M=e[4]:(M=async()=>{if(!t){ie();return}await ge({filename:t,includeCode:!0})},e[3]=t,e[4]=M);let B;return e[5]!==u||e[6]!==K||e[7]!==m||e[8]!==o||e[9]!==f||e[10]!==j||e[11]!==y||e[12]!==Y||e[13]!==t||e[14]!==J||e[15]!==d||e[16]!==i||e[17]!==n||e[18]!==R||e[19]!==S||e[20]!==k||e[21]!==b||e[22]!==F||e[23]!==X||e[24]!==r||e[25]!==v||e[26]!==z||e[27]!==Z||e[28]!==A||e[29]!==H||e[30]!==L||e[31]!==M||e[32]!==Q||e[33]!==l||e[34]!==T||e[35]!==g||e[36]!==w||e[37]!==G||e[38]!==s.mode?(B=[{icon:V,label:"Download",handle:E,dropdown:[{icon:O,label:"Download as HTML",handle:M},{icon:(0,a.jsx)(we,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{if(!t){ie();return}await ge({filename:t,includeCode:!1})}},{icon:(0,a.jsx)(oa,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{let c=await Y({download:!1});ve(new Blob([c],{type:"text/plain"}),Ce.toMarkdown(document.title))}},{icon:(0,a.jsx)(ut,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let c=await S();ve(new Blob([c.contents],{type:"text/plain"}),Ce.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: ",Me("global.hideCode",!1)]}),handle:Ya},{icon:(0,a.jsx)(Nt,{size:14,strokeWidth:1.5}),label:"Download as PDF",disabled:!R,tooltip:R?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",Me("global.hideCode",!1)]}),handle:async()=>{if(le){if(!t){ie();return}await vt("Downloading PDF...",async N=>{await la({progress:N,takeScreenshots:Q,updateCellOutputs:G}),await Ct({filename:t,webpdf:!1})});return}let c=new Event("export-beforeprint"),x=new Event("export-afterprint");(function(){window.dispatchEvent(c),setTimeout(Ua,0),setTimeout(()=>window.dispatchEvent(x),0)})()}}]},{icon:(0,a.jsx)(ua,{size:14,strokeWidth:1.5}),label:"Share",handle:E,hidden:!H&&!L,dropdown:[{icon:(0,a.jsx)(Tt,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!H,handle:async()=>{n((0,a.jsx)(ya,{onClose:o}))}},{icon:(0,a.jsx)(qt,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!L,handle:async()=>{await $(ea({code:(await S()).contents})),C({title:"Copied",description:"Link copied to clipboard."})}}]},{icon:(0,a.jsx)(ma,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:E,dropdown:Ke.flatMap(c=>{let{type:x,Icon:N,hidden:Ve}=c;return Ve?[]:{label:ue(x),rightElement:Re(r===x),icon:(0,a.jsx)(N,{size:14,strokeWidth:1.5}),handle:()=>l(x)}})},{icon:(0,a.jsx)(De,{size:14,strokeWidth:1.5}),label:"Present as",handle:E,dropdown:[{icon:s.mode==="present"?(0,a.jsx)(Ot,{size:14,strokeWidth:1.5}):(0,a.jsx)(Ne,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{T()}},...We.map((c,x)=>{let N=He(c);return{divider:x===0,label:Le(c),icon:(0,a.jsx)(N,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:X===c&&(0,a.jsx)(je,{size:14})}),handle:()=>{Z(c),s.mode==="edit"&&T()}}})]},{icon:(0,a.jsx)(ca,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!t||ke(),handle:j},{icon:(0,a.jsx)(_e,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!t,handle:async()=>{await $((await S()).contents),C({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(Mt,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!J||i,handle:async()=>{let c=at(he());await F({configs:fe.fromEntries(c.map($a))});for(let x of c)w({cellId:x,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)(Se,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{u({})}},{icon:(0,a.jsx)(Ye,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n((0,a.jsx)(nt,{onClose:o}))}},{icon:(0,a.jsx)(Pe,{size:14,strokeWidth:1.5}),label:"Undo cell deletion",hidden:!K||i,handle:()=>{g()}},{icon:(0,a.jsx)(fa,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:k},{icon:(0,a.jsx)(da,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{b()}},{icon:(0,a.jsx)(Fe,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{m()}},{icon:(0,a.jsx)(At,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:d,redundant:!0},{icon:(0,a.jsx)(ra,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:f,redundant:!0},{icon:(0,a.jsx)(sa,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:y,redundant:!0},{divider:!0,icon:(0,a.jsx)(Ae,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>v(Ba)},{icon:(0,a.jsx)(ha,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>z(Oa)},{icon:(0,a.jsx)(Vt,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>A(Va),redundant:!0},{icon:(0,a.jsx)(zt,{size:14,strokeWidth:1.5}),label:"Resources",handle:E,dropdown:[{icon:(0,a.jsx)(Ue,{size:14,strokeWidth:1.5}),label:"Documentation",handle:Ra},{icon:(0,a.jsx)(Dt,{size:14,strokeWidth:1.5}),label:"GitHub",handle:qa},{icon:(0,a.jsx)(Pt,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:La},{icon:(0,a.jsx)(Et,{size:14,strokeWidth:1.5}),label:"YouTube",handle:Ha},{icon:(0,a.jsx)(Je,{size:14,strokeWidth:1.5}),label:"Changelog",handle:Ta}]},{divider:!0,icon:(0,a.jsx)(Ht,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:Ea},{icon:(0,a.jsx)(St,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:Ia}].filter(Pa).map(Na),e[5]=u,e[6]=K,e[7]=m,e[8]=o,e[9]=f,e[10]=j,e[11]=y,e[12]=Y,e[13]=t,e[14]=J,e[15]=d,e[16]=i,e[17]=n,e[18]=R,e[19]=S,e[20]=k,e[21]=b,e[22]=F,e[23]=X,e[24]=r,e[25]=v,e[26]=z,e[27]=Z,e[28]=A,e[29]=H,e[30]=L,e[31]=M,e[32]=Q,e[33]=l,e[34]=T,e[35]=g,e[36]=w,e[37]=G,e[38]=s.mode,e[39]=B):B=e[39],B}function Na(e){return e.dropdown?{...e,dropdown:e.dropdown.filter(Da)}:e}function Da(e){return!e.hidden}function Pa(e){return!e.hidden}function Ia(){let e=dt();window.open(e,"_blank")}function Ea(){let e=document.baseURI.split("?")[0];window.open(e,"_self")}function Ta(){window.open(_.releasesPage,"_blank")}function Ha(){window.open(_.youtube,"_blank")}function La(){window.open(_.discordLink,"_blank")}function qa(){window.open(_.githubPage,"_blank")}function Ra(){window.open(_.docsPage,"_blank")}function Va(e){return!e}function Oa(e){return!e}function Ba(e){return!e}function $a(e){return[e,{disabled:!1}]}function Ua(){return window.print()}async function Ya(){let e=document.getElementById("App");e&&await jt({element:e,filename:document.title})}function Fa(e){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:e&&(0,a.jsx)(je,{size:14})})}function ie(){C({title:"Error",description:"Notebooks must be named to be exported.",variant:"danger"})}export{Ee as a,Se as c,Te as i,Ae as l,qe as n,Pe as o,ja as r,Ne as s,Sa as t,_e as u};
|
|
1
|
+
import{s as de}from"./chunk-LvLJmgfZ.js";import{d as D,l as Oe,p as Be,u as ee}from"./useEvent-DO6uJBas.js";import{t as $e}from"./react-BGmjiNul.js";import{$n as Ue,Gn as Ye,Jn as Fe,Rt as Ge,Un as Je,ai as te,dn as Ke,g as Xe,hn as ce,jt as Ze,ln as Qe,m as he,t as et,un as tt,w as pe,yr as at,zt as me}from"./cells-Mf-pdsEh.js";import{t as W}from"./compiler-runtime-DeeZ7FnK.js";import{n as ot}from"./assertNever-CBU83Y6o.js";import{s as ue}from"./useLifecycle-D35CBukS.js";import{n as nt}from"./add-database-form-DAMSmPZS.js";import{n as it,x as lt}from"./ai-model-dropdown-DxImvtE1.js";import{a as fe,d as P}from"./hotkeys-BHHWjLlp.js";import{y as st}from"./utils-DXvhzCGS.js";import{n as _,t as ye}from"./constants-B6Cb__3x.js";import{A as rt,f as dt,j as ke,w as ct}from"./config-CIrPQIbt.js";import{t as ht}from"./jsx-runtime-ZmTK25f3.js";import{r as pt,t as ae}from"./button-YC1gW_kJ.js";import{r as I}from"./requests-BsVD4CdD.js";import{t as h}from"./createLucideIcon-CnW3RofX.js";import{a as be,f as mt,i as xe,m as ut,p as we,u as ge}from"./layout-C50dPCAb.js";import{t as je}from"./check-DdfN0k2d.js";import{a as ft,c as yt,i as kt,n as bt,r as xt,s as wt,t as gt}from"./select-V5IdpNiR.js";import{a as jt,n as ve,s as vt,t as Ct,u as Ce}from"./download-vBVDTXQk.js";import{f as zt}from"./maps-t9yNKYA8.js";import{r as Mt}from"./useCellActionButton-Ddy42rre.js";import{t as Wt}from"./copy-CQ15EONK.js";import{t as _t}from"./download-B9SUL40m.js";import{t as At}from"./eye-off-BhExYOph.js";import{t as St}from"./file-plus-corner-Da9I6dgU.js";import{t as Nt}from"./file-Cs1JbsV6.js";import{i as Dt,n as Pt,r as It,t as Et}from"./youtube-8p26v8EM.js";import{n as Tt,t as Ht}from"./house-DhFkiXz7.js";import{n as Lt}from"./play-BPIh-ZEU.js";import{t as qt}from"./link-BsTPF7B0.js";import{r as Rt}from"./input-pAun1m1X.js";import{t as Vt}from"./settings-DOXWMfVd.js";import{y as Ot}from"./textarea-Ddtm_ohJ.js";import{t as Bt}from"./square-C8Tw_XXG.js";import{t as C}from"./use-toast-rmUWldD_.js";import{t as $t}from"./tooltip-CEc2ajau.js";import{a as ze,i as Ut,r as Yt}from"./mode-TsexQOfl.js";import{o as Ft}from"./alert-dialog-DwQffb13.js";import{a as Gt,c as Jt,i as Kt,n as Xt,r as Zt}from"./dialog-CxGKN4C_.js";import{n as oe}from"./ImperativeModal-CUbWEBci.js";import{r as Qt,t as ea}from"./share-CbPtIlnM.js";import{t as $}from"./copy-Bv2DBpIS.js";import{r as ta}from"./useRunCells-BgXbioPv.js";import{a as aa}from"./cell-link-a1r84hCk.js";import{a as Me}from"./renderShortcut-DHc-p-_c.js";import{t as oa}from"./icons-BhEXrzsb.js";import{t as na}from"./links-C-GGaW8R.js";import{r as ia,t as la}from"./hooks-CPM5R4f-.js";import{t as We}from"./types-z6Sk3JCV.js";var sa=h("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),ra=h("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),_e=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"}]]),Ae=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"}]]),Se=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"}]]),da=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"}]]),ca=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"}]]),ha=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"}]]),Ne=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"}]]),pa=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"}]]),ma=h("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),De=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"}]]),ua=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"}]]),fa=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"}]]),Pe=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"}]]),Ie=W(),ne=de($e(),1),a=de(ht(),1),U="https://static.marimo.app";const ya=e=>{let t=(0,Ie.c)(25),{onClose:n}=e,[o,l]=(0,ne.useState)(""),{exportAsHTML:r}=I(),s=`${o}-${Math.random().toString(36).slice(2,6)}`,i=`${U}/static/${s}`,d;t[0]!==r||t[1]!==n||t[2]!==s?(d=async v=>{v.preventDefault(),n();let A=await r({download:!1,includeCode:!0,files:mt.INSTANCE.filenames()}),z=C({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${U}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:A,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)(Jt,{children:"Share static notebook"}),t[4]=p):p=t[4];let w;t[5]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsxs)(Gt,{children:[p,(0,a.jsxs)(Zt,{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:U,target:"_blank",children:U}),"."]})]}),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 m;t[7]===o?m=t[8]:(m=(0,a.jsx)(Rt,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:g,required:!0,autoComplete:"off"}),t[7]=o,t[8]=m);let u;t[9]===i?u=t[10]:(u=(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)(ka,{text:i}),(0,a.jsx)("span",{className:"text-primary",children:i})]})]}),t[9]=i,t[10]=u);let f;t[11]!==m||t[12]!==u?(f=(0,a.jsxs)("div",{className:"flex flex-col gap-6 py-4",children:[m,u]}),t[11]=m,t[12]=u,t[13]=f):f=t[13];let y;t[14]===n?y=t[15]:(y=(0,a.jsx)(ae,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),t[14]=n,t[15]=y);let k;t[16]===i?k=t[17]:(k=(0,a.jsx)(ae,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await $(i)},children:"Create"}),t[16]=i,t[17]=k);let b;t[18]!==y||t[19]!==k?(b=(0,a.jsxs)(Kt,{children:[y,k]}),t[18]=y,t[19]=k,t[20]=b):b=t[20];let j;return t[21]!==d||t[22]!==b||t[23]!==f?(j=(0,a.jsx)(Xt,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:d,children:[w,f,b]})}),t[21]=d,t[22]=b,t[23]=f,t[24]=j):j=t[24],j};var ka=e=>{let t=(0,Ie.c)(8),[n,o]=ne.useState(!1),l;t[0]===e.text?l=t[1]:(l=pt.stopPropagation(async p=>{p.preventDefault(),await $(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)(Wt,{size:14,strokeWidth:1.5}),t[2]=s):s=t[2];let i;t[3]===r?i=t[4]:(i=(0,a.jsx)(ae,{"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)($t,{content:"Copied!",open:n,children:i}),t[5]=n,t[6]=i,t[7]=d):d=t[7],d},ba=W();function xa(){let e=document.getElementsByClassName(ye.outputArea);for(let t of e){let n=t.getBoundingClientRect();if(n.bottom>0&&n.top<window.innerHeight){let o=te.findElement(t);if(!o){P.warn("Could not find HTMLCellId for visible output area",t);continue}return{cellId:te.parse(o.id)}}}return P.warn("No visible output area found for scroll anchor"),null}function wa(e){if(!e){P.warn("No scroll anchor provided to restore scroll position");return}let t=document.getElementById(te.create(e.cellId));if(!t){P.warn("Could not find cell element to restore scroll position",e.cellId);return}if(!t.querySelector(`.${ye.outputArea}`)){P.warn("Could not find output area to restore scroll position",e.cellId);return}t.scrollIntoView({block:"start",behavior:"auto"})}function Ee(){let e=(0,ba.c)(2),t=D(ze),n;return e[0]===t?n=e[1]:(n=()=>{let o=xa();t(l=>({mode:Ut(l.mode),cellAnchor:(o==null?void 0:o.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{wa(o)})})},e[0]=t,e[1]=n),n}const Te=Be(!1);var ga=W();const ja=()=>{let e=(0,ga.c)(7),{selectedLayout:t}=be(),{setLayoutView:n}=xe();if(ke()&&!ce("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)(wt,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(yt,{placeholder:"Select a view"})}),e[2]=l):l=e[2];let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)(bt,{children:(0,a.jsxs)(xt,{children:[(0,a.jsx)(ft,{children:"View as"}),We.map(Ca)]})}),e[3]=r):r=e[3];let s;return e[4]!==t||e[5]!==o?(s=(0,a.jsxs)(gt,{"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 va(e){return(0,a.jsx)(He(e),{className:"h-4 w-4"})}function He(e){switch(e){case"vertical":return pa;case"grid":return It;case"slides":return De;default:return ot(e),Bt}}function Le(e){return ue(e)}function Ca(e){return(0,a.jsx)(kt,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[va(e),(0,a.jsx)("span",{children:Le(e)})]})},e)}var za=W();function Ma(e){let t=(0,za.c)(5),{openPrompt:n,closeModal:o}=oe(),{sendCopy:l}=I(),r;return t[0]!==o||t[1]!==n||t[2]!==l||t[3]!==e?(r=()=>{if(!e)return null;let s=Ge.guessDeliminator(e);n({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${me.basename(e)}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:i=>{let d=s.join(me.dirname(e),i);l({source:e,destination:d}).then(()=>{o(),C({title:"Notebook copied",description:"A copy of the notebook has been created."}),na(d)})}})},t[0]=o,t[1]=n,t[2]=l,t[3]=e,t[4]=r):r=t[4],r}const Wa=()=>{let{updateCellConfig:e}=pe(),{saveCellConfig:t}=I();return(0,ne.useCallback)(async()=>{let n=new Ze,o=he(),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=fe.entries(r);if(s.length!==0){await t({configs:r});for(let[i,d]of s)e({cellId:i,config:d})}},[e])};var _a=W();function qe(){let e=(0,_a.c)(4),{openConfirm:t}=oe(),n=D(ct),{sendRestart:o}=I(),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)(Ft,{onClick:async()=>{n({state:rt.CLOSING}),await o(),Qt()},"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(),E=e=>{e==null||e.preventDefault(),e==null||e.stopPropagation()};function Sa(){var se,re;let e=(0,Aa.c)(40),t=aa(),{openModal:n,closeModal:o}=oe(),{toggleApplication:l}=Qe(),{selectedPanel:r}=tt(),[s]=Oe(ze),i=ee(Yt),d=Wa(),[p]=st(),{updateCellConfig:w,undoDeleteCell:g,clearAllCellOutputs:m,addSetupCellIfDoesntExist:u,collapseAllCells:f,expandAllCells:y}=pe(),k=qe(),b=ta(),j=Ma(t),v=D(Te),A=D(it),z=D(lt),{exportAsMarkdown:Y,readCode:S,saveCellConfig:F,updateCellOutputs:G}=I(),J=ee(Xe),K=ee(et),{selectedLayout:X}=be(),{setLayoutView:Z}=xe(),T=Ee(),Q=ia(),H=((se=p.sharing)==null?void 0:se.html)??!0,L=((re=p.sharing)==null?void 0:re.wasm)??!0,q;e[0]===Symbol.for("react.memo_cache_sentinel")?(q=ce("server_side_pdf_export"),e[0]=q):q=e[0];let le=q,R=le||s.mode==="present",Re=Fa,V;e[1]===Symbol.for("react.memo_cache_sentinel")?(V=(0,a.jsx)(_t,{size:14,strokeWidth:1.5}),e[1]=V):V=e[1];let O;e[2]===Symbol.for("react.memo_cache_sentinel")?(O=(0,a.jsx)(we,{size:14,strokeWidth:1.5}),e[2]=O):O=e[2];let M;e[3]===t?M=e[4]:(M=async()=>{if(!t){ie();return}await ge({filename:t,includeCode:!0})},e[3]=t,e[4]=M);let B;return e[5]!==u||e[6]!==K||e[7]!==m||e[8]!==o||e[9]!==f||e[10]!==j||e[11]!==y||e[12]!==Y||e[13]!==t||e[14]!==J||e[15]!==d||e[16]!==i||e[17]!==n||e[18]!==R||e[19]!==S||e[20]!==k||e[21]!==b||e[22]!==F||e[23]!==X||e[24]!==r||e[25]!==v||e[26]!==z||e[27]!==Z||e[28]!==A||e[29]!==H||e[30]!==L||e[31]!==M||e[32]!==Q||e[33]!==l||e[34]!==T||e[35]!==g||e[36]!==w||e[37]!==G||e[38]!==s.mode?(B=[{icon:V,label:"Download",handle:E,dropdown:[{icon:O,label:"Download as HTML",handle:M},{icon:(0,a.jsx)(we,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{if(!t){ie();return}await ge({filename:t,includeCode:!1})}},{icon:(0,a.jsx)(oa,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{let c=await Y({download:!1});ve(new Blob([c],{type:"text/plain"}),Ce.toMarkdown(document.title))}},{icon:(0,a.jsx)(ut,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let c=await S();ve(new Blob([c.contents],{type:"text/plain"}),Ce.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: ",Me("global.hideCode",!1)]}),handle:Ya},{icon:(0,a.jsx)(Nt,{size:14,strokeWidth:1.5}),label:"Download as PDF",disabled:!R,tooltip:R?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",Me("global.hideCode",!1)]}),handle:async()=>{if(le){if(!t){ie();return}await vt("Downloading PDF...",async N=>{await la({takeScreenshots:()=>Q({progress:N,snappy:!1}),updateCellOutputs:G}),await Ct({filename:t,webpdf:!1})});return}let c=new Event("export-beforeprint"),x=new Event("export-afterprint");(function(){window.dispatchEvent(c),setTimeout(Ua,0),setTimeout(()=>window.dispatchEvent(x),0)})()}}]},{icon:(0,a.jsx)(ua,{size:14,strokeWidth:1.5}),label:"Share",handle:E,hidden:!H&&!L,dropdown:[{icon:(0,a.jsx)(Tt,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!H,handle:async()=>{n((0,a.jsx)(ya,{onClose:o}))}},{icon:(0,a.jsx)(qt,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!L,handle:async()=>{await $(ea({code:(await S()).contents})),C({title:"Copied",description:"Link copied to clipboard."})}}]},{icon:(0,a.jsx)(ma,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:E,dropdown:Ke.flatMap(c=>{let{type:x,Icon:N,hidden:Ve}=c;return Ve?[]:{label:ue(x),rightElement:Re(r===x),icon:(0,a.jsx)(N,{size:14,strokeWidth:1.5}),handle:()=>l(x)}})},{icon:(0,a.jsx)(De,{size:14,strokeWidth:1.5}),label:"Present as",handle:E,dropdown:[{icon:s.mode==="present"?(0,a.jsx)(Ot,{size:14,strokeWidth:1.5}):(0,a.jsx)(Ne,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{T()}},...We.map((c,x)=>{let N=He(c);return{divider:x===0,label:Le(c),icon:(0,a.jsx)(N,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:X===c&&(0,a.jsx)(je,{size:14})}),handle:()=>{Z(c),s.mode==="edit"&&T()}}})]},{icon:(0,a.jsx)(ca,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!t||ke(),handle:j},{icon:(0,a.jsx)(_e,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!t,handle:async()=>{await $((await S()).contents),C({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(Mt,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!J||i,handle:async()=>{let c=at(he());await F({configs:fe.fromEntries(c.map($a))});for(let x of c)w({cellId:x,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)(Se,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{u({})}},{icon:(0,a.jsx)(Ye,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n((0,a.jsx)(nt,{onClose:o}))}},{icon:(0,a.jsx)(Pe,{size:14,strokeWidth:1.5}),label:"Undo cell deletion",hidden:!K||i,handle:()=>{g()}},{icon:(0,a.jsx)(fa,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:k},{icon:(0,a.jsx)(da,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{b()}},{icon:(0,a.jsx)(Fe,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{m()}},{icon:(0,a.jsx)(At,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:d,redundant:!0},{icon:(0,a.jsx)(ra,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:f,redundant:!0},{icon:(0,a.jsx)(sa,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:y,redundant:!0},{divider:!0,icon:(0,a.jsx)(Ae,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>v(Ba)},{icon:(0,a.jsx)(ha,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>z(Oa)},{icon:(0,a.jsx)(Vt,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>A(Va),redundant:!0},{icon:(0,a.jsx)(zt,{size:14,strokeWidth:1.5}),label:"Resources",handle:E,dropdown:[{icon:(0,a.jsx)(Ue,{size:14,strokeWidth:1.5}),label:"Documentation",handle:Ra},{icon:(0,a.jsx)(Dt,{size:14,strokeWidth:1.5}),label:"GitHub",handle:qa},{icon:(0,a.jsx)(Pt,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:La},{icon:(0,a.jsx)(Et,{size:14,strokeWidth:1.5}),label:"YouTube",handle:Ha},{icon:(0,a.jsx)(Je,{size:14,strokeWidth:1.5}),label:"Changelog",handle:Ta}]},{divider:!0,icon:(0,a.jsx)(Ht,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:Ea},{icon:(0,a.jsx)(St,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:Ia}].filter(Pa).map(Na),e[5]=u,e[6]=K,e[7]=m,e[8]=o,e[9]=f,e[10]=j,e[11]=y,e[12]=Y,e[13]=t,e[14]=J,e[15]=d,e[16]=i,e[17]=n,e[18]=R,e[19]=S,e[20]=k,e[21]=b,e[22]=F,e[23]=X,e[24]=r,e[25]=v,e[26]=z,e[27]=Z,e[28]=A,e[29]=H,e[30]=L,e[31]=M,e[32]=Q,e[33]=l,e[34]=T,e[35]=g,e[36]=w,e[37]=G,e[38]=s.mode,e[39]=B):B=e[39],B}function Na(e){return e.dropdown?{...e,dropdown:e.dropdown.filter(Da)}:e}function Da(e){return!e.hidden}function Pa(e){return!e.hidden}function Ia(){let e=dt();window.open(e,"_blank")}function Ea(){let e=document.baseURI.split("?")[0];window.open(e,"_self")}function Ta(){window.open(_.releasesPage,"_blank")}function Ha(){window.open(_.youtube,"_blank")}function La(){window.open(_.discordLink,"_blank")}function qa(){window.open(_.githubPage,"_blank")}function Ra(){window.open(_.docsPage,"_blank")}function Va(e){return!e}function Oa(e){return!e}function Ba(e){return!e}function $a(e){return[e,{disabled:!1}]}function Ua(){return window.print()}async function Ya(){let e=document.getElementById("App");e&&await jt({element:e,filename:document.title})}function Fa(e){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:e&&(0,a.jsx)(je,{size:14})})}function ie(){C({title:"Error",description:"Notebooks must be named to be exported.",variant:"danger"})}export{Ee as a,Se as c,Te as i,Ae as l,qe as n,Pe as o,ja as r,Ne as s,Sa as t,_e as u};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var it=Object.defineProperty;var ot=(t,e,n)=>e in t?it(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var a=(t,e,n)=>ot(t,typeof e!="symbol"?e+"":e,n);var M;import{s as ce}from"./chunk-LvLJmgfZ.js";import{i as Q,l as D,o as lt,p as q,u as ut}from"./useEvent-DO6uJBas.js";import{t as ct}from"./react-BGmjiNul.js";import{Wr as dt,Xr as ft,b as mt,ni as z,ti as pt,y as ht}from"./cells-Mf-pdsEh.js";import{B as gt,C as de,D as yt,I as bt,N as wt,P as O,R as fe,k as W,w as me}from"./zod-Cg4WLWh2.js";import{t as pe}from"./compiler-runtime-DeeZ7FnK.js";import{t as vt}from"./get-6uJrSKbw.js";import{t as xt}from"./assertNever-CBU83Y6o.js";import{t as Et}from"./debounce-B3mjKxHe.js";import{t as _t}from"./_baseSet-5Rdwpmr3.js";import{d as E,p as y}from"./hotkeys-BHHWjLlp.js";import{t as Ct}from"./invariant-CAG_dYON.js";import{S as kt}from"./utils-DXvhzCGS.js";import{j as Ft}from"./config-CIrPQIbt.js";import{a as Rt}from"./switch-NTEWSiVz.js";import{n as he}from"./globals-Du9rkBEf.js";import{t as ge}from"./ErrorBoundary-ChCiwl15.js";import{t as Nt}from"./jsx-runtime-ZmTK25f3.js";import{t as St}from"./button-YC1gW_kJ.js";import{t as qt}from"./cn-BKtXLv3a.js";import{Z as Pt}from"./JsonOutput-CaYsBlIL.js";import{t as jt}from"./createReducer-Dnna-AUO.js";import{t as ye}from"./requests-BsVD4CdD.js";import{t as be}from"./createLucideIcon-CnW3RofX.js";import{h as Mt}from"./select-V5IdpNiR.js";import{a as At,l as Tt,r as It}from"./markdown-renderer-aprG4bjs.js";import{t as Lt}from"./DeferredRequestRegistry-CO2AyNfd.js";import{t as K}from"./Deferred-CrO5-0RA.js";import{t as we}from"./uuid-DercMavo.js";import{t as Ut}from"./use-toast-rmUWldD_.js";import{t as ve}from"./tooltip-CEc2ajau.js";import{t as xe}from"./mode-TsexQOfl.js";import{n as zt,r as Ot,t as Wt}from"./share-CbPtIlnM.js";import{r as Dt,t as Ht}from"./react-resizable-panels.browser.esm-Ctj_10o2.js";import{t as Ee}from"./toggle-jWKnIArU.js";function Bt(t,e,n){return t==null?t:_t(t,e,n)}var H=Bt,Vt=be("crosshair",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]]),Xt=be("pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);function $t(t){return{all:t||(t=new Map),on:function(e,n){var r=t.get(e);r?r.push(n):t.set(e,[n])},off:function(e,n){var r=t.get(e);r&&(n?r.splice(r.indexOf(n)>>>0,1):t.set(e,[]))},emit:function(e,n){var r=t.get(e);r&&r.slice().map(function(s){s(n)}),(r=t.get("*"))&&r.slice().map(function(s){s(e,n)})}}}var u=ce(ct(),1),Z=(0,u.createContext)(null),Yt=t=>{let{controller:e}=(0,u.useContext)(Z),n=u.useRef(Symbol("fill"));return(0,u.useEffect)(()=>(e.mount({name:t.name,ref:n.current,children:t.children}),()=>{e.unmount({name:t.name,ref:n.current})}),[]),(0,u.useEffect)(()=>{e.update({name:t.name,ref:n.current,children:t.children})}),null},Gt=Object.defineProperty,Qt=(t,e,n)=>e in t?Gt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,_e=(t,e,n)=>(Qt(t,typeof e=="symbol"?e:e+"",n),n),Ce=console,Kt=class{constructor(t){_e(this,"_bus"),_e(this,"_db"),this._bus=t,this.handleFillMount=this.handleFillMount.bind(this),this.handleFillUpdated=this.handleFillUpdated.bind(this),this.handleFillUnmount=this.handleFillUnmount.bind(this),this._db={byName:new Map,byFill:new Map}}mount(){this._bus.on("fill-mount",this.handleFillMount),this._bus.on("fill-updated",this.handleFillUpdated),this._bus.on("fill-unmount",this.handleFillUnmount)}unmount(){this._bus.off("fill-mount",this.handleFillMount),this._bus.off("fill-updated",this.handleFillUpdated),this._bus.off("fill-unmount",this.handleFillUnmount)}handleFillMount({fill:t}){let e=u.Children.toArray(t.children),n=t.name,r={fill:t,children:e,name:n},s=this._db.byName.get(n);s?(s.components.push(r),s.listeners.forEach(i=>i([...s.components]))):this._db.byName.set(n,{listeners:[],components:[r]}),this._db.byFill.set(t.ref,r)}handleFillUpdated({fill:t}){let e=this._db.byFill.get(t.ref),n=u.Children.toArray(t.children);if(e){e.children=n;let r=this._db.byName.get(e.name);if(r)r.listeners.forEach(s=>s([...r.components]));else throw Error("registration was expected to be defined")}else{Ce.error("[handleFillUpdated] component was expected to be defined");return}}handleFillUnmount({fill:t}){let e=this._db.byFill.get(t.ref);if(!e){Ce.error("[handleFillUnmount] component was expected to be defined");return}let n=e.name,r=this._db.byName.get(n);if(!r)throw Error("registration was expected to be defined");r.components=r.components.filter(s=>s!==e),this._db.byFill.delete(t.ref),r.listeners.length===0&&r.components.length===0?this._db.byName.delete(n):r.listeners.forEach(s=>s([...r.components]))}onComponentsChange(t,e){let n=this._db.byName.get(t);n?(n.listeners.push(e),e(n.components)):(this._db.byName.set(t,{listeners:[e],components:[]}),e([]))}getFillsByName(t){let e=this._db.byName.get(t);return e?e.components.map(n=>n.fill):[]}getChildrenByName(t){let e=this._db.byName.get(t);return e?e.components.map(n=>n.children).reduce((n,r)=>n.concat(r),[]):[]}removeOnComponentsChange(t,e){let n=this._db.byName.get(t);if(!n)throw Error("expected registration to be defined");let r=n.listeners;r.splice(r.indexOf(e),1)}},Zt=Object.defineProperty,Jt=(t,e,n)=>e in t?Zt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,en=(t,e,n)=>(Jt(t,typeof e=="symbol"?e:e+"",n),n),ke=class{constructor(){en(this,"bus",$t())}mount(t){this.bus.emit("fill-mount",{fill:t})}unmount(t){this.bus.emit("fill-unmount",{fill:t})}update(t){this.bus.emit("fill-updated",{fill:t})}};function tn(t){let e=t||new ke;return{controller:e,manager:new Kt(e.bus)}}var nn=({controller:t,children:e})=>{let[n]=u.useState(()=>{let r=tn(t);return r.manager.mount(),r});return u.useEffect(()=>()=>{n.manager.unmount()},[]),u.createElement(Z.Provider,{value:n},e)};function J(t,e){let[n,r]=(0,u.useState)([]),{manager:s}=(0,u.useContext)(Z);return(0,u.useEffect)(()=>(s.onComponentsChange(t,r),()=>{s.removeOnComponentsChange(t,r)}),[t]),n.flatMap((i,d)=>{let{children:l}=i;return l.map((p,b)=>{if(typeof p=="number"||typeof p=="string")throw Error("Only element children will work here");return u.cloneElement(p,{key:d.toString()+b.toString(),...e})})})}var Fe=t=>{let e=J(t.name,t.childProps);if(typeof t.children=="function"){let n=t.children(e);if(u.isValidElement(n)||n===null)return n;throw Error("Slot rendered with function must return a valid React Element.")}return e};const rn=q(null);var{valueAtom:sn,useActions:an}=jt(()=>({banners:[]}),{addBanner:(t,e)=>({...t,banners:[...t.banners,{...e,id:we()}]}),removeBanner:(t,e)=>({...t,banners:t.banners.filter(n=>n.id!==e)}),clearBanners:t=>({...t,banners:[]})});const on=()=>ut(sn);function ln(){return an()}const un=new ke,B={SIDEBAR:"sidebar",CONTEXT_AWARE_PANEL:"context-aware-panel"};var cn=class{constructor(){a(this,"subscriptions",new Map)}addSubscription(t,e){var n;this.subscriptions.has(t)||this.subscriptions.set(t,new Set),(n=this.subscriptions.get(t))==null||n.add(e)}removeSubscription(t,e){var n;(n=this.subscriptions.get(t))==null||n.delete(e)}notify(t,e){for(let n of this.subscriptions.get(t)??[])n(e)}},Re=class ue{constructor(e){a(this,"subscriptions",new cn);this.producer=e}static withProducerCallback(e){return new ue(e)}static empty(){return new ue}startProducer(){this.producer&&this.producer(e=>{this.subscriptions.notify("message",e)})}connect(){return new Promise(e=>setTimeout(e,0)).then(()=>{this.subscriptions.notify("open",new Event("open"))})}get readyState(){return WebSocket.OPEN}reconnect(e,n){this.close(),this.connect()}close(){this.subscriptions.notify("close",new Event("close"))}send(e){return this.subscriptions.notify("message",new MessageEvent("message",{data:e})),Promise.resolve()}addEventListener(e,n){this.subscriptions.addSubscription(e,n),e==="open"&&n(new Event("open")),e==="message"&&this.startProducer()}removeEventListener(e,n){this.subscriptions.removeSubscription(e,n)}},dn=1e10,fn=1e3;function V(t,e){let n=t.map(r=>`"${r}"`).join(", ");return Error(`This RPC instance cannot ${e} because the transport did not provide one or more of these methods: ${n}`)}function mn(t={}){let e={};function n(o){e=o}let r={};function s(o){var f;r.unregisterHandler&&r.unregisterHandler(),r=o,(f=r.registerHandler)==null||f.call(r,U)}let i;function d(o){if(typeof o=="function"){i=o;return}i=(f,g)=>{let c=o[f];if(c)return c(g);let h=o._;if(!h)throw Error(`The requested method has no handler: ${f}`);return h(f,g)}}let{maxRequestTime:l=fn}=t;t.transport&&s(t.transport),t.requestHandler&&d(t.requestHandler),t._debugHooks&&n(t._debugHooks);let p=0;function b(){return p<=dn?++p:p=0}let x=new Map,w=new Map;function _(o,...f){let g=f[0];return new Promise((c,h)=>{var T;if(!r.send)throw V(["send"],"make requests");let S=b(),j={type:"request",id:S,method:o,params:g};x.set(S,{resolve:c,reject:h}),l!==1/0&&w.set(S,setTimeout(()=>{w.delete(S),h(Error("RPC request timed out."))},l)),(T=e.onSend)==null||T.call(e,j),r.send(j)})}let R=new Proxy(_,{get:(o,f,g)=>f in o?Reflect.get(o,f,g):c=>_(f,c)}),C=R;function k(o,...f){var h;let g=f[0];if(!r.send)throw V(["send"],"send messages");let c={type:"message",id:o,payload:g};(h=e.onSend)==null||h.call(e,c),r.send(c)}let F=new Proxy(k,{get:(o,f,g)=>f in o?Reflect.get(o,f,g):c=>k(f,c)}),v=F,N=new Map,P=new Set;function A(o,f){var g;if(!r.registerHandler)throw V(["registerHandler"],"register message listeners");if(o==="*"){P.add(f);return}N.has(o)||N.set(o,new Set),(g=N.get(o))==null||g.add(f)}function L(o,f){var g,c;if(o==="*"){P.delete(f);return}(g=N.get(o))==null||g.delete(f),((c=N.get(o))==null?void 0:c.size)===0&&N.delete(o)}async function U(o){var f,g;if((f=e.onReceive)==null||f.call(e,o),!("type"in o))throw Error("Message does not contain a type.");if(o.type==="request"){if(!r.send||!i)throw V(["send","requestHandler"],"handle requests");let{id:c,method:h,params:S}=o,j;try{j={type:"response",id:c,success:!0,payload:await i(h,S)}}catch(T){if(!(T instanceof Error))throw T;j={type:"response",id:c,success:!1,error:T.message}}(g=e.onSend)==null||g.call(e,j),r.send(j);return}if(o.type==="response"){let c=w.get(o.id);c!=null&&clearTimeout(c);let{resolve:h,reject:S}=x.get(o.id)??{};o.success?h==null||h(o.payload):S==null||S(Error(o.error));return}if(o.type==="message"){for(let h of P)h(o.id,o.payload);let c=N.get(o.id);if(!c)return;for(let h of c)h(o.payload);return}throw Error(`Unexpected RPC message type: ${o.type}`)}return{setTransport:s,setRequestHandler:d,request:R,requestProxy:C,send:F,sendProxy:v,addMessageListener:A,removeMessageListener:L,proxy:{send:v,request:C},_setDebugHooks:n}}function pn(t){return mn(t)}var Ne="[transport-id]";function hn(t,e){let{transportId:n}=e;return n==null?t:{[Ne]:n,data:t}}function gn(t,e){let{transportId:n,filter:r}=e,s=r==null?void 0:r();if(n!=null&&s!=null)throw Error("Cannot use both `transportId` and `filter` at the same time");let i=t;if(n){if(t[Ne]!==n)return[!0];i=t.data}return s===!1?[!0]:[!1,i]}function yn(t,e={}){let{transportId:n,filter:r,remotePort:s}=e,i=t,d=s??t,l;return{send(p){d.postMessage(hn(p,{transportId:n}))},registerHandler(p){l=b=>{let x=b.data,[w,_]=gn(x,{transportId:n,filter:()=>r==null?void 0:r(b)});w||p(_)},i.addEventListener("message",l)},unregisterHandler(){l&&i.removeEventListener("message",l)}}}function bn(t,e){return yn(t,e)}function Se(t){return pn({transport:bn(t,{transportId:"marimo-transport"}),maxRequestTime:2e4,_debugHooks:{onSend:e=>{E.debug("[rpc] Parent -> Worker",e)},onReceive:e=>{E.debug("[rpc] Worker -> Parent",e)}}})}const qe=q("Initializing..."),wn=q(t=>{let e=t(ht),n=Object.values(e.cellRuntime);return n.some(r=>!Tt(r.output))?!0:n.every(r=>r.status==="idle")});var Pe=zt(),je="marimo:file",Me=new dt(null);const vn={saveFile(t){Me.set(je,t)},readFile(){return Me.get(je)}};var xn={saveFile(t){z.setCodeForHash((0,Pe.compressToEncodedURIComponent)(t))},readFile(){let t=z.getCodeFromHash()||z.getCodeFromSearchParam();return t?(0,Pe.decompressFromEncodedURIComponent)(t):null}};const En={saveFile(t){},readFile(){let t=document.querySelector("marimo-code");return t?decodeURIComponent(t.textContent||"").trim():null}};var _n={saveFile(t){},readFile(){if(window.location.hostname!=="marimo.app")return null;let t=new URL("files/wasm-intro.py",document.baseURI);return fetch(t.toString()).then(e=>e.ok?e.text():null).catch(()=>null)}},Cn={saveFile(t){},readFile(){return["import marimo","app = marimo.App()","","@app.cell","def __():"," return","",'if __name__ == "__main__":'," app.run()"].join(`
|
|
1
|
+
var it=Object.defineProperty;var ot=(t,e,n)=>e in t?it(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var a=(t,e,n)=>ot(t,typeof e!="symbol"?e+"":e,n);var M;import{s as ce}from"./chunk-LvLJmgfZ.js";import{i as Q,l as D,o as lt,p as q,u as ut}from"./useEvent-DO6uJBas.js";import{t as ct}from"./react-BGmjiNul.js";import{Wr as dt,Xr as ft,b as mt,ni as z,ti as pt,y as ht}from"./cells-Mf-pdsEh.js";import{B as gt,C as de,D as yt,I as bt,N as wt,P as O,R as fe,k as W,w as me}from"./zod-Cg4WLWh2.js";import{t as pe}from"./compiler-runtime-DeeZ7FnK.js";import{t as vt}from"./get-6uJrSKbw.js";import{t as xt}from"./assertNever-CBU83Y6o.js";import{t as Et}from"./debounce-B3mjKxHe.js";import{t as _t}from"./_baseSet-5Rdwpmr3.js";import{d as E,p as y}from"./hotkeys-BHHWjLlp.js";import{t as Ct}from"./invariant-CAG_dYON.js";import{S as kt}from"./utils-DXvhzCGS.js";import{j as Ft}from"./config-CIrPQIbt.js";import{a as Rt}from"./switch-NTEWSiVz.js";import{n as he}from"./globals-Du9rkBEf.js";import{t as ge}from"./ErrorBoundary-ChCiwl15.js";import{t as Nt}from"./jsx-runtime-ZmTK25f3.js";import{t as St}from"./button-YC1gW_kJ.js";import{t as qt}from"./cn-BKtXLv3a.js";import{Z as Pt}from"./JsonOutput-Dw_ZIGoz.js";import{t as jt}from"./createReducer-Dnna-AUO.js";import{t as ye}from"./requests-BsVD4CdD.js";import{t as be}from"./createLucideIcon-CnW3RofX.js";import{h as Mt}from"./select-V5IdpNiR.js";import{a as At,l as Tt,r as It}from"./markdown-renderer-DSY-ElEE.js";import{t as Lt}from"./DeferredRequestRegistry-CO2AyNfd.js";import{t as K}from"./Deferred-CrO5-0RA.js";import{t as we}from"./uuid-DercMavo.js";import{t as Ut}from"./use-toast-rmUWldD_.js";import{t as ve}from"./tooltip-CEc2ajau.js";import{t as xe}from"./mode-TsexQOfl.js";import{n as zt,r as Ot,t as Wt}from"./share-CbPtIlnM.js";import{r as Dt,t as Ht}from"./react-resizable-panels.browser.esm-Ctj_10o2.js";import{t as Ee}from"./toggle-jWKnIArU.js";function Bt(t,e,n){return t==null?t:_t(t,e,n)}var H=Bt,Vt=be("crosshair",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]]),Xt=be("pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);function $t(t){return{all:t||(t=new Map),on:function(e,n){var r=t.get(e);r?r.push(n):t.set(e,[n])},off:function(e,n){var r=t.get(e);r&&(n?r.splice(r.indexOf(n)>>>0,1):t.set(e,[]))},emit:function(e,n){var r=t.get(e);r&&r.slice().map(function(s){s(n)}),(r=t.get("*"))&&r.slice().map(function(s){s(e,n)})}}}var u=ce(ct(),1),Z=(0,u.createContext)(null),Yt=t=>{let{controller:e}=(0,u.useContext)(Z),n=u.useRef(Symbol("fill"));return(0,u.useEffect)(()=>(e.mount({name:t.name,ref:n.current,children:t.children}),()=>{e.unmount({name:t.name,ref:n.current})}),[]),(0,u.useEffect)(()=>{e.update({name:t.name,ref:n.current,children:t.children})}),null},Gt=Object.defineProperty,Qt=(t,e,n)=>e in t?Gt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,_e=(t,e,n)=>(Qt(t,typeof e=="symbol"?e:e+"",n),n),Ce=console,Kt=class{constructor(t){_e(this,"_bus"),_e(this,"_db"),this._bus=t,this.handleFillMount=this.handleFillMount.bind(this),this.handleFillUpdated=this.handleFillUpdated.bind(this),this.handleFillUnmount=this.handleFillUnmount.bind(this),this._db={byName:new Map,byFill:new Map}}mount(){this._bus.on("fill-mount",this.handleFillMount),this._bus.on("fill-updated",this.handleFillUpdated),this._bus.on("fill-unmount",this.handleFillUnmount)}unmount(){this._bus.off("fill-mount",this.handleFillMount),this._bus.off("fill-updated",this.handleFillUpdated),this._bus.off("fill-unmount",this.handleFillUnmount)}handleFillMount({fill:t}){let e=u.Children.toArray(t.children),n=t.name,r={fill:t,children:e,name:n},s=this._db.byName.get(n);s?(s.components.push(r),s.listeners.forEach(i=>i([...s.components]))):this._db.byName.set(n,{listeners:[],components:[r]}),this._db.byFill.set(t.ref,r)}handleFillUpdated({fill:t}){let e=this._db.byFill.get(t.ref),n=u.Children.toArray(t.children);if(e){e.children=n;let r=this._db.byName.get(e.name);if(r)r.listeners.forEach(s=>s([...r.components]));else throw Error("registration was expected to be defined")}else{Ce.error("[handleFillUpdated] component was expected to be defined");return}}handleFillUnmount({fill:t}){let e=this._db.byFill.get(t.ref);if(!e){Ce.error("[handleFillUnmount] component was expected to be defined");return}let n=e.name,r=this._db.byName.get(n);if(!r)throw Error("registration was expected to be defined");r.components=r.components.filter(s=>s!==e),this._db.byFill.delete(t.ref),r.listeners.length===0&&r.components.length===0?this._db.byName.delete(n):r.listeners.forEach(s=>s([...r.components]))}onComponentsChange(t,e){let n=this._db.byName.get(t);n?(n.listeners.push(e),e(n.components)):(this._db.byName.set(t,{listeners:[e],components:[]}),e([]))}getFillsByName(t){let e=this._db.byName.get(t);return e?e.components.map(n=>n.fill):[]}getChildrenByName(t){let e=this._db.byName.get(t);return e?e.components.map(n=>n.children).reduce((n,r)=>n.concat(r),[]):[]}removeOnComponentsChange(t,e){let n=this._db.byName.get(t);if(!n)throw Error("expected registration to be defined");let r=n.listeners;r.splice(r.indexOf(e),1)}},Zt=Object.defineProperty,Jt=(t,e,n)=>e in t?Zt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,en=(t,e,n)=>(Jt(t,typeof e=="symbol"?e:e+"",n),n),ke=class{constructor(){en(this,"bus",$t())}mount(t){this.bus.emit("fill-mount",{fill:t})}unmount(t){this.bus.emit("fill-unmount",{fill:t})}update(t){this.bus.emit("fill-updated",{fill:t})}};function tn(t){let e=t||new ke;return{controller:e,manager:new Kt(e.bus)}}var nn=({controller:t,children:e})=>{let[n]=u.useState(()=>{let r=tn(t);return r.manager.mount(),r});return u.useEffect(()=>()=>{n.manager.unmount()},[]),u.createElement(Z.Provider,{value:n},e)};function J(t,e){let[n,r]=(0,u.useState)([]),{manager:s}=(0,u.useContext)(Z);return(0,u.useEffect)(()=>(s.onComponentsChange(t,r),()=>{s.removeOnComponentsChange(t,r)}),[t]),n.flatMap((i,d)=>{let{children:l}=i;return l.map((p,b)=>{if(typeof p=="number"||typeof p=="string")throw Error("Only element children will work here");return u.cloneElement(p,{key:d.toString()+b.toString(),...e})})})}var Fe=t=>{let e=J(t.name,t.childProps);if(typeof t.children=="function"){let n=t.children(e);if(u.isValidElement(n)||n===null)return n;throw Error("Slot rendered with function must return a valid React Element.")}return e};const rn=q(null);var{valueAtom:sn,useActions:an}=jt(()=>({banners:[]}),{addBanner:(t,e)=>({...t,banners:[...t.banners,{...e,id:we()}]}),removeBanner:(t,e)=>({...t,banners:t.banners.filter(n=>n.id!==e)}),clearBanners:t=>({...t,banners:[]})});const on=()=>ut(sn);function ln(){return an()}const un=new ke,B={SIDEBAR:"sidebar",CONTEXT_AWARE_PANEL:"context-aware-panel"};var cn=class{constructor(){a(this,"subscriptions",new Map)}addSubscription(t,e){var n;this.subscriptions.has(t)||this.subscriptions.set(t,new Set),(n=this.subscriptions.get(t))==null||n.add(e)}removeSubscription(t,e){var n;(n=this.subscriptions.get(t))==null||n.delete(e)}notify(t,e){for(let n of this.subscriptions.get(t)??[])n(e)}},Re=class ue{constructor(e){a(this,"subscriptions",new cn);this.producer=e}static withProducerCallback(e){return new ue(e)}static empty(){return new ue}startProducer(){this.producer&&this.producer(e=>{this.subscriptions.notify("message",e)})}connect(){return new Promise(e=>setTimeout(e,0)).then(()=>{this.subscriptions.notify("open",new Event("open"))})}get readyState(){return WebSocket.OPEN}reconnect(e,n){this.close(),this.connect()}close(){this.subscriptions.notify("close",new Event("close"))}send(e){return this.subscriptions.notify("message",new MessageEvent("message",{data:e})),Promise.resolve()}addEventListener(e,n){this.subscriptions.addSubscription(e,n),e==="open"&&n(new Event("open")),e==="message"&&this.startProducer()}removeEventListener(e,n){this.subscriptions.removeSubscription(e,n)}},dn=1e10,fn=1e3;function V(t,e){let n=t.map(r=>`"${r}"`).join(", ");return Error(`This RPC instance cannot ${e} because the transport did not provide one or more of these methods: ${n}`)}function mn(t={}){let e={};function n(o){e=o}let r={};function s(o){var f;r.unregisterHandler&&r.unregisterHandler(),r=o,(f=r.registerHandler)==null||f.call(r,U)}let i;function d(o){if(typeof o=="function"){i=o;return}i=(f,g)=>{let c=o[f];if(c)return c(g);let h=o._;if(!h)throw Error(`The requested method has no handler: ${f}`);return h(f,g)}}let{maxRequestTime:l=fn}=t;t.transport&&s(t.transport),t.requestHandler&&d(t.requestHandler),t._debugHooks&&n(t._debugHooks);let p=0;function b(){return p<=dn?++p:p=0}let x=new Map,w=new Map;function _(o,...f){let g=f[0];return new Promise((c,h)=>{var T;if(!r.send)throw V(["send"],"make requests");let S=b(),j={type:"request",id:S,method:o,params:g};x.set(S,{resolve:c,reject:h}),l!==1/0&&w.set(S,setTimeout(()=>{w.delete(S),h(Error("RPC request timed out."))},l)),(T=e.onSend)==null||T.call(e,j),r.send(j)})}let R=new Proxy(_,{get:(o,f,g)=>f in o?Reflect.get(o,f,g):c=>_(f,c)}),C=R;function k(o,...f){var h;let g=f[0];if(!r.send)throw V(["send"],"send messages");let c={type:"message",id:o,payload:g};(h=e.onSend)==null||h.call(e,c),r.send(c)}let F=new Proxy(k,{get:(o,f,g)=>f in o?Reflect.get(o,f,g):c=>k(f,c)}),v=F,N=new Map,P=new Set;function A(o,f){var g;if(!r.registerHandler)throw V(["registerHandler"],"register message listeners");if(o==="*"){P.add(f);return}N.has(o)||N.set(o,new Set),(g=N.get(o))==null||g.add(f)}function L(o,f){var g,c;if(o==="*"){P.delete(f);return}(g=N.get(o))==null||g.delete(f),((c=N.get(o))==null?void 0:c.size)===0&&N.delete(o)}async function U(o){var f,g;if((f=e.onReceive)==null||f.call(e,o),!("type"in o))throw Error("Message does not contain a type.");if(o.type==="request"){if(!r.send||!i)throw V(["send","requestHandler"],"handle requests");let{id:c,method:h,params:S}=o,j;try{j={type:"response",id:c,success:!0,payload:await i(h,S)}}catch(T){if(!(T instanceof Error))throw T;j={type:"response",id:c,success:!1,error:T.message}}(g=e.onSend)==null||g.call(e,j),r.send(j);return}if(o.type==="response"){let c=w.get(o.id);c!=null&&clearTimeout(c);let{resolve:h,reject:S}=x.get(o.id)??{};o.success?h==null||h(o.payload):S==null||S(Error(o.error));return}if(o.type==="message"){for(let h of P)h(o.id,o.payload);let c=N.get(o.id);if(!c)return;for(let h of c)h(o.payload);return}throw Error(`Unexpected RPC message type: ${o.type}`)}return{setTransport:s,setRequestHandler:d,request:R,requestProxy:C,send:F,sendProxy:v,addMessageListener:A,removeMessageListener:L,proxy:{send:v,request:C},_setDebugHooks:n}}function pn(t){return mn(t)}var Ne="[transport-id]";function hn(t,e){let{transportId:n}=e;return n==null?t:{[Ne]:n,data:t}}function gn(t,e){let{transportId:n,filter:r}=e,s=r==null?void 0:r();if(n!=null&&s!=null)throw Error("Cannot use both `transportId` and `filter` at the same time");let i=t;if(n){if(t[Ne]!==n)return[!0];i=t.data}return s===!1?[!0]:[!1,i]}function yn(t,e={}){let{transportId:n,filter:r,remotePort:s}=e,i=t,d=s??t,l;return{send(p){d.postMessage(hn(p,{transportId:n}))},registerHandler(p){l=b=>{let x=b.data,[w,_]=gn(x,{transportId:n,filter:()=>r==null?void 0:r(b)});w||p(_)},i.addEventListener("message",l)},unregisterHandler(){l&&i.removeEventListener("message",l)}}}function bn(t,e){return yn(t,e)}function Se(t){return pn({transport:bn(t,{transportId:"marimo-transport"}),maxRequestTime:2e4,_debugHooks:{onSend:e=>{E.debug("[rpc] Parent -> Worker",e)},onReceive:e=>{E.debug("[rpc] Worker -> Parent",e)}}})}const qe=q("Initializing..."),wn=q(t=>{let e=t(ht),n=Object.values(e.cellRuntime);return n.some(r=>!Tt(r.output))?!0:n.every(r=>r.status==="idle")});var Pe=zt(),je="marimo:file",Me=new dt(null);const vn={saveFile(t){Me.set(je,t)},readFile(){return Me.get(je)}};var xn={saveFile(t){z.setCodeForHash((0,Pe.compressToEncodedURIComponent)(t))},readFile(){let t=z.getCodeFromHash()||z.getCodeFromSearchParam();return t?(0,Pe.decompressFromEncodedURIComponent)(t):null}};const En={saveFile(t){},readFile(){let t=document.querySelector("marimo-code");return t?decodeURIComponent(t.textContent||"").trim():null}};var _n={saveFile(t){},readFile(){if(window.location.hostname!=="marimo.app")return null;let t=new URL("files/wasm-intro.py",document.baseURI);return fetch(t.toString()).then(e=>e.ok?e.text():null).catch(()=>null)}},Cn={saveFile(t){},readFile(){return["import marimo","app = marimo.App()","","@app.cell","def __():"," return","",'if __name__ == "__main__":'," app.run()"].join(`
|
|
2
2
|
`)}},Ae=class{constructor(t){this.stores=t}insert(t,e){this.stores.splice(t,0,e)}saveFile(t){this.stores.forEach(e=>e.saveFile(t))}readFile(){for(let t of this.stores){let e=t.readFile();if(e)return e}return null}};const X=new Ae([En,xn]),ee=new Ae([vn,_n,Cn]);var Te=class st{constructor(){a(this,"initialized",new K);a(this,"sendRename",async({filename:e})=>(e===null||(z.setFilename(e),await this.rpc.proxy.request.bridge({functionName:"rename_file",payload:e})),null));a(this,"sendSave",async e=>{if(!this.saveRpc)return E.warn("Save RPC not initialized"),null;await this.saveRpc.saveNotebook(e);let n=await this.readCode();return n.contents&&(X.saveFile(n.contents),ee.saveFile(n.contents)),this.rpc.proxy.request.saveNotebook(e).catch(r=>{E.error(r)}),null});a(this,"sendCopy",async()=>{y()});a(this,"sendStdin",async e=>(await this.rpc.proxy.request.bridge({functionName:"put_input",payload:e.text}),null));a(this,"sendPdb",async()=>{y()});a(this,"sendRun",async e=>(await this.rpc.proxy.request.loadPackages(e.codes.join(`
|
|
3
3
|
`)),await this.putControlRequest({type:"execute-cells",...e}),null));a(this,"sendRunScratchpad",async e=>(await this.rpc.proxy.request.loadPackages(e.code),await this.putControlRequest({type:"execute-scratchpad",...e}),null));a(this,"sendInterrupt",async()=>(this.interruptBuffer!==void 0&&(this.interruptBuffer[0]=2),null));a(this,"sendShutdown",async()=>(window.close(),null));a(this,"sendFormat",async e=>await this.rpc.proxy.request.bridge({functionName:"format",payload:e}));a(this,"sendDeleteCell",async e=>(await this.putControlRequest({type:"delete-cell",...e}),null));a(this,"sendInstallMissingPackages",async e=>(this.putControlRequest({type:"install-packages",...e}),null));a(this,"sendCodeCompletionRequest",async e=>(Q.get(mt)||await this.rpc.proxy.request.bridge({functionName:"code_complete",payload:e}),null));a(this,"saveUserConfig",async e=>(await this.rpc.proxy.request.bridge({functionName:"save_user_config",payload:e}),Rt.post("/kernel/save_user_config",e,{baseUrl:"/"}).catch(n=>(E.error(n),null))));a(this,"saveAppConfig",async e=>(await this.rpc.proxy.request.bridge({functionName:"save_app_config",payload:e}),null));a(this,"saveCellConfig",async e=>(await this.putControlRequest({type:"update-cell-config",...e}),null));a(this,"sendRestart",async()=>{let e=await this.readCode();return e.contents&&(X.saveFile(e.contents),ee.saveFile(e.contents)),Ot(),null});a(this,"readCode",async()=>this.saveRpc?{contents:await this.saveRpc.readNotebook()}:(E.warn("Save RPC not initialized"),{contents:""}));a(this,"readSnippets",async()=>await this.rpc.proxy.request.bridge({functionName:"read_snippets",payload:void 0}));a(this,"openFile",async({path:e})=>{let n=Wt({code:null,baseUrl:window.location.origin});return window.open(n,"_blank"),null});a(this,"sendListFiles",async e=>await this.rpc.proxy.request.bridge({functionName:"list_files",payload:e}));a(this,"sendSearchFiles",async e=>await this.rpc.proxy.request.bridge({functionName:"search_files",payload:e}));a(this,"sendComponentValues",async e=>(await this.putControlRequest({type:"update-ui-element",...e,token:we()}),null));a(this,"sendInstantiate",async e=>null);a(this,"sendFunctionRequest",async e=>(await this.putControlRequest({type:"invoke-function",...e}),null));a(this,"sendCreateFileOrFolder",async e=>await this.rpc.proxy.request.bridge({functionName:"create_file_or_directory",payload:e}));a(this,"sendDeleteFileOrFolder",async e=>await this.rpc.proxy.request.bridge({functionName:"delete_file_or_directory",payload:e}));a(this,"sendRenameFileOrFolder",async e=>await this.rpc.proxy.request.bridge({functionName:"move_file_or_directory",payload:e}));a(this,"sendUpdateFile",async e=>await this.rpc.proxy.request.bridge({functionName:"update_file",payload:e}));a(this,"sendFileDetails",async e=>await this.rpc.proxy.request.bridge({functionName:"file_details",payload:e}));a(this,"exportAsHTML",async e=>await this.rpc.proxy.request.bridge({functionName:"export_html",payload:e}));a(this,"exportAsMarkdown",async e=>await this.rpc.proxy.request.bridge({functionName:"export_markdown",payload:e}));a(this,"previewDatasetColumn",async e=>(await this.putControlRequest({type:"preview-dataset-column",...e}),null));a(this,"previewSQLTable",async e=>(await this.putControlRequest({type:"preview-sql-table",...e}),null));a(this,"previewSQLTableList",async e=>(await this.putControlRequest({type:"list-sql-tables",...e}),null));a(this,"previewDataSourceConnection",async e=>(await this.putControlRequest({type:"list-data-source-connection",...e}),null));a(this,"validateSQL",async e=>(await this.putControlRequest({type:"validate-sql",...e}),null));a(this,"sendModelValue",async e=>(await this.putControlRequest({type:"update-widget-model",...e}),null));a(this,"syncCellIds",()=>Promise.resolve(null));a(this,"addPackage",async e=>this.rpc.proxy.request.addPackage(e));a(this,"removePackage",async e=>this.rpc.proxy.request.removePackage(e));a(this,"getPackageList",async()=>await this.rpc.proxy.request.listPackages());a(this,"getDependencyTree",async()=>({tree:{dependencies:[],name:"",tags:[],version:null}}));a(this,"listSecretKeys",async e=>(await this.putControlRequest({type:"list-secret-keys",...e}),null));a(this,"getUsageStats",y);a(this,"openTutorial",y);a(this,"getRecentFiles",y);a(this,"getWorkspaceFiles",y);a(this,"getRunningNotebooks",y);a(this,"shutdownSession",y);a(this,"exportAsPDF",y);a(this,"autoExportAsHTML",y);a(this,"autoExportAsMarkdown",y);a(this,"autoExportAsIPYNB",y);a(this,"updateCellOutputs",y);a(this,"writeSecret",y);a(this,"invokeAiTool",y);a(this,"clearCache",y);a(this,"getCacheInfo",y);Ft()&&(this.rpc=Se(new Worker(new URL(""+new URL("worker-CUL1lW-N.js",import.meta.url).href,""+import.meta.url),{type:"module",name:he()})),this.rpc.addMessageListener("ready",()=>{this.startSession()}),this.rpc.addMessageListener("initialized",()=>{this.saveRpc=this.getSaveWorker(),this.setInterruptBuffer(),this.initialized.resolve()}),this.rpc.addMessageListener("initializingMessage",({message:e})=>{Q.set(qe,e)}),this.rpc.addMessageListener("initializedError",({error:e})=>{this.initialized.status==="resolved"&&(E.error(e),Ut({title:"Error initializing",description:e,variant:"danger"})),this.initialized.reject(Error(e))}),this.rpc.addMessageListener("kernelMessage",({message:e})=>{var n;(n=this.messageConsumer)==null||n.call(this,new MessageEvent("message",{data:e}))}))}static get INSTANCE(){let e="_marimo_private_PyodideBridge";return window[e]||(window[e]=new st),window[e]}getSaveWorker(){return xe()==="read"?(E.debug("Skipping SaveWorker in read-mode"),{readFile:y,readNotebook:y,saveNotebook:y}):Se(new Worker(new URL(""+new URL("save-worker-DtF6B3PS.js",import.meta.url).href,""+import.meta.url),{type:"module",name:he()})).proxy.request}async startSession(){let e=await X.readFile(),n=await ee.readFile(),r=z.getFilename(),s=Q.get(kt),i={},d=new URLSearchParams(window.location.search);for(let l of d.keys()){let p=d.getAll(l);i[l]=p.length===1?p[0]:p}await this.rpc.proxy.request.startSession({queryParameters:i,code:e||n||"",filename:r,userConfig:{...s,runtime:{...s.runtime,auto_instantiate:xe()==="read"?!0:s.runtime.auto_instantiate}}})}setInterruptBuffer(){crossOriginIsolated?(this.interruptBuffer=new Uint8Array(new SharedArrayBuffer(1)),this.rpc.proxy.request.setInterruptBuffer(this.interruptBuffer)):E.warn("Not running in a secure context; interrupts are not available.")}attachMessageConsumer(e){this.messageConsumer=e,this.rpc.proxy.send.consumerReady({})}async putControlRequest(e){await this.rpc.proxy.request.bridge({functionName:"put_control_request",payload:e})}};function kn(){return Re.withProducerCallback(t=>{Te.INSTANCE.attachMessageConsumer(t)})}const Ie=q({isInstantiated:!1,error:null});function Fn(){return lt(Ie,t=>t.isInstantiated)}function $(t){return()=>({TYPE:t,is(e){return e.type===t},create(e){return new CustomEvent(t,e)}})}const Le=$("marimo-value-input")(),Ue=$("marimo-value-update")(),ze=$("marimo-value-ready")(),Oe=$("marimo-incoming-message")();function Rn(t,e){return Le.create({bubbles:!0,composed:!0,detail:{value:t,element:e}})}var We=class at{static get INSTANCE(){let e="_marimo_private_UIElementRegistry";return window[e]||(window[e]=new at),window[e]}constructor(){this.entries=new Map}has(e){return this.entries.has(e)}set(e,n){if(this.entries.has(e))throw Error(`UIElement ${e} already registered`);this.entries.set(e,{objectId:e,value:n,elements:new Set})}registerInstance(e,n){let r=this.entries.get(e);r===void 0?this.entries.set(e,{objectId:e,value:pt(n,this),elements:new Set([n])}):r.elements.add(n)}removeInstance(e,n){let r=this.entries.get(e);r!=null&&r.elements.has(n)&&r.elements.delete(n)}removeElementsByCell(e){[...this.entries.keys()].filter(n=>n.startsWith(`${e}-`)).forEach(n=>{this.entries.delete(n)})}lookupValue(e){let n=this.entries.get(e);return n===void 0?void 0:n.value}broadcastMessage(e,n,r){let s=this.entries.get(e);s===void 0?E.warn("UIElementRegistry missing entry",e):s.elements.forEach(i=>{i.dispatchEvent(Oe.create({bubbles:!1,composed:!0,detail:{objectId:e,message:n,buffers:r}}))})}broadcastValueUpdate(e,n,r){let s=this.entries.get(n);s===void 0?E.warn("UIElementRegistry missing entry",n):(s.value=r,s.elements.forEach(i=>{i!==e&&i.dispatchEvent(Ue.create({bubbles:!1,composed:!0,detail:{value:r,element:i}}))}),document.dispatchEvent(ze.create({bubbles:!0,composed:!0,detail:{objectId:n}})))}};const Nn=We.INSTANCE,Sn=new Lt("function-call-result",async(t,e)=>{await ye().sendFunctionRequest({functionCallId:t,...e})}),qn="68px";var Pn="288px";const jn=t=>t?/^\d+$/.test(t)?`${t}px`:t:Pn,Mn=ft({isOpen:!0},(t,e)=>{if(!e)return t;switch(e.type){case"toggle":return{...t,isOpen:e.isOpen??t.isOpen};case"setWidth":return{...t,width:e.width};default:return t}});function te(t,e=[]){let n=[];if(t instanceof DataView)n.push(e);else if(Array.isArray(t))for(let[r,s]of t.entries())n.push(...te(s,[...e,r]));else if(typeof t=="object"&&t)for(let[r,s]of Object.entries(t))n.push(...te(s,[...e,r]));return n}function ne(t){let e=te(t);if(e.length===0)return{state:t,buffers:[],bufferPaths:[]};let n=structuredClone(t),r=[],s=[];for(let i of e){let d=vt(t,i);if(d instanceof DataView){let l=At(d);r.push(l),s.push(i),H(n,i,l)}}return{state:n,buffers:r,bufferPaths:s}}function An(t){return typeof t=="object"&&!!t&&"state"in t&&"bufferPaths"in t&&"buffers"in t}function Y(t){let{state:e,bufferPaths:n,buffers:r}=t;if(!n||n.length===0)return e;r&&Ct(r.length===n.length,"Buffers and buffer paths not the same length");let s=structuredClone(e);for(let[i,d]of n.entries()){let l=r==null?void 0:r[i];if(l==null){E.warn("[anywidget] Could not find buffer at path",d);continue}typeof l=="string"?H(s,d,It(l)):H(s,d,l)}return s}const De=new class{constructor(t=1e4){a(this,"models",new Map);this.timeout=t}get(t){let e=this.models.get(t);return e||(e=new K,this.models.set(t,e),setTimeout(()=>{e.status==="pending"&&(e.reject(Error(`Model not found for key: ${t}`)),this.models.delete(t))},this.timeout)),e.promise}set(t,e){let n=this.models.get(t);n||(n=new K,this.models.set(t,n)),n.resolve(e)}delete(t){this.models.delete(t)}};var He=(M=class{constructor(e,n,r,s){a(this,"ANY_CHANGE_EVENT","change");a(this,"listeners",{});a(this,"widget_manager",{async get_model(e){let n=await M._modelManager.get(e);if(!n)throw Error(`Model not found with id: ${e}. This is likely because the model was not registered.`);return n}});a(this,"emitAnyChange",Et(()=>{var e;(e=this.listeners[this.ANY_CHANGE_EVENT])==null||e.forEach(n=>n())},0));this.data=e,this.onChange=n,this.sendToWidget=r,this.dirtyFields=new Map([...s].map(i=>[i,this.data[i]]))}off(e,n){var r;if(!e){this.listeners={};return}if(!n){this.listeners[e]=new Set;return}(r=this.listeners[e])==null||r.delete(n)}send(e,n,r){let{state:s,bufferPaths:i,buffers:d}=ne(e);this.sendToWidget({content:{state:s,bufferPaths:i},buffers:d}).then(n)}get(e){return this.data[e]}set(e,n){this.data={...this.data,[e]:n},this.dirtyFields.set(e,n),this.emit(`change:${e}`,n),this.emitAnyChange()}save_changes(){if(this.dirtyFields.size===0)return;let e=Object.fromEntries(this.dirtyFields.entries());this.dirtyFields.clear(),this.onChange(e)}updateAndEmitDiffs(e){e!=null&&Object.keys(e).forEach(n=>{let r=n;this.data[r]!==e[r]&&this.set(r,e[r])})}receiveCustomMessage(e,n=[]){var s;let r=Be.safeParse(e);if(r.success){let i=r.data;switch(i.method){case"update":this.updateAndEmitDiffs(Y({state:i.state,bufferPaths:i.buffer_paths??[],buffers:n}));break;case"custom":(s=this.listeners["msg:custom"])==null||s.forEach(d=>d(i.content,n));break;case"open":this.updateAndEmitDiffs(Y({state:i.state,bufferPaths:i.buffer_paths??[],buffers:n}));break;case"echo_update":break;default:E.error("[anywidget] Unknown message method",i.method);break}}else E.error("Failed to parse message",r.error),E.error("Message",e)}on(e,n){this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e].add(n)}emit(e,n){this.listeners[e]&&this.listeners[e].forEach(r=>r(n))}},a(M,"_modelManager",De),M),re=me(me(gt([fe(),wt()]))),se=bt(fe(),de()),Be=yt("method",[O({method:W("open"),state:se,buffer_paths:re.optional()}),O({method:W("update"),state:se,buffer_paths:re.optional()}),O({method:W("custom"),content:de()}),O({method:W("echo_update"),buffer_paths:re,state:se}),O({method:W("close")})]);function Tn(t){return t==null?!1:Be.safeParse(t).success}async function In({modelId:t,msg:e,buffers:n,modelManager:r}){if(e.method==="echo_update")return;if(e.method==="custom"){(await r.get(t)).receiveCustomMessage(e,n);return}if(e.method==="close"){r.delete(t);return}let{method:s,state:i,buffer_paths:d=[]}=e,l=Y({state:i,bufferPaths:d,buffers:n});if(s==="open"){let p=new He(l,b=>{let{state:x,buffers:w,bufferPaths:_}=ne(b);ye().sendModelValue({modelId:t,message:{state:x,bufferPaths:_},buffers:w})},y,new Set);r.set(t,p);return}if(s==="update"){(await r.get(t)).updateAndEmitDiffs(l);return}xt(s)}const Ve=q(null),Ln=q(null),Xe=q(!1),Un=q(!1),$e=q(!1);var zn=pe();const Ye=t=>{let e=(0,zn.c)(8),{onResize:n,startingWidth:r,minWidth:s,maxWidth:i}=t,d=(0,u.useRef)(null),l=(0,u.useRef)(null),p=(0,u.useRef)(null),b,x;e[0]!==i||e[1]!==s||e[2]!==n?(b=()=>{let C=d.current,k=l.current,F=p.current;if(!C||!k&&!F)return;let v=Number.parseInt(window.getComputedStyle(C).width,10),N=0,P=!1,A=null,L=c=>{if(!C||!P||!A)return;let h=c.clientX-N;N=c.clientX,v=A==="left"?v-h:v+h,s&&(v=Math.max(s,v)),i&&(v=Math.min(i,v)),C.style.width=`${v}px`},U=()=>{P&&(n==null||n(v),P=!1,A=null),document.removeEventListener("mousemove",L),document.removeEventListener("mouseup",U)},o=(c,h)=>{c.preventDefault(),P=!0,A=h,N=c.clientX,document.addEventListener("mousemove",L),document.addEventListener("mouseup",U)},f=c=>o(c,"left"),g=c=>o(c,"right");return k&&k.addEventListener("mousedown",f),F&&F.addEventListener("mousedown",g),()=>{k&&k.removeEventListener("mousedown",f),F&&F.removeEventListener("mousedown",g),document.removeEventListener("mousemove",L),document.removeEventListener("mouseup",U)}},x=[s,i,n],e[0]=i,e[1]=s,e[2]=n,e[3]=b,e[4]=x):(b=e[3],x=e[4]),(0,u.useEffect)(b,x);let w;e[5]===Symbol.for("react.memo_cache_sentinel")?(w={left:l,right:p},e[5]=w):w=e[5];let _=r==="contentWidth"?"var(--content-width-medium)":`${r}px`,R;return e[6]===_?R=e[7]:(R={resizableDivRef:d,handleRefs:w,style:{width:_}},e[6]=_,e[7]=R),R};function Ge(t){t||window.dispatchEvent(new Event("resize"))}var Qe=pe(),m=ce(Nt(),1);const On=()=>{let t=(0,Qe.c)(16),[e,n]=D(Ve),[r,s]=D(Xe),[i,d]=D(Un),[l,p]=D($e),b;t[0]!==s||t[1]!==n?(b=()=>{n(null),s(!1)},t[0]=s,t[1]=n,t[2]=b):b=t[2];let x=b;if(J(B.CONTEXT_AWARE_PANEL).length===0||!e||!r)return null;let w;t[3]!==l||t[4]!==i||t[5]!==p||t[6]!==d?(w=()=>(0,m.jsxs)("div",{className:"flex flex-row items-center gap-3",children:[(0,m.jsx)(ve,{content:i?"Unpin panel":"Pin panel",children:(0,m.jsx)(Ee,{size:"xs",onPressedChange:()=>d(!i),pressed:i,"aria-label":i?"Unpin panel":"Pin panel",children:i?(0,m.jsx)(Xt,{className:"w-4 h-4"}):(0,m.jsx)(Pt,{className:"w-4 h-4"})})}),(0,m.jsx)(ve,{content:l?(0,m.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,m.jsx)("span",{children:"Follow focused table"}),(0,m.jsx)("span",{className:"text-xs text-muted-foreground w-64",children:"The panel updates as cells that output tables are focused. Click to fix to the current cell."})]}):(0,m.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,m.jsx)("span",{children:"Focus on current table"}),(0,m.jsx)("span",{className:"text-xs text-muted-foreground w-64",children:"The panel is focused on the current table. Click to update based on which cell is focused."})]}),children:(0,m.jsx)(Ee,{size:"xs",onPressedChange:()=>p(!l),pressed:l,"aria-label":l?"Follow focused cell":"Fixed",children:(0,m.jsx)(Vt,{className:qt("w-4 h-4",l&&"text-primary")})})})]}),t[3]=l,t[4]=i,t[5]=p,t[6]=d,t[7]=w):w=t[7];let _=w,R;t[8]!==x||t[9]!==_?(R=()=>(0,m.jsxs)("div",{className:"mt-2 pb-7 mb-4 h-full overflow-auto",children:[(0,m.jsxs)("div",{className:"flex flex-row justify-between items-center mx-2",children:[_(),(0,m.jsx)(St,{variant:"linkDestructive",size:"icon",onClick:x,"aria-label":"Close selection panel",children:(0,m.jsx)(Mt,{className:"w-4 h-4"})})]}),(0,m.jsx)(ge,{children:(0,m.jsx)(Fe,{name:B.CONTEXT_AWARE_PANEL})})]}),t[8]=x,t[9]=_,t[10]=R):R=t[10];let C=R;if(!i){let v;return t[11]===C?v=t[12]:(v=(0,m.jsx)(Dn,{children:C()}),t[11]=C,t[12]=v),v}let k;t[13]===Symbol.for("react.memo_cache_sentinel")?(k=(0,m.jsx)(Dt,{onDragging:Ge,className:"resize-handle border-border z-20 no-print border-l"}),t[13]=k):k=t[13];let F;return t[14]===C?F=t[15]:(F=(0,m.jsxs)(m.Fragment,{children:[k,(0,m.jsx)(Ht,{defaultSize:20,minSize:15,maxSize:80,children:C()})]}),t[14]=C,t[15]=F),F},Wn=t=>{let e=(0,Qe.c)(2),{children:n}=t,r;return e[0]===n?r=e[1]:(r=(0,m.jsx)(ge,{children:(0,m.jsx)(Yt,{name:B.CONTEXT_AWARE_PANEL,children:n})}),e[0]=n,e[1]=r),r};var Dn=({children:t})=>{let{resizableDivRef:e,handleRefs:n,style:r}=Ye({startingWidth:400,minWidth:300,maxWidth:1500});return(0,m.jsxs)("div",{className:"absolute z-40 right-0 h-full bg-background flex flex-row",children:[(0,m.jsx)("div",{ref:n.left,className:"w-1 h-full cursor-col-resize border-l"}),(0,m.jsx)("div",{ref:e,style:r,children:t})]})};function Hn(){var t=[...arguments];return(0,u.useMemo)(()=>e=>{t.forEach(n=>n(e))},t)}var Ke=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0;function G(t){let e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function ae(t){return"nodeType"in t}function I(t){var e;return t?G(t)?t:ae(t)?((e=t.ownerDocument)==null?void 0:e.defaultView)??window:window:window}function Ze(t){let{Document:e}=I(t);return t instanceof e}function Je(t){return G(t)?!1:t instanceof I(t).HTMLElement}function et(t){return t instanceof I(t).SVGElement}function Bn(t){return t?G(t)?t.document:ae(t)?Ze(t)?t:Je(t)||et(t)?t.ownerDocument:document:document:document}var ie=Ke?u.useLayoutEffect:u.useEffect;function tt(t){let e=(0,u.useRef)(t);return ie(()=>{e.current=t}),(0,u.useCallback)(function(){var n=[...arguments];return e.current==null?void 0:e.current(...n)},[])}function Vn(){let t=(0,u.useRef)(null);return[(0,u.useCallback)((e,n)=>{t.current=setInterval(e,n)},[]),(0,u.useCallback)(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[])]}function Xn(t,e){e===void 0&&(e=[t]);let n=(0,u.useRef)(t);return ie(()=>{n.current!==t&&(n.current=t)},e),n}function $n(t,e){let n=(0,u.useRef)();return(0,u.useMemo)(()=>{let r=t(n.current);return n.current=r,r},[...e])}function Yn(t){let e=tt(t),n=(0,u.useRef)(null);return[n,(0,u.useCallback)(r=>{r!==n.current&&(e==null||e(r,n.current)),n.current=r},[])]}function Gn(t){let e=(0,u.useRef)();return(0,u.useEffect)(()=>{e.current=t},[t]),e.current}var oe={};function Qn(t,e){return(0,u.useMemo)(()=>{if(e)return e;let n=oe[t]==null?0:oe[t]+1;return oe[t]=n,t+"-"+n},[t,e])}function nt(t){return function(e){return[...arguments].slice(1).reduce((n,r)=>{let s=Object.entries(r);for(let[i,d]of s){let l=n[i];l!=null&&(n[i]=l+t*d)}return n},{...e})}}var Kn=nt(1),Zn=nt(-1);function Jn(t){return"clientX"in t&&"clientY"in t}function er(t){if(!t)return!1;let{KeyboardEvent:e}=I(t.target);return e&&t instanceof e}function tr(t){if(!t)return!1;let{TouchEvent:e}=I(t.target);return e&&t instanceof e}function nr(t){if(tr(t)){if(t.touches&&t.touches.length){let{clientX:e,clientY:n}=t.touches[0];return{x:e,y:n}}else if(t.changedTouches&&t.changedTouches.length){let{clientX:e,clientY:n}=t.changedTouches[0];return{x:e,y:n}}}return Jn(t)?{x:t.clientX,y:t.clientY}:null}var le=Object.freeze({Translate:{toString(t){if(!t)return;let{x:e,y:n}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;let{scaleX:e,scaleY:n}=t;return"scaleX("+e+") scaleY("+n+")"}},Transform:{toString(t){if(t)return[le.Translate.toString(t),le.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),rt="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function rr(t){return t.matches(rt)?t:t.querySelector(rt)}export{kn as $,Ln as A,jn as B,Qn as C,Ye as D,Ge as E,Tn as F,Oe as G,Sn as H,Y as I,Ue as J,Le as K,An as L,De as M,He as N,Xe as O,In as P,Te as Q,ne as R,Gn as S,Wn as T,We as U,Mn as V,Nn as W,Ie as X,Rn as Y,Fn as Z,Vn as _,nr as a,un as at,$n as b,Ze as c,ln as ct,ae as d,J as dt,X as et,et as f,H as ft,tt as g,Hn as h,rr as i,B as it,$e as j,Ve as k,Je as l,nn as lt,Zn as m,Kn as n,qe as nt,Bn as o,rn as ot,G as p,ze as q,Ke as r,Re as rt,I as s,on as st,le as t,wn as tt,er as u,Fe as ut,ie as v,On as w,Yn as x,Xn as y,qn as z};
|
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-DL0FpFYQ.js"></script>
|
|
70
70
|
<link rel="modulepreload" crossorigin href="./assets/preload-helper-DItdS47A.js">
|
|
71
71
|
<link rel="modulepreload" crossorigin href="./assets/clsx-D8GwTfvk.js">
|
|
72
72
|
<link rel="modulepreload" crossorigin href="./assets/cn-BKtXLv3a.js">
|
|
@@ -181,14 +181,14 @@
|
|
|
181
181
|
<link rel="modulepreload" crossorigin href="./assets/state-BXbqGYab.js">
|
|
182
182
|
<link rel="modulepreload" crossorigin href="./assets/MarimoErrorOutput-DscugIeA.js">
|
|
183
183
|
<link rel="modulepreload" crossorigin href="./assets/copy-icon-BhONVREY.js">
|
|
184
|
-
<link rel="modulepreload" crossorigin href="./assets/html-to-image-
|
|
184
|
+
<link rel="modulepreload" crossorigin href="./assets/html-to-image-Cdx1xsbU.js">
|
|
185
185
|
<link rel="modulepreload" crossorigin href="./assets/focus-ay4g-SB6.js">
|
|
186
186
|
<link rel="modulepreload" crossorigin href="./assets/LazyAnyLanguageCodeMirror-yzHjsVJt.js">
|
|
187
187
|
<link rel="modulepreload" crossorigin href="./assets/chunk-5FQGJX7Z-CVUXBqX6.js">
|
|
188
188
|
<link rel="modulepreload" crossorigin href="./assets/katex-Dc8yG8NU.js">
|
|
189
|
-
<link rel="modulepreload" crossorigin href="./assets/markdown-renderer-
|
|
189
|
+
<link rel="modulepreload" crossorigin href="./assets/markdown-renderer-DSY-ElEE.js">
|
|
190
190
|
<link rel="modulepreload" crossorigin href="./assets/command-BmWAYrdT.js">
|
|
191
|
-
<link rel="modulepreload" crossorigin href="./assets/download-
|
|
191
|
+
<link rel="modulepreload" crossorigin href="./assets/download-vBVDTXQk.js">
|
|
192
192
|
<link rel="modulepreload" crossorigin href="./assets/useRunCells-BgXbioPv.js">
|
|
193
193
|
<link rel="modulepreload" crossorigin href="./assets/purify.es-DNVQZNFu.js">
|
|
194
194
|
<link rel="modulepreload" crossorigin href="./assets/RenderHTML-DPkeBHFB.js">
|
|
@@ -203,33 +203,33 @@
|
|
|
203
203
|
<link rel="modulepreload" crossorigin href="./assets/useDateFormatter-CS4kbWl2.js">
|
|
204
204
|
<link rel="modulepreload" crossorigin href="./assets/range-D2UKkEg-.js">
|
|
205
205
|
<link rel="modulepreload" crossorigin href="./assets/table-DZR6ewbN.js">
|
|
206
|
-
<link rel="modulepreload" crossorigin href="./assets/JsonOutput-
|
|
206
|
+
<link rel="modulepreload" crossorigin href="./assets/JsonOutput-Dw_ZIGoz.js">
|
|
207
207
|
<link rel="modulepreload" crossorigin href="./assets/file-Cs1JbsV6.js">
|
|
208
208
|
<link rel="modulepreload" crossorigin href="./assets/play-BPIh-ZEU.js">
|
|
209
209
|
<link rel="modulepreload" crossorigin href="./assets/chat-components-BpunBJu9.js">
|
|
210
210
|
<link rel="modulepreload" crossorigin href="./assets/isEmpty-CgX_-6Mt.js">
|
|
211
|
-
<link rel="modulepreload" crossorigin href="./assets/chat-display-
|
|
211
|
+
<link rel="modulepreload" crossorigin href="./assets/chat-display-B0625p01.js">
|
|
212
212
|
<link rel="modulepreload" crossorigin href="./assets/useDeleteCell-Ct7dOEmt.js">
|
|
213
213
|
<link rel="modulepreload" crossorigin href="./assets/icons-BhEXrzsb.js">
|
|
214
214
|
<link rel="modulepreload" crossorigin href="./assets/process-output-ccUMEFYE.js">
|
|
215
215
|
<link rel="modulepreload" crossorigin href="./assets/blob-CuXvdYPX.js">
|
|
216
216
|
<link rel="modulepreload" crossorigin href="./assets/objectWithoutPropertiesLoose-DaPAPabU.js">
|
|
217
217
|
<link rel="modulepreload" crossorigin href="./assets/esm-DpMp6qko.js">
|
|
218
|
-
<link rel="modulepreload" crossorigin href="./assets/add-cell-with-ai-
|
|
218
|
+
<link rel="modulepreload" crossorigin href="./assets/add-cell-with-ai-BHgqYu8P.js">
|
|
219
219
|
<link rel="modulepreload" crossorigin href="./assets/chart-no-axes-column-W42b2ZIs.js">
|
|
220
220
|
<link rel="modulepreload" crossorigin href="./assets/square-function-CqXXKtIq.js">
|
|
221
221
|
<link rel="modulepreload" crossorigin href="./assets/spec-D1kBp3jX.js">
|
|
222
|
-
<link rel="modulepreload" crossorigin href="./assets/column-preview-
|
|
222
|
+
<link rel="modulepreload" crossorigin href="./assets/column-preview-YJ759JhT.js">
|
|
223
223
|
<link rel="modulepreload" crossorigin href="./assets/toggle-jWKnIArU.js">
|
|
224
224
|
<link rel="modulepreload" crossorigin href="./assets/globals-Du9rkBEf.js">
|
|
225
225
|
<link rel="modulepreload" crossorigin href="./assets/share-CbPtIlnM.js">
|
|
226
226
|
<link rel="modulepreload" crossorigin href="./assets/_baseSet-5Rdwpmr3.js">
|
|
227
227
|
<link rel="modulepreload" crossorigin href="./assets/react-resizable-panels.browser.esm-Ctj_10o2.js">
|
|
228
|
-
<link rel="modulepreload" crossorigin href="./assets/utilities.esm-
|
|
228
|
+
<link rel="modulepreload" crossorigin href="./assets/utilities.esm-BsBOP1QQ.js">
|
|
229
229
|
<link rel="modulepreload" crossorigin href="./assets/floating-outline-mEMcQGQK.js">
|
|
230
|
-
<link rel="modulepreload" crossorigin href="./assets/useAddCell-
|
|
230
|
+
<link rel="modulepreload" crossorigin href="./assets/useAddCell-M6_IuI4C.js">
|
|
231
231
|
<link rel="modulepreload" crossorigin href="./assets/eye-off-BhExYOph.js">
|
|
232
|
-
<link rel="modulepreload" crossorigin href="./assets/readonly-python-code-
|
|
232
|
+
<link rel="modulepreload" crossorigin href="./assets/readonly-python-code-B1UBDfCT.js">
|
|
233
233
|
<link rel="modulepreload" crossorigin href="./assets/file-video-camera-DW3v07j2.js">
|
|
234
234
|
<link rel="modulepreload" crossorigin href="./assets/types-1gCn5Ky0.js">
|
|
235
235
|
<link rel="modulepreload" crossorigin href="./assets/refresh-ccw-DLEiQDS3.js">
|
|
@@ -253,7 +253,7 @@
|
|
|
253
253
|
<link rel="stylesheet" crossorigin href="./assets/cells-jmgGt1lS.css">
|
|
254
254
|
<link rel="stylesheet" crossorigin href="./assets/markdown-renderer-DdDKmWlR.css">
|
|
255
255
|
<link rel="stylesheet" crossorigin href="./assets/JsonOutput-B7vuddcd.css">
|
|
256
|
-
<link rel="stylesheet" crossorigin href="./assets/index-
|
|
256
|
+
<link rel="stylesheet" crossorigin href="./assets/index-DmMvDRRC.css">
|
|
257
257
|
</head>
|
|
258
258
|
<body>
|
|
259
259
|
<div id="root"></div>
|
package/package.json
CHANGED
|
@@ -241,8 +241,8 @@ export function useNotebookActions() {
|
|
|
241
241
|
|
|
242
242
|
const downloadPDF = async (progress: ProgressState) => {
|
|
243
243
|
await updateCellOutputsWithScreenshots({
|
|
244
|
-
|
|
245
|
-
|
|
244
|
+
takeScreenshots: () =>
|
|
245
|
+
takeScreenshots({ progress, snappy: false }),
|
|
246
246
|
updateCellOutputs,
|
|
247
247
|
});
|
|
248
248
|
await downloadAsPDF({
|
|
@@ -102,8 +102,8 @@ describe("useEnrichCellOutputs", () => {
|
|
|
102
102
|
|
|
103
103
|
const { result } = renderHook(() => useEnrichCellOutputs(), { wrapper });
|
|
104
104
|
|
|
105
|
-
const
|
|
106
|
-
const output = await
|
|
105
|
+
const takeScreenshots = result.current;
|
|
106
|
+
const output = await takeScreenshots({ progress, snappy: false });
|
|
107
107
|
|
|
108
108
|
expect(output).toEqual({});
|
|
109
109
|
expect(document.getElementById).not.toHaveBeenCalled();
|
|
@@ -134,8 +134,8 @@ describe("useEnrichCellOutputs", () => {
|
|
|
134
134
|
|
|
135
135
|
const { result } = renderHook(() => useEnrichCellOutputs(), { wrapper });
|
|
136
136
|
|
|
137
|
-
const
|
|
138
|
-
const output = await
|
|
137
|
+
const takeScreenshots = result.current;
|
|
138
|
+
const output = await takeScreenshots({ progress, snappy: false });
|
|
139
139
|
|
|
140
140
|
expect(document.getElementById).toHaveBeenCalledWith(
|
|
141
141
|
CellOutputId.create(cellId),
|
|
@@ -152,6 +152,50 @@ describe("useEnrichCellOutputs", () => {
|
|
|
152
152
|
});
|
|
153
153
|
});
|
|
154
154
|
|
|
155
|
+
it("should pass snappy=true to toPng with includeStyleProperties", async () => {
|
|
156
|
+
const cellId = "cell-1" as CellId;
|
|
157
|
+
const mockElement = document.createElement("div");
|
|
158
|
+
const mockDataUrl = "data:image/png;base64,mockImageData";
|
|
159
|
+
|
|
160
|
+
// Mock document.getElementById
|
|
161
|
+
vi.spyOn(document, "getElementById").mockReturnValue(mockElement);
|
|
162
|
+
vi.mocked(toPng).mockResolvedValue(mockDataUrl);
|
|
163
|
+
|
|
164
|
+
setCellsRuntime(
|
|
165
|
+
createMockCellRuntimes({
|
|
166
|
+
[cellId]: {
|
|
167
|
+
output: {
|
|
168
|
+
channel: "output",
|
|
169
|
+
mimetype: "text/html",
|
|
170
|
+
data: "<div>Chart</div>",
|
|
171
|
+
timestamp: 0,
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
}),
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
const { result } = renderHook(() => useEnrichCellOutputs(), { wrapper });
|
|
178
|
+
|
|
179
|
+
const takeScreenshots = result.current;
|
|
180
|
+
const output = await takeScreenshots({ progress, snappy: true });
|
|
181
|
+
|
|
182
|
+
expect(document.getElementById).toHaveBeenCalledWith(
|
|
183
|
+
CellOutputId.create(cellId),
|
|
184
|
+
);
|
|
185
|
+
// When snappy=true, includeStyleProperties should be set
|
|
186
|
+
expect(toPng).toHaveBeenCalledWith(
|
|
187
|
+
mockElement,
|
|
188
|
+
expect.objectContaining({
|
|
189
|
+
filter: expect.any(Function),
|
|
190
|
+
onImageErrorHandler: expect.any(Function),
|
|
191
|
+
includeStyleProperties: expect.any(Array),
|
|
192
|
+
}),
|
|
193
|
+
);
|
|
194
|
+
expect(output).toEqual({
|
|
195
|
+
[cellId]: ["image/png", mockDataUrl],
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
|
|
155
199
|
it("should skip cells where output has not changed", async () => {
|
|
156
200
|
const cellId = "cell-1" as CellId;
|
|
157
201
|
const mockElement = document.createElement("div");
|
|
@@ -179,8 +223,8 @@ describe("useEnrichCellOutputs", () => {
|
|
|
179
223
|
});
|
|
180
224
|
|
|
181
225
|
// First call - should capture
|
|
182
|
-
let
|
|
183
|
-
let output = await
|
|
226
|
+
let takeScreenshots = result.current;
|
|
227
|
+
let output = await takeScreenshots({ progress, snappy: false });
|
|
184
228
|
expect(output).toEqual({ [cellId]: ["image/png", mockDataUrl] });
|
|
185
229
|
expect(toPng).toHaveBeenCalledTimes(1);
|
|
186
230
|
|
|
@@ -188,8 +232,8 @@ describe("useEnrichCellOutputs", () => {
|
|
|
188
232
|
rerender();
|
|
189
233
|
|
|
190
234
|
// Second call with same output - should not capture again
|
|
191
|
-
|
|
192
|
-
output = await
|
|
235
|
+
takeScreenshots = result.current;
|
|
236
|
+
output = await takeScreenshots({ progress, snappy: false });
|
|
193
237
|
expect(output).toEqual({}); // Empty because output hasn't changed
|
|
194
238
|
expect(toPng).toHaveBeenCalledTimes(1); // Still only 1 call
|
|
195
239
|
});
|
|
@@ -217,8 +261,8 @@ describe("useEnrichCellOutputs", () => {
|
|
|
217
261
|
|
|
218
262
|
const { result } = renderHook(() => useEnrichCellOutputs(), { wrapper });
|
|
219
263
|
|
|
220
|
-
const
|
|
221
|
-
const output = await
|
|
264
|
+
const takeScreenshots = result.current;
|
|
265
|
+
const output = await takeScreenshots({ progress, snappy: false });
|
|
222
266
|
|
|
223
267
|
expect(output).toEqual({}); // Failed screenshot should be filtered out
|
|
224
268
|
expect(Logger.error).toHaveBeenCalledWith(
|
|
@@ -247,8 +291,8 @@ describe("useEnrichCellOutputs", () => {
|
|
|
247
291
|
|
|
248
292
|
const { result } = renderHook(() => useEnrichCellOutputs(), { wrapper });
|
|
249
293
|
|
|
250
|
-
const
|
|
251
|
-
const output = await
|
|
294
|
+
const takeScreenshots = result.current;
|
|
295
|
+
const output = await takeScreenshots({ progress, snappy: false });
|
|
252
296
|
|
|
253
297
|
expect(output).toEqual({});
|
|
254
298
|
expect(Logger.error).toHaveBeenCalledWith(
|
|
@@ -296,8 +340,8 @@ describe("useEnrichCellOutputs", () => {
|
|
|
296
340
|
|
|
297
341
|
const { result } = renderHook(() => useEnrichCellOutputs(), { wrapper });
|
|
298
342
|
|
|
299
|
-
const
|
|
300
|
-
const output = await
|
|
343
|
+
const takeScreenshots = result.current;
|
|
344
|
+
const output = await takeScreenshots({ progress, snappy: false });
|
|
301
345
|
|
|
302
346
|
expect(output).toEqual({
|
|
303
347
|
[cell1]: ["image/png", mockDataUrl1],
|
|
@@ -342,8 +386,8 @@ describe("useEnrichCellOutputs", () => {
|
|
|
342
386
|
|
|
343
387
|
const { result } = renderHook(() => useEnrichCellOutputs(), { wrapper });
|
|
344
388
|
|
|
345
|
-
const
|
|
346
|
-
const output = await
|
|
389
|
+
const takeScreenshots = result.current;
|
|
390
|
+
const output = await takeScreenshots({ progress, snappy: false });
|
|
347
391
|
|
|
348
392
|
// Only the successful screenshot should be in the result
|
|
349
393
|
expect(output).toEqual({
|
|
@@ -384,14 +428,14 @@ describe("useEnrichCellOutputs", () => {
|
|
|
384
428
|
});
|
|
385
429
|
|
|
386
430
|
// First screenshot
|
|
387
|
-
let
|
|
388
|
-
let output = await
|
|
431
|
+
let takeScreenshots = result.current;
|
|
432
|
+
let output = await takeScreenshots({ progress, snappy: false });
|
|
389
433
|
expect(output).toEqual({ [cellId]: ["image/png", mockDataUrl1] });
|
|
390
434
|
|
|
391
435
|
// Second call - same output, should not be captured
|
|
392
436
|
rerender();
|
|
393
|
-
|
|
394
|
-
output = await
|
|
437
|
+
takeScreenshots = result.current;
|
|
438
|
+
output = await takeScreenshots({ progress, snappy: false });
|
|
395
439
|
expect(output).toEqual({});
|
|
396
440
|
|
|
397
441
|
// Third call - output changed, should be captured
|
|
@@ -409,8 +453,8 @@ describe("useEnrichCellOutputs", () => {
|
|
|
409
453
|
);
|
|
410
454
|
|
|
411
455
|
rerender();
|
|
412
|
-
|
|
413
|
-
output = await
|
|
456
|
+
takeScreenshots = result.current;
|
|
457
|
+
output = await takeScreenshots({ progress, snappy: false });
|
|
414
458
|
expect(output).toEqual({ [cellId]: ["image/png", mockDataUrl2] });
|
|
415
459
|
expect(toPng).toHaveBeenCalledTimes(2);
|
|
416
460
|
});
|
|
@@ -449,8 +493,8 @@ describe("useEnrichCellOutputs", () => {
|
|
|
449
493
|
|
|
450
494
|
const { result } = renderHook(() => useEnrichCellOutputs(), { wrapper });
|
|
451
495
|
|
|
452
|
-
const
|
|
453
|
-
const output = await
|
|
496
|
+
const takeScreenshots = result.current;
|
|
497
|
+
const output = await takeScreenshots({ progress, snappy: false });
|
|
454
498
|
|
|
455
499
|
// None of these should trigger screenshots
|
|
456
500
|
expect(output).toEqual({});
|
|
@@ -474,8 +518,8 @@ describe("useEnrichCellOutputs", () => {
|
|
|
474
518
|
|
|
475
519
|
const { result } = renderHook(() => useEnrichCellOutputs(), { wrapper });
|
|
476
520
|
|
|
477
|
-
const
|
|
478
|
-
const output = await
|
|
521
|
+
const takeScreenshots = result.current;
|
|
522
|
+
const output = await takeScreenshots({ progress, snappy: false });
|
|
479
523
|
|
|
480
524
|
expect(output).toEqual({});
|
|
481
525
|
expect(document.getElementById).not.toHaveBeenCalled();
|
|
@@ -506,8 +550,8 @@ describe("useEnrichCellOutputs", () => {
|
|
|
506
550
|
|
|
507
551
|
const { result } = renderHook(() => useEnrichCellOutputs(), { wrapper });
|
|
508
552
|
|
|
509
|
-
const
|
|
510
|
-
const output = await
|
|
553
|
+
const takeScreenshots = result.current;
|
|
554
|
+
const output = await takeScreenshots({ progress, snappy: false });
|
|
511
555
|
|
|
512
556
|
// Verify the exact return type structure
|
|
513
557
|
expect(output).toHaveProperty(cellId);
|
|
@@ -539,7 +583,6 @@ describe("updateCellOutputsWithScreenshots", () => {
|
|
|
539
583
|
const updateCellOutputs = vi.fn().mockResolvedValue(null);
|
|
540
584
|
|
|
541
585
|
await updateCellOutputsWithScreenshots({
|
|
542
|
-
progress,
|
|
543
586
|
takeScreenshots,
|
|
544
587
|
updateCellOutputs,
|
|
545
588
|
});
|
|
@@ -556,7 +599,6 @@ describe("updateCellOutputsWithScreenshots", () => {
|
|
|
556
599
|
const updateCellOutputs = vi.fn().mockResolvedValue(null);
|
|
557
600
|
|
|
558
601
|
await updateCellOutputsWithScreenshots({
|
|
559
|
-
progress,
|
|
560
602
|
takeScreenshots,
|
|
561
603
|
updateCellOutputs,
|
|
562
604
|
});
|
|
@@ -583,7 +625,6 @@ describe("updateCellOutputsWithScreenshots", () => {
|
|
|
583
625
|
const updateCellOutputs = vi.fn().mockResolvedValue(null);
|
|
584
626
|
|
|
585
627
|
await updateCellOutputsWithScreenshots({
|
|
586
|
-
progress,
|
|
587
628
|
takeScreenshots,
|
|
588
629
|
updateCellOutputs,
|
|
589
630
|
});
|
|
@@ -600,7 +641,6 @@ describe("updateCellOutputsWithScreenshots", () => {
|
|
|
600
641
|
|
|
601
642
|
// Should not throw - errors are caught and shown via toast
|
|
602
643
|
await updateCellOutputsWithScreenshots({
|
|
603
|
-
progress,
|
|
604
644
|
takeScreenshots,
|
|
605
645
|
updateCellOutputs,
|
|
606
646
|
});
|
|
@@ -633,7 +673,6 @@ describe("updateCellOutputsWithScreenshots", () => {
|
|
|
633
673
|
|
|
634
674
|
// Should not throw - errors are caught and shown via toast
|
|
635
675
|
await updateCellOutputsWithScreenshots({
|
|
636
|
-
progress,
|
|
637
676
|
takeScreenshots,
|
|
638
677
|
updateCellOutputs,
|
|
639
678
|
});
|