@marimo-team/frontend 0.23.3 → 0.23.4-dev1

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 (80) hide show
  1. package/dist/assets/{CellStatus-BTL_sgUY.js → CellStatus-PIeZtHEl.js} +1 -1
  2. package/dist/assets/JsonOutput-BVAcY5xS.js +49 -0
  3. package/dist/assets/{MarimoErrorOutput-BBD405a6.js → MarimoErrorOutput-B9_RO5eX.js} +2 -2
  4. package/dist/assets/{RenderHTML-BT9obKLc.js → RenderHTML-DR6lqJGS.js} +1 -1
  5. package/dist/assets/{add-cell-with-ai-qEfAzC8R.js → add-cell-with-ai-DjfY8mF1.js} +9 -9
  6. package/dist/assets/{add-connection-dialog-HCShSlr3.js → add-connection-dialog-gd2yD9Qo.js} +2 -2
  7. package/dist/assets/{agent-panel-CoBHxHpJ.js → agent-panel-TetMUXWP.js} +3 -3
  8. package/dist/assets/{ai-model-dropdown-CYx9ZfdS.js → ai-model-dropdown-By4Ohb0R.js} +3 -3
  9. package/dist/assets/{app-config-button-DC5UlXZA.js → app-config-button-YS8lpoUa.js} +1 -1
  10. package/dist/assets/{cell-editor-BMjfXh0J.js → cell-editor-C6vZfKyj.js} +10 -10
  11. package/dist/assets/{cell-link-BA7Demf0.js → cell-link-d38hFEon.js} +1 -1
  12. package/dist/assets/{cells-CJlo_hG2.js → cells-A-ljPpuj.js} +55 -55
  13. package/dist/assets/{chat-display-DbztpRD4.js → chat-display-Be0U92hE.js} +1 -1
  14. package/dist/assets/{chat-panel-H-xFzATI.js → chat-panel-BEz970S3.js} +1 -1
  15. package/dist/assets/{chat-ui-CFqAy2ck.js → chat-ui-CdW7awFa.js} +1 -1
  16. package/dist/assets/{column-preview-DzN2QumC.js → column-preview-_5uYiy74.js} +1 -1
  17. package/dist/assets/{command-DbT_zkRP.js → command-CzIDL1VI.js} +1 -1
  18. package/dist/assets/{command-palette-DSSR50KF.js → command-palette-DfotChyr.js} +1 -1
  19. package/dist/assets/{common-CquNY-ok.js → common-DC9LEIym.js} +1 -1
  20. package/dist/assets/{components-BXKuiPiF.js → components-BDnRtsA5.js} +1 -1
  21. package/dist/assets/{components-BiBOcq1x.js → components-FepcpFGL.js} +1 -1
  22. package/dist/assets/{datasource-BKDU-4D5.js → datasource-BCnGIjqn.js} +2 -2
  23. package/dist/assets/{dependency-graph-panel-ayo-Mm2j.js → dependency-graph-panel-Yk1Ch_Gj.js} +1 -1
  24. package/dist/assets/{documentation-panel-ph6755dz.js → documentation-panel-BMrGuByB.js} +1 -1
  25. package/dist/assets/{download-mzsKQgiy.js → download-Iyng0xCz.js} +4 -4
  26. package/dist/assets/{edit-page-Bxa5DWoE.js → edit-page-C-LIP5uT.js} +6 -6
  27. package/dist/assets/{error-panel-BfG_JeMA.js → error-panel-CHSsnRFF.js} +1 -1
  28. package/dist/assets/{file-explorer-panel-D7-d0Puf.js → file-explorer-panel-Dlwspu2Y.js} +3 -3
  29. package/dist/assets/{file-icons-BNrh8MRG.js → file-icons-DTNZv05h.js} +1 -1
  30. package/dist/assets/{floating-outline-BMB4_phA.js → floating-outline-CSNGDMAm.js} +1 -1
  31. package/dist/assets/{focus-BX3gXJxx.js → focus-Baz7rlo0.js} +1 -1
  32. package/dist/assets/form-Dr-_EXr8.js +2 -0
  33. package/dist/assets/{home-page-B1ELDhn8.js → home-page-QvO22-4u.js} +1 -1
  34. package/dist/assets/{hooks-b3J1eFE-.js → hooks-CNPv5U-N.js} +1 -1
  35. package/dist/assets/{html-to-image-Cz8lDF-Y.js → html-to-image-tbPEMBJg.js} +1 -1
  36. package/dist/assets/{index-BjiE1T38.js → index-BFivsT-R.js} +8 -8
  37. package/dist/assets/index-DH5UUBE4.css +2 -0
  38. package/dist/assets/{kiosk-mode-Dxbs5i5g.js → kiosk-mode-cWTXpegb.js} +1 -1
  39. package/dist/assets/{layout-lxwMDUgI.js → layout-DDh3d8oW.js} +5 -5
  40. package/dist/assets/{logs-panel-BW6S5AI1.js → logs-panel-Dgkr6V7q.js} +1 -1
  41. package/dist/assets/{markdown-renderer-CeHY2KoQ.js → markdown-renderer-CFrgiLqu.js} +1 -1
  42. package/dist/assets/{name-cell-input-B1BCybeo.js → name-cell-input-C5LXTI3T.js} +1 -1
  43. package/dist/assets/{outline-panel-DgMz83Mx.js → outline-panel-0lyts6z4.js} +1 -1
  44. package/dist/assets/{packages-panel-CbjavFh2.js → packages-panel-BhI1lbfw.js} +1 -1
  45. package/dist/assets/{panels-BPzk3EbR.js → panels-CbRenLjk.js} +1 -1
  46. package/dist/assets/{process-output-CggRIZ6s.js → process-output-BwZ5VxXO.js} +1 -1
  47. package/dist/assets/{readonly-python-code-Ccd8HM-7.js → readonly-python-code-B0nrQE3U.js} +1 -1
  48. package/dist/assets/{reveal-component-BamXsTkr.js → reveal-component-CLjsFHmT.js} +1 -1
  49. package/dist/assets/{run-page-C5cZvltI.js → run-page-C1Wd8dr8.js} +1 -1
  50. package/dist/assets/{scratchpad-panel-PMFH4Ktp.js → scratchpad-panel-DpqODhZ3.js} +1 -1
  51. package/dist/assets/{session-panel-CUTSr9rt.js → session-panel-BvCIuxgU.js} +1 -1
  52. package/dist/assets/{slide-form-Bi8ZYBHP.js → slide-form-CXqvfwGg.js} +1 -1
  53. package/dist/assets/{snippets-panel-CdhDsAII.js → snippets-panel-COBTGJcr.js} +1 -1
  54. package/dist/assets/{state-C5AUgyZT.js → state-Bsz477is.js} +1 -1
  55. package/dist/assets/{state-DHlRrwyY.js → state-LyvUXW6A.js} +2 -2
  56. package/dist/assets/{textarea-BXPC1-kb.js → textarea-Dd0InTQJ.js} +1 -1
  57. package/dist/assets/{tracing-wSufGcF9.js → tracing-DjZGgWTo.js} +1 -1
  58. package/dist/assets/{tracing-panel-BO6MMAXa.js → tracing-panel-8eFzEjG0.js} +2 -2
  59. package/dist/assets/{useAddCell-CqBbGhrY.js → useAddCell-De9xD63_.js} +1 -1
  60. package/dist/assets/{useCellActionButton-DYwx4pGE.js → useCellActionButton-Bjxun3wK.js} +1 -1
  61. package/dist/assets/{useDeleteCell-BJlGbsbV.js → useDeleteCell-C2Stbb6Q.js} +1 -1
  62. package/dist/assets/{useDependencyPanelTab-rkAIQ6zL.js → useDependencyPanelTab-DFZNQ3a8.js} +1 -1
  63. package/dist/assets/{useNotebookActions-Dga3qEHF.js → useNotebookActions-F5fGMe9N.js} +1 -1
  64. package/dist/assets/{useRunCells-B531RIUE.js → useRunCells-DU1tawR-.js} +1 -1
  65. package/dist/assets/{useSplitCell-BnuJW5uo.js → useSplitCell-BZPuhd8z.js} +1 -1
  66. package/dist/index.html +25 -25
  67. package/package.json +1 -1
  68. package/src/components/data-table/data-table.tsx +11 -2
  69. package/src/components/data-table/filter-by-values-picker.tsx +238 -0
  70. package/src/components/data-table/filter-pill-editor.tsx +470 -0
  71. package/src/components/data-table/filter-pills.tsx +177 -41
  72. package/src/components/ui/checkbox.tsx +8 -4
  73. package/src/components/ui/combobox.tsx +3 -0
  74. package/src/css/app/Cell.css +4 -0
  75. package/src/plugins/impl/DataTablePlugin.tsx +1 -0
  76. package/src/plugins/impl/data-frames/forms/__tests__/__snapshots__/form.test.tsx.snap +15 -15
  77. package/src/utils/sets.ts +13 -0
  78. package/dist/assets/JsonOutput-DXnOS_Hk.js +0 -49
  79. package/dist/assets/form-CPDlIjdV.js +0 -2
  80. package/dist/assets/index-BYLYJcAY.css +0 -2
@@ -1,7 +1,7 @@
1
- import{s as J}from"./chunk-LvLJmgfZ.js";import{d as ve,f as Ne,l as be,u as ke}from"./useEvent-D91BmmQi.js";import{t as we}from"./react-Bj1aDYRI.js";import{E as Ie,Nn as $e,Tn as _e,ai as K,ar as Fe,b as Te,ii as Ae,nt as Ce,vi as Se}from"./cells-CJlo_hG2.js";import{t as q}from"./compiler-runtime-B3qBwwSJ.js";import{t as Me}from"./invariant-BUdrueMv.js";import{r as ze}from"./utils-DIGrmLDO.js";import{t as X}from"./cn-DCUzRj2J.js";import{t as Ee}from"./jsx-runtime-BqBOg78p.js";import{a as qe,i as Pe,n as Le,r as We}from"./multi-map-rafH3cg3.js";import{a as Ve,p as Be,r as Qe,t as De}from"./dropdown-menu-D1A3cFC8.js";import{t as Y}from"./tooltip-Gcwqb_SK.js";import{r as Z,t as $}from"./button-D9nb17Rw.js";import{t as H}from"./createLucideIcon-D5guW7EU.js";import{r as Oe}from"./x-C-6liIBr.js";import{t as He}from"./sparkles-CZ5WmLPA.js";import{c as ee,n as Ue}from"./datasource-BKDU-4D5.js";import{a as Re}from"./dist-CRPTyqAT.js";import{t as te}from"./RenderHTML-BT9obKLc.js";import{t as re}from"./kbd-CGShmG7L.js";import{t as T}from"./links-C-rLiK3d.js";import{r as Ge,t as Je}from"./alert-cDholnQq.js";import{o as Ke,t as Xe}from"./useInstallPackage-afgh7PwB.js";import{n as Ye}from"./state-C5AUgyZT.js";import{n as b}from"./cell-link-BA7Demf0.js";var Ze=H("package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]),A=H("square-arrow-out-up-right",[["path",{d:"M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6",key:"y09zxi"}],["path",{d:"m21 3-9 9",key:"mpx6sq"}],["path",{d:"M15 3h6v6",key:"1q9fwt"}]]),se=H("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);function et(t){let e=null,s=t.cursor();do s.name==="ExpressionStatement"&&(e=s.node);while(s.next());return e}function tt(t){let e=t.split(`
1
+ import{s as J}from"./chunk-LvLJmgfZ.js";import{d as ve,f as Ne,l as be,u as ke}from"./useEvent-D91BmmQi.js";import{t as we}from"./react-Bj1aDYRI.js";import{E as Ie,Nn as $e,Tn as _e,ai as Fe,ar as Te,b as Ae,nt as Ce,oi as K,yi as Se}from"./cells-A-ljPpuj.js";import{t as q}from"./compiler-runtime-B3qBwwSJ.js";import{t as Me}from"./invariant-BUdrueMv.js";import{r as ze}from"./utils-DIGrmLDO.js";import{t as X}from"./cn-DCUzRj2J.js";import{t as Ee}from"./jsx-runtime-BqBOg78p.js";import{a as qe,i as Pe,n as Le,r as We}from"./multi-map-rafH3cg3.js";import{a as Ve,p as Be,r as Qe,t as De}from"./dropdown-menu-D1A3cFC8.js";import{t as Y}from"./tooltip-Gcwqb_SK.js";import{r as Z,t as $}from"./button-D9nb17Rw.js";import{t as H}from"./createLucideIcon-D5guW7EU.js";import{r as Oe}from"./x-C-6liIBr.js";import{t as He}from"./sparkles-CZ5WmLPA.js";import{c as ee,n as Ue}from"./datasource-BCnGIjqn.js";import{a as Re}from"./dist-CRPTyqAT.js";import{t as te}from"./RenderHTML-DR6lqJGS.js";import{t as re}from"./kbd-CGShmG7L.js";import{t as T}from"./links-C-rLiK3d.js";import{r as Ge,t as Je}from"./alert-cDholnQq.js";import{o as Ke,t as Xe}from"./useInstallPackage-afgh7PwB.js";import{n as Ye}from"./state-Bsz477is.js";import{n as b}from"./cell-link-d38hFEon.js";var Ze=H("package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]),A=H("square-arrow-out-up-right",[["path",{d:"M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6",key:"y09zxi"}],["path",{d:"m21 3-9 9",key:"mpx6sq"}],["path",{d:"M15 3h6v6",key:"1q9fwt"}]]),se=H("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);function et(t){let e=null,s=t.cursor();do s.name==="ExpressionStatement"&&(e=s.node);while(s.next());return e}function tt(t){let e=t.split(`
2
2
  `),s=" ",n=et(Re.parse(t));if(!n)return["def _():",...U(e,s),`${s}return`,"","","_()"].join(`
3
3
  `);let i=t.slice(0,n.from).trim(),l=t.slice(n.from).trim(),a=i.split(`
4
4
  `),c=l.split(`
5
5
  `);return["def _():",...U(a,s),`${s}return ${c[0]}`,...U(c.slice(1),s),"","","_()"].join(`
6
6
  `)}function U(t,e){if(t.length===1&&t[0]==="")return[];let s=[];for(let n of t)n===""?s.push(""):s.push(e+n);return s}function rt(t,e){var s;if(t.type==="multiple-defs")return[{title:"Fix: Wrap in a function",description:"Make this cell's variables local by wrapping the cell in a function.",fixType:"manual",onFix:async n=>{Me(n.editor,"Editor is null");let i=tt(n.editor.state.doc.toString());n.editor.dispatch({changes:{from:0,to:n.editor.state.doc.length,insert:i}})}}];if(t.type==="exception"&&t.exception_type==="NameError"){let n=(s=t.msg.match(/name '(.+)' is not defined/))==null?void 0:s[1];if(!n||!(n in ne))return[];let i=st(n);return[{title:`Fix: Add '${i}'`,description:"Add a new cell for the missing import",fixType:"manual",onFix:async l=>{l.addCodeBelow(i)}}]}return t.type==="sql-error"&&e.aiEnabled?[{title:"Fix with AI",description:"Fix the SQL statement",fixType:"ai",onFix:async n=>{var a;let i=Ue(n.cellId),l=`Fix the SQL statement: ${t.msg}.`;i&&(l+=`
7
- Database schema: ${i}`),(a=n.aiFix)==null||a.setAiCompletionCell({cellId:n.cellId,initialPrompt:l,triggerImmediately:n.aiFix.triggerFix})}}]:[]}function st(t){let e=ne[t];return e===t?`import ${e}`:`import ${e} as ${t}`}var ne={mo:"marimo",alt:"altair",bokeh:"bokeh",dask:"dask",np:"numpy",pd:"pandas",pl:"polars",plotly:"plotly",plt:"matplotlib.pyplot",px:"plotly.express",scipy:"scipy",sk:"sklearn",sns:"seaborn",stats:"scipy.stats",tf:"tensorflow",torch:"torch",xr:"xarray",dt:"datetime",json:"json",math:"math",os:"os",re:"re",sys:"sys"},nt=q(),lt=Se("marimo:ai-autofix-mode","autofix",$e);function it(){let t=(0,nt.c)(3),[e,s]=be(lt),n;return t[0]!==e||t[1]!==s?(n={fixMode:e,setFixMode:s},t[0]=e,t[1]=s,t[2]=n):n=t[2],n}var R=q(),r=J(Ee(),1);const N=t=>{let e=(0,R.c)(21),{errors:s,cellId:n,className:i}=t,l=Ne(),{createNewCell:a}=Ie(),c=ke(ze),o;if(e[0]!==c||e[1]!==s){let x;e[3]===c?x=e[4]:(x=y=>rt(y,{aiEnabled:c}),e[3]=c,e[4]=x),o=s.flatMap(x),e[0]=c,e[1]=s,e[2]=o}else o=e[2];let m=o,p=ve(Ye);if(m.length===0)return null;let d=m[0],f;e[5]!==n||e[6]!==a||e[7]!==d||e[8]!==p||e[9]!==l?(f=x=>{var k;let y=(k=l.get(Te).cellHandles[n].current)==null?void 0:k.editorView;d.onFix({addCodeBelow:_=>{a({cellId:n,autoFocus:!1,before:!1,code:_})},editor:y,cellId:n,aiFix:{setAiCompletionCell:p,triggerFix:x}}),y==null||y.focus()},e[5]=n,e[6]=a,e[7]=d,e[8]=p,e[9]=l,e[10]=f):f=e[10];let u=f,j;e[11]===i?j=e[12]:(j=X("my-2",i),e[11]=i,e[12]=j);let h;e[13]!==d.description||e[14]!==d.fixType||e[15]!==d.title||e[16]!==u?(h=d.fixType==="ai"?(0,r.jsx)(ce,{tooltip:d.description,openPrompt:()=>u(!1),applyAutofix:()=>u(!0)}):(0,r.jsx)(Y,{content:d.description,align:"start",children:(0,r.jsxs)($,{size:"xs",variant:"outline",className:"font-normal",onClick:()=>u(!1),children:[(0,r.jsx)(ee,{className:"h-3 w-3 mr-2"}),d.title]})}),e[13]=d.description,e[14]=d.fixType,e[15]=d.title,e[16]=u,e[17]=h):h=e[17];let g;return e[18]!==j||e[19]!==h?(g=(0,r.jsx)("div",{className:j,children:h}),e[18]=j,e[19]=h,e[20]=g):g=e[20],g};var le=He,ie=ee,ae="Suggest a prompt",oe="Fix with AI";const ce=t=>{let e=(0,R.c)(21),{tooltip:s,openPrompt:n,applyAutofix:i}=t,{fixMode:l,setFixMode:a}=it(),c=l==="prompt"?n:i,o;e[0]===l?o=e[1]:(o=l==="prompt"?(0,r.jsx)(le,{className:"h-3 w-3 mr-2 mb-0.5"}):(0,r.jsx)(ie,{className:"h-3 w-3 mr-2 mb-0.5"}),e[0]=l,e[1]=o);let m=l==="prompt"?ae:oe,p;e[2]!==c||e[3]!==o||e[4]!==m?(p=(0,r.jsxs)($,{size:"xs",variant:"outline",className:"font-normal rounded-r-none border-r-0",onClick:c,children:[o,m]}),e[2]=c,e[3]=o,e[4]=m,e[5]=p):p=e[5];let d;e[6]!==p||e[7]!==s?(d=(0,r.jsx)(Y,{content:s,align:"start",children:p}),e[6]=p,e[7]=s,e[8]=d):d=e[8];let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f=(0,r.jsx)(Be,{asChild:!0,children:(0,r.jsx)($,{size:"xs",variant:"outline",className:"rounded-l-none px-2","aria-label":"Fix options",children:(0,r.jsx)(Oe,{className:"h-3 w-3"})})}),e[9]=f):f=e[9];let u;e[10]!==l||e[11]!==a?(u=()=>{a(l==="prompt"?"autofix":"prompt")},e[10]=l,e[11]=a,e[12]=u):u=e[12];let j=l==="prompt"?"autofix":"prompt",h;e[13]===j?h=e[14]:(h=(0,r.jsx)(at,{mode:j}),e[13]=j,e[14]=h);let g;e[15]!==u||e[16]!==h?(g=(0,r.jsxs)(De,{children:[f,(0,r.jsx)(Qe,{align:"end",className:"w-56",children:(0,r.jsx)(Ve,{className:"flex items-center gap-2",onClick:u,children:h})})]}),e[15]=u,e[16]=h,e[17]=g):g=e[17];let x;return e[18]!==g||e[19]!==d?(x=(0,r.jsxs)("div",{className:"flex",children:[d,g]}),e[18]=g,e[19]=d,e[20]=x):x=e[20],x};var at=t=>{let e=(0,R.c)(12),{mode:s}=t,n;e[0]===s?n=e[1]:(n=s==="prompt"?(0,r.jsx)(le,{className:"h-4 w-4"}):(0,r.jsx)(ie,{className:"h-4 w-4"}),e[0]=s,e[1]=n);let i=n,l=s==="prompt"?ae:oe,a=s==="prompt"?"Edit the prompt before applying":"Apply AI fixes automatically",c;e[2]===l?c=e[3]:(c=(0,r.jsx)("span",{className:"font-medium",children:l}),e[2]=l,e[3]=c);let o;e[4]===a?o=e[5]:(o=(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:a}),e[4]=a,e[5]=o);let m;e[6]!==c||e[7]!==o?(m=(0,r.jsxs)("div",{className:"flex flex-col",children:[c,o]}),e[6]=c,e[7]=o,e[8]=m):m=e[8];let p;return e[9]!==i||e[10]!==m?(p=(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[i,m]}),e[9]=i,e[10]=m,e[11]=p):p=e[11],p},de=/(https?:\/\/\S+)/,ot=/\.(png|jpe?g|gif|webp|svg|ico)(\?.*)?$/i,me=/^data:image\//i,ct=["avatars.githubusercontent.com"];function pe(t){return me.test(t)?[{type:"image",url:t}]:t.split(de).filter(e=>e!=="").map(e=>de.test(e)?ot.test(e)||me.test(e)||ct.some(s=>e.includes(s))?{type:"image",url:e}:{type:"url",url:e}:{type:"text",value:e})}var ue=q(),P=J(we(),1),dt=new Ce;const G=t=>{let e=RegExp("\x1B\\[[0-9;]*m","g");return t.replaceAll(e,"")};var he=/(pip\s+install|uv\s+add|uv\s+pip\s+install)\s+/gi;function mt(t){he.lastIndex=0;let e=he.exec(t);if(!e)return null;let s=e.index+e[0].length,n=t.slice(s).split(/\s+/),i="",l=0;for(let c of n){let o=c.trim();if(!o)continue;if(o.startsWith("-")){l+=o.length+1;continue}let m=o.match(/^[\w,.[\]-]+/);if(m){i=m[0];break}break}if(!i)return null;let a=s+l+i.length;return{package:i,endIndex:a}}function w(t,e=""){if(!t)return null;if(!/https?:\/\//.test(t))return t;let s=pe(t);return s.length===1&&s[0].type==="text"?t:(0,r.jsx)(r.Fragment,{children:s.map((n,i)=>{let l=e?`${e}-${i}`:i;if(n.type==="url"){let a=G(n.url);return(0,r.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:Z.stopPropagation(),className:"text-link hover:underline",children:a},l)}if(n.type==="image"){let a=G(n.url);return(0,r.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:Z.stopPropagation(),className:"text-link hover:underline",children:a},l)}return(0,r.jsx)(P.Fragment,{children:n.value},l)})})}var pt=t=>{let e=(0,ue.c)(6),{packages:s,children:n}=t,{handleInstallPackages:i}=Xe(),l;e[0]!==i||e[1]!==s?(l=c=>{i(s),c.preventDefault()},e[0]=i,e[1]=s,e[2]=l):l=e[2];let a;return e[3]!==n||e[4]!==l?(a=(0,r.jsx)("button",{onClick:l,className:"text-link hover:underline",type:"button",children:n}),e[3]=n,e[4]=l,e[5]=a):a=e[5],a};const ut=t=>{if(!(t instanceof K.Text))return;let e=G(t.data);if(!/(pip\s+install|uv\s+add|uv\s+pip\s+install)/i.test(e))return;let s=[],n=/(pip\s+install|uv\s+add|uv\s+pip\s+install)\s+/gi,i;for(;(i=n.exec(e))!==null;){let c=i.index,o=mt(e.slice(c));o&&s.push({match:i,result:o})}if(s.length===0)return;let l=[],a=0;if(s.forEach((c,o)=>{let{match:m,result:p}=c,d=m.index,f=d+p.endIndex;if(a<d){let j=e.slice(a,d);l.push((0,r.jsx)(P.Fragment,{children:w(j,`before-${o}`)},`before-${o}`))}let u=e.slice(d,f);l.push((0,r.jsx)(pt,{packages:[p.package],children:u},`install-${o}`)),a=f}),a<e.length){let c=e.slice(a);l.push((0,r.jsx)(P.Fragment,{children:w(c,"after")},"after"))}return(0,r.jsx)(r.Fragment,{children:l})},ht=t=>{if(!(t instanceof K.Text))return;let e=t.data;if(!/https?:\/\//.test(e))return;let s=w(e);if(typeof s!="string")return(0,r.jsx)(r.Fragment,{children:s})},xt=(...t)=>e=>{for(let s of t){let n=s(e);if(n!==void 0)return n}},ft=(t,e)=>(0,r.jsx)("span",{children:Ae(dt.ansi_to_html(t),{replace:s=>e(s)})}),jt=t=>{let e=(0,ue.c)(4),{text:s}=t,n;e[0]===s?n=e[1]:(n=ft(s,xt(ut,ht)),e[0]=s,e[1]=n);let i=n,l;return e[2]===i?l=e[3]:(l=(0,r.jsx)(r.Fragment,{children:i}),e[2]=i,e[3]=l),l};var xe=q(),I=t=>{let e=(0,xe.c)(10),s=t.title??"Tip",n;e[0]===s?n=e[1]:(n=(0,r.jsx)(qe,{className:"pt-2 pb-2 font-normal",children:s}),e[0]=s,e[1]=n);let i;e[2]===t.children?i=e[3]:(i=(0,r.jsx)(We,{className:"mr-24 text-[0.84375rem]",children:t.children}),e[2]=t.children,e[3]=i);let l;e[4]!==n||e[5]!==i?(l=(0,r.jsxs)(Pe,{value:"item-1",className:"text-muted-foreground",children:[n,i]}),e[4]=n,e[5]=i,e[6]=l):l=e[6];let a;return e[7]!==t.className||e[8]!==l?(a=(0,r.jsx)(Le,{type:"single",collapsible:!0,className:t.className,children:l}),e[7]=t.className,e[8]=l,e[9]=a):a=e[9],a};const gt=t=>{let e=(0,xe.c)(31),{errors:s,cellId:n,className:i}=t,l=_e(),a="This cell wasn't run because it has errors",c="destructive",o="text-error";if(s.some(yt))a="Interrupted";else if(s.some(vt))a="An internal error occurred";else if(s.some(Nt))a="Ancestor prevented from running",c="default",o="text-secondary-foreground";else if(s.some(bt))a="Ancestor stopped",c="default",o="text-secondary-foreground";else if(s.some(kt))a="SQL error";else{let x;e[0]===s?x=e[1]:(x=s.find(wt),e[0]=s,e[1]=x);let y=x;y&&"exception_type"in y&&(a=y.exception_type)}let m,p,d,f,u,j;if(e[2]!==c||e[3]!==n||e[4]!==l||e[5]!==i||e[6]!==s||e[7]!==o||e[8]!==a){let x=s.filter(It),y=s.filter($t),k=s.filter(_t),_=s.filter(Ft),L=s.filter(Tt),C=s.filter(At),S=s.filter(Ct),W=s.filter(St),V=s.filter(Mt),B=s.filter(zt),F=s.filter(Et),Q=s.filter(qt),D=s.filter(Pt),M;e[15]===l?M=e[16]:(M=()=>{l.openApplication("scratchpad")},e[15]=l,e[16]=M);let fe=M,je=()=>{let v=[];if(F.length>0||Q.length>0){let E=F.some(Lt),ye=!E&&F.some(Wt);v.push((0,r.jsxs)("div",{children:[F.map(Vt),Q.map(Bt),E&&(0,r.jsxs)($,{size:"xs",variant:"outline",className:"mt-2 font-normal",onClick:()=>Ke(l),children:[(0,r.jsx)(Ze,{className:"h-3.5 w-3.5 mr-1.5 mb-0.5"}),(0,r.jsx)("span",{children:"Open package manager"})]}),ye&&(0,r.jsxs)($,{size:"xs",variant:"outline",className:"mt-2 font-normal",onClick:()=>l.openApplication("terminal"),children:[(0,r.jsx)(se,{className:"h-3.5 w-3.5 mr-1.5"}),(0,r.jsx)("span",{children:"Open terminal"})]}),n&&(0,r.jsx)(N,{errors:[...F,...Q],cellId:n})]},"syntax-unknown"))}if(x.length>0&&v.push((0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-muted-foreground font-medium",children:"The setup cell cannot be run because it has references."}),(0,r.jsx)("ul",{className:"list-disc",children:x.flatMap(Qt)}),n&&(0,r.jsx)(N,{errors:x,cellId:n}),(0,r.jsxs)(I,{title:"Why can't the setup cell have references?",className:"mb-2",children:[(0,r.jsx)("p",{className:"pb-2",children:"The setup cell contains logic that must be run before any other cell runs, including top-level imports used by top-level functions. For this reason, it can't refer to other cells' variables."}),(0,r.jsx)("p",{className:"py-2",children:"Try simplifying the setup cell to only contain only necessary variables."}),(0,r.jsxs)("p",{className:"py-2",children:[(0,r.jsxs)(T,{href:"https://links.marimo.app/errors-setup",children:["Learn more at our docs"," ",(0,r.jsx)(A,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"setup-refs")),y.length>0&&v.push((0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-muted-foreground font-medium",children:"This cell is in a cycle."}),(0,r.jsx)("ul",{className:"list-disc",children:y.flatMap(Dt)}),n&&(0,r.jsx)(N,{errors:y,cellId:n}),(0,r.jsxs)(I,{title:"What are cycles and how do I resolve them?",className:"mb-2",children:[(0,r.jsx)("p",{className:"pb-2",children:"An example of a cycle is if one cell declares a variable 'a' and reads 'b', and another cell declares 'b' and and reads 'a'. Cycles like this make it impossible for marimo to know how to run your cells, and generally suggest that your code has a bug."}),(0,r.jsx)("p",{className:"py-2",children:"Try merging these cells into a single cell to eliminate the cycle."}),(0,r.jsxs)("p",{className:"py-2",children:[(0,r.jsxs)(T,{href:"https://links.marimo.app/errors-cycles",children:["Learn more at our docs"," ",(0,r.jsx)(A,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"cycle")),k.length>0){let E=k[0].name;v.push((0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-muted-foreground font-medium",children:"This cell redefines variables from other cells."}),k.map(Ht),n&&(0,r.jsx)(N,{errors:k,cellId:n}),(0,r.jsxs)(I,{title:"Why can't I redefine variables?",children:[(0,r.jsx)("p",{className:"pb-2",children:"marimo requires that each variable is defined in just one cell. This constraint enables reactive and reproducible execution, arbitrary cell reordering, seamless UI elements, execution as a script, and more."}),(0,r.jsxs)("p",{className:"py-2",children:["Try merging this cell with the mentioned cells or wrapping it in a function. Alternatively, prefix variables with an underscore (e.g., ",(0,r.jsxs)(re,{className:"inline",children:["_",E]}),"). to make them private to this cell."]}),(0,r.jsxs)("p",{className:"py-2",children:[(0,r.jsxs)(T,{href:"https://links.marimo.app/errors-multiple-definitions",children:["Learn more at our docs"," ",(0,r.jsx)(A,{size:"0.75rem",className:"inline"})]}),"."]})]}),(0,r.jsx)(I,{title:"Need a scratchpad?",children:(0,r.jsxs)("div",{className:"flex flex-row gap-2 items-center",children:[(0,r.jsxs)($,{size:"xs",variant:"link",className:"my-2 font-normal mx-0 px-0",onClick:fe,children:[(0,r.jsx)(Fe,{className:"h-3"}),(0,r.jsx)("span",{children:"Try the scratchpad"})]}),(0,r.jsx)("span",{children:"to experiment without restrictions on variable names."})]})})]},"multiple-defs"))}return _.length>0&&v.push((0,r.jsxs)("div",{children:[_.map(Ut),n&&(0,r.jsx)(N,{errors:_,cellId:n}),(0,r.jsxs)(I,{title:"Why can't I use `import *`?",children:[(0,r.jsx)("p",{className:"pb-2",children:"Star imports are incompatible with marimo's git-friendly file format and reproducible reactive execution."}),(0,r.jsx)("p",{className:"py-2",children:"marimo's Python file format stores code in functions, so notebooks can be imported as regular Python modules without executing all their code. But Python disallows `import *` everywhere except at the top-level of a module."}),(0,r.jsx)("p",{className:"py-2",children:"Star imports would also silently add names to globals, which would be incompatible with reactive execution."}),(0,r.jsxs)("p",{className:"py-2",children:[(0,r.jsxs)(T,{href:"https://links.marimo.app/errors-import-star",children:["Learn more at our docs"," ",(0,r.jsx)(A,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"import-star")),L.length>0&&v.push((0,r.jsxs)("div",{children:[L.map(Rt),n&&(0,r.jsx)(N,{errors:L,cellId:n})]},"interruption")),C.length>0&&v.push((0,r.jsxs)("ul",{children:[C.map(Gt),C.some(Jt)&&(0,r.jsx)(I,{children:"Fix the error in the mentioned cells, or handle the exceptions with try/except blocks."}),n&&(0,r.jsx)(N,{errors:C,cellId:n})]},"exception")),S.length>0&&v.push((0,r.jsxs)("ul",{children:[S.map(Kt),n&&(0,r.jsx)(N,{errors:S,cellId:n}),(0,r.jsx)(I,{children:S.some(Xt)?"Ensure that the referenced cells define the required variables, or turn off strict execution.":"Something is wrong with your declarations. Fix any discrepancies, or turn off strict execution."})]},"strict-exception")),W.length>0&&v.push((0,r.jsxs)("div",{children:[W.map(Yt),n&&(0,r.jsx)(N,{errors:W,cellId:n})]},"internal")),V.length>0&&v.push((0,r.jsxs)("div",{children:[V.map(Zt),n&&(0,r.jsx)(N,{errors:V,cellId:n})]},"ancestor-prevented")),B.length>0&&v.push((0,r.jsxs)("div",{children:[B.map(er),n&&(0,r.jsx)(N,{errors:B,cellId:n})]},"ancestor-stopped")),D.length>0&&v.push((0,r.jsxs)("div",{children:[D.map(tr),n&&(0,r.jsx)(N,{errors:D,cellId:n,className:"mt-2.5"})]},"sql-errors")),v},O=`font-code font-medium tracking-wide ${o}`,z;e[17]!==O||e[18]!==a?(z=(0,r.jsx)(Ge,{className:O,children:a}),e[17]=O,e[18]=a,e[19]=z):z=e[19];let ge=z;m=Je,f=c,e[20]===i?u=e[21]:(u=X("border-none font-code text-sm text-[0.84375rem] px-0 text-muted-foreground normal [&:has(svg)]:pl-0 space-y-4",i),e[20]=i,e[21]=u),j=ge,p="flex flex-col gap-8",d=je(),e[2]=c,e[3]=n,e[4]=l,e[5]=i,e[6]=s,e[7]=o,e[8]=a,e[9]=m,e[10]=p,e[11]=d,e[12]=f,e[13]=u,e[14]=j}else m=e[9],p=e[10],d=e[11],f=e[12],u=e[13],j=e[14];let h;e[22]!==p||e[23]!==d?(h=(0,r.jsx)("div",{children:(0,r.jsx)("div",{className:p,children:d})}),e[22]=p,e[23]=d,e[24]=h):h=e[24];let g;return e[25]!==m||e[26]!==f||e[27]!==u||e[28]!==j||e[29]!==h?(g=(0,r.jsxs)(m,{variant:f,className:u,children:[j,h]}),e[25]=m,e[26]=f,e[27]=u,e[28]=j,e[29]=h,e[30]=g):g=e[30],g};function yt(t){return t.type==="interruption"}function vt(t){return t.type==="internal"}function Nt(t){return t.type==="ancestor-prevented"}function bt(t){return t.type==="ancestor-stopped"}function kt(t){return t.type==="sql-error"}function wt(t){return t.type==="exception"}function It(t){return t.type==="setup-refs"}function $t(t){return t.type==="cycle"}function _t(t){return t.type==="multiple-defs"}function Ft(t){return t.type==="import-star"}function Tt(t){return t.type==="interruption"}function At(t){return t.type==="exception"}function Ct(t){return t.type==="strict-exception"}function St(t){return t.type==="internal"}function Mt(t){return t.type==="ancestor-prevented"}function zt(t){return t.type==="ancestor-stopped"}function Et(t){return t.type==="syntax"}function qt(t){return t.type==="unknown"}function Pt(t){return t.type==="sql-error"}function Lt(t){return t.msg.includes("!pip")}function Wt(t){return t.msg.includes("use os.subprocess")}function Vt(t,e){return(0,r.jsx)("pre",{children:w(t.msg,`syntax-${e}`)},`syntax-${e}`)}function Bt(t,e){return(0,r.jsx)("pre",{children:w(t.msg,`unknown-${e}`)},`unknown-${e}`)}function Qt(t,e){return t.edges_with_vars.map((s,n)=>(0,r.jsxs)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:[(0,r.jsx)(b,{cellId:s[0]}),(0,r.jsxs)("span",{className:"text-muted-foreground",children:[": "," ",s[1].length===1?s[1][0]:s[1].join(", ")]})]},`setup-refs-${e}-${n}`))}function Dt(t,e){return t.edges_with_vars.map((s,n)=>(0,r.jsxs)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:[(0,r.jsx)(b,{cellId:s[0]}),(0,r.jsxs)("span",{className:"text-muted-foreground",children:[" -> ",s[1].length===1?s[1][0]:s[1].join(", ")," -> "]}),(0,r.jsx)(b,{cellId:s[2]})]},`cycle-${e}-${n}`))}function Ot(t,e){return(0,r.jsx)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:(0,r.jsx)(b,{cellId:t})},`cell-${e}`)}function Ht(t,e){return(0,r.jsxs)(P.Fragment,{children:[(0,r.jsx)("p",{className:"text-muted-foreground mt-2",children:`'${t.name}' was also defined by:`}),(0,r.jsx)("ul",{className:"list-disc",children:t.cells.map(Ot)})]},`multiple-defs-${e}`)}function Ut(t,e){return(0,r.jsx)("p",{className:"text-muted-foreground",children:t.msg},`import-star-${e}`)}function Rt(t,e){return(0,r.jsx)("p",{children:"This cell was interrupted and needs to be re-run."},`interruption-${e}`)}function Gt(t,e){return t.exception_type==="NameError"&&t.msg.startsWith("name 'mo'")?(0,r.jsx)("li",{className:"my-2",children:(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-muted-foreground",children:"name 'mo' is not defined."}),(0,r.jsxs)("p",{className:"text-muted-foreground mt-2",children:["The marimo module (imported as"," ",(0,r.jsx)(re,{className:"inline",children:"mo"}),") is required for Markdown, SQL, and UI elements."]})]})},`exception-${e}`):t.exception_type==="NameError"&&t.msg.startsWith("name '_")?(0,r.jsx)("li",{className:"my-2",children:(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-muted-foreground",children:t.msg}),(0,r.jsxs)("p",{className:"text-muted-foreground mt-2",children:["Variables prefixed with an underscore are local to a cell"," ","(",(0,r.jsxs)(T,{href:"https://links.marimo.app/local-variables",children:["docs"," ",(0,r.jsx)(A,{size:"0.75rem",className:"inline"})]}),")."]}),(0,r.jsx)("div",{className:"text-muted-foreground mt-2",children:"See the console area for a traceback."})]})},`exception-${e}`):(0,r.jsx)("li",{className:"my-2",children:t.raising_cell==null?(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-muted-foreground",children:w(t.msg,`exception-${e}`)}),"traceback"in t&&t.traceback?(0,r.jsx)("div",{className:"font-code text-sm mt-2 p-3 bg-muted rounded border overflow-auto max-h-[50vh] cursor-text select-text",children:te({html:t.traceback})}):(0,r.jsx)("div",{className:"text-muted-foreground mt-2",children:"See the console area for a traceback."})]}):(0,r.jsxs)("div",{children:[w(t.msg,`exception-${e}`),(0,r.jsx)(b,{cellId:t.raising_cell}),"traceback"in t&&t.traceback&&(0,r.jsx)("div",{className:"font-code text-sm mt-2 p-3 bg-muted rounded border overflow-auto max-h-[50vh] cursor-text select-text",children:te({html:t.traceback})})]})},`exception-${e}`)}function Jt(t){return t.raising_cell!=null}function Kt(t,e){return(0,r.jsx)("li",{className:"my-2",children:t.blamed_cell==null?(0,r.jsx)("p",{children:t.msg}):(0,r.jsxs)("div",{children:[t.msg,(0,r.jsx)(b,{cellId:t.blamed_cell})]})},`strict-exception-${e}`)}function Xt(t){return t.blamed_cell!=null}function Yt(t,e){return(0,r.jsx)("p",{children:t.msg},`internal-${e}`)}function Zt(t,e){return(0,r.jsxs)("div",{children:[t.msg,t.blamed_cell==null?(0,r.jsxs)("span",{children:["(",(0,r.jsx)(b,{cellId:t.raising_cell}),")"]}):(0,r.jsxs)("span",{children:["(",(0,r.jsx)(b,{cellId:t.raising_cell}),"\xA0blames\xA0",(0,r.jsx)(b,{cellId:t.blamed_cell}),")"]})]},`ancestor-prevented-${e}`)}function er(t,e){return(0,r.jsxs)("div",{children:[t.msg,(0,r.jsx)(b,{cellId:t.raising_cell})]},`ancestor-stopped-${e}`)}function tr(t,e){return(0,r.jsx)("div",{className:"space-y-2 mt-2",children:(0,r.jsx)("p",{className:"text-muted-foreground whitespace-pre-wrap",children:t.msg})},`sql-error-${e}`)}export{se as a,ce as i,jt as n,pe as r,gt as t};
7
+ Database schema: ${i}`),(a=n.aiFix)==null||a.setAiCompletionCell({cellId:n.cellId,initialPrompt:l,triggerImmediately:n.aiFix.triggerFix})}}]:[]}function st(t){let e=ne[t];return e===t?`import ${e}`:`import ${e} as ${t}`}var ne={mo:"marimo",alt:"altair",bokeh:"bokeh",dask:"dask",np:"numpy",pd:"pandas",pl:"polars",plotly:"plotly",plt:"matplotlib.pyplot",px:"plotly.express",scipy:"scipy",sk:"sklearn",sns:"seaborn",stats:"scipy.stats",tf:"tensorflow",torch:"torch",xr:"xarray",dt:"datetime",json:"json",math:"math",os:"os",re:"re",sys:"sys"},nt=q(),lt=Se("marimo:ai-autofix-mode","autofix",$e);function it(){let t=(0,nt.c)(3),[e,s]=be(lt),n;return t[0]!==e||t[1]!==s?(n={fixMode:e,setFixMode:s},t[0]=e,t[1]=s,t[2]=n):n=t[2],n}var R=q(),r=J(Ee(),1);const N=t=>{let e=(0,R.c)(21),{errors:s,cellId:n,className:i}=t,l=Ne(),{createNewCell:a}=Ie(),c=ke(ze),o;if(e[0]!==c||e[1]!==s){let x;e[3]===c?x=e[4]:(x=y=>rt(y,{aiEnabled:c}),e[3]=c,e[4]=x),o=s.flatMap(x),e[0]=c,e[1]=s,e[2]=o}else o=e[2];let m=o,p=ve(Ye);if(m.length===0)return null;let d=m[0],f;e[5]!==n||e[6]!==a||e[7]!==d||e[8]!==p||e[9]!==l?(f=x=>{var k;let y=(k=l.get(Ae).cellHandles[n].current)==null?void 0:k.editorView;d.onFix({addCodeBelow:_=>{a({cellId:n,autoFocus:!1,before:!1,code:_})},editor:y,cellId:n,aiFix:{setAiCompletionCell:p,triggerFix:x}}),y==null||y.focus()},e[5]=n,e[6]=a,e[7]=d,e[8]=p,e[9]=l,e[10]=f):f=e[10];let u=f,j;e[11]===i?j=e[12]:(j=X("my-2",i),e[11]=i,e[12]=j);let h;e[13]!==d.description||e[14]!==d.fixType||e[15]!==d.title||e[16]!==u?(h=d.fixType==="ai"?(0,r.jsx)(ce,{tooltip:d.description,openPrompt:()=>u(!1),applyAutofix:()=>u(!0)}):(0,r.jsx)(Y,{content:d.description,align:"start",children:(0,r.jsxs)($,{size:"xs",variant:"outline",className:"font-normal",onClick:()=>u(!1),children:[(0,r.jsx)(ee,{className:"h-3 w-3 mr-2"}),d.title]})}),e[13]=d.description,e[14]=d.fixType,e[15]=d.title,e[16]=u,e[17]=h):h=e[17];let g;return e[18]!==j||e[19]!==h?(g=(0,r.jsx)("div",{className:j,children:h}),e[18]=j,e[19]=h,e[20]=g):g=e[20],g};var le=He,ie=ee,ae="Suggest a prompt",oe="Fix with AI";const ce=t=>{let e=(0,R.c)(21),{tooltip:s,openPrompt:n,applyAutofix:i}=t,{fixMode:l,setFixMode:a}=it(),c=l==="prompt"?n:i,o;e[0]===l?o=e[1]:(o=l==="prompt"?(0,r.jsx)(le,{className:"h-3 w-3 mr-2 mb-0.5"}):(0,r.jsx)(ie,{className:"h-3 w-3 mr-2 mb-0.5"}),e[0]=l,e[1]=o);let m=l==="prompt"?ae:oe,p;e[2]!==c||e[3]!==o||e[4]!==m?(p=(0,r.jsxs)($,{size:"xs",variant:"outline",className:"font-normal rounded-r-none border-r-0",onClick:c,children:[o,m]}),e[2]=c,e[3]=o,e[4]=m,e[5]=p):p=e[5];let d;e[6]!==p||e[7]!==s?(d=(0,r.jsx)(Y,{content:s,align:"start",children:p}),e[6]=p,e[7]=s,e[8]=d):d=e[8];let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f=(0,r.jsx)(Be,{asChild:!0,children:(0,r.jsx)($,{size:"xs",variant:"outline",className:"rounded-l-none px-2","aria-label":"Fix options",children:(0,r.jsx)(Oe,{className:"h-3 w-3"})})}),e[9]=f):f=e[9];let u;e[10]!==l||e[11]!==a?(u=()=>{a(l==="prompt"?"autofix":"prompt")},e[10]=l,e[11]=a,e[12]=u):u=e[12];let j=l==="prompt"?"autofix":"prompt",h;e[13]===j?h=e[14]:(h=(0,r.jsx)(at,{mode:j}),e[13]=j,e[14]=h);let g;e[15]!==u||e[16]!==h?(g=(0,r.jsxs)(De,{children:[f,(0,r.jsx)(Qe,{align:"end",className:"w-56",children:(0,r.jsx)(Ve,{className:"flex items-center gap-2",onClick:u,children:h})})]}),e[15]=u,e[16]=h,e[17]=g):g=e[17];let x;return e[18]!==g||e[19]!==d?(x=(0,r.jsxs)("div",{className:"flex",children:[d,g]}),e[18]=g,e[19]=d,e[20]=x):x=e[20],x};var at=t=>{let e=(0,R.c)(12),{mode:s}=t,n;e[0]===s?n=e[1]:(n=s==="prompt"?(0,r.jsx)(le,{className:"h-4 w-4"}):(0,r.jsx)(ie,{className:"h-4 w-4"}),e[0]=s,e[1]=n);let i=n,l=s==="prompt"?ae:oe,a=s==="prompt"?"Edit the prompt before applying":"Apply AI fixes automatically",c;e[2]===l?c=e[3]:(c=(0,r.jsx)("span",{className:"font-medium",children:l}),e[2]=l,e[3]=c);let o;e[4]===a?o=e[5]:(o=(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:a}),e[4]=a,e[5]=o);let m;e[6]!==c||e[7]!==o?(m=(0,r.jsxs)("div",{className:"flex flex-col",children:[c,o]}),e[6]=c,e[7]=o,e[8]=m):m=e[8];let p;return e[9]!==i||e[10]!==m?(p=(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[i,m]}),e[9]=i,e[10]=m,e[11]=p):p=e[11],p},de=/(https?:\/\/\S+)/,ot=/\.(png|jpe?g|gif|webp|svg|ico)(\?.*)?$/i,me=/^data:image\//i,ct=["avatars.githubusercontent.com"];function pe(t){return me.test(t)?[{type:"image",url:t}]:t.split(de).filter(e=>e!=="").map(e=>de.test(e)?ot.test(e)||me.test(e)||ct.some(s=>e.includes(s))?{type:"image",url:e}:{type:"url",url:e}:{type:"text",value:e})}var ue=q(),P=J(we(),1),dt=new Ce;const G=t=>{let e=RegExp("\x1B\\[[0-9;]*m","g");return t.replaceAll(e,"")};var he=/(pip\s+install|uv\s+add|uv\s+pip\s+install)\s+/gi;function mt(t){he.lastIndex=0;let e=he.exec(t);if(!e)return null;let s=e.index+e[0].length,n=t.slice(s).split(/\s+/),i="",l=0;for(let c of n){let o=c.trim();if(!o)continue;if(o.startsWith("-")){l+=o.length+1;continue}let m=o.match(/^[\w,.[\]-]+/);if(m){i=m[0];break}break}if(!i)return null;let a=s+l+i.length;return{package:i,endIndex:a}}function w(t,e=""){if(!t)return null;if(!/https?:\/\//.test(t))return t;let s=pe(t);return s.length===1&&s[0].type==="text"?t:(0,r.jsx)(r.Fragment,{children:s.map((n,i)=>{let l=e?`${e}-${i}`:i;if(n.type==="url"){let a=G(n.url);return(0,r.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:Z.stopPropagation(),className:"text-link hover:underline",children:a},l)}if(n.type==="image"){let a=G(n.url);return(0,r.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:Z.stopPropagation(),className:"text-link hover:underline",children:a},l)}return(0,r.jsx)(P.Fragment,{children:n.value},l)})})}var pt=t=>{let e=(0,ue.c)(6),{packages:s,children:n}=t,{handleInstallPackages:i}=Xe(),l;e[0]!==i||e[1]!==s?(l=c=>{i(s),c.preventDefault()},e[0]=i,e[1]=s,e[2]=l):l=e[2];let a;return e[3]!==n||e[4]!==l?(a=(0,r.jsx)("button",{onClick:l,className:"text-link hover:underline",type:"button",children:n}),e[3]=n,e[4]=l,e[5]=a):a=e[5],a};const ut=t=>{if(!(t instanceof K.Text))return;let e=G(t.data);if(!/(pip\s+install|uv\s+add|uv\s+pip\s+install)/i.test(e))return;let s=[],n=/(pip\s+install|uv\s+add|uv\s+pip\s+install)\s+/gi,i;for(;(i=n.exec(e))!==null;){let c=i.index,o=mt(e.slice(c));o&&s.push({match:i,result:o})}if(s.length===0)return;let l=[],a=0;if(s.forEach((c,o)=>{let{match:m,result:p}=c,d=m.index,f=d+p.endIndex;if(a<d){let j=e.slice(a,d);l.push((0,r.jsx)(P.Fragment,{children:w(j,`before-${o}`)},`before-${o}`))}let u=e.slice(d,f);l.push((0,r.jsx)(pt,{packages:[p.package],children:u},`install-${o}`)),a=f}),a<e.length){let c=e.slice(a);l.push((0,r.jsx)(P.Fragment,{children:w(c,"after")},"after"))}return(0,r.jsx)(r.Fragment,{children:l})},ht=t=>{if(!(t instanceof K.Text))return;let e=t.data;if(!/https?:\/\//.test(e))return;let s=w(e);if(typeof s!="string")return(0,r.jsx)(r.Fragment,{children:s})},xt=(...t)=>e=>{for(let s of t){let n=s(e);if(n!==void 0)return n}},ft=(t,e)=>(0,r.jsx)("span",{children:Fe(dt.ansi_to_html(t),{replace:s=>e(s)})}),jt=t=>{let e=(0,ue.c)(4),{text:s}=t,n;e[0]===s?n=e[1]:(n=ft(s,xt(ut,ht)),e[0]=s,e[1]=n);let i=n,l;return e[2]===i?l=e[3]:(l=(0,r.jsx)(r.Fragment,{children:i}),e[2]=i,e[3]=l),l};var xe=q(),I=t=>{let e=(0,xe.c)(10),s=t.title??"Tip",n;e[0]===s?n=e[1]:(n=(0,r.jsx)(qe,{className:"pt-2 pb-2 font-normal",children:s}),e[0]=s,e[1]=n);let i;e[2]===t.children?i=e[3]:(i=(0,r.jsx)(We,{className:"mr-24 text-[0.84375rem]",children:t.children}),e[2]=t.children,e[3]=i);let l;e[4]!==n||e[5]!==i?(l=(0,r.jsxs)(Pe,{value:"item-1",className:"text-muted-foreground",children:[n,i]}),e[4]=n,e[5]=i,e[6]=l):l=e[6];let a;return e[7]!==t.className||e[8]!==l?(a=(0,r.jsx)(Le,{type:"single",collapsible:!0,className:t.className,children:l}),e[7]=t.className,e[8]=l,e[9]=a):a=e[9],a};const gt=t=>{let e=(0,xe.c)(31),{errors:s,cellId:n,className:i}=t,l=_e(),a="This cell wasn't run because it has errors",c="destructive",o="text-error";if(s.some(yt))a="Interrupted";else if(s.some(vt))a="An internal error occurred";else if(s.some(Nt))a="Ancestor prevented from running",c="default",o="text-secondary-foreground";else if(s.some(bt))a="Ancestor stopped",c="default",o="text-secondary-foreground";else if(s.some(kt))a="SQL error";else{let x;e[0]===s?x=e[1]:(x=s.find(wt),e[0]=s,e[1]=x);let y=x;y&&"exception_type"in y&&(a=y.exception_type)}let m,p,d,f,u,j;if(e[2]!==c||e[3]!==n||e[4]!==l||e[5]!==i||e[6]!==s||e[7]!==o||e[8]!==a){let x=s.filter(It),y=s.filter($t),k=s.filter(_t),_=s.filter(Ft),L=s.filter(Tt),C=s.filter(At),S=s.filter(Ct),W=s.filter(St),V=s.filter(Mt),B=s.filter(zt),F=s.filter(Et),Q=s.filter(qt),D=s.filter(Pt),M;e[15]===l?M=e[16]:(M=()=>{l.openApplication("scratchpad")},e[15]=l,e[16]=M);let fe=M,je=()=>{let v=[];if(F.length>0||Q.length>0){let E=F.some(Lt),ye=!E&&F.some(Wt);v.push((0,r.jsxs)("div",{children:[F.map(Vt),Q.map(Bt),E&&(0,r.jsxs)($,{size:"xs",variant:"outline",className:"mt-2 font-normal",onClick:()=>Ke(l),children:[(0,r.jsx)(Ze,{className:"h-3.5 w-3.5 mr-1.5 mb-0.5"}),(0,r.jsx)("span",{children:"Open package manager"})]}),ye&&(0,r.jsxs)($,{size:"xs",variant:"outline",className:"mt-2 font-normal",onClick:()=>l.openApplication("terminal"),children:[(0,r.jsx)(se,{className:"h-3.5 w-3.5 mr-1.5"}),(0,r.jsx)("span",{children:"Open terminal"})]}),n&&(0,r.jsx)(N,{errors:[...F,...Q],cellId:n})]},"syntax-unknown"))}if(x.length>0&&v.push((0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-muted-foreground font-medium",children:"The setup cell cannot be run because it has references."}),(0,r.jsx)("ul",{className:"list-disc",children:x.flatMap(Qt)}),n&&(0,r.jsx)(N,{errors:x,cellId:n}),(0,r.jsxs)(I,{title:"Why can't the setup cell have references?",className:"mb-2",children:[(0,r.jsx)("p",{className:"pb-2",children:"The setup cell contains logic that must be run before any other cell runs, including top-level imports used by top-level functions. For this reason, it can't refer to other cells' variables."}),(0,r.jsx)("p",{className:"py-2",children:"Try simplifying the setup cell to only contain only necessary variables."}),(0,r.jsxs)("p",{className:"py-2",children:[(0,r.jsxs)(T,{href:"https://links.marimo.app/errors-setup",children:["Learn more at our docs"," ",(0,r.jsx)(A,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"setup-refs")),y.length>0&&v.push((0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-muted-foreground font-medium",children:"This cell is in a cycle."}),(0,r.jsx)("ul",{className:"list-disc",children:y.flatMap(Dt)}),n&&(0,r.jsx)(N,{errors:y,cellId:n}),(0,r.jsxs)(I,{title:"What are cycles and how do I resolve them?",className:"mb-2",children:[(0,r.jsx)("p",{className:"pb-2",children:"An example of a cycle is if one cell declares a variable 'a' and reads 'b', and another cell declares 'b' and and reads 'a'. Cycles like this make it impossible for marimo to know how to run your cells, and generally suggest that your code has a bug."}),(0,r.jsx)("p",{className:"py-2",children:"Try merging these cells into a single cell to eliminate the cycle."}),(0,r.jsxs)("p",{className:"py-2",children:[(0,r.jsxs)(T,{href:"https://links.marimo.app/errors-cycles",children:["Learn more at our docs"," ",(0,r.jsx)(A,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"cycle")),k.length>0){let E=k[0].name;v.push((0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-muted-foreground font-medium",children:"This cell redefines variables from other cells."}),k.map(Ht),n&&(0,r.jsx)(N,{errors:k,cellId:n}),(0,r.jsxs)(I,{title:"Why can't I redefine variables?",children:[(0,r.jsx)("p",{className:"pb-2",children:"marimo requires that each variable is defined in just one cell. This constraint enables reactive and reproducible execution, arbitrary cell reordering, seamless UI elements, execution as a script, and more."}),(0,r.jsxs)("p",{className:"py-2",children:["Try merging this cell with the mentioned cells or wrapping it in a function. Alternatively, prefix variables with an underscore (e.g., ",(0,r.jsxs)(re,{className:"inline",children:["_",E]}),"). to make them private to this cell."]}),(0,r.jsxs)("p",{className:"py-2",children:[(0,r.jsxs)(T,{href:"https://links.marimo.app/errors-multiple-definitions",children:["Learn more at our docs"," ",(0,r.jsx)(A,{size:"0.75rem",className:"inline"})]}),"."]})]}),(0,r.jsx)(I,{title:"Need a scratchpad?",children:(0,r.jsxs)("div",{className:"flex flex-row gap-2 items-center",children:[(0,r.jsxs)($,{size:"xs",variant:"link",className:"my-2 font-normal mx-0 px-0",onClick:fe,children:[(0,r.jsx)(Te,{className:"h-3"}),(0,r.jsx)("span",{children:"Try the scratchpad"})]}),(0,r.jsx)("span",{children:"to experiment without restrictions on variable names."})]})})]},"multiple-defs"))}return _.length>0&&v.push((0,r.jsxs)("div",{children:[_.map(Ut),n&&(0,r.jsx)(N,{errors:_,cellId:n}),(0,r.jsxs)(I,{title:"Why can't I use `import *`?",children:[(0,r.jsx)("p",{className:"pb-2",children:"Star imports are incompatible with marimo's git-friendly file format and reproducible reactive execution."}),(0,r.jsx)("p",{className:"py-2",children:"marimo's Python file format stores code in functions, so notebooks can be imported as regular Python modules without executing all their code. But Python disallows `import *` everywhere except at the top-level of a module."}),(0,r.jsx)("p",{className:"py-2",children:"Star imports would also silently add names to globals, which would be incompatible with reactive execution."}),(0,r.jsxs)("p",{className:"py-2",children:[(0,r.jsxs)(T,{href:"https://links.marimo.app/errors-import-star",children:["Learn more at our docs"," ",(0,r.jsx)(A,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"import-star")),L.length>0&&v.push((0,r.jsxs)("div",{children:[L.map(Rt),n&&(0,r.jsx)(N,{errors:L,cellId:n})]},"interruption")),C.length>0&&v.push((0,r.jsxs)("ul",{children:[C.map(Gt),C.some(Jt)&&(0,r.jsx)(I,{children:"Fix the error in the mentioned cells, or handle the exceptions with try/except blocks."}),n&&(0,r.jsx)(N,{errors:C,cellId:n})]},"exception")),S.length>0&&v.push((0,r.jsxs)("ul",{children:[S.map(Kt),n&&(0,r.jsx)(N,{errors:S,cellId:n}),(0,r.jsx)(I,{children:S.some(Xt)?"Ensure that the referenced cells define the required variables, or turn off strict execution.":"Something is wrong with your declarations. Fix any discrepancies, or turn off strict execution."})]},"strict-exception")),W.length>0&&v.push((0,r.jsxs)("div",{children:[W.map(Yt),n&&(0,r.jsx)(N,{errors:W,cellId:n})]},"internal")),V.length>0&&v.push((0,r.jsxs)("div",{children:[V.map(Zt),n&&(0,r.jsx)(N,{errors:V,cellId:n})]},"ancestor-prevented")),B.length>0&&v.push((0,r.jsxs)("div",{children:[B.map(er),n&&(0,r.jsx)(N,{errors:B,cellId:n})]},"ancestor-stopped")),D.length>0&&v.push((0,r.jsxs)("div",{children:[D.map(tr),n&&(0,r.jsx)(N,{errors:D,cellId:n,className:"mt-2.5"})]},"sql-errors")),v},O=`font-code font-medium tracking-wide ${o}`,z;e[17]!==O||e[18]!==a?(z=(0,r.jsx)(Ge,{className:O,children:a}),e[17]=O,e[18]=a,e[19]=z):z=e[19];let ge=z;m=Je,f=c,e[20]===i?u=e[21]:(u=X("border-none font-code text-sm text-[0.84375rem] px-0 text-muted-foreground normal [&:has(svg)]:pl-0 space-y-4",i),e[20]=i,e[21]=u),j=ge,p="flex flex-col gap-8",d=je(),e[2]=c,e[3]=n,e[4]=l,e[5]=i,e[6]=s,e[7]=o,e[8]=a,e[9]=m,e[10]=p,e[11]=d,e[12]=f,e[13]=u,e[14]=j}else m=e[9],p=e[10],d=e[11],f=e[12],u=e[13],j=e[14];let h;e[22]!==p||e[23]!==d?(h=(0,r.jsx)("div",{children:(0,r.jsx)("div",{className:p,children:d})}),e[22]=p,e[23]=d,e[24]=h):h=e[24];let g;return e[25]!==m||e[26]!==f||e[27]!==u||e[28]!==j||e[29]!==h?(g=(0,r.jsxs)(m,{variant:f,className:u,children:[j,h]}),e[25]=m,e[26]=f,e[27]=u,e[28]=j,e[29]=h,e[30]=g):g=e[30],g};function yt(t){return t.type==="interruption"}function vt(t){return t.type==="internal"}function Nt(t){return t.type==="ancestor-prevented"}function bt(t){return t.type==="ancestor-stopped"}function kt(t){return t.type==="sql-error"}function wt(t){return t.type==="exception"}function It(t){return t.type==="setup-refs"}function $t(t){return t.type==="cycle"}function _t(t){return t.type==="multiple-defs"}function Ft(t){return t.type==="import-star"}function Tt(t){return t.type==="interruption"}function At(t){return t.type==="exception"}function Ct(t){return t.type==="strict-exception"}function St(t){return t.type==="internal"}function Mt(t){return t.type==="ancestor-prevented"}function zt(t){return t.type==="ancestor-stopped"}function Et(t){return t.type==="syntax"}function qt(t){return t.type==="unknown"}function Pt(t){return t.type==="sql-error"}function Lt(t){return t.msg.includes("!pip")}function Wt(t){return t.msg.includes("use os.subprocess")}function Vt(t,e){return(0,r.jsx)("pre",{children:w(t.msg,`syntax-${e}`)},`syntax-${e}`)}function Bt(t,e){return(0,r.jsx)("pre",{children:w(t.msg,`unknown-${e}`)},`unknown-${e}`)}function Qt(t,e){return t.edges_with_vars.map((s,n)=>(0,r.jsxs)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:[(0,r.jsx)(b,{cellId:s[0]}),(0,r.jsxs)("span",{className:"text-muted-foreground",children:[": "," ",s[1].length===1?s[1][0]:s[1].join(", ")]})]},`setup-refs-${e}-${n}`))}function Dt(t,e){return t.edges_with_vars.map((s,n)=>(0,r.jsxs)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:[(0,r.jsx)(b,{cellId:s[0]}),(0,r.jsxs)("span",{className:"text-muted-foreground",children:[" -> ",s[1].length===1?s[1][0]:s[1].join(", ")," -> "]}),(0,r.jsx)(b,{cellId:s[2]})]},`cycle-${e}-${n}`))}function Ot(t,e){return(0,r.jsx)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:(0,r.jsx)(b,{cellId:t})},`cell-${e}`)}function Ht(t,e){return(0,r.jsxs)(P.Fragment,{children:[(0,r.jsx)("p",{className:"text-muted-foreground mt-2",children:`'${t.name}' was also defined by:`}),(0,r.jsx)("ul",{className:"list-disc",children:t.cells.map(Ot)})]},`multiple-defs-${e}`)}function Ut(t,e){return(0,r.jsx)("p",{className:"text-muted-foreground",children:t.msg},`import-star-${e}`)}function Rt(t,e){return(0,r.jsx)("p",{children:"This cell was interrupted and needs to be re-run."},`interruption-${e}`)}function Gt(t,e){return t.exception_type==="NameError"&&t.msg.startsWith("name 'mo'")?(0,r.jsx)("li",{className:"my-2",children:(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-muted-foreground",children:"name 'mo' is not defined."}),(0,r.jsxs)("p",{className:"text-muted-foreground mt-2",children:["The marimo module (imported as"," ",(0,r.jsx)(re,{className:"inline",children:"mo"}),") is required for Markdown, SQL, and UI elements."]})]})},`exception-${e}`):t.exception_type==="NameError"&&t.msg.startsWith("name '_")?(0,r.jsx)("li",{className:"my-2",children:(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-muted-foreground",children:t.msg}),(0,r.jsxs)("p",{className:"text-muted-foreground mt-2",children:["Variables prefixed with an underscore are local to a cell"," ","(",(0,r.jsxs)(T,{href:"https://links.marimo.app/local-variables",children:["docs"," ",(0,r.jsx)(A,{size:"0.75rem",className:"inline"})]}),")."]}),(0,r.jsx)("div",{className:"text-muted-foreground mt-2",children:"See the console area for a traceback."})]})},`exception-${e}`):(0,r.jsx)("li",{className:"my-2",children:t.raising_cell==null?(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-muted-foreground",children:w(t.msg,`exception-${e}`)}),"traceback"in t&&t.traceback?(0,r.jsx)("div",{className:"font-code text-sm mt-2 p-3 bg-muted rounded border overflow-auto max-h-[50vh] cursor-text select-text",children:te({html:t.traceback})}):(0,r.jsx)("div",{className:"text-muted-foreground mt-2",children:"See the console area for a traceback."})]}):(0,r.jsxs)("div",{children:[w(t.msg,`exception-${e}`),(0,r.jsx)(b,{cellId:t.raising_cell}),"traceback"in t&&t.traceback&&(0,r.jsx)("div",{className:"font-code text-sm mt-2 p-3 bg-muted rounded border overflow-auto max-h-[50vh] cursor-text select-text",children:te({html:t.traceback})})]})},`exception-${e}`)}function Jt(t){return t.raising_cell!=null}function Kt(t,e){return(0,r.jsx)("li",{className:"my-2",children:t.blamed_cell==null?(0,r.jsx)("p",{children:t.msg}):(0,r.jsxs)("div",{children:[t.msg,(0,r.jsx)(b,{cellId:t.blamed_cell})]})},`strict-exception-${e}`)}function Xt(t){return t.blamed_cell!=null}function Yt(t,e){return(0,r.jsx)("p",{children:t.msg},`internal-${e}`)}function Zt(t,e){return(0,r.jsxs)("div",{children:[t.msg,t.blamed_cell==null?(0,r.jsxs)("span",{children:["(",(0,r.jsx)(b,{cellId:t.raising_cell}),")"]}):(0,r.jsxs)("span",{children:["(",(0,r.jsx)(b,{cellId:t.raising_cell}),"\xA0blames\xA0",(0,r.jsx)(b,{cellId:t.blamed_cell}),")"]})]},`ancestor-prevented-${e}`)}function er(t,e){return(0,r.jsxs)("div",{children:[t.msg,(0,r.jsx)(b,{cellId:t.raising_cell})]},`ancestor-stopped-${e}`)}function tr(t,e){return(0,r.jsx)("div",{className:"space-y-2 mt-2",children:(0,r.jsx)("p",{className:"text-muted-foreground whitespace-pre-wrap",children:t.msg})},`sql-error-${e}`)}export{se as a,ce as i,jt as n,pe as r,gt as t};
@@ -1 +1 @@
1
- import{s as y}from"./chunk-LvLJmgfZ.js";import{i as g,p as C,u as M}from"./useEvent-D91BmmQi.js";import{t as S}from"./react-Bj1aDYRI.js";import{_n as H,ai as c,ii as I,it as j,m as L,xn as N,yt as k}from"./cells-CJlo_hG2.js";import{t as E}from"./compiler-runtime-B3qBwwSJ.js";import{_}from"./useEventListener-BR0C1MaI.js";import{o as w}from"./utils-DIGrmLDO.js";import{t as A}from"./jsx-runtime-BqBOg78p.js";import{t as F}from"./tooltip-Gcwqb_SK.js";import{t as O}from"./copy-icon-C67c9EwB.js";import{t as W}from"./usePress-CtfZXGno.js";import{n as q}from"./useDebounce-BDIglWmG.js";import{t as R}from"./useRunCells-B531RIUE.js";var z=E(),m=y(S(),1),l=y(A(),1);const V=e=>{let t=(0,z.c)(16),r,n,i;t[0]===e?(r=t[1],n=t[2],i=t[3]):({href:n,children:r,...i}=e,t[0]=e,t[1]=r,t[2]=n,t[3]=i);let a=(0,m.useRef)(null),o;t[4]===n?o=t[5]:(o=()=>{let p=new URL(globalThis.location.href);p.hash=n,globalThis.history.pushState({},"",p.toString()),globalThis.dispatchEvent(new HashChangeEvent("hashchange"));let T=n.slice(1),x=document.getElementById(T);x&&x.scrollIntoView({behavior:"smooth",block:"start"})},t[4]=n,t[5]=o);let s=o,f;t[6]===s?f=t[7]:(f={onPress:()=>{s()}},t[6]=s,t[7]=f);let{pressProps:h}=W(f),u;t[8]===s?u=t[9]:(u=p=>{p.preventDefault(),s()},t[8]=s,t[9]=u);let b=u,d;return t[10]!==r||t[11]!==b||t[12]!==n||t[13]!==h||t[14]!==i?(d=(0,l.jsx)("a",{ref:a,href:n,...h,onClick:b,...i,children:r}),t[10]=r,t[11]=b,t[12]=n,t[13]=h,t[14]=i,t[15]=d):d=t[15],d};async function P(e){let t=L().inOrderIds.at(0);if(t)try{let r=await H.request({document:e,cellId:t});if(!r||r.options.length===0)return;let n=e.split(".").pop()??e,i=r.options[0],a=r.options.find(o=>o.name===n)??i;a!=null&&a.completion_info&&g.set(N,{documentation:a.completion_info})}catch(r){_.debug(`Doc lookup failed for "${e}"`,r)}}var D=E();const $=e=>{let t=(0,D.c)(8),{qualifiedName:r,children:n}=e,i;t[0]===r?i=t[1]:(i=()=>{P(r)},t[0]=r,t[1]=i);let a=q(i,100),o;t[2]===a?o=t[3]:(o=()=>a.cancel(),t[2]=a,t[3]=o);let s;return t[4]!==n||t[5]!==a||t[6]!==o?(s=(0,l.jsx)("span",{onMouseEnter:a,onMouseLeave:o,children:n}),t[4]=n,t[5]=a,t[6]=o,t[7]=s):s=t[7],s};function B(e){if(typeof e!="object"||!e)return!1;let t=e;return!(t.trusted!==!0||t.notebookCode!==void 0&&typeof t.notebookCode!="string")}function U(){let e=window==null?void 0:window.__MARIMO_EXPORT_CONTEXT__;return B(e)?e:void 0}function v(){var e;return((e=U())==null?void 0:e.trusted)===!0}function X(){if(g.get(R)||v()||g.get(w))return!0;try{if(j()==="read")return!0}catch{}return!1}var G=C(e=>{let t=e(R),r=e(w);if(t||r||v())return!1;let n=!0;try{n=j()==="read"}catch{return!0}return!n});function K(){return M(G)}var Z=E(),J=e=>{if(e instanceof c.Element&&!/^[A-Za-z][\w-]*$/.test(e.name))return m.createElement(m.Fragment)},Q=(e,t)=>{if(t instanceof c.Element&&t.name==="body"){if((0,m.isValidElement)(e)&&"props"in e){let r=e.props.children;return(0,l.jsx)(l.Fragment,{children:r})}return}},Y=(e,t)=>{if(t instanceof c.Element&&t.name==="html"){if((0,m.isValidElement)(e)&&"props"in e){let r=e.props.children;return(0,l.jsx)(l.Fragment,{children:r})}return}},tt=e=>{if(e instanceof c.Element&&e.attribs&&e.name==="iframe"){let t=document.createElement("iframe");return Object.entries(e.attribs).forEach(([r,n])=>{r.startsWith('"')&&r.endsWith('"')&&(r=r.slice(1,-1)),t.setAttribute(r,n)}),(0,l.jsx)("div",{dangerouslySetInnerHTML:{__html:t.outerHTML}})}},et=e=>{if(e instanceof c.Element&&e.name==="script"){let t=e.attribs.src;if(!t)return;if(!X())return _.warn(`[RenderHTML] refusing <script src> in untrusted context: ${t}`),(0,l.jsx)(l.Fragment,{});if(![...document.querySelectorAll("script[src]")].some(r=>r.getAttribute("src")===t)){let r=document.createElement("script");r.src=t,document.head.append(r)}return(0,l.jsx)(l.Fragment,{})}},rt=(e,t)=>{if(t instanceof c.Element&&t.name==="a"){let r=t.attribs.href;if(r!=null&&r.startsWith("#")&&!r.startsWith("#code/")){let n=null;return(0,m.isValidElement)(e)&&"props"in e&&(n=e.props.children),(0,l.jsx)(V,{href:r,...t.attribs,children:n})}}},nt=(e,t,r)=>{var n,i;if(t instanceof c.Element&&t.name==="div"&&((i=(n=t.attribs)==null?void 0:n.class)!=null&&i.includes("codehilite")))return(0,l.jsx)(ot,{children:e},r)},it=(e,t)=>{var r;if(t instanceof c.Element&&((r=t.attribs)!=null&&r["data-marimo-doc"])){let n=t.attribs["data-marimo-doc"];return(0,l.jsx)($,{qualifiedName:n,children:e})}},at=(e,t)=>{var r,n;if(t instanceof c.Element&&((r=t.attribs)!=null&&r["data-tooltip"])){if((((n=t.name)==null?void 0:n.toLowerCase())??"").startsWith("marimo-"))return;let i=t.attribs["data-tooltip"];return(0,l.jsx)(F,{content:i,children:e})}},ot=e=>{let t=(0,Z.c)(3),{children:r}=e,n=(0,m.useRef)(null),i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,l.jsx)("div",{className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity",children:(0,l.jsx)(O,{tooltip:!1,className:"p-1",value:()=>{var s;let o=(s=n.current)==null?void 0:s.firstChild;return o&&o.textContent||""}})}),t[0]=i):i=t[0];let a;return t[1]===r?a=t[2]:(a=(0,l.jsxs)("div",{className:"relative group codehilite-wrapper",ref:n,children:[r,i]}),t[1]=r,t[2]=a),a};const st=({html:e,additionalReplacements:t=[],alwaysSanitizeHtml:r=!0})=>(0,l.jsx)(lt,{html:e,alwaysSanitizeHtml:r,additionalReplacements:t});var lt=({html:e,additionalReplacements:t=[],alwaysSanitizeHtml:r})=>{let n=K();return ct({html:(0,m.useMemo)(()=>r||n?k(e):e,[e,r,n]),additionalReplacements:t})};function ct({html:e,additionalReplacements:t=[]}){let r=[J,tt,et,...t],n=[nt,rt,it,at,Q,Y];return I(e,{replace:(i,a)=>{for(let o of r){let s=o(i,a);if(s)return s}return i},transform:(i,a,o)=>{for(let s of n){let f=s(i,a,o);if(f)return f}return i}})}export{v as n,st as t};
1
+ import{s as y}from"./chunk-LvLJmgfZ.js";import{i as g,p as C,u as M}from"./useEvent-D91BmmQi.js";import{t as S}from"./react-Bj1aDYRI.js";import{_n as H,ai as I,it as j,m as L,oi as c,xn as N,yt as k}from"./cells-A-ljPpuj.js";import{t as E}from"./compiler-runtime-B3qBwwSJ.js";import{_}from"./useEventListener-BR0C1MaI.js";import{o as w}from"./utils-DIGrmLDO.js";import{t as A}from"./jsx-runtime-BqBOg78p.js";import{t as F}from"./tooltip-Gcwqb_SK.js";import{t as O}from"./copy-icon-C67c9EwB.js";import{t as W}from"./usePress-CtfZXGno.js";import{n as q}from"./useDebounce-BDIglWmG.js";import{t as R}from"./useRunCells-DU1tawR-.js";var z=E(),m=y(S(),1),l=y(A(),1);const V=e=>{let t=(0,z.c)(16),r,n,i;t[0]===e?(r=t[1],n=t[2],i=t[3]):({href:n,children:r,...i}=e,t[0]=e,t[1]=r,t[2]=n,t[3]=i);let a=(0,m.useRef)(null),o;t[4]===n?o=t[5]:(o=()=>{let p=new URL(globalThis.location.href);p.hash=n,globalThis.history.pushState({},"",p.toString()),globalThis.dispatchEvent(new HashChangeEvent("hashchange"));let T=n.slice(1),x=document.getElementById(T);x&&x.scrollIntoView({behavior:"smooth",block:"start"})},t[4]=n,t[5]=o);let s=o,f;t[6]===s?f=t[7]:(f={onPress:()=>{s()}},t[6]=s,t[7]=f);let{pressProps:h}=W(f),u;t[8]===s?u=t[9]:(u=p=>{p.preventDefault(),s()},t[8]=s,t[9]=u);let b=u,d;return t[10]!==r||t[11]!==b||t[12]!==n||t[13]!==h||t[14]!==i?(d=(0,l.jsx)("a",{ref:a,href:n,...h,onClick:b,...i,children:r}),t[10]=r,t[11]=b,t[12]=n,t[13]=h,t[14]=i,t[15]=d):d=t[15],d};async function P(e){let t=L().inOrderIds.at(0);if(t)try{let r=await H.request({document:e,cellId:t});if(!r||r.options.length===0)return;let n=e.split(".").pop()??e,i=r.options[0],a=r.options.find(o=>o.name===n)??i;a!=null&&a.completion_info&&g.set(N,{documentation:a.completion_info})}catch(r){_.debug(`Doc lookup failed for "${e}"`,r)}}var D=E();const $=e=>{let t=(0,D.c)(8),{qualifiedName:r,children:n}=e,i;t[0]===r?i=t[1]:(i=()=>{P(r)},t[0]=r,t[1]=i);let a=q(i,100),o;t[2]===a?o=t[3]:(o=()=>a.cancel(),t[2]=a,t[3]=o);let s;return t[4]!==n||t[5]!==a||t[6]!==o?(s=(0,l.jsx)("span",{onMouseEnter:a,onMouseLeave:o,children:n}),t[4]=n,t[5]=a,t[6]=o,t[7]=s):s=t[7],s};function B(e){if(typeof e!="object"||!e)return!1;let t=e;return!(t.trusted!==!0||t.notebookCode!==void 0&&typeof t.notebookCode!="string")}function U(){let e=window==null?void 0:window.__MARIMO_EXPORT_CONTEXT__;return B(e)?e:void 0}function v(){var e;return((e=U())==null?void 0:e.trusted)===!0}function X(){if(g.get(R)||v()||g.get(w))return!0;try{if(j()==="read")return!0}catch{}return!1}var G=C(e=>{let t=e(R),r=e(w);if(t||r||v())return!1;let n=!0;try{n=j()==="read"}catch{return!0}return!n});function K(){return M(G)}var Z=E(),J=e=>{if(e instanceof c.Element&&!/^[A-Za-z][\w-]*$/.test(e.name))return m.createElement(m.Fragment)},Q=(e,t)=>{if(t instanceof c.Element&&t.name==="body"){if((0,m.isValidElement)(e)&&"props"in e){let r=e.props.children;return(0,l.jsx)(l.Fragment,{children:r})}return}},Y=(e,t)=>{if(t instanceof c.Element&&t.name==="html"){if((0,m.isValidElement)(e)&&"props"in e){let r=e.props.children;return(0,l.jsx)(l.Fragment,{children:r})}return}},tt=e=>{if(e instanceof c.Element&&e.attribs&&e.name==="iframe"){let t=document.createElement("iframe");return Object.entries(e.attribs).forEach(([r,n])=>{r.startsWith('"')&&r.endsWith('"')&&(r=r.slice(1,-1)),t.setAttribute(r,n)}),(0,l.jsx)("div",{dangerouslySetInnerHTML:{__html:t.outerHTML}})}},et=e=>{if(e instanceof c.Element&&e.name==="script"){let t=e.attribs.src;if(!t)return;if(!X())return _.warn(`[RenderHTML] refusing <script src> in untrusted context: ${t}`),(0,l.jsx)(l.Fragment,{});if(![...document.querySelectorAll("script[src]")].some(r=>r.getAttribute("src")===t)){let r=document.createElement("script");r.src=t,document.head.append(r)}return(0,l.jsx)(l.Fragment,{})}},rt=(e,t)=>{if(t instanceof c.Element&&t.name==="a"){let r=t.attribs.href;if(r!=null&&r.startsWith("#")&&!r.startsWith("#code/")){let n=null;return(0,m.isValidElement)(e)&&"props"in e&&(n=e.props.children),(0,l.jsx)(V,{href:r,...t.attribs,children:n})}}},nt=(e,t,r)=>{var n,i;if(t instanceof c.Element&&t.name==="div"&&((i=(n=t.attribs)==null?void 0:n.class)!=null&&i.includes("codehilite")))return(0,l.jsx)(ot,{children:e},r)},it=(e,t)=>{var r;if(t instanceof c.Element&&((r=t.attribs)!=null&&r["data-marimo-doc"])){let n=t.attribs["data-marimo-doc"];return(0,l.jsx)($,{qualifiedName:n,children:e})}},at=(e,t)=>{var r,n;if(t instanceof c.Element&&((r=t.attribs)!=null&&r["data-tooltip"])){if((((n=t.name)==null?void 0:n.toLowerCase())??"").startsWith("marimo-"))return;let i=t.attribs["data-tooltip"];return(0,l.jsx)(F,{content:i,children:e})}},ot=e=>{let t=(0,Z.c)(3),{children:r}=e,n=(0,m.useRef)(null),i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,l.jsx)("div",{className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity",children:(0,l.jsx)(O,{tooltip:!1,className:"p-1",value:()=>{var s;let o=(s=n.current)==null?void 0:s.firstChild;return o&&o.textContent||""}})}),t[0]=i):i=t[0];let a;return t[1]===r?a=t[2]:(a=(0,l.jsxs)("div",{className:"relative group codehilite-wrapper",ref:n,children:[r,i]}),t[1]=r,t[2]=a),a};const st=({html:e,additionalReplacements:t=[],alwaysSanitizeHtml:r=!0})=>(0,l.jsx)(lt,{html:e,alwaysSanitizeHtml:r,additionalReplacements:t});var lt=({html:e,additionalReplacements:t=[],alwaysSanitizeHtml:r})=>{let n=K();return ct({html:(0,m.useMemo)(()=>r||n?k(e):e,[e,r,n]),additionalReplacements:t})};function ct({html:e,additionalReplacements:t=[]}){let r=[J,tt,et,...t],n=[nt,rt,it,at,Q,Y];return I(e,{replace:(i,a)=>{for(let o of r){let s=o(i,a);if(s)return s}return i},transform:(i,a,o)=>{for(let s of n){let f=s(i,a,o);if(f)return f}return i}})}export{v as n,st as t};