@marimo-team/frontend 0.19.3-dev4 → 0.19.3-dev41

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 (176) hide show
  1. package/dist/assets/{CellStatus-Ba6Af_Tb.js → CellStatus-b7Yo2X9j.js} +1 -1
  2. package/dist/assets/{ConnectedDataExplorerComponent-KlUs_Sz3.js → ConnectedDataExplorerComponent-Cr6-n9Em.js} +1 -1
  3. package/dist/assets/{ErrorBoundary-Drf1manw.js → ErrorBoundary-C7JBxSzd.js} +1 -1
  4. package/dist/assets/{ImperativeModal-q6QlC2aZ.js → ImperativeModal-DVhvP4lH.js} +1 -1
  5. package/dist/assets/{JsonOutput-4ruRfyOj.js → JsonOutput-C8Eo1zBR.js} +5 -5
  6. package/dist/assets/{LazyAnyLanguageCodeMirror-jpEDlD0M.js → LazyAnyLanguageCodeMirror-Cp2punaU.js} +2 -2
  7. package/dist/assets/{MarimoErrorOutput-DnjH3pD8.js → MarimoErrorOutput-CXBGzjO2.js} +2 -2
  8. package/dist/assets/{RenderHTML-DaJXe2U2.js → RenderHTML-SoetmcW2.js} +1 -1
  9. package/dist/assets/VisuallyHidden-B9t3FhTP.js +1 -0
  10. package/dist/assets/{add-cell-with-ai-Bsds_6SU.js → add-cell-with-ai-Csh7GHT3.js} +8 -8
  11. package/dist/assets/{add-database-form-CqIp3_WN.js → add-database-form-BBkiGMZ_.js} +2 -2
  12. package/dist/assets/agent-panel-C5C18dfm.js +287 -0
  13. package/dist/assets/{ai-model-dropdown-LK8Wr5iu.js → ai-model-dropdown-CrMTCgo7.js} +1 -1
  14. package/dist/assets/{alert-dialog-k5KxevGr.js → alert-dialog-jcHA5geR.js} +1 -1
  15. package/dist/assets/{any-language-editor-DQu1Tt2N.js → any-language-editor-Cm83E7D_.js} +1 -1
  16. package/dist/assets/{app-config-button-BaVc4Y5z.js → app-config-button-9izWmQ0X.js} +1 -1
  17. package/dist/assets/button-B8cGZzP5.js +1 -0
  18. package/dist/assets/{cache-panel-C1So4Zu3.js → cache-panel-1FqnpB9y.js} +1 -1
  19. package/dist/assets/cell-editor-gOJZyTG_.js +23 -0
  20. package/dist/assets/cell-link-BP7_Ns0N.js +1 -0
  21. package/dist/assets/{cells-KYKWFk6C.js → cells-Cv9PtwL9.js} +49 -49
  22. package/dist/assets/{chat-components-O6DUIpBx.js → chat-components-Be6BPrbT.js} +1 -1
  23. package/dist/assets/{chat-display-DD3KokYi.js → chat-display-BRKfnhbm.js} +1 -1
  24. package/dist/assets/{chat-panel-D4DIcOM1.js → chat-panel-BwP6HOKA.js} +2 -2
  25. package/dist/assets/client-CGOlSEYr.js +4 -0
  26. package/dist/assets/{column-preview-EpCGr4Xp.js → column-preview-MC6VOHbd.js} +1 -1
  27. package/dist/assets/{command-Dqe0kvHp.js → command-n_oMaKjl.js} +1 -1
  28. package/dist/assets/{command-palette-DWacsFDk.js → command-palette-DfZNcw7W.js} +1 -1
  29. package/dist/assets/common-MUZIZluQ.js +1 -0
  30. package/dist/assets/config-DFDEcYvy.js +1 -0
  31. package/dist/assets/context-DHfVoQfl.js +1 -0
  32. package/dist/assets/{copy-icon-B69c-352.js → copy-icon-jWsqdLn1.js} +1 -1
  33. package/dist/assets/{datasource-JeWYnuIr.js → datasource-CEsMStKs.js} +2 -2
  34. package/dist/assets/{dependency-graph-panel-BJibnwCO.js → dependency-graph-panel-CNTGbfLZ.js} +4 -4
  35. package/dist/assets/{dialog-DUEuLcT2.js → dialog-CF5DtF1E.js} +1 -1
  36. package/dist/assets/{dist-DOFFh6Ii.js → dist-Dg7UO_Vw.js} +1 -1
  37. package/dist/assets/{documentation-panel-B2W3q2YB.js → documentation-panel-Cb9AHO2C.js} +1 -1
  38. package/dist/assets/{download-NfnO_JCs.js → download-24bI2vH0.js} +1 -1
  39. package/dist/assets/edit-page-KoYkiOm1.js +12 -0
  40. package/dist/assets/{error-banner-DU5Qb8a8.js → error-banner-DvT0IGDZ.js} +1 -1
  41. package/dist/assets/{error-panel-Bv-7GYgJ.js → error-panel-CpYH0GfR.js} +1 -1
  42. package/dist/assets/{es-KtEicG7U.js → es-BITbuY9w.js} +1 -1
  43. package/dist/assets/{field-DDKGFzpC.js → field-Clr_fqUr.js} +1 -1
  44. package/dist/assets/{file-explorer-panel-CToUezud.js → file-explorer-panel-CdA81LHh.js} +1 -1
  45. package/dist/assets/{floating-outline-Db40vhG8.js → floating-outline-BbJ4ldyu.js} +1 -1
  46. package/dist/assets/{focus-BCdX47jS.js → focus-D1y1tXyC.js} +1 -1
  47. package/dist/assets/{form-DwtJQd_Z.js → form-BAtvsPJL.js} +2 -2
  48. package/dist/assets/{glide-data-editor-D_bRnWfy.js → glide-data-editor-Dv8ZW9dk.js} +1 -1
  49. package/dist/assets/{globals-MS86g8oR.js → globals-C6OH39EA.js} +1 -1
  50. package/dist/assets/{home-page-BfVf41OG.js → home-page-B_YprqxM.js} +2 -2
  51. package/dist/assets/house-CncUa_LL.js +1 -0
  52. package/dist/assets/index-Bq3Xa2YC.js +43 -0
  53. package/dist/assets/index-__6MNWbe.css +2 -0
  54. package/dist/assets/input-B80Yt1uu.js +1 -0
  55. package/dist/assets/{kiosk-mode-CEhvsEr0.js → kiosk-mode-DfyjlR7p.js} +1 -1
  56. package/dist/assets/{label-qwandMoh.js → label-CNZLffHW.js} +1 -1
  57. package/dist/assets/{layout-Cvaok8Kj.js → layout-9uQoV-6h.js} +4 -4
  58. package/dist/assets/links-DbDrjRnm.js +1 -0
  59. package/dist/assets/{logs-panel-J2FKnKaj.js → logs-panel-svcirwjp.js} +1 -1
  60. package/dist/assets/{markdown-renderer-BlG9DgUG.js → markdown-renderer-DlVqlHOL.js} +2 -2
  61. package/dist/assets/mode-PeuS_Lp-.js +1 -0
  62. package/dist/assets/{multi-map-fjX9ImVF.js → multi-map-CQd4MZr5.js} +1 -1
  63. package/dist/assets/name-cell-input-YMoA0SQj.js +1 -0
  64. package/dist/assets/{outline-panel-Doj3GJrQ.js → outline-panel-RKJ5Mqrt.js} +1 -1
  65. package/dist/assets/{packages-panel-nqWXQzKf.js → packages-panel-BuiAGEBw.js} +1 -1
  66. package/dist/assets/panels-BKsZUDjc.js +1 -0
  67. package/dist/assets/{process-output-DiSW8Nbo.js → process-output-KJWsSvCT.js} +1 -1
  68. package/dist/assets/{readonly-python-code-CKY5LsMp.js → readonly-python-code-HPlG_YPX.js} +1 -1
  69. package/dist/assets/run-page-CBDzVDX3.js +1 -0
  70. package/dist/assets/scratchpad-panel-BcE_ovEU.js +1 -0
  71. package/dist/assets/{secrets-panel-CDWmmmBS.js → secrets-panel-BMY6PPth.js} +1 -1
  72. package/dist/assets/{select-D0g5GnIs.js → select-D9lTzMzP.js} +1 -1
  73. package/dist/assets/{session-panel-CGFRSBw9.js → session-panel-Cv14Ehfm.js} +1 -1
  74. package/dist/assets/{slides-component-MkPkpql1.js → slides-component-Dp0Yv5b0.js} +1 -1
  75. package/dist/assets/{snippets-panel-ClHeSpc5.js → snippets-panel-OAdQXQ93.js} +1 -1
  76. package/dist/assets/state-DYG6kYly.js +1 -0
  77. package/dist/assets/state-xh6GqNrp.js +1 -0
  78. package/dist/assets/{switch-BmbGJWHc.js → switch-DPeh0R76.js} +1 -1
  79. package/dist/assets/{terminal-BvgBa6Ri.js → terminal-BbAhzgnR.js} +1 -1
  80. package/dist/assets/{textarea-WklymBeK.js → textarea-wbzgrXvB.js} +1 -1
  81. package/dist/assets/{tracing-D0WYhZdr.js → tracing-Bh3EJxAS.js} +1 -1
  82. package/dist/assets/{tracing-panel-CNxN58z7.js → tracing-panel-BzSQ7qvB.js} +2 -2
  83. package/dist/assets/{types-BrgXpvGt.js → types-B8Qb1FfB.js} +1 -1
  84. package/dist/assets/{useAddCell-a9qZ0_KE.js → useAddCell-DBGvrN8K.js} +1 -1
  85. package/dist/assets/{useBoolean-5kuXz69O.js → useBoolean-CyOFPk5r.js} +1 -1
  86. package/dist/assets/{useCellActionButton-9W_R41MM.js → useCellActionButton-BlS_HKk-.js} +1 -1
  87. package/dist/assets/{useDateFormatter-CV0QXb5P.js → useDateFormatter-DsANziQR.js} +1 -1
  88. package/dist/assets/useDeleteCell-BvQIJfpI.js +1 -0
  89. package/dist/assets/{useDependencyPanelTab-0reaqvvh.js → useDependencyPanelTab-BqEhbPr2.js} +1 -1
  90. package/dist/assets/useInterval-BGPIviJp.js +1 -0
  91. package/dist/assets/useNotebookActions-D1Woz3AV.js +1 -0
  92. package/dist/assets/{useNumberFormatter-D8ks3oPN.js → useNumberFormatter-FoXhpyAb.js} +1 -1
  93. package/dist/assets/usePress-DTwIUo40.js +7 -0
  94. package/dist/assets/useRunCells-B9Xr4tcH.js +1 -0
  95. package/dist/assets/useSplitCell-7xBW3b8-.js +1 -0
  96. package/dist/assets/utilities.esm-xahhGpny.js +3 -0
  97. package/dist/assets/{vega-component-DpAAiTdH.js → vega-component-dUiiVmIx.js} +1 -1
  98. package/dist/assets/{write-secret-modal-CLm48gMe.js → write-secret-modal-hOetwavI.js} +1 -1
  99. package/dist/index.html +54 -54
  100. package/package.json +5 -5
  101. package/src/__mocks__/requests.ts +1 -0
  102. package/src/__tests__/mount.test.ts +128 -0
  103. package/src/components/app-config/__tests__/get-dirty-values.test.ts +1 -1
  104. package/src/components/app-config/user-config-form.tsx +1 -1
  105. package/src/components/chat/acp/agent-panel.tsx +56 -43
  106. package/src/components/data-table/column-header.tsx +1 -1
  107. package/src/components/editor/KernelStartupErrorModal.tsx +101 -0
  108. package/src/components/editor/actions/name-cell-input.tsx +10 -4
  109. package/src/components/editor/alerts/connecting-alert.tsx +33 -6
  110. package/src/components/editor/chrome/types.ts +2 -4
  111. package/src/components/editor/chrome/wrapper/app-chrome.tsx +55 -58
  112. package/src/components/editor/chrome/wrapper/footer-items/runtime-settings.tsx +150 -96
  113. package/src/components/editor/renderers/vertical-layout/__tests__/useFocusFirstEditor.test.ts +27 -0
  114. package/src/components/editor/renderers/vertical-layout/useFocusFirstEditor.ts +6 -0
  115. package/src/components/utils/lazy-mount.tsx +29 -8
  116. package/src/core/MarimoApp.tsx +2 -0
  117. package/src/core/cells/cells.ts +2 -0
  118. package/src/core/cells/scrollCellIntoView.ts +3 -2
  119. package/src/core/codemirror/cm.ts +2 -0
  120. package/src/core/codemirror/lsp/__tests__/notebook-lsp.test.ts +123 -0
  121. package/src/core/codemirror/lsp/notebook-lsp.ts +44 -4
  122. package/src/core/codemirror/misc/__tests__/string-braces.test.ts +200 -0
  123. package/src/core/codemirror/misc/string-braces.ts +37 -0
  124. package/src/core/errors/state.ts +7 -1
  125. package/src/core/export/__tests__/hooks.test.ts +504 -0
  126. package/src/core/export/hooks.ts +93 -4
  127. package/src/core/islands/bridge.ts +1 -0
  128. package/src/core/islands/main.ts +2 -0
  129. package/src/core/kernel/__tests__/handlers.test.ts +2 -2
  130. package/src/core/kernel/state.ts +1 -0
  131. package/src/core/network/__tests__/requests-lazy.test.ts +1 -1
  132. package/src/core/network/__tests__/requests-network.test.ts +0 -18
  133. package/src/core/network/requests-lazy.ts +3 -2
  134. package/src/core/network/requests-network.ts +10 -7
  135. package/src/core/network/requests-static.ts +1 -0
  136. package/src/core/network/requests-toasting.tsx +1 -0
  137. package/src/core/network/types.ts +2 -0
  138. package/src/core/wasm/bridge.ts +1 -0
  139. package/src/core/websocket/types.ts +1 -0
  140. package/src/core/websocket/useMarimoKernelConnection.tsx +18 -1
  141. package/src/css/globals.css +2 -0
  142. package/src/hooks/__tests__/useInterval.test.tsx +104 -0
  143. package/src/hooks/useInterval.ts +32 -6
  144. package/src/mount.tsx +6 -0
  145. package/src/plugins/impl/chat/chat-ui.tsx +16 -4
  146. package/src/plugins/impl/data-frames/DataFramePlugin.tsx +3 -1
  147. package/src/utils/events.ts +1 -0
  148. package/dist/assets/VisuallyHidden-BodIky8L.js +0 -1
  149. package/dist/assets/agent-panel-CaAPVPdJ.js +0 -287
  150. package/dist/assets/button-DuYGqRtX.js +0 -1
  151. package/dist/assets/cell-editor-OFm-OSAP.js +0 -23
  152. package/dist/assets/cell-link-CfLJRl3p.js +0 -1
  153. package/dist/assets/client-Cha_JfGC.js +0 -4
  154. package/dist/assets/common-A6YWtmpq.js +0 -1
  155. package/dist/assets/config-babG4OBR.js +0 -1
  156. package/dist/assets/context-BAYdLMF_.js +0 -1
  157. package/dist/assets/edit-page-nuU4FVXi.js +0 -12
  158. package/dist/assets/globe-CY9im410.js +0 -1
  159. package/dist/assets/index-BI88xbv4.js +0 -43
  160. package/dist/assets/index-Chgc_07S.css +0 -2
  161. package/dist/assets/input-CaEtLL8p.js +0 -1
  162. package/dist/assets/links-ENMiP32L.js +0 -1
  163. package/dist/assets/mode-CK5Oq-Jz.js +0 -1
  164. package/dist/assets/name-cell-input-D7axzd6k.js +0 -1
  165. package/dist/assets/panels-CdYbZBqo.js +0 -1
  166. package/dist/assets/run-page-GP8eGE39.js +0 -1
  167. package/dist/assets/scratchpad-panel-B1p8zqAE.js +0 -1
  168. package/dist/assets/state-BBgXjqJI.js +0 -1
  169. package/dist/assets/state-CP7_TGWl.js +0 -1
  170. package/dist/assets/useDeleteCell-5kJUaejE.js +0 -1
  171. package/dist/assets/useInterval-DpipYmgs.js +0 -1
  172. package/dist/assets/useNotebookActions-o341ZCMJ.js +0 -1
  173. package/dist/assets/usePress-C2LPFxyv.js +0 -7
  174. package/dist/assets/useRunCells-wXhl9zOP.js +0 -1
  175. package/dist/assets/useSplitCell-mmm5jxn2.js +0 -1
  176. package/dist/assets/utilities.esm-Ckt5kMF-.js +0 -3
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./any-language-editor-DQu1Tt2N.js","./copy-icon-B69c-352.js","./button-DuYGqRtX.js","./hotkeys-uKX61F1_.js","./useEventListener-COkmyg1v.js","./compiler-runtime-DeeZ7FnK.js","./react-BGmjiNul.js","./chunk-LvLJmgfZ.js","./cn-C1rgT0yh.js","./clsx-D0MtrJOx.js","./jsx-runtime-DN_bIXfG.js","./tooltip-CvjcEpZC.js","./Combination-D1TsGrBC.js","./react-dom-C9fstfnp.js","./dist-CBrDuocE.js","./use-toast-Bzf3rpev.js","./copy-DRhpWiOq.js","./check-CrAQug3q.js","./createLucideIcon-CW2xpJ57.js","./copy-gBVL4NN-.js","./error-banner-DU5Qb8a8.js","./alert-dialog-k5KxevGr.js","./zod-Cg4WLWh2.js","./dist-BRZzJw_5.js","./dist-CAcX026F.js","./dist-BVf1IY4_.js","./dist-P7JHert4.js","./dist-DKNOF5xd.js","./dist-CVj-_Iiz.js","./dist-Cq_4nPfh.js","./dist-CoiWxjLF.js","./dist-cVYW_wBR.js","./dist-HGZzCB0y.js","./dist-BAmo7Mv9.js","./dist-RKnr9SNh.js","./dist-3oAtECdQ.js","./dist-D6Pwf0VF.js","./dist-D9HMoxdZ.js","./dist-JtCdI6tY.js","./esm-B3JckBtM.js","./extends-B9D0JO9U.js","./objectWithoutPropertiesLoose-CboCOq4o.js","./dist-CI6_zMIl.js","./esm-CCqLcax5.js","./dist-DrrmBmzm.js","./dist-Cv7ifwsi.js","./dist-ChHsi1N7.js","./dist-BuhT82Xx.js","./dist-Cd0uZhiN.js","./dist-DxRoHFaH.js","./apl-iXnrDoYq.js","./asciiarmor-CK-aFa78.js","./asn1-DWJdxrMP.js","./brainfuck-0bMZHpH_.js","./clike-5SQqmvx2.js","./clojure-B0kIwyv8.js","./cmake-CLXeINvH.js","./cobol-C9SsG--s.js","./coffeescript-UIQG6RnU.js","./commonlisp-BBPumpJY.js","./crystal-CGN1wsuY.js","./css-aQ-Krb7T.js","./cypher-DEE4_Yec.js","./d-CgJ8N-gL.js","./diff-B8e18dKs.js","./dtd-DtwMcoo9.js","./dylan-Be6i1K-V.js","./ecl-D5tlhe8s.js","./eiffel-8SQWO4xP.js","./elm-CtGe_7Jw.js","./erlang-CNwX3Z_M.js","./factor-DgyyQiBQ.js","./simple-mode-CZ1ts7NY.js","./forth-CaVwPSxM.js","./fortran-B28t9xoj.js","./gas-BSiJHAcz.js","./gherkin-1QurHPOF.js","./groovy-DFOLwJLv.js","./haskell-CUN2jxPH.js","./haxe-BYzKptPQ.js","./idl-cdmrQY5J.js","./javascript-l5LYdpfx.js","./julia-DxiTohY8.js","./livescript-BZkzGFkJ.js","./lua-rVV1vLen.js","./mathematica-DktJ0aJB.js","./mbox-Ch6IVA7h.js","./mirc-CdWws4At.js","./mllike-CB0tp4Bz.js","./modelica-DQGg_xsi.js","./mscgen-vDSxnAXy.js","./mumps-BzlVzIzl.js","./nsis-bDE8IZXy.js","./ntriples-BndMB6TK.js","./octave-DhnkL0CH.js","./oz-DbZmNL9y.js","./pascal-DhE1sEjD.js","./perl-BOZHK4Y3.js","./pig-eswHTOE9.js","./powershell-pm9G_Qg5.js","./properties-7VoeFdHR.js","./protobuf-BAsuCsmK.js","./pug-CcL3ml0F.js","./puppet-DUYPK8CV.js","./python-UQl3_T6H.js","./q-CnvA_jxT.js","./r-fM1OLzJB.js","./rpm-D62D_dq6.js","./ruby-DemvBD0m.js","./sas-CZjYQi4h.js","./scheme-nPNaP0Qp.js","./shell-BE2ANxN1.js","./sieve-DXFUN4C7.js","./smalltalk-DwXXlSAY.js","./sparql-CgejAdiJ.js","./stex-0ac7Aukl.js","./stylus-CslB9TS3.js","./swift-5t7SQPo8.js","./tcl-Ddpe8YBc.js","./textile-D_Db33mq.js","./toml-CgkLq_pv.js","./troff-6nX9d05T.js","./ttcn-cfg-ByNDYolW.js","./ttcn-Dd4SMoHT.js","./turtle-LDF8uFGv.js","./vb-DaLxM60T.js","./vbscript-CwitZ57u.js","./velocity-D6bc4mrP.js","./verilog-CIyPdzYJ.js","./vhdl-DfyhlM4K.js","./webidl-C23hA3Le.js","./xquery-BAVQXrAf.js","./yacas-DrybVty2.js","./z80-8KI6AMtY.js"])))=>i.map(i=>d[i]);
2
- import{s as e}from"./chunk-LvLJmgfZ.js";import{t as i}from"./react-BGmjiNul.js";import{t as o}from"./createLucideIcon-CW2xpJ57.js";import{t as m}from"./preload-helper-BW0IMuFq.js";let r,a,s=(async()=>{r=o("between-horizontal-start",[["rect",{width:"13",height:"7",x:"8",y:"3",rx:"1",key:"pkso9a"}],["path",{d:"m2 9 3 3-3 3",key:"1agib5"}],["rect",{width:"13",height:"7",x:"8",y:"14",rx:"1",key:"1q5fc1"}]]),a=(0,e(i(),1).lazy)(()=>m(()=>import("./any-language-editor-DQu1Tt2N.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133]),import.meta.url))})();export{s as __tla,r as n,a as t};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./any-language-editor-Cm83E7D_.js","./copy-icon-jWsqdLn1.js","./button-B8cGZzP5.js","./hotkeys-uKX61F1_.js","./useEventListener-COkmyg1v.js","./compiler-runtime-DeeZ7FnK.js","./react-BGmjiNul.js","./chunk-LvLJmgfZ.js","./cn-C1rgT0yh.js","./clsx-D0MtrJOx.js","./jsx-runtime-DN_bIXfG.js","./tooltip-CvjcEpZC.js","./Combination-D1TsGrBC.js","./react-dom-C9fstfnp.js","./dist-CBrDuocE.js","./use-toast-Bzf3rpev.js","./copy-DRhpWiOq.js","./check-CrAQug3q.js","./createLucideIcon-CW2xpJ57.js","./copy-gBVL4NN-.js","./error-banner-DvT0IGDZ.js","./alert-dialog-jcHA5geR.js","./zod-Cg4WLWh2.js","./dist-BRZzJw_5.js","./dist-CAcX026F.js","./dist-BVf1IY4_.js","./dist-P7JHert4.js","./dist-DKNOF5xd.js","./dist-CVj-_Iiz.js","./dist-Cq_4nPfh.js","./dist-CoiWxjLF.js","./dist-cVYW_wBR.js","./dist-HGZzCB0y.js","./dist-BAmo7Mv9.js","./dist-RKnr9SNh.js","./dist-3oAtECdQ.js","./dist-D6Pwf0VF.js","./dist-D9HMoxdZ.js","./dist-JtCdI6tY.js","./esm-B3JckBtM.js","./extends-B9D0JO9U.js","./objectWithoutPropertiesLoose-CboCOq4o.js","./dist-CI6_zMIl.js","./esm-CCqLcax5.js","./dist-DrrmBmzm.js","./dist-Cv7ifwsi.js","./dist-ChHsi1N7.js","./dist-BuhT82Xx.js","./dist-Cd0uZhiN.js","./dist-DxRoHFaH.js","./apl-iXnrDoYq.js","./asciiarmor-CK-aFa78.js","./asn1-DWJdxrMP.js","./brainfuck-0bMZHpH_.js","./clike-5SQqmvx2.js","./clojure-B0kIwyv8.js","./cmake-CLXeINvH.js","./cobol-C9SsG--s.js","./coffeescript-UIQG6RnU.js","./commonlisp-BBPumpJY.js","./crystal-CGN1wsuY.js","./css-aQ-Krb7T.js","./cypher-DEE4_Yec.js","./d-CgJ8N-gL.js","./diff-B8e18dKs.js","./dtd-DtwMcoo9.js","./dylan-Be6i1K-V.js","./ecl-D5tlhe8s.js","./eiffel-8SQWO4xP.js","./elm-CtGe_7Jw.js","./erlang-CNwX3Z_M.js","./factor-DgyyQiBQ.js","./simple-mode-CZ1ts7NY.js","./forth-CaVwPSxM.js","./fortran-B28t9xoj.js","./gas-BSiJHAcz.js","./gherkin-1QurHPOF.js","./groovy-DFOLwJLv.js","./haskell-CUN2jxPH.js","./haxe-BYzKptPQ.js","./idl-cdmrQY5J.js","./javascript-l5LYdpfx.js","./julia-DxiTohY8.js","./livescript-BZkzGFkJ.js","./lua-rVV1vLen.js","./mathematica-DktJ0aJB.js","./mbox-Ch6IVA7h.js","./mirc-CdWws4At.js","./mllike-CB0tp4Bz.js","./modelica-DQGg_xsi.js","./mscgen-vDSxnAXy.js","./mumps-BzlVzIzl.js","./nsis-bDE8IZXy.js","./ntriples-BndMB6TK.js","./octave-DhnkL0CH.js","./oz-DbZmNL9y.js","./pascal-DhE1sEjD.js","./perl-BOZHK4Y3.js","./pig-eswHTOE9.js","./powershell-pm9G_Qg5.js","./properties-7VoeFdHR.js","./protobuf-BAsuCsmK.js","./pug-CcL3ml0F.js","./puppet-DUYPK8CV.js","./python-UQl3_T6H.js","./q-CnvA_jxT.js","./r-fM1OLzJB.js","./rpm-D62D_dq6.js","./ruby-DemvBD0m.js","./sas-CZjYQi4h.js","./scheme-nPNaP0Qp.js","./shell-BE2ANxN1.js","./sieve-DXFUN4C7.js","./smalltalk-DwXXlSAY.js","./sparql-CgejAdiJ.js","./stex-0ac7Aukl.js","./stylus-CslB9TS3.js","./swift-5t7SQPo8.js","./tcl-Ddpe8YBc.js","./textile-D_Db33mq.js","./toml-CgkLq_pv.js","./troff-6nX9d05T.js","./ttcn-cfg-ByNDYolW.js","./ttcn-Dd4SMoHT.js","./turtle-LDF8uFGv.js","./vb-DaLxM60T.js","./vbscript-CwitZ57u.js","./velocity-D6bc4mrP.js","./verilog-CIyPdzYJ.js","./vhdl-DfyhlM4K.js","./webidl-C23hA3Le.js","./xquery-BAVQXrAf.js","./yacas-DrybVty2.js","./z80-8KI6AMtY.js"])))=>i.map(i=>d[i]);
2
+ import{s as e}from"./chunk-LvLJmgfZ.js";import{t as i}from"./react-BGmjiNul.js";import{t as o}from"./createLucideIcon-CW2xpJ57.js";import{t as m}from"./preload-helper-BW0IMuFq.js";let r,a,s=(async()=>{r=o("between-horizontal-start",[["rect",{width:"13",height:"7",x:"8",y:"3",rx:"1",key:"pkso9a"}],["path",{d:"m2 9 3 3-3 3",key:"1agib5"}],["rect",{width:"13",height:"7",x:"8",y:"14",rx:"1",key:"1q5fc1"}]]),a=(0,e(i(),1).lazy)(()=>m(()=>import("./any-language-editor-Cm83E7D_.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133]),import.meta.url))})();export{s as __tla,r as n,a as t};
@@ -1,7 +1,7 @@
1
- import{s as G}from"./chunk-LvLJmgfZ.js";import{d as ye,f as ve,l as Ne,u as be}from"./useEvent-DlWF5OMa.js";import{t as we}from"./react-BGmjiNul.js";import{C as ke,Fr as J,Kr as Ie,Pn as $e,Pr as _e,fn as Fe,in as Ae,q as Te,v as Ce}from"./cells-KYKWFk6C.js";import{t as E}from"./compiler-runtime-DeeZ7FnK.js";import{t as Se}from"./invariant-C6yE60hi.js";import{r as Me}from"./utils-CJJIceVn.js";import{t as qe}from"./jsx-runtime-DN_bIXfG.js";import{r as X,t as $}from"./button-DuYGqRtX.js";import{t as Y}from"./cn-C1rgT0yh.js";import{t as H}from"./createLucideIcon-CW2xpJ57.js";import{_ as ze}from"./select-D0g5GnIs.js";import{a as Ee,p as Pe,r as Le,t as We}from"./dropdown-menu-BP4_BZLr.js";import{a as Ve,n as Be}from"./state-CP7_TGWl.js";import{c as Z,n as Qe}from"./datasource-JeWYnuIr.js";import{a as De}from"./dist-RKnr9SNh.js";import{t as ee}from"./tooltip-CvjcEpZC.js";import{a as Oe,i as He,n as Ue,r as Ke}from"./multi-map-fjX9ImVF.js";import{t as te}from"./kbd-Czc5z_04.js";import{t as A}from"./links-DNmjkr65.js";import{r as Re,t as Ge}from"./alert-BEdExd6A.js";import{o as Je,t as Xe}from"./useInstallPackage-RldLPyJs.js";import{n as b}from"./cell-link-CfLJRl3p.js";var Ye=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"}]]),T=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"}]]),re=H("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);function Ze(r){let e=null,s=r.cursor();do s.name==="ExpressionStatement"&&(e=s.node);while(s.next());return e}function et(r){let e=r.split(`
1
+ import{s as G}from"./chunk-LvLJmgfZ.js";import{d as ye,f as ve,l as Ne,u as be}from"./useEvent-DlWF5OMa.js";import{t as we}from"./react-BGmjiNul.js";import{Fn as ke,Fr as Ie,Ir as K,J as $e,an as _e,pn as Fe,qr as Ae,w as Te,y as Ce}from"./cells-Cv9PtwL9.js";import{t as E}from"./compiler-runtime-DeeZ7FnK.js";import{t as Se}from"./invariant-C6yE60hi.js";import{r as Me}from"./utils-CJJIceVn.js";import{t as qe}from"./jsx-runtime-DN_bIXfG.js";import{r as X,t as $}from"./button-B8cGZzP5.js";import{t as Y}from"./cn-C1rgT0yh.js";import{t as H}from"./createLucideIcon-CW2xpJ57.js";import{_ as ze}from"./select-D9lTzMzP.js";import{a as Ee,p as Pe,r as Le,t as We}from"./dropdown-menu-BP4_BZLr.js";import{a as Ve,n as Be}from"./state-xh6GqNrp.js";import{c as Z,n as Qe}from"./datasource-CEsMStKs.js";import{a as De}from"./dist-RKnr9SNh.js";import{t as ee}from"./tooltip-CvjcEpZC.js";import{a as Oe,i as He,n as Ue,r as Je}from"./multi-map-CQd4MZr5.js";import{t as te}from"./kbd-Czc5z_04.js";import{t as A}from"./links-DNmjkr65.js";import{r as Re,t as Ge}from"./alert-BEdExd6A.js";import{o as Ke,t as Xe}from"./useInstallPackage-RldLPyJs.js";import{n as b}from"./cell-link-BP7_Ns0N.js";var Ye=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"}]]),T=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"}]]),re=H("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);function Ze(r){let e=null,s=r.cursor();do s.name==="ExpressionStatement"&&(e=s.node);while(s.next());return e}function et(r){let e=r.split(`
2
2
  `),s=" ",n=Ze(De.parse(r));if(!n)return["def _():",...U(e,s),`${s}return`,"","","_()"].join(`
3
3
  `);let i=r.slice(0,n.from).trim(),l=r.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(r,e){if(r.length===1&&r[0]==="")return[];let s=[];for(let n of r)n===""?s.push(""):s.push(e+n);return s}function tt(r,e){var s;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 n=>{Se(n.editor,"Editor is null");let i=et(n.editor.state.doc.toString());n.editor.dispatch({changes:{from:0,to:n.editor.state.doc.length,insert:i}})}}];if(r.type==="exception"&&r.exception_type==="NameError"){let n=(s=r.msg.match(/name '(.+)' is not defined/))==null?void 0:s[1];if(!n||!(n in se))return[];let i=rt(n);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 n=>{var a;let i=Qe(n.cellId),l=`Fix the SQL statement: ${r.msg}.`;i&&(l+=`
7
- Database schema: ${i}`),(a=n.aiFix)==null||a.setAiCompletionCell({cellId:n.cellId,initialPrompt:l,triggerImmediately:n.aiFix.triggerFix})}}]:[]}function rt(r){let e=se[r];return e===r?`import ${e}`:`import ${e} as ${r}`}var se={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"},st=E(),nt=Ie("marimo:ai-autofix-mode","autofix",Fe);function lt(){let r=(0,st.c)(3),[e,s]=Ne(nt),n;return r[0]!==e||r[1]!==s?(n={fixMode:e,setFixMode:s},r[0]=e,r[1]=s,r[2]=n):n=r[2],n}var K=E(),t=G(qe(),1);const N=r=>{let e=(0,K.c)(21),{errors:s,cellId:n,className:i}=r,l=ve(),{createNewCell:a}=ke(),c=be(Me),o;if(e[0]!==c||e[1]!==s){let x;e[3]===c?x=e[4]:(x=y=>tt(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=ye(Be);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 w;let y=(w=l.get(Ce).cellHandles[n].current)==null?void 0:w.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=Y("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,t.jsx)(oe,{tooltip:d.description,openPrompt:()=>u(!1),applyAutofix:()=>u(!0)}):(0,t.jsx)(ee,{content:d.description,align:"start",children:(0,t.jsxs)($,{size:"xs",variant:"outline",className:"font-normal",onClick:()=>u(!1),children:[(0,t.jsx)(Z,{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,t.jsx)("div",{className:j,children:h}),e[18]=j,e[19]=h,e[20]=g):g=e[20],g};var ne=Ve,le=Z,ie="Suggest a prompt",ae="Fix with AI";const oe=r=>{let e=(0,K.c)(21),{tooltip:s,openPrompt:n,applyAutofix:i}=r,{fixMode:l,setFixMode:a}=lt(),c=l==="prompt"?n:i,o;e[0]===l?o=e[1]:(o=l==="prompt"?(0,t.jsx)(ne,{className:"h-3 w-3 mr-2 mb-0.5"}):(0,t.jsx)(le,{className:"h-3 w-3 mr-2 mb-0.5"}),e[0]=l,e[1]=o);let m=l==="prompt"?ie:ae,p;e[2]!==c||e[3]!==o||e[4]!==m?(p=(0,t.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,t.jsx)(ee,{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,t.jsx)(Pe,{asChild:!0,children:(0,t.jsx)($,{size:"xs",variant:"outline",className:"rounded-l-none px-2","aria-label":"Fix options",children:(0,t.jsx)(ze,{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,t.jsx)(it,{mode:j}),e[13]=j,e[14]=h);let g;e[15]!==u||e[16]!==h?(g=(0,t.jsxs)(We,{children:[f,(0,t.jsx)(Le,{align:"end",className:"w-56",children:(0,t.jsx)(Ee,{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,t.jsxs)("div",{className:"flex",children:[d,g]}),e[18]=g,e[19]=d,e[20]=x):x=e[20],x};var it=r=>{let e=(0,K.c)(12),{mode:s}=r,n;e[0]===s?n=e[1]:(n=s==="prompt"?(0,t.jsx)(ne,{className:"h-4 w-4"}):(0,t.jsx)(le,{className:"h-4 w-4"}),e[0]=s,e[1]=n);let i=n,l=s==="prompt"?ie:ae,a=s==="prompt"?"Edit the prompt before applying":"Apply AI fixes automatically",c;e[2]===l?c=e[3]:(c=(0,t.jsx)("span",{className:"font-medium",children:l}),e[2]=l,e[3]=c);let o;e[4]===a?o=e[5]:(o=(0,t.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,t.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,t.jsxs)("div",{className:"flex items-center gap-2",children:[i,m]}),e[9]=i,e[10]=m,e[11]=p):p=e[11],p},ce=/(https?:\/\/\S+)/,at=/\.(png|jpe?g|gif|webp|svg|ico)(\?.*)?$/i,de=/^data:image\//i,ot=["avatars.githubusercontent.com"];function me(r){return de.test(r)?[{type:"image",url:r}]:r.split(ce).filter(e=>e.trim()!=="").map(e=>ce.test(e)?at.test(e)||de.test(e)||ot.some(s=>e.includes(s))?{type:"image",url:e}:{type:"url",url:e}:{type:"text",value:e})}var pe=E(),P=G(we(),1),ct=new Te;const R=r=>{let e=RegExp("\x1B\\[[0-9;]*m","g");return r.replaceAll(e,"")};var ue=/(pip\s+install|uv\s+add|uv\s+pip\s+install)\s+/gi;function dt(r){ue.lastIndex=0;let e=ue.exec(r);if(!e)return null;let s=e.index+e[0].length,n=r.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 k(r,e=""){if(!r)return null;if(!/https?:\/\//.test(r))return r;let s=me(r);return s.length===1&&s[0].type==="text"?r:(0,t.jsx)(t.Fragment,{children:s.map((n,i)=>{let l=e?`${e}-${i}`:i;if(n.type==="url"){let a=R(n.url);return(0,t.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:X.stopPropagation(),className:"text-link hover:underline",children:a},l)}if(n.type==="image"){let a=R(n.url);return(0,t.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:X.stopPropagation(),className:"text-link hover:underline",children:a},l)}return(0,t.jsx)(P.Fragment,{children:n.value},l)})})}var mt=r=>{let e=(0,pe.c)(6),{packages:s,children:n}=r,{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,t.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 pt=r=>{if(!(r instanceof J.Text))return;let e=R(r.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=dt(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,t.jsx)(P.Fragment,{children:k(j,`before-${o}`)},`before-${o}`))}let u=e.slice(d,f);l.push((0,t.jsx)(mt,{packages:[p.package],children:u},`install-${o}`)),a=f}),a<e.length){let c=e.slice(a);l.push((0,t.jsx)(P.Fragment,{children:k(c,"after")},"after"))}return(0,t.jsx)(t.Fragment,{children:l})},ut=r=>{if(!(r instanceof J.Text))return;let e=r.data;if(!/https?:\/\//.test(e))return;let s=k(e);if(typeof s!="string")return(0,t.jsx)(t.Fragment,{children:s})},ht=(...r)=>e=>{for(let s of r){let n=s(e);if(n!==void 0)return n}},xt=(r,e)=>(0,t.jsx)("span",{children:_e(ct.ansi_to_html(r),{replace:s=>e(s)})}),ft=r=>{let e=(0,pe.c)(4),{text:s}=r,n;e[0]===s?n=e[1]:(n=xt(s,ht(pt,ut)),e[0]=s,e[1]=n);let i=n,l;return e[2]===i?l=e[3]:(l=(0,t.jsx)(t.Fragment,{children:i}),e[2]=i,e[3]=l),l};var he=E(),I=r=>{let e=(0,he.c)(10),s=r.title??"Tip",n;e[0]===s?n=e[1]:(n=(0,t.jsx)(Oe,{className:"pt-2 pb-2 font-normal",children:s}),e[0]=s,e[1]=n);let i;e[2]===r.children?i=e[3]:(i=(0,t.jsx)(Ke,{className:"mr-24 text-[0.84375rem]",children:r.children}),e[2]=r.children,e[3]=i);let l;e[4]!==n||e[5]!==i?(l=(0,t.jsxs)(He,{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]!==r.className||e[8]!==l?(a=(0,t.jsx)(Ue,{type:"single",collapsible:!0,className:r.className,children:l}),e[7]=r.className,e[8]=l,e[9]=a):a=e[9],a};const jt=r=>{let e=(0,he.c)(31),{errors:s,cellId:n,className:i}=r,l=Ae(),a="This cell wasn't run because it has errors",c="destructive",o="text-error";if(s.some(gt))a="Interrupted";else if(s.some(yt))a="An internal error occurred";else if(s.some(vt))a="Ancestor prevented from running",c="default",o="text-secondary-foreground";else if(s.some(Nt))a="Ancestor stopped",c="default",o="text-secondary-foreground";else if(s.some(bt))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(kt),y=s.filter(It),w=s.filter($t),_=s.filter(_t),L=s.filter(Ft),C=s.filter(At),S=s.filter(Tt),W=s.filter(Ct),V=s.filter(St),B=s.filter(Mt),F=s.filter(qt),Q=s.filter(zt),D=s.filter(Et),M;e[15]===l?M=e[16]:(M=()=>{l.openApplication("scratchpad")},e[15]=l,e[16]=M);let xe=M,fe=()=>{let v=[];if(F.length>0||Q.length>0){let z=F.some(Pt),ge=!z&&F.some(Lt);v.push((0,t.jsxs)("div",{children:[F.map(Wt),Q.map(Vt),z&&(0,t.jsxs)($,{size:"xs",variant:"outline",className:"mt-2 font-normal",onClick:()=>Je(l),children:[(0,t.jsx)(Ye,{className:"h-3.5 w-3.5 mr-1.5 mb-0.5"}),(0,t.jsx)("span",{children:"Open package manager"})]}),ge&&(0,t.jsxs)($,{size:"xs",variant:"outline",className:"mt-2 font-normal",onClick:()=>l.openApplication("terminal"),children:[(0,t.jsx)(re,{className:"h-3.5 w-3.5 mr-1.5"}),(0,t.jsx)("span",{children:"Open terminal"})]}),n&&(0,t.jsx)(N,{errors:[...F,...Q],cellId:n})]},"syntax-unknown"))}if(x.length>0&&v.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:x.flatMap(Bt)}),n&&(0,t.jsx)(N,{errors:x,cellId:n}),(0,t.jsxs)(I,{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)(A,{href:"https://links.marimo.app/errors-setup",children:["Learn more at our docs"," ",(0,t.jsx)(T,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"setup-refs")),y.length>0&&v.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:y.flatMap(Qt)}),n&&(0,t.jsx)(N,{errors:y,cellId:n}),(0,t.jsxs)(I,{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)(A,{href:"https://links.marimo.app/errors-cycles",children:["Learn more at our docs"," ",(0,t.jsx)(T,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"cycle")),w.length>0){let z=w[0].name;v.push((0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground font-medium",children:"This cell redefines variables from other cells."}),w.map(Ot),n&&(0,t.jsx)(N,{errors:w,cellId:n}),(0,t.jsxs)(I,{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)(te,{className:"inline",children:["_",z]}),"). to make them private to this cell."]}),(0,t.jsxs)("p",{className:"py-2",children:[(0,t.jsxs)(A,{href:"https://links.marimo.app/errors-multiple-definitions",children:["Learn more at our docs"," ",(0,t.jsx)(T,{size:"0.75rem",className:"inline"})]}),"."]})]}),(0,t.jsx)(I,{title:"Need a scratchpad?",children:(0,t.jsxs)("div",{className:"flex flex-row gap-2 items-center",children:[(0,t.jsxs)($,{size:"xs",variant:"link",className:"my-2 font-normal mx-0 px-0",onClick:xe,children:[(0,t.jsx)($e,{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 _.length>0&&v.push((0,t.jsxs)("div",{children:[_.map(Ht),n&&(0,t.jsx)(N,{errors:_,cellId:n}),(0,t.jsxs)(I,{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)(A,{href:"https://links.marimo.app/errors-import-star",children:["Learn more at our docs"," ",(0,t.jsx)(T,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"import-star")),L.length>0&&v.push((0,t.jsxs)("div",{children:[L.map(Ut),n&&(0,t.jsx)(N,{errors:L,cellId:n})]},"interruption")),C.length>0&&v.push((0,t.jsxs)("ul",{children:[C.map(Kt),C.some(Rt)&&(0,t.jsx)(I,{children:"Fix the error in the mentioned cells, or handle the exceptions with try/except blocks."}),n&&(0,t.jsx)(N,{errors:C,cellId:n})]},"exception")),S.length>0&&v.push((0,t.jsxs)("ul",{children:[S.map(Gt),n&&(0,t.jsx)(N,{errors:S,cellId:n}),(0,t.jsx)(I,{children:S.some(Jt)?"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,t.jsxs)("div",{children:[W.map(Xt),n&&(0,t.jsx)(N,{errors:W,cellId:n})]},"internal")),V.length>0&&v.push((0,t.jsxs)("div",{children:[V.map(Yt),n&&(0,t.jsx)(N,{errors:V,cellId:n})]},"ancestor-prevented")),B.length>0&&v.push((0,t.jsxs)("div",{children:[B.map(Zt),n&&(0,t.jsx)(N,{errors:B,cellId:n})]},"ancestor-stopped")),D.length>0&&v.push((0,t.jsxs)("div",{children:[D.map(er),n&&(0,t.jsx)(N,{errors:D,cellId:n,className:"mt-2.5"})]},"sql-errors")),v},O=`font-code font-medium tracking-wide ${o}`,q;e[17]!==O||e[18]!==a?(q=(0,t.jsx)(Re,{className:O,children:a}),e[17]=O,e[18]=a,e[19]=q):q=e[19];let je=q;m=Ge,f=c,e[20]===i?u=e[21]:(u=Y("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=je,p="flex flex-col gap-8",d=fe(),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,t.jsx)("div",{children:(0,t.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,t.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 gt(r){return r.type==="interruption"}function yt(r){return r.type==="internal"}function vt(r){return r.type==="ancestor-prevented"}function Nt(r){return r.type==="ancestor-stopped"}function bt(r){return r.type==="sql-error"}function wt(r){return r.type==="exception"}function kt(r){return r.type==="setup-refs"}function It(r){return r.type==="cycle"}function $t(r){return r.type==="multiple-defs"}function _t(r){return r.type==="import-star"}function Ft(r){return r.type==="interruption"}function At(r){return r.type==="exception"}function Tt(r){return r.type==="strict-exception"}function Ct(r){return r.type==="internal"}function St(r){return r.type==="ancestor-prevented"}function Mt(r){return r.type==="ancestor-stopped"}function qt(r){return r.type==="syntax"}function zt(r){return r.type==="unknown"}function Et(r){return r.type==="sql-error"}function Pt(r){return r.msg.includes("!pip")}function Lt(r){return r.msg.includes("use os.subprocess")}function Wt(r,e){return(0,t.jsx)("pre",{children:k(r.msg,`syntax-${e}`)},`syntax-${e}`)}function Vt(r,e){return(0,t.jsx)("pre",{children:k(r.msg,`unknown-${e}`)},`unknown-${e}`)}function Bt(r,e){return r.edges_with_vars.map((s,n)=>(0,t.jsxs)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:[(0,t.jsx)(b,{cellId:s[0]}),(0,t.jsxs)("span",{className:"text-muted-foreground",children:[": "," ",s[1].length===1?s[1][0]:s[1].join(", ")]})]},`setup-refs-${e}-${n}`))}function Qt(r,e){return r.edges_with_vars.map((s,n)=>(0,t.jsxs)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:[(0,t.jsx)(b,{cellId:s[0]}),(0,t.jsxs)("span",{className:"text-muted-foreground",children:[" -> ",s[1].length===1?s[1][0]:s[1].join(", ")," -> "]}),(0,t.jsx)(b,{cellId:s[2]})]},`cycle-${e}-${n}`))}function Dt(r,e){return(0,t.jsx)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:(0,t.jsx)(b,{cellId:r})},`cell-${e}`)}function Ot(r,e){return(0,t.jsxs)(P.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(Dt)})]},`multiple-defs-${e}`)}function Ht(r,e){return(0,t.jsx)("p",{className:"text-muted-foreground",children:r.msg},`import-star-${e}`)}function Ut(r,e){return(0,t.jsx)("p",{children:"This cell was interrupted and needs to be re-run."},`interruption-${e}`)}function Kt(r,e){return r.exception_type==="NameError"&&r.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)(te,{className:"inline",children:"mo"}),") is required for Markdown, SQL, and UI elements."]})]})},`exception-${e}`):r.exception_type==="NameError"&&r.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:r.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)(A,{href:"https://links.marimo.app/local-variables",children:["docs"," ",(0,t.jsx)(T,{size:"0.75rem",className:"inline"})]}),")."]}),(0,t.jsx)("div",{className:"text-muted-foreground mt-2",children:"See the console area for a traceback."})]})},`exception-${e}`):(0,t.jsx)("li",{className:"my-2",children:r.raising_cell==null?(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground",children:k(r.msg,`exception-${e}`)}),(0,t.jsx)("div",{className:"text-muted-foreground mt-2",children:"See the console area for a traceback."})]}):(0,t.jsxs)("div",{children:[k(r.msg,`exception-${e}`),(0,t.jsx)(b,{cellId:r.raising_cell})]})},`exception-${e}`)}function Rt(r){return r.raising_cell!=null}function Gt(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)(b,{cellId:r.blamed_cell})]})},`strict-exception-${e}`)}function Jt(r){return r.blamed_cell!=null}function Xt(r,e){return(0,t.jsx)("p",{children:r.msg},`internal-${e}`)}function Yt(r,e){return(0,t.jsxs)("div",{children:[r.msg,r.blamed_cell==null?(0,t.jsxs)("span",{children:["(",(0,t.jsx)(b,{cellId:r.raising_cell}),")"]}):(0,t.jsxs)("span",{children:["(",(0,t.jsx)(b,{cellId:r.raising_cell}),"\xA0blames\xA0",(0,t.jsx)(b,{cellId:r.blamed_cell}),")"]})]},`ancestor-prevented-${e}`)}function Zt(r,e){return(0,t.jsxs)("div",{children:[r.msg,(0,t.jsx)(b,{cellId:r.raising_cell})]},`ancestor-stopped-${e}`)}function er(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{re as a,oe as i,ft as n,me as r,jt as t};
7
+ Database schema: ${i}`),(a=n.aiFix)==null||a.setAiCompletionCell({cellId:n.cellId,initialPrompt:l,triggerImmediately:n.aiFix.triggerFix})}}]:[]}function rt(r){let e=se[r];return e===r?`import ${e}`:`import ${e} as ${r}`}var se={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"},st=E(),nt=Ae("marimo:ai-autofix-mode","autofix",Fe);function lt(){let r=(0,st.c)(3),[e,s]=Ne(nt),n;return r[0]!==e||r[1]!==s?(n={fixMode:e,setFixMode:s},r[0]=e,r[1]=s,r[2]=n):n=r[2],n}var J=E(),t=G(qe(),1);const N=r=>{let e=(0,J.c)(21),{errors:s,cellId:n,className:i}=r,l=ve(),{createNewCell:a}=Te(),c=be(Me),o;if(e[0]!==c||e[1]!==s){let x;e[3]===c?x=e[4]:(x=y=>tt(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=ye(Be);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 w;let y=(w=l.get(Ce).cellHandles[n].current)==null?void 0:w.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=Y("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,t.jsx)(oe,{tooltip:d.description,openPrompt:()=>u(!1),applyAutofix:()=>u(!0)}):(0,t.jsx)(ee,{content:d.description,align:"start",children:(0,t.jsxs)($,{size:"xs",variant:"outline",className:"font-normal",onClick:()=>u(!1),children:[(0,t.jsx)(Z,{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,t.jsx)("div",{className:j,children:h}),e[18]=j,e[19]=h,e[20]=g):g=e[20],g};var ne=Ve,le=Z,ie="Suggest a prompt",ae="Fix with AI";const oe=r=>{let e=(0,J.c)(21),{tooltip:s,openPrompt:n,applyAutofix:i}=r,{fixMode:l,setFixMode:a}=lt(),c=l==="prompt"?n:i,o;e[0]===l?o=e[1]:(o=l==="prompt"?(0,t.jsx)(ne,{className:"h-3 w-3 mr-2 mb-0.5"}):(0,t.jsx)(le,{className:"h-3 w-3 mr-2 mb-0.5"}),e[0]=l,e[1]=o);let m=l==="prompt"?ie:ae,p;e[2]!==c||e[3]!==o||e[4]!==m?(p=(0,t.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,t.jsx)(ee,{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,t.jsx)(Pe,{asChild:!0,children:(0,t.jsx)($,{size:"xs",variant:"outline",className:"rounded-l-none px-2","aria-label":"Fix options",children:(0,t.jsx)(ze,{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,t.jsx)(it,{mode:j}),e[13]=j,e[14]=h);let g;e[15]!==u||e[16]!==h?(g=(0,t.jsxs)(We,{children:[f,(0,t.jsx)(Le,{align:"end",className:"w-56",children:(0,t.jsx)(Ee,{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,t.jsxs)("div",{className:"flex",children:[d,g]}),e[18]=g,e[19]=d,e[20]=x):x=e[20],x};var it=r=>{let e=(0,J.c)(12),{mode:s}=r,n;e[0]===s?n=e[1]:(n=s==="prompt"?(0,t.jsx)(ne,{className:"h-4 w-4"}):(0,t.jsx)(le,{className:"h-4 w-4"}),e[0]=s,e[1]=n);let i=n,l=s==="prompt"?ie:ae,a=s==="prompt"?"Edit the prompt before applying":"Apply AI fixes automatically",c;e[2]===l?c=e[3]:(c=(0,t.jsx)("span",{className:"font-medium",children:l}),e[2]=l,e[3]=c);let o;e[4]===a?o=e[5]:(o=(0,t.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,t.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,t.jsxs)("div",{className:"flex items-center gap-2",children:[i,m]}),e[9]=i,e[10]=m,e[11]=p):p=e[11],p},ce=/(https?:\/\/\S+)/,at=/\.(png|jpe?g|gif|webp|svg|ico)(\?.*)?$/i,de=/^data:image\//i,ot=["avatars.githubusercontent.com"];function me(r){return de.test(r)?[{type:"image",url:r}]:r.split(ce).filter(e=>e.trim()!=="").map(e=>ce.test(e)?at.test(e)||de.test(e)||ot.some(s=>e.includes(s))?{type:"image",url:e}:{type:"url",url:e}:{type:"text",value:e})}var pe=E(),P=G(we(),1),ct=new $e;const R=r=>{let e=RegExp("\x1B\\[[0-9;]*m","g");return r.replaceAll(e,"")};var ue=/(pip\s+install|uv\s+add|uv\s+pip\s+install)\s+/gi;function dt(r){ue.lastIndex=0;let e=ue.exec(r);if(!e)return null;let s=e.index+e[0].length,n=r.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 k(r,e=""){if(!r)return null;if(!/https?:\/\//.test(r))return r;let s=me(r);return s.length===1&&s[0].type==="text"?r:(0,t.jsx)(t.Fragment,{children:s.map((n,i)=>{let l=e?`${e}-${i}`:i;if(n.type==="url"){let a=R(n.url);return(0,t.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:X.stopPropagation(),className:"text-link hover:underline",children:a},l)}if(n.type==="image"){let a=R(n.url);return(0,t.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:X.stopPropagation(),className:"text-link hover:underline",children:a},l)}return(0,t.jsx)(P.Fragment,{children:n.value},l)})})}var mt=r=>{let e=(0,pe.c)(6),{packages:s,children:n}=r,{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,t.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 pt=r=>{if(!(r instanceof K.Text))return;let e=R(r.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=dt(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,t.jsx)(P.Fragment,{children:k(j,`before-${o}`)},`before-${o}`))}let u=e.slice(d,f);l.push((0,t.jsx)(mt,{packages:[p.package],children:u},`install-${o}`)),a=f}),a<e.length){let c=e.slice(a);l.push((0,t.jsx)(P.Fragment,{children:k(c,"after")},"after"))}return(0,t.jsx)(t.Fragment,{children:l})},ut=r=>{if(!(r instanceof K.Text))return;let e=r.data;if(!/https?:\/\//.test(e))return;let s=k(e);if(typeof s!="string")return(0,t.jsx)(t.Fragment,{children:s})},ht=(...r)=>e=>{for(let s of r){let n=s(e);if(n!==void 0)return n}},xt=(r,e)=>(0,t.jsx)("span",{children:Ie(ct.ansi_to_html(r),{replace:s=>e(s)})}),ft=r=>{let e=(0,pe.c)(4),{text:s}=r,n;e[0]===s?n=e[1]:(n=xt(s,ht(pt,ut)),e[0]=s,e[1]=n);let i=n,l;return e[2]===i?l=e[3]:(l=(0,t.jsx)(t.Fragment,{children:i}),e[2]=i,e[3]=l),l};var he=E(),I=r=>{let e=(0,he.c)(10),s=r.title??"Tip",n;e[0]===s?n=e[1]:(n=(0,t.jsx)(Oe,{className:"pt-2 pb-2 font-normal",children:s}),e[0]=s,e[1]=n);let i;e[2]===r.children?i=e[3]:(i=(0,t.jsx)(Je,{className:"mr-24 text-[0.84375rem]",children:r.children}),e[2]=r.children,e[3]=i);let l;e[4]!==n||e[5]!==i?(l=(0,t.jsxs)(He,{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]!==r.className||e[8]!==l?(a=(0,t.jsx)(Ue,{type:"single",collapsible:!0,className:r.className,children:l}),e[7]=r.className,e[8]=l,e[9]=a):a=e[9],a};const jt=r=>{let e=(0,he.c)(31),{errors:s,cellId:n,className:i}=r,l=_e(),a="This cell wasn't run because it has errors",c="destructive",o="text-error";if(s.some(gt))a="Interrupted";else if(s.some(yt))a="An internal error occurred";else if(s.some(vt))a="Ancestor prevented from running",c="default",o="text-secondary-foreground";else if(s.some(Nt))a="Ancestor stopped",c="default",o="text-secondary-foreground";else if(s.some(bt))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(kt),y=s.filter(It),w=s.filter($t),_=s.filter(_t),L=s.filter(Ft),C=s.filter(At),S=s.filter(Tt),W=s.filter(Ct),V=s.filter(St),B=s.filter(Mt),F=s.filter(qt),Q=s.filter(zt),D=s.filter(Et),M;e[15]===l?M=e[16]:(M=()=>{l.openApplication("scratchpad")},e[15]=l,e[16]=M);let xe=M,fe=()=>{let v=[];if(F.length>0||Q.length>0){let z=F.some(Pt),ge=!z&&F.some(Lt);v.push((0,t.jsxs)("div",{children:[F.map(Wt),Q.map(Vt),z&&(0,t.jsxs)($,{size:"xs",variant:"outline",className:"mt-2 font-normal",onClick:()=>Ke(l),children:[(0,t.jsx)(Ye,{className:"h-3.5 w-3.5 mr-1.5 mb-0.5"}),(0,t.jsx)("span",{children:"Open package manager"})]}),ge&&(0,t.jsxs)($,{size:"xs",variant:"outline",className:"mt-2 font-normal",onClick:()=>l.openApplication("terminal"),children:[(0,t.jsx)(re,{className:"h-3.5 w-3.5 mr-1.5"}),(0,t.jsx)("span",{children:"Open terminal"})]}),n&&(0,t.jsx)(N,{errors:[...F,...Q],cellId:n})]},"syntax-unknown"))}if(x.length>0&&v.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:x.flatMap(Bt)}),n&&(0,t.jsx)(N,{errors:x,cellId:n}),(0,t.jsxs)(I,{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)(A,{href:"https://links.marimo.app/errors-setup",children:["Learn more at our docs"," ",(0,t.jsx)(T,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"setup-refs")),y.length>0&&v.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:y.flatMap(Qt)}),n&&(0,t.jsx)(N,{errors:y,cellId:n}),(0,t.jsxs)(I,{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)(A,{href:"https://links.marimo.app/errors-cycles",children:["Learn more at our docs"," ",(0,t.jsx)(T,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"cycle")),w.length>0){let z=w[0].name;v.push((0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground font-medium",children:"This cell redefines variables from other cells."}),w.map(Ot),n&&(0,t.jsx)(N,{errors:w,cellId:n}),(0,t.jsxs)(I,{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)(te,{className:"inline",children:["_",z]}),"). to make them private to this cell."]}),(0,t.jsxs)("p",{className:"py-2",children:[(0,t.jsxs)(A,{href:"https://links.marimo.app/errors-multiple-definitions",children:["Learn more at our docs"," ",(0,t.jsx)(T,{size:"0.75rem",className:"inline"})]}),"."]})]}),(0,t.jsx)(I,{title:"Need a scratchpad?",children:(0,t.jsxs)("div",{className:"flex flex-row gap-2 items-center",children:[(0,t.jsxs)($,{size:"xs",variant:"link",className:"my-2 font-normal mx-0 px-0",onClick:xe,children:[(0,t.jsx)(ke,{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 _.length>0&&v.push((0,t.jsxs)("div",{children:[_.map(Ht),n&&(0,t.jsx)(N,{errors:_,cellId:n}),(0,t.jsxs)(I,{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)(A,{href:"https://links.marimo.app/errors-import-star",children:["Learn more at our docs"," ",(0,t.jsx)(T,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"import-star")),L.length>0&&v.push((0,t.jsxs)("div",{children:[L.map(Ut),n&&(0,t.jsx)(N,{errors:L,cellId:n})]},"interruption")),C.length>0&&v.push((0,t.jsxs)("ul",{children:[C.map(Jt),C.some(Rt)&&(0,t.jsx)(I,{children:"Fix the error in the mentioned cells, or handle the exceptions with try/except blocks."}),n&&(0,t.jsx)(N,{errors:C,cellId:n})]},"exception")),S.length>0&&v.push((0,t.jsxs)("ul",{children:[S.map(Gt),n&&(0,t.jsx)(N,{errors:S,cellId:n}),(0,t.jsx)(I,{children:S.some(Kt)?"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,t.jsxs)("div",{children:[W.map(Xt),n&&(0,t.jsx)(N,{errors:W,cellId:n})]},"internal")),V.length>0&&v.push((0,t.jsxs)("div",{children:[V.map(Yt),n&&(0,t.jsx)(N,{errors:V,cellId:n})]},"ancestor-prevented")),B.length>0&&v.push((0,t.jsxs)("div",{children:[B.map(Zt),n&&(0,t.jsx)(N,{errors:B,cellId:n})]},"ancestor-stopped")),D.length>0&&v.push((0,t.jsxs)("div",{children:[D.map(er),n&&(0,t.jsx)(N,{errors:D,cellId:n,className:"mt-2.5"})]},"sql-errors")),v},O=`font-code font-medium tracking-wide ${o}`,q;e[17]!==O||e[18]!==a?(q=(0,t.jsx)(Re,{className:O,children:a}),e[17]=O,e[18]=a,e[19]=q):q=e[19];let je=q;m=Ge,f=c,e[20]===i?u=e[21]:(u=Y("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=je,p="flex flex-col gap-8",d=fe(),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,t.jsx)("div",{children:(0,t.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,t.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 gt(r){return r.type==="interruption"}function yt(r){return r.type==="internal"}function vt(r){return r.type==="ancestor-prevented"}function Nt(r){return r.type==="ancestor-stopped"}function bt(r){return r.type==="sql-error"}function wt(r){return r.type==="exception"}function kt(r){return r.type==="setup-refs"}function It(r){return r.type==="cycle"}function $t(r){return r.type==="multiple-defs"}function _t(r){return r.type==="import-star"}function Ft(r){return r.type==="interruption"}function At(r){return r.type==="exception"}function Tt(r){return r.type==="strict-exception"}function Ct(r){return r.type==="internal"}function St(r){return r.type==="ancestor-prevented"}function Mt(r){return r.type==="ancestor-stopped"}function qt(r){return r.type==="syntax"}function zt(r){return r.type==="unknown"}function Et(r){return r.type==="sql-error"}function Pt(r){return r.msg.includes("!pip")}function Lt(r){return r.msg.includes("use os.subprocess")}function Wt(r,e){return(0,t.jsx)("pre",{children:k(r.msg,`syntax-${e}`)},`syntax-${e}`)}function Vt(r,e){return(0,t.jsx)("pre",{children:k(r.msg,`unknown-${e}`)},`unknown-${e}`)}function Bt(r,e){return r.edges_with_vars.map((s,n)=>(0,t.jsxs)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:[(0,t.jsx)(b,{cellId:s[0]}),(0,t.jsxs)("span",{className:"text-muted-foreground",children:[": "," ",s[1].length===1?s[1][0]:s[1].join(", ")]})]},`setup-refs-${e}-${n}`))}function Qt(r,e){return r.edges_with_vars.map((s,n)=>(0,t.jsxs)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:[(0,t.jsx)(b,{cellId:s[0]}),(0,t.jsxs)("span",{className:"text-muted-foreground",children:[" -> ",s[1].length===1?s[1][0]:s[1].join(", ")," -> "]}),(0,t.jsx)(b,{cellId:s[2]})]},`cycle-${e}-${n}`))}function Dt(r,e){return(0,t.jsx)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:(0,t.jsx)(b,{cellId:r})},`cell-${e}`)}function Ot(r,e){return(0,t.jsxs)(P.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(Dt)})]},`multiple-defs-${e}`)}function Ht(r,e){return(0,t.jsx)("p",{className:"text-muted-foreground",children:r.msg},`import-star-${e}`)}function Ut(r,e){return(0,t.jsx)("p",{children:"This cell was interrupted and needs to be re-run."},`interruption-${e}`)}function Jt(r,e){return r.exception_type==="NameError"&&r.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)(te,{className:"inline",children:"mo"}),") is required for Markdown, SQL, and UI elements."]})]})},`exception-${e}`):r.exception_type==="NameError"&&r.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:r.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)(A,{href:"https://links.marimo.app/local-variables",children:["docs"," ",(0,t.jsx)(T,{size:"0.75rem",className:"inline"})]}),")."]}),(0,t.jsx)("div",{className:"text-muted-foreground mt-2",children:"See the console area for a traceback."})]})},`exception-${e}`):(0,t.jsx)("li",{className:"my-2",children:r.raising_cell==null?(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground",children:k(r.msg,`exception-${e}`)}),(0,t.jsx)("div",{className:"text-muted-foreground mt-2",children:"See the console area for a traceback."})]}):(0,t.jsxs)("div",{children:[k(r.msg,`exception-${e}`),(0,t.jsx)(b,{cellId:r.raising_cell})]})},`exception-${e}`)}function Rt(r){return r.raising_cell!=null}function Gt(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)(b,{cellId:r.blamed_cell})]})},`strict-exception-${e}`)}function Kt(r){return r.blamed_cell!=null}function Xt(r,e){return(0,t.jsx)("p",{children:r.msg},`internal-${e}`)}function Yt(r,e){return(0,t.jsxs)("div",{children:[r.msg,r.blamed_cell==null?(0,t.jsxs)("span",{children:["(",(0,t.jsx)(b,{cellId:r.raising_cell}),")"]}):(0,t.jsxs)("span",{children:["(",(0,t.jsx)(b,{cellId:r.raising_cell}),"\xA0blames\xA0",(0,t.jsx)(b,{cellId:r.blamed_cell}),")"]})]},`ancestor-prevented-${e}`)}function Zt(r,e){return(0,t.jsxs)("div",{children:[r.msg,(0,t.jsx)(b,{cellId:r.raising_cell})]},`ancestor-stopped-${e}`)}function er(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{re as a,oe as i,ft as n,me as r,jt as t};
@@ -1 +1 @@
1
- import{s as v}from"./chunk-LvLJmgfZ.js";import{p as x,u as j}from"./useEvent-DlWF5OMa.js";import{t as _}from"./react-BGmjiNul.js";import{Fr as u,Pr as w}from"./cells-KYKWFk6C.js";import{t as y}from"./compiler-runtime-DeeZ7FnK.js";import{o as N}from"./utils-CJJIceVn.js";import{t as R}from"./jsx-runtime-DN_bIXfG.js";import{t as z}from"./mode-CK5Oq-Jz.js";import{t as C}from"./usePress-C2LPFxyv.js";import{t as F}from"./copy-icon-B69c-352.js";import{t as E}from"./purify.es-N-2faAGj.js";import{t as H}from"./useRunCells-wXhl9zOP.js";var k=y(),m=v(_(),1),s=v(R(),1);const M=e=>{let t=(0,k.c)(16),r,a,i;t[0]===e?(r=t[1],a=t[2],i=t[3]):({href:a,children:r,...i}=e,t[0]=e,t[1]=r,t[2]=a,t[3]=i);let o=(0,m.useRef)(null),l;t[4]===a?l=t[5]:(l=()=>{let d=new URL(globalThis.location.href);d.hash=a,globalThis.history.pushState({},"",d.toString()),globalThis.dispatchEvent(new HashChangeEvent("hashchange"));let S=a.slice(1),A=document.getElementById(S);A&&A.scrollIntoView({behavior:"smooth",block:"start"})},t[4]=a,t[5]=l);let n=l,c;t[6]===n?c=t[7]:(c={onPress:()=>{n()}},t[6]=n,t[7]=c);let{pressProps:b}=C(c),f;t[8]===n?f=t[9]:(f=d=>{d.preventDefault(),n()},t[8]=n,t[9]=f);let g=f,h;return t[10]!==r||t[11]!==g||t[12]!==a||t[13]!==b||t[14]!==i?(h=(0,s.jsx)("a",{ref:o,href:a,...b,onClick:g,...i,children:r}),t[10]=r,t[11]=g,t[12]=a,t[13]=b,t[14]=i,t[15]=h):h=t[15],h};var T=x(e=>{let t=e(H),r=e(N);if(t||r)return!1;let a=!0;try{a=z()==="read"}catch{return!0}return!a});function L(){return j(T)}var p="data-temp-href-target";E.addHook("beforeSanitizeAttributes",e=>{e.tagName==="A"&&(e.hasAttribute("target")||e.setAttribute("target","_self"),e.hasAttribute("target")&&e.setAttribute(p,e.getAttribute("target")||""))}),E.addHook("afterSanitizeAttributes",e=>{e.tagName==="A"&&e.hasAttribute(p)&&(e.setAttribute("target",e.getAttribute(p)||""),e.removeAttribute(p),e.getAttribute("target")==="_blank"&&e.setAttribute("rel","noopener noreferrer"))});function O(e){let t={USE_PROFILES:{html:!0,svg:!0,mathMl:!0},FORCE_BODY:!0,CUSTOM_ELEMENT_HANDLING:{tagNameCheck:/^(marimo-[A-Za-z][\w-]*|iconify-icon)$/,attributeNameCheck:/^[A-Za-z][\w-]*$/},SAFE_FOR_XML:!e.includes("marimo-mermaid")};return E.sanitize(e,t)}var I=y(),D=e=>{if(e instanceof u.Element&&!/^[A-Za-z][\w-]*$/.test(e.name))return m.createElement(m.Fragment)},P=(e,t)=>{if(t instanceof u.Element&&t.name==="body"){if((0,m.isValidElement)(e)&&"props"in e){let r=e.props.children;return(0,s.jsx)(s.Fragment,{children:r})}return}},V=(e,t)=>{if(t instanceof u.Element&&t.name==="html"){if((0,m.isValidElement)(e)&&"props"in e){let r=e.props.children;return(0,s.jsx)(s.Fragment,{children:r})}return}},W=e=>{if(e instanceof u.Element&&e.attribs&&e.name==="iframe"){let t=document.createElement("iframe");return Object.entries(e.attribs).forEach(([r,a])=>{r.startsWith('"')&&r.endsWith('"')&&(r=r.slice(1,-1)),t.setAttribute(r,a)}),(0,s.jsx)("div",{dangerouslySetInnerHTML:{__html:t.outerHTML}})}},$=e=>{if(e instanceof u.Element&&e.name==="script"){let t=e.attribs.src;if(!t)return;if(!document.querySelector(`script[src="${t}"]`)){let r=document.createElement("script");r.src=t,document.head.append(r)}return(0,s.jsx)(s.Fragment,{})}},U=(e,t)=>{if(t instanceof u.Element&&t.name==="a"){let r=t.attribs.href;if(r!=null&&r.startsWith("#")&&!r.startsWith("#code/")){let a=null;return(0,m.isValidElement)(e)&&"props"in e&&(a=e.props.children),(0,s.jsx)(M,{href:r,...t.attribs,children:a})}}},Z=(e,t,r)=>{var a,i;if(t instanceof u.Element&&t.name==="div"&&((i=(a=t.attribs)==null?void 0:a.class)!=null&&i.includes("codehilite")))return(0,s.jsx)(B,{children:e},r)},B=e=>{let t=(0,I.c)(3),{children:r}=e,a=(0,m.useRef)(null),i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,s.jsx)("div",{className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity",children:(0,s.jsx)(F,{tooltip:!1,className:"p-1",value:()=>{var n;let l=(n=a.current)==null?void 0:n.firstChild;return l&&l.textContent||""}})}),t[0]=i):i=t[0];let o;return t[1]===r?o=t[2]:(o=(0,s.jsxs)("div",{className:"relative group codehilite-wrapper",ref:a,children:[r,i]}),t[1]=r,t[2]=o),o};const q=({html:e,additionalReplacements:t=[],alwaysSanitizeHtml:r=!0})=>(0,s.jsx)(G,{html:e,alwaysSanitizeHtml:r,additionalReplacements:t});var G=({html:e,additionalReplacements:t=[],alwaysSanitizeHtml:r})=>{let a=L();return X({html:(0,m.useMemo)(()=>r||a?O(e):e,[e,r,a]),additionalReplacements:t})};function X({html:e,additionalReplacements:t=[]}){let r=[D,W,$,...t],a=[Z,U,P,V];return w(e,{replace:(i,o)=>{for(let l of r){let n=l(i,o);if(n)return n}return i},transform:(i,o,l)=>{for(let n of a){let c=n(i,o,l);if(c)return c}return i}})}export{q as t};
1
+ import{s as v}from"./chunk-LvLJmgfZ.js";import{p as x,u as j}from"./useEvent-DlWF5OMa.js";import{t as _}from"./react-BGmjiNul.js";import{Fr as w,Ir as u}from"./cells-Cv9PtwL9.js";import{t as y}from"./compiler-runtime-DeeZ7FnK.js";import{o as N}from"./utils-CJJIceVn.js";import{t as R}from"./jsx-runtime-DN_bIXfG.js";import{t as z}from"./mode-PeuS_Lp-.js";import{t as C}from"./usePress-DTwIUo40.js";import{t as F}from"./copy-icon-jWsqdLn1.js";import{t as E}from"./purify.es-N-2faAGj.js";import{t as H}from"./useRunCells-B9Xr4tcH.js";var k=y(),m=v(_(),1),s=v(R(),1);const M=e=>{let t=(0,k.c)(16),r,a,i;t[0]===e?(r=t[1],a=t[2],i=t[3]):({href:a,children:r,...i}=e,t[0]=e,t[1]=r,t[2]=a,t[3]=i);let o=(0,m.useRef)(null),l;t[4]===a?l=t[5]:(l=()=>{let d=new URL(globalThis.location.href);d.hash=a,globalThis.history.pushState({},"",d.toString()),globalThis.dispatchEvent(new HashChangeEvent("hashchange"));let S=a.slice(1),A=document.getElementById(S);A&&A.scrollIntoView({behavior:"smooth",block:"start"})},t[4]=a,t[5]=l);let n=l,c;t[6]===n?c=t[7]:(c={onPress:()=>{n()}},t[6]=n,t[7]=c);let{pressProps:b}=C(c),f;t[8]===n?f=t[9]:(f=d=>{d.preventDefault(),n()},t[8]=n,t[9]=f);let g=f,h;return t[10]!==r||t[11]!==g||t[12]!==a||t[13]!==b||t[14]!==i?(h=(0,s.jsx)("a",{ref:o,href:a,...b,onClick:g,...i,children:r}),t[10]=r,t[11]=g,t[12]=a,t[13]=b,t[14]=i,t[15]=h):h=t[15],h};var T=x(e=>{let t=e(H),r=e(N);if(t||r)return!1;let a=!0;try{a=z()==="read"}catch{return!0}return!a});function L(){return j(T)}var p="data-temp-href-target";E.addHook("beforeSanitizeAttributes",e=>{e.tagName==="A"&&(e.hasAttribute("target")||e.setAttribute("target","_self"),e.hasAttribute("target")&&e.setAttribute(p,e.getAttribute("target")||""))}),E.addHook("afterSanitizeAttributes",e=>{e.tagName==="A"&&e.hasAttribute(p)&&(e.setAttribute("target",e.getAttribute(p)||""),e.removeAttribute(p),e.getAttribute("target")==="_blank"&&e.setAttribute("rel","noopener noreferrer"))});function O(e){let t={USE_PROFILES:{html:!0,svg:!0,mathMl:!0},FORCE_BODY:!0,CUSTOM_ELEMENT_HANDLING:{tagNameCheck:/^(marimo-[A-Za-z][\w-]*|iconify-icon)$/,attributeNameCheck:/^[A-Za-z][\w-]*$/},SAFE_FOR_XML:!e.includes("marimo-mermaid")};return E.sanitize(e,t)}var I=y(),D=e=>{if(e instanceof u.Element&&!/^[A-Za-z][\w-]*$/.test(e.name))return m.createElement(m.Fragment)},V=(e,t)=>{if(t instanceof u.Element&&t.name==="body"){if((0,m.isValidElement)(e)&&"props"in e){let r=e.props.children;return(0,s.jsx)(s.Fragment,{children:r})}return}},W=(e,t)=>{if(t instanceof u.Element&&t.name==="html"){if((0,m.isValidElement)(e)&&"props"in e){let r=e.props.children;return(0,s.jsx)(s.Fragment,{children:r})}return}},$=e=>{if(e instanceof u.Element&&e.attribs&&e.name==="iframe"){let t=document.createElement("iframe");return Object.entries(e.attribs).forEach(([r,a])=>{r.startsWith('"')&&r.endsWith('"')&&(r=r.slice(1,-1)),t.setAttribute(r,a)}),(0,s.jsx)("div",{dangerouslySetInnerHTML:{__html:t.outerHTML}})}},P=e=>{if(e instanceof u.Element&&e.name==="script"){let t=e.attribs.src;if(!t)return;if(!document.querySelector(`script[src="${t}"]`)){let r=document.createElement("script");r.src=t,document.head.append(r)}return(0,s.jsx)(s.Fragment,{})}},U=(e,t)=>{if(t instanceof u.Element&&t.name==="a"){let r=t.attribs.href;if(r!=null&&r.startsWith("#")&&!r.startsWith("#code/")){let a=null;return(0,m.isValidElement)(e)&&"props"in e&&(a=e.props.children),(0,s.jsx)(M,{href:r,...t.attribs,children:a})}}},Z=(e,t,r)=>{var a,i;if(t instanceof u.Element&&t.name==="div"&&((i=(a=t.attribs)==null?void 0:a.class)!=null&&i.includes("codehilite")))return(0,s.jsx)(B,{children:e},r)},B=e=>{let t=(0,I.c)(3),{children:r}=e,a=(0,m.useRef)(null),i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,s.jsx)("div",{className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity",children:(0,s.jsx)(F,{tooltip:!1,className:"p-1",value:()=>{var n;let l=(n=a.current)==null?void 0:n.firstChild;return l&&l.textContent||""}})}),t[0]=i):i=t[0];let o;return t[1]===r?o=t[2]:(o=(0,s.jsxs)("div",{className:"relative group codehilite-wrapper",ref:a,children:[r,i]}),t[1]=r,t[2]=o),o};const q=({html:e,additionalReplacements:t=[],alwaysSanitizeHtml:r=!0})=>(0,s.jsx)(G,{html:e,alwaysSanitizeHtml:r,additionalReplacements:t});var G=({html:e,additionalReplacements:t=[],alwaysSanitizeHtml:r})=>{let a=L();return X({html:(0,m.useMemo)(()=>r||a?O(e):e,[e,r,a]),additionalReplacements:t})};function X({html:e,additionalReplacements:t=[]}){let r=[D,$,P,...t],a=[Z,U,V,W];return w(e,{replace:(i,o)=>{for(let l of r){let n=l(i,o);if(n)return n}return i},transform:(i,o,l)=>{for(let n of a){let c=n(i,o,l);if(c)return c}return i}})}export{q as t};
@@ -0,0 +1 @@
1
+ import{s as ee}from"./chunk-LvLJmgfZ.js";import{t as te}from"./react-BGmjiNul.js";import{P as re,R as ne,z as oe}from"./input-B80Yt1uu.js";import{A as q,M as _,N as ie,P as v,T as le,c as ce,j as w,k as se,l as ae,p as ue,w as de,x as fe,z as R}from"./usePress-DTwIUo40.js";import{t as he}from"./context-DHfVoQfl.js";var f=ee(te(),1),pe=(0,f.createContext)(null);(0,f.createContext)(null),(0,f.createContext)(null),(0,f.createContext)(null),(0,f.createContext)(null);var Ne=(0,f.createContext)({}),be=(0,f.createContext)(null);(0,f.createContext)(null);var me=class{get currentNode(){return this._currentNode}set currentNode(e){if(!q(this.root,e))throw Error("Cannot set currentNode to a node that is not contained by the root node.");let t=[],r=e,n=e;for(this._currentNode=e;r&&r!==this.root;)if(r.nodeType===Node.DOCUMENT_FRAGMENT_NODE){let i=r,l=this._doc.createTreeWalker(i,this.whatToShow,{acceptNode:this._acceptNode});t.push(l),l.currentNode=n,this._currentSetFor.add(l),r=n=i.host}else r=r.parentNode;let o=this._doc.createTreeWalker(this.root,this.whatToShow,{acceptNode:this._acceptNode});t.push(o),o.currentNode=n,this._currentSetFor.add(o),this._walkerStack=t}get doc(){return this._doc}firstChild(){let e=this.currentNode,t=this.nextNode();return q(e,t)?(t&&(this.currentNode=t),t):(this.currentNode=e,null)}lastChild(){let e=this._walkerStack[0].lastChild();return e&&(this.currentNode=e),e}nextNode(){var t;let e=this._walkerStack[0].nextNode();if(e){if(e.shadowRoot){let r;if(typeof this.filter=="function"?r=this.filter(e):(t=this.filter)!=null&&t.acceptNode&&(r=this.filter.acceptNode(e)),r===NodeFilter.FILTER_ACCEPT)return this.currentNode=e,e;let n=this.nextNode();return n&&(this.currentNode=n),n}return e&&(this.currentNode=e),e}else if(this._walkerStack.length>1){this._walkerStack.shift();let r=this.nextNode();return r&&(this.currentNode=r),r}else return null}previousNode(){var r;let e=this._walkerStack[0];if(e.currentNode===e.root){if(this._currentSetFor.has(e))if(this._currentSetFor.delete(e),this._walkerStack.length>1){this._walkerStack.shift();let n=this.previousNode();return n&&(this.currentNode=n),n}else return null;return null}let t=e.previousNode();if(t){if(t.shadowRoot){let n;if(typeof this.filter=="function"?n=this.filter(t):(r=this.filter)!=null&&r.acceptNode&&(n=this.filter.acceptNode(t)),n===NodeFilter.FILTER_ACCEPT)return t&&(this.currentNode=t),t;let o=this.lastChild();return o&&(this.currentNode=o),o}return t&&(this.currentNode=t),t}else if(this._walkerStack.length>1){this._walkerStack.shift();let n=this.previousNode();return n&&(this.currentNode=n),n}else return null}nextSibling(){return null}previousSibling(){return null}parentNode(){return null}constructor(e,t,r,n){this._walkerStack=[],this._currentSetFor=new Set,this._acceptNode=i=>{var l;if(i.nodeType===Node.ELEMENT_NODE){let s=i.shadowRoot;if(s){let u=this._doc.createTreeWalker(s,this.whatToShow,{acceptNode:this._acceptNode});return this._walkerStack.unshift(u),NodeFilter.FILTER_ACCEPT}else{if(typeof this.filter=="function")return this.filter(i);if((l=this.filter)!=null&&l.acceptNode)return this.filter.acceptNode(i);if(this.filter===null)return NodeFilter.FILTER_ACCEPT}}return NodeFilter.FILTER_SKIP},this._doc=e,this.root=t,this.filter=n??null,this.whatToShow=r??NodeFilter.SHOW_ALL,this._currentNode=t,this._walkerStack.unshift(e.createTreeWalker(t,r,this._acceptNode));let o=t.shadowRoot;if(o){let i=this._doc.createTreeWalker(o,this.whatToShow,{acceptNode:this._acceptNode});this._walkerStack.unshift(i)}}};function ve(e,t,r,n){return ie()?new me(e,t,r,n):e.createTreeWalker(t,r,n)}function Ee(e,t){let r=(0,f.useRef)(!0),n=(0,f.useRef)(null),o=ue(e);(0,f.useEffect)(()=>(r.current=!0,()=>{r.current=!1}),[]),(0,f.useEffect)(()=>{let i=n.current;r.current?r.current=!1:(!i||t.some((l,s)=>!Object.is(l,i[s])))&&o(),n.current=t},t)}function L(e,t){if(!e)return!1;let r=window.getComputedStyle(e),n=/(auto|scroll)/.test(r.overflow+r.overflowX+r.overflowY);return n&&t&&(n=e.scrollHeight!==e.clientHeight||e.scrollWidth!==e.clientWidth),n}function Te(e,t){let r=e;for(L(r,t)&&(r=r.parentElement);r&&!L(r,t);)r=r.parentElement;return r||document.scrollingElement||document.documentElement}function ge(e,t){let r=[];for(;e&&e!==document.documentElement;)L(e,t)&&r.push(e),e=e.parentElement;return r}function we(e){return de()?e.metaKey:e.ctrlKey}var Re=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function ye(e){return e instanceof HTMLInputElement&&!Re.has(e.type)||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}var Ce=0,M=new Map;function Se(e){let[t,r]=(0,f.useState)();return R(()=>{if(!e)return;let n=M.get(e);if(n)r(n.element.id);else{let o=`react-aria-description-${Ce++}`;r(o);let i=document.createElement("div");i.id=o,i.style.display="none",i.textContent=e,document.body.appendChild(i),n={refCount:0,element:i},M.set(e,n)}return n.refCount++,()=>{n&&--n.refCount===0&&(n.element.remove(),M.delete(e))}},[e]),{"aria-describedby":e?t:void 0}}function B(e,t){let r=U(e,t,"left"),n=U(e,t,"top"),o=t.offsetWidth,i=t.offsetHeight,l=e.scrollLeft,s=e.scrollTop,{borderTopWidth:u,borderLeftWidth:c,scrollPaddingTop:a,scrollPaddingRight:h,scrollPaddingBottom:d,scrollPaddingLeft:N}=getComputedStyle(e),m=l+parseInt(c,10),k=s+parseInt(u,10),S=m+e.clientWidth,H=k+e.clientHeight,O=parseInt(a,10)||0,D=parseInt(d,10)||0,z=parseInt(h,10)||0,j=parseInt(N,10)||0;r<=l+j?l=r-parseInt(c,10)-j:r+o>S-z&&(l+=r+o-S+z),n<=k+O?s=n-parseInt(u,10)-O:n+i>H-D&&(s+=n+i-H+D),e.scrollLeft=l,e.scrollTop=s}function U(e,t,r){let n=r==="left"?"offsetLeft":"offsetTop",o=0;for(;t.offsetParent&&(o+=t[n],t.offsetParent!==e);){if(t.offsetParent.contains(e)){o-=e[n];break}t=t.offsetParent}return o}function _e(e,t){if(e&&document.contains(e)){let l=document.scrollingElement||document.documentElement,s=window.getComputedStyle(l).overflow==="hidden";if(s){let u=ge(e);s||u.push(l);for(let c of u)B(c,e)}else{var r;let{left:u,top:c}=e.getBoundingClientRect();e==null||(r=e.scrollIntoView)==null||r.call(e,{block:"nearest"});let{left:a,top:h}=e.getBoundingClientRect();if(Math.abs(u-a)>1||Math.abs(c-h)>1){var n,o,i;t==null||(o=t.containingElement)==null||(n=o.scrollIntoView)==null||n.call(o,{block:"center",inline:"center"}),(i=e.scrollIntoView)==null||i.call(e,{block:"nearest"})}}}}var P=new Map;function ke(e){let{locale:t}=he(),r=t+(e?Object.entries(e).sort((o,i)=>o[0]<i[0]?-1:1).join():"");if(P.has(r))return P.get(r);let n=new Intl.Collator(t,e);return P.set(r,n),n}var V=f.createContext(null),I="react-aria-focus-scope-restore",p=null;function xe(e){let{children:t,contain:r,restoreFocus:n,autoFocus:o}=e,i=(0,f.useRef)(null),l=(0,f.useRef)(null),s=(0,f.useRef)([]),{parentNode:u}=(0,f.useContext)(V)||{},c=(0,f.useMemo)(()=>new K({scopeRef:s}),[s]);R(()=>{let d=u||b.root;if(b.getTreeNode(d.scopeRef)&&p&&!F(p,d.scopeRef)){let N=b.getTreeNode(p);N&&(d=N)}d.addChild(c),b.addNode(c)},[c,u]),R(()=>{let d=b.getTreeNode(s);d&&(d.contain=!!r)},[r]),R(()=>{var k;let d=(k=i.current)==null?void 0:k.nextSibling,N=[],m=S=>S.stopPropagation();for(;d&&d!==l.current;)N.push(d),d.addEventListener(I,m),d=d.nextSibling;return s.current=N,()=>{for(let S of N)S.removeEventListener(I,m)}},[t]),Ae(s,n,r),Me(s,r),We(s,n,r),Ie(s,o),(0,f.useEffect)(()=>{let d=w(v(s.current?s.current[0]:void 0)),N=null;if(g(d,s.current)){for(let m of b.traverse())m.scopeRef&&g(d,m.scopeRef.current)&&(N=m);N===b.getTreeNode(s)&&(p=N.scopeRef)}},[s]),R(()=>()=>{var N,m;let d=((m=(N=b.getTreeNode(s))==null?void 0:N.parent)==null?void 0:m.scopeRef)??null;(s===p||F(s,p))&&(!d||b.getTreeNode(d))&&(p=d),b.removeTreeNode(s)},[s]);let a=(0,f.useMemo)(()=>Le(s),[]),h=(0,f.useMemo)(()=>({focusManager:a,parentNode:c}),[c,a]);return f.createElement(V.Provider,{value:h},f.createElement("span",{"data-focus-scope-start":!0,hidden:!0,ref:i}),t,f.createElement("span",{"data-focus-scope-end":!0,hidden:!0,ref:l}))}function Le(e){return{focusNext(t={}){let r=e.current,{from:n,tabbable:o,wrap:i,accept:l}=t,s=n||w(v(r[0]??void 0)),u=r[0].previousElementSibling,c=T(C(r),{tabbable:o,accept:l},r);c.currentNode=g(s,r)?s:u;let a=c.nextNode();return!a&&i&&(c.currentNode=u,a=c.nextNode()),a&&E(a,!0),a},focusPrevious(t={}){let r=e.current,{from:n,tabbable:o,wrap:i,accept:l}=t,s=n||w(v(r[0]??void 0)),u=r[r.length-1].nextElementSibling,c=T(C(r),{tabbable:o,accept:l},r);c.currentNode=g(s,r)?s:u;let a=c.previousNode();return!a&&i&&(c.currentNode=u,a=c.previousNode()),a&&E(a,!0),a},focusFirst(t={}){let r=e.current,{tabbable:n,accept:o}=t,i=T(C(r),{tabbable:n,accept:o},r);i.currentNode=r[0].previousElementSibling;let l=i.nextNode();return l&&E(l,!0),l},focusLast(t={}){let r=e.current,{tabbable:n,accept:o}=t,i=T(C(r),{tabbable:n,accept:o},r);i.currentNode=r[r.length-1].nextElementSibling;let l=i.previousNode();return l&&E(l,!0),l}}}function C(e){return e[0].parentElement}function x(e){let t=b.getTreeNode(p);for(;t&&t.scopeRef!==e;){if(t.contain)return!1;t=t.parent}return!0}function Fe(e){var r,n;if(e.checked)return!0;let t=[];return t=e.form?[...((n=(r=e.form)==null?void 0:r.elements)==null?void 0:n.namedItem(e.name))??[]]:[...v(e).querySelectorAll(`input[type="radio"][name="${CSS.escape(e.name)}"]`)].filter(o=>!o.form),t?!t.some(o=>o.checked):!1}function Me(e,t){let r=(0,f.useRef)(void 0),n=(0,f.useRef)(void 0);R(()=>{let o=e.current;if(!t){n.current&&(n.current=(cancelAnimationFrame(n.current),void 0));return}let i=v(o?o[0]:void 0),l=c=>{if(c.key!=="Tab"||c.altKey||c.ctrlKey||c.metaKey||!x(e)||c.isComposing)return;let a=w(i),h=e.current;if(!h||!g(a,h))return;let d=T(C(h),{tabbable:!0},h);if(!a)return;d.currentNode=a;let N=c.shiftKey?d.previousNode():d.nextNode();N||(N=(d.currentNode=c.shiftKey?h[h.length-1].nextElementSibling:h[0].previousElementSibling,c.shiftKey?d.previousNode():d.nextNode())),c.preventDefault(),N&&E(N,!0)},s=c=>{(!p||F(p,e))&&g(_(c),e.current)?(p=e,r.current=_(c)):x(e)&&!y(_(c),e)?r.current?r.current.focus():p&&p.current&&A(p.current):x(e)&&(r.current=_(c))},u=c=>{n.current&&cancelAnimationFrame(n.current),n.current=requestAnimationFrame(()=>{let a=oe(),h=(a==="virtual"||a===null)&&le()&&fe(),d=w(i);if(!h&&d&&x(e)&&!y(d,e)){p=e;let m=_(c);if(m&&m.isConnected){var N;r.current=m,(N=r.current)==null||N.focus()}else p.current&&A(p.current)}})};return i.addEventListener("keydown",l,!1),i.addEventListener("focusin",s,!1),o==null||o.forEach(c=>c.addEventListener("focusin",s,!1)),o==null||o.forEach(c=>c.addEventListener("focusout",u,!1)),()=>{i.removeEventListener("keydown",l,!1),i.removeEventListener("focusin",s,!1),o==null||o.forEach(c=>c.removeEventListener("focusin",s,!1)),o==null||o.forEach(c=>c.removeEventListener("focusout",u,!1))}},[e,t]),R(()=>()=>{n.current&&cancelAnimationFrame(n.current)},[n])}function $(e){return y(e)}function g(e,t){return!e||!t?!1:t.some(r=>r.contains(e))}function y(e,t=null){if(e instanceof Element&&e.closest("[data-react-aria-top-layer]"))return!0;for(let{scopeRef:r}of b.traverse(b.getTreeNode(t)))if(r&&g(e,r.current))return!0;return!1}function Pe(e){return y(e,p)}function F(e,t){var n;let r=(n=b.getTreeNode(t))==null?void 0:n.parent;for(;r;){if(r.scopeRef===e)return!0;r=r.parent}return!1}function E(e,t=!1){if(e!=null&&!t)try{ne(e)}catch{}else if(e!=null)try{e.focus()}catch{}}function G(e,t=!0){let r=e[0].previousElementSibling,n=C(e),o=T(n,{tabbable:t},e);o.currentNode=r;let i=o.nextNode();return t&&!i&&(n=C(e),o=T(n,{tabbable:!1},e),o.currentNode=r,i=o.nextNode()),i}function A(e,t=!0){E(G(e,t))}function Ie(e,t){let r=f.useRef(t);(0,f.useEffect)(()=>{r.current&&(p=e,!g(w(v(e.current?e.current[0]:void 0)),p.current)&&e.current&&A(e.current)),r.current=!1},[e])}function Ae(e,t,r){R(()=>{if(t||r)return;let n=e.current,o=v(n?n[0]:void 0),i=l=>{let s=_(l);g(s,e.current)?p=e:$(s)||(p=null)};return o.addEventListener("focusin",i,!1),n==null||n.forEach(l=>l.addEventListener("focusin",i,!1)),()=>{o.removeEventListener("focusin",i,!1),n==null||n.forEach(l=>l.removeEventListener("focusin",i,!1))}},[e,t,r])}function J(e){let t=b.getTreeNode(p);for(;t&&t.scopeRef!==e;){if(t.nodeToRestore)return!1;t=t.parent}return(t==null?void 0:t.scopeRef)===e}function We(e,t,r){let n=(0,f.useRef)(typeof document<"u"?w(v(e.current?e.current[0]:void 0)):null);R(()=>{let o=e.current,i=v(o?o[0]:void 0);if(!t||r)return;let l=()=>{(!p||F(p,e))&&g(w(i),e.current)&&(p=e)};return i.addEventListener("focusin",l,!1),o==null||o.forEach(s=>s.addEventListener("focusin",l,!1)),()=>{i.removeEventListener("focusin",l,!1),o==null||o.forEach(s=>s.removeEventListener("focusin",l,!1))}},[e,r]),R(()=>{let o=v(e.current?e.current[0]:void 0);if(!t)return;let i=l=>{if(l.key!=="Tab"||l.altKey||l.ctrlKey||l.metaKey||!x(e)||l.isComposing)return;let s=o.activeElement;if(!y(s,e)||!J(e))return;let u=b.getTreeNode(e);if(!u)return;let c=u.nodeToRestore,a=T(o.body,{tabbable:!0});a.currentNode=s;let h=l.shiftKey?a.previousNode():a.nextNode();if((!c||!c.isConnected||c===o.body)&&(c=void 0,u.nodeToRestore=void 0),(!h||!y(h,e))&&c){a.currentNode=c;do h=l.shiftKey?a.previousNode():a.nextNode();while(y(h,e));l.preventDefault(),l.stopPropagation(),h?E(h,!0):$(c)?E(c,!0):s.blur()}};return r||o.addEventListener("keydown",i,!0),()=>{r||o.removeEventListener("keydown",i,!0)}},[e,t,r]),R(()=>{let o=v(e.current?e.current[0]:void 0);if(!t)return;let i=b.getTreeNode(e);if(i)return i.nodeToRestore=n.current??void 0,()=>{let l=b.getTreeNode(e);if(!l)return;let s=l.nodeToRestore,u=w(o);if(t&&s&&(u&&y(u,e)||u===o.body&&J(e))){let c=b.clone();requestAnimationFrame(()=>{if(o.activeElement===o.body){let a=c.getTreeNode(e);for(;a;){if(a.nodeToRestore&&a.nodeToRestore.isConnected){X(a.nodeToRestore);return}a=a.parent}for(a=c.getTreeNode(e);a;){if(a.scopeRef&&a.scopeRef.current&&b.getTreeNode(a.scopeRef)){X(G(a.scopeRef.current,!0));return}a=a.parent}}})}}},[e,t])}function X(e){e.dispatchEvent(new CustomEvent(I,{bubbles:!0,cancelable:!0}))&&E(e)}function T(e,t,r){let n=t!=null&&t.tabbable?ae:ce,o=v((e==null?void 0:e.nodeType)===Node.ELEMENT_NODE?e:null),i=ve(o,e||o,NodeFilter.SHOW_ELEMENT,{acceptNode(l){var s;return t!=null&&((s=t.from)!=null&&s.contains(l))||t!=null&&t.tabbable&&l.tagName==="INPUT"&&l.getAttribute("type")==="radio"&&(!Fe(l)||i.currentNode.tagName==="INPUT"&&i.currentNode.type==="radio"&&i.currentNode.name===l.name)?NodeFilter.FILTER_REJECT:n(l)&&(!r||g(l,r))&&(!(t!=null&&t.accept)||t.accept(l))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});return t!=null&&t.from&&(i.currentNode=t.from),i}function Ke(e,t={}){return{focusNext(r={}){let n=e.current;if(!n)return null;let{from:o,tabbable:i=t.tabbable,wrap:l=t.wrap,accept:s=t.accept}=r,u=o||w(v(n)),c=T(n,{tabbable:i,accept:s});n.contains(u)&&(c.currentNode=u);let a=c.nextNode();return!a&&l&&(c.currentNode=n,a=c.nextNode()),a&&E(a,!0),a},focusPrevious(r=t){let n=e.current;if(!n)return null;let{from:o,tabbable:i=t.tabbable,wrap:l=t.wrap,accept:s=t.accept}=r,u=o||w(v(n)),c=T(n,{tabbable:i,accept:s});if(n.contains(u))c.currentNode=u;else{let h=W(c);return h&&E(h,!0),h??null}let a=c.previousNode();if(!a&&l){c.currentNode=n;let h=W(c);if(!h)return null;a=h}return a&&E(a,!0),a??null},focusFirst(r=t){let n=e.current;if(!n)return null;let{tabbable:o=t.tabbable,accept:i=t.accept}=r,l=T(n,{tabbable:o,accept:i}).nextNode();return l&&E(l,!0),l},focusLast(r=t){let n=e.current;if(!n)return null;let{tabbable:o=t.tabbable,accept:i=t.accept}=r,l=W(T(n,{tabbable:o,accept:i}));return l&&E(l,!0),l??null}}}function W(e){let t,r;do r=e.lastChild(),r&&(t=r);while(r);return t}var He=class Z{get size(){return this.fastMap.size}getTreeNode(t){return this.fastMap.get(t)}addTreeNode(t,r,n){let o=this.fastMap.get(r??null);if(!o)return;let i=new K({scopeRef:t});o.addChild(i),i.parent=o,this.fastMap.set(t,i),n&&(i.nodeToRestore=n)}addNode(t){this.fastMap.set(t.scopeRef,t)}removeTreeNode(t){if(t===null)return;let r=this.fastMap.get(t);if(!r)return;let n=r.parent;for(let i of this.traverse())i!==r&&r.nodeToRestore&&i.nodeToRestore&&r.scopeRef&&r.scopeRef.current&&g(i.nodeToRestore,r.scopeRef.current)&&(i.nodeToRestore=r.nodeToRestore);let o=r.children;n&&(n.removeChild(r),o.size>0&&o.forEach(i=>n&&n.addChild(i))),this.fastMap.delete(r.scopeRef)}*traverse(t=this.root){if(t.scopeRef!=null&&(yield t),t.children.size>0)for(let r of t.children)yield*this.traverse(r)}clone(){var r;let t=new Z;for(let n of this.traverse())t.addTreeNode(n.scopeRef,((r=n.parent)==null?void 0:r.scopeRef)??null,n.nodeToRestore);return t}constructor(){this.fastMap=new Map,this.root=new K({scopeRef:null}),this.fastMap.set(null,this.root)}},K=class{addChild(e){this.children.add(e),e.parent=this}removeChild(e){this.children.delete(e),e.parent=void 0}constructor(e){this.children=new Set,this.contain=!1,this.scopeRef=e.scopeRef}},b=new He,Y={border:0,clip:"rect(0 0 0 0)",clipPath:"inset(50%)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap"};function Q(e={}){let{style:t,isFocusable:r}=e,[n,o]=(0,f.useState)(!1),{focusWithinProps:i}=re({isDisabled:!r,onFocusWithinChange:s=>o(s)}),l=(0,f.useMemo)(()=>n?t:t?{...Y,...t}:Y,[n]);return{visuallyHiddenProps:{...i,style:l}}}function Oe(e){let{children:t,elementType:r="div",isFocusable:n,style:o,...i}=e,{visuallyHiddenProps:l}=Q(e);return f.createElement(r,se(i,l),t)}export{be as _,T as a,B as c,we as d,ye as f,pe as g,Ee as h,xe as i,_e as l,L as m,Q as n,Ke as o,Te as p,Pe as r,ke as s,Oe as t,Se as u,Ne as v};
@@ -1,4 +1,4 @@
1
- var Un=Object.defineProperty;var Vn=(t,e,a)=>e in t?Un(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a;var $=(t,e,a)=>Vn(t,typeof e!="symbol"?e+"":e,a);import{s as ka,t as qn}from"./chunk-LvLJmgfZ.js";import{f as Rr,i as Nr,l as Bn,n as Wn,o as Jn,u as Kn}from"./useEvent-DlWF5OMa.js";import{t as Yn}from"./react-BGmjiNul.js";import{$n as Mr,$r as Hn,At as Gn,Bn as Qn,Br as Xn,C as Pr,Cn as ei,Kr as ti,Qn as ai,Qr as jr,Sr as ri,Tt as $r,Wr as si,Xn as ni,d as ii,fn as oi,hn as li,i as di,it as Ca,pt as ui,v as Ge,yr as ci}from"./cells-KYKWFk6C.js";import{B as Te,D as pi,E as Lr,H as mi,I as It,J as Dr,L as ee,N as Zr,O as hi,P as Q,R as k,S as fi,T as de,V as Ue,W as Fr,b as Bt,k as N,w as Ve,x as Wt}from"./zod-Cg4WLWh2.js";import{t as Ea}from"./compiler-runtime-DeeZ7FnK.js";import{i as zr}from"./useLifecycle-CmDXEyIC.js";import{d as oe,s as gi}from"./hotkeys-uKX61F1_.js";import{o as yi}from"./config-babG4OBR.js";import{t as vi}from"./jsx-runtime-DN_bIXfG.js";import{t as Qe}from"./button-DuYGqRtX.js";import{t as Ur}from"./cn-C1rgT0yh.js";import{Bt as _i,Jt,St as Kt,Ut as Vr,Vt as bi,Xt as xi,at as qr,ct as wi,lt as Br,qt as Yt,rt as Ta,xt as ki}from"./dist-CAcX026F.js";import{t as Ci}from"./createReducer-DDa-hVe3.js";import{h as Ei,n as Ti,o as Ii,r as Si}from"./dist-DKNOF5xd.js";import{r as Oi,t as Ai}from"./requests-C0HaHO6a.js";import{t as Ia}from"./createLucideIcon-CW2xpJ57.js";import{t as Ri}from"./ai-model-dropdown-LK8Wr5iu.js";import{h as Ni}from"./select-D0g5GnIs.js";import{f as Mi,n as Pi,u as Wr}from"./markdown-renderer-BlG9DgUG.js";import{a as Jr,c as ji,p as $i,r as Li,t as Di}from"./dropdown-menu-BP4_BZLr.js";import{t as Zi}from"./play-BJDBXApx.js";import{n as Fi}from"./spinner-C1czjtp7.js";import{a as zi}from"./state-CP7_TGWl.js";import{a as St,i as yt,o as Ot,r as vt,s as Ui,t as Vi}from"./datasource-JeWYnuIr.js";import{a as qi}from"./dist-HGZzCB0y.js";import{t as Kr}from"./use-toast-Bzf3rpev.js";import{r as Bi}from"./useTheme-DfP1CWaW.js";import{t as Wi}from"./tooltip-CvjcEpZC.js";import{s as Ji}from"./popover-DtnzNVk-.js";import{a as Ki}from"./error-banner-DU5Qb8a8.js";import{n as Yi}from"./useRunCells-wXhl9zOP.js";import{i as Sa}from"./cell-link-CfLJRl3p.js";import{r as Hi,t as Gi}from"./es-KtEicG7U.js";import{n as Oa}from"./renderShortcut-D0Pei-OA.js";import{t as Qi}from"./process-output-DiSW8Nbo.js";import{t as Xi}from"./blob-Dg_vNTSs.js";import{t as eo}from"./useDeleteCell-5kJUaejE.js";import{r as to,t as ao}from"./esm-B3JckBtM.js";import{n as ro}from"./icons-D4lB4En9.js";var so=Ia("at-sign",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]]),no=Ia("send-horizontal",[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]]),io=Ia("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]),Yr="vercel.ai.error",oo=Symbol.for(Yr),Hr,Gr,Xe=class Pn extends(Gr=Error,Hr=oo,Gr){constructor({name:e,message:a,cause:r}){super(a),this[Hr]=!0,this.name=e,this.cause=r}static isInstance(e){return Pn.hasMarker(e,Yr)}static hasMarker(e,a){let r=Symbol.for(a);return typeof e=="object"&&!!e&&r in e&&typeof e[r]=="boolean"&&e[r]===!0}};function Qr(t){return t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:JSON.stringify(t)}var Xr="AI_InvalidArgumentError",es=`vercel.ai.error.${Xr}`,lo=Symbol.for(es),ts,as,uo=class extends(as=Xe,ts=lo,as){constructor({message:t,cause:e,argument:a}){super({name:Xr,message:t,cause:e}),this[ts]=!0,this.argument=a}static isInstance(t){return Xe.hasMarker(t,es)}},rs="AI_JSONParseError",ss=`vercel.ai.error.${rs}`,co=Symbol.for(ss),ns,is,os=class extends(is=Xe,ns=co,is){constructor({text:t,cause:e}){super({name:rs,message:`JSON parsing failed: Text: ${t}.
1
+ var Un=Object.defineProperty;var Vn=(t,e,a)=>e in t?Un(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a;var $=(t,e,a)=>Vn(t,typeof e!="symbol"?e+"":e,a);import{s as ka,t as qn}from"./chunk-LvLJmgfZ.js";import{f as Rr,i as Nr,l as Bn,n as Wn,o as Jn,u as Kn}from"./useEvent-DlWF5OMa.js";import{t as Yn}from"./react-BGmjiNul.js";import{$n as Hn,$r as Mr,Cr as Gn,Et as Pr,Gr as Qn,Vn as Xn,Vr as ei,Zn as ti,at as Ca,br as ai,ei as ri,er as jr,f as si,gn as ni,i as ii,jt as oi,mt as li,pn as di,qr as ui,w as $r,wn as ci,y as Ge}from"./cells-Cv9PtwL9.js";import{B as Te,D as pi,E as Lr,H as mi,I as It,J as Dr,L as ee,N as Zr,O as hi,P as Q,R as k,S as fi,T as de,V as Ue,W as Fr,b as Bt,k as N,w as Ve,x as Wt}from"./zod-Cg4WLWh2.js";import{t as Ea}from"./compiler-runtime-DeeZ7FnK.js";import{i as zr}from"./useLifecycle-CmDXEyIC.js";import{d as oe,s as gi}from"./hotkeys-uKX61F1_.js";import{o as yi}from"./config-DFDEcYvy.js";import{t as vi}from"./jsx-runtime-DN_bIXfG.js";import{t as Qe}from"./button-B8cGZzP5.js";import{t as Ur}from"./cn-C1rgT0yh.js";import{Bt as _i,Jt,St as Kt,Ut as Vr,Vt as bi,Xt as xi,at as qr,ct as wi,lt as Br,qt as Yt,rt as Ta,xt as ki}from"./dist-CAcX026F.js";import{t as Ci}from"./createReducer-DDa-hVe3.js";import{h as Ei,n as Ti,o as Ii,r as Si}from"./dist-DKNOF5xd.js";import{r as Oi,t as Ai}from"./requests-C0HaHO6a.js";import{t as Ia}from"./createLucideIcon-CW2xpJ57.js";import{t as Ri}from"./ai-model-dropdown-CrMTCgo7.js";import{h as Ni}from"./select-D9lTzMzP.js";import{f as Mi,n as Pi,u as Wr}from"./markdown-renderer-DlVqlHOL.js";import{a as Jr,c as ji,p as $i,r as Li,t as Di}from"./dropdown-menu-BP4_BZLr.js";import{t as Zi}from"./play-BJDBXApx.js";import{n as Fi}from"./spinner-C1czjtp7.js";import{a as zi}from"./state-xh6GqNrp.js";import{a as St,i as yt,o as Ot,r as vt,s as Ui,t as Vi}from"./datasource-CEsMStKs.js";import{a as qi}from"./dist-HGZzCB0y.js";import{t as Kr}from"./use-toast-Bzf3rpev.js";import{r as Bi}from"./useTheme-DfP1CWaW.js";import{t as Wi}from"./tooltip-CvjcEpZC.js";import{s as Ji}from"./popover-DtnzNVk-.js";import{a as Ki}from"./error-banner-DvT0IGDZ.js";import{n as Yi}from"./useRunCells-B9Xr4tcH.js";import{i as Sa}from"./cell-link-BP7_Ns0N.js";import{r as Hi,t as Gi}from"./es-BITbuY9w.js";import{n as Oa}from"./renderShortcut-D0Pei-OA.js";import{t as Qi}from"./process-output-KJWsSvCT.js";import{t as Xi}from"./blob-Dg_vNTSs.js";import{t as eo}from"./useDeleteCell-BvQIJfpI.js";import{r as to,t as ao}from"./esm-B3JckBtM.js";import{n as ro}from"./icons-D4lB4En9.js";var so=Ia("at-sign",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]]),no=Ia("send-horizontal",[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]]),io=Ia("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]),Yr="vercel.ai.error",oo=Symbol.for(Yr),Hr,Gr,Xe=class Pn extends(Gr=Error,Hr=oo,Gr){constructor({name:e,message:a,cause:r}){super(a),this[Hr]=!0,this.name=e,this.cause=r}static isInstance(e){return Pn.hasMarker(e,Yr)}static hasMarker(e,a){let r=Symbol.for(a);return typeof e=="object"&&!!e&&r in e&&typeof e[r]=="boolean"&&e[r]===!0}};function Qr(t){return t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:JSON.stringify(t)}var Xr="AI_InvalidArgumentError",es=`vercel.ai.error.${Xr}`,lo=Symbol.for(es),ts,as,uo=class extends(as=Xe,ts=lo,as){constructor({message:t,cause:e,argument:a}){super({name:Xr,message:t,cause:e}),this[ts]=!0,this.argument=a}static isInstance(t){return Xe.hasMarker(t,es)}},rs="AI_JSONParseError",ss=`vercel.ai.error.${rs}`,co=Symbol.for(ss),ns,is,os=class extends(is=Xe,ns=co,is){constructor({text:t,cause:e}){super({name:rs,message:`JSON parsing failed: Text: ${t}.
2
2
  Error message: ${Qr(e)}`,cause:e}),this[ns]=!0,this.text=t}static isInstance(t){return Xe.hasMarker(t,ss)}},ls="AI_TypeValidationError",ds=`vercel.ai.error.${ls}`,po=Symbol.for(ds),us,cs,Ht=class Er extends(cs=Xe,us=po,cs){constructor({value:e,cause:a}){super({name:ls,message:`Type validation failed: Value: ${JSON.stringify(e)}.
3
3
  Error message: ${Qr(a)}`,cause:a}),this[us]=!0,this.value=e}static isInstance(e){return Xe.hasMarker(e,ds)}static wrap({value:e,cause:a}){return Er.isInstance(a)&&a.value===e?a:new Er({value:e,cause:a})}},ps=class extends Error{constructor(t,e){super(t),this.name="ParseError",this.type=e.type,this.field=e.field,this.value=e.value,this.line=e.line}};function Aa(t){}function mo(t){if(typeof t=="function")throw TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");let{onEvent:e=Aa,onError:a=Aa,onRetry:r=Aa,onComment:s}=t,n="",o=!0,i,l="",d="";function u(f){let c=o?f.replace(/^\xEF\xBB\xBF/,""):f,[m,_]=ho(`${n}${c}`);for(let E of m)p(E);n=_,o=!1}function p(f){if(f===""){h();return}if(f.startsWith(":")){s&&s(f.slice(f.startsWith(": ")?2:1));return}let c=f.indexOf(":");if(c!==-1){let m=f.slice(0,c),_=f[c+1]===" "?2:1;g(m,f.slice(c+_),f);return}g(f,"",f)}function g(f,c,m){switch(f){case"event":d=c;break;case"data":l=`${l}${c}
4
4
  `;break;case"id":i=c.includes("\0")?void 0:c;break;case"retry":/^\d+$/.test(c)?r(parseInt(c,10)):a(new ps(`Invalid \`retry\` value: "${c}"`,{type:"invalid-retry",value:c,line:m}));break;default:a(new ps(`Unknown field "${f.length>20?`${f.slice(0,20)}\u2026`:f}"`,{type:"unknown-field",field:f,value:c,line:m}));break}}function h(){l.length>0&&e({id:i,event:d||void 0,data:l.endsWith(`
@@ -17,15 +17,15 @@ ${n}
17
17
 
18
18
  `;return a.outputType==="text"&&a.processedContent?i+=`Output:
19
19
  ${a.processedContent}`:a.outputType==="media"&&(i+=`Media Output: Contains ${a.output.mimetype} content`,a.imageUrl&&(i+=`
20
- Image URL: ${a.imageUrl}`)),St({type:this.contextType,data:o,details:i})}async getAttachments(e){let a=e[0].data.cellId,r=e[0].data.cellName;return Wd(e.map(s=>s.data.cellOutput),a,r)}};async function Wd(t,e,a){let r=t.filter(n=>n.shouldDownloadImage&&n.outputType==="media");if(r.length===0)return[];let s=r.flatMap(n=>{let o=document.getElementById(Hn.create(e));return o?{cellId:e,cellName:a,mimetype:n.output.mimetype,element:o}:(oe.warn(`Output element not found for cell ${e}`),[])});try{return await Promise.all(s.map(async n=>({type:"file",filename:`${a}-output-screenshot`,mediaType:"image/png",url:await Gi(n.element)})))}catch(n){return oe.error("Error downloading cell output images:",n),[]}}function un(t){if(Wr(t))return null;let e=t.mimetype,a=qd(e,String(t.data))?"media":"text",r=Qi(t),s,n=!1;return a==="media"&&(typeof t.data=="string"&&t.data.startsWith("data:")||typeof t.data=="string"&&t.data.startsWith("http")?s=t.data:n=!0),{processedContent:r,imageUrl:s,shouldDownloadImage:n,outputType:a,output:t}}function cn(t,e,a){let{includeConsoleOutput:r=!1}=a||{},s=e.cellRuntime[t],n=e.cellData[t],o=e.cellIds.inOrderIds.indexOf(t),i=ui(n.name,o),l;r&&(l=s.consoleOutputs.map(p=>un(p)).filter(p=>p!==null));let d,u=s.output;return u&&!Wr(u)&&(d=un(u)??void 0),{cellId:t,cellName:i,cellCode:n.code,cellOutput:d,consoleOutputs:l}}function Jd(t){return t.type==="setup-refs"?"The setup cell cannot have references":t.type==="cycle"?"This cell is in a cycle":t.type==="multiple-defs"?`The variable '${t.name}' was defined by another cell`:t.type==="import-star"||t.type==="ancestor-stopped"||t.type==="ancestor-prevented"||t.type==="exception"||t.type==="strict-exception"?t.msg:t.type==="interruption"?"This cell was interrupted and needs to be re-run":t.type==="syntax"||t.type==="unknown"||t.type==="sql-error"?t.msg:t.type==="internal"?t.msg||"An internal error occurred":(zr(t),"Unknown error")}var pn=new ei("error","errors"),Kd=class extends Ot{constructor(e){super();$(this,"title","Errors");$(this,"mentionPrefix","@");$(this,"contextType","error");this.store=e}getItems(){let e=this.store.get(di);return e.length===0?[]:[{uri:this.asURI("all"),name:"Errors",type:this.contextType,data:{type:"all-errors",errors:e.map(a=>({cellId:a.cellId,cellName:a.cellName,errorData:a.output.data}))},description:"All errors in the notebook"}]}formatCompletion(e){return e.data.type==="all-errors"?{label:"@Errors",displayLabel:"Errors",detail:`${e.data.errors.length} ${pn.pluralize(e.data.errors.length)}`,type:"error",apply:"@Errors",section:yt.ERROR,info:()=>{let a=document.createElement("div");a.classList.add("mo-cm-tooltip","docs-documentation","min-w-[200px]","flex","flex-col","gap-1","p-2");let r=document.createElement("div");r.classList.add("flex","flex-col","gap-1");let s=document.createElement("div");s.classList.add("font-bold","text-base"),s.textContent="Errors",r.append(s);let n=document.createElement("div");return n.classList.add("text-sm","text-muted-foreground"),n.textContent=`${e.data.errors.length} ${pn.pluralize(e.data.errors.length)}`,r.append(n),a.append(r),a}}:{label:"Error",displayLabel:"Error",section:yt.ERROR}}formatContext(e){let{data:a}=e;return a.errors.map(r=>St({type:this.contextType,data:{name:r.cellName||`Cell ${r.cellId}`,description:r.errorData.map(s=>Jd(s)).join(`
20
+ Image URL: ${a.imageUrl}`)),St({type:this.contextType,data:o,details:i})}async getAttachments(e){let a=e[0].data.cellId,r=e[0].data.cellName;return Wd(e.map(s=>s.data.cellOutput),a,r)}};async function Wd(t,e,a){let r=t.filter(n=>n.shouldDownloadImage&&n.outputType==="media");if(r.length===0)return[];let s=r.flatMap(n=>{let o=document.getElementById(ri.create(e));return o?{cellId:e,cellName:a,mimetype:n.output.mimetype,element:o}:(oe.warn(`Output element not found for cell ${e}`),[])});try{return await Promise.all(s.map(async n=>({type:"file",filename:`${a}-output-screenshot`,mediaType:"image/png",url:await Gi(n.element)})))}catch(n){return oe.error("Error downloading cell output images:",n),[]}}function un(t){if(Wr(t))return null;let e=t.mimetype,a=qd(e,String(t.data))?"media":"text",r=Qi(t),s,n=!1;return a==="media"&&(typeof t.data=="string"&&t.data.startsWith("data:")||typeof t.data=="string"&&t.data.startsWith("http")?s=t.data:n=!0),{processedContent:r,imageUrl:s,shouldDownloadImage:n,outputType:a,output:t}}function cn(t,e,a){let{includeConsoleOutput:r=!1}=a||{},s=e.cellRuntime[t],n=e.cellData[t],o=e.cellIds.inOrderIds.indexOf(t),i=li(n.name,o),l;r&&(l=s.consoleOutputs.map(p=>un(p)).filter(p=>p!==null));let d,u=s.output;return u&&!Wr(u)&&(d=un(u)??void 0),{cellId:t,cellName:i,cellCode:n.code,cellOutput:d,consoleOutputs:l}}function Jd(t){return t.type==="setup-refs"?"The setup cell cannot have references":t.type==="cycle"?"This cell is in a cycle":t.type==="multiple-defs"?`The variable '${t.name}' was defined by another cell`:t.type==="import-star"||t.type==="ancestor-stopped"||t.type==="ancestor-prevented"||t.type==="exception"||t.type==="strict-exception"?t.msg:t.type==="interruption"?"This cell was interrupted and needs to be re-run":t.type==="syntax"||t.type==="unknown"||t.type==="sql-error"?t.msg:t.type==="internal"?t.msg||"An internal error occurred":(zr(t),"Unknown error")}var pn=new ci("error","errors"),Kd=class extends Ot{constructor(e){super();$(this,"title","Errors");$(this,"mentionPrefix","@");$(this,"contextType","error");this.store=e}getItems(){let e=this.store.get(ii);return e.length===0?[]:[{uri:this.asURI("all"),name:"Errors",type:this.contextType,data:{type:"all-errors",errors:e.map(a=>({cellId:a.cellId,cellName:a.cellName,errorData:a.output.data}))},description:"All errors in the notebook"}]}formatCompletion(e){return e.data.type==="all-errors"?{label:"@Errors",displayLabel:"Errors",detail:`${e.data.errors.length} ${pn.pluralize(e.data.errors.length)}`,type:"error",apply:"@Errors",section:yt.ERROR,info:()=>{let a=document.createElement("div");a.classList.add("mo-cm-tooltip","docs-documentation","min-w-[200px]","flex","flex-col","gap-1","p-2");let r=document.createElement("div");r.classList.add("flex","flex-col","gap-1");let s=document.createElement("div");s.classList.add("font-bold","text-base"),s.textContent="Errors",r.append(s);let n=document.createElement("div");return n.classList.add("text-sm","text-muted-foreground"),n.textContent=`${e.data.errors.length} ${pn.pluralize(e.data.errors.length)}`,r.append(n),a.append(r),a}}:{label:"Error",displayLabel:"Error",section:yt.ERROR}}formatContext(e){let{data:a}=e;return a.errors.map(r=>St({type:this.contextType,data:{name:r.cellName||`Cell ${r.cellId}`,description:r.errorData.map(s=>Jd(s)).join(`
21
21
  `)}})).join(`
22
22
 
23
- `)}};const mn=ri();var Yd={maxDepth:3,maxResults:20,defaultResultsLimit:5,includeDirectories:!1},Hd=class extends Ot{constructor(e,a=Yd){super();$(this,"title","Files");$(this,"mentionPrefix","#");$(this,"contextType","file");$(this,"searchFiles",async(e,a={})=>{let{maxDepth:r,maxResults:s,includeDirectories:n}={...this.config,...a};return(await this.apiRequests.sendSearchFiles({query:e,includeFiles:!0,includeDirectories:n,depth:r,limit:s})).files});this.apiRequests=e,this.config=a}createCompletionSource(){return async e=>{let a=e.matchBefore(/#[^\s#]*/);if(!a)return null;let r=a.text;if(!r.startsWith("#"))return null;let s=r.slice(1);if(s.length===0)return this.getDefaultCompletions(a);try{let n=(await this.searchFiles(s)||[]).map(o=>{let i={uri:this.asURI(o.path),name:o.name,type:this.contextType,description:o.isDirectory?"Directory":"File",data:{path:o.path,isDirectory:o.isDirectory}};return this.formatCompletion(i)});return{from:a.from,options:n}}catch(n){return oe.error("Failed to search files:",n),null}}}async getDefaultCompletions(e){try{for(let a of["py","md","csv"])try{let r=await this.searchFiles(a,{maxDepth:1,maxResults:5});if(r&&r.length>0){let s=r.map(n=>{let o={uri:this.asURI(n.path),name:n.name,type:this.contextType,description:n.isDirectory?"Directory":"File",data:{path:n.path,isDirectory:n.isDirectory}};return this.formatCompletion(o)});return{from:e.from,options:s}}}catch(r){oe.error("Failed to get default file completions:",r)}return{from:e.from,options:[]}}catch(a){return oe.error("Failed to get default file completions:",a),null}}getItems(){return[]}formatCompletion(e){let{data:a,name:r}=e,s=a.isDirectory?"\u{1F4C1}":"\u{1F4C4}";return{...this.createBasicCompletion(e),type:"file",section:yt.FILE,boost:a.isDirectory?vt.MEDIUM:vt.LOW,detail:a.path,displayLabel:`${s} ${r}`,apply:async(n,o,i,l)=>{var h;let d=(h=n.state.facet(mn))==null?void 0:h.addAttachment;if(!d){oe.warn("No addAttachment callback provided");return}let u=await this.apiRequests.sendFileDetails({path:a.path}).catch(b=>(Kr({title:"Failed to get file details",description:b.message}),null));if(!u)return;let p=u.mimeType||"text/plain",g;if(p.startsWith("text/")||p.includes("json")||p.includes("xml"))g=new Blob([u.contents||""],{type:p});else if(u.contents)try{g=await Xi(Pi(u.contents,p))}catch{g=new Blob([u.contents],{type:p})}else g=new Blob([""],{type:p});d(new File([g],r,{type:p})),n.dispatch({changes:{from:i,to:l,insert:""}}),Ii(n)},info:()=>{let n=document.createElement("div");n.classList.add("flex","flex-col","gap-1","p-2");let o=document.createElement("div");o.classList.add("font-bold"),o.textContent=r,n.append(o);let i=document.createElement("div");return i.classList.add("text-xs","text-muted-foreground"),i.textContent=a.path,n.append(i),n}}}formatContext(e){let{data:a,name:r}=e;return St({type:this.contextType,data:{name:r,path:a.path,isDirectory:a.isDirectory},details:a.isDirectory?"Directory containing files and subdirectories":"File"})}},Gd=class extends Ot{constructor(e){super();$(this,"title","Tables");$(this,"mentionPrefix","@");$(this,"contextType","data");this.tablesMap=e}getItems(){return[...this.tablesMap.entries()].map(([e,a])=>({uri:this.asURI(e),name:e,type:this.contextType,description:a.source==="memory"?"in-memory":a.source,data:a}))}formatContext(e){let{data:a}=e,{columns:r,source:s,num_rows:n,num_columns:o,name:i,variable_name:l}=a,d=[n==null?void 0:`${n} rows`,o==null?void 0:`${o} columns`].filter(Boolean).join(", "),u="";if(d&&(u+=`Shape: ${d}
23
+ `)}};const mn=Gn();var Yd={maxDepth:3,maxResults:20,defaultResultsLimit:5,includeDirectories:!1},Hd=class extends Ot{constructor(e,a=Yd){super();$(this,"title","Files");$(this,"mentionPrefix","#");$(this,"contextType","file");$(this,"searchFiles",async(e,a={})=>{let{maxDepth:r,maxResults:s,includeDirectories:n}={...this.config,...a};return(await this.apiRequests.sendSearchFiles({query:e,includeFiles:!0,includeDirectories:n,depth:r,limit:s})).files});this.apiRequests=e,this.config=a}createCompletionSource(){return async e=>{let a=e.matchBefore(/#[^\s#]*/);if(!a)return null;let r=a.text;if(!r.startsWith("#"))return null;let s=r.slice(1);if(s.length===0)return this.getDefaultCompletions(a);try{let n=(await this.searchFiles(s)||[]).map(o=>{let i={uri:this.asURI(o.path),name:o.name,type:this.contextType,description:o.isDirectory?"Directory":"File",data:{path:o.path,isDirectory:o.isDirectory}};return this.formatCompletion(i)});return{from:a.from,options:n}}catch(n){return oe.error("Failed to search files:",n),null}}}async getDefaultCompletions(e){try{for(let a of["py","md","csv"])try{let r=await this.searchFiles(a,{maxDepth:1,maxResults:5});if(r&&r.length>0){let s=r.map(n=>{let o={uri:this.asURI(n.path),name:n.name,type:this.contextType,description:n.isDirectory?"Directory":"File",data:{path:n.path,isDirectory:n.isDirectory}};return this.formatCompletion(o)});return{from:e.from,options:s}}}catch(r){oe.error("Failed to get default file completions:",r)}return{from:e.from,options:[]}}catch(a){return oe.error("Failed to get default file completions:",a),null}}getItems(){return[]}formatCompletion(e){let{data:a,name:r}=e,s=a.isDirectory?"\u{1F4C1}":"\u{1F4C4}";return{...this.createBasicCompletion(e),type:"file",section:yt.FILE,boost:a.isDirectory?vt.MEDIUM:vt.LOW,detail:a.path,displayLabel:`${s} ${r}`,apply:async(n,o,i,l)=>{var h;let d=(h=n.state.facet(mn))==null?void 0:h.addAttachment;if(!d){oe.warn("No addAttachment callback provided");return}let u=await this.apiRequests.sendFileDetails({path:a.path}).catch(b=>(Kr({title:"Failed to get file details",description:b.message}),null));if(!u)return;let p=u.mimeType||"text/plain",g;if(p.startsWith("text/")||p.includes("json")||p.includes("xml"))g=new Blob([u.contents||""],{type:p});else if(u.contents)try{g=await Xi(Pi(u.contents,p))}catch{g=new Blob([u.contents],{type:p})}else g=new Blob([""],{type:p});d(new File([g],r,{type:p})),n.dispatch({changes:{from:i,to:l,insert:""}}),Ii(n)},info:()=>{let n=document.createElement("div");n.classList.add("flex","flex-col","gap-1","p-2");let o=document.createElement("div");o.classList.add("font-bold"),o.textContent=r,n.append(o);let i=document.createElement("div");return i.classList.add("text-xs","text-muted-foreground"),i.textContent=a.path,n.append(i),n}}}formatContext(e){let{data:a,name:r}=e;return St({type:this.contextType,data:{name:r,path:a.path,isDirectory:a.isDirectory},details:a.isDirectory?"Directory containing files and subdirectories":"File"})}},Gd=class extends Ot{constructor(e){super();$(this,"title","Tables");$(this,"mentionPrefix","@");$(this,"contextType","data");this.tablesMap=e}getItems(){return[...this.tablesMap.entries()].map(([e,a])=>({uri:this.asURI(e),name:e,type:this.contextType,description:a.source==="memory"?"in-memory":a.source,data:a}))}formatContext(e){let{data:a}=e,{columns:r,source:s,num_rows:n,num_columns:o,name:i,variable_name:l}=a,d=[n==null?void 0:`${n} rows`,o==null?void 0:`${o} columns`].filter(Boolean).join(", "),u="";if(d&&(u+=`Shape: ${d}
24
24
  `),l&&(u+=`Variable: ${l}
25
25
  `),r&&r.length>0){u+=`Columns:
26
26
  `;for(let p of r){let g=` ${p.name} (${p.type})`;if(p.sample_values&&p.sample_values.length>0){let h=p.sample_values.slice(0,3).map(b=>b===null?"null":String(b)).join(", ");g+=` - samples: [${h}]`}u+=`${g}
27
- `}}return St({type:this.contextType,data:{name:i,source:s??"unknown"},details:u.trim()})}formatCompletion(e){let a=e.data.name,r=e.data;return{label:`@${a}`,displayLabel:a,detail:r.source==="memory"?"in-memory":r.source,boost:r.source_type==="local"?vt.LOCAL_TABLE:vt.REMOTE_TABLE,type:Mr(r),apply:`@${a}`,section:{name:Mr(r)==="dataframe"?"Dataframe":"Table",rank:yt.TABLE.rank},info:()=>this.createTableInfoElement(a,r)}}createTableInfoElement(e,a){let r=document.createElement("div");r.classList.add("mo-cm-tooltip","docs-documentation","min-w-[200px]","flex","flex-col","gap-1","p-2");let s=document.createElement("div");s.classList.add("flex","flex-col","gap-1");let n=document.createElement("div");if(n.classList.add("font-bold","text-base"),n.textContent=e,s.append(n),a.source){let i=document.createElement("div");i.classList.add("text-xs","text-muted-foreground"),i.textContent=`Source: ${a.source}`,s.append(i)}r.append(s);let o=[a.num_rows==null?void 0:`${a.num_rows} rows`,a.num_columns==null?void 0:`${a.num_columns} columns`].filter(Boolean).join(", ");if(o){let i=document.createElement("div");i.classList.add("text-xs","bg-muted","px-2","py-1","rounded"),i.textContent=o,r.append(i)}if(a.columns&&a.columns.length>0){let i=document.createElement("div");i.classList.add("overflow-auto","max-h-60");let l=document.createElement("table");l.classList.add("w-full","text-xs","border-collapse");let d=l.insertRow();d.classList.add("bg-muted");let u=d.insertCell();u.classList.add("p-2","font-medium","text-left"),u.textContent="Column";let p=d.insertCell();p.classList.add("p-2","font-medium","text-left"),p.textContent="Type";let g=a.columns.some(b=>this.getItemMetadata(a,b)!==void 0),h;g&&(h=d.insertCell(),h.classList.add("p-2","font-medium","text-left"),h.textContent="Metadata"),a.columns.forEach((b,f)=>{let c=l.insertRow();c.classList.add(f%2==0?"bg-background":"bg-muted/30");let m=c.insertCell();m.classList.add("p-2","font-mono"),m.textContent=b.name;let _=c.insertCell();if(_.classList.add("p-2","text-muted-foreground"),_.textContent=b.type,g){let E=c.insertCell();E.classList.add("p-2");let C=this.getItemMetadata(a,b);C&&E.append(C)}}),i.append(l),r.append(i)}return r}getItemMetadata(e,a){var n,o;let r=(n=e.primary_keys)==null?void 0:n.includes(a.name),s=(o=e.indexes)==null?void 0:o.includes(a.name);if(r||s){let i=document.createElement("span");i.textContent=r?"PK":"IDX";let l=r?"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200":"bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-200";return i.classList.add("text-xs","px-1.5","py-0.5","rounded-full","font-medium",...l.split(" ")),i}}},Qd=class extends Ot{constructor(e,a){super();$(this,"title","Variables");$(this,"mentionPrefix","@");$(this,"contextType","variable");this.variables=e,this.tablesMap=a}getItems(){let e=new Set(this.tablesMap.keys());return Object.entries(this.variables).flatMap(([a,r])=>e.has(a)?[]:[{uri:this.asURI(a),name:a,type:this.contextType,description:r.dataType??"",dataType:r.dataType,data:{variable:r}}])}formatCompletion(e){let{data:a}=e,{variable:r}=a;return{label:`@${r.name}`,displayLabel:r.name,detail:r.dataType??"",type:this.contextType,section:yt.VARIABLE,info:()=>Gn(r)}}formatContext(e){let{data:a}=e,{variable:r}=a;return St({type:this.contextType,data:{name:r.name,dataType:r.dataType},details:r.value==null?void 0:JSON.stringify(r.value)})}};function mt(t){let e=t.get(ai),a=t.get(ni),r=t.get(li);return new Ui().register(new Gd(a)).register(new Qd(r,a)).register(new Kd(t)).register(new Bd(t)).register(new Vi(e.connectionsMap,a))}function Xd(){return new Hd(Ai())}const eu="@";function tu({input:t}){let e="";return t.includes("@")&&(e=ru(t),oe.debug("Included context",e)),{includeOtherCode:$r(""),context:{plainText:e,schema:[],variables:[]}}}async function au({input:t}){let e="",a=[];if(t.includes("@")){let r=mt(Nr),s=r.parseAllContextIds(t);e=r.formatContextForAI(s);try{a=await r.getAttachmentsForContext(s),oe.debug("Included attachments",a.length)}catch(n){oe.error("Error getting attachments:",n)}}return{body:{includeOtherCode:$r(""),context:{plainText:e,schema:[],variables:[]}},attachments:a}}function ru(t){let e=mt(Nr),a=e.parseAllContextIds(t);return e.formatContextForAI(a)}function su(t,e=[]){return a=>{let r=t.map(s=>a.matchBefore(s)).find(Boolean);return!r||r&&r.from===r.to&&!a.explicit?null:{from:r==null?void 0:r.from,options:[...e]}}}function nu(t){var e;if((e=t.current)!=null&&e.view){let a=t.current.view.state.selection.main.from;t.current.view.dispatch({changes:{from:a,to:a,insert:"@"},selection:{anchor:a+1,head:a+1}}),t.current.view.focus(),Ei(t.current.view)}}function iu(t){if(t.trim().length===0)return[];if(!t.includes("```"))return[{language:"python",code:t}];let e=[],a=0,r=t.indexOf("```",a);for(;r!==-1;){let s=t.indexOf(`
28
- `,r);if(s===-1){let d=t.slice(r+3),u=d.indexOf(" "),p=u===-1?d:d.slice(0,u),g=p==="markdown"?"markdown":p==="sql"?"sql":"python",h=u===-1?"":d.slice(u+1);h.trim()&&e.push({language:g,code:h.trim()});break}let n=t.slice(r+3,s).trim()||"";n=n==="markdown"?"markdown":n==="sql"?"sql":"python";let o=s+1,i=t.indexOf("```",o);if(i===-1){let d=t.slice(o).replace(/\n+$/,"");d.trim()&&e.push({language:n,code:d});break}let l=t.slice(o,i).replace(/\n+$/,"");l.trim()&&e.push({language:n,code:l}),a=i+3,r=t.indexOf("```",a)}return e.length===0&&e.push({language:"python",code:t}),e}var ou=Ea(),hn=()=>new Map,{valueAtom:Zt,useActions:fn,createActions:Bc,reducer:Wc}=Ci(hn,{addStagedCell:(t,e)=>{let{cellId:a,edit:r}=e;return new Map([...t,[a,r]])},removeStagedCell:(t,e)=>{let a=new Map(t);return a.delete(e),a},clearStagedCells:()=>hn()});function gn(t){let e=(0,ou.c)(27),{addStagedCell:a,removeStagedCell:r,clearStagedCells:s}=fn(),{createNewCell:n,updateCellCode:o}=Pr(),i=eo(),l=(0,A.useRef)(null),d;e[0]!==a||e[1]!==n?(d=C=>{let I=jr.create();return a({cellId:I,edit:{type:"add_cell"}}),n({cellId:"__end__",code:C,before:!1,newCellId:I}),I},e[0]=a,e[1]=n,e[2]=d):d=e[2];let u=d,p;e[3]!==t||e[4]!==o?(p=C=>{let{cellId:I,code:P}=C;if(!t.get(Zt).has(I)){oe.error("Staged cell not found",{cellId:I});return}let D=ii(I);D?Ca(D,P):o({cellId:I,code:P,formattingChange:!1})},e[3]=t,e[4]=o,e[5]=p):p=e[5];let g=p,h;e[6]!==i||e[7]!==r?(h=C=>{r(C),i({cellId:C})},e[6]=i,e[7]=r,e[8]=h):h=e[8];let b=h,f;e[9]!==s||e[10]!==i||e[11]!==t?(f=()=>{let C=t.get(Zt);for(let I of C.keys())i({cellId:I});s()},e[9]=s,e[10]=i,e[11]=t,e[12]=f):f=e[12];let c=f,m;e[13]!==a||e[14]!==n||e[15]!==u||e[16]!==g?(m=C=>{e:switch(C.type){case"text-start":l.current=new lu(u,g,a,n);break e;case"text-delta":if(!l.current){oe.error("Cell creation stream not found");return}l.current.stream(C);break e;case"text-end":case"finish":if(!l.current){oe.error("Cell creation stream not found");return}l.current.stop();break e;case"abort":case"error":case"tool-input-error":case"tool-output-error":oe.error("Error",C.type,{chunk:C});break e;case"start":case"start-step":case"finish-step":case"data-reasoning-signature":break e;case"message-metadata":case"tool-input-available":case"tool-output-available":case"reasoning-start":case"reasoning-delta":case"reasoning-end":case"file":case"source-document":case"source-url":case"tool-input-start":case"tool-input-delta":oe.debug(C.type,{chunk:C});break e;default:if(du(C)){oe.debug("Data chunk",{chunk:C});break e}zr(C)}},e[13]=a,e[14]=n,e[15]=u,e[16]=g,e[17]=m):m=e[17];let _=m,E;return e[18]!==a||e[19]!==s||e[20]!==u||e[21]!==c||e[22]!==b||e[23]!==_||e[24]!==r||e[25]!==g?(E={createStagedCell:u,updateStagedCell:g,addStagedCell:a,removeStagedCell:r,clearStagedCells:s,deleteStagedCell:b,deleteAllStagedCells:c,onStream:_},e[18]=a,e[19]=s,e[20]=u,e[21]=c,e[22]=b,e[23]=_,e[24]=r,e[25]=g,e[26]=E):E=e[26],E}var lu=class{constructor(t,e,a,r){$(this,"createdCells",[]);$(this,"buffer","");$(this,"hasMarimoImport",!1);this.onCreateCell=t,this.onUpdateCell=e,this.addStagedCell=a,this.createNewCell=r}stream(t){let e=t.delta;this.buffer+=e;let a=iu(this.buffer);for(let[r,s]of a.entries())if(r<this.createdCells.length){this.addMarimoImport(s.language);let n=this.createdCells[r];this.createdCells[r]={...n,cell:s},this.onUpdateCell({cellId:n.cellId,code:s.code,language:s.language})}else{let n=this.onCreateCell(s.code);this.createdCells.push({cellId:n,cell:s})}}addMarimoImport(t){var a;if(this.hasMarimoImport||t==="python")return;let e=Hi({autoInstantiate:!1,createNewCell:this.createNewCell,fromCellId:(a=this.createdCells[0])==null?void 0:a.cellId,before:!0});e&&this.addStagedCell({cellId:e,edit:{type:"add_cell"}}),this.hasMarimoImport=!0}stop(){this.buffer=""}};function du(t){return t.type.startsWith("data-")}var uu={baseDescription:"Perform editing operations on the current notebook. You should prefer to create new cells unless you need to edit existing cells. Call this tool multiple times to perform multiple edits. Separate code into logical individual cells to take advantage of the notebook's reactive execution model.",prerequisites:["If you are updating existing cells, you need the cellIds. If they are not known, call the lightweight_cell_map_tool to find out."],additionalInfo:`
27
+ `}}return St({type:this.contextType,data:{name:i,source:s??"unknown"},details:u.trim()})}formatCompletion(e){let a=e.data.name,r=e.data;return{label:`@${a}`,displayLabel:a,detail:r.source==="memory"?"in-memory":r.source,boost:r.source_type==="local"?vt.LOCAL_TABLE:vt.REMOTE_TABLE,type:jr(r),apply:`@${a}`,section:{name:jr(r)==="dataframe"?"Dataframe":"Table",rank:yt.TABLE.rank},info:()=>this.createTableInfoElement(a,r)}}createTableInfoElement(e,a){let r=document.createElement("div");r.classList.add("mo-cm-tooltip","docs-documentation","min-w-[200px]","flex","flex-col","gap-1","p-2");let s=document.createElement("div");s.classList.add("flex","flex-col","gap-1");let n=document.createElement("div");if(n.classList.add("font-bold","text-base"),n.textContent=e,s.append(n),a.source){let i=document.createElement("div");i.classList.add("text-xs","text-muted-foreground"),i.textContent=`Source: ${a.source}`,s.append(i)}r.append(s);let o=[a.num_rows==null?void 0:`${a.num_rows} rows`,a.num_columns==null?void 0:`${a.num_columns} columns`].filter(Boolean).join(", ");if(o){let i=document.createElement("div");i.classList.add("text-xs","bg-muted","px-2","py-1","rounded"),i.textContent=o,r.append(i)}if(a.columns&&a.columns.length>0){let i=document.createElement("div");i.classList.add("overflow-auto","max-h-60");let l=document.createElement("table");l.classList.add("w-full","text-xs","border-collapse");let d=l.insertRow();d.classList.add("bg-muted");let u=d.insertCell();u.classList.add("p-2","font-medium","text-left"),u.textContent="Column";let p=d.insertCell();p.classList.add("p-2","font-medium","text-left"),p.textContent="Type";let g=a.columns.some(b=>this.getItemMetadata(a,b)!==void 0),h;g&&(h=d.insertCell(),h.classList.add("p-2","font-medium","text-left"),h.textContent="Metadata"),a.columns.forEach((b,f)=>{let c=l.insertRow();c.classList.add(f%2==0?"bg-background":"bg-muted/30");let m=c.insertCell();m.classList.add("p-2","font-mono"),m.textContent=b.name;let _=c.insertCell();if(_.classList.add("p-2","text-muted-foreground"),_.textContent=b.type,g){let E=c.insertCell();E.classList.add("p-2");let C=this.getItemMetadata(a,b);C&&E.append(C)}}),i.append(l),r.append(i)}return r}getItemMetadata(e,a){var n,o;let r=(n=e.primary_keys)==null?void 0:n.includes(a.name),s=(o=e.indexes)==null?void 0:o.includes(a.name);if(r||s){let i=document.createElement("span");i.textContent=r?"PK":"IDX";let l=r?"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200":"bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-200";return i.classList.add("text-xs","px-1.5","py-0.5","rounded-full","font-medium",...l.split(" ")),i}}},Qd=class extends Ot{constructor(e,a){super();$(this,"title","Variables");$(this,"mentionPrefix","@");$(this,"contextType","variable");this.variables=e,this.tablesMap=a}getItems(){let e=new Set(this.tablesMap.keys());return Object.entries(this.variables).flatMap(([a,r])=>e.has(a)?[]:[{uri:this.asURI(a),name:a,type:this.contextType,description:r.dataType??"",dataType:r.dataType,data:{variable:r}}])}formatCompletion(e){let{data:a}=e,{variable:r}=a;return{label:`@${r.name}`,displayLabel:r.name,detail:r.dataType??"",type:this.contextType,section:yt.VARIABLE,info:()=>oi(r)}}formatContext(e){let{data:a}=e,{variable:r}=a;return St({type:this.contextType,data:{name:r.name,dataType:r.dataType},details:r.value==null?void 0:JSON.stringify(r.value)})}};function mt(t){let e=t.get(Hn),a=t.get(ti),r=t.get(ni);return new Ui().register(new Gd(a)).register(new Qd(r,a)).register(new Kd(t)).register(new Bd(t)).register(new Vi(e.connectionsMap,a))}function Xd(){return new Hd(Ai())}const eu="@";function tu({input:t}){let e="";return t.includes("@")&&(e=ru(t),oe.debug("Included context",e)),{includeOtherCode:Pr(""),context:{plainText:e,schema:[],variables:[]}}}async function au({input:t}){let e="",a=[];if(t.includes("@")){let r=mt(Nr),s=r.parseAllContextIds(t);e=r.formatContextForAI(s);try{a=await r.getAttachmentsForContext(s),oe.debug("Included attachments",a.length)}catch(n){oe.error("Error getting attachments:",n)}}return{body:{includeOtherCode:Pr(""),context:{plainText:e,schema:[],variables:[]}},attachments:a}}function ru(t){let e=mt(Nr),a=e.parseAllContextIds(t);return e.formatContextForAI(a)}function su(t,e=[]){return a=>{let r=t.map(s=>a.matchBefore(s)).find(Boolean);return!r||r&&r.from===r.to&&!a.explicit?null:{from:r==null?void 0:r.from,options:[...e]}}}function nu(t){var e;if((e=t.current)!=null&&e.view){let a=t.current.view.state.selection.main.from;t.current.view.dispatch({changes:{from:a,to:a,insert:"@"},selection:{anchor:a+1,head:a+1}}),t.current.view.focus(),Ei(t.current.view)}}function iu(t){if(t.trim().length===0)return[];if(!t.includes("```"))return[{language:"python",code:t}];let e=[],a=0,r=t.indexOf("```",a);for(;r!==-1;){let s=t.indexOf(`
28
+ `,r);if(s===-1){let d=t.slice(r+3),u=d.indexOf(" "),p=u===-1?d:d.slice(0,u),g=p==="markdown"?"markdown":p==="sql"?"sql":"python",h=u===-1?"":d.slice(u+1);h.trim()&&e.push({language:g,code:h.trim()});break}let n=t.slice(r+3,s).trim()||"";n=n==="markdown"?"markdown":n==="sql"?"sql":"python";let o=s+1,i=t.indexOf("```",o);if(i===-1){let d=t.slice(o).replace(/\n+$/,"");d.trim()&&e.push({language:n,code:d});break}let l=t.slice(o,i).replace(/\n+$/,"");l.trim()&&e.push({language:n,code:l}),a=i+3,r=t.indexOf("```",a)}return e.length===0&&e.push({language:"python",code:t}),e}var ou=Ea(),hn=()=>new Map,{valueAtom:Zt,useActions:fn,createActions:Bc,reducer:Wc}=Ci(hn,{addStagedCell:(t,e)=>{let{cellId:a,edit:r}=e;return new Map([...t,[a,r]])},removeStagedCell:(t,e)=>{let a=new Map(t);return a.delete(e),a},clearStagedCells:()=>hn()});function gn(t){let e=(0,ou.c)(27),{addStagedCell:a,removeStagedCell:r,clearStagedCells:s}=fn(),{createNewCell:n,updateCellCode:o}=$r(),i=eo(),l=(0,A.useRef)(null),d;e[0]!==a||e[1]!==n?(d=C=>{let I=Mr.create();return a({cellId:I,edit:{type:"add_cell"}}),n({cellId:"__end__",code:C,before:!1,newCellId:I}),I},e[0]=a,e[1]=n,e[2]=d):d=e[2];let u=d,p;e[3]!==t||e[4]!==o?(p=C=>{let{cellId:I,code:P}=C;if(!t.get(Zt).has(I)){oe.error("Staged cell not found",{cellId:I});return}let D=si(I);D?Ca(D,P):o({cellId:I,code:P,formattingChange:!1})},e[3]=t,e[4]=o,e[5]=p):p=e[5];let g=p,h;e[6]!==i||e[7]!==r?(h=C=>{r(C),i({cellId:C})},e[6]=i,e[7]=r,e[8]=h):h=e[8];let b=h,f;e[9]!==s||e[10]!==i||e[11]!==t?(f=()=>{let C=t.get(Zt);for(let I of C.keys())i({cellId:I});s()},e[9]=s,e[10]=i,e[11]=t,e[12]=f):f=e[12];let c=f,m;e[13]!==a||e[14]!==n||e[15]!==u||e[16]!==g?(m=C=>{e:switch(C.type){case"text-start":l.current=new lu(u,g,a,n);break e;case"text-delta":if(!l.current){oe.error("Cell creation stream not found");return}l.current.stream(C);break e;case"text-end":case"finish":if(!l.current){oe.error("Cell creation stream not found");return}l.current.stop();break e;case"abort":case"error":case"tool-input-error":case"tool-output-error":oe.error("Error",C.type,{chunk:C});break e;case"start":case"start-step":case"finish-step":case"data-reasoning-signature":break e;case"message-metadata":case"tool-input-available":case"tool-output-available":case"reasoning-start":case"reasoning-delta":case"reasoning-end":case"file":case"source-document":case"source-url":case"tool-input-start":case"tool-input-delta":oe.debug(C.type,{chunk:C});break e;default:if(du(C)){oe.debug("Data chunk",{chunk:C});break e}zr(C)}},e[13]=a,e[14]=n,e[15]=u,e[16]=g,e[17]=m):m=e[17];let _=m,E;return e[18]!==a||e[19]!==s||e[20]!==u||e[21]!==c||e[22]!==b||e[23]!==_||e[24]!==r||e[25]!==g?(E={createStagedCell:u,updateStagedCell:g,addStagedCell:a,removeStagedCell:r,clearStagedCells:s,deleteStagedCell:b,deleteAllStagedCells:c,onStream:_},e[18]=a,e[19]=s,e[20]=u,e[21]=c,e[22]=b,e[23]=_,e[24]=r,e[25]=g,e[26]=E):E=e[26],E}var lu=class{constructor(t,e,a,r){$(this,"createdCells",[]);$(this,"buffer","");$(this,"hasMarimoImport",!1);this.onCreateCell=t,this.onUpdateCell=e,this.addStagedCell=a,this.createNewCell=r}stream(t){let e=t.delta;this.buffer+=e;let a=iu(this.buffer);for(let[r,s]of a.entries())if(r<this.createdCells.length){this.addMarimoImport(s.language);let n=this.createdCells[r];this.createdCells[r]={...n,cell:s},this.onUpdateCell({cellId:n.cellId,code:s.code,language:s.language})}else{let n=this.onCreateCell(s.code);this.createdCells.push({cellId:n,cell:s})}}addMarimoImport(t){var a;if(this.hasMarimoImport||t==="python")return;let e=Hi({autoInstantiate:!1,createNewCell:this.createNewCell,fromCellId:(a=this.createdCells[0])==null?void 0:a.cellId,before:!0});e&&this.addStagedCell({cellId:e,edit:{type:"add_cell"}}),this.hasMarimoImport=!0}stop(){this.buffer=""}};function du(t){return t.type.startsWith("data-")}var uu={baseDescription:"Perform editing operations on the current notebook. You should prefer to create new cells unless you need to edit existing cells. Call this tool multiple times to perform multiple edits. Separate code into logical individual cells to take advantage of the notebook's reactive execution model.",prerequisites:["If you are updating existing cells, you need the cellIds. If they are not known, call the lightweight_cell_map_tool to find out."],additionalInfo:`
29
29
  Args:
30
30
  edit (object): The editing operation to perform with the following structure:
31
31
  - type: One of "update_cell", "add_cell", or "delete_cell"
@@ -49,7 +49,7 @@ Image URL: ${a.imageUrl}`)),St({type:this.contextType,data:o,details:i})}async g
49
49
  - SQL cells: use mo.sql(f"""{content}""") function to insert content. If a database engine is specified, use mo.sql(f"""{content}""", engine=engine) instead.
50
50
 
51
51
  Returns:
52
- - A result object containing standard tool metadata.`},cu=Q({edit:Q({type:Bt(["update_cell","add_cell","delete_cell"]),code:k().optional(),position:Q({type:Bt(["relative","column_end","notebook_end"]).optional(),cellId:k().optional(),columnIndex:Zr().optional(),before:de().optional()})})}),pu=class{constructor(){$(this,"name","edit_notebook_tool");$(this,"description",uu);$(this,"schema",cu);$(this,"outputSchema",dn);$(this,"mode",["agent"]);$(this,"handler",async({edit:t},e)=>{let{addStagedCell:a,createNewCell:r,store:s}=e;switch(t.type){case"update_cell":{let{position:n,code:o}=t,i=n.cellId;if(i){if(!o)throw new we("Code is required for update_cell","CODE_REQUIRED_FOR_UPDATE_CELL",!0,"Provide the new code to update the cell")}else throw new we("Cell ID is required for update_cell","CELL_ID_REQUIRED_FOR_UPDATE_CELL",!0,"Provide a cell ID to update");let l=s.get(Ge);this.validateCellIdExists(i,l);let d=this.getCellEditorView(i,l);Sa(i);let u=s.get(Zt).get(i);if((u==null?void 0:u.type)==="add_cell"){Ca(d,o);break}let p=d.state.doc.toString();a({cellId:i,edit:{type:"update_cell",previousCode:(u==null?void 0:u.previousCode)??p}}),Ca(d,o);break}case"add_cell":{let{position:n,code:o}=t,i="__end__",l=!1,d=jr.create(),u=s.get(Ge);switch(n.type){case"relative":{let p=n.cellId;if(!p)throw new we("Cell ID is required for add_cell with relative position","TOOL_ERROR",!0,"Provide a cell ID to add the cell before");if(n.before===void 0)throw new we("Before is required for add_cell with relative position","TOOL_ERROR",!0,`Provide a boolean value for before, true to add before cell ${p}, false to add after the cell`);this.validateCellIdExists(p,u),i=p,l=n.before;break}case"column_end":if(!n.columnIndex)throw new we("Column index is required for add_cell with column_end position","TOOL_ERROR",!0,"Provide a column index to add the cell at the end of");i={type:"__end__",columnId:this.getColumnId(n.columnIndex,u)};break;case"notebook_end":break}r({cellId:i,before:l,code:o,newCellId:d}),a({cellId:d,edit:{type:"add_cell"}}),Sa(d);break}case"delete_cell":{let{position:n}=t,o=n.cellId;if(!o)throw new we("Cell ID is required for delete_cell","CELL_ID_REQUIRED_FOR_DELETE_CELL",!0,"Provide a cell ID to delete");let i=s.get(Ge);this.validateCellIdExists(o,i),a({cellId:o,edit:{type:"delete_cell",previousCode:this.getCellEditorView(o,i).state.doc.toString()}}),Sa(o);break}}return{status:"success",next_steps:["If you need to perform more edits, call this tool again.","You should use the lint notebook tool to check for errors and lint issues. Fix them by editing the notebook.","You should use the run stale cells tool to run the cells that have been edited or newly added. This allows you to see the output of the cells and fix any errors."]}})}validateCellIdExists(t,e){if(!e.cellIds.getColumns().some(a=>a.idSet.has(t)))throw new we("Cell not found","CELL_NOT_FOUND",!1,"Check which cells exist in the notebook")}getColumnId(t,e){let a=e.cellIds.getColumns();if(t<0||t>=a.length)throw new we("Column index is out of range","COLUMN_INDEX_OUT_OF_RANGE",!0,"Choose a column index between 0 and the number of columns in the notebook (0-based)");return a[t].id}getCellEditorView(t,e){let a=e.cellHandles[t].current;if(!(a!=null&&a.editorView))throw new we("Cell editor not found","CELL_EDITOR_NOT_FOUND",!1,"Internal error, ask the user to report this error");return a.editorView}},mu=200,hu=3e4,fu={baseDescription:"Run cells in the current notebook that are stale. Stale cells are cells that have been edited or newly added. You can run this tool after editing the notebook or when requested. The output of the ran cells will be returned alongside metadata."},yn=Q({type:N("file"),url:k(),mediaType:k()}),gu=class{constructor(t){$(this,"name","run_stale_cells_tool");$(this,"description",fu);$(this,"schema",Q({}));$(this,"outputSchema",dn.extend({cellsToOutput:It(k(),Q({consoleOutput:k().optional(),cellOutput:k().optional(),consoleAttachments:Ve(yn).optional(),cellAttachments:Ve(yn).optional()}).nullable()).optional()}));$(this,"mode",["agent"]);$(this,"handler",async(t,e)=>{let{prepareForRun:a,sendRun:r,store:s}=e,n=s.get(Ge),o=ci(n);if(o.length===0)return{status:"success",message:"No stale cells found."};if(await Yi({cellIds:o,sendRun:r,prepareForRun:a,notebook:n}),!await this.waitForCellsToFinish(s,o,hu,this.postExecutionDelay))return{status:"success",message:"No output was returned because some cells have not finished executing"};let i=s.get(Ge),l=new Map,d="",u=!1;for(let g of o){let h=cn(g,i,{includeConsoleOutput:!0}),b,f,c=h.cellOutput,m=h.consoleOutputs,_=m&&m.length>0;if(!c&&!_){l.set(g,null);continue}c&&(b=this.formatOutputString(c),this.outputHasErrors(c)&&(u=!0)),_&&(f=m.map(E=>this.formatOutputString(E)).join(`
52
+ - A result object containing standard tool metadata.`},cu=Q({edit:Q({type:Bt(["update_cell","add_cell","delete_cell"]),code:k().optional(),position:Q({type:Bt(["relative","column_end","notebook_end"]).optional(),cellId:k().optional(),columnIndex:Zr().optional(),before:de().optional()})})}),pu=class{constructor(){$(this,"name","edit_notebook_tool");$(this,"description",uu);$(this,"schema",cu);$(this,"outputSchema",dn);$(this,"mode",["agent"]);$(this,"handler",async({edit:t},e)=>{let{addStagedCell:a,createNewCell:r,store:s}=e;switch(t.type){case"update_cell":{let{position:n,code:o}=t,i=n.cellId;if(i){if(!o)throw new we("Code is required for update_cell","CODE_REQUIRED_FOR_UPDATE_CELL",!0,"Provide the new code to update the cell")}else throw new we("Cell ID is required for update_cell","CELL_ID_REQUIRED_FOR_UPDATE_CELL",!0,"Provide a cell ID to update");let l=s.get(Ge);this.validateCellIdExists(i,l);let d=this.getCellEditorView(i,l);Sa(i);let u=s.get(Zt).get(i);if((u==null?void 0:u.type)==="add_cell"){Ca(d,o);break}let p=d.state.doc.toString();a({cellId:i,edit:{type:"update_cell",previousCode:(u==null?void 0:u.previousCode)??p}}),Ca(d,o);break}case"add_cell":{let{position:n,code:o}=t,i="__end__",l=!1,d=Mr.create(),u=s.get(Ge);switch(n.type){case"relative":{let p=n.cellId;if(!p)throw new we("Cell ID is required for add_cell with relative position","TOOL_ERROR",!0,"Provide a cell ID to add the cell before");if(n.before===void 0)throw new we("Before is required for add_cell with relative position","TOOL_ERROR",!0,`Provide a boolean value for before, true to add before cell ${p}, false to add after the cell`);this.validateCellIdExists(p,u),i=p,l=n.before;break}case"column_end":if(!n.columnIndex)throw new we("Column index is required for add_cell with column_end position","TOOL_ERROR",!0,"Provide a column index to add the cell at the end of");i={type:"__end__",columnId:this.getColumnId(n.columnIndex,u)};break;case"notebook_end":break}r({cellId:i,before:l,code:o,newCellId:d}),a({cellId:d,edit:{type:"add_cell"}}),Sa(d);break}case"delete_cell":{let{position:n}=t,o=n.cellId;if(!o)throw new we("Cell ID is required for delete_cell","CELL_ID_REQUIRED_FOR_DELETE_CELL",!0,"Provide a cell ID to delete");let i=s.get(Ge);this.validateCellIdExists(o,i),a({cellId:o,edit:{type:"delete_cell",previousCode:this.getCellEditorView(o,i).state.doc.toString()}}),Sa(o);break}}return{status:"success",next_steps:["If you need to perform more edits, call this tool again.","You should use the lint notebook tool to check for errors and lint issues. Fix them by editing the notebook.","You should use the run stale cells tool to run the cells that have been edited or newly added. This allows you to see the output of the cells and fix any errors."]}})}validateCellIdExists(t,e){if(!e.cellIds.getColumns().some(a=>a.idSet.has(t)))throw new we("Cell not found","CELL_NOT_FOUND",!1,"Check which cells exist in the notebook")}getColumnId(t,e){let a=e.cellIds.getColumns();if(t<0||t>=a.length)throw new we("Column index is out of range","COLUMN_INDEX_OUT_OF_RANGE",!0,"Choose a column index between 0 and the number of columns in the notebook (0-based)");return a[t].id}getCellEditorView(t,e){let a=e.cellHandles[t].current;if(!(a!=null&&a.editorView))throw new we("Cell editor not found","CELL_EDITOR_NOT_FOUND",!1,"Internal error, ask the user to report this error");return a.editorView}},mu=200,hu=3e4,fu={baseDescription:"Run cells in the current notebook that are stale. Stale cells are cells that have been edited or newly added. You can run this tool after editing the notebook or when requested. The output of the ran cells will be returned alongside metadata."},yn=Q({type:N("file"),url:k(),mediaType:k()}),gu=class{constructor(t){$(this,"name","run_stale_cells_tool");$(this,"description",fu);$(this,"schema",Q({}));$(this,"outputSchema",dn.extend({cellsToOutput:It(k(),Q({consoleOutput:k().optional(),cellOutput:k().optional(),consoleAttachments:Ve(yn).optional(),cellAttachments:Ve(yn).optional()}).nullable()).optional()}));$(this,"mode",["agent"]);$(this,"handler",async(t,e)=>{let{prepareForRun:a,sendRun:r,store:s}=e,n=s.get(Ge),o=ai(n);if(o.length===0)return{status:"success",message:"No stale cells found."};if(await Yi({cellIds:o,sendRun:r,prepareForRun:a,notebook:n}),!await this.waitForCellsToFinish(s,o,hu,this.postExecutionDelay))return{status:"success",message:"No output was returned because some cells have not finished executing"};let i=s.get(Ge),l=new Map,d="",u=!1;for(let g of o){let h=cn(g,i,{includeConsoleOutput:!0}),b,f,c=h.cellOutput,m=h.consoleOutputs,_=m&&m.length>0;if(!c&&!_){l.set(g,null);continue}c&&(b=this.formatOutputString(c),this.outputHasErrors(c)&&(u=!0)),_&&(f=m.map(E=>this.formatOutputString(E)).join(`
53
53
  `),d+="Console output represents the stdout or stderr of the cell (eg. print statements).",m.some(E=>this.outputHasErrors(E))&&(u=!0)),l.set(g,{cellOutput:b,consoleOutput:f})}if(l.size===0)return{status:"success",message:"Stale cells have been run. No output was returned."};let p=["Review the output of the cells. The CellId is the key of the result object.",u?"There are errors in the cells. Please fix them by using the edit notebook tool and the given CellIds.":"You may edit the notebook further with the given CellIds."];return{status:"success",cellsToOutput:Object.fromEntries(l),message:d===""?void 0:d,next_steps:p}});this.postExecutionDelay=(t==null?void 0:t.postExecutionDelay)??mu}outputHasErrors(t){let{output:e}=t;return e.mimetype==="application/vnd.marimo+error"||e.mimetype==="application/vnd.marimo+traceback"}formatOutputString(t){let e="",{outputType:a,processedContent:r,imageUrl:s,output:n}=t;return a==="text"?(e+=`Output:
54
54
  `,r?e+=r:typeof n.data=="string"?e+=n.data:e+=JSON.stringify(n.data)):a==="media"&&(e+=`Media Output: Contains ${n.mimetype} content`,s&&(e+=`
55
55
  Image URL: ${s}`)),e}async waitForCellsToFinish(t,e,a,r){let s=o=>e.every(i=>{let l=o.cellRuntime[i];return(l==null?void 0:l.status)!=="running"&&(l==null?void 0:l.status)!=="queued"}),n=async()=>(r>0&&await new Promise(o=>setTimeout(o,r)),!0);if(s(t.get(Ge)))return await n();try{return await Promise.race([Jn(Ge,s),new Promise((o,i)=>setTimeout(()=>i(Error("timeout")),a))]),await n()}catch{return!1}}};function yu(t){let e=t.baseDescription;return t.whenToUse&&(e+=`
@@ -71,7 +71,7 @@ Image URL: ${s}`)),e}async waitForCellsToFinish(t,e,a,r){let s=o=>e.every(i=>{le
71
71
  - `)}`),t.additionalInfo&&(e+=`
72
72
 
73
73
  ## Additional info:
74
- - ${t.additionalInfo}`),e}var vn,Ft;function vu(t,e,a,r,s){var n={};return Object.keys(r).forEach(function(o){n[o]=r[o]}),n.enumerable=!!n.enumerable,n.configurable=!!n.configurable,("value"in n||n.initializer)&&(n.writable=!0),n=a.slice().reverse().reduce(function(o,i){return i(t,e,o)||o},n),s&&n.initializer!==void 0&&(n.value=n.initializer?n.initializer.call(s):void 0,n.initializer=void 0),n.initializer===void 0?(Object.defineProperty(t,e,n),null):n}const _r=new(vn=si(),Ft=class{constructor(t=[]){$(this,"tools",new Map);this.tools=new Map(t.map(e=>[e.name,e]))}has(t){return this.tools.has(t)}getToolOrThrow(t){let e=this.tools.get(t);if(!e)throw Error(`Tool ${t} not found`);return e}async invoke(t,e,a){var i;let r=this.getToolOrThrow(t),s=r.handler,n=r.schema,o=r.outputSchema;try{let l=await n.safeParseAsync(e);if(l.error)throw new we(`Tool ${t} returned invalid input: ${Dr(l.error)}`,"INVALID_ARGUMENTS",!0,"Please check the arguments and try again.");let d=l.data,u=await s(d,a),p=await o.safeParseAsync(u);if(p.error){let g=Dr(p.error);throw Error(`Tool ${t} returned invalid output: ${g}`)}return{tool_name:t,result:p.data,error:null}}catch(l){return l instanceof we?{tool_name:t,result:null,error:l.toStructuredString()}:{tool_name:t,result:null,error:new we(l instanceof Error?l.message:String(l),"TOOL_ERROR",!1,"Check the error message and try again with valid arguments.",{args:e,errorType:((i=l==null?void 0:l.constructor)==null?void 0:i.name)??typeof l}).toStructuredString()}}}getToolSchemas(t){return[...this.tools.values()].filter(e=>e.mode.includes(t)).map(e=>({name:e.name,description:yu(e.description),parameters:Fr(e.schema),source:"frontend",mode:e.mode}))}},vu(Ft.prototype,"getToolSchemas",[vn],Object.getOwnPropertyDescriptor(Ft.prototype,"getToolSchemas"),Ft.prototype),Ft)([new pu,new gu]);function br(t,e){return new Promise(a=>{let r=new FileReader;r.readAsDataURL(t),r.onload=s=>{var n;if((n=s.target)!=null&&n.result){let o=s.target.result;a(e==="base64"?o.slice(o.indexOf(",")+1):o)}}})}function _u(t){return Promise.all(t.map(e=>br(e,"base64").then(a=>[e.name,a])))}function bu(t){return t.length>50?`${t.slice(0,50)}...`:t}async function xu(t){return await Promise.all(t.map(async e=>({type:"file",mediaType:e.type,filename:e.name,url:await br(e,"dataUrl")})))}function wu(t){if(t.length===0)return!1;let e=t.at(-1);if(!e||e.role!=="assistant"||!e.parts)return!1;let a=e.parts;return a.length===0?!1:a[a.length-1].type==="reasoning"}function _n(t){return t.map(e=>e.type==="text"?e.text:"").join(`
74
+ - ${t.additionalInfo}`),e}var vn,Ft;function vu(t,e,a,r,s){var n={};return Object.keys(r).forEach(function(o){n[o]=r[o]}),n.enumerable=!!n.enumerable,n.configurable=!!n.configurable,("value"in n||n.initializer)&&(n.writable=!0),n=a.slice().reverse().reduce(function(o,i){return i(t,e,o)||o},n),s&&n.initializer!==void 0&&(n.value=n.initializer?n.initializer.call(s):void 0,n.initializer=void 0),n.initializer===void 0?(Object.defineProperty(t,e,n),null):n}const _r=new(vn=Qn(),Ft=class{constructor(t=[]){$(this,"tools",new Map);this.tools=new Map(t.map(e=>[e.name,e]))}has(t){return this.tools.has(t)}getToolOrThrow(t){let e=this.tools.get(t);if(!e)throw Error(`Tool ${t} not found`);return e}async invoke(t,e,a){var i;let r=this.getToolOrThrow(t),s=r.handler,n=r.schema,o=r.outputSchema;try{let l=await n.safeParseAsync(e);if(l.error)throw new we(`Tool ${t} returned invalid input: ${Dr(l.error)}`,"INVALID_ARGUMENTS",!0,"Please check the arguments and try again.");let d=l.data,u=await s(d,a),p=await o.safeParseAsync(u);if(p.error){let g=Dr(p.error);throw Error(`Tool ${t} returned invalid output: ${g}`)}return{tool_name:t,result:p.data,error:null}}catch(l){return l instanceof we?{tool_name:t,result:null,error:l.toStructuredString()}:{tool_name:t,result:null,error:new we(l instanceof Error?l.message:String(l),"TOOL_ERROR",!1,"Check the error message and try again with valid arguments.",{args:e,errorType:((i=l==null?void 0:l.constructor)==null?void 0:i.name)??typeof l}).toStructuredString()}}}getToolSchemas(t){return[...this.tools.values()].filter(e=>e.mode.includes(t)).map(e=>({name:e.name,description:yu(e.description),parameters:Fr(e.schema),source:"frontend",mode:e.mode}))}},vu(Ft.prototype,"getToolSchemas",[vn],Object.getOwnPropertyDescriptor(Ft.prototype,"getToolSchemas"),Ft.prototype),Ft)([new pu,new gu]);function br(t,e){return new Promise(a=>{let r=new FileReader;r.readAsDataURL(t),r.onload=s=>{var n;if((n=s.target)!=null&&n.result){let o=s.target.result;a(e==="base64"?o.slice(o.indexOf(",")+1):o)}}})}function _u(t){return Promise.all(t.map(e=>br(e,"base64").then(a=>[e.name,a])))}function bu(t){return t.length>50?`${t.slice(0,50)}...`:t}async function xu(t){return await Promise.all(t.map(async e=>({type:"file",mediaType:e.type,filename:e.name,url:await br(e,"dataUrl")})))}function wu(t){if(t.length===0)return!1;let e=t.at(-1);if(!e||e.role!=="assistant"||!e.parts)return!1;let a=e.parts;return a.length===0?!1:a[a.length-1].type==="reasoning"}function _n(t){return t.map(e=>e.type==="text"?e.text:"").join(`
75
75
  `)}async function bn(t){let e=await au({input:_n(t.flatMap(s=>s.parts))});function a(s,n){return n?{...s,parts:[...s.parts,...e.attachments]}:s}function r(s,n){let o=[...s.parts];return n&&o.push(...e.attachments),{id:s.id,role:s.role,content:_n(s.parts),parts:o}}return{...e.body,messages:t.map((s,n)=>r(s,n===t.length-1)),uiMessages:t.map((s,n)=>a(s,n===t.length-1))}}async function xn({invokeAiTool:t,addToolOutput:e,toolCall:a,toolContext:r}){try{if(_r.has(a.toolName)){let s=await _r.invoke(a.toolName,a.input,r);e({tool:a.toolName,toolCallId:a.toolCallId,output:s.result||s.error})}else{let s=await t({toolName:a.toolName,arguments:a.input??{}});e({tool:a.toolName,toolCallId:a.toolCallId,output:s.result||s.error})}}catch(s){oe.error("Tool call failed:",s),e({tool:a.toolName,toolCallId:a.toolCallId,output:`Error: ${s instanceof Error?s.message:String(s)}`})}}function ku(t){var i;if(t.length===0)return!1;let e=t[t.length-1],a=e.parts;if(a.length===0||e.role!=="assistant")return!1;let r=a.filter(l=>l.type.startsWith("tool-"));if(r.length===0)return!1;let s=r.every(l=>l.state==="output-available"),n=a[a.length-1],o=n.type==="text"&&((i=n.text)==null?void 0:i.trim().length)>0;return oe.warn("All tool calls completed: %s",s),s&&!o}function Cu(t){return bi.define({combine:e=>e[0]??t})}var wn=Cu({}),xr=Yt.define(),ba=Yt.define(),Eu=50,wr=Jt.define({create(){return{prompts:[],navigationIndex:-1,originalText:""}},update(t,e){var r,s;let a={...t};e.docChanged&&t.navigationIndex!==-1&&(e.effects.some(n=>n.is(ba)||n.is(xr))||(a.navigationIndex=-1,a.originalText=""));for(let n of e.effects)if(n.is(xr)){let o=n.value.trim();o&&(a.prompts=[o,...t.prompts.filter(i=>i!==o)].slice(0,Eu),(s=(r=e.state.facet(wn)).save)==null||s.call(r,a.prompts)),a.navigationIndex=-1,a.originalText=""}else n.is(ba)&&(a.navigationIndex=n.value.index,a.originalText=n.value.originalText);return a}}),Tu=t=>{let e=t.state.field(wr),a=t.state.doc;if(e.prompts.length===0)return!1;let r,s=e.originalText;if(e.navigationIndex===-1){if(a.length>0)return!1;r=0,s=a.toString()}else if(r=Math.min(e.navigationIndex+1,e.prompts.length-1),r===e.navigationIndex)return!1;let n=e.prompts[r];return t.dispatch({changes:{from:0,to:t.state.doc.length,insert:n},effects:ba.of({index:r,originalText:s})}),!0},Iu=t=>{let e=t.state.field(wr);if(e.navigationIndex===-1)return!1;let a,r;return e.navigationIndex===0?(a=e.originalText,r=-1):(r=e.navigationIndex-1,a=e.prompts[r]??""),t.dispatch({changes:{from:0,to:t.state.doc.length,insert:a},effects:ba.of({index:r,originalText:e.originalText})}),!0};const kn=t=>{let e=t.state.doc.toString();return e.trim()?(t.dispatch({effects:xr.of(e)}),!0):!1};function Su(t={}){let{storage:e,defaultKeymap:a=!0}=t,r=[wr.init(()=>{var s;return{prompts:((s=e==null?void 0:e.load)==null?void 0:s.call(e))??[],navigationIndex:-1,originalText:""}}),wn.of(e??{})];return a&&r.push(Kt.of([{key:"ArrowUp",run:Tu},{key:"ArrowDown",run:Iu}])),r}const kr=Yt.define(),Ke=Jt.define({create(){return new Map},update(t,e){let a=!1,r=t;for(let s of e.effects)if(s.is(kr)){a||(a=(r=new Map(t),!0));for(let[n,o]of s.value)r.set(n,o)}return r}}),Ou=Jt.define({create(){return{onResourceClick:void 0,onResourceMouseOver:void 0,onResourceMouseOut:void 0,onPromptSubmit:void 0}},update(t){return t}}),Au=Yt.define();Jt.define({create(){return new Map},update(t,e){let a=!1,r=t;for(let s of e.effects)if(s.is(Au)){a||(a=(r=new Map(t),!0));for(let[n,o]of s.value)r.set(n,o)}return r}});const Ru=(t,e)=>async a=>{let r=a.matchBefore(/@(\w+)?/);if(!r||r.from===r.to&&!a.explicit)return null;let s=await t();if(s.length===0)return null;let n=kr.of(new Map(s.map(i=>[i.uri,i])));a.view&&a.view.dispatch({effects:n});let o=s.map(i=>({label:`@${i.name}`,displayLabel:i.name,detail:i.uri,info:i.description||void 0,type:i.mimeType?"constant":"variable",boost:i.description?100:0,...e==null?void 0:e(i),apply:(l,d,u,p)=>{l.dispatch({changes:{from:u,to:p,insert:`@${i.uri} `}})}}));return{from:r.from,options:o}},Nu=/@[\w-]+:\/\/(?!\/)[^\s]+/;function st(t){return t.matchAll(new RegExp(Nu.source,"g"))}var Mu=class extends Br{constructor(e,a){super();$(this,"resource");$(this,"view");this.resource=e,this.view=a}eq(e){return e.resource.uri===this.resource.uri}toDOM(){let e=document.createElement("span");e.className="cm-resource-widget",e.textContent=`@${this.resource.name}`;let a=this.view.state.field(Ou,!1),r=a==null?void 0:a.onResourceClick,s=a==null?void 0:a.onResourceMouseOver,n=a==null?void 0:a.onResourceMouseOut;return r&&(e.style.cursor="pointer",e.addEventListener("click",o=>{o.preventDefault(),o.stopPropagation(),r(this.resource)})),s&&e.addEventListener("mouseover",o=>{o.preventDefault(),o.stopPropagation(),s(this.resource)}),n&&e.addEventListener("mouseout",o=>{o.preventDefault(),o.stopPropagation(),n(this.resource)}),e}},Pu=class extends Br{constructor(e,a){super();$(this,"uri");$(this,"view");this.uri=e,this.view=a}eq(e){return e.uri===this.uri}toDOM(){let e=document.createElement("span");return e.className="cm-not-found-resource-widget",e.textContent=`@${this.uri.split("://")[1]??this.uri}`,e}};function Cn(t){let e=t.state.field(Ke),a=[];for(let{from:r,to:s}of t.visibleRanges){let n=t.state.doc.sliceString(r,s);for(let o of st(n)){let i=r+o.index,l=o[0].slice(1),d=e.get(l);d?a.push(Ta.replace({widget:new Mu(d,t)}).range(i,i+o[0].length)):a.push(Ta.replace({widget:new Pu(l,t)}).range(i,i+o[0].length))}}return Ta.set(a)}const ju=wi.fromClass(class{constructor(t){$(this,"decorations");this.decorations=Cn(t)}update(t){(t.docChanged||t.viewportChanged||t.transactions.some(e=>e.effects.some(a=>a.is(kr))))&&(this.decorations=Cn(t.view))}},{decorations:t=>t.decorations});function $u(t){let e=document.createElement("div");e.className="cm-tooltip-cursor";let a=document.createElement("div");if(a.className="cm-tooltip-cursor-title",a.textContent=`${t.name} (${t.uri})`,e.appendChild(a),t.description){let r=document.createElement("div");r.className="cm-tooltip-cursor-description",r.textContent=t.description,e.appendChild(r)}if(t.mimeType){let r=document.createElement("div");r.className="cm-tooltip-cursor-mimetype",r.textContent=t.mimeType,e.appendChild(r)}return{dom:e}}function Lu(t,e,a,r=0){for(let s of st(t)){let n=r+s.index,o=n+s[0].length;if(e>=n&&e<=o){let i=s[0].slice(1),l=a.get(i);if(l)return{resource:l,start:n,end:o}}}return null}function Du(t){return ki((e,a)=>{let{from:r,text:s}=e.state.doc.lineAt(a),n=Lu(s,a,e.state.field(Ke),r);return n?{pos:n.start,end:n.end,above:!0,create(){return(t.createTooltip??$u)(n.resource)}}:null})}function Zu(t,e){let a=t.field(Ke),r=t.doc,s=r.lineAt(e),n=r.sliceString(s.from,s.to),o=Array.from(st(n));if(o.length===0)return null;for(let i of o){let l=s.from+i.index,d=l+i[0].length,u=i[0].slice(1);if(e===d&&a.has(u))return{from:l,to:d,uri:u}}return null}function Fu(t,e){let a=t.field(Ke),r=t.doc,s=r.lineAt(e).to,n=r.sliceString(e,s),o=Array.from(st(n));if(o.length===0)return null;let i=o[0];if(!i||i.index!==0)return null;let l=e,d=e+i[0].length,u=i[0].slice(1);return a.has(u)?{from:l,to:d,uri:u}:null}function En(t,e){let a=t.field(Ke),r=t.doc,s=r.lineAt(e),n=r.sliceString(s.from,s.to),o=Array.from(st(n));for(let i of o){let l=s.from+i.index,d=l+i[0].length,u=i[0].slice(1);if(e>l&&e<d&&a.has(u))return{from:l,to:d,uri:u}}return null}function zu(t,e){let a=t.field(Ke),r=t.doc,s=r.lineAt(e),n=r.sliceString(s.from,e),o=Array.from(st(n)),i=null;for(let l of o){let d=s.from+l.index,u=d+l[0].length,p=l[0].slice(1);a.has(p)&&u<=e&&(e>u?i=u:e===u&&(i=d))}return i}function Uu(t,e){let a=t.field(Ke),r=t.doc,s=r.lineAt(e),n=r.sliceString(s.from,s.to),o=Array.from(st(n));for(let i of o){let l=s.from+i.index,d=l+i[0].length,u=i[0].slice(1);if(a.has(u)&&l>=e){if(e<l)return l;if(e===l)return d}}return null}const Vu=_i.transactionFilter.of(t=>{var r;let e=t.annotation(xi.userEvent);if(!e)return t;let a=t.startState.selection.main;if(!a.empty)return t;if(e==="input.type"||e.startsWith("input")){if(t.changes.empty)return t;let s=t.startState.field(Ke),n=t.startState.doc,o=!1,i=0,l=[];if(t.changes.iterChanges((d,u,p,g,h)=>{let b=h.toString(),f=d;if(/^\s+$/.test(b)){l.push({from:d,to:u,insert:b});return}let c=n.lineAt(f),m=n.sliceString(c.from,c.to),_=Array.from(st(m)),E=!1,C=!1;for(let P of _){let D=c.from+P.index,M=D+P[0].length,H=P[0].slice(1);if(s.has(H)){if(f===D){let j=f>0?n.sliceString(f-1,f):"";j!==""&&j!==" "&&j!==`
76
76
  `&&j!==" "&&(E=!0)}if(f===M){let j=f<n.length?n.sliceString(f,f+1):"";(j===""||j!==" "&&j!==`
77
77
  `&&j!==" ")&&(C=!0)}}}let I=b;E&&(I=` ${I}`,i+=1),C&&(I=` ${I}`,i+=1),I!==b&&(o=!0),l.push({from:d,to:u,insert:I})}),o)return[{changes:l,selection:t.selection?{anchor:t.selection.main.anchor+i,head:t.selection.main.head+i}:void 0,scrollIntoView:t.scrollIntoView}]}if(e==="delete.backward"||e==="delete.forward"){let s=null;return e==="delete.backward"?s=Zu(t.startState,a.head):e==="delete.forward"&&(s=Fu(t.startState,a.head)),s?[{changes:{from:s.from,to:s.to,insert:""},selection:{anchor:s.from},scrollIntoView:!0}]:t}if((r=t.selection)!=null&&r.main.empty&&a.empty&&!e.startsWith("input")&&e!=="input.type"){let s=a.head,n=t.selection.main.head,o=null;if(n<s){let i=En(t.startState,s);o=i&&s>i.from?i.from:zu(t.startState,s)}else if(n>s){let i=En(t.startState,s);o=i&&s<i.to?i.to:Uu(t.startState,s)}if(o!==null&&o!==n)return[{selection:{anchor:o},scrollIntoView:!0}]}return t}),qu=qr.baseTheme({".cm-resource-widget":{background:"light-dark(rgba(86,156,214,0.08),rgba(86,156,214,0.18))",borderRadius:"4px",padding:"2px 4px",color:"light-dark(#2367a2,#7ecbff)",fontWeight:"500"},".cm-resource-widget:hover":{background:"light-dark(rgba(86,156,214,0.18),rgba(86,156,214,0.28))"},".cm-not-found-resource-widget":{background:"light-dark(rgba(151,151,151,0.08),rgba(151,151,151,0.18))",borderRadius:"4px",padding:"2px 4px",color:"light-dark(#b00020,#ff8080)",fontWeight:"500"}});var Tn="_none_",Bu=[{uri:"",name:"No resources",type:Tn,data:{}}],Wu={info:"Variables, dataframes, and tables will appear here.",apply:()=>{}};function Ju(t){let{language:e,store:a,onAddFiles:r}=t;return[e.data.of({autocomplete:Ru(async()=>{let s=mt(a).getAllItems();return s.length===0?Bu:s},s=>{var n;return s.type===Tn?Wu:((n=mt(a).getProvider(s.type))==null?void 0:n.formatCompletion(s))||{}})}),Vr.high(Kt.of([{key:"Tab",run:s=>Ti(s)}])),mn.of({addAttachment:s=>r==null?void 0:r([s])}),...r?[e.data.of({autocomplete:Xd().createCompletionSource()})]:[],ju,Vu,Ke.init(()=>{let s=mt(a).getAllItems();return new Map(s.map(n=>[n.uri,n]))}),qu,Du({createTooltip:s=>{let n=mt(a).getProvider(s.type);if(!n)return oe.warn("No provider found for resource",s),zt(s.description||s.name);let o=n.formatCompletion(s),i=s.description||s.name;if(!(o!=null&&o.info))return zt(i);if(typeof o.info=="string")return zt(o.info);let l=o.info(o);return l?"dom"in l?{dom:l.dom}:"then"in l?(oe.warn("info is a promise. This is not supported",l),zt(i)):{dom:l}:zt(i)}})]}function zt(t){let e=document.createElement("div");return e.innerHTML=t,{dom:e}}var Cr=Ea(),O=ka(vi(),1);const In=t=>{let{handleAcceptCompletion:e,handleDeclineCompletion:a,isLoading:r,hasCompletion:s}=t;return n=>{let o=gi()?n.metaKey:n.ctrlKey;o&&n.key==="Enter"&&!r&&s&&e(),(n.key==="Delete"||n.key==="Backspace")&&o&&n.shiftKey&&(a(),n.preventDefault(),n.stopPropagation())}},Ku=t=>{let e=(0,Cr.c)(9),{isLoading:a,onAccept:r,onDecline:s,runCell:n}=t,o;e[0]!==a||e[1]!==r||e[2]!==n?(o=(0,O.jsx)(Sn,{isLoading:a,onAccept:r,size:"xs",runCell:n}),e[0]=a,e[1]=r,e[2]=n,e[3]=o):o=e[3];let i;e[4]===s?i=e[5]:(i=(0,O.jsx)(On,{onDecline:s,size:"xs"}),e[4]=s,e[5]=i);let l;return e[6]!==o||e[7]!==i?(l=(0,O.jsxs)(O.Fragment,{children:[o,i]}),e[6]=o,e[7]=i,e[8]=l):l=e[8],l},Sn=t=>{let e=(0,Cr.c)(33),{isLoading:a,onAccept:r,multipleCompletions:s,size:n,buttonStyles:o,acceptShortcut:i,runCell:l,playButtonStyles:d,borderless:u}=t,p=s===void 0?!1:s,g=n===void 0?"sm":n,h=u===void 0?!1:u,b;e[0]!==r||e[1]!==l?(b=()=>{r(),l&&l()},e[0]=r,e[1]=l,e[2]=b):b=e[2];let f=b,c=p?"Accept all":"Accept";if(l){let C=`h-6 text-(--grass-11) bg-(--grass-3)/60
@@ -86,5 +86,5 @@ Image URL: ${s}`)),e}async waitForCellsToFinish(t,e,a,r){let s=o=>e.every(i=>{le
86
86
  border-(--green-6) border hover:shadow-xs rounded px-3 ${o}`,_;e[24]===i?_=e[25]:(_=i&&(0,O.jsx)(Oa,{className:"ml-1 inline",shortcut:i}),e[24]=i,e[25]=_);let E;return e[26]!==a||e[27]!==r||e[28]!==g||e[29]!==m||e[30]!==_||e[31]!==c?(E=(0,O.jsxs)(Qe,{variant:"text",size:g,disabled:a,onClick:r,className:m,children:[c,_]}),e[26]=a,e[27]=r,e[28]=g,e[29]=m,e[30]=_,e[31]=c,e[32]=E):E=e[32],E},On=t=>{let e=(0,Cr.c)(8),{onDecline:a,multipleCompletions:r,size:s,className:n,declineShortcut:o,borderless:i}=t,l=r===void 0?!1:r,d=s===void 0?"sm":s,u=`h-6 text-(--red-10) bg-(--red-3)/60 hover:bg-(--red-3)
87
87
  dark:bg-(--red-4)/80 dark:hover:bg-(--red-3) rounded px-3 font-semibold
88
88
  active:bg-(--red-5) dark:active:bg-(--red-4)
89
- border-(--red-6) border hover:shadow-xs ${(i===void 0?!1:i)&&"border-none rounded-md"} ${n}`,p=l&&" all",g;e[0]===o?g=e[1]:(g=o&&(0,O.jsx)(Oa,{className:"ml-1 inline",shortcut:o}),e[0]=o,e[1]=g);let h;return e[2]!==a||e[3]!==d||e[4]!==u||e[5]!==p||e[6]!==g?(h=(0,O.jsxs)(Qe,{variant:"text",size:d,onClick:a,className:u,children:["Reject",p,g]}),e[2]=a,e[3]=d,e[4]=u,e[5]=p,e[6]=g,e[7]=h):h=e[7],h};var Yu=class extends er{constructor(t,e){super(t),this.onChunkReceived=e}processResponseStream(t){let e=this.onChunkReceived;return super.processResponseStream(t).pipeThrough(new TransformStream({async transform(a,r){e(a),r.enqueue(a)}}))}},An=Ea(),Hu=ti("marimo:ai-language","python",oi),Rn="marimo:ai-prompt-history",Nn=new Xn(Ve(k()),()=>[]);const Gu=t=>{let e=(0,An.c)(82),{onClose:a}=t,r=Rr(),[s,n]=(0,A.useState)(""),{deleteAllStagedCells:o,clearStagedCells:i,onStream:l,addStagedCell:d}=gn(r),[u,p]=Bn(Hu),g=yi(),{invokeAiTool:h,sendRun:b}=Oi(),f=Kn(Zt),c=(0,A.useRef)(null),{createNewCell:m,prepareForRun:_}=Pr(),E;e[0]!==d||e[1]!==m||e[2]!==_||e[3]!==b||e[4]!==r?(E={store:r,addStagedCell:d,createNewCell:m,prepareForRun:_,sendRun:b},e[0]=d,e[1]=m,e[2]=_,e[3]=b,e[4]=r,e[5]=E):E=e[5];let C=E,I;if(e[6]!==u||e[7]!==l||e[8]!==g){let Ee;e[10]===u?Ee=e[11]:(Ee=async qt=>{let zn=await bn(qt.messages);return{body:{...qt,...zn,code:"",prompt:"",language:u}}},e[10]=u,e[11]=Ee);let He;e[12]===l?He=e[13]:(He=qt=>{l(qt)},e[12]=l,e[13]=He),I=new Yu({api:g.getAiURL("completion").toString(),headers:g.headers(),prepareSendMessagesRequest:Ee},He),e[6]=u,e[7]=l,e[8]=g,e[9]=I}else I=e[9];let{sendMessage:P,stop:D,status:M,addToolOutput:H}=ln({experimental_throttle:100,transport:I,onToolCall:async Ee=>{let{toolCall:He}=Ee;await xn({invokeAiTool:h,addToolOutput:j,toolCall:{toolName:He.toolName,toolCallId:He.toolCallId,input:He.input},toolContext:C})},onError:Qu}),j=H,F=M==="streaming"||M==="submitted",K=f.size>0,X;e[14]!==o||e[15]!==s||e[16]!==F||e[17]!==P?(X=()=>{var Ee;F||((Ee=c.current)!=null&&Ee.view&&kn(c.current.view),o(),P({text:s}))},e[14]=o,e[15]=s,e[16]=F,e[17]=P,e[18]=X):X=e[18];let W=X,J;e[19]===Symbol.for("react.memo_cache_sentinel")?(J=(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(ro,{className:"size-4 mr-2"}),"Python"]}),e[19]=J):J=e[19];let te=J,ie;e[20]===Symbol.for("react.memo_cache_sentinel")?(ie=(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(Qn,{className:"size-4 mr-2"}),"SQL"]}),e[20]=ie):ie=e[20];let ae=ie,Ye=u==="python"?te:ae,ke;e[21]===Symbol.for("react.memo_cache_sentinel")?(ke=(0,O.jsx)(Mi,{className:"ml-1 h-3.5 w-3.5 text-muted-foreground/70"}),e[21]=ke):ke=e[21];let ye;e[22]===Ye?ye=e[23]:(ye=(0,O.jsx)($i,{asChild:!0,children:(0,O.jsxs)(Qe,{variant:"text",className:"ml-2",size:"xs","data-testid":"language-button",children:[Ye,ke]})}),e[22]=Ye,e[23]=ye);let be,De;e[24]===Symbol.for("react.memo_cache_sentinel")?(be=(0,O.jsx)("div",{className:"px-2 py-1 font-semibold",children:"Select language"}),De=(0,O.jsx)(ji,{}),e[24]=be,e[25]=De):(be=e[24],De=e[25]);let Ne;e[26]===p?Ne=e[27]:(Ne=(0,O.jsx)(Jr,{onClick:()=>p("python"),children:te}),e[26]=p,e[27]=Ne);let Ce;e[28]===p?Ce=e[29]:(Ce=(0,O.jsx)(Jr,{onClick:()=>p("sql"),children:ae}),e[28]=p,e[29]=Ce);let Ze;e[30]!==Ne||e[31]!==Ce?(Ze=(0,O.jsxs)(Li,{align:"center",children:[be,De,Ne,Ce]}),e[30]=Ne,e[31]=Ce,e[32]=Ze):Ze=e[32];let nt;e[33]!==ye||e[34]!==Ze?(nt=(0,O.jsxs)(Di,{modal:!1,children:[ye,Ze]}),e[33]=ye,e[34]=Ze,e[35]=nt):nt=e[35];let Tt=nt,ht;e[36]!==i||e[37]!==a?(ht=()=>{i(),a()},e[36]=i,e[37]=a,e[38]=ht):ht=e[38];let Fe=ht,it;e[39]===o?it=e[40]:(it=()=>{o()},e[39]=o,e[40]=it);let B=it,U;e[41]===Symbol.for("react.memo_cache_sentinel")?(U=(0,O.jsx)(zi,{className:"size-4 text-(--blue-11) mr-2"}),e[41]=U):U=e[41];let G;e[42]!==o||e[43]!==a?(G=()=>{o(),a()},e[42]=o,e[43]=a,e[44]=G):G=e[44];let V;e[45]===Symbol.for("react.memo_cache_sentinel")?(V=Ee=>{n(Ee)},e[45]=V):V=e[45];let me;e[46]!==Fe||e[47]!==B||e[48]!==K||e[49]!==F?(me=In({handleAcceptCompletion:Fe,handleDeclineCompletion:B,isLoading:F,hasCompletion:K}),e[46]=Fe,e[47]=B,e[48]=K,e[49]=F,e[50]=me):me=e[50];let he;e[51]!==s||e[52]!==W||e[53]!==G||e[54]!==me?(he=(0,O.jsx)(Mn,{inputRef:c,onClose:G,value:s,onChange:V,onSubmit:W,onKeyDown:me}),e[51]=s,e[52]=W,e[53]=G,e[54]=me,e[55]=he):he=e[55];let re;e[56]!==F||e[57]!==D?(re=F&&(0,O.jsxs)(Qe,{"data-testid":"stop-completion-button",variant:"text",size:"sm",className:"mb-0",onClick:D,children:[(0,O.jsx)(Fi,{className:"animate-spin mr-1",size:14}),"Stop"]}),e[56]=F,e[57]=D,e[58]=re):re=e[58];let ne;e[59]===Symbol.for("react.memo_cache_sentinel")?(ne=(0,O.jsx)(no,{className:"size-4"}),e[59]=ne):ne=e[59];let ce;e[60]===W?ce=e[61]:(ce=(0,O.jsx)(Qe,{variant:"text",size:"sm",onClick:W,title:"Submit",children:ne}),e[60]=W,e[61]=ce);let ot;e[62]===Symbol.for("react.memo_cache_sentinel")?(ot=(0,O.jsx)(Ni,{className:"size-4"}),e[62]=ot):ot=e[62];let ze;e[63]===a?ze=e[64]:(ze=(0,O.jsx)(Qe,{variant:"text",size:"sm",className:"mb-0 px-1",onClick:a,children:ot}),e[63]=a,e[64]=ze);let lt;e[65]!==he||e[66]!==re||e[67]!==ce||e[68]!==ze?(lt=(0,O.jsxs)("div",{className:"flex items-center px-3",children:[U,he,re,ce,ze]}),e[65]=he,e[66]=re,e[67]=ce,e[68]=ze,e[69]=lt):lt=e[69];let le=lt,fe;e[70]===Symbol.for("react.memo_cache_sentinel")?(fe=Ur("flex flex-col w-full py-2"),e[70]=fe):fe=e[70];let Me;e[71]===K?Me=e[72]:(Me=!K&&(0,O.jsx)("span",{className:"text-xs text-muted-foreground px-3 flex flex-col gap-1 mt-2",children:(0,O.jsxs)("span",{children:["You can mention"," ",(0,O.jsx)("span",{className:"text-(--cyan-11)",children:"@dataframe"})," or"," ",(0,O.jsx)("span",{className:"text-(--cyan-11)",children:"@sql_table"})," to pull additional context such as column names. Code from other cells is automatically included."]})}),e[71]=K,e[72]=Me);let ft;e[73]===Symbol.for("react.memo_cache_sentinel")?(ft=(0,O.jsx)(Ri,{triggerClassName:"h-7 text-xs max-w-64",iconSize:"small",forRole:"edit"}),e[73]=ft):ft=e[73];let Pe;e[74]===Tt?Pe=e[75]:(Pe=(0,O.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[Tt,ft]}),e[74]=Tt,e[75]=Pe);let gt;e[76]!==Me||e[77]!==Pe?(gt=(0,O.jsxs)("div",{className:"flex flex-row justify-between -mt-1 ml-1 mr-3",children:[Me,Pe]}),e[76]=Me,e[77]=Pe,e[78]=gt):gt=e[78];let Vt;return e[79]!==le||e[80]!==gt?(Vt=(0,O.jsxs)("div",{className:fe,children:[le,gt]}),e[79]=le,e[80]=gt,e[81]=Vt):Vt=e[81],Vt},Mn=t=>{let e=(0,An.c)(35),{value:a,placeholder:r,inputRef:s,className:n,onChange:o,onSubmit:i,onKeyDown:l,onClose:d,onAddFiles:u,additionalCompletions:p,maxHeight:g}=t,h=i,b=d,f=Rr(),{theme:c}=Bi(),m;e[0]===p?m=e[1]:(m=ie=>p?su([p.triggerCompletionRegex],p.completions)(ie):null,e[0]=p,e[1]=m);let _=Wn(m),E,C,I,P;if(e[2]!==_||e[3]!==u||e[4]!==f){let ie=qi();e[9]===Symbol.for("react.memo_cache_sentinel")?(E=Si({}),e[9]=E):E=e[9],C=ie,I=Ju({language:ie.language,store:f,onAddFiles:u}),P=ie.language.data.of({autocomplete:_}),e[2]=_,e[3]=u,e[4]=f,e[5]=E,e[6]=C,e[7]=I,e[8]=P}else E=e[5],C=e[6],I=e[7],P=e[8];let D;e[10]===Symbol.for("react.memo_cache_sentinel")?(D=Su({storage:{load:Xu,save:ec}}),e[10]=D):D=e[10];let M;e[11]===Symbol.for("react.memo_cache_sentinel")?(M=to(),e[11]=M):M=e[11];let H;e[12]===h?H=e[13]:(H=Vr.highest(Kt.of([{preventDefault:!0,stopPropagation:!0,any:(ie,ae)=>{let Ye=ae.metaKey||ae.ctrlKey||ae.shiftKey;if(ae.key==="Enter"&&!Ye)return h(ae,ie.state.doc.toString()),ae.preventDefault(),ae.stopPropagation(),!0;if(ae.key==="Enter"&&ae.shiftKey){let ke=ie.state.selection.main.from;return ie.dispatch({changes:{from:ke,to:ke,insert:`
89
+ border-(--red-6) border hover:shadow-xs ${(i===void 0?!1:i)&&"border-none rounded-md"} ${n}`,p=l&&" all",g;e[0]===o?g=e[1]:(g=o&&(0,O.jsx)(Oa,{className:"ml-1 inline",shortcut:o}),e[0]=o,e[1]=g);let h;return e[2]!==a||e[3]!==d||e[4]!==u||e[5]!==p||e[6]!==g?(h=(0,O.jsxs)(Qe,{variant:"text",size:d,onClick:a,className:u,children:["Reject",p,g]}),e[2]=a,e[3]=d,e[4]=u,e[5]=p,e[6]=g,e[7]=h):h=e[7],h};var Yu=class extends er{constructor(t,e){super(t),this.onChunkReceived=e}processResponseStream(t){let e=this.onChunkReceived;return super.processResponseStream(t).pipeThrough(new TransformStream({async transform(a,r){e(a),r.enqueue(a)}}))}},An=Ea(),Hu=ui("marimo:ai-language","python",di),Rn="marimo:ai-prompt-history",Nn=new ei(Ve(k()),()=>[]);const Gu=t=>{let e=(0,An.c)(82),{onClose:a}=t,r=Rr(),[s,n]=(0,A.useState)(""),{deleteAllStagedCells:o,clearStagedCells:i,onStream:l,addStagedCell:d}=gn(r),[u,p]=Bn(Hu),g=yi(),{invokeAiTool:h,sendRun:b}=Oi(),f=Kn(Zt),c=(0,A.useRef)(null),{createNewCell:m,prepareForRun:_}=$r(),E;e[0]!==d||e[1]!==m||e[2]!==_||e[3]!==b||e[4]!==r?(E={store:r,addStagedCell:d,createNewCell:m,prepareForRun:_,sendRun:b},e[0]=d,e[1]=m,e[2]=_,e[3]=b,e[4]=r,e[5]=E):E=e[5];let C=E,I;if(e[6]!==u||e[7]!==l||e[8]!==g){let Ee;e[10]===u?Ee=e[11]:(Ee=async qt=>{let zn=await bn(qt.messages);return{body:{...qt,...zn,code:"",prompt:"",language:u}}},e[10]=u,e[11]=Ee);let He;e[12]===l?He=e[13]:(He=qt=>{l(qt)},e[12]=l,e[13]=He),I=new Yu({api:g.getAiURL("completion").toString(),headers:g.headers(),prepareSendMessagesRequest:Ee},He),e[6]=u,e[7]=l,e[8]=g,e[9]=I}else I=e[9];let{sendMessage:P,stop:D,status:M,addToolOutput:H}=ln({experimental_throttle:100,transport:I,onToolCall:async Ee=>{let{toolCall:He}=Ee;await xn({invokeAiTool:h,addToolOutput:j,toolCall:{toolName:He.toolName,toolCallId:He.toolCallId,input:He.input},toolContext:C})},onError:Qu}),j=H,F=M==="streaming"||M==="submitted",K=f.size>0,X;e[14]!==o||e[15]!==s||e[16]!==F||e[17]!==P?(X=()=>{var Ee;F||((Ee=c.current)!=null&&Ee.view&&kn(c.current.view),o(),P({text:s}))},e[14]=o,e[15]=s,e[16]=F,e[17]=P,e[18]=X):X=e[18];let W=X,J;e[19]===Symbol.for("react.memo_cache_sentinel")?(J=(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(ro,{className:"size-4 mr-2"}),"Python"]}),e[19]=J):J=e[19];let te=J,ie;e[20]===Symbol.for("react.memo_cache_sentinel")?(ie=(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(Xn,{className:"size-4 mr-2"}),"SQL"]}),e[20]=ie):ie=e[20];let ae=ie,Ye=u==="python"?te:ae,ke;e[21]===Symbol.for("react.memo_cache_sentinel")?(ke=(0,O.jsx)(Mi,{className:"ml-1 h-3.5 w-3.5 text-muted-foreground/70"}),e[21]=ke):ke=e[21];let ye;e[22]===Ye?ye=e[23]:(ye=(0,O.jsx)($i,{asChild:!0,children:(0,O.jsxs)(Qe,{variant:"text",className:"ml-2",size:"xs","data-testid":"language-button",children:[Ye,ke]})}),e[22]=Ye,e[23]=ye);let be,De;e[24]===Symbol.for("react.memo_cache_sentinel")?(be=(0,O.jsx)("div",{className:"px-2 py-1 font-semibold",children:"Select language"}),De=(0,O.jsx)(ji,{}),e[24]=be,e[25]=De):(be=e[24],De=e[25]);let Ne;e[26]===p?Ne=e[27]:(Ne=(0,O.jsx)(Jr,{onClick:()=>p("python"),children:te}),e[26]=p,e[27]=Ne);let Ce;e[28]===p?Ce=e[29]:(Ce=(0,O.jsx)(Jr,{onClick:()=>p("sql"),children:ae}),e[28]=p,e[29]=Ce);let Ze;e[30]!==Ne||e[31]!==Ce?(Ze=(0,O.jsxs)(Li,{align:"center",children:[be,De,Ne,Ce]}),e[30]=Ne,e[31]=Ce,e[32]=Ze):Ze=e[32];let nt;e[33]!==ye||e[34]!==Ze?(nt=(0,O.jsxs)(Di,{modal:!1,children:[ye,Ze]}),e[33]=ye,e[34]=Ze,e[35]=nt):nt=e[35];let Tt=nt,ht;e[36]!==i||e[37]!==a?(ht=()=>{i(),a()},e[36]=i,e[37]=a,e[38]=ht):ht=e[38];let Fe=ht,it;e[39]===o?it=e[40]:(it=()=>{o()},e[39]=o,e[40]=it);let B=it,U;e[41]===Symbol.for("react.memo_cache_sentinel")?(U=(0,O.jsx)(zi,{className:"size-4 text-(--blue-11) mr-2"}),e[41]=U):U=e[41];let G;e[42]!==o||e[43]!==a?(G=()=>{o(),a()},e[42]=o,e[43]=a,e[44]=G):G=e[44];let V;e[45]===Symbol.for("react.memo_cache_sentinel")?(V=Ee=>{n(Ee)},e[45]=V):V=e[45];let me;e[46]!==Fe||e[47]!==B||e[48]!==K||e[49]!==F?(me=In({handleAcceptCompletion:Fe,handleDeclineCompletion:B,isLoading:F,hasCompletion:K}),e[46]=Fe,e[47]=B,e[48]=K,e[49]=F,e[50]=me):me=e[50];let he;e[51]!==s||e[52]!==W||e[53]!==G||e[54]!==me?(he=(0,O.jsx)(Mn,{inputRef:c,onClose:G,value:s,onChange:V,onSubmit:W,onKeyDown:me}),e[51]=s,e[52]=W,e[53]=G,e[54]=me,e[55]=he):he=e[55];let re;e[56]!==F||e[57]!==D?(re=F&&(0,O.jsxs)(Qe,{"data-testid":"stop-completion-button",variant:"text",size:"sm",className:"mb-0",onClick:D,children:[(0,O.jsx)(Fi,{className:"animate-spin mr-1",size:14}),"Stop"]}),e[56]=F,e[57]=D,e[58]=re):re=e[58];let ne;e[59]===Symbol.for("react.memo_cache_sentinel")?(ne=(0,O.jsx)(no,{className:"size-4"}),e[59]=ne):ne=e[59];let ce;e[60]===W?ce=e[61]:(ce=(0,O.jsx)(Qe,{variant:"text",size:"sm",onClick:W,title:"Submit",children:ne}),e[60]=W,e[61]=ce);let ot;e[62]===Symbol.for("react.memo_cache_sentinel")?(ot=(0,O.jsx)(Ni,{className:"size-4"}),e[62]=ot):ot=e[62];let ze;e[63]===a?ze=e[64]:(ze=(0,O.jsx)(Qe,{variant:"text",size:"sm",className:"mb-0 px-1",onClick:a,children:ot}),e[63]=a,e[64]=ze);let lt;e[65]!==he||e[66]!==re||e[67]!==ce||e[68]!==ze?(lt=(0,O.jsxs)("div",{className:"flex items-center px-3",children:[U,he,re,ce,ze]}),e[65]=he,e[66]=re,e[67]=ce,e[68]=ze,e[69]=lt):lt=e[69];let le=lt,fe;e[70]===Symbol.for("react.memo_cache_sentinel")?(fe=Ur("flex flex-col w-full py-2"),e[70]=fe):fe=e[70];let Me;e[71]===K?Me=e[72]:(Me=!K&&(0,O.jsx)("span",{className:"text-xs text-muted-foreground px-3 flex flex-col gap-1 mt-2",children:(0,O.jsxs)("span",{children:["You can mention"," ",(0,O.jsx)("span",{className:"text-(--cyan-11)",children:"@dataframe"})," or"," ",(0,O.jsx)("span",{className:"text-(--cyan-11)",children:"@sql_table"})," to pull additional context such as column names. Code from other cells is automatically included."]})}),e[71]=K,e[72]=Me);let ft;e[73]===Symbol.for("react.memo_cache_sentinel")?(ft=(0,O.jsx)(Ri,{triggerClassName:"h-7 text-xs max-w-64",iconSize:"small",forRole:"edit"}),e[73]=ft):ft=e[73];let Pe;e[74]===Tt?Pe=e[75]:(Pe=(0,O.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[Tt,ft]}),e[74]=Tt,e[75]=Pe);let gt;e[76]!==Me||e[77]!==Pe?(gt=(0,O.jsxs)("div",{className:"flex flex-row justify-between -mt-1 ml-1 mr-3",children:[Me,Pe]}),e[76]=Me,e[77]=Pe,e[78]=gt):gt=e[78];let Vt;return e[79]!==le||e[80]!==gt?(Vt=(0,O.jsxs)("div",{className:fe,children:[le,gt]}),e[79]=le,e[80]=gt,e[81]=Vt):Vt=e[81],Vt},Mn=t=>{let e=(0,An.c)(35),{value:a,placeholder:r,inputRef:s,className:n,onChange:o,onSubmit:i,onKeyDown:l,onClose:d,onAddFiles:u,additionalCompletions:p,maxHeight:g}=t,h=i,b=d,f=Rr(),{theme:c}=Bi(),m;e[0]===p?m=e[1]:(m=ie=>p?su([p.triggerCompletionRegex],p.completions)(ie):null,e[0]=p,e[1]=m);let _=Wn(m),E,C,I,P;if(e[2]!==_||e[3]!==u||e[4]!==f){let ie=qi();e[9]===Symbol.for("react.memo_cache_sentinel")?(E=Si({}),e[9]=E):E=e[9],C=ie,I=Ju({language:ie.language,store:f,onAddFiles:u}),P=ie.language.data.of({autocomplete:_}),e[2]=_,e[3]=u,e[4]=f,e[5]=E,e[6]=C,e[7]=I,e[8]=P}else E=e[5],C=e[6],I=e[7],P=e[8];let D;e[10]===Symbol.for("react.memo_cache_sentinel")?(D=Su({storage:{load:Xu,save:ec}}),e[10]=D):D=e[10];let M;e[11]===Symbol.for("react.memo_cache_sentinel")?(M=to(),e[11]=M):M=e[11];let H;e[12]===h?H=e[13]:(H=Vr.highest(Kt.of([{preventDefault:!0,stopPropagation:!0,any:(ie,ae)=>{let Ye=ae.metaKey||ae.ctrlKey||ae.shiftKey;if(ae.key==="Enter"&&!Ye)return h(ae,ie.state.doc.toString()),ae.preventDefault(),ae.stopPropagation(),!0;if(ae.key==="Enter"&&ae.shiftKey){let ke=ie.state.selection.main.from;return ie.dispatch({changes:{from:ke,to:ke,insert:`
90
90
  `},selection:{anchor:ke+1,head:ke+1}}),ae.preventDefault(),ae.stopPropagation(),!0}return!1}}])),e[12]=h,e[13]=H);let j;e[14]===b?j=e[15]:(j=Kt.of([{key:"Escape",preventDefault:!0,stopPropagation:!0,run:()=>(b(),!0)}]),e[14]=b,e[15]=j);let F;e[16]!==E||e[17]!==C||e[18]!==I||e[19]!==P||e[20]!==H||e[21]!==j?(F=[E,C,I,P,D,qr.lineWrapping,M,H,j],e[16]=E,e[17]=C,e[18]=I,e[19]=P,e[20]=H,e[21]=j,e[22]=F):F=e[22];let K=F,X;e[23]===n?X=e[24]:(X=Ur("flex-1 font-sans overflow-auto my-1",n),e[23]=n,e[24]=X);let W=c==="dark"?"dark":"light",J=r||"Generate with AI, @ to include context",te;return e[25]!==K||e[26]!==s||e[27]!==g||e[28]!==o||e[29]!==l||e[30]!==X||e[31]!==W||e[32]!==J||e[33]!==a?(te=(0,O.jsx)(ao,{ref:s,className:X,width:"100%",maxHeight:g,value:a,basicSetup:!1,extensions:K,onChange:o,onKeyDown:l,theme:W,placeholder:J}),e[25]=K,e[26]=s,e[27]=g,e[28]=o,e[29]=l,e[30]=X,e[31]=W,e[32]=J,e[33]=a,e[34]=te):te=e[34],te};function Qu(t){Kr({title:"Generate with AI failed",description:Ki(t)})}function Xu(){return Nn.get(Rn)}function ec(t){return Nn.set(Rn,t)}export{mt as C,ed as D,er as E,io as O,tu as S,Vd as T,Zt as _,On as a,eu as b,bn as c,xn as d,ku as f,_r as g,_u as h,Ku as i,so as k,xu as l,br as m,Mn as n,In as o,wu as p,Sn as r,kn as s,Gu as t,bu as u,fn as v,ln as w,nu as x,gn as y};