@marimo-team/frontend 0.23.11-dev1 → 0.23.11-dev10

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 (84) hide show
  1. package/dist/assets/{CellStatus-e0ex7Iei.js → CellStatus-CLGvVxcw.js} +1 -1
  2. package/dist/assets/{JsonOutput-DRNPZOvX.js → JsonOutput-uEJijGXp.js} +5 -5
  3. package/dist/assets/{MarimoErrorOutput-BH6hs0Ir.js → MarimoErrorOutput-DzoKyXWR.js} +2 -2
  4. package/dist/assets/{RenderHTML-BQ1PO4Wd.js → RenderHTML-DAt48X-F.js} +1 -1
  5. package/dist/assets/{RunButton-F8pLIvFp.js → RunButton-B7msyyYi.js} +1 -1
  6. package/dist/assets/{add-cell-with-ai-C2OtCghK.js → add-cell-with-ai-CAkcousR.js} +8 -8
  7. package/dist/assets/{add-connection-dialog-AhwxOztN.js → add-connection-dialog-ZyXXfAVG.js} +32 -32
  8. package/dist/assets/{agent-panel-D6ryE8xb.js → agent-panel-BfIguQXh.js} +3 -3
  9. package/dist/assets/{ai-model-dropdown-CG4B4rqH.js → ai-model-dropdown-rE64ytSX.js} +3 -3
  10. package/dist/assets/{app-config-button-D_sFrSql.js → app-config-button-DLRZ5d9c.js} +1 -1
  11. package/dist/assets/{cell-editor-XNa3wJ3P.js → cell-editor-2JIpvFn4.js} +5 -5
  12. package/dist/assets/{cell-link-Bj4-yOIx.js → cell-link-DY95GSb7.js} +1 -1
  13. package/dist/assets/{cells-DOA0Gew8.js → cells-D-v2lBet.js} +67 -67
  14. package/dist/assets/{chat-display-CezkHLLR.js → chat-display-DO-tqsbY.js} +1 -1
  15. package/dist/assets/{chat-panel-DEBTPtwE.js → chat-panel-BT5gLfs6.js} +1 -1
  16. package/dist/assets/{chat-ui-CIr1o1hq.js → chat-ui-Be4yDBZS.js} +1 -1
  17. package/dist/assets/column-preview-BzvFdLI5.js +1 -0
  18. package/dist/assets/{command-palette-_VEEjmkI.js → command-palette-CKKzfpGt.js} +1 -1
  19. package/dist/assets/{common-fDFYY_sv.js → common-Do4N1uVK.js} +1 -1
  20. package/dist/assets/{components--C6N-DXq.js → components-DUC0f1XD.js} +1 -1
  21. package/dist/assets/{datasource-CR6RRpTi.js → datasource-BQGI7c_u.js} +2 -2
  22. package/dist/assets/{dependency-graph-panel-BEgkvdX0.js → dependency-graph-panel-Czoya7c2.js} +1 -1
  23. package/dist/assets/{documentation-panel-HvbKykbI.js → documentation-panel-LokVYDIZ.js} +1 -1
  24. package/dist/assets/{download-DhxnAw14.js → download-WGU5w_3m.js} +3 -3
  25. package/dist/assets/{edit-page-D-02q6iz.js → edit-page-BPQO1Uuz.js} +6 -6
  26. package/dist/assets/{error-panel-WLBQ3q9p.js → error-panel-BCm_e4eM.js} +1 -1
  27. package/dist/assets/{file-explorer-panel-DtzGlnzT.js → file-explorer-panel-D1NN-z8x.js} +3 -3
  28. package/dist/assets/{file-icons-D2f3nfbq.js → file-icons-CF-YT4hq.js} +1 -1
  29. package/dist/assets/{file-name-input-BNYf9WWM.js → file-name-input-BRVXQ3OU.js} +1 -1
  30. package/dist/assets/{floating-outline-BvHFWRoz.js → floating-outline-D33Zu-Ad.js} +1 -1
  31. package/dist/assets/{focus-Ldqh99xE.js → focus-BfFAxl9X.js} +1 -1
  32. package/dist/assets/{form-CxBAInfg.js → form-CVBFx2z3.js} +1 -1
  33. package/dist/assets/{home-page-DwFpLpXK.js → home-page-CL9Hv1Hg.js} +2 -2
  34. package/dist/assets/{hooks-5gNQitDd.js → hooks-83y0XCiC.js} +1 -1
  35. package/dist/assets/{html-to-image-CyAtzePO.js → html-to-image-IPNqWX7V.js} +2 -2
  36. package/dist/assets/index-BNWrEIlp.css +2 -0
  37. package/dist/assets/{index-CGCBsDqs.js → index-CuhY66ZR.js} +14 -14
  38. package/dist/assets/{kiosk-mode-CTWHjzXs.js → kiosk-mode-BSufcIZH.js} +1 -1
  39. package/dist/assets/{layout-D3pd3R21.js → layout-ks0WJ2vR.js} +5 -5
  40. package/dist/assets/{logs-panel-BVLYycQb.js → logs-panel-DXN6sUaA.js} +1 -1
  41. package/dist/assets/{markdown-renderer-C9Ujvj0b.js → markdown-renderer-DWRPo52L.js} +1 -1
  42. package/dist/assets/{name-cell-input-DabvuruX.js → name-cell-input-BiDIx6YQ.js} +1 -1
  43. package/dist/assets/{outline-panel-B-ncbNWI.js → outline-panel-DVSGNRgP.js} +1 -1
  44. package/dist/assets/{packages-panel-CESeW_3T.js → packages-panel-DTX6CBnm.js} +1 -1
  45. package/dist/assets/{panels-CTy3hq0L.js → panels-NhGV0SBq.js} +1 -1
  46. package/dist/assets/{process-output-pPgH0ANl.js → process-output-BiWV34b7.js} +1 -1
  47. package/dist/assets/{radio-group-D7rh6Zek.js → radio-group-DV-lQvil.js} +1 -1
  48. package/dist/assets/{readonly-python-code-CvPx4CU_.js → readonly-python-code-B0glFTKW.js} +1 -1
  49. package/dist/assets/{reveal-component-lTtEZQh1.js → reveal-component-C2M2FixA.js} +12 -12
  50. package/dist/assets/{run-page-BB6ghGfO.js → run-page-B6I-Lshx.js} +1 -1
  51. package/dist/assets/{scratchpad-panel-Bvb8RxUv.js → scratchpad-panel-DU7perVk.js} +1 -1
  52. package/dist/assets/session-panel-B4UTmf-j.js +1 -0
  53. package/dist/assets/{snippets-panel-BSgcoo-M.js → snippets-panel-KRdl4bVk.js} +1 -1
  54. package/dist/assets/{state-BWM3qRkR.js → state-BSm0OM93.js} +1 -1
  55. package/dist/assets/{state-C8yHPSLN.js → state-CbkvENzk.js} +2 -2
  56. package/dist/assets/{textarea-bBuxbFm7.js → textarea-CBbixTxi.js} +1 -1
  57. package/dist/assets/{tracing-pt7eDHWc.js → tracing-D8LGpuXa.js} +1 -1
  58. package/dist/assets/{tracing-panel-BveZ5DZw.js → tracing-panel-TUP6kAd5.js} +2 -2
  59. package/dist/assets/{tree-actions-1KQDSu1H.js → tree-actions-BvrKFU0g.js} +1 -1
  60. package/dist/assets/{useCellActionButton-C4V7J6PS.js → useCellActionButton-CtOZIXD0.js} +1 -1
  61. package/dist/assets/{useDeleteCell-BvnurAZ9.js → useDeleteCell-BLvzLWAT.js} +1 -1
  62. package/dist/assets/{useDependencyPanelTab-DNlXaxbt.js → useDependencyPanelTab-BP0sNfUz.js} +1 -1
  63. package/dist/assets/{useNotebookActions-BIQkawja.js → useNotebookActions-BI5dWutQ.js} +1 -1
  64. package/dist/assets/{useRunCells-cSZpNqnR.js → useRunCells-BClkx9Pq.js} +1 -1
  65. package/dist/assets/{useSplitCell-s7dSiBUa.js → useSplitCell-CpddCX_u.js} +1 -1
  66. package/dist/index.html +23 -23
  67. package/package.json +1 -1
  68. package/src/components/datasources/__tests__/column-preview.test.tsx +97 -0
  69. package/src/components/datasources/__tests__/filter-empty.test.ts +81 -0
  70. package/src/components/datasources/__tests__/utils.test.ts +62 -1
  71. package/src/components/datasources/column-preview.tsx +2 -4
  72. package/src/components/datasources/components.tsx +15 -7
  73. package/src/components/datasources/datasources.tsx +311 -178
  74. package/src/components/datasources/utils.ts +40 -1
  75. package/src/components/editor/connections/components.tsx +13 -0
  76. package/src/components/editor/connections/storage/__tests__/__snapshots__/as-code.test.ts.snap +4 -4
  77. package/src/components/editor/connections/storage/as-code.ts +11 -4
  78. package/src/core/cells/__tests__/cells.test.ts +33 -0
  79. package/src/core/cells/cells.ts +1 -1
  80. package/src/core/datasets/__tests__/data-source.test.ts +226 -0
  81. package/src/core/datasets/data-source-connections.ts +88 -24
  82. package/dist/assets/column-preview-nu3Qo2OW.js +0 -1
  83. package/dist/assets/index-BAYF7dcV.css +0 -2
  84. package/dist/assets/session-panel-CTJPYbAa.js +0 -1
@@ -1,7 +1,7 @@
1
- import{s as te}from"./chunk-LvLJmgfZ.js";import{d as Ae,f as Se,l as Ee,u as re}from"./useEvent-D91BmmQi.js";import{t as ze}from"./react-Bj1aDYRI.js";import{D as Me,In as qe,On as Pe,_r as Le,b as We,gi as se,hi as De,it as Oe,ki as Be,pr as Qe}from"./cells-DOA0Gew8.js";import{t as E}from"./compiler-runtime-B3qBwwSJ.js";import{t as Re}from"./invariant-BUdrueMv.js";import{i as Ve,y as He}from"./utils-CvI-39U6.js";import{t as ne}from"./cn-DCUzRj2J.js";import{t as Ue}from"./jsx-runtime-BqBOg78p.js";import{a as Ge,i as Je,n as Ke,r as Xe}from"./multi-map-C4OANz8X.js";import{a as Ye,p as Ze,r as et,t as tt}from"./dropdown-menu-CZ4XbE-c.js";import{t as B}from"./tooltip-B_PkSKN3.js";import{r as le,t as A}from"./button-BbCh-29a.js";import{t as ie}from"./createLucideIcon-D5guW7EU.js";import{r as ae}from"./x-C-6liIBr.js";import{t as rt}from"./chevron-right-CG5QYXYk.js";import{t as st}from"./package-Tv6ztuzw.js";import{t as nt}from"./sparkles-lWUAsPhp.js";import{c as ce,n as lt}from"./datasource-CR6RRpTi.js";import{a as it}from"./dist-BURue7-e.js";import{t as at}from"./RenderHTML-BQ1PO4Wd.js";import{t as oe}from"./kbd-CTUAEnEx.js";import{t as z}from"./links-D1JoyKTt.js";import{r as ct,t as ot}from"./alert-yTS3WpF4.js";import{o as mt,t as dt}from"./useInstallPackage-GI6gu7_S.js";import{n as pt}from"./state-BWM3qRkR.js";import{n as k}from"./cell-link-Bj4-yOIx.js";var M=ie("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"}]]),me=ie("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]),de=String.raw`_cell_([^\W_][\w-]*?)(_\w*)`,pe=String.raw`(?<!_)${de}`;`${de}`;var ut=new RegExp(pe),K=new RegExp(pe,"g");function ue(r){let e=[];K.lastIndex=0;let n=0,s=K.exec(r);for(;s!==null;)s.index>n&&e.push(r.slice(n,s.index)),e.push({cellId:s[1],name:s[2]}),n=s.index+s[0].length,s=K.exec(r);return n<r.length&&e.push(r.slice(n)),e}function xt(r){return ut.test(r)}function ht(r){let e=null,n=r.cursor();do n.name==="ExpressionStatement"&&(e=n.node);while(n.next());return e}function ft(r){let e=r.split(`
1
+ import{s as te}from"./chunk-LvLJmgfZ.js";import{d as Ae,f as Se,l as Ee,u as re}from"./useEvent-D91BmmQi.js";import{t as ze}from"./react-Bj1aDYRI.js";import{D as Me,In as qe,Ni as Pe,On as Le,_r as We,b as De,bi as se,it as Oe,pr as Be,yi as Qe}from"./cells-D-v2lBet.js";import{t as E}from"./compiler-runtime-B3qBwwSJ.js";import{t as Re}from"./invariant-BUdrueMv.js";import{i as Ve,y as He}from"./utils-CvI-39U6.js";import{t as ne}from"./cn-DCUzRj2J.js";import{t as Ue}from"./jsx-runtime-BqBOg78p.js";import{a as Ge,i as Je,n as Ke,r as Xe}from"./multi-map-C4OANz8X.js";import{a as Ye,p as Ze,r as et,t as tt}from"./dropdown-menu-CZ4XbE-c.js";import{t as B}from"./tooltip-B_PkSKN3.js";import{r as le,t as A}from"./button-BbCh-29a.js";import{t as ie}from"./createLucideIcon-D5guW7EU.js";import{r as ae}from"./x-C-6liIBr.js";import{t as rt}from"./chevron-right-CG5QYXYk.js";import{t as st}from"./package-Tv6ztuzw.js";import{t as nt}from"./sparkles-lWUAsPhp.js";import{c as ce,n as lt}from"./datasource-BQGI7c_u.js";import{a as it}from"./dist-BURue7-e.js";import{t as at}from"./RenderHTML-DAt48X-F.js";import{t as oe}from"./kbd-CTUAEnEx.js";import{t as z}from"./links-D1JoyKTt.js";import{r as ct,t as ot}from"./alert-yTS3WpF4.js";import{o as mt,t as dt}from"./useInstallPackage-GI6gu7_S.js";import{n as pt}from"./state-BSm0OM93.js";import{n as k}from"./cell-link-DY95GSb7.js";var M=ie("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"}]]),me=ie("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]),de=String.raw`_cell_([^\W_][\w-]*?)(_\w*)`,pe=String.raw`(?<!_)${de}`;`${de}`;var ut=new RegExp(pe),K=new RegExp(pe,"g");function ue(r){let e=[];K.lastIndex=0;let n=0,s=K.exec(r);for(;s!==null;)s.index>n&&e.push(r.slice(n,s.index)),e.push({cellId:s[1],name:s[2]}),n=s.index+s[0].length,s=K.exec(r);return n<r.length&&e.push(r.slice(n)),e}function xt(r){return ut.test(r)}function ht(r){let e=null,n=r.cursor();do n.name==="ExpressionStatement"&&(e=n.node);while(n.next());return e}function ft(r){let e=r.split(`
2
2
  `),n=" ",s=ht(it.parse(r));if(!s)return["def _():",...X(e,n),`${n}return`,"","","_()"].join(`
3
3
  `);let i=r.slice(0,s.from).trim(),l=r.slice(s.from).trim(),c=i.split(`
4
4
  `),a=l.split(`
5
5
  `);return["def _():",...X(c,n),`${n}return ${a[0]}`,...X(a.slice(1),n),"","","_()"].join(`
6
6
  `)}function X(r,e){if(r.length===1&&r[0]==="")return[];let n=[];for(let s of r)s===""?n.push(""):n.push(e+s);return n}function jt(r,e){var n;if(r.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 s=>{Re(s.editor,"Editor is null");let i=ft(s.editor.state.doc.toString());s.editor.dispatch({changes:{from:0,to:s.editor.state.doc.length,insert:i}})}}];if(r.type==="exception"&&r.exception_type==="NameError"){let s=(n=r.msg.match(/name '(.+)' is not defined/))==null?void 0:n[1];if(!s||!(s in xe))return[];let i=gt(s);return[{title:`Fix: Add '${i}'`,description:"Add a new cell for the missing import",fixType:"manual",onFix:async l=>{l.addCodeBelow(i)}}]}return r.type==="sql-error"&&e.aiEnabled?[{title:"Fix with AI",description:"Fix the SQL statement",fixType:"ai",onFix:async s=>{var c;let i=lt(s.cellId),l=`Fix the SQL statement: ${r.msg}.`;i&&(l+=`
7
- Database schema: ${i}`),(c=s.aiFix)==null||c.setAiCompletionCell({cellId:s.cellId,initialPrompt:l,triggerImmediately:s.aiFix.triggerFix})}}]:[]}function gt(r){let e=xe[r];return e===r?`import ${e}`:`import ${e} as ${r}`}var xe={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"},yt=E(),Nt=Be("marimo:ai-autofix-mode","autofix",qe);function bt(){let r=(0,yt.c)(3),[e,n]=Ee(Nt),s;return r[0]!==e||r[1]!==n?(s={fixMode:e,setFixMode:n},r[0]=e,r[1]=n,r[2]=s):s=r[2],s}var Y=E(),t=te(Ue(),1);const b=r=>{let e=(0,Y.c)(21),{errors:n,cellId:s,className:i}=r,l=Se(),{createNewCell:c}=Me(),a=re(Ve),o;if(e[0]!==a||e[1]!==n){let y;e[3]===a?y=e[4]:(y=v=>jt(v,{aiEnabled:a}),e[3]=a,e[4]=y),o=n.flatMap(y),e[0]=a,e[1]=n,e[2]=o}else o=e[2];let d=o,p=Ae(pt);if(d.length===0)return null;let m=d[0],f;e[5]!==s||e[6]!==c||e[7]!==m||e[8]!==p||e[9]!==l?(f=y=>{var w;let v=(w=l.get(We).cellHandles[s].current)==null?void 0:w.editorView;m.onFix({addCodeBelow:I=>{c({cellId:s,autoFocus:!1,before:!1,code:I})},editor:v,cellId:s,aiFix:{setAiCompletionCell:p,triggerFix:y}}),v==null||v.focus()},e[5]=s,e[6]=c,e[7]=m,e[8]=p,e[9]=l,e[10]=f):f=e[10];let x=f,j;e[11]===i?j=e[12]:(j=ne("my-2",i),e[11]=i,e[12]=j);let u;e[13]!==m.description||e[14]!==m.fixType||e[15]!==m.title||e[16]!==x?(u=m.fixType==="ai"?(0,t.jsx)(ye,{tooltip:m.description,openPrompt:()=>x(!1),applyAutofix:()=>x(!0)}):(0,t.jsx)(B,{content:m.description,align:"start",children:(0,t.jsxs)(A,{size:"xs",variant:"outline",className:"font-normal",onClick:()=>x(!1),children:[(0,t.jsx)(ce,{className:"h-3 w-3 mr-2"}),m.title]})}),e[13]=m.description,e[14]=m.fixType,e[15]=m.title,e[16]=x,e[17]=u):u=e[17];let g;return e[18]!==j||e[19]!==u?(g=(0,t.jsx)("div",{className:j,children:u}),e[18]=j,e[19]=u,e[20]=g):g=e[20],g};var he=nt,fe=ce,je="Suggest a prompt",ge="Fix with AI";const ye=r=>{let e=(0,Y.c)(21),{tooltip:n,openPrompt:s,applyAutofix:i}=r,{fixMode:l,setFixMode:c}=bt(),a=l==="prompt"?s:i,o;e[0]===l?o=e[1]:(o=l==="prompt"?(0,t.jsx)(he,{className:"h-3 w-3 mr-2 mb-0.5"}):(0,t.jsx)(fe,{className:"h-3 w-3 mr-2 mb-0.5"}),e[0]=l,e[1]=o);let d=l==="prompt"?je:ge,p;e[2]!==a||e[3]!==o||e[4]!==d?(p=(0,t.jsxs)(A,{size:"xs",variant:"outline",className:"font-normal rounded-r-none border-r-0",onClick:a,children:[o,d]}),e[2]=a,e[3]=o,e[4]=d,e[5]=p):p=e[5];let m;e[6]!==p||e[7]!==n?(m=(0,t.jsx)(B,{content:n,align:"start",children:p}),e[6]=p,e[7]=n,e[8]=m):m=e[8];let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f=(0,t.jsx)(Ze,{asChild:!0,children:(0,t.jsx)(A,{size:"xs",variant:"outline",className:"rounded-l-none px-2","aria-label":"Fix options",children:(0,t.jsx)(ae,{className:"h-3 w-3"})})}),e[9]=f):f=e[9];let x;e[10]!==l||e[11]!==c?(x=()=>{c(l==="prompt"?"autofix":"prompt")},e[10]=l,e[11]=c,e[12]=x):x=e[12];let j=l==="prompt"?"autofix":"prompt",u;e[13]===j?u=e[14]:(u=(0,t.jsx)(vt,{mode:j}),e[13]=j,e[14]=u);let g;e[15]!==x||e[16]!==u?(g=(0,t.jsxs)(tt,{children:[f,(0,t.jsx)(et,{align:"end",className:"w-56",children:(0,t.jsx)(Ye,{className:"flex items-center gap-2",onClick:x,children:u})})]}),e[15]=x,e[16]=u,e[17]=g):g=e[17];let y;return e[18]!==g||e[19]!==m?(y=(0,t.jsxs)("div",{className:"flex",children:[m,g]}),e[18]=g,e[19]=m,e[20]=y):y=e[20],y};var vt=r=>{let e=(0,Y.c)(12),{mode:n}=r,s;e[0]===n?s=e[1]:(s=n==="prompt"?(0,t.jsx)(he,{className:"h-4 w-4"}):(0,t.jsx)(fe,{className:"h-4 w-4"}),e[0]=n,e[1]=s);let i=s,l=n==="prompt"?je:ge,c=n==="prompt"?"Edit the prompt before applying":"Apply AI fixes automatically",a;e[2]===l?a=e[3]:(a=(0,t.jsx)("span",{className:"font-medium",children:l}),e[2]=l,e[3]=a);let o;e[4]===c?o=e[5]:(o=(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:c}),e[4]=c,e[5]=o);let d;e[6]!==a||e[7]!==o?(d=(0,t.jsxs)("div",{className:"flex flex-col",children:[a,o]}),e[6]=a,e[7]=o,e[8]=d):d=e[8];let p;return e[9]!==i||e[10]!==d?(p=(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[i,d]}),e[9]=i,e[10]=d,e[11]=p):p=e[11],p},Ne=E();const wt=r=>{let e=(0,Ne.c)(12),{local:n}=r,s;e[0]===n.name?s=e[1]:(s=(0,t.jsx)("span",{className:"font-code",children:n.name}),e[0]=n.name,e[1]=s);let i;e[2]===n.cellId?i=e[3]:(i=(0,t.jsx)(k,{cellId:n.cellId}),e[2]=n.cellId,e[3]=i);let l;e[4]!==s||e[5]!==i?(l=(0,t.jsxs)("div",{className:"max-w-xs",children:["Local variable ",s," in cell"," ",i,"."]}),e[4]=s,e[5]=i,e[6]=l):l=e[6];let c=l,a;e[7]===n.name?a=e[8]:(a=(0,t.jsx)("span",{className:"font-code cursor-help",children:n.name}),e[7]=n.name,e[8]=a);let o;return e[9]!==a||e[10]!==c?(o=(0,t.jsx)(B,{content:c,children:a}),e[9]=a,e[10]=c,e[11]=o):o=e[11],o},be=r=>{let e=(0,Ne.c)(4),{segments:n}=r,s;e[0]===n?s=e[1]:(s=n.map(kt),e[0]=n,e[1]=s);let i;return e[2]===s?i=e[3]:(i=(0,t.jsx)(t.Fragment,{children:s}),e[2]=s,e[3]=i),i};function kt(r,e){return typeof r=="string"?(0,t.jsx)("span",{children:r},e):(0,t.jsx)(wt,{local:r},e)}var ve=/(https?:\/\/\S+)/,It=/\.(png|jpe?g|gif|webp|svg|ico)(\?.*)?$/i,we=/^data:image\//i,_t=["avatars.githubusercontent.com"];function ke(r){return we.test(r)?[{type:"image",url:r}]:r.split(ve).filter(e=>e!=="").map(e=>ve.test(e)?It.test(e)||we.test(e)||_t.some(n=>e.includes(n))?{type:"image",url:e}:{type:"url",url:e}:{type:"text",value:e})}var Ie=E(),q=te(ze(),1),$t=new Oe;const Z=r=>{let e=RegExp("\x1B\\[[0-9;]*m","g");return r.replaceAll(e,"")};var _e=/(pip\s+install|uv\s+add|uv\s+pip\s+install)\s+/gi;function Ft(r){_e.lastIndex=0;let e=_e.exec(r);if(!e)return null;let n=e.index+e[0].length,s=r.slice(n).split(/\s+/),i="",l=0;for(let a of s){let o=a.trim();if(!o)continue;if(o.startsWith("-")){l+=o.length+1;continue}let d=o.match(/^[\w,.[\]-]+/);if(d){i=d[0];break}break}if(!i)return null;let c=n+l+i.length;return{package:i,endIndex:c}}function $(r,e=""){if(!r)return null;if(!/https?:\/\//.test(r))return r;let n=ke(r);return n.length===1&&n[0].type==="text"?r:(0,t.jsx)(t.Fragment,{children:n.map((s,i)=>{let l=e?`${e}-${i}`:i;if(s.type==="url"){let c=Z(s.url);return(0,t.jsx)("a",{href:c,target:"_blank",rel:"noopener noreferrer",onClick:le.stopPropagation(),className:"text-link hover:underline",children:c},l)}if(s.type==="image"){let c=Z(s.url);return(0,t.jsx)("a",{href:c,target:"_blank",rel:"noopener noreferrer",onClick:le.stopPropagation(),className:"text-link hover:underline",children:c},l)}return(0,t.jsx)(q.Fragment,{children:s.value},l)})})}var Ct=r=>{let e=(0,Ie.c)(6),{packages:n,children:s}=r,{handleInstallPackages:i}=dt(),l;e[0]!==i||e[1]!==n?(l=a=>{i(n),a.preventDefault()},e[0]=i,e[1]=n,e[2]=l):l=e[2];let c;return e[3]!==s||e[4]!==l?(c=(0,t.jsx)("button",{onClick:l,className:"text-link hover:underline",type:"button",children:s}),e[3]=s,e[4]=l,e[5]=c):c=e[5],c};const Tt=r=>{if(!(r instanceof se.Text))return;let e=Z(r.data);if(!/(pip\s+install|uv\s+add|uv\s+pip\s+install)/i.test(e))return;let n=[],s=/(pip\s+install|uv\s+add|uv\s+pip\s+install)\s+/gi,i;for(;(i=s.exec(e))!==null;){let a=i.index,o=Ft(e.slice(a));o&&n.push({match:i,result:o})}if(n.length===0)return;let l=[],c=0;if(n.forEach((a,o)=>{let{match:d,result:p}=a,m=d.index,f=m+p.endIndex;if(c<m){let j=e.slice(c,m);l.push((0,t.jsx)(q.Fragment,{children:$(j,`before-${o}`)},`before-${o}`))}let x=e.slice(m,f);l.push((0,t.jsx)(Ct,{packages:[p.package],children:x},`install-${o}`)),c=f}),c<e.length){let a=e.slice(c);l.push((0,t.jsx)(q.Fragment,{children:$(a,"after")},"after"))}return(0,t.jsx)(t.Fragment,{children:l})},At=r=>{if(!(r instanceof se.Text))return;let e=r.data;if(!/https?:\/\//.test(e))return;let n=$(e);if(typeof n!="string")return(0,t.jsx)(t.Fragment,{children:n})},St=(...r)=>e=>{for(let n of r){let s=n(e);if(s!==void 0)return s}},Et=(r,e)=>(0,t.jsx)("span",{children:De($t.ansi_to_html(r),{replace:n=>e(n)})}),zt=r=>{let e=(0,Ie.c)(4),{text:n}=r,s;e[0]===n?s=e[1]:(s=Et(n,St(Tt,At)),e[0]=n,e[1]=s);let i=s,l;return e[2]===i?l=e[3]:(l=(0,t.jsx)(t.Fragment,{children:i}),e[2]=i,e[3]=l),l};var ee=E(),$e=r=>{let e=(0,ee.c)(16),{traceback:n}=r,[s,i]=(0,q.useState)(!0),l;e[0]===s?l=e[1]:(l=()=>i(!s),e[0]=s,e[1]=l);let c=s?"Collapse traceback":"Expand traceback",a;e[2]===s?a=e[3]:(a=s?(0,t.jsx)(ae,{className:"h-3 w-3"}):(0,t.jsx)(rt,{className:"h-3 w-3"}),e[2]=s,e[3]=a);let o;e[4]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)("span",{className:"text-[0.6875rem] uppercase tracking-wider",children:"Traceback"}),e[4]=o):o=e[4];let d;e[5]!==s||e[6]!==l||e[7]!==c||e[8]!==a?(d=(0,t.jsxs)("button",{type:"button",onClick:l,"aria-expanded":s,"aria-label":c,className:"flex items-center gap-1 text-muted-foreground/70 hover:text-muted-foreground transition-colors",children:[a,o]}),e[5]=s,e[6]=l,e[7]=c,e[8]=a,e[9]=d):d=e[9];let p;e[10]!==s||e[11]!==n?(p=s&&(0,t.jsx)("div",{className:"font-code text-sm mt-1 p-3 bg-muted rounded border overflow-auto max-h-[50vh] cursor-text select-text",children:at({html:n})}),e[10]=s,e[11]=n,e[12]=p):p=e[12];let m;return e[13]!==d||e[14]!==p?(m=(0,t.jsxs)("div",{className:"mt-2",children:[d,p]}),e[13]=d,e[14]=p,e[15]=m):m=e[15],m},F=r=>{let e=(0,ee.c)(10),n=r.title??"Tip",s;e[0]===n?s=e[1]:(s=(0,t.jsx)(Ge,{className:"pt-2 pb-0 font-normal",children:n}),e[0]=n,e[1]=s);let i;e[2]===r.children?i=e[3]:(i=(0,t.jsx)(Xe,{className:"mr-24 text-[0.84375rem]",wrapperClassName:"pt-0 pb-2",children:r.children}),e[2]=r.children,e[3]=i);let l;e[4]!==s||e[5]!==i?(l=(0,t.jsxs)(Je,{value:"item-1",className:"text-muted-foreground",children:[s,i]}),e[4]=s,e[5]=i,e[6]=l):l=e[6];let c;return e[7]!==r.className||e[8]!==l?(c=(0,t.jsx)(Ke,{type:"single",collapsible:!0,className:r.className,children:l}),e[7]=r.className,e[8]=l,e[9]=c):c=e[9],c};const Mt=r=>{let e=(0,ee.c)(38),{errors:n,cellId:s,className:i}=r,l=Pe(),c=re(He).display.cell_output==="above",a="This cell wasn't run because it has errors",o="destructive",d="text-error",p=null;if(n.some(qt))a="Interrupted";else if(n.some(Pt))a="An internal error occurred";else if(n.some(Lt))a="Ancestor prevented from running",o="default",d="text-secondary-foreground";else if(n.some(Wt))a="Ancestor stopped",o="default",d="text-secondary-foreground";else if(n.some(Dt))a="SQL error";else if(n.some(Ot))a=null,p="Cell not run";else{let w;e[0]===n?w=e[1]:(w=n.find(Bt),e[0]=n,e[1]=w);let I=w;I&&"exception_type"in I&&(a=I.exception_type)}let m,f,x,j,u,g;if(e[2]!==o||e[3]!==s||e[4]!==l||e[5]!==i||e[6]!==n||e[7]!==c||e[8]!==p||e[9]!==d||e[10]!==a){let w=n.filter(Qt),I=n.filter(Rt),P=n.filter(Vt),Q=n.filter(Ht),R=n.filter(Ut),L=n.filter(Gt),W=n.filter(Jt),V=n.filter(Kt),H=n.filter(Xt),U=n.filter(Yt),S=n.filter(Zt),G=n.filter(er),J=n.filter(tr),D;e[17]===l?D=e[18]:(D=()=>{l.openApplication("scratchpad")},e[17]=l,e[18]=D);let Fe=D,Ce=()=>{let N=[];if(S.length>0||G.length>0){let h=S.some(rr),_=!h&&S.some(sr);N.push((0,t.jsxs)("div",{children:[S.map(nr),G.map(lr),h&&(0,t.jsxs)(A,{size:"xs",variant:"outline",className:"mt-2 font-normal",onClick:()=>mt(l),children:[(0,t.jsx)(st,{className:"h-3.5 w-3.5 mr-1.5 mb-0.5"}),(0,t.jsx)("span",{children:"Open package manager"})]}),_&&(0,t.jsxs)(A,{size:"xs",variant:"outline",className:"mt-2 font-normal",onClick:()=>l.openApplication("terminal"),children:[(0,t.jsx)(me,{className:"h-3.5 w-3.5 mr-1.5"}),(0,t.jsx)("span",{children:"Open terminal"})]}),s&&(0,t.jsx)(b,{errors:[...S,...G],cellId:s})]},"syntax-unknown"))}if(w.length>0&&N.push((0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground font-medium",children:"The setup cell cannot be run because it has references."}),(0,t.jsx)("ul",{className:"list-disc",children:w.flatMap(ir)}),s&&(0,t.jsx)(b,{errors:w,cellId:s}),(0,t.jsxs)(F,{title:"Why can't the setup cell have references?",className:"mb-2",children:[(0,t.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,t.jsx)("p",{className:"py-2",children:"Try simplifying the setup cell to only contain only necessary variables."}),(0,t.jsxs)("p",{className:"py-2",children:[(0,t.jsxs)(z,{href:"https://links.marimo.app/errors-setup",children:["Learn more at our docs"," ",(0,t.jsx)(M,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"setup-refs")),I.length>0&&N.push((0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground font-medium",children:"This cell is in a cycle."}),(0,t.jsx)("ul",{className:"list-disc",children:I.flatMap(ar)}),s&&(0,t.jsx)(b,{errors:I,cellId:s}),(0,t.jsxs)(F,{title:"What are cycles and how do I resolve them?",className:"mb-2",children:[(0,t.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,t.jsx)("p",{className:"py-2",children:"Try merging these cells into a single cell to eliminate the cycle."}),(0,t.jsxs)("p",{className:"py-2",children:[(0,t.jsxs)(z,{href:"https://links.marimo.app/errors-cycles",children:["Learn more at our docs"," ",(0,t.jsx)(M,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"cycle")),P.length>0){let h=P[0].name;N.push((0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground font-medium",children:"This cell redefines variables from other cells."}),P.map(or),s&&(0,t.jsx)(b,{errors:P,cellId:s}),(0,t.jsxs)(F,{title:"Why can't I redefine variables?",children:[(0,t.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,t.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,t.jsxs)(oe,{className:"inline",children:["_",h]}),"). to make them private to this cell."]}),(0,t.jsxs)("p",{className:"py-2",children:[(0,t.jsxs)(z,{href:"https://links.marimo.app/errors-multiple-definitions",children:["Learn more at our docs"," ",(0,t.jsx)(M,{size:"0.75rem",className:"inline"})]}),"."]})]}),(0,t.jsx)(F,{title:"Need a scratchpad?",children:(0,t.jsxs)("div",{className:"flex flex-row gap-2 items-center",children:[(0,t.jsxs)(A,{size:"xs",variant:"link",className:"my-2 font-normal mx-0 px-0",onClick:Fe,children:[(0,t.jsx)(Qe,{className:"h-3"}),(0,t.jsx)("span",{children:"Try the scratchpad"})]}),(0,t.jsx)("span",{children:"to experiment without restrictions on variable names."})]})})]},"multiple-defs"))}return Q.length>0&&N.push((0,t.jsxs)("div",{children:[Q.map(mr),s&&(0,t.jsx)(b,{errors:Q,cellId:s}),(0,t.jsxs)(F,{title:"Why can't I use `import *`?",children:[(0,t.jsx)("p",{className:"pb-2",children:"Star imports are incompatible with marimo's git-friendly file format and reproducible reactive execution."}),(0,t.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,t.jsx)("p",{className:"py-2",children:"Star imports would also silently add names to globals, which would be incompatible with reactive execution."}),(0,t.jsxs)("p",{className:"py-2",children:[(0,t.jsxs)(z,{href:"https://links.marimo.app/errors-import-star",children:["Learn more at our docs"," ",(0,t.jsx)(M,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"import-star")),R.length>0&&N.push((0,t.jsxs)("div",{children:[R.map(dr),s&&(0,t.jsx)(b,{errors:R,cellId:s})]},"interruption")),L.length>0&&N.push((0,t.jsxs)("ul",{children:[L.map((h,_)=>h.exception_type==="NameError"&&h.msg.startsWith("name 'mo'")?(0,t.jsx)("li",{className:"my-2",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground",children:"name 'mo' is not defined."}),(0,t.jsxs)("p",{className:"text-muted-foreground mt-2",children:["The marimo module (imported as"," ",(0,t.jsx)(oe,{className:"inline",children:"mo"}),") is required for Markdown, SQL, and UI elements."]})]})},`exception-${_}`):h.exception_type==="NameError"&&h.msg.startsWith("name '_")?(0,t.jsx)("li",{className:"my-2",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground",children:(0,t.jsx)(be,{segments:ue(h.msg)})}),(0,t.jsxs)("p",{className:"text-muted-foreground mt-2",children:["Variables prefixed with an underscore are local to a cell"," ","(",(0,t.jsxs)(z,{href:"https://links.marimo.app/local-variables",children:["docs"," ",(0,t.jsx)(M,{size:"0.75rem",className:"inline"})]}),")."]}),c&&(0,t.jsx)("div",{className:"text-muted-foreground mt-2",children:"See the console area for a traceback."})]})},`exception-${_}`):(0,t.jsx)("li",{className:"my-2",children:h.raising_cell==null?(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground",children:$(h.msg,`exception-${_}`)}),"traceback"in h&&h.traceback?(0,t.jsx)($e,{traceback:h.traceback}):c&&(0,t.jsx)("div",{className:"text-muted-foreground mt-2",children:"See the console area for a traceback."})]}):(0,t.jsxs)("div",{children:[$(h.msg,`exception-${_}`),(0,t.jsx)(k,{cellId:h.raising_cell}),"traceback"in h&&h.traceback&&(0,t.jsx)($e,{traceback:h.traceback})]})},`exception-${_}`)),L.some(pr)&&(0,t.jsx)(F,{children:"Fix the error in the mentioned cells, or handle the exceptions with try/except blocks."}),s&&(0,t.jsx)(b,{errors:L,cellId:s})]},"exception")),W.length>0&&N.push((0,t.jsxs)("ul",{children:[W.map(ur),s&&(0,t.jsx)(b,{errors:W,cellId:s}),(0,t.jsx)(F,{children:W.some(xr)?"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")),V.length>0&&N.push((0,t.jsxs)("div",{children:[V.map(hr),s&&(0,t.jsx)(b,{errors:V,cellId:s})]},"internal")),H.length>0&&N.push((0,t.jsxs)("div",{children:[H.map(fr),s&&(0,t.jsx)(b,{errors:H,cellId:s})]},"ancestor-prevented")),U.length>0&&N.push((0,t.jsxs)("div",{children:[U.map(jr),s&&(0,t.jsx)(b,{errors:U,cellId:s})]},"ancestor-stopped")),J.length>0&&N.push((0,t.jsxs)("div",{children:[J.map(gr),s&&(0,t.jsx)(b,{errors:J,cellId:s,className:"mt-2.5"})]},"sql-errors")),N},C;e[19]===p?C=e[20]:(C=p&&(0,t.jsxs)("div",{className:"flex items-center gap-1 font-code text-[0.6875rem] uppercase tracking-wider text-muted-foreground/70",children:[p,(0,t.jsx)(B,{content:"marimo didn't run this cell because it detected an error.",delayDuration:200,children:(0,t.jsx)(Le,{className:"size-3 cursor-help"})})]}),e[19]=p,e[20]=C);let T;e[21]!==d||e[22]!==a?(T=a&&(0,t.jsx)(ct,{className:`font-code font-medium ${d}`,children:a}),e[21]=d,e[22]=a,e[23]=T):T=e[23];let O;e[24]!==C||e[25]!==T?(O=(0,t.jsxs)("div",{className:"space-y-0.5",children:[C,T]}),e[24]=C,e[25]=T,e[26]=O):O=e[26];let Te=O;m=ot,j=o,e[27]===i?u=e[28]:(u=ne("border-none font-code text-sm text-[0.84375rem] p-0 text-muted-foreground normal [&:has(svg)]:pl-0 space-y-2",i),e[27]=i,e[28]=u),g=Te,f="flex flex-col gap-4",x=Ce(),e[2]=o,e[3]=s,e[4]=l,e[5]=i,e[6]=n,e[7]=c,e[8]=p,e[9]=d,e[10]=a,e[11]=m,e[12]=f,e[13]=x,e[14]=j,e[15]=u,e[16]=g}else m=e[11],f=e[12],x=e[13],j=e[14],u=e[15],g=e[16];let y;e[29]!==f||e[30]!==x?(y=(0,t.jsx)("div",{className:f,children:x}),e[29]=f,e[30]=x,e[31]=y):y=e[31];let v;return e[32]!==m||e[33]!==j||e[34]!==u||e[35]!==g||e[36]!==y?(v=(0,t.jsxs)(m,{variant:j,className:u,children:[g,y]}),e[32]=m,e[33]=j,e[34]=u,e[35]=g,e[36]=y,e[37]=v):v=e[37],v};function qt(r){return r.type==="interruption"}function Pt(r){return r.type==="internal"}function Lt(r){return r.type==="ancestor-prevented"}function Wt(r){return r.type==="ancestor-stopped"}function Dt(r){return r.type==="sql-error"}function Ot(r){return r.type==="multiple-defs"||r.type==="cycle"||r.type==="setup-refs"||r.type==="import-star"}function Bt(r){return r.type==="exception"}function Qt(r){return r.type==="setup-refs"}function Rt(r){return r.type==="cycle"}function Vt(r){return r.type==="multiple-defs"}function Ht(r){return r.type==="import-star"}function Ut(r){return r.type==="interruption"}function Gt(r){return r.type==="exception"}function Jt(r){return r.type==="strict-exception"}function Kt(r){return r.type==="internal"}function Xt(r){return r.type==="ancestor-prevented"}function Yt(r){return r.type==="ancestor-stopped"}function Zt(r){return r.type==="syntax"}function er(r){return r.type==="unknown"}function tr(r){return r.type==="sql-error"}function rr(r){return r.msg.includes("!pip")}function sr(r){return r.msg.includes("use os.subprocess")}function nr(r,e){return(0,t.jsx)("pre",{children:$(r.msg,`syntax-${e}`)},`syntax-${e}`)}function lr(r,e){return(0,t.jsx)("pre",{children:$(r.msg,`unknown-${e}`)},`unknown-${e}`)}function ir(r,e){return r.edges_with_vars.map((n,s)=>(0,t.jsxs)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:[(0,t.jsx)(k,{cellId:n[0]}),(0,t.jsxs)("span",{className:"text-muted-foreground",children:[": "," ",n[1].length===1?n[1][0]:n[1].join(", ")]})]},`setup-refs-${e}-${s}`))}function ar(r,e){return r.edges_with_vars.map((n,s)=>(0,t.jsxs)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:[(0,t.jsx)(k,{cellId:n[0]}),(0,t.jsxs)("span",{className:"text-muted-foreground",children:[" -> ",n[1].length===1?n[1][0]:n[1].join(", ")," -> "]}),(0,t.jsx)(k,{cellId:n[2]})]},`cycle-${e}-${s}`))}function cr(r,e){return(0,t.jsx)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:(0,t.jsx)(k,{cellId:r})},`cell-${e}`)}function or(r,e){return(0,t.jsxs)(q.Fragment,{children:[(0,t.jsx)("p",{className:"text-muted-foreground mt-2",children:`'${r.name}' was also defined by:`}),(0,t.jsx)("ul",{className:"list-disc",children:r.cells.map(cr)})]},`multiple-defs-${e}`)}function mr(r,e){return(0,t.jsx)("p",{className:"text-muted-foreground",children:r.msg},`import-star-${e}`)}function dr(r,e){return(0,t.jsx)("p",{children:"This cell was interrupted and needs to be re-run."},`interruption-${e}`)}function pr(r){return r.raising_cell!=null}function ur(r,e){return(0,t.jsx)("li",{className:"my-2",children:r.blamed_cell==null?(0,t.jsx)("p",{children:r.msg}):(0,t.jsxs)("div",{children:[r.msg,(0,t.jsx)(k,{cellId:r.blamed_cell})]})},`strict-exception-${e}`)}function xr(r){return r.blamed_cell!=null}function hr(r,e){return(0,t.jsx)("p",{children:r.msg},`internal-${e}`)}function fr(r,e){return(0,t.jsxs)("div",{children:[r.msg,r.blamed_cell==null?(0,t.jsxs)("span",{children:["(",(0,t.jsx)(k,{cellId:r.raising_cell}),")"]}):(0,t.jsxs)("span",{children:["(",(0,t.jsx)(k,{cellId:r.raising_cell}),"\xA0blames\xA0",(0,t.jsx)(k,{cellId:r.blamed_cell}),")"]})]},`ancestor-prevented-${e}`)}function jr(r,e){return(0,t.jsxs)("div",{children:[r.msg,(0,t.jsx)(k,{cellId:r.raising_cell})]},`ancestor-stopped-${e}`)}function gr(r,e){return(0,t.jsx)("div",{className:"space-y-2 mt-2",children:(0,t.jsx)("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.msg})},`sql-error-${e}`)}export{ye as a,me as c,be as i,zt as n,xt as o,ke as r,ue as s,Mt as t};
7
+ Database schema: ${i}`),(c=s.aiFix)==null||c.setAiCompletionCell({cellId:s.cellId,initialPrompt:l,triggerImmediately:s.aiFix.triggerFix})}}]:[]}function gt(r){let e=xe[r];return e===r?`import ${e}`:`import ${e} as ${r}`}var xe={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"},yt=E(),Nt=Pe("marimo:ai-autofix-mode","autofix",qe);function bt(){let r=(0,yt.c)(3),[e,n]=Ee(Nt),s;return r[0]!==e||r[1]!==n?(s={fixMode:e,setFixMode:n},r[0]=e,r[1]=n,r[2]=s):s=r[2],s}var Y=E(),t=te(Ue(),1);const b=r=>{let e=(0,Y.c)(21),{errors:n,cellId:s,className:i}=r,l=Se(),{createNewCell:c}=Me(),a=re(Ve),o;if(e[0]!==a||e[1]!==n){let y;e[3]===a?y=e[4]:(y=v=>jt(v,{aiEnabled:a}),e[3]=a,e[4]=y),o=n.flatMap(y),e[0]=a,e[1]=n,e[2]=o}else o=e[2];let d=o,p=Ae(pt);if(d.length===0)return null;let m=d[0],f;e[5]!==s||e[6]!==c||e[7]!==m||e[8]!==p||e[9]!==l?(f=y=>{var w;let v=(w=l.get(De).cellHandles[s].current)==null?void 0:w.editorView;m.onFix({addCodeBelow:I=>{c({cellId:s,autoFocus:!1,before:!1,code:I})},editor:v,cellId:s,aiFix:{setAiCompletionCell:p,triggerFix:y}}),v==null||v.focus()},e[5]=s,e[6]=c,e[7]=m,e[8]=p,e[9]=l,e[10]=f):f=e[10];let x=f,j;e[11]===i?j=e[12]:(j=ne("my-2",i),e[11]=i,e[12]=j);let u;e[13]!==m.description||e[14]!==m.fixType||e[15]!==m.title||e[16]!==x?(u=m.fixType==="ai"?(0,t.jsx)(ye,{tooltip:m.description,openPrompt:()=>x(!1),applyAutofix:()=>x(!0)}):(0,t.jsx)(B,{content:m.description,align:"start",children:(0,t.jsxs)(A,{size:"xs",variant:"outline",className:"font-normal",onClick:()=>x(!1),children:[(0,t.jsx)(ce,{className:"h-3 w-3 mr-2"}),m.title]})}),e[13]=m.description,e[14]=m.fixType,e[15]=m.title,e[16]=x,e[17]=u):u=e[17];let g;return e[18]!==j||e[19]!==u?(g=(0,t.jsx)("div",{className:j,children:u}),e[18]=j,e[19]=u,e[20]=g):g=e[20],g};var he=nt,fe=ce,je="Suggest a prompt",ge="Fix with AI";const ye=r=>{let e=(0,Y.c)(21),{tooltip:n,openPrompt:s,applyAutofix:i}=r,{fixMode:l,setFixMode:c}=bt(),a=l==="prompt"?s:i,o;e[0]===l?o=e[1]:(o=l==="prompt"?(0,t.jsx)(he,{className:"h-3 w-3 mr-2 mb-0.5"}):(0,t.jsx)(fe,{className:"h-3 w-3 mr-2 mb-0.5"}),e[0]=l,e[1]=o);let d=l==="prompt"?je:ge,p;e[2]!==a||e[3]!==o||e[4]!==d?(p=(0,t.jsxs)(A,{size:"xs",variant:"outline",className:"font-normal rounded-r-none border-r-0",onClick:a,children:[o,d]}),e[2]=a,e[3]=o,e[4]=d,e[5]=p):p=e[5];let m;e[6]!==p||e[7]!==n?(m=(0,t.jsx)(B,{content:n,align:"start",children:p}),e[6]=p,e[7]=n,e[8]=m):m=e[8];let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f=(0,t.jsx)(Ze,{asChild:!0,children:(0,t.jsx)(A,{size:"xs",variant:"outline",className:"rounded-l-none px-2","aria-label":"Fix options",children:(0,t.jsx)(ae,{className:"h-3 w-3"})})}),e[9]=f):f=e[9];let x;e[10]!==l||e[11]!==c?(x=()=>{c(l==="prompt"?"autofix":"prompt")},e[10]=l,e[11]=c,e[12]=x):x=e[12];let j=l==="prompt"?"autofix":"prompt",u;e[13]===j?u=e[14]:(u=(0,t.jsx)(vt,{mode:j}),e[13]=j,e[14]=u);let g;e[15]!==x||e[16]!==u?(g=(0,t.jsxs)(tt,{children:[f,(0,t.jsx)(et,{align:"end",className:"w-56",children:(0,t.jsx)(Ye,{className:"flex items-center gap-2",onClick:x,children:u})})]}),e[15]=x,e[16]=u,e[17]=g):g=e[17];let y;return e[18]!==g||e[19]!==m?(y=(0,t.jsxs)("div",{className:"flex",children:[m,g]}),e[18]=g,e[19]=m,e[20]=y):y=e[20],y};var vt=r=>{let e=(0,Y.c)(12),{mode:n}=r,s;e[0]===n?s=e[1]:(s=n==="prompt"?(0,t.jsx)(he,{className:"h-4 w-4"}):(0,t.jsx)(fe,{className:"h-4 w-4"}),e[0]=n,e[1]=s);let i=s,l=n==="prompt"?je:ge,c=n==="prompt"?"Edit the prompt before applying":"Apply AI fixes automatically",a;e[2]===l?a=e[3]:(a=(0,t.jsx)("span",{className:"font-medium",children:l}),e[2]=l,e[3]=a);let o;e[4]===c?o=e[5]:(o=(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:c}),e[4]=c,e[5]=o);let d;e[6]!==a||e[7]!==o?(d=(0,t.jsxs)("div",{className:"flex flex-col",children:[a,o]}),e[6]=a,e[7]=o,e[8]=d):d=e[8];let p;return e[9]!==i||e[10]!==d?(p=(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[i,d]}),e[9]=i,e[10]=d,e[11]=p):p=e[11],p},Ne=E();const wt=r=>{let e=(0,Ne.c)(12),{local:n}=r,s;e[0]===n.name?s=e[1]:(s=(0,t.jsx)("span",{className:"font-code",children:n.name}),e[0]=n.name,e[1]=s);let i;e[2]===n.cellId?i=e[3]:(i=(0,t.jsx)(k,{cellId:n.cellId}),e[2]=n.cellId,e[3]=i);let l;e[4]!==s||e[5]!==i?(l=(0,t.jsxs)("div",{className:"max-w-xs",children:["Local variable ",s," in cell"," ",i,"."]}),e[4]=s,e[5]=i,e[6]=l):l=e[6];let c=l,a;e[7]===n.name?a=e[8]:(a=(0,t.jsx)("span",{className:"font-code cursor-help",children:n.name}),e[7]=n.name,e[8]=a);let o;return e[9]!==a||e[10]!==c?(o=(0,t.jsx)(B,{content:c,children:a}),e[9]=a,e[10]=c,e[11]=o):o=e[11],o},be=r=>{let e=(0,Ne.c)(4),{segments:n}=r,s;e[0]===n?s=e[1]:(s=n.map(kt),e[0]=n,e[1]=s);let i;return e[2]===s?i=e[3]:(i=(0,t.jsx)(t.Fragment,{children:s}),e[2]=s,e[3]=i),i};function kt(r,e){return typeof r=="string"?(0,t.jsx)("span",{children:r},e):(0,t.jsx)(wt,{local:r},e)}var ve=/(https?:\/\/\S+)/,It=/\.(png|jpe?g|gif|webp|svg|ico)(\?.*)?$/i,we=/^data:image\//i,_t=["avatars.githubusercontent.com"];function ke(r){return we.test(r)?[{type:"image",url:r}]:r.split(ve).filter(e=>e!=="").map(e=>ve.test(e)?It.test(e)||we.test(e)||_t.some(n=>e.includes(n))?{type:"image",url:e}:{type:"url",url:e}:{type:"text",value:e})}var Ie=E(),q=te(ze(),1),$t=new Oe;const Z=r=>{let e=RegExp("\x1B\\[[0-9;]*m","g");return r.replaceAll(e,"")};var _e=/(pip\s+install|uv\s+add|uv\s+pip\s+install)\s+/gi;function Ft(r){_e.lastIndex=0;let e=_e.exec(r);if(!e)return null;let n=e.index+e[0].length,s=r.slice(n).split(/\s+/),i="",l=0;for(let a of s){let o=a.trim();if(!o)continue;if(o.startsWith("-")){l+=o.length+1;continue}let d=o.match(/^[\w,.[\]-]+/);if(d){i=d[0];break}break}if(!i)return null;let c=n+l+i.length;return{package:i,endIndex:c}}function $(r,e=""){if(!r)return null;if(!/https?:\/\//.test(r))return r;let n=ke(r);return n.length===1&&n[0].type==="text"?r:(0,t.jsx)(t.Fragment,{children:n.map((s,i)=>{let l=e?`${e}-${i}`:i;if(s.type==="url"){let c=Z(s.url);return(0,t.jsx)("a",{href:c,target:"_blank",rel:"noopener noreferrer",onClick:le.stopPropagation(),className:"text-link hover:underline",children:c},l)}if(s.type==="image"){let c=Z(s.url);return(0,t.jsx)("a",{href:c,target:"_blank",rel:"noopener noreferrer",onClick:le.stopPropagation(),className:"text-link hover:underline",children:c},l)}return(0,t.jsx)(q.Fragment,{children:s.value},l)})})}var Ct=r=>{let e=(0,Ie.c)(6),{packages:n,children:s}=r,{handleInstallPackages:i}=dt(),l;e[0]!==i||e[1]!==n?(l=a=>{i(n),a.preventDefault()},e[0]=i,e[1]=n,e[2]=l):l=e[2];let c;return e[3]!==s||e[4]!==l?(c=(0,t.jsx)("button",{onClick:l,className:"text-link hover:underline",type:"button",children:s}),e[3]=s,e[4]=l,e[5]=c):c=e[5],c};const Tt=r=>{if(!(r instanceof se.Text))return;let e=Z(r.data);if(!/(pip\s+install|uv\s+add|uv\s+pip\s+install)/i.test(e))return;let n=[],s=/(pip\s+install|uv\s+add|uv\s+pip\s+install)\s+/gi,i;for(;(i=s.exec(e))!==null;){let a=i.index,o=Ft(e.slice(a));o&&n.push({match:i,result:o})}if(n.length===0)return;let l=[],c=0;if(n.forEach((a,o)=>{let{match:d,result:p}=a,m=d.index,f=m+p.endIndex;if(c<m){let j=e.slice(c,m);l.push((0,t.jsx)(q.Fragment,{children:$(j,`before-${o}`)},`before-${o}`))}let x=e.slice(m,f);l.push((0,t.jsx)(Ct,{packages:[p.package],children:x},`install-${o}`)),c=f}),c<e.length){let a=e.slice(c);l.push((0,t.jsx)(q.Fragment,{children:$(a,"after")},"after"))}return(0,t.jsx)(t.Fragment,{children:l})},At=r=>{if(!(r instanceof se.Text))return;let e=r.data;if(!/https?:\/\//.test(e))return;let n=$(e);if(typeof n!="string")return(0,t.jsx)(t.Fragment,{children:n})},St=(...r)=>e=>{for(let n of r){let s=n(e);if(s!==void 0)return s}},Et=(r,e)=>(0,t.jsx)("span",{children:Qe($t.ansi_to_html(r),{replace:n=>e(n)})}),zt=r=>{let e=(0,Ie.c)(4),{text:n}=r,s;e[0]===n?s=e[1]:(s=Et(n,St(Tt,At)),e[0]=n,e[1]=s);let i=s,l;return e[2]===i?l=e[3]:(l=(0,t.jsx)(t.Fragment,{children:i}),e[2]=i,e[3]=l),l};var ee=E(),$e=r=>{let e=(0,ee.c)(16),{traceback:n}=r,[s,i]=(0,q.useState)(!0),l;e[0]===s?l=e[1]:(l=()=>i(!s),e[0]=s,e[1]=l);let c=s?"Collapse traceback":"Expand traceback",a;e[2]===s?a=e[3]:(a=s?(0,t.jsx)(ae,{className:"h-3 w-3"}):(0,t.jsx)(rt,{className:"h-3 w-3"}),e[2]=s,e[3]=a);let o;e[4]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)("span",{className:"text-[0.6875rem] uppercase tracking-wider",children:"Traceback"}),e[4]=o):o=e[4];let d;e[5]!==s||e[6]!==l||e[7]!==c||e[8]!==a?(d=(0,t.jsxs)("button",{type:"button",onClick:l,"aria-expanded":s,"aria-label":c,className:"flex items-center gap-1 text-muted-foreground/70 hover:text-muted-foreground transition-colors",children:[a,o]}),e[5]=s,e[6]=l,e[7]=c,e[8]=a,e[9]=d):d=e[9];let p;e[10]!==s||e[11]!==n?(p=s&&(0,t.jsx)("div",{className:"font-code text-sm mt-1 p-3 bg-muted rounded border overflow-auto max-h-[50vh] cursor-text select-text",children:at({html:n})}),e[10]=s,e[11]=n,e[12]=p):p=e[12];let m;return e[13]!==d||e[14]!==p?(m=(0,t.jsxs)("div",{className:"mt-2",children:[d,p]}),e[13]=d,e[14]=p,e[15]=m):m=e[15],m},F=r=>{let e=(0,ee.c)(10),n=r.title??"Tip",s;e[0]===n?s=e[1]:(s=(0,t.jsx)(Ge,{className:"pt-2 pb-0 font-normal",children:n}),e[0]=n,e[1]=s);let i;e[2]===r.children?i=e[3]:(i=(0,t.jsx)(Xe,{className:"mr-24 text-[0.84375rem]",wrapperClassName:"pt-0 pb-2",children:r.children}),e[2]=r.children,e[3]=i);let l;e[4]!==s||e[5]!==i?(l=(0,t.jsxs)(Je,{value:"item-1",className:"text-muted-foreground",children:[s,i]}),e[4]=s,e[5]=i,e[6]=l):l=e[6];let c;return e[7]!==r.className||e[8]!==l?(c=(0,t.jsx)(Ke,{type:"single",collapsible:!0,className:r.className,children:l}),e[7]=r.className,e[8]=l,e[9]=c):c=e[9],c};const Mt=r=>{let e=(0,ee.c)(38),{errors:n,cellId:s,className:i}=r,l=Le(),c=re(He).display.cell_output==="above",a="This cell wasn't run because it has errors",o="destructive",d="text-error",p=null;if(n.some(qt))a="Interrupted";else if(n.some(Pt))a="An internal error occurred";else if(n.some(Lt))a="Ancestor prevented from running",o="default",d="text-secondary-foreground";else if(n.some(Wt))a="Ancestor stopped",o="default",d="text-secondary-foreground";else if(n.some(Dt))a="SQL error";else if(n.some(Ot))a=null,p="Cell not run";else{let w;e[0]===n?w=e[1]:(w=n.find(Bt),e[0]=n,e[1]=w);let I=w;I&&"exception_type"in I&&(a=I.exception_type)}let m,f,x,j,u,g;if(e[2]!==o||e[3]!==s||e[4]!==l||e[5]!==i||e[6]!==n||e[7]!==c||e[8]!==p||e[9]!==d||e[10]!==a){let w=n.filter(Qt),I=n.filter(Rt),P=n.filter(Vt),Q=n.filter(Ht),R=n.filter(Ut),L=n.filter(Gt),W=n.filter(Jt),V=n.filter(Kt),H=n.filter(Xt),U=n.filter(Yt),S=n.filter(Zt),G=n.filter(er),J=n.filter(tr),D;e[17]===l?D=e[18]:(D=()=>{l.openApplication("scratchpad")},e[17]=l,e[18]=D);let Fe=D,Ce=()=>{let N=[];if(S.length>0||G.length>0){let h=S.some(rr),_=!h&&S.some(sr);N.push((0,t.jsxs)("div",{children:[S.map(nr),G.map(lr),h&&(0,t.jsxs)(A,{size:"xs",variant:"outline",className:"mt-2 font-normal",onClick:()=>mt(l),children:[(0,t.jsx)(st,{className:"h-3.5 w-3.5 mr-1.5 mb-0.5"}),(0,t.jsx)("span",{children:"Open package manager"})]}),_&&(0,t.jsxs)(A,{size:"xs",variant:"outline",className:"mt-2 font-normal",onClick:()=>l.openApplication("terminal"),children:[(0,t.jsx)(me,{className:"h-3.5 w-3.5 mr-1.5"}),(0,t.jsx)("span",{children:"Open terminal"})]}),s&&(0,t.jsx)(b,{errors:[...S,...G],cellId:s})]},"syntax-unknown"))}if(w.length>0&&N.push((0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground font-medium",children:"The setup cell cannot be run because it has references."}),(0,t.jsx)("ul",{className:"list-disc",children:w.flatMap(ir)}),s&&(0,t.jsx)(b,{errors:w,cellId:s}),(0,t.jsxs)(F,{title:"Why can't the setup cell have references?",className:"mb-2",children:[(0,t.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,t.jsx)("p",{className:"py-2",children:"Try simplifying the setup cell to only contain only necessary variables."}),(0,t.jsxs)("p",{className:"py-2",children:[(0,t.jsxs)(z,{href:"https://links.marimo.app/errors-setup",children:["Learn more at our docs"," ",(0,t.jsx)(M,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"setup-refs")),I.length>0&&N.push((0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground font-medium",children:"This cell is in a cycle."}),(0,t.jsx)("ul",{className:"list-disc",children:I.flatMap(ar)}),s&&(0,t.jsx)(b,{errors:I,cellId:s}),(0,t.jsxs)(F,{title:"What are cycles and how do I resolve them?",className:"mb-2",children:[(0,t.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,t.jsx)("p",{className:"py-2",children:"Try merging these cells into a single cell to eliminate the cycle."}),(0,t.jsxs)("p",{className:"py-2",children:[(0,t.jsxs)(z,{href:"https://links.marimo.app/errors-cycles",children:["Learn more at our docs"," ",(0,t.jsx)(M,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"cycle")),P.length>0){let h=P[0].name;N.push((0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground font-medium",children:"This cell redefines variables from other cells."}),P.map(or),s&&(0,t.jsx)(b,{errors:P,cellId:s}),(0,t.jsxs)(F,{title:"Why can't I redefine variables?",children:[(0,t.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,t.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,t.jsxs)(oe,{className:"inline",children:["_",h]}),"). to make them private to this cell."]}),(0,t.jsxs)("p",{className:"py-2",children:[(0,t.jsxs)(z,{href:"https://links.marimo.app/errors-multiple-definitions",children:["Learn more at our docs"," ",(0,t.jsx)(M,{size:"0.75rem",className:"inline"})]}),"."]})]}),(0,t.jsx)(F,{title:"Need a scratchpad?",children:(0,t.jsxs)("div",{className:"flex flex-row gap-2 items-center",children:[(0,t.jsxs)(A,{size:"xs",variant:"link",className:"my-2 font-normal mx-0 px-0",onClick:Fe,children:[(0,t.jsx)(Be,{className:"h-3"}),(0,t.jsx)("span",{children:"Try the scratchpad"})]}),(0,t.jsx)("span",{children:"to experiment without restrictions on variable names."})]})})]},"multiple-defs"))}return Q.length>0&&N.push((0,t.jsxs)("div",{children:[Q.map(mr),s&&(0,t.jsx)(b,{errors:Q,cellId:s}),(0,t.jsxs)(F,{title:"Why can't I use `import *`?",children:[(0,t.jsx)("p",{className:"pb-2",children:"Star imports are incompatible with marimo's git-friendly file format and reproducible reactive execution."}),(0,t.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,t.jsx)("p",{className:"py-2",children:"Star imports would also silently add names to globals, which would be incompatible with reactive execution."}),(0,t.jsxs)("p",{className:"py-2",children:[(0,t.jsxs)(z,{href:"https://links.marimo.app/errors-import-star",children:["Learn more at our docs"," ",(0,t.jsx)(M,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"import-star")),R.length>0&&N.push((0,t.jsxs)("div",{children:[R.map(dr),s&&(0,t.jsx)(b,{errors:R,cellId:s})]},"interruption")),L.length>0&&N.push((0,t.jsxs)("ul",{children:[L.map((h,_)=>h.exception_type==="NameError"&&h.msg.startsWith("name 'mo'")?(0,t.jsx)("li",{className:"my-2",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground",children:"name 'mo' is not defined."}),(0,t.jsxs)("p",{className:"text-muted-foreground mt-2",children:["The marimo module (imported as"," ",(0,t.jsx)(oe,{className:"inline",children:"mo"}),") is required for Markdown, SQL, and UI elements."]})]})},`exception-${_}`):h.exception_type==="NameError"&&h.msg.startsWith("name '_")?(0,t.jsx)("li",{className:"my-2",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground",children:(0,t.jsx)(be,{segments:ue(h.msg)})}),(0,t.jsxs)("p",{className:"text-muted-foreground mt-2",children:["Variables prefixed with an underscore are local to a cell"," ","(",(0,t.jsxs)(z,{href:"https://links.marimo.app/local-variables",children:["docs"," ",(0,t.jsx)(M,{size:"0.75rem",className:"inline"})]}),")."]}),c&&(0,t.jsx)("div",{className:"text-muted-foreground mt-2",children:"See the console area for a traceback."})]})},`exception-${_}`):(0,t.jsx)("li",{className:"my-2",children:h.raising_cell==null?(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground",children:$(h.msg,`exception-${_}`)}),"traceback"in h&&h.traceback?(0,t.jsx)($e,{traceback:h.traceback}):c&&(0,t.jsx)("div",{className:"text-muted-foreground mt-2",children:"See the console area for a traceback."})]}):(0,t.jsxs)("div",{children:[$(h.msg,`exception-${_}`),(0,t.jsx)(k,{cellId:h.raising_cell}),"traceback"in h&&h.traceback&&(0,t.jsx)($e,{traceback:h.traceback})]})},`exception-${_}`)),L.some(pr)&&(0,t.jsx)(F,{children:"Fix the error in the mentioned cells, or handle the exceptions with try/except blocks."}),s&&(0,t.jsx)(b,{errors:L,cellId:s})]},"exception")),W.length>0&&N.push((0,t.jsxs)("ul",{children:[W.map(ur),s&&(0,t.jsx)(b,{errors:W,cellId:s}),(0,t.jsx)(F,{children:W.some(xr)?"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")),V.length>0&&N.push((0,t.jsxs)("div",{children:[V.map(hr),s&&(0,t.jsx)(b,{errors:V,cellId:s})]},"internal")),H.length>0&&N.push((0,t.jsxs)("div",{children:[H.map(fr),s&&(0,t.jsx)(b,{errors:H,cellId:s})]},"ancestor-prevented")),U.length>0&&N.push((0,t.jsxs)("div",{children:[U.map(jr),s&&(0,t.jsx)(b,{errors:U,cellId:s})]},"ancestor-stopped")),J.length>0&&N.push((0,t.jsxs)("div",{children:[J.map(gr),s&&(0,t.jsx)(b,{errors:J,cellId:s,className:"mt-2.5"})]},"sql-errors")),N},C;e[19]===p?C=e[20]:(C=p&&(0,t.jsxs)("div",{className:"flex items-center gap-1 font-code text-[0.6875rem] uppercase tracking-wider text-muted-foreground/70",children:[p,(0,t.jsx)(B,{content:"marimo didn't run this cell because it detected an error.",delayDuration:200,children:(0,t.jsx)(We,{className:"size-3 cursor-help"})})]}),e[19]=p,e[20]=C);let T;e[21]!==d||e[22]!==a?(T=a&&(0,t.jsx)(ct,{className:`font-code font-medium ${d}`,children:a}),e[21]=d,e[22]=a,e[23]=T):T=e[23];let O;e[24]!==C||e[25]!==T?(O=(0,t.jsxs)("div",{className:"space-y-0.5",children:[C,T]}),e[24]=C,e[25]=T,e[26]=O):O=e[26];let Te=O;m=ot,j=o,e[27]===i?u=e[28]:(u=ne("border-none font-code text-sm text-[0.84375rem] p-0 text-muted-foreground normal [&:has(svg)]:pl-0 space-y-2",i),e[27]=i,e[28]=u),g=Te,f="flex flex-col gap-4",x=Ce(),e[2]=o,e[3]=s,e[4]=l,e[5]=i,e[6]=n,e[7]=c,e[8]=p,e[9]=d,e[10]=a,e[11]=m,e[12]=f,e[13]=x,e[14]=j,e[15]=u,e[16]=g}else m=e[11],f=e[12],x=e[13],j=e[14],u=e[15],g=e[16];let y;e[29]!==f||e[30]!==x?(y=(0,t.jsx)("div",{className:f,children:x}),e[29]=f,e[30]=x,e[31]=y):y=e[31];let v;return e[32]!==m||e[33]!==j||e[34]!==u||e[35]!==g||e[36]!==y?(v=(0,t.jsxs)(m,{variant:j,className:u,children:[g,y]}),e[32]=m,e[33]=j,e[34]=u,e[35]=g,e[36]=y,e[37]=v):v=e[37],v};function qt(r){return r.type==="interruption"}function Pt(r){return r.type==="internal"}function Lt(r){return r.type==="ancestor-prevented"}function Wt(r){return r.type==="ancestor-stopped"}function Dt(r){return r.type==="sql-error"}function Ot(r){return r.type==="multiple-defs"||r.type==="cycle"||r.type==="setup-refs"||r.type==="import-star"}function Bt(r){return r.type==="exception"}function Qt(r){return r.type==="setup-refs"}function Rt(r){return r.type==="cycle"}function Vt(r){return r.type==="multiple-defs"}function Ht(r){return r.type==="import-star"}function Ut(r){return r.type==="interruption"}function Gt(r){return r.type==="exception"}function Jt(r){return r.type==="strict-exception"}function Kt(r){return r.type==="internal"}function Xt(r){return r.type==="ancestor-prevented"}function Yt(r){return r.type==="ancestor-stopped"}function Zt(r){return r.type==="syntax"}function er(r){return r.type==="unknown"}function tr(r){return r.type==="sql-error"}function rr(r){return r.msg.includes("!pip")}function sr(r){return r.msg.includes("use os.subprocess")}function nr(r,e){return(0,t.jsx)("pre",{children:$(r.msg,`syntax-${e}`)},`syntax-${e}`)}function lr(r,e){return(0,t.jsx)("pre",{children:$(r.msg,`unknown-${e}`)},`unknown-${e}`)}function ir(r,e){return r.edges_with_vars.map((n,s)=>(0,t.jsxs)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:[(0,t.jsx)(k,{cellId:n[0]}),(0,t.jsxs)("span",{className:"text-muted-foreground",children:[": "," ",n[1].length===1?n[1][0]:n[1].join(", ")]})]},`setup-refs-${e}-${s}`))}function ar(r,e){return r.edges_with_vars.map((n,s)=>(0,t.jsxs)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:[(0,t.jsx)(k,{cellId:n[0]}),(0,t.jsxs)("span",{className:"text-muted-foreground",children:[" -> ",n[1].length===1?n[1][0]:n[1].join(", ")," -> "]}),(0,t.jsx)(k,{cellId:n[2]})]},`cycle-${e}-${s}`))}function cr(r,e){return(0,t.jsx)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:(0,t.jsx)(k,{cellId:r})},`cell-${e}`)}function or(r,e){return(0,t.jsxs)(q.Fragment,{children:[(0,t.jsx)("p",{className:"text-muted-foreground mt-2",children:`'${r.name}' was also defined by:`}),(0,t.jsx)("ul",{className:"list-disc",children:r.cells.map(cr)})]},`multiple-defs-${e}`)}function mr(r,e){return(0,t.jsx)("p",{className:"text-muted-foreground",children:r.msg},`import-star-${e}`)}function dr(r,e){return(0,t.jsx)("p",{children:"This cell was interrupted and needs to be re-run."},`interruption-${e}`)}function pr(r){return r.raising_cell!=null}function ur(r,e){return(0,t.jsx)("li",{className:"my-2",children:r.blamed_cell==null?(0,t.jsx)("p",{children:r.msg}):(0,t.jsxs)("div",{children:[r.msg,(0,t.jsx)(k,{cellId:r.blamed_cell})]})},`strict-exception-${e}`)}function xr(r){return r.blamed_cell!=null}function hr(r,e){return(0,t.jsx)("p",{children:r.msg},`internal-${e}`)}function fr(r,e){return(0,t.jsxs)("div",{children:[r.msg,r.blamed_cell==null?(0,t.jsxs)("span",{children:["(",(0,t.jsx)(k,{cellId:r.raising_cell}),")"]}):(0,t.jsxs)("span",{children:["(",(0,t.jsx)(k,{cellId:r.raising_cell}),"\xA0blames\xA0",(0,t.jsx)(k,{cellId:r.blamed_cell}),")"]})]},`ancestor-prevented-${e}`)}function jr(r,e){return(0,t.jsxs)("div",{children:[r.msg,(0,t.jsx)(k,{cellId:r.raising_cell})]},`ancestor-stopped-${e}`)}function gr(r,e){return(0,t.jsx)("div",{className:"space-y-2 mt-2",children:(0,t.jsx)("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.msg})},`sql-error-${e}`)}export{ye as a,me as c,be as i,zt as n,xt as o,ke as r,ue as s,Mt 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{bn as k,gi as f,hi as H,m as I,ot as j,wn as L,xt as N}from"./cells-DOA0Gew8.js";import{t as E}from"./compiler-runtime-B3qBwwSJ.js";import{_ as w}from"./useEventListener-DvoEXWke.js";import{c as _}from"./utils-CvI-39U6.js";import{t as A}from"./jsx-runtime-BqBOg78p.js";import{t as F}from"./tooltip-B_PkSKN3.js";import{t as O}from"./copy-icon-BuRdHNPA.js";import{t as V}from"./usePress-DQ_tAz5W.js";import{n as W}from"./useDebounce-7xZwVnnu.js";import{t as R}from"./useRunCells-cSZpNqnR.js";var q=E(),u=y(S(),1),l=y(A(),1);const z=e=>{let t=(0,q.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,u.useRef)(null),o;t[4]===n?o=t[5]:(o=()=>{let h=new URL(globalThis.location.href);h.hash=n,globalThis.history.pushState({},"",h.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,c;t[6]===s?c=t[7]:(c={onPress:()=>{s()}},t[6]=s,t[7]=c);let{pressProps:d}=V(c),m;t[8]===s?m=t[9]:(m=h=>{h.preventDefault(),s()},t[8]=s,t[9]=m);let b=m,p;return t[10]!==r||t[11]!==b||t[12]!==n||t[13]!==d||t[14]!==i?(p=(0,l.jsx)("a",{ref:a,href:n,...d,onClick:b,...i,children:r}),t[10]=r,t[11]=b,t[12]=n,t[13]=d,t[14]=i,t[15]=p):p=t[15],p};async function $(e){let t=I().inOrderIds.at(0);if(t)try{let r=await k.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(L,{documentation:a.completion_info})}catch(r){w.debug(`Doc lookup failed for "${e}"`,r)}}var P=E();const D=e=>{let t=(0,P.c)(8),{qualifiedName:r,children:n}=e,i;t[0]===r?i=t[1]:(i=()=>{$(r)},t[0]=r,t[1]=i);let a=W(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(_))return!0;try{if(j()==="read")return!0}catch{}return!1}var G=C(e=>{let t=e(R),r=e(_);if(t||r||v())return!1;let n=!0;try{n=j()==="read"}catch{return!0}return!n});function J(){return M(G)}var K=E(),Z=e=>{if(e instanceof f.Element&&!/^[A-Za-z][\w-]*$/.test(e.name))return u.createElement(u.Fragment)},Q=(e,t)=>{if(t instanceof f.Element&&t.name==="body"){if((0,u.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 f.Element&&t.name==="html"){if((0,u.isValidElement)(e)&&"props"in e){let r=e.props.children;return(0,l.jsx)(l.Fragment,{children:r})}return}},tt=e=>{if(e instanceof f.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 f.Element&&e.name==="script"){let t=e.attribs.src;if(!t)return;if(!X())return w.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 f.Element&&t.name==="a"){let r=t.attribs.href;if(r!=null&&r.startsWith("#")&&!r.startsWith("#code/")){let n=null;return(0,u.isValidElement)(e)&&"props"in e&&(n=e.props.children),(0,l.jsx)(z,{href:r,...t.attribs,children:n})}}},nt=(e,t,r)=>{var n,i;if(t instanceof f.Element&&t.name==="div"&&((i=(n=t.attribs)==null?void 0:n.class)!=null&&i.includes("codehilite")))return(0,l.jsx)(st,{children:e},r)},it=(e,t,r)=>{var i;if(!(t instanceof f.Element)||t.name!=="img")return;let n=(i=t.attribs)==null?void 0:i.src;if(!(!n||!(0,u.isValidElement)(e))&&!/^data:/i.test(n))return(0,u.cloneElement)(e,{key:`${n}-${r}`})},at=(e,t)=>{var r;if(t instanceof f.Element&&((r=t.attribs)!=null&&r["data-marimo-doc"])){let n=t.attribs["data-marimo-doc"];return(0,l.jsx)(D,{qualifiedName:n,children:e})}},ot=(e,t)=>{var r,n;if(t instanceof f.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})}},st=e=>{let t=(0,K.c)(3),{children:r}=e,n=(0,u.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 lt=({html:e,additionalReplacements:t=[],alwaysSanitizeHtml:r=!0})=>(0,l.jsx)(ct,{html:e,alwaysSanitizeHtml:r,additionalReplacements:t});var ct=({html:e,additionalReplacements:t=[],alwaysSanitizeHtml:r})=>{let n=J();return mt({html:(0,u.useMemo)(()=>r||n?N(e):e,[e,r,n]),additionalReplacements:t})};function mt({html:e,additionalReplacements:t=[]}){let r=[Z,tt,et,...t],n=[nt,rt,at,ot,Q,Y],i=[it];return H(e,{replace:(a,o)=>{for(let s of r){let c=s(a,o);if(c)return c}return a},transform:(a,o,s)=>{let c=a;for(let d of n){let m=d(c,o,s);if(m){c=m;break}}for(let d of i){let m=d(c,o,s);m&&(c=m)}return c}})}export{v as n,lt as t};
1
+ import{s as x}from"./chunk-LvLJmgfZ.js";import{i as E,p as C,u as M}from"./useEvent-D91BmmQi.js";import{t as S}from"./react-Bj1aDYRI.js";import{bi as f,bn as k,m as H,ot as j,wn as I,xt as L,yi as N}from"./cells-D-v2lBet.js";import{t as g}from"./compiler-runtime-B3qBwwSJ.js";import{_ as w}from"./useEventListener-DvoEXWke.js";import{c as _}from"./utils-CvI-39U6.js";import{t as A}from"./jsx-runtime-BqBOg78p.js";import{t as F}from"./tooltip-B_PkSKN3.js";import{t as O}from"./copy-icon-BuRdHNPA.js";import{t as V}from"./usePress-DQ_tAz5W.js";import{n as W}from"./useDebounce-7xZwVnnu.js";import{t as R}from"./useRunCells-BClkx9Pq.js";var q=g(),u=x(S(),1),l=x(A(),1);const z=e=>{let t=(0,q.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,u.useRef)(null),o;t[4]===n?o=t[5]:(o=()=>{let h=new URL(globalThis.location.href);h.hash=n,globalThis.history.pushState({},"",h.toString()),globalThis.dispatchEvent(new HashChangeEvent("hashchange"));let T=n.slice(1),v=document.getElementById(T);v&&v.scrollIntoView({behavior:"smooth",block:"start"})},t[4]=n,t[5]=o);let s=o,c;t[6]===s?c=t[7]:(c={onPress:()=>{s()}},t[6]=s,t[7]=c);let{pressProps:d}=V(c),m;t[8]===s?m=t[9]:(m=h=>{h.preventDefault(),s()},t[8]=s,t[9]=m);let b=m,p;return t[10]!==r||t[11]!==b||t[12]!==n||t[13]!==d||t[14]!==i?(p=(0,l.jsx)("a",{ref:a,href:n,...d,onClick:b,...i,children:r}),t[10]=r,t[11]=b,t[12]=n,t[13]=d,t[14]=i,t[15]=p):p=t[15],p};async function $(e){let t=H().inOrderIds.at(0);if(t)try{let r=await k.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&&E.set(I,{documentation:a.completion_info})}catch(r){w.debug(`Doc lookup failed for "${e}"`,r)}}var P=g();const D=e=>{let t=(0,P.c)(8),{qualifiedName:r,children:n}=e,i;t[0]===r?i=t[1]:(i=()=>{$(r)},t[0]=r,t[1]=i);let a=W(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 y(){var e;return((e=U())==null?void 0:e.trusted)===!0}function X(){if(E.get(R)||y()||E.get(_))return!0;try{if(j()==="read")return!0}catch{}return!1}var G=C(e=>{let t=e(R),r=e(_);if(t||r||y())return!1;let n=!0;try{n=j()==="read"}catch{return!0}return!n});function J(){return M(G)}var K=g(),Z=e=>{if(e instanceof f.Element&&!/^[A-Za-z][\w-]*$/.test(e.name))return u.createElement(u.Fragment)},Q=(e,t)=>{if(t instanceof f.Element&&t.name==="body"){if((0,u.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 f.Element&&t.name==="html"){if((0,u.isValidElement)(e)&&"props"in e){let r=e.props.children;return(0,l.jsx)(l.Fragment,{children:r})}return}},tt=e=>{if(e instanceof f.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 f.Element&&e.name==="script"){let t=e.attribs.src;if(!t)return;if(!X())return w.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 f.Element&&t.name==="a"){let r=t.attribs.href;if(r!=null&&r.startsWith("#")&&!r.startsWith("#code/")){let n=null;return(0,u.isValidElement)(e)&&"props"in e&&(n=e.props.children),(0,l.jsx)(z,{href:r,...t.attribs,children:n})}}},nt=(e,t,r)=>{var n,i;if(t instanceof f.Element&&t.name==="div"&&((i=(n=t.attribs)==null?void 0:n.class)!=null&&i.includes("codehilite")))return(0,l.jsx)(st,{children:e},r)},it=(e,t,r)=>{var i;if(!(t instanceof f.Element)||t.name!=="img")return;let n=(i=t.attribs)==null?void 0:i.src;if(!(!n||!(0,u.isValidElement)(e))&&!/^data:/i.test(n))return(0,u.cloneElement)(e,{key:`${n}-${r}`})},at=(e,t)=>{var r;if(t instanceof f.Element&&((r=t.attribs)!=null&&r["data-marimo-doc"])){let n=t.attribs["data-marimo-doc"];return(0,l.jsx)(D,{qualifiedName:n,children:e})}},ot=(e,t)=>{var r,n;if(t instanceof f.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})}},st=e=>{let t=(0,K.c)(3),{children:r}=e,n=(0,u.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 lt=({html:e,additionalReplacements:t=[],alwaysSanitizeHtml:r=!0})=>(0,l.jsx)(ct,{html:e,alwaysSanitizeHtml:r,additionalReplacements:t});var ct=({html:e,additionalReplacements:t=[],alwaysSanitizeHtml:r})=>{let n=J();return mt({html:(0,u.useMemo)(()=>r||n?L(e):e,[e,r,n]),additionalReplacements:t})};function mt({html:e,additionalReplacements:t=[]}){let r=[Z,tt,et,...t],n=[nt,rt,at,ot,Q,Y],i=[it];return N(e,{replace:(a,o)=>{for(let s of r){let c=s(a,o);if(c)return c}return a},transform:(a,o,s)=>{let c=a;for(let d of n){let m=d(c,o,s);if(m){c=m;break}}for(let d of i){let m=d(c,o,s);m&&(c=m)}return c}})}export{y as n,lt as t};
@@ -1 +1 @@
1
- import{s as S}from"./chunk-LvLJmgfZ.js";import{t as D}from"./react-Bj1aDYRI.js";import{t as x}from"./compiler-runtime-B3qBwwSJ.js";import{v as M}from"./useEventListener-DvoEXWke.js";import{h as w,u as q}from"./config-ClMcu_sV.js";import{n as E,t as T}from"./cn-DCUzRj2J.js";import{t as F}from"./jsx-runtime-BqBOg78p.js";import{t as O}from"./tooltip-B_PkSKN3.js";import{r as W}from"./button-BbCh-29a.js";import{r as L}from"./requests-DIwGYs0l.js";import{t as V}from"./createLucideIcon-D5guW7EU.js";import{i as N}from"./useDeleteCell-BvnurAZ9.js";import{C as B,O as I,ut as P,w as K}from"./input-DA8xlX70.js";import{t as U}from"./square-B5xWCt0a.js";import{N as H,P as _,V as G,j as C,k as J}from"./usePress-DQ_tAz5W.js";import{l as Q}from"./RSPContexts-C3vBe8nL.js";import{t as X}from"./context-QkTujrKn.js";import{a as z}from"./renderShortcut--ku7VECI.js";var Y=V("hard-drive-download",[["path",{d:"M12 2v8",key:"1q4o3n"}],["path",{d:"m16 6-4 4-4-4",key:"6wukr"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 18h.01",key:"h775k"}]]),y=S(D(),1);function Z(n,e){let{"aria-label":t,"aria-labelledby":a,orientation:r="horizontal"}=n,[o,c]=(0,y.useState)(!1);G(()=>{var i;c(!!(e.current&&((i=e.current.parentElement)!=null&&i.closest('[role="toolbar"]'))))});let{direction:u}=X(),m=u==="rtl"&&r==="horizontal",f=Q(e),l=i=>{if(C(i.currentTarget,_(i))){if(r==="horizontal"&&i.key==="ArrowRight"||r==="vertical"&&i.key==="ArrowDown")m?f.focusPrevious():f.focusNext();else if(r==="horizontal"&&i.key==="ArrowLeft"||r==="vertical"&&i.key==="ArrowUp")m?f.focusNext():f.focusPrevious();else if(i.key==="Tab"){i.stopPropagation(),s.current=H(),i.shiftKey?f.focusFirst():f.focusLast();return}else return;i.stopPropagation(),i.preventDefault()}},s=(0,y.useRef)(null),b=i=>{!C(i.currentTarget,i.relatedTarget)&&!s.current&&(s.current=_(i))},p=i=>{if(s.current&&!C(i.currentTarget,i.relatedTarget)&&C(e.current,_(i))){var h;(h=s.current)==null||h.focus(),s.current=null}};return{toolbarProps:{...P(n,{labelable:!0}),role:o?"group":"toolbar","aria-orientation":r,"aria-label":t,"aria-labelledby":t==null?a:void 0,onKeyDownCapture:o?void 0:l,onFocusCapture:o?void 0:p,onBlurCapture:o?void 0:b}}}var $=(0,y.createContext)({}),ee=(0,y.forwardRef)(function(n,e){[n,e]=B(n,e,$);let{toolbarProps:t}=Z(n,e),a=K({...n,values:{orientation:n.orientation||"horizontal"},defaultClassName:"react-aria-Toolbar"}),r=P(n,{global:!0});return delete r.id,y.createElement(I.div,{...J(r,a,t),ref:e,slot:n.slot||void 0,"data-orientation":n.orientation||"horizontal"},a.children)}),te=x(),re=200;function R(n){let e=(0,te.c)(3),[t,a]=(0,y.useState)(!1),r,o;return e[0]===n?(r=e[1],o=e[2]):(r=()=>{if(!n)return;a(!1);let c=setTimeout(()=>{a(!0)},re);return()=>clearTimeout(c)},o=[n],e[0]=n,e[1]=r,e[2]=o),(0,y.useEffect)(r,o),n&&t}var A=x(),g=S(F(),1),oe=E("rounded-full shadow-xs-solid border p-[5px] transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 [&>svg]:size-3 active:shadow-none bg-background",{variants:{variant:{default:"hover:bg-accent hover:text-accent-foreground",stale:"bg-(--yellow-3) hover:bg-(--yellow-4) text-(--yellow-11)",green:"hover:bg-(--grass-2) hover:text-(--grass-11) hover:border-[var(--grass-7)],",disabled:"opacity-50 cursor-not-allowed",danger:"hover:bg-(--red-3) hover:text-(--red-11)"}},defaultVariants:{variant:"default"}});const k=n=>{let e=(0,A.c)(18),t,a,r,o,c,u,m;if(e[0]!==n){let{children:s,tooltip:b,disabled:p,variant:i,...h}=n;t=s,m=b;let d=p===void 0?!1:p;a=d,r=h,o=v=>{var j;d||((j=h.onClick)==null||j.call(h,v))},c=W.preventFocus,u=T(oe({variant:i}),h.className),e[0]=n,e[1]=t,e[2]=a,e[3]=r,e[4]=o,e[5]=c,e[6]=u,e[7]=m}else t=e[1],a=e[2],r=e[3],o=e[4],c=e[5],u=e[6],m=e[7];let f;e[8]!==t||e[9]!==a||e[10]!==r||e[11]!==o||e[12]!==c||e[13]!==u?(f=(0,g.jsx)("button",{disabled:a,...r,onClick:o,onMouseDown:c,className:u,children:t}),e[8]=t,e[9]=a,e[10]=r,e[11]=o,e[12]=c,e[13]=u,e[14]=f):f=e[14];let l=f;if(m){let s;return e[15]!==l||e[16]!==m?(s=(0,g.jsx)(O,{content:m,side:"top",delayDuration:200,usePortal:!1,children:l}),e[15]=l,e[16]=m,e[17]=s):s=e[17],s}return l},ae=n=>{let e=(0,A.c)(5),{children:t,className:a}=n,r;e[0]===a?r=e[1]:(r=T("flex items-center gap-1 bg-background m-[2px] rounded-full",a),e[0]=a,e[1]=r);let o;return e[2]!==t||e[3]!==r?(o=(0,g.jsx)(ee,{className:r,children:t}),e[2]=t,e[3]=r,e[4]=o):o=e[4],o};var ne=x();const ie=n=>{let e=(0,ne.c)(9),{connectionState:t,status:a}=n,{sendInterrupt:r}=L(),o=R(a==="running"),c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=z("global.interrupt"),e[0]=c):c=e[0];let u;e[1]!==t||e[2]!==o?(u=w(t)||!o,e[1]=t,e[2]=o,e[3]=u):u=e[3];let m=o?r:M.NOOP,f=o?"stale":"disabled",l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=(0,g.jsx)(U,{strokeWidth:1.5}),e[4]=l):l=e[4];let s;return e[5]!==u||e[6]!==m||e[7]!==f?(s=(0,g.jsx)(k,{tooltip:c,disabled:u,onClick:m,variant:f,"data-testid":"run-button",children:l}),e[5]=u,e[6]=m,e[7]=f,e[8]=s):s=e[8],s};var le=x();function se({connectionState:n,needsRun:e,loading:t,inactive:a}){return w(n)?"disabled":e&&!t?"stale":t||a?"disabled":"green"}const de=n=>{let e=(0,le.c)(27),{onClick:t,connectionState:a,needsRun:r,status:o,config:c,edited:u}=n,m=o==="disabled-transitively",f=o==="running"||o==="queued",l,s;e[0]!==m||e[1]!==c.disabled||e[2]!==a||e[3]!==u||e[4]!==f||e[5]!==r?(l=w(a)||f||!c.disabled&&m&&!u,s=se({connectionState:a,needsRun:r,loading:f,inactive:l}),e[0]=m,e[1]=c.disabled,e[2]=a,e[3]=u,e[4]=f,e[5]=r,e[6]=l,e[7]=s):(l=e[6],s=e[7]);let b=s;if(c.disabled){let d;e[8]===Symbol.for("react.memo_cache_sentinel")?(d=(0,g.jsx)(Y,{}),e[8]=d):d=e[8];let v;return e[9]!==l||e[10]!==t||e[11]!==b?(v=(0,g.jsx)(k,{tooltip:"Add code to notebook",disabled:l,onClick:t,variant:b,"data-testid":"run-button",children:d}),e[9]=l,e[10]=t,e[11]=b,e[12]=v):v=e[12],v}if(!c.disabled&&m&&!u){let d;e[13]===Symbol.for("react.memo_cache_sentinel")?(d=(0,g.jsx)(N,{strokeWidth:1.2}),e[13]=d):d=e[13];let v;return e[14]!==l||e[15]!==t||e[16]!==b?(v=(0,g.jsx)(k,{disabled:l,tooltip:"This cell can't be run because it has a disabled ancestor",onClick:t,variant:b,"data-testid":"run-button",children:d}),e[14]=l,e[15]=t,e[16]=b,e[17]=v):v=e[17],v}let p;if(w(a)){let d;e[18]===a?d=e[19]:(d=q(a),e[18]=a,e[19]=d),p=d}else if(o==="queued")p="This cell is already queued to run";else if(o==="running")p="This cell is already running.";else{let d;e[20]===Symbol.for("react.memo_cache_sentinel")?(d=z("cell.run"),e[20]=d):d=e[20],p=d}let i;e[21]===Symbol.for("react.memo_cache_sentinel")?(i=(0,g.jsx)(N,{strokeWidth:1.2}),e[21]=i):i=e[21];let h;return e[22]!==l||e[23]!==t||e[24]!==p||e[25]!==b?(h=(0,g.jsx)(k,{tooltip:p,disabled:l,onClick:t,variant:b,"data-testid":"run-button",children:i}),e[22]=l,e[23]=t,e[24]=p,e[25]=b,e[26]=h):h=e[26],h};export{R as a,k as i,ie as n,ae as r,de as t};
1
+ import{s as S}from"./chunk-LvLJmgfZ.js";import{t as D}from"./react-Bj1aDYRI.js";import{t as x}from"./compiler-runtime-B3qBwwSJ.js";import{v as M}from"./useEventListener-DvoEXWke.js";import{h as w,u as q}from"./config-ClMcu_sV.js";import{n as E,t as T}from"./cn-DCUzRj2J.js";import{t as F}from"./jsx-runtime-BqBOg78p.js";import{t as O}from"./tooltip-B_PkSKN3.js";import{r as W}from"./button-BbCh-29a.js";import{r as L}from"./requests-DIwGYs0l.js";import{t as V}from"./createLucideIcon-D5guW7EU.js";import{i as N}from"./useDeleteCell-BLvzLWAT.js";import{C as B,O as I,ut as P,w as K}from"./input-DA8xlX70.js";import{t as U}from"./square-B5xWCt0a.js";import{N as H,P as _,V as G,j as C,k as J}from"./usePress-DQ_tAz5W.js";import{l as Q}from"./RSPContexts-C3vBe8nL.js";import{t as X}from"./context-QkTujrKn.js";import{a as z}from"./renderShortcut--ku7VECI.js";var Y=V("hard-drive-download",[["path",{d:"M12 2v8",key:"1q4o3n"}],["path",{d:"m16 6-4 4-4-4",key:"6wukr"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 18h.01",key:"h775k"}]]),y=S(D(),1);function Z(n,e){let{"aria-label":t,"aria-labelledby":a,orientation:r="horizontal"}=n,[o,c]=(0,y.useState)(!1);G(()=>{var i;c(!!(e.current&&((i=e.current.parentElement)!=null&&i.closest('[role="toolbar"]'))))});let{direction:u}=X(),m=u==="rtl"&&r==="horizontal",f=Q(e),l=i=>{if(C(i.currentTarget,_(i))){if(r==="horizontal"&&i.key==="ArrowRight"||r==="vertical"&&i.key==="ArrowDown")m?f.focusPrevious():f.focusNext();else if(r==="horizontal"&&i.key==="ArrowLeft"||r==="vertical"&&i.key==="ArrowUp")m?f.focusNext():f.focusPrevious();else if(i.key==="Tab"){i.stopPropagation(),s.current=H(),i.shiftKey?f.focusFirst():f.focusLast();return}else return;i.stopPropagation(),i.preventDefault()}},s=(0,y.useRef)(null),b=i=>{!C(i.currentTarget,i.relatedTarget)&&!s.current&&(s.current=_(i))},p=i=>{if(s.current&&!C(i.currentTarget,i.relatedTarget)&&C(e.current,_(i))){var h;(h=s.current)==null||h.focus(),s.current=null}};return{toolbarProps:{...P(n,{labelable:!0}),role:o?"group":"toolbar","aria-orientation":r,"aria-label":t,"aria-labelledby":t==null?a:void 0,onKeyDownCapture:o?void 0:l,onFocusCapture:o?void 0:p,onBlurCapture:o?void 0:b}}}var $=(0,y.createContext)({}),ee=(0,y.forwardRef)(function(n,e){[n,e]=B(n,e,$);let{toolbarProps:t}=Z(n,e),a=K({...n,values:{orientation:n.orientation||"horizontal"},defaultClassName:"react-aria-Toolbar"}),r=P(n,{global:!0});return delete r.id,y.createElement(I.div,{...J(r,a,t),ref:e,slot:n.slot||void 0,"data-orientation":n.orientation||"horizontal"},a.children)}),te=x(),re=200;function R(n){let e=(0,te.c)(3),[t,a]=(0,y.useState)(!1),r,o;return e[0]===n?(r=e[1],o=e[2]):(r=()=>{if(!n)return;a(!1);let c=setTimeout(()=>{a(!0)},re);return()=>clearTimeout(c)},o=[n],e[0]=n,e[1]=r,e[2]=o),(0,y.useEffect)(r,o),n&&t}var A=x(),g=S(F(),1),oe=E("rounded-full shadow-xs-solid border p-[5px] transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 [&>svg]:size-3 active:shadow-none bg-background",{variants:{variant:{default:"hover:bg-accent hover:text-accent-foreground",stale:"bg-(--yellow-3) hover:bg-(--yellow-4) text-(--yellow-11)",green:"hover:bg-(--grass-2) hover:text-(--grass-11) hover:border-[var(--grass-7)],",disabled:"opacity-50 cursor-not-allowed",danger:"hover:bg-(--red-3) hover:text-(--red-11)"}},defaultVariants:{variant:"default"}});const k=n=>{let e=(0,A.c)(18),t,a,r,o,c,u,m;if(e[0]!==n){let{children:s,tooltip:b,disabled:p,variant:i,...h}=n;t=s,m=b;let d=p===void 0?!1:p;a=d,r=h,o=v=>{var j;d||((j=h.onClick)==null||j.call(h,v))},c=W.preventFocus,u=T(oe({variant:i}),h.className),e[0]=n,e[1]=t,e[2]=a,e[3]=r,e[4]=o,e[5]=c,e[6]=u,e[7]=m}else t=e[1],a=e[2],r=e[3],o=e[4],c=e[5],u=e[6],m=e[7];let f;e[8]!==t||e[9]!==a||e[10]!==r||e[11]!==o||e[12]!==c||e[13]!==u?(f=(0,g.jsx)("button",{disabled:a,...r,onClick:o,onMouseDown:c,className:u,children:t}),e[8]=t,e[9]=a,e[10]=r,e[11]=o,e[12]=c,e[13]=u,e[14]=f):f=e[14];let l=f;if(m){let s;return e[15]!==l||e[16]!==m?(s=(0,g.jsx)(O,{content:m,side:"top",delayDuration:200,usePortal:!1,children:l}),e[15]=l,e[16]=m,e[17]=s):s=e[17],s}return l},ae=n=>{let e=(0,A.c)(5),{children:t,className:a}=n,r;e[0]===a?r=e[1]:(r=T("flex items-center gap-1 bg-background m-[2px] rounded-full",a),e[0]=a,e[1]=r);let o;return e[2]!==t||e[3]!==r?(o=(0,g.jsx)(ee,{className:r,children:t}),e[2]=t,e[3]=r,e[4]=o):o=e[4],o};var ne=x();const ie=n=>{let e=(0,ne.c)(9),{connectionState:t,status:a}=n,{sendInterrupt:r}=L(),o=R(a==="running"),c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=z("global.interrupt"),e[0]=c):c=e[0];let u;e[1]!==t||e[2]!==o?(u=w(t)||!o,e[1]=t,e[2]=o,e[3]=u):u=e[3];let m=o?r:M.NOOP,f=o?"stale":"disabled",l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=(0,g.jsx)(U,{strokeWidth:1.5}),e[4]=l):l=e[4];let s;return e[5]!==u||e[6]!==m||e[7]!==f?(s=(0,g.jsx)(k,{tooltip:c,disabled:u,onClick:m,variant:f,"data-testid":"run-button",children:l}),e[5]=u,e[6]=m,e[7]=f,e[8]=s):s=e[8],s};var le=x();function se({connectionState:n,needsRun:e,loading:t,inactive:a}){return w(n)?"disabled":e&&!t?"stale":t||a?"disabled":"green"}const de=n=>{let e=(0,le.c)(27),{onClick:t,connectionState:a,needsRun:r,status:o,config:c,edited:u}=n,m=o==="disabled-transitively",f=o==="running"||o==="queued",l,s;e[0]!==m||e[1]!==c.disabled||e[2]!==a||e[3]!==u||e[4]!==f||e[5]!==r?(l=w(a)||f||!c.disabled&&m&&!u,s=se({connectionState:a,needsRun:r,loading:f,inactive:l}),e[0]=m,e[1]=c.disabled,e[2]=a,e[3]=u,e[4]=f,e[5]=r,e[6]=l,e[7]=s):(l=e[6],s=e[7]);let b=s;if(c.disabled){let d;e[8]===Symbol.for("react.memo_cache_sentinel")?(d=(0,g.jsx)(Y,{}),e[8]=d):d=e[8];let v;return e[9]!==l||e[10]!==t||e[11]!==b?(v=(0,g.jsx)(k,{tooltip:"Add code to notebook",disabled:l,onClick:t,variant:b,"data-testid":"run-button",children:d}),e[9]=l,e[10]=t,e[11]=b,e[12]=v):v=e[12],v}if(!c.disabled&&m&&!u){let d;e[13]===Symbol.for("react.memo_cache_sentinel")?(d=(0,g.jsx)(N,{strokeWidth:1.2}),e[13]=d):d=e[13];let v;return e[14]!==l||e[15]!==t||e[16]!==b?(v=(0,g.jsx)(k,{disabled:l,tooltip:"This cell can't be run because it has a disabled ancestor",onClick:t,variant:b,"data-testid":"run-button",children:d}),e[14]=l,e[15]=t,e[16]=b,e[17]=v):v=e[17],v}let p;if(w(a)){let d;e[18]===a?d=e[19]:(d=q(a),e[18]=a,e[19]=d),p=d}else if(o==="queued")p="This cell is already queued to run";else if(o==="running")p="This cell is already running.";else{let d;e[20]===Symbol.for("react.memo_cache_sentinel")?(d=z("cell.run"),e[20]=d):d=e[20],p=d}let i;e[21]===Symbol.for("react.memo_cache_sentinel")?(i=(0,g.jsx)(N,{strokeWidth:1.2}),e[21]=i):i=e[21];let h;return e[22]!==l||e[23]!==t||e[24]!==p||e[25]!==b?(h=(0,g.jsx)(k,{tooltip:p,disabled:l,onClick:t,variant:b,"data-testid":"run-button",children:i}),e[22]=l,e[23]=t,e[24]=p,e[25]=b,e[26]=h):h=e[26],h};export{R as a,k as i,ie as n,ae as r,de as t};