@marimo-team/frontend 0.21.2-dev5 → 0.21.2-dev53
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.
- package/dist/assets/{CellStatus-CDSBsjjF.js → CellStatus-DX8MnBMk.js} +1 -1
- package/dist/assets/{ConnectedDataExplorerComponent-Buaffg3u.js → ConnectedDataExplorerComponent-7yXYooWG.js} +1 -1
- package/dist/assets/{DeferredRequestRegistry-O6RDJKs0.js → DeferredRequestRegistry-B8jPCuU1.js} +1 -1
- package/dist/assets/{ImperativeModal-qEtcJ95s.js → ImperativeModal-C3CD5-Aq.js} +1 -1
- package/dist/assets/JsonOutput-DqjAyzM8.js +46 -0
- package/dist/assets/{LazyAnyLanguageCodeMirror-m8w66E4s.js → LazyAnyLanguageCodeMirror-CcCHIX38.js} +2 -2
- package/dist/assets/{MarimoErrorOutput-az74f3Mp.js → MarimoErrorOutput-Dat_S09q.js} +5 -5
- package/dist/assets/RenderHTML-C7XM39M2.js +1 -0
- package/dist/assets/{add-cell-with-ai-DUn4LN4W.js → add-cell-with-ai-y2xroEGf.js} +9 -9
- package/dist/assets/{add-connection-dialog-CBz0AUVX.js → add-connection-dialog-QDBOmil3.js} +23 -23
- package/dist/assets/{agent-panel-u83dsDsM.js → agent-panel-DziFrEjJ.js} +6 -6
- package/dist/assets/ai-model-dropdown-CiJpv5wN.js +5 -0
- package/dist/assets/{alert-dialog-9WfvUF7e.js → alert-dialog-ebk_-wsU.js} +1 -1
- package/dist/assets/{any-language-editor-DwQMnAM3.js → any-language-editor-DZYnKlJB.js} +1 -1
- package/dist/assets/{app-config-button-rDu-lCIB.js → app-config-button-CpAv9Tiu.js} +1 -1
- package/dist/assets/{architectureDiagram-VXUJARFQ-DfMHHFZ3.js → architectureDiagram-VXUJARFQ-DKmk99ac.js} +1 -1
- package/dist/assets/{azure-BTXHztTw.js → azure-Dw5gKmUz.js} +1 -1
- package/dist/assets/{blockDiagram-VD42YOAC-CuEDwbg7.js → blockDiagram-VD42YOAC-TpAhP5OQ.js} +1 -1
- package/dist/assets/{c4Diagram-YG6GDRKO-CD9uz7WG.js → c4Diagram-YG6GDRKO-Dg8hCyKf.js} +1 -1
- package/dist/assets/{cache-panel-qIxnndwr.js → cache-panel-D0OsHk_D.js} +1 -1
- package/dist/assets/cell-editor-RbAVpSFb.js +22 -0
- package/dist/assets/{cell-link-Q_UEP94Z.js → cell-link-CNgO3c-T.js} +1 -1
- package/dist/assets/{cells-fq1RMGX_.js → cells-39RE4UzS.js} +77 -76
- package/dist/assets/channel-D1wPYhc9.js +1 -0
- package/dist/assets/{chat-display-D_Fuuy6r.js → chat-display-BPUVrlA6.js} +1 -1
- package/dist/assets/{chat-panel-BO-JoQSp.js → chat-panel-esz5TfF-.js} +2 -2
- package/dist/assets/{chunk-5FQGJX7Z-CM1a_K7I.js → chunk-5FQGJX7Z-sGWxL7Ey.js} +3 -3
- package/dist/assets/{chunk-ABZYJK2D-D_Wumzom.js → chunk-ABZYJK2D-DXJ7hnjx.js} +1 -1
- package/dist/assets/{chunk-ATLVNIR6-BZ0lTgIn.js → chunk-ATLVNIR6-CTEqcLEc.js} +1 -1
- package/dist/assets/{chunk-B4BG7PRW-Dw1S6osV.js → chunk-B4BG7PRW-CkAIqtPf.js} +1 -1
- package/dist/assets/{chunk-DI55MBZ5-Q63FTCPP.js → chunk-DI55MBZ5-C4F9vu8o.js} +1 -1
- package/dist/assets/{chunk-EXTU4WIE-CfkJ_R7W.js → chunk-EXTU4WIE-BT0Py-4P.js} +1 -1
- package/dist/assets/{chunk-JA3XYJ7Z-B41fGeoj.js → chunk-JA3XYJ7Z-CGd7jja_.js} +1 -1
- package/dist/assets/{chunk-JZLCHNYA-D43EJxQw.js → chunk-JZLCHNYA-CqY-RYTj.js} +1 -1
- package/dist/assets/{chunk-N4CR4FBY-DCtw0-ni.js → chunk-N4CR4FBY-aUDjVzN7.js} +2 -2
- package/dist/assets/{chunk-QN33PNHL-CLA2rsaS.js → chunk-QN33PNHL-DHnCb5-U.js} +1 -1
- package/dist/assets/{chunk-QXUST7PY-De1DpbnL.js → chunk-QXUST7PY-CRO5kYCE.js} +1 -1
- package/dist/assets/{chunk-S3R3BYOJ-qrwvlUdq.js → chunk-S3R3BYOJ-CSHQgcuP.js} +1 -1
- package/dist/assets/{chunk-TZMSLE5B-C4KcThb0.js → chunk-TZMSLE5B-CE7o9asH.js} +1 -1
- package/dist/assets/classDiagram-2ON5EDUG-BDIQSKYv.js +1 -0
- package/dist/assets/classDiagram-v2-WZHVMYZB-Cdh4cVOB.js +1 -0
- package/dist/assets/{code-block-37QAKDTI-D4FF4cnN.js → code-block-37QAKDTI-DMpe1jNG.js} +1 -1
- package/dist/assets/{column-preview-WsubyItX.js → column-preview-BUKHsglA.js} +1 -1
- package/dist/assets/{command-rfxSsiHU.js → command-DmzEbs6L.js} +1 -1
- package/dist/assets/{command-palette-Bez4BqJF.js → command-palette-BX5gNpUr.js} +1 -1
- package/dist/assets/{common-BYwO983A.js → common-B4yshY-H.js} +1 -1
- package/dist/assets/{components-Ozq0825a.js → components-DCqJqyys.js} +1 -1
- package/dist/assets/{components-Bpgzv_5_.js → components-oKCjx6cN.js} +1 -1
- package/dist/assets/{config-3Aq84phF.js → config-DqxNMQDN.js} +1 -1
- package/dist/assets/{context-CIAP2NOh.js → context-CRmPPhx9.js} +1 -1
- package/dist/assets/{context-aware-panel-CfsfBlhO.js → context-aware-panel-DC0Te9Hj.js} +2 -2
- package/dist/assets/copy-KjcPgPw9.js +1 -0
- package/dist/assets/{copy-icon-BgmMM9Zg.js → copy-icon-P0kzz1Pr.js} +1 -1
- package/dist/assets/{dagre-6UL2VRFP-BhMnPhuU.js → dagre-6UL2VRFP-XqoNLMQ3.js} +1 -1
- package/dist/assets/{data-grid-overlay-editor-kbv73SQ7.js → data-grid-overlay-editor-Cus1-BFN.js} +1 -1
- package/dist/assets/{datasource-F9sJtuof.js → datasource-DKHG39NV.js} +2 -2
- package/dist/assets/{dates-CHaNfieI.js → dates-CTqMeMGY.js} +1 -1
- package/dist/assets/{dependency-graph-panel-AOBcX2tP.js → dependency-graph-panel-7GKT3dyD.js} +4 -4
- package/dist/assets/{diagram-PSM6KHXK-Cr2t4zul.js → diagram-PSM6KHXK-BuzKNNcN.js} +1 -1
- package/dist/assets/{diagram-QEK2KX5R-DLU_hSO4.js → diagram-QEK2KX5R-A5LBQS11.js} +1 -1
- package/dist/assets/{diagram-S2PKOQOG-C7EkNAO3.js → diagram-S2PKOQOG-dkJE8SA0.js} +1 -1
- package/dist/assets/{dialog-CVN1lcMF.js → dialog-1_jIyAb_.js} +1 -1
- package/dist/assets/{dist-DJBpXGro.js → dist-6P6vjf93.js} +1 -1
- package/dist/assets/dist-BWGxTsTP.js +1 -0
- package/dist/assets/{dist-CblX3KGI.js → dist-B_buFm3B.js} +1 -1
- package/dist/assets/{dist-CXLJUPFl.js → dist-BatEf-0f.js} +1 -1
- package/dist/assets/dist-C3AnARPE.js +1 -0
- package/dist/assets/{dist-BNC_tnlW.js → dist-C6ohaMKU.js} +1 -1
- package/dist/assets/{dist-BoDHthoc.js → dist-CO9Pg2Rc.js} +1 -1
- package/dist/assets/{dist-By6zhkxZ.js → dist-CSV6H5w_.js} +1 -1
- package/dist/assets/{dist-6FIAeDIu.js → dist-CYs1oP7g.js} +1 -1
- package/dist/assets/{dist-DbK_4_qo.js → dist-DD9ZJMK5.js} +1 -1
- package/dist/assets/{dist-DlTbNRBn.js → dist-DReDpc2z.js} +1 -1
- package/dist/assets/dist-DSlq5ZeQ.js +1 -0
- package/dist/assets/{dist-DrceDAhM.js → dist-DXyIIB32.js} +1 -1
- package/dist/assets/{dist-CcGcwrUD.js → dist-DkaderFA.js} +1 -1
- package/dist/assets/{dist-BiZQlfhr.js → dist-Dq3BlK4R.js} +1 -1
- package/dist/assets/{dist-ClzRAVN-.js → dist-Dxov2ltb.js} +1 -1
- package/dist/assets/{dist-BXXPfIam.js → dist-EtGG9C1A.js} +1 -1
- package/dist/assets/{dist-C3MmXcLA.js → dist-NjId5Gdz.js} +1 -1
- package/dist/assets/dist-ZM59OWYL.js +1 -0
- package/dist/assets/dist-_TwZ4tIe.js +1 -0
- package/dist/assets/dist-f9b2H4q_.js +1 -0
- package/dist/assets/{dist-mxGLXOFm.js → dist-feWVQ4dq.js} +1 -1
- package/dist/assets/{documentation-panel-D28MpqbI.js → documentation-panel-D5d_BbHV.js} +1 -1
- package/dist/assets/{download-B9_ToVd4.js → download-B1vXaivj.js} +4 -4
- package/dist/assets/{dropdown-menu-DdPu5Kfu.js → dropdown-menu-BehqiLFL.js} +1 -1
- package/dist/assets/{edit-page-otS-QvnC.js → edit-page-B5cAZdO7.js} +7 -7
- package/dist/assets/{en-US-BO8E69bZ.js → en-US-f8tajDx1.js} +1 -1
- package/dist/assets/{erDiagram-Q2GNP2WA-DqlEo_Us.js → erDiagram-Q2GNP2WA-CgH6udOW.js} +1 -1
- package/dist/assets/{error-banner-BRG6IPhC.js → error-banner-J5F3weEj.js} +1 -1
- package/dist/assets/{error-panel-RRoj_iOR.js → error-panel-DnhKJ5Ou.js} +1 -1
- package/dist/assets/{es-CzkousWe.js → es-DYI7U61K.js} +1 -1
- package/dist/assets/{esm-CBkHtTOV.js → esm-BC1J92im.js} +1 -1
- package/dist/assets/{esm-DhTsVMLM.js → esm-DKLLCu3N.js} +1 -1
- package/dist/assets/{field-B1jGbQlH.js → field-B08lvxnl.js} +1 -1
- package/dist/assets/file-explorer-panel-BUk69TND.js +26 -0
- package/dist/assets/{file-icons-CWLHDa1J.js → file-icons-3DTS8ZM7.js} +1 -1
- package/dist/assets/{floating-outline-BvQKiC0F.js → floating-outline-DmugATcB.js} +1 -1
- package/dist/assets/{flowDiagram-NV44I4VS-CQlIJ12H.js → flowDiagram-NV44I4VS-D85BL4rA.js} +1 -1
- package/dist/assets/{focus-DYwTiH9-.js → focus-DlJH7sfh.js} +1 -1
- package/dist/assets/{form-CrQYrsUC.js → form-760_EqmF.js} +2 -2
- package/dist/assets/{formats-rhOJovGE.js → formats-wYuh1bqp.js} +1 -1
- package/dist/assets/{formatting-B4ZCH3ol.js → formatting-CraOPe94.js} +1 -1
- package/dist/assets/{gallery-page-eRea0yic.js → gallery-page--paiPvYX.js} +1 -1
- package/dist/assets/{ganttDiagram-JELNMOA3-B3EGIuZL.js → ganttDiagram-JELNMOA3-DzCOXWlF.js} +1 -1
- package/dist/assets/{gitGraphDiagram-V2S2FVAM-h5SlguJK.js → gitGraphDiagram-V2S2FVAM-BUHURX6t.js} +1 -1
- package/dist/assets/{glide-data-editor-xt5xNZeV.js → glide-data-editor-DYdoQTO5.js} +4 -4
- package/dist/assets/{globals-BsV5fVR-.js → globals-7M5DRsIb.js} +1 -1
- package/dist/assets/home-page-CxQ1e98h.js +4 -0
- package/dist/assets/{hooks-CHx5dUUq.js → hooks-C3jEff2O.js} +1 -1
- package/dist/assets/html-to-image-DTFXm6_Z.js +2 -0
- package/dist/assets/{index-GjXovVsl.css → index-BmoocKR0.css} +1 -1
- package/dist/assets/index-DNchElHl.js +38 -0
- package/dist/assets/{infoDiagram-HS3SLOUP-pzpClObZ.js → infoDiagram-HS3SLOUP-GG5r0Y5G.js} +1 -1
- package/dist/assets/{input-CUwqpKjd.js → input-CN1ZeRYm.js} +1 -1
- package/dist/assets/{isValid-BGe7pJXT.js → isValid-DY4Mgbr7.js} +1 -1
- package/dist/assets/{journeyDiagram-XKPGCS4Q-BrdRi92v.js → journeyDiagram-XKPGCS4Q-B1dvnV4D.js} +1 -1
- package/dist/assets/{kanban-definition-3W4ZIXB7-B6WqgFqh.js → kanban-definition-3W4ZIXB7-CefbrXQv.js} +1 -1
- package/dist/assets/{kiosk-mode-DNjEnIWb.js → kiosk-mode-CyTnrzwK.js} +1 -1
- package/dist/assets/{layout-CwFtCyW8.js → layout-3b3tzmbb.js} +3 -3
- package/dist/assets/{linear-BP9rwmWK.js → linear-BDnrHGYO.js} +1 -1
- package/dist/assets/{links-CIQwYQ48.js → links-CptYD1FP.js} +1 -1
- package/dist/assets/{logs-panel-BU1tNEVc.js → logs-panel-C4k_2IHW.js} +1 -1
- package/dist/assets/{markdown-renderer-MR9df58W.js → markdown-renderer-DSy5IuAx.js} +1 -1
- package/dist/assets/{menu-items-UxKrm8hS.js → menu-items-BpHXKv51.js} +1 -1
- package/dist/assets/mermaid-4DMBBIKO-g7AL4SLJ.js +1 -0
- package/dist/assets/{mermaid-Djr3jUAB.js → mermaid-C43VbdrM.js} +3 -3
- package/dist/assets/{mermaid-parser.core-DR82IMb2.js → mermaid-parser.core-CdM8D_p_.js} +1 -1
- package/dist/assets/{mindmap-definition-VGOIOE7T-DAmJpbPM.js → mindmap-definition-VGOIOE7T-CcV7D-wF.js} +1 -1
- package/dist/assets/{mode-AcL8c6qH.js → mode-D-iRbN9x.js} +1 -1
- package/dist/assets/{multi-map-Pp1P2DOX.js → multi-map-C8RbwBrw.js} +1 -1
- package/dist/assets/{name-cell-input-DVFEv_aO.js → name-cell-input-Dyb0ZO4X.js} +1 -1
- package/dist/assets/{number-overlay-editor-D__AflXQ.js → number-overlay-editor-BBJO1mf8.js} +1 -1
- package/dist/assets/{outline-panel-CP0oIuiU.js → outline-panel-D7CJwO8u.js} +1 -1
- package/dist/assets/{packages-panel-CzRELimG.js → packages-panel-Bp1SYjgc.js} +1 -1
- package/dist/assets/{panels-wTweRyIv.js → panels-D0aw6jdc.js} +1 -1
- package/dist/assets/{pieDiagram-ADFJNKIX-DbGIFRoq.js → pieDiagram-ADFJNKIX-C1fBf15W.js} +1 -1
- package/dist/assets/{popover-BPGG2gPG.js → popover-Bvoif-Mg.js} +1 -1
- package/dist/assets/{precisionRound-BOmLQIKI.js → precisionRound-CCOoIlcP.js} +1 -1
- package/dist/assets/{process-output-CTVsT--B.js → process-output-BxPWHcIi.js} +1 -1
- package/dist/assets/{quadrantDiagram-AYHSOK5B-CLAtyple.js → quadrantDiagram-AYHSOK5B-RVooN-fX.js} +1 -1
- package/dist/assets/{react-vega-BZav_-2n.js → react-vega-BKRQSy0g.js} +1 -1
- package/dist/assets/react-vega-DXESF7qN.js +1 -0
- package/dist/assets/{readonly-python-code-DH-1xZGq.js → readonly-python-code-D95oshJa.js} +1 -1
- package/dist/assets/{renderShortcut-CnD1Dah5.js → renderShortcut-BYvKm38e.js} +1 -1
- package/dist/assets/{request-registry-B-7cIM_I.js → request-registry-XB2EzJHm.js} +1 -1
- package/dist/assets/{requirementDiagram-UZGBJVZJ-DDDTB1LD.js → requirementDiagram-UZGBJVZJ-DtqOYJpH.js} +1 -1
- package/dist/assets/{run-page-FCvGnICa.js → run-page-B7CASued.js} +1 -1
- package/dist/assets/{sankeyDiagram-TZEHDZUN-DAWPOfBw.js → sankeyDiagram-TZEHDZUN-DmcooLA8.js} +1 -1
- package/dist/assets/{scratchpad-panel-k9lrm-rC.js → scratchpad-panel-BIVRgYOU.js} +1 -1
- package/dist/assets/{secrets-panel-B1Z-6dmz.js → secrets-panel-C24hZEiO.js} +1 -1
- package/dist/assets/{select-CxT2Geqr.js → select-Cnd3vm9n.js} +1 -1
- package/dist/assets/{sequenceDiagram-WL72ISMW-D_qAidD2.js → sequenceDiagram-WL72ISMW-S2qeLb7J.js} +1 -1
- package/dist/assets/{session-panel-WhN0qilM.js → session-panel-CNabBHQm.js} +1 -1
- package/dist/assets/{share-BdH_5I58.js → share-NjpZ54PJ.js} +1 -1
- package/dist/assets/{snippets-panel-BCDHUuku.js → snippets-panel-D1JAeJj1.js} +1 -1
- package/dist/assets/{spec-DbmSqx09.js → spec-DnVBmJUh.js} +1 -1
- package/dist/assets/{state-Ce7CVShi.js → state-BagvlaEz.js} +1 -1
- package/dist/assets/{state-3V5UxC3B.js → state-Cz_wrzCz.js} +1 -1
- package/dist/assets/{state-CBmCYWFH.js → state-DMQXxemS.js} +1 -1
- package/dist/assets/{stateDiagram-FKZM4ZOC-C7qgDrGA.js → stateDiagram-FKZM4ZOC-uuQ60pIl.js} +1 -1
- package/dist/assets/stateDiagram-v2-4FDKWEC3-D-GWhQTG.js +1 -0
- package/dist/assets/stex-CruVQx-P.js +1 -0
- package/dist/assets/{switch-CVKxYu_0.js → switch-Bwpd2AFq.js} +1 -1
- package/dist/assets/{terminal-Cr7wbEjz.js → terminal-Gl8Fi44y.js} +1 -1
- package/dist/assets/{time-D2GKc0U6.js → time-Bw8f15NM.js} +1 -1
- package/dist/assets/{timeline-definition-IT6M3QCI-hd6uJKGs.js → timeline-definition-IT6M3QCI-TKWeDnSQ.js} +1 -1
- package/dist/assets/{toggle-RCwU-rnE.js → toggle-C_gNjXg8.js} +1 -1
- package/dist/assets/{tooltip-D9723Brr.js → tooltip-CR_izE8Q.js} +1 -1
- package/dist/assets/tracing-DwAC7DWN.js +1 -0
- package/dist/assets/tracing-panel-D1iNgclL.js +2 -0
- package/dist/assets/{tree-Ch2-GuhG.js → tree-WVrWjdwv.js} +3 -3
- package/dist/assets/{useAddCell-YC7rpcmD.js → useAddCell-D6Q7JziZ.js} +1 -1
- package/dist/assets/{useBoolean-m1e6E3Ao.js → useBoolean-CrltYVhE.js} +1 -1
- package/dist/assets/{useCellActionButton-GUb2fXU8.js → useCellActionButton-B2G9OaX9.js} +1 -1
- package/dist/assets/{useDateFormatter-CpE7XQLs.js → useDateFormatter-DOoVZUts.js} +1 -1
- package/dist/assets/{useDeleteCell-DRUDRiy0.js → useDeleteCell-d8veThW7.js} +1 -1
- package/dist/assets/{useDependencyPanelTab-nFVMlEx0.js → useDependencyPanelTab-B3iIj3MO.js} +1 -1
- package/dist/assets/{useInstallPackage-C9V-on2J.js → useInstallPackage-CQEr5429.js} +1 -1
- package/dist/assets/{useNotebookActions-ChLHy-0O.js → useNotebookActions-SAEOWcBo.js} +1 -1
- package/dist/assets/{useNumberFormatter-DbDKSvEd.js → useNumberFormatter-BXZcbTzH.js} +1 -1
- package/dist/assets/{usePress-BHGkpw8X.js → usePress-alQ5Crny.js} +1 -1
- package/dist/assets/{useRunCells-5m6jCnyo.js → useRunCells-Dhl8ZTGh.js} +1 -1
- package/dist/assets/{useSplitCell-DGD9smMq.js → useSplitCell-BSnFazbH.js} +1 -1
- package/dist/assets/{utils-CdjCA1J8.js → utils-C24l2A1T.js} +1 -1
- package/dist/assets/{vega-component-CRbeDmeM.js → vega-component-9Pf4pVZL.js} +1 -1
- package/dist/assets/{vega-loader.browser-CZV6_g2i.js → vega-loader.browser-BJ9oKrvH.js} +1 -1
- package/dist/assets/{write-secret-modal-BCvuRAFb.js → write-secret-modal-BFCsWMoW.js} +1 -1
- package/dist/assets/{xychartDiagram-PRI3JC2R-CXlUBSbQ.js → xychartDiagram-PRI3JC2R-CIp-yeSa.js} +1 -1
- package/dist/index.html +125 -125
- package/package.json +1 -1
- package/src/__mocks__/notebook.ts +9 -9
- package/src/__tests__/branded.ts +20 -0
- package/src/components/app-config/user-config-form.tsx +5 -4
- package/src/components/data-table/__tests__/utils.test.ts +138 -1
- package/src/components/data-table/charts/__tests__/storage.test.ts +7 -7
- package/src/components/data-table/context-menu.tsx +9 -5
- package/src/components/data-table/data-table.tsx +3 -0
- package/src/components/data-table/range-focus/__tests__/atoms.test.ts +8 -2
- package/src/components/data-table/range-focus/__tests__/test-utils.ts +2 -0
- package/src/components/data-table/range-focus/__tests__/utils.test.ts +82 -8
- package/src/components/data-table/range-focus/atoms.ts +2 -2
- package/src/components/data-table/range-focus/utils.ts +50 -12
- package/src/components/data-table/types.ts +7 -0
- package/src/components/data-table/utils.ts +87 -0
- package/src/components/editor/__tests__/data-attributes.test.tsx +8 -8
- package/src/components/editor/ai/__tests__/completion-utils.test.ts +15 -15
- package/src/components/editor/navigation/__tests__/clipboard.test.ts +2 -2
- package/src/components/editor/navigation/__tests__/selection.test.ts +7 -6
- package/src/components/editor/navigation/__tests__/state.test.ts +8 -7
- package/src/components/editor/output/MarimoErrorOutput.tsx +7 -7
- package/src/components/editor/output/__tests__/traceback.test.tsx +4 -4
- package/src/components/editor/output/console/__tests__/ConsoleOutput.test.tsx +4 -4
- package/src/components/editor/renderers/vertical-layout/useFocusFirstEditor.ts +8 -1
- package/src/components/storage/storage-file-viewer.tsx +35 -1
- package/src/components/storage/storage-inspector.tsx +9 -4
- package/src/components/storage/storage-snippets.ts +3 -3
- package/src/components/tracing/tracing.tsx +3 -1
- package/src/components/ui/range-slider.tsx +108 -1
- package/src/core/ai/__tests__/staged-cells.test.ts +9 -8
- package/src/core/ai/context/providers/__tests__/cell-output.test.ts +31 -31
- package/src/core/ai/context/providers/__tests__/datasource.test.ts +3 -3
- package/src/core/ai/context/providers/__tests__/tables.test.ts +3 -2
- package/src/core/ai/context/providers/__tests__/variable.test.ts +84 -63
- package/src/core/ai/tools/__tests__/edit-notebook-tool.test.ts +10 -9
- package/src/core/ai/tools/__tests__/run-cells-tool.test.ts +6 -6
- package/src/core/ai/tools/edit-notebook-tool.ts +3 -3
- package/src/core/cells/__tests__/add-missing-import.test.ts +3 -3
- package/src/core/cells/__tests__/cells.test.ts +192 -135
- package/src/core/cells/__tests__/focus.test.ts +5 -4
- package/src/core/cells/__tests__/logs.test.ts +13 -12
- package/src/core/cells/__tests__/pending-delete-service.test.tsx +3 -3
- package/src/core/cells/__tests__/runs.test.ts +22 -21
- package/src/core/cells/__tests__/scrollCellIntoView.test.ts +8 -7
- package/src/core/cells/__tests__/session.test.ts +23 -22
- package/src/core/cells/cells.ts +1 -1
- package/src/core/cells/ids.ts +5 -5
- package/src/core/cells/logs.ts +2 -2
- package/src/core/cells/runs.ts +6 -8
- package/src/core/codemirror/__tests__/format.test.ts +34 -36
- package/src/core/codemirror/__tests__/setup.test.ts +2 -2
- package/src/core/codemirror/cells/__tests__/extensions.test.ts +114 -0
- package/src/core/codemirror/cells/__tests__/traceback-decorations.test.ts +33 -32
- package/src/core/codemirror/cells/extensions.ts +66 -23
- package/src/core/codemirror/completion/__tests__/keymap.test.ts +15 -35
- package/src/core/codemirror/completion/keymap.ts +14 -4
- package/src/core/codemirror/copilot/__tests__/getCodes.test.ts +12 -13
- package/src/core/codemirror/language/__tests__/utils.test.ts +3 -3
- package/src/core/codemirror/language/embedded/__tests__/embedded-python.test.ts +7 -8
- package/src/core/codemirror/language/languages/python.ts +4 -0
- package/src/core/codemirror/lsp/__tests__/notebook-lsp.test.ts +4 -3
- package/src/core/codemirror/lsp/notebook-lsp.ts +28 -2
- package/src/core/codemirror/reactive-references/__tests__/analyzer.test.ts +7 -6
- package/src/core/codemirror/reactive-references/analyzer.ts +2 -2
- package/src/core/codemirror/rtc/loro/__tests__/sync.test.ts +52 -0
- package/src/core/codemirror/rtc/loro/sync.ts +1 -0
- package/src/core/datasets/__tests__/data-source.test.ts +5 -6
- package/src/core/datasets/state.ts +1 -1
- package/src/core/errors/__tests__/errors.test.ts +2 -1
- package/src/core/export/__tests__/hooks.test.ts +37 -36
- package/src/core/islands/main.ts +2 -7
- package/src/core/kernel/__tests__/handlers.test.ts +5 -4
- package/src/core/kernel/handlers.ts +7 -4
- package/src/core/network/DeferredRequestRegistry.ts +2 -2
- package/src/core/network/__tests__/CachingRequestRegistry.test.ts +9 -10
- package/src/core/network/__tests__/DeferredRequestRegistry.test.ts +4 -6
- package/src/core/static/__tests__/virtual-file-tracker.test.ts +8 -8
- package/src/core/static/virtual-file-tracker.ts +1 -1
- package/src/core/storage/__tests__/state.test.ts +31 -21
- package/src/core/storage/state.ts +1 -1
- package/src/core/variables/__tests__/state.test.ts +6 -6
- package/src/core/variables/types.ts +2 -2
- package/src/core/wasm/__tests__/state.test.ts +8 -8
- package/src/core/websocket/useMarimoKernelConnection.tsx +12 -15
- package/src/css/md-tooltip.css +4 -39
- package/src/css/md.css +7 -0
- package/src/plugins/core/RenderHTML.tsx +17 -0
- package/src/plugins/core/__test__/RenderHTML.test.ts +45 -0
- package/src/plugins/core/sanitize-html.ts +25 -18
- package/src/plugins/impl/DataTablePlugin.tsx +23 -2
- package/src/plugins/impl/SliderPlugin.tsx +1 -3
- package/src/plugins/impl/__tests__/SliderPlugin.test.tsx +120 -0
- package/src/plugins/impl/anywidget/model.ts +1 -2
- package/src/stories/cell.stories.tsx +8 -8
- package/src/stories/layout/vertical/one-column.stories.tsx +9 -8
- package/src/stories/log-viewer.stories.tsx +8 -8
- package/src/stories/variables.stories.tsx +2 -2
- package/src/utils/__tests__/download.test.tsx +21 -20
- package/src/utils/copy.ts +18 -5
- package/src/utils/download.ts +4 -3
- package/src/utils/html-to-image.ts +6 -0
- package/src/utils/json/base64.ts +3 -3
- package/src/utils/traceback.ts +5 -3
- package/dist/assets/JsonOutput-DKXKGKvX.js +0 -46
- package/dist/assets/RenderHTML-DJ8khuob.js +0 -1
- package/dist/assets/ai-model-dropdown-DPTa_EpU.js +0 -5
- package/dist/assets/cell-editor-DX7IcqNr.js +0 -23
- package/dist/assets/channel-CkT8Qdo2.js +0 -1
- package/dist/assets/classDiagram-2ON5EDUG-BhMT_rTz.js +0 -1
- package/dist/assets/classDiagram-v2-WZHVMYZB-D-F4WEyb.js +0 -1
- package/dist/assets/copy-YwM0Pd7v.js +0 -1
- package/dist/assets/dist-BTqMkf4j.js +0 -1
- package/dist/assets/dist-DHw9sXeN.js +0 -1
- package/dist/assets/dist-Du0qZeXz.js +0 -1
- package/dist/assets/dist-a0FfbvMD.js +0 -1
- package/dist/assets/dist-cfkfP0ni.js +0 -1
- package/dist/assets/dist-pzQ9JG-p.js +0 -1
- package/dist/assets/file-explorer-panel-CB8vF5ob.js +0 -26
- package/dist/assets/home-page-itW0tRmv.js +0 -4
- package/dist/assets/html-to-image-BnSc-Wa0.js +0 -2
- package/dist/assets/index-0n92c_W7.js +0 -38
- package/dist/assets/mermaid-4DMBBIKO-PoHnhmy8.js +0 -1
- package/dist/assets/react-vega-Da-Ps9UW.js +0 -1
- package/dist/assets/stateDiagram-v2-4FDKWEC3-CEqeIlM0.js +0 -1
- package/dist/assets/stex-BBWVYm-R.js +0 -1
- package/dist/assets/tracing-DUVd0jtl.js +0 -1
- package/dist/assets/tracing-panel-CuTxPn_x.js +0 -2
- /package/dist/assets/{Combination-Cs9nbinQ.js → Combination-CSPK4t6z.js} +0 -0
- /package/dist/assets/{Deferred-BMfCOLaw.js → Deferred-CfyqLOPG.js} +0 -0
- /package/dist/assets/{SSRProvider-DC7ElCZZ.js → SSRProvider-CwqN9FWV.js} +0 -0
- /package/dist/assets/{badge-hTpPIsMT.js → badge-DImLVznf.js} +0 -0
- /package/dist/assets/{blob-CObhN-9g.js → blob-DgooIGjS.js} +0 -0
- /package/dist/assets/{bot-message-square-CK6eoGWy.js → bot-message-square-Dw41U6lL.js} +0 -0
- /package/dist/assets/{chart-no-axes-column-DV8gdCvH.js → chart-no-axes-column-a9XtWmzk.js} +0 -0
- /package/dist/assets/{check-BE0hEwVo.js → check-DZA_bRpw.js} +0 -0
- /package/dist/assets/{chevron-right-D0GQBpTb.js → chevron-right-CvVxySQk.js} +0 -0
- /package/dist/assets/{circle-check-gLIOLu8x.js → circle-check-CbaVeozR.js} +0 -0
- /package/dist/assets/{circle-play-DYGULlKZ.js → circle-play-DYn5nR6N.js} +0 -0
- /package/dist/assets/{circle-plus-CGG-gArM.js → circle-plus-nCze0-py.js} +0 -0
- /package/dist/assets/{clipboard-paste-DoYSN8Sv.js → clipboard-paste-EHXeKq9D.js} +0 -0
- /package/dist/assets/{code-xml-DwHPF_nL.js → code-xml-BlrJCgNZ.js} +0 -0
- /package/dist/assets/{copy-CkudG0Ej.js → copy-D6N1-xc1.js} +0 -0
- /package/dist/assets/{database-zap-DTWCDKdn.js → database-zap-BIGMFOfP.js} +0 -0
- /package/dist/assets/{defaultLocale-DK1MWd7f.js → defaultLocale-CGfP-Ye3.js} +0 -0
- /package/dist/assets/{defaultLocale-OkOxlkkM.js → defaultLocale-CuYNS33t.js} +0 -0
- /package/dist/assets/{dist-8UD0A5sU.js → dist-BF9S272t.js} +0 -0
- /package/dist/assets/{dist-apDpadc4.js → dist-Bk1itfBD.js} +0 -0
- /package/dist/assets/{dist-CQqv2gQL.js → dist-Dm11d0_A.js} +0 -0
- /package/dist/assets/{download-DBW9RXtT.js → download-nLboiTtW.js} +0 -0
- /package/dist/assets/{ellipsis-0_zJdF6H.js → ellipsis-d7eaKIFn.js} +0 -0
- /package/dist/assets/{ellipsis-vertical-CAB7tdza.js → ellipsis-vertical-DBQ5kWTo.js} +0 -0
- /package/dist/assets/{emotion-is-prop-valid.esm-D1keIaYa.js → emotion-is-prop-valid.esm-D7FeWASw.js} +0 -0
- /package/dist/assets/{errors-Bfogio62.js → errors-0IrrdfSG.js} +0 -0
- /package/dist/assets/{extends-DRbCSry7.js → extends-aq1t6BkR.js} +0 -0
- /package/dist/assets/{eye-off-vwi9L975.js → eye-off-CF3GmvXV.js} +0 -0
- /package/dist/assets/{file-DzHkbIdO.js → file-C-yMeaec.js} +0 -0
- /package/dist/assets/{file-headphone-B5q2Ow55.js → file-headphone-CPAP8asn.js} +0 -0
- /package/dist/assets/{file-plus-corner-lLQw9OnR.js → file-plus-corner-ks__N1mr.js} +0 -0
- /package/dist/assets/{github-BVtI-3F1.js → github-CRD4USKm.js} +0 -0
- /package/dist/assets/{image-DXfkah9d.js → image-CfyJzBP9.js} +0 -0
- /package/dist/assets/{link-Cf10mh3t.js → link-_dbp0XNB.js} +0 -0
- /package/dist/assets/{maps-OKerBHH8.js → maps-DQsjfyTy.js} +0 -0
- /package/dist/assets/{numbers-CYnquDho.js → numbers-Cno6K0UF.js} +0 -0
- /package/dist/assets/{objectWithoutPropertiesLoose-DP4vAkvg.js → objectWithoutPropertiesLoose-Dxmp_Bd_.js} +0 -0
- /package/dist/assets/{ordinal-BjO5SoTk.js → ordinal-CMAUv8ku.js} +0 -0
- /package/dist/assets/{paths-D2lG83Oh.js → paths-BVwhPRFT.js} +0 -0
- /package/dist/assets/{play-DKSqmedg.js → play-Bu_0ogGD.js} +0 -0
- /package/dist/assets/{plus-dVmh0yTy.js → plus-DJ99CUbx.js} +0 -0
- /package/dist/assets/{preload-helper-BW0IMuFq.js → preload-helper-y72bE5iF.js} +0 -0
- /package/dist/assets/{prop-types-RrUi-pOT.js → prop-types-DRf51_gT.js} +0 -0
- /package/dist/assets/{purify.es-BBn8CPhf.js → purify.es-Cf8RQecB.js} +0 -0
- /package/dist/assets/{range-DNqFcYmr.js → range-ClqUI25v.js} +0 -0
- /package/dist/assets/{refresh-ccw-DLpfIr8v.js → refresh-ccw-DQ6SJ8UC.js} +0 -0
- /package/dist/assets/{refresh-cw-CHAHPgkx.js → refresh-cw-Dg9tCj4k.js} +0 -0
- /package/dist/assets/{rotate-ccw-hLlF_82X.js → rotate-ccw-BCkZViUZ.js} +0 -0
- /package/dist/assets/{save-8fSvKYJT.js → save-CUdcv5qm.js} +0 -0
- /package/dist/assets/{session-BrEm7qNv.js → session-CByuQ-M-.js} +0 -0
- /package/dist/assets/{settings-CzQUw9rV.js → settings-B7nhfCat.js} +0 -0
- /package/dist/assets/{spinner-C5JoisA7.js → spinner-pCogyRyo.js} +0 -0
- /package/dist/assets/{square-CxAsQQ77.js → square-KVNDGpgy.js} +0 -0
- /package/dist/assets/{square-function-B006EYFX.js → square-function-BMNCw7Qb.js} +0 -0
- /package/dist/assets/{stex-0ac7Aukl.js → stex-C6JeW1YI.js} +0 -0
- /package/dist/assets/{table-BCnp9gKC.js → table-Od8PbuV-.js} +0 -0
- /package/dist/assets/{toDate-BqKH-Jd9.js → toDate-Cfp9W_O9.js} +0 -0
- /package/dist/assets/{trash-2-CAoNMkjq.js → trash-2-Bc_J7TQO.js} +0 -0
- /package/dist/assets/{trash-BZMAQneW.js → trash-Cxd189Vw.js} +0 -0
- /package/dist/assets/{triangle-alert-qZo1ox6x.js → triangle-alert-CzLrbLGN.js} +0 -0
- /package/dist/assets/{types-C1RN112u.js → types-CLOMZuqU.js} +0 -0
- /package/dist/assets/{use-toast-Hc8CXlvz.js → use-toast-BtZldTi5.js} +0 -0
- /package/dist/assets/{useDebounce-B0dx2Gp0.js → useDebounce-DwTO_rGp.js} +0 -0
- /package/dist/assets/{useTheme-BYXBU1of.js → useTheme-KDW4sktg.js} +0 -0
- /package/dist/assets/{uuid-ClFZlR7U.js → uuid-BukULOeS.js} +0 -0
- /package/dist/assets/{workflow-BmeqNuSH.js → workflow-BqHyyStM.js} +0 -0
- /package/dist/assets/{x-BI1M8X_v.js → x-CdLP7-v3.js} +0 -0
- /package/dist/assets/{youtube-DE-Ej6FR.js → youtube-CfU-SnDw.js} +0 -0
package/dist/assets/{LazyAnyLanguageCodeMirror-m8w66E4s.js → LazyAnyLanguageCodeMirror-CcCHIX38.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./any-language-editor-
|
|
2
|
-
import{s as e}from"./chunk-LvLJmgfZ.js";import{t as i}from"./react-Bj1aDYRI.js";import{t as o}from"./createLucideIcon-Cm-Z7dYr.js";import{t as m}from"./preload-helper-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./any-language-editor-DZYnKlJB.js","./copy-icon-P0kzz1Pr.js","./button-Ej3vmCIF.js","./useEventListener-Dy81QR4n.js","./compiler-runtime-B3qBwwSJ.js","./react-Bj1aDYRI.js","./chunk-LvLJmgfZ.js","./cn-BoaCR37F.js","./clsx-BDxNtGmi.js","./jsx-runtime-icT_Ltz2.js","./tooltip-CR_izE8Q.js","./Combination-CSPK4t6z.js","./react-dom-CSu739Rf.js","./dist-6P6vjf93.js","./use-toast-BtZldTi5.js","./copy-KjcPgPw9.js","./check-DZA_bRpw.js","./createLucideIcon-Cm-Z7dYr.js","./copy-D6N1-xc1.js","./error-banner-J5F3weEj.js","./alert-dialog-ebk_-wsU.js","./errors-0IrrdfSG.js","./zod-H_cgTO0M.js","./dist-D9Vhptds.js","./dist-B_cxg-E4.js","./dist-Dm11d0_A.js","./dist-CVEvQ1Ex.js","./dist-D0Vj4Kqc.js","./dist-BatEf-0f.js","./dist-BF9S272t.js","./dist-sVuk6mkQ.js","./dist-DxrbvUBv.js","./dist-C6ohaMKU.js","./dist-CYs1oP7g.js","./dist-Bk1itfBD.js","./dist-CgC048vN.js","./dist-DD9ZJMK5.js","./dist-ASlWkGgG.js","./dist-DBPtheKQ.js","./esm-BC1J92im.js","./extends-aq1t6BkR.js","./objectWithoutPropertiesLoose-Dxmp_Bd_.js","./dist-CtXb4bUU.js","./esm-DKLLCu3N.js","./dist-DXyIIB32.js","./dist-feWVQ4dq.js","./dist-DkaderFA.js","./dist-CEeVCRd_.js","./dist-Dxov2ltb.js","./dist-BR9zyVPH.js","./apl-CexVE068.js","./asciiarmor-DzdXFxI-.js","./asn1-lKNP6w4p.js","./brainfuck-pTL_9bJ7.js","./clike-BCxd7pZ9.js","./clojure-CPAS-74L.js","./cmake-DMONEHtp.js","./cobol-0rQGzjf0.js","./coffeescript-BHNUw4aR.js","./commonlisp-Cjiyl45-.js","./crystal-CUMDisY2.js","./css-B6NFOUor.js","./cypher-DcWJtLBw.js","./d-CpNp8oDv.js","./diff-BCFJsGHX.js","./dtd-D7nO7isU.js","./dylan-qEhlQv4l.js","./ecl-cXHEjabG.js","./eiffel-CUTEIYa-.js","./elm-DOfGHeKn.js","./erlang-B5R7Byby.js","./factor-CrpY0izf.js","./simple-mode-oMMOWqWz.js","./forth-BjV8SV3p.js","./fortran-CvNblcug.js","./gas-D1YrZZUY.js","./gherkin-CAUl7roi.js","./groovy-CnmCDhLm.js","./haskell-qdBb4h_7.js","./haxe-MQhLSFhI.js","./idl-CcZzcWCI.js","./javascript-hE4QNtKl.js","./julia-BjrvvLkp.js","./livescript-B01pNEzu.js","./lua-BwfRgSM6.js","./mathematica-DLi5eijp.js","./mbox-QweTYWJQ.js","./mirc-1J5TZ8Tf.js","./mllike-DRzCrpbj.js","./modelica-GZKavTLw.js","./mscgen-HMNaCHuy.js","./mumps-CzCxfP2m.js","./nsis-BeaU1Q2K.js","./ntriples-DT57g_ZF.js","./octave-CtuTaUjQ.js","./oz-BS8LEqKx.js","./pascal-Db0ZEHQw.js","./perl-DgJKzgyz.js","./pig-Dk6eYa40.js","./powershell-dW0qpS7j.js","./properties-oMha4ix2.js","./protobuf-CfWJ4EtB.js","./pug-v81J9ytZ.js","./puppet-O2K_n-UM.js","./python-qMKsSr4L.js","./q-ewn8d81Q.js","./r-CqF-AjDv.js","./rpm-BqLq138P.js","./ruby-CQfbO3YY.js","./sas-BmpgVn6Q.js","./scheme-rgyDg_wq.js","./shell-Dndk6Ld6.js","./sieve-bGgktpLX.js","./smalltalk-CU43LrKS.js","./sparql-BycKC3X4.js","./stex-C6JeW1YI.js","./stylus-CePwhvgW.js","./swift-CfgglXjR.js","./tcl-D_gYSBm0.js","./textile-BEvFU9wV.js","./toml-DGJRpV2e.js","./troff-CUlohIux.js","./ttcn-cfg-DCxdE-sj.js","./ttcn-nuQ3wCdy.js","./turtle-B2N96QpC.js","./vb-CBiIL_zx.js","./vbscript-B3Y69Iw0.js","./velocity-B5BPA7FX.js","./verilog-BwmYR8E3.js","./vhdl-VXFnDy2U.js","./webidl-Bcmf9JWd.js","./xquery-8pWKOyFY.js","./yacas-BFcwo3Cx.js","./z80-t3SBb7Lt.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{s as e}from"./chunk-LvLJmgfZ.js";import{t as i}from"./react-Bj1aDYRI.js";import{t as o}from"./createLucideIcon-Cm-Z7dYr.js";import{t as m}from"./preload-helper-y72bE5iF.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-DZYnKlJB.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
|
|
2
|
-
`),s=" ",n=Ze(
|
|
1
|
+
import{s as X}from"./chunk-LvLJmgfZ.js";import{d as ye,f as ve,l as Ne,u as be}from"./useEvent-O0nX5vok.js";import{t as we}from"./react-Bj1aDYRI.js";import{E as ke,Gn as Ie,Gr as J,Wr as $e,X as _e,b as Fe,dn as Ae,ri as Te,yn as Ce}from"./cells-39RE4UzS.js";import{t as q}from"./compiler-runtime-B3qBwwSJ.js";import{t as Se}from"./invariant-CQUIhlu2.js";import{r as Me}from"./utils-tNbLd14P.js";import{t as ze}from"./jsx-runtime-icT_Ltz2.js";import{r as K,t as $}from"./button-Ej3vmCIF.js";import{t as Y}from"./cn-BoaCR37F.js";import{t as G}from"./createLucideIcon-Cm-Z7dYr.js";import{r as Ee}from"./x-CdLP7-v3.js";import{a as qe,p as Pe,r as We,t as Le}from"./dropdown-menu-BehqiLFL.js";import{a as Ve,n as Be}from"./state-Cz_wrzCz.js";import{c as Z,n as Qe}from"./datasource-DKHG39NV.js";import{a as De}from"./dist-Bk1itfBD.js";import{t as ee}from"./tooltip-CR_izE8Q.js";import{a as Oe,i as Ge,n as He,r as Ue}from"./multi-map-C8RbwBrw.js";import{t as te}from"./kbd-DvKpAc6K.js";import{t as A}from"./links-DzgPOFJ-.js";import{r as Re,t as Xe}from"./alert-OQZHipbB.js";import{o as Je,t as Ke}from"./useInstallPackage-CQEr5429.js";import{n as b}from"./cell-link-CNgO3c-T.js";var Ye=G("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=G("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=G("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
|
+
`),s=" ",n=Ze(De.parse(r));if(!n)return["def _():",...H(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
|
-
`);return["def _():",...
|
|
6
|
-
`)}function
|
|
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=q(),nt=Te("marimo:ai-autofix-mode","autofix",Ce);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 R=q(),t=G(ze(),1);const N=r=>{let e=(0,R.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(Fe).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,R.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)(Ee,{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)(qe,{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,R.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!=="").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=q(),P=G(we(),1),ct=new _e;const X=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=X(n.url);return(0,t.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:K.stopPropagation(),className:"text-link hover:underline",children:a},l)}if(n.type==="image"){let a=X(n.url);return(0,t.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:K.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}=Ke(),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=X(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: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=q(),I=r=>{let e=(0,he.c)(10),s=r.title??"Tip",n;e[0]===s?n=e[1]:(n=(0,t.jsx)(De,{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)(Re,{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)(Oe,{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(zt),Q=s.filter(Et),U=s.filter(qt),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 E=F.some(Pt),ge=!E&&F.some(Lt);v.push((0,t.jsxs)("div",{children:[F.map(Wt),Q.map(Vt),E&&(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 E=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(Dt),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:["_",E]}),"). 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(Ot),n&&(0,t.jsx)(N,{errors:L,cellId:n})]},"interruption")),C.length>0&&v.push((0,t.jsxs)("ul",{children:[C.map(Rt),C.some(Xt)&&(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(Kt),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")),U.length>0&&v.push((0,t.jsxs)("div",{children:[U.map(er),n&&(0,t.jsx)(N,{errors:U,cellId:n,className:"mt-2.5"})]},"sql-errors")),v},D=`font-code font-medium tracking-wide ${o}`,z;e[17]!==D||e[18]!==a?(z=(0,t.jsx)(Xe,{className:D,children:a}),e[17]=D,e[18]=a,e[19]=z):z=e[19];let je=z;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 zt(r){return r.type==="syntax"}function Et(r){return r.type==="unknown"}function qt(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 Ut(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 Dt(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(Ut)})]},`multiple-defs-${e}`)}function Ht(r,e){return(0,t.jsx)("p",{className:"text-muted-foreground",children:r.msg},`import-star-${e}`)}function Ot(r,e){return(0,t.jsx)("p",{children:"This cell was interrupted and needs to be re-run."},`interruption-${e}`)}function Rt(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 Xt(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 Kt(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};
|
|
5
|
+
`);return["def _():",...H(a,s),`${s}return ${c[0]}`,...H(c.slice(1),s),"","","_()"].join(`
|
|
6
|
+
`)}function H(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=q(),nt=Te("marimo:ai-autofix-mode","autofix",Ce);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 U=q(),t=X(ze(),1);const N=r=>{let e=(0,U.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(Fe).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,U.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)(Ee,{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)(Le,{children:[f,(0,t.jsx)(We,{align:"end",className:"w-56",children:(0,t.jsx)(qe,{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,U.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!=="").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=q(),P=X(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:K.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:K.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}=Ke(),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=q(),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)(Ue,{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)(Ge,{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)(He,{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),W=s.filter(Ft),C=s.filter(At),S=s.filter(Tt),L=s.filter(Ct),V=s.filter(St),B=s.filter(Mt),F=s.filter(zt),Q=s.filter(Et),D=s.filter(qt),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 E=F.some(Pt),ge=!E&&F.some(Wt);v.push((0,t.jsxs)("div",{children:[F.map(Lt),Q.map(Vt),E&&(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 E=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:["_",E]}),"). 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)(Ie,{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(Gt),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")),W.length>0&&v.push((0,t.jsxs)("div",{children:[W.map(Ht),n&&(0,t.jsx)(N,{errors:W,cellId:n})]},"interruption")),C.length>0&&v.push((0,t.jsxs)("ul",{children:[C.map(Ut),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(Xt),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")),L.length>0&&v.push((0,t.jsxs)("div",{children:[L.map(Kt),n&&(0,t.jsx)(N,{errors:L,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}`,z;e[17]!==O||e[18]!==a?(z=(0,t.jsx)(Re,{className:O,children:a}),e[17]=O,e[18]=a,e[19]=z):z=e[19];let je=z;m=Xe,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 zt(r){return r.type==="syntax"}function Et(r){return r.type==="unknown"}function qt(r){return r.type==="sql-error"}function Pt(r){return r.msg.includes("!pip")}function Wt(r){return r.msg.includes("use os.subprocess")}function Lt(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 Gt(r,e){return(0,t.jsx)("p",{className:"text-muted-foreground",children:r.msg},`import-star-${e}`)}function Ht(r,e){return(0,t.jsx)("p",{children:"This cell was interrupted and needs to be re-run."},`interruption-${e}`)}function Ut(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 Xt(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 Kt(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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{s as v}from"./chunk-LvLJmgfZ.js";import{i as j,p as y,u as w}from"./useEvent-O0nX5vok.js";import{t as R}from"./react-Bj1aDYRI.js";import{Gr as m,Wr as S,m as H,ot as _,rn as I,sn as M}from"./cells-39RE4UzS.js";import{t as E}from"./compiler-runtime-B3qBwwSJ.js";import{m as N}from"./useEventListener-Dy81QR4n.js";import{o as T}from"./utils-tNbLd14P.js";import{t as z}from"./jsx-runtime-icT_Ltz2.js";import{t as C}from"./tooltip-CR_izE8Q.js";import{t as F}from"./mode-D-iRbN9x.js";import{t as L}from"./usePress-alQ5Crny.js";import{n as V}from"./useDebounce-DwTO_rGp.js";import{t as W}from"./copy-icon-P0kzz1Pr.js";import{t as k}from"./useRunCells-Dhl8ZTGh.js";var q=E(),c=v(R(),1),o=v(z(),1);const A=r=>{let t=(0,q.c)(16),e,n,i;t[0]===r?(e=t[1],n=t[2],i=t[3]):({href:n,children:e,...i}=r,t[0]=r,t[1]=e,t[2]=n,t[3]=i);let a=(0,c.useRef)(null),s;t[4]===n?s=t[5]:(s=()=>{let u=new URL(globalThis.location.href);u.hash=n,globalThis.history.pushState({},"",u.toString()),globalThis.dispatchEvent(new HashChangeEvent("hashchange"));let x=n.slice(1),g=document.getElementById(x);g&&g.scrollIntoView({behavior:"smooth",block:"start"})},t[4]=n,t[5]=s);let l=s,f;t[6]===l?f=t[7]:(f={onPress:()=>{l()}},t[6]=l,t[7]=f);let{pressProps:h}=L(f),d;t[8]===l?d=t[9]:(d=u=>{u.preventDefault(),l()},t[8]=l,t[9]=d);let b=d,p;return t[10]!==e||t[11]!==b||t[12]!==n||t[13]!==h||t[14]!==i?(p=(0,o.jsx)("a",{ref:a,href:n,...h,onClick:b,...i,children:e}),t[10]=e,t[11]=b,t[12]=n,t[13]=h,t[14]=i,t[15]=p):p=t[15],p};async function D(r){let t=H().inOrderIds.at(0);if(t)try{let e=await I.request({document:r,cellId:t});if(!e||e.options.length===0)return;let n=r.split(".").pop()??r,i=e.options[0],a=e.options.find(s=>s.name===n)??i;a!=null&&a.completion_info&&j.set(M,{documentation:a.completion_info})}catch(e){N.debug(`Doc lookup failed for "${r}"`,e)}}var O=E();const P=r=>{let t=(0,O.c)(8),{qualifiedName:e,children:n}=r,i;t[0]===e?i=t[1]:(i=()=>{D(e)},t[0]=e,t[1]=i);let a=V(i,100),s;t[2]===a?s=t[3]:(s=()=>a.cancel(),t[2]=a,t[3]=s);let l;return t[4]!==n||t[5]!==a||t[6]!==s?(l=(0,o.jsx)("span",{onMouseEnter:a,onMouseLeave:s,children:n}),t[4]=n,t[5]=a,t[6]=s,t[7]=l):l=t[7],l};var $=y(r=>{let t=r(k),e=r(T);if(t||e)return!1;let n=!0;try{n=F()==="read"}catch{return!0}return!n});function B(){return w($)}var U=E(),G=r=>{if(r instanceof m.Element&&!/^[A-Za-z][\w-]*$/.test(r.name))return c.createElement(c.Fragment)},Z=(r,t)=>{if(t instanceof m.Element&&t.name==="body"){if((0,c.isValidElement)(r)&&"props"in r){let e=r.props.children;return(0,o.jsx)(o.Fragment,{children:e})}return}},J=(r,t)=>{if(t instanceof m.Element&&t.name==="html"){if((0,c.isValidElement)(r)&&"props"in r){let e=r.props.children;return(0,o.jsx)(o.Fragment,{children:e})}return}},K=r=>{if(r instanceof m.Element&&r.attribs&&r.name==="iframe"){let t=document.createElement("iframe");return Object.entries(r.attribs).forEach(([e,n])=>{e.startsWith('"')&&e.endsWith('"')&&(e=e.slice(1,-1)),t.setAttribute(e,n)}),(0,o.jsx)("div",{dangerouslySetInnerHTML:{__html:t.outerHTML}})}},Q=r=>{if(r instanceof m.Element&&r.name==="script"){let t=r.attribs.src;if(!t)return;if(!document.querySelector(`script[src="${t}"]`)){let e=document.createElement("script");e.src=t,document.head.append(e)}return(0,o.jsx)(o.Fragment,{})}},X=(r,t)=>{if(t instanceof m.Element&&t.name==="a"){let e=t.attribs.href;if(e!=null&&e.startsWith("#")&&!e.startsWith("#code/")){let n=null;return(0,c.isValidElement)(r)&&"props"in r&&(n=r.props.children),(0,o.jsx)(A,{href:e,...t.attribs,children:n})}}},Y=(r,t,e)=>{var n,i;if(t instanceof m.Element&&t.name==="div"&&((i=(n=t.attribs)==null?void 0:n.class)!=null&&i.includes("codehilite")))return(0,o.jsx)(rt,{children:r},e)},tt=(r,t)=>{var e;if(t instanceof m.Element&&((e=t.attribs)!=null&&e["data-marimo-doc"])){let n=t.attribs["data-marimo-doc"];return(0,o.jsx)(P,{qualifiedName:n,children:r})}},et=(r,t)=>{var e;if(t instanceof m.Element&&((e=t.attribs)!=null&&e["data-tooltip"])){let n=t.attribs["data-tooltip"];return(0,o.jsx)(C,{content:n,children:r})}},rt=r=>{let t=(0,U.c)(3),{children:e}=r,n=(0,c.useRef)(null),i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,o.jsx)("div",{className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity",children:(0,o.jsx)(W,{tooltip:!1,className:"p-1",value:()=>{var l;let s=(l=n.current)==null?void 0:l.firstChild;return s&&s.textContent||""}})}),t[0]=i):i=t[0];let a;return t[1]===e?a=t[2]:(a=(0,o.jsxs)("div",{className:"relative group codehilite-wrapper",ref:n,children:[e,i]}),t[1]=e,t[2]=a),a};const nt=({html:r,additionalReplacements:t=[],alwaysSanitizeHtml:e=!0})=>(0,o.jsx)(it,{html:r,alwaysSanitizeHtml:e,additionalReplacements:t});var it=({html:r,additionalReplacements:t=[],alwaysSanitizeHtml:e})=>{let n=B();return at({html:(0,c.useMemo)(()=>e||n?_(r):r,[r,e,n]),additionalReplacements:t})};function at({html:r,additionalReplacements:t=[]}){let e=[G,K,Q,...t],n=[Y,X,tt,et,Z,J];return S(r,{replace:(i,a)=>{for(let s of e){let l=s(i,a);if(l)return l}return i},transform:(i,a,s)=>{for(let l of n){let f=l(i,a,s);if(f)return f}return i}})}export{nt as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _i=Object.defineProperty;var bi=(t,e,a)=>e in t?_i(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a;var L=(t,e,a)=>bi(t,typeof e!="symbol"?e+"":e,a);import{s as Za,t as xi}from"./chunk-LvLJmgfZ.js";import{f as Kr,i as Yr,l as wi,n as Hr,o as ki,u as Gr}from"./useEvent-O0nX5vok.js";import{t as Ci}from"./react-Bj1aDYRI.js";import{
|
|
1
|
+
var _i=Object.defineProperty;var bi=(t,e,a)=>e in t?_i(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a;var L=(t,e,a)=>bi(t,typeof e!="symbol"?e+"":e,a);import{s as Za,t as xi}from"./chunk-LvLJmgfZ.js";import{f as Kr,i as Yr,l as wi,n as Hr,o as ki,u as Gr}from"./useEvent-O0nX5vok.js";import{t as Ci}from"./react-Bj1aDYRI.js";import{Ar as Ei,E as Qr,Nr as Ti,Nt as Xr,Pn as Ii,Sn as Si,Xr as Ai,Yn as Oi,Zn as Ri,b as Ge,ct as Fa,f as Ni,i as ji,li as es,lr as Mi,ri as Pi,sr as Li,ti as $i,ui as Di,ur as ts,xt as Zi,yn as Fi,zt as zi}from"./cells-39RE4UzS.js";import{B as Ce,D as Ui,E as as,H as Vi,I as Nt,J as rs,L as Q,N as ss,O as qi,P as H,R as E,S as Bi,T as ce,V as Fe,W as ns,b as aa,k as M,w as ze,x as ra}from"./zod-H_cgTO0M.js";import{t as jt}from"./compiler-runtime-B3qBwwSJ.js";import{n as is}from"./assertNever-DWSyoPEi.js";import{t as Wi,w as Ji}from"./ai-model-dropdown-CiJpv5wN.js";import{m as ie,u as Ki}from"./useEventListener-Dy81QR4n.js";import{n as Yi}from"./utils-tNbLd14P.js";import{o as Hi}from"./config-DqxNMQDN.js";import{t as Gi}from"./jsx-runtime-icT_Ltz2.js";import{t as Qe}from"./button-Ej3vmCIF.js";import{t as za}from"./cn-BoaCR37F.js";import{Ht as Qi,Jt as sa,St as na,Vt as Xi,Wt as os,Yt as ia,Zt as eo,at as ls,ct as to,lt as ds,rt as Ua,xt as ao}from"./dist-B_cxg-E4.js";import{t as ro}from"./createReducer-Drh7NmIR.js";import{h as so,n as no,o as io,r as oo}from"./dist-D0Vj4Kqc.js";import{r as lo,t as uo}from"./requests-Bgjtqo_1.js";import{t as oa}from"./createLucideIcon-Cm-Z7dYr.js";import{t as us}from"./x-CdLP7-v3.js";import{l as cs,n as co,p as po}from"./markdown-renderer-DSy5IuAx.js";import{a as ps,c as mo,p as ho,r as fo,t as go}from"./dropdown-menu-BehqiLFL.js";import{t as ms}from"./file-C-yMeaec.js";import{t as yo}from"./image-CfyJzBP9.js";import{t as vo}from"./spinner-pCogyRyo.js";import{t as _o}from"./play-Bu_0ogGD.js";import{r as bo}from"./input-CN1ZeRYm.js";import{a as xo}from"./state-Cz_wrzCz.js";import{a as Mt,i as wt,o as Pt,r as kt,s as wo,t as ko}from"./datasource-DKHG39NV.js";import{a as Co}from"./dist-C6ohaMKU.js";import{t as Va}from"./use-toast-BtZldTi5.js";import{r as Eo}from"./useTheme-KDW4sktg.js";import{t as la}from"./tooltip-CR_izE8Q.js";import{d as To}from"./popover-Bvoif-Mg.js";import{r as Io}from"./errors-0IrrdfSG.js";import{t as So}from"./blob-DgooIGjS.js";import{n as Ao}from"./useRunCells-Dhl8ZTGh.js";import{i as qa}from"./cell-link-CNgO3c-T.js";import{r as Oo,t as Ro}from"./html-to-image-DTFXm6_Z.js";import{n as Ba}from"./renderShortcut-BYvKm38e.js";import{t as No}from"./process-output-BxPWHcIi.js";import{t as jo}from"./useDeleteCell-d8veThW7.js";import{r as Mo,t as Po}from"./esm-BC1J92im.js";import{n as Lo}from"./icons-CrUXojcA.js";var hs=oa("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"}]]),fs=oa("circle-stop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]),gs=oa("paperclip",[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]]),ys=oa("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"}]]),vs="vercel.ai.error",$o=Symbol.for(vs),_s,bs,Xe=class ci extends(bs=Error,_s=$o,bs){constructor({name:e,message:a,cause:r}){super(a),this[_s]=!0,this.name=e,this.cause=r}static isInstance(e){return ci.hasMarker(e,vs)}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 xs(t){return t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:JSON.stringify(t)}var ws="AI_InvalidArgumentError",ks=`vercel.ai.error.${ws}`,Do=Symbol.for(ks),Cs,Es,Zo=class extends(Es=Xe,Cs=Do,Es){constructor({message:t,cause:e,argument:a}){super({name:ws,message:t,cause:e}),this[Cs]=!0,this.argument=a}static isInstance(t){return Xe.hasMarker(t,ks)}},Ts="AI_JSONParseError",Is=`vercel.ai.error.${Ts}`,Fo=Symbol.for(Is),Ss,As,Os=class extends(As=Xe,Ss=Fo,As){constructor({text:t,cause:e}){super({name:Ts,message:`JSON parsing failed: Text: ${t}.
|
|
2
2
|
Error message: ${xs(e)}`,cause:e}),this[Ss]=!0,this.text=t}static isInstance(t){return Xe.hasMarker(t,Is)}},Rs="AI_TypeValidationError",Ns=`vercel.ai.error.${Rs}`,zo=Symbol.for(Ns),js,Ms,da=class zr extends(Ms=Xe,js=zo,Ms){constructor({value:e,cause:a}){super({name:Rs,message:`Type validation failed: Value: ${JSON.stringify(e)}.
|
|
3
3
|
Error message: ${xs(a)}`,cause:a}),this[js]=!0,this.value=e}static isInstance(e){return Xe.hasMarker(e,Ns)}static wrap({value:e,cause:a}){return zr.isInstance(a)&&a.value===e?a:new zr({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 Wa(t){}function Uo(t){if(typeof t=="function")throw TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");let{onEvent:e=Wa,onError:a=Wa,onRetry:r=Wa,onComment:s}=t,n="",o=!0,i,l="",d="";function u(f){let p=o?f.replace(/^\xEF\xBB\xBF/,""):f,[h,v]=Vo(`${n}${p}`);for(let T of h)c(T);n=v,o=!1}function c(f){if(f===""){m();return}if(f.startsWith(":")){s&&s(f.slice(f.startsWith(": ")?2:1));return}let p=f.indexOf(":");if(p!==-1){let h=f.slice(0,p),v=f[p+1]===" "?2:1;g(h,f.slice(p+v),f);return}g(f,"",f)}function g(f,p,h){switch(f){case"event":d=p;break;case"data":l=`${l}${p}
|
|
4
4
|
`;break;case"id":i=p.includes("\0")?void 0:p;break;case"retry":/^\d+$/.test(p)?r(parseInt(p,10)):a(new Ps(`Invalid \`retry\` value: "${p}"`,{type:"invalid-retry",value:p,line:h}));break;default:a(new Ps(`Unknown field "${f.length>20?`${f.slice(0,20)}\u2026`:f}"`,{type:"unknown-field",field:f,value:p,line:h}));break}}function m(){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}`)),Mt({type:this.contextType,data:o,details:i})}async getAttachments(e){let a=e[0].data.cellId,r=e[0].data.cellName;return xu(e.map(s=>s.data.cellOutput),a,r)}};async function xu(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(
|
|
20
|
+
Image URL: ${a.imageUrl}`)),Mt({type:this.contextType,data:o,details:i})}async getAttachments(e){let a=e[0].data.cellId,r=e[0].data.cellName;return xu(e.map(s=>s.data.cellOutput),a,r)}};async function xu(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(Di.create(e));return o?{cellId:e,cellName:a,mimetype:n.output.mimetype,element:o}:(ie.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 Ro(n.element)})))}catch(n){return ie.error("Error downloading cell output images:",n),[]}}function jn(t){if(cs(t))return null;let e=t.mimetype,a=_u(e,String(t.data))?"media":"text",r=No(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 Mn(t,e,a){let{includeConsoleOutput:r=!1}=a||{},s=e.cellRuntime[t],n=e.cellData[t],o=e.cellIds.inOrderIds.indexOf(t),i=Zi(n.name,o),l;r&&(l=s.consoleOutputs.map(c=>jn(c)).filter(c=>c!==null));let d,u=s.output;return u&&!cs(u)&&(d=jn(u)??void 0),{cellId:t,cellName:i,cellCode:n.code,cellOutput:d,consoleOutputs:l}}function wu(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":(is(t),"Unknown error")}var Pn=new Ii("error","errors"),ku=class extends Pt{constructor(e){super();L(this,"title","Errors");L(this,"mentionPrefix","@");L(this,"contextType","error");this.store=e}getItems(){let e=this.store.get(ji);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:wt.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:wt.ERROR}}formatContext(e){let{data:a}=e;return a.errors.map(r=>Mt({type:this.contextType,data:{name:r.cellName||`Cell ${r.cellId}`,description:r.errorData.map(s=>wu(s)).join(`
|
|
21
21
|
`)}})).join(`
|
|
22
22
|
|
|
23
|
-
`)}};const Ln=
|
|
23
|
+
`)}};const Ln=Ti();var Cu={maxDepth:3,maxResults:20,defaultResultsLimit:5,includeDirectories:!1},Eu=class extends Pt{constructor(e,a=Cu){super();L(this,"title","Files");L(this,"mentionPrefix","#");L(this,"contextType","file");L(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 ie.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){ie.error("Failed to get default file completions:",r)}return{from:e.from,options:[]}}catch(a){return ie.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:wt.FILE,boost:a.isDirectory?kt.MEDIUM:kt.LOW,detail:a.path,displayLabel:`${s} ${r}`,apply:async(n,o,i,l)=>{var m;let d=(m=n.state.facet(Ln))==null?void 0:m.addAttachment;if(!d){ie.warn("No addAttachment callback provided");return}let u=await this.apiRequests.sendFileDetails({path:a.path}).catch(b=>(Va({title:"Failed to get file details",description:b.message}),null));if(!u)return;let c=u.mimeType||"text/plain",g;if(c.startsWith("text/")||c.includes("json")||c.includes("xml"))g=new Blob([u.contents||""],{type:c});else if(u.contents)try{g=So(co(u.contents,c))}catch{g=new Blob([u.contents],{type:c})}else g=new Blob([""],{type:c});d(new File([g],r,{type:c})),n.dispatch({changes:{from:i,to:l,insert:""}}),io(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 Mt({type:this.contextType,data:{name:r,path:a.path,isDirectory:a.isDirectory},details:a.isDirectory?"Directory containing files and subdirectories":"File"})}},Tu=class extends Pt{constructor(e){super();L(this,"title","Tables");L(this,"mentionPrefix","@");L(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 c of r){let g=` ${c.name} (${c.type})`;if(c.sample_values&&c.sample_values.length>0){let m=c.sample_values.slice(0,3).map(b=>b===null?"null":String(b)).join(", ");g+=` - samples: [${m}]`}u+=`${g}
|
|
27
|
-
`}}return Mt({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"?kt.LOCAL_TABLE:kt.REMOTE_TABLE,type:
|
|
28
|
-
`,r);if(s===-1){let d=t.slice(r+3),u=d.indexOf(" "),c=u===-1?d:d.slice(0,u),g=c==="markdown"?"markdown":c==="sql"?"sql":"python",m=u===-1?"":d.slice(u+1);m.trim()&&e.push({language:g,code:m.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 Pu=jt(),Dn=()=>new Map,{valueAtom:Bt,useActions:Zn,createActions:Np,reducer:jp}=ro(Dn,{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:()=>Dn()});function Fn(t){let e=(0,Pu.c)(27),{addStagedCell:a,removeStagedCell:r,clearStagedCells:s}=Zn(),{createNewCell:n,updateCellCode:o}=Qr(),i=jo(),l=(0,A.useRef)(null),d;e[0]!==a||e[1]!==n?(d=w=>{let S=
|
|
27
|
+
`}}return Mt({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"?kt.LOCAL_TABLE:kt.REMOTE_TABLE,type:ts(r),apply:`@${a}`,section:{name:ts(r)==="dataframe"?"Dataframe":"Table",rank:wt.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 c=d.insertCell();c.classList.add("p-2","font-medium","text-left"),c.textContent="Type";let g=a.columns.some(b=>this.getItemMetadata(a,b)!==void 0),m;g&&(m=d.insertCell(),m.classList.add("p-2","font-medium","text-left"),m.textContent="Metadata"),a.columns.forEach((b,f)=>{let p=l.insertRow();p.classList.add(f%2==0?"bg-background":"bg-muted/30");let h=p.insertCell();h.classList.add("p-2","font-mono"),h.textContent=b.name;let v=p.insertCell();if(v.classList.add("p-2","text-muted-foreground"),v.textContent=b.type,g){let T=p.insertCell();T.classList.add("p-2");let w=this.getItemMetadata(a,b);w&&T.append(w)}}),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}}},Iu=class extends Pt{constructor(e,a){super();L(this,"title","Variables");L(this,"mentionPrefix","@");L(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:wt.VARIABLE,info:()=>zi(r)}}formatContext(e){let{data:a}=e,{variable:r}=a;return Mt({type:this.contextType,data:{name:r.name,dataType:r.dataType},details:r.value==null?void 0:JSON.stringify(r.value)})}};function pt(t){let e=t.get(Mi),a=t.get(Li),r=t.get(Si);return new wo().register(new Tu(a)).register(new Iu(r,a)).register(new ku(t)).register(new bu(t)).register(new ko(e.connectionsMap,a))}function Su(){return new Eu(uo())}const Au="@";function Ou({input:t}){let e="";return t.includes("@")&&(e=Nu(t),ie.debug("Included context",e)),{includeOtherCode:Xr(""),context:{plainText:e,schema:[],variables:[]}}}async function Ru({input:t}){let e="",a=[];if(t.includes("@")){let r=pt(Yr),s=r.parseAllContextIds(t);e=r.formatContextForAI(s);try{a=await r.getAttachmentsForContext(s),ie.debug("Included attachments",a.length)}catch(n){ie.error("Error getting attachments:",n)}}return{body:{includeOtherCode:Xr(""),context:{plainText:e,schema:[],variables:[]}},attachments:a}}function Nu(t){let e=pt(Yr),a=e.parseAllContextIds(t);return e.formatContextForAI(a)}function ju(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 $n(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(),so(t.current.view)}}function Mu(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(" "),c=u===-1?d:d.slice(0,u),g=c==="markdown"?"markdown":c==="sql"?"sql":"python",m=u===-1?"":d.slice(u+1);m.trim()&&e.push({language:g,code:m.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 Pu=jt(),Dn=()=>new Map,{valueAtom:Bt,useActions:Zn,createActions:Np,reducer:jp}=ro(Dn,{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:()=>Dn()});function Fn(t){let e=(0,Pu.c)(27),{addStagedCell:a,removeStagedCell:r,clearStagedCells:s}=Zn(),{createNewCell:n,updateCellCode:o}=Qr(),i=jo(),l=(0,A.useRef)(null),d;e[0]!==a||e[1]!==n?(d=w=>{let S=es.create();return a({cellId:S,edit:{type:"add_cell"}}),n({cellId:"__end__",code:w,before:!1,newCellId:S}),S},e[0]=a,e[1]=n,e[2]=d):d=e[2];let u=d,c;e[3]!==t||e[4]!==o?(c=w=>{let{cellId:S,code:P}=w;if(!t.get(Bt).has(S)){ie.error("Staged cell not found",{cellId:S});return}let D=Ni(S);D?Fa(D,P):o({cellId:S,code:P,formattingChange:!1})},e[3]=t,e[4]=o,e[5]=c):c=e[5];let g=c,m;e[6]!==i||e[7]!==r?(m=w=>{r(w),i({cellId:w})},e[6]=i,e[7]=r,e[8]=m):m=e[8];let b=m,f;e[9]!==s||e[10]!==i||e[11]!==t?(f=()=>{let w=t.get(Bt);for(let S of w.keys())i({cellId:S});s()},e[9]=s,e[10]=i,e[11]=t,e[12]=f):f=e[12];let p=f,h;e[13]!==a||e[14]!==n||e[15]!==u||e[16]!==g?(h=w=>{e:switch(w.type){case"text-start":l.current=new Lu(u,g,a,n);break e;case"text-delta":if(!l.current){ie.error("Cell creation stream not found");return}l.current.stream(w);break e;case"text-end":case"finish":if(!l.current){ie.error("Cell creation stream not found");return}l.current.stop();break e;case"abort":case"error":case"tool-input-error":case"tool-output-error":ie.error("Error",w.type,{chunk:w});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":ie.debug(w.type,{chunk:w});break e;default:if($u(w)){ie.debug("Data chunk",{chunk:w});break e}is(w)}},e[13]=a,e[14]=n,e[15]=u,e[16]=g,e[17]=h):h=e[17];let v=h,T;return e[18]!==a||e[19]!==s||e[20]!==u||e[21]!==p||e[22]!==b||e[23]!==v||e[24]!==r||e[25]!==g?(T={createStagedCell:u,updateStagedCell:g,addStagedCell:a,removeStagedCell:r,clearStagedCells:s,deleteStagedCell:b,deleteAllStagedCells:p,onStream:v},e[18]=a,e[19]=s,e[20]=u,e[21]=p,e[22]=b,e[23]=v,e[24]=r,e[25]=g,e[26]=T):T=e[26],T}var Lu=class{constructor(t,e,a,r){L(this,"createdCells",[]);L(this,"buffer","");L(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=Mu(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=Oo({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 $u(t){return t.type.startsWith("data-")}var Du={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}`)),Mt({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.`},Zu=H({edit:H({type:aa(["update_cell","add_cell","delete_cell"]),code:E().optional(),position:H({type:aa(["relative","column_end","notebook_end"]).optional(),cellId:E().optional(),columnIndex:ss().optional(),before:ce().optional()})})}),Fu=class{constructor(){L(this,"name","edit_notebook_tool");L(this,"description",Du);L(this,"schema",Zu);L(this,"outputSchema",Nn);L(this,"mode",["agent"]);L(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 xe("Code is required for update_cell","CODE_REQUIRED_FOR_UPDATE_CELL",!0,"Provide the new code to update the cell")}else throw new xe("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);qa(i);let u=s.get(Bt).get(i);if((u==null?void 0:u.type)==="add_cell"){Fa(d,o);break}let c=d.state.doc.toString(),g=(u==null?void 0:u.previousCode)??c;if(o===g)break;a({cellId:i,edit:{type:"update_cell",previousCode:g}}),Fa(d,o);break}case"add_cell":{let{position:n,code:o}=t,i="__end__",l=!1,d=
|
|
52
|
+
- A result object containing standard tool metadata.`},Zu=H({edit:H({type:aa(["update_cell","add_cell","delete_cell"]),code:E().optional(),position:H({type:aa(["relative","column_end","notebook_end"]).optional(),cellId:E().optional(),columnIndex:ss().optional(),before:ce().optional()})})}),Fu=class{constructor(){L(this,"name","edit_notebook_tool");L(this,"description",Du);L(this,"schema",Zu);L(this,"outputSchema",Nn);L(this,"mode",["agent"]);L(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 xe("Code is required for update_cell","CODE_REQUIRED_FOR_UPDATE_CELL",!0,"Provide the new code to update the cell")}else throw new xe("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);qa(i);let u=s.get(Bt).get(i);if((u==null?void 0:u.type)==="add_cell"){Fa(d,o);break}let c=d.state.doc.toString(),g=(u==null?void 0:u.previousCode)??c;if(o===g)break;a({cellId:i,edit:{type:"update_cell",previousCode:g}}),Fa(d,o);break}case"add_cell":{let{position:n,code:o}=t,i="__end__",l=!1,d=es.create(),u=s.get(Ge);switch(n.type){case"relative":{let c=n.cellId;if(!c)throw new xe("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 xe("Before is required for add_cell with relative position","TOOL_ERROR",!0,`Provide a boolean value for before, true to add before cell ${c}, false to add after the cell`);this.validateCellIdExists(c,u),i=c,l=n.before;break}case"column_end":if(!n.columnIndex)throw new xe("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"}}),qa(d);break}case"delete_cell":{let{position:n}=t,o=n.cellId;if(!o)throw new xe("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()}}),qa(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 xe("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 xe("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 xe("Cell editor not found","CELL_EDITOR_NOT_FOUND",!1,"Internal error, ask the user to report this error");return a.editorView}},zu=200,Uu=3e4,zn=2e3,Vu=3e3,qu=4e4,Bu={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."},Un=H({type:M("file"),url:E(),mediaType:E()}),Wu=class{constructor(t){L(this,"name","run_stale_cells_tool");L(this,"description",Bu);L(this,"schema",H({}));L(this,"outputSchema",Nn.extend({cellsToOutput:Nt(E(),H({consoleOutput:E().optional(),cellOutput:E().optional(),consoleAttachments:ze(Un).optional(),cellAttachments:ze(Un).optional()}).nullable()).optional()}));L(this,"mode",["agent"]);L(this,"handler",async(t,e)=>{let{prepareForRun:a,sendRun:r,store:s}=e,n=s.get(Ge),o=Ei(n);if(o.length===0)return{status:"success",message:"No stale cells found."};if(await Ao({cellIds:o,sendRun:r,prepareForRun:a,notebook:n}),!await this.waitForCellsToFinish(s,o,Uu,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=!1,u=!1,c=0;for(let m of o){let b=Mn(m,i,{includeConsoleOutput:!0}),f=b.cellOutput,p=b.consoleOutputs,h=p&&p.length>0;if((f&&this.outputHasErrors(f)||h&&p.some(w=>this.outputHasErrors(w)))&&(d=!0),!f&&!h){l.set(m,null);continue}if(c>=qu){l.set(m,{cellOutput:"Cell executed (output omitted due to context limits)."});continue}let v,T;f&&(v=this.formatOutputString(f),c+=v.length),h&&(u=!0,T=p.map(w=>this.formatOutputString(w)).join(`
|
|
53
53
|
`),T=this.truncateString(T,zn),c+=T.length),l.set(m,{cellOutput:v,consoleOutput:T})}if(l.size===0)return{status:"success",message:"Stale cells have been run. No output was returned."};let g=["Review the output of the cells. The CellId is the key of the result object.",d?"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:u?"Console output represents the stdout or stderr of the cell (eg. print statements).":void 0,next_steps:g}});this.postExecutionDelay=(t==null?void 0:t.postExecutionDelay)??zu}outputHasErrors(t){return t.output.mimetype==="application/vnd.marimo+error"||t.output.mimetype==="application/vnd.marimo+traceback"}formatOutputString(t){let{outputType:e,processedContent:a,imageUrl:r,output:s}=t;if(e==="media"){let i=`Media Output: Contains ${s.mimetype} content`;return r?`${i}
|
|
54
54
|
Image URL: ${r}`:i}if(s.mimetype==="text/html")return`HTML Output: text/html content (${(typeof s.data=="string"?s.data.length:JSON.stringify(s.data).length).toLocaleString()} chars). Full output visible in notebook UI.`;let n=this.outputHasErrors(t)?Vu:zn,o=a;return o||(o=typeof s.data=="string"?s.data:JSON.stringify(s.data)),`Output:
|
|
55
55
|
${this.truncateString(o,n)}`}truncateString(t,e){return t.length<=e?t:`${t.slice(0,e)}
|
|
@@ -73,8 +73,8 @@ ${this.truncateString(o,n)}`}truncateString(t,e){return t.length<=e?t:`${t.slice
|
|
|
73
73
|
- `)}`),t.additionalInfo&&(e+=`
|
|
74
74
|
|
|
75
75
|
## Additional info:
|
|
76
|
-
- ${t.additionalInfo}`),e}var Vn,Wt;function Ku(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 Pr=new(Vn
|
|
77
|
-
`)}async function Wn(t){let e=await Ru({input:tc(t.flatMap(r=>r.parts))});function a(r,s){return s?{...r,parts:[...r.parts,...e.attachments]}:r}return{...e.body,uiMessages:t.map((r,s)=>a(r,s===t.length-1))}}async function Jn({invokeAiTool:t,addToolOutput:e,toolCall:a,toolContext:r}){try{if(Pr.has(a.toolName)){let s=await Pr.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){ie.error("Tool call failed:",s),e({tool:a.toolName,toolCallId:a.toolCallId,output:`Error: ${s instanceof Error?s.message:String(s)}`})}}function ac(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 ie.warn("All tool calls completed: %s",s),s&&!o}function Kn(){let t=(0,Hu.c)(7),e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],t[0]=e):e=t[0];let[a,r]=(0,A.useState)(e),s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=c=>{if(c.length!==0){if(c.reduce(rc,0)>Qu){Va({title:"File size exceeded",description:"Attachments must be under 50 MB",variant:"danger"});return}r(g=>[...g,...c])}},t[1]=s):s=t[1];let n=Hr(s),o;t[2]===Symbol.for("react.memo_cache_sentinel")?(o=()=>r([]),t[2]=o):o=t[2];let i=o,l;t[3]===Symbol.for("react.memo_cache_sentinel")?(l=c=>r(g=>g.filter(m=>m!==c)),t[3]=l):l=t[3];let d=l,u;return t[4]!==n||t[5]!==a?(u={files:a,addFiles:n,clearFiles:i,removeFile:d},t[4]=n,t[5]=a,t[6]=u):u=t[6],u}function rc(t,e){return t+e.size}var Jt=jt(),C=Za(Gi(),1);const sc=t=>{var o;let e=(0,Jt.c)(6),{attachment:a}=t;if((o=a.mediaType)!=null&&o.startsWith("image/")){let i=a.filename||"Attachment",l;return e[0]!==a.url||e[1]!==i?(l=(0,C.jsx)("img",{src:a.url,alt:i,className:"max-h-[100px] max-w-[100px] object-contain mb-1.5"}),e[0]=a.url,e[1]=i,e[2]=l):l=e[2],l}let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,C.jsx)(ms,{className:"h-3 w-3 mt-0.5"}),e[3]=r):r=e[3];let s=a.filename||"Attachment",n;return e[4]===s?n=e[5]:(n=(0,C.jsxs)("div",{className:"flex flex-row gap-1 items-center text-xs",children:[r,s]}),e[4]=s,e[5]=n),n},Yn=t=>{let e=(0,Jt.c)(12),{file:a,className:r,onRemove:s}=t,[n,o]=(0,A.useState)(!1),i;e[0]===r?i=e[1]:(i=za("py-1 px-1.5 bg-muted rounded-md cursor-pointer flex flex-row gap-1 items-center text-xs",r),e[0]=r,e[1]=i);let l,d;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>o(!0),d=()=>o(!1),e[2]=l,e[3]=d):(l=e[2],d=e[3]);let u;e[4]!==a||e[5]!==n||e[6]!==s?(u=n?(0,C.jsx)(us,{className:"h-3 w-3 mt-0.5",onClick:s}):nc(a),e[4]=a,e[5]=n,e[6]=s,e[7]=u):u=e[7];let c;return e[8]!==a.name||e[9]!==i||e[10]!==u?(c=(0,C.jsxs)("div",{className:i,onMouseEnter:l,onMouseLeave:d,children:[u,a.name]}),e[8]=a.name,e[9]=i,e[10]=u,e[11]=c):c=e[11],c},Hn=t=>{let e=(0,Jt.c)(12),{isLoading:a,onStop:r,onSendClick:s,isEmpty:n,showStopLabel:o}=t,i=o===void 0?!1:o,l;e[0]===i?l=e[1]:(l=i?(0,C.jsxs)("div",{className:"flex flex-row items-center gap-1 px-1.5",children:[(0,C.jsx)("span",{className:"text-xs text-error",children:"Stop"}),(0,C.jsx)(vo,{size:"small"})]}):(0,C.jsx)(fs,{className:"size-4 text-error"}),e[0]=i,e[1]=l);let d=l,u=a?"Stop":"Submit",c=a?r:s,g=a?!1:n,m;e[2]!==a||e[3]!==d?(m=a?d:(0,C.jsx)(ys,{className:"h-3.5 w-3.5"}),e[2]=a,e[3]=d,e[4]=m):m=e[4];let b;e[5]!==c||e[6]!==g||e[7]!==m?(b=(0,C.jsx)(Qe,{variant:"text",size:"sm",className:"h-6 min-w-6 p-0 hover:bg-muted/30 cursor-pointer",onClick:c,disabled:g,children:m}),e[5]=c,e[6]=g,e[7]=m,e[8]=b):b=e[8];let f;return e[9]!==u||e[10]!==b?(f=(0,C.jsx)(la,{content:u,children:b}),e[9]=u,e[10]=b,e[11]=f):f=e[11],f},Gn=t=>{let e=(0,Jt.c)(4),{handleAddContext:a,isLoading:r}=t,s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,C.jsx)(hs,{className:"h-3.5 w-3.5"}),e[0]=s):s=e[0];let n;return e[1]!==a||e[2]!==r?(n=(0,C.jsx)(la,{content:"Add context",children:(0,C.jsx)(Qe,{variant:"text",size:"icon",onClick:a,disabled:r,children:s})}),e[1]=a,e[2]=r,e[3]=n):n=e[3],n},Qn=t=>{let e=(0,Jt.c)(15),{fileInputRef:a,isLoading:r,onAddFiles:s}=t,n;e[0]===a?n=e[1]:(n=()=>{var g;return(g=a.current)==null?void 0:g.click()},e[0]=a,e[1]=n);let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=(0,C.jsx)(gs,{className:"h-3.5 w-3.5"}),e[2]=o):o=e[2];let i;e[3]!==r||e[4]!==n?(i=(0,C.jsx)(la,{content:"Attach a file",children:(0,C.jsx)(Qe,{variant:"text",size:"icon",onClick:n,disabled:r,children:o})}),e[3]=r,e[4]=n,e[5]=i):i=e[5];let l;e[6]===s?l=e[7]:(l=g=>{g.target.files&&s([...g.target.files])},e[6]=s,e[7]=l);let d;e[8]===Symbol.for("react.memo_cache_sentinel")?(d=Gu.join(","),e[8]=d):d=e[8];let u;e[9]!==a||e[10]!==l?(u=(0,C.jsx)(bo,{ref:a,type:"file",multiple:!0,hidden:!0,onChange:l,accept:d}),e[9]=a,e[10]=l,e[11]=u):u=e[11];let c;return e[12]!==i||e[13]!==u?(c=(0,C.jsxs)(C.Fragment,{children:[i,u]}),e[12]=i,e[13]=u,e[14]=c):c=e[14],c};function nc(t){let e="h-3 w-3 mt-0.5";return t.type.startsWith("image/")?(0,C.jsx)(yo,{className:e}):t.type.startsWith("text/")?(0,C.jsx)(Li,{className:e}):(0,C.jsx)(ms,{className:e})}function ic(t){return Qi.define({combine:e=>e[0]??t})}var Xn=ic({}),$r=sa.define(),ja=sa.define(),oc=50,Dr=ia.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(ja)||n.is($r))||(a.navigationIndex=-1,a.originalText=""));for(let n of e.effects)if(n.is($r)){let o=n.value.trim();o&&(a.prompts=[o,...t.prompts.filter(i=>i!==o)].slice(0,oc),(s=(r=e.state.facet(Xn)).save)==null||s.call(r,a.prompts)),a.navigationIndex=-1,a.originalText=""}else n.is(ja)&&(a.navigationIndex=n.value.index,a.originalText=n.value.originalText);return a}}),lc=t=>{let e=t.state.field(Dr),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:ja.of({index:r,originalText:s})}),!0},dc=t=>{let e=t.state.field(Dr);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:ja.of({index:r,originalText:e.originalText})}),!0};const ei=t=>{let e=t.state.doc.toString();return e.trim()?(t.dispatch({effects:$r.of(e)}),!0):!1};function uc(t={}){let{storage:e,defaultKeymap:a=!0}=t,r=[Dr.init(()=>{var s;return{prompts:((s=e==null?void 0:e.load)==null?void 0:s.call(e))??[],navigationIndex:-1,originalText:""}}),Xn.of(e??{})];return a&&r.push(na.of([{key:"ArrowUp",run:lc},{key:"ArrowDown",run:dc}])),r}const Zr=sa.define(),We=ia.define({create(){return new Map},update(t,e){let a=!1,r=t;for(let s of e.effects)if(s.is(Zr)){a||(a=(r=new Map(t),!0));for(let[n,o]of s.value)r.set(n,o)}return r}}),cc=ia.define({create(){return{onResourceClick:void 0,onResourceMouseOver:void 0,onResourceMouseOut:void 0,onPromptSubmit:void 0}},update(t){return t}}),pc=sa.define();ia.define({create(){return new Map},update(t,e){let a=!1,r=t;for(let s of e.effects)if(s.is(pc)){a||(a=(r=new Map(t),!0));for(let[n,o]of s.value)r.set(n,o)}return r}});const mc=(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=Zr.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,c)=>{l.dispatch({changes:{from:u,to:c,insert:`@${i.uri} `}})}}));return{from:r.from,options:o}},hc=/@[\w-]+:\/\/(?!\/)[^\s]+/;function st(t){return t.matchAll(new RegExp(hc.source,"g"))}var fc=class extends ds{constructor(e,a){super();L(this,"resource");L(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(cc,!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}},gc=class extends ds{constructor(e,a){super();L(this,"uri");L(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 ti(t){let e=t.state.field(We),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(Ua.replace({widget:new fc(d,t)}).range(i,i+o[0].length)):a.push(Ua.replace({widget:new gc(l,t)}).range(i,i+o[0].length))}}return Ua.set(a)}const yc=to.fromClass(class{constructor(t){L(this,"decorations");this.decorations=ti(t)}update(t){(t.docChanged||t.viewportChanged||t.transactions.some(e=>e.effects.some(a=>a.is(Zr))))&&(this.decorations=ti(t.view))}},{decorations:t=>t.decorations});function vc(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 _c(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 bc(t){return ao((e,a)=>{let{from:r,text:s}=e.state.doc.lineAt(a),n=_c(s,a,e.state.field(We),r);return n?{pos:n.start,end:n.end,above:!0,create(){return(t.createTooltip??vc)(n.resource)}}:null})}function xc(t,e){let a=t.field(We),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 wc(t,e){let a=t.field(We),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 ai(t,e){let a=t.field(We),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 kc(t,e){let a=t.field(We),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,c=l[0].slice(1);a.has(c)&&u<=e&&(e>u?i=u:e===u&&(i=d))}return i}function Cc(t,e){let a=t.field(We),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 Ec=Xi.transactionFilter.of(t=>{var r;let e=t.annotation(eo.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(We),n=t.startState.doc,o=!1,i=0,l=[];if(t.changes.iterChanges((d,u,c,g,m)=>{let b=m.toString(),f=d;if(/^\s+$/.test(b)){l.push({from:d,to:u,insert:b});return}let p=n.lineAt(f),h=n.sliceString(p.from,p.to),v=Array.from(st(h)),T=!1,w=!1;for(let P of v){let D=p.from+P.index,N=D+P[0].length,K=P[0].slice(1);if(s.has(K)){if(f===D){let j=f>0?n.sliceString(f-1,f):"";j!==""&&j!==" "&&j!==`
|
|
76
|
+
- ${t.additionalInfo}`),e}var Vn,Wt;function Ku(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 Pr=new(Vn=$i(),Wt=class{constructor(t=[]){L(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 xe(`Tool ${t} returned invalid input: ${rs(l.error)}`,"INVALID_ARGUMENTS",!0,"Please check the arguments and try again.");let d=l.data,u=await s(d,a),c=await o.safeParseAsync(u);if(c.error){let g=rs(c.error);throw Error(`Tool ${t} returned invalid output: ${g}`)}return{tool_name:t,result:c.data,error:null}}catch(l){return l instanceof xe?{tool_name:t,result:null,error:l.toStructuredString()}:{tool_name:t,result:null,error:new xe(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:Ju(e.description),parameters:ns(e.schema),source:"frontend",mode:e.mode}))}},Ku(Wt.prototype,"getToolSchemas",[Vn],Object.getOwnPropertyDescriptor(Wt.prototype,"getToolSchemas"),Wt.prototype),Wt)([new Fu,new Wu]);function Lr(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 Yu(t){return Promise.all(t.map(e=>Lr(e,"base64").then(a=>[e.name,a])))}var Hu=jt();const qn=new Set(["openai","google","anthropic"]),Gu=["image/*","text/*"];var Qu=1024*1024*50;function Xu(t){return t.length>50?`${t.slice(0,50)}...`:t}async function Bn(t){return await Promise.all(t.map(async e=>({type:"file",mediaType:e.type,filename:e.name,url:await Lr(e,"dataUrl")})))}function ec(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 tc(t){return t.map(e=>e.type==="text"?e.text:"").join(`
|
|
77
|
+
`)}async function Wn(t){let e=await Ru({input:tc(t.flatMap(r=>r.parts))});function a(r,s){return s?{...r,parts:[...r.parts,...e.attachments]}:r}return{...e.body,uiMessages:t.map((r,s)=>a(r,s===t.length-1))}}async function Jn({invokeAiTool:t,addToolOutput:e,toolCall:a,toolContext:r}){try{if(Pr.has(a.toolName)){let s=await Pr.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){ie.error("Tool call failed:",s),e({tool:a.toolName,toolCallId:a.toolCallId,output:`Error: ${s instanceof Error?s.message:String(s)}`})}}function ac(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 ie.warn("All tool calls completed: %s",s),s&&!o}function Kn(){let t=(0,Hu.c)(7),e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],t[0]=e):e=t[0];let[a,r]=(0,A.useState)(e),s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=c=>{if(c.length!==0){if(c.reduce(rc,0)>Qu){Va({title:"File size exceeded",description:"Attachments must be under 50 MB",variant:"danger"});return}r(g=>[...g,...c])}},t[1]=s):s=t[1];let n=Hr(s),o;t[2]===Symbol.for("react.memo_cache_sentinel")?(o=()=>r([]),t[2]=o):o=t[2];let i=o,l;t[3]===Symbol.for("react.memo_cache_sentinel")?(l=c=>r(g=>g.filter(m=>m!==c)),t[3]=l):l=t[3];let d=l,u;return t[4]!==n||t[5]!==a?(u={files:a,addFiles:n,clearFiles:i,removeFile:d},t[4]=n,t[5]=a,t[6]=u):u=t[6],u}function rc(t,e){return t+e.size}var Jt=jt(),C=Za(Gi(),1);const sc=t=>{var o;let e=(0,Jt.c)(6),{attachment:a}=t;if((o=a.mediaType)!=null&&o.startsWith("image/")){let i=a.filename||"Attachment",l;return e[0]!==a.url||e[1]!==i?(l=(0,C.jsx)("img",{src:a.url,alt:i,className:"max-h-[100px] max-w-[100px] object-contain mb-1.5"}),e[0]=a.url,e[1]=i,e[2]=l):l=e[2],l}let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,C.jsx)(ms,{className:"h-3 w-3 mt-0.5"}),e[3]=r):r=e[3];let s=a.filename||"Attachment",n;return e[4]===s?n=e[5]:(n=(0,C.jsxs)("div",{className:"flex flex-row gap-1 items-center text-xs",children:[r,s]}),e[4]=s,e[5]=n),n},Yn=t=>{let e=(0,Jt.c)(12),{file:a,className:r,onRemove:s}=t,[n,o]=(0,A.useState)(!1),i;e[0]===r?i=e[1]:(i=za("py-1 px-1.5 bg-muted rounded-md cursor-pointer flex flex-row gap-1 items-center text-xs",r),e[0]=r,e[1]=i);let l,d;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>o(!0),d=()=>o(!1),e[2]=l,e[3]=d):(l=e[2],d=e[3]);let u;e[4]!==a||e[5]!==n||e[6]!==s?(u=n?(0,C.jsx)(us,{className:"h-3 w-3 mt-0.5",onClick:s}):nc(a),e[4]=a,e[5]=n,e[6]=s,e[7]=u):u=e[7];let c;return e[8]!==a.name||e[9]!==i||e[10]!==u?(c=(0,C.jsxs)("div",{className:i,onMouseEnter:l,onMouseLeave:d,children:[u,a.name]}),e[8]=a.name,e[9]=i,e[10]=u,e[11]=c):c=e[11],c},Hn=t=>{let e=(0,Jt.c)(12),{isLoading:a,onStop:r,onSendClick:s,isEmpty:n,showStopLabel:o}=t,i=o===void 0?!1:o,l;e[0]===i?l=e[1]:(l=i?(0,C.jsxs)("div",{className:"flex flex-row items-center gap-1 px-1.5",children:[(0,C.jsx)("span",{className:"text-xs text-error",children:"Stop"}),(0,C.jsx)(vo,{size:"small"})]}):(0,C.jsx)(fs,{className:"size-4 text-error"}),e[0]=i,e[1]=l);let d=l,u=a?"Stop":"Submit",c=a?r:s,g=a?!1:n,m;e[2]!==a||e[3]!==d?(m=a?d:(0,C.jsx)(ys,{className:"h-3.5 w-3.5"}),e[2]=a,e[3]=d,e[4]=m):m=e[4];let b;e[5]!==c||e[6]!==g||e[7]!==m?(b=(0,C.jsx)(Qe,{variant:"text",size:"sm",className:"h-6 min-w-6 p-0 hover:bg-muted/30 cursor-pointer",onClick:c,disabled:g,children:m}),e[5]=c,e[6]=g,e[7]=m,e[8]=b):b=e[8];let f;return e[9]!==u||e[10]!==b?(f=(0,C.jsx)(la,{content:u,children:b}),e[9]=u,e[10]=b,e[11]=f):f=e[11],f},Gn=t=>{let e=(0,Jt.c)(4),{handleAddContext:a,isLoading:r}=t,s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,C.jsx)(hs,{className:"h-3.5 w-3.5"}),e[0]=s):s=e[0];let n;return e[1]!==a||e[2]!==r?(n=(0,C.jsx)(la,{content:"Add context",children:(0,C.jsx)(Qe,{variant:"text",size:"icon",onClick:a,disabled:r,children:s})}),e[1]=a,e[2]=r,e[3]=n):n=e[3],n},Qn=t=>{let e=(0,Jt.c)(15),{fileInputRef:a,isLoading:r,onAddFiles:s}=t,n;e[0]===a?n=e[1]:(n=()=>{var g;return(g=a.current)==null?void 0:g.click()},e[0]=a,e[1]=n);let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=(0,C.jsx)(gs,{className:"h-3.5 w-3.5"}),e[2]=o):o=e[2];let i;e[3]!==r||e[4]!==n?(i=(0,C.jsx)(la,{content:"Attach a file",children:(0,C.jsx)(Qe,{variant:"text",size:"icon",onClick:n,disabled:r,children:o})}),e[3]=r,e[4]=n,e[5]=i):i=e[5];let l;e[6]===s?l=e[7]:(l=g=>{g.target.files&&s([...g.target.files])},e[6]=s,e[7]=l);let d;e[8]===Symbol.for("react.memo_cache_sentinel")?(d=Gu.join(","),e[8]=d):d=e[8];let u;e[9]!==a||e[10]!==l?(u=(0,C.jsx)(bo,{ref:a,type:"file",multiple:!0,hidden:!0,onChange:l,accept:d}),e[9]=a,e[10]=l,e[11]=u):u=e[11];let c;return e[12]!==i||e[13]!==u?(c=(0,C.jsxs)(C.Fragment,{children:[i,u]}),e[12]=i,e[13]=u,e[14]=c):c=e[14],c};function nc(t){let e="h-3 w-3 mt-0.5";return t.type.startsWith("image/")?(0,C.jsx)(yo,{className:e}):t.type.startsWith("text/")?(0,C.jsx)(Oi,{className:e}):(0,C.jsx)(ms,{className:e})}function ic(t){return Qi.define({combine:e=>e[0]??t})}var Xn=ic({}),$r=sa.define(),ja=sa.define(),oc=50,Dr=ia.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(ja)||n.is($r))||(a.navigationIndex=-1,a.originalText=""));for(let n of e.effects)if(n.is($r)){let o=n.value.trim();o&&(a.prompts=[o,...t.prompts.filter(i=>i!==o)].slice(0,oc),(s=(r=e.state.facet(Xn)).save)==null||s.call(r,a.prompts)),a.navigationIndex=-1,a.originalText=""}else n.is(ja)&&(a.navigationIndex=n.value.index,a.originalText=n.value.originalText);return a}}),lc=t=>{let e=t.state.field(Dr),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:ja.of({index:r,originalText:s})}),!0},dc=t=>{let e=t.state.field(Dr);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:ja.of({index:r,originalText:e.originalText})}),!0};const ei=t=>{let e=t.state.doc.toString();return e.trim()?(t.dispatch({effects:$r.of(e)}),!0):!1};function uc(t={}){let{storage:e,defaultKeymap:a=!0}=t,r=[Dr.init(()=>{var s;return{prompts:((s=e==null?void 0:e.load)==null?void 0:s.call(e))??[],navigationIndex:-1,originalText:""}}),Xn.of(e??{})];return a&&r.push(na.of([{key:"ArrowUp",run:lc},{key:"ArrowDown",run:dc}])),r}const Zr=sa.define(),We=ia.define({create(){return new Map},update(t,e){let a=!1,r=t;for(let s of e.effects)if(s.is(Zr)){a||(a=(r=new Map(t),!0));for(let[n,o]of s.value)r.set(n,o)}return r}}),cc=ia.define({create(){return{onResourceClick:void 0,onResourceMouseOver:void 0,onResourceMouseOut:void 0,onPromptSubmit:void 0}},update(t){return t}}),pc=sa.define();ia.define({create(){return new Map},update(t,e){let a=!1,r=t;for(let s of e.effects)if(s.is(pc)){a||(a=(r=new Map(t),!0));for(let[n,o]of s.value)r.set(n,o)}return r}});const mc=(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=Zr.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,c)=>{l.dispatch({changes:{from:u,to:c,insert:`@${i.uri} `}})}}));return{from:r.from,options:o}},hc=/@[\w-]+:\/\/(?!\/)[^\s]+/;function st(t){return t.matchAll(new RegExp(hc.source,"g"))}var fc=class extends ds{constructor(e,a){super();L(this,"resource");L(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(cc,!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}},gc=class extends ds{constructor(e,a){super();L(this,"uri");L(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 ti(t){let e=t.state.field(We),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(Ua.replace({widget:new fc(d,t)}).range(i,i+o[0].length)):a.push(Ua.replace({widget:new gc(l,t)}).range(i,i+o[0].length))}}return Ua.set(a)}const yc=to.fromClass(class{constructor(t){L(this,"decorations");this.decorations=ti(t)}update(t){(t.docChanged||t.viewportChanged||t.transactions.some(e=>e.effects.some(a=>a.is(Zr))))&&(this.decorations=ti(t.view))}},{decorations:t=>t.decorations});function vc(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 _c(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 bc(t){return ao((e,a)=>{let{from:r,text:s}=e.state.doc.lineAt(a),n=_c(s,a,e.state.field(We),r);return n?{pos:n.start,end:n.end,above:!0,create(){return(t.createTooltip??vc)(n.resource)}}:null})}function xc(t,e){let a=t.field(We),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 wc(t,e){let a=t.field(We),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 ai(t,e){let a=t.field(We),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 kc(t,e){let a=t.field(We),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,c=l[0].slice(1);a.has(c)&&u<=e&&(e>u?i=u:e===u&&(i=d))}return i}function Cc(t,e){let a=t.field(We),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 Ec=Xi.transactionFilter.of(t=>{var r;let e=t.annotation(eo.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(We),n=t.startState.doc,o=!1,i=0,l=[];if(t.changes.iterChanges((d,u,c,g,m)=>{let b=m.toString(),f=d;if(/^\s+$/.test(b)){l.push({from:d,to:u,insert:b});return}let p=n.lineAt(f),h=n.sliceString(p.from,p.to),v=Array.from(st(h)),T=!1,w=!1;for(let P of v){let D=p.from+P.index,N=D+P[0].length,K=P[0].slice(1);if(s.has(K)){if(f===D){let j=f>0?n.sliceString(f-1,f):"";j!==""&&j!==" "&&j!==`
|
|
78
78
|
`&&j!==" "&&(T=!0)}if(f===N){let j=f<n.length?n.sliceString(f,f+1):"";(j===""||j!==" "&&j!==`
|
|
79
79
|
`&&j!==" ")&&(w=!0)}}}let S=b;T&&(S=` ${S}`,i+=1),w&&(S=` ${S}`,i+=1),S!==b&&(o=!0),l.push({from:d,to:u,insert:S})}),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=xc(t.startState,a.head):e==="delete.forward"&&(s=wc(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=ai(t.startState,s);o=i&&s>i.from?i.from:kc(t.startState,s)}else if(n>s){let i=ai(t.startState,s);o=i&&s<i.to?i.to:Cc(t.startState,s)}if(o!==null&&o!==n)return[{selection:{anchor:o},scrollIntoView:!0}]}return t}),Tc=ls.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 ri="_none_",Ic=[{uri:"",name:"No resources",type:ri,data:{}}],Sc={info:"Variables, dataframes, and tables will appear here.",apply:()=>{}};function Ac(t){let{language:e,store:a,onAddFiles:r}=t;return[e.data.of({autocomplete:mc(async()=>{let s=pt(a).getAllItems();return s.length===0?Ic:s},s=>{var n;return s.type===ri?Sc:((n=pt(a).getProvider(s.type))==null?void 0:n.formatCompletion(s))||{}})}),os.high(na.of([{key:"Tab",run:s=>no(s)}])),Ln.of({addAttachment:s=>r==null?void 0:r([s])}),...r?[e.data.of({autocomplete:Su().createCompletionSource()})]:[],yc,Ec,We.init(()=>{let s=pt(a).getAllItems();return new Map(s.map(n=>[n.uri,n]))}),Tc,bc({createTooltip:s=>{let n=pt(a).getProvider(s.type);if(!n)return ie.warn("No provider found for resource",s),Kt(s.description||s.name);let o=n.formatCompletion(s),i=s.description||s.name;if(!(o!=null&&o.info))return Kt(i);if(typeof o.info=="string")return Kt(o.info);let l=o.info(o);return l?"dom"in l?{dom:l.dom}:"then"in l?(ie.warn("info is a promise. This is not supported",l),Kt(i)):{dom:l}:Kt(i)}})]}function Kt(t){let e=document.createElement("div");return e.innerHTML=t,{dom:e}}var Fr=jt();const si=t=>{let{handleAcceptCompletion:e,handleDeclineCompletion:a,isLoading:r,hasCompletion:s}=t;return n=>{let o=Ki()?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())}},Oc=t=>{let e=(0,Fr.c)(9),{isLoading:a,onAccept:r,onDecline:s,runCell:n}=t,o;e[0]!==a||e[1]!==r||e[2]!==n?(o=(0,C.jsx)(ni,{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,C.jsx)(ii,{onDecline:s,size:"xs"}),e[4]=s,e[5]=i);let l;return e[6]!==o||e[7]!==i?(l=(0,C.jsxs)(C.Fragment,{children:[o,i]}),e[6]=o,e[7]=i,e[8]=l):l=e[8],l},ni=t=>{let e=(0,Fr.c)(33),{isLoading:a,onAccept:r,multipleCompletions:s,size:n,buttonStyles:o,acceptShortcut:i,runCell:l,playButtonStyles:d,borderless:u}=t,c=s===void 0?!1:s,g=n===void 0?"sm":n,m=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,p=c?"Accept all":"Accept";if(l){let w=`h-6 text-(--grass-11) bg-(--grass-3)/60
|
|
80
80
|
hover:bg-(--grass-3) dark:bg-(--grass-4)/80 dark:hover:bg-(--grass-3) font-semibold
|
|
@@ -88,5 +88,5 @@ ${this.truncateString(o,n)}`}truncateString(t,e){return t.length<=e?t:`${t.slice
|
|
|
88
88
|
border-(--green-6) border hover:shadow-xs rounded px-3 ${o}`,v;e[24]===i?v=e[25]:(v=i&&(0,C.jsx)(Ba,{className:"ml-1 inline",shortcut:i}),e[24]=i,e[25]=v);let T;return e[26]!==a||e[27]!==r||e[28]!==g||e[29]!==h||e[30]!==v||e[31]!==p?(T=(0,C.jsxs)(Qe,{variant:"text",size:g,disabled:a,onClick:r,className:h,children:[p,v]}),e[26]=a,e[27]=r,e[28]=g,e[29]=h,e[30]=v,e[31]=p,e[32]=T):T=e[32],T},ii=t=>{let e=(0,Fr.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)
|
|
89
89
|
dark:bg-(--red-4)/80 dark:hover:bg-(--red-3) rounded px-3 font-semibold
|
|
90
90
|
active:bg-(--red-5) dark:active:bg-(--red-4)
|
|
91
|
-
border-(--red-6) border hover:shadow-xs ${(i===void 0?!1:i)&&"border-none rounded-md"} ${n}`,c=l&&" all",g;e[0]===o?g=e[1]:(g=o&&(0,C.jsx)(Ba,{className:"ml-1 inline",shortcut:o}),e[0]=o,e[1]=g);let m;return e[2]!==a||e[3]!==d||e[4]!==u||e[5]!==c||e[6]!==g?(m=(0,C.jsxs)(Qe,{variant:"text",size:d,onClick:a,className:u,children:["Reject",c,g]}),e[2]=a,e[3]=d,e[4]=u,e[5]=c,e[6]=g,e[7]=m):m=e[7],m};var Rc=class extends gr{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)}}))}},oi=jt(),Nc=
|
|
91
|
+
border-(--red-6) border hover:shadow-xs ${(i===void 0?!1:i)&&"border-none rounded-md"} ${n}`,c=l&&" all",g;e[0]===o?g=e[1]:(g=o&&(0,C.jsx)(Ba,{className:"ml-1 inline",shortcut:o}),e[0]=o,e[1]=g);let m;return e[2]!==a||e[3]!==d||e[4]!==u||e[5]!==c||e[6]!==g?(m=(0,C.jsxs)(Qe,{variant:"text",size:d,onClick:a,className:u,children:["Reject",c,g]}),e[2]=a,e[3]=d,e[4]=u,e[5]=c,e[6]=g,e[7]=m):m=e[7],m};var Rc=class extends gr{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)}}))}},oi=jt(),Nc=Pi("marimo:ai-language","python",Fi),li="marimo:ai-prompt-history",di=new Ai(ze(E()),()=>[]);const jc=t=>{var Jr;let e=(0,oi.c)(95),{onClose:a}=t,r=Kr(),[s,n]=(0,A.useState)(""),{deleteAllStagedCells:o,clearStagedCells:i,onStream:l,addStagedCell:d}=Fn(r),[u,c]=wi(Nc),g=Hi(),{invokeAiTool:m,sendRun:b}=lo(),f=Gr(Bt),p=(0,A.useRef)(null),h=(0,A.useRef)(null),{files:v,addFiles:T,removeFile:w}=Kn(),S=Gr(Yi),{createNewCell:P,prepareForRun:D}=Qr(),N;e[0]!==d||e[1]!==P||e[2]!==D||e[3]!==b||e[4]!==r?(N={store:r,addStagedCell:d,createNewCell:P,prepareForRun:D,sendRun:b},e[0]=d,e[1]=P,e[2]=D,e[3]=b,e[4]=r,e[5]=N):N=e[5];let K=N,j;if(e[6]!==u||e[7]!==l||e[8]!==g){let de;e[10]===u?de=e[11]:(de=async ta=>{let vi=await Wn(ta.messages);return{body:{...ta,...vi,code:"",prompt:"",language:u}}},e[10]=u,e[11]=de);let Ne;e[12]===l?Ne=e[13]:(Ne=ta=>{l(ta)},e[12]=l,e[13]=Ne),j=new Rc({api:g.getAiURL("completion").toString(),headers:g.headers(),prepareSendMessagesRequest:de},Ne),e[6]=u,e[7]=l,e[8]=g,e[9]=j}else j=e[9];let{sendMessage:W,stop:X,status:te,addToolOutput:ae}=Rn({experimental_throttle:100,transport:j,onToolCall:async de=>{let{toolCall:Ne}=de;await Jn({invokeAiTool:m,addToolOutput:G,toolCall:{toolName:Ne.toolName,toolCallId:Ne.toolCallId,input:Ne.input},toolContext:K})},onError:Mc}),G=ae,Z=te==="streaming"||te==="submitted",oe=f.size>0,ee=((Jr=S==null?void 0:S.models)==null?void 0:Jr.edit_model)||"openai/gpt-4o",Le;if(e[14]!==ee){let de=Ji.parse(ee).providerId;Le=qn.has(de),e[14]=ee,e[15]=Le}else Le=e[15];let Oe=Le,we;e[16]!==o||e[17]!==v||e[18]!==s||e[19]!==Z||e[20]!==W?(we=async()=>{var de;Z||((de=p.current)!=null&&de.view&&ei(p.current.view),o(),W({text:s,files:v?await Bn(v):void 0}))},e[16]=o,e[17]=v,e[18]=s,e[19]=Z,e[20]=W,e[21]=we):we=e[21];let he=we,$e;e[22]===Symbol.for("react.memo_cache_sentinel")?($e=(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(Lo,{className:"size-4 mr-2"}),"Python"]}),e[22]=$e):$e=e[22];let mt=$e,De;e[23]===Symbol.for("react.memo_cache_sentinel")?(De=(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(Ri,{className:"size-4 mr-2"}),"SQL"]}),e[23]=De):De=e[23];let Rt=De,ht=u==="python"?mt:Rt,ft;e[24]===Symbol.for("react.memo_cache_sentinel")?(ft=(0,C.jsx)(po,{className:"ml-1 h-3.5 w-3.5 text-muted-foreground/70"}),e[24]=ft):ft=e[24];let Je;e[25]===ht?Je=e[26]:(Je=(0,C.jsxs)(ho,{className:"flex items-center justify-between h-7 text-xs px-2 py-0.5 border rounded-md hover:text-accent-foreground","data-testid":"language-button",children:[ht,ft]}),e[25]=ht,e[26]=Je);let Re,nt;e[27]===Symbol.for("react.memo_cache_sentinel")?(Re=(0,C.jsx)("div",{className:"px-2 py-1 text-sm text-muted-foreground",children:"Select language"}),nt=(0,C.jsx)(mo,{}),e[27]=Re,e[28]=nt):(Re=e[27],nt=e[28]);let U;e[29]===c?U=e[30]:(U=(0,C.jsx)(ps,{onClick:()=>c("python"),children:mt}),e[29]=c,e[30]=U);let V;e[31]===c?V=e[32]:(V=(0,C.jsx)(ps,{onClick:()=>c("sql"),children:Rt}),e[31]=c,e[32]=V);let Y;e[33]!==U||e[34]!==V?(Y=(0,C.jsxs)(fo,{align:"center",children:[Re,nt,U,V]}),e[33]=U,e[34]=V,e[35]=Y):Y=e[35];let q;e[36]!==Je||e[37]!==Y?(q=(0,C.jsxs)(go,{modal:!1,children:[Je,Y]}),e[36]=Je,e[37]=Y,e[38]=q):q=e[38];let ke=q,ve;e[39]!==i||e[40]!==a?(ve=()=>{i(),a()},e[39]=i,e[40]=a,e[41]=ve):ve=e[41];let le=ve,se;e[42]===o?se=e[43]:(se=()=>{o()},e[42]=o,e[43]=se);let _e=se,it;e[44]===Symbol.for("react.memo_cache_sentinel")?(it=(0,C.jsx)(xo,{className:"size-4 text-(--blue-11) mr-2"}),e[44]=it):it=e[44];let Ze;e[45]!==o||e[46]!==a?(Ze=()=>{o(),a()},e[45]=o,e[46]=a,e[47]=Ze):Ze=e[47];let ot;e[48]===Symbol.for("react.memo_cache_sentinel")?(ot=de=>{n(de)},e[48]=ot):ot=e[48];let ne;e[49]!==le||e[50]!==_e||e[51]!==oe||e[52]!==Z?(ne=si({handleAcceptCompletion:le,handleDeclineCompletion:_e,isLoading:Z,hasCompletion:oe}),e[49]=le,e[50]=_e,e[51]=oe,e[52]=Z,e[53]=ne):ne=e[53];let ue;e[54]!==s||e[55]!==he||e[56]!==Ze||e[57]!==ne?(ue=(0,C.jsx)(ui,{inputRef:p,onClose:Ze,value:s,onChange:ot,onSubmit:he,onKeyDown:ne}),e[54]=s,e[55]=he,e[56]=Ze,e[57]=ne,e[58]=ue):ue=e[58];let Ke;e[59]===Symbol.for("react.memo_cache_sentinel")?(Ke=(0,C.jsx)(us,{className:"size-4"}),e[59]=Ke):Ke=e[59];let Ye;e[60]===a?Ye=e[61]:(Ye=(0,C.jsx)(Qe,{variant:"text",size:"sm",className:"mb-0 px-1",onClick:a,children:Ke}),e[60]=a,e[61]=Ye);let He;e[62]!==ue||e[63]!==Ye?(He=(0,C.jsxs)("div",{className:"flex items-center px-3",children:[it,ue,Ye]}),e[62]=ue,e[63]=Ye,e[64]=He):He=e[64];let La=He,Ht;e[65]===Symbol.for("react.memo_cache_sentinel")?(Ht=(0,C.jsx)(Wi,{triggerClassName:"h-7 text-xs max-w-64",iconSize:"small",forRole:"edit",showAddCustomModelDocs:!0}),e[65]=Ht):Ht=e[65];let gt;e[66]===ke?gt=e[67]:(gt=(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[Ht,ke]}),e[66]=ke,e[67]=gt);let yt;e[68]!==v||e[69]!==w?(yt=v.length>0&&(0,C.jsx)("div",{className:"flex flex-row gap-1 flex-wrap pr-1",children:v==null?void 0:v.map((de,Ne)=>(0,C.jsx)(Yn,{file:de,onRemove:()=>w(de)},`${de.name}-${Ne}`))}),e[68]=v,e[69]=w,e[70]=yt):yt=e[70];let Gt;e[71]===Symbol.for("react.memo_cache_sentinel")?(Gt=()=>$n(p),e[71]=Gt):Gt=e[71];let vt;e[72]===Z?vt=e[73]:(vt=(0,C.jsx)(Gn,{handleAddContext:Gt,isLoading:Z}),e[72]=Z,e[73]=vt);let _t;e[74]!==T||e[75]!==Oe||e[76]!==Z?(_t=Oe&&(0,C.jsx)(Qn,{fileInputRef:h,isLoading:Z,onAddFiles:T}),e[74]=T,e[75]=Oe,e[76]=Z,e[77]=_t):_t=e[77];let $a=!s.trim(),bt;e[78]!==Z||e[79]!==X||e[80]!==he||e[81]!==$a?(bt=(0,C.jsx)(Hn,{isLoading:Z,onStop:X,onSendClick:he,isEmpty:$a,showStopLabel:!0}),e[78]=Z,e[79]=X,e[80]=he,e[81]=$a,e[82]=bt):bt=e[82];let xt;e[83]!==yt||e[84]!==vt||e[85]!==_t||e[86]!==bt?(xt=(0,C.jsxs)("div",{className:"flex flex-row items-center",children:[yt,vt,_t,bt]}),e[83]=yt,e[84]=vt,e[85]=_t,e[86]=bt,e[87]=xt):xt=e[87];let Qt;e[88]!==gt||e[89]!==xt?(Qt=(0,C.jsxs)("div",{className:"px-3 pt-1 flex flex-row items-center justify-between",children:[gt,xt]}),e[88]=gt,e[89]=xt,e[90]=Qt):Qt=e[90];let Da=Qt,Xt;e[91]===Symbol.for("react.memo_cache_sentinel")?(Xt=za("flex flex-col w-full py-2"),e[91]=Xt):Xt=e[91];let ea;return e[92]!==Da||e[93]!==La?(ea=(0,C.jsxs)("div",{className:Xt,children:[La,Da]}),e[92]=Da,e[93]=La,e[94]=ea):ea=e[94],ea},ui=t=>{let e=(0,oi.c)(35),{value:a,placeholder:r,inputRef:s,className:n,onChange:o,onSubmit:i,onKeyDown:l,onClose:d,onAddFiles:u,additionalCompletions:c,maxHeight:g}=t,m=i,b=d,f=Kr(),{theme:p}=Eo(),h;e[0]===c?h=e[1]:(h=oe=>c?ju([c.triggerCompletionRegex],c.completions)(oe):null,e[0]=c,e[1]=h);let v=Hr(h),T,w,S,P;if(e[2]!==v||e[3]!==u||e[4]!==f){let oe=Co();e[9]===Symbol.for("react.memo_cache_sentinel")?(T=oo({}),e[9]=T):T=e[9],w=oe,S=Ac({language:oe.language,store:f,onAddFiles:u}),P=oe.language.data.of({autocomplete:v}),e[2]=v,e[3]=u,e[4]=f,e[5]=T,e[6]=w,e[7]=S,e[8]=P}else T=e[5],w=e[6],S=e[7],P=e[8];let D;e[10]===Symbol.for("react.memo_cache_sentinel")?(D=uc({storage:{load:Pc,save:Lc}}),e[10]=D):D=e[10];let N;e[11]===Symbol.for("react.memo_cache_sentinel")?(N=Mo(),e[11]=N):N=e[11];let K;e[12]===m?K=e[13]:(K=os.highest(na.of([{preventDefault:!0,stopPropagation:!0,any:(oe,ee)=>{let Le=ee.metaKey||ee.ctrlKey||ee.shiftKey;if(ee.key==="Enter"&&!Le)return m(ee,oe.state.doc.toString()),ee.preventDefault(),ee.stopPropagation(),!0;if(ee.key==="Enter"&&ee.shiftKey){let Oe=oe.state.selection.main.from;return oe.dispatch({changes:{from:Oe,to:Oe,insert:`
|
|
92
92
|
`},selection:{anchor:Oe+1,head:Oe+1}}),ee.preventDefault(),ee.stopPropagation(),!0}return!1}}])),e[12]=m,e[13]=K);let j;e[14]===b?j=e[15]:(j=na.of([{key:"Escape",preventDefault:!0,stopPropagation:!0,run:()=>(b(),!0)}]),e[14]=b,e[15]=j);let W;e[16]!==T||e[17]!==w||e[18]!==S||e[19]!==P||e[20]!==K||e[21]!==j?(W=[T,w,S,P,D,ls.lineWrapping,N,K,j],e[16]=T,e[17]=w,e[18]=S,e[19]=P,e[20]=K,e[21]=j,e[22]=W):W=e[22];let X=W,te;e[23]===n?te=e[24]:(te=za("flex-1 font-sans overflow-auto my-1",n),e[23]=n,e[24]=te);let ae=p==="dark"?"dark":"light",G=r||"Generate with AI, @ to include context",Z;return e[25]!==X||e[26]!==s||e[27]!==g||e[28]!==o||e[29]!==l||e[30]!==te||e[31]!==ae||e[32]!==G||e[33]!==a?(Z=(0,C.jsx)(Po,{ref:s,className:te,width:"100%",maxHeight:g,value:a,basicSetup:!1,extensions:X,onChange:o,onKeyDown:l,theme:ae,placeholder:G}),e[25]=X,e[26]=s,e[27]=g,e[28]=o,e[29]=l,e[30]=te,e[31]=ae,e[32]=G,e[33]=a,e[34]=Z):Z=e[34],Z};function Mc(t){Va({title:"Generate with AI failed",description:Io(t)})}function Pc(){return di.get(li)}function Lc(t){return di.set(li,t)}export{pt as A,Pr as C,Au as D,Fn as E,ys as F,gs as I,fs as L,vu as M,gr as N,$n as O,Ad as P,hs as R,Yu as S,Zn as T,Jn as _,ii as a,Kn as b,Gn as c,Yn as d,Hn as f,Xu as g,Bn as h,Oc as i,Rn as j,Ou as k,Qn as l,Wn as m,ui as n,si as o,qn as p,ni as r,ei as s,jc as t,sc as u,ac as v,Bt as w,Lr as x,ec as y};
|