@marimo-team/frontend 0.21.2-dev1 → 0.21.2-dev13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/assets/{JsonOutput-DKXKGKvX.js → JsonOutput-0OSBP9mW.js} +1 -1
  2. package/dist/assets/{add-cell-with-ai-DUn4LN4W.js → add-cell-with-ai-CngarziZ.js} +1 -1
  3. package/dist/assets/{agent-panel-u83dsDsM.js → agent-panel-BEDG3iXT.js} +1 -1
  4. package/dist/assets/{cell-editor-DX7IcqNr.js → cell-editor-DYbGTjbA.js} +1 -1
  5. package/dist/assets/{chat-display-D_Fuuy6r.js → chat-display-CQpJ2w8h.js} +1 -1
  6. package/dist/assets/{chat-panel-BO-JoQSp.js → chat-panel-DctJaHWw.js} +1 -1
  7. package/dist/assets/{column-preview-WsubyItX.js → column-preview-BRmbsSSX.js} +1 -1
  8. package/dist/assets/{command-palette-Bez4BqJF.js → command-palette-DR4A-wEc.js} +1 -1
  9. package/dist/assets/{context-aware-panel-CfsfBlhO.js → context-aware-panel-DpscNCjB.js} +1 -1
  10. package/dist/assets/{dependency-graph-panel-AOBcX2tP.js → dependency-graph-panel-C6qsCxd3.js} +1 -1
  11. package/dist/assets/{download-B9_ToVd4.js → download-CubygmCt.js} +4 -4
  12. package/dist/assets/{edit-page-otS-QvnC.js → edit-page-DEylVQeS.js} +3 -3
  13. package/dist/assets/{file-explorer-panel-CB8vF5ob.js → file-explorer-panel-POO8DT3e.js} +1 -1
  14. package/dist/assets/{hooks-CHx5dUUq.js → hooks-C6oI58kL.js} +1 -1
  15. package/dist/assets/html-to-image-D2AayAxp.js +2 -0
  16. package/dist/assets/{index-GjXovVsl.css → index-CkOKOnvu.css} +1 -1
  17. package/dist/assets/{index-0n92c_W7.js → index-CnrVTVWS.js} +4 -4
  18. package/dist/assets/{layout-CwFtCyW8.js → layout-TQCb0upy.js} +1 -1
  19. package/dist/assets/{markdown-renderer-MR9df58W.js → markdown-renderer-Cq3Wh2i9.js} +1 -1
  20. package/dist/assets/{panels-wTweRyIv.js → panels-C_hjAdk2.js} +1 -1
  21. package/dist/assets/{readonly-python-code-DH-1xZGq.js → readonly-python-code-D4-6Eh-f.js} +1 -1
  22. package/dist/assets/{run-page-FCvGnICa.js → run-page-CFOIz6Rr.js} +1 -1
  23. package/dist/assets/{scratchpad-panel-k9lrm-rC.js → scratchpad-panel-CAzUtGTa.js} +1 -1
  24. package/dist/assets/{session-panel-WhN0qilM.js → session-panel-BDWXmSLj.js} +1 -1
  25. package/dist/assets/{useAddCell-YC7rpcmD.js → useAddCell-Q17XaFd_.js} +1 -1
  26. package/dist/assets/{useCellActionButton-GUb2fXU8.js → useCellActionButton-CQp_OE4x.js} +1 -1
  27. package/dist/assets/{useDependencyPanelTab-nFVMlEx0.js → useDependencyPanelTab-DjgvHfyz.js} +1 -1
  28. package/dist/assets/{useNotebookActions-ChLHy-0O.js → useNotebookActions-DEOC7V-6.js} +1 -1
  29. package/dist/index.html +12 -12
  30. package/package.json +1 -1
  31. package/src/css/md.css +7 -0
  32. package/src/plugins/impl/SliderPlugin.tsx +1 -3
  33. package/src/plugins/impl/__tests__/SliderPlugin.test.tsx +120 -0
  34. package/src/utils/__tests__/download.test.tsx +2 -2
  35. package/src/utils/download.ts +4 -3
  36. package/src/utils/html-to-image.ts +6 -0
  37. package/dist/assets/html-to-image-BnSc-Wa0.js +0 -2
@@ -1,4 +1,4 @@
1
- var Dt=Object.defineProperty;var zt=(t,e,n)=>e in t?Dt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var B=(t,e,n)=>zt(t,typeof e!="symbol"?e+"":e,n);import{s as Re}from"./chunk-LvLJmgfZ.js";import{i as Ot,l as me,n as L,p as Te,u as se}from"./useEvent-O0nX5vok.js";import{t as Mt}from"./react-Bj1aDYRI.js";import{E as $t,Qr as Rt,er as Tt,gn as At,ti as Ae,yn as Ee}from"./cells-fq1RMGX_.js";import"./react-dom-CSu739Rf.js";import{t as te}from"./compiler-runtime-B3qBwwSJ.js";import"./utils-CdjCA1J8.js";import{i as Ie,r as Et,t as Le}from"./add-connection-dialog-CBz0AUVX.js";import{h as It,m as ge}from"./useEventListener-Dy81QR4n.js";import{t as Lt}from"./invariant-CQUIhlu2.js";import{p as Bt,u as Be}from"./utils-tNbLd14P.js";import{S as he}from"./config-3Aq84phF.js";import{t as Vt}from"./jsx-runtime-icT_Ltz2.js";import{n as Ht,t as R}from"./button-Ej3vmCIF.js";import{t as q}from"./cn-BoaCR37F.js";import{St as Ut}from"./dist-B_cxg-E4.js";import{a as qt,i as Ve,o as pe}from"./JsonOutput-DKXKGKvX.js";import"./cjs-BU2qXMKx.js";import"./main-DrBRErTM.js";import"./useNonce-BtW-rR_1.js";import{n as Wt,r as je}from"./requests-Bgjtqo_1.js";import{t as ae}from"./createLucideIcon-Cm-Z7dYr.js";import{a as He,c as Ue,i as qe,n as fe,o as ye,r as Kt,t as Gt}from"./state-CBmCYWFH.js";import{n as Jt}from"./LazyAnyLanguageCodeMirror-m8w66E4s.js";import{a as Qt,i as Yt,n as be,o as Zt,r as Xt,t as ea}from"./tree-Ch2-GuhG.js";import{t as ta}from"./x-BI1M8X_v.js";import{c as aa,i as ve,r as We}from"./download-B9_ToVd4.js";import{f as we}from"./maps-OKerBHH8.js";import{n as na}from"./markdown-renderer-MR9df58W.js";import{u as sa}from"./toDate-BqKH-Jd9.js";import{a as M,c as ne,p as Ke,r as Ge,t as Je}from"./dropdown-menu-DdPu5Kfu.js";import{t as Ne}from"./copy-CkudG0Ej.js";import{t as ke}from"./download-DBW9RXtT.js";import{t as ra}from"./eye-off-vwi9L975.js";import{a as ia,i as Qe,n as Ye,r as la,t as oa}from"./file-icons-CWLHDa1J.js";import{t as Ze}from"./file-plus-corner-lLQw9OnR.js";import{t as Xe}from"./file-DzHkbIdO.js";import{t as ca}from"./link-Cf10mh3t.js";import{n as Ce,t as da}from"./spinner-C5JoisA7.js";import{t as et}from"./plus-dVmh0yTy.js";import{t as tt}from"./refresh-cw-CHAHPgkx.js";import{t as ma}from"./save-8fSvKYJT.js";import{t as ha}from"./trash-2-CAoNMkjq.js";import{t as pa}from"./triangle-alert-qZo1ox6x.js";import{i as fa,n as xa,t as ua}from"./es-CzkousWe.js";import"./dist-BNC_tnlW.js";import"./dist-CXLJUPFl.js";import"./dist-CQqv2gQL.js";import"./dist-8UD0A5sU.js";import"./dist-apDpadc4.js";import{t as A}from"./use-toast-Hc8CXlvz.js";import{t as Fe}from"./paths-D2lG83Oh.js";import"./session-BrEm7qNv.js";import"./Combination-Cs9nbinQ.js";import{t as T}from"./tooltip-D9723Brr.js";import"./purify.es-BBn8CPhf.js";import"./dates-CHaNfieI.js";import{o as ga}from"./alert-dialog-9WfvUF7e.js";import{t as at}from"./context-CIAP2NOh.js";import"./popover-BPGG2gPG.js";import{n as nt}from"./ImperativeModal-qEtcJ95s.js";import{r as ja}from"./errors-Bfogio62.js";import{n as ya}from"./blob-CObhN-9g.js";import"./vega-loader.browser-CZV6_g2i.js";import"./defaultLocale-OkOxlkkM.js";import"./defaultLocale-DK1MWd7f.js";import{n as re}from"./copy-YwM0Pd7v.js";import{t as ba}from"./copy-icon-BgmMM9Zg.js";import{n as va}from"./multi-map-Pp1P2DOX.js";import{n as wa,t as Na}from"./alert-OQZHipbB.js";import{n as st}from"./error-banner-BRG6IPhC.js";import{n as _e}from"./useAsyncData-D-4ifFXh.js";import{a as ka,o as rt,t as Ca,u as Fa}from"./command-rfxSsiHU.js";import"./chunk-5FQGJX7Z-CM1a_K7I.js";import"./katex-rvFxOCU-.js";import"./html-to-image-BnSc-Wa0.js";import{o as _a}from"./focus-DYwTiH9-.js";import{a as Sa}from"./renderShortcut-CnD1Dah5.js";import{t as Pa}from"./bundle.esm-idScn0w0.js";import{t as Da}from"./useAddCell-YC7rpcmD.js";import{a as za,c as Se,d as Pe,l as it,u as lt}from"./components-Bpgzv_5_.js";import{t as Oa}from"./empty-state-B_US46Us.js";import{t as De}from"./formatting-B4ZCH3ol.js";import{a as Ma,i as $a,n as ot,r as ct,t as dt}from"./components-Ozq0825a.js";import{n as mt,t as Ra}from"./marimo-icons-C_YDiXeg.js";import{t as Ta}from"./links-CIQwYQ48.js";var Aa=ae("copy-minus",[["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),ht=ae("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),pt=ae("list-tree",[["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"M3 10a2 2 0 0 0 2 2h3",key:"1npucw"}],["path",{d:"M3 5v12a2 2 0 0 0 2 2h3",key:"x1gjn2"}]]),Ea=ae("pen-line",[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]),Ia=ae("square-play",[["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["path",{d:"M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z",key:"kmsa83"}]]),ft=ae("view",[["path",{d:"M21 17v2a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-2",key:"mrq65r"}],["path",{d:"M21 7V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2",key:"be3xqs"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M18.944 12.33a1 1 0 0 0 0-.66 7.5 7.5 0 0 0-13.888 0 1 1 0 0 0 0 .66 7.5 7.5 0 0 0 13.888 0",key:"11ak4c"}]]),z=Re(Mt(),1),La=te(),a=Re(Vt(),1);const xt=t=>{let e=(0,La.c)(17),{filename:n,filenameIcon:i,onBack:r,onRefresh:s,onDownload:c,actions:o}=t,h;e[0]===r?h=e[1]:(h=r&&(0,a.jsx)(T,{content:"Back to file list",children:(0,a.jsx)(R,{variant:"text",size:"xs",onClick:r,children:(0,a.jsx)(Ue,{className:"h-4 w-4"})})}),e[0]=r,e[1]=h);let l;e[2]!==n||e[3]!==i?(l=n?(0,a.jsxs)("span",{className:"flex items-center gap-1.5 flex-1 min-w-0 text-xs font-semibold truncate",children:[i,n]}):(0,a.jsx)("span",{className:"flex-1"}),e[2]=n,e[3]=i,e[4]=l):l=e[4];let f;e[5]===s?f=e[6]:(f=s&&(0,a.jsx)(T,{content:"Refresh",children:(0,a.jsx)(R,{variant:"text",size:"xs",onClick:s,children:(0,a.jsx)(tt,{className:"h-3.5 w-3.5"})})}),e[5]=s,e[6]=f);let j;e[7]===c?j=e[8]:(j=c&&(0,a.jsx)(T,{content:"Download",children:(0,a.jsx)(R,{variant:"text",size:"xs",onClick:c,children:(0,a.jsx)(ke,{className:"h-3.5 w-3.5"})})}),e[7]=c,e[8]=j);let y;e[9]!==o||e[10]!==f||e[11]!==j?(y=(0,a.jsxs)("div",{className:"flex items-center gap-0.5 shrink-0",children:[f,o,j]}),e[9]=o,e[10]=f,e[11]=j,e[12]=y):y=e[12];let p;return e[13]!==h||e[14]!==l||e[15]!==y?(p=(0,a.jsxs)("div",{className:"flex items-center shrink-0 border-b px-1 gap-1",children:[h,l,y]}),e[13]=h,e[14]=l,e[15]=y,e[16]=p):p=e[16],p};var Ba=100*1024*1024;function Va(t){let e=t.endsWith("/")?t.slice(0,-1):t,n=e.split("/");return n[n.length-1]||e}const Ha=({entry:t,namespace:e,onBack:n})=>{let{locale:i}=at(),r=Va(t.path),s=t.mimeType||"text/plain",c=pe(s),o=c&&t.size>Ba&&t.size>0,{data:h,isPending:l,error:f,refetch:j}=_e(async()=>{if(o)return null;let x=await ye.request({namespace:e,path:t.path,preview:!c});if(x.error)throw Error(x.error);if(!x.url)throw Error("No URL returned");if(c)return{type:"media",url:x.url};let b=await fetch(x.url);if(!b.ok)throw Error(`Failed to fetch preview: ${b.statusText}`);return{type:"text",content:await b.text()}},[e,t.path,c,o]),y=(0,z.useCallback)(async()=>{try{let x=await ye.request({namespace:e,path:t.path});if(x.error){A({title:"Download failed",description:x.error,variant:"danger"});return}x.url&&ve(x.url,x.filename??r)}catch(x){ge.error("Failed to download storage entry",x),A({title:"Download failed",description:String(x),variant:"danger"})}},[e,t.path,r]),p=(0,a.jsx)(xt,{filename:r,filenameIcon:Qe(r),onBack:n,onDownload:y}),m=({includeMime:x=!1})=>(0,a.jsxs)("div",{className:"grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 p-4 text-xs",children:[(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"Path"}),(0,a.jsxs)("div",{className:"truncate flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"font-mono text-[11px]",children:t.path}),(0,a.jsx)(ba,{value:t.path,className:"h-3 w-3"})]}),x&&(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"Type"}),x&&(0,a.jsx)("span",{children:s}),t.size>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"Size"}),(0,a.jsx)("span",{children:De(t.size,i)})]}),t.lastModified!=null&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"Modified"}),(0,a.jsx)("span",{children:new Date(t.lastModified*1e3).toLocaleString()})]})]});return o?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[p,m({includeMime:!0}),(0,a.jsxs)("div",{className:"px-4 pb-4 text-xs text-muted-foreground italic",children:["File is too large to preview (",De(t.size,i),")."]})]}):l?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[p,m({}),(0,a.jsxs)("div",{className:"flex-1 flex items-center justify-center gap-2 text-xs text-muted-foreground min-h-24",children:[(0,a.jsx)(Ce,{className:"h-4 w-4 animate-spin"}),"Loading preview..."]})]}):f?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[p,m({includeMime:!0}),(0,a.jsxs)("div",{className:"px-4 pb-4 text-xs text-destructive",children:["Failed to load preview: ",f.message]}),(0,a.jsx)("div",{className:"px-4 pb-4",children:(0,a.jsxs)(R,{variant:"secondary",size:"xs",onClick:j,children:[(0,a.jsx)(tt,{className:"h-3 w-3 mr-1"}),"Retry"]})})]}):h?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[p,m({}),(0,a.jsx)(Ve,{mimeType:s,contents:h.type==="text"?h.content:void 0,mediaSource:h.type==="media"?{url:h.url}:void 0})]}):(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[p,m({includeMime:!0}),(0,a.jsxs)("div",{className:"p-4 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,a.jsx)(Xe,{className:"h-4 w-4"}),"Preview not available for this file type."]})]})};var Ua=new Set(["http","file","in-memory"]);function ze(t){return JSON.stringify(t).slice(1,-1)}const qa=[{id:"read-file",label:"Insert read snippet",icon:Zt,getCode:t=>{if(t.entry.kind==="directory")return null;let e=ze(t.entry.path);return t.backendType==="obstore"?`_data = ${t.variableName}.get("${e}").bytes()
1
+ var Dt=Object.defineProperty;var zt=(t,e,n)=>e in t?Dt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var B=(t,e,n)=>zt(t,typeof e!="symbol"?e+"":e,n);import{s as Re}from"./chunk-LvLJmgfZ.js";import{i as Ot,l as me,n as L,p as Te,u as se}from"./useEvent-O0nX5vok.js";import{t as Mt}from"./react-Bj1aDYRI.js";import{E as $t,Qr as Rt,er as Tt,gn as At,ti as Ae,yn as Ee}from"./cells-fq1RMGX_.js";import"./react-dom-CSu739Rf.js";import{t as te}from"./compiler-runtime-B3qBwwSJ.js";import"./utils-CdjCA1J8.js";import{i as Ie,r as Et,t as Le}from"./add-connection-dialog-CBz0AUVX.js";import{h as It,m as ge}from"./useEventListener-Dy81QR4n.js";import{t as Lt}from"./invariant-CQUIhlu2.js";import{p as Bt,u as Be}from"./utils-tNbLd14P.js";import{S as he}from"./config-3Aq84phF.js";import{t as Vt}from"./jsx-runtime-icT_Ltz2.js";import{n as Ht,t as R}from"./button-Ej3vmCIF.js";import{t as q}from"./cn-BoaCR37F.js";import{St as Ut}from"./dist-B_cxg-E4.js";import{a as qt,i as Ve,o as pe}from"./JsonOutput-0OSBP9mW.js";import"./cjs-BU2qXMKx.js";import"./main-DrBRErTM.js";import"./useNonce-BtW-rR_1.js";import{n as Wt,r as je}from"./requests-Bgjtqo_1.js";import{t as ae}from"./createLucideIcon-Cm-Z7dYr.js";import{a as He,c as Ue,i as qe,n as fe,o as ye,r as Kt,t as Gt}from"./state-CBmCYWFH.js";import{n as Jt}from"./LazyAnyLanguageCodeMirror-m8w66E4s.js";import{a as Qt,i as Yt,n as be,o as Zt,r as Xt,t as ea}from"./tree-Ch2-GuhG.js";import{t as ta}from"./x-BI1M8X_v.js";import{c as aa,i as ve,r as We}from"./download-CubygmCt.js";import{f as we}from"./maps-OKerBHH8.js";import{n as na}from"./markdown-renderer-Cq3Wh2i9.js";import{u as sa}from"./toDate-BqKH-Jd9.js";import{a as M,c as ne,p as Ke,r as Ge,t as Je}from"./dropdown-menu-DdPu5Kfu.js";import{t as Ne}from"./copy-CkudG0Ej.js";import{t as ke}from"./download-DBW9RXtT.js";import{t as ra}from"./eye-off-vwi9L975.js";import{a as ia,i as Qe,n as Ye,r as la,t as oa}from"./file-icons-CWLHDa1J.js";import{t as Ze}from"./file-plus-corner-lLQw9OnR.js";import{t as Xe}from"./file-DzHkbIdO.js";import{t as ca}from"./link-Cf10mh3t.js";import{n as Ce,t as da}from"./spinner-C5JoisA7.js";import{t as et}from"./plus-dVmh0yTy.js";import{t as tt}from"./refresh-cw-CHAHPgkx.js";import{t as ma}from"./save-8fSvKYJT.js";import{t as ha}from"./trash-2-CAoNMkjq.js";import{t as pa}from"./triangle-alert-qZo1ox6x.js";import{i as fa,n as xa,t as ua}from"./es-CzkousWe.js";import"./dist-BNC_tnlW.js";import"./dist-CXLJUPFl.js";import"./dist-CQqv2gQL.js";import"./dist-8UD0A5sU.js";import"./dist-apDpadc4.js";import{t as A}from"./use-toast-Hc8CXlvz.js";import{t as Fe}from"./paths-D2lG83Oh.js";import"./session-BrEm7qNv.js";import"./Combination-Cs9nbinQ.js";import{t as T}from"./tooltip-D9723Brr.js";import"./purify.es-BBn8CPhf.js";import"./dates-CHaNfieI.js";import{o as ga}from"./alert-dialog-9WfvUF7e.js";import{t as at}from"./context-CIAP2NOh.js";import"./popover-BPGG2gPG.js";import{n as nt}from"./ImperativeModal-qEtcJ95s.js";import{r as ja}from"./errors-Bfogio62.js";import{n as ya}from"./blob-CObhN-9g.js";import"./vega-loader.browser-CZV6_g2i.js";import"./defaultLocale-OkOxlkkM.js";import"./defaultLocale-DK1MWd7f.js";import{n as re}from"./copy-YwM0Pd7v.js";import{t as ba}from"./copy-icon-BgmMM9Zg.js";import{n as va}from"./multi-map-Pp1P2DOX.js";import{n as wa,t as Na}from"./alert-OQZHipbB.js";import{n as st}from"./error-banner-BRG6IPhC.js";import{n as _e}from"./useAsyncData-D-4ifFXh.js";import{a as ka,o as rt,t as Ca,u as Fa}from"./command-rfxSsiHU.js";import"./chunk-5FQGJX7Z-CM1a_K7I.js";import"./katex-rvFxOCU-.js";import"./html-to-image-D2AayAxp.js";import{o as _a}from"./focus-DYwTiH9-.js";import{a as Sa}from"./renderShortcut-CnD1Dah5.js";import{t as Pa}from"./bundle.esm-idScn0w0.js";import{t as Da}from"./useAddCell-Q17XaFd_.js";import{a as za,c as Se,d as Pe,l as it,u as lt}from"./components-Bpgzv_5_.js";import{t as Oa}from"./empty-state-B_US46Us.js";import{t as De}from"./formatting-B4ZCH3ol.js";import{a as Ma,i as $a,n as ot,r as ct,t as dt}from"./components-Ozq0825a.js";import{n as mt,t as Ra}from"./marimo-icons-C_YDiXeg.js";import{t as Ta}from"./links-CIQwYQ48.js";var Aa=ae("copy-minus",[["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),ht=ae("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),pt=ae("list-tree",[["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"M3 10a2 2 0 0 0 2 2h3",key:"1npucw"}],["path",{d:"M3 5v12a2 2 0 0 0 2 2h3",key:"x1gjn2"}]]),Ea=ae("pen-line",[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]),Ia=ae("square-play",[["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["path",{d:"M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z",key:"kmsa83"}]]),ft=ae("view",[["path",{d:"M21 17v2a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-2",key:"mrq65r"}],["path",{d:"M21 7V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2",key:"be3xqs"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M18.944 12.33a1 1 0 0 0 0-.66 7.5 7.5 0 0 0-13.888 0 1 1 0 0 0 0 .66 7.5 7.5 0 0 0 13.888 0",key:"11ak4c"}]]),z=Re(Mt(),1),La=te(),a=Re(Vt(),1);const xt=t=>{let e=(0,La.c)(17),{filename:n,filenameIcon:i,onBack:r,onRefresh:s,onDownload:c,actions:o}=t,h;e[0]===r?h=e[1]:(h=r&&(0,a.jsx)(T,{content:"Back to file list",children:(0,a.jsx)(R,{variant:"text",size:"xs",onClick:r,children:(0,a.jsx)(Ue,{className:"h-4 w-4"})})}),e[0]=r,e[1]=h);let l;e[2]!==n||e[3]!==i?(l=n?(0,a.jsxs)("span",{className:"flex items-center gap-1.5 flex-1 min-w-0 text-xs font-semibold truncate",children:[i,n]}):(0,a.jsx)("span",{className:"flex-1"}),e[2]=n,e[3]=i,e[4]=l):l=e[4];let f;e[5]===s?f=e[6]:(f=s&&(0,a.jsx)(T,{content:"Refresh",children:(0,a.jsx)(R,{variant:"text",size:"xs",onClick:s,children:(0,a.jsx)(tt,{className:"h-3.5 w-3.5"})})}),e[5]=s,e[6]=f);let j;e[7]===c?j=e[8]:(j=c&&(0,a.jsx)(T,{content:"Download",children:(0,a.jsx)(R,{variant:"text",size:"xs",onClick:c,children:(0,a.jsx)(ke,{className:"h-3.5 w-3.5"})})}),e[7]=c,e[8]=j);let y;e[9]!==o||e[10]!==f||e[11]!==j?(y=(0,a.jsxs)("div",{className:"flex items-center gap-0.5 shrink-0",children:[f,o,j]}),e[9]=o,e[10]=f,e[11]=j,e[12]=y):y=e[12];let p;return e[13]!==h||e[14]!==l||e[15]!==y?(p=(0,a.jsxs)("div",{className:"flex items-center shrink-0 border-b px-1 gap-1",children:[h,l,y]}),e[13]=h,e[14]=l,e[15]=y,e[16]=p):p=e[16],p};var Ba=100*1024*1024;function Va(t){let e=t.endsWith("/")?t.slice(0,-1):t,n=e.split("/");return n[n.length-1]||e}const Ha=({entry:t,namespace:e,onBack:n})=>{let{locale:i}=at(),r=Va(t.path),s=t.mimeType||"text/plain",c=pe(s),o=c&&t.size>Ba&&t.size>0,{data:h,isPending:l,error:f,refetch:j}=_e(async()=>{if(o)return null;let x=await ye.request({namespace:e,path:t.path,preview:!c});if(x.error)throw Error(x.error);if(!x.url)throw Error("No URL returned");if(c)return{type:"media",url:x.url};let b=await fetch(x.url);if(!b.ok)throw Error(`Failed to fetch preview: ${b.statusText}`);return{type:"text",content:await b.text()}},[e,t.path,c,o]),y=(0,z.useCallback)(async()=>{try{let x=await ye.request({namespace:e,path:t.path});if(x.error){A({title:"Download failed",description:x.error,variant:"danger"});return}x.url&&ve(x.url,x.filename??r)}catch(x){ge.error("Failed to download storage entry",x),A({title:"Download failed",description:String(x),variant:"danger"})}},[e,t.path,r]),p=(0,a.jsx)(xt,{filename:r,filenameIcon:Qe(r),onBack:n,onDownload:y}),m=({includeMime:x=!1})=>(0,a.jsxs)("div",{className:"grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 p-4 text-xs",children:[(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"Path"}),(0,a.jsxs)("div",{className:"truncate flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"font-mono text-[11px]",children:t.path}),(0,a.jsx)(ba,{value:t.path,className:"h-3 w-3"})]}),x&&(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"Type"}),x&&(0,a.jsx)("span",{children:s}),t.size>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"Size"}),(0,a.jsx)("span",{children:De(t.size,i)})]}),t.lastModified!=null&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"Modified"}),(0,a.jsx)("span",{children:new Date(t.lastModified*1e3).toLocaleString()})]})]});return o?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[p,m({includeMime:!0}),(0,a.jsxs)("div",{className:"px-4 pb-4 text-xs text-muted-foreground italic",children:["File is too large to preview (",De(t.size,i),")."]})]}):l?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[p,m({}),(0,a.jsxs)("div",{className:"flex-1 flex items-center justify-center gap-2 text-xs text-muted-foreground min-h-24",children:[(0,a.jsx)(Ce,{className:"h-4 w-4 animate-spin"}),"Loading preview..."]})]}):f?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[p,m({includeMime:!0}),(0,a.jsxs)("div",{className:"px-4 pb-4 text-xs text-destructive",children:["Failed to load preview: ",f.message]}),(0,a.jsx)("div",{className:"px-4 pb-4",children:(0,a.jsxs)(R,{variant:"secondary",size:"xs",onClick:j,children:[(0,a.jsx)(tt,{className:"h-3 w-3 mr-1"}),"Retry"]})})]}):h?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[p,m({}),(0,a.jsx)(Ve,{mimeType:s,contents:h.type==="text"?h.content:void 0,mediaSource:h.type==="media"?{url:h.url}:void 0})]}):(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[p,m({includeMime:!0}),(0,a.jsxs)("div",{className:"p-4 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,a.jsx)(Xe,{className:"h-4 w-4"}),"Preview not available for this file type."]})]})};var Ua=new Set(["http","file","in-memory"]);function ze(t){return JSON.stringify(t).slice(1,-1)}const qa=[{id:"read-file",label:"Insert read snippet",icon:Zt,getCode:t=>{if(t.entry.kind==="directory")return null;let e=ze(t.entry.path);return t.backendType==="obstore"?`_data = ${t.variableName}.get("${e}").bytes()
2
2
  _data`:`_data = ${t.variableName}.cat_file("${e}")
3
3
  _data`}},{id:"download-file",label:"Insert download snippet",icon:ca,getCode:t=>{if(t.entry.kind==="directory")return null;let e=ze(t.entry.path);if(t.backendType==="obstore")return Ua.has(t.protocol)?null:`from datetime import timedelta
4
4
  from obstore import sign
@@ -1 +1 @@
1
- var O=Object.defineProperty;var V=(t,e,i)=>e in t?O(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var b=(t,e,i)=>V(t,typeof e!="symbol"?e+"":e,i);import{u as I}from"./useEvent-O0nX5vok.js";import{o as j}from"./cells-fq1RMGX_.js";import{t as T}from"./compiler-runtime-B3qBwwSJ.js";import{c as k,m as E}from"./useEventListener-Dy81QR4n.js";import{i as N}from"./utils-tNbLd14P.js";import{h as P,x as _}from"./config-3Aq84phF.js";import{r as z}from"./requests-Bgjtqo_1.js";import{f as D}from"./layout-CwFtCyW8.js";import{s as $,u as B}from"./download-B9_ToVd4.js";import{t as H}from"./Deferred-BMfCOLaw.js";import{t as L}from"./use-toast-Hc8CXlvz.js";import{t as x}from"./useInterval-BJucVdV-.js";var R=class{constructor(){b(this,"capturedInputs",new Map);b(this,"inFlight",new Map)}cancelEntry(t){t.controller.abort(),t.deferred.status==="pending"&&t.deferred.resolve(void 0)}needsCapture(t,e){if(this.capturedInputs.get(t)===e)return!1;let i=this.inFlight.get(t);return!(i&&i.inputValue===e)}waitForInFlight(t,e){let i=this.inFlight.get(t);return i&&i.inputValue===e?i.deferred.promise:null}startCapture(t,e){let i=this.inFlight.get(t);i&&this.cancelEntry(i);let n=new AbortController,l=new H,u={controller:n,inputValue:e,deferred:l};return this.inFlight.set(t,u),{signal:n.signal,markCaptured:p=>{this.inFlight.get(t)===u&&(l.resolve(p),this.capturedInputs.set(t,e),this.inFlight.delete(t))},markFailed:()=>{this.inFlight.get(t)===u&&(l.resolve(void 0),this.inFlight.delete(t))}}}prune(t){for(let e of this.capturedInputs.keys())t.has(e)||this.capturedInputs.delete(e);for(let[e,i]of this.inFlight)t.has(e)||(this.cancelEntry(i),this.inFlight.delete(e))}get isCapturing(){return this.inFlight.size>0}abort(){for(let t of this.inFlight.values())this.cancelEntry(t);this.inFlight.clear()}reset(){this.abort(),this.capturedInputs.clear()}},Y=T(),M=5e3;function q(){let t=(0,Y.c)(14),e=I(N),{state:i}=I(P),n=e.auto_download.includes("markdown"),l=e.auto_download.includes("html"),u=e.auto_download.includes("ipynb"),p=i===_.OPEN,m=!n||!p,d=!l||!p,h=!u||!p,{autoExportAsHTML:a,autoExportAsIPYNB:s,autoExportAsMarkdown:r,updateCellOutputs:o}=z(),c=S(),f;t[0]===r?f=t[1]:(f=async()=>{await r({download:!1})},t[0]=r,t[1]=f);let g;t[2]===m?g=t[3]:(g={delayMs:M,whenVisible:!0,disabled:m},t[2]=m,t[3]=g),x(f,g);let w;t[4]===a?w=t[5]:(w=async()=>{await a({download:!1,includeCode:!0,files:D.INSTANCE.filenames()})},t[4]=a,t[5]=w);let v;t[6]===d?v=t[7]:(v={delayMs:M,whenVisible:!0,disabled:d},t[6]=d,t[7]=v),x(w,v);let F;t[8]!==s||t[9]!==c||t[10]!==o?(F=async()=>{await A({takeScreenshots:()=>c({progress:B.indeterminate()}),updateCellOutputs:o}),await s({download:!1})},t[8]=s,t[9]=c,t[10]=o,t[11]=F):F=t[11];let y;t[12]===h?y=t[13]:(y={delayMs:M,whenVisible:!0,disabled:h,skipIfRunning:!0},t[12]=h,t[13]=y),x(F,y)}var G=new Set(["text/html","application/vnd.vegalite.v5+json","application/vnd.vega.v5+json","application/vnd.vegalite.v6+json","application/vnd.vega.v6+json"]);const C=new R;function S(){let t=I(j);return async e=>{var d,h;let{progress:i}=e,n=new Set(k.keys(t));C.prune(n);let l=[],u=[];for(let[a,s]of k.entries(t)){let r=(d=s.output)==null?void 0:d.data;if((h=s.output)!=null&&h.mimetype&&G.has(s.output.mimetype)&&r)if(C.needsCapture(a,r))l.push([a,r]);else{let o=C.waitForInFlight(a,r);o&&u.push({cellId:a,promise:o})}}if(l.length===0&&u.length===0)return{};l.length>0&&i.addTotal(l.length);let p={};for(let[a,s]of l){let r=C.startCapture(a,s);try{let o=await $(a);if(r.signal.aborted)continue;if(!o){E.error(`Failed to capture screenshot for cell ${a}`),r.markFailed();continue}let c=["image/png",o];p[a]=c,r.markCaptured(c)}catch(o){E.error(`Error screenshotting cell ${a}:`,o),r.markFailed()}finally{i.increment(1)}}let m=await Promise.allSettled(u.map(({promise:a})=>a));for(let[a,{cellId:s}]of u.entries()){let r=m[a];r.status==="fulfilled"&&r.value&&(p[s]=r.value)}return p}}async function A(t){let{takeScreenshots:e,updateCellOutputs:i}=t;try{let n=await e();k.size(n)>0&&await i({cellIdsToOutput:n})}catch(n){E.error("Error updating cell outputs with screenshots:",n),L({title:"Failed to capture cell outputs",description:"Some outputs may not appear in the PDF. Continuing with export.",variant:"danger"})}}export{q as n,S as r,A as t};
1
+ var O=Object.defineProperty;var V=(t,e,i)=>e in t?O(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var b=(t,e,i)=>V(t,typeof e!="symbol"?e+"":e,i);import{u as I}from"./useEvent-O0nX5vok.js";import{o as j}from"./cells-fq1RMGX_.js";import{t as T}from"./compiler-runtime-B3qBwwSJ.js";import{c as k,m as E}from"./useEventListener-Dy81QR4n.js";import{i as N}from"./utils-tNbLd14P.js";import{h as P,x as _}from"./config-3Aq84phF.js";import{r as z}from"./requests-Bgjtqo_1.js";import{f as D}from"./layout-TQCb0upy.js";import{s as $,u as B}from"./download-CubygmCt.js";import{t as H}from"./Deferred-BMfCOLaw.js";import{t as L}from"./use-toast-Hc8CXlvz.js";import{t as x}from"./useInterval-BJucVdV-.js";var R=class{constructor(){b(this,"capturedInputs",new Map);b(this,"inFlight",new Map)}cancelEntry(t){t.controller.abort(),t.deferred.status==="pending"&&t.deferred.resolve(void 0)}needsCapture(t,e){if(this.capturedInputs.get(t)===e)return!1;let i=this.inFlight.get(t);return!(i&&i.inputValue===e)}waitForInFlight(t,e){let i=this.inFlight.get(t);return i&&i.inputValue===e?i.deferred.promise:null}startCapture(t,e){let i=this.inFlight.get(t);i&&this.cancelEntry(i);let n=new AbortController,l=new H,u={controller:n,inputValue:e,deferred:l};return this.inFlight.set(t,u),{signal:n.signal,markCaptured:p=>{this.inFlight.get(t)===u&&(l.resolve(p),this.capturedInputs.set(t,e),this.inFlight.delete(t))},markFailed:()=>{this.inFlight.get(t)===u&&(l.resolve(void 0),this.inFlight.delete(t))}}}prune(t){for(let e of this.capturedInputs.keys())t.has(e)||this.capturedInputs.delete(e);for(let[e,i]of this.inFlight)t.has(e)||(this.cancelEntry(i),this.inFlight.delete(e))}get isCapturing(){return this.inFlight.size>0}abort(){for(let t of this.inFlight.values())this.cancelEntry(t);this.inFlight.clear()}reset(){this.abort(),this.capturedInputs.clear()}},Y=T(),M=5e3;function q(){let t=(0,Y.c)(14),e=I(N),{state:i}=I(P),n=e.auto_download.includes("markdown"),l=e.auto_download.includes("html"),u=e.auto_download.includes("ipynb"),p=i===_.OPEN,m=!n||!p,d=!l||!p,h=!u||!p,{autoExportAsHTML:a,autoExportAsIPYNB:s,autoExportAsMarkdown:r,updateCellOutputs:o}=z(),c=S(),f;t[0]===r?f=t[1]:(f=async()=>{await r({download:!1})},t[0]=r,t[1]=f);let g;t[2]===m?g=t[3]:(g={delayMs:M,whenVisible:!0,disabled:m},t[2]=m,t[3]=g),x(f,g);let w;t[4]===a?w=t[5]:(w=async()=>{await a({download:!1,includeCode:!0,files:D.INSTANCE.filenames()})},t[4]=a,t[5]=w);let v;t[6]===d?v=t[7]:(v={delayMs:M,whenVisible:!0,disabled:d},t[6]=d,t[7]=v),x(w,v);let F;t[8]!==s||t[9]!==c||t[10]!==o?(F=async()=>{await A({takeScreenshots:()=>c({progress:B.indeterminate()}),updateCellOutputs:o}),await s({download:!1})},t[8]=s,t[9]=c,t[10]=o,t[11]=F):F=t[11];let y;t[12]===h?y=t[13]:(y={delayMs:M,whenVisible:!0,disabled:h,skipIfRunning:!0},t[12]=h,t[13]=y),x(F,y)}var G=new Set(["text/html","application/vnd.vegalite.v5+json","application/vnd.vega.v5+json","application/vnd.vegalite.v6+json","application/vnd.vega.v6+json"]);const C=new R;function S(){let t=I(j);return async e=>{var d,h;let{progress:i}=e,n=new Set(k.keys(t));C.prune(n);let l=[],u=[];for(let[a,s]of k.entries(t)){let r=(d=s.output)==null?void 0:d.data;if((h=s.output)!=null&&h.mimetype&&G.has(s.output.mimetype)&&r)if(C.needsCapture(a,r))l.push([a,r]);else{let o=C.waitForInFlight(a,r);o&&u.push({cellId:a,promise:o})}}if(l.length===0&&u.length===0)return{};l.length>0&&i.addTotal(l.length);let p={};for(let[a,s]of l){let r=C.startCapture(a,s);try{let o=await $(a);if(r.signal.aborted)continue;if(!o){E.error(`Failed to capture screenshot for cell ${a}`),r.markFailed();continue}let c=["image/png",o];p[a]=c,r.markCaptured(c)}catch(o){E.error(`Error screenshotting cell ${a}:`,o),r.markFailed()}finally{i.increment(1)}}let m=await Promise.allSettled(u.map(({promise:a})=>a));for(let[a,{cellId:s}]of u.entries()){let r=m[a];r.status==="fulfilled"&&r.value&&(p[s]=r.value)}return p}}async function A(t){let{takeScreenshots:e,updateCellOutputs:i}=t;try{let n=await e();k.size(n)>0&&await i({cellIdsToOutput:n})}catch(n){E.error("Error updating cell outputs with screenshots:",n),L({title:"Failed to capture cell outputs",description:"Some outputs may not appear in the PDF. Continuing with export.",variant:"danger"})}}export{q as n,S as r,A as t};
@@ -0,0 +1,2 @@
1
+ import{i as q}from"./useEvent-O0nX5vok.js";import{Sn as W,b as G,si as C}from"./cells-fq1RMGX_.js";import{m as v}from"./useEventListener-Dy81QR4n.js";import{t as $}from"./requests-Bgjtqo_1.js";function I({moduleName:e,variableName:t,onAddImport:r,appStore:n=q}){if(t in n.get(W))return!1;let{cellData:i,cellIds:o}=n.get(G),a=RegExp(`import[ ]+${e}[ ]+as[ ]+${t}`,"g");for(let l of o.inOrderIds)if(a.test(i[l].code))return!1;return r(`import ${e} as ${t}`),!0}function J({autoInstantiate:e,createNewCell:t,fromCellId:r,before:n}){let i=$(),o=null;return I({moduleName:"marimo",variableName:"mo",onAddImport:a=>{o=C.create(),t({cellId:r??"__end__",before:n??!1,code:a,lastCodeRun:e?a:void 0,newCellId:o,skipIfCodeExists:!0,autoFocus:!1}),e&&i.sendRun({cellIds:[o],codes:[a]})}})?o:null}function K({autoInstantiate:e,createNewCell:t,fromCellId:r}){let n=$(),i=null;return I({moduleName:"altair",variableName:"alt",onAddImport:o=>{i=C.create(),t({cellId:r??"__end__",before:!1,code:o,lastCodeRun:e?o:void 0,newCellId:i,skipIfCodeExists:!0,autoFocus:!1}),e&&n.sendRun({cellIds:[i],codes:[o]})}})?i:null}function X(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;let r=document.implementation.createHTMLDocument(),n=r.createElement("base"),i=r.createElement("a");return r.head.appendChild(n),r.body.appendChild(i),t&&(n.href=t),i.href=e,i.href}const Y=(()=>{let e=0,t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function d(e){let t=[];for(let r=0,n=e.length;r<n;r++)t.push(e[r]);return t}var g=null;function R(e={}){return g||(e.includeStyleProperties?(g=e.includeStyleProperties,g):(g=d(window.getComputedStyle(document.documentElement)),g))}function p(e,t){let r=(e.ownerDocument.defaultView||window).getComputedStyle(e).getPropertyValue(t);return r?parseFloat(r.replace("px","")):0}function Z(e){let t=p(e,"border-left-width"),r=p(e,"border-right-width");return e.clientWidth+t+r}function ee(e){let t=p(e,"border-top-width"),r=p(e,"border-bottom-width");return e.clientHeight+t+r}function k(e,t={}){return{width:t.width||Z(e),height:t.height||ee(e)}}function te(){let e,t;try{t=process}catch{}let r=t&&t.env?t.env.devicePixelRatio:null;return r&&(e=parseInt(r,10),Number.isNaN(e)&&(e=1)),e||window.devicePixelRatio||1}var u=16384;function re(e){(e.width>u||e.height>u)&&(e.width>u&&e.height>u?e.width>e.height?(e.height*=u/e.width,e.width=u):(e.width*=u/e.height,e.height=u):e.width>u?(e.height*=u/e.width,e.width=u):(e.width*=u/e.height,e.height=u))}function w(e){return new Promise((t,r)=>{let n=new Image;n.onload=()=>{n.decode().then(()=>{requestAnimationFrame(()=>t(n))})},n.onerror=r,n.crossOrigin="anonymous",n.decoding="async",n.src=e})}async function ne(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function ie(e,t,r){let n="http://www.w3.org/2000/svg",i=document.createElementNS(n,"svg"),o=document.createElementNS(n,"foreignObject");return i.setAttribute("width",`${t}`),i.setAttribute("height",`${r}`),i.setAttribute("viewBox",`0 0 ${t} ${r}`),o.setAttribute("width","100%"),o.setAttribute("height","100%"),o.setAttribute("x","0"),o.setAttribute("y","0"),o.setAttribute("externalResourcesRequired","true"),i.appendChild(o),o.appendChild(e),ne(i)}const c=(e,t)=>{if(e instanceof t)return!0;let r=Object.getPrototypeOf(e);return r===null?!1:r.constructor.name===t.name||c(r,t)};function oe(e){let t=e.getPropertyValue("content");return`${e.cssText} content: '${t.replace(/'|"/g,"")}';`}function ae(e,t){return R(t).map(r=>`${r}: ${e.getPropertyValue(r)}${e.getPropertyPriority(r)?" !important":""};`).join(" ")}function le(e,t,r,n){let i=`.${e}:${t}`,o=r.cssText?oe(r):ae(r,n);return document.createTextNode(`${i}{${o}}`)}function P(e,t,r,n){let i=window.getComputedStyle(e,r),o=i.getPropertyValue("content");if(o===""||o==="none")return;let a=Y();try{t.className=`${t.className} ${a}`}catch{return}let l=document.createElement("style");l.appendChild(le(a,r,i,n)),t.appendChild(l)}function se(e,t,r){P(e,t,":before",r),P(e,t,":after",r)}var N="application/font-woff",T="image/jpeg",ce={woff:N,woff2:N,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:T,jpeg:T,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function ue(e){let t=/\.([^./]*?)$/g.exec(e);return t?t[1]:""}function A(e){return ce[ue(e).toLowerCase()]||""}function de(e){return e.split(/,/)[1]}function x(e){return e.search(/^(data:)/)!==-1}function L(e,t){return`data:${t};base64,${e}`}async function F(e,t,r){let n=await fetch(e,t);if(n.status===404)throw Error(`Resource "${n.url}" not found`);let i=await n.blob();return new Promise((o,a)=>{let l=new FileReader;l.onerror=a,l.onloadend=()=>{try{o(r({res:n,result:l.result}))}catch(s){a(s)}},l.readAsDataURL(i)})}var E={};function fe(e,t,r){let n=e.replace(/\?.*/,"");return r&&(n=e),/ttf|otf|eot|woff2?/i.test(n)&&(n=n.replace(/.*\//,"")),t?`[${t}]${n}`:n}async function S(e,t,r){let n=fe(e,t,r.includeQueryParams);if(E[n]!=null)return E[n];r.cacheBust&&(e+=(/\?/.test(e)?"&":"?")+new Date().getTime());let i;try{i=L(await F(e,r.fetchRequestInit,({res:o,result:a})=>(t||(t=o.headers.get("Content-Type")||""),de(a))),t)}catch(o){i=r.imagePlaceholder||"";let a=`Failed to fetch resource: ${e}`;o&&(a=typeof o=="string"?o:o.message),a&&console.warn(a)}return E[n]=i,i}async function he(e){let t=e.toDataURL();return t==="data:,"?e.cloneNode(!1):w(t)}async function me(e,t){if(e.currentSrc){let n=document.createElement("canvas"),i=n.getContext("2d");return n.width=e.clientWidth,n.height=e.clientHeight,i==null||i.drawImage(e,0,0,n.width,n.height),w(n.toDataURL())}let r=e.poster;return w(await S(r,A(r),t))}async function ge(e,t){var r;try{if((r=e==null?void 0:e.contentDocument)!=null&&r.body)return await y(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function pe(e,t){return c(e,HTMLCanvasElement)?he(e):c(e,HTMLVideoElement)?me(e,t):c(e,HTMLIFrameElement)?ge(e,t):e.cloneNode(H(e))}var we=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SLOT",H=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SVG";async function ye(e,t,r){var i;if(H(t))return t;let n=[];if(we(e)&&e.assignedNodes)n=d(e.assignedNodes());else if(c(e,HTMLIFrameElement))try{(i=e.contentDocument)!=null&&i.body&&(n=d(e.contentDocument.body.childNodes))}catch{}else n=d((e.shadowRoot??e).childNodes);return n.length===0||c(e,HTMLVideoElement)||await n.reduce((o,a)=>o.then(()=>y(a,r)).then(l=>{l&&t.appendChild(l)}),Promise.resolve()),t}function be(e,t,r){let n=t.style;if(!n)return;let i=window.getComputedStyle(e);i.cssText?(n.cssText=i.cssText,n.transformOrigin=i.transformOrigin):R(r).forEach(o=>{let a=i.getPropertyValue(o);o==="font-size"&&a.endsWith("px")&&(a=`${Math.floor(parseFloat(a.substring(0,a.length-2)))-.1}px`),c(e,HTMLIFrameElement)&&o==="display"&&a==="inline"&&(a="block"),o==="d"&&t.getAttribute("d")&&(a=`path(${t.getAttribute("d")})`),n.setProperty(o,a,i.getPropertyPriority(o))})}function Ae(e,t){c(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),c(e,HTMLInputElement)&&t.setAttribute("value",e.value)}function xe(e,t){if(c(e,HTMLSelectElement)){let r=t,n=Array.from(r.children).find(i=>e.value===i.getAttribute("value"));n&&n.setAttribute("selected","")}}function Ee(e,t,r){return c(t,Element)&&(be(e,t,r),se(e,t,r),Ae(e,t),xe(e,t)),t}async function Se(e,t){let r=e.querySelectorAll?e.querySelectorAll("use"):[];if(r.length===0)return e;let n={};for(let o=0;o<r.length;o++){let a=r[o].getAttribute("xlink:href");if(a){let l=e.querySelector(a),s=document.querySelector(a);!l&&s&&!n[a]&&(n[a]=await y(s,t,!0))}}let i=Object.values(n);if(i.length){let o="http://www.w3.org/1999/xhtml",a=document.createElementNS(o,"svg");a.setAttribute("xmlns",o),a.style.position="absolute",a.style.width="0",a.style.height="0",a.style.overflow="hidden",a.style.display="none";let l=document.createElementNS(o,"defs");a.appendChild(l);for(let s=0;s<i.length;s++)l.appendChild(i[s]);e.appendChild(a)}return e}async function y(e,t,r){return!r&&t.filter&&!t.filter(e)?null:Promise.resolve(e).then(n=>pe(n,t)).then(n=>ye(e,n,t)).then(n=>Ee(e,n,t)).then(n=>Se(n,t))}var V=/url\((['"]?)([^'"]+?)\1\)/g,Ce=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,ve=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function $e(e){let t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function Ie(e){let t=[];return e.replace(V,(r,n,i)=>(t.push(i),r)),t.filter(r=>!x(r))}async function Re(e,t,r,n,i){try{let o=r?X(t,r):t,a=A(t),l;return l=i?L(await i(o),a):await S(o,a,n),e.replace($e(t),`$1${l}$3`)}catch{}return e}function ke(e,{preferredFontFormat:t}){return t?e.replace(ve,r=>{for(;;){let[n,,i]=Ce.exec(r)||[];if(!i)return"";if(i===t)return`src: ${n};`}}):e}function D(e){return e.search(V)!==-1}async function M(e,t,r){if(!D(e))return e;let n=ke(e,r);return Ie(n).reduce((i,o)=>i.then(a=>Re(a,o,t,r)),Promise.resolve(n))}async function h(e,t,r){var i;let n=(i=t.style)==null?void 0:i.getPropertyValue(e);if(n){let o=await M(n,null,r);return t.style.setProperty(e,o,t.style.getPropertyPriority(e)),!0}return!1}async function Pe(e,t){await h("background",e,t)||await h("background-image",e,t),await h("mask",e,t)||await h("-webkit-mask",e,t)||await h("mask-image",e,t)||await h("-webkit-mask-image",e,t)}async function Ne(e,t){let r=c(e,HTMLImageElement);if(!(r&&!x(e.src))&&!(c(e,SVGImageElement)&&!x(e.href.baseVal)))return;let n=r?e.src:e.href.baseVal,i=await S(n,A(n),t);await new Promise((o,a)=>{e.onload=o,e.onerror=t.onImageErrorHandler?(...s)=>{try{o(t.onImageErrorHandler(...s))}catch(f){a(f)}}:a;let l=e;l.decode&&(l.decode=o),l.loading==="lazy"&&(l.loading="eager"),r?(e.srcset="",e.src=i):e.href.baseVal=i})}async function Te(e,t){let r=d(e.childNodes).map(n=>j(n,t));await Promise.all(r).then(()=>e)}async function j(e,t){c(e,Element)&&(await Pe(e,t),await Ne(e,t),await Te(e,t))}function Le(e,t){let{style:r}=e;t.backgroundColor&&(r.backgroundColor=t.backgroundColor),t.width&&(r.width=`${t.width}px`),t.height&&(r.height=`${t.height}px`);let n=t.style;return n!=null&&Object.keys(n).forEach(i=>{r[i]=n[i]}),e}var O={};async function U(e){let t=O[e];return t??(t={url:e,cssText:await(await fetch(e)).text()},O[e]=t,t)}async function z(e,t){let r=e.cssText,n=/url\(["']?([^"')]+)["']?\)/g,i=(r.match(/url\([^)]+\)/g)||[]).map(async o=>{let a=o.replace(n,"$1");return a.startsWith("https://")||(a=new URL(a,e.url).href),F(a,t.fetchRequestInit,({result:l})=>(r=r.replace(o,`url(${l})`),[o,l]))});return Promise.all(i).then(()=>r)}function _(e){if(e==null)return[];let t=[],r=e.replace(/(\/\*[\s\S]*?\*\/)/gi,""),n=RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){let a=n.exec(r);if(a===null)break;t.push(a[0])}r=r.replace(n,"");let i=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,o=RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})","gi");for(;;){let a=i.exec(r);if(a===null){if(a=o.exec(r),a===null)break;i.lastIndex=o.lastIndex}else o.lastIndex=i.lastIndex;t.push(a[0])}return t}async function Fe(e,t){let r=[],n=[];return e.forEach(i=>{if("cssRules"in i)try{d(i.cssRules||[]).forEach((o,a)=>{if(o.type===CSSRule.IMPORT_RULE){let l=a+1,s=o.href,f=U(s).then(m=>z(m,t)).then(m=>_(m).forEach(b=>{try{i.insertRule(b,b.startsWith("@import")?l+=1:i.cssRules.length)}catch(B){console.error("Error inserting rule from remote css",{rule:b,error:B})}})).catch(m=>{console.error("Error loading remote css",m.toString())});n.push(f)}})}catch(o){let a=e.find(l=>l.href==null)||document.styleSheets[0];i.href!=null&&n.push(U(i.href).then(l=>z(l,t)).then(l=>_(l).forEach(s=>{a.insertRule(s,a.cssRules.length)})).catch(l=>{console.error("Error loading remote stylesheet",l)})),console.error("Error inlining remote css file",o)}}),Promise.all(n).then(()=>(e.forEach(i=>{if("cssRules"in i)try{d(i.cssRules||[]).forEach(o=>{r.push(o)})}catch(o){console.error(`Error while reading CSS rules from ${i.href}`,o)}}),r))}function He(e){return e.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>D(t.style.getPropertyValue("src")))}async function Ve(e,t){if(e.ownerDocument==null)throw Error("Provided element is not within a Document");return He(await Fe(d(e.ownerDocument.styleSheets),t))}function Q(e){return(e||"").trim().replace(/["']/g,"")}function De(e){let t=new Set;function r(n){let i=n.style.fontFamily||getComputedStyle(n).fontFamily;i&&i.split(",").forEach(o=>{t.add(Q(o))}),Array.from(n.children).forEach(o=>{o instanceof HTMLElement&&r(o)})}return r(e),t}async function Me(e,t){let r=await Ve(e,t),n=De(e);return(await Promise.all(r.filter(i=>n.has(Q(i.style.fontFamily))).map(i=>{let o=i.parentStyleSheet?i.parentStyleSheet.href:null;return M(i.cssText,o,t)}))).join(`
2
+ `)}async function je(e,t){let r=t.fontEmbedCSS==null?t.skipFonts?null:await Me(e,t):t.fontEmbedCSS,n=t.extraStyleContent==null?r:(r||"").concat(t.extraStyleContent);if(n){let i=document.createElement("style"),o=document.createTextNode(n);i.appendChild(o),e.firstChild?e.insertBefore(i,e.firstChild):e.appendChild(i)}}async function Oe(e,t={}){let{width:r,height:n}=k(e,t),i=await y(e,t,!0);return await je(i,t),await j(i,t),Le(i,t),await ie(i,r,n)}async function Ue(e,t={}){let{width:r,height:n}=k(e,t),i=await w(await Oe(e,t)),o=document.createElement("canvas"),a=o.getContext("2d"),l=t.pixelRatio||te(),s=t.canvasWidth||r,f=t.canvasHeight||n;return o.width=s*l,o.height=f*l,t.skipAutoScale||re(o),o.style.width=`${s}`,o.style.height=`${f}`,t.backgroundColor&&(a.fillStyle=t.backgroundColor,a.fillRect(0,0,o.width,o.height)),a.drawImage(i,0,0,o.width,o.height),o}async function ze(e,t={}){return(await Ue(e,t)).toDataURL()}const _e={filter:e=>{try{if("classList"in e){let t=e.classList;if(t.contains("mpl-toolbar")||t.contains("print:hidden"))return!1}return!0}catch(t){return v.error("Error filtering node:",t),!0}},imagePlaceholder:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQI12NgAAIABQABNjN9GQAAAAlwSFlzAAAWJQAAFiUBSVIk8AAAAA0lEQVQI12P4z8BQDwAEgAF/QualIQAAAABJRU5ErkJggg==",onImageErrorHandler:e=>{v.error("Error loading image:",e)},includeStyleProperties:"width.height.min-width.min-height.max-width.max-height.box-sizing.aspect-ratio.display.position.top.left.bottom.right.z-index.float.clear.flex.flex-direction.flex-wrap.flex-grow.flex-shrink.flex-basis.align-items.align-self.justify-content.gap.order.grid-template-columns.grid-template-rows.grid-column.grid-row.row-gap.column-gap.margin.margin-top.margin-right.margin-bottom.margin-left.padding.padding-top.padding-right.padding-bottom.padding-left.font.font-family.font-size.font-weight.font-style.line-height.letter-spacing.word-spacing.text-align.text-decoration.text-transform.text-indent.text-shadow.white-space.text-wrap.word-break.text-overflow.vertical-align.color.background.background-color.background-image.background-size.background-position.background-repeat.background-clip.border.border-width.border-style.border-color.border-top.border-right.border-bottom.border-left.border-radius.outline.box-shadow.text-shadow.opacity.filter.backdrop-filter.mix-blend-mode.transform.clip-path.overflow.overflow-x.overflow-y.visibility.fill.stroke.stroke-width.object-fit.object-position.list-style.list-style-type.border-collapse.border-spacing.content.cursor".split(".")};async function Qe(e,t){return ze(e,{..._e,...t})}export{K as n,J as r,Qe as t};