@marimo-team/frontend 0.20.4-dev2 → 0.20.5-dev0

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.
@@ -0,0 +1 @@
1
+ import{s as fe}from"./chunk-LvLJmgfZ.js";import{d as E,l as Ge,p as Ye,u as ie}from"./useEvent-WUlsM6MC.js";import{t as $e}from"./react-Bj1aDYRI.js";import{Cn as Ke,En as Je,Gt as Xe,Nr as Ze,Sn as Qe,T as ye,_ as et,ar as tt,cr as at,dt as ke,h as be,lt as ot,pr as nt,pt as it,rr as st,t as lt,ut as rt,vi as se,xn as dt}from"./cells-CCtxWKxf.js";import{t as S}from"./compiler-runtime-B3qBwwSJ.js";import{n as ct}from"./assertNever-Dw9aFN4h.js";import{s as xe}from"./useLifecycle-BDXC6oVR.js";import{a as ht,n as we}from"./add-connection-dialog-D4U9I7ze.js";import{n as pt,x as mt}from"./ai-model-dropdown-C3Y44M85.js";import{c as ge,m as I}from"./useEventListener-CjXriKgk.js";import{y as ut}from"./utils-CORJ8yYa.js";import{n as _,t as je}from"./constants-CdR60lKM.js";import{S as le,h as ft,x as yt}from"./config-D9X9QKiL.js";import{t as kt}from"./jsx-runtime-CP2fAiZX.js";import{r as bt,t as re}from"./button-BmOH9agK.js";import{r as L}from"./requests-DZy_SQ_v.js";import{t as h}from"./createLucideIcon-BvP5LBIs.js";import{a as ve,f as xt,i as Ce,m as wt,p as ze,u as We}from"./layout-DnAy5Tn0.js";import{t as Me}from"./check-BnZGcuDh.js";import{c as gt,d as Se,n as jt,o as vt,r as _e,t as Ct}from"./download-BTm4CTKr.js";import{f as zt}from"./maps-8VTEe-0T.js";import{r as Wt}from"./useCellActionButton-DFgACqVf.js";import{t as Mt}from"./copy-CAR4dOiD.js";import{t as St}from"./download-BG-iMGgV.js";import{t as _t}from"./eye-off-DgTL09j7.js";import{t as Dt}from"./file-plus-corner-BRwJx0yp.js";import{t as Y}from"./file-DVwc11C3.js";import{t as At}from"./github-BrsjF9dp.js";import{m as Nt}from"./form-B7_NRa34.js";import{n as Pt,r as Et,t as It}from"./youtube-fKFch587.js";import{n as Lt,t as Tt}from"./square-oV8Csj8Y.js";import{i as Ht}from"./html-to-image-b9BimK8l.js";import{t as qt}from"./link-Cpo6yhBB.js";import{r as Rt}from"./input-BPldEXfy.js";import{t as Vt}from"./settings-DD8FJvQ_.js";import{x as Ft}from"./azure-Ddr1pZpW.js";import{t as C}from"./use-toast-BhMe50aT.js";import{n as De,t as Ot}from"./paths-bMgYkaP2.js";import{o as Ut}from"./session-DnMOyddG.js";import{a as Bt,c as Gt,i as Yt,n as $t,r as Kt,s as Jt,t as Xt}from"./select-DygbgNTD.js";import{t as Zt}from"./tooltip-DOQlecCr.js";import{o as Qt}from"./alert-dialog-DsNfSYaw.js";import{a as ea,c as ta,i as aa,n as oa,r as na}from"./dialog-BXzvlof-.js";import{n as de}from"./ImperativeModal-CRNJOvqT.js";import{r as ia,t as sa}from"./share-sD4fbzpH.js";import{t as $}from"./copy-DMCkK2TI.js";import{a as la}from"./cell-link-B59Kn5nL.js";import{a as ra}from"./renderShortcut-BJEd-iA7.js";import{t as da}from"./icons-B9sHgc9n.js";import{t as ca}from"./links-syPBpTLO.js";import{r as ha,t as pa}from"./hooks-FnmFpagQ.js";import{t as Ae}from"./types-Myu7G9iV.js";var ma=h("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),ua=h("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),Ne=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"}]]),Pe=h("command",[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]]),Ee=h("diamond-plus",[["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0z",key:"1ey20j"}],["path",{d:"M8 12h8",key:"1wcyev"}]]),fa=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"}]]),ya=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"}]]),ka=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"}]]),Ie=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"}]]),ba=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"}]]),xa=h("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),Le=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"}]]),wa=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"}]]),ga=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"}]]),Te=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"}]]),He=S(),ce=fe($e(),1),a=fe(kt(),1),K="https://static.marimo.app";const ja=e=>{let t=(0,He.c)(25),{onClose:n}=e,[o,s]=(0,ce.useState)(""),{exportAsHTML:r}=L(),l=`${o}-${Math.random().toString(36).slice(2,6)}`,i=`${K}/static/${l}`,d;t[0]!==r||t[1]!==n||t[2]!==l?(d=async v=>{v.preventDefault(),n();let A=await r({download:!1,includeCode:!0,files:xt.INSTANCE.filenames()}),z=C({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${K}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:A,path:l})}).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]=l,t[3]=d):d=t[3];let p;t[4]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsx)(ta,{children:"Share static notebook"}),t[4]=p):p=t[4];let w;t[5]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsxs)(ea,{children:[p,(0,a.jsxs)(na,{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:K,target:"_blank",children:K}),"."]})]}),t[5]=w):w=t[5];let g;t[6]===Symbol.for("react.memo_cache_sentinel")?(g=v=>{s(v.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,""))},t[6]=g):g=t[6];let u;t[7]===o?u=t[8]:(u=(0,a.jsx)(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]=u);let f;t[9]===i?f=t[10]:(f=(0,a.jsxs)("div",{className:"font-semibold text-sm text-muted-foreground gap-2 flex flex-col",children:["Anyone will be able to access your notebook at this URL:",(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(va,{text:i}),(0,a.jsx)("span",{className:"text-primary",children:i})]})]}),t[9]=i,t[10]=f);let y;t[11]!==u||t[12]!==f?(y=(0,a.jsxs)("div",{className:"flex flex-col gap-6 py-4",children:[u,f]}),t[11]=u,t[12]=f,t[13]=y):y=t[13];let k;t[14]===n?k=t[15]:(k=(0,a.jsx)(re,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),t[14]=n,t[15]=k);let b;t[16]===i?b=t[17]:(b=(0,a.jsx)(re,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await $(i)},children:"Create"}),t[16]=i,t[17]=b);let x;t[18]!==k||t[19]!==b?(x=(0,a.jsxs)(aa,{children:[k,b]}),t[18]=k,t[19]=b,t[20]=x):x=t[20];let j;return t[21]!==d||t[22]!==x||t[23]!==y?(j=(0,a.jsx)(oa,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:d,children:[w,y,x]})}),t[21]=d,t[22]=x,t[23]=y,t[24]=j):j=t[24],j};var va=e=>{let t=(0,He.c)(8),[n,o]=ce.useState(!1),s;t[0]===e.text?s=t[1]:(s=bt.stopPropagation(async p=>{p.preventDefault(),await $(e.text),o(!0),setTimeout(()=>o(!1),2e3)}),t[0]=e.text,t[1]=s);let r=s,l;t[2]===Symbol.for("react.memo_cache_sentinel")?(l=(0,a.jsx)(Mt,{size:14,strokeWidth:1.5}),t[2]=l):l=t[2];let i;t[3]===r?i=t[4]:(i=(0,a.jsx)(re,{"data-testid":"copy-static-notebook-url-button",onClick:r,size:"xs",variant:"secondary",children:l}),t[3]=r,t[4]=i);let d;return t[5]!==n||t[6]!==i?(d=(0,a.jsx)(Zt,{content:"Copied!",open:n,children:i}),t[5]=n,t[6]=i,t[7]=d):d=t[7],d},Ca=S();function za(){let e=document.getElementsByClassName(je.outputArea);for(let t of e){let n=t.getBoundingClientRect();if(n.bottom>0&&n.top<window.innerHeight){let o=se.findElement(t);if(!o){I.warn("Could not find HTMLCellId for visible output area",t);continue}return{cellId:se.parse(o.id)}}}return I.warn("No visible output area found for scroll anchor"),null}function Wa(e){if(!e){I.warn("No scroll anchor provided to restore scroll position");return}let t=document.getElementById(se.create(e.cellId));if(!t){I.warn("Could not find cell element to restore scroll position",e.cellId);return}if(!t.querySelector(`.${je.outputArea}`)){I.warn("Could not find output area to restore scroll position",e.cellId);return}t.scrollIntoView({block:"start",behavior:"auto"})}function qe(){let e=(0,Ca.c)(2),t=E(ke),n;return e[0]===t?n=e[1]:(n=()=>{let o=za();t(s=>({mode:rt(s.mode),cellAnchor:(o==null?void 0:o.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{Wa(o)})})},e[0]=t,e[1]=n),n}const Re=Ye(!1);var Ma=S();const Sa=()=>{let e=(0,Ma.c)(7),{selectedLayout:t}=ve(),{setLayoutView:n}=Ce();if(le()&&!Je("wasm_layouts"))return null;let o;e[0]===n?o=e[1]:(o=i=>n(i),e[0]=n,e[1]=o);let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(Jt,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(Gt,{placeholder:"Select a view"})}),e[2]=s):s=e[2];let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)($t,{children:(0,a.jsxs)(Kt,{children:[(0,a.jsx)(Bt,{children:"View as"}),Ae.map(Da)]})}),e[3]=r):r=e[3];let l;return e[4]!==t||e[5]!==o?(l=(0,a.jsxs)(Xt,{"data-testid":"layout-select",value:t,onValueChange:o,children:[s,r]}),e[4]=t,e[5]=o,e[6]=l):l=e[6],l};function _a(e){return(0,a.jsx)(Ve(e),{className:"h-4 w-4"})}function Ve(e){switch(e){case"vertical":return ba;case"grid":return Et;case"slides":return Le;default:return ct(e),Tt}}function Fe(e){return xe(e)}function Da(e){return(0,a.jsx)(Yt,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[_a(e),(0,a.jsx)("span",{children:Fe(e)})]})},e)}async function Aa(e){let{filename:t,preset:n,downloadPDF:o}=e;await o({filename:t,webpdf:!1,preset:n,includeInputs:!0,rasterServer:"static"})}var Na=S();function Pa(e){let t=(0,Na.c)(5),{openPrompt:n,closeModal:o}=de(),{sendCopy:s}=L(),r;return t[0]!==o||t[1]!==n||t[2]!==s||t[3]!==e?(r=()=>{if(!e)return null;let l=Ot.guessDeliminator(e);n({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${De.basename(e)}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:i=>{let d=l.join(De.dirname(e),i);s({source:e,destination:d}).then(()=>{o(),C({title:"Notebook copied",description:"A copy of the notebook has been created."}),ca(d)})}})},t[0]=o,t[1]=n,t[2]=s,t[3]=e,t[4]=r):r=t[4],r}const Ea=()=>{let{updateCellConfig:e}=ye(),{saveCellConfig:t}=L();return(0,ce.useCallback)(async()=>{let n=new Xe,o=be(),s=o.cellIds.inOrderIds,r={};for(let i of s){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 l=ge.entries(r);if(l.length!==0){await t({configs:r});for(let[i,d]of l)e({cellId:i,config:d})}},[e])};var Ia=S();function Oe(){let e=(0,Ia.c)(4),{openConfirm:t}=de(),n=E(ft),{sendRestart:o}=L(),s;return e[0]!==t||e[1]!==o||e[2]!==n?(s=()=>{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)(Qt,{onClick:async()=>{n({state:yt.CLOSING}),await o(),ia()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=o,e[2]=n,e[3]=s):s=e[3],s}var La=S(),D=e=>{e==null||e.preventDefault(),e==null||e.stopPropagation()};function Ta(){var me,ue;let e=(0,La.c)(45),t=la(),{openModal:n,closeModal:o}=de(),{toggleApplication:s}=dt(),{selectedPanel:r}=Qe(),[l]=Ge(ke),i=ie(ot),d=Ea(),[p]=ut(),{updateCellConfig:w,undoDeleteCell:g,clearAllCellOutputs:u,addSetupCellIfDoesntExist:f,collapseAllCells:y,expandAllCells:k}=ye(),b=Oe(),x=it(),j=Pa(t),v=E(Re),A=E(pt),z=E(mt),{exportAsMarkdown:J,readCode:N,saveCellConfig:X,updateCellOutputs:Z}=L(),Q=ha(),ee=ie(et),te=ie(lt),{selectedLayout:T}=ve(),{setLayoutView:ae}=Ce(),H=qe(),q=((me=p.sharing)==null?void 0:me.html)??!0,R=((ue=p.sharing)==null?void 0:ue.wasm)??!0,pe=!le(),oe=T==="slides",Ue=to,Be=eo,V;e[0]!==t||e[1]!==Q||e[2]!==Z?(V=async c=>{let{preset:m,title:P}=c;if(!t){he();return}await gt(P,async ne=>{await pa({takeScreenshots:()=>Q({progress:ne}),updateCellOutputs:Z}),await Aa({filename:t,preset:m,downloadPDF:jt})})},e[0]=t,e[1]=Q,e[2]=Z,e[3]=V):V=e[3];let W=V,F;e[4]===W?F=e[5]:(F=async()=>{if(pe){await W({preset:"document",title:"Downloading Document PDF..."});return}let c=new Event("export-beforeprint"),m=new Event("export-afterprint");window.dispatchEvent(c),setTimeout(Qa,0),setTimeout(()=>window.dispatchEvent(m),0)},e[4]=W,e[5]=F);let O=F,U;e[6]===Symbol.for("react.memo_cache_sentinel")?(U=(0,a.jsx)(St,{size:14,strokeWidth:1.5}),e[6]=U):U=e[6];let B;e[7]===Symbol.for("react.memo_cache_sentinel")?(B=(0,a.jsx)(ze,{size:14,strokeWidth:1.5}),e[7]=B):B=e[7];let M;e[8]===t?M=e[9]:(M=async()=>{if(!t){he();return}await We({filename:t,includeCode:!0})},e[8]=t,e[9]=M);let G;return e[10]!==f||e[11]!==te||e[12]!==u||e[13]!==o||e[14]!==y||e[15]!==j||e[16]!==W||e[17]!==k||e[18]!==J||e[19]!==t||e[20]!==O||e[21]!==ee||e[22]!==d||e[23]!==oe||e[24]!==i||e[25]!==n||e[26]!==N||e[27]!==b||e[28]!==x||e[29]!==X||e[30]!==T||e[31]!==r||e[32]!==v||e[33]!==z||e[34]!==ae||e[35]!==A||e[36]!==q||e[37]!==R||e[38]!==M||e[39]!==s||e[40]!==H||e[41]!==g||e[42]!==w||e[43]!==l.mode?(G=[{icon:U,label:"Download",handle:D,dropdown:[{icon:B,label:"Download as HTML",handle:M},{icon:(0,a.jsx)(ze,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{if(!t){he();return}await We({filename:t,includeCode:!1})}},{icon:(0,a.jsx)(da,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{let c=await J({download:!1});_e(new Blob([c],{type:"text/plain"}),Se.toMarkdown(document.title))}},{icon:(0,a.jsx)(wt,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let c=await N();_e(new Blob([c.contents],{type:"text/plain"}),Se.toPY(document.title))}},{divider:!0,icon:(0,a.jsx)(Ht,{size:14,strokeWidth:1.5}),label:"Download as PNG",disabled:l.mode!=="present",tooltip:l.mode==="present"?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",ra("global.hideCode",!1)]}),handle:Za},oe?{divider:!0,icon:(0,a.jsx)(Y,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:D,dropdown:[{icon:(0,a.jsx)(Y,{size:14,strokeWidth:1.5}),label:"Document Layout",handle:O},{icon:(0,a.jsx)(Y,{size:14,strokeWidth:1.5}),label:"Slides Layout",rightElement:Be(!0),hidden:!pe,handle:async()=>{await W({preset:"slides",title:"Downloading Slides PDF..."})}}]}:{divider:!0,icon:(0,a.jsx)(Y,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:O}]},{icon:(0,a.jsx)(wa,{size:14,strokeWidth:1.5}),label:"Share",handle:D,hidden:!q&&!R,dropdown:[{icon:(0,a.jsx)(Nt,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!q,handle:async()=>{n((0,a.jsx)(ja,{onClose:o}))}},{icon:(0,a.jsx)(qt,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!R,handle:async()=>{await $(sa({code:(await N()).contents})),C({title:"Copied",description:"Link copied to clipboard."})}}]},{icon:(0,a.jsx)(xa,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:D,dropdown:Ke.flatMap(c=>{let{type:m,Icon:P,hidden:ne}=c;return ne?[]:{label:xe(m),rightElement:Ue(r===m),icon:(0,a.jsx)(P,{size:14,strokeWidth:1.5}),handle:()=>s(m)}})},{icon:(0,a.jsx)(Le,{size:14,strokeWidth:1.5}),label:"Present as",handle:D,dropdown:[{icon:l.mode==="present"?(0,a.jsx)(Ft,{size:14,strokeWidth:1.5}):(0,a.jsx)(Ie,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{H()}},...Ae.map((c,m)=>{let P=Ve(c);return{divider:m===0,label:Fe(c),icon:(0,a.jsx)(P,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:T===c&&(0,a.jsx)(Me,{size:14})}),handle:()=>{ae(c),l.mode==="edit"&&H()}}})]},{icon:(0,a.jsx)(ya,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!t||le(),handle:j},{icon:(0,a.jsx)(Ne,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!t,handle:async()=>{await $((await N()).contents),C({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(Wt,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!ee||i,handle:async()=>{let c=Ze(be());await X({configs:ge.fromEntries(c.map(Xa))});for(let m of c)w({cellId:m,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)(Ee,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{f({})}},{icon:(0,a.jsx)(tt,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n((0,a.jsx)(we,{onClose:o}))}},{icon:(0,a.jsx)(ht,{size:14,strokeWidth:1.5}),label:"Add remote storage",handle:()=>{n((0,a.jsx)(we,{defaultTab:"storage",onClose:o}))}},{icon:(0,a.jsx)(Te,{size:14,strokeWidth:1.5}),label:"Undo cell deletion",hidden:!te||i,handle:()=>{g()}},{icon:(0,a.jsx)(ga,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:b},{icon:(0,a.jsx)(fa,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{x()}},{icon:(0,a.jsx)(at,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{u()}},{icon:(0,a.jsx)(_t,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:d,redundant:!0},{icon:(0,a.jsx)(ua,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:y,redundant:!0},{icon:(0,a.jsx)(ma,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:k,redundant:!0},{divider:!0,icon:(0,a.jsx)(Pe,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>v(Ja)},{icon:(0,a.jsx)(ka,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>z(Ka)},{icon:(0,a.jsx)(Vt,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>A($a),redundant:!0},{icon:(0,a.jsx)(zt,{size:14,strokeWidth:1.5}),label:"Resources",handle:D,dropdown:[{icon:(0,a.jsx)(nt,{size:14,strokeWidth:1.5}),label:"Documentation",handle:Ya},{icon:(0,a.jsx)(At,{size:14,strokeWidth:1.5}),label:"GitHub",handle:Ga},{icon:(0,a.jsx)(Pt,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:Ba},{icon:(0,a.jsx)(It,{size:14,strokeWidth:1.5}),label:"YouTube",handle:Ua},{icon:(0,a.jsx)(st,{size:14,strokeWidth:1.5}),label:"Changelog",handle:Oa}]},{divider:!0,icon:(0,a.jsx)(Lt,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:Fa},{icon:(0,a.jsx)(Dt,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:Va}].filter(Ra).map(Ha),e[10]=f,e[11]=te,e[12]=u,e[13]=o,e[14]=y,e[15]=j,e[16]=W,e[17]=k,e[18]=J,e[19]=t,e[20]=O,e[21]=ee,e[22]=d,e[23]=oe,e[24]=i,e[25]=n,e[26]=N,e[27]=b,e[28]=x,e[29]=X,e[30]=T,e[31]=r,e[32]=v,e[33]=z,e[34]=ae,e[35]=A,e[36]=q,e[37]=R,e[38]=M,e[39]=s,e[40]=H,e[41]=g,e[42]=w,e[43]=l.mode,e[44]=G):G=e[44],G}function Ha(e){return e.dropdown?{...e,dropdown:e.dropdown.filter(qa)}:e}function qa(e){return!e.hidden}function Ra(e){return!e.hidden}function Va(){let e=Ut();window.open(e,"_blank")}function Fa(){let e=document.baseURI.split("?")[0];window.open(e,"_self")}function Oa(){window.open(_.releasesPage,"_blank")}function Ua(){window.open(_.youtube,"_blank")}function Ba(){window.open(_.discordLink,"_blank")}function Ga(){window.open(_.githubPage,"_blank")}function Ya(){window.open(_.docsPage,"_blank")}function $a(e){return!e}function Ka(e){return!e}function Ja(e){return!e}function Xa(e){return[e,{disabled:!1}]}async function Za(){let e=document.getElementById("App");e&&await vt({element:e,filename:document.title,prepare:Ct})}function Qa(){return window.print()}function eo(e){return e?(0,a.jsx)("span",{className:"ml-3 shrink-0 rounded-full border border-emerald-200 bg-emerald-50 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-emerald-700",children:"Recommended"}):null}function to(e){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:e&&(0,a.jsx)(Me,{size:14})})}function he(){C({title:"Error",description:"Notebooks must be named to be exported.",variant:"danger"})}export{qe as a,Ee as c,Re as i,Pe as l,Oe as n,Te as o,Sa as r,Ie as s,Ta as t,Ne as u};
package/dist/index.html CHANGED
@@ -66,7 +66,7 @@
66
66
  <marimo-server-token data-token="{{ server_token }}" hidden></marimo-server-token>
67
67
  <!-- /TODO -->
68
68
  <title>{{ title }}</title>
69
- <script type="module" crossorigin src="./assets/index-Svkti1d4.js"></script>
69
+ <script type="module" crossorigin src="./assets/index-DyRdaW9o.js"></script>
70
70
  <link rel="modulepreload" crossorigin href="./assets/preload-helper-TXkS1QI3.js">
71
71
  <link rel="modulepreload" crossorigin href="./assets/clsx-A78R3nYl.js">
72
72
  <link rel="modulepreload" crossorigin href="./assets/cn-d_A4rA-x.js">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marimo-team/frontend",
3
- "version": "0.20.4-dev2",
3
+ "version": "0.20.5-dev0",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -184,6 +184,21 @@ export function useNotebookActions() {
184
184
  await withLoadingToast(title, runDownload);
185
185
  };
186
186
 
187
+ const handleDocumentPDF = async () => {
188
+ if (serverSidePdfEnabled) {
189
+ await downloadServerSidePDF({
190
+ preset: "document",
191
+ title: "Downloading Document PDF...",
192
+ });
193
+ return;
194
+ }
195
+ const beforeprint = new Event("export-beforeprint");
196
+ const afterprint = new Event("export-afterprint");
197
+ window.dispatchEvent(beforeprint);
198
+ setTimeout(() => window.print(), 0);
199
+ setTimeout(() => window.dispatchEvent(afterprint), 0);
200
+ };
201
+
187
202
  const actions: ActionButton[] = [
188
203
  {
189
204
  icon: <DownloadIcon size={14} strokeWidth={1.5} />,
@@ -261,49 +276,38 @@ export function useNotebookActions() {
261
276
  });
262
277
  },
263
278
  },
264
- {
265
- divider: true,
266
- icon: <FileIcon size={14} strokeWidth={1.5} />,
267
- label: "Download as PDF",
268
- handle: NOOP_HANDLER,
269
- dropdown: [
270
- {
279
+ isSlidesLayout
280
+ ? {
281
+ divider: true,
271
282
  icon: <FileIcon size={14} strokeWidth={1.5} />,
272
- label: "Document Layout",
273
- rightElement: renderRecommendedElement(!isSlidesLayout),
274
- handle: async () => {
275
- if (serverSidePdfEnabled) {
276
- await downloadServerSidePDF({
277
- preset: "document",
278
- title: "Downloading Document PDF...",
279
- });
280
- return;
281
- }
282
-
283
- const beforeprint = new Event("export-beforeprint");
284
- const afterprint = new Event("export-afterprint");
285
- function print() {
286
- window.dispatchEvent(beforeprint);
287
- setTimeout(() => window.print(), 0);
288
- setTimeout(() => window.dispatchEvent(afterprint), 0);
289
- }
290
- print();
291
- },
292
- },
293
- {
283
+ label: "Download as PDF",
284
+ handle: NOOP_HANDLER,
285
+ dropdown: [
286
+ {
287
+ icon: <FileIcon size={14} strokeWidth={1.5} />,
288
+ label: "Document Layout",
289
+ handle: handleDocumentPDF,
290
+ },
291
+ {
292
+ icon: <FileIcon size={14} strokeWidth={1.5} />,
293
+ label: "Slides Layout",
294
+ rightElement: renderRecommendedElement(true),
295
+ hidden: !serverSidePdfEnabled,
296
+ handle: async () => {
297
+ await downloadServerSidePDF({
298
+ preset: "slides",
299
+ title: "Downloading Slides PDF...",
300
+ });
301
+ },
302
+ },
303
+ ],
304
+ }
305
+ : {
306
+ divider: true,
294
307
  icon: <FileIcon size={14} strokeWidth={1.5} />,
295
- label: "Slides Layout",
296
- rightElement: renderRecommendedElement(isSlidesLayout),
297
- hidden: !serverSidePdfEnabled,
298
- handle: async () => {
299
- await downloadServerSidePDF({
300
- preset: "slides",
301
- title: "Downloading Slides PDF...",
302
- });
303
- },
308
+ label: "Download as PDF",
309
+ handle: handleDocumentPDF,
304
310
  },
305
- ],
306
- },
307
311
  ],
308
312
  },
309
313
 
@@ -1 +0,0 @@
1
- import{s as ue}from"./chunk-LvLJmgfZ.js";import{d as P,l as Be,p as Ue,u as ae}from"./useEvent-WUlsM6MC.js";import{t as Ge}from"./react-Bj1aDYRI.js";import{Cn as Ye,En as $e,Gt as Ke,Nr as Je,Sn as Xe,T as fe,_ as Qe,ar as Ze,cr as et,dt as ye,h as ke,lt as tt,pr as at,pt as ot,rr as nt,t as it,ut as st,vi as oe,xn as lt}from"./cells-CCtxWKxf.js";import{t as W}from"./compiler-runtime-B3qBwwSJ.js";import{n as rt}from"./assertNever-Dw9aFN4h.js";import{s as be}from"./useLifecycle-BDXC6oVR.js";import{a as dt,n as xe}from"./add-connection-dialog-D4U9I7ze.js";import{n as ct,x as ht}from"./ai-model-dropdown-C3Y44M85.js";import{c as we,m as E}from"./useEventListener-CjXriKgk.js";import{y as pt}from"./utils-CORJ8yYa.js";import{n as S,t as ge}from"./constants-CdR60lKM.js";import{S as ne,h as mt,x as ut}from"./config-D9X9QKiL.js";import{t as ft}from"./jsx-runtime-CP2fAiZX.js";import{r as yt,t as ie}from"./button-BmOH9agK.js";import{r as I}from"./requests-DZy_SQ_v.js";import{t as h}from"./createLucideIcon-BvP5LBIs.js";import{a as je,f as kt,i as ve,m as bt,p as Ce,u as ze}from"./layout-DnAy5Tn0.js";import{t as Me}from"./check-BnZGcuDh.js";import{c as xt,d as We,n as wt,o as gt,r as Se,t as jt}from"./download-BTm4CTKr.js";import{f as vt}from"./maps-8VTEe-0T.js";import{r as Ct}from"./useCellActionButton-DFgACqVf.js";import{t as zt}from"./copy-CAR4dOiD.js";import{t as Mt}from"./download-BG-iMGgV.js";import{t as Wt}from"./eye-off-DgTL09j7.js";import{t as St}from"./file-plus-corner-BRwJx0yp.js";import{t as se}from"./file-DVwc11C3.js";import{t as _t}from"./github-BrsjF9dp.js";import{m as At}from"./form-B7_NRa34.js";import{n as Dt,r as Nt,t as Pt}from"./youtube-fKFch587.js";import{n as Et,t as It}from"./square-oV8Csj8Y.js";import{i as Tt}from"./html-to-image-b9BimK8l.js";import{t as Lt}from"./link-Cpo6yhBB.js";import{r as Ht}from"./input-BPldEXfy.js";import{t as qt}from"./settings-DD8FJvQ_.js";import{x as Rt}from"./azure-Ddr1pZpW.js";import{t as C}from"./use-toast-BhMe50aT.js";import{n as _e,t as Ft}from"./paths-bMgYkaP2.js";import{o as Vt}from"./session-DnMOyddG.js";import{a as Ot,c as Bt,i as Ut,n as Gt,r as Yt,s as $t,t as Kt}from"./select-DygbgNTD.js";import{t as Jt}from"./tooltip-DOQlecCr.js";import{o as Xt}from"./alert-dialog-DsNfSYaw.js";import{a as Qt,c as Zt,i as ea,n as ta,r as aa}from"./dialog-BXzvlof-.js";import{n as le}from"./ImperativeModal-CRNJOvqT.js";import{r as oa,t as na}from"./share-sD4fbzpH.js";import{t as G}from"./copy-DMCkK2TI.js";import{a as ia}from"./cell-link-B59Kn5nL.js";import{a as sa}from"./renderShortcut-BJEd-iA7.js";import{t as la}from"./icons-B9sHgc9n.js";import{t as ra}from"./links-syPBpTLO.js";import{r as da,t as ca}from"./hooks-FnmFpagQ.js";import{t as Ae}from"./types-Myu7G9iV.js";var ha=h("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),pa=h("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),De=h("clipboard-copy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]),Ne=h("command",[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]]),Pe=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"}]]),ma=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"}]]),ua=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"}]]),fa=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"}]]),Ee=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"}]]),ya=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"}]]),ka=h("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),Ie=h("presentation",[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]]),ba=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"}]]),xa=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"}]]),Te=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"}]]),Le=W(),re=ue(Ge(),1),a=ue(ft(),1),Y="https://static.marimo.app";const wa=e=>{let t=(0,Le.c)(25),{onClose:n}=e,[o,s]=(0,re.useState)(""),{exportAsHTML:r}=I(),l=`${o}-${Math.random().toString(36).slice(2,6)}`,i=`${Y}/static/${l}`,d;t[0]!==r||t[1]!==n||t[2]!==l?(d=async v=>{v.preventDefault(),n();let A=await r({download:!1,includeCode:!0,files:kt.INSTANCE.filenames()}),z=C({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${Y}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:A,path:l})}).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:S.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]=l,t[3]=d):d=t[3];let p;t[4]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsx)(Zt,{children:"Share static notebook"}),t[4]=p):p=t[4];let w;t[5]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsxs)(Qt,{children:[p,(0,a.jsxs)(aa,{children:["You can publish a static, non-interactive version of this notebook to the public web. We will create a link for you that lives on"," ",(0,a.jsx)("a",{href:Y,target:"_blank",children:Y}),"."]})]}),t[5]=w):w=t[5];let g;t[6]===Symbol.for("react.memo_cache_sentinel")?(g=v=>{s(v.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,""))},t[6]=g):g=t[6];let u;t[7]===o?u=t[8]:(u=(0,a.jsx)(Ht,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:g,required:!0,autoComplete:"off"}),t[7]=o,t[8]=u);let f;t[9]===i?f=t[10]:(f=(0,a.jsxs)("div",{className:"font-semibold text-sm text-muted-foreground gap-2 flex flex-col",children:["Anyone will be able to access your notebook at this URL:",(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(ga,{text:i}),(0,a.jsx)("span",{className:"text-primary",children:i})]})]}),t[9]=i,t[10]=f);let y;t[11]!==u||t[12]!==f?(y=(0,a.jsxs)("div",{className:"flex flex-col gap-6 py-4",children:[u,f]}),t[11]=u,t[12]=f,t[13]=y):y=t[13];let k;t[14]===n?k=t[15]:(k=(0,a.jsx)(ie,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),t[14]=n,t[15]=k);let b;t[16]===i?b=t[17]:(b=(0,a.jsx)(ie,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await G(i)},children:"Create"}),t[16]=i,t[17]=b);let x;t[18]!==k||t[19]!==b?(x=(0,a.jsxs)(ea,{children:[k,b]}),t[18]=k,t[19]=b,t[20]=x):x=t[20];let j;return t[21]!==d||t[22]!==x||t[23]!==y?(j=(0,a.jsx)(ta,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:d,children:[w,y,x]})}),t[21]=d,t[22]=x,t[23]=y,t[24]=j):j=t[24],j};var ga=e=>{let t=(0,Le.c)(8),[n,o]=re.useState(!1),s;t[0]===e.text?s=t[1]:(s=yt.stopPropagation(async p=>{p.preventDefault(),await G(e.text),o(!0),setTimeout(()=>o(!1),2e3)}),t[0]=e.text,t[1]=s);let r=s,l;t[2]===Symbol.for("react.memo_cache_sentinel")?(l=(0,a.jsx)(zt,{size:14,strokeWidth:1.5}),t[2]=l):l=t[2];let i;t[3]===r?i=t[4]:(i=(0,a.jsx)(ie,{"data-testid":"copy-static-notebook-url-button",onClick:r,size:"xs",variant:"secondary",children:l}),t[3]=r,t[4]=i);let d;return t[5]!==n||t[6]!==i?(d=(0,a.jsx)(Jt,{content:"Copied!",open:n,children:i}),t[5]=n,t[6]=i,t[7]=d):d=t[7],d},ja=W();function va(){let e=document.getElementsByClassName(ge.outputArea);for(let t of e){let n=t.getBoundingClientRect();if(n.bottom>0&&n.top<window.innerHeight){let o=oe.findElement(t);if(!o){E.warn("Could not find HTMLCellId for visible output area",t);continue}return{cellId:oe.parse(o.id)}}}return E.warn("No visible output area found for scroll anchor"),null}function Ca(e){if(!e){E.warn("No scroll anchor provided to restore scroll position");return}let t=document.getElementById(oe.create(e.cellId));if(!t){E.warn("Could not find cell element to restore scroll position",e.cellId);return}if(!t.querySelector(`.${ge.outputArea}`)){E.warn("Could not find output area to restore scroll position",e.cellId);return}t.scrollIntoView({block:"start",behavior:"auto"})}function He(){let e=(0,ja.c)(2),t=P(ye),n;return e[0]===t?n=e[1]:(n=()=>{let o=va();t(s=>({mode:st(s.mode),cellAnchor:(o==null?void 0:o.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{Ca(o)})})},e[0]=t,e[1]=n),n}const qe=Ue(!1);var za=W();const Ma=()=>{let e=(0,za.c)(7),{selectedLayout:t}=je(),{setLayoutView:n}=ve();if(ne()&&!$e("wasm_layouts"))return null;let o;e[0]===n?o=e[1]:(o=i=>n(i),e[0]=n,e[1]=o);let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)($t,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(Bt,{placeholder:"Select a view"})}),e[2]=s):s=e[2];let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)(Gt,{children:(0,a.jsxs)(Yt,{children:[(0,a.jsx)(Ot,{children:"View as"}),Ae.map(Sa)]})}),e[3]=r):r=e[3];let l;return e[4]!==t||e[5]!==o?(l=(0,a.jsxs)(Kt,{"data-testid":"layout-select",value:t,onValueChange:o,children:[s,r]}),e[4]=t,e[5]=o,e[6]=l):l=e[6],l};function Wa(e){return(0,a.jsx)(Re(e),{className:"h-4 w-4"})}function Re(e){switch(e){case"vertical":return ya;case"grid":return Nt;case"slides":return Ie;default:return rt(e),It}}function Fe(e){return be(e)}function Sa(e){return(0,a.jsx)(Ut,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[Wa(e),(0,a.jsx)("span",{children:Fe(e)})]})},e)}async function _a(e){let{filename:t,preset:n,downloadPDF:o}=e;await o({filename:t,webpdf:!1,preset:n,includeInputs:!0,rasterServer:"static"})}var Aa=W();function Da(e){let t=(0,Aa.c)(5),{openPrompt:n,closeModal:o}=le(),{sendCopy:s}=I(),r;return t[0]!==o||t[1]!==n||t[2]!==s||t[3]!==e?(r=()=>{if(!e)return null;let l=Ft.guessDeliminator(e);n({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${_e.basename(e)}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:i=>{let d=l.join(_e.dirname(e),i);s({source:e,destination:d}).then(()=>{o(),C({title:"Notebook copied",description:"A copy of the notebook has been created."}),ra(d)})}})},t[0]=o,t[1]=n,t[2]=s,t[3]=e,t[4]=r):r=t[4],r}const Na=()=>{let{updateCellConfig:e}=fe(),{saveCellConfig:t}=I();return(0,re.useCallback)(async()=>{let n=new Ke,o=ke(),s=o.cellIds.inOrderIds,r={};for(let i of s){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 l=we.entries(r);if(l.length!==0){await t({configs:r});for(let[i,d]of l)e({cellId:i,config:d})}},[e])};var Pa=W();function Ve(){let e=(0,Pa.c)(4),{openConfirm:t}=le(),n=P(mt),{sendRestart:o}=I(),s;return e[0]!==t||e[1]!==o||e[2]!==n?(s=()=>{t({title:"Restart Kernel",description:"This will restart the Python kernel. You'll lose all data that's in memory. You will also lose any unsaved changes, so make sure to save your work before restarting.",variant:"destructive",confirmAction:(0,a.jsx)(Xt,{onClick:async()=>{n({state:ut.CLOSING}),await o(),oa()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=o,e[2]=n,e[3]=s):s=e[3],s}var Ea=W(),_=e=>{e==null||e.preventDefault(),e==null||e.stopPropagation()};function Ia(){var pe,me;let e=(0,Ea.c)(42),t=ia(),{openModal:n,closeModal:o}=le(),{toggleApplication:s}=lt(),{selectedPanel:r}=Xe(),[l]=Be(ye),i=ae(tt),d=Na(),[p]=pt(),{updateCellConfig:w,undoDeleteCell:g,clearAllCellOutputs:u,addSetupCellIfDoesntExist:f,collapseAllCells:y,expandAllCells:k}=fe(),b=Ve(),x=ot(),j=Da(t),v=P(qe),A=P(ct),z=P(ht),{exportAsMarkdown:$,readCode:D,saveCellConfig:K,updateCellOutputs:J}=I(),X=da(),Q=ae(Qe),Z=ae(it),{selectedLayout:T}=je(),{setLayoutView:ee}=ve(),L=He(),H=((pe=p.sharing)==null?void 0:pe.html)??!0,q=((me=p.sharing)==null?void 0:me.wasm)??!0,ce=!ne(),R=T==="slides",Oe=Za,he=Qa,F;e[0]!==t||e[1]!==X||e[2]!==J?(F=async c=>{let{preset:m,title:N}=c;if(!t){de();return}await xt(N,async te=>{await ca({takeScreenshots:()=>X({progress:te}),updateCellOutputs:J}),await _a({filename:t,preset:m,downloadPDF:wt})})},e[0]=t,e[1]=X,e[2]=J,e[3]=F):F=e[3];let V=F,O;e[4]===Symbol.for("react.memo_cache_sentinel")?(O=(0,a.jsx)(Mt,{size:14,strokeWidth:1.5}),e[4]=O):O=e[4];let B;e[5]===Symbol.for("react.memo_cache_sentinel")?(B=(0,a.jsx)(Ce,{size:14,strokeWidth:1.5}),e[5]=B):B=e[5];let M;e[6]===t?M=e[7]:(M=async()=>{if(!t){de();return}await ze({filename:t,includeCode:!0})},e[6]=t,e[7]=M);let U;return e[8]!==f||e[9]!==Z||e[10]!==u||e[11]!==o||e[12]!==y||e[13]!==j||e[14]!==V||e[15]!==k||e[16]!==$||e[17]!==t||e[18]!==Q||e[19]!==d||e[20]!==R||e[21]!==i||e[22]!==n||e[23]!==D||e[24]!==b||e[25]!==x||e[26]!==K||e[27]!==T||e[28]!==r||e[29]!==v||e[30]!==z||e[31]!==ee||e[32]!==A||e[33]!==H||e[34]!==q||e[35]!==M||e[36]!==s||e[37]!==L||e[38]!==g||e[39]!==w||e[40]!==l.mode?(U=[{icon:O,label:"Download",handle:_,dropdown:[{icon:B,label:"Download as HTML",handle:M},{icon:(0,a.jsx)(Ce,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{if(!t){de();return}await ze({filename:t,includeCode:!1})}},{icon:(0,a.jsx)(la,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{let c=await $({download:!1});Se(new Blob([c],{type:"text/plain"}),We.toMarkdown(document.title))}},{icon:(0,a.jsx)(bt,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let c=await D();Se(new Blob([c.contents],{type:"text/plain"}),We.toPY(document.title))}},{divider:!0,icon:(0,a.jsx)(Tt,{size:14,strokeWidth:1.5}),label:"Download as PNG",disabled:l.mode!=="present",tooltip:l.mode==="present"?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",sa("global.hideCode",!1)]}),handle:Xa},{divider:!0,icon:(0,a.jsx)(se,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:_,dropdown:[{icon:(0,a.jsx)(se,{size:14,strokeWidth:1.5}),label:"Document Layout",rightElement:he(!R),handle:async()=>{if(ce){await V({preset:"document",title:"Downloading Document PDF..."});return}let c=new Event("export-beforeprint"),m=new Event("export-afterprint");(function(){window.dispatchEvent(c),setTimeout(Ja,0),setTimeout(()=>window.dispatchEvent(m),0)})()}},{icon:(0,a.jsx)(se,{size:14,strokeWidth:1.5}),label:"Slides Layout",rightElement:he(R),hidden:!ce,handle:async()=>{await V({preset:"slides",title:"Downloading Slides PDF..."})}}]}]},{icon:(0,a.jsx)(ba,{size:14,strokeWidth:1.5}),label:"Share",handle:_,hidden:!H&&!q,dropdown:[{icon:(0,a.jsx)(At,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!H,handle:async()=>{n((0,a.jsx)(wa,{onClose:o}))}},{icon:(0,a.jsx)(Lt,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!q,handle:async()=>{await G(na({code:(await D()).contents})),C({title:"Copied",description:"Link copied to clipboard."})}}]},{icon:(0,a.jsx)(ka,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:_,dropdown:Ye.flatMap(c=>{let{type:m,Icon:N,hidden:te}=c;return te?[]:{label:be(m),rightElement:Oe(r===m),icon:(0,a.jsx)(N,{size:14,strokeWidth:1.5}),handle:()=>s(m)}})},{icon:(0,a.jsx)(Ie,{size:14,strokeWidth:1.5}),label:"Present as",handle:_,dropdown:[{icon:l.mode==="present"?(0,a.jsx)(Rt,{size:14,strokeWidth:1.5}):(0,a.jsx)(Ee,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{L()}},...Ae.map((c,m)=>{let N=Re(c);return{divider:m===0,label:Fe(c),icon:(0,a.jsx)(N,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:T===c&&(0,a.jsx)(Me,{size:14})}),handle:()=>{ee(c),l.mode==="edit"&&L()}}})]},{icon:(0,a.jsx)(ua,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!t||ne(),handle:j},{icon:(0,a.jsx)(De,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!t,handle:async()=>{await G((await D()).contents),C({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(Ct,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!Q||i,handle:async()=>{let c=Je(ke());await K({configs:we.fromEntries(c.map(Ka))});for(let m of c)w({cellId:m,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)(Pe,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{f({})}},{icon:(0,a.jsx)(Ze,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n((0,a.jsx)(xe,{onClose:o}))}},{icon:(0,a.jsx)(dt,{size:14,strokeWidth:1.5}),label:"Add remote storage",handle:()=>{n((0,a.jsx)(xe,{defaultTab:"storage",onClose:o}))}},{icon:(0,a.jsx)(Te,{size:14,strokeWidth:1.5}),label:"Undo cell deletion",hidden:!Z||i,handle:()=>{g()}},{icon:(0,a.jsx)(xa,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:b},{icon:(0,a.jsx)(ma,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{x()}},{icon:(0,a.jsx)(et,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{u()}},{icon:(0,a.jsx)(Wt,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:d,redundant:!0},{icon:(0,a.jsx)(pa,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:y,redundant:!0},{icon:(0,a.jsx)(ha,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:k,redundant:!0},{divider:!0,icon:(0,a.jsx)(Ne,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>v($a)},{icon:(0,a.jsx)(fa,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>z(Ya)},{icon:(0,a.jsx)(qt,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>A(Ga),redundant:!0},{icon:(0,a.jsx)(vt,{size:14,strokeWidth:1.5}),label:"Resources",handle:_,dropdown:[{icon:(0,a.jsx)(at,{size:14,strokeWidth:1.5}),label:"Documentation",handle:Ua},{icon:(0,a.jsx)(_t,{size:14,strokeWidth:1.5}),label:"GitHub",handle:Ba},{icon:(0,a.jsx)(Dt,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:Oa},{icon:(0,a.jsx)(Pt,{size:14,strokeWidth:1.5}),label:"YouTube",handle:Va},{icon:(0,a.jsx)(nt,{size:14,strokeWidth:1.5}),label:"Changelog",handle:Fa}]},{divider:!0,icon:(0,a.jsx)(Et,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:Ra},{icon:(0,a.jsx)(St,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:qa}].filter(Ha).map(Ta),e[8]=f,e[9]=Z,e[10]=u,e[11]=o,e[12]=y,e[13]=j,e[14]=V,e[15]=k,e[16]=$,e[17]=t,e[18]=Q,e[19]=d,e[20]=R,e[21]=i,e[22]=n,e[23]=D,e[24]=b,e[25]=x,e[26]=K,e[27]=T,e[28]=r,e[29]=v,e[30]=z,e[31]=ee,e[32]=A,e[33]=H,e[34]=q,e[35]=M,e[36]=s,e[37]=L,e[38]=g,e[39]=w,e[40]=l.mode,e[41]=U):U=e[41],U}function Ta(e){return e.dropdown?{...e,dropdown:e.dropdown.filter(La)}:e}function La(e){return!e.hidden}function Ha(e){return!e.hidden}function qa(){let e=Vt();window.open(e,"_blank")}function Ra(){let e=document.baseURI.split("?")[0];window.open(e,"_self")}function Fa(){window.open(S.releasesPage,"_blank")}function Va(){window.open(S.youtube,"_blank")}function Oa(){window.open(S.discordLink,"_blank")}function Ba(){window.open(S.githubPage,"_blank")}function Ua(){window.open(S.docsPage,"_blank")}function Ga(e){return!e}function Ya(e){return!e}function $a(e){return!e}function Ka(e){return[e,{disabled:!1}]}function Ja(){return window.print()}async function Xa(){let e=document.getElementById("App");e&&await gt({element:e,filename:document.title,prepare:jt})}function Qa(e){return e?(0,a.jsx)("span",{className:"ml-3 shrink-0 rounded-full border border-emerald-200 bg-emerald-50 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-emerald-700",children:"Recommended"}):null}function Za(e){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:e&&(0,a.jsx)(Me,{size:14})})}function de(){C({title:"Error",description:"Notebooks must be named to be exported.",variant:"danger"})}export{He as a,Pe as c,qe as i,Ne as l,Ve as n,Te as o,Ma as r,Ee as s,Ia as t,De as u};