@marimo-team/frontend 0.16.4 → 0.16.5
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-CEVFBnyt.js → CellStatus-BJRDATxe.js} +1 -1
- package/dist/assets/{ConnectedDataExplorerComponent-5izWKQVQ.js → ConnectedDataExplorerComponent-Cs4pQOKx.js} +1 -1
- package/dist/assets/{ImperativeModal-DujtmdOO.js → ImperativeModal-BG5LTpV0.js} +1 -1
- package/dist/assets/{JsonOutput-E2xVojk5.js → JsonOutput-BID8Oos7.js} +1 -1
- package/dist/assets/{LazyAnyLanguageCodeMirror-DHH4zj72.js → LazyAnyLanguageCodeMirror-RkzkO2YV.js} +2 -2
- package/dist/assets/MarimoErrorOutput-Lft73Wnl.js +6 -0
- package/dist/assets/{RenderHTML-BCi_V67U.js → RenderHTML-BoDLdBq-.js} +1 -1
- package/dist/assets/{VisuallyHidden-DvpnK2wO.js → VisuallyHidden-BiHw-PIc.js} +1 -1
- package/dist/assets/{accordion-C3CAEPwC.js → accordion-A41ffd5P.js} +1 -1
- package/dist/assets/{activity-BCW0BU81.js → activity-BhLNCNHF.js} +1 -1
- package/dist/assets/add-cell-with-ai-CxM_YKzf.js +36 -0
- package/dist/assets/{add-database-form-DSnHGqMe.js → add-database-form-Br1fMkMI.js} +1 -1
- package/dist/assets/{add-missing-import-Cwedhjm5.js → add-missing-import-CfRgNApn.js} +1 -1
- package/dist/assets/agent-panel-7ocujO8C.js +287 -0
- package/dist/assets/ai-model-dropdown-DSUVFIso.js +2 -0
- package/dist/assets/{alert-dialog-M1dUQe7C.js → alert-dialog-BO8sf-73.js} +1 -1
- package/dist/assets/{ansi_up-ZmFuCItK.js → ansi_up-D_b0GS7N.js} +1 -1
- package/dist/assets/{any-language-editor-BqGBgxZE.js → any-language-editor-edee1A1P.js} +1 -1
- package/dist/assets/app-config-button-Bg_CEfls.js +1 -0
- package/dist/assets/{architecture-O4VJ6CD3-CbkBEQri.js → architecture-O4VJ6CD3-CIYFBxkI.js} +1 -1
- package/dist/assets/{architectureDiagram-W76B3OCA-di95lJcF.js → architectureDiagram-W76B3OCA-CXqAkVTy.js} +1 -1
- package/dist/assets/{arrow-left-DQ-94PlS.js → arrow-left-D97p491f.js} +1 -1
- package/dist/assets/{between-horizontal-start-CotWLlFt.js → between-horizontal-start-DWTOsiF_.js} +1 -1
- package/dist/assets/{blockDiagram-QIGZ2CNN-ClcJSQFf.js → blockDiagram-QIGZ2CNN-DhYrUig_.js} +1 -1
- package/dist/assets/{c4Diagram-FPNF74CW-Cq2vxSdy.js → c4Diagram-FPNF74CW-Bj1S_Fyy.js} +1 -1
- package/dist/assets/{cell-actions-C5S4W3g_.js → cell-actions-hNx4EMmZ.js} +1 -1
- package/dist/assets/{cell-editor-X6EY7GQl.js → cell-editor-JimG_bBz.js} +13 -13
- package/dist/assets/cell-link-_kF38gGF.js +1 -0
- package/dist/assets/{cells-B4cnsYe_.js → cells-Dd1FatlG.js} +54 -54
- package/dist/assets/channel-Bil_pUlM.js +1 -0
- package/dist/assets/{chart-no-axes-column-DrG7h8mS.js → chart-no-axes-column-DmR44Tbq.js} +1 -1
- package/dist/assets/{chat-components-DXkntpg4.js → chat-components-OoNU4tLf.js} +3 -3
- package/dist/assets/chat-panel-DatwRFif.js +3 -0
- package/dist/assets/check-C5PVLNkJ.js +1 -0
- package/dist/assets/{chevron-right-Caf5yL5B.js → chevron-right-BDEhimQq.js} +1 -1
- package/dist/assets/{chunk-3AY6CYHV-BFFUJATX.js → chunk-3AY6CYHV-CBq2x1Nc.js} +1 -1
- package/dist/assets/{chunk-4KMFLZZN-D8J8fzqf.js → chunk-4KMFLZZN-DEMg9QYp.js} +1 -1
- package/dist/assets/{chunk-6OXUPJBA-Clo7-gS4.js → chunk-6OXUPJBA-CjFdZBrY.js} +2 -2
- package/dist/assets/{chunk-ABZYJK2D-DjRcbxmx.js → chunk-ABZYJK2D-eZsthrBr.js} +1 -1
- package/dist/assets/{chunk-BN7GFLIU-DvomLhVN.js → chunk-BN7GFLIU-ez-vZ7uD.js} +1 -1
- package/dist/assets/{chunk-CXMOBAN2-GhUPxuLT.js → chunk-CXMOBAN2-DxbPW6zT.js} +1 -1
- package/dist/assets/{chunk-EXTU4WIE-97Zvkznr.js → chunk-EXTU4WIE-C8Y_P6y8.js} +1 -1
- package/dist/assets/{chunk-JA3XYJ7Z-Mvfz9vG6.js → chunk-JA3XYJ7Z-pR89xWsn.js} +1 -1
- package/dist/assets/{chunk-JEIROHC2-Cp1tR_z8.js → chunk-JEIROHC2-2-ucCTVJ.js} +1 -1
- package/dist/assets/{chunk-K7UQS3LO-BbFs0Y5e.js → chunk-K7UQS3LO-Bz3bjON2.js} +1 -1
- package/dist/assets/{chunk-KMC2YHZD-Buiqyl2g.js → chunk-KMC2YHZD-BvMr39QE.js} +1 -1
- package/dist/assets/{chunk-QN33PNHL-dhs223oU.js → chunk-QN33PNHL-DgF0LOHR.js} +1 -1
- package/dist/assets/{chunk-QYVHNE3D-DA_jYaIp.js → chunk-QYVHNE3D-BxN3DJBX.js} +1 -1
- package/dist/assets/{chunk-S3R3BYOJ-DO68jEIo.js → chunk-S3R3BYOJ-Dy72CLbv.js} +1 -1
- package/dist/assets/{chunk-T44TD3VJ-Ww2OhwR5.js → chunk-T44TD3VJ-BfMjD4hS.js} +1 -1
- package/dist/assets/{chunk-TVAH2DTR-j2EljfwG.js → chunk-TVAH2DTR-CKnRAcjo.js} +1 -1
- package/dist/assets/{chunk-TZMSLE5B-DYFKU4Pb.js → chunk-TZMSLE5B-DdgcuCwZ.js} +1 -1
- package/dist/assets/{chunk-WFRQ32O7-k2LaZwie.js → chunk-WFRQ32O7-CHVQx4E8.js} +1 -1
- package/dist/assets/{chunk-WFWHJNB7-h5yM_3qQ.js → chunk-WFWHJNB7-B095GDsj.js} +1 -1
- package/dist/assets/{chunk-XRWGC2XP-C9Mh6qts.js → chunk-XRWGC2XP-C9u0mhR4.js} +1 -1
- package/dist/assets/{circle-play-Cktn64O2.js → circle-play-BnvyuDgL.js} +1 -1
- package/dist/assets/{circle-plus-CR5IX63e.js → circle-plus-CfdbDkkn.js} +1 -1
- package/dist/assets/{circle-x-t3DIkXqJ.js → circle-x-BsVcxKkV.js} +1 -1
- package/dist/assets/classDiagram-KNZD7YFC-CjqRV-TB.js +1 -0
- package/dist/assets/classDiagram-v2-RKCZMP56-CGekJfCg.js +1 -0
- package/dist/assets/client-RNr6mM1Y.js +2 -0
- package/dist/assets/{clipboard-paste-CCXUHJEo.js → clipboard-paste-CYFMW3x7.js} +1 -1
- package/dist/assets/column-preview-2H8pwalb.js +2 -0
- package/dist/assets/{columns-BBxos2iF.js → columns-qXe5bccO.js} +7 -7
- package/dist/assets/{command-CMralWVx.js → command-BZVf1cJP.js} +1 -1
- package/dist/assets/command-palette-CYMxp9xF.js +1 -0
- package/dist/assets/{common-CGhyb0HV.js → common-DW3bNKWY.js} +1 -1
- package/dist/assets/{config-DiCy6eC0.js → config-DXGmIv9f.js} +1 -1
- package/dist/assets/{copy-DAVB02c8.js → copy-6mpL4BeI.js} +1 -1
- package/dist/assets/{copy-icon-GGPHJWJ0.js → copy-icon-6ICckC-p.js} +1 -1
- package/dist/assets/{dagre-5GWH7T2D-B1wEBSrx.js → dagre-5GWH7T2D-hVCok2au.js} +1 -1
- package/dist/assets/{data-grid-overlay-editor-Drp4I0tg.js → data-grid-overlay-editor-BwcAr1JM.js} +1 -1
- package/dist/assets/datasources-panel-BvrtAadm.js +1 -0
- package/dist/assets/{dates-grtSI02N.js → dates-Au76svwW.js} +1 -1
- package/dist/assets/dependency-graph-panel-F9AD_whb.js +4 -0
- package/dist/assets/{diagram-N5W7TBWH-D0MGIq61.js → diagram-N5W7TBWH-C26XpepA.js} +1 -1
- package/dist/assets/{diagram-QEK2KX5R-DU6geLeA.js → diagram-QEK2KX5R-yrTR8I_L.js} +1 -1
- package/dist/assets/{diagram-S2PKOQOG-BNhY4Z1-.js → diagram-S2PKOQOG-BnrvSrEb.js} +1 -1
- package/dist/assets/{dialog-B7icy1Vb.js → dialog-CR68_CUl.js} +1 -1
- package/dist/assets/{dist-BNjtn4W8.js → dist--01dzFeG.js} +1 -1
- package/dist/assets/{dist-BagyUivg.js → dist--UHY1FN-.js} +1 -1
- package/dist/assets/{dist-5Gm6w_15.js → dist-6vTAXnMq.js} +1 -1
- package/dist/assets/{dist-DTazGMur.js → dist-B6CCfKkp.js} +1 -1
- package/dist/assets/dist-BAqgWgpM.js +1 -0
- package/dist/assets/{dist-BaApG_tl.js → dist-BUe_o-3o.js} +1 -1
- package/dist/assets/{dist-BpAb8rGb.js → dist-BnTbfmCK.js} +1 -1
- package/dist/assets/dist-C-4GTx-T.js +1 -0
- package/dist/assets/{dist-C0ek66tJ.js → dist-C1lnVyyK.js} +1 -1
- package/dist/assets/{dist-DGiVfc7V.js → dist-CbsJnssA.js} +1 -1
- package/dist/assets/{dist-DV-8bxFo.js → dist-CjoeBoZ9.js} +1 -1
- package/dist/assets/{dist-D5QvSsL_.js → dist-CsC8ZokE.js} +1 -1
- package/dist/assets/{dist-C69eWtaQ.js → dist-CyqTsfyg.js} +1 -1
- package/dist/assets/dist-D-ZYdf69.js +1 -0
- package/dist/assets/dist-D3B_GqVR.js +1 -0
- package/dist/assets/{dist-BME02X12.js → dist-DFJwMM7Z.js} +1 -1
- package/dist/assets/dist-Db9UVaw9.js +1 -0
- package/dist/assets/{dist-BPr57Wxb.js → dist-DhXqYYeD.js} +1 -1
- package/dist/assets/{dist-CL0hPMY6.js → dist-Dm8m1boP.js} +1 -1
- package/dist/assets/{dist-B0vg88Aq.js → dist-DvDyxv8b.js} +1 -1
- package/dist/assets/{dist-Bzn1Zd0x.js → dist-DzUKODTF.js} +1 -1
- package/dist/assets/dist-LmEq3o4w.js +1 -0
- package/dist/assets/dist-Z_cK0cSh.js +1 -0
- package/dist/assets/dist-biP83Yvc.js +1 -0
- package/dist/assets/dist-dJ4FqqTe.js +1 -0
- package/dist/assets/{documentation-panel-D4iq1tSm.js → documentation-panel-DYKAf6Sg.js} +1 -1
- package/dist/assets/{dom-4KyFHEbl.js → dom-CT3dAMQW.js} +1 -1
- package/dist/assets/{download-C4Fyu6kU.js → download-B4_BX7gi.js} +1 -1
- package/dist/assets/{download-qt61TbgC.js → download-BB5Iexmn.js} +1 -1
- package/dist/assets/{dropdown-menu-Bp1vhqcS.js → dropdown-menu-CJDB1PNI.js} +1 -1
- package/dist/assets/edit-page-BK3Irdme.js +12 -0
- package/dist/assets/{ellipsis-DVXWk8Lc.js → ellipsis-CJtiw1k3.js} +1 -1
- package/dist/assets/{ellipsis-vertical-DfpheMuY.js → ellipsis-vertical-DK--y082.js} +1 -1
- package/dist/assets/{en-US-B2g9dciI.js → en-US-CjWuOpsV.js} +1 -1
- package/dist/assets/{erDiagram-AWTI2OKA-DxxWZrYD.js → erDiagram-AWTI2OKA-9EqwLrlG.js} +1 -1
- package/dist/assets/{error-banner-ARu6PiHL.js → error-banner-BGjnZePp.js} +1 -1
- package/dist/assets/error-panel-CrkbkIF_.js +1 -0
- package/dist/assets/{es-C0Ih1AxE.js → es-C-CWIA-E.js} +1 -1
- package/dist/assets/{esm-BR7TuyMc.js → esm-7XxuulnL.js} +1 -1
- package/dist/assets/{esm-Cb-iIF_w.js → esm-B39og2OG.js} +1 -1
- package/dist/assets/{esm-BIF8NHm8.js → esm-BBn_y9Ew.js} +1 -1
- package/dist/assets/esm-DjUQOOJ2.js +1 -0
- package/dist/assets/{eye-off-BEVibdMQ.js → eye-off-9UMe_Y7D.js} +1 -1
- package/dist/assets/field-D6g5A_wf.js +1 -0
- package/dist/assets/{file-DqkkCGhs.js → file-BENStGHx.js} +1 -1
- package/dist/assets/file-explorer-panel-Cgv3WjVh.js +1 -0
- package/dist/assets/{file-plus-2-BCmZgbYs.js → file-plus-2-CloHhbsF.js} +1 -1
- package/dist/assets/{file-text-DNmaotaP.js → file-text-Lr1kJd4E.js} +1 -1
- package/dist/assets/{file-video-camera-C5lALvNf.js → file-video-camera-CfnyBQQe.js} +1 -1
- package/dist/assets/filename-B5Yo1bOu.js +1 -0
- package/dist/assets/{floating-outline-Cjas_exC.js → floating-outline-DZnSnZfg.js} +1 -1
- package/dist/assets/{flowDiagram-PVAE7QVJ-DlTZtqcN.js → flowDiagram-PVAE7QVJ-iOj6Qgu-.js} +1 -1
- package/dist/assets/{focus-OWoLlKnm.js → focus-Bnk25hTp.js} +1 -1
- package/dist/assets/{form-xOqp67zT.js → form-BGZvwlog.js} +1 -1
- package/dist/assets/{form--nX5W3gQ.js → form-DyKYT1WR.js} +1 -1
- package/dist/assets/{formats-C8bbggqj.js → formats-CWdWXhfT.js} +1 -1
- package/dist/assets/{fullscreen-BFmvQx5m.js → fullscreen-DTPr3iBY.js} +1 -1
- package/dist/assets/{ganttDiagram-OWAHRB6G-BEPmawB5.js → ganttDiagram-OWAHRB6G-BWbXeAXa.js} +1 -1
- package/dist/assets/{gitGraph-ZV4HHKMB-DsmmnKI3.js → gitGraph-ZV4HHKMB-BpeeuO4L.js} +1 -1
- package/dist/assets/{gitGraphDiagram-NY62KEGX-DfTKmX9v.js → gitGraphDiagram-NY62KEGX-BX3O-mzY.js} +1 -1
- package/dist/assets/{glide-data-editor-CzDe-oK3.js → glide-data-editor-C45ArX7n.js} +4 -4
- package/dist/assets/globals-BFoVgbHf.js +1 -0
- package/dist/assets/{globe-CgG1jfYF.js → globe-CPrVx8HM.js} +1 -1
- package/dist/assets/home-page-DhT6cm6c.js +4 -0
- package/dist/assets/{image-DXGqie4b.js → image-DTv0Ic6H.js} +1 -1
- package/dist/assets/{index-DtggTI4O.js → index-29P5xX8u.js} +11 -11
- package/dist/assets/index-Optxbl37.css +2 -0
- package/dist/assets/{info-63CPKGFF-BVRAJzgS.js → info-63CPKGFF-Czr08O9A.js} +1 -1
- package/dist/assets/{infoDiagram-STP46IZ2-CcEqfhrj.js → infoDiagram-STP46IZ2-C1JX9JfB.js} +1 -1
- package/dist/assets/input-C1RzjWSK.js +7 -0
- package/dist/assets/{isValid-gOtpcPxn.js → isValid-o3nZVu8e.js} +1 -1
- package/dist/assets/{journeyDiagram-BIP6EPQ6-CfxDuLls.js → journeyDiagram-BIP6EPQ6-CC2JvTQD.js} +1 -1
- package/dist/assets/{kanban-definition-6OIFK2YF-BwopERfW.js → kanban-definition-6OIFK2YF-3qAhCi66.js} +1 -1
- package/dist/assets/{key-BuxNhFKW.js → key-D4QiH_7H.js} +1 -1
- package/dist/assets/{kiosk-mode--OX2RHZj.js → kiosk-mode-Dy2WnuWt.js} +1 -1
- package/dist/assets/{label-COeaBwl_.js → label-BEUjZsdo.js} +1 -1
- package/dist/assets/{layout-CKoMTVJt.js → layout-C6K0XXFK.js} +3 -3
- package/dist/assets/{linear-BI0LBATm.js → linear-nWRf49aw.js} +1 -1
- package/dist/assets/{link-DSY8ADga.js → link-CDOxp9sn.js} +1 -1
- package/dist/assets/links-D-L0rzz9.js +1 -0
- package/dist/assets/{list-filter-D2Wx3thV.js → list-filter-CRC72QPW.js} +1 -1
- package/dist/assets/{loader-CPDA0quD.js → loader-CgbiPC_T.js} +1 -1
- package/dist/assets/logs-panel-BB-6orqg.js +1 -0
- package/dist/assets/{maps-CxCIYhRT.js → maps-DaQbs_UR.js} +1 -1
- package/dist/assets/{menu-items-COILZQ4q.js → menu-items-Bo6Dyd_Q.js} +1 -1
- package/dist/assets/{mermaid-oqJ6vLFm.js → mermaid-Bqzxmx0C.js} +1 -1
- package/dist/assets/{mermaid-parser.core-8414a7OP.js → mermaid-parser.core-CwRCqiGJ.js} +2 -2
- package/dist/assets/{mermaid.core-CKfX2q8j.js → mermaid.core-C4o4vdkw.js} +3 -3
- package/dist/assets/mermaid.core-DjncFP_O.js +1 -0
- package/dist/assets/{mindmap-definition-Q6HEUPPD-nadsjaMC.js → mindmap-definition-Q6HEUPPD-pLcSm-bI.js} +1 -1
- package/dist/assets/{mode-CBh2Ag_Y.js → mode-DQPKc-Hp.js} +1 -1
- package/dist/assets/{name-cell-input-CAG50xh2.js → name-cell-input-DQd65hJw.js} +1 -1
- package/dist/assets/{number-overlay-editor-CbWBjwI1.js → number-overlay-editor-Ce_FEpnn.js} +1 -1
- package/dist/assets/once-8ZDiGGtA.js +1 -0
- package/dist/assets/outline-panel-BJDiYH61.js +1 -0
- package/dist/assets/packages-panel-D_VswrEd.js +1 -0
- package/dist/assets/{packet-HUATNLJX-BJ_b_gYi.js → packet-HUATNLJX-C5NsAS_7.js} +1 -1
- package/dist/assets/{pie-WTHONI2E-CS2JfH5S.js → pie-WTHONI2E-BCNGQ0_9.js} +1 -1
- package/dist/assets/{pieDiagram-ADFJNKIX-DP_lAtPz.js → pieDiagram-ADFJNKIX-CUCBn1VN.js} +1 -1
- package/dist/assets/plug-DrNpofTj.js +1 -0
- package/dist/assets/{plus-C1zexBxS.js → plus-d2HNOuZI.js} +1 -1
- package/dist/assets/{popover-CLp_lH16.js → popover-DW0D4l0O.js} +1 -1
- package/dist/assets/{precisionRound-CR2cxaaR.js → precisionRound-TxjBk8nN.js} +1 -1
- package/dist/assets/{quadrantDiagram-LMRXKWRM-gzT_-w3S.js → quadrantDiagram-LMRXKWRM-C6DXTSnZ.js} +1 -1
- package/dist/assets/{radar-NJJJXTRR-ChMDxgqR.js → radar-NJJJXTRR-Cck-wBOB.js} +1 -1
- package/dist/assets/{react-plotly-DUuIpNDT.js → react-plotly-x7-8ig7L.js} +1 -1
- package/dist/assets/{readonly-python-code-DMLMHG1v.js → readonly-python-code-Cb7Ak_Dy.js} +1 -1
- package/dist/assets/{refresh-ccw-lUiAEOAx.js → refresh-ccw-CCJeTTJO.js} +1 -1
- package/dist/assets/{refresh-cw-CSv3xyYY.js → refresh-cw-B_tmnHav.js} +1 -1
- package/dist/assets/{renderShortcut-DMYtt-ju.js → renderShortcut-C9_NT6sD.js} +1 -1
- package/dist/assets/{request-registry-4Bq310sk.js → request-registry-D4PD0fDJ.js} +1 -1
- package/dist/assets/{requirementDiagram-4UW4RH46-aavD0qQF.js → requirementDiagram-4UW4RH46-Bj7w3axz.js} +1 -1
- package/dist/assets/run-page-D9jntYU0.js +1 -0
- package/dist/assets/{runs-CItfCHkl.js → runs-BWcKkv9g.js} +1 -1
- package/dist/assets/{sankeyDiagram-GR3RE2ED-r95m_h3N.js → sankeyDiagram-GR3RE2ED-DCmlCkUu.js} +1 -1
- package/dist/assets/{save-Bg0tsaXV.js → save-CVcbYdvl.js} +1 -1
- package/dist/assets/scratchpad-panel-BUGlPLwQ.js +1 -0
- package/dist/assets/{scroll-text-SAt1GCBr.js → scroll-text-CN-2fr92.js} +1 -1
- package/dist/assets/secrets-panel-DGPyMcTb.js +1 -0
- package/dist/assets/{select-CMG6DC3j.js → select-DKRTzlUU.js} +1 -1
- package/dist/assets/{send-ePQN2mpH.js → send-DRRBOpzT.js} +1 -1
- package/dist/assets/{sequenceDiagram-C3RYC4MD-C4GqHIgf.js → sequenceDiagram-C3RYC4MD-CtIOF8jj.js} +1 -1
- package/dist/assets/{settings-TIv8aSog.js → settings-6ySBJQ7Y.js} +1 -1
- package/dist/assets/{share-CUbi0XlA.js → share-Dcl7D_tA.js} +1 -1
- package/dist/assets/snippets-panel-CKi40HiX.js +1 -0
- package/dist/assets/{spinner-CxlO4-GJ.js → spinner-BhnfQOEl.js} +1 -1
- package/dist/assets/{square-uM1ci7iL.js → square-DKPXnMmD.js} +1 -1
- package/dist/assets/{square-function-OflPQrBg.js → square-function-DBJINsmk.js} +1 -1
- package/dist/assets/{square-terminal-DZAwMMdQ.js → square-terminal-DoFRZ-M6.js} +1 -1
- package/dist/assets/{src-BOK-SWX4.js → src-KuQao6GK.js} +1 -1
- package/dist/assets/state-B37sZn4X.js +1 -0
- package/dist/assets/{state-COfuW2QS.js → state-CEmS5WFQ.js} +1 -1
- package/dist/assets/state-jvUYiWCG.js +1 -0
- package/dist/assets/{stateDiagram-KXAO66HF-CdN43FzO.js → stateDiagram-KXAO66HF-DwZscOce.js} +1 -1
- package/dist/assets/stateDiagram-v2-UMBNRL4Z-D5XUGcJP.js +1 -0
- package/dist/assets/stex-C7nwqmPk.js +1 -0
- package/dist/assets/storage-CaQ7kwuv.js +1 -0
- package/dist/assets/{switch-BKaPFRvh.js → switch-B5bMMWJn.js} +1 -1
- package/dist/assets/{tabs-C8HicIPZ.js → tabs-8ThyQfYh.js} +1 -1
- package/dist/assets/{terminal-Cnm8ANjQ.js → terminal-CPdYItDn.js} +1 -1
- package/dist/assets/{text-search-DpMeajoz.js → text-search-iEvFn29l.js} +1 -1
- package/dist/assets/{textarea-DhU2DWSB.js → textarea-B-_OthMe.js} +1 -1
- package/dist/assets/{time-Dzg4b75Q.js → time-BkIHCvH2.js} +1 -1
- package/dist/assets/{timeline-definition-XQNQX7LJ-D48ppGT8.js → timeline-definition-XQNQX7LJ-BGsZ09p6.js} +1 -1
- package/dist/assets/{toDate-BartytS4.js → toDate-Daj1hQSF.js} +1 -1
- package/dist/assets/{toggle-BLLoLiay.js → toggle-BpFqu8FB.js} +1 -1
- package/dist/assets/{tooltip-BjoMzmCN.js → tooltip-ULHbIsj9.js} +1 -1
- package/dist/assets/tracing-UKZUjbDB.js +2 -0
- package/dist/assets/tracing-panel-CuDItRLt.js +2 -0
- package/dist/assets/{trash-2-GOPu47oc.js → trash-2-3UJSaMKF.js} +1 -1
- package/dist/assets/{trash-BpVsWH8l.js → trash-CYX7fe5Y.js} +1 -1
- package/dist/assets/{tree-qyAlDlFy.js → tree-3z9r1N_5.js} +1 -1
- package/dist/assets/{treemap-75Q7IDZK-B4o24kyC.js → treemap-75Q7IDZK-MX1Hmq0m.js} +1 -1
- package/dist/assets/{type-C9leWRlU.js → type-kF6pOJbH.js} +1 -1
- package/dist/assets/{types-BBD3GQ0S.js → types-DQDL7dro.js} +1 -1
- package/dist/assets/{types-DEwRoAG0.js → types-DyTIgBnH.js} +1 -1
- package/dist/assets/{useAddCell-DJhNA_O5.js → useAddCell-Dq3HqYz1.js} +1 -1
- package/dist/assets/{useAsyncData-BEqqunls.js → useAsyncData-D9GA9BWg.js} +1 -1
- package/dist/assets/{useBoolean-DnggoYme.js → useBoolean-CSR3XjhE.js} +1 -1
- package/dist/assets/{useCellActionButton-B_a4Sv2X.js → useCellActionButton-BAG0Vvnt.js} +1 -1
- package/dist/assets/{useDateFormatter-DjmrLzxH.js → useDateFormatter-DrFLqO1D.js} +1 -1
- package/dist/assets/{useDebounce-9_rqRiHk.js → useDebounce-_ztZiL0I.js} +1 -1
- package/dist/assets/{useDeepCompareMemoize-DIhr42Iz.js → useDeepCompareMemoize-BsZY8i2r.js} +1 -1
- package/dist/assets/{useDeleteCell-DVNOLjwN.js → useDeleteCell-CJaipocw.js} +1 -1
- package/dist/assets/useHotkey-DkiyGPLs.js +1 -0
- package/dist/assets/{useInstallPackage-CTHO3tj3.js → useInstallPackage-DoKAq17E.js} +1 -1
- package/dist/assets/useNotebookActions-CQd8IgyR.js +1 -0
- package/dist/assets/useSplitCell-Dodncnp8.js +1 -0
- package/dist/assets/{useTheme-C5JyqXTm.js → useTheme-oPMxEKRc.js} +1 -1
- package/dist/assets/{utilities.esm-DbqS7Pjb.js → utilities.esm-DcV_e-D3.js} +1 -1
- package/dist/assets/utils-DBmmAf_K.js +1 -0
- package/dist/assets/variable-panel-BCihDsBL.js +1 -0
- package/dist/assets/{vega-component-D1ZJxK-L.js → vega-component-CWMEFM7y.js} +1 -1
- package/dist/assets/{vega-loader.browser.module-Jwd7L8Ye.js → vega-loader.browser.module-BkWiTok0.js} +1 -1
- package/dist/assets/{with-selector-CXhuorCH.js → with-selector-BmLsipPw.js} +1 -1
- package/dist/assets/{workflow-Covue_dW.js → workflow-DA01FBLw.js} +1 -1
- package/dist/assets/{wrench-DNJq8NCj.js → wrench-B2m2X1sb.js} +1 -1
- package/dist/assets/{write-secret-modal-qe46KOIw.js → write-secret-modal-Dx9oubag.js} +1 -1
- package/dist/assets/{xychartDiagram-6GGTOJPD-DK41sZTI.js → xychartDiagram-6GGTOJPD-D-i5LTeX.js} +1 -1
- package/dist/assets/{youtube-0-RiaVkr.js → youtube-Bl4NeyvA.js} +1 -1
- package/dist/index.html +155 -155
- package/package.json +1 -1
- package/src/__tests__/chat-history.test.ts +123 -0
- package/src/components/app-config/ai-config.tsx +23 -0
- package/src/components/app-config/mcp-config.tsx +42 -2
- package/src/components/app-config/user-config-form.tsx +0 -24
- package/src/components/chat/acp/__tests__/context-utils.test.ts +1 -1
- package/src/components/chat/acp/agent-panel.tsx +1 -1
- package/src/components/chat/acp/blocks.tsx +46 -53
- package/src/components/chat/acp/common.tsx +1 -1
- package/src/components/chat/acp/context-utils.ts +1 -1
- package/src/components/chat/acp/session-tabs.tsx +1 -1
- package/src/components/chat/chat-history-popover.tsx +125 -0
- package/src/components/chat/chat-history-utils.ts +69 -0
- package/src/components/chat/chat-panel.tsx +9 -57
- package/src/components/editor/__tests__/data-attributes.test.tsx +1 -1
- package/src/components/editor/actions/useNotebookActions.tsx +2 -4
- package/src/components/editor/ai/__tests__/completion-utils.test.ts +23 -31
- package/src/components/editor/cell/CreateCellButton.tsx +14 -2
- package/src/components/editor/cell/code/cell-editor.tsx +1 -0
- package/src/components/editor/database/schemas.ts +2 -10
- package/src/components/editor/{Cell.tsx → notebook-cell.tsx} +5 -1
- package/src/components/editor/output/MarimoErrorOutput.tsx +4 -34
- package/src/components/editor/renderers/{CellArray.tsx → cell-array.tsx} +1 -1
- package/src/components/forms/__tests__/form-utils.test.ts +2 -2
- package/src/components/mcp/hooks.ts +48 -0
- package/src/components/mcp/mcp-status-indicator.tsx +144 -0
- package/src/components/ui/number-field.tsx +4 -1
- package/src/core/ai/context/providers/__tests__/__snapshots__/tables.test.ts.snap +13 -19
- package/src/core/ai/context/providers/__tests__/cell-output.test.ts +0 -1
- package/src/core/ai/context/providers/__tests__/datasource.test.ts +5 -6
- package/src/core/ai/context/providers/__tests__/error.test.ts +24 -15
- package/src/core/ai/context/providers/cell-output.ts +5 -5
- package/src/core/ai/context/providers/common.ts +13 -4
- package/src/core/ai/context/providers/datasource.ts +31 -20
- package/src/core/ai/context/providers/error.ts +3 -4
- package/src/core/ai/context/providers/file.ts +2 -2
- package/src/core/ai/context/providers/tables.ts +36 -8
- package/src/core/ai/context/providers/variable.ts +2 -3
- package/src/core/cells/__tests__/cells.test.ts +6 -6
- package/src/core/cells/cells.ts +12 -13
- package/src/core/cells/scrollCellIntoView.ts +1 -1
- package/src/core/codemirror/__tests__/setup.test.ts +1 -0
- package/src/core/codemirror/cm.ts +3 -2
- package/src/core/config/__tests__/config-schema.test.ts +2 -0
- package/src/core/config/config-schema.ts +2 -0
- package/src/core/config/feature-flag.tsx +0 -2
- package/src/core/edit-app.tsx +1 -1
- package/src/core/network/CachingRequestRegistry.ts +2 -2
- package/src/stories/cell.stories.tsx +1 -1
- package/src/stories/layout/vertical/one-column.stories.tsx +1 -1
- package/src/utils/numbers.ts +24 -1
- package/dist/assets/MarimoErrorOutput-CUb4AQdT.js +0 -6
- package/dist/assets/add-cell-with-ai-DCyfgnLI.js +0 -36
- package/dist/assets/agent-panel-B_MMb9mo.js +0 -287
- package/dist/assets/ai-model-dropdown-Dk9Kz_pz.js +0 -2
- package/dist/assets/api-DBBaApVO.js +0 -1
- package/dist/assets/app-config-button-Cbw9b5rl.js +0 -1
- package/dist/assets/cell-link-woRE950-.js +0 -1
- package/dist/assets/channel-D-YgrD6I.js +0 -1
- package/dist/assets/chat-panel-DLphumiN.js +0 -3
- package/dist/assets/check-hL6-9SZK.js +0 -1
- package/dist/assets/circle-check-big-C7DGeh12.js +0 -1
- package/dist/assets/classDiagram-KNZD7YFC-yzXw7kFX.js +0 -1
- package/dist/assets/classDiagram-v2-RKCZMP56-Co2zbBi0.js +0 -1
- package/dist/assets/client-CA946N69.js +0 -2
- package/dist/assets/column-preview-BT14RHNM.js +0 -2
- package/dist/assets/command-palette-qYrNUNjA.js +0 -1
- package/dist/assets/datasources-panel-2YJ76Lq8.js +0 -1
- package/dist/assets/dependency-graph-panel-CnzvmPdT.js +0 -4
- package/dist/assets/dist-BtRvVXgu.js +0 -1
- package/dist/assets/dist-CAZ5kHnb.js +0 -1
- package/dist/assets/dist-CN8IvtVY.js +0 -1
- package/dist/assets/dist-Cw007UHk.js +0 -1
- package/dist/assets/dist-DEfSR7VW.js +0 -1
- package/dist/assets/dist-DSbiMNpu.js +0 -1
- package/dist/assets/dist-DeIZvG9x.js +0 -1
- package/dist/assets/dist-DyZWkD0n.js +0 -1
- package/dist/assets/dist-hfODPqg9.js +0 -1
- package/dist/assets/edit-page-Bt_YqRld.js +0 -12
- package/dist/assets/error-panel-dvBEznKE.js +0 -1
- package/dist/assets/esm-hOS9Yf3s.js +0 -1
- package/dist/assets/field-Ota1KKvP.js +0 -1
- package/dist/assets/file-explorer-panel-Pa89UfV1.js +0 -1
- package/dist/assets/filename-BYm5Do9U.js +0 -1
- package/dist/assets/home-page-B3bIZC6F.js +0 -4
- package/dist/assets/index-BQd14tU4.css +0 -2
- package/dist/assets/input-Dm-m3XYB.js +0 -7
- package/dist/assets/links-CQoApRoA.js +0 -1
- package/dist/assets/logs-panel-R50NxjC7.js +0 -1
- package/dist/assets/mermaid.core-BjBlUxCx.js +0 -1
- package/dist/assets/numbers-DtHKLeOn.js +0 -1
- package/dist/assets/outline-panel-CB2kV_p5.js +0 -1
- package/dist/assets/packages-panel-BpFuUbAr.js +0 -1
- package/dist/assets/run-page-ClDuCh42.js +0 -1
- package/dist/assets/scratchpad-panel-BRljth0m.js +0 -1
- package/dist/assets/secrets-panel-CQON2dfx.js +0 -1
- package/dist/assets/snippets-panel-C0OdhmTA.js +0 -1
- package/dist/assets/state-DaDgAzck.js +0 -1
- package/dist/assets/state-Do6Fn2Io.js +0 -1
- package/dist/assets/stateDiagram-v2-UMBNRL4Z-Bi0DZGHg.js +0 -1
- package/dist/assets/stex-CbLDtSMU.js +0 -1
- package/dist/assets/storage-DFOl3UlZ.js +0 -1
- package/dist/assets/tracing-k1M6Upka.js +0 -2
- package/dist/assets/tracing-panel-CyG4yTCu.js +0 -2
- package/dist/assets/useHotkey-CJ5v8JMM.js +0 -1
- package/dist/assets/useNotebookActions-BB-5-4dL.js +0 -1
- package/dist/assets/useSplitCell-Cy53n7mS.js +0 -1
- package/dist/assets/utils-CfnN8i3Y.js +0 -1
- package/dist/assets/variable-panel-Dd_6lOoR.js +0 -1
- /package/dist/assets/{Deferred-BIEvCvJC.js → Deferred-Mppm0cvJ.js} +0 -0
- /package/dist/assets/{alert-B2-Y1fzf.js → alert-hjKHAeOD.js} +0 -0
- /package/dist/assets/{badge-D5b5ze0K.js → badge-DJuT6BaT.js} +0 -0
- /package/dist/assets/{blob-DFrnsWYL.js → blob-CTPcPiam.js} +0 -0
- /package/dist/assets/{connection-Cb7zku0y.js → connection-D2GvycR9.js} +0 -0
- /package/dist/assets/{copy-BiKQh0sU.js → copy-CkZsxeON.js} +0 -0
- /package/dist/assets/{createLucideIcon-Be9UM2Pe.js → createLucideIcon-QLW8E4z5.js} +0 -0
- /package/dist/assets/{createReducer-BaSP2BKE.js → createReducer-CFr1RdS2.js} +0 -0
- /package/dist/assets/{defaultLocale-DU4zdxes.js → defaultLocale-C6TNIE_k.js} +0 -0
- /package/dist/assets/{defaultLocale-BCtmQtCj.js → defaultLocale-DPsgYaXf.js} +0 -0
- /package/dist/assets/{dist-DIuPmJ5w.js → dist-Bz53xjA5.js} +0 -0
- /package/dist/assets/{dist-BhR4qmIv.js → dist-DcASoeRZ.js} +0 -0
- /package/dist/assets/{dist-BMAXVGJe.js → dist-Dlusp3mb.js} +0 -0
- /package/dist/assets/{documentation-BZROoSma.js → documentation-B7z6bB-t.js} +0 -0
- /package/dist/assets/{emotion-is-prop-valid.esm-plUNooLR.js → emotion-is-prop-valid.esm-BbphD4LX.js} +0 -0
- /package/dist/assets/{errors-qtuExmE-.js → errors-_3XAtRr3.js} +0 -0
- /package/dist/assets/{es-Hxx5X1vH.js → es-BVCqnQhJ.js} +0 -0
- /package/dist/assets/{extends--r5KbeWh.js → extends-Bwhapo2B.js} +0 -0
- /package/dist/assets/{fast-deep-equal-DT2Tke28.js → fast-deep-equal-BdzBWnNx.js} +0 -0
- /package/dist/assets/{icons-BUUt9FMo.js → icons-CLD-J5J3.js} +0 -0
- /package/dist/assets/{kbd-DItNvBdP.js → kbd-BQFiWIjd.js} +0 -0
- /package/dist/assets/{main-Co0CqoDt.js → main-CfqcqCNp.js} +0 -0
- /package/dist/assets/{marked.esm-BVjBUuHx.js → marked.esm-C_54K2ke.js} +0 -0
- /package/dist/assets/{namespace-BstGchRe.js → namespace-CnoeT75h.js} +0 -0
- /package/dist/assets/{objectWithoutPropertiesLoose-CGYpiDu4.js → objectWithoutPropertiesLoose-CDpgRi8_.js} +0 -0
- /package/dist/assets/{ordinal-DO1z0TEs.js → ordinal-CHS6rGcb.js} +0 -0
- /package/dist/assets/{preload-helper-CxnU7XTI.js → preload-helper-DImqtvgl.js} +0 -0
- /package/dist/assets/{prop-types-Bv8iPqhZ.js → prop-types-CHKlDUlJ.js} +0 -0
- /package/dist/assets/{range-CJAH1fu_.js → range-BPiwmiGf.js} +0 -0
- /package/dist/assets/{shim-Bk8nzKPV.js → shim-CWt9rDBn.js} +0 -0
- /package/dist/assets/{stex-CETff8Y9.js → stex-BrOrfhKB.js} +0 -0
- /package/dist/assets/{strings-1yw0WVap.js → strings-DYBy5ejj.js} +0 -0
- /package/dist/assets/{tslib.es6-DItc8Tbq.js → tslib.es6-dlz5WbC8.js} +0 -0
- /package/dist/assets/{use-toast-C07-frN_.js → use-toast-D6NNsC80.js} +0 -0
- /package/dist/assets/{useEvent-BIiDVnhT.js → useEvent-BOb1a9d1.js} +0 -0
- /package/dist/assets/{useLifecycle-Bnvt0QrQ.js → useLifecycle-BfeAlD80.js} +0 -0
- /package/dist/assets/{useNonce-Cw4ZAbgi.js → useNonce-BbWkd3B4.js} +0 -0
- /package/dist/assets/{useNumberFormatter-DYIEUCTe.js → useNumberFormatter-D21brJ0f.js} +0 -0
- /package/dist/assets/{uuid-BWz20PcF.js → uuid-4lb_EYpq.js} +0 -0
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./loro_wasm_bg-C1m39yOY.js","./loro_wasm_bg-CRzpkj3q.js","./chunk-DZLz74EQ.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
var
|
|
3
|
-
`).length-1}},Fs=class{constructor(e){p(this,"cache",new Map);p(this,"timeout");this.timeout=e}get(e){let t=this.cache.get(e);return t?Date.now()-t.timestamp>this.timeout?(this.cache.delete(e),null):t.result:null}set(e,t){this.cache.set(e,{result:t,timestamp:Date.now()})}},Ls=(e,t)=>$e.fromClass(class{constructor(){p(this,"abortController",null);p(this,"cache");this.cache=new Fs(t.cacheTimeout??1e3)}async update(r){var i,s,l,c,d;if(!r.docChanged||((s=(i=t.events)==null?void 0:i.beforeSuggestionFetch)==null?void 0:s.call(i,r.view))===!1)return;(l=this.abortController)==null||l.abort(),this.abortController=new AbortController;let n=r.state.doc,o=n.toString(),a=this.cache.get(o);if(a){r.view.dispatch({effects:nr.of({text:a,doc:n})});return}try{let f=await e(r.state,this.abortController.signal,r.view);if(this.abortController.signal.aborted||((d=(c=t.events)==null?void 0:c.shouldShowSuggestion)==null?void 0:d.call(c,r.view,f))===!1)return;this.cache.set(o,f),r.view.dispatch({effects:nr.of({text:f,doc:n})})}catch(f){f instanceof Error&&f.name!=="AbortError"&&console.error("Suggestion fetch error:",f)}}destroy(){var r;(r=this.abortController)==null||r.abort()}}),Os=$e.fromClass(class{constructor(){p(this,"decorations");this.decorations=_.none}update(e){var r;let t=(r=e.state.field(rr))==null?void 0:r.suggestion;if(!t){this.decorations=_.none;return}this.decorations=Ts(e.view,t)}},{decorations:e=>e.decorations});function Bs(e,t,r,n){return{...e.changeByRange(o=>{if(o===e.selection.main)return{changes:{from:r,to:n,insert:t},range:ft.cursor(r+t.length)};let a=n-r;return!o.empty||a&&e.sliceDoc(o.from-a,o.from)!==e.sliceDoc(r,n)?{range:o}:{changes:{from:o.from-a,to:o.from,insert:t},range:ft.cursor(o.from-a+t.length)}}),userEvent:"input.complete"}}var Ds=e=>{var n,o,a;let t=(n=e.state.field(rr))==null?void 0:n.suggestion;if(!t)return!1;let r=e.state.facet(Qr);return e.dispatch({...Bs(e.state,t,e.state.selection.main.head,e.state.selection.main.head)}),(a=(o=r.events)==null?void 0:o.onSuggestionAccepted)==null||a.call(o,e,t),!0},uo=e=>{var n,o,a;let t=(n=e.state.field(rr))==null?void 0:n.suggestion;if(!t)return!1;let r=e.state.facet(Qr);return e.dispatch({effects:nr.of({text:null,doc:e.state.doc})}),(a=(o=r.events)==null?void 0:o.onSuggestionRejected)==null||a.call(o,e,t),!0},Us=We.of([{key:"Tab",run:Ds},{key:"Escape",run:uo}]),Qr=dt.define({combine:e=>e.at(-1)});function fo(e){let{delay:t=500,includeKeymap:r=!0}=e,n=Ss(e.fetchFn,t);return[rr,Qr.of(e),Ls(n,e),Os,r?Us:[]]}const _s=O.baseTheme({".cm-ai-input-container":{display:"flex",flexDirection:"column",gap:"4px",width:"min(calc(100% + 7px), 500px)",padding:"5px 5px",margin:"0 -6px",backgroundColor:"light-dark(rgb(241, 243, 245), rgb(40, 40, 40))"},".cm-ai-input":{display:"block",width:"100%",padding:"3px 8px",border:"2px solid rgb(51, 154, 240)",borderRadius:"5px",fontSize:"12px"},".cm-ai-help-info-button":{fontSize:"10px",paddingLeft:"10px",height:"18px",color:"light-dark(rgb(109, 117, 125), rgb(170, 170, 170))",display:"block",marginRight:"auto"},".cm-ai-help-info-button:hover":{color:"light-dark(rgb(89, 97, 105), rgb(190, 190, 190))"},".cm-ai-generate-button":{background:"#0E639C",border:"none",padding:"2px 6px",color:"#ffffff",cursor:"pointer",font:"inherit",borderRadius:"4px","&:hover":{backgroundColor:"#1177bb"}},".cm-line.cm-ai-selection, .cm-line.cm-ai-selection.cm-active-line":{backgroundColor:"light-dark(color-mix(in srgb, rgb(223, 227, 232) 50%, transparent), color-mix(in srgb, rgb(50, 50, 50) 50%, transparent)) !important"},".cm-line:has(.cm-new-code-line)":{backgroundColor:"light-dark(color-mix(in srgb, rgb(183, 235, 143) 50%, transparent), color-mix(in srgb, rgb(40, 100, 40) 50%, transparent)) !important"},".cm-old-code-container":{backgroundColor:"light-dark(rgb(255, 205, 205), rgb(100, 40, 40))",position:"relative",display:"flex",paddingTop:"0",width:"100%",alignItems:"center"},".cm-code-button":{position:"absolute",right:"5px",top:"50%",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",fontSize:"16px"},".cm-floating-buttons":{fontFamily:"sans-serif",position:"absolute",top:"-20px",left:"5px",display:"flex"},".cm-floating-button":{fontFamily:"sans-serif",padding:"2px 5px",fontSize:"10px",cursor:"pointer",fontWeight:"700"},".cm-floating-accept":{backgroundColor:"light-dark(rgb(55, 125, 34), rgb(40, 80, 25))",borderTopLeftRadius:"5px",borderBottomLeftRadius:"5px",color:"white",filter:"brightness(90%)","&:hover":{filter:"brightness(100%)"}},".cm-floating-reject":{backgroundColor:"light-dark(rgb(220, 53, 69), rgb(180, 40, 50))",color:"white",borderTopRightRadius:"5px",borderBottomRightRadius:"5px",filter:"brightness(90%)","&:hover":{filter:"brightness(100%)"}},".hotkey":{display:"inline-block",padding:"0 4px",borderRadius:"3px",backgroundColor:"rgba(255, 255, 255, 0.1)",fontSize:"90%"},".cm-ai-loading-indicator":{fontStyle:"italic",fontSize:"10px",paddingLeft:"12px",color:"light-dark(rgb(109, 117, 125), rgb(170, 170, 170))",opacity:"0",transition:"opacity 0.3s ease-in-out","&::after":{content:'""',display:"inline-block",animation:"ellipsis-pulse 1.5s steps(4, end) infinite"},"&:not(:empty)":{opacity:"1"}},".cm-ai-input:disabled":{opacity:"0.5"},"@keyframes ellipsis-pulse":{"0%":{content:"'.'"},"25%":{content:"'..'"},"50%":{content:"'...'"},"75%":{content:"''"}},".cm-ai-loading-container":{display:"flex",alignItems:"center",padding:"0 8px"},".cm-ai-cancel-button":{padding:"2px 8px",fontSize:"10px",borderRadius:"4px",color:"light-dark(rgb(109, 117, 125), rgb(170, 170, 170))",cursor:"pointer","&:hover":{background:"light-dark(rgb(223, 227, 232), rgb(50, 50, 50))"}},".hidden":{display:"none"}});function Ms(e){var o,a;let t=e.state.facet(It),r={...z,...t.keymaps},n=fe("div","cm-ai-tooltip").appendChild(fe("div","cm-ai-tooltip-button"));return n.innerHTML=`<span>Edit <span class="hotkey">${Xr(r.showInput)}</span></span>`,(o=n.querySelector("span"))==null||o.addEventListener("mousedown",i=>{i.stopPropagation(),i.button===0&&i.preventDefault()}),(a=n.querySelector("span"))==null||a.addEventListener("click",i=>{i.preventDefault(),so(e)}),n}const Zr=dt.define({combine(e){return Vr(e,{render:Ms,hideOnBlur:!1})}}),Ps=$e.fromClass((ki=class{constructor(e){p(this,"view");p(this,"suppress");p(this,"dom");p(this,"mousedown",()=>{this.suppress=!0});p(this,"mouseup",()=>{this.suppress=!1,this.display(this.view)});p(this,"scroll",()=>{this.display(this.view)});p(this,"windowScroll",()=>{this.display(this.view)});Ni(this,_r,e=>{var r;let t=e.state.selection.ranges.find(n=>!n.empty);if(t&&!this.suppress){let n=e.coordsAtPos(t.from);if(!n)return;let o=e.dom.getBoundingClientRect(),a=(r=e.dom.parentElement)==null?void 0:r.getBoundingClientRect(),i=n.top>=o.top&&n.top<=o.bottom&&n.left>=o.left&&n.left<=o.right,s=!a||n.top>=a.top&&n.top<=a.bottom&&n.left>=a.left&&n.left<=a.right;if(!i||!s){this.dom.style.display="none",this.dom.setAttribute("aria-hidden","true");return}this.dom.style.display="flex",this.dom.setAttribute("aria-hidden","false");let l=this.dom.getBoundingClientRect(),c=o.width-l.width,d=Math.min(n.left,c),f=n.top-l.height;f=a?Math.max(a.y,f):f,this.dom.style.left=`${d}px`,this.dom.style.top=`${f}px`,requestAnimationFrame(()=>{this.dom&&this.dom.setAttribute("aria-hidden","false")})}else this.dom.style.display="none",this.dom.setAttribute("aria-hidden","true")});this.view=e;let t=e.state.facet(Zr);this.suppress=!1,document.addEventListener("mousedown",this.mousedown),document.addEventListener("mouseup",this.mouseup),e.scrollDOM.addEventListener("scroll",this.scroll),window.addEventListener("scroll",this.windowScroll,!0);let r=t.render(e);e.dom.appendChild(r),this.dom=r}update(e){this.display(e.view)}docViewUpdate(e){this.display(e)}display(e){if(e.state.field(at).show){this.dom.style.display="none";return}if(e.state.facet(Zr).hideOnBlur&&!e.hasFocus){this.dom.style.display="none",this.dom.setAttribute("aria-hidden","true");return}e.requestMeasure({read:Ci(this,_r)})}destroy(){document.removeEventListener("mousedown",this.mousedown),document.removeEventListener("mouseup",this.mouseup),this.view.scrollDOM.removeEventListener("scroll",this.scroll),window.removeEventListener("scroll",this.windowScroll,!0),this.dom.remove()}},_r=new WeakMap,ki));var js=O.baseTheme({".cm-ai-tooltip-button":{userSelect:"none",fontFamily:"system-ui, -apple-system, sans-serif",position:"fixed",display:"flex",boxSizing:"border-box",padding:"2px 6px",borderRadius:"4px",fontSize:"12px",backgroundColor:"#0E639C",color:"#ffffff",border:"1px solid transparent",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",zIndex:"999",transition:"opacity 0.5s","&[aria-hidden='true']":{opacity:"0"},"&[aria-hidden='false']":{opacity:"1"},"& > span":{pointerEvents:"auto",cursor:"pointer",display:"inline-block",padding:"2px"},"&:hover":{backgroundColor:"#1177bb"}}});function Rs(){return[Ps,js]}var Gs=class extends Nt{constructor(t){super();p(this,"oldCode");this.oldCode=t}toDOM(t){let r=fe("div","cm-old-code-container");r.setAttribute("role","region"),r.setAttribute("aria-label","Previous code version");let n=fe("div","cm-old-code cm-line");n.textContent=this.oldCode;let o=fe("div","cm-floating-buttons"),a=t.state.facet(It),i={...z,...a.keymaps},s=fe("button","cm-floating-button cm-floating-accept");s.innerHTML=`<span class="hotkey">${Xr(i.acceptEdit)}</span> Accept`,s.setAttribute("aria-label","Accept changes"),s.addEventListener("click",c=>{c.preventDefault(),c.stopPropagation(),t.focus(),lo(t)});let l=fe("button","cm-floating-button cm-floating-reject");return l.innerHTML=`<span class="hotkey">${Xr(i.rejectEdit)}</span> Reject`,l.setAttribute("aria-label","Reject changes"),l.addEventListener("click",c=>{c.preventDefault(),c.stopPropagation(),t.focus(),co(t)}),o.append(s,l),r.append(n,o),r}updateDOM(t,r){return!0}},Js=class extends Nt{constructor(t){super();p(this,"complete");p(this,"abortController",null);p(this,"dom",null);p(this,"input",null);p(this,"loadingContainer",null);p(this,"helpInfo",null);p(this,"inputContainer",null);p(this,"form",null);p(this,"view",null);p(this,"onKeyDown",async t=>{t.key==="Enter"&&!t.shiftKey?(t.preventDefault(),await this.handleSubmit()):t.key==="Escape"&&this.onCancel()});p(this,"onCancel",()=>{this.cleanup();let t=this.view;t&&(t.dispatch({effects:[ot.of({show:!1,lineFrom:0,lineTo:0}),gt.of(!1)]}),t.focus())});p(this,"handleSubmit",async t=>{var g;let r=this.view;if(!r)return;let n=r.state.facet(It);t==null||t.stopPropagation();let o=r.state.field(at),{input:a}=this;if(!a)return;let i=a.value.trim();if(!o.show||!i)return;let s=r.state.doc.line(o.lineFrom),l=r.state.doc.line(o.lineTo),c=s.from,d=l.to,f=r.state.sliceDoc(c,d),h=r.state.sliceDoc(0,c),m=r.state.sliceDoc(d);this.abortController=new AbortController,r.dispatch({effects:gt.of(!0)}),this.toggleLoading(!0);try{let b=await this.complete({prompt:i,selection:f,codeBefore:h,codeAfter:m,editorView:r,signal:this.abortController.signal});if(!r.state.field(at).show)return;if(!b||typeof b!="string")throw Error("Invalid completion result");r.dispatch({changes:{from:c,to:d,insert:b},effects:[ot.of({show:!1,lineFrom:0,lineTo:0}),tr.of({from:c,to:c+b.length,oldCode:f,newCode:b}),gt.of(!1)]})}catch(b){if(b instanceof DOMException&&b.name==="AbortError")return;(g=n.onError)==null||g.call(n,b)}finally{this.cleanup(),this.toggleLoading(!1),r.focus()}});this.complete=t}toDOM(t){if(this.dom)return this.dom;this.view=t;let r=t.state.field(ao),n=t.state.field(io),o=fe("div","cm-ai-input-container");this.inputContainer=o,this.dom=o;let a=fe("form","cm-ai-input-form");this.form=a,a.setAttribute("role","search"),a.setAttribute("aria-label","AI editing instructions"),a.addEventListener("submit",y=>y.preventDefault());let i=fe("input","cm-ai-input");this.input=i,a.append(i),i.placeholder="Editing instructions...",i.setAttribute("aria-label","AI editing instructions"),i.setAttribute("autocomplete","off"),i.setAttribute("spellcheck","true"),i.value=r.inputValue;let s=fe("div","cm-ai-loading-container");this.loadingContainer=s;let l=fe("div","cm-ai-loading-indicator");l.setAttribute("role","status"),l.setAttribute("aria-live","polite"),l.textContent="Generating";let c=fe("button","cm-ai-cancel-button");c.textContent="Cancel",c.setAttribute("aria-label","Cancel code generation"),c.addEventListener("click",this.onCancel),s.append(c,l);let d=fe("div","cm-ai-help-info");this.helpInfo=d;let f=d.appendChild(document.createElement("button"));f.className="cm-ai-help-info-button",f.textContent="Esc to close",f.addEventListener("click",this.onCancel);let h=fe("button","cm-ai-generate-button");h.textContent="\u23CE Generate",h.setAttribute("aria-label","Generate code"),h.addEventListener("click",this.handleSubmit),this.toggleLoading(n),r.shouldFocus&&requestAnimationFrame(()=>{i.value=r.inputValue,i.focus(),t.dispatch({effects:Lt.of(!1)})}),m(i.value),i.addEventListener("input",b),i.addEventListener("keydown",this.onKeyDown);function m(y){d.replaceChildren(y?h:f)}let g="";function b(){t.dispatch({effects:Ft.of(i.value)});let y=i.value.trim();y!==g&&(g=y,m(y))}return o}toggleLoading(t){var r;this.inputContainer&&this.form&&this.loadingContainer&&this.helpInfo&&((r=this.inputContainer)==null||r.replaceChildren(this.form,t?this.loadingContainer:this.helpInfo))}updateDOM(t,r){return this.dom=t,this.input=t.querySelector(".cm-ai-input"),!0}cleanup(){var t,r,n;(t=this.abortController)==null||t.abort(),this.abortController=null,(r=this.dom)==null||r.remove(),(n=this.input)==null||n.remove(),this.dom=null,this.input=null}destroy(){this.cleanup()}};function Vs(e){if(!e.prompt)throw Error("prompt function is required");let t={...z,...e.keymaps};return[It.of(e),at,ao,Ot,io,Rs(),_s,We.of([{key:t.showInput,run:so}]),et.highest([We.of([{key:t.acceptEdit,run:lo},{key:t.rejectEdit,run:co}])]),Ws,$s,Hs,qs]}const Ws=O.updateListener.of(e=>{let t=e.state.field(at);if(!t.show||!e.docChanged)return;let{lineFrom:r,lineTo:n}=t,o=!1;e.changes.iterChanges((a,i,s,l)=>{let c=e.state.doc.lineAt(a).number;if(c<r){let d=e.state.doc.lineAt(l).number-e.state.doc.lineAt(s).number;r+=d,n+=d,o=!0}else if(c<=n){let d=e.state.doc.lineAt(l).number-e.state.doc.lineAt(s).number;n+=d,o=!0}}),o&&e.view.dispatch({effects:[ot.of({show:!0,lineFrom:r,lineTo:n})]})}),$s=O.decorations.of(e=>{let t=e.state.field(Ot);return t?_.set([_.mark({class:"cm-new-code-line"}).range(t.from,t.to)]):_.none}),Hs=O.decorations.compute([at],e=>{let t=e.field(at),r=e.facet(It),n=[];if(t.show){let o=t.lineFrom,a=t.lineTo;for(let i=o;i<=a;i++){let s=e.doc.line(i).from;n.push(_.line({class:"cm-ai-selection"}).range(s)),i===o&&n.push(_.widget({widget:new Js(r.prompt),side:-1}).range(s))}}return _.set(n)}),qs=ve.define({create(e){return _.none},update(e,t){let r=t.state.field(Ot);return r?_.set([_.widget({widget:new Gs(r.oldCode),block:!0}).range(r.from)]):_.none},provide:e=>O.decorations.from(e)});var zs=ge(Ve()),L=ge(pf()),en=()=>({entries:new Map}),{valueAtom:mo,useActions:ho}=Xn(en,{submit:(e,t)=>{let{cellIds:r,deleteCell:n,deleteManyCells:o,store:a}=t,i=a.get(nt),s=a.get(kf),l=new Set(i.cellIds.inOrderIds.filter(f=>i.cellData[f].code.trim()==="")),c=new Map;for(let f of r){if(l.has(f)){c.set(f,{cellId:f,type:"simple"});continue}let h=i.cellRuntime[f],m=new Map;for(let b of Object.values(s)){let y=b.declaredBy.includes(f),E=b.usedBy.some(C=>!l.has(C));y&&E&&m.set(b.name,b.usedBy)}let g;h!=null&&h.runElapsedTimeMs&&h.runElapsedTimeMs>2e3&&(g=h.runElapsedTimeMs),m.size===0&&g===void 0?c.set(f,{cellId:f,type:"simple"}):c.set(f,{cellId:f,type:"expensive",executionDurationMs:g,defs:m})}let d=[...c.values()].every(f=>f.type==="simple");return c.size>0&&d?(c.size===1?n({cellId:[...c.values()][0].cellId}):o({cellIds:[...c.values()].map(f=>f.cellId)}),en()):{...e,entries:c}},clear:()=>en()});Kr=function(){let e=Pn(),{submit:t,clear:r}=ho(),{entries:n}=le(mo),o=Zi(),a=Qn();return(0,L.useMemo)(()=>({submit:i=>{t({cellIds:i,deleteCell:o,deleteManyCells:a,store:e})},clear:r,get idle(){return n.size===0},get shouldConfirmDelete(){return n.size>1}}),[e,t,r,n,o,a])},gs=function(e){let t=(0,zs.c)(16),r=le(mo),n=ho(),o=Qn(),a;t[0]!==e||t[1]!==r.entries?(a=r.entries.get(e),t[0]=e,t[1]=r.entries,t[2]=a):a=t[2];let i=a;if(!i){let d;return t[3]===Symbol.for("react.memo_cache_sentinel")?(d={isPending:!1},t[3]=d):d=t[3],d}if(r.entries.size!==1){let d;return t[4]===i?d=t[5]:(d={isPending:!0,shouldConfirmDelete:!1,...i},t[4]=i,t[5]=d),d}let s;t[6]!==n||t[7]!==o||t[8]!==r.entries?(s=()=>{o({cellIds:[...r.entries.values()].map(Ks)}),n.clear()},t[6]=n,t[7]=o,t[8]=r.entries,t[9]=s):s=t[9];let l;t[10]===n?l=t[11]:(l=()=>n.clear(),t[10]=n,t[11]=l);let c;return t[12]!==i||t[13]!==s||t[14]!==l?(c={isPending:!0,...i,shouldConfirmDelete:!0,confirm:s,cancel:l},t[12]=i,t[13]=s,t[14]=l,t[15]=c):c=t[15],c};function Ks(e){return e.cellId}async function Ys(e){var s,l;let t=`
|
|
2
|
+
var ff=Object.defineProperty;var Ai=re=>{throw TypeError(re)};var mf=(re,z,we)=>z in re?ff(re,z,{enumerable:!0,configurable:!0,writable:!0,value:we}):re[z]=we;var p=(re,z,we)=>mf(re,typeof z!="symbol"?z+"":z,we),hf=(re,z,we)=>z.has(re)||Ai("Cannot "+we);var Ci=(re,z,we)=>(hf(re,z,"read from private field"),we?we.call(re):z.get(re)),Ni=(re,z,we)=>z.has(re)?Ai("Cannot add the same private member more than once"):z instanceof WeakSet?z.add(re):z.set(re,we);import{s as pe}from"./chunk-DZLz74EQ.js";import{a as Pn,i as xi,n as Pr,o as Wt,r as le}from"./react-7g8sREeT.js";import{t as gf}from"./react-BcIddLXZ.js";import{$n as pf,B as bf,Bn as yf,Cn as wf,Cr as vf,E as jr,En as Rr,F as Ef,H as Si,J as jn,Jn as kf,Ln as Af,Mr as Ti,Ot as Cf,Pn as Nf,Sn as Qe,Un as Rn,V as Ii,Vn as xf,Xn as Sf,Y as Tf,Yn as If,_n as Fi,at as Ff,bn as Lf,cn as Gn,d as Li,dn as Of,f as Oi,gn as Bi,h as Jn,hn as Vn,ht as Di,it as Gr,kn as Bf,lr as Df,mt as Uf,nn as _f,nt as Mf,ot as Pf,rn as jf,rt as Wn,s as Ui,sr as $n,st as $t,tn as Rf,tr as Gf,ur as Jf,x as ot,xr as _i,yn as Vf,zn as Wf,__tla as $f}from"./cells-Dd1FatlG.js";import{A as Hf,F as Mi,w as qf,z as zf}from"./zod-BEi78Y5d.js";import{n as We,t as Kf}from"./jsx-runtime-DvsdsEjx.js";import{o as Jr,r as Y,t as Ht}from"./invariant-91cSKJcr.js";import{l as Yf,n as Xf,o as Qf,r as Zf,t as em}from"./client-RNr6mM1Y.js";import{n as tm,t as Ze}from"./Logger-BkkOJyg0.js";import{n as Pi,s as Hn}from"./hotkeys-CBY41Jr2.js";import{f as ji,i as rm,m as Ri,o as nm,p as om,s as Gi,x as qn}from"./utils-DBmmAf_K.js";import{a as am,g as im,o as sm,r as Ji}from"./config-DXGmIv9f.js";import{i as lm,t as Vi}from"./useHotkey-DkiyGPLs.js";import{n as cm}from"./globals-BFoVgbHf.js";import{t as um}from"./ErrorBoundary-CeiDOU5x.js";import{t as qt}from"./cn-Dr9kMPPj.js";import{t as dm}from"./useEventListener-g9rPKvBX.js";import{t as zn}from"./events-BGfCi1Xy.js";import{t as et}from"./button-Bxk0BtBn.js";import{$ as fm,Bt as Nt,E as mm,Et as hm,Ft as zt,Gt as Kt,Ht as te,It as ft,Jt as Vr,M as gm,Nt as Kn,Ot as pm,P as bm,Pt as mt,Q as _,R as Wi,Rt as tt,St as ym,U as u,Ut as Ee,_ as wm,_t as $e,a as vm,ct as Em,et as L,ft as km,ht as Am,it as xt,jt as Yt,kt as Wr,m as Cm,mt as Nm,nt as xm,pt as Sm,rt as He,st as Tm,tt as Im,vt as $i,w as Fm,yt as Lm,z as Om,zt as Bm}from"./dist-CoL9j4yJ.js";import{C as Dm,_ as Um,c as _m,n as Mm,s as Yn,u as Pm,v as jm,x as Rm,y as Gm}from"./dist-Cs8TISgf.js";import{S as Jm,__tla as Vm}from"./columns-qXe5bccO.js";import{c as Hi,n as Wm}from"./once-8ZDiGGtA.js";import{t as Xn}from"./createReducer-CFr1RdS2.js";import{a as Xt,r as $m}from"./key-D4QiH_7H.js";import{t as Hm}from"./preload-helper-DImqtvgl.js";import{a as qm,c as zm,f as $r,h as Km,i as Ym,l as Qt,n as qi,o as Xm,t as Qm}from"./dist-Bz53xjA5.js";import{t as St}from"./use-toast-D6NNsC80.js";import{a as zi,s as rt,t as ht}from"./connection-D2GvycR9.js";import{r as Zm}from"./useTheme-oPMxEKRc.js";import{t as eh}from"./createLucideIcon-QLW8E4z5.js";import{f as th,r as Ki,t as rh,__tla as nh}from"./layout-C6K0XXFK.js";import{C as oh,T as ah,_ as ih,a as sh,c as lh,g as ch,n as uh,r as dh}from"./add-cell-with-ai-CxM_YKzf.js";import{t as fh}from"./ai-model-dropdown-DSUVFIso.js";import{h as mh}from"./select-DKRTzlUU.js";import{t as hh}from"./download-B4_BX7gi.js";import{r as gh,t as ph}from"./types-DyTIgBnH.js";import{n as bh}from"./spinner-BhnfQOEl.js";import{t as yh}from"./readonly-python-code-Cb7Ak_Dy.js";import{t as Yi}from"./save-CVcbYdvl.js";import{Et as wh,I as vh,R as Xi}from"./input-C1RzjWSK.js";import{i as Eh,n as Qn,t as Qi}from"./useDeleteCell-CJaipocw.js";import{t as Zt}from"./tooltip-ULHbIsj9.js";import{r as kh,t as Ah}from"./mode-DQPKc-Hp.js";import{c as Zi,i as es,n as ts,r as Ch}from"./dialog-CR68_CUl.js";import{n as de}from"./useEvent-BOb1a9d1.js";import{n as rs}from"./ImperativeModal-BG5LTpV0.js";import{n as Nh}from"./errors-_3XAtRr3.js";import{t as X}from"./extends-Bwhapo2B.js";import{t as er}from"./objectWithoutPropertiesLoose-CDpgRi8_.js";import{n as xh}from"./useAsyncData-D9GA9BWg.js";import{t as Sh}from"./kbd-BQFiWIjd.js";import{a as ns}from"./renderShortcut-C9_NT6sD.js";import{t as os}from"./label-BEUjZsdo.js";import{a as Th,r as Ih,t as Fh}from"./popover-DW0D4l0O.js";import{n as Tt}from"./esm-7XxuulnL.js";import{n as Lh}from"./add-missing-import-CfRgNApn.js";import{n as Oh,t as Bh}from"./icons-CLD-J5J3.js";import{a as Dh,o as as,r as Uh,s as is,t as _h}from"./command-BZVf1cJP.js";import{i as Mh,n as ss}from"./state-jvUYiWCG.js";import{n as Ph,t as jh}from"./filename-B5Yo1bOu.js";import{a as Rh}from"./focus-Bnk25hTp.js";import{i as Gh,t as Jh}from"./useSplitCell-Dodncnp8.js";import{t as ls}from"./Inputs-kgumHs7_.js";import{t as Vh}from"./constants-BblE208_.js";import{$a as cs,Qa as us,Za as Wh,ct as $h,eo as ds,no as fs,ro as Hh,to as Zn,w as ms,__tla as qh}from"./loro_wasm_bg-CRzpkj3q.js";import{t as zh}from"./ws-D5K2BGtY.js";import{t as eo}from"./useInterval-C1jCNqdM.js";let hs,to,gs,gt,ps,Hr,ro,tr,qr,ke,bs,ys,ws,vs,zr,Es,no,Kr,Kh=Promise.all([(()=>{try{return $f}catch{}})(),(()=>{try{return Vm}catch{}})(),(()=>{try{return nh}catch{}})(),(()=>{try{return qh}catch{}})()]).then(async()=>{var Mr,ki,Ce,Ne,xe,Se,Te,Ie,Fe,Le,Oe,Be,De,Ue,_e,Me,Pe,je,Re,Ge,Je;var re=eh("file-pen",[["path",{d:"M12.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v9.5",key:"1couwa"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M13.378 15.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1y4qbx"}]]);const z={showInput:"Mod-l",acceptEdit:"Mod-y",rejectEdit:"Mod-u"};var we=300;const Ft=ft.define({combine:e=>Vr(e,{onError:console.error,inputDebounceTime:we,keymaps:z},{onError:(t,r)=>t&&r,inputDebounceTime:(t,r)=>t&&r,keymaps:(t,r)=>t&&r})}),at=te.define(),it=Ee.define({create(){return{show:!1,lineFrom:0,lineTo:0}},update(e,t){for(let r of t.effects)if(r.is(at))return r.value;return e}}),Lt=te.define(),Ot=te.define(),ao=Ee.define({create(){return{shouldFocus:!1,inputValue:""}},update(e,t){let r=e;for(let n of t.effects)n.is(Lt)&&(r={...r,inputValue:n.value}),n.is(Ot)&&(r={...r,shouldFocus:n.value});return r}}),rr=te.define(),Bt=Ee.define({create(){return null},update(e,t){for(let r of t.effects)if(r.is(rr))return r.value;return e}}),pt=te.define(),io=Ee.define({create(){return!1},update(e,t){for(let r of t.effects)if(r.is(pt))return r.value;return e}});var Cs=1;const so=e=>{let{state:t}=e,r=t.selection.main;if(r.empty)return!1;let n=t.doc,o=n.lineAt(r.from),a=n.lineAt(r.to);if(t.sliceDoc(o.from,a.to).trim().length<Cs)return!1;let i=Math.max(1,Math.min(o.number,n.lines)),s=Math.max(1,Math.min(a.number,n.lines));return e.dispatch({effects:[at.of({show:!0,lineFrom:i,lineTo:s}),Ot.of(!0),Lt.of("")],selection:mt.cursor(o.from)}),!0},lo=e=>e.state.field(Bt)?(e.dispatch({effects:[rr.of(null),at.of({show:!1,lineFrom:0,lineTo:0}),Ot.of(!1),Lt.of(""),pt.of(!1)]}),!0):!1,co=e=>{let t=e.state.field(Bt);return t?(e.dispatch({changes:{from:t.from,to:t.to,insert:t.oldCode},effects:[rr.of(null),at.of({show:!1,lineFrom:0,lineTo:0}),Ot.of(!1),Lt.of(""),pt.of(!1)]}),!0):!1};var Yr={mac:"\u2318",windows:"\u229E Win",default:"Ctrl"};function Ns(){return navigator.platform.startsWith("Mac")?Yr.mac:navigator.platform.startsWith("Win")?Yr.windows:Yr.default}function Xr(e){return e.replace("Mod",Ns()).replace("-"," ").toUpperCase()}function fe(e,t){let r=document.createElement(e);return r.className=t,r}function xs(e,t,r=void 0){let n=()=>{};return(...o)=>(n(),new Promise((a,i)=>{let s=setTimeout(()=>a(e(...o)),t);n=()=>{clearTimeout(s),r!==void 0&&i(r)}}))}var nr=Ee.define({create(){return{suggestion:null}},update(e,t){let r=t.effects.find(n=>n.is(or));return!t.docChanged&&!r&&!t.selection?e:r&&t.state.doc===r.value.doc?{suggestion:r.value.text}:{suggestion:null}}}),or=te.define();function Ss(e,t){let r=e.state.selection.main.head,n=[],o=_.widget({widget:new Ts(t),side:1});return n.push(o.range(r)),_.set(n)}var Ts=class extends xt{constructor(t){super();p(this,"suggestion");this.suggestion=t}toDOM(){let t=document.createElement("span");return t.style.opacity="0.4",t.className="cm-inline-suggestion",t.textContent=this.suggestion,t.setAttribute("role","suggestion"),t.setAttribute("aria-label",`Suggestion: ${this.suggestion}`),t}get lineBreaks(){return this.suggestion.split(`
|
|
3
|
+
`).length-1}},Is=class{constructor(e){p(this,"cache",new Map);p(this,"timeout");this.timeout=e}get(e){let t=this.cache.get(e);return t?Date.now()-t.timestamp>this.timeout?(this.cache.delete(e),null):t.result:null}set(e,t){this.cache.set(e,{result:t,timestamp:Date.now()})}},Fs=(e,t)=>He.fromClass(class{constructor(){p(this,"abortController",null);p(this,"cache");this.cache=new Is(t.cacheTimeout??1e3)}async update(r){var i,s,l,c,d;if(!r.docChanged||((s=(i=t.events)==null?void 0:i.beforeSuggestionFetch)==null?void 0:s.call(i,r.view))===!1)return;(l=this.abortController)==null||l.abort(),this.abortController=new AbortController;let n=r.state.doc,o=n.toString(),a=this.cache.get(o);if(a){r.view.dispatch({effects:or.of({text:a,doc:n})});return}try{let f=await e(r.state,this.abortController.signal,r.view);if(this.abortController.signal.aborted||((d=(c=t.events)==null?void 0:c.shouldShowSuggestion)==null?void 0:d.call(c,r.view,f))===!1)return;this.cache.set(o,f),r.view.dispatch({effects:or.of({text:f,doc:n})})}catch(f){f instanceof Error&&f.name!=="AbortError"&&console.error("Suggestion fetch error:",f)}}destroy(){var r;(r=this.abortController)==null||r.abort()}}),Ls=He.fromClass(class{constructor(){p(this,"decorations");this.decorations=_.none}update(e){var r;let t=(r=e.state.field(nr))==null?void 0:r.suggestion;if(!t){this.decorations=_.none;return}this.decorations=Ss(e.view,t)}},{decorations:e=>e.decorations});function Os(e,t,r,n){return{...e.changeByRange(o=>{if(o===e.selection.main)return{changes:{from:r,to:n,insert:t},range:mt.cursor(r+t.length)};let a=n-r;return!o.empty||a&&e.sliceDoc(o.from-a,o.from)!==e.sliceDoc(r,n)?{range:o}:{changes:{from:o.from-a,to:o.from,insert:t},range:mt.cursor(o.from-a+t.length)}}),userEvent:"input.complete"}}var Bs=e=>{var n,o,a;let t=(n=e.state.field(nr))==null?void 0:n.suggestion;if(!t)return!1;let r=e.state.facet(Qr);return e.dispatch({...Os(e.state,t,e.state.selection.main.head,e.state.selection.main.head)}),(a=(o=r.events)==null?void 0:o.onSuggestionAccepted)==null||a.call(o,e,t),!0},uo=e=>{var n,o,a;let t=(n=e.state.field(nr))==null?void 0:n.suggestion;if(!t)return!1;let r=e.state.facet(Qr);return e.dispatch({effects:or.of({text:null,doc:e.state.doc})}),(a=(o=r.events)==null?void 0:o.onSuggestionRejected)==null||a.call(o,e,t),!0},Ds=$e.of([{key:"Tab",run:Bs},{key:"Escape",run:uo}]),Qr=ft.define({combine:e=>e.at(-1)});function fo(e){let{delay:t=500,includeKeymap:r=!0}=e,n=xs(e.fetchFn,t);return[nr,Qr.of(e),Fs(n,e),Ls,r?Ds:[]]}const Us=L.baseTheme({".cm-ai-input-container":{display:"flex",flexDirection:"column",gap:"4px",width:"min(calc(100% + 7px), 500px)",padding:"5px 5px",margin:"0 -6px",backgroundColor:"light-dark(rgb(241, 243, 245), rgb(40, 40, 40))"},".cm-ai-input":{display:"block",width:"100%",padding:"3px 8px",border:"2px solid rgb(51, 154, 240)",borderRadius:"5px",fontSize:"12px"},".cm-ai-help-info-button":{fontSize:"10px",paddingLeft:"10px",height:"18px",color:"light-dark(rgb(109, 117, 125), rgb(170, 170, 170))",display:"block",marginRight:"auto"},".cm-ai-help-info-button:hover":{color:"light-dark(rgb(89, 97, 105), rgb(190, 190, 190))"},".cm-ai-generate-button":{background:"#0E639C",border:"none",padding:"2px 6px",color:"#ffffff",cursor:"pointer",font:"inherit",borderRadius:"4px","&:hover":{backgroundColor:"#1177bb"}},".cm-line.cm-ai-selection, .cm-line.cm-ai-selection.cm-active-line":{backgroundColor:"light-dark(color-mix(in srgb, rgb(223, 227, 232) 50%, transparent), color-mix(in srgb, rgb(50, 50, 50) 50%, transparent)) !important"},".cm-line:has(.cm-new-code-line)":{backgroundColor:"light-dark(color-mix(in srgb, rgb(183, 235, 143) 50%, transparent), color-mix(in srgb, rgb(40, 100, 40) 50%, transparent)) !important"},".cm-old-code-container":{backgroundColor:"light-dark(rgb(255, 205, 205), rgb(100, 40, 40))",position:"relative",display:"flex",paddingTop:"0",width:"100%",alignItems:"center"},".cm-code-button":{position:"absolute",right:"5px",top:"50%",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",fontSize:"16px"},".cm-floating-buttons":{fontFamily:"sans-serif",position:"absolute",top:"-20px",left:"5px",display:"flex"},".cm-floating-button":{fontFamily:"sans-serif",padding:"2px 5px",fontSize:"10px",cursor:"pointer",fontWeight:"700"},".cm-floating-accept":{backgroundColor:"light-dark(rgb(55, 125, 34), rgb(40, 80, 25))",borderTopLeftRadius:"5px",borderBottomLeftRadius:"5px",color:"white",filter:"brightness(90%)","&:hover":{filter:"brightness(100%)"}},".cm-floating-reject":{backgroundColor:"light-dark(rgb(220, 53, 69), rgb(180, 40, 50))",color:"white",borderTopRightRadius:"5px",borderBottomRightRadius:"5px",filter:"brightness(90%)","&:hover":{filter:"brightness(100%)"}},".hotkey":{display:"inline-block",padding:"0 4px",borderRadius:"3px",backgroundColor:"rgba(255, 255, 255, 0.1)",fontSize:"90%"},".cm-ai-loading-indicator":{fontStyle:"italic",fontSize:"10px",paddingLeft:"12px",color:"light-dark(rgb(109, 117, 125), rgb(170, 170, 170))",opacity:"0",transition:"opacity 0.3s ease-in-out","&::after":{content:'""',display:"inline-block",animation:"ellipsis-pulse 1.5s steps(4, end) infinite"},"&:not(:empty)":{opacity:"1"}},".cm-ai-input:disabled":{opacity:"0.5"},"@keyframes ellipsis-pulse":{"0%":{content:"'.'"},"25%":{content:"'..'"},"50%":{content:"'...'"},"75%":{content:"''"}},".cm-ai-loading-container":{display:"flex",alignItems:"center",padding:"0 8px"},".cm-ai-cancel-button":{padding:"2px 8px",fontSize:"10px",borderRadius:"4px",color:"light-dark(rgb(109, 117, 125), rgb(170, 170, 170))",cursor:"pointer","&:hover":{background:"light-dark(rgb(223, 227, 232), rgb(50, 50, 50))"}},".hidden":{display:"none"}});function _s(e){var o,a;let t=e.state.facet(Ft),r={...z,...t.keymaps},n=fe("div","cm-ai-tooltip").appendChild(fe("div","cm-ai-tooltip-button"));return n.innerHTML=`<span>Edit <span class="hotkey">${Xr(r.showInput)}</span></span>`,(o=n.querySelector("span"))==null||o.addEventListener("mousedown",i=>{i.stopPropagation(),i.button===0&&i.preventDefault()}),(a=n.querySelector("span"))==null||a.addEventListener("click",i=>{i.preventDefault(),so(e)}),n}const Zr=ft.define({combine(e){return Vr(e,{render:_s,hideOnBlur:!1})}}),Ms=He.fromClass((ki=class{constructor(e){p(this,"view");p(this,"suppress");p(this,"dom");p(this,"mousedown",()=>{this.suppress=!0});p(this,"mouseup",()=>{this.suppress=!1,this.display(this.view)});p(this,"scroll",()=>{this.display(this.view)});p(this,"windowScroll",()=>{this.display(this.view)});Ni(this,Mr,e=>{var r;let t=e.state.selection.ranges.find(n=>!n.empty);if(t&&!this.suppress){let n=e.coordsAtPos(t.from);if(!n)return;let o=e.dom.getBoundingClientRect(),a=(r=e.dom.parentElement)==null?void 0:r.getBoundingClientRect(),i=n.top>=o.top&&n.top<=o.bottom&&n.left>=o.left&&n.left<=o.right,s=!a||n.top>=a.top&&n.top<=a.bottom&&n.left>=a.left&&n.left<=a.right;if(!i||!s){this.dom.style.display="none",this.dom.setAttribute("aria-hidden","true");return}this.dom.style.display="flex",this.dom.setAttribute("aria-hidden","false");let l=this.dom.getBoundingClientRect(),c=o.width-l.width,d=Math.min(n.left,c),f=n.top-l.height;f=a?Math.max(a.y,f):f,this.dom.style.left=`${d}px`,this.dom.style.top=`${f}px`,requestAnimationFrame(()=>{this.dom&&this.dom.setAttribute("aria-hidden","false")})}else this.dom.style.display="none",this.dom.setAttribute("aria-hidden","true")});this.view=e;let t=e.state.facet(Zr);this.suppress=!1,document.addEventListener("mousedown",this.mousedown),document.addEventListener("mouseup",this.mouseup),e.scrollDOM.addEventListener("scroll",this.scroll),window.addEventListener("scroll",this.windowScroll,!0);let r=t.render(e);e.dom.appendChild(r),this.dom=r}update(e){this.display(e.view)}docViewUpdate(e){this.display(e)}display(e){if(e.state.field(it).show){this.dom.style.display="none";return}if(e.state.facet(Zr).hideOnBlur&&!e.hasFocus){this.dom.style.display="none",this.dom.setAttribute("aria-hidden","true");return}e.requestMeasure({read:Ci(this,Mr)})}destroy(){document.removeEventListener("mousedown",this.mousedown),document.removeEventListener("mouseup",this.mouseup),this.view.scrollDOM.removeEventListener("scroll",this.scroll),window.removeEventListener("scroll",this.windowScroll,!0),this.dom.remove()}},Mr=new WeakMap,ki));var Ps=L.baseTheme({".cm-ai-tooltip-button":{userSelect:"none",fontFamily:"system-ui, -apple-system, sans-serif",position:"fixed",display:"flex",boxSizing:"border-box",padding:"2px 6px",borderRadius:"4px",fontSize:"12px",backgroundColor:"#0E639C",color:"#ffffff",border:"1px solid transparent",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",zIndex:"999",transition:"opacity 0.5s","&[aria-hidden='true']":{opacity:"0"},"&[aria-hidden='false']":{opacity:"1"},"& > span":{pointerEvents:"auto",cursor:"pointer",display:"inline-block",padding:"2px"},"&:hover":{backgroundColor:"#1177bb"}}});function js(){return[Ms,Ps]}var Rs=class extends xt{constructor(t){super();p(this,"oldCode");this.oldCode=t}toDOM(t){let r=fe("div","cm-old-code-container");r.setAttribute("role","region"),r.setAttribute("aria-label","Previous code version");let n=fe("div","cm-old-code cm-line");n.textContent=this.oldCode;let o=fe("div","cm-floating-buttons"),a=t.state.facet(Ft),i={...z,...a.keymaps},s=fe("button","cm-floating-button cm-floating-accept");s.innerHTML=`<span class="hotkey">${Xr(i.acceptEdit)}</span> Accept`,s.setAttribute("aria-label","Accept changes"),s.addEventListener("click",c=>{c.preventDefault(),c.stopPropagation(),t.focus(),lo(t)});let l=fe("button","cm-floating-button cm-floating-reject");return l.innerHTML=`<span class="hotkey">${Xr(i.rejectEdit)}</span> Reject`,l.setAttribute("aria-label","Reject changes"),l.addEventListener("click",c=>{c.preventDefault(),c.stopPropagation(),t.focus(),co(t)}),o.append(s,l),r.append(n,o),r}updateDOM(t,r){return!0}},Gs=class extends xt{constructor(t){super();p(this,"complete");p(this,"abortController",null);p(this,"dom",null);p(this,"input",null);p(this,"loadingContainer",null);p(this,"helpInfo",null);p(this,"inputContainer",null);p(this,"form",null);p(this,"view",null);p(this,"onKeyDown",async t=>{t.key==="Enter"&&!t.shiftKey?(t.preventDefault(),await this.handleSubmit()):t.key==="Escape"&&this.onCancel()});p(this,"onCancel",()=>{this.cleanup();let t=this.view;t&&(t.dispatch({effects:[at.of({show:!1,lineFrom:0,lineTo:0}),pt.of(!1)]}),t.focus())});p(this,"handleSubmit",async t=>{var g;let r=this.view;if(!r)return;let n=r.state.facet(Ft);t==null||t.stopPropagation();let o=r.state.field(it),{input:a}=this;if(!a)return;let i=a.value.trim();if(!o.show||!i)return;let s=r.state.doc.line(o.lineFrom),l=r.state.doc.line(o.lineTo),c=s.from,d=l.to,f=r.state.sliceDoc(c,d),h=r.state.sliceDoc(0,c),m=r.state.sliceDoc(d);this.abortController=new AbortController,r.dispatch({effects:pt.of(!0)}),this.toggleLoading(!0);try{let b=await this.complete({prompt:i,selection:f,codeBefore:h,codeAfter:m,editorView:r,signal:this.abortController.signal});if(!r.state.field(it).show)return;if(!b||typeof b!="string")throw Error("Invalid completion result");r.dispatch({changes:{from:c,to:d,insert:b},effects:[at.of({show:!1,lineFrom:0,lineTo:0}),rr.of({from:c,to:c+b.length,oldCode:f,newCode:b}),pt.of(!1)]})}catch(b){if(b instanceof DOMException&&b.name==="AbortError")return;(g=n.onError)==null||g.call(n,b)}finally{this.cleanup(),this.toggleLoading(!1),r.focus()}});this.complete=t}toDOM(t){if(this.dom)return this.dom;this.view=t;let r=t.state.field(ao),n=t.state.field(io),o=fe("div","cm-ai-input-container");this.inputContainer=o,this.dom=o;let a=fe("form","cm-ai-input-form");this.form=a,a.setAttribute("role","search"),a.setAttribute("aria-label","AI editing instructions"),a.addEventListener("submit",y=>y.preventDefault());let i=fe("input","cm-ai-input");this.input=i,a.append(i),i.placeholder="Editing instructions...",i.setAttribute("aria-label","AI editing instructions"),i.setAttribute("autocomplete","off"),i.setAttribute("spellcheck","true"),i.value=r.inputValue;let s=fe("div","cm-ai-loading-container");this.loadingContainer=s;let l=fe("div","cm-ai-loading-indicator");l.setAttribute("role","status"),l.setAttribute("aria-live","polite"),l.textContent="Generating";let c=fe("button","cm-ai-cancel-button");c.textContent="Cancel",c.setAttribute("aria-label","Cancel code generation"),c.addEventListener("click",this.onCancel),s.append(c,l);let d=fe("div","cm-ai-help-info");this.helpInfo=d;let f=d.appendChild(document.createElement("button"));f.className="cm-ai-help-info-button",f.textContent="Esc to close",f.addEventListener("click",this.onCancel);let h=fe("button","cm-ai-generate-button");h.textContent="\u23CE Generate",h.setAttribute("aria-label","Generate code"),h.addEventListener("click",this.handleSubmit),this.toggleLoading(n),r.shouldFocus&&requestAnimationFrame(()=>{i.value=r.inputValue,i.focus(),t.dispatch({effects:Ot.of(!1)})}),m(i.value),i.addEventListener("input",b),i.addEventListener("keydown",this.onKeyDown);function m(y){d.replaceChildren(y?h:f)}let g="";function b(){t.dispatch({effects:Lt.of(i.value)});let y=i.value.trim();y!==g&&(g=y,m(y))}return o}toggleLoading(t){var r;this.inputContainer&&this.form&&this.loadingContainer&&this.helpInfo&&((r=this.inputContainer)==null||r.replaceChildren(this.form,t?this.loadingContainer:this.helpInfo))}updateDOM(t,r){return this.dom=t,this.input=t.querySelector(".cm-ai-input"),!0}cleanup(){var t,r,n;(t=this.abortController)==null||t.abort(),this.abortController=null,(r=this.dom)==null||r.remove(),(n=this.input)==null||n.remove(),this.dom=null,this.input=null}destroy(){this.cleanup()}};function Js(e){if(!e.prompt)throw Error("prompt function is required");let t={...z,...e.keymaps};return[Ft.of(e),it,ao,Bt,io,js(),Us,$e.of([{key:t.showInput,run:so}]),tt.highest([$e.of([{key:t.acceptEdit,run:lo},{key:t.rejectEdit,run:co}])]),Vs,Ws,$s,Hs]}const Vs=L.updateListener.of(e=>{let t=e.state.field(it);if(!t.show||!e.docChanged)return;let{lineFrom:r,lineTo:n}=t,o=!1;e.changes.iterChanges((a,i,s,l)=>{let c=e.state.doc.lineAt(a).number;if(c<r){let d=e.state.doc.lineAt(l).number-e.state.doc.lineAt(s).number;r+=d,n+=d,o=!0}else if(c<=n){let d=e.state.doc.lineAt(l).number-e.state.doc.lineAt(s).number;n+=d,o=!0}}),o&&e.view.dispatch({effects:[at.of({show:!0,lineFrom:r,lineTo:n})]})}),Ws=L.decorations.of(e=>{let t=e.state.field(Bt);return t?_.set([_.mark({class:"cm-new-code-line"}).range(t.from,t.to)]):_.none}),$s=L.decorations.compute([it],e=>{let t=e.field(it),r=e.facet(Ft),n=[];if(t.show){let o=t.lineFrom,a=t.lineTo;for(let i=o;i<=a;i++){let s=e.doc.line(i).from;n.push(_.line({class:"cm-ai-selection"}).range(s)),i===o&&n.push(_.widget({widget:new Gs(r.prompt),side:-1}).range(s))}}return _.set(n)}),Hs=Ee.define({create(e){return _.none},update(e,t){let r=t.state.field(Bt);return r?_.set([_.widget({widget:new Rs(r.oldCode),block:!0}).range(r.from)]):_.none},provide:e=>L.decorations.from(e)});var qs=pe(We()),F=pe(gf()),en=()=>({entries:new Map}),{valueAtom:mo,useActions:ho}=Xn(en,{submit:(e,t)=>{let{cellIds:r,deleteCell:n,deleteManyCells:o,store:a}=t,i=a.get(ot),s=a.get(kf),l=new Set(i.cellIds.inOrderIds.filter(f=>i.cellData[f].code.trim()==="")),c=new Map;for(let f of r){if(l.has(f)){c.set(f,{cellId:f,type:"simple"});continue}let h=i.cellRuntime[f],m=new Map;for(let b of Object.values(s)){let y=b.declaredBy.includes(f),E=b.usedBy.some(C=>!l.has(C));y&&E&&m.set(b.name,b.usedBy)}let g;h!=null&&h.runElapsedTimeMs&&h.runElapsedTimeMs>2e3&&(g=h.runElapsedTimeMs),m.size===0&&g===void 0?c.set(f,{cellId:f,type:"simple"}):c.set(f,{cellId:f,type:"expensive",executionDurationMs:g,defs:m})}let d=[...c.values()].every(f=>f.type==="simple");return c.size>0&&d?(c.size===1?n({cellId:[...c.values()][0].cellId}):o({cellIds:[...c.values()].map(f=>f.cellId)}),en()):{...e,entries:c}},clear:()=>en()});Kr=function(){let e=Pn(),{submit:t,clear:r}=ho(),{entries:n}=le(mo),o=Qi(),a=Qn();return(0,F.useMemo)(()=>({submit:i=>{t({cellIds:i,deleteCell:o,deleteManyCells:a,store:e})},clear:r,get idle(){return n.size===0},get shouldConfirmDelete(){return n.size>1}}),[e,t,r,n,o,a])},hs=function(e){let t=(0,qs.c)(16),r=le(mo),n=ho(),o=Qn(),a;t[0]!==e||t[1]!==r.entries?(a=r.entries.get(e),t[0]=e,t[1]=r.entries,t[2]=a):a=t[2];let i=a;if(!i){let d;return t[3]===Symbol.for("react.memo_cache_sentinel")?(d={isPending:!1},t[3]=d):d=t[3],d}if(r.entries.size!==1){let d;return t[4]===i?d=t[5]:(d={isPending:!0,shouldConfirmDelete:!1,...i},t[4]=i,t[5]=d),d}let s;t[6]!==n||t[7]!==o||t[8]!==r.entries?(s=()=>{o({cellIds:[...r.entries.values()].map(zs)}),n.clear()},t[6]=n,t[7]=o,t[8]=r.entries,t[9]=s):s=t[9];let l;t[10]===n?l=t[11]:(l=()=>n.clear(),t[10]=n,t[11]=l);let c;return t[12]!==i||t[13]!==s||t[14]!==l?(c={isPending:!0,...i,shouldConfirmDelete:!0,confirm:s,cancel:l},t[12]=i,t[13]=s,t[14]=l,t[15]=c):c=t[15],c};function zs(e){return e.cellId}async function Ks(e){var s,l;let t=`
|
|
4
4
|
${e.codeBefore}
|
|
5
5
|
<rewrite_this>
|
|
6
6
|
${e.selection}
|
|
7
7
|
</rewrite_this>
|
|
8
8
|
${e.codeAfter}
|
|
9
|
-
`.trim(),r=Wi();await Ki();let n=await fetch(r.getAiURL("completion").toString(),{method:"POST",headers:r.headers(),body:JSON.stringify({prompt:e.prompt,code:t,selectedText:e.selection,includeOtherCode:"",language:e.language})}),o=((s=e.selection.match(/^\s*/))==null?void 0:s[0])||"",a=(l=n.body)==null?void 0:l.getReader();if(!a)throw Error("Failed to get response reader");let i="";for(;;){let{done:c,value:d}=await a.read();if(c)break;i+=new TextDecoder().decode(d)}return i.startsWith(o)||(i=o+i),i}var w=ge(Yf()),Xs=["%alias","%cd","%clear","%debug","%env","%load","%load_ext","%lsmagic","%matplotlib","%pwd","%who_ls","%system","%%time","%%timeit","%%writefile","%%capture","%%html","%%latex"],tn;function Qs(){let e=async o=>{let a=Y.get(qn),{saveUserConfig:i}=$m(),s={...a,runtime:{...a.runtime,auto_reload:o}};await i({config:s}).then(()=>Y.set(qn,s))},t=()=>{requestAnimationFrame(()=>{let o=document.getElementById(Vh);o&&o.focus()})},r=[{match:"!pip install",onMatch:()=>{Y.set(Rn,o=>({...o,isSidebarOpen:!0,selectedPanel:"packages"})),t()},title:"Package Installation",description:(0,w.jsxs)(w.Fragment,{children:["The package manager sidebar has been opened.",(0,w.jsx)("br",{}),"Install packages directly from there instead."]})},{match:"!uv pip install",onMatch:()=>{Y.set(Rn,o=>({...o,isSidebarOpen:!0,selectedPanel:"packages"})),t()},title:"Package Installation",description:(0,w.jsxs)(w.Fragment,{children:["The package manager sidebar has been opened.",(0,w.jsx)("br",{}),"Install packages directly from there instead."]})},{match:"!uv add",onMatch:()=>{Y.set(Rn,o=>({...o,isSidebarOpen:!0,selectedPanel:"packages"})),t()},title:"Package Installation",description:(0,w.jsxs)(w.Fragment,{children:["The package manager sidebar has been opened.",(0,w.jsx)("br",{}),"Install packages directly from there instead."]})},{match:"%autoreload 2",onMatch:async()=>{await e("autorun")},title:"Module reload",description:(0,w.jsxs)(w.Fragment,{children:["Module reload mode set to ",(0,w.jsx)("b",{children:"autorun"})," - module changes will re-run the cells that import them."]})},{match:"%autoreload 1",onMatch:async()=>{await e("lazy")},title:"Module reload",description:(0,w.jsxs)(w.Fragment,{children:["Module reload mode set to ",(0,w.jsx)("b",{children:"lazy"})," - module changes will mark the cells that import them as stale."]})},{match:"%autoreload 0",onMatch:async()=>{await e("off")},title:"Module reload",description:(0,w.jsx)(w.Fragment,{children:"Module reload disabled - module changes will not be detected."})},{match:"!ls",onMatch:()=>{},title:"Listing files",description:(0,w.jsxs)(w.Fragment,{children:["Shell commands are not directly supported.",(0,w.jsx)("br",{}),"Use ",(0,w.jsx)("code",{children:"import subprocess; subprocess.run(['ls'])"})," instead."]})},...Xs.map(o=>({match:o,onMatch:()=>{},title:(0,w.jsx)(Sh,{className:"inline",children:o}),description:(0,w.jsxs)(w.Fragment,{children:["Magic commands are not supported in marimo. Read more about replacements in the"," ",(0,w.jsx)("a",{href:"https://docs.marimo.io/guides/coming_from/jupyter/#adapting-to-the-absence-of-magic-commands",target:"_blank",className:"text-link underline cursor-pointer",rel:"noopener noreferrer",children:"documentation"}),"."]})}))],n=new Map(r.map(o=>[o.match,o]));return O.updateListener.of(o=>{if(o.docChanged){let a=o.state.selection.main,i=o.state.doc,s=i.lineAt(a.head),l=i.sliceString(s.from,a.anchor).trim(),c=n.get(l);c&&(c.onMatch(),tn?tn.upsert({title:c.title,description:c.description}):tn=xt({title:c.title,description:c.description}))}})}var Zs=new Set(["Escape","Alt-`"]);function el(){let e=zm.filter(t=>!Zs.has(t.key));return et.highest(We.of([...e,{key:"Ctrl-y",run:t=>Rr(t)?zi(t):!1},{key:"Ctrl-n",run:t=>Rr(t)?$r(!0)(t):!1},{key:"Ctrl-p",run:t=>Rr(t)?$r(!1)(t):!1}]))}const rn=te.define(),nn=te.define(),on=te.define();function K(e,t){if(!e)throw Error(t)}var tl=3402823466385289e23,rl=-3402823466385289e23,nl=4294967295,ol=2147483647,al=-2147483648;function or(e){if(typeof e!="number")throw Error("invalid int 32: "+typeof e);if(!Number.isInteger(e)||e>ol||e<al)throw Error("invalid int 32: "+e)}function an(e){if(typeof e!="number")throw Error("invalid uint 32: "+typeof e);if(!Number.isInteger(e)||e>nl||e<0)throw Error("invalid uint 32: "+e)}function go(e){if(typeof e!="number")throw Error("invalid float 32: "+typeof e);if(Number.isFinite(e)&&(e>tl||e<rl))throw Error("invalid float 32: "+e)}var po=Symbol("@bufbuild/protobuf/enum-type");function il(e){let t=e[po];return K(t,"missing enum type on enum object"),t}function bo(e,t,r,n){e[po]=yo(t,r.map(o=>({no:o.no,name:o.name,localName:e[o.no]})),n)}function yo(e,t,r){let n=Object.create(null),o=Object.create(null),a=[];for(let i of t){let s=wo(i);a.push(s),n[i.name]=s,o[i.no]=s}return{typeName:e,values:a,findName(i){return n[i]},findNumber(i){return o[i]}}}function sl(e,t,r){let n={};for(let o of t){let a=wo(o);n[a.localName]=a.no,n[a.no]=a.localName}return bo(n,e,t,r),n}function wo(e){return"localName"in e?e:Object.assign(Object.assign({},e),{localName:e.name})}var Q=class{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,t){let r=this.getType().runtime.bin,n=r.makeReadOptions(t);return r.readMessage(this,n.readerFactory(e),e.byteLength,n),this}fromJson(e,t){let r=this.getType(),n=r.runtime.json,o=n.makeReadOptions(t);return n.readMessage(r,e,o,this),this}fromJsonString(e,t){let r;try{r=JSON.parse(e)}catch(n){throw Error(`cannot decode ${this.getType().typeName} from JSON: ${n instanceof Error?n.message:String(n)}`)}return this.fromJson(r,t)}toBinary(e){let t=this.getType().runtime.bin,r=t.makeWriteOptions(e),n=r.writerFactory();return t.writeMessage(this,n,r),n.finish()}toJson(e){let t=this.getType().runtime.json,r=t.makeWriteOptions(e);return t.writeMessage(this,r)}toJsonString(e){let t=this.toJson(e);return JSON.stringify(t,null,(e==null?void 0:e.prettySpaces)??0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}};function ll(e,t,r,n){let o=(n==null?void 0:n.localName)??t.substring(t.lastIndexOf(".")+1),a={[o]:function(i){e.util.initFields(this),e.util.initPartial(i,this)}}[o];return Object.setPrototypeOf(a.prototype,new Q),Object.assign(a,{runtime:e,typeName:t,fields:e.util.newFieldList(r),fromBinary(i,s){return new a().fromBinary(i,s)},fromJson(i,s){return new a().fromJson(i,s)},fromJsonString(i,s){return new a().fromJsonString(i,s)},equals(i,s){return e.util.equals(a,i,s)}}),a}function cl(){let e=0,t=0;for(let n=0;n<28;n+=7){let o=this.buf[this.pos++];if(e|=(o&127)<<n,!(o&128))return this.assertBounds(),[e,t]}let r=this.buf[this.pos++];if(e|=(r&15)<<28,t=(r&112)>>4,!(r&128))return this.assertBounds(),[e,t];for(let n=3;n<=31;n+=7){let o=this.buf[this.pos++];if(t|=(o&127)<<n,!(o&128))return this.assertBounds(),[e,t]}throw Error("invalid varint")}function sn(e,t,r){for(let a=0;a<28;a+=7){let i=e>>>a,s=!(!(i>>>7)&&t==0),l=(s?i|128:i)&255;if(r.push(l),!s)return}let n=e>>>28&15|(t&7)<<4,o=!!(t>>3);if(r.push((o?n|128:n)&255),o){for(let a=3;a<31;a+=7){let i=t>>>a,s=!!(i>>>7),l=(s?i|128:i)&255;if(r.push(l),!s)return}r.push(t>>>31&1)}}var ar=4294967296;function vo(e){let t=e[0]==="-";t&&(e=e.slice(1));let r=1e6,n=0,o=0;function a(i,s){let l=Number(e.slice(i,s));o*=r,n=n*r+l,n>=ar&&(o+=n/ar|0,n%=ar)}return a(-24,-18),a(-18,-12),a(-12,-6),a(-6),t?ko(n,o):ln(n,o)}function ul(e,t){let r=ln(e,t),n=r.hi&2147483648;n&&(r=ko(r.lo,r.hi));let o=Eo(r.lo,r.hi);return n?"-"+o:o}function Eo(e,t){if({lo:e,hi:t}=dl(e,t),t<=2097151)return String(ar*t+e);let r=e&16777215,n=(e>>>24|t<<8)&16777215,o=t>>16&65535,a=r+n*6777216+o*6710656,i=n+o*8147497,s=o*2,l=1e7;return a>=l&&(i+=Math.floor(a/l),a%=l),i>=l&&(s+=Math.floor(i/l),i%=l),s.toString()+Ao(i)+Ao(a)}function dl(e,t){return{lo:e>>>0,hi:t>>>0}}function ln(e,t){return{lo:e|0,hi:t|0}}function ko(e,t){return t=~t,e?e=~e+1:t+=1,ln(e,t)}var Ao=e=>{let t=String(e);return"0000000".slice(t.length)+t};function Co(e,t){if(e>=0){for(;e>127;)t.push(e&127|128),e>>>=7;t.push(e)}else{for(let r=0;r<9;r++)t.push(e&127|128),e>>=7;t.push(1)}}function fl(){let e=this.buf[this.pos++],t=e&127;if(!(e&128)||(e=this.buf[this.pos++],t|=(e&127)<<7,!(e&128))||(e=this.buf[this.pos++],t|=(e&127)<<14,!(e&128))||(e=this.buf[this.pos++],t|=(e&127)<<21,!(e&128)))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(e&15)<<28;for(let r=5;e&128&&r<10;r++)e=this.buf[this.pos++];if(e&128)throw Error("invalid varint");return this.assertBounds(),t>>>0}function ml(){let e=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof e.getBigInt64=="function"&&typeof e.getBigUint64=="function"&&typeof e.setBigInt64=="function"&&typeof e.setBigUint64=="function"&&(typeof process!="object"||{}.BUF_BIGINT_DISABLE!=="1")){let n=BigInt("-9223372036854775808"),o=BigInt("9223372036854775807"),a=BigInt("0"),i=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(s){let l=typeof s=="bigint"?s:BigInt(s);if(l>o||l<n)throw Error(`int64 invalid: ${s}`);return l},uParse(s){let l=typeof s=="bigint"?s:BigInt(s);if(l>i||l<a)throw Error(`uint64 invalid: ${s}`);return l},enc(s){return e.setBigInt64(0,this.parse(s),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(s){return e.setBigInt64(0,this.uParse(s),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec(s,l){return e.setInt32(0,s,!0),e.setInt32(4,l,!0),e.getBigInt64(0,!0)},uDec(s,l){return e.setInt32(0,s,!0),e.setInt32(4,l,!0),e.getBigUint64(0,!0)}}}let t=n=>K(/^-?[0-9]+$/.test(n),`int64 invalid: ${n}`),r=n=>K(/^[0-9]+$/.test(n),`uint64 invalid: ${n}`);return{zero:"0",supported:!1,parse(n){return typeof n!="string"&&(n=n.toString()),t(n),n},uParse(n){return typeof n!="string"&&(n=n.toString()),r(n),n},enc(n){return typeof n!="string"&&(n=n.toString()),t(n),vo(n)},uEnc(n){return typeof n!="string"&&(n=n.toString()),r(n),vo(n)},dec(n,o){return ul(n,o)},uDec(n,o){return Eo(n,o)}}}const W=ml();var v;(function(e){e[e.DOUBLE=1]="DOUBLE",e[e.FLOAT=2]="FLOAT",e[e.INT64=3]="INT64",e[e.UINT64=4]="UINT64",e[e.INT32=5]="INT32",e[e.FIXED64=6]="FIXED64",e[e.FIXED32=7]="FIXED32",e[e.BOOL=8]="BOOL",e[e.STRING=9]="STRING",e[e.BYTES=12]="BYTES",e[e.UINT32=13]="UINT32",e[e.SFIXED32=15]="SFIXED32",e[e.SFIXED64=16]="SFIXED64",e[e.SINT32=17]="SINT32",e[e.SINT64=18]="SINT64"})(v||(v={}));var it;(function(e){e[e.BIGINT=0]="BIGINT",e[e.STRING=1]="STRING"})(it||(it={}));function rt(e,t,r){if(t===r)return!0;if(e==v.BYTES){if(!(t instanceof Uint8Array)||!(r instanceof Uint8Array)||t.length!==r.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==r[n])return!1;return!0}switch(e){case v.UINT64:case v.FIXED64:case v.INT64:case v.SFIXED64:case v.SINT64:return t==r}return!1}function pt(e,t){switch(e){case v.BOOL:return!1;case v.UINT64:case v.FIXED64:case v.INT64:case v.SFIXED64:case v.SINT64:return t==0?W.zero:"0";case v.DOUBLE:case v.FLOAT:return 0;case v.BYTES:return new Uint8Array;case v.STRING:return"";default:return 0}}function No(e,t){switch(e){case v.BOOL:return t===!1;case v.STRING:return t==="";case v.BYTES:return t instanceof Uint8Array&&!t.byteLength;default:return t==0}}var ee;(function(e){e[e.Varint=0]="Varint",e[e.Bit64=1]="Bit64",e[e.LengthDelimited=2]="LengthDelimited",e[e.StartGroup=3]="StartGroup",e[e.EndGroup=4]="EndGroup",e[e.Bit32=5]="Bit32"})(ee||(ee={}));var hl=class{constructor(e){this.stack=[],this.textEncoder=e??new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let n=0;n<this.chunks.length;n++)e+=this.chunks[n].length;let t=new Uint8Array(e),r=0;for(let n=0;n<this.chunks.length;n++)t.set(this.chunks[n],r),r+=this.chunks[n].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(an(e);e>127;)this.buf.push(e&127|128),e>>>=7;return this.buf.push(e),this}int32(e){return or(e),Co(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){go(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){an(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){or(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return or(e),e=(e<<1^e>>31)>>>0,Co(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),n=W.enc(e);return r.setInt32(0,n.lo,!0),r.setInt32(4,n.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),n=W.uEnc(e);return r.setInt32(0,n.lo,!0),r.setInt32(4,n.hi,!0),this.raw(t)}int64(e){let t=W.enc(e);return sn(t.lo,t.hi,this.buf),this}sint64(e){let t=W.enc(e),r=t.hi>>31,n=t.lo<<1^r,o=(t.hi<<1|t.lo>>>31)^r;return sn(n,o,this.buf),this}uint64(e){let t=W.uEnc(e);return sn(t.lo,t.hi,this.buf),this}},gl=class{constructor(e,t){this.varint64=cl,this.uint32=fl,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=t??new TextDecoder}tag(){let e=this.uint32(),t=e>>>3,r=e&7;if(t<=0||r<0||r>5)throw Error("illegal tag: field no "+t+" wire type "+r);return[t,r]}skip(e,t){let r=this.pos;switch(e){case ee.Varint:for(;this.buf[this.pos++]&128;);break;case ee.Bit64:this.pos+=4;case ee.Bit32:this.pos+=4;break;case ee.LengthDelimited:let n=this.uint32();this.pos+=n;break;case ee.StartGroup:for(;;){let[o,a]=this.tag();if(a===ee.EndGroup){if(t!==void 0&&o!==t)throw Error("invalid end group tag");break}this.skip(a,o)}break;default:throw Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(r,this.pos)}assertBounds(){if(this.pos>this.len)throw RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return W.dec(...this.varint64())}uint64(){return W.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),r=-(e&1);return e=(e>>>1|(t&1)<<31)^r,t=t>>>1^r,W.dec(e,t)}bool(){let[e,t]=this.varint64();return e!==0||t!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return W.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return W.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}};function pl(e,t,r,n){let o;return{typeName:t,extendee:r,get field(){if(!o){let a=typeof n=="function"?n():n;a.name=t.split(".").pop(),a.jsonName=`[${t}]`,o=e.util.newFieldList([a]).list()[0]}return o},runtime:e}}function xo(e){let t=e.field.localName,r=Object.create(null);return r[t]=bl(e),[r,()=>r[t]]}function bl(e){let t=e.field;if(t.repeated)return[];if(t.default!==void 0)return t.default;switch(t.kind){case"enum":return t.T.values[0].no;case"scalar":return pt(t.T,t.L);case"message":let r=t.T,n=new r;return r.fieldWrapper?r.fieldWrapper.unwrapField(n):n;case"map":throw"map fields are not allowed to be extensions"}}function yl(e,t){if(!t.repeated&&(t.kind=="enum"||t.kind=="scalar")){for(let r=e.length-1;r>=0;--r)if(e[r].no==t.no)return[e[r]];return[]}return e.filter(r=>r.no===t.no)}var ze="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),ir=[];for(let e=0;e<ze.length;e++)ir[ze[e].charCodeAt(0)]=e;ir[45]=ze.indexOf("+"),ir[95]=ze.indexOf("/");const sr={dec(e){let t=e.length*3/4;e[e.length-2]=="="?t-=2:e[e.length-1]=="="&&--t;let r=new Uint8Array(t),n=0,o=0,a,i=0;for(let s=0;s<e.length;s++){if(a=ir[e.charCodeAt(s)],a===void 0)switch(e[s]){case"=":o=0;case`
|
|
10
|
-
`:case"\r":case" ":case" ":continue;default:throw Error("invalid base64 string.")}switch(o){case 0:i=a,o=1;break;case 1:r[n++]=i<<2|(a&48)>>4,i=a,o=2;break;case 2:r[n++]=(i&15)<<4|(a&60)>>2,i=a,o=3;break;case 3:r[n++]=(i&3)<<6|a,o=0;break}}if(o==1)throw Error("invalid base64 string.");return r.subarray(0,n)},enc(e){let t="",r=0,n,o=0;for(let a=0;a<e.length;a++)switch(n=e[a],r){case 0:t+=ze[n>>2],o=(n&3)<<4,r=1;break;case 1:t+=ze[o|n>>4],o=(n&15)<<2,r=2;break;case 2:t+=ze[o|n>>6],t+=ze[n&63],r=0;break}return r&&(t+=ze[o],t+="=",r==1&&(t+="=")),t}};function wl(e,t,r){To(t,e);let n=t.runtime.bin.makeReadOptions(r),o=yl(e.getType().runtime.bin.listUnknownFields(e),t.field),[a,i]=xo(t);for(let s of o)t.runtime.bin.readField(a,n.readerFactory(s.data),t.field,s.wireType,n);return i()}function vl(e,t,r,n){To(t,e);let o=t.runtime.bin.makeReadOptions(n),a=t.runtime.bin.makeWriteOptions(n);if(So(e,t)){let c=e.getType().runtime.bin.listUnknownFields(e).filter(d=>d.no!=t.field.no);e.getType().runtime.bin.discardUnknownFields(e);for(let d of c)e.getType().runtime.bin.onUnknownField(e,d.no,d.wireType,d.data)}let i=a.writerFactory(),s=t.field;!s.opt&&!s.repeated&&(s.kind=="enum"||s.kind=="scalar")&&(s=Object.assign(Object.assign({},t.field),{opt:!0})),t.runtime.bin.writeField(s,r,i,a);let l=o.readerFactory(i.finish());for(;l.pos<l.len;){let[c,d]=l.tag(),f=l.skip(d,c);e.getType().runtime.bin.onUnknownField(e,c,d,f)}}function So(e,t){let r=e.getType();return t.extendee.typeName===r.typeName&&!!r.runtime.bin.listUnknownFields(e).find(n=>n.no==t.field.no)}function To(e,t){K(e.extendee.typeName==t.getType().typeName,`extension ${e.typeName} can only be applied to message ${e.extendee.typeName}`)}function Io(e,t){let r=e.localName;if(e.repeated)return t[r].length>0;if(e.oneof)return t[e.oneof.localName].case===r;switch(e.kind){case"enum":case"scalar":return e.opt||e.req?t[r]!==void 0:e.kind=="enum"?t[r]!==e.T.values[0].no:!No(e.T,t[r]);case"message":return t[r]!==void 0;case"map":return Object.keys(t[r]).length>0}}function Fo(e,t){let r=e.localName,n=!e.opt&&!e.req;if(e.repeated)t[r]=[];else if(e.oneof)t[e.oneof.localName]={case:void 0};else switch(e.kind){case"map":t[r]={};break;case"enum":t[r]=n?e.T.values[0].no:void 0;break;case"scalar":t[r]=n?pt(e.T,e.L):void 0;break;case"message":t[r]=void 0;break}}function Ke(e,t){if(typeof e!="object"||!e||!Object.getOwnPropertyNames(Q.prototype).every(n=>n in e&&typeof e[n]=="function"))return!1;let r=e.getType();return r===null||typeof r!="function"||!("typeName"in r)||typeof r.typeName!="string"?!1:t===void 0?!0:r.typeName==t.typeName}function Lo(e,t){return Ke(t)||!e.fieldWrapper?t:e.fieldWrapper.wrapField(t)}v.DOUBLE,v.FLOAT,v.INT64,v.UINT64,v.INT32,v.UINT32,v.BOOL,v.STRING,v.BYTES;var Oo={ignoreUnknownFields:!1},Bo={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function El(e){return e?Object.assign(Object.assign({},Oo),e):Oo}function kl(e){return e?Object.assign(Object.assign({},Bo),e):Bo}var lr=Symbol(),cr=Symbol();function Al(){return{makeReadOptions:El,makeWriteOptions:kl,readMessage(e,t,r,n){if(t==null||Array.isArray(t)||typeof t!="object")throw Error(`cannot decode message ${e.typeName} from JSON: ${He(t)}`);n??(n=new e);let o=new Map,a=r.typeRegistry;for(let[i,s]of Object.entries(t)){let l=e.fields.findJsonName(i);if(l){if(l.oneof){if(s===null&&l.kind=="scalar")continue;let c=o.get(l.oneof);if(c!==void 0)throw Error(`cannot decode message ${e.typeName} from JSON: multiple keys for oneof "${l.oneof.name}" present: "${c}", "${i}"`);o.set(l.oneof,i)}Do(n,s,l,r,e)}else{let c=!1;if(a!=null&&a.findExtension&&i.startsWith("[")&&i.endsWith("]")){let d=a.findExtension(i.substring(1,i.length-1));if(d&&d.extendee.typeName==e.typeName){c=!0;let[f,h]=xo(d);Do(f,s,d.field,r,d),vl(n,d,h(),r)}}if(!c&&!r.ignoreUnknownFields)throw Error(`cannot decode message ${e.typeName} from JSON: key "${i}" is unknown`)}}return n},writeMessage(e,t){let r=e.getType(),n={},o;try{for(o of r.fields.byNumber()){if(!Io(o,e)){if(o.req)throw"required field not set";if(!t.emitDefaultValues||!Nl(o))continue}let i=o.oneof?e[o.oneof.localName].value:e[o.localName],s=Uo(o,i,t);s!==void 0&&(n[t.useProtoFieldName?o.name:o.jsonName]=s)}let a=t.typeRegistry;if(a!=null&&a.findExtensionFor)for(let i of r.runtime.bin.listUnknownFields(e)){let s=a.findExtensionFor(r.typeName,i.no);if(s&&So(e,s)){let l=wl(e,s,t),c=Uo(s.field,l,t);c!==void 0&&(n[s.field.jsonName]=c)}}}catch(a){let i=o?`cannot encode field ${r.typeName}.${o.name} to JSON`:`cannot encode message ${r.typeName} to JSON`,s=a instanceof Error?a.message:String(a);throw Error(i+(s.length>0?`: ${s}`:""))}return n},readScalar(e,t,r){return Bt(e,t,r??it.BIGINT,!0)},writeScalar(e,t,r){if(t!==void 0&&(r||No(e,t)))return ur(e,t)},debug:He}}function He(e){if(e===null)return"null";switch(typeof e){case"object":return Array.isArray(e)?"array":"object";case"string":return e.length>100?"string":`"${e.split('"').join('\\"')}"`;default:return String(e)}}function Do(e,t,r,n,o){let a=r.localName;if(r.repeated){if(K(r.kind!="map"),t===null)return;if(!Array.isArray(t))throw Error(`cannot decode field ${o.typeName}.${r.name} from JSON: ${He(t)}`);let i=e[a];for(let s of t){if(s===null)throw Error(`cannot decode field ${o.typeName}.${r.name} from JSON: ${He(s)}`);switch(r.kind){case"message":i.push(r.T.fromJson(s,n));break;case"enum":let l=cn(r.T,s,n.ignoreUnknownFields,!0);l!==cr&&i.push(l);break;case"scalar":try{i.push(Bt(r.T,s,r.L,!0))}catch(c){let d=`cannot decode field ${o.typeName}.${r.name} from JSON: ${He(s)}`;throw c instanceof Error&&c.message.length>0&&(d+=`: ${c.message}`),Error(d)}break}}}else if(r.kind=="map"){if(t===null)return;if(typeof t!="object"||Array.isArray(t))throw Error(`cannot decode field ${o.typeName}.${r.name} from JSON: ${He(t)}`);let i=e[a];for(let[s,l]of Object.entries(t)){if(l===null)throw Error(`cannot decode field ${o.typeName}.${r.name} from JSON: map value null`);let c;try{c=Cl(r.K,s)}catch(d){let f=`cannot decode map key for field ${o.typeName}.${r.name} from JSON: ${He(t)}`;throw d instanceof Error&&d.message.length>0&&(f+=`: ${d.message}`),Error(f)}switch(r.V.kind){case"message":i[c]=r.V.T.fromJson(l,n);break;case"enum":let d=cn(r.V.T,l,n.ignoreUnknownFields,!0);d!==cr&&(i[c]=d);break;case"scalar":try{i[c]=Bt(r.V.T,l,it.BIGINT,!0)}catch(f){let h=`cannot decode map value for field ${o.typeName}.${r.name} from JSON: ${He(t)}`;throw f instanceof Error&&f.message.length>0&&(h+=`: ${f.message}`),Error(h)}break}}}else switch(r.oneof&&(e=e[r.oneof.localName]={case:a},a="value"),r.kind){case"message":let i=r.T;if(t===null&&i.typeName!="google.protobuf.Value")return;let s=e[a];Ke(s)?s.fromJson(t,n):(e[a]=s=i.fromJson(t,n),i.fieldWrapper&&!r.oneof&&(e[a]=i.fieldWrapper.unwrapField(s)));break;case"enum":let l=cn(r.T,t,n.ignoreUnknownFields,!1);switch(l){case lr:Fo(r,e);break;case cr:break;default:e[a]=l;break}break;case"scalar":try{let c=Bt(r.T,t,r.L,!1);switch(c){case lr:Fo(r,e);break;default:e[a]=c;break}}catch(c){let d=`cannot decode field ${o.typeName}.${r.name} from JSON: ${He(t)}`;throw c instanceof Error&&c.message.length>0&&(d+=`: ${c.message}`),Error(d)}break}}function Cl(e,t){if(e===v.BOOL)switch(t){case"true":t=!0;break;case"false":t=!1;break}return Bt(e,t,it.BIGINT,!0).toString()}function Bt(e,t,r,n){if(t===null)return n?pt(e,r):lr;switch(e){case v.DOUBLE:case v.FLOAT:if(t==="NaN")return NaN;if(t==="Infinity")return 1/0;if(t==="-Infinity")return-1/0;if(t===""||typeof t=="string"&&t.trim().length!==t.length||typeof t!="string"&&typeof t!="number")break;let o=Number(t);if(Number.isNaN(o)||!Number.isFinite(o))break;return e==v.FLOAT&&go(o),o;case v.INT32:case v.FIXED32:case v.SFIXED32:case v.SINT32:case v.UINT32:let a;if(typeof t=="number"?a=t:typeof t=="string"&&t.length>0&&t.trim().length===t.length&&(a=Number(t)),a===void 0)break;return e==v.UINT32||e==v.FIXED32?an(a):or(a),a;case v.INT64:case v.SFIXED64:case v.SINT64:if(typeof t!="number"&&typeof t!="string")break;let i=W.parse(t);return r?i.toString():i;case v.FIXED64:case v.UINT64:if(typeof t!="number"&&typeof t!="string")break;let s=W.uParse(t);return r?s.toString():s;case v.BOOL:if(typeof t!="boolean")break;return t;case v.STRING:if(typeof t!="string")break;return t;case v.BYTES:if(t==="")return new Uint8Array;if(typeof t!="string")break;return sr.dec(t)}throw Error()}function cn(e,t,r,n){if(t===null)return e.typeName=="google.protobuf.NullValue"?0:n?e.values[0].no:lr;switch(typeof t){case"number":if(Number.isInteger(t))return t;break;case"string":let o=e.findName(t);if(o!==void 0)return o.no;if(r)return cr;break}throw Error(`cannot decode enum ${e.typeName} from JSON: ${He(t)}`)}function Nl(e){return e.repeated||e.kind=="map"?!0:!(e.oneof||e.kind=="message"||e.opt||e.req)}function Uo(e,t,r){if(e.kind=="map"){K(typeof t=="object"&&!!t);let n={},o=Object.entries(t);switch(e.V.kind){case"scalar":for(let[i,s]of o)n[i.toString()]=ur(e.V.T,s);break;case"message":for(let[i,s]of o)n[i.toString()]=s.toJson(r);break;case"enum":let a=e.V.T;for(let[i,s]of o)n[i.toString()]=un(a,s,r.enumAsInteger);break}return r.emitDefaultValues||o.length>0?n:void 0}if(e.repeated){K(Array.isArray(t));let n=[];switch(e.kind){case"scalar":for(let o=0;o<t.length;o++)n.push(ur(e.T,t[o]));break;case"enum":for(let o=0;o<t.length;o++)n.push(un(e.T,t[o],r.enumAsInteger));break;case"message":for(let o=0;o<t.length;o++)n.push(t[o].toJson(r));break}return r.emitDefaultValues||n.length>0?n:void 0}switch(e.kind){case"scalar":return ur(e.T,t);case"enum":return un(e.T,t,r.enumAsInteger);case"message":return Lo(e.T,t).toJson(r)}}function un(e,t,r){var n;return K(typeof t=="number"),e.typeName=="google.protobuf.NullValue"?null:r?t:((n=e.findNumber(t))==null?void 0:n.name)??t}function ur(e,t){switch(e){case v.INT32:case v.SFIXED32:case v.SINT32:case v.FIXED32:case v.UINT32:return K(typeof t=="number"),t;case v.FLOAT:case v.DOUBLE:return K(typeof t=="number"),Number.isNaN(t)?"NaN":t===1/0?"Infinity":t===-1/0?"-Infinity":t;case v.STRING:return K(typeof t=="string"),t;case v.BOOL:return K(typeof t=="boolean"),t;case v.UINT64:case v.FIXED64:case v.INT64:case v.SFIXED64:case v.SINT64:return K(typeof t=="bigint"||typeof t=="string"||typeof t=="number"),t.toString();case v.BYTES:return K(t instanceof Uint8Array),sr.enc(t)}}var bt=Symbol("@bufbuild/protobuf/unknown-fields"),_o={readUnknownFields:!0,readerFactory:e=>new gl(e)},Mo={writeUnknownFields:!0,writerFactory:()=>new hl};function xl(e){return e?Object.assign(Object.assign({},_o),e):_o}function Sl(e){return e?Object.assign(Object.assign({},Mo),e):Mo}function Tl(){return{makeReadOptions:xl,makeWriteOptions:Sl,listUnknownFields(e){return e[bt]??[]},discardUnknownFields(e){delete e[bt]},writeUnknownFields(e,t){let r=e[bt];if(r)for(let n of r)t.tag(n.no,n.wireType).raw(n.data)},onUnknownField(e,t,r,n){let o=e;Array.isArray(o[bt])||(o[bt]=[]),o[bt].push({no:t,wireType:r,data:n})},readMessage(e,t,r,n,o){let a=e.getType(),i=o?t.len:t.pos+r,s,l;for(;t.pos<i&&([s,l]=t.tag(),!(o===!0&&l==ee.EndGroup));){let c=a.fields.find(s);if(!c){let d=t.skip(l,s);n.readUnknownFields&&this.onUnknownField(e,s,l,d);continue}Po(e,t,c,l,n)}if(o&&(l!=ee.EndGroup||s!==r))throw Error("invalid end group tag")},readField:Po,writeMessage(e,t,r){let n=e.getType();for(let o of n.fields.byNumber()){if(!Io(o,e)){if(o.req)throw Error(`cannot encode field ${n.typeName}.${o.name} to binary: required field not set`);continue}let a=o.oneof?e[o.oneof.localName].value:e[o.localName];jo(o,a,t,r)}return r.writeUnknownFields&&this.writeUnknownFields(e,t),t},writeField(e,t,r,n){t!==void 0&&jo(e,t,r,n)}}}function Po(e,t,r,n,o){let{repeated:a,localName:i}=r;switch(r.oneof&&(e=e[r.oneof.localName],e.case!=i&&delete e.value,e.case=i,i="value"),r.kind){case"scalar":case"enum":let s=r.kind=="enum"?v.INT32:r.T,l=fr;if(r.kind=="scalar"&&r.L>0&&(l=Fl),a){let h=e[i];if(n==ee.LengthDelimited&&s!=v.STRING&&s!=v.BYTES){let m=t.uint32()+t.pos;for(;t.pos<m;)h.push(l(t,s))}else h.push(l(t,s))}else e[i]=l(t,s);break;case"message":let c=r.T;a?e[i].push(dr(t,new c,o,r)):Ke(e[i])?dr(t,e[i],o,r):(e[i]=dr(t,new c,o,r),c.fieldWrapper&&!r.oneof&&!r.repeated&&(e[i]=c.fieldWrapper.unwrapField(e[i])));break;case"map":let[d,f]=Il(r,t,o);e[i][d]=f;break}}function dr(e,t,r,n){let o=t.getType().runtime.bin,a=n==null?void 0:n.delimited;return o.readMessage(t,e,a?n.no:e.uint32(),r,a),t}function Il(e,t,r){let n=t.uint32(),o=t.pos+n,a,i;for(;t.pos<o;){let[s]=t.tag();switch(s){case 1:a=fr(t,e.K);break;case 2:switch(e.V.kind){case"scalar":i=fr(t,e.V.T);break;case"enum":i=t.int32();break;case"message":i=dr(t,new e.V.T,r,void 0);break}break}}if(a===void 0&&(a=pt(e.K,it.BIGINT)),typeof a!="string"&&typeof a!="number"&&(a=a.toString()),i===void 0)switch(e.V.kind){case"scalar":i=pt(e.V.T,it.BIGINT);break;case"enum":i=e.V.T.values[0].no;break;case"message":i=new e.V.T;break}return[a,i]}function Fl(e,t){let r=fr(e,t);return typeof r=="bigint"?r.toString():r}function fr(e,t){switch(t){case v.STRING:return e.string();case v.BOOL:return e.bool();case v.DOUBLE:return e.double();case v.FLOAT:return e.float();case v.INT32:return e.int32();case v.INT64:return e.int64();case v.UINT64:return e.uint64();case v.FIXED64:return e.fixed64();case v.BYTES:return e.bytes();case v.FIXED32:return e.fixed32();case v.SFIXED32:return e.sfixed32();case v.SFIXED64:return e.sfixed64();case v.SINT64:return e.sint64();case v.UINT32:return e.uint32();case v.SINT32:return e.sint32()}}function jo(e,t,r,n){K(t!==void 0);let o=e.repeated;switch(e.kind){case"scalar":case"enum":let a=e.kind=="enum"?v.INT32:e.T;if(o)if(K(Array.isArray(t)),e.packed)Ol(r,a,e.no,t);else for(let i of t)Dt(r,a,e.no,i);else Dt(r,a,e.no,t);break;case"message":if(o){K(Array.isArray(t));for(let i of t)Ro(r,n,e,i)}else Ro(r,n,e,t);break;case"map":K(typeof t=="object"&&!!t);for(let[i,s]of Object.entries(t))Ll(r,n,e,i,s);break}}function Ll(e,t,r,n,o){e.tag(r.no,ee.LengthDelimited),e.fork();let a=n;switch(r.K){case v.INT32:case v.FIXED32:case v.UINT32:case v.SFIXED32:case v.SINT32:a=Number.parseInt(n);break;case v.BOOL:K(n=="true"||n=="false"),a=n=="true";break}switch(Dt(e,r.K,1,a),r.V.kind){case"scalar":Dt(e,r.V.T,2,o);break;case"enum":Dt(e,v.INT32,2,o);break;case"message":K(o!==void 0),e.tag(2,ee.LengthDelimited).bytes(o.toBinary(t));break}e.join()}function Ro(e,t,r,n){let o=Lo(r.T,n);r.delimited?e.tag(r.no,ee.StartGroup).raw(o.toBinary(t)).tag(r.no,ee.EndGroup):e.tag(r.no,ee.LengthDelimited).bytes(o.toBinary(t))}function Dt(e,t,r,n){K(n!==void 0);let[o,a]=Go(t);e.tag(r,o)[a](n)}function Ol(e,t,r,n){if(!n.length)return;e.tag(r,ee.LengthDelimited).fork();let[,o]=Go(t);for(let a=0;a<n.length;a++)e[o](n[a]);e.join()}function Go(e){let t=ee.Varint;switch(e){case v.BYTES:case v.STRING:t=ee.LengthDelimited;break;case v.DOUBLE:case v.FIXED64:case v.SFIXED64:t=ee.Bit64;break;case v.FIXED32:case v.SFIXED32:case v.FLOAT:t=ee.Bit32;break}let r=v[e].toLowerCase();return[t,r]}function Bl(){return{setEnumType:bo,initPartial(e,t){if(e===void 0)return;let r=t.getType();for(let n of r.fields.byMember()){let o=n.localName,a=t,i=e;if(i[o]!=null)switch(n.kind){case"oneof":let s=i[o].case;if(s===void 0)continue;let l=n.findField(s),c=i[o].value;l&&l.kind=="message"&&!Ke(c,l.T)?c=new l.T(c):l&&l.kind==="scalar"&&l.T===v.BYTES&&(c=Ut(c)),a[o]={case:s,value:c};break;case"scalar":case"enum":let d=i[o];n.T===v.BYTES&&(d=n.repeated?d.map(Ut):Ut(d)),a[o]=d;break;case"map":switch(n.V.kind){case"scalar":case"enum":if(n.V.T===v.BYTES)for(let[m,g]of Object.entries(i[o]))a[o][m]=Ut(g);else Object.assign(a[o],i[o]);break;case"message":let h=n.V.T;for(let m of Object.keys(i[o])){let g=i[o][m];h.fieldWrapper||(g=new h(g)),a[o][m]=g}break}break;case"message":let f=n.T;if(n.repeated)a[o]=i[o].map(h=>Ke(h,f)?h:new f(h));else{let h=i[o];f.fieldWrapper?f.typeName==="google.protobuf.BytesValue"?a[o]=Ut(h):a[o]=h:a[o]=Ke(h,f)?h:new f(h)}break}}},equals(e,t,r){return t===r?!0:!t||!r?!1:e.fields.byMember().every(n=>{let o=t[n.localName],a=r[n.localName];if(n.repeated){if(o.length!==a.length)return!1;switch(n.kind){case"message":return o.every((i,s)=>n.T.equals(i,a[s]));case"scalar":return o.every((i,s)=>rt(n.T,i,a[s]));case"enum":return o.every((i,s)=>rt(v.INT32,i,a[s]))}throw Error(`repeated cannot contain ${n.kind}`)}switch(n.kind){case"message":let i=o,s=a;return n.T.fieldWrapper&&(i!==void 0&&!Ke(i)&&(i=n.T.fieldWrapper.wrapField(i)),s!==void 0&&!Ke(s)&&(s=n.T.fieldWrapper.wrapField(s))),n.T.equals(i,s);case"enum":return rt(v.INT32,o,a);case"scalar":return rt(n.T,o,a);case"oneof":if(o.case!==a.case)return!1;let l=n.findField(o.case);if(l===void 0)return!0;switch(l.kind){case"message":return l.T.equals(o.value,a.value);case"enum":return rt(v.INT32,o.value,a.value);case"scalar":return rt(l.T,o.value,a.value)}throw Error(`oneof cannot contain ${l.kind}`);case"map":let c=Object.keys(o).concat(Object.keys(a));switch(n.V.kind){case"message":let d=n.V.T;return c.every(h=>d.equals(o[h],a[h]));case"enum":return c.every(h=>rt(v.INT32,o[h],a[h]));case"scalar":let f=n.V.T;return c.every(h=>rt(f,o[h],a[h]))}break}})},clone(e){let t=e.getType(),r=new t,n=r;for(let o of t.fields.byMember()){let a=e[o.localName],i;if(o.repeated)i=a.map(mr);else if(o.kind=="map"){i=n[o.localName];for(let[s,l]of Object.entries(a))i[s]=mr(l)}else i=o.kind=="oneof"?o.findField(a.case)?{case:a.case,value:mr(a.value)}:{case:void 0}:mr(a);n[o.localName]=i}for(let o of t.runtime.bin.listUnknownFields(e))t.runtime.bin.onUnknownField(n,o.no,o.wireType,o.data);return r}}}function mr(e){if(e===void 0)return e;if(Ke(e))return e.clone();if(e instanceof Uint8Array){let t=new Uint8Array(e.byteLength);return t.set(e),t}return e}function Ut(e){return e instanceof Uint8Array?e:new Uint8Array(e)}function Dl(e,t,r){return{syntax:e,json:Al(),bin:Tl(),util:Object.assign(Object.assign({},Bl()),{newFieldList:t,initFields:r}),makeMessageType(n,o,a){return ll(this,n,o,a)},makeEnum:sl,makeEnumType:yo,getEnumType:il,makeExtension(n,o,a){return pl(this,n,o,a)}}}var Ul=class{constructor(e,t){this._fields=e,this._normalizer=t}findJsonName(e){if(!this.jsonNames){let t={};for(let r of this.list())t[r.jsonName]=t[r.name]=r;this.jsonNames=t}return this.jsonNames[e]}find(e){if(!this.numbers){let t={};for(let r of this.list())t[r.no]=r;this.numbers=t}return this.numbers[e]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort((e,t)=>e.no-t.no)),this.numbersAsc}byMember(){if(!this.members){this.members=[];let e=this.members,t;for(let r of this.list())r.oneof?r.oneof!==t&&(t=r.oneof,e.push(t)):e.push(r)}return this.members}};function Jo(e,t){let r=Vo(e);return t?r:Gl(Rl(r))}function _l(e){return Jo(e,!1)}const Ml=Vo;function Vo(e){let t=!1,r=[];for(let n=0;n<e.length;n++){let o=e.charAt(n);switch(o){case"_":t=!0;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":r.push(o),t=!1;break;default:t&&(t=!1,o=o.toUpperCase()),r.push(o);break}}return r.join("")}var Pl=new Set(["constructor","toString","toJSON","valueOf"]),jl=new Set(["getType","clone","equals","fromBinary","fromJson","fromJsonString","toBinary","toJson","toJsonString","toObject"]),Wo=e=>`${e}$`,Rl=e=>jl.has(e)?Wo(e):e;const Gl=e=>Pl.has(e)?Wo(e):e;var Jl=class{constructor(e){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=e,this.localName=_l(e)}addField(e){K(e.oneof===this,`field ${e.name} not one of ${this.name}`),this.fields.push(e)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let t=0;t<this.fields.length;t++)this._lookup[this.fields[t].localName]=this.fields[t]}return this._lookup[e]}};function Vl(e,t){let r=[],n;for(let o of typeof e=="function"?e():e){let a=o;if(a.localName=Jo(o.name,o.oneof!==void 0),a.jsonName=o.jsonName??Ml(o.name),a.repeated=o.repeated??!1,o.kind=="scalar"&&(a.L=o.L??it.BIGINT),a.delimited=o.delimited??!1,a.req=o.req??!1,a.opt=o.opt??!1,o.packed===void 0&&(t?a.packed=o.kind=="enum"||o.kind=="scalar"&&o.T!=v.BYTES&&o.T!=v.STRING:a.packed=!1),o.oneof!==void 0){let i=typeof o.oneof=="string"?o.oneof:o.oneof.name;(!n||n.name!=i)&&(n=new Jl(i)),a.oneof=n,n.addField(a)}r.push(a)}return r}const A=Dl("proto3",e=>new Ul(e,t=>Vl(t,!0)),e=>{for(let t of e.getType().fields.byMember()){if(t.opt)continue;let r=t.localName,n=e;if(t.repeated){n[r]=[];continue}switch(t.kind){case"oneof":n[r]={case:void 0};break;case"enum":n[r]=0;break;case"map":n[r]={};break;case"scalar":n[r]=pt(t.T,t.L);break;case"message":break}}});var ke;(function(e){e[e.Unary=0]="Unary",e[e.ServerStreaming=1]="ServerStreaming",e[e.ClientStreaming=2]="ClientStreaming",e[e.BiDiStreaming=3]="BiDiStreaming"})(ke||(ke={}));var $o;(function(e){e[e.NoSideEffects=1]="NoSideEffects",e[e.Idempotent=2]="Idempotent"})($o||($o={}));var dn;(function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.JUPYTER_FORMAT=77]="JUPYTER_FORMAT"})(dn||(dn={})),A.util.setEnumType(dn,"exa.codeium_common_pb.ExperimentKey",[{no:0,name:"UNSPECIFIED"},{no:77,name:"JUPYTER_FORMAT"}]);var hr;(function(e){e[e.CODEIUM=0]="CODEIUM"})(hr||(hr={})),A.util.setEnumType(hr,"exa.codeium_common_pb.AuthSource",[{no:0,name:"AUTH_SOURCE_CODEIUM"}]);var gr;(function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.ENABLE_CODEIUM=1]="ENABLE_CODEIUM",e[e.DISABLE_CODEIUM=2]="DISABLE_CODEIUM",e[e.SHOW_PREVIOUS_COMPLETION=3]="SHOW_PREVIOUS_COMPLETION",e[e.SHOW_NEXT_COMPLETION=4]="SHOW_NEXT_COMPLETION"})(gr||(gr={})),A.util.setEnumType(gr,"exa.codeium_common_pb.EventType",[{no:0,name:"EVENT_TYPE_UNSPECIFIED"},{no:1,name:"EVENT_TYPE_ENABLE_CODEIUM"},{no:2,name:"EVENT_TYPE_DISABLE_CODEIUM"},{no:3,name:"EVENT_TYPE_SHOW_PREVIOUS_COMPLETION"},{no:4,name:"EVENT_TYPE_SHOW_NEXT_COMPLETION"}]);var pr;(function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.TYPING_AS_SUGGESTED=1]="TYPING_AS_SUGGESTED",e[e.CACHE=2]="CACHE",e[e.NETWORK=3]="NETWORK"})(pr||(pr={})),A.util.setEnumType(pr,"exa.codeium_common_pb.CompletionSource",[{no:0,name:"COMPLETION_SOURCE_UNSPECIFIED"},{no:1,name:"COMPLETION_SOURCE_TYPING_AS_SUGGESTED"},{no:2,name:"COMPLETION_SOURCE_CACHE"},{no:3,name:"COMPLETION_SOURCE_NETWORK"}]);var st;(function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.C=1]="C",e[e.CLOJURE=2]="CLOJURE",e[e.COFFEESCRIPT=3]="COFFEESCRIPT",e[e.CPP=4]="CPP",e[e.CSHARP=5]="CSHARP",e[e.CSS=6]="CSS",e[e.CUDACPP=7]="CUDACPP",e[e.DOCKERFILE=8]="DOCKERFILE",e[e.GO=9]="GO",e[e.GROOVY=10]="GROOVY",e[e.HANDLEBARS=11]="HANDLEBARS",e[e.HASKELL=12]="HASKELL",e[e.HCL=13]="HCL",e[e.HTML=14]="HTML",e[e.INI=15]="INI",e[e.JAVA=16]="JAVA",e[e.JAVASCRIPT=17]="JAVASCRIPT",e[e.JSON=18]="JSON",e[e.JULIA=19]="JULIA",e[e.KOTLIN=20]="KOTLIN",e[e.LATEX=21]="LATEX",e[e.LESS=22]="LESS",e[e.LUA=23]="LUA",e[e.MAKEFILE=24]="MAKEFILE",e[e.MARKDOWN=25]="MARKDOWN",e[e.OBJECTIVEC=26]="OBJECTIVEC",e[e.OBJECTIVECPP=27]="OBJECTIVECPP",e[e.PERL=28]="PERL",e[e.PHP=29]="PHP",e[e.PLAINTEXT=30]="PLAINTEXT",e[e.PROTOBUF=31]="PROTOBUF",e[e.PBTXT=32]="PBTXT",e[e.PYTHON=33]="PYTHON",e[e.R=34]="R",e[e.RUBY=35]="RUBY",e[e.RUST=36]="RUST",e[e.SASS=37]="SASS",e[e.SCALA=38]="SCALA",e[e.SCSS=39]="SCSS",e[e.SHELL=40]="SHELL",e[e.SQL=41]="SQL",e[e.STARLARK=42]="STARLARK",e[e.SWIFT=43]="SWIFT",e[e.TSX=44]="TSX",e[e.TYPESCRIPT=45]="TYPESCRIPT",e[e.VISUALBASIC=46]="VISUALBASIC",e[e.VUE=47]="VUE",e[e.XML=48]="XML",e[e.XSL=49]="XSL",e[e.YAML=50]="YAML",e[e.SVELTE=51]="SVELTE",e[e.TOML=52]="TOML",e[e.DART=53]="DART",e[e.RST=54]="RST",e[e.OCAML=55]="OCAML",e[e.CMAKE=56]="CMAKE",e[e.PASCAL=57]="PASCAL",e[e.ELIXIR=58]="ELIXIR",e[e.FSHARP=59]="FSHARP",e[e.LISP=60]="LISP",e[e.MATLAB=61]="MATLAB",e[e.POWERSHELL=62]="POWERSHELL",e[e.SOLIDITY=63]="SOLIDITY",e[e.ADA=64]="ADA",e[e.OCAML_INTERFACE=65]="OCAML_INTERFACE"})(st||(st={})),A.util.setEnumType(st,"exa.codeium_common_pb.Language",[{no:0,name:"LANGUAGE_UNSPECIFIED"},{no:1,name:"LANGUAGE_C"},{no:2,name:"LANGUAGE_CLOJURE"},{no:3,name:"LANGUAGE_COFFEESCRIPT"},{no:4,name:"LANGUAGE_CPP"},{no:5,name:"LANGUAGE_CSHARP"},{no:6,name:"LANGUAGE_CSS"},{no:7,name:"LANGUAGE_CUDACPP"},{no:8,name:"LANGUAGE_DOCKERFILE"},{no:9,name:"LANGUAGE_GO"},{no:10,name:"LANGUAGE_GROOVY"},{no:11,name:"LANGUAGE_HANDLEBARS"},{no:12,name:"LANGUAGE_HASKELL"},{no:13,name:"LANGUAGE_HCL"},{no:14,name:"LANGUAGE_HTML"},{no:15,name:"LANGUAGE_INI"},{no:16,name:"LANGUAGE_JAVA"},{no:17,name:"LANGUAGE_JAVASCRIPT"},{no:18,name:"LANGUAGE_JSON"},{no:19,name:"LANGUAGE_JULIA"},{no:20,name:"LANGUAGE_KOTLIN"},{no:21,name:"LANGUAGE_LATEX"},{no:22,name:"LANGUAGE_LESS"},{no:23,name:"LANGUAGE_LUA"},{no:24,name:"LANGUAGE_MAKEFILE"},{no:25,name:"LANGUAGE_MARKDOWN"},{no:26,name:"LANGUAGE_OBJECTIVEC"},{no:27,name:"LANGUAGE_OBJECTIVECPP"},{no:28,name:"LANGUAGE_PERL"},{no:29,name:"LANGUAGE_PHP"},{no:30,name:"LANGUAGE_PLAINTEXT"},{no:31,name:"LANGUAGE_PROTOBUF"},{no:32,name:"LANGUAGE_PBTXT"},{no:33,name:"LANGUAGE_PYTHON"},{no:34,name:"LANGUAGE_R"},{no:35,name:"LANGUAGE_RUBY"},{no:36,name:"LANGUAGE_RUST"},{no:37,name:"LANGUAGE_SASS"},{no:38,name:"LANGUAGE_SCALA"},{no:39,name:"LANGUAGE_SCSS"},{no:40,name:"LANGUAGE_SHELL"},{no:41,name:"LANGUAGE_SQL"},{no:42,name:"LANGUAGE_STARLARK"},{no:43,name:"LANGUAGE_SWIFT"},{no:44,name:"LANGUAGE_TSX"},{no:45,name:"LANGUAGE_TYPESCRIPT"},{no:46,name:"LANGUAGE_VISUALBASIC"},{no:47,name:"LANGUAGE_VUE"},{no:48,name:"LANGUAGE_XML"},{no:49,name:"LANGUAGE_XSL"},{no:50,name:"LANGUAGE_YAML"},{no:51,name:"LANGUAGE_SVELTE"},{no:52,name:"LANGUAGE_TOML"},{no:53,name:"LANGUAGE_DART"},{no:54,name:"LANGUAGE_RST"},{no:55,name:"LANGUAGE_OCAML"},{no:56,name:"LANGUAGE_CMAKE"},{no:57,name:"LANGUAGE_PASCAL"},{no:58,name:"LANGUAGE_ELIXIR"},{no:59,name:"LANGUAGE_FSHARP"},{no:60,name:"LANGUAGE_LISP"},{no:61,name:"LANGUAGE_MATLAB"},{no:62,name:"LANGUAGE_POWERSHELL"},{no:63,name:"LANGUAGE_SOLIDITY"},{no:64,name:"LANGUAGE_ADA"},{no:65,name:"LANGUAGE_OCAML_INTERFACE"}]);var Wl=(Ae=class extends Q{constructor(r){super();p(this,"completionId","");p(this,"text","");p(this,"prefix","");p(this,"stop","");p(this,"score",0);p(this,"tokens",[]);p(this,"decodedTokens",[]);p(this,"probabilities",[]);p(this,"adjustedProbabilities",[]);p(this,"generatedLength",W.zero);A.util.initPartial(r,this)}static fromBinary(r,n){return new Ae().fromBinary(r,n)}static fromJson(r,n){return new Ae().fromJson(r,n)}static fromJsonString(r,n){return new Ae().fromJsonString(r,n)}static equals(r,n){return A.util.equals(Ae,r,n)}},p(Ae,"runtime",A),p(Ae,"typeName","exa.codeium_common_pb.Completion"),p(Ae,"fields",A.util.newFieldList(()=>[{no:1,name:"completion_id",kind:"scalar",T:9},{no:2,name:"text",kind:"scalar",T:9},{no:3,name:"prefix",kind:"scalar",T:9},{no:4,name:"stop",kind:"scalar",T:9},{no:5,name:"score",kind:"scalar",T:1},{no:6,name:"tokens",kind:"scalar",T:4,repeated:!0},{no:7,name:"decoded_tokens",kind:"scalar",T:9,repeated:!0},{no:8,name:"probabilities",kind:"scalar",T:1,repeated:!0},{no:9,name:"adjusted_probabilities",kind:"scalar",T:1,repeated:!0},{no:10,name:"generated_length",kind:"scalar",T:4}])),Ae),Ho=(Ce=class extends Q{constructor(r){super();p(this,"ideName","");p(this,"ideVersion","");p(this,"extensionName","");p(this,"extensionVersion","");p(this,"apiKey","");p(this,"locale","");p(this,"sessionId","");p(this,"requestId",W.zero);p(this,"userAgent","");p(this,"url","");p(this,"authSource",hr.CODEIUM);A.util.initPartial(r,this)}static fromBinary(r,n){return new Ce().fromBinary(r,n)}static fromJson(r,n){return new Ce().fromJson(r,n)}static fromJsonString(r,n){return new Ce().fromJsonString(r,n)}static equals(r,n){return A.util.equals(Ce,r,n)}},p(Ce,"runtime",A),p(Ce,"typeName","exa.codeium_common_pb.Metadata"),p(Ce,"fields",A.util.newFieldList(()=>[{no:1,name:"ide_name",kind:"scalar",T:9},{no:7,name:"ide_version",kind:"scalar",T:9},{no:12,name:"extension_name",kind:"scalar",T:9},{no:2,name:"extension_version",kind:"scalar",T:9},{no:3,name:"api_key",kind:"scalar",T:9},{no:4,name:"locale",kind:"scalar",T:9},{no:10,name:"session_id",kind:"scalar",T:9},{no:9,name:"request_id",kind:"scalar",T:4},{no:13,name:"user_agent",kind:"scalar",T:9},{no:14,name:"url",kind:"scalar",T:9},{no:15,name:"auth_source",kind:"enum",T:A.getEnumType(hr)}])),Ce),$l=(Ne=class extends Q{constructor(r){super();p(this,"tabSize",W.zero);p(this,"insertSpaces",!1);A.util.initPartial(r,this)}static fromBinary(r,n){return new Ne().fromBinary(r,n)}static fromJson(r,n){return new Ne().fromJson(r,n)}static fromJsonString(r,n){return new Ne().fromJsonString(r,n)}static equals(r,n){return A.util.equals(Ne,r,n)}},p(Ne,"runtime",A),p(Ne,"typeName","exa.codeium_common_pb.EditorOptions"),p(Ne,"fields",A.util.newFieldList(()=>[{no:1,name:"tab_size",kind:"scalar",T:4},{no:2,name:"insert_spaces",kind:"scalar",T:8}])),Ne);xe=class extends Q{constructor(r){super();p(this,"eventType",gr.UNSPECIFIED);p(this,"eventJson","");p(this,"timestampUnixMs",W.zero);A.util.initPartial(r,this)}static fromBinary(r,n){return new xe().fromBinary(r,n)}static fromJson(r,n){return new xe().fromJson(r,n)}static fromJsonString(r,n){return new xe().fromJsonString(r,n)}static equals(r,n){return A.util.equals(xe,r,n)}},p(xe,"runtime",A),p(xe,"typeName","exa.codeium_common_pb.Event"),p(xe,"fields",A.util.newFieldList(()=>[{no:1,name:"event_type",kind:"enum",T:A.getEnumType(gr)},{no:2,name:"event_json",kind:"scalar",T:9},{no:3,name:"timestamp_unix_ms",kind:"scalar",T:3}]));var Hl=class extends Nt{constructor(t,r){super();p(this,"index");p(this,"total");this.index=t,this.total=r}toDOM(){let t=document.createElement("span");t.setAttribute("aria-hidden","true"),t.className="cm-codeium-cycle";let r=t.appendChild(document.createElement("span"));r.className="cm-codeium-cycle-explanation",r.innerText=`${this.index+1}/${this.total}`;let n=t.appendChild(document.createElement("button"));return n.className="cm-codeium-cycle-key",n.innerText="\u2192 (Ctrl ])",n.dataset.action="codeium-cycle",t}ignoreEvent(){return!1}};const br=dt.define({combine(e){return Vr(e,{language:st.TYPESCRIPT,timeout:150,widgetClass:Hl,alwaysOn:!0},{})}}),qo=dt.define({combine(e){return Vr(e,{override:()=>[]},{})}});var ql=_.mark({class:"cm-ghostText"});const lt=ve.define({create(e){return null},update(e,t){var n;let r=t.state.facet(br);for(let o of t.effects){if(o.is(rn)){let{changeSpecs:a,index:i}=o.value,s=a[i].map(d=>ql.range(d.absoluteStartPos,d.absoluteEndPos)),l=(n=s.at(-1))==null?void 0:n.to,c=_.set([...s,...l!==void 0&&a.length>1&&r.widgetClass?[_.widget({widget:new r.widgetClass(i,a.length),side:1}).range(l)]:[]]);return{index:i,decorations:c,changeSpecs:a,reverseChangeSet:o.value.reverseChangeSet}}if(o.is(nn)||o.is(on))return null}return e&&{...e,decorations:e.decorations.map(t.changes),reverseChangeSet:e.reverseChangeSet.map(t.changes)}},provide:e=>O.decorations.from(e,t=>(t==null?void 0:t.decorations)||_.none)}),yt=Wr.define(),yr=Wr.define();var J;(function(e){e[e.Canceled=1]="Canceled",e[e.Unknown=2]="Unknown",e[e.InvalidArgument=3]="InvalidArgument",e[e.DeadlineExceeded=4]="DeadlineExceeded",e[e.NotFound=5]="NotFound",e[e.AlreadyExists=6]="AlreadyExists",e[e.PermissionDenied=7]="PermissionDenied",e[e.ResourceExhausted=8]="ResourceExhausted",e[e.FailedPrecondition=9]="FailedPrecondition",e[e.Aborted=10]="Aborted",e[e.OutOfRange=11]="OutOfRange",e[e.Unimplemented=12]="Unimplemented",e[e.Internal=13]="Internal",e[e.Unavailable=14]="Unavailable",e[e.DataLoss=15]="DataLoss",e[e.Unauthenticated=16]="Unauthenticated"})(J||(J={}));function fn(e){let t=J[e];return typeof t=="string"?t[0].toLowerCase()+t.substring(1).replace(/[A-Z]/g,r=>"_"+r.toLowerCase()):e.toString()}var wr;function zl(e){if(!wr){wr={};for(let t of Object.values(J))typeof t!="string"&&(wr[fn(t)]=t)}return wr[e]}var pe=class Tt extends Error{constructor(t,r=J.Unknown,n,o,a){super(Kl(t,r)),this.name="ConnectError",Object.setPrototypeOf(this,new.target.prototype),this.rawMessage=t,this.code=r,this.metadata=new Headers(n??{}),this.details=o??[],this.cause=a}static from(t,r=J.Unknown){return t instanceof Tt?t:t instanceof Error?t.name=="AbortError"?new Tt(t.message,J.Canceled):new Tt(t.message,r,void 0,void 0,t):new Tt(String(t),r,void 0,void 0,t)}static[Symbol.hasInstance](t){return t instanceof Error?Object.getPrototypeOf(t)===Tt.prototype?!0:t.name==="ConnectError"&&"code"in t&&typeof t.code=="number"&&"metadata"in t&&"details"in t&&Array.isArray(t.details)&&"rawMessage"in t&&typeof t.rawMessage=="string"&&"cause"in t:!1}findDetails(t){let r="typeName"in t?{findMessage:o=>o===t.typeName?t:void 0}:t,n=[];for(let o of this.details){if("getType"in o){r.findMessage(o.getType().typeName)&&n.push(o);continue}let a=r.findMessage(o.type);if(a)try{n.push(a.fromBinary(o.value))}catch{}}return n}};function Kl(e,t){return e.length?`[${fn(t)}] ${e}`:`[${fn(t)}]`}function Yl(...e){let t=new Headers;for(let r of e)r.forEach((n,o)=>{t.append(o,n)});return t}function Xl(e,t){let r={};for(let[n,o]of Object.entries(e.methods)){let a=t(Object.assign(Object.assign({},o),{localName:n,service:e}));a!=null&&(r[n]=a)}return r}function Ql(e){let t,r=new Uint8Array;function n(o){let a=new Uint8Array(r.length+o.length);a.set(r),a.set(o,r.length),r=a}return new ReadableStream({start(){t=e.getReader()},async pull(o){let a;for(;;){if(a===void 0&&r.byteLength>=5){let l=0;for(let c=1;c<5;c++)l=(l<<8)+r[c];a={flags:r[0],length:l}}if(a!==void 0&&r.byteLength>=a.length+5)break;let s=await t.read();if(s.done)break;n(s.value)}if(a===void 0){if(r.byteLength==0){o.close();return}o.error(new pe("premature end of stream",J.DataLoss));return}let i=r.subarray(5,5+a.length);r=r.subarray(5+a.length),o.enqueue({flags:a.flags,data:i})}})}function Zl(e,t){let r=new Uint8Array(t.length+5);r.set(t,5);let n=new DataView(r.buffer,r.byteOffset,r.byteLength);return n.setUint8(0,e),n.setUint32(1,t.length),r}var ec=function(e){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof __values=="function"?__values(e):e[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(a){r[a]=e[a]&&function(i){return new Promise(function(s,l){i=e[a](i),o(s,l,i.done,i.value)})}}function o(a,i,s,l){Promise.resolve(l).then(function(c){a({value:c,done:s})},i)}},_t=function(e){return this instanceof _t?(this.v=e,this):new _t(e)},tc=function(e,t,r){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(e,t||[]),o,a=[];return o={},s("next"),s("throw"),s("return",i),o[Symbol.asyncIterator]=function(){return this},o;function i(m){return function(g){return Promise.resolve(g).then(m,f)}}function s(m,g){n[m]&&(o[m]=function(b){return new Promise(function(y,E){a.push([m,b,y,E])>1||l(m,b)})},g&&(o[m]=g(o[m])))}function l(m,g){try{c(n[m](g))}catch(b){h(a[0][3],b)}}function c(m){m.value instanceof _t?Promise.resolve(m.value.v).then(d,f):h(a[0][2],m)}function d(m){l("next",m)}function f(m){l("throw",m)}function h(m,g){m(g),a.shift(),a.length&&l(a[0][0],a[0][1])}},rc=function(e){var t,r;return t={},n("next"),n("throw",function(o){throw o}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(o,a){t[o]=e[o]?function(i){return(r=!r)?{value:_t(e[o](i)),done:!1}:a?a(i):i}:a}};function nc(e){return tc(this,arguments,function*(){yield _t(yield*rc(ec(e)))})}var zo=function(e){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof __values=="function"?__values(e):e[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(a){r[a]=e[a]&&function(i){return new Promise(function(s,l){i=e[a](i),o(s,l,i.done,i.value)})}}function o(a,i,s,l){Promise.resolve(l).then(function(c){a({value:c,done:s})},i)}},wt=function(e){return this instanceof wt?(this.v=e,this):new wt(e)},oc=function(e){var t,r;return t={},n("next"),n("throw",function(o){throw o}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(o,a){t[o]=e[o]?function(i){return(r=!r)?{value:wt(e[o](i)),done:!1}:a?a(i):i}:a}},ac=function(e,t,r){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(e,t||[]),o,a=[];return o={},s("next"),s("throw"),s("return",i),o[Symbol.asyncIterator]=function(){return this},o;function i(m){return function(g){return Promise.resolve(g).then(m,f)}}function s(m,g){n[m]&&(o[m]=function(b){return new Promise(function(y,E){a.push([m,b,y,E])>1||l(m,b)})},g&&(o[m]=g(o[m])))}function l(m,g){try{c(n[m](g))}catch(b){h(a[0][3],b)}}function c(m){m.value instanceof wt?Promise.resolve(m.value.v).then(d,f):h(a[0][2],m)}function d(m){l("next",m)}function f(m){l("throw",m)}function h(m,g){m(g),a.shift(),a.length&&l(a[0][0],a[0][1])}};function ic(e,t){return Xl(e,r=>{switch(r.kind){case ke.Unary:return lc(t,e,r);case ke.ServerStreaming:return cc(t,e,r);case ke.ClientStreaming:return uc(t,e,r);case ke.BiDiStreaming:return dc(t,e,r);default:return null}})}function sc(e,t){return ic(e,t)}function lc(e,t,r){return async function(n,o){var a,i;let s=await e.unary(t,r,o==null?void 0:o.signal,o==null?void 0:o.timeoutMs,o==null?void 0:o.headers,n,o==null?void 0:o.contextValues);return(a=o==null?void 0:o.onHeader)==null||a.call(o,s.header),(i=o==null?void 0:o.onTrailer)==null||i.call(o,s.trailer),s.message}}function cc(e,t,r){return function(n,o){return Ko(e.stream(t,r,o==null?void 0:o.signal,o==null?void 0:o.timeoutMs,o==null?void 0:o.headers,nc([n]),o==null?void 0:o.contextValues),o)}}function uc(e,t,r){return async function(n,o){var a,i,s,l,c,d;let f=await e.stream(t,r,o==null?void 0:o.signal,o==null?void 0:o.timeoutMs,o==null?void 0:o.headers,n,o==null?void 0:o.contextValues);(c=o==null?void 0:o.onHeader)==null||c.call(o,f.header);let h,m=0;try{for(var g=!0,b=zo(f.message),y;y=await b.next(),a=y.done,!a;g=!0)l=y.value,g=!1,h=l,m++}catch(E){i={error:E}}finally{try{!g&&!a&&(s=b.return)&&await s.call(b)}finally{if(i)throw i.error}}if(!h)throw new pe("protocol error: missing response message",J.Unimplemented);if(m>1)throw new pe("protocol error: received extra messages for client streaming method",J.Unimplemented);return(d=o==null?void 0:o.onTrailer)==null||d.call(o,f.trailer),h}}function dc(e,t,r){return function(n,o){return Ko(e.stream(t,r,o==null?void 0:o.signal,o==null?void 0:o.timeoutMs,o==null?void 0:o.headers,n,o==null?void 0:o.contextValues),o)}}function Ko(e,t){let r=(function(){return ac(this,arguments,function*(){var n,o;let a=yield wt(e);(n=t==null?void 0:t.onHeader)==null||n.call(t,a.header),yield wt(yield*oc(zo(a.message))),(o=t==null?void 0:t.onTrailer)==null||o.call(t,a.trailer)})})()[Symbol.asyncIterator]();return{[Symbol.asyncIterator]:()=>({next:()=>r.next()})}}function fc(...e){let t=new AbortController,r=e.filter(o=>o!==void 0).concat(t.signal);for(let o of r){if(o.aborted){n.apply(o);break}o.addEventListener("abort",n)}function n(){t.signal.aborted||t.abort(Yo(this));for(let o of r)o.removeEventListener("abort",n)}return t}function mc(e){let t=new AbortController,r=()=>{t.abort(new pe("the operation timed out",J.DeadlineExceeded))},n;return e!==void 0&&(e<=0?r():n=setTimeout(r,e)),{signal:t.signal,cleanup:()=>clearTimeout(n)}}function Yo(e){if(!e.aborted)return;if(e.reason!==void 0)return e.reason;let t=Error("This operation was aborted");return t.name="AbortError",t}function Xo(){return{get(e){return e.id in this?this[e.id]:e.defaultValue},set(e,t){return this[e.id]=t,this},delete(e){return delete this[e.id],this}}}function Qo(e,t,r){let n=typeof t=="string"?t:t.typeName,o=typeof r=="string"?r:r.name;return e.toString().replace(/\/?$/,`/${n}/${o}`)}function Zo(e,t){return t instanceof e?t:new e(t)}function hc(e,t){function r(n){return n.done===!0?n:{done:n.done,value:Zo(e,n.value)}}return{[Symbol.asyncIterator](){let n=t[Symbol.asyncIterator](),o={next:()=>n.next().then(r)};return n.throw!==void 0&&(o.throw=a=>n.throw(a).then(r)),n.return!==void 0&&(o.return=a=>n.return(a).then(r)),o}}}function ea(e,t){return(t==null?void 0:t.concat().reverse().reduce((r,n)=>n(r),e))??e}function ta(e){let t=Object.assign({},e);return t.ignoreUnknownFields??(t.ignoreUnknownFields=!0),t}function ra(e,t,r,n){let o=t?na(e.I,n):oa(e.I,r);return{parse:(t?na(e.O,n):oa(e.O,r)).parse,serialize:o.serialize}}function na(e,t){return{parse(r){try{return e.fromBinary(r,t)}catch(n){let o=n instanceof Error?n.message:String(n);throw new pe(`parse binary: ${o}`,J.Internal)}},serialize(r){try{return r.toBinary(t)}catch(n){let o=n instanceof Error?n.message:String(n);throw new pe(`serialize binary: ${o}`,J.Internal)}}}}function oa(e,t){let r=(t==null?void 0:t.textEncoder)??new TextEncoder,n=(t==null?void 0:t.textDecoder)??new TextDecoder,o=ta(t);return{parse(a){try{let i=n.decode(a);return e.fromJsonString(i,o)}catch(i){throw pe.from(i,J.InvalidArgument)}},serialize(a){try{let i=a.toJsonString(o);return r.encode(i)}catch(i){throw pe.from(i,J.Internal)}}}}const gc=/^application\/(connect\+)?(?:(json)(?:; ?charset=utf-?8)?|(proto))$/i;function pc(e){let t=e==null?void 0:e.match(gc);if(!t)return;let r=!!t[1],n=!!t[3];return{stream:r,binary:n}}function aa(e,t,r){if(t&&new Headers(t).forEach((i,s)=>r.metadata.append(s,i)),typeof e!="object"||!e||Array.isArray(e))throw r;let n=r.code;"code"in e&&typeof e.code=="string"&&(n=zl(e.code)??n);let o=e.message;if(o!=null&&typeof o!="string")throw r;let a=new pe(o??"",n,t);if("details"in e&&Array.isArray(e.details))for(let i of e.details){if(typeof i!="object"||!i||Array.isArray(i)||typeof i.type!="string"||typeof i.value!="string")throw r;try{a.details.push({type:i.type,value:sr.dec(i.value),debug:i.debug})}catch{throw r}}return a}function bc(e){let t=new pe("invalid end stream",J.Unknown),r;try{r=JSON.parse(typeof e=="string"?e:new TextDecoder().decode(e))}catch{throw t}if(typeof r!="object"||!r||Array.isArray(r))throw t;let n=new Headers;if("metadata"in r){if(typeof r.metadata!="object"||r.metadata==null||Array.isArray(r.metadata))throw t;for(let[a,i]of Object.entries(r.metadata)){if(!Array.isArray(i)||i.some(s=>typeof s!="string"))throw t;for(let s of i)n.append(a,s)}}let o="error"in r&&r.error!=null?aa(r.error,n,t):void 0;return{metadata:n,error:o}}const vr="Content-Type",ia="Content-Encoding",sa="Connect-Protocol-Version";function yc(e){switch(e){case 400:return J.Internal;case 401:return J.Unauthenticated;case 403:return J.PermissionDenied;case 404:return J.Unimplemented;case 429:return J.Unavailable;case 502:return J.Unavailable;case 503:return J.Unavailable;case 504:return J.Unavailable;default:return J.Unknown}}function la(e){let t=new Headers,r=new Headers;return e.forEach((n,o)=>{o.toLowerCase().startsWith("trailer-")?r.append(o.substring(8),n):t.append(o,n)}),[t,r]}function ca(e,t,r,n,o){let a=new Headers(n??{});return r!==void 0&&a.set("Connect-Timeout-Ms",`${r}`),a.set(vr,e==ke.Unary?t?"application/proto":"application/json":t?"application/connect+proto":"application/connect+json"),a.set(sa,"1"),o&&a.set("User-Agent","connect-es/1.6.1"),a}function ua(e,t,r,n){let o=n.get(vr),a=pc(o);if(r!==200){let s=new pe(`HTTP ${r}`,yc(r),n);if(e==ke.Unary&&a&&!a.binary)return{isUnaryError:!0,unaryError:s};throw s}let i={binary:t,stream:e!==ke.Unary};if((a==null?void 0:a.binary)!==i.binary||a.stream!==i.stream)throw new pe(`unsupported content type ${o}`,a===void 0?J.Unknown:J.Internal,n);return{isUnaryError:!1}}var wc="application/";function vc(e,t){return t?sr.enc(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""):encodeURIComponent(new TextDecoder().decode(e))}function Ec(e,t,r){let n="?connect=v1",o=e.header.get(vr);(o==null?void 0:o.indexOf(wc))===0&&(n+="&encoding="+encodeURIComponent(o.slice(12)));let a=e.header.get(ia);a!==null&&a!=="identity"&&(n+="&compression="+encodeURIComponent(a),r=!0),r&&(n+="&base64=1"),n+="&message="+vc(t,r);let i=e.url+n,s=new Headers(e.header);return[sa,vr,"Content-Length",ia,"Accept-Encoding"].forEach(l=>s.delete(l)),Object.assign(Object.assign({},e),{init:Object.assign(Object.assign({},e.init),{method:"GET"}),url:i,header:s})}function kc(e){let t=ea(e.next,e.interceptors),[r,n,o]=da(e),a=Object.assign(Object.assign({},e.req),{message:Zo(e.req.method.I,e.req.message),signal:r});return t(a).then(i=>(o(),i),n)}function Ac(e){let t=ea(e.next,e.interceptors),[r,n,o]=da(e),a=Object.assign(Object.assign({},e.req),{message:hc(e.req.method.I,e.req.message),signal:r}),i=!1;return r.addEventListener("abort",function(){var s,l;let c=e.req.message[Symbol.asyncIterator]();i||(s=c.throw)==null||s.call(c,this.reason).catch(()=>{}),(l=c.return)==null||l.call(c).catch(()=>{})}),t(a).then(s=>Object.assign(Object.assign({},s),{message:{[Symbol.asyncIterator](){let l=s.message[Symbol.asyncIterator]();return{next(){return l.next().then(c=>(c.done==1&&(i=!0,o()),c),n)}}}}}),n)}function da(e){let{signal:t,cleanup:r}=mc(e.timeoutMs),n=fc(e.signal,t);return[n.signal,function(o){let a=pe.from(t.aborted?Yo(t):o);return n.abort(a),r(),Promise.reject(a)},function(){r(),n.abort()}]}var Er;(function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.INACTIVE=1]="INACTIVE",e[e.PROCESSING=2]="PROCESSING",e[e.SUCCESS=3]="SUCCESS",e[e.WARNING=4]="WARNING",e[e.ERROR=5]="ERROR"})(Er||(Er={})),A.util.setEnumType(Er,"exa.language_server_pb.CodeiumState",[{no:0,name:"CODEIUM_STATE_UNSPECIFIED"},{no:1,name:"CODEIUM_STATE_INACTIVE"},{no:2,name:"CODEIUM_STATE_PROCESSING"},{no:3,name:"CODEIUM_STATE_SUCCESS"},{no:4,name:"CODEIUM_STATE_WARNING"},{no:5,name:"CODEIUM_STATE_ERROR"}]);var fa;(function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.SINGLE=1]="SINGLE",e[e.MULTI=2]="MULTI"})(fa||(fa={})),A.util.setEnumType(fa,"exa.language_server_pb.LineType",[{no:0,name:"LINE_TYPE_UNSPECIFIED"},{no:1,name:"LINE_TYPE_SINGLE"},{no:2,name:"LINE_TYPE_MULTI"}]);var kr;(function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.INLINE=1]="INLINE",e[e.BLOCK=2]="BLOCK",e[e.INLINE_MASK=3]="INLINE_MASK"})(kr||(kr={})),A.util.setEnumType(kr,"exa.language_server_pb.CompletionPartType",[{no:0,name:"COMPLETION_PART_TYPE_UNSPECIFIED"},{no:1,name:"COMPLETION_PART_TYPE_INLINE"},{no:2,name:"COMPLETION_PART_TYPE_BLOCK"},{no:3,name:"COMPLETION_PART_TYPE_INLINE_MASK"}]);var Cc=(Se=class extends Q{constructor(r){super();p(this,"threshold",0);A.util.initPartial(r,this)}static fromBinary(r,n){return new Se().fromBinary(r,n)}static fromJson(r,n){return new Se().fromJson(r,n)}static fromJsonString(r,n){return new Se().fromJsonString(r,n)}static equals(r,n){return A.util.equals(Se,r,n)}},p(Se,"runtime",A),p(Se,"typeName","exa.language_server_pb.MultilineConfig"),p(Se,"fields",A.util.newFieldList(()=>[{no:1,name:"threshold",kind:"scalar",T:2}])),Se),Nc=(Te=class extends Q{constructor(r){super();p(this,"metadata");p(this,"document");p(this,"editorOptions");p(this,"otherDocuments",[]);p(this,"experimentConfig");p(this,"modelName","");p(this,"multilineConfig");A.util.initPartial(r,this)}static fromBinary(r,n){return new Te().fromBinary(r,n)}static fromJson(r,n){return new Te().fromJson(r,n)}static fromJsonString(r,n){return new Te().fromJsonString(r,n)}static equals(r,n){return A.util.equals(Te,r,n)}},p(Te,"runtime",A),p(Te,"typeName","exa.language_server_pb.GetCompletionsRequest"),p(Te,"fields",A.util.newFieldList(()=>[{no:1,name:"metadata",kind:"message",T:Ho},{no:2,name:"document",kind:"message",T:ma},{no:3,name:"editor_options",kind:"message",T:$l},{no:5,name:"other_documents",kind:"message",T:ma,repeated:!0},{no:7,name:"experiment_config",kind:"message",T:Lc},{no:10,name:"model_name",kind:"scalar",T:9},{no:13,name:"multiline_config",kind:"message",T:Cc}])),Te),xc=(Ie=class extends Q{constructor(r){super();p(this,"state");p(this,"completionItems",[]);A.util.initPartial(r,this)}static fromBinary(r,n){return new Ie().fromBinary(r,n)}static fromJson(r,n){return new Ie().fromJson(r,n)}static fromJsonString(r,n){return new Ie().fromJsonString(r,n)}static equals(r,n){return A.util.equals(Ie,r,n)}},p(Ie,"runtime",A),p(Ie,"typeName","exa.language_server_pb.GetCompletionsResponse"),p(Ie,"fields",A.util.newFieldList(()=>[{no:1,name:"state",kind:"message",T:Oc},{no:2,name:"completion_items",kind:"message",T:_c,repeated:!0}])),Ie),Sc=(Fe=class extends Q{constructor(r){super();p(this,"metadata");p(this,"completionId","");A.util.initPartial(r,this)}static fromBinary(r,n){return new Fe().fromBinary(r,n)}static fromJson(r,n){return new Fe().fromJson(r,n)}static fromJsonString(r,n){return new Fe().fromJsonString(r,n)}static equals(r,n){return A.util.equals(Fe,r,n)}},p(Fe,"runtime",A),p(Fe,"typeName","exa.language_server_pb.AcceptCompletionRequest"),p(Fe,"fields",A.util.newFieldList(()=>[{no:1,name:"metadata",kind:"message",T:Ho},{no:2,name:"completion_id",kind:"scalar",T:9}])),Fe),Tc=(Le=class extends Q{constructor(t){super(),A.util.initPartial(t,this)}static fromBinary(t,r){return new Le().fromBinary(t,r)}static fromJson(t,r){return new Le().fromJson(t,r)}static fromJsonString(t,r){return new Le().fromJsonString(t,r)}static equals(t,r){return A.util.equals(Le,t,r)}},p(Le,"runtime",A),p(Le,"typeName","exa.language_server_pb.AcceptCompletionResponse"),p(Le,"fields",A.util.newFieldList(()=>[])),Le),Ic=(Oe=class extends Q{constructor(t){super(),A.util.initPartial(t,this)}static fromBinary(t,r){return new Oe().fromBinary(t,r)}static fromJson(t,r){return new Oe().fromJson(t,r)}static fromJsonString(t,r){return new Oe().fromJsonString(t,r)}static equals(t,r){return A.util.equals(Oe,t,r)}},p(Oe,"runtime",A),p(Oe,"typeName","exa.language_server_pb.GetAuthTokenRequest"),p(Oe,"fields",A.util.newFieldList(()=>[])),Oe),Fc=(Be=class extends Q{constructor(r){super();p(this,"authToken","");p(this,"uuid","");A.util.initPartial(r,this)}static fromBinary(r,n){return new Be().fromBinary(r,n)}static fromJson(r,n){return new Be().fromJson(r,n)}static fromJsonString(r,n){return new Be().fromJsonString(r,n)}static equals(r,n){return A.util.equals(Be,r,n)}},p(Be,"runtime",A),p(Be,"typeName","exa.language_server_pb.GetAuthTokenResponse"),p(Be,"fields",A.util.newFieldList(()=>[{no:1,name:"auth_token",kind:"scalar",T:9},{no:2,name:"uuid",kind:"scalar",T:9}])),Be),mn=(De=class extends Q{constructor(r){super();p(this,"row",W.zero);p(this,"col",W.zero);A.util.initPartial(r,this)}static fromBinary(r,n){return new De().fromBinary(r,n)}static fromJson(r,n){return new De().fromJson(r,n)}static fromJsonString(r,n){return new De().fromJsonString(r,n)}static equals(r,n){return A.util.equals(De,r,n)}},p(De,"runtime",A),p(De,"typeName","exa.language_server_pb.DocumentPosition"),p(De,"fields",A.util.newFieldList(()=>[{no:1,name:"row",kind:"scalar",T:4},{no:2,name:"col",kind:"scalar",T:4}])),De),ma=(Ue=class extends Q{constructor(r){super();p(this,"absolutePath","");p(this,"relativePath","");p(this,"text","");p(this,"editorLanguage","");p(this,"language",st.UNSPECIFIED);p(this,"cursorOffset",W.zero);p(this,"cursorPosition");p(this,"lineEnding","");A.util.initPartial(r,this)}static fromBinary(r,n){return new Ue().fromBinary(r,n)}static fromJson(r,n){return new Ue().fromJson(r,n)}static fromJsonString(r,n){return new Ue().fromJsonString(r,n)}static equals(r,n){return A.util.equals(Ue,r,n)}},p(Ue,"runtime",A),p(Ue,"typeName","exa.language_server_pb.Document"),p(Ue,"fields",A.util.newFieldList(()=>[{no:1,name:"absolute_path",kind:"scalar",T:9},{no:2,name:"relative_path",kind:"scalar",T:9},{no:3,name:"text",kind:"scalar",T:9},{no:4,name:"editor_language",kind:"scalar",T:9},{no:5,name:"language",kind:"enum",T:A.getEnumType(st)},{no:6,name:"cursor_offset",kind:"scalar",T:4},{no:8,name:"cursor_position",kind:"message",T:mn},{no:7,name:"line_ending",kind:"scalar",T:9}])),Ue),Lc=(_e=class extends Q{constructor(r){super();p(this,"forceEnableExperiments",[]);A.util.initPartial(r,this)}static fromBinary(r,n){return new _e().fromBinary(r,n)}static fromJson(r,n){return new _e().fromJson(r,n)}static fromJsonString(r,n){return new _e().fromJsonString(r,n)}static equals(r,n){return A.util.equals(_e,r,n)}},p(_e,"runtime",A),p(_e,"typeName","exa.language_server_pb.ExperimentConfig"),p(_e,"fields",A.util.newFieldList(()=>[{no:1,name:"force_enable_experiments",kind:"enum",T:A.getEnumType(dn),repeated:!0}])),_e),Oc=(Me=class extends Q{constructor(r){super();p(this,"state",Er.UNSPECIFIED);p(this,"message","");A.util.initPartial(r,this)}static fromBinary(r,n){return new Me().fromBinary(r,n)}static fromJson(r,n){return new Me().fromJson(r,n)}static fromJsonString(r,n){return new Me().fromJsonString(r,n)}static equals(r,n){return A.util.equals(Me,r,n)}},p(Me,"runtime",A),p(Me,"typeName","exa.language_server_pb.State"),p(Me,"fields",A.util.newFieldList(()=>[{no:1,name:"state",kind:"enum",T:A.getEnumType(Er)},{no:2,name:"message",kind:"scalar",T:9}])),Me),Bc=(Pe=class extends Q{constructor(r){super();p(this,"startOffset",W.zero);p(this,"endOffset",W.zero);p(this,"startPosition");p(this,"endPosition");A.util.initPartial(r,this)}static fromBinary(r,n){return new Pe().fromBinary(r,n)}static fromJson(r,n){return new Pe().fromJson(r,n)}static fromJsonString(r,n){return new Pe().fromJsonString(r,n)}static equals(r,n){return A.util.equals(Pe,r,n)}},p(Pe,"runtime",A),p(Pe,"typeName","exa.language_server_pb.Range"),p(Pe,"fields",A.util.newFieldList(()=>[{no:1,name:"start_offset",kind:"scalar",T:4},{no:2,name:"end_offset",kind:"scalar",T:4},{no:3,name:"start_position",kind:"message",T:mn},{no:4,name:"end_position",kind:"message",T:mn}])),Pe),Dc=(je=class extends Q{constructor(r){super();p(this,"text","");p(this,"deltaCursorOffset",W.zero);A.util.initPartial(r,this)}static fromBinary(r,n){return new je().fromBinary(r,n)}static fromJson(r,n){return new je().fromJson(r,n)}static fromJsonString(r,n){return new je().fromJsonString(r,n)}static equals(r,n){return A.util.equals(je,r,n)}},p(je,"runtime",A),p(je,"typeName","exa.language_server_pb.Suffix"),p(je,"fields",A.util.newFieldList(()=>[{no:1,name:"text",kind:"scalar",T:9},{no:2,name:"delta_cursor_offset",kind:"scalar",T:3}])),je),Uc=(Re=class extends Q{constructor(r){super();p(this,"text","");p(this,"offset",W.zero);p(this,"type",kr.UNSPECIFIED);p(this,"prefix","");p(this,"line",W.zero);A.util.initPartial(r,this)}static fromBinary(r,n){return new Re().fromBinary(r,n)}static fromJson(r,n){return new Re().fromJson(r,n)}static fromJsonString(r,n){return new Re().fromJsonString(r,n)}static equals(r,n){return A.util.equals(Re,r,n)}},p(Re,"runtime",A),p(Re,"typeName","exa.language_server_pb.CompletionPart"),p(Re,"fields",A.util.newFieldList(()=>[{no:1,name:"text",kind:"scalar",T:9},{no:2,name:"offset",kind:"scalar",T:4},{no:3,name:"type",kind:"enum",T:A.getEnumType(kr)},{no:4,name:"prefix",kind:"scalar",T:9},{no:5,name:"line",kind:"scalar",T:4}])),Re),_c=(Ge=class extends Q{constructor(r){super();p(this,"completion");p(this,"suffix");p(this,"range");p(this,"source",pr.UNSPECIFIED);p(this,"completionParts",[]);A.util.initPartial(r,this)}static fromBinary(r,n){return new Ge().fromBinary(r,n)}static fromJson(r,n){return new Ge().fromJson(r,n)}static fromJsonString(r,n){return new Ge().fromJsonString(r,n)}static equals(r,n){return A.util.equals(Ge,r,n)}},p(Ge,"runtime",A),p(Ge,"typeName","exa.language_server_pb.CompletionItem"),p(Ge,"fields",A.util.newFieldList(()=>[{no:1,name:"completion",kind:"message",T:Wl},{no:5,name:"suffix",kind:"message",T:Dc},{no:2,name:"range",kind:"message",T:Bc},{no:3,name:"source",kind:"enum",T:A.getEnumType(pr)},{no:8,name:"completion_parts",kind:"message",T:Uc,repeated:!0}])),Ge);const Mc={typeName:"exa.language_server_pb.LanguageServerService",methods:{getCompletions:{name:"GetCompletions",I:Nc,O:xc,kind:ke.Unary},acceptCompletion:{name:"AcceptCompletion",I:Sc,O:Tc,kind:ke.Unary},getAuthToken:{name:"GetAuthToken",I:Ic,O:Fc,kind:ke.Unary}}};function Pc(){try{new Headers}catch{throw Error("connect-web requires the fetch API. Are you running on an old version of Node.js? Node.js is not supported in Connect for Web - please stay tuned for Connect for Node.")}}var Mt=function(e){return this instanceof Mt?(this.v=e,this):new Mt(e)},jc=function(e,t,r){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(e,t||[]),o,a=[];return o={},s("next"),s("throw"),s("return",i),o[Symbol.asyncIterator]=function(){return this},o;function i(m){return function(g){return Promise.resolve(g).then(m,f)}}function s(m,g){n[m]&&(o[m]=function(b){return new Promise(function(y,E){a.push([m,b,y,E])>1||l(m,b)})},g&&(o[m]=g(o[m])))}function l(m,g){try{c(n[m](g))}catch(b){h(a[0][3],b)}}function c(m){m.value instanceof Mt?Promise.resolve(m.value.v).then(d,f):h(a[0][2],m)}function d(m){l("next",m)}function f(m){l("throw",m)}function h(m,g){m(g),a.shift(),a.length&&l(a[0][0],a[0][1])}};function Rc(e){Pc();let t=e.useBinaryFormat??!1;return{async unary(r,n,o,a,i,s,l){let{serialize:c,parse:d}=ra(n,t,e.jsonOptions,e.binaryOptions);return a=a===void 0?e.defaultTimeoutMs:a<=0?void 0:a,await kc({interceptors:e.interceptors,signal:o,timeoutMs:a,req:{stream:!1,service:r,method:n,url:Qo(e.baseUrl,r,n),init:{method:"POST",credentials:e.credentials??"same-origin",redirect:"error",mode:"cors"},header:ca(n.kind,t,a,i,!1),contextValues:l??Xo(),message:s},next:async f=>{let h=e.useHttpGet===!0&&n.idempotency===$o.NoSideEffects,m=null;h?f=Ec(f,c(f.message),t):m=c(f.message);let g=await(e.fetch??globalThis.fetch)(f.url,Object.assign(Object.assign({},f.init),{headers:f.header,signal:f.signal,body:m})),{isUnaryError:b,unaryError:y}=ua(n.kind,t,g.status,g.headers);if(b)throw aa(await g.json(),Yl(...la(g.headers)),y);let[E,C]=la(g.headers);return{stream:!1,service:r,method:n,header:E,message:t?d(new Uint8Array(await g.arrayBuffer())):n.O.fromJson(await g.json(),ta(e.jsonOptions)),trailer:C}}})},async stream(r,n,o,a,i,s,l){let{serialize:c,parse:d}=ra(n,t,e.jsonOptions,e.binaryOptions);function f(m,g,b,y){return jc(this,arguments,function*(){let E=Ql(m).getReader(),C=!1;for(;;){let B=yield Mt(E.read());if(B.done)break;let{flags:M,data:D}=B.value;if((M&1)==1)throw new pe("protocol error: received unsupported compressed output",J.Internal);if((M&2)==2){C=!0;let S=bc(D);if(S.error){let x=S.error;throw b.forEach((H,R)=>{x.metadata.append(R,H)}),x}S.metadata.forEach((x,H)=>g.set(H,x));continue}yield yield Mt(d(D))}if("throwIfAborted"in y&&y.throwIfAborted(),!C)throw"missing EndStreamResponse"})}async function h(m){if(n.kind!=ke.ServerStreaming)throw"The fetch API does not support streaming request bodies";let g=await m[Symbol.asyncIterator]().next();if(g.done==1)throw"missing request message";return Zl(0,c(g.value))}return a=a===void 0?e.defaultTimeoutMs:a<=0?void 0:a,await Ac({interceptors:e.interceptors,timeoutMs:a,signal:o,req:{stream:!0,service:r,method:n,url:Qo(e.baseUrl,r,n),init:{method:"POST",credentials:e.credentials??"same-origin",redirect:"error",mode:"cors"},header:ca(n.kind,t,a,i,!1),contextValues:l??Xo(),message:s},next:async m=>{let g=await(e.fetch??globalThis.fetch)(m.url,Object.assign(Object.assign({},m.init),{headers:m.header,signal:m.signal,body:await h(m.message)}));if(ua(n.kind,t,g.status,g.headers),g.body===null)throw"missing response body";let b=new Headers;return Object.assign(Object.assign({},m),{header:g.headers,trailer:b,message:f(g.body,b,g.headers,m.signal)})}})}}}var Gc=Rc({baseUrl:"https://web-backend.codeium.com",useBinaryFormat:!0}),Jc=sc(Mc,Gc),Ar;try{Ar=crypto.randomUUID()}catch{Ar=function(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,t=>(t^(crypto.getRandomValues(new Uint8Array(1))[0]??0)&15>>t/4).toString(16))}()}async function Vc({text:e,cursorOffset:t,config:r,otherDocuments:n}){return await Jc.getCompletions({metadata:{ideName:"web",ideVersion:"0.0.5",extensionName:"@valtown/codemirror-codeium",extensionVersion:"1.0.0",apiKey:r.apiKey,sessionId:Ar,authSource:r.authSource},document:{text:e,cursorOffset:BigInt(t),language:r.language,editorLanguage:"typescript",lineEnding:`
|
|
11
|
-
`},editorOptions:{tabSize:2n,insertSpaces:!0},otherDocuments:n,multilineConfig:void 0},{headers:{Authorization:`Basic ${r.apiKey}-${
|
|
12
|
-
${n.text}`:n.text,i={absoluteStartPos:r+o,absoluteEndPos:r+o+a.length,from:o,to:o,insert:a};return r+=a.length,i})})}async function
|
|
9
|
+
`.trim(),r=Ji();await zi();let n=await fetch(r.getAiURL("completion").toString(),{method:"POST",headers:r.headers(),body:JSON.stringify({prompt:e.prompt,code:t,selectedText:e.selection,includeOtherCode:"",language:e.language})}),o=((s=e.selection.match(/^\s*/))==null?void 0:s[0])||"",a=(l=n.body)==null?void 0:l.getReader();if(!a)throw Error("Failed to get response reader");let i="";for(;;){let{done:c,value:d}=await a.read();if(c)break;i+=new TextDecoder().decode(d)}return i.startsWith(o)||(i=o+i),i}var w=pe(Kf()),Ys=["%alias","%cd","%clear","%debug","%env","%load","%load_ext","%lsmagic","%matplotlib","%pwd","%who_ls","%system","%%time","%%timeit","%%writefile","%%capture","%%html","%%latex"],tn;function Xs(){let e=async o=>{let a=Y.get(qn),{saveUserConfig:i}=$m(),s={...a,runtime:{...a.runtime,auto_reload:o}};await i({config:s}).then(()=>Y.set(qn,s))},t=()=>{requestAnimationFrame(()=>{let o=document.getElementById(Vh);o&&o.focus()})},r=[{match:"!pip install",onMatch:()=>{Y.set(Rn,o=>({...o,isSidebarOpen:!0,selectedPanel:"packages"})),t()},title:"Package Installation",description:(0,w.jsxs)(w.Fragment,{children:["The package manager sidebar has been opened.",(0,w.jsx)("br",{}),"Install packages directly from there instead."]})},{match:"!uv pip install",onMatch:()=>{Y.set(Rn,o=>({...o,isSidebarOpen:!0,selectedPanel:"packages"})),t()},title:"Package Installation",description:(0,w.jsxs)(w.Fragment,{children:["The package manager sidebar has been opened.",(0,w.jsx)("br",{}),"Install packages directly from there instead."]})},{match:"!uv add",onMatch:()=>{Y.set(Rn,o=>({...o,isSidebarOpen:!0,selectedPanel:"packages"})),t()},title:"Package Installation",description:(0,w.jsxs)(w.Fragment,{children:["The package manager sidebar has been opened.",(0,w.jsx)("br",{}),"Install packages directly from there instead."]})},{match:"%autoreload 2",onMatch:async()=>{await e("autorun")},title:"Module reload",description:(0,w.jsxs)(w.Fragment,{children:["Module reload mode set to ",(0,w.jsx)("b",{children:"autorun"})," - module changes will re-run the cells that import them."]})},{match:"%autoreload 1",onMatch:async()=>{await e("lazy")},title:"Module reload",description:(0,w.jsxs)(w.Fragment,{children:["Module reload mode set to ",(0,w.jsx)("b",{children:"lazy"})," - module changes will mark the cells that import them as stale."]})},{match:"%autoreload 0",onMatch:async()=>{await e("off")},title:"Module reload",description:(0,w.jsx)(w.Fragment,{children:"Module reload disabled - module changes will not be detected."})},{match:"!ls",onMatch:()=>{},title:"Listing files",description:(0,w.jsxs)(w.Fragment,{children:["Shell commands are not directly supported.",(0,w.jsx)("br",{}),"Use ",(0,w.jsx)("code",{children:"import subprocess; subprocess.run(['ls'])"})," instead."]})},...Ys.map(o=>({match:o,onMatch:()=>{},title:(0,w.jsx)(Sh,{className:"inline",children:o}),description:(0,w.jsxs)(w.Fragment,{children:["Magic commands are not supported in marimo. Read more about replacements in the"," ",(0,w.jsx)("a",{href:"https://docs.marimo.io/guides/coming_from/jupyter/#adapting-to-the-absence-of-magic-commands",target:"_blank",className:"text-link underline cursor-pointer",rel:"noopener noreferrer",children:"documentation"}),"."]})}))],n=new Map(r.map(o=>[o.match,o]));return L.updateListener.of(o=>{if(o.docChanged){let a=o.state.selection.main,i=o.state.doc,s=i.lineAt(a.head),l=i.sliceString(s.from,a.anchor).trim(),c=n.get(l);c&&(c.onMatch(),tn?tn.upsert({title:c.title,description:c.description}):tn=St({title:c.title,description:c.description}))}})}var Qs=new Set(["Escape","Alt-`"]);function Zs(){let e=zm.filter(t=>!Qs.has(t.key));return tt.highest($e.of([...e,{key:"Ctrl-y",run:t=>Rr(t)?qi(t):!1},{key:"Ctrl-n",run:t=>Rr(t)?$r(!0)(t):!1},{key:"Ctrl-p",run:t=>Rr(t)?$r(!1)(t):!1}]))}const rn=te.define(),nn=te.define(),on=te.define();function K(e,t){if(!e)throw Error(t)}var el=3402823466385289e23,tl=-3402823466385289e23,rl=4294967295,nl=2147483647,ol=-2147483648;function ar(e){if(typeof e!="number")throw Error("invalid int 32: "+typeof e);if(!Number.isInteger(e)||e>nl||e<ol)throw Error("invalid int 32: "+e)}function an(e){if(typeof e!="number")throw Error("invalid uint 32: "+typeof e);if(!Number.isInteger(e)||e>rl||e<0)throw Error("invalid uint 32: "+e)}function go(e){if(typeof e!="number")throw Error("invalid float 32: "+typeof e);if(Number.isFinite(e)&&(e>el||e<tl))throw Error("invalid float 32: "+e)}var po=Symbol("@bufbuild/protobuf/enum-type");function al(e){let t=e[po];return K(t,"missing enum type on enum object"),t}function bo(e,t,r,n){e[po]=yo(t,r.map(o=>({no:o.no,name:o.name,localName:e[o.no]})),n)}function yo(e,t,r){let n=Object.create(null),o=Object.create(null),a=[];for(let i of t){let s=wo(i);a.push(s),n[i.name]=s,o[i.no]=s}return{typeName:e,values:a,findName(i){return n[i]},findNumber(i){return o[i]}}}function il(e,t,r){let n={};for(let o of t){let a=wo(o);n[a.localName]=a.no,n[a.no]=a.localName}return bo(n,e,t,r),n}function wo(e){return"localName"in e?e:Object.assign(Object.assign({},e),{localName:e.name})}var Q=class{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,t){let r=this.getType().runtime.bin,n=r.makeReadOptions(t);return r.readMessage(this,n.readerFactory(e),e.byteLength,n),this}fromJson(e,t){let r=this.getType(),n=r.runtime.json,o=n.makeReadOptions(t);return n.readMessage(r,e,o,this),this}fromJsonString(e,t){let r;try{r=JSON.parse(e)}catch(n){throw Error(`cannot decode ${this.getType().typeName} from JSON: ${n instanceof Error?n.message:String(n)}`)}return this.fromJson(r,t)}toBinary(e){let t=this.getType().runtime.bin,r=t.makeWriteOptions(e),n=r.writerFactory();return t.writeMessage(this,n,r),n.finish()}toJson(e){let t=this.getType().runtime.json,r=t.makeWriteOptions(e);return t.writeMessage(this,r)}toJsonString(e){let t=this.toJson(e);return JSON.stringify(t,null,(e==null?void 0:e.prettySpaces)??0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}};function sl(e,t,r,n){let o=(n==null?void 0:n.localName)??t.substring(t.lastIndexOf(".")+1),a={[o]:function(i){e.util.initFields(this),e.util.initPartial(i,this)}}[o];return Object.setPrototypeOf(a.prototype,new Q),Object.assign(a,{runtime:e,typeName:t,fields:e.util.newFieldList(r),fromBinary(i,s){return new a().fromBinary(i,s)},fromJson(i,s){return new a().fromJson(i,s)},fromJsonString(i,s){return new a().fromJsonString(i,s)},equals(i,s){return e.util.equals(a,i,s)}}),a}function ll(){let e=0,t=0;for(let n=0;n<28;n+=7){let o=this.buf[this.pos++];if(e|=(o&127)<<n,!(o&128))return this.assertBounds(),[e,t]}let r=this.buf[this.pos++];if(e|=(r&15)<<28,t=(r&112)>>4,!(r&128))return this.assertBounds(),[e,t];for(let n=3;n<=31;n+=7){let o=this.buf[this.pos++];if(t|=(o&127)<<n,!(o&128))return this.assertBounds(),[e,t]}throw Error("invalid varint")}function sn(e,t,r){for(let a=0;a<28;a+=7){let i=e>>>a,s=!(!(i>>>7)&&t==0),l=(s?i|128:i)&255;if(r.push(l),!s)return}let n=e>>>28&15|(t&7)<<4,o=!!(t>>3);if(r.push((o?n|128:n)&255),o){for(let a=3;a<31;a+=7){let i=t>>>a,s=!!(i>>>7),l=(s?i|128:i)&255;if(r.push(l),!s)return}r.push(t>>>31&1)}}var ir=4294967296;function vo(e){let t=e[0]==="-";t&&(e=e.slice(1));let r=1e6,n=0,o=0;function a(i,s){let l=Number(e.slice(i,s));o*=r,n=n*r+l,n>=ir&&(o+=n/ir|0,n%=ir)}return a(-24,-18),a(-18,-12),a(-12,-6),a(-6),t?ko(n,o):ln(n,o)}function cl(e,t){let r=ln(e,t),n=r.hi&2147483648;n&&(r=ko(r.lo,r.hi));let o=Eo(r.lo,r.hi);return n?"-"+o:o}function Eo(e,t){if({lo:e,hi:t}=ul(e,t),t<=2097151)return String(ir*t+e);let r=e&16777215,n=(e>>>24|t<<8)&16777215,o=t>>16&65535,a=r+n*6777216+o*6710656,i=n+o*8147497,s=o*2,l=1e7;return a>=l&&(i+=Math.floor(a/l),a%=l),i>=l&&(s+=Math.floor(i/l),i%=l),s.toString()+Ao(i)+Ao(a)}function ul(e,t){return{lo:e>>>0,hi:t>>>0}}function ln(e,t){return{lo:e|0,hi:t|0}}function ko(e,t){return t=~t,e?e=~e+1:t+=1,ln(e,t)}var Ao=e=>{let t=String(e);return"0000000".slice(t.length)+t};function Co(e,t){if(e>=0){for(;e>127;)t.push(e&127|128),e>>>=7;t.push(e)}else{for(let r=0;r<9;r++)t.push(e&127|128),e>>=7;t.push(1)}}function dl(){let e=this.buf[this.pos++],t=e&127;if(!(e&128)||(e=this.buf[this.pos++],t|=(e&127)<<7,!(e&128))||(e=this.buf[this.pos++],t|=(e&127)<<14,!(e&128))||(e=this.buf[this.pos++],t|=(e&127)<<21,!(e&128)))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(e&15)<<28;for(let r=5;e&128&&r<10;r++)e=this.buf[this.pos++];if(e&128)throw Error("invalid varint");return this.assertBounds(),t>>>0}function fl(){let e=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof e.getBigInt64=="function"&&typeof e.getBigUint64=="function"&&typeof e.setBigInt64=="function"&&typeof e.setBigUint64=="function"&&(typeof process!="object"||{}.BUF_BIGINT_DISABLE!=="1")){let n=BigInt("-9223372036854775808"),o=BigInt("9223372036854775807"),a=BigInt("0"),i=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(s){let l=typeof s=="bigint"?s:BigInt(s);if(l>o||l<n)throw Error(`int64 invalid: ${s}`);return l},uParse(s){let l=typeof s=="bigint"?s:BigInt(s);if(l>i||l<a)throw Error(`uint64 invalid: ${s}`);return l},enc(s){return e.setBigInt64(0,this.parse(s),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(s){return e.setBigInt64(0,this.uParse(s),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec(s,l){return e.setInt32(0,s,!0),e.setInt32(4,l,!0),e.getBigInt64(0,!0)},uDec(s,l){return e.setInt32(0,s,!0),e.setInt32(4,l,!0),e.getBigUint64(0,!0)}}}let t=n=>K(/^-?[0-9]+$/.test(n),`int64 invalid: ${n}`),r=n=>K(/^[0-9]+$/.test(n),`uint64 invalid: ${n}`);return{zero:"0",supported:!1,parse(n){return typeof n!="string"&&(n=n.toString()),t(n),n},uParse(n){return typeof n!="string"&&(n=n.toString()),r(n),n},enc(n){return typeof n!="string"&&(n=n.toString()),t(n),vo(n)},uEnc(n){return typeof n!="string"&&(n=n.toString()),r(n),vo(n)},dec(n,o){return cl(n,o)},uDec(n,o){return Eo(n,o)}}}const W=fl();var v;(function(e){e[e.DOUBLE=1]="DOUBLE",e[e.FLOAT=2]="FLOAT",e[e.INT64=3]="INT64",e[e.UINT64=4]="UINT64",e[e.INT32=5]="INT32",e[e.FIXED64=6]="FIXED64",e[e.FIXED32=7]="FIXED32",e[e.BOOL=8]="BOOL",e[e.STRING=9]="STRING",e[e.BYTES=12]="BYTES",e[e.UINT32=13]="UINT32",e[e.SFIXED32=15]="SFIXED32",e[e.SFIXED64=16]="SFIXED64",e[e.SINT32=17]="SINT32",e[e.SINT64=18]="SINT64"})(v||(v={}));var st;(function(e){e[e.BIGINT=0]="BIGINT",e[e.STRING=1]="STRING"})(st||(st={}));function nt(e,t,r){if(t===r)return!0;if(e==v.BYTES){if(!(t instanceof Uint8Array)||!(r instanceof Uint8Array)||t.length!==r.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==r[n])return!1;return!0}switch(e){case v.UINT64:case v.FIXED64:case v.INT64:case v.SFIXED64:case v.SINT64:return t==r}return!1}function bt(e,t){switch(e){case v.BOOL:return!1;case v.UINT64:case v.FIXED64:case v.INT64:case v.SFIXED64:case v.SINT64:return t==0?W.zero:"0";case v.DOUBLE:case v.FLOAT:return 0;case v.BYTES:return new Uint8Array;case v.STRING:return"";default:return 0}}function No(e,t){switch(e){case v.BOOL:return t===!1;case v.STRING:return t==="";case v.BYTES:return t instanceof Uint8Array&&!t.byteLength;default:return t==0}}var ee;(function(e){e[e.Varint=0]="Varint",e[e.Bit64=1]="Bit64",e[e.LengthDelimited=2]="LengthDelimited",e[e.StartGroup=3]="StartGroup",e[e.EndGroup=4]="EndGroup",e[e.Bit32=5]="Bit32"})(ee||(ee={}));var ml=class{constructor(e){this.stack=[],this.textEncoder=e??new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let n=0;n<this.chunks.length;n++)e+=this.chunks[n].length;let t=new Uint8Array(e),r=0;for(let n=0;n<this.chunks.length;n++)t.set(this.chunks[n],r),r+=this.chunks[n].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(an(e);e>127;)this.buf.push(e&127|128),e>>>=7;return this.buf.push(e),this}int32(e){return ar(e),Co(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){go(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){an(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){ar(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return ar(e),e=(e<<1^e>>31)>>>0,Co(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),n=W.enc(e);return r.setInt32(0,n.lo,!0),r.setInt32(4,n.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),n=W.uEnc(e);return r.setInt32(0,n.lo,!0),r.setInt32(4,n.hi,!0),this.raw(t)}int64(e){let t=W.enc(e);return sn(t.lo,t.hi,this.buf),this}sint64(e){let t=W.enc(e),r=t.hi>>31,n=t.lo<<1^r,o=(t.hi<<1|t.lo>>>31)^r;return sn(n,o,this.buf),this}uint64(e){let t=W.uEnc(e);return sn(t.lo,t.hi,this.buf),this}},hl=class{constructor(e,t){this.varint64=ll,this.uint32=dl,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=t??new TextDecoder}tag(){let e=this.uint32(),t=e>>>3,r=e&7;if(t<=0||r<0||r>5)throw Error("illegal tag: field no "+t+" wire type "+r);return[t,r]}skip(e,t){let r=this.pos;switch(e){case ee.Varint:for(;this.buf[this.pos++]&128;);break;case ee.Bit64:this.pos+=4;case ee.Bit32:this.pos+=4;break;case ee.LengthDelimited:let n=this.uint32();this.pos+=n;break;case ee.StartGroup:for(;;){let[o,a]=this.tag();if(a===ee.EndGroup){if(t!==void 0&&o!==t)throw Error("invalid end group tag");break}this.skip(a,o)}break;default:throw Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(r,this.pos)}assertBounds(){if(this.pos>this.len)throw RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return W.dec(...this.varint64())}uint64(){return W.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),r=-(e&1);return e=(e>>>1|(t&1)<<31)^r,t=t>>>1^r,W.dec(e,t)}bool(){let[e,t]=this.varint64();return e!==0||t!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return W.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return W.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}};function gl(e,t,r,n){let o;return{typeName:t,extendee:r,get field(){if(!o){let a=typeof n=="function"?n():n;a.name=t.split(".").pop(),a.jsonName=`[${t}]`,o=e.util.newFieldList([a]).list()[0]}return o},runtime:e}}function xo(e){let t=e.field.localName,r=Object.create(null);return r[t]=pl(e),[r,()=>r[t]]}function pl(e){let t=e.field;if(t.repeated)return[];if(t.default!==void 0)return t.default;switch(t.kind){case"enum":return t.T.values[0].no;case"scalar":return bt(t.T,t.L);case"message":let r=t.T,n=new r;return r.fieldWrapper?r.fieldWrapper.unwrapField(n):n;case"map":throw"map fields are not allowed to be extensions"}}function bl(e,t){if(!t.repeated&&(t.kind=="enum"||t.kind=="scalar")){for(let r=e.length-1;r>=0;--r)if(e[r].no==t.no)return[e[r]];return[]}return e.filter(r=>r.no===t.no)}var Ke="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),sr=[];for(let e=0;e<Ke.length;e++)sr[Ke[e].charCodeAt(0)]=e;sr[45]=Ke.indexOf("+"),sr[95]=Ke.indexOf("/");const lr={dec(e){let t=e.length*3/4;e[e.length-2]=="="?t-=2:e[e.length-1]=="="&&--t;let r=new Uint8Array(t),n=0,o=0,a,i=0;for(let s=0;s<e.length;s++){if(a=sr[e.charCodeAt(s)],a===void 0)switch(e[s]){case"=":o=0;case`
|
|
10
|
+
`:case"\r":case" ":case" ":continue;default:throw Error("invalid base64 string.")}switch(o){case 0:i=a,o=1;break;case 1:r[n++]=i<<2|(a&48)>>4,i=a,o=2;break;case 2:r[n++]=(i&15)<<4|(a&60)>>2,i=a,o=3;break;case 3:r[n++]=(i&3)<<6|a,o=0;break}}if(o==1)throw Error("invalid base64 string.");return r.subarray(0,n)},enc(e){let t="",r=0,n,o=0;for(let a=0;a<e.length;a++)switch(n=e[a],r){case 0:t+=Ke[n>>2],o=(n&3)<<4,r=1;break;case 1:t+=Ke[o|n>>4],o=(n&15)<<2,r=2;break;case 2:t+=Ke[o|n>>6],t+=Ke[n&63],r=0;break}return r&&(t+=Ke[o],t+="=",r==1&&(t+="=")),t}};function yl(e,t,r){To(t,e);let n=t.runtime.bin.makeReadOptions(r),o=bl(e.getType().runtime.bin.listUnknownFields(e),t.field),[a,i]=xo(t);for(let s of o)t.runtime.bin.readField(a,n.readerFactory(s.data),t.field,s.wireType,n);return i()}function wl(e,t,r,n){To(t,e);let o=t.runtime.bin.makeReadOptions(n),a=t.runtime.bin.makeWriteOptions(n);if(So(e,t)){let c=e.getType().runtime.bin.listUnknownFields(e).filter(d=>d.no!=t.field.no);e.getType().runtime.bin.discardUnknownFields(e);for(let d of c)e.getType().runtime.bin.onUnknownField(e,d.no,d.wireType,d.data)}let i=a.writerFactory(),s=t.field;!s.opt&&!s.repeated&&(s.kind=="enum"||s.kind=="scalar")&&(s=Object.assign(Object.assign({},t.field),{opt:!0})),t.runtime.bin.writeField(s,r,i,a);let l=o.readerFactory(i.finish());for(;l.pos<l.len;){let[c,d]=l.tag(),f=l.skip(d,c);e.getType().runtime.bin.onUnknownField(e,c,d,f)}}function So(e,t){let r=e.getType();return t.extendee.typeName===r.typeName&&!!r.runtime.bin.listUnknownFields(e).find(n=>n.no==t.field.no)}function To(e,t){K(e.extendee.typeName==t.getType().typeName,`extension ${e.typeName} can only be applied to message ${e.extendee.typeName}`)}function Io(e,t){let r=e.localName;if(e.repeated)return t[r].length>0;if(e.oneof)return t[e.oneof.localName].case===r;switch(e.kind){case"enum":case"scalar":return e.opt||e.req?t[r]!==void 0:e.kind=="enum"?t[r]!==e.T.values[0].no:!No(e.T,t[r]);case"message":return t[r]!==void 0;case"map":return Object.keys(t[r]).length>0}}function Fo(e,t){let r=e.localName,n=!e.opt&&!e.req;if(e.repeated)t[r]=[];else if(e.oneof)t[e.oneof.localName]={case:void 0};else switch(e.kind){case"map":t[r]={};break;case"enum":t[r]=n?e.T.values[0].no:void 0;break;case"scalar":t[r]=n?bt(e.T,e.L):void 0;break;case"message":t[r]=void 0;break}}function Ye(e,t){if(typeof e!="object"||!e||!Object.getOwnPropertyNames(Q.prototype).every(n=>n in e&&typeof e[n]=="function"))return!1;let r=e.getType();return r===null||typeof r!="function"||!("typeName"in r)||typeof r.typeName!="string"?!1:t===void 0?!0:r.typeName==t.typeName}function Lo(e,t){return Ye(t)||!e.fieldWrapper?t:e.fieldWrapper.wrapField(t)}v.DOUBLE,v.FLOAT,v.INT64,v.UINT64,v.INT32,v.UINT32,v.BOOL,v.STRING,v.BYTES;var Oo={ignoreUnknownFields:!1},Bo={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function vl(e){return e?Object.assign(Object.assign({},Oo),e):Oo}function El(e){return e?Object.assign(Object.assign({},Bo),e):Bo}var cr=Symbol(),ur=Symbol();function kl(){return{makeReadOptions:vl,makeWriteOptions:El,readMessage(e,t,r,n){if(t==null||Array.isArray(t)||typeof t!="object")throw Error(`cannot decode message ${e.typeName} from JSON: ${qe(t)}`);n??(n=new e);let o=new Map,a=r.typeRegistry;for(let[i,s]of Object.entries(t)){let l=e.fields.findJsonName(i);if(l){if(l.oneof){if(s===null&&l.kind=="scalar")continue;let c=o.get(l.oneof);if(c!==void 0)throw Error(`cannot decode message ${e.typeName} from JSON: multiple keys for oneof "${l.oneof.name}" present: "${c}", "${i}"`);o.set(l.oneof,i)}Do(n,s,l,r,e)}else{let c=!1;if(a!=null&&a.findExtension&&i.startsWith("[")&&i.endsWith("]")){let d=a.findExtension(i.substring(1,i.length-1));if(d&&d.extendee.typeName==e.typeName){c=!0;let[f,h]=xo(d);Do(f,s,d.field,r,d),wl(n,d,h(),r)}}if(!c&&!r.ignoreUnknownFields)throw Error(`cannot decode message ${e.typeName} from JSON: key "${i}" is unknown`)}}return n},writeMessage(e,t){let r=e.getType(),n={},o;try{for(o of r.fields.byNumber()){if(!Io(o,e)){if(o.req)throw"required field not set";if(!t.emitDefaultValues||!Cl(o))continue}let i=o.oneof?e[o.oneof.localName].value:e[o.localName],s=Uo(o,i,t);s!==void 0&&(n[t.useProtoFieldName?o.name:o.jsonName]=s)}let a=t.typeRegistry;if(a!=null&&a.findExtensionFor)for(let i of r.runtime.bin.listUnknownFields(e)){let s=a.findExtensionFor(r.typeName,i.no);if(s&&So(e,s)){let l=yl(e,s,t),c=Uo(s.field,l,t);c!==void 0&&(n[s.field.jsonName]=c)}}}catch(a){let i=o?`cannot encode field ${r.typeName}.${o.name} to JSON`:`cannot encode message ${r.typeName} to JSON`,s=a instanceof Error?a.message:String(a);throw Error(i+(s.length>0?`: ${s}`:""))}return n},readScalar(e,t,r){return Dt(e,t,r??st.BIGINT,!0)},writeScalar(e,t,r){if(t!==void 0&&(r||No(e,t)))return dr(e,t)},debug:qe}}function qe(e){if(e===null)return"null";switch(typeof e){case"object":return Array.isArray(e)?"array":"object";case"string":return e.length>100?"string":`"${e.split('"').join('\\"')}"`;default:return String(e)}}function Do(e,t,r,n,o){let a=r.localName;if(r.repeated){if(K(r.kind!="map"),t===null)return;if(!Array.isArray(t))throw Error(`cannot decode field ${o.typeName}.${r.name} from JSON: ${qe(t)}`);let i=e[a];for(let s of t){if(s===null)throw Error(`cannot decode field ${o.typeName}.${r.name} from JSON: ${qe(s)}`);switch(r.kind){case"message":i.push(r.T.fromJson(s,n));break;case"enum":let l=cn(r.T,s,n.ignoreUnknownFields,!0);l!==ur&&i.push(l);break;case"scalar":try{i.push(Dt(r.T,s,r.L,!0))}catch(c){let d=`cannot decode field ${o.typeName}.${r.name} from JSON: ${qe(s)}`;throw c instanceof Error&&c.message.length>0&&(d+=`: ${c.message}`),Error(d)}break}}}else if(r.kind=="map"){if(t===null)return;if(typeof t!="object"||Array.isArray(t))throw Error(`cannot decode field ${o.typeName}.${r.name} from JSON: ${qe(t)}`);let i=e[a];for(let[s,l]of Object.entries(t)){if(l===null)throw Error(`cannot decode field ${o.typeName}.${r.name} from JSON: map value null`);let c;try{c=Al(r.K,s)}catch(d){let f=`cannot decode map key for field ${o.typeName}.${r.name} from JSON: ${qe(t)}`;throw d instanceof Error&&d.message.length>0&&(f+=`: ${d.message}`),Error(f)}switch(r.V.kind){case"message":i[c]=r.V.T.fromJson(l,n);break;case"enum":let d=cn(r.V.T,l,n.ignoreUnknownFields,!0);d!==ur&&(i[c]=d);break;case"scalar":try{i[c]=Dt(r.V.T,l,st.BIGINT,!0)}catch(f){let h=`cannot decode map value for field ${o.typeName}.${r.name} from JSON: ${qe(t)}`;throw f instanceof Error&&f.message.length>0&&(h+=`: ${f.message}`),Error(h)}break}}}else switch(r.oneof&&(e=e[r.oneof.localName]={case:a},a="value"),r.kind){case"message":let i=r.T;if(t===null&&i.typeName!="google.protobuf.Value")return;let s=e[a];Ye(s)?s.fromJson(t,n):(e[a]=s=i.fromJson(t,n),i.fieldWrapper&&!r.oneof&&(e[a]=i.fieldWrapper.unwrapField(s)));break;case"enum":let l=cn(r.T,t,n.ignoreUnknownFields,!1);switch(l){case cr:Fo(r,e);break;case ur:break;default:e[a]=l;break}break;case"scalar":try{let c=Dt(r.T,t,r.L,!1);switch(c){case cr:Fo(r,e);break;default:e[a]=c;break}}catch(c){let d=`cannot decode field ${o.typeName}.${r.name} from JSON: ${qe(t)}`;throw c instanceof Error&&c.message.length>0&&(d+=`: ${c.message}`),Error(d)}break}}function Al(e,t){if(e===v.BOOL)switch(t){case"true":t=!0;break;case"false":t=!1;break}return Dt(e,t,st.BIGINT,!0).toString()}function Dt(e,t,r,n){if(t===null)return n?bt(e,r):cr;switch(e){case v.DOUBLE:case v.FLOAT:if(t==="NaN")return NaN;if(t==="Infinity")return 1/0;if(t==="-Infinity")return-1/0;if(t===""||typeof t=="string"&&t.trim().length!==t.length||typeof t!="string"&&typeof t!="number")break;let o=Number(t);if(Number.isNaN(o)||!Number.isFinite(o))break;return e==v.FLOAT&&go(o),o;case v.INT32:case v.FIXED32:case v.SFIXED32:case v.SINT32:case v.UINT32:let a;if(typeof t=="number"?a=t:typeof t=="string"&&t.length>0&&t.trim().length===t.length&&(a=Number(t)),a===void 0)break;return e==v.UINT32||e==v.FIXED32?an(a):ar(a),a;case v.INT64:case v.SFIXED64:case v.SINT64:if(typeof t!="number"&&typeof t!="string")break;let i=W.parse(t);return r?i.toString():i;case v.FIXED64:case v.UINT64:if(typeof t!="number"&&typeof t!="string")break;let s=W.uParse(t);return r?s.toString():s;case v.BOOL:if(typeof t!="boolean")break;return t;case v.STRING:if(typeof t!="string")break;return t;case v.BYTES:if(t==="")return new Uint8Array;if(typeof t!="string")break;return lr.dec(t)}throw Error()}function cn(e,t,r,n){if(t===null)return e.typeName=="google.protobuf.NullValue"?0:n?e.values[0].no:cr;switch(typeof t){case"number":if(Number.isInteger(t))return t;break;case"string":let o=e.findName(t);if(o!==void 0)return o.no;if(r)return ur;break}throw Error(`cannot decode enum ${e.typeName} from JSON: ${qe(t)}`)}function Cl(e){return e.repeated||e.kind=="map"?!0:!(e.oneof||e.kind=="message"||e.opt||e.req)}function Uo(e,t,r){if(e.kind=="map"){K(typeof t=="object"&&!!t);let n={},o=Object.entries(t);switch(e.V.kind){case"scalar":for(let[i,s]of o)n[i.toString()]=dr(e.V.T,s);break;case"message":for(let[i,s]of o)n[i.toString()]=s.toJson(r);break;case"enum":let a=e.V.T;for(let[i,s]of o)n[i.toString()]=un(a,s,r.enumAsInteger);break}return r.emitDefaultValues||o.length>0?n:void 0}if(e.repeated){K(Array.isArray(t));let n=[];switch(e.kind){case"scalar":for(let o=0;o<t.length;o++)n.push(dr(e.T,t[o]));break;case"enum":for(let o=0;o<t.length;o++)n.push(un(e.T,t[o],r.enumAsInteger));break;case"message":for(let o=0;o<t.length;o++)n.push(t[o].toJson(r));break}return r.emitDefaultValues||n.length>0?n:void 0}switch(e.kind){case"scalar":return dr(e.T,t);case"enum":return un(e.T,t,r.enumAsInteger);case"message":return Lo(e.T,t).toJson(r)}}function un(e,t,r){var n;return K(typeof t=="number"),e.typeName=="google.protobuf.NullValue"?null:r?t:((n=e.findNumber(t))==null?void 0:n.name)??t}function dr(e,t){switch(e){case v.INT32:case v.SFIXED32:case v.SINT32:case v.FIXED32:case v.UINT32:return K(typeof t=="number"),t;case v.FLOAT:case v.DOUBLE:return K(typeof t=="number"),Number.isNaN(t)?"NaN":t===1/0?"Infinity":t===-1/0?"-Infinity":t;case v.STRING:return K(typeof t=="string"),t;case v.BOOL:return K(typeof t=="boolean"),t;case v.UINT64:case v.FIXED64:case v.INT64:case v.SFIXED64:case v.SINT64:return K(typeof t=="bigint"||typeof t=="string"||typeof t=="number"),t.toString();case v.BYTES:return K(t instanceof Uint8Array),lr.enc(t)}}var yt=Symbol("@bufbuild/protobuf/unknown-fields"),_o={readUnknownFields:!0,readerFactory:e=>new hl(e)},Mo={writeUnknownFields:!0,writerFactory:()=>new ml};function Nl(e){return e?Object.assign(Object.assign({},_o),e):_o}function xl(e){return e?Object.assign(Object.assign({},Mo),e):Mo}function Sl(){return{makeReadOptions:Nl,makeWriteOptions:xl,listUnknownFields(e){return e[yt]??[]},discardUnknownFields(e){delete e[yt]},writeUnknownFields(e,t){let r=e[yt];if(r)for(let n of r)t.tag(n.no,n.wireType).raw(n.data)},onUnknownField(e,t,r,n){let o=e;Array.isArray(o[yt])||(o[yt]=[]),o[yt].push({no:t,wireType:r,data:n})},readMessage(e,t,r,n,o){let a=e.getType(),i=o?t.len:t.pos+r,s,l;for(;t.pos<i&&([s,l]=t.tag(),!(o===!0&&l==ee.EndGroup));){let c=a.fields.find(s);if(!c){let d=t.skip(l,s);n.readUnknownFields&&this.onUnknownField(e,s,l,d);continue}Po(e,t,c,l,n)}if(o&&(l!=ee.EndGroup||s!==r))throw Error("invalid end group tag")},readField:Po,writeMessage(e,t,r){let n=e.getType();for(let o of n.fields.byNumber()){if(!Io(o,e)){if(o.req)throw Error(`cannot encode field ${n.typeName}.${o.name} to binary: required field not set`);continue}let a=o.oneof?e[o.oneof.localName].value:e[o.localName];jo(o,a,t,r)}return r.writeUnknownFields&&this.writeUnknownFields(e,t),t},writeField(e,t,r,n){t!==void 0&&jo(e,t,r,n)}}}function Po(e,t,r,n,o){let{repeated:a,localName:i}=r;switch(r.oneof&&(e=e[r.oneof.localName],e.case!=i&&delete e.value,e.case=i,i="value"),r.kind){case"scalar":case"enum":let s=r.kind=="enum"?v.INT32:r.T,l=mr;if(r.kind=="scalar"&&r.L>0&&(l=Il),a){let h=e[i];if(n==ee.LengthDelimited&&s!=v.STRING&&s!=v.BYTES){let m=t.uint32()+t.pos;for(;t.pos<m;)h.push(l(t,s))}else h.push(l(t,s))}else e[i]=l(t,s);break;case"message":let c=r.T;a?e[i].push(fr(t,new c,o,r)):Ye(e[i])?fr(t,e[i],o,r):(e[i]=fr(t,new c,o,r),c.fieldWrapper&&!r.oneof&&!r.repeated&&(e[i]=c.fieldWrapper.unwrapField(e[i])));break;case"map":let[d,f]=Tl(r,t,o);e[i][d]=f;break}}function fr(e,t,r,n){let o=t.getType().runtime.bin,a=n==null?void 0:n.delimited;return o.readMessage(t,e,a?n.no:e.uint32(),r,a),t}function Tl(e,t,r){let n=t.uint32(),o=t.pos+n,a,i;for(;t.pos<o;){let[s]=t.tag();switch(s){case 1:a=mr(t,e.K);break;case 2:switch(e.V.kind){case"scalar":i=mr(t,e.V.T);break;case"enum":i=t.int32();break;case"message":i=fr(t,new e.V.T,r,void 0);break}break}}if(a===void 0&&(a=bt(e.K,st.BIGINT)),typeof a!="string"&&typeof a!="number"&&(a=a.toString()),i===void 0)switch(e.V.kind){case"scalar":i=bt(e.V.T,st.BIGINT);break;case"enum":i=e.V.T.values[0].no;break;case"message":i=new e.V.T;break}return[a,i]}function Il(e,t){let r=mr(e,t);return typeof r=="bigint"?r.toString():r}function mr(e,t){switch(t){case v.STRING:return e.string();case v.BOOL:return e.bool();case v.DOUBLE:return e.double();case v.FLOAT:return e.float();case v.INT32:return e.int32();case v.INT64:return e.int64();case v.UINT64:return e.uint64();case v.FIXED64:return e.fixed64();case v.BYTES:return e.bytes();case v.FIXED32:return e.fixed32();case v.SFIXED32:return e.sfixed32();case v.SFIXED64:return e.sfixed64();case v.SINT64:return e.sint64();case v.UINT32:return e.uint32();case v.SINT32:return e.sint32()}}function jo(e,t,r,n){K(t!==void 0);let o=e.repeated;switch(e.kind){case"scalar":case"enum":let a=e.kind=="enum"?v.INT32:e.T;if(o)if(K(Array.isArray(t)),e.packed)Ll(r,a,e.no,t);else for(let i of t)Ut(r,a,e.no,i);else Ut(r,a,e.no,t);break;case"message":if(o){K(Array.isArray(t));for(let i of t)Ro(r,n,e,i)}else Ro(r,n,e,t);break;case"map":K(typeof t=="object"&&!!t);for(let[i,s]of Object.entries(t))Fl(r,n,e,i,s);break}}function Fl(e,t,r,n,o){e.tag(r.no,ee.LengthDelimited),e.fork();let a=n;switch(r.K){case v.INT32:case v.FIXED32:case v.UINT32:case v.SFIXED32:case v.SINT32:a=Number.parseInt(n);break;case v.BOOL:K(n=="true"||n=="false"),a=n=="true";break}switch(Ut(e,r.K,1,a),r.V.kind){case"scalar":Ut(e,r.V.T,2,o);break;case"enum":Ut(e,v.INT32,2,o);break;case"message":K(o!==void 0),e.tag(2,ee.LengthDelimited).bytes(o.toBinary(t));break}e.join()}function Ro(e,t,r,n){let o=Lo(r.T,n);r.delimited?e.tag(r.no,ee.StartGroup).raw(o.toBinary(t)).tag(r.no,ee.EndGroup):e.tag(r.no,ee.LengthDelimited).bytes(o.toBinary(t))}function Ut(e,t,r,n){K(n!==void 0);let[o,a]=Go(t);e.tag(r,o)[a](n)}function Ll(e,t,r,n){if(!n.length)return;e.tag(r,ee.LengthDelimited).fork();let[,o]=Go(t);for(let a=0;a<n.length;a++)e[o](n[a]);e.join()}function Go(e){let t=ee.Varint;switch(e){case v.BYTES:case v.STRING:t=ee.LengthDelimited;break;case v.DOUBLE:case v.FIXED64:case v.SFIXED64:t=ee.Bit64;break;case v.FIXED32:case v.SFIXED32:case v.FLOAT:t=ee.Bit32;break}let r=v[e].toLowerCase();return[t,r]}function Ol(){return{setEnumType:bo,initPartial(e,t){if(e===void 0)return;let r=t.getType();for(let n of r.fields.byMember()){let o=n.localName,a=t,i=e;if(i[o]!=null)switch(n.kind){case"oneof":let s=i[o].case;if(s===void 0)continue;let l=n.findField(s),c=i[o].value;l&&l.kind=="message"&&!Ye(c,l.T)?c=new l.T(c):l&&l.kind==="scalar"&&l.T===v.BYTES&&(c=_t(c)),a[o]={case:s,value:c};break;case"scalar":case"enum":let d=i[o];n.T===v.BYTES&&(d=n.repeated?d.map(_t):_t(d)),a[o]=d;break;case"map":switch(n.V.kind){case"scalar":case"enum":if(n.V.T===v.BYTES)for(let[m,g]of Object.entries(i[o]))a[o][m]=_t(g);else Object.assign(a[o],i[o]);break;case"message":let h=n.V.T;for(let m of Object.keys(i[o])){let g=i[o][m];h.fieldWrapper||(g=new h(g)),a[o][m]=g}break}break;case"message":let f=n.T;if(n.repeated)a[o]=i[o].map(h=>Ye(h,f)?h:new f(h));else{let h=i[o];f.fieldWrapper?f.typeName==="google.protobuf.BytesValue"?a[o]=_t(h):a[o]=h:a[o]=Ye(h,f)?h:new f(h)}break}}},equals(e,t,r){return t===r?!0:!t||!r?!1:e.fields.byMember().every(n=>{let o=t[n.localName],a=r[n.localName];if(n.repeated){if(o.length!==a.length)return!1;switch(n.kind){case"message":return o.every((i,s)=>n.T.equals(i,a[s]));case"scalar":return o.every((i,s)=>nt(n.T,i,a[s]));case"enum":return o.every((i,s)=>nt(v.INT32,i,a[s]))}throw Error(`repeated cannot contain ${n.kind}`)}switch(n.kind){case"message":let i=o,s=a;return n.T.fieldWrapper&&(i!==void 0&&!Ye(i)&&(i=n.T.fieldWrapper.wrapField(i)),s!==void 0&&!Ye(s)&&(s=n.T.fieldWrapper.wrapField(s))),n.T.equals(i,s);case"enum":return nt(v.INT32,o,a);case"scalar":return nt(n.T,o,a);case"oneof":if(o.case!==a.case)return!1;let l=n.findField(o.case);if(l===void 0)return!0;switch(l.kind){case"message":return l.T.equals(o.value,a.value);case"enum":return nt(v.INT32,o.value,a.value);case"scalar":return nt(l.T,o.value,a.value)}throw Error(`oneof cannot contain ${l.kind}`);case"map":let c=Object.keys(o).concat(Object.keys(a));switch(n.V.kind){case"message":let d=n.V.T;return c.every(h=>d.equals(o[h],a[h]));case"enum":return c.every(h=>nt(v.INT32,o[h],a[h]));case"scalar":let f=n.V.T;return c.every(h=>nt(f,o[h],a[h]))}break}})},clone(e){let t=e.getType(),r=new t,n=r;for(let o of t.fields.byMember()){let a=e[o.localName],i;if(o.repeated)i=a.map(hr);else if(o.kind=="map"){i=n[o.localName];for(let[s,l]of Object.entries(a))i[s]=hr(l)}else i=o.kind=="oneof"?o.findField(a.case)?{case:a.case,value:hr(a.value)}:{case:void 0}:hr(a);n[o.localName]=i}for(let o of t.runtime.bin.listUnknownFields(e))t.runtime.bin.onUnknownField(n,o.no,o.wireType,o.data);return r}}}function hr(e){if(e===void 0)return e;if(Ye(e))return e.clone();if(e instanceof Uint8Array){let t=new Uint8Array(e.byteLength);return t.set(e),t}return e}function _t(e){return e instanceof Uint8Array?e:new Uint8Array(e)}function Bl(e,t,r){return{syntax:e,json:kl(),bin:Sl(),util:Object.assign(Object.assign({},Ol()),{newFieldList:t,initFields:r}),makeMessageType(n,o,a){return sl(this,n,o,a)},makeEnum:il,makeEnumType:yo,getEnumType:al,makeExtension(n,o,a){return gl(this,n,o,a)}}}var Dl=class{constructor(e,t){this._fields=e,this._normalizer=t}findJsonName(e){if(!this.jsonNames){let t={};for(let r of this.list())t[r.jsonName]=t[r.name]=r;this.jsonNames=t}return this.jsonNames[e]}find(e){if(!this.numbers){let t={};for(let r of this.list())t[r.no]=r;this.numbers=t}return this.numbers[e]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort((e,t)=>e.no-t.no)),this.numbersAsc}byMember(){if(!this.members){this.members=[];let e=this.members,t;for(let r of this.list())r.oneof?r.oneof!==t&&(t=r.oneof,e.push(t)):e.push(r)}return this.members}};function Jo(e,t){let r=Vo(e);return t?r:Rl(jl(r))}function Ul(e){return Jo(e,!1)}const _l=Vo;function Vo(e){let t=!1,r=[];for(let n=0;n<e.length;n++){let o=e.charAt(n);switch(o){case"_":t=!0;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":r.push(o),t=!1;break;default:t&&(t=!1,o=o.toUpperCase()),r.push(o);break}}return r.join("")}var Ml=new Set(["constructor","toString","toJSON","valueOf"]),Pl=new Set(["getType","clone","equals","fromBinary","fromJson","fromJsonString","toBinary","toJson","toJsonString","toObject"]),Wo=e=>`${e}$`,jl=e=>Pl.has(e)?Wo(e):e;const Rl=e=>Ml.has(e)?Wo(e):e;var Gl=class{constructor(e){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=e,this.localName=Ul(e)}addField(e){K(e.oneof===this,`field ${e.name} not one of ${this.name}`),this.fields.push(e)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let t=0;t<this.fields.length;t++)this._lookup[this.fields[t].localName]=this.fields[t]}return this._lookup[e]}};function Jl(e,t){let r=[],n;for(let o of typeof e=="function"?e():e){let a=o;if(a.localName=Jo(o.name,o.oneof!==void 0),a.jsonName=o.jsonName??_l(o.name),a.repeated=o.repeated??!1,o.kind=="scalar"&&(a.L=o.L??st.BIGINT),a.delimited=o.delimited??!1,a.req=o.req??!1,a.opt=o.opt??!1,o.packed===void 0&&(t?a.packed=o.kind=="enum"||o.kind=="scalar"&&o.T!=v.BYTES&&o.T!=v.STRING:a.packed=!1),o.oneof!==void 0){let i=typeof o.oneof=="string"?o.oneof:o.oneof.name;(!n||n.name!=i)&&(n=new Gl(i)),a.oneof=n,n.addField(a)}r.push(a)}return r}const A=Bl("proto3",e=>new Dl(e,t=>Jl(t,!0)),e=>{for(let t of e.getType().fields.byMember()){if(t.opt)continue;let r=t.localName,n=e;if(t.repeated){n[r]=[];continue}switch(t.kind){case"oneof":n[r]={case:void 0};break;case"enum":n[r]=0;break;case"map":n[r]={};break;case"scalar":n[r]=bt(t.T,t.L);break;case"message":break}}});var Ae;(function(e){e[e.Unary=0]="Unary",e[e.ServerStreaming=1]="ServerStreaming",e[e.ClientStreaming=2]="ClientStreaming",e[e.BiDiStreaming=3]="BiDiStreaming"})(Ae||(Ae={}));var $o;(function(e){e[e.NoSideEffects=1]="NoSideEffects",e[e.Idempotent=2]="Idempotent"})($o||($o={}));var dn;(function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.JUPYTER_FORMAT=77]="JUPYTER_FORMAT"})(dn||(dn={})),A.util.setEnumType(dn,"exa.codeium_common_pb.ExperimentKey",[{no:0,name:"UNSPECIFIED"},{no:77,name:"JUPYTER_FORMAT"}]);var gr;(function(e){e[e.CODEIUM=0]="CODEIUM"})(gr||(gr={})),A.util.setEnumType(gr,"exa.codeium_common_pb.AuthSource",[{no:0,name:"AUTH_SOURCE_CODEIUM"}]);var pr;(function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.ENABLE_CODEIUM=1]="ENABLE_CODEIUM",e[e.DISABLE_CODEIUM=2]="DISABLE_CODEIUM",e[e.SHOW_PREVIOUS_COMPLETION=3]="SHOW_PREVIOUS_COMPLETION",e[e.SHOW_NEXT_COMPLETION=4]="SHOW_NEXT_COMPLETION"})(pr||(pr={})),A.util.setEnumType(pr,"exa.codeium_common_pb.EventType",[{no:0,name:"EVENT_TYPE_UNSPECIFIED"},{no:1,name:"EVENT_TYPE_ENABLE_CODEIUM"},{no:2,name:"EVENT_TYPE_DISABLE_CODEIUM"},{no:3,name:"EVENT_TYPE_SHOW_PREVIOUS_COMPLETION"},{no:4,name:"EVENT_TYPE_SHOW_NEXT_COMPLETION"}]);var br;(function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.TYPING_AS_SUGGESTED=1]="TYPING_AS_SUGGESTED",e[e.CACHE=2]="CACHE",e[e.NETWORK=3]="NETWORK"})(br||(br={})),A.util.setEnumType(br,"exa.codeium_common_pb.CompletionSource",[{no:0,name:"COMPLETION_SOURCE_UNSPECIFIED"},{no:1,name:"COMPLETION_SOURCE_TYPING_AS_SUGGESTED"},{no:2,name:"COMPLETION_SOURCE_CACHE"},{no:3,name:"COMPLETION_SOURCE_NETWORK"}]);var lt;(function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.C=1]="C",e[e.CLOJURE=2]="CLOJURE",e[e.COFFEESCRIPT=3]="COFFEESCRIPT",e[e.CPP=4]="CPP",e[e.CSHARP=5]="CSHARP",e[e.CSS=6]="CSS",e[e.CUDACPP=7]="CUDACPP",e[e.DOCKERFILE=8]="DOCKERFILE",e[e.GO=9]="GO",e[e.GROOVY=10]="GROOVY",e[e.HANDLEBARS=11]="HANDLEBARS",e[e.HASKELL=12]="HASKELL",e[e.HCL=13]="HCL",e[e.HTML=14]="HTML",e[e.INI=15]="INI",e[e.JAVA=16]="JAVA",e[e.JAVASCRIPT=17]="JAVASCRIPT",e[e.JSON=18]="JSON",e[e.JULIA=19]="JULIA",e[e.KOTLIN=20]="KOTLIN",e[e.LATEX=21]="LATEX",e[e.LESS=22]="LESS",e[e.LUA=23]="LUA",e[e.MAKEFILE=24]="MAKEFILE",e[e.MARKDOWN=25]="MARKDOWN",e[e.OBJECTIVEC=26]="OBJECTIVEC",e[e.OBJECTIVECPP=27]="OBJECTIVECPP",e[e.PERL=28]="PERL",e[e.PHP=29]="PHP",e[e.PLAINTEXT=30]="PLAINTEXT",e[e.PROTOBUF=31]="PROTOBUF",e[e.PBTXT=32]="PBTXT",e[e.PYTHON=33]="PYTHON",e[e.R=34]="R",e[e.RUBY=35]="RUBY",e[e.RUST=36]="RUST",e[e.SASS=37]="SASS",e[e.SCALA=38]="SCALA",e[e.SCSS=39]="SCSS",e[e.SHELL=40]="SHELL",e[e.SQL=41]="SQL",e[e.STARLARK=42]="STARLARK",e[e.SWIFT=43]="SWIFT",e[e.TSX=44]="TSX",e[e.TYPESCRIPT=45]="TYPESCRIPT",e[e.VISUALBASIC=46]="VISUALBASIC",e[e.VUE=47]="VUE",e[e.XML=48]="XML",e[e.XSL=49]="XSL",e[e.YAML=50]="YAML",e[e.SVELTE=51]="SVELTE",e[e.TOML=52]="TOML",e[e.DART=53]="DART",e[e.RST=54]="RST",e[e.OCAML=55]="OCAML",e[e.CMAKE=56]="CMAKE",e[e.PASCAL=57]="PASCAL",e[e.ELIXIR=58]="ELIXIR",e[e.FSHARP=59]="FSHARP",e[e.LISP=60]="LISP",e[e.MATLAB=61]="MATLAB",e[e.POWERSHELL=62]="POWERSHELL",e[e.SOLIDITY=63]="SOLIDITY",e[e.ADA=64]="ADA",e[e.OCAML_INTERFACE=65]="OCAML_INTERFACE"})(lt||(lt={})),A.util.setEnumType(lt,"exa.codeium_common_pb.Language",[{no:0,name:"LANGUAGE_UNSPECIFIED"},{no:1,name:"LANGUAGE_C"},{no:2,name:"LANGUAGE_CLOJURE"},{no:3,name:"LANGUAGE_COFFEESCRIPT"},{no:4,name:"LANGUAGE_CPP"},{no:5,name:"LANGUAGE_CSHARP"},{no:6,name:"LANGUAGE_CSS"},{no:7,name:"LANGUAGE_CUDACPP"},{no:8,name:"LANGUAGE_DOCKERFILE"},{no:9,name:"LANGUAGE_GO"},{no:10,name:"LANGUAGE_GROOVY"},{no:11,name:"LANGUAGE_HANDLEBARS"},{no:12,name:"LANGUAGE_HASKELL"},{no:13,name:"LANGUAGE_HCL"},{no:14,name:"LANGUAGE_HTML"},{no:15,name:"LANGUAGE_INI"},{no:16,name:"LANGUAGE_JAVA"},{no:17,name:"LANGUAGE_JAVASCRIPT"},{no:18,name:"LANGUAGE_JSON"},{no:19,name:"LANGUAGE_JULIA"},{no:20,name:"LANGUAGE_KOTLIN"},{no:21,name:"LANGUAGE_LATEX"},{no:22,name:"LANGUAGE_LESS"},{no:23,name:"LANGUAGE_LUA"},{no:24,name:"LANGUAGE_MAKEFILE"},{no:25,name:"LANGUAGE_MARKDOWN"},{no:26,name:"LANGUAGE_OBJECTIVEC"},{no:27,name:"LANGUAGE_OBJECTIVECPP"},{no:28,name:"LANGUAGE_PERL"},{no:29,name:"LANGUAGE_PHP"},{no:30,name:"LANGUAGE_PLAINTEXT"},{no:31,name:"LANGUAGE_PROTOBUF"},{no:32,name:"LANGUAGE_PBTXT"},{no:33,name:"LANGUAGE_PYTHON"},{no:34,name:"LANGUAGE_R"},{no:35,name:"LANGUAGE_RUBY"},{no:36,name:"LANGUAGE_RUST"},{no:37,name:"LANGUAGE_SASS"},{no:38,name:"LANGUAGE_SCALA"},{no:39,name:"LANGUAGE_SCSS"},{no:40,name:"LANGUAGE_SHELL"},{no:41,name:"LANGUAGE_SQL"},{no:42,name:"LANGUAGE_STARLARK"},{no:43,name:"LANGUAGE_SWIFT"},{no:44,name:"LANGUAGE_TSX"},{no:45,name:"LANGUAGE_TYPESCRIPT"},{no:46,name:"LANGUAGE_VISUALBASIC"},{no:47,name:"LANGUAGE_VUE"},{no:48,name:"LANGUAGE_XML"},{no:49,name:"LANGUAGE_XSL"},{no:50,name:"LANGUAGE_YAML"},{no:51,name:"LANGUAGE_SVELTE"},{no:52,name:"LANGUAGE_TOML"},{no:53,name:"LANGUAGE_DART"},{no:54,name:"LANGUAGE_RST"},{no:55,name:"LANGUAGE_OCAML"},{no:56,name:"LANGUAGE_CMAKE"},{no:57,name:"LANGUAGE_PASCAL"},{no:58,name:"LANGUAGE_ELIXIR"},{no:59,name:"LANGUAGE_FSHARP"},{no:60,name:"LANGUAGE_LISP"},{no:61,name:"LANGUAGE_MATLAB"},{no:62,name:"LANGUAGE_POWERSHELL"},{no:63,name:"LANGUAGE_SOLIDITY"},{no:64,name:"LANGUAGE_ADA"},{no:65,name:"LANGUAGE_OCAML_INTERFACE"}]);var Vl=(Ce=class extends Q{constructor(r){super();p(this,"completionId","");p(this,"text","");p(this,"prefix","");p(this,"stop","");p(this,"score",0);p(this,"tokens",[]);p(this,"decodedTokens",[]);p(this,"probabilities",[]);p(this,"adjustedProbabilities",[]);p(this,"generatedLength",W.zero);A.util.initPartial(r,this)}static fromBinary(r,n){return new Ce().fromBinary(r,n)}static fromJson(r,n){return new Ce().fromJson(r,n)}static fromJsonString(r,n){return new Ce().fromJsonString(r,n)}static equals(r,n){return A.util.equals(Ce,r,n)}},p(Ce,"runtime",A),p(Ce,"typeName","exa.codeium_common_pb.Completion"),p(Ce,"fields",A.util.newFieldList(()=>[{no:1,name:"completion_id",kind:"scalar",T:9},{no:2,name:"text",kind:"scalar",T:9},{no:3,name:"prefix",kind:"scalar",T:9},{no:4,name:"stop",kind:"scalar",T:9},{no:5,name:"score",kind:"scalar",T:1},{no:6,name:"tokens",kind:"scalar",T:4,repeated:!0},{no:7,name:"decoded_tokens",kind:"scalar",T:9,repeated:!0},{no:8,name:"probabilities",kind:"scalar",T:1,repeated:!0},{no:9,name:"adjusted_probabilities",kind:"scalar",T:1,repeated:!0},{no:10,name:"generated_length",kind:"scalar",T:4}])),Ce),Ho=(Ne=class extends Q{constructor(r){super();p(this,"ideName","");p(this,"ideVersion","");p(this,"extensionName","");p(this,"extensionVersion","");p(this,"apiKey","");p(this,"locale","");p(this,"sessionId","");p(this,"requestId",W.zero);p(this,"userAgent","");p(this,"url","");p(this,"authSource",gr.CODEIUM);A.util.initPartial(r,this)}static fromBinary(r,n){return new Ne().fromBinary(r,n)}static fromJson(r,n){return new Ne().fromJson(r,n)}static fromJsonString(r,n){return new Ne().fromJsonString(r,n)}static equals(r,n){return A.util.equals(Ne,r,n)}},p(Ne,"runtime",A),p(Ne,"typeName","exa.codeium_common_pb.Metadata"),p(Ne,"fields",A.util.newFieldList(()=>[{no:1,name:"ide_name",kind:"scalar",T:9},{no:7,name:"ide_version",kind:"scalar",T:9},{no:12,name:"extension_name",kind:"scalar",T:9},{no:2,name:"extension_version",kind:"scalar",T:9},{no:3,name:"api_key",kind:"scalar",T:9},{no:4,name:"locale",kind:"scalar",T:9},{no:10,name:"session_id",kind:"scalar",T:9},{no:9,name:"request_id",kind:"scalar",T:4},{no:13,name:"user_agent",kind:"scalar",T:9},{no:14,name:"url",kind:"scalar",T:9},{no:15,name:"auth_source",kind:"enum",T:A.getEnumType(gr)}])),Ne),Wl=(xe=class extends Q{constructor(r){super();p(this,"tabSize",W.zero);p(this,"insertSpaces",!1);A.util.initPartial(r,this)}static fromBinary(r,n){return new xe().fromBinary(r,n)}static fromJson(r,n){return new xe().fromJson(r,n)}static fromJsonString(r,n){return new xe().fromJsonString(r,n)}static equals(r,n){return A.util.equals(xe,r,n)}},p(xe,"runtime",A),p(xe,"typeName","exa.codeium_common_pb.EditorOptions"),p(xe,"fields",A.util.newFieldList(()=>[{no:1,name:"tab_size",kind:"scalar",T:4},{no:2,name:"insert_spaces",kind:"scalar",T:8}])),xe);Se=class extends Q{constructor(r){super();p(this,"eventType",pr.UNSPECIFIED);p(this,"eventJson","");p(this,"timestampUnixMs",W.zero);A.util.initPartial(r,this)}static fromBinary(r,n){return new Se().fromBinary(r,n)}static fromJson(r,n){return new Se().fromJson(r,n)}static fromJsonString(r,n){return new Se().fromJsonString(r,n)}static equals(r,n){return A.util.equals(Se,r,n)}},p(Se,"runtime",A),p(Se,"typeName","exa.codeium_common_pb.Event"),p(Se,"fields",A.util.newFieldList(()=>[{no:1,name:"event_type",kind:"enum",T:A.getEnumType(pr)},{no:2,name:"event_json",kind:"scalar",T:9},{no:3,name:"timestamp_unix_ms",kind:"scalar",T:3}]));var $l=class extends xt{constructor(t,r){super();p(this,"index");p(this,"total");this.index=t,this.total=r}toDOM(){let t=document.createElement("span");t.setAttribute("aria-hidden","true"),t.className="cm-codeium-cycle";let r=t.appendChild(document.createElement("span"));r.className="cm-codeium-cycle-explanation",r.innerText=`${this.index+1}/${this.total}`;let n=t.appendChild(document.createElement("button"));return n.className="cm-codeium-cycle-key",n.innerText="\u2192 (Ctrl ])",n.dataset.action="codeium-cycle",t}ignoreEvent(){return!1}};const yr=ft.define({combine(e){return Vr(e,{language:lt.TYPESCRIPT,timeout:150,widgetClass:$l,alwaysOn:!0},{})}}),qo=ft.define({combine(e){return Vr(e,{override:()=>[]},{})}});var Hl=_.mark({class:"cm-ghostText"});const ct=Ee.define({create(e){return null},update(e,t){var n;let r=t.state.facet(yr);for(let o of t.effects){if(o.is(rn)){let{changeSpecs:a,index:i}=o.value,s=a[i].map(d=>Hl.range(d.absoluteStartPos,d.absoluteEndPos)),l=(n=s.at(-1))==null?void 0:n.to,c=_.set([...s,...l!==void 0&&a.length>1&&r.widgetClass?[_.widget({widget:new r.widgetClass(i,a.length),side:1}).range(l)]:[]]);return{index:i,decorations:c,changeSpecs:a,reverseChangeSet:o.value.reverseChangeSet}}if(o.is(nn)||o.is(on))return null}return e&&{...e,decorations:e.decorations.map(t.changes),reverseChangeSet:e.reverseChangeSet.map(t.changes)}},provide:e=>L.decorations.from(e,t=>(t==null?void 0:t.decorations)||_.none)}),wt=Wr.define(),wr=Wr.define();var J;(function(e){e[e.Canceled=1]="Canceled",e[e.Unknown=2]="Unknown",e[e.InvalidArgument=3]="InvalidArgument",e[e.DeadlineExceeded=4]="DeadlineExceeded",e[e.NotFound=5]="NotFound",e[e.AlreadyExists=6]="AlreadyExists",e[e.PermissionDenied=7]="PermissionDenied",e[e.ResourceExhausted=8]="ResourceExhausted",e[e.FailedPrecondition=9]="FailedPrecondition",e[e.Aborted=10]="Aborted",e[e.OutOfRange=11]="OutOfRange",e[e.Unimplemented=12]="Unimplemented",e[e.Internal=13]="Internal",e[e.Unavailable=14]="Unavailable",e[e.DataLoss=15]="DataLoss",e[e.Unauthenticated=16]="Unauthenticated"})(J||(J={}));function fn(e){let t=J[e];return typeof t=="string"?t[0].toLowerCase()+t.substring(1).replace(/[A-Z]/g,r=>"_"+r.toLowerCase()):e.toString()}var vr;function ql(e){if(!vr){vr={};for(let t of Object.values(J))typeof t!="string"&&(vr[fn(t)]=t)}return vr[e]}var be=class It extends Error{constructor(t,r=J.Unknown,n,o,a){super(zl(t,r)),this.name="ConnectError",Object.setPrototypeOf(this,new.target.prototype),this.rawMessage=t,this.code=r,this.metadata=new Headers(n??{}),this.details=o??[],this.cause=a}static from(t,r=J.Unknown){return t instanceof It?t:t instanceof Error?t.name=="AbortError"?new It(t.message,J.Canceled):new It(t.message,r,void 0,void 0,t):new It(String(t),r,void 0,void 0,t)}static[Symbol.hasInstance](t){return t instanceof Error?Object.getPrototypeOf(t)===It.prototype?!0:t.name==="ConnectError"&&"code"in t&&typeof t.code=="number"&&"metadata"in t&&"details"in t&&Array.isArray(t.details)&&"rawMessage"in t&&typeof t.rawMessage=="string"&&"cause"in t:!1}findDetails(t){let r="typeName"in t?{findMessage:o=>o===t.typeName?t:void 0}:t,n=[];for(let o of this.details){if("getType"in o){r.findMessage(o.getType().typeName)&&n.push(o);continue}let a=r.findMessage(o.type);if(a)try{n.push(a.fromBinary(o.value))}catch{}}return n}};function zl(e,t){return e.length?`[${fn(t)}] ${e}`:`[${fn(t)}]`}function Kl(...e){let t=new Headers;for(let r of e)r.forEach((n,o)=>{t.append(o,n)});return t}function Yl(e,t){let r={};for(let[n,o]of Object.entries(e.methods)){let a=t(Object.assign(Object.assign({},o),{localName:n,service:e}));a!=null&&(r[n]=a)}return r}function Xl(e){let t,r=new Uint8Array;function n(o){let a=new Uint8Array(r.length+o.length);a.set(r),a.set(o,r.length),r=a}return new ReadableStream({start(){t=e.getReader()},async pull(o){let a;for(;;){if(a===void 0&&r.byteLength>=5){let l=0;for(let c=1;c<5;c++)l=(l<<8)+r[c];a={flags:r[0],length:l}}if(a!==void 0&&r.byteLength>=a.length+5)break;let s=await t.read();if(s.done)break;n(s.value)}if(a===void 0){if(r.byteLength==0){o.close();return}o.error(new be("premature end of stream",J.DataLoss));return}let i=r.subarray(5,5+a.length);r=r.subarray(5+a.length),o.enqueue({flags:a.flags,data:i})}})}function Ql(e,t){let r=new Uint8Array(t.length+5);r.set(t,5);let n=new DataView(r.buffer,r.byteOffset,r.byteLength);return n.setUint8(0,e),n.setUint32(1,t.length),r}var Zl=function(e){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof __values=="function"?__values(e):e[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(a){r[a]=e[a]&&function(i){return new Promise(function(s,l){i=e[a](i),o(s,l,i.done,i.value)})}}function o(a,i,s,l){Promise.resolve(l).then(function(c){a({value:c,done:s})},i)}},Mt=function(e){return this instanceof Mt?(this.v=e,this):new Mt(e)},ec=function(e,t,r){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(e,t||[]),o,a=[];return o={},s("next"),s("throw"),s("return",i),o[Symbol.asyncIterator]=function(){return this},o;function i(m){return function(g){return Promise.resolve(g).then(m,f)}}function s(m,g){n[m]&&(o[m]=function(b){return new Promise(function(y,E){a.push([m,b,y,E])>1||l(m,b)})},g&&(o[m]=g(o[m])))}function l(m,g){try{c(n[m](g))}catch(b){h(a[0][3],b)}}function c(m){m.value instanceof Mt?Promise.resolve(m.value.v).then(d,f):h(a[0][2],m)}function d(m){l("next",m)}function f(m){l("throw",m)}function h(m,g){m(g),a.shift(),a.length&&l(a[0][0],a[0][1])}},tc=function(e){var t,r;return t={},n("next"),n("throw",function(o){throw o}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(o,a){t[o]=e[o]?function(i){return(r=!r)?{value:Mt(e[o](i)),done:!1}:a?a(i):i}:a}};function rc(e){return ec(this,arguments,function*(){yield Mt(yield*tc(Zl(e)))})}var zo=function(e){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof __values=="function"?__values(e):e[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(a){r[a]=e[a]&&function(i){return new Promise(function(s,l){i=e[a](i),o(s,l,i.done,i.value)})}}function o(a,i,s,l){Promise.resolve(l).then(function(c){a({value:c,done:s})},i)}},vt=function(e){return this instanceof vt?(this.v=e,this):new vt(e)},nc=function(e){var t,r;return t={},n("next"),n("throw",function(o){throw o}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(o,a){t[o]=e[o]?function(i){return(r=!r)?{value:vt(e[o](i)),done:!1}:a?a(i):i}:a}},oc=function(e,t,r){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(e,t||[]),o,a=[];return o={},s("next"),s("throw"),s("return",i),o[Symbol.asyncIterator]=function(){return this},o;function i(m){return function(g){return Promise.resolve(g).then(m,f)}}function s(m,g){n[m]&&(o[m]=function(b){return new Promise(function(y,E){a.push([m,b,y,E])>1||l(m,b)})},g&&(o[m]=g(o[m])))}function l(m,g){try{c(n[m](g))}catch(b){h(a[0][3],b)}}function c(m){m.value instanceof vt?Promise.resolve(m.value.v).then(d,f):h(a[0][2],m)}function d(m){l("next",m)}function f(m){l("throw",m)}function h(m,g){m(g),a.shift(),a.length&&l(a[0][0],a[0][1])}};function ac(e,t){return Yl(e,r=>{switch(r.kind){case Ae.Unary:return sc(t,e,r);case Ae.ServerStreaming:return lc(t,e,r);case Ae.ClientStreaming:return cc(t,e,r);case Ae.BiDiStreaming:return uc(t,e,r);default:return null}})}function ic(e,t){return ac(e,t)}function sc(e,t,r){return async function(n,o){var a,i;let s=await e.unary(t,r,o==null?void 0:o.signal,o==null?void 0:o.timeoutMs,o==null?void 0:o.headers,n,o==null?void 0:o.contextValues);return(a=o==null?void 0:o.onHeader)==null||a.call(o,s.header),(i=o==null?void 0:o.onTrailer)==null||i.call(o,s.trailer),s.message}}function lc(e,t,r){return function(n,o){return Ko(e.stream(t,r,o==null?void 0:o.signal,o==null?void 0:o.timeoutMs,o==null?void 0:o.headers,rc([n]),o==null?void 0:o.contextValues),o)}}function cc(e,t,r){return async function(n,o){var a,i,s,l,c,d;let f=await e.stream(t,r,o==null?void 0:o.signal,o==null?void 0:o.timeoutMs,o==null?void 0:o.headers,n,o==null?void 0:o.contextValues);(c=o==null?void 0:o.onHeader)==null||c.call(o,f.header);let h,m=0;try{for(var g=!0,b=zo(f.message),y;y=await b.next(),a=y.done,!a;g=!0)l=y.value,g=!1,h=l,m++}catch(E){i={error:E}}finally{try{!g&&!a&&(s=b.return)&&await s.call(b)}finally{if(i)throw i.error}}if(!h)throw new be("protocol error: missing response message",J.Unimplemented);if(m>1)throw new be("protocol error: received extra messages for client streaming method",J.Unimplemented);return(d=o==null?void 0:o.onTrailer)==null||d.call(o,f.trailer),h}}function uc(e,t,r){return function(n,o){return Ko(e.stream(t,r,o==null?void 0:o.signal,o==null?void 0:o.timeoutMs,o==null?void 0:o.headers,n,o==null?void 0:o.contextValues),o)}}function Ko(e,t){let r=(function(){return oc(this,arguments,function*(){var n,o;let a=yield vt(e);(n=t==null?void 0:t.onHeader)==null||n.call(t,a.header),yield vt(yield*nc(zo(a.message))),(o=t==null?void 0:t.onTrailer)==null||o.call(t,a.trailer)})})()[Symbol.asyncIterator]();return{[Symbol.asyncIterator]:()=>({next:()=>r.next()})}}function dc(...e){let t=new AbortController,r=e.filter(o=>o!==void 0).concat(t.signal);for(let o of r){if(o.aborted){n.apply(o);break}o.addEventListener("abort",n)}function n(){t.signal.aborted||t.abort(Yo(this));for(let o of r)o.removeEventListener("abort",n)}return t}function fc(e){let t=new AbortController,r=()=>{t.abort(new be("the operation timed out",J.DeadlineExceeded))},n;return e!==void 0&&(e<=0?r():n=setTimeout(r,e)),{signal:t.signal,cleanup:()=>clearTimeout(n)}}function Yo(e){if(!e.aborted)return;if(e.reason!==void 0)return e.reason;let t=Error("This operation was aborted");return t.name="AbortError",t}function Xo(){return{get(e){return e.id in this?this[e.id]:e.defaultValue},set(e,t){return this[e.id]=t,this},delete(e){return delete this[e.id],this}}}function Qo(e,t,r){let n=typeof t=="string"?t:t.typeName,o=typeof r=="string"?r:r.name;return e.toString().replace(/\/?$/,`/${n}/${o}`)}function Zo(e,t){return t instanceof e?t:new e(t)}function mc(e,t){function r(n){return n.done===!0?n:{done:n.done,value:Zo(e,n.value)}}return{[Symbol.asyncIterator](){let n=t[Symbol.asyncIterator](),o={next:()=>n.next().then(r)};return n.throw!==void 0&&(o.throw=a=>n.throw(a).then(r)),n.return!==void 0&&(o.return=a=>n.return(a).then(r)),o}}}function ea(e,t){return(t==null?void 0:t.concat().reverse().reduce((r,n)=>n(r),e))??e}function ta(e){let t=Object.assign({},e);return t.ignoreUnknownFields??(t.ignoreUnknownFields=!0),t}function ra(e,t,r,n){let o=t?na(e.I,n):oa(e.I,r);return{parse:(t?na(e.O,n):oa(e.O,r)).parse,serialize:o.serialize}}function na(e,t){return{parse(r){try{return e.fromBinary(r,t)}catch(n){let o=n instanceof Error?n.message:String(n);throw new be(`parse binary: ${o}`,J.Internal)}},serialize(r){try{return r.toBinary(t)}catch(n){let o=n instanceof Error?n.message:String(n);throw new be(`serialize binary: ${o}`,J.Internal)}}}}function oa(e,t){let r=(t==null?void 0:t.textEncoder)??new TextEncoder,n=(t==null?void 0:t.textDecoder)??new TextDecoder,o=ta(t);return{parse(a){try{let i=n.decode(a);return e.fromJsonString(i,o)}catch(i){throw be.from(i,J.InvalidArgument)}},serialize(a){try{let i=a.toJsonString(o);return r.encode(i)}catch(i){throw be.from(i,J.Internal)}}}}const hc=/^application\/(connect\+)?(?:(json)(?:; ?charset=utf-?8)?|(proto))$/i;function gc(e){let t=e==null?void 0:e.match(hc);if(!t)return;let r=!!t[1],n=!!t[3];return{stream:r,binary:n}}function aa(e,t,r){if(t&&new Headers(t).forEach((i,s)=>r.metadata.append(s,i)),typeof e!="object"||!e||Array.isArray(e))throw r;let n=r.code;"code"in e&&typeof e.code=="string"&&(n=ql(e.code)??n);let o=e.message;if(o!=null&&typeof o!="string")throw r;let a=new be(o??"",n,t);if("details"in e&&Array.isArray(e.details))for(let i of e.details){if(typeof i!="object"||!i||Array.isArray(i)||typeof i.type!="string"||typeof i.value!="string")throw r;try{a.details.push({type:i.type,value:lr.dec(i.value),debug:i.debug})}catch{throw r}}return a}function pc(e){let t=new be("invalid end stream",J.Unknown),r;try{r=JSON.parse(typeof e=="string"?e:new TextDecoder().decode(e))}catch{throw t}if(typeof r!="object"||!r||Array.isArray(r))throw t;let n=new Headers;if("metadata"in r){if(typeof r.metadata!="object"||r.metadata==null||Array.isArray(r.metadata))throw t;for(let[a,i]of Object.entries(r.metadata)){if(!Array.isArray(i)||i.some(s=>typeof s!="string"))throw t;for(let s of i)n.append(a,s)}}let o="error"in r&&r.error!=null?aa(r.error,n,t):void 0;return{metadata:n,error:o}}const Er="Content-Type",ia="Content-Encoding",sa="Connect-Protocol-Version";function bc(e){switch(e){case 400:return J.Internal;case 401:return J.Unauthenticated;case 403:return J.PermissionDenied;case 404:return J.Unimplemented;case 429:return J.Unavailable;case 502:return J.Unavailable;case 503:return J.Unavailable;case 504:return J.Unavailable;default:return J.Unknown}}function la(e){let t=new Headers,r=new Headers;return e.forEach((n,o)=>{o.toLowerCase().startsWith("trailer-")?r.append(o.substring(8),n):t.append(o,n)}),[t,r]}function ca(e,t,r,n,o){let a=new Headers(n??{});return r!==void 0&&a.set("Connect-Timeout-Ms",`${r}`),a.set(Er,e==Ae.Unary?t?"application/proto":"application/json":t?"application/connect+proto":"application/connect+json"),a.set(sa,"1"),o&&a.set("User-Agent","connect-es/1.6.1"),a}function ua(e,t,r,n){let o=n.get(Er),a=gc(o);if(r!==200){let s=new be(`HTTP ${r}`,bc(r),n);if(e==Ae.Unary&&a&&!a.binary)return{isUnaryError:!0,unaryError:s};throw s}let i={binary:t,stream:e!==Ae.Unary};if((a==null?void 0:a.binary)!==i.binary||a.stream!==i.stream)throw new be(`unsupported content type ${o}`,a===void 0?J.Unknown:J.Internal,n);return{isUnaryError:!1}}var yc="application/";function wc(e,t){return t?lr.enc(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""):encodeURIComponent(new TextDecoder().decode(e))}function vc(e,t,r){let n="?connect=v1",o=e.header.get(Er);(o==null?void 0:o.indexOf(yc))===0&&(n+="&encoding="+encodeURIComponent(o.slice(12)));let a=e.header.get(ia);a!==null&&a!=="identity"&&(n+="&compression="+encodeURIComponent(a),r=!0),r&&(n+="&base64=1"),n+="&message="+wc(t,r);let i=e.url+n,s=new Headers(e.header);return[sa,Er,"Content-Length",ia,"Accept-Encoding"].forEach(l=>s.delete(l)),Object.assign(Object.assign({},e),{init:Object.assign(Object.assign({},e.init),{method:"GET"}),url:i,header:s})}function Ec(e){let t=ea(e.next,e.interceptors),[r,n,o]=da(e),a=Object.assign(Object.assign({},e.req),{message:Zo(e.req.method.I,e.req.message),signal:r});return t(a).then(i=>(o(),i),n)}function kc(e){let t=ea(e.next,e.interceptors),[r,n,o]=da(e),a=Object.assign(Object.assign({},e.req),{message:mc(e.req.method.I,e.req.message),signal:r}),i=!1;return r.addEventListener("abort",function(){var s,l;let c=e.req.message[Symbol.asyncIterator]();i||(s=c.throw)==null||s.call(c,this.reason).catch(()=>{}),(l=c.return)==null||l.call(c).catch(()=>{})}),t(a).then(s=>Object.assign(Object.assign({},s),{message:{[Symbol.asyncIterator](){let l=s.message[Symbol.asyncIterator]();return{next(){return l.next().then(c=>(c.done==1&&(i=!0,o()),c),n)}}}}}),n)}function da(e){let{signal:t,cleanup:r}=fc(e.timeoutMs),n=dc(e.signal,t);return[n.signal,function(o){let a=be.from(t.aborted?Yo(t):o);return n.abort(a),r(),Promise.reject(a)},function(){r(),n.abort()}]}var kr;(function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.INACTIVE=1]="INACTIVE",e[e.PROCESSING=2]="PROCESSING",e[e.SUCCESS=3]="SUCCESS",e[e.WARNING=4]="WARNING",e[e.ERROR=5]="ERROR"})(kr||(kr={})),A.util.setEnumType(kr,"exa.language_server_pb.CodeiumState",[{no:0,name:"CODEIUM_STATE_UNSPECIFIED"},{no:1,name:"CODEIUM_STATE_INACTIVE"},{no:2,name:"CODEIUM_STATE_PROCESSING"},{no:3,name:"CODEIUM_STATE_SUCCESS"},{no:4,name:"CODEIUM_STATE_WARNING"},{no:5,name:"CODEIUM_STATE_ERROR"}]);var fa;(function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.SINGLE=1]="SINGLE",e[e.MULTI=2]="MULTI"})(fa||(fa={})),A.util.setEnumType(fa,"exa.language_server_pb.LineType",[{no:0,name:"LINE_TYPE_UNSPECIFIED"},{no:1,name:"LINE_TYPE_SINGLE"},{no:2,name:"LINE_TYPE_MULTI"}]);var Ar;(function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.INLINE=1]="INLINE",e[e.BLOCK=2]="BLOCK",e[e.INLINE_MASK=3]="INLINE_MASK"})(Ar||(Ar={})),A.util.setEnumType(Ar,"exa.language_server_pb.CompletionPartType",[{no:0,name:"COMPLETION_PART_TYPE_UNSPECIFIED"},{no:1,name:"COMPLETION_PART_TYPE_INLINE"},{no:2,name:"COMPLETION_PART_TYPE_BLOCK"},{no:3,name:"COMPLETION_PART_TYPE_INLINE_MASK"}]);var Ac=(Te=class extends Q{constructor(r){super();p(this,"threshold",0);A.util.initPartial(r,this)}static fromBinary(r,n){return new Te().fromBinary(r,n)}static fromJson(r,n){return new Te().fromJson(r,n)}static fromJsonString(r,n){return new Te().fromJsonString(r,n)}static equals(r,n){return A.util.equals(Te,r,n)}},p(Te,"runtime",A),p(Te,"typeName","exa.language_server_pb.MultilineConfig"),p(Te,"fields",A.util.newFieldList(()=>[{no:1,name:"threshold",kind:"scalar",T:2}])),Te),Cc=(Ie=class extends Q{constructor(r){super();p(this,"metadata");p(this,"document");p(this,"editorOptions");p(this,"otherDocuments",[]);p(this,"experimentConfig");p(this,"modelName","");p(this,"multilineConfig");A.util.initPartial(r,this)}static fromBinary(r,n){return new Ie().fromBinary(r,n)}static fromJson(r,n){return new Ie().fromJson(r,n)}static fromJsonString(r,n){return new Ie().fromJsonString(r,n)}static equals(r,n){return A.util.equals(Ie,r,n)}},p(Ie,"runtime",A),p(Ie,"typeName","exa.language_server_pb.GetCompletionsRequest"),p(Ie,"fields",A.util.newFieldList(()=>[{no:1,name:"metadata",kind:"message",T:Ho},{no:2,name:"document",kind:"message",T:ma},{no:3,name:"editor_options",kind:"message",T:Wl},{no:5,name:"other_documents",kind:"message",T:ma,repeated:!0},{no:7,name:"experiment_config",kind:"message",T:Fc},{no:10,name:"model_name",kind:"scalar",T:9},{no:13,name:"multiline_config",kind:"message",T:Ac}])),Ie),Nc=(Fe=class extends Q{constructor(r){super();p(this,"state");p(this,"completionItems",[]);A.util.initPartial(r,this)}static fromBinary(r,n){return new Fe().fromBinary(r,n)}static fromJson(r,n){return new Fe().fromJson(r,n)}static fromJsonString(r,n){return new Fe().fromJsonString(r,n)}static equals(r,n){return A.util.equals(Fe,r,n)}},p(Fe,"runtime",A),p(Fe,"typeName","exa.language_server_pb.GetCompletionsResponse"),p(Fe,"fields",A.util.newFieldList(()=>[{no:1,name:"state",kind:"message",T:Lc},{no:2,name:"completion_items",kind:"message",T:Uc,repeated:!0}])),Fe),xc=(Le=class extends Q{constructor(r){super();p(this,"metadata");p(this,"completionId","");A.util.initPartial(r,this)}static fromBinary(r,n){return new Le().fromBinary(r,n)}static fromJson(r,n){return new Le().fromJson(r,n)}static fromJsonString(r,n){return new Le().fromJsonString(r,n)}static equals(r,n){return A.util.equals(Le,r,n)}},p(Le,"runtime",A),p(Le,"typeName","exa.language_server_pb.AcceptCompletionRequest"),p(Le,"fields",A.util.newFieldList(()=>[{no:1,name:"metadata",kind:"message",T:Ho},{no:2,name:"completion_id",kind:"scalar",T:9}])),Le),Sc=(Oe=class extends Q{constructor(t){super(),A.util.initPartial(t,this)}static fromBinary(t,r){return new Oe().fromBinary(t,r)}static fromJson(t,r){return new Oe().fromJson(t,r)}static fromJsonString(t,r){return new Oe().fromJsonString(t,r)}static equals(t,r){return A.util.equals(Oe,t,r)}},p(Oe,"runtime",A),p(Oe,"typeName","exa.language_server_pb.AcceptCompletionResponse"),p(Oe,"fields",A.util.newFieldList(()=>[])),Oe),Tc=(Be=class extends Q{constructor(t){super(),A.util.initPartial(t,this)}static fromBinary(t,r){return new Be().fromBinary(t,r)}static fromJson(t,r){return new Be().fromJson(t,r)}static fromJsonString(t,r){return new Be().fromJsonString(t,r)}static equals(t,r){return A.util.equals(Be,t,r)}},p(Be,"runtime",A),p(Be,"typeName","exa.language_server_pb.GetAuthTokenRequest"),p(Be,"fields",A.util.newFieldList(()=>[])),Be),Ic=(De=class extends Q{constructor(r){super();p(this,"authToken","");p(this,"uuid","");A.util.initPartial(r,this)}static fromBinary(r,n){return new De().fromBinary(r,n)}static fromJson(r,n){return new De().fromJson(r,n)}static fromJsonString(r,n){return new De().fromJsonString(r,n)}static equals(r,n){return A.util.equals(De,r,n)}},p(De,"runtime",A),p(De,"typeName","exa.language_server_pb.GetAuthTokenResponse"),p(De,"fields",A.util.newFieldList(()=>[{no:1,name:"auth_token",kind:"scalar",T:9},{no:2,name:"uuid",kind:"scalar",T:9}])),De),mn=(Ue=class extends Q{constructor(r){super();p(this,"row",W.zero);p(this,"col",W.zero);A.util.initPartial(r,this)}static fromBinary(r,n){return new Ue().fromBinary(r,n)}static fromJson(r,n){return new Ue().fromJson(r,n)}static fromJsonString(r,n){return new Ue().fromJsonString(r,n)}static equals(r,n){return A.util.equals(Ue,r,n)}},p(Ue,"runtime",A),p(Ue,"typeName","exa.language_server_pb.DocumentPosition"),p(Ue,"fields",A.util.newFieldList(()=>[{no:1,name:"row",kind:"scalar",T:4},{no:2,name:"col",kind:"scalar",T:4}])),Ue),ma=(_e=class extends Q{constructor(r){super();p(this,"absolutePath","");p(this,"relativePath","");p(this,"text","");p(this,"editorLanguage","");p(this,"language",lt.UNSPECIFIED);p(this,"cursorOffset",W.zero);p(this,"cursorPosition");p(this,"lineEnding","");A.util.initPartial(r,this)}static fromBinary(r,n){return new _e().fromBinary(r,n)}static fromJson(r,n){return new _e().fromJson(r,n)}static fromJsonString(r,n){return new _e().fromJsonString(r,n)}static equals(r,n){return A.util.equals(_e,r,n)}},p(_e,"runtime",A),p(_e,"typeName","exa.language_server_pb.Document"),p(_e,"fields",A.util.newFieldList(()=>[{no:1,name:"absolute_path",kind:"scalar",T:9},{no:2,name:"relative_path",kind:"scalar",T:9},{no:3,name:"text",kind:"scalar",T:9},{no:4,name:"editor_language",kind:"scalar",T:9},{no:5,name:"language",kind:"enum",T:A.getEnumType(lt)},{no:6,name:"cursor_offset",kind:"scalar",T:4},{no:8,name:"cursor_position",kind:"message",T:mn},{no:7,name:"line_ending",kind:"scalar",T:9}])),_e),Fc=(Me=class extends Q{constructor(r){super();p(this,"forceEnableExperiments",[]);A.util.initPartial(r,this)}static fromBinary(r,n){return new Me().fromBinary(r,n)}static fromJson(r,n){return new Me().fromJson(r,n)}static fromJsonString(r,n){return new Me().fromJsonString(r,n)}static equals(r,n){return A.util.equals(Me,r,n)}},p(Me,"runtime",A),p(Me,"typeName","exa.language_server_pb.ExperimentConfig"),p(Me,"fields",A.util.newFieldList(()=>[{no:1,name:"force_enable_experiments",kind:"enum",T:A.getEnumType(dn),repeated:!0}])),Me),Lc=(Pe=class extends Q{constructor(r){super();p(this,"state",kr.UNSPECIFIED);p(this,"message","");A.util.initPartial(r,this)}static fromBinary(r,n){return new Pe().fromBinary(r,n)}static fromJson(r,n){return new Pe().fromJson(r,n)}static fromJsonString(r,n){return new Pe().fromJsonString(r,n)}static equals(r,n){return A.util.equals(Pe,r,n)}},p(Pe,"runtime",A),p(Pe,"typeName","exa.language_server_pb.State"),p(Pe,"fields",A.util.newFieldList(()=>[{no:1,name:"state",kind:"enum",T:A.getEnumType(kr)},{no:2,name:"message",kind:"scalar",T:9}])),Pe),Oc=(je=class extends Q{constructor(r){super();p(this,"startOffset",W.zero);p(this,"endOffset",W.zero);p(this,"startPosition");p(this,"endPosition");A.util.initPartial(r,this)}static fromBinary(r,n){return new je().fromBinary(r,n)}static fromJson(r,n){return new je().fromJson(r,n)}static fromJsonString(r,n){return new je().fromJsonString(r,n)}static equals(r,n){return A.util.equals(je,r,n)}},p(je,"runtime",A),p(je,"typeName","exa.language_server_pb.Range"),p(je,"fields",A.util.newFieldList(()=>[{no:1,name:"start_offset",kind:"scalar",T:4},{no:2,name:"end_offset",kind:"scalar",T:4},{no:3,name:"start_position",kind:"message",T:mn},{no:4,name:"end_position",kind:"message",T:mn}])),je),Bc=(Re=class extends Q{constructor(r){super();p(this,"text","");p(this,"deltaCursorOffset",W.zero);A.util.initPartial(r,this)}static fromBinary(r,n){return new Re().fromBinary(r,n)}static fromJson(r,n){return new Re().fromJson(r,n)}static fromJsonString(r,n){return new Re().fromJsonString(r,n)}static equals(r,n){return A.util.equals(Re,r,n)}},p(Re,"runtime",A),p(Re,"typeName","exa.language_server_pb.Suffix"),p(Re,"fields",A.util.newFieldList(()=>[{no:1,name:"text",kind:"scalar",T:9},{no:2,name:"delta_cursor_offset",kind:"scalar",T:3}])),Re),Dc=(Ge=class extends Q{constructor(r){super();p(this,"text","");p(this,"offset",W.zero);p(this,"type",Ar.UNSPECIFIED);p(this,"prefix","");p(this,"line",W.zero);A.util.initPartial(r,this)}static fromBinary(r,n){return new Ge().fromBinary(r,n)}static fromJson(r,n){return new Ge().fromJson(r,n)}static fromJsonString(r,n){return new Ge().fromJsonString(r,n)}static equals(r,n){return A.util.equals(Ge,r,n)}},p(Ge,"runtime",A),p(Ge,"typeName","exa.language_server_pb.CompletionPart"),p(Ge,"fields",A.util.newFieldList(()=>[{no:1,name:"text",kind:"scalar",T:9},{no:2,name:"offset",kind:"scalar",T:4},{no:3,name:"type",kind:"enum",T:A.getEnumType(Ar)},{no:4,name:"prefix",kind:"scalar",T:9},{no:5,name:"line",kind:"scalar",T:4}])),Ge),Uc=(Je=class extends Q{constructor(r){super();p(this,"completion");p(this,"suffix");p(this,"range");p(this,"source",br.UNSPECIFIED);p(this,"completionParts",[]);A.util.initPartial(r,this)}static fromBinary(r,n){return new Je().fromBinary(r,n)}static fromJson(r,n){return new Je().fromJson(r,n)}static fromJsonString(r,n){return new Je().fromJsonString(r,n)}static equals(r,n){return A.util.equals(Je,r,n)}},p(Je,"runtime",A),p(Je,"typeName","exa.language_server_pb.CompletionItem"),p(Je,"fields",A.util.newFieldList(()=>[{no:1,name:"completion",kind:"message",T:Vl},{no:5,name:"suffix",kind:"message",T:Bc},{no:2,name:"range",kind:"message",T:Oc},{no:3,name:"source",kind:"enum",T:A.getEnumType(br)},{no:8,name:"completion_parts",kind:"message",T:Dc,repeated:!0}])),Je);const _c={typeName:"exa.language_server_pb.LanguageServerService",methods:{getCompletions:{name:"GetCompletions",I:Cc,O:Nc,kind:Ae.Unary},acceptCompletion:{name:"AcceptCompletion",I:xc,O:Sc,kind:Ae.Unary},getAuthToken:{name:"GetAuthToken",I:Tc,O:Ic,kind:Ae.Unary}}};function Mc(){try{new Headers}catch{throw Error("connect-web requires the fetch API. Are you running on an old version of Node.js? Node.js is not supported in Connect for Web - please stay tuned for Connect for Node.")}}var Pt=function(e){return this instanceof Pt?(this.v=e,this):new Pt(e)},Pc=function(e,t,r){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(e,t||[]),o,a=[];return o={},s("next"),s("throw"),s("return",i),o[Symbol.asyncIterator]=function(){return this},o;function i(m){return function(g){return Promise.resolve(g).then(m,f)}}function s(m,g){n[m]&&(o[m]=function(b){return new Promise(function(y,E){a.push([m,b,y,E])>1||l(m,b)})},g&&(o[m]=g(o[m])))}function l(m,g){try{c(n[m](g))}catch(b){h(a[0][3],b)}}function c(m){m.value instanceof Pt?Promise.resolve(m.value.v).then(d,f):h(a[0][2],m)}function d(m){l("next",m)}function f(m){l("throw",m)}function h(m,g){m(g),a.shift(),a.length&&l(a[0][0],a[0][1])}};function jc(e){Mc();let t=e.useBinaryFormat??!1;return{async unary(r,n,o,a,i,s,l){let{serialize:c,parse:d}=ra(n,t,e.jsonOptions,e.binaryOptions);return a=a===void 0?e.defaultTimeoutMs:a<=0?void 0:a,await Ec({interceptors:e.interceptors,signal:o,timeoutMs:a,req:{stream:!1,service:r,method:n,url:Qo(e.baseUrl,r,n),init:{method:"POST",credentials:e.credentials??"same-origin",redirect:"error",mode:"cors"},header:ca(n.kind,t,a,i,!1),contextValues:l??Xo(),message:s},next:async f=>{let h=e.useHttpGet===!0&&n.idempotency===$o.NoSideEffects,m=null;h?f=vc(f,c(f.message),t):m=c(f.message);let g=await(e.fetch??globalThis.fetch)(f.url,Object.assign(Object.assign({},f.init),{headers:f.header,signal:f.signal,body:m})),{isUnaryError:b,unaryError:y}=ua(n.kind,t,g.status,g.headers);if(b)throw aa(await g.json(),Kl(...la(g.headers)),y);let[E,C]=la(g.headers);return{stream:!1,service:r,method:n,header:E,message:t?d(new Uint8Array(await g.arrayBuffer())):n.O.fromJson(await g.json(),ta(e.jsonOptions)),trailer:C}}})},async stream(r,n,o,a,i,s,l){let{serialize:c,parse:d}=ra(n,t,e.jsonOptions,e.binaryOptions);function f(m,g,b,y){return Pc(this,arguments,function*(){let E=Xl(m).getReader(),C=!1;for(;;){let O=yield Pt(E.read());if(O.done)break;let{flags:M,data:B}=O.value;if((M&1)==1)throw new be("protocol error: received unsupported compressed output",J.Internal);if((M&2)==2){C=!0;let S=pc(B);if(S.error){let x=S.error;throw b.forEach((H,j)=>{x.metadata.append(j,H)}),x}S.metadata.forEach((x,H)=>g.set(H,x));continue}yield yield Pt(d(B))}if("throwIfAborted"in y&&y.throwIfAborted(),!C)throw"missing EndStreamResponse"})}async function h(m){if(n.kind!=Ae.ServerStreaming)throw"The fetch API does not support streaming request bodies";let g=await m[Symbol.asyncIterator]().next();if(g.done==1)throw"missing request message";return Ql(0,c(g.value))}return a=a===void 0?e.defaultTimeoutMs:a<=0?void 0:a,await kc({interceptors:e.interceptors,timeoutMs:a,signal:o,req:{stream:!0,service:r,method:n,url:Qo(e.baseUrl,r,n),init:{method:"POST",credentials:e.credentials??"same-origin",redirect:"error",mode:"cors"},header:ca(n.kind,t,a,i,!1),contextValues:l??Xo(),message:s},next:async m=>{let g=await(e.fetch??globalThis.fetch)(m.url,Object.assign(Object.assign({},m.init),{headers:m.header,signal:m.signal,body:await h(m.message)}));if(ua(n.kind,t,g.status,g.headers),g.body===null)throw"missing response body";let b=new Headers;return Object.assign(Object.assign({},m),{header:g.headers,trailer:b,message:f(g.body,b,g.headers,m.signal)})}})}}}var Rc=jc({baseUrl:"https://web-backend.codeium.com",useBinaryFormat:!0}),Gc=ic(_c,Rc),Cr;try{Cr=crypto.randomUUID()}catch{Cr=function(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,t=>(t^(crypto.getRandomValues(new Uint8Array(1))[0]??0)&15>>t/4).toString(16))}()}async function Jc({text:e,cursorOffset:t,config:r,otherDocuments:n}){return await Gc.getCompletions({metadata:{ideName:"web",ideVersion:"0.0.5",extensionName:"@valtown/codemirror-codeium",extensionVersion:"1.0.0",apiKey:r.apiKey,sessionId:Cr,authSource:r.authSource},document:{text:e,cursorOffset:BigInt(t),language:r.language,editorLanguage:"typescript",lineEnding:`
|
|
11
|
+
`},editorOptions:{tabSize:2n,insertSpaces:!0},otherDocuments:n,multilineConfig:void 0},{headers:{Authorization:`Basic ${r.apiKey}-${Cr}`}})}function Vc(e){return e.completionItems.map(t=>{let r=0;return t.completionParts.filter(n=>n.type!==3).map(n=>{let o=Number(n.offset),a=n.type===2?`
|
|
12
|
+
${n.text}`:n.text,i={absoluteStartPos:r+o,absoluteEndPos:r+o+a.length,from:o,to:o,insert:a};return r+=a.length,i})})}async function Wc(e,t){let r=e.state.facet(yr),{override:n}=e.state.facet(qo),o=await n(),a=e.state,i=a.selection.main.head,s=a.doc.toString();try{let l=await Jc({text:s,cursorOffset:i,config:r,otherDocuments:o});if(!l||l.completionItems.length===0||!((t===void 0||i===t)&&Qt(e.state)!=="active"&&e.hasFocus))return;let c=Vc(l),d=c.at(0);if(!d)return;let f=Yt.of(d,a.doc.length),h=f.invert(a.doc);e.dispatch({changes:f,effects:rn.of({index:0,reverseChangeSet:h,changeSpecs:c}),annotations:[wr.of(null),wt.of(null),Kt.addToHistory.of(!1)]})}catch(l){console.warn("copilot completion failed",l),await new Promise(c=>setTimeout(c,300))}}function $c(e){return e.docChanged&&!e.transactions.some(t=>t.effects.some(r=>r.is(nn)||r.is(on)))}function Hc(e){if(!e.view.hasFocus||e.state.field(ct)||Qt(e.state)==="active")return!0;for(let t of e.transactions)if(t.annotation(wt)!==void 0)return!0}function qc(){let e=null,t=0;return L.updateListener.of(r=>{let n=r.view.state.facet(yr);if(!n.alwaysOn||!$c(r)||(e&&clearTimeout(e),Hc(r)))return;let o=r.state.selection.main.head;n.shouldComplete&&!n.shouldComplete(new Qm(r.view.state,o,!1))||(e=setTimeout(async()=>{o===t&&await Wc(r.view,t)},n.timeout),t=o)})}function ha(e){var o;let t=e.state.field(ct);if(!t)return!1;let r=(o=t.reverseChangeSet)==null?void 0:o.invert(e.state.doc);e.dispatch({changes:t.reverseChangeSet,effects:nn.of(null),annotations:[wr.of(null),wt.of(null),Kt.addToHistory.of(!1)]});let n=0;return r==null||r.iterChangedRanges((a,i,s,l)=>{n=l}),e.dispatch({changes:r,selection:mt.cursor(n),annotations:[wt.of(null),Kt.addToHistory.of(!0)]}),!0}const ga=e=>{let{state:t}=e,r=t.field(ct);if(!r)return!1;let{changeSpecs:n}=r;if(n.length<2)return!1;let o=(r.index+1)%n.length,a=n.at(o);if(!a)return!1;let i=r.reverseChangeSet.apply(t.doc),s=Yt.of(r.reverseChangeSet,t.doc.length).compose(Yt.of(a,i.length)),l=Yt.of(a,i.length).invert(i);return e.dispatch({changes:s,effects:rn.of({index:o,reverseChangeSet:l,changeSpecs:n}),annotations:[wr.of(null),wt.of(null),Kt.addToHistory.of(!1)]}),!0};function hn(e){let t=e.state.field(ct);return t&&e.dispatch({changes:t.reverseChangeSet,effects:on.of(null),annotations:[wr.of(null),wt.of(null),Kt.addToHistory.of(!1)]}),!1}function zc(e,t){return e.state.field(ct)?t==="Tab"?ha(e):hn(e):!1}function Kc(e){var o,a;let t=!1,r=(o=e.state.selection.asSingle().ranges.at(0))==null?void 0:o.head,n=e.state.field(ct);return r!==void 0&&n?((a=n.decorations)==null||a.between(r,r,()=>{t=!0}),t):!1}function Yc(){return L.domEventHandlers({keydown(e,t){return e.key==="]"&&e.ctrlKey?!1:e.key!=="Shift"&&e.key!=="Control"&&e.key!=="Alt"&&e.key!=="Meta"?zc(t,e.key):!1},mouseup(e,t){let r=e.target;return r.nodeName==="BUTTON"&&r.dataset.action==="codeium-cycle"?(ga(t),e.stopPropagation(),e.preventDefault(),!0):Kc(t)?ha(t):hn(t)}})}function Xc(){return $e.of([{key:"Ctrl-]",run:ga}])}function Qc(){return L.updateListener.of(e=>{e.focusChanged&&hn(e.view)})}function Zc(e){return[yr.of(e),ct,tt.highest(Xc()),tt.highest(Qc()),tt.high(Yc()),qc()]}function eu({response:e,prefix:t,suffix:r}){if(!e)return e;let n=e;return t&&n.startsWith(t)&&(n=n.slice(t.length)),r&&n.endsWith(r)&&(n=n.slice(0,-r.length)),n}var tu=pe(Of()),ru=new Kn,gn=Ze.get("@github/copilot-language-server"),pa={delay:300,includeKeymap:!0,events:{shouldShowSuggestion:e=>e.hasFocus,beforeSuggestionFetch:e=>e.hasFocus}};const nu=e=>{let t=[];return e.copilot==="codeium"&&e.codeium_api_key&&t.push(Zc({apiKey:e.codeium_api_key,language:lt.PYTHON}),qo.of({override:async()=>[{text:Gn(""),language:lt.PYTHON,editorLanguage:"python"}]})),e.copilot==="github"&&t.push(fo({...pa,fetchFn:async(r,n,o)=>{let a=r.selection.main.head;if(!Qf()||!o.hasFocus||r.doc.length===0)return"";await new Promise(d=>setTimeout(d,20));let i=r.doc.toString(),s=Gn(i),l=ou(r,s),c=await Zf().getCompletion(l);return a===o.state.selection.main.head?au(c,l.position,r):(Ze.debug("ignoring response because of new position"),"")}})),e.copilot==="custom"&&t.push(fo({...pa,fetchFn:async(r,n,o)=>{let a=r.selection.main.head;if(r.doc.length===0||!o.hasFocus)return"";let i=r.doc.sliceString(0,r.selection.main.head),s=r.doc.sliceString(r.selection.main.head,r.doc.length);if(i.length===0)return"";let l=r.field(Gr).type,c=await lm.post("/ai/inline_completion",{prefix:i,suffix:s,language:l});return a===o.state.selection.main.head?(c=eu({response:c,prefix:i,suffix:s}),c):(Ze.debug("ignoring response because of new position"),"")}})),[...t,tt.highest($e.of([{key:"Escape",run:r=>{let n=uo(r);return Rr(r)?!1:n}}])),ru.of(Xf())]};function ou(e,t){let r=e.doc.toString(),n=t.split(`
|
|
13
13
|
`).length-r.split(`
|
|
14
|
-
`).length,o=
|
|
15
|
-
`),n=[],o=!1,a=0,i=!1,s=!1,l=0,c=/\(/g,d=/\)/g,f=new Set(["@"]);function h(g){return(g.match(c)||[]).length-(g.match(d)||[]).length}function m(){if(n.length!==0){for(;n.length>0&&n[n.length-1].trim().startsWith("return");)n.pop();n.some(g=>g.trim()!=="")&&t.push(
|
|
16
|
-
`))),n=[]}}for(let g of r){let b=g.trim();if(!(!b&&!o)){if(b.startsWith("@app.cell")){m(),o=!0,a=1;continue}if(a>0){b.startsWith("def")&&b.includes("(")&&!b.includes("):")&&(i=!0,l=h(b)),a--;continue}if(i){l+=h(b),l===0&&(i=!1);continue}if(o){if(f.has(b[0])||b.startsWith("if __name__")){m(),o=b.startsWith("@");continue}if(b.startsWith("return")){b.includes("(")&&!b.endsWith(")")&&(s=!0,l=h(b));continue}if(s){l+=h(b),l===0&&(s=!1);continue}n.push(g)}}}return m(),t}function
|
|
14
|
+
`).length,o=iu(e.doc,e.selection.main.head);return o.line+=n,{textDocument:{uri:`file://${em}`,version:"replace_me"},position:o,context:{triggerKind:tu.InlineCompletionTriggerKind.Automatic},formattingOptions:{tabSize:e.tabSize,insertSpaces:!0}}}function au(e,t,r){if(!e)return gn.debug("No response from copilot"),"";let n=Array.isArray(e)?e[0]:e.items[0];if(!n)return gn.debug("No response from copilot"),"";let{insertText:o,range:a}=n,i=String(o);if(!a)return gn.error("No range from copilot"),i;let s=a.start.character-t.character,l=s<0?i.slice(-s):i,c=r.doc.sliceString(r.selection.main.head,r.doc.length);for(let d=0;d<l.length;d++){let f=l.slice(d);if(c.startsWith(f))return l.slice(0,d)}return l}function iu(e,t){let r=e.lineAt(t);return{line:r.number-1,character:t-r.from}}Hr=function(e){return Ht("create"in e,'Expected query to have a "create" method'),e},ke=vf({findText:"",replaceText:"",caseSensitive:!1,wholeWord:!1,regexp:!1,isOpen:!1,currentView:void 0},(e,t)=>{if(t===void 0)return e;switch(t.type){case"setFind":return{...e,findText:t.find};case"setReplace":return{...e,replaceText:t.replace};case"setCaseSensitive":return{...e,caseSensitive:t.caseSensitive};case"setWholeWord":return{...e,wholeWord:t.wholeWord};case"setRegex":return{...e,regexp:t.regexp};case"setIsOpen":return{...e,isOpen:t.isOpen};case"setCurrentView":return{...e,currentView:{view:t.view,range:t.range}};case"clearCurrentView":return{...e,currentView:void 0}}}),ro=function(e){if([...document.querySelectorAll('[role="dialog"][data-state="open"]')].some(t=>t instanceof HTMLElement&&t.childNodes.length>0))return!1;if(e){let t=e.state.selection.main,r=e.state.sliceDoc(t.from,t.to);r?(Y.set(ke,{type:"setFind",find:r}),Y.set(ke,{type:"setCurrentView",view:e,range:{from:t.from,to:t.to}})):Y.set(ke,{type:"setCurrentView",view:e,range:{from:0,to:0}})}return Y.get(ke).isOpen?(Y.set(ke,{type:"setIsOpen",isOpen:!1}),requestAnimationFrame(()=>{Y.set(ke,{type:"setIsOpen",isOpen:!0})}),!0):(Y.set(ke,{type:"setIsOpen",isOpen:!0}),!0)};function su(){return Y.get(ke).isOpen?(Y.set(ke,{type:"setIsOpen",isOpen:!1}),!0):!1}var pn=te.define();ws=function(){let e=Y.get(ke),t=Li();for(let r of t)r.state.readOnly||r.dispatch({effects:pn.of(new Yn({search:e.findText,caseSensitive:e.caseSensitive,regexp:e.regexp,replace:e.replaceText,wholeWord:e.wholeWord}))})},ps=function(){let e=Li();for(let t of e)t.state.readOnly||t.dispatch({effects:pn.of(new Yn({search:""}))})};const Nr=Ee.define({create(){let e=Y.get(ke),t=new Yn({search:e.findText,caseSensitive:e.caseSensitive,regexp:e.regexp,replace:e.replaceText,wholeWord:e.wholeWord});return Hr(t).create()},update(e,t){for(let r of t.effects)r.is(pn)&&(e=Hr(r.value).create());return e}});var lu=_.mark({class:"cm-searchMatch"}),cu=_.mark({class:"cm-searchMatch cm-searchMatch-selected"}),uu=250;const du=He.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(Nr))}update(e){let t=e.state.field(Nr);(t!==e.startState.field(Nr)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight(e){if(!e.spec.valid)return _.none;let{view:t}=this,r=new Nt,n=t.visibleRanges,o=n.length;for(let a=0;a<o;a++){let{to:i}=n[a],{from:s}=n[a];for(;a<o-1&&i>n[a+1].from-2*uu;)i=n[++a].to;e.highlight(t.state,s,i,(l,c)=>{let d=t.state.selection.ranges.some(f=>f.from===l&&f.to===c);r.add(l,c,d?cu:lu)})}return r.finish()}},{decorations:e=>e.decorations}),fu=L.baseTheme({"&light .cm-searchMatch":{backgroundColor:"#99ff7780"},"&dark .cm-searchMatch":{backgroundColor:"#22bb0070"},"&light .cm-searchMatch-selected":{backgroundColor:"transparent"},"&dark .cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff88 !important"}});function mu(e){return[$e.of([{key:"Escape",preventDefault:!1,run:su},{key:e.getHotkey("cell.selectNextOccurrence").key,preventDefault:!0,run:Pm},{key:e.getHotkey("cell.findAndReplace").key,preventDefault:!0,run:ro}]),_m(),du,Nr,fu]}var hu=_.mark({class:"underline"}),ba=te.define(),ya=te.define(),wa=te.define();const gu=Ee.define({create(){return _.none},update(e,t){let r=e.map(t.changes);for(let n of t.effects)n.is(ba)?r=e.update({add:[hu.range(n.value.from,n.value.to)]}):n.is(ya)?r=e.update({add:[Wf.range(n.value.from,n.value.to)]}):n.is(wa)&&(r=_.none);return r},provide:e=>L.decorations.from(e)});var pu=class{constructor(e,t){p(this,"keydown",e=>{(e.key==="Meta"||e.key==="Control")&&(this.commandClickMode=!0,this.view.dom.addEventListener("mousemove",this.mousemove),this.view.dom.addEventListener("click",this.click))});p(this,"keyup",e=>{(e.key==="Meta"||e.key==="Control")&&this.exitCommandClickMode()});p(this,"windowBlur",()=>{this.commandClickMode&&this.exitCommandClickMode()});p(this,"mousemove",e=>{var o;if(!e.metaKey&&!e.ctrlKey){this.exitCommandClickMode();return}if(!this.commandClickMode){this.clearUnderline();return}let t=this.view.posAtCoords({x:e.clientX,y:e.clientY});if(t==null){this.clearUnderline();return}let r=(o=this.view.state.field(xf,!1))==null?void 0:o.ranges.find(a=>t>=a.from&&t<=a.to);if(r){let{from:a,to:i}=r;if(this.hoveredRange&&this.hoveredRange.from===a&&this.hoveredRange.to===i)return;this.clearUnderline(),this.hoveredRange={from:a,to:i,position:t},this.view.dispatch({effects:ya.of(this.hoveredRange)});return}let n=Om(this.view.state).cursorAt(t);if(n.name==="VariableName"){let{from:a,to:i}=n;if(this.hoveredRange&&this.hoveredRange.from===a&&this.hoveredRange.to===i)return;this.clearUnderline(),this.hoveredRange={from:a,to:i,position:t},this.view.dispatch({effects:ba.of(this.hoveredRange)})}else this.clearUnderline()});p(this,"click",e=>{if(this.hoveredRange){let t=this.view.state.doc.sliceString(this.hoveredRange.from,this.hoveredRange.to);e.preventDefault(),e.stopPropagation(),this.onClick(this.view,t),this.view.dispatch({selection:{head:this.hoveredRange.position,anchor:this.hoveredRange.position}})}});this.view=e,this.commandClickMode=!1,this.hoveredRange=null,this.onClick=t,window.addEventListener("keydown",this.keydown),window.addEventListener("keyup",this.keyup),window.addEventListener("blur",this.windowBlur),window.addEventListener("mouseleave",this.windowBlur)}update(e){}destroy(){window.removeEventListener("keydown",this.keydown),window.removeEventListener("keyup",this.keyup),window.removeEventListener("blur",this.windowBlur),window.removeEventListener("mouseleave",this.windowBlur),this.view.dom.removeEventListener("mousemove",this.mousemove),this.view.dom.removeEventListener("click",this.click)}exitCommandClickMode(){this.commandClickMode=!1,this.view.dom.removeEventListener("mousemove",this.mousemove),this.view.dom.removeEventListener("click",this.click),this.clearUnderline()}clearUnderline(){this.hoveredRange&&(this.hoveredRange=(this.view.dispatch({effects:wa.of(null)}),null))}};const bu=e=>He.define(t=>new pu(t,e));function yu(){return[gu,bu((e,t)=>{Nf(e,t)}),L.baseTheme({".underline":{textDecoration:"underline",cursor:"pointer",color:"var(--link)"}})]}function wu(){return[L.domEventHandlers({drop:(e,t)=>{var o,a;let r=(o=e.dataTransfer)==null?void 0:o.files[0];if(r!=null&&r.type.startsWith("text/"))return e.preventDefault(),Lf(t,r),!0;if(r!=null&&r.type.startsWith("image/"))return e.preventDefault(),Vf(t,r),!0;let n=(a=e.dataTransfer)==null?void 0:a.getData("text/plain");if(n){e.preventDefault();let i=t.posAtCoords({x:e.clientX,y:e.clientY});return i!==null&&t.dispatch({changes:{from:i,to:i,insert:n},scrollIntoView:!0}),!0}return!1},dragover:e=>{e.preventDefault()}})]}function vu(){return[L.domEventHandlers({paste:(e,t)=>{var o;let r=(o=e.clipboardData)==null?void 0:o.getData("text/plain");if(!(r!=null&&r.includes("@app.cell")))return!1;let n=Eu(r);return n.length===0?!1:(t.state.facet(Gf).createManyBelow(n),!0)}})]}function Eu(e){if(!e.includes("@app.cell"))return[];let t=[],r=e.split(`
|
|
15
|
+
`),n=[],o=!1,a=0,i=!1,s=!1,l=0,c=/\(/g,d=/\)/g,f=new Set(["@"]);function h(g){return(g.match(c)||[]).length-(g.match(d)||[]).length}function m(){if(n.length!==0){for(;n.length>0&&n[n.length-1].trim().startsWith("return");)n.pop();n.some(g=>g.trim()!=="")&&t.push(ku(n.join(`
|
|
16
|
+
`))),n=[]}}for(let g of r){let b=g.trim();if(!(!b&&!o)){if(b.startsWith("@app.cell")){m(),o=!0,a=1;continue}if(a>0){b.startsWith("def")&&b.includes("(")&&!b.includes("):")&&(i=!0,l=h(b)),a--;continue}if(i){l+=h(b),l===0&&(i=!1);continue}if(o){if(f.has(b[0])||b.startsWith("if __name__")){m(),o=b.startsWith("@");continue}if(b.startsWith("return")){b.includes("(")&&!b.endsWith(")")&&(s=!0,l=h(b));continue}if(s){l+=h(b),l===0&&(s=!1);continue}n.push(g)}}}return m(),t}function ku(e){let t=e.split(`
|
|
17
17
|
`);if(t.length===0)return"";let r=t.filter(a=>a.trim().length>0);if(r.length===0)return"";let n=/^\s*/,o=Math.min(...r.map(a=>{var i;return((i=a.match(n))==null?void 0:i[0].length)??1/0}));return o===0?e.trim():t.map(a=>a.slice(o)).join(`
|
|
18
|
-
`).trim()}var ae=({variant:e,settings:t,styles:r})=>{let n=O.theme({"&":{backgroundColor:t.background,color:t.foreground},".cm-content":{caretColor:t.caret},".cm-cursor, .cm-dropCursor":{borderLeftColor:t.caret},"&.cm-focused .cm-selectionBackgroundm .cm-selectionBackground, .cm-content ::selection":{backgroundColor:t.selection},".cm-activeLine":{backgroundColor:t.lineHighlight},".cm-gutters":{backgroundColor:t.gutterBackground,color:t.gutterForeground},".cm-activeLineGutter":{backgroundColor:t.lineHighlight}},{dark:e==="dark"}),o=Em.define(r);return[n,Hi(o)]};ae({variant:"dark",settings:{background:"#200020",foreground:"#D0D0FF",caret:"#7070FF",selection:"#80000080",gutterBackground:"#200020",gutterForeground:"#C080C0",lineHighlight:"#80000040"},styles:[{tag:u.comment,color:"#404080"},{tag:[u.string,u.regexp],color:"#999999"},{tag:u.number,color:"#7090B0"},{tag:[u.bool,u.null],color:"#8080A0"},{tag:[u.punctuation,u.derefOperator],color:"#805080"},{tag:u.keyword,color:"#60B0FF"},{tag:u.definitionKeyword,color:"#B0FFF0"},{tag:u.moduleKeyword,color:"#60B0FF"},{tag:u.operator,color:"#A0A0FF"},{tag:[u.variableName,u.self],color:"#008080"},{tag:u.operatorKeyword,color:"#A0A0FF"},{tag:u.controlKeyword,color:"#80A0FF"},{tag:u.className,color:"#70E080"},{tag:[u.function(u.propertyName),u.propertyName],color:"#50A0A0"},{tag:u.tagName,color:"#009090"},{tag:u.modifier,color:"#B0FFF0"},{tag:[u.squareBracket,u.attributeName],color:"#D0D0FF"}]}),ae({variant:"light",settings:{background:"#fcfcfc",foreground:"#5c6166",caret:"#ffaa33",selection:"#036dd626",gutterBackground:"#fcfcfc",gutterForeground:"#8a919966",lineHighlight:"#8a91991a"},styles:[{tag:u.comment,color:"#787b8099"},{tag:u.string,color:"#86b300"},{tag:u.regexp,color:"#4cbf99"},{tag:[u.number,u.bool,u.null],color:"#ffaa33"},{tag:u.variableName,color:"#5c6166"},{tag:[u.definitionKeyword,u.modifier],color:"#fa8d3e"},{tag:[u.keyword,u.special(u.brace)],color:"#fa8d3e"},{tag:u.operator,color:"#ed9366"},{tag:u.separator,color:"#5c6166b3"},{tag:u.punctuation,color:"#5c6166"},{tag:[u.definition(u.propertyName),u.function(u.variableName)],color:"#f2ae49"},{tag:[u.className,u.definition(u.typeName)],color:"#22a4e6"},{tag:[u.tagName,u.typeName,u.self,u.labelName],color:"#55b4d4"},{tag:u.angleBracket,color:"#55b4d480"},{tag:u.attributeName,color:"#f2ae49"}]}),ae({variant:"dark",settings:{background:"#15191EFA",foreground:"#EEF2F7",caret:"#C4C4C4",selection:"#90B2D557",gutterBackground:"#15191EFA",gutterForeground:"#aaaaaa95",lineHighlight:"#57575712"},styles:[{tag:u.comment,color:"#6E6E6E"},{tag:[u.string,u.regexp,u.special(u.brace)],color:"#5C81B3"},{tag:u.number,color:"#C1E1B8"},{tag:u.bool,color:"#53667D"},{tag:[u.definitionKeyword,u.modifier,u.function(u.propertyName)],color:"#A3D295",fontWeight:"bold"},{tag:[u.keyword,u.moduleKeyword,u.operatorKeyword,u.operator],color:"#697A8E",fontWeight:"bold"},{tag:[u.variableName,u.attributeName],color:"#708E67"},{tag:[u.function(u.variableName),u.definition(u.propertyName),u.derefOperator],color:"#fff"},{tag:u.tagName,color:"#A3D295"}]}),ae({variant:"dark",settings:{background:"#2e241d",foreground:"#BAAE9E",caret:"#A7A7A7",selection:"#DDF0FF33",gutterBackground:"#28211C",gutterForeground:"#BAAE9E90",lineHighlight:"#FFFFFF08"},styles:[{tag:u.comment,color:"#666666"},{tag:[u.string,u.special(u.brace)],color:"#54BE0D"},{tag:u.regexp,color:"#E9C062"},{tag:u.number,color:"#CF6A4C"},{tag:[u.keyword,u.operator],color:"#5EA6EA"},{tag:u.variableName,color:"#7587A6"},{tag:[u.definitionKeyword,u.modifier],color:"#F9EE98"},{tag:[u.propertyName,u.function(u.variableName)],color:"#937121"},{tag:[u.typeName,u.angleBracket,u.tagName],color:"#9B859D"}]}),ae({variant:"dark",settings:{background:"#3b2627",foreground:"#E6E1C4",caret:"#E6E1C4",selection:"#16120E",gutterBackground:"#3b2627",gutterForeground:"#E6E1C490",lineHighlight:"#1F1611"},styles:[{tag:u.comment,color:"#6B4E32"},{tag:[u.keyword,u.operator,u.derefOperator],color:"#EF5D32"},{tag:u.className,color:"#EFAC32",fontWeight:"bold"},{tag:[u.typeName,u.propertyName,u.function(u.variableName),u.definition(u.variableName)],color:"#EFAC32"},{tag:u.definition(u.typeName),color:"#EFAC32",fontWeight:"bold"},{tag:u.labelName,color:"#EFAC32",fontWeight:"bold"},{tag:[u.number,u.bool],color:"#6C99BB"},{tag:[u.variableName,u.self],color:"#7DAF9C"},{tag:[u.string,u.special(u.brace),u.regexp],color:"#D9D762"},{tag:[u.angleBracket,u.tagName,u.attributeName],color:"#EFCB43"}]}),ae({variant:"dark",settings:{background:"#000205",foreground:"#FFFFFF",caret:"#E60065",selection:"#E60C6559",gutterBackground:"#000205",gutterForeground:"#ffffff90",lineHighlight:"#4DD7FC1A"},styles:[{tag:u.comment,color:"#404040"},{tag:[u.string,u.special(u.brace),u.regexp],color:"#00D8FF"},{tag:u.number,color:"#E62286"},{tag:[u.variableName,u.attributeName,u.self],color:"#E62286",fontWeight:"bold"},{tag:u.function(u.variableName),color:"#fff",fontWeight:"bold"}]}),ae({variant:"light",settings:{background:"#fff",foreground:"#000",caret:"#000",selection:"#BDD5FC",gutterBackground:"#fff",gutterForeground:"#00000070",lineHighlight:"#FFFBD1"},styles:[{tag:u.comment,color:"#BCC8BA"},{tag:[u.string,u.special(u.brace),u.regexp],color:"#5D90CD"},{tag:[u.number,u.bool,u.null],color:"#46A609"},{tag:u.keyword,color:"#AF956F"},{tag:[u.definitionKeyword,u.modifier],color:"#C52727"},{tag:[u.angleBracket,u.tagName,u.attributeName],color:"#606060"},{tag:u.self,color:"#000"}]}),ae({variant:"dark",settings:{background:"#00254b",foreground:"#FFFFFF",caret:"#FFFFFF",selection:"#B36539BF",gutterBackground:"#00254b",gutterForeground:"#FFFFFF70",lineHighlight:"#00000059"},styles:[{tag:u.comment,color:"#0088FF"},{tag:u.string,color:"#3AD900"},{tag:u.regexp,color:"#80FFC2"},{tag:[u.number,u.bool,u.null],color:"#FF628C"},{tag:[u.definitionKeyword,u.modifier],color:"#FFEE80"},{tag:u.variableName,color:"#CCCCCC"},{tag:u.self,color:"#FF80E1"},{tag:[u.className,u.definition(u.propertyName),u.function(u.variableName),u.definition(u.typeName),u.labelName],color:"#FFDD00"},{tag:[u.keyword,u.operator],color:"#FF9D00"},{tag:[u.propertyName,u.typeName],color:"#80FFBB"},{tag:u.special(u.brace),color:"#EDEF7D"},{tag:u.attributeName,color:"#9EFFFF"},{tag:u.derefOperator,color:"#fff"}]}),ae({variant:"dark",settings:{background:"#060521",foreground:"#E0E0E0",caret:"#FFFFFFA6",selection:"#122BBB",gutterBackground:"#060521",gutterForeground:"#E0E0E090",lineHighlight:"#FFFFFF0F"},styles:[{tag:u.comment,color:"#AEAEAE"},{tag:[u.string,u.special(u.brace),u.regexp],color:"#8DFF8E"},{tag:[u.className,u.definition(u.propertyName),u.function(u.variableName),u.function(u.definition(u.variableName)),u.definition(u.typeName)],color:"#A3EBFF"},{tag:[u.number,u.bool,u.null],color:"#62E9BD"},{tag:[u.keyword,u.operator],color:"#2BF1DC"},{tag:[u.definitionKeyword,u.modifier],color:"#F8FBB1"},{tag:[u.variableName,u.self],color:"#B683CA"},{tag:[u.angleBracket,u.tagName,u.typeName,u.propertyName],color:"#60A4F1"},{tag:u.derefOperator,color:"#E0E0E0"},{tag:u.attributeName,color:"#7BACCA"}]}),ae({variant:"dark",settings:{background:"#2d2f3f",foreground:"#f8f8f2",caret:"#f8f8f0",selection:"#44475a",gutterBackground:"#282a36",gutterForeground:"rgb(144, 145, 148)",lineHighlight:"#44475a"},styles:[{tag:u.comment,color:"#6272a4"},{tag:[u.string,u.special(u.brace)],color:"#f1fa8c"},{tag:[u.number,u.self,u.bool,u.null],color:"#bd93f9"},{tag:[u.keyword,u.operator],color:"#ff79c6"},{tag:[u.definitionKeyword,u.typeName],color:"#8be9fd"},{tag:u.definition(u.typeName),color:"#f8f8f2"},{tag:[u.className,u.definition(u.propertyName),u.function(u.variableName),u.attributeName],color:"#50fa7b"}]}),ae({variant:"light",settings:{background:"#FFFFFF",foreground:"#000000",caret:"#000000",selection:"#80C7FF",gutterBackground:"#FFFFFF",gutterForeground:"#00000070",lineHighlight:"#C1E2F8"},styles:[{tag:u.comment,color:"#AAAAAA"},{tag:[u.keyword,u.operator,u.typeName,u.tagName,u.propertyName],color:"#2F6F9F",fontWeight:"bold"},{tag:[u.attributeName,u.definition(u.propertyName)],color:"#4F9FD0"},{tag:[u.className,u.string,u.special(u.brace)],color:"#CF4F5F"},{tag:u.number,color:"#CF4F5F",fontWeight:"bold"},{tag:u.variableName,fontWeight:"bold"}]}),ae({variant:"light",settings:{background:"#f2f1f8",foreground:"#0c006b",caret:"#5c49e9",selection:"#d5d1f2",gutterBackground:"#f2f1f8",gutterForeground:"#0c006b70",lineHighlight:"#e1def3"},styles:[{tag:u.comment,color:"#9995b7"},{tag:u.keyword,color:"#ff5792",fontWeight:"bold"},{tag:[u.definitionKeyword,u.modifier],color:"#ff5792"},{tag:[u.className,u.tagName,u.definition(u.typeName)],color:"#0094f0"},{tag:[u.number,u.bool,u.null,u.special(u.brace)],color:"#5842ff"},{tag:[u.definition(u.propertyName),u.function(u.variableName)],color:"#0095a8"},{tag:u.typeName,color:"#b3694d"},{tag:[u.propertyName,u.variableName],color:"#fa8900"},{tag:u.operator,color:"#ff5792"},{tag:u.self,color:"#e64100"},{tag:[u.string,u.regexp],color:"#00b368"},{tag:[u.paren,u.bracket],color:"#0431fa"},{tag:u.labelName,color:"#00bdd6"},{tag:u.attributeName,color:"#e64100"},{tag:u.angleBracket,color:"#9995b7"}]}),ae({variant:"light",settings:{background:"#faf4ed",foreground:"#575279",caret:"#575279",selection:"#6e6a8614",gutterBackground:"#faf4ed",gutterForeground:"#57527970",lineHighlight:"#6e6a860d"},styles:[{tag:u.comment,color:"#9893a5"},{tag:[u.bool,u.null],color:"#286983"},{tag:u.number,color:"#d7827e"},{tag:u.className,color:"#d7827e"},{tag:[u.angleBracket,u.tagName,u.typeName],color:"#56949f"},{tag:u.attributeName,color:"#907aa9"},{tag:u.punctuation,color:"#797593"},{tag:[u.keyword,u.modifier],color:"#286983"},{tag:[u.string,u.regexp],color:"#ea9d34"},{tag:u.variableName,color:"#d7827e"}]}),ae({variant:"light",settings:{background:"#FFFFFF",foreground:"#000000",caret:"#000000",selection:"#FFFD0054",gutterBackground:"#FFFFFF",gutterForeground:"#00000070",lineHighlight:"#00000008"},styles:[{tag:u.comment,color:"#CFCFCF"},{tag:[u.number,u.bool,u.null],color:"#E66C29"},{tag:[u.className,u.definition(u.propertyName),u.function(u.variableName),u.labelName,u.definition(u.typeName)],color:"#2EB43B"},{tag:u.keyword,color:"#D8B229"},{tag:u.operator,color:"#4EA44E",fontWeight:"bold"},{tag:[u.definitionKeyword,u.modifier],color:"#925A47"},{tag:u.string,color:"#704D3D"},{tag:u.typeName,color:"#2F8996"},{tag:[u.variableName,u.propertyName],color:"#77ACB0"},{tag:u.self,color:"#77ACB0",fontWeight:"bold"},{tag:u.regexp,color:"#E3965E"},{tag:[u.tagName,u.angleBracket],color:"#BAA827"},{tag:u.attributeName,color:"#B06520"},{tag:u.derefOperator,color:"#000"}]}),ae({variant:"light",settings:{background:"#fef7e5",foreground:"#586E75",caret:"#000000",selection:"#073642",gutterBackground:"#fef7e5",gutterForeground:"#586E7580",lineHighlight:"#EEE8D5"},styles:[{tag:u.comment,color:"#93A1A1"},{tag:u.string,color:"#2AA198"},{tag:u.regexp,color:"#D30102"},{tag:u.number,color:"#D33682"},{tag:u.variableName,color:"#268BD2"},{tag:[u.keyword,u.operator,u.punctuation],color:"#859900"},{tag:[u.definitionKeyword,u.modifier],color:"#073642",fontWeight:"bold"},{tag:[u.className,u.self,u.definition(u.propertyName)],color:"#268BD2"},{tag:u.function(u.variableName),color:"#268BD2"},{tag:[u.bool,u.null],color:"#B58900"},{tag:u.tagName,color:"#268BD2",fontWeight:"bold"},{tag:u.angleBracket,color:"#93A1A1"},{tag:u.attributeName,color:"#93A1A1"},{tag:u.typeName,color:"#859900"}]}),ae({variant:"light",settings:{background:"#FFFFFF",foreground:"#4D4D4C",caret:"#AEAFAD",selection:"#D6D6D6",gutterBackground:"#FFFFFF",gutterForeground:"#4D4D4C80",lineHighlight:"#EFEFEF"},styles:[{tag:u.comment,color:"#8E908C"},{tag:[u.variableName,u.self,u.propertyName,u.attributeName,u.regexp],color:"#C82829"},{tag:[u.number,u.bool,u.null],color:"#F5871F"},{tag:[u.className,u.typeName,u.definition(u.typeName)],color:"#C99E00"},{tag:[u.string,u.special(u.brace)],color:"#718C00"},{tag:u.operator,color:"#3E999F"},{tag:[u.definition(u.propertyName),u.function(u.variableName)],color:"#4271AE"},{tag:u.keyword,color:"#8959A8"},{tag:u.derefOperator,color:"#4D4D4C"}]});const Cu=[ae({variant:"dark",settings:{background:"var(--cm-background)",foreground:"#abb2bf",caret:"#528bff",selection:"#3E4451",lineHighlight:"#2c313c",gutterBackground:"var(--color-background)",gutterForeground:"var(--gray-10)"},styles:[{tag:u.comment,color:"var(--cm-comment)"},{tag:u.variableName,color:"#abb2bf"},{tag:[u.string,u.special(u.brace)],color:"#98c379"},{tag:u.number,color:"#d19a66"},{tag:u.bool,color:"#d19a66"},{tag:u.null,color:"#d19a66"},{tag:u.keyword,color:"#c678dd",fontWeight:500},{tag:u.className,color:"#61afef"},{tag:u.definition(u.typeName),color:"#61afef"},{tag:u.typeName,color:"#56b6c2"},{tag:u.angleBracket,color:"#abb2bf"},{tag:u.tagName,color:"#e06c75"},{tag:u.attributeName,color:"#d19a66"},{tag:u.operator,color:"#56b6c2",fontWeight:500},{tag:[u.function(u.variableName)],color:"#61afef"},{tag:[u.propertyName],color:"#e5c07b"}]}),O.theme({".mo-cm-reactive-reference":{fontWeight:"400",color:"#2a7aa5",borderBottom:"2px solid #bad3de"},".mo-cm-reactive-reference-hover":{cursor:"pointer",borderBottomWidth:"3px",borderBottomColor:"#4a90a5"}})],Nu=[ae({variant:"light",settings:{background:"#ffffff",foreground:"#000000",caret:"#000000",selection:"#d7d4f0",lineHighlight:"#cceeff44",gutterBackground:"var(--color-background)",gutterForeground:"var(--gray-10)"},styles:[{tag:u.comment,color:"var(--cm-comment)"},{tag:u.variableName,color:"#000000"},{tag:[u.string,u.special(u.brace)],color:"#a11"},{tag:u.number,color:"#164"},{tag:u.bool,color:"#219"},{tag:u.null,color:"#219"},{tag:u.keyword,color:"#708",fontWeight:500},{tag:u.className,color:"#00f"},{tag:u.definition(u.typeName),color:"#00f"},{tag:u.typeName,color:"#085"},{tag:u.angleBracket,color:"#000000"},{tag:u.tagName,color:"#170"},{tag:u.attributeName,color:"#00c"},{tag:u.operator,color:"#a2f",fontWeight:500},{tag:[u.function(u.variableName)],color:"#00c"},{tag:[u.propertyName],color:"#05a"}]}),O.theme({".mo-cm-reactive-reference":{fontWeight:"400",color:"#005f87",borderBottom:"2px solid #bad3de"},".mo-cm-reactive-reference-hover":{cursor:"pointer",borderBottomWidth:"3px"}})];function va(e){let{showPlaceholder:t,enableAI:r}=e;return t?"marimo-import":r?"ai":"none"}const xu=e=>{let{cellId:t,keymapConfig:r,hotkeys:n,enableAI:o,cellActions:a,completionConfig:i,lspConfig:s,diagnosticsConfig:l,displayConfig:c}=e,d=va(e);return[Xf(r,n),vu(),Eu(),Qs(),Uf({completionConfig:i,hotkeys:n,placeholderType:d,lspConfig:s,diagnosticsConfig:l}),vf({cellId:t,hotkeys:n,cellActions:a,keymapConfig:r}),Tu(e),wu(),l!=null&&l.enabled?Pm():[],o&&Mi("inline_ai_tooltip")?[Vs({prompt:f=>Ys({prompt:f.prompt,selection:f.selection,codeBefore:f.codeBefore,codeAfter:f.codeAfter,language:Sf(f.editorView)})}),Zr.of({hideOnBlur:!0})]:[],Gf(Y),wf(t,c.reference_highlighting??!1)]};var Su=e=>{let{from:t,to:r}=e.state.selection.main;if(t!==r)return!1;let n=e.state.doc.lineAt(r);return n.text.slice(0,r-n.from).trim()===""?!1:Km(e)};const Tu=e=>{let{theme:t,hotkeys:r,completionConfig:n,cellId:o,lspConfig:a,diagnosticsConfig:i}=e,s=va(e);return[O.lineWrapping,Im(),km(),Tm(),xm(),Cm(),Om(),wm(),gm({position:"fixed",parent:document.querySelector("#App")??void 0}),If(),t==="dark"?Cu:Nu,Af(a),ou(n),Lm(),Ym(),el(),et.high(We.of(qm)),Nm(),pm(),ym.of(" "),Hi(vm,{fallback:!0}),We.of(hm),jf({placeholderType:s,completionConfig:n,hotkeys:r,cellId:o,lspConfig:{...a,diagnostics:i}}),Bf.of(_m()),qt.allowMultipleSelections.of(!0),hu(r),We.of([{key:"Tab",run:l=>zi(l)||Su(l)||Gm(l),preventDefault:!0},{key:r.getHotkey("completion.moveDown").key,run:l=>Xt(l.state)===null?!1:($r(!0)(l),!0),preventDefault:!0},{key:r.getHotkey("completion.moveUp").key,run:l=>Xt(l.state)===null?!1:($r(!1)(l),!0),preventDefault:!0}]),We.of([...Jm,Um])]};if(hs)ms($h),hs();else if(!("Bun"in globalThis)){let e=await Hm(()=>import("./loro_wasm_bg-C1m39yOY.js").then(async r=>(await r.__tla,r)),__vite__mapDeps([0,1,2]),import.meta.url),t=new WebAssembly.Instance(e.default,{"./loro_wasm_bg.js":Hh});ms(t.exports)}var Iu=["Map","Text","List","Tree","MovableList","Counter"];function Fu(e){return e.startsWith("cid:")}function Ea(e){if(typeof e!="object"||!e)return!1;let t=Object.getPrototypeOf(e);return typeof t!="object"||!t||typeof t.kind!="function"?!1:Iu.includes(e.kind())}var Lu=class{constructor(e,t=3e4){this.listeners=new Set,this.inner=new Wh(e,t),this.peer=e,this.timeout=t}apply(e,t="remote"){let{updated:r,added:n}=this.inner.apply(e);this.listeners.forEach(o=>{o({updated:r,added:n,removed:[]},t)}),this.startTimerIfNotEmpty()}setLocalState(e){let t=this.inner.getState(this.peer)==null;this.inner.setLocalState(e),t?this.listeners.forEach(r=>{r({updated:[],added:[this.inner.peer()],removed:[]},"local")}):this.listeners.forEach(r=>{r({updated:[this.inner.peer()],added:[],removed:[]},"local")}),this.startTimerIfNotEmpty()}getLocalState(){return this.inner.getState(this.peer)}getAllStates(){return this.inner.getAllStates()}encode(e){return this.inner.encode(e)}encodeAll(){return this.inner.encodeAll()}addListener(e){this.listeners.add(e)}removeListener(e){this.listeners.delete(e)}peers(){return this.inner.peers()}destroy(){clearInterval(this.timer),this.listeners.clear()}startTimerIfNotEmpty(){this.inner.isEmpty()||this.timer!=null||(this.timer=setInterval(()=>{let e=this.inner.removeOutdated();e.length>0&&this.listeners.forEach(t=>{t({updated:[],added:[],removed:e},"timeout")}),this.inner.isEmpty()&&(clearInterval(this.timer),this.timer=void 0)},this.timeout/2))}};us.prototype.toJsonWithReplacer=function(e){let t=new Set,r=this,n=(i,s)=>{if(typeof s=="string"&&Fu(s)&&!t.has(s)){t.add(s);let c=r.getContainerById(s);if(c==null)throw Error(`ContainerID not found: ${s}`);let d=e(i,c);if(d===c){let f=c.getShallowValue();return typeof f=="object"?o(f):f}if(Ea(d))throw Error("Using new container is not allowed in toJsonWithReplacer");return typeof d=="object"&&d?o(d):d}if(typeof s=="object"&&s)return o(s);let l=e(i,s);if(Ea(l))throw Error("Using new container is not allowed in toJsonWithReplacer");return l},o=i=>{if(Array.isArray(i))return i.map((l,c)=>n(c,l)).filter(l=>l!==void 0);let s={};for(let[l,c]of Object.entries(i)){let d=n(l,c);d!==void 0&&(s[l]=d)}return s},a=r.getShallowValue();return o(a)};const Ou=O.baseTheme({".loro-cursor":{position:"absolute",width:"2px",display:"inline-block",height:"1.2em"},".loro-cursor::before":{position:"absolute",top:"1.3em",left:"0",content:"var(--rtc-name)",padding:"2px 6px",fontSize:"12px",borderRadius:"3px",whiteSpace:"nowrap",userSelect:"none",backgroundColor:"inherit",opacity:"0.7"},".loro-selection":{opacity:"0.5"}});Wr.define();const Pt=te.define(),bn=ve.define({create(){return{remoteCursors:new Map,isCheckout:!1}},update(e,t){for(let r of t.effects)if(r.is(Pt))switch(r.value.type){case"update":{let{peer:n,user:o,cursor:a}=r.value;e.remoteCursors.set(n,{uid:n,cursor:a,user:o});break}case"delete":e.remoteCursors.delete(r.value.peer);break;case"checkout":e.isCheckout=r.value.checkout}return e}});var ka=e=>{let t=e.transactions.flatMap(r=>r.effects).filter(r=>r.is(Pt));return e.docChanged||e.viewportChanged||t.length>0};const Bu=()=>qi({above:!0,class:"loro-cursor-layer",update:ka,markers:e=>{let{remoteCursors:t,isCheckout:r}=e.state.field(bn);return r?[]:[...t.values()].flatMap(n=>{var a,i;let o=ft.cursor(n.cursor.anchor);return Uu.createCursor(e,o,((a=n.user)==null?void 0:a.name)||"unknown",((i=n.user)==null?void 0:i.colorClassName)||"")})}}),Du=()=>qi({above:!1,class:"loro-selection-layer",update:ka,markers:e=>{let{remoteCursors:t,isCheckout:r}=e.state.field(bn);return r?[]:[...t.entries()].filter(([,n])=>n.cursor.head!==void 0&&n.cursor.anchor!==n.cursor.head).flatMap(([,n])=>{var a;let o=ft.range(n.cursor.anchor,n.cursor.head);return Sm.forRange(e,`loro-selection ${((a=n.user)==null?void 0:a.colorClassName)||""}`,o)})}});var Uu=class oo{constructor(t,r,n,o,a){this.left=t,this.top=r,this.height=n,this.name=o,this.colorClassName=a}draw(){let t=document.createElement("div");return this.adjust(t),t}update(t){return this.adjust(t),!0}adjust(t){t.style.left=`${this.left}px`,t.style.top=`${this.top}px`,t.style.height=`${this.height}px`,t.className=`loro-cursor ${this.colorClassName}`,t.style.setProperty("--rtc-name",`"${this.name}"`)}eq(t){return this.left===t.left&&this.top===t.top&&this.height===t.height&&this.name===t.name}static createCursor(t,r,n,o){let a=oo.calculateAbsoluteCursorPosition(r,t);if(!a)return[];let i=t.scrollDOM.getBoundingClientRect(),s=(t.textDirection===mm.LTR?i.left:i.right-t.scrollDOM.clientWidth)-t.scrollDOM.scrollLeft,l=i.top-t.scrollDOM.scrollTop;return[new oo(a.left-s,a.top-l,a.bottom-a.top,n,o)]}static calculateAbsoluteCursorPosition(t,r){let n=Math.max(0,Math.min(r.state.doc.length,t.anchor));return r.coordsAtPos(n,t.assoc||1)}},_u=(e,t,r,n)=>{let o=[],{updated:a,added:i}=r;for(let s of[...a,...i]){let l=Aa(e,t,s,n);l&&o.push(l)}return o},Aa=(e,t,r,n)=>{let o=t.getAllStates()[r];if(!o||r===e.peerIdStr||o.scopeId!==n)return;if(o.type==="delete")return Pt.of({type:"delete",peer:o.uid,scopeId:o.scopeId});let a=ds.decode(o.cursor.anchor),i=e.getCursorPos(a).offset,s=i;if(o.cursor.head){let l=ds.decode(o.cursor.head);s=e.getCursorPos(l).offset}return Pt.of({type:"update",peer:o.uid,scopeId:o.scopeId,cursor:{anchor:i,head:s},user:o.user})},Mu=class{constructor(e,t,r,n,o,a,i){this.view=e,this.doc=t,this.user=r,this.awareness=n,this.getTextFromDoc=o,this.scopeId=a,this.getUserId=i,this.sub=this.doc.subscribe(s=>{if(s.by==="local"){let l=[];for(let c of this.awareness.peers()){let d=Aa(this.doc,this.awareness,c,this.scopeId);d&&l.push(d)}this.view.dispatch({effects:l})}else s.by==="checkout"&&this.view.dispatch({effects:[Pt.of({type:"checkout",checkout:this.doc.isDetached()})]})})}update(e){if(!e.selectionSet&&!e.focusChanged&&!e.docChanged)return;let t=e.state.selection.main;if(this.view.hasFocus&&!this.doc.isDetached()){let r=ju({doc:this.doc,getTextFromDoc:this.getTextFromDoc,anchor:t.anchor,head:t.head});this.awareness.setLocalState({type:"update",uid:this.getUserId?this.getUserId():this.doc.peerIdStr,scopeId:this.scopeId,cursor:r,user:this.user})}else this.awareness.setLocalState({type:"delete",uid:this.getUserId?this.getUserId():this.doc.peerIdStr,scopeId:this.scopeId})}destroy(){var e;(e=this.sub)==null||e.call(this),this.awareness.setLocalState({type:"delete",uid:this.getUserId?this.getUserId():this.doc.peerIdStr,scopeId:this.scopeId})}},Pu=class{constructor(e,t,r,n){this.view=e,this.doc=t,this.awareness=r,this.scopeId=n;let o=async(a,i)=>{i!=="local"&&this.view.dispatch({effects:_u(this.doc,this.awareness,a,this.scopeId)})};this._awarenessListener=o,this.awareness.addListener(o)}destroy(){this._awarenessListener&&this.awareness.removeListener(this._awarenessListener)}},ju=({doc:e,getTextFromDoc:t,anchor:r,head:n})=>{var i,s;r===n&&(n=void 0);let o=(i=t(e).getCursor(r))==null?void 0:i.encode();if(!o)throw Error("cursor head not found");let a;return n!==void 0&&(a=(s=t(e).getCursor(n))==null?void 0:s.encode()),{anchor:o,head:a}};const Nr=["bg-(--amber-6)","bg-(--blue-6)","bg-(--crimson-6)","bg-(--cyan-6)","bg-(--grass-6)","bg-(--gray-6)","bg-(--green-6)","bg-(--lime-6)","bg-(--orange-6)","bg-(--purple-6)","bg-(--red-6)","bg-(--sage-6)","bg-(--sky-6)","bg-(--slate-6)"],Ru=e=>{if(typeof e=="string"){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t=Math.trunc(t);return Nr[Math.abs(t)%Nr.length]}return Nr[e%Nr.length]},Gu=(e,t,r)=>$e.define(n=>new Ju(n,e,t,r)),vt=Wr.define();var Ju=class{constructor(e,t,r,n){p(this,"isInitDispatch",!1);p(this,"onRemoteUpdate",e=>{if(e.by!=="local"){if(e.by==="checkout"){this.view.dispatch({changes:[{from:0,to:this.view.state.doc.length,insert:this.getTextFromDoc(this.doc).toString()}],annotations:[vt.of(this)]});return}if(e.by==="import"){let t=[],r=0;for(let{diff:n,path:o}of e.events){if(o.join("/")!==this.docPath.join("/")||n.type!=="text")continue;let a=n.diff;for(let i of a)i.insert?t.push({from:r,to:r,insert:i.insert}):i.delete?(t.push({from:r,to:r+i.delete}),r+=i.delete):i.retain!=null&&(r+=i.retain);t.length>0&&this.view.dispatch({changes:t,annotations:[vt.of(this)]})}}}});this.view=e,this.doc=t,this.docPath=r,this.getTextFromDoc=n,this.sub=t.subscribe(this.onRemoteUpdate),Promise.resolve().then(()=>{this.isInitDispatch=!0;let o=this.view.state.doc.toString(),a=this.getTextFromDoc(this.doc);o!==a.toString()&&e.dispatch({changes:[{from:0,to:this.view.state.doc.length,insert:a.toString()}]})})}update(e){if(this.isInitDispatch){this.isInitDispatch=!1;return}if(!e.docChanged||e.transactions.length>0&&(e.transactions[0].annotation(vt)===this||e.transactions[0].annotation(vt)==="undo"))return;let t=0;e.changes.iterChanges((r,n,o,a,i)=>{let s=i.sliceString(0,i.length,`
|
|
19
|
-
`);r!==n&&this.getTextFromDoc(this.doc).delete(r+t,n-r),s.length>0&&this.getTextFromDoc(this.doc).insert(r+t,s),t+=s.length-(n-r)}),this.doc.commit()}destroy(){var e;(e=this.sub)==null||e.call(this),this.sub=void 0}},me=Qe.get("rtc"),Ca=me.get("awareness").disabled(),yn="awareness:";function Vu(e,t){let r=new TextEncoder().encode(e);return new Uint8Array([...r,...t])}function Wu(e,t){return new TextDecoder().decode(e.slice(0,t.length))===t}function $u(e,t){return e.slice(t.length)}ht=Vt(void 0);var ie=new us,xr=new Lu(ie.peerIdStr),wn=Df(()=>{me.debug("creating websocket");let e=Wi().getWsSyncURL(lm()).toString(),t=new zh(e,void 0,{maxRetries:10,debug:!1,startClosed:!0,connectionTimeout:1e4});return Promise.resolve().then(async()=>{await Ki(),Ah()==="edit"&&t.reconnect()}),t.addEventListener("message",async r=>{let n=await r.data.arrayBuffer(),o=new Uint8Array(n);if(Wu(o,yn)){let a=$u(o,yn);xr.apply(a),Ca.debug("applied awareness update");return}ie.import(o),me.debug("imported doc change. new doc:",ie.toJSON()),Y.get(ht)!==ie&&Y.set(ht,ie)}),t.addEventListener("open",()=>{me.debug("websocket open")}),t.addEventListener("close",r=>{me.warn("websocket close",r),Y.get(ht)===ie&&Y.set(ht,void 0)}),t});jn()&&wn(),ie.subscribeLocalUpdates(e=>{me.debug("local update, sending to server"),wn().send(e)}),xr.addListener((e,t)=>{let r=[...e.added,...e.removed,...e.updated];t==="local"&&(Ca.debug("awareness changes",r),wn().send(Vu(yn,xr.encode(r))))});function vn(e,t,r=""){if(sm())return{extension:[],code:r};let n=ie.getByPath(`codes/${e}`)!==void 0,o=ie.getMap("codes").getOrCreateContainer(e,new Zn);return n||(me.log("initializing code for new cell",r),o.insert(0,r)),{code:r.toString(),extension:[Hu(e),qu(e),zu(ie,xr,{get name(){return Y.get(Tf)||"Anonymous"},get colorClassName(){return Ru(this.name)}},()=>o,e),Gu(ie,["codes",e],()=>o)]}}function Hu(e){let t=(n,o)=>{let a=n.state.field(Gr).type,i=o.toString();i&&i!==a&&(me.debug(`[incoming] setting language type: ${a} -> ${i}`),Wt(n,{language:i,keepCodeAsIs:!0}))},r=(n,o)=>{let a=n.state.field(Vn),i=o.toJSON();Jr(a,i)||n.dispatch({effects:[Li.of(i)],annotations:[vt.of(!0)]})};return $e.define(n=>{let o;return Promise.resolve().then(()=>{let a=ie.getByPath(`languages/${e}`);if(!a){me.error("no language container found for cell",e);return}$t(a instanceof Zn,"language type is not a LoroText");let i=ie.getByPath(`language_metadata/${e}`);if(!i){me.error("no language metadata container found for cell",e);return}$t(i instanceof fs,"language metadata is not a LoroMap"),t(n,a),r(n,i),o=ie.subscribe(s=>{if(s.origin==="local")return;let l=s.events.some(d=>d.target===a.id),c=s.events.some(d=>d.target===i.id);l&&t(n,a),c&&r(n,i)})}),{destroy(){o()}}})}function qu(e){let t=ie.getMap("languages").getOrCreateContainer(e,new Zn),r=ie.getMap("language_metadata").getOrCreateContainer(e,new fs);return O.updateListener.of(n=>{let o=t.toString()!=="";if(!n.docChanged&&o)return;if(!o){let i=$n(n.state).type;Wt(n.view,{language:i}),me.debug("no initial language, setting default to",i),t.delete(0,t.length),t.insert(0,i),me.debug("no initial language metadata, setting default to",n.state.field(Vn));let s=n.state.field(Vn);for(let l of Object.keys(s))r.set(l,s[l]);ie.commit();return}let a=!1;for(let i of n.transactions)if(!i.annotation(vt)){for(let s of i.effects)if(s.is(Rf)&&t.toString()!==s.value.type&&(me.debug(`[outgoing] language change: ${t} -> ${s.value.type}`),t.delete(0,t.length),t.insert(0,s.value.type),a=!0),s.is(Li)||s.is(Di)){let l=s.value;s.is(Di)?(me.debug("[outgoing] setting language metadata: ",l),r.clear()):me.debug("[outgoing] updating language metadata: ",l);for(let c of Object.keys(l))r.set(c,l[c]);a=!0}}a&&ie.commit()})}function zu(e,t,r,n,o,a){let i=`loro:cell:${o}`;return[bn,Bu(),Du(),$e.define(s=>new Mu(s,e,r,t,n,i,a)),$e.define(s=>new Pu(s,e,t,i)),Ou]}var Ku=ge(Ve());no=e=>{let t=(0,Ku.c)(41),{resetOnBlur:r,placeholderText:n,initialValue:o,flexibleWidth:a,onNameChange:i,className:s}=e,l=r===void 0?!1:r,c=o===void 0?null:o,d=a===void 0?!1:a,{sendListFiles:f}=Yt(),[h,m]=(0,L.useState)(c),g;t[0]===Symbol.for("react.memo_cache_sentinel")?(g=[],t[0]=g):g=t[0];let[b,y]=(0,L.useState)(g),[E,C]=(0,L.useState)(!1),B=(0,L.useRef)(null),M=(0,L.useRef)(!1),D,S;t[1]===c?(D=t[2],S=t[3]):(D=()=>{m(c)},S=[c],t[1]=c,t[2]=D,t[3]=S),(0,L.useEffect)(D,S);let x;t[4]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{C(!0)},t[4]=x):x=t[4];let H=x,R;t[5]!==c||t[6]!==l?(R=oe=>{var Mr;(Mr=oe.relatedTarget)!=null&&Mr.closest(".filename-input")||(C(!1),l&&m(c))},t[5]=c,t[6]=l,t[7]=R):R=t[7];let Z=R,T;t[8]===h?T=t[9]:(T=Xe.dirname(h||""),t[8]=h,t[9]=T);let $=T,ce=Xe.basename(h||""),P=b.filter(oe=>Xe.basename(oe.path).startsWith(ce)),G;t[10]!==$||t[11]!==E||t[12]!==f?(G=async()=>{if(!E){y([]);return}let oe=await f({path:$});y(oe.files)},t[10]=$,t[11]=E,t[12]=f,t[13]=G):G=t[13];let ne;t[14]!==$||t[15]!==E?(ne=[$,E],t[14]=$,t[15]=E,t[16]=ne):ne=t[16];let{isPending:ue}=xh(G,ne),k=Yu(h,b,c),N=(k||P.length>0)&&(0,w.jsxs)(ss,{className:"font-mono",children:[!ue&&(0,w.jsx)(Uh,{children:"No files"}),k&&(0,w.jsxs)(is,{variant:"success",className:"py-2 px-3",onSelect:()=>{var oe;k&&(M.current=!0,i(k),(oe=B.current)==null||oe.blur())},children:[(0,w.jsx)(re,{className:"w-4 h-4 mr-2"})," ",(0,w.jsxs)("span",{className:"text-sm",children:[c?"Rename to: ":"Save as: ",(0,w.jsx)("span",{className:"font-medium text-sm",children:Xe.basename(k)})]})]},"_rename_"),P.map(oe=>{let Mr=oe.isDirectory?"directory":gh(oe.path),ff=ph[Mr];return(0,w.jsxs)(is,{variant:oe.isDirectory?"default":"muted",className:"py-2 px-3",onSelect:()=>{oe.isDirectory?m(`${oe.path}/`):m(oe.path)},children:[(0,w.jsx)(ff,{className:"w-4 h-4 mr-2"})," ",Xe.basename(oe.path)]},oe.path)})]}),V=Math.max(20,(h==null?void 0:h.length)||(n==null?void 0:n.length)||0)*10,U=E?h||"":c||"",q;t[17]!==d||t[18]!==V?(q=d?{maxWidth:V}:void 0,t[17]=d,t[18]=V,t[19]=q):q=t[19];let Je;t[20]===s?Je=t[21]:(Je=Ht(s,"w-full px-4 py-1 my-1 h-9 font-mono text-foreground/60"),t[20]=s,t[21]=Je);let he;t[22]!==n||t[23]!==U||t[24]!==q||t[25]!==Je?(he=(0,w.jsx)(Th,{children:(0,w.jsx)(Dh,{"data-testid":"dir-completion-input",tabIndex:-1,rootClassName:"border-none justify-center px-1",spellCheck:"false",value:U,onKeyDown:Xu,icon:null,ref:B,onValueChange:m,placeholder:n,autoComplete:"off",style:q,className:Je})}),t[22]=n,t[23]=U,t[24]=q,t[25]=Je,t[26]=he):he=t[26];let be=N&&"group-focus-within:block",we;t[27]===be?we=t[28]:(we=Ht("p-0 w-full min-w-80 max-w-80vw hidden",be),t[27]=be,t[28]=we);let F;t[29]!==N||t[30]!==we?(F=(0,w.jsx)(Ih,{side:"bottom",className:we,portal:!1,children:N}),t[29]=N,t[30]=we,t[31]=F):F=t[31];let I;t[32]!==he||t[33]!==F?(I=(0,w.jsxs)(ss,{children:[he,F]}),t[32]=he,t[33]=F,t[34]=I):I=t[34];let j;t[35]!==Z||t[36]!==I?(j=(0,w.jsx)(_h,{onFocus:H,onBlur:Z,shouldFilter:!1,id:"filename-input",className:"bg-transparent group filename-input",children:I}),t[35]=Z,t[36]=I,t[37]=j):j=t[37];let At;return t[38]!==E||t[39]!==j?(At=(0,w.jsx)(dm,{children:(0,w.jsx)(Fh,{open:E,modal:!1,children:j})}),t[38]=E,t[39]=j,t[40]=At):At=t[40],At};function Yu(e,t,r){if(e&&!e.endsWith("/")&&((Mi("markdown")?new Set(["py","md","markdown","qmd"]):new Set(["py"])).has(Xe.extension(e))||(e=e.endsWith(".")?`${e}py`:e.endsWith(".p")?`${e}y`:`${e}.py`),!t.some(n=>n.path===e||Xe.basename(n.path)===e)&&!(r&&(r===e||Xe.basename(r)===e))))return e}function Xu(e){e.key==="Escape"&&e.currentTarget.blur()}var Na=ge(Ve()),Qu=e=>{let t=(0,Na.c)(33),r=()=>{hh(new Blob([n()],{type:"text/plain"}),`${e.proposedName}.json`)},n=de(td),o;t[0]!==r||t[1]!==e?(o=D=>{D.preventDefault(),r(),e.closeModal()},t[0]=r,t[1]=e,t[2]=o):o=t[2];let a;t[3]===e?a=t[4]:(a=D=>{D.key==="Escape"&&e.closeModal()},t[3]=e,t[4]=a);let i;t[5]===Symbol.for("react.memo_cache_sentinel")?(i=(0,w.jsx)(es,{className:"text-accent-foreground mb-6",children:"Download unsaved changes?"}),t[5]=i):i=t[5];let s;t[6]===Symbol.for("react.memo_cache_sentinel")?(s={wordBreak:"break-word"},t[6]=s):s=t[6];let l,c;t[7]===Symbol.for("react.memo_cache_sentinel")?(l=(0,w.jsx)("p",{children:"This app has unsaved changes. To recover:"}),c={paddingBottom:"10px"},t[7]=l,t[8]=c):(l=t[7],c=t[8]);let d;t[9]===e.proposedName?d=t[10]:(d=(0,w.jsxs)("li",{style:c,children:['Click the "Download" button. This will download a file called\xA0',(0,w.jsxs)("code",{children:[e.proposedName,".json"]}),". This file contains your code."]}),t[9]=e.proposedName,t[10]=d);let f;t[11]===Symbol.for("react.memo_cache_sentinel")?(f={paddingBottom:"10px"},t[11]=f):f=t[11];let h;t[12]===Symbol.for("react.memo_cache_sentinel")?(h={display:"block",padding:"10px"},t[12]=h):h=t[12];let m;t[13]===e.proposedName?m=t[14]:(m=(0,w.jsxs)("code",{style:h,children:["marimo recover ",e.proposedName,".json ",">"," ",e.proposedName,".py"]}),t[13]=e.proposedName,t[14]=m);let g;t[15]===e.proposedName?g=t[16]:(g=(0,w.jsxs)("code",{children:[e.proposedName,".py"]}),t[15]=e.proposedName,t[16]=g);let b;t[17]!==g||t[18]!==m?(b=(0,w.jsxs)("li",{style:f,children:["In your terminal, type",m,"to overwrite ",g," with the recovered changes."]}),t[17]=g,t[18]=m,t[19]=b):b=t[19];let y;t[20]!==b||t[21]!==d?(y=(0,w.jsx)(Ch,{className:"markdown break-words",style:s,children:(0,w.jsxs)("div",{className:"prose dark:prose-invert",children:[l,(0,w.jsxs)("ol",{children:[d,b]})]})}),t[20]=b,t[21]=d,t[22]=y):y=t[22];let E;t[23]===e.closeModal?E=t[24]:(E=(0,w.jsx)(Ze,{"aria-label":"Cancel",variant:"secondary","data-testid":"cancel-recovery-button",onClick:e.closeModal,children:"Cancel"}),t[23]=e.closeModal,t[24]=E);let C;t[25]===Symbol.for("react.memo_cache_sentinel")?(C=(0,w.jsx)(Ze,{"data-testid":"download-recovery-button","aria-label":"Download",variant:"default",type:"submit",children:"Download"}),t[25]=C):C=t[25];let B;t[26]===E?B=t[27]:(B=(0,w.jsxs)(ts,{children:[E,C]}),t[26]=E,t[27]=B);let M;return t[28]!==o||t[29]!==a||t[30]!==y||t[31]!==B?(M=(0,w.jsx)(rs,{className:"w-fit",children:(0,w.jsxs)("form",{onSubmit:o,onKeyDown:a,children:[i,y,B]})}),t[28]=o,t[29]=a,t[30]=y,t[31]=B,t[32]=M):M=t[32],M};const Zu=e=>{let t=(0,Na.c)(12),{filename:r,needsSave:n}=e,{openModal:o,closeModal:a}=ns(),i;t[0]===r?i=t[1]:(i=r===null?"app":Xe.basename(r).split(".")[0],t[0]=r,t[1]=i);let s=i,l;t[2]!==a||t[3]!==n||t[4]!==o||t[5]!==s?(l=()=>{n&&o((0,w.jsx)(Qu,{proposedName:s,closeModal:a}))},t[2]=a,t[3]=n,t[4]=o,t[5]=s,t[6]=l):l=t[6];let c=l;$i("global.save",c);let d;t[7]===Symbol.for("react.memo_cache_sentinel")?(d=os("global.save"),t[7]=d):d=t[7];let f=n?"yellow":"gray",h;t[8]===Symbol.for("react.memo_cache_sentinel")?(h=(0,w.jsx)(Xi,{strokeWidth:1.5,size:18}),t[8]=h):h=t[8];let m;return t[9]!==c||t[10]!==f?(m=(0,w.jsx)(Qt,{content:d,children:(0,w.jsx)(cs,{onClick:c,id:"save-button","aria-label":"Save",className:"rectangle",color:f,children:h})}),t[9]=c,t[10]=f,t[11]=m):m=t[11],m};function ed(e){return{id:e.id,name:e.name,code:e.code,code_hash:null,config:{column:0,...e.config}}}function td(){let e=Jn(),t=Wn(e),r={version:"1",metadata:{marimo_version:cm()},cells:t.map(ed)};return JSON.stringify(r,null,2)}var rd=ge(Ve()),En=5e3;function nd(){let e=(0,rd.c)(12),t=le(nm),{state:r}=le(mt),n=t.auto_download.includes("markdown"),o=t.auto_download.includes("html"),a=t.auto_download.includes("ipynb"),i=!n||r!==tt.OPEN,s=!o||r!==tt.OPEN,l=!a||r!==tt.OPEN,{autoExportAsHTML:c,autoExportAsIPYNB:d,autoExportAsMarkdown:f}=Yt(),h;e[0]===f?h=e[1]:(h=async()=>{await f({download:!1})},e[0]=f,e[1]=h);let m;e[2]===i?m=e[3]:(m={delayMs:En,whenVisible:!0,disabled:i},e[2]=i,e[3]=m),eo(h,m);let g;e[4]===c?g=e[5]:(g=async()=>{await c({download:!1,includeCode:!0,files:th.INSTANCE.filenames()})},e[4]=c,e[5]=g);let b;e[6]===s?b=e[7]:(b={delayMs:En,whenVisible:!0,disabled:s},e[6]=s,e[7]=b),eo(g,b);let y;e[8]===d?y=e[9]:(y=async()=>{await d({download:!1})},e[8]=d,e[9]=y);let E;e[10]===l?E=e[11]:(E={delayMs:En,whenVisible:!0,disabled:l},e[10]=l,e[11]=E),eo(y,E)}let kn;qr=Vt(void 0),kn=Vt(e=>{let t=e(qr),r=e(nt),n=e(Yi);return od({state:r,layout:n,lastSavedNotebook:t})});function od({state:e,layout:t,lastSavedNotebook:r}){if(!r)return!1;let{cellIds:n,cellData:o}=e,a=n.inOrderIds.map(c=>o[c]),i=a.map(c=>c.code),s=a.map(c=>c.config),l=a.map(c=>c.name);return!Ii(i,r.codes)||!Ii(l,r.names)||!Jr(s,r.configs)||!Jr(t.selectedLayout,r.layout.selectedLayout)||!Jr(t.layoutData,r.layout.layoutData)}var ad=ge(Ve());function id(e){let t=(0,ad.c)(21),{codes:r,cellConfigs:n,config:o,connStatus:a,cellNames:i,needsSave:s,kioskMode:l,onSave:c}=e,d=(0,L.useRef)(null),f;t[0]===r?f=t[1]:(f=r.join(":"),t[0]=r,t[1]=f);let h=f,m;t[2]===n?m=t[3]:(m=n.map(sd).join(":"),t[2]=n,t[3]=m);let g=m,b;t[4]===i?b=t[5]:(b=i.join(":"),t[4]=i,t[5]=b);let y=b,E;t[6]!==o||t[7]!==a.state||t[8]!==l||t[9]!==s||t[10]!==c?(E=()=>{if(!l)return o.autosave==="after_delay"&&(d.current!==null&&clearTimeout(d.current),s&&a.state===tt.OPEN&&(d.current=setTimeout(c,o.autosave_delay))),()=>{d.current!==null&&clearTimeout(d.current)}},t[6]=o,t[7]=a.state,t[8]=l,t[9]=s,t[10]=c,t[11]=E):E=t[11];let C;t[12]!==g||t[13]!==y||t[14]!==h||t[15]!==o||t[16]!==a.state||t[17]!==l||t[18]!==s||t[19]!==c?(C=[h,g,y,o,a.state,c,l,s],t[12]=g,t[13]=y,t[14]=h,t[15]=o,t[16]=a.state,t[17]=l,t[18]=s,t[19]=c,t[20]=C):C=t[20],(0,L.useEffect)(E,C)}function sd(e){return JSON.stringify(e)}var Sr=ge(Ve());ps=e=>{let t=(0,Sr.c)(15),{kioskMode:r}=e,n=jh(),o=le(kn),a=le(mt).state===tt.CLOSED,{saveOrNameNotebook:i,saveIfNotebookIsPersistent:s}=An(),l;t[0]!==r||t[1]!==s?(l={onSave:s,kioskMode:r},t[0]=r,t[1]=s,t[2]=l):l=t[2],dd(l),nd();let c;t[3]===o?c=t[4]:(c=y=>{if(o)return y.preventDefault(),y.returnValue="You have unsaved changes. Are you sure you want to leave?",y.returnValue},t[3]=o,t[4]=c),fm(window,"beforeunload",c);let d;t[5]===i?d=t[6]:(d=y=>{y.preventDefault(),y.stopPropagation(),i()},t[5]=i,t[6]=d);let f=d;if($i("global.save",i),a){let y;return t[7]!==n||t[8]!==o?(y=(0,w.jsx)(Zu,{filename:n,needsSave:o}),t[7]=n,t[8]=o,t[9]=y):y=t[9],y}let h;t[10]===Symbol.for("react.memo_cache_sentinel")?(h=os("global.save"),t[10]=h):h=t[10];let m=o?"yellow":"hint-green",g;t[11]===Symbol.for("react.memo_cache_sentinel")?(g=(0,w.jsx)(Xi,{strokeWidth:1.5,size:18}),t[11]=g):g=t[11];let b;return t[12]!==f||t[13]!==m?(b=(0,w.jsx)(Qt,{content:h,children:(0,w.jsx)(cs,{"data-testid":"save-button",id:"save-button",shape:"rectangle",color:m,onClick:f,children:g})}),t[12]=f,t[13]=m,t[14]=b):b=t[14],b};function An(){let e=(0,Sr.c)(20),{sendSave:t}=Yt(),{openModal:r,closeModal:n,openAlert:o}=ns(),a=xi(qr),i=Ph(),s=Pn(),l;e[0]!==o||e[1]!==t||e[2]!==a||e[3]!==s?(l=(E,C)=>{let B=Jn(),M=Wn(B),D=M.map(ud),S=M.map(cd),x=M.map(ld),H=Bi(B),R=s.get(mt),Z=s.get(Vi),T=s.get(Yi);if(!s.get(kh)&&S.length!==0){if(R.state!==tt.OPEN){o("Failed to save notebook: not connected to a kernel.");return}Qe.log("saving to ",E),t({cellIds:D,codes:S,names:x,filename:E,configs:H,layout:rh(),persist:!0}).then(()=>{C&&Z.format_on_save&&Vf(),a({names:x,codes:S,configs:H,layout:T})})}},e[0]=o,e[1]=t,e[2]=a,e[3]=s,e[4]=l):l=e[4];let c=de(l),d;e[5]!==c||e[6]!==s?(d=E=>{let C=E===void 0?!1:E,B=s.get(Si),M=s.get(mt);xa(B)&&M.state===tt.OPEN&&c(B,C)},e[5]=c,e[6]=s,e[7]=d):d=e[7];let f=de(d),h;e[8]!==c||e[9]!==i?(h=E=>{i(E).then(C=>{C!==null&&c(C,!0)})},e[8]=c,e[9]=i,e[10]=h):h=e[10];let m=h,g;e[11]!==n||e[12]!==m||e[13]!==r||e[14]!==f||e[15]!==s?(g=()=>{let E=s.get(Si),C=s.get(mt);f(!0),!xa(E)&&C.state!==tt.CLOSED&&r((0,w.jsx)(hd,{onClose:n,onSave:m}))},e[11]=n,e[12]=m,e[13]=r,e[14]=f,e[15]=s,e[16]=g):g=e[16];let b=de(g),y;return e[17]!==f||e[18]!==b?(y={saveOrNameNotebook:b,saveIfNotebookIsPersistent:f},e[17]=f,e[18]=b,e[19]=y):y=e[19],y}function ld(e){return e.name}function cd(e){return e.code}function ud(e){return e.id}function xa(e){return e!==null&&!e.startsWith("/tmp")&&!e.startsWith("/var/folders")&&!e.includes("AppData\\Local\\Temp")}function dd(e){let t=(0,Sr.c)(14),r=le(Vi),n=Ef(),[o]=Pr(mt),a=le(kn),i,s;if(t[0]!==n){let h=Wn(n);i=h.map(md),s=h.map(fd),t[0]=n,t[1]=i,t[2]=s}else i=t[1],s=t[2];let l=s,c;t[3]===n?c=t[4]:(c=Bi(n),t[3]=n,t[4]=c);let d=c,f;t[5]!==r||t[6]!==l||t[7]!==i||t[8]!==d||t[9]!==o||t[10]!==a||t[11]!==e.kioskMode||t[12]!==e.onSave?(f={onSave:e.onSave,needsSave:a,codes:i,cellConfigs:d,cellNames:l,connStatus:o,config:r,kioskMode:e.kioskMode},t[5]=r,t[6]=l,t[7]=i,t[8]=d,t[9]=o,t[10]=a,t[11]=e.kioskMode,t[12]=e.onSave,t[13]=f):f=t[13],id(f)}function fd(e){return e.name}function md(e){return e.code}var hd=e=>{let t=(0,Sr.c)(17),{onClose:r,onSave:n}=e,[o,a]=(0,L.useState)(),i;t[0]!==r||t[1]!==n?(i=y=>{a(y),y.trim()&&(n(y),r())},t[0]=r,t[1]=n,t[2]=i):i=t[2];let s=i,l;t[3]===Symbol.for("react.memo_cache_sentinel")?(l=(0,w.jsx)(es,{children:"Save notebook"}),t[3]=l):l=t[3];let c;t[4]===Symbol.for("react.memo_cache_sentinel")?(c=(0,w.jsx)(as,{className:"text-md pt-6 px-1",children:"Save as"}),t[4]=c):c=t[4];let d;t[5]===s?d=t[6]:(d=(0,w.jsxs)("div",{className:"flex flex-col",children:[c,(0,w.jsx)(no,{onNameChange:s,placeholderText:"filename",className:"missing-filename"})]}),t[5]=s,t[6]=d);let f;t[7]===r?f=t[8]:(f=(0,w.jsx)(Ze,{"data-testid":"cancel-save-dialog-button","aria-label":"Cancel",variant:"secondary",onClick:r,children:"Cancel"}),t[7]=r,t[8]=f);let h=!o,m;t[9]===h?m=t[10]:(m=(0,w.jsx)(Ze,{"data-testid":"submit-save-dialog-button","aria-label":"Save",variant:"default",disabled:h,type:"submit",children:"Save"}),t[9]=h,t[10]=m);let g;t[11]!==f||t[12]!==m?(g=(0,w.jsxs)(ts,{children:[f,m]}),t[11]=f,t[12]=m,t[13]=g):g=t[13];let b;return t[14]!==d||t[15]!==g?(b=(0,w.jsxs)(rs,{children:[l,d,g]}),t[14]=d,t[15]=g,t[16]=b):b=t[16],b};zr=function(...e){return t=>{e.forEach(r=>{typeof r=="function"?r(t):r!=null&&(r.current=t)})}};var Sa={modified:{doc:""},original:{doc:""}},Ta=(0,L.createContext)(Sa);function gd(e,t){return X({},e,t,{modified:X({},e.modified,t.modified),original:X({},e.original,t.original)})}var Cn=()=>(0,L.useContext)(Ta),pd=e=>{var{children:t,theme:r}=e,[n,o]=(0,L.useReducer)(gd,X({},Sa,{theme:r}));return(0,L.useEffect)(()=>o({theme:r}),[r]),(0,w.jsx)(Ta.Provider,{value:X({},n,{dispatch:o}),children:t})},bd=["extensions","value","selection","onChange"],Ia=e=>{var{extensions:t=[],value:r,selection:n,onChange:o}=e,a=Zt(e,bd),{theme:i,dispatch:s}=Cn(),l=St(X({},a,{theme:i}));return(0,L.useEffect)(()=>s({original:{doc:r,selection:n,extensions:[...l,...t]},originalExtension:{onChange:o,option:a,extension:[t]}}),[e]),null};Ia.displayName="CodeMirrorMerge.Original";var yd=["extensions","value","selection","onChange"],Fa=e=>{var{extensions:t=[],value:r,selection:n,onChange:o}=e,a=Zt(e,yd),{theme:i,dispatch:s}=Cn(),l=St(X({},a,{theme:i}));return(0,L.useEffect)(()=>{s({modified:{doc:r,selection:n,extensions:[...l,...t]},modifiedExtension:{onChange:o,option:a,extension:[t]}})},[e]),null};Fa.displayName="CodeMirrorMerge.Modified";var se=class As{constructor(t,r,n,o){this.fromA=t,this.toA=r,this.fromB=n,this.toB=o}offset(t,r=t){return new As(this.fromA+t,this.toA+t,this.fromB+r,this.toB+r)}};function ct(e,t,r,n,o,a){if(e==n)return[];let i=Tn(e,t,r,n,o,a),s=In(e,t+i,r,n,o+i,a);t+=i,r-=s,o+=i,a-=s;let l=r-t,c=a-o;if(!l||!c)return[new se(t,r,o,a)];if(l>c){let f=e.slice(t,r).indexOf(n.slice(o,a));if(f>-1)return[new se(t,t+f,o,o),new se(t+f+c,r,a,a)]}else if(c>l){let f=n.slice(o,a).indexOf(e.slice(t,r));if(f>-1)return[new se(t,t,o,o+f),new se(r,r,o+f+l,a)]}if(l==1||c==1)return[new se(t,r,o,a)];let d=Ba(e,t,r,n,o,a);if(d){let[f,h,m]=d;return ct(e,t,f,n,o,h).concat(ct(e,f+m,r,n,h+m,a))}return wd(e,t,r,n,o,a)}var jt=1e9,Rt=0,Nn=!1;function wd(e,t,r,n,o,a){let i=r-t,s=a-o;if(jt<1e9&&Math.min(i,s)>jt*16||Rt>0&&Date.now()>Rt)return Math.min(i,s)>jt*64?[new se(t,r,o,a)]:Da(e,t,r,n,o,a);let l=Math.ceil((i+s)/2);xn.reset(l),Sn.reset(l);let c=(m,g)=>e.charCodeAt(t+m)==n.charCodeAt(o+g),d=(m,g)=>e.charCodeAt(r-m-1)==n.charCodeAt(a-g-1),f=(i-s)%2==0?null:Sn,h=f?null:xn;for(let m=0;m<l;m++){if(m>jt||Rt>0&&!(m&63)&&Date.now()>Rt)return Da(e,t,r,n,o,a);let g=xn.advance(m,i,s,l,f,!1,c)||Sn.advance(m,i,s,l,h,!0,d);if(g)return vd(e,t,r,t+g[0],n,o,a,o+g[1])}return[new se(t,r,o,a)]}var La=class{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let t=0;t<this.len;t++)this.vec[t]=-1;this.vec[e+1]=0,this.start=this.end=0}advance(e,t,r,n,o,a,i){for(let s=-e+this.start;s<=e-this.end;s+=2){let l=n+s,c=s==-e||s!=e&&this.vec[l-1]<this.vec[l+1]?this.vec[l+1]:this.vec[l-1]+1,d=c-s;for(;c<t&&d<r&&i(c,d);)c++,d++;if(this.vec[l]=c,c>t)this.end+=2;else if(d>r)this.start+=2;else if(o){let f=n+(t-r)-s;if(f>=0&&f<this.len&&o.vec[f]!=-1)if(a){let h=o.vec[f];if(h>=t-c)return[h,n+h-f]}else{let h=t-o.vec[f];if(c>=h)return[c,d]}}}return null}},xn=new La,Sn=new La;function vd(e,t,r,n,o,a,i,s){let l=!1;return!Et(e,n)&&++n==r&&(l=!0),!Et(o,s)&&++s==i&&(l=!0),l?[new se(t,r,a,i)]:ct(e,t,n,o,a,s).concat(ct(e,n,r,o,s,i))}function Oa(e,t){let r=1,n=Math.min(e,t);for(;r<n;)r<<=1;return r}function Tn(e,t,r,n,o,a){if(t==r||t==a||e.charCodeAt(t)!=n.charCodeAt(o))return 0;let i=Oa(r-t,a-o);for(let s=t,l=o;;){let c=s+i,d=l+i;if(c>r||d>a||e.slice(s,c)!=n.slice(l,d)){if(i==1)return s-t-(Et(e,s)?0:1);i>>=1}else{if(c==r||d==a)return c-t;s=c,l=d}}}function In(e,t,r,n,o,a){if(t==r||o==a||e.charCodeAt(r-1)!=n.charCodeAt(a-1))return 0;let i=Oa(r-t,a-o);for(let s=r,l=a;;){let c=s-i,d=l-i;if(c<t||d<o||e.slice(c,s)!=n.slice(d,l)){if(i==1)return r-s-(Et(e,s)?0:1);i>>=1}else{if(c==t||d==o)return r-c;s=c,l=d}}}function Fn(e,t,r,n,o,a,i,s){let l=n.slice(o,a),c=null;for(;;){if(c||i<s)return c;for(let d=t+i;;){Et(e,d)||d++;let f=d+i;if(Et(e,f)||(f+=f==d+1?1:-1),f>=r)break;let h=e.slice(d,f),m=-1;for(;(m=l.indexOf(h,m+1))!=-1;){let g=Tn(e,f,r,n,o+m+h.length,a),b=In(e,t,d,n,o,o+m),y=h.length+g+b;(!c||c[2]<y)&&(c=[d-b,o+m-b,y])}d=f}if(s<0)return c;i>>=1}}function Ba(e,t,r,n,o,a){let i=r-t,s=a-o;if(i<s){let l=Ba(n,o,a,e,t,r);return l&&[l[1],l[0],l[2]]}return i<4||s*2<i?null:Fn(e,t,r,n,o,a,Math.floor(i/4),-1)}function Da(e,t,r,n,o,a){Nn=!0;let i=r-t,s=a-o,l;if(i<s){let h=Fn(n,o,a,e,t,r,Math.floor(i/6),50);l=h&&[h[1],h[0],h[2]]}else l=Fn(e,t,r,n,o,a,Math.floor(s/6),50);if(!l)return[new se(t,r,o,a)];let[c,d,f]=l;return ct(e,t,c,n,o,d).concat(ct(e,c+f,r,n,d+f,a))}function Ua(e,t){for(let r=1;r<e.length;r++){let n=e[r-1],o=e[r];n.toA>o.fromA-t&&n.toB>o.fromB-t&&(e[r-1]=new se(n.fromA,o.toA,n.fromB,o.toB),e.splice(r--,1))}}function Ed(e,t,r){for(;;){Ua(r,1);let n=!1;for(let o=0;o<r.length;o++){let a=r[o],i,s;(i=Tn(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=r[o]=new se(a.fromA+i,a.toA,a.fromB+i,a.toB)),(s=In(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=r[o]=new se(a.fromA,a.toA-s,a.fromB,a.toB-s));let l=a.toA-a.fromA,c=a.toB-a.fromB;if(l&&c)continue;let d=a.fromA-(o?r[o-1].toA:0),f=(o<r.length-1?r[o+1].fromA:e.length)-a.toA;if(!d||!f)continue;let h=l?e.slice(a.fromA,a.toA):t.slice(a.fromB,a.toB);d<=h.length&&e.slice(a.fromA-d,a.fromA)==h.slice(h.length-d)?(r[o]=new se(a.fromA-d,a.toA-d,a.fromB-d,a.toB-d),n=!0):f<=h.length&&e.slice(a.toA,a.toA+f)==h.slice(0,f)&&(r[o]=new se(a.fromA+f,a.toA+f,a.fromB+f,a.toB+f),n=!0)}if(!n)break}return r}function kd(e,t,r){for(let n=0,o=0;o<e.length;o++){let a=e[o],i=a.toA-a.fromA,s=a.toB-a.fromB;if(i&&s||i>3||s>3){let l=o==e.length-1?t.length:e[o+1].fromA,c=a.fromA-n,d=l-a.toA,f=Ga(t,a.fromA,c),h=Ra(t,a.toA,d),m=a.fromA-f,g=h-a.toA;if((!i||!s)&&m&&g){let b=Math.max(i,s),[y,E,C]=i?[t,a.fromA,a.toA]:[r,a.fromB,a.toB];b>m&&t.slice(f,a.fromA)==y.slice(C-m,C)?(a=e[o]=new se(f,f+i,a.fromB-m,a.toB-m),f=a.fromA,h=Ra(t,a.toA,l-a.toA)):b>g&&t.slice(a.toA,h)==y.slice(E,E+g)&&(a=e[o]=new se(h-i,h,a.fromB+g,a.toB+g),h=a.toA,f=Ga(t,a.fromA,a.fromA-n)),m=a.fromA-f,g=h-a.toA}if(m||g)a=e[o]=new se(a.fromA-m,a.toA+g,a.fromB-m,a.toB+g);else if(i){if(!s){let b=Va(t,a.fromA,a.toA),y,E=b<0?-1:Ja(t,a.toA,a.fromA);b>-1&&(y=b-a.fromA)<=d&&t.slice(a.fromA,b)==t.slice(a.toA,a.toA+y)?a=e[o]=a.offset(y):E>-1&&(y=a.toA-E)<=c&&t.slice(a.fromA-y,a.fromA)==t.slice(E,a.toA)&&(a=e[o]=a.offset(-y))}}else{let b=Va(r,a.fromB,a.toB),y,E=b<0?-1:Ja(r,a.toB,a.fromB);b>-1&&(y=b-a.fromB)<=d&&r.slice(a.fromB,b)==r.slice(a.toB,a.toB+y)?a=e[o]=a.offset(y):E>-1&&(y=a.toB-E)<=c&&r.slice(a.fromB-y,a.fromB)==r.slice(E,a.toB)&&(a=e[o]=a.offset(-y))}}n=a.toA}return Ua(e,3),e}var ut;try{ut=RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch{}function _a(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function Ma(e,t){if(t==e.length)return 0;let r=e.charCodeAt(t);return r<192?_a(r)?1:0:ut?!Wa(r)||t==e.length-1?ut.test(String.fromCharCode(r))?1:0:ut.test(e.slice(t,t+2))?2:0:0}function Pa(e,t){if(!t)return 0;let r=e.charCodeAt(t-1);return r<192?_a(r)?1:0:ut?!$a(r)||t==1?ut.test(String.fromCharCode(r))?1:0:ut.test(e.slice(t-2,t))?2:0:0}var ja=8;function Ra(e,t,r){if(t==e.length||!Pa(e,t))return t;for(let n=t,o=t+r,a=0;a<ja;a++){let i=Ma(e,n);if(!i||n+i>o)return n;n+=i}return t}function Ga(e,t,r){if(!t||!Ma(e,t))return t;for(let n=t,o=t-r,a=0;a<ja;a++){let i=Pa(e,n);if(!i||n-i<o)return n;n-=i}return t}function Ja(e,t,r){for(;t!=r;t--)if(e.charCodeAt(t-1)==10)return t;return-1}function Va(e,t,r){for(;t!=r;t++)if(e.charCodeAt(t)==10)return t;return-1}var Wa=e=>e>=55296&&e<=56319,$a=e=>e>=56320&&e<=57343;function Et(e,t){return!t||t==e.length||!Wa(e.charCodeAt(t-1))||!$a(e.charCodeAt(t))}function Ad(e,t,r){return jt=((r==null?void 0:r.scanLimit)??1e9)>>1,Rt=r!=null&&r.timeout?Date.now()+r.timeout:0,Nn=!1,Ed(e,t,ct(e,0,e.length,t,0,t.length))}function Ha(){return!Nn}function qa(e,t,r){return kd(Ad(e,t,r),e,t)}var qe=dt.define({combine:e=>e[0]}),Ln=te.define(),Cd=dt.define(),kt=ve.define({create(e){return null},update(e,t){for(let r of t.effects)r.is(Ln)&&(e=r.value);for(let r of t.state.facet(Cd))e=r(e,t);return e}}),Tr=class Cs{constructor(t,r,n,o,a,i=!0){this.changes=t,this.fromA=r,this.toA=n,this.fromB=o,this.toB=a,this.precise=i}offset(t,r){return t||r?new Cs(this.changes,this.fromA+t,this.toA+t,this.fromB+r,this.toB+r,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(t,r,n){let o=qa(t.toString(),r.toString(),n);return Ya(o,t,r,0,0,Ha())}static updateA(t,r,n,o,a){return Za(Qa(t,o,!0,n.length),t,r,n,a)}static updateB(t,r,n,o,a){return Za(Qa(t,o,!1,r.length),t,r,n,a)}};function za(e,t,r,n){let o=r.lineAt(e),a=n.lineAt(t);return o.to==e&&a.to==t&&e<r.length&&t<n.length?[e+1,t+1]:[o.from,a.from]}function Ka(e,t,r,n){let o=r.lineAt(e),a=n.lineAt(t);return o.from==e&&a.from==t?[e,t]:[o.to+1,a.to+1]}function Ya(e,t,r,n,o,a){let i=[];for(let s=0;s<e.length;s++){let l=e[s],[c,d]=za(l.fromA+n,l.fromB+o,t,r),[f,h]=Ka(l.toA+n,l.toB+o,t,r),m=[l.offset(-c+n,-d+o)];for(;s<e.length-1;){let g=e[s+1],[b,y]=za(g.fromA+n,g.fromB+o,t,r);if(b>f+1&&y>h+1)break;m.push(g.offset(-c+n,-d+o)),[f,h]=Ka(g.toA+n,g.toB+o,t,r),s++}i.push(new Tr(m,c,Math.max(c,f),d,Math.max(d,h),a))}return i}var Ir=1e3;function Xa(e,t,r,n){let o=0,a=e.length;for(;;){if(o==a){let d=0,f=0;o&&({toA:d,toB:f}=e[o-1]);let h=t-(r?d:f);return[d+h,f+h]}let i=o+a>>1,s=e[i],[l,c]=r?[s.fromA,s.toA]:[s.fromB,s.toB];if(l>t)a=i;else if(c<=t)o=i+1;else return n?[s.fromA,s.fromB]:[s.toA,s.toB]}}function Qa(e,t,r,n){let o=[];return t.iterChangedRanges((a,i,s,l)=>{let c=0,d=r?t.length:n,f=0,h=r?n:t.length;a>Ir&&([c,f]=Xa(e,a-Ir,r,!0)),i<t.length-Ir&&([d,h]=Xa(e,i+Ir,r,!1));let m=l-s-(i-a),g,[b,y]=r?[m,0]:[0,m];o.length&&(g=o[o.length-1]).toA>=c?o[o.length-1]={fromA:g.fromA,fromB:g.fromB,toA:d,toB:h,diffA:g.diffA+b,diffB:g.diffB+y}:o.push({fromA:c,toA:d,fromB:f,toB:h,diffA:b,diffB:y})}),o}function Za(e,t,r,n,o){if(!e.length)return t;let a=[];for(let i=0,s=0,l=0,c=0;;i++){let d=i==e.length?null:e[i],f=d?d.fromA+s:r.length,h=d?d.fromB+l:n.length;for(;c<t.length;){let y=t[c];if(y.toA+s>f||y.toB+l>h)break;a.push(y.offset(s,l)),c++}if(!d)break;let m=d.toA+s+d.diffA,g=d.toB+l+d.diffB,b=qa(r.sliceString(f,m),n.sliceString(h,g),o);for(let y of Ya(b,r,n,f,h,Ha()))a.push(y);for(s+=d.diffA,l+=d.diffB;c<t.length;){let y=t[c];if(y.fromA+s>m&&y.fromB+l>g)break;c++}}return a}var Nd={scanLimit:500},ei=$e.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=ni(e))}update(e){(e.docChanged||e.viewportChanged||xd(e.startState,e.state)||Sd(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=ni(e.view))}},{decorations:e=>e.deco}),Fr=et.low(Am({class:"cm-changeGutter",markers:e=>{var t;return((t=e.plugin(ei))==null?void 0:t.gutter)||Dm.empty}}));function xd(e,t){return e.field(kt,!1)!=t.field(kt,!1)}function Sd(e,t){return e.facet(qe)!=t.facet(qe)}var ti=_.line({class:"cm-changedLine"}),Td=_.mark({class:"cm-changedText"}),Id=_.mark({tagName:"ins",class:"cm-insertedLine"}),Fd=_.mark({tagName:"del",class:"cm-deletedLine"}),ri=new class extends Fm{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function Ld(e,t,r,n,o,a){let i=r?e.fromA:e.fromB,s=r?e.toA:e.toB,l=0;if(i!=s){o.add(i,i,ti),o.add(i,s,r?Fd:Id),a&&a.add(i,i,ri);for(let c=t.iterRange(i,s-1),d=i;!c.next().done;){if(c.lineBreak){d++,o.add(d,d,ti),a&&a.add(d,d,ri);continue}let f=d+c.value.length;if(n)for(;l<e.changes.length;){let h=e.changes[l],m=i+(r?h.fromA:h.fromB),g=i+(r?h.toA:h.toB),b=Math.max(d,m),y=Math.min(f,g);if(b<y&&o.add(b,y,Td),g<f)l++;else break}d=f}}}function ni(e){let t=e.state.field(kt),{side:r,highlightChanges:n,markGutter:o,overrideChunk:a}=e.state.facet(qe),i=r=="a",s=new Ct,l=o?new Ct:null,{from:c,to:d}=e.viewport;for(let f of t){if((i?f.fromA:f.fromB)>=d)break;(i?f.toA:f.toB)>c&&(!a||!a(e.state,f,s,l))&&Ld(f,e.state.doc,i,n,s,l)}return{deco:s.finish(),gutter:l&&l.finish()}}var Lr=class extends Nt{constructor(e){super(),this.height=e}eq(e){return this.height==e.height}toDOM(){let e=document.createElement("div");return e.className="cm-mergeSpacer",e.style.height=this.height+"px",e}updateDOM(e){return e.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}},Or=te.define({map:(e,t)=>e.map(t)}),Gt=ve.define({create:()=>_.none,update:(e,t)=>{for(let r of t.effects)if(r.is(Or))return r.value;return e.map(t.changes)},provide:e=>O.decorations.from(e)}),Br=.01;function oi(e,t){if(e.size!=t.size)return!1;let r=e.iter(),n=t.iter();for(;r.value;){if(r.from!=n.from||Math.abs(r.value.spec.widget.height-n.value.spec.widget.height)>1)return!1;r.next(),n.next()}return!0}function Od(e,t,r){let n=new Ct,o=new Ct,a=e.state.field(Gt).iter(),i=t.state.field(Gt).iter(),s=0,l=0,c=0,d=0,f=e.viewport,h=t.viewport;for(let y=0;;y++){let E=y<r.length?r[y]:null,C=E?E.fromA:e.state.doc.length,B=E?E.fromB:t.state.doc.length;if(s<C){let M=e.lineBlockAt(s).top+c,D=t.lineBlockAt(l).top+d,S=M-D;S<-Br?(c-=S,n.add(s,s,_.widget({widget:new Lr(-S),block:!0,side:-1}))):S>Br&&(d+=S,o.add(l,l,_.widget({widget:new Lr(S),block:!0,side:-1})))}if(C>s+1e3&&s<f.from&&C>f.from&&l<h.from&&B>h.from){let M=Math.min(f.from-s,h.from-l);s+=M,l+=M,y--}else if(E)s=E.toA,l=E.toB;else break;for(;a.value&&a.from<s;)c-=a.value.spec.widget.height,a.next();for(;i.value&&i.from<l;)d-=i.value.spec.widget.height,i.next()}for(;a.value;)c-=a.value.spec.widget.height,a.next();for(;i.value;)d-=i.value.spec.widget.height,i.next();let m=e.contentHeight+c-(t.contentHeight+d);m<Br?n.add(e.state.doc.length,e.state.doc.length,_.widget({widget:new Lr(-m),block:!0,side:1})):m>Br&&o.add(t.state.doc.length,t.state.doc.length,_.widget({widget:new Lr(m),block:!0,side:1}));let g=n.finish(),b=o.finish();oi(g,e.state.field(Gt))||e.dispatch({effects:Or.of(g)}),oi(b,t.state.field(Gt))||t.dispatch({effects:Or.of(b)})}var On=te.define({map:(e,t)=>t.mapPos(e)}),Bd=class extends Nt{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let t=document.createElement("div");return t.className="cm-collapsedLines",t.textContent=e.state.phrase("$ unchanged lines",this.lines),t.addEventListener("click",r=>{let n=e.posAtDOM(r.target);e.dispatch({effects:On.of(n)});let{side:o,sibling:a}=e.state.facet(qe);a&&a().dispatch({effects:On.of(Dd(n,e.state.field(kt),o=="a"))})}),t}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return"collapsed-unchanged-code"}};function Dd(e,t,r){let n=0,o=0;for(let a=0;;a++){let i=a<t.length?t[a]:null;if(!i||(r?i.fromA:i.fromB)>=e)return o+(e-n);[n,o]=r?[i.toA,i.toB]:[i.toB,i.toA]}}var Ud=ve.define({create(e){return _.none},update(e,t){e=e.map(t.changes);for(let r of t.effects)r.is(On)&&(e=e.update({filter:n=>n!=r.value}));return e},provide:e=>O.decorations.from(e)});function ai({margin:e=3,minSize:t=4}){return Ud.init(r=>_d(r,e,t))}function _d(e,t,r){let n=new Ct,o=e.facet(qe).side=="a",a=e.field(kt),i=1;for(let s=0;;s++){let l=s<a.length?a[s]:null,c=s?i+t:1,d=l?e.doc.lineAt(o?l.fromA:l.fromB).number-1-t:e.doc.lines,f=d-c+1;if(f>=r&&n.add(e.doc.line(c).from,e.doc.line(d).to,_.replace({widget:new Bd(f),block:!0})),!l)break;i=e.doc.lineAt(Math.min(e.doc.length,o?l.toA:l.toB)).number}return n.finish()}var Md=O.styleModule.of(new bm({".cm-mergeView":{overflowY:"auto"},".cm-mergeViewEditors":{display:"flex",alignItems:"stretch"},".cm-mergeViewEditor":{flexGrow:1,flexBasis:0,overflow:"hidden"},".cm-merge-revert":{width:"1.6em",flexGrow:0,flexShrink:0,position:"relative"},".cm-merge-revert button":{position:"absolute",display:"block",width:"100%",boxSizing:"border-box",textAlign:"center",background:"none",border:"none",font:"inherit",cursor:"pointer"}})),Pd=O.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:"auto !important",overflowY:"visible !important"},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:"rgba(160, 128, 100, .08)"},"&.cm-merge-b .cm-changedLine, .cm-inlineChangedLine":{backgroundColor:"rgba(100, 160, 128, .08)"},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat"},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat"},"&light.cm-merge-b .cm-changedText":{background:"linear-gradient(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat"},"&dark.cm-merge-b .cm-changedText":{background:"linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat"},"&.cm-merge-b .cm-deletedText":{background:"#ff000033"},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{textDecoration:"none"},".cm-deletedChunk":{paddingLeft:"6px","& .cm-chunkButtons":{position:"absolute",insetInlineEnd:"5px"},"& button":{border:"none",cursor:"pointer",color:"white",margin:"0 2px",borderRadius:"3px","&[name=accept]":{background:"#2a2"},"&[name=reject]":{background:"#d43"}}},".cm-collapsedLines":{padding:"5px 5px 5px 10px",cursor:"pointer","&:before":{content:'"\u299A"',marginInlineEnd:"7px"},"&:after":{content:'"\u299A"',marginInlineStart:"7px"}},"&light .cm-collapsedLines":{color:"#444",background:"linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)"},"&dark .cm-collapsedLines":{color:"#ddd",background:"linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)"},".cm-changeGutter":{width:"3px",paddingLeft:"1px"},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:"#e43"},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:"#fa9"},"&light.cm-merge-b .cm-changedLineGutter":{background:"#2b2"},"&dark.cm-merge-b .cm-changedLineGutter":{background:"#8f8"},".cm-inlineChangedLineGutter":{background:"#75d"}}),ii=new Kn,Dr=new Kn,si=class{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig||Nd;let t=[et.low(ei),Pd,Md,Gt,O.updateListener.of(d=>{this.measuring<0&&(d.heightChanged||d.viewportChanged)&&!d.transactions.some(f=>f.effects.some(h=>h.is(Or)))&&this.measure()})],r=[qe.of({side:"a",sibling:()=>this.b,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&r.push(Fr);let n=qt.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],O.editorAttributes.of({class:"cm-merge-a"}),Dr.of(r),t]}),o=[qe.of({side:"b",sibling:()=>this.a,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&o.push(Fr);let a=qt.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],O.editorAttributes.of({class:"cm-merge-b"}),Dr.of(o),t]});this.chunks=Tr.build(n.doc,a.doc,this.diffConf);let i=[kt.init(()=>this.chunks),ii.of(e.collapseUnchanged?ai(e.collapseUnchanged):[])];n=n.update({effects:te.appendConfig.of(i)}).state,a=a.update({effects:te.appendConfig.of(i)}).state,this.dom=document.createElement("div"),this.dom.className="cm-mergeView",this.editorDOM=this.dom.appendChild(document.createElement("div")),this.editorDOM.className="cm-mergeViewEditors";let s=e.orientation||"a-b",l=document.createElement("div");l.className="cm-mergeViewEditor";let c=document.createElement("div");c.className="cm-mergeViewEditor",this.editorDOM.appendChild(s=="a-b"?l:c),this.editorDOM.appendChild(s=="a-b"?c:l),this.a=new O({state:n,parent:l,root:e.root,dispatchTransactions:d=>this.dispatch(d,this.a)}),this.b=new O({state:a,parent:c,root:e.root,dispatchTransactions:d=>this.dispatch(d,this.b)}),this.setupRevertControls(!!e.revertControls,e.revertControls=="b-to-a",e.renderRevertControl),e.parent&&e.parent.appendChild(this.dom),this.scheduleMeasure()}dispatch(e,t){if(e.some(r=>r.docChanged)){let r=e[e.length-1],n=e.reduce((a,i)=>a.compose(i.changes),Kt.empty(e[0].startState.doc.length));this.chunks=t==this.a?Tr.updateA(this.chunks,r.newDoc,this.b.state.doc,n,this.diffConf):Tr.updateB(this.chunks,this.a.state.doc,r.newDoc,n,this.diffConf),t.update([...e,r.state.update({effects:Ln.of(this.chunks)})]);let o=t==this.a?this.b:this.a;o.update([o.state.update({effects:Ln.of(this.chunks)})]),this.scheduleMeasure()}else t.update(e)}reconfigure(e){if("diffConfig"in e&&(this.diffConf=e.diffConfig),"orientation"in e){let o=e.orientation!="b-a";if(o!=(this.editorDOM.firstChild==this.a.dom.parentNode)){let a=this.a.dom.parentNode,i=this.b.dom.parentNode;a.remove(),i.remove(),this.editorDOM.insertBefore(o?a:i,this.editorDOM.firstChild),this.editorDOM.appendChild(o?i:a),this.revertToLeft=!this.revertToLeft,this.revertDOM&&(this.revertDOM.textContent="")}}if("revertControls"in e||"renderRevertControl"in e){let o=!!this.revertDOM,a=this.revertToA,i=this.renderRevert;"revertControls"in e&&(o=!!e.revertControls,a=e.revertControls=="b-to-a"),"renderRevertControl"in e&&(i=e.renderRevertControl),this.setupRevertControls(o,a,i)}let t="highlightChanges"in e,r="gutter"in e,n="collapseUnchanged"in e;if(t||r||n){let o=[],a=[];if(t||r){let i=this.a.state.facet(qe),s=r?e.gutter!==!1:i.markGutter,l=t?e.highlightChanges!==!1:i.highlightChanges;o.push(Dr.reconfigure([qe.of({side:"a",sibling:()=>this.b,highlightChanges:l,markGutter:s}),s?Fr:[]])),a.push(Dr.reconfigure([qe.of({side:"b",sibling:()=>this.a,highlightChanges:l,markGutter:s}),s?Fr:[]]))}if(n){let i=ii.reconfigure(e.collapseUnchanged?ai(e.collapseUnchanged):[]);o.push(i),a.push(i)}this.a.dispatch({effects:o}),this.b.dispatch({effects:a})}this.scheduleMeasure()}setupRevertControls(e,t,r){this.revertToA=t,this.revertToLeft=this.revertToA==(this.editorDOM.firstChild==this.a.dom.parentNode),this.renderRevert=r,!e&&this.revertDOM?(this.revertDOM.remove(),this.revertDOM=null):e&&!this.revertDOM?(this.revertDOM=this.editorDOM.insertBefore(document.createElement("div"),this.editorDOM.firstChild.nextSibling),this.revertDOM.addEventListener("mousedown",n=>this.revertClicked(n)),this.revertDOM.className="cm-merge-revert"):this.revertDOM&&(this.revertDOM.textContent="")}scheduleMeasure(){this.measuring<0&&(this.measuring=(this.dom.ownerDocument.defaultView||window).requestAnimationFrame(()=>{this.measuring=-1,this.measure()}))}measure(){Od(this.a,this.b,this.chunks),this.revertDOM&&this.updateRevertButtons()}updateRevertButtons(){let e=this.revertDOM,t=e.firstChild,r=this.a.viewport,n=this.b.viewport;for(let o=0;o<this.chunks.length;o++){let a=this.chunks[o];if(a.fromA>r.to||a.fromB>n.to)break;if(a.fromA<r.from||a.fromB<n.from)continue;let i=this.a.lineBlockAt(a.fromA).top+"px";for(;t&&+t.dataset.chunk<o;)t=li(t);t&&t.dataset.chunk==String(o)?(t.style.top!=i&&(t.style.top=i),t=t.nextSibling):e.insertBefore(this.renderRevertButton(i,o),t)}for(;t;)t=li(t)}renderRevertButton(e,t){let r;if(this.renderRevert)r=this.renderRevert();else{r=document.createElement("button");let n=this.a.state.phrase("Revert this chunk");r.setAttribute("aria-label",n),r.setAttribute("title",n),r.textContent=this.revertToLeft?"\u21DC":"\u21DD"}return r.style.top=e,r.setAttribute("data-chunk",String(t)),r}revertClicked(e){let t=e.target,r;for(;t&&t.parentNode!=this.revertDOM;)t=t.parentNode;if(t&&(r=this.chunks[t.dataset.chunk])){let[n,o,a,i,s,l]=this.revertToA?[this.b,this.a,r.fromB,r.toB,r.fromA,r.toA]:[this.a,this.b,r.fromA,r.toA,r.fromB,r.toB],c=n.state.sliceDoc(a,Math.max(a,i-1));a!=i&&l<=o.state.doc.length&&(c+=n.state.lineBreak),o.dispatch({changes:{from:s,to:Math.min(o.state.doc.length,l),insert:c},userEvent:"revert"}),e.preventDefault()}}destroy(){this.a.destroy(),this.b.destroy(),this.measuring>-1&&(this.dom.ownerDocument.defaultView||window).cancelAnimationFrame(this.measuring),this.dom.remove()}};function li(e){let t=e.nextSibling;return e.remove(),t}var jd=["className","children","orientation","revertControls","highlightChanges","gutter","collapseUnchanged","destroyRerender","renderRevertControl","diffConfig","root"],Rd=["modified","modifiedExtension","original","originalExtension","theme","dispatch"],ci=L.forwardRef((e,t)=>{var{className:r,children:n,orientation:o,revertControls:a,highlightChanges:i,gutter:s,collapseUnchanged:l,destroyRerender:c=!0,renderRevertControl:d,diffConfig:f,root:h}=e,m=Zt(e,jd),g=Cn(),{modified:b,modifiedExtension:y,original:E,originalExtension:C,theme:B,dispatch:M}=g,D=Zt(g,Rd),S=(0,L.useRef)(null),x=(0,L.useRef)(),H={orientation:o,revertControls:a,highlightChanges:i,gutter:s,collapseUnchanged:l,renderRevertControl:d,diffConfig:f,root:h};(0,L.useImperativeHandle)(t,()=>({container:S.current,view:x.current,modified:b,original:E,config:X({a:E,b,parent:S.current},H)}),[S,x,b,E,H]);var R=O.updateListener.of(T=>{if(T.docChanged&&typeof(C==null?void 0:C.onChange)=="function"){var $=T.state.doc.toString();C==null||C.onChange($,T)}}),Z=O.updateListener.of(T=>{if(T.docChanged&&typeof(y==null?void 0:y.onChange)=="function"){var $=T.state.doc.toString();y==null||y.onChange($,T)}});return(0,L.useEffect)(()=>{!x.current&&S.current&&C&&y&&(x.current=new si(X({a:X({},E,{extensions:[...(C==null?void 0:C.extension)||[],...St(X({},C==null?void 0:C.option,{theme:B})),R]}),b:X({},b,{extensions:[...(y==null?void 0:y.extension)||[],...St(X({},y==null?void 0:y.option,{theme:B})),Z]}),parent:S.current},H)),M({view:x.current}))},[x,S,C,y]),(0,L.useEffect)(()=>{var ue,k;if(E&&E.doc&&x.current){var T=(ue=x.current)==null?void 0:ue.a.state.doc.toString();if(T!==E.doc){var $;($=x.current)==null||$.a.dispatch({changes:{from:0,to:T.length,insert:E.doc||""}})}}if(b&&b.doc&&x.current){var ce=(k=x.current)==null?void 0:k.b.state.doc.toString();if(ce!==b.doc){var P;(P=x.current)==null||P.b.dispatch({changes:{from:0,to:ce.length,insert:b.doc||""}})}}if(c&&x.current){var G=x.current.a.state.selection.ranges[0].from,ne=x.current.b.state.selection.ranges[0].from;x.current.destroy(),x.current=new si(X({a:X({},E,{extensions:[...(C==null?void 0:C.extension)||[],...St(X({},C==null?void 0:C.option,{theme:B}))]}),b:X({},b,{extensions:[...(y==null?void 0:y.extension)||[],...St(X({},y==null?void 0:y.option,{theme:B}))]}),parent:S.current},H)),G&&(x.current.a.focus(),x.current.a.dispatch({selection:{anchor:G,head:G}})),ne&&(x.current.b.focus(),x.current.b.dispatch({selection:{anchor:ne,head:ne}}))}},[x,B,S.current,E,b,C,y,c]),(0,L.useEffect)(()=>()=>x.current&&x.current.destroy(),[]),(0,L.useEffect)(()=>{if(x.current){var T={};D.orientation!==o&&(T.orientation=o),D.revertControls!==a&&(T.revertControls=a),D.highlightChanges!==i&&(T.highlightChanges=i),D.gutter!==s&&(T.gutter=s),D.collapseUnchanged!==l&&(T.collapseUnchanged=l),D.renderRevertControl!==d&&(T.collapseUnchanged=l),Object.keys(T).length&&M&&x.current&&(x.current.reconfigure(X({},T)),M(X({},T)))}},[M,x,o,a,i,s,l,d]),(0,w.jsx)("div",X({ref:S,className:"cm-merge-theme"+(r?" "+r:"")},m,{children:n}))});ci.displayName="CodeMirrorMerge.Internal";var Gd=["theme"],Ur=L.forwardRef((e,t)=>{var{theme:r}=e,n=Zt(e,Gd);return(0,w.jsx)(pd,{theme:r,children:(0,w.jsx)(ci,X({},n,{ref:t}))})});Ur.Original=Ia,Ur.Modified=Fa,Ur.displayName="CodeMirrorMerge";var Bn=Ur,Jd=ge(Ve()),Vd=Bn.Original,Wd=Bn.Modified,ui=[Pf(),O.lineWrapping];const $d=e=>{let t=(0,Jd.c)(28),{className:r,onChange:n,initialPrompt:o,currentLanguageAdapter:a,currentCode:i,declineChange:s,acceptChange:l,enabled:c,children:d}=e,f;t[0]===Symbol.for("react.memo_cache_sentinel")?(f={},t[0]=f):f=t[0];let[h,m]=(0,L.useState)(f),[g,b]=Pr(Mh),y=(0,L.useId)(),E=im(),{completion:C,input:B,stop:M,isLoading:D,setCompletion:S,setInput:x,handleSubmit:H}=oh({api:E.getAiURL("completion").toString(),headers:E.headers(),initialInput:o,streamProtocol:"text",experimental_throttle:100,body:{...h,includeOtherCode:g?Gn(i):"",code:i,language:a},onError:Hd,onFinish:(I,j)=>{R(j.trimEnd())}}),R=S,Z=L.useRef(null),T=C.trimEnd(),$,ce;t[1]===c?($=t[2],ce=t[3]):($=()=>{var I;c&&(yf(()=>{let j=Z.current;return j!=null&&j.view?(j.view.focus(),!0):!1},{retries:3,delay:100,initialDelay:100}),_f((I=Z.current)==null?void 0:I.view))},ce=[c],t[1]=c,t[2]=$,t[3]=ce),(0,L.useEffect)($,ce);let P,G;t[4]!==c||t[5]!==o||t[6]!==x?(P=()=>{c&&x(o||"")},G=[c,o,x],t[4]=c,t[5]=o,t[6]=x,t[7]=P,t[8]=G):(P=t[7],G=t[8]),(0,L.useEffect)(P,G);let{theme:ne}=Zm(),ue=()=>{l(T),R("")},k=()=>{R("")},N;t[9]===r?N=t[10]:(N=Ht("flex flex-col w-full rounded-[inherit]",r),t[9]=r,t[10]=N);let V=c&&"max-h-[400px] min-h-11 visible",U=!c&&"max-h-0 min-h-0 invisible",q;t[11]!==V||t[12]!==U?(q=Ht("flex items-center gap-2 border-b px-3 transition-all rounded-[inherit] rounded-b-none duration-300",V,U),t[11]=V,t[12]=U,t[13]=q):q=t[13];let Je=c&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(Eh,{className:"text-(--blue-10) shrink-0",size:16}),(0,w.jsx)(uh,{inputRef:Z,className:"h-full my-0 py-2 flex items-center",onClose:()=>{s(),R("")},value:B,onChange:I=>{x(I),m(ih({input:I}))},onSubmit:()=>{var I;D||((I=Z.current)!=null&&I.view&&lh(Z.current.view),H())},onKeyDown:sh({handleAcceptCompletion:ue,handleDeclineCompletion:k,isLoading:D,hasCompletion:T.trim().length>0})}),D&&(0,w.jsxs)(Ze,{"data-testid":"stop-completion-button",variant:"text",size:"xs",className:"mb-0",onClick:M,children:[(0,w.jsx)(bh,{className:"animate-spin mr-1",size:14}),"Stop"]}),(0,w.jsxs)("div",{className:"-mr-1.5 py-1.5",children:[(0,w.jsxs)("div",{className:"flex flex-row items-center justify-end gap-0.5",children:[(0,w.jsx)(Qt,{content:"Add context",children:(0,w.jsx)(Ze,{variant:"text",size:"icon",onClick:()=>ch(Z),children:(0,w.jsx)(ah,{className:"h-3 w-3"})})}),(0,w.jsx)(fh,{triggerClassName:"h-7 text-xs w-24",iconSize:"small",forRole:"edit"})]}),T&&(0,w.jsx)("div",{className:"-mb-1.5",children:(0,w.jsx)(dh,{isLoading:D,onAccept:ue,onDecline:k,size:"xs"})})]}),(0,w.jsx)("div",{className:"h-full w-px bg-border mx-2"}),(0,w.jsx)(Qt,{content:"Include code from other cells",children:(0,w.jsxs)("div",{className:"flex flex-row items-start gap-1 overflow-hidden",children:[(0,w.jsx)(Mf,{"data-testid":"include-other-cells-checkbox",id:y,checked:g,onCheckedChange:I=>b(!!I)}),(0,w.jsx)(as,{htmlFor:y,className:"text-muted-foreground text-xs whitespace-nowrap ellipsis",children:"Include all code"})]})}),(0,w.jsx)(Ze,{"data-testid":"decline-completion-button",variant:"text",size:"icon",disabled:D,onClick:()=>{M(),s(),R("")},children:(0,w.jsx)(mh,{className:"text-(--red-10)",size:16})})]}),he;t[14]!==q||t[15]!==Je?(he=(0,w.jsx)("div",{className:q,children:Je}),t[14]=q,t[15]=Je,t[16]=he):he=t[16];let be;t[17]!==T||t[18]!==i||t[19]!==c||t[20]!==n||t[21]!==ne?(be=T&&c&&(0,w.jsxs)(Bn,{className:"cm",theme:ne,children:[(0,w.jsx)(Vd,{onChange:n,value:i,extensions:ui}),(0,w.jsx)(Wd,{value:T,editable:!1,readOnly:!0,extensions:ui})]}),t[17]=T,t[18]=i,t[19]=c,t[20]=n,t[21]=ne,t[22]=be):be=t[22];let we=(!T||!c)&&d,F;return t[23]!==he||t[24]!==be||t[25]!==we||t[26]!==N?(F=(0,w.jsxs)("div",{className:N,children:[he,be,we]}),t[23]=he,t[24]=be,t[25]=we,t[26]=N,t[27]=F):F=t[27],F};function Hd(e){xt({title:"Completion failed",description:Nh(e)})}var Dn="web application/x-marimo-cell",qd=ji({cells:zf(ji({code:Kf()})),version:qf("1.0")});function zd(){let e=jr(),t=de(async n=>{let o=Jn(),a=n.map(i=>o.cellData[i]).filter(Boolean);if(a.length!==0)try{let i={cells:a.map(c=>({code:c.code})),version:"1.0"},s=a.map(c=>c.code).join(`
|
|
18
|
+
`).trim()}var ae=({variant:e,settings:t,styles:r})=>{let n=L.theme({"&":{backgroundColor:t.background,color:t.foreground},".cm-content":{caretColor:t.caret},".cm-cursor, .cm-dropCursor":{borderLeftColor:t.caret},"&.cm-focused .cm-selectionBackgroundm .cm-selectionBackground, .cm-content ::selection":{backgroundColor:t.selection},".cm-activeLine":{backgroundColor:t.lineHighlight},".cm-gutters":{backgroundColor:t.gutterBackground,color:t.gutterForeground},".cm-activeLineGutter":{backgroundColor:t.lineHighlight}},{dark:e==="dark"}),o=vm.define(r);return[n,Wi(o)]};ae({variant:"dark",settings:{background:"#200020",foreground:"#D0D0FF",caret:"#7070FF",selection:"#80000080",gutterBackground:"#200020",gutterForeground:"#C080C0",lineHighlight:"#80000040"},styles:[{tag:u.comment,color:"#404080"},{tag:[u.string,u.regexp],color:"#999999"},{tag:u.number,color:"#7090B0"},{tag:[u.bool,u.null],color:"#8080A0"},{tag:[u.punctuation,u.derefOperator],color:"#805080"},{tag:u.keyword,color:"#60B0FF"},{tag:u.definitionKeyword,color:"#B0FFF0"},{tag:u.moduleKeyword,color:"#60B0FF"},{tag:u.operator,color:"#A0A0FF"},{tag:[u.variableName,u.self],color:"#008080"},{tag:u.operatorKeyword,color:"#A0A0FF"},{tag:u.controlKeyword,color:"#80A0FF"},{tag:u.className,color:"#70E080"},{tag:[u.function(u.propertyName),u.propertyName],color:"#50A0A0"},{tag:u.tagName,color:"#009090"},{tag:u.modifier,color:"#B0FFF0"},{tag:[u.squareBracket,u.attributeName],color:"#D0D0FF"}]}),ae({variant:"light",settings:{background:"#fcfcfc",foreground:"#5c6166",caret:"#ffaa33",selection:"#036dd626",gutterBackground:"#fcfcfc",gutterForeground:"#8a919966",lineHighlight:"#8a91991a"},styles:[{tag:u.comment,color:"#787b8099"},{tag:u.string,color:"#86b300"},{tag:u.regexp,color:"#4cbf99"},{tag:[u.number,u.bool,u.null],color:"#ffaa33"},{tag:u.variableName,color:"#5c6166"},{tag:[u.definitionKeyword,u.modifier],color:"#fa8d3e"},{tag:[u.keyword,u.special(u.brace)],color:"#fa8d3e"},{tag:u.operator,color:"#ed9366"},{tag:u.separator,color:"#5c6166b3"},{tag:u.punctuation,color:"#5c6166"},{tag:[u.definition(u.propertyName),u.function(u.variableName)],color:"#f2ae49"},{tag:[u.className,u.definition(u.typeName)],color:"#22a4e6"},{tag:[u.tagName,u.typeName,u.self,u.labelName],color:"#55b4d4"},{tag:u.angleBracket,color:"#55b4d480"},{tag:u.attributeName,color:"#f2ae49"}]}),ae({variant:"dark",settings:{background:"#15191EFA",foreground:"#EEF2F7",caret:"#C4C4C4",selection:"#90B2D557",gutterBackground:"#15191EFA",gutterForeground:"#aaaaaa95",lineHighlight:"#57575712"},styles:[{tag:u.comment,color:"#6E6E6E"},{tag:[u.string,u.regexp,u.special(u.brace)],color:"#5C81B3"},{tag:u.number,color:"#C1E1B8"},{tag:u.bool,color:"#53667D"},{tag:[u.definitionKeyword,u.modifier,u.function(u.propertyName)],color:"#A3D295",fontWeight:"bold"},{tag:[u.keyword,u.moduleKeyword,u.operatorKeyword,u.operator],color:"#697A8E",fontWeight:"bold"},{tag:[u.variableName,u.attributeName],color:"#708E67"},{tag:[u.function(u.variableName),u.definition(u.propertyName),u.derefOperator],color:"#fff"},{tag:u.tagName,color:"#A3D295"}]}),ae({variant:"dark",settings:{background:"#2e241d",foreground:"#BAAE9E",caret:"#A7A7A7",selection:"#DDF0FF33",gutterBackground:"#28211C",gutterForeground:"#BAAE9E90",lineHighlight:"#FFFFFF08"},styles:[{tag:u.comment,color:"#666666"},{tag:[u.string,u.special(u.brace)],color:"#54BE0D"},{tag:u.regexp,color:"#E9C062"},{tag:u.number,color:"#CF6A4C"},{tag:[u.keyword,u.operator],color:"#5EA6EA"},{tag:u.variableName,color:"#7587A6"},{tag:[u.definitionKeyword,u.modifier],color:"#F9EE98"},{tag:[u.propertyName,u.function(u.variableName)],color:"#937121"},{tag:[u.typeName,u.angleBracket,u.tagName],color:"#9B859D"}]}),ae({variant:"dark",settings:{background:"#3b2627",foreground:"#E6E1C4",caret:"#E6E1C4",selection:"#16120E",gutterBackground:"#3b2627",gutterForeground:"#E6E1C490",lineHighlight:"#1F1611"},styles:[{tag:u.comment,color:"#6B4E32"},{tag:[u.keyword,u.operator,u.derefOperator],color:"#EF5D32"},{tag:u.className,color:"#EFAC32",fontWeight:"bold"},{tag:[u.typeName,u.propertyName,u.function(u.variableName),u.definition(u.variableName)],color:"#EFAC32"},{tag:u.definition(u.typeName),color:"#EFAC32",fontWeight:"bold"},{tag:u.labelName,color:"#EFAC32",fontWeight:"bold"},{tag:[u.number,u.bool],color:"#6C99BB"},{tag:[u.variableName,u.self],color:"#7DAF9C"},{tag:[u.string,u.special(u.brace),u.regexp],color:"#D9D762"},{tag:[u.angleBracket,u.tagName,u.attributeName],color:"#EFCB43"}]}),ae({variant:"dark",settings:{background:"#000205",foreground:"#FFFFFF",caret:"#E60065",selection:"#E60C6559",gutterBackground:"#000205",gutterForeground:"#ffffff90",lineHighlight:"#4DD7FC1A"},styles:[{tag:u.comment,color:"#404040"},{tag:[u.string,u.special(u.brace),u.regexp],color:"#00D8FF"},{tag:u.number,color:"#E62286"},{tag:[u.variableName,u.attributeName,u.self],color:"#E62286",fontWeight:"bold"},{tag:u.function(u.variableName),color:"#fff",fontWeight:"bold"}]}),ae({variant:"light",settings:{background:"#fff",foreground:"#000",caret:"#000",selection:"#BDD5FC",gutterBackground:"#fff",gutterForeground:"#00000070",lineHighlight:"#FFFBD1"},styles:[{tag:u.comment,color:"#BCC8BA"},{tag:[u.string,u.special(u.brace),u.regexp],color:"#5D90CD"},{tag:[u.number,u.bool,u.null],color:"#46A609"},{tag:u.keyword,color:"#AF956F"},{tag:[u.definitionKeyword,u.modifier],color:"#C52727"},{tag:[u.angleBracket,u.tagName,u.attributeName],color:"#606060"},{tag:u.self,color:"#000"}]}),ae({variant:"dark",settings:{background:"#00254b",foreground:"#FFFFFF",caret:"#FFFFFF",selection:"#B36539BF",gutterBackground:"#00254b",gutterForeground:"#FFFFFF70",lineHighlight:"#00000059"},styles:[{tag:u.comment,color:"#0088FF"},{tag:u.string,color:"#3AD900"},{tag:u.regexp,color:"#80FFC2"},{tag:[u.number,u.bool,u.null],color:"#FF628C"},{tag:[u.definitionKeyword,u.modifier],color:"#FFEE80"},{tag:u.variableName,color:"#CCCCCC"},{tag:u.self,color:"#FF80E1"},{tag:[u.className,u.definition(u.propertyName),u.function(u.variableName),u.definition(u.typeName),u.labelName],color:"#FFDD00"},{tag:[u.keyword,u.operator],color:"#FF9D00"},{tag:[u.propertyName,u.typeName],color:"#80FFBB"},{tag:u.special(u.brace),color:"#EDEF7D"},{tag:u.attributeName,color:"#9EFFFF"},{tag:u.derefOperator,color:"#fff"}]}),ae({variant:"dark",settings:{background:"#060521",foreground:"#E0E0E0",caret:"#FFFFFFA6",selection:"#122BBB",gutterBackground:"#060521",gutterForeground:"#E0E0E090",lineHighlight:"#FFFFFF0F"},styles:[{tag:u.comment,color:"#AEAEAE"},{tag:[u.string,u.special(u.brace),u.regexp],color:"#8DFF8E"},{tag:[u.className,u.definition(u.propertyName),u.function(u.variableName),u.function(u.definition(u.variableName)),u.definition(u.typeName)],color:"#A3EBFF"},{tag:[u.number,u.bool,u.null],color:"#62E9BD"},{tag:[u.keyword,u.operator],color:"#2BF1DC"},{tag:[u.definitionKeyword,u.modifier],color:"#F8FBB1"},{tag:[u.variableName,u.self],color:"#B683CA"},{tag:[u.angleBracket,u.tagName,u.typeName,u.propertyName],color:"#60A4F1"},{tag:u.derefOperator,color:"#E0E0E0"},{tag:u.attributeName,color:"#7BACCA"}]}),ae({variant:"dark",settings:{background:"#2d2f3f",foreground:"#f8f8f2",caret:"#f8f8f0",selection:"#44475a",gutterBackground:"#282a36",gutterForeground:"rgb(144, 145, 148)",lineHighlight:"#44475a"},styles:[{tag:u.comment,color:"#6272a4"},{tag:[u.string,u.special(u.brace)],color:"#f1fa8c"},{tag:[u.number,u.self,u.bool,u.null],color:"#bd93f9"},{tag:[u.keyword,u.operator],color:"#ff79c6"},{tag:[u.definitionKeyword,u.typeName],color:"#8be9fd"},{tag:u.definition(u.typeName),color:"#f8f8f2"},{tag:[u.className,u.definition(u.propertyName),u.function(u.variableName),u.attributeName],color:"#50fa7b"}]}),ae({variant:"light",settings:{background:"#FFFFFF",foreground:"#000000",caret:"#000000",selection:"#80C7FF",gutterBackground:"#FFFFFF",gutterForeground:"#00000070",lineHighlight:"#C1E2F8"},styles:[{tag:u.comment,color:"#AAAAAA"},{tag:[u.keyword,u.operator,u.typeName,u.tagName,u.propertyName],color:"#2F6F9F",fontWeight:"bold"},{tag:[u.attributeName,u.definition(u.propertyName)],color:"#4F9FD0"},{tag:[u.className,u.string,u.special(u.brace)],color:"#CF4F5F"},{tag:u.number,color:"#CF4F5F",fontWeight:"bold"},{tag:u.variableName,fontWeight:"bold"}]}),ae({variant:"light",settings:{background:"#f2f1f8",foreground:"#0c006b",caret:"#5c49e9",selection:"#d5d1f2",gutterBackground:"#f2f1f8",gutterForeground:"#0c006b70",lineHighlight:"#e1def3"},styles:[{tag:u.comment,color:"#9995b7"},{tag:u.keyword,color:"#ff5792",fontWeight:"bold"},{tag:[u.definitionKeyword,u.modifier],color:"#ff5792"},{tag:[u.className,u.tagName,u.definition(u.typeName)],color:"#0094f0"},{tag:[u.number,u.bool,u.null,u.special(u.brace)],color:"#5842ff"},{tag:[u.definition(u.propertyName),u.function(u.variableName)],color:"#0095a8"},{tag:u.typeName,color:"#b3694d"},{tag:[u.propertyName,u.variableName],color:"#fa8900"},{tag:u.operator,color:"#ff5792"},{tag:u.self,color:"#e64100"},{tag:[u.string,u.regexp],color:"#00b368"},{tag:[u.paren,u.bracket],color:"#0431fa"},{tag:u.labelName,color:"#00bdd6"},{tag:u.attributeName,color:"#e64100"},{tag:u.angleBracket,color:"#9995b7"}]}),ae({variant:"light",settings:{background:"#faf4ed",foreground:"#575279",caret:"#575279",selection:"#6e6a8614",gutterBackground:"#faf4ed",gutterForeground:"#57527970",lineHighlight:"#6e6a860d"},styles:[{tag:u.comment,color:"#9893a5"},{tag:[u.bool,u.null],color:"#286983"},{tag:u.number,color:"#d7827e"},{tag:u.className,color:"#d7827e"},{tag:[u.angleBracket,u.tagName,u.typeName],color:"#56949f"},{tag:u.attributeName,color:"#907aa9"},{tag:u.punctuation,color:"#797593"},{tag:[u.keyword,u.modifier],color:"#286983"},{tag:[u.string,u.regexp],color:"#ea9d34"},{tag:u.variableName,color:"#d7827e"}]}),ae({variant:"light",settings:{background:"#FFFFFF",foreground:"#000000",caret:"#000000",selection:"#FFFD0054",gutterBackground:"#FFFFFF",gutterForeground:"#00000070",lineHighlight:"#00000008"},styles:[{tag:u.comment,color:"#CFCFCF"},{tag:[u.number,u.bool,u.null],color:"#E66C29"},{tag:[u.className,u.definition(u.propertyName),u.function(u.variableName),u.labelName,u.definition(u.typeName)],color:"#2EB43B"},{tag:u.keyword,color:"#D8B229"},{tag:u.operator,color:"#4EA44E",fontWeight:"bold"},{tag:[u.definitionKeyword,u.modifier],color:"#925A47"},{tag:u.string,color:"#704D3D"},{tag:u.typeName,color:"#2F8996"},{tag:[u.variableName,u.propertyName],color:"#77ACB0"},{tag:u.self,color:"#77ACB0",fontWeight:"bold"},{tag:u.regexp,color:"#E3965E"},{tag:[u.tagName,u.angleBracket],color:"#BAA827"},{tag:u.attributeName,color:"#B06520"},{tag:u.derefOperator,color:"#000"}]}),ae({variant:"light",settings:{background:"#fef7e5",foreground:"#586E75",caret:"#000000",selection:"#073642",gutterBackground:"#fef7e5",gutterForeground:"#586E7580",lineHighlight:"#EEE8D5"},styles:[{tag:u.comment,color:"#93A1A1"},{tag:u.string,color:"#2AA198"},{tag:u.regexp,color:"#D30102"},{tag:u.number,color:"#D33682"},{tag:u.variableName,color:"#268BD2"},{tag:[u.keyword,u.operator,u.punctuation],color:"#859900"},{tag:[u.definitionKeyword,u.modifier],color:"#073642",fontWeight:"bold"},{tag:[u.className,u.self,u.definition(u.propertyName)],color:"#268BD2"},{tag:u.function(u.variableName),color:"#268BD2"},{tag:[u.bool,u.null],color:"#B58900"},{tag:u.tagName,color:"#268BD2",fontWeight:"bold"},{tag:u.angleBracket,color:"#93A1A1"},{tag:u.attributeName,color:"#93A1A1"},{tag:u.typeName,color:"#859900"}]}),ae({variant:"light",settings:{background:"#FFFFFF",foreground:"#4D4D4C",caret:"#AEAFAD",selection:"#D6D6D6",gutterBackground:"#FFFFFF",gutterForeground:"#4D4D4C80",lineHighlight:"#EFEFEF"},styles:[{tag:u.comment,color:"#8E908C"},{tag:[u.variableName,u.self,u.propertyName,u.attributeName,u.regexp],color:"#C82829"},{tag:[u.number,u.bool,u.null],color:"#F5871F"},{tag:[u.className,u.typeName,u.definition(u.typeName)],color:"#C99E00"},{tag:[u.string,u.special(u.brace)],color:"#718C00"},{tag:u.operator,color:"#3E999F"},{tag:[u.definition(u.propertyName),u.function(u.variableName)],color:"#4271AE"},{tag:u.keyword,color:"#8959A8"},{tag:u.derefOperator,color:"#4D4D4C"}]});const Au=[ae({variant:"dark",settings:{background:"var(--cm-background)",foreground:"#abb2bf",caret:"#528bff",selection:"#3E4451",lineHighlight:"#2c313c",gutterBackground:"var(--color-background)",gutterForeground:"var(--gray-10)"},styles:[{tag:u.comment,color:"var(--cm-comment)"},{tag:u.variableName,color:"#abb2bf"},{tag:[u.string,u.special(u.brace)],color:"#98c379"},{tag:u.number,color:"#d19a66"},{tag:u.bool,color:"#d19a66"},{tag:u.null,color:"#d19a66"},{tag:u.keyword,color:"#c678dd",fontWeight:500},{tag:u.className,color:"#61afef"},{tag:u.definition(u.typeName),color:"#61afef"},{tag:u.typeName,color:"#56b6c2"},{tag:u.angleBracket,color:"#abb2bf"},{tag:u.tagName,color:"#e06c75"},{tag:u.attributeName,color:"#d19a66"},{tag:u.operator,color:"#56b6c2",fontWeight:500},{tag:[u.function(u.variableName)],color:"#61afef"},{tag:[u.propertyName],color:"#e5c07b"}]}),L.theme({".mo-cm-reactive-reference":{fontWeight:"400",color:"#2a7aa5",borderBottom:"2px solid #bad3de"},".mo-cm-reactive-reference-hover":{cursor:"pointer",borderBottomWidth:"3px",borderBottomColor:"#4a90a5"}})],Cu=[ae({variant:"light",settings:{background:"#ffffff",foreground:"#000000",caret:"#000000",selection:"#d7d4f0",lineHighlight:"#cceeff44",gutterBackground:"var(--color-background)",gutterForeground:"var(--gray-10)"},styles:[{tag:u.comment,color:"var(--cm-comment)"},{tag:u.variableName,color:"#000000"},{tag:[u.string,u.special(u.brace)],color:"#a11"},{tag:u.number,color:"#164"},{tag:u.bool,color:"#219"},{tag:u.null,color:"#219"},{tag:u.keyword,color:"#708",fontWeight:500},{tag:u.className,color:"#00f"},{tag:u.definition(u.typeName),color:"#00f"},{tag:u.typeName,color:"#085"},{tag:u.angleBracket,color:"#000000"},{tag:u.tagName,color:"#170"},{tag:u.attributeName,color:"#00c"},{tag:u.operator,color:"#a2f",fontWeight:500},{tag:[u.function(u.variableName)],color:"#00c"},{tag:[u.propertyName],color:"#05a"}]}),L.theme({".mo-cm-reactive-reference":{fontWeight:"400",color:"#005f87",borderBottom:"2px solid #bad3de"},".mo-cm-reactive-reference-hover":{cursor:"pointer",borderBottomWidth:"3px"}})];function va(e){let{showPlaceholder:t,enableAI:r}=e;return t?"marimo-import":r?"ai":"none"}const Nu=e=>{let{cellId:t,keymapConfig:r,hotkeys:n,enableAI:o,cellActions:a,completionConfig:i,lspConfig:s,diagnosticsConfig:l,displayConfig:c,inlineAiTooltip:d}=e,f=va(e);return[Yf(r,n),wu(),vu(),Xs(),Jf({completionConfig:i,hotkeys:n,placeholderType:f,lspConfig:s,diagnosticsConfig:l}),wf({cellId:t,hotkeys:n,cellActions:a,keymapConfig:r}),Su(e),yu(),l!=null&&l.enabled?Mm():[],o&&d?[Js({prompt:h=>Ks({prompt:h.prompt,selection:h.selection,codeBefore:h.codeBefore,codeAfter:h.codeAfter,language:Sf(h.editorView)})}),Zr.of({hideOnBlur:!0})]:[],jf(Y),yf(t,c.reference_highlighting??!1)]};var xu=e=>{let{from:t,to:r}=e.state.selection.main;if(t!==r)return!1;let n=e.state.doc.lineAt(r);return n.text.slice(0,r-n.from).trim()===""?!1:Km(e)};const Su=e=>{let{theme:t,hotkeys:r,completionConfig:n,cellId:o,lspConfig:a,diagnosticsConfig:i}=e,s=va(e);return[L.lineWrapping,Tm(),Em(),Sm(),Nm(),Am(),Lm(),ym(),hm({position:"fixed",parent:document.querySelector("#App")??void 0}),If(),t==="dark"?Au:Cu,Af(a),nu(n),Fm(),Ym(),Zs(),tt.high($e.of(qm)),Cm(),gm(),bm.of(" "),Wi(wm,{fallback:!0}),$e.of(mm),Mf({placeholderType:s,completionConfig:n,hotkeys:r,cellId:o,lspConfig:{...a,diagnostics:i}}),Df.of(Um()),zt.allowMultipleSelections.of(!0),mu(r),$e.of([{key:"Tab",run:l=>qi(l)||xu(l)||Rm(l),preventDefault:!0},{key:r.getHotkey("completion.moveDown").key,run:l=>Qt(l.state)===null?!1:($r(!0)(l),!0),preventDefault:!0},{key:r.getHotkey("completion.moveUp").key,run:l=>Qt(l.state)===null?!1:($r(!1)(l),!0),preventDefault:!0}]),$e.of([...Gm,Dm])]};if(ms)fs($h),ms();else if(!("Bun"in globalThis)){let e=await Hm(()=>import("./loro_wasm_bg-C1m39yOY.js").then(async r=>(await r.__tla,r)),__vite__mapDeps([0,1,2]),import.meta.url),t=new WebAssembly.Instance(e.default,{"./loro_wasm_bg.js":Hh});fs(t.exports)}var Tu=["Map","Text","List","Tree","MovableList","Counter"];function Iu(e){return e.startsWith("cid:")}function Ea(e){if(typeof e!="object"||!e)return!1;let t=Object.getPrototypeOf(e);return typeof t!="object"||!t||typeof t.kind!="function"?!1:Tu.includes(e.kind())}var Fu=class{constructor(e,t=3e4){this.listeners=new Set,this.inner=new Wh(e,t),this.peer=e,this.timeout=t}apply(e,t="remote"){let{updated:r,added:n}=this.inner.apply(e);this.listeners.forEach(o=>{o({updated:r,added:n,removed:[]},t)}),this.startTimerIfNotEmpty()}setLocalState(e){let t=this.inner.getState(this.peer)==null;this.inner.setLocalState(e),t?this.listeners.forEach(r=>{r({updated:[],added:[this.inner.peer()],removed:[]},"local")}):this.listeners.forEach(r=>{r({updated:[this.inner.peer()],added:[],removed:[]},"local")}),this.startTimerIfNotEmpty()}getLocalState(){return this.inner.getState(this.peer)}getAllStates(){return this.inner.getAllStates()}encode(e){return this.inner.encode(e)}encodeAll(){return this.inner.encodeAll()}addListener(e){this.listeners.add(e)}removeListener(e){this.listeners.delete(e)}peers(){return this.inner.peers()}destroy(){clearInterval(this.timer),this.listeners.clear()}startTimerIfNotEmpty(){this.inner.isEmpty()||this.timer!=null||(this.timer=setInterval(()=>{let e=this.inner.removeOutdated();e.length>0&&this.listeners.forEach(t=>{t({updated:[],added:[],removed:e},"timeout")}),this.inner.isEmpty()&&(clearInterval(this.timer),this.timer=void 0)},this.timeout/2))}};cs.prototype.toJsonWithReplacer=function(e){let t=new Set,r=this,n=(i,s)=>{if(typeof s=="string"&&Iu(s)&&!t.has(s)){t.add(s);let c=r.getContainerById(s);if(c==null)throw Error(`ContainerID not found: ${s}`);let d=e(i,c);if(d===c){let f=c.getShallowValue();return typeof f=="object"?o(f):f}if(Ea(d))throw Error("Using new container is not allowed in toJsonWithReplacer");return typeof d=="object"&&d?o(d):d}if(typeof s=="object"&&s)return o(s);let l=e(i,s);if(Ea(l))throw Error("Using new container is not allowed in toJsonWithReplacer");return l},o=i=>{if(Array.isArray(i))return i.map((l,c)=>n(c,l)).filter(l=>l!==void 0);let s={};for(let[l,c]of Object.entries(i)){let d=n(l,c);d!==void 0&&(s[l]=d)}return s},a=r.getShallowValue();return o(a)};const Lu=L.baseTheme({".loro-cursor":{position:"absolute",width:"2px",display:"inline-block",height:"1.2em"},".loro-cursor::before":{position:"absolute",top:"1.3em",left:"0",content:"var(--rtc-name)",padding:"2px 6px",fontSize:"12px",borderRadius:"3px",whiteSpace:"nowrap",userSelect:"none",backgroundColor:"inherit",opacity:"0.7"},".loro-selection":{opacity:"0.5"}});Wr.define();const jt=te.define(),bn=Ee.define({create(){return{remoteCursors:new Map,isCheckout:!1}},update(e,t){for(let r of t.effects)if(r.is(jt))switch(r.value.type){case"update":{let{peer:n,user:o,cursor:a}=r.value;e.remoteCursors.set(n,{uid:n,cursor:a,user:o});break}case"delete":e.remoteCursors.delete(r.value.peer);break;case"checkout":e.isCheckout=r.value.checkout}return e}});var ka=e=>{let t=e.transactions.flatMap(r=>r.effects).filter(r=>r.is(jt));return e.docChanged||e.viewportChanged||t.length>0};const Ou=()=>$i({above:!0,class:"loro-cursor-layer",update:ka,markers:e=>{let{remoteCursors:t,isCheckout:r}=e.state.field(bn);return r?[]:[...t.values()].flatMap(n=>{var a,i;let o=mt.cursor(n.cursor.anchor);return Du.createCursor(e,o,((a=n.user)==null?void 0:a.name)||"unknown",((i=n.user)==null?void 0:i.colorClassName)||"")})}}),Bu=()=>$i({above:!1,class:"loro-selection-layer",update:ka,markers:e=>{let{remoteCursors:t,isCheckout:r}=e.state.field(bn);return r?[]:[...t.entries()].filter(([,n])=>n.cursor.head!==void 0&&n.cursor.anchor!==n.cursor.head).flatMap(([,n])=>{var a;let o=mt.range(n.cursor.anchor,n.cursor.head);return xm.forRange(e,`loro-selection ${((a=n.user)==null?void 0:a.colorClassName)||""}`,o)})}});var Du=class oo{constructor(t,r,n,o,a){this.left=t,this.top=r,this.height=n,this.name=o,this.colorClassName=a}draw(){let t=document.createElement("div");return this.adjust(t),t}update(t){return this.adjust(t),!0}adjust(t){t.style.left=`${this.left}px`,t.style.top=`${this.top}px`,t.style.height=`${this.height}px`,t.className=`loro-cursor ${this.colorClassName}`,t.style.setProperty("--rtc-name",`"${this.name}"`)}eq(t){return this.left===t.left&&this.top===t.top&&this.height===t.height&&this.name===t.name}static createCursor(t,r,n,o){let a=oo.calculateAbsoluteCursorPosition(r,t);if(!a)return[];let i=t.scrollDOM.getBoundingClientRect(),s=(t.textDirection===fm.LTR?i.left:i.right-t.scrollDOM.clientWidth)-t.scrollDOM.scrollLeft,l=i.top-t.scrollDOM.scrollTop;return[new oo(a.left-s,a.top-l,a.bottom-a.top,n,o)]}static calculateAbsoluteCursorPosition(t,r){let n=Math.max(0,Math.min(r.state.doc.length,t.anchor));return r.coordsAtPos(n,t.assoc||1)}},Uu=(e,t,r,n)=>{let o=[],{updated:a,added:i}=r;for(let s of[...a,...i]){let l=Aa(e,t,s,n);l&&o.push(l)}return o},Aa=(e,t,r,n)=>{let o=t.getAllStates()[r];if(!o||r===e.peerIdStr||o.scopeId!==n)return;if(o.type==="delete")return jt.of({type:"delete",peer:o.uid,scopeId:o.scopeId});let a=us.decode(o.cursor.anchor),i=e.getCursorPos(a).offset,s=i;if(o.cursor.head){let l=us.decode(o.cursor.head);s=e.getCursorPos(l).offset}return jt.of({type:"update",peer:o.uid,scopeId:o.scopeId,cursor:{anchor:i,head:s},user:o.user})},_u=class{constructor(e,t,r,n,o,a,i){this.view=e,this.doc=t,this.user=r,this.awareness=n,this.getTextFromDoc=o,this.scopeId=a,this.getUserId=i,this.sub=this.doc.subscribe(s=>{if(s.by==="local"){let l=[];for(let c of this.awareness.peers()){let d=Aa(this.doc,this.awareness,c,this.scopeId);d&&l.push(d)}this.view.dispatch({effects:l})}else s.by==="checkout"&&this.view.dispatch({effects:[jt.of({type:"checkout",checkout:this.doc.isDetached()})]})})}update(e){if(!e.selectionSet&&!e.focusChanged&&!e.docChanged)return;let t=e.state.selection.main;if(this.view.hasFocus&&!this.doc.isDetached()){let r=Pu({doc:this.doc,getTextFromDoc:this.getTextFromDoc,anchor:t.anchor,head:t.head});this.awareness.setLocalState({type:"update",uid:this.getUserId?this.getUserId():this.doc.peerIdStr,scopeId:this.scopeId,cursor:r,user:this.user})}else this.awareness.setLocalState({type:"delete",uid:this.getUserId?this.getUserId():this.doc.peerIdStr,scopeId:this.scopeId})}destroy(){var e;(e=this.sub)==null||e.call(this),this.awareness.setLocalState({type:"delete",uid:this.getUserId?this.getUserId():this.doc.peerIdStr,scopeId:this.scopeId})}},Mu=class{constructor(e,t,r,n){this.view=e,this.doc=t,this.awareness=r,this.scopeId=n;let o=async(a,i)=>{i!=="local"&&this.view.dispatch({effects:Uu(this.doc,this.awareness,a,this.scopeId)})};this._awarenessListener=o,this.awareness.addListener(o)}destroy(){this._awarenessListener&&this.awareness.removeListener(this._awarenessListener)}},Pu=({doc:e,getTextFromDoc:t,anchor:r,head:n})=>{var i,s;r===n&&(n=void 0);let o=(i=t(e).getCursor(r))==null?void 0:i.encode();if(!o)throw Error("cursor head not found");let a;return n!==void 0&&(a=(s=t(e).getCursor(n))==null?void 0:s.encode()),{anchor:o,head:a}};const xr=["bg-(--amber-6)","bg-(--blue-6)","bg-(--crimson-6)","bg-(--cyan-6)","bg-(--grass-6)","bg-(--gray-6)","bg-(--green-6)","bg-(--lime-6)","bg-(--orange-6)","bg-(--purple-6)","bg-(--red-6)","bg-(--sage-6)","bg-(--sky-6)","bg-(--slate-6)"],ju=e=>{if(typeof e=="string"){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t=Math.trunc(t);return xr[Math.abs(t)%xr.length]}return xr[e%xr.length]},Ru=(e,t,r)=>He.define(n=>new Gu(n,e,t,r)),Et=Wr.define();var Gu=class{constructor(e,t,r,n){p(this,"isInitDispatch",!1);p(this,"onRemoteUpdate",e=>{if(e.by!=="local"){if(e.by==="checkout"){this.view.dispatch({changes:[{from:0,to:this.view.state.doc.length,insert:this.getTextFromDoc(this.doc).toString()}],annotations:[Et.of(this)]});return}if(e.by==="import"){let t=[],r=0;for(let{diff:n,path:o}of e.events){if(o.join("/")!==this.docPath.join("/")||n.type!=="text")continue;let a=n.diff;for(let i of a)i.insert?t.push({from:r,to:r,insert:i.insert}):i.delete?(t.push({from:r,to:r+i.delete}),r+=i.delete):i.retain!=null&&(r+=i.retain);t.length>0&&this.view.dispatch({changes:t,annotations:[Et.of(this)]})}}}});this.view=e,this.doc=t,this.docPath=r,this.getTextFromDoc=n,this.sub=t.subscribe(this.onRemoteUpdate),Promise.resolve().then(()=>{this.isInitDispatch=!0;let o=this.view.state.doc.toString(),a=this.getTextFromDoc(this.doc);o!==a.toString()&&e.dispatch({changes:[{from:0,to:this.view.state.doc.length,insert:a.toString()}]})})}update(e){if(this.isInitDispatch){this.isInitDispatch=!1;return}if(!e.docChanged||e.transactions.length>0&&(e.transactions[0].annotation(Et)===this||e.transactions[0].annotation(Et)==="undo"))return;let t=0;e.changes.iterChanges((r,n,o,a,i)=>{let s=i.sliceString(0,i.length,`
|
|
19
|
+
`);r!==n&&this.getTextFromDoc(this.doc).delete(r+t,n-r),s.length>0&&this.getTextFromDoc(this.doc).insert(r+t,s),t+=s.length-(n-r)}),this.doc.commit()}destroy(){var e;(e=this.sub)==null||e.call(this),this.sub=void 0}},me=Ze.get("rtc"),Ca=me.get("awareness").disabled(),yn="awareness:";function Ju(e,t){let r=new TextEncoder().encode(e);return new Uint8Array([...r,...t])}function Vu(e,t){return new TextDecoder().decode(e.slice(0,t.length))===t}function Wu(e,t){return e.slice(t.length)}gt=Wt(void 0);var ie=new cs,Sr=new Fu(ie.peerIdStr),wn=Wm(()=>{me.debug("creating websocket");let e=Ji().getWsSyncURL(sm()).toString(),t=new zh(e,void 0,{maxRetries:10,debug:!1,startClosed:!0,connectionTimeout:1e4});return Promise.resolve().then(async()=>{await zi(),Ah()==="edit"&&t.reconnect()}),t.addEventListener("message",async r=>{let n=await r.data.arrayBuffer(),o=new Uint8Array(n);if(Vu(o,yn)){let a=Wu(o,yn);Sr.apply(a),Ca.debug("applied awareness update");return}ie.import(o),me.debug("imported doc change. new doc:",ie.toJSON()),Y.get(gt)!==ie&&Y.set(gt,ie)}),t.addEventListener("open",()=>{me.debug("websocket open")}),t.addEventListener("close",r=>{me.warn("websocket close",r),Y.get(gt)===ie&&Y.set(gt,void 0)}),t});jn()&&wn(),ie.subscribeLocalUpdates(e=>{me.debug("local update, sending to server"),wn().send(e)}),Sr.addListener((e,t)=>{let r=[...e.added,...e.removed,...e.updated];t==="local"&&(Ca.debug("awareness changes",r),wn().send(Ju(yn,Sr.encode(r))))});function vn(e,t,r=""){if(im())return{extension:[],code:r};let n=ie.getByPath(`codes/${e}`)!==void 0,o=ie.getMap("codes").getOrCreateContainer(e,new Zn);return n||(me.log("initializing code for new cell",r),o.insert(0,r)),{code:r.toString(),extension:[$u(e),Hu(e),qu(ie,Sr,{get name(){return Y.get(Tf)||"Anonymous"},get colorClassName(){return ju(this.name)}},()=>o,e),Ru(ie,["codes",e],()=>o)]}}function $u(e){let t=(n,o)=>{let a=n.state.field(Gr).type,i=o.toString();i&&i!==a&&(me.debug(`[incoming] setting language type: ${a} -> ${i}`),$t(n,{language:i,keepCodeAsIs:!0}))},r=(n,o)=>{let a=n.state.field(Vn),i=o.toJSON();Jr(a,i)||n.dispatch({effects:[Fi.of(i)],annotations:[Et.of(!0)]})};return He.define(n=>{let o;return Promise.resolve().then(()=>{let a=ie.getByPath(`languages/${e}`);if(!a){me.error("no language container found for cell",e);return}Ht(a instanceof Zn,"language type is not a LoroText");let i=ie.getByPath(`language_metadata/${e}`);if(!i){me.error("no language metadata container found for cell",e);return}Ht(i instanceof ds,"language metadata is not a LoroMap"),t(n,a),r(n,i),o=ie.subscribe(s=>{if(s.origin==="local")return;let l=s.events.some(d=>d.target===a.id),c=s.events.some(d=>d.target===i.id);l&&t(n,a),c&&r(n,i)})}),{destroy(){o()}}})}function Hu(e){let t=ie.getMap("languages").getOrCreateContainer(e,new Zn),r=ie.getMap("language_metadata").getOrCreateContainer(e,new ds);return L.updateListener.of(n=>{let o=t.toString()!=="";if(!n.docChanged&&o)return;if(!o){let i=Wn(n.state).type;$t(n.view,{language:i}),me.debug("no initial language, setting default to",i),t.delete(0,t.length),t.insert(0,i),me.debug("no initial language metadata, setting default to",n.state.field(Vn));let s=n.state.field(Vn);for(let l of Object.keys(s))r.set(l,s[l]);ie.commit();return}let a=!1;for(let i of n.transactions)if(!i.annotation(Et)){for(let s of i.effects)if(s.is(Pf)&&t.toString()!==s.value.type&&(me.debug(`[outgoing] language change: ${t} -> ${s.value.type}`),t.delete(0,t.length),t.insert(0,s.value.type),a=!0),s.is(Fi)||s.is(Bi)){let l=s.value;s.is(Bi)?(me.debug("[outgoing] setting language metadata: ",l),r.clear()):me.debug("[outgoing] updating language metadata: ",l);for(let c of Object.keys(l))r.set(c,l[c]);a=!0}}a&&ie.commit()})}function qu(e,t,r,n,o,a){let i=`loro:cell:${o}`;return[bn,Ou(),Bu(),He.define(s=>new _u(s,e,r,t,n,i,a)),He.define(s=>new Mu(s,e,t,i)),Lu]}var zu=pe(We());no=e=>{let t=(0,zu.c)(41),{resetOnBlur:r,placeholderText:n,initialValue:o,flexibleWidth:a,onNameChange:i,className:s}=e,l=r===void 0?!1:r,c=o===void 0?null:o,d=a===void 0?!1:a,{sendListFiles:f}=Xt(),[h,m]=(0,F.useState)(c),g;t[0]===Symbol.for("react.memo_cache_sentinel")?(g=[],t[0]=g):g=t[0];let[b,y]=(0,F.useState)(g),[E,C]=(0,F.useState)(!1),O=(0,F.useRef)(null),M=(0,F.useRef)(!1),B,S;t[1]===c?(B=t[2],S=t[3]):(B=()=>{m(c)},S=[c],t[1]=c,t[2]=B,t[3]=S),(0,F.useEffect)(B,S);let x;t[4]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{C(!0)},t[4]=x):x=t[4];let H=x,j;t[5]!==c||t[6]!==l?(j=oe=>{var Ct;(Ct=oe.relatedTarget)!=null&&Ct.closest(".filename-input")||(C(!1),l&&m(c))},t[5]=c,t[6]=l,t[7]=j):j=t[7];let Z=j,T;t[8]===h?T=t[9]:(T=Qe.dirname(h||""),t[8]=h,t[9]=T);let $=T,ce=Qe.basename(h||""),P=b.filter(oe=>Qe.basename(oe.path).startsWith(ce)),G;t[10]!==$||t[11]!==E||t[12]!==f?(G=async()=>{if(!E){y([]);return}let oe=await f({path:$});y(oe.files)},t[10]=$,t[11]=E,t[12]=f,t[13]=G):G=t[13];let ne;t[14]!==$||t[15]!==E?(ne=[$,E],t[14]=$,t[15]=E,t[16]=ne):ne=t[16];let{isPending:ue}=xh(G,ne),k=Ku(h,b,c),N=(k||P.length>0)&&(0,w.jsxs)(is,{className:"font-mono",children:[!ue&&(0,w.jsx)(Uh,{children:"No files"}),k&&(0,w.jsxs)(as,{variant:"success",className:"py-2 px-3",onSelect:()=>{var oe;k&&(M.current=!0,i(k),(oe=O.current)==null||oe.blur())},children:[(0,w.jsx)(re,{className:"w-4 h-4 mr-2"})," ",(0,w.jsxs)("span",{className:"text-sm",children:[c?"Rename to: ":"Save as: ",(0,w.jsx)("span",{className:"font-medium text-sm",children:Qe.basename(k)})]})]},"_rename_"),P.map(oe=>{let Ct=oe.isDirectory?"directory":gh(oe.path),df=ph[Ct];return(0,w.jsxs)(as,{variant:oe.isDirectory?"default":"muted",className:"py-2 px-3",onSelect:()=>{oe.isDirectory?m(`${oe.path}/`):m(oe.path)},children:[(0,w.jsx)(df,{className:"w-4 h-4 mr-2"})," ",Qe.basename(oe.path)]},oe.path)})]}),V=Math.max(20,(h==null?void 0:h.length)||(n==null?void 0:n.length)||0)*10,D=E?h||"":c||"",q;t[17]!==d||t[18]!==V?(q=d?{maxWidth:V}:void 0,t[17]=d,t[18]=V,t[19]=q):q=t[19];let Ve;t[20]===s?Ve=t[21]:(Ve=qt(s,"w-full px-4 py-1 my-1 h-9 font-mono text-foreground/60"),t[20]=s,t[21]=Ve);let he;t[22]!==n||t[23]!==D||t[24]!==q||t[25]!==Ve?(he=(0,w.jsx)(Th,{children:(0,w.jsx)(Dh,{"data-testid":"dir-completion-input",tabIndex:-1,rootClassName:"border-none justify-center px-1",spellCheck:"false",value:D,onKeyDown:Yu,icon:null,ref:O,onValueChange:m,placeholder:n,autoComplete:"off",style:q,className:Ve})}),t[22]=n,t[23]=D,t[24]=q,t[25]=Ve,t[26]=he):he=t[26];let ye=N&&"group-focus-within:block",ve;t[27]===ye?ve=t[28]:(ve=qt("p-0 w-full min-w-80 max-w-80vw hidden",ye),t[27]=ye,t[28]=ve);let I;t[29]!==N||t[30]!==ve?(I=(0,w.jsx)(Ih,{side:"bottom",className:ve,portal:!1,children:N}),t[29]=N,t[30]=ve,t[31]=I):I=t[31];let U;t[32]!==he||t[33]!==I?(U=(0,w.jsxs)(is,{children:[he,I]}),t[32]=he,t[33]=I,t[34]=U):U=t[34];let R;t[35]!==Z||t[36]!==U?(R=(0,w.jsx)(_h,{onFocus:H,onBlur:Z,shouldFilter:!1,id:"filename-input",className:"bg-transparent group filename-input",children:U}),t[35]=Z,t[36]=U,t[37]=R):R=t[37];let ge;return t[38]!==E||t[39]!==R?(ge=(0,w.jsx)(um,{children:(0,w.jsx)(Fh,{open:E,modal:!1,children:R})}),t[38]=E,t[39]=R,t[40]=ge):ge=t[40],ge};function Ku(e,t,r){if(e&&!e.endsWith("/")&&((Rf("markdown")?new Set(["py","md","markdown","qmd"]):new Set(["py"])).has(Qe.extension(e))||(e=e.endsWith(".")?`${e}py`:e.endsWith(".p")?`${e}y`:`${e}.py`),!t.some(n=>n.path===e||Qe.basename(n.path)===e)&&!(r&&(r===e||Qe.basename(r)===e))))return e}function Yu(e){e.key==="Escape"&&e.currentTarget.blur()}var Na=pe(We()),Xu=e=>{let t=(0,Na.c)(33),r=()=>{hh(new Blob([n()],{type:"text/plain"}),`${e.proposedName}.json`)},n=de(ed),o;t[0]!==r||t[1]!==e?(o=B=>{B.preventDefault(),r(),e.closeModal()},t[0]=r,t[1]=e,t[2]=o):o=t[2];let a;t[3]===e?a=t[4]:(a=B=>{B.key==="Escape"&&e.closeModal()},t[3]=e,t[4]=a);let i;t[5]===Symbol.for("react.memo_cache_sentinel")?(i=(0,w.jsx)(Zi,{className:"text-accent-foreground mb-6",children:"Download unsaved changes?"}),t[5]=i):i=t[5];let s;t[6]===Symbol.for("react.memo_cache_sentinel")?(s={wordBreak:"break-word"},t[6]=s):s=t[6];let l,c;t[7]===Symbol.for("react.memo_cache_sentinel")?(l=(0,w.jsx)("p",{children:"This app has unsaved changes. To recover:"}),c={paddingBottom:"10px"},t[7]=l,t[8]=c):(l=t[7],c=t[8]);let d;t[9]===e.proposedName?d=t[10]:(d=(0,w.jsxs)("li",{style:c,children:['Click the "Download" button. This will download a file called\xA0',(0,w.jsxs)("code",{children:[e.proposedName,".json"]}),". This file contains your code."]}),t[9]=e.proposedName,t[10]=d);let f;t[11]===Symbol.for("react.memo_cache_sentinel")?(f={paddingBottom:"10px"},t[11]=f):f=t[11];let h;t[12]===Symbol.for("react.memo_cache_sentinel")?(h={display:"block",padding:"10px"},t[12]=h):h=t[12];let m;t[13]===e.proposedName?m=t[14]:(m=(0,w.jsxs)("code",{style:h,children:["marimo recover ",e.proposedName,".json ",">"," ",e.proposedName,".py"]}),t[13]=e.proposedName,t[14]=m);let g;t[15]===e.proposedName?g=t[16]:(g=(0,w.jsxs)("code",{children:[e.proposedName,".py"]}),t[15]=e.proposedName,t[16]=g);let b;t[17]!==g||t[18]!==m?(b=(0,w.jsxs)("li",{style:f,children:["In your terminal, type",m,"to overwrite ",g," with the recovered changes."]}),t[17]=g,t[18]=m,t[19]=b):b=t[19];let y;t[20]!==b||t[21]!==d?(y=(0,w.jsx)(Ch,{className:"markdown break-words",style:s,children:(0,w.jsxs)("div",{className:"prose dark:prose-invert",children:[l,(0,w.jsxs)("ol",{children:[d,b]})]})}),t[20]=b,t[21]=d,t[22]=y):y=t[22];let E;t[23]===e.closeModal?E=t[24]:(E=(0,w.jsx)(et,{"aria-label":"Cancel",variant:"secondary","data-testid":"cancel-recovery-button",onClick:e.closeModal,children:"Cancel"}),t[23]=e.closeModal,t[24]=E);let C;t[25]===Symbol.for("react.memo_cache_sentinel")?(C=(0,w.jsx)(et,{"data-testid":"download-recovery-button","aria-label":"Download",variant:"default",type:"submit",children:"Download"}),t[25]=C):C=t[25];let O;t[26]===E?O=t[27]:(O=(0,w.jsxs)(es,{children:[E,C]}),t[26]=E,t[27]=O);let M;return t[28]!==o||t[29]!==a||t[30]!==y||t[31]!==O?(M=(0,w.jsx)(ts,{className:"w-fit",children:(0,w.jsxs)("form",{onSubmit:o,onKeyDown:a,children:[i,y,O]})}),t[28]=o,t[29]=a,t[30]=y,t[31]=O,t[32]=M):M=t[32],M};const Qu=e=>{let t=(0,Na.c)(12),{filename:r,needsSave:n}=e,{openModal:o,closeModal:a}=rs(),i;t[0]===r?i=t[1]:(i=r===null?"app":Qe.basename(r).split(".")[0],t[0]=r,t[1]=i);let s=i,l;t[2]!==a||t[3]!==n||t[4]!==o||t[5]!==s?(l=()=>{n&&o((0,w.jsx)(Xu,{proposedName:s,closeModal:a}))},t[2]=a,t[3]=n,t[4]=o,t[5]=s,t[6]=l):l=t[6];let c=l;Vi("global.save",c);let d;t[7]===Symbol.for("react.memo_cache_sentinel")?(d=ns("global.save"),t[7]=d):d=t[7];let f=n?"yellow":"gray",h;t[8]===Symbol.for("react.memo_cache_sentinel")?(h=(0,w.jsx)(Yi,{strokeWidth:1.5,size:18}),t[8]=h):h=t[8];let m;return t[9]!==c||t[10]!==f?(m=(0,w.jsx)(Zt,{content:d,children:(0,w.jsx)(ls,{onClick:c,id:"save-button","aria-label":"Save",className:"rectangle",color:f,children:h})}),t[9]=c,t[10]=f,t[11]=m):m=t[11],m};function Zu(e){return{id:e.id,name:e.name,code:e.code,code_hash:null,config:{column:0,...e.config}}}function ed(){let e=Jn(),t=$n(e),r={version:"1",metadata:{marimo_version:cm()},cells:t.map(Zu)};return JSON.stringify(r,null,2)}var td=pe(We()),En=5e3;function rd(){let e=(0,td.c)(12),t=le(rm),{state:r}=le(ht),n=t.auto_download.includes("markdown"),o=t.auto_download.includes("html"),a=t.auto_download.includes("ipynb"),i=!n||r!==rt.OPEN,s=!o||r!==rt.OPEN,l=!a||r!==rt.OPEN,{autoExportAsHTML:c,autoExportAsIPYNB:d,autoExportAsMarkdown:f}=Xt(),h;e[0]===f?h=e[1]:(h=async()=>{await f({download:!1})},e[0]=f,e[1]=h);let m;e[2]===i?m=e[3]:(m={delayMs:En,whenVisible:!0,disabled:i},e[2]=i,e[3]=m),eo(h,m);let g;e[4]===c?g=e[5]:(g=async()=>{await c({download:!1,includeCode:!0,files:th.INSTANCE.filenames()})},e[4]=c,e[5]=g);let b;e[6]===s?b=e[7]:(b={delayMs:En,whenVisible:!0,disabled:s},e[6]=s,e[7]=b),eo(g,b);let y;e[8]===d?y=e[9]:(y=async()=>{await d({download:!1})},e[8]=d,e[9]=y);let E;e[10]===l?E=e[11]:(E={delayMs:En,whenVisible:!0,disabled:l},e[10]=l,e[11]=E),eo(y,E)}let kn;qr=Wt(void 0),kn=Wt(e=>{let t=e(qr),r=e(ot),n=e(Ki);return nd({state:r,layout:n,lastSavedNotebook:t})});function nd({state:e,layout:t,lastSavedNotebook:r}){if(!r)return!1;let{cellIds:n,cellData:o}=e,a=n.inOrderIds.map(c=>o[c]),i=a.map(c=>c.code),s=a.map(c=>c.config),l=a.map(c=>c.name);return!Hi(i,r.codes)||!Hi(l,r.names)||!Jr(s,r.configs)||!Jr(t.selectedLayout,r.layout.selectedLayout)||!Jr(t.layoutData,r.layout.layoutData)}var od=pe(We());function ad(e){let t=(0,od.c)(21),{codes:r,cellConfigs:n,config:o,connStatus:a,cellNames:i,needsSave:s,kioskMode:l,onSave:c}=e,d=(0,F.useRef)(null),f;t[0]===r?f=t[1]:(f=r.join(":"),t[0]=r,t[1]=f);let h=f,m;t[2]===n?m=t[3]:(m=n.map(id).join(":"),t[2]=n,t[3]=m);let g=m,b;t[4]===i?b=t[5]:(b=i.join(":"),t[4]=i,t[5]=b);let y=b,E;t[6]!==o||t[7]!==a.state||t[8]!==l||t[9]!==s||t[10]!==c?(E=()=>{if(!l)return o.autosave==="after_delay"&&(d.current!==null&&clearTimeout(d.current),s&&a.state===rt.OPEN&&(d.current=setTimeout(c,o.autosave_delay))),()=>{d.current!==null&&clearTimeout(d.current)}},t[6]=o,t[7]=a.state,t[8]=l,t[9]=s,t[10]=c,t[11]=E):E=t[11];let C;t[12]!==g||t[13]!==y||t[14]!==h||t[15]!==o||t[16]!==a.state||t[17]!==l||t[18]!==s||t[19]!==c?(C=[h,g,y,o,a.state,c,l,s],t[12]=g,t[13]=y,t[14]=h,t[15]=o,t[16]=a.state,t[17]=l,t[18]=s,t[19]=c,t[20]=C):C=t[20],(0,F.useEffect)(E,C)}function id(e){return JSON.stringify(e)}var Tr=pe(We());gs=e=>{let t=(0,Tr.c)(15),{kioskMode:r}=e,n=jh(),o=le(kn),a=le(ht).state===rt.CLOSED,{saveOrNameNotebook:i,saveIfNotebookIsPersistent:s}=An(),l;t[0]!==r||t[1]!==s?(l={onSave:s,kioskMode:r},t[0]=r,t[1]=s,t[2]=l):l=t[2],ud(l),rd();let c;t[3]===o?c=t[4]:(c=y=>{if(o)return y.preventDefault(),y.returnValue="You have unsaved changes. Are you sure you want to leave?",y.returnValue},t[3]=o,t[4]=c),dm(window,"beforeunload",c);let d;t[5]===i?d=t[6]:(d=y=>{y.preventDefault(),y.stopPropagation(),i()},t[5]=i,t[6]=d);let f=d;if(Vi("global.save",i),a){let y;return t[7]!==n||t[8]!==o?(y=(0,w.jsx)(Qu,{filename:n,needsSave:o}),t[7]=n,t[8]=o,t[9]=y):y=t[9],y}let h;t[10]===Symbol.for("react.memo_cache_sentinel")?(h=ns("global.save"),t[10]=h):h=t[10];let m=o?"yellow":"hint-green",g;t[11]===Symbol.for("react.memo_cache_sentinel")?(g=(0,w.jsx)(Yi,{strokeWidth:1.5,size:18}),t[11]=g):g=t[11];let b;return t[12]!==f||t[13]!==m?(b=(0,w.jsx)(Zt,{content:h,children:(0,w.jsx)(ls,{"data-testid":"save-button",id:"save-button",shape:"rectangle",color:m,onClick:f,children:g})}),t[12]=f,t[13]=m,t[14]=b):b=t[14],b};function An(){let e=(0,Tr.c)(20),{sendSave:t}=Xt(),{openModal:r,closeModal:n,openAlert:o}=rs(),a=xi(qr),i=Ph(),s=Pn(),l;e[0]!==o||e[1]!==t||e[2]!==a||e[3]!==s?(l=(E,C)=>{let O=Jn(),M=$n(O),B=M.map(cd),S=M.map(ld),x=M.map(sd),H=Oi(O),j=s.get(ht),Z=s.get(Gi),T=s.get(Ki);if(!s.get(kh)&&S.length!==0){if(j.state!==rt.OPEN){o("Failed to save notebook: not connected to a kernel.");return}Ze.log("saving to ",E),t({cellIds:B,codes:S,names:x,filename:E,configs:H,layout:rh(),persist:!0}).then(()=>{C&&Z.format_on_save&&pf(),a({names:x,codes:S,configs:H,layout:T})})}},e[0]=o,e[1]=t,e[2]=a,e[3]=s,e[4]=l):l=e[4];let c=de(l),d;e[5]!==c||e[6]!==s?(d=E=>{let C=E===void 0?!1:E,O=s.get(_i),M=s.get(ht);xa(O)&&M.state===rt.OPEN&&c(O,C)},e[5]=c,e[6]=s,e[7]=d):d=e[7];let f=de(d),h;e[8]!==c||e[9]!==i?(h=E=>{i(E).then(C=>{C!==null&&c(C,!0)})},e[8]=c,e[9]=i,e[10]=h):h=e[10];let m=h,g;e[11]!==n||e[12]!==m||e[13]!==r||e[14]!==f||e[15]!==s?(g=()=>{let E=s.get(_i),C=s.get(ht);f(!0),!xa(E)&&C.state!==rt.CLOSED&&r((0,w.jsx)(md,{onClose:n,onSave:m}))},e[11]=n,e[12]=m,e[13]=r,e[14]=f,e[15]=s,e[16]=g):g=e[16];let b=de(g),y;return e[17]!==f||e[18]!==b?(y={saveOrNameNotebook:b,saveIfNotebookIsPersistent:f},e[17]=f,e[18]=b,e[19]=y):y=e[19],y}function sd(e){return e.name}function ld(e){return e.code}function cd(e){return e.id}function xa(e){return e!==null&&!e.startsWith("/tmp")&&!e.startsWith("/var/folders")&&!e.includes("AppData\\Local\\Temp")}function ud(e){let t=(0,Tr.c)(14),r=le(Gi),n=Ef(),[o]=Pr(ht),a=le(kn),i,s;if(t[0]!==n){let h=$n(n);i=h.map(fd),s=h.map(dd),t[0]=n,t[1]=i,t[2]=s}else i=t[1],s=t[2];let l=s,c;t[3]===n?c=t[4]:(c=Oi(n),t[3]=n,t[4]=c);let d=c,f;t[5]!==r||t[6]!==l||t[7]!==i||t[8]!==d||t[9]!==o||t[10]!==a||t[11]!==e.kioskMode||t[12]!==e.onSave?(f={onSave:e.onSave,needsSave:a,codes:i,cellConfigs:d,cellNames:l,connStatus:o,config:r,kioskMode:e.kioskMode},t[5]=r,t[6]=l,t[7]=i,t[8]=d,t[9]=o,t[10]=a,t[11]=e.kioskMode,t[12]=e.onSave,t[13]=f):f=t[13],ad(f)}function dd(e){return e.name}function fd(e){return e.code}var md=e=>{let t=(0,Tr.c)(17),{onClose:r,onSave:n}=e,[o,a]=(0,F.useState)(),i;t[0]!==r||t[1]!==n?(i=y=>{a(y),y.trim()&&(n(y),r())},t[0]=r,t[1]=n,t[2]=i):i=t[2];let s=i,l;t[3]===Symbol.for("react.memo_cache_sentinel")?(l=(0,w.jsx)(Zi,{children:"Save notebook"}),t[3]=l):l=t[3];let c;t[4]===Symbol.for("react.memo_cache_sentinel")?(c=(0,w.jsx)(os,{className:"text-md pt-6 px-1",children:"Save as"}),t[4]=c):c=t[4];let d;t[5]===s?d=t[6]:(d=(0,w.jsxs)("div",{className:"flex flex-col",children:[c,(0,w.jsx)(no,{onNameChange:s,placeholderText:"filename",className:"missing-filename"})]}),t[5]=s,t[6]=d);let f;t[7]===r?f=t[8]:(f=(0,w.jsx)(et,{"data-testid":"cancel-save-dialog-button","aria-label":"Cancel",variant:"secondary",onClick:r,children:"Cancel"}),t[7]=r,t[8]=f);let h=!o,m;t[9]===h?m=t[10]:(m=(0,w.jsx)(et,{"data-testid":"submit-save-dialog-button","aria-label":"Save",variant:"default",disabled:h,type:"submit",children:"Save"}),t[9]=h,t[10]=m);let g;t[11]!==f||t[12]!==m?(g=(0,w.jsxs)(es,{children:[f,m]}),t[11]=f,t[12]=m,t[13]=g):g=t[13];let b;return t[14]!==d||t[15]!==g?(b=(0,w.jsxs)(ts,{children:[l,d,g]}),t[14]=d,t[15]=g,t[16]=b):b=t[16],b};zr=function(...e){return t=>{e.forEach(r=>{typeof r=="function"?r(t):r!=null&&(r.current=t)})}};var Sa={modified:{doc:""},original:{doc:""}},Ta=(0,F.createContext)(Sa);function hd(e,t){return X({},e,t,{modified:X({},e.modified,t.modified),original:X({},e.original,t.original)})}var Cn=()=>(0,F.useContext)(Ta),gd=e=>{var{children:t,theme:r}=e,[n,o]=(0,F.useReducer)(hd,X({},Sa,{theme:r}));return(0,F.useEffect)(()=>o({theme:r}),[r]),(0,w.jsx)(Ta.Provider,{value:X({},n,{dispatch:o}),children:t})},pd=["extensions","value","selection","onChange"],Ia=e=>{var{extensions:t=[],value:r,selection:n,onChange:o}=e,a=er(e,pd),{theme:i,dispatch:s}=Cn(),l=Tt(X({},a,{theme:i}));return(0,F.useEffect)(()=>s({original:{doc:r,selection:n,extensions:[...l,...t]},originalExtension:{onChange:o,option:a,extension:[t]}}),[e]),null};Ia.displayName="CodeMirrorMerge.Original";var bd=["extensions","value","selection","onChange"],Fa=e=>{var{extensions:t=[],value:r,selection:n,onChange:o}=e,a=er(e,bd),{theme:i,dispatch:s}=Cn(),l=Tt(X({},a,{theme:i}));return(0,F.useEffect)(()=>{s({modified:{doc:r,selection:n,extensions:[...l,...t]},modifiedExtension:{onChange:o,option:a,extension:[t]}})},[e]),null};Fa.displayName="CodeMirrorMerge.Modified";var se=class ks{constructor(t,r,n,o){this.fromA=t,this.toA=r,this.fromB=n,this.toB=o}offset(t,r=t){return new ks(this.fromA+t,this.toA+t,this.fromB+r,this.toB+r)}};function ut(e,t,r,n,o,a){if(e==n)return[];let i=Tn(e,t,r,n,o,a),s=In(e,t+i,r,n,o+i,a);t+=i,r-=s,o+=i,a-=s;let l=r-t,c=a-o;if(!l||!c)return[new se(t,r,o,a)];if(l>c){let f=e.slice(t,r).indexOf(n.slice(o,a));if(f>-1)return[new se(t,t+f,o,o),new se(t+f+c,r,a,a)]}else if(c>l){let f=n.slice(o,a).indexOf(e.slice(t,r));if(f>-1)return[new se(t,t,o,o+f),new se(r,r,o+f+l,a)]}if(l==1||c==1)return[new se(t,r,o,a)];let d=Ba(e,t,r,n,o,a);if(d){let[f,h,m]=d;return ut(e,t,f,n,o,h).concat(ut(e,f+m,r,n,h+m,a))}return yd(e,t,r,n,o,a)}var Rt=1e9,Gt=0,Nn=!1;function yd(e,t,r,n,o,a){let i=r-t,s=a-o;if(Rt<1e9&&Math.min(i,s)>Rt*16||Gt>0&&Date.now()>Gt)return Math.min(i,s)>Rt*64?[new se(t,r,o,a)]:Da(e,t,r,n,o,a);let l=Math.ceil((i+s)/2);xn.reset(l),Sn.reset(l);let c=(m,g)=>e.charCodeAt(t+m)==n.charCodeAt(o+g),d=(m,g)=>e.charCodeAt(r-m-1)==n.charCodeAt(a-g-1),f=(i-s)%2==0?null:Sn,h=f?null:xn;for(let m=0;m<l;m++){if(m>Rt||Gt>0&&!(m&63)&&Date.now()>Gt)return Da(e,t,r,n,o,a);let g=xn.advance(m,i,s,l,f,!1,c)||Sn.advance(m,i,s,l,h,!0,d);if(g)return wd(e,t,r,t+g[0],n,o,a,o+g[1])}return[new se(t,r,o,a)]}var La=class{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let t=0;t<this.len;t++)this.vec[t]=-1;this.vec[e+1]=0,this.start=this.end=0}advance(e,t,r,n,o,a,i){for(let s=-e+this.start;s<=e-this.end;s+=2){let l=n+s,c=s==-e||s!=e&&this.vec[l-1]<this.vec[l+1]?this.vec[l+1]:this.vec[l-1]+1,d=c-s;for(;c<t&&d<r&&i(c,d);)c++,d++;if(this.vec[l]=c,c>t)this.end+=2;else if(d>r)this.start+=2;else if(o){let f=n+(t-r)-s;if(f>=0&&f<this.len&&o.vec[f]!=-1)if(a){let h=o.vec[f];if(h>=t-c)return[h,n+h-f]}else{let h=t-o.vec[f];if(c>=h)return[c,d]}}}return null}},xn=new La,Sn=new La;function wd(e,t,r,n,o,a,i,s){let l=!1;return!kt(e,n)&&++n==r&&(l=!0),!kt(o,s)&&++s==i&&(l=!0),l?[new se(t,r,a,i)]:ut(e,t,n,o,a,s).concat(ut(e,n,r,o,s,i))}function Oa(e,t){let r=1,n=Math.min(e,t);for(;r<n;)r<<=1;return r}function Tn(e,t,r,n,o,a){if(t==r||t==a||e.charCodeAt(t)!=n.charCodeAt(o))return 0;let i=Oa(r-t,a-o);for(let s=t,l=o;;){let c=s+i,d=l+i;if(c>r||d>a||e.slice(s,c)!=n.slice(l,d)){if(i==1)return s-t-(kt(e,s)?0:1);i>>=1}else{if(c==r||d==a)return c-t;s=c,l=d}}}function In(e,t,r,n,o,a){if(t==r||o==a||e.charCodeAt(r-1)!=n.charCodeAt(a-1))return 0;let i=Oa(r-t,a-o);for(let s=r,l=a;;){let c=s-i,d=l-i;if(c<t||d<o||e.slice(c,s)!=n.slice(d,l)){if(i==1)return r-s-(kt(e,s)?0:1);i>>=1}else{if(c==t||d==o)return r-c;s=c,l=d}}}function Fn(e,t,r,n,o,a,i,s){let l=n.slice(o,a),c=null;for(;;){if(c||i<s)return c;for(let d=t+i;;){kt(e,d)||d++;let f=d+i;if(kt(e,f)||(f+=f==d+1?1:-1),f>=r)break;let h=e.slice(d,f),m=-1;for(;(m=l.indexOf(h,m+1))!=-1;){let g=Tn(e,f,r,n,o+m+h.length,a),b=In(e,t,d,n,o,o+m),y=h.length+g+b;(!c||c[2]<y)&&(c=[d-b,o+m-b,y])}d=f}if(s<0)return c;i>>=1}}function Ba(e,t,r,n,o,a){let i=r-t,s=a-o;if(i<s){let l=Ba(n,o,a,e,t,r);return l&&[l[1],l[0],l[2]]}return i<4||s*2<i?null:Fn(e,t,r,n,o,a,Math.floor(i/4),-1)}function Da(e,t,r,n,o,a){Nn=!0;let i=r-t,s=a-o,l;if(i<s){let h=Fn(n,o,a,e,t,r,Math.floor(i/6),50);l=h&&[h[1],h[0],h[2]]}else l=Fn(e,t,r,n,o,a,Math.floor(s/6),50);if(!l)return[new se(t,r,o,a)];let[c,d,f]=l;return ut(e,t,c,n,o,d).concat(ut(e,c+f,r,n,d+f,a))}function Ua(e,t){for(let r=1;r<e.length;r++){let n=e[r-1],o=e[r];n.toA>o.fromA-t&&n.toB>o.fromB-t&&(e[r-1]=new se(n.fromA,o.toA,n.fromB,o.toB),e.splice(r--,1))}}function vd(e,t,r){for(;;){Ua(r,1);let n=!1;for(let o=0;o<r.length;o++){let a=r[o],i,s;(i=Tn(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=r[o]=new se(a.fromA+i,a.toA,a.fromB+i,a.toB)),(s=In(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=r[o]=new se(a.fromA,a.toA-s,a.fromB,a.toB-s));let l=a.toA-a.fromA,c=a.toB-a.fromB;if(l&&c)continue;let d=a.fromA-(o?r[o-1].toA:0),f=(o<r.length-1?r[o+1].fromA:e.length)-a.toA;if(!d||!f)continue;let h=l?e.slice(a.fromA,a.toA):t.slice(a.fromB,a.toB);d<=h.length&&e.slice(a.fromA-d,a.fromA)==h.slice(h.length-d)?(r[o]=new se(a.fromA-d,a.toA-d,a.fromB-d,a.toB-d),n=!0):f<=h.length&&e.slice(a.toA,a.toA+f)==h.slice(0,f)&&(r[o]=new se(a.fromA+f,a.toA+f,a.fromB+f,a.toB+f),n=!0)}if(!n)break}return r}function Ed(e,t,r){for(let n=0,o=0;o<e.length;o++){let a=e[o],i=a.toA-a.fromA,s=a.toB-a.fromB;if(i&&s||i>3||s>3){let l=o==e.length-1?t.length:e[o+1].fromA,c=a.fromA-n,d=l-a.toA,f=Ga(t,a.fromA,c),h=Ra(t,a.toA,d),m=a.fromA-f,g=h-a.toA;if((!i||!s)&&m&&g){let b=Math.max(i,s),[y,E,C]=i?[t,a.fromA,a.toA]:[r,a.fromB,a.toB];b>m&&t.slice(f,a.fromA)==y.slice(C-m,C)?(a=e[o]=new se(f,f+i,a.fromB-m,a.toB-m),f=a.fromA,h=Ra(t,a.toA,l-a.toA)):b>g&&t.slice(a.toA,h)==y.slice(E,E+g)&&(a=e[o]=new se(h-i,h,a.fromB+g,a.toB+g),h=a.toA,f=Ga(t,a.fromA,a.fromA-n)),m=a.fromA-f,g=h-a.toA}if(m||g)a=e[o]=new se(a.fromA-m,a.toA+g,a.fromB-m,a.toB+g);else if(i){if(!s){let b=Va(t,a.fromA,a.toA),y,E=b<0?-1:Ja(t,a.toA,a.fromA);b>-1&&(y=b-a.fromA)<=d&&t.slice(a.fromA,b)==t.slice(a.toA,a.toA+y)?a=e[o]=a.offset(y):E>-1&&(y=a.toA-E)<=c&&t.slice(a.fromA-y,a.fromA)==t.slice(E,a.toA)&&(a=e[o]=a.offset(-y))}}else{let b=Va(r,a.fromB,a.toB),y,E=b<0?-1:Ja(r,a.toB,a.fromB);b>-1&&(y=b-a.fromB)<=d&&r.slice(a.fromB,b)==r.slice(a.toB,a.toB+y)?a=e[o]=a.offset(y):E>-1&&(y=a.toB-E)<=c&&r.slice(a.fromB-y,a.fromB)==r.slice(E,a.toB)&&(a=e[o]=a.offset(-y))}}n=a.toA}return Ua(e,3),e}var dt;try{dt=RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch{}function _a(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function Ma(e,t){if(t==e.length)return 0;let r=e.charCodeAt(t);return r<192?_a(r)?1:0:dt?!Wa(r)||t==e.length-1?dt.test(String.fromCharCode(r))?1:0:dt.test(e.slice(t,t+2))?2:0:0}function Pa(e,t){if(!t)return 0;let r=e.charCodeAt(t-1);return r<192?_a(r)?1:0:dt?!$a(r)||t==1?dt.test(String.fromCharCode(r))?1:0:dt.test(e.slice(t-2,t))?2:0:0}var ja=8;function Ra(e,t,r){if(t==e.length||!Pa(e,t))return t;for(let n=t,o=t+r,a=0;a<ja;a++){let i=Ma(e,n);if(!i||n+i>o)return n;n+=i}return t}function Ga(e,t,r){if(!t||!Ma(e,t))return t;for(let n=t,o=t-r,a=0;a<ja;a++){let i=Pa(e,n);if(!i||n-i<o)return n;n-=i}return t}function Ja(e,t,r){for(;t!=r;t--)if(e.charCodeAt(t-1)==10)return t;return-1}function Va(e,t,r){for(;t!=r;t++)if(e.charCodeAt(t)==10)return t;return-1}var Wa=e=>e>=55296&&e<=56319,$a=e=>e>=56320&&e<=57343;function kt(e,t){return!t||t==e.length||!Wa(e.charCodeAt(t-1))||!$a(e.charCodeAt(t))}function kd(e,t,r){return Rt=((r==null?void 0:r.scanLimit)??1e9)>>1,Gt=r!=null&&r.timeout?Date.now()+r.timeout:0,Nn=!1,vd(e,t,ut(e,0,e.length,t,0,t.length))}function Ha(){return!Nn}function qa(e,t,r){return Ed(kd(e,t,r),e,t)}var ze=ft.define({combine:e=>e[0]}),Ln=te.define(),Ad=ft.define(),At=Ee.define({create(e){return null},update(e,t){for(let r of t.effects)r.is(Ln)&&(e=r.value);for(let r of t.state.facet(Ad))e=r(e,t);return e}}),Ir=class As{constructor(t,r,n,o,a,i=!0){this.changes=t,this.fromA=r,this.toA=n,this.fromB=o,this.toB=a,this.precise=i}offset(t,r){return t||r?new As(this.changes,this.fromA+t,this.toA+t,this.fromB+r,this.toB+r,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(t,r,n){let o=qa(t.toString(),r.toString(),n);return Ya(o,t,r,0,0,Ha())}static updateA(t,r,n,o,a){return Za(Qa(t,o,!0,n.length),t,r,n,a)}static updateB(t,r,n,o,a){return Za(Qa(t,o,!1,r.length),t,r,n,a)}};function za(e,t,r,n){let o=r.lineAt(e),a=n.lineAt(t);return o.to==e&&a.to==t&&e<r.length&&t<n.length?[e+1,t+1]:[o.from,a.from]}function Ka(e,t,r,n){let o=r.lineAt(e),a=n.lineAt(t);return o.from==e&&a.from==t?[e,t]:[o.to+1,a.to+1]}function Ya(e,t,r,n,o,a){let i=[];for(let s=0;s<e.length;s++){let l=e[s],[c,d]=za(l.fromA+n,l.fromB+o,t,r),[f,h]=Ka(l.toA+n,l.toB+o,t,r),m=[l.offset(-c+n,-d+o)];for(;s<e.length-1;){let g=e[s+1],[b,y]=za(g.fromA+n,g.fromB+o,t,r);if(b>f+1&&y>h+1)break;m.push(g.offset(-c+n,-d+o)),[f,h]=Ka(g.toA+n,g.toB+o,t,r),s++}i.push(new Ir(m,c,Math.max(c,f),d,Math.max(d,h),a))}return i}var Fr=1e3;function Xa(e,t,r,n){let o=0,a=e.length;for(;;){if(o==a){let d=0,f=0;o&&({toA:d,toB:f}=e[o-1]);let h=t-(r?d:f);return[d+h,f+h]}let i=o+a>>1,s=e[i],[l,c]=r?[s.fromA,s.toA]:[s.fromB,s.toB];if(l>t)a=i;else if(c<=t)o=i+1;else return n?[s.fromA,s.fromB]:[s.toA,s.toB]}}function Qa(e,t,r,n){let o=[];return t.iterChangedRanges((a,i,s,l)=>{let c=0,d=r?t.length:n,f=0,h=r?n:t.length;a>Fr&&([c,f]=Xa(e,a-Fr,r,!0)),i<t.length-Fr&&([d,h]=Xa(e,i+Fr,r,!1));let m=l-s-(i-a),g,[b,y]=r?[m,0]:[0,m];o.length&&(g=o[o.length-1]).toA>=c?o[o.length-1]={fromA:g.fromA,fromB:g.fromB,toA:d,toB:h,diffA:g.diffA+b,diffB:g.diffB+y}:o.push({fromA:c,toA:d,fromB:f,toB:h,diffA:b,diffB:y})}),o}function Za(e,t,r,n,o){if(!e.length)return t;let a=[];for(let i=0,s=0,l=0,c=0;;i++){let d=i==e.length?null:e[i],f=d?d.fromA+s:r.length,h=d?d.fromB+l:n.length;for(;c<t.length;){let y=t[c];if(y.toA+s>f||y.toB+l>h)break;a.push(y.offset(s,l)),c++}if(!d)break;let m=d.toA+s+d.diffA,g=d.toB+l+d.diffB,b=qa(r.sliceString(f,m),n.sliceString(h,g),o);for(let y of Ya(b,r,n,f,h,Ha()))a.push(y);for(s+=d.diffA,l+=d.diffB;c<t.length;){let y=t[c];if(y.fromA+s>m&&y.fromB+l>g)break;c++}}return a}var Cd={scanLimit:500},ei=He.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=ni(e))}update(e){(e.docChanged||e.viewportChanged||Nd(e.startState,e.state)||xd(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=ni(e.view))}},{decorations:e=>e.deco}),Lr=tt.low(km({class:"cm-changeGutter",markers:e=>{var t;return((t=e.plugin(ei))==null?void 0:t.gutter)||Bm.empty}}));function Nd(e,t){return e.field(At,!1)!=t.field(At,!1)}function xd(e,t){return e.facet(ze)!=t.facet(ze)}var ti=_.line({class:"cm-changedLine"}),Sd=_.mark({class:"cm-changedText"}),Td=_.mark({tagName:"ins",class:"cm-insertedLine"}),Id=_.mark({tagName:"del",class:"cm-deletedLine"}),ri=new class extends Im{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function Fd(e,t,r,n,o,a){let i=r?e.fromA:e.fromB,s=r?e.toA:e.toB,l=0;if(i!=s){o.add(i,i,ti),o.add(i,s,r?Id:Td),a&&a.add(i,i,ri);for(let c=t.iterRange(i,s-1),d=i;!c.next().done;){if(c.lineBreak){d++,o.add(d,d,ti),a&&a.add(d,d,ri);continue}let f=d+c.value.length;if(n)for(;l<e.changes.length;){let h=e.changes[l],m=i+(r?h.fromA:h.fromB),g=i+(r?h.toA:h.toB),b=Math.max(d,m),y=Math.min(f,g);if(b<y&&o.add(b,y,Sd),g<f)l++;else break}d=f}}}function ni(e){let t=e.state.field(At),{side:r,highlightChanges:n,markGutter:o,overrideChunk:a}=e.state.facet(ze),i=r=="a",s=new Nt,l=o?new Nt:null,{from:c,to:d}=e.viewport;for(let f of t){if((i?f.fromA:f.fromB)>=d)break;(i?f.toA:f.toB)>c&&(!a||!a(e.state,f,s,l))&&Fd(f,e.state.doc,i,n,s,l)}return{deco:s.finish(),gutter:l&&l.finish()}}var Or=class extends xt{constructor(e){super(),this.height=e}eq(e){return this.height==e.height}toDOM(){let e=document.createElement("div");return e.className="cm-mergeSpacer",e.style.height=this.height+"px",e}updateDOM(e){return e.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}},Br=te.define({map:(e,t)=>e.map(t)}),Jt=Ee.define({create:()=>_.none,update:(e,t)=>{for(let r of t.effects)if(r.is(Br))return r.value;return e.map(t.changes)},provide:e=>L.decorations.from(e)}),Dr=.01;function oi(e,t){if(e.size!=t.size)return!1;let r=e.iter(),n=t.iter();for(;r.value;){if(r.from!=n.from||Math.abs(r.value.spec.widget.height-n.value.spec.widget.height)>1)return!1;r.next(),n.next()}return!0}function Ld(e,t,r){let n=new Nt,o=new Nt,a=e.state.field(Jt).iter(),i=t.state.field(Jt).iter(),s=0,l=0,c=0,d=0,f=e.viewport,h=t.viewport;for(let y=0;;y++){let E=y<r.length?r[y]:null,C=E?E.fromA:e.state.doc.length,O=E?E.fromB:t.state.doc.length;if(s<C){let M=e.lineBlockAt(s).top+c,B=t.lineBlockAt(l).top+d,S=M-B;S<-Dr?(c-=S,n.add(s,s,_.widget({widget:new Or(-S),block:!0,side:-1}))):S>Dr&&(d+=S,o.add(l,l,_.widget({widget:new Or(S),block:!0,side:-1})))}if(C>s+1e3&&s<f.from&&C>f.from&&l<h.from&&O>h.from){let M=Math.min(f.from-s,h.from-l);s+=M,l+=M,y--}else if(E)s=E.toA,l=E.toB;else break;for(;a.value&&a.from<s;)c-=a.value.spec.widget.height,a.next();for(;i.value&&i.from<l;)d-=i.value.spec.widget.height,i.next()}for(;a.value;)c-=a.value.spec.widget.height,a.next();for(;i.value;)d-=i.value.spec.widget.height,i.next();let m=e.contentHeight+c-(t.contentHeight+d);m<Dr?n.add(e.state.doc.length,e.state.doc.length,_.widget({widget:new Or(-m),block:!0,side:1})):m>Dr&&o.add(t.state.doc.length,t.state.doc.length,_.widget({widget:new Or(m),block:!0,side:1}));let g=n.finish(),b=o.finish();oi(g,e.state.field(Jt))||e.dispatch({effects:Br.of(g)}),oi(b,t.state.field(Jt))||t.dispatch({effects:Br.of(b)})}var On=te.define({map:(e,t)=>t.mapPos(e)}),Od=class extends xt{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let t=document.createElement("div");return t.className="cm-collapsedLines",t.textContent=e.state.phrase("$ unchanged lines",this.lines),t.addEventListener("click",r=>{let n=e.posAtDOM(r.target);e.dispatch({effects:On.of(n)});let{side:o,sibling:a}=e.state.facet(ze);a&&a().dispatch({effects:On.of(Bd(n,e.state.field(At),o=="a"))})}),t}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return"collapsed-unchanged-code"}};function Bd(e,t,r){let n=0,o=0;for(let a=0;;a++){let i=a<t.length?t[a]:null;if(!i||(r?i.fromA:i.fromB)>=e)return o+(e-n);[n,o]=r?[i.toA,i.toB]:[i.toB,i.toA]}}var Dd=Ee.define({create(e){return _.none},update(e,t){e=e.map(t.changes);for(let r of t.effects)r.is(On)&&(e=e.update({filter:n=>n!=r.value}));return e},provide:e=>L.decorations.from(e)});function ai({margin:e=3,minSize:t=4}){return Dd.init(r=>Ud(r,e,t))}function Ud(e,t,r){let n=new Nt,o=e.facet(ze).side=="a",a=e.field(At),i=1;for(let s=0;;s++){let l=s<a.length?a[s]:null,c=s?i+t:1,d=l?e.doc.lineAt(o?l.fromA:l.fromB).number-1-t:e.doc.lines,f=d-c+1;if(f>=r&&n.add(e.doc.line(c).from,e.doc.line(d).to,_.replace({widget:new Od(f),block:!0})),!l)break;i=e.doc.lineAt(Math.min(e.doc.length,o?l.toA:l.toB)).number}return n.finish()}var _d=L.styleModule.of(new pm({".cm-mergeView":{overflowY:"auto"},".cm-mergeViewEditors":{display:"flex",alignItems:"stretch"},".cm-mergeViewEditor":{flexGrow:1,flexBasis:0,overflow:"hidden"},".cm-merge-revert":{width:"1.6em",flexGrow:0,flexShrink:0,position:"relative"},".cm-merge-revert button":{position:"absolute",display:"block",width:"100%",boxSizing:"border-box",textAlign:"center",background:"none",border:"none",font:"inherit",cursor:"pointer"}})),Md=L.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:"auto !important",overflowY:"visible !important"},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:"rgba(160, 128, 100, .08)"},"&.cm-merge-b .cm-changedLine, .cm-inlineChangedLine":{backgroundColor:"rgba(100, 160, 128, .08)"},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat"},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat"},"&light.cm-merge-b .cm-changedText":{background:"linear-gradient(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat"},"&dark.cm-merge-b .cm-changedText":{background:"linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat"},"&.cm-merge-b .cm-deletedText":{background:"#ff000033"},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{textDecoration:"none"},".cm-deletedChunk":{paddingLeft:"6px","& .cm-chunkButtons":{position:"absolute",insetInlineEnd:"5px"},"& button":{border:"none",cursor:"pointer",color:"white",margin:"0 2px",borderRadius:"3px","&[name=accept]":{background:"#2a2"},"&[name=reject]":{background:"#d43"}}},".cm-collapsedLines":{padding:"5px 5px 5px 10px",cursor:"pointer","&:before":{content:'"\u299A"',marginInlineEnd:"7px"},"&:after":{content:'"\u299A"',marginInlineStart:"7px"}},"&light .cm-collapsedLines":{color:"#444",background:"linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)"},"&dark .cm-collapsedLines":{color:"#ddd",background:"linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)"},".cm-changeGutter":{width:"3px",paddingLeft:"1px"},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:"#e43"},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:"#fa9"},"&light.cm-merge-b .cm-changedLineGutter":{background:"#2b2"},"&dark.cm-merge-b .cm-changedLineGutter":{background:"#8f8"},".cm-inlineChangedLineGutter":{background:"#75d"}}),ii=new Kn,Ur=new Kn,si=class{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig||Cd;let t=[tt.low(ei),Md,_d,Jt,L.updateListener.of(d=>{this.measuring<0&&(d.heightChanged||d.viewportChanged)&&!d.transactions.some(f=>f.effects.some(h=>h.is(Br)))&&this.measure()})],r=[ze.of({side:"a",sibling:()=>this.b,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&r.push(Lr);let n=zt.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],L.editorAttributes.of({class:"cm-merge-a"}),Ur.of(r),t]}),o=[ze.of({side:"b",sibling:()=>this.a,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&o.push(Lr);let a=zt.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],L.editorAttributes.of({class:"cm-merge-b"}),Ur.of(o),t]});this.chunks=Ir.build(n.doc,a.doc,this.diffConf);let i=[At.init(()=>this.chunks),ii.of(e.collapseUnchanged?ai(e.collapseUnchanged):[])];n=n.update({effects:te.appendConfig.of(i)}).state,a=a.update({effects:te.appendConfig.of(i)}).state,this.dom=document.createElement("div"),this.dom.className="cm-mergeView",this.editorDOM=this.dom.appendChild(document.createElement("div")),this.editorDOM.className="cm-mergeViewEditors";let s=e.orientation||"a-b",l=document.createElement("div");l.className="cm-mergeViewEditor";let c=document.createElement("div");c.className="cm-mergeViewEditor",this.editorDOM.appendChild(s=="a-b"?l:c),this.editorDOM.appendChild(s=="a-b"?c:l),this.a=new L({state:n,parent:l,root:e.root,dispatchTransactions:d=>this.dispatch(d,this.a)}),this.b=new L({state:a,parent:c,root:e.root,dispatchTransactions:d=>this.dispatch(d,this.b)}),this.setupRevertControls(!!e.revertControls,e.revertControls=="b-to-a",e.renderRevertControl),e.parent&&e.parent.appendChild(this.dom),this.scheduleMeasure()}dispatch(e,t){if(e.some(r=>r.docChanged)){let r=e[e.length-1],n=e.reduce((a,i)=>a.compose(i.changes),Yt.empty(e[0].startState.doc.length));this.chunks=t==this.a?Ir.updateA(this.chunks,r.newDoc,this.b.state.doc,n,this.diffConf):Ir.updateB(this.chunks,this.a.state.doc,r.newDoc,n,this.diffConf),t.update([...e,r.state.update({effects:Ln.of(this.chunks)})]);let o=t==this.a?this.b:this.a;o.update([o.state.update({effects:Ln.of(this.chunks)})]),this.scheduleMeasure()}else t.update(e)}reconfigure(e){if("diffConfig"in e&&(this.diffConf=e.diffConfig),"orientation"in e){let o=e.orientation!="b-a";if(o!=(this.editorDOM.firstChild==this.a.dom.parentNode)){let a=this.a.dom.parentNode,i=this.b.dom.parentNode;a.remove(),i.remove(),this.editorDOM.insertBefore(o?a:i,this.editorDOM.firstChild),this.editorDOM.appendChild(o?i:a),this.revertToLeft=!this.revertToLeft,this.revertDOM&&(this.revertDOM.textContent="")}}if("revertControls"in e||"renderRevertControl"in e){let o=!!this.revertDOM,a=this.revertToA,i=this.renderRevert;"revertControls"in e&&(o=!!e.revertControls,a=e.revertControls=="b-to-a"),"renderRevertControl"in e&&(i=e.renderRevertControl),this.setupRevertControls(o,a,i)}let t="highlightChanges"in e,r="gutter"in e,n="collapseUnchanged"in e;if(t||r||n){let o=[],a=[];if(t||r){let i=this.a.state.facet(ze),s=r?e.gutter!==!1:i.markGutter,l=t?e.highlightChanges!==!1:i.highlightChanges;o.push(Ur.reconfigure([ze.of({side:"a",sibling:()=>this.b,highlightChanges:l,markGutter:s}),s?Lr:[]])),a.push(Ur.reconfigure([ze.of({side:"b",sibling:()=>this.a,highlightChanges:l,markGutter:s}),s?Lr:[]]))}if(n){let i=ii.reconfigure(e.collapseUnchanged?ai(e.collapseUnchanged):[]);o.push(i),a.push(i)}this.a.dispatch({effects:o}),this.b.dispatch({effects:a})}this.scheduleMeasure()}setupRevertControls(e,t,r){this.revertToA=t,this.revertToLeft=this.revertToA==(this.editorDOM.firstChild==this.a.dom.parentNode),this.renderRevert=r,!e&&this.revertDOM?(this.revertDOM.remove(),this.revertDOM=null):e&&!this.revertDOM?(this.revertDOM=this.editorDOM.insertBefore(document.createElement("div"),this.editorDOM.firstChild.nextSibling),this.revertDOM.addEventListener("mousedown",n=>this.revertClicked(n)),this.revertDOM.className="cm-merge-revert"):this.revertDOM&&(this.revertDOM.textContent="")}scheduleMeasure(){this.measuring<0&&(this.measuring=(this.dom.ownerDocument.defaultView||window).requestAnimationFrame(()=>{this.measuring=-1,this.measure()}))}measure(){Ld(this.a,this.b,this.chunks),this.revertDOM&&this.updateRevertButtons()}updateRevertButtons(){let e=this.revertDOM,t=e.firstChild,r=this.a.viewport,n=this.b.viewport;for(let o=0;o<this.chunks.length;o++){let a=this.chunks[o];if(a.fromA>r.to||a.fromB>n.to)break;if(a.fromA<r.from||a.fromB<n.from)continue;let i=this.a.lineBlockAt(a.fromA).top+"px";for(;t&&+t.dataset.chunk<o;)t=li(t);t&&t.dataset.chunk==String(o)?(t.style.top!=i&&(t.style.top=i),t=t.nextSibling):e.insertBefore(this.renderRevertButton(i,o),t)}for(;t;)t=li(t)}renderRevertButton(e,t){let r;if(this.renderRevert)r=this.renderRevert();else{r=document.createElement("button");let n=this.a.state.phrase("Revert this chunk");r.setAttribute("aria-label",n),r.setAttribute("title",n),r.textContent=this.revertToLeft?"\u21DC":"\u21DD"}return r.style.top=e,r.setAttribute("data-chunk",String(t)),r}revertClicked(e){let t=e.target,r;for(;t&&t.parentNode!=this.revertDOM;)t=t.parentNode;if(t&&(r=this.chunks[t.dataset.chunk])){let[n,o,a,i,s,l]=this.revertToA?[this.b,this.a,r.fromB,r.toB,r.fromA,r.toA]:[this.a,this.b,r.fromA,r.toA,r.fromB,r.toB],c=n.state.sliceDoc(a,Math.max(a,i-1));a!=i&&l<=o.state.doc.length&&(c+=n.state.lineBreak),o.dispatch({changes:{from:s,to:Math.min(o.state.doc.length,l),insert:c},userEvent:"revert"}),e.preventDefault()}}destroy(){this.a.destroy(),this.b.destroy(),this.measuring>-1&&(this.dom.ownerDocument.defaultView||window).cancelAnimationFrame(this.measuring),this.dom.remove()}};function li(e){let t=e.nextSibling;return e.remove(),t}var Pd=["className","children","orientation","revertControls","highlightChanges","gutter","collapseUnchanged","destroyRerender","renderRevertControl","diffConfig","root"],jd=["modified","modifiedExtension","original","originalExtension","theme","dispatch"],ci=F.forwardRef((e,t)=>{var{className:r,children:n,orientation:o,revertControls:a,highlightChanges:i,gutter:s,collapseUnchanged:l,destroyRerender:c=!0,renderRevertControl:d,diffConfig:f,root:h}=e,m=er(e,Pd),g=Cn(),{modified:b,modifiedExtension:y,original:E,originalExtension:C,theme:O,dispatch:M}=g,B=er(g,jd),S=(0,F.useRef)(null),x=(0,F.useRef)(),H={orientation:o,revertControls:a,highlightChanges:i,gutter:s,collapseUnchanged:l,renderRevertControl:d,diffConfig:f,root:h};(0,F.useImperativeHandle)(t,()=>({container:S.current,view:x.current,modified:b,original:E,config:X({a:E,b,parent:S.current},H)}),[S,x,b,E,H]);var j=L.updateListener.of(T=>{if(T.docChanged&&typeof(C==null?void 0:C.onChange)=="function"){var $=T.state.doc.toString();C==null||C.onChange($,T)}}),Z=L.updateListener.of(T=>{if(T.docChanged&&typeof(y==null?void 0:y.onChange)=="function"){var $=T.state.doc.toString();y==null||y.onChange($,T)}});return(0,F.useEffect)(()=>{!x.current&&S.current&&C&&y&&(x.current=new si(X({a:X({},E,{extensions:[...(C==null?void 0:C.extension)||[],...Tt(X({},C==null?void 0:C.option,{theme:O})),j]}),b:X({},b,{extensions:[...(y==null?void 0:y.extension)||[],...Tt(X({},y==null?void 0:y.option,{theme:O})),Z]}),parent:S.current},H)),M({view:x.current}))},[x,S,C,y]),(0,F.useEffect)(()=>{var ue,k;if(E&&E.doc&&x.current){var T=(ue=x.current)==null?void 0:ue.a.state.doc.toString();if(T!==E.doc){var $;($=x.current)==null||$.a.dispatch({changes:{from:0,to:T.length,insert:E.doc||""}})}}if(b&&b.doc&&x.current){var ce=(k=x.current)==null?void 0:k.b.state.doc.toString();if(ce!==b.doc){var P;(P=x.current)==null||P.b.dispatch({changes:{from:0,to:ce.length,insert:b.doc||""}})}}if(c&&x.current){var G=x.current.a.state.selection.ranges[0].from,ne=x.current.b.state.selection.ranges[0].from;x.current.destroy(),x.current=new si(X({a:X({},E,{extensions:[...(C==null?void 0:C.extension)||[],...Tt(X({},C==null?void 0:C.option,{theme:O}))]}),b:X({},b,{extensions:[...(y==null?void 0:y.extension)||[],...Tt(X({},y==null?void 0:y.option,{theme:O}))]}),parent:S.current},H)),G&&(x.current.a.focus(),x.current.a.dispatch({selection:{anchor:G,head:G}})),ne&&(x.current.b.focus(),x.current.b.dispatch({selection:{anchor:ne,head:ne}}))}},[x,O,S.current,E,b,C,y,c]),(0,F.useEffect)(()=>()=>x.current&&x.current.destroy(),[]),(0,F.useEffect)(()=>{if(x.current){var T={};B.orientation!==o&&(T.orientation=o),B.revertControls!==a&&(T.revertControls=a),B.highlightChanges!==i&&(T.highlightChanges=i),B.gutter!==s&&(T.gutter=s),B.collapseUnchanged!==l&&(T.collapseUnchanged=l),B.renderRevertControl!==d&&(T.collapseUnchanged=l),Object.keys(T).length&&M&&x.current&&(x.current.reconfigure(X({},T)),M(X({},T)))}},[M,x,o,a,i,s,l,d]),(0,w.jsx)("div",X({ref:S,className:"cm-merge-theme"+(r?" "+r:"")},m,{children:n}))});ci.displayName="CodeMirrorMerge.Internal";var Rd=["theme"],_r=F.forwardRef((e,t)=>{var{theme:r}=e,n=er(e,Rd);return(0,w.jsx)(gd,{theme:r,children:(0,w.jsx)(ci,X({},n,{ref:t}))})});_r.Original=Ia,_r.Modified=Fa,_r.displayName="CodeMirrorMerge";var Bn=_r,Gd=pe(We()),Jd=Bn.Original,Vd=Bn.Modified,ui=[_f(),L.lineWrapping];const Wd=e=>{let t=(0,Gd.c)(28),{className:r,onChange:n,initialPrompt:o,currentLanguageAdapter:a,currentCode:i,declineChange:s,acceptChange:l,enabled:c,children:d}=e,f;t[0]===Symbol.for("react.memo_cache_sentinel")?(f={},t[0]=f):f=t[0];let[h,m]=(0,F.useState)(f),[g,b]=Pr(Mh),y=(0,F.useId)(),E=am(),{completion:C,input:O,stop:M,isLoading:B,setCompletion:S,setInput:x,handleSubmit:H}=oh({api:E.getAiURL("completion").toString(),headers:E.headers(),initialInput:o,streamProtocol:"text",experimental_throttle:100,body:{...h,includeOtherCode:g?Gn(i):"",code:i,language:a},onError:$d,onFinish:(U,R)=>{j(R.trimEnd())}}),j=S,Z=F.useRef(null),T=C.trimEnd(),$,ce;t[1]===c?($=t[2],ce=t[3]):($=()=>{var U;c&&(bf(()=>{let R=Z.current;return R!=null&&R.view?(R.view.focus(),!0):!1},{retries:3,delay:100,initialDelay:100}),Bf((U=Z.current)==null?void 0:U.view))},ce=[c],t[1]=c,t[2]=$,t[3]=ce),(0,F.useEffect)($,ce);let P,G;t[4]!==c||t[5]!==o||t[6]!==x?(P=()=>{c&&x(o||"")},G=[c,o,x],t[4]=c,t[5]=o,t[6]=x,t[7]=P,t[8]=G):(P=t[7],G=t[8]),(0,F.useEffect)(P,G);let{theme:ne}=Zm(),ue=()=>{l(T),j("")},k=()=>{j("")},N;t[9]===r?N=t[10]:(N=qt("flex flex-col w-full rounded-[inherit]",r),t[9]=r,t[10]=N);let V=c&&"max-h-[400px] min-h-11 visible",D=!c&&"max-h-0 min-h-0 invisible",q;t[11]!==V||t[12]!==D?(q=qt("flex items-center gap-2 border-b px-3 transition-all rounded-[inherit] rounded-b-none duration-300",V,D),t[11]=V,t[12]=D,t[13]=q):q=t[13];let Ve=c&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(Eh,{className:"text-(--blue-10) shrink-0",size:16}),(0,w.jsx)(uh,{inputRef:Z,className:"h-full my-0 py-2 flex items-center",onClose:()=>{s(),j("")},value:O,onChange:U=>{x(U),m(ih({input:U}))},onSubmit:()=>{var U;B||((U=Z.current)!=null&&U.view&&lh(Z.current.view),H())},onKeyDown:sh({handleAcceptCompletion:ue,handleDeclineCompletion:k,isLoading:B,hasCompletion:T.trim().length>0})}),B&&(0,w.jsxs)(et,{"data-testid":"stop-completion-button",variant:"text",size:"xs",className:"mb-0",onClick:M,children:[(0,w.jsx)(bh,{className:"animate-spin mr-1",size:14}),"Stop"]}),(0,w.jsxs)("div",{className:"-mr-1.5 py-1.5",children:[(0,w.jsxs)("div",{className:"flex flex-row items-center justify-end gap-0.5",children:[(0,w.jsx)(Zt,{content:"Add context",children:(0,w.jsx)(et,{variant:"text",size:"icon",onClick:()=>ch(Z),children:(0,w.jsx)(ah,{className:"h-3 w-3"})})}),(0,w.jsx)(fh,{triggerClassName:"h-7 text-xs w-24",iconSize:"small",forRole:"edit"})]}),T&&(0,w.jsx)("div",{className:"-mb-1.5",children:(0,w.jsx)(dh,{isLoading:B,onAccept:ue,onDecline:k,size:"xs"})})]}),(0,w.jsx)("div",{className:"h-full w-px bg-border mx-2"}),(0,w.jsx)(Zt,{content:"Include code from other cells",children:(0,w.jsxs)("div",{className:"flex flex-row items-start gap-1 overflow-hidden",children:[(0,w.jsx)(Uf,{"data-testid":"include-other-cells-checkbox",id:y,checked:g,onCheckedChange:U=>b(!!U)}),(0,w.jsx)(os,{htmlFor:y,className:"text-muted-foreground text-xs whitespace-nowrap ellipsis",children:"Include all code"})]})}),(0,w.jsx)(et,{"data-testid":"decline-completion-button",variant:"text",size:"icon",disabled:B,onClick:()=>{M(),s(),j("")},children:(0,w.jsx)(mh,{className:"text-(--red-10)",size:16})})]}),he;t[14]!==q||t[15]!==Ve?(he=(0,w.jsx)("div",{className:q,children:Ve}),t[14]=q,t[15]=Ve,t[16]=he):he=t[16];let ye;t[17]!==T||t[18]!==i||t[19]!==c||t[20]!==n||t[21]!==ne?(ye=T&&c&&(0,w.jsxs)(Bn,{className:"cm",theme:ne,children:[(0,w.jsx)(Jd,{onChange:n,value:i,extensions:ui}),(0,w.jsx)(Vd,{value:T,editable:!1,readOnly:!0,extensions:ui})]}),t[17]=T,t[18]=i,t[19]=c,t[20]=n,t[21]=ne,t[22]=ye):ye=t[22];let ve=(!T||!c)&&d,I;return t[23]!==he||t[24]!==ye||t[25]!==ve||t[26]!==N?(I=(0,w.jsxs)("div",{className:N,children:[he,ye,ve]}),t[23]=he,t[24]=ye,t[25]=ve,t[26]=N,t[27]=I):I=t[27],I};function $d(e){St({title:"Completion failed",description:Nh(e)})}var Dn="web application/x-marimo-cell",Hd=Mi({cells:qf(Mi({code:zf()})),version:Hf("1.0")});function qd(){let e=jr(),t=de(async n=>{let o=Jn(),a=n.map(i=>o.cellData[i]).filter(Boolean);if(a.length!==0)try{let i={cells:a.map(c=>({code:c.code})),version:"1.0"},s=a.map(c=>c.code).join(`
|
|
20
20
|
|
|
21
|
-
`),l=new
|
|
21
|
+
`),l=new Xd().add(Dn,i).add("text/plain",s).build();await navigator.clipboard.write([l]),di(a.length)}catch(i){Ze.error("Failed to copy cells to clipboard",i);try{let s=a.map(l=>l.code).join(`
|
|
22
22
|
|
|
23
|
-
`);await navigator.clipboard.writeText(s),di(a.length)}catch{Kd()}}}),r=de(async(n,o)=>{let{before:a=!1}=o??{};try{let i=await navigator.clipboard.read();for(let l of i)if(l.types.includes(Dn)){let c=await(await l.getType(Dn)).text();try{let d=qd.parse(JSON.parse(c));if(d.cells.length===0)break;let f=n,h=d.cells.reverse();for(let m of h)e.createNewCell({cellId:f,before:a,code:m.code,autoFocus:!0});return}catch(d){Qe.warn("Failed to parse clipboard cell data",d)}}let s=await navigator.clipboard.readText();s.trim()?e.createNewCell({cellId:n,before:a,code:s,autoFocus:!0}):Yd()}catch(i){Qe.error("Failed to paste from clipboard",i),Xd()}});return{copyCells:t,pasteAtCell:r}}var di=e=>{let t=e===1?"Cell":`${e} cells`;xt({title:`${t} copied`,description:`${t} ${e===1?"has":"have"} been copied to clipboard.`})},Kd=()=>{xt({title:"Copy failed",description:"Failed to copy cells to clipboard.",variant:"danger"})},Yd=()=>{xt({title:"Nothing to paste",description:"No cell or text found in clipboard.",variant:"danger"})},Xd=()=>{xt({title:"Paste failed",description:"Failed to read from clipboard",variant:"danger"})},Qd=class{constructor(){p(this,"items",{})}add(e,t){return ClipboardItem.supports(e)?typeof t=="string"?(this.items[e]=new Blob([t],{type:e}),this):(this.items[e]=new Blob([JSON.stringify(t)],{type:e}),this):(Qe.warn(`ClipboardItem does not support ${e}`),this)}build(){return new ClipboardItem(this.items)}},Zd=ge(Ve());function fi(){return{selectionStart:null,selectionEnd:null,selected:new Set}}var{reducer:Yh,createActions:Xh,valueAtom:Un,useActions:ef}=Xn(fi,{select:(e,t)=>({selectionStart:t.cellId,selectionEnd:t.cellId,selected:new Set([t.cellId])}),extend:(e,t)=>{if(!e.selectionStart)return{selectionStart:t.cellId,selectionEnd:t.cellId,selected:new Set([t.cellId])};let{cellId:r,allCellIds:n}=t;try{let o=n.findWithId(e.selectionStart),a=o.indexOfOrThrow(e.selectionStart),i=o.indexOfOrThrow(r),[s,l]=a<i?[a,i]:[i,a],c=o.slice(s,l+1);return{selectionStart:e.selectionStart,selectionEnd:r,selected:new Set(c)}}catch{return{selectionStart:r,selectionEnd:r,selected:new Set([r])}}},clear:e=>e.selected.size===0?e:fi()});ws=()=>le(Un);function tf(e){let t=(0,Zd.c)(2),r;return t[0]===e?r=t[1]:(r=Vt(n=>n(Un).selected.has(e)),t[0]=e,t[1]=r),le(r)}to=function(){return ef()};function rf(e){return e.get(Un).selected}let mi,hi,gi;mi=ge(Ve()),{valueAtom:hi,useActions:er}=Xn(()=>new Set,{add:(e,t)=>{let r=new Set(e);return r.add(t),r},remove:(e,t)=>{let r=new Set(e);return r.delete(t),r}}),gi=e=>Vt(t=>t(hi).has(e)),Es=function(e){let t=(0,mi.c)(2),r;return t[0]===e?r=t[1]:(r=gi(e),t[0]=e,t[1]=r),le(r)};var Jt=new WeakMap,nf=500;function of(e){if(e.ctrlKey||e.metaKey||e.altKey)return"";let t=e.key.toLowerCase();return e.shiftKey?`shift+${t}`:t}function af(e,t){let r=of(e),n=e.target;if(!r||!n)return!1;let o=Jt.get(n),a=r;o!=null&&o.timeout&&clearTimeout(o.timeout),o&&(a=`${o.sequence} ${r}`);let i=t[a];if(i)return Jt.delete(n),i();if(!o){let s=t[r];if(s)return s()}if(Object.keys(t).some(s=>s.startsWith(`${a} `))){let s=window.setTimeout(()=>{Jt.delete(n)},nf);return Jt.set(n,{sequence:a,timeout:s}),!0}return Jt.delete(n),!1}var _n=ge(Ve());function pi(e){return{handle:t=>e(t),bulkHandle:t=>{let r=!0;try{for(let n of t)r&&(r=e(n));return r}catch{return!1}}}}function Ye(e){return{handle:t=>e([t]),bulkHandle:t=>e(t)}}function sf(e){let t=(0,_n.c)(11),r=Rh(),n=jr(),o=er(),a;t[0]!==e||t[1]!==r?(a=()=>{r.focusCell({cellId:e})},t[0]=e,t[1]=r,t[2]=a):a=t[2];let i;t[3]!==n||t[4]!==e||t[5]!==r||t[6]!==o?(i=()=>{o.remove(e),n.markTouched({cellId:e}),r.blurCell()},t[3]=n,t[4]=e,t[5]=r,t[6]=o,t[7]=i):i=t[7];let s;t[8]!==a||t[9]!==i?(s={onFocusWithin:a,onBlurWithin:i},t[8]=a,t[9]=i,t[10]=s):s=t[10];let{focusWithinProps:l}=vh(s);return l}ys=function(e,t){let r=(0,_n.c)(30),{canMoveX:n,editorView:o,cellActionDropdownRef:a}=t,{saveOrNameNotebook:i}=An(),{saveCellConfig:s}=Yt(),l=xi(ls),c=jr(),d=Pn(),f=er(),h=Gh(),m=le(Ji),{copyCells:g,pasteAtCell:b}=zd(),y=to(),E=tf(e),C=Kr(),B=Qn(),M=le(qn),D;r[0]!==C||r[1]!==y?(D={clear:()=>{C.clear(),y.clear()},extend:P=>{C.clear(),y.extend(P)},select:P=>{C.clear(),y.select(P)}},r[0]=C,r[1]=y,r[2]=D):D=r[2];let S=D,x=le(Gi),H;r[3]===x?H=r[4]:(H=(P,G)=>Hn(x.getHotkey(P).key)(G.nativeEvent||G),r[3]=x,r[4]=H);let R=H,Z=sf(e),T;r[5]!==c||r[6]!==n||r[7]!==a||r[8]!==e||r[9]!==g||r[10]!==B||r[11]!==o||r[12]!==E||r[13]!==R||r[14]!==m||r[15]!==b||r[16]!==C||r[17]!==h||r[18]!==s||r[19]!==i||r[20]!==S||r[21]!==l||r[22]!==d||r[23]!==f||r[24]!==M?(T={onKeyDown:P=>{if(zn.fromInput(P)){P.continuePropagation();return}let G={"Mod+ArrowUp":()=>(c.focusTopCell(),S.clear(),!0),"Mod+ArrowDown":()=>(c.focusBottomCell(),S.clear(),!0),ArrowUp:()=>(c.focusCell({cellId:e,where:"before"}),S.clear(),!0),ArrowDown:()=>(c.focusCell({cellId:e,where:"after"}),S.clear(),!0),ArrowLeft:()=>{if(n){let k=d.get(nt),N=k.cellIds.findWithId(e),V=k.cellIds.indexOf(N),U=k.cellIds.at(V-1);if(U&&U.length>0){let q=bi(e,U);return c.focusCell({cellId:q,where:"exact"}),S.clear(),!0}}return!1},ArrowRight:()=>{if(n){let k=d.get(nt),N=k.cellIds.findWithId(e),V=k.cellIds.indexOf(N),U=k.cellIds.at(V+1);if(U&&U.length>0){let q=bi(e,U);return c.focusCell({cellId:q,where:"exact"}),S.clear(),!0}}return!1},"Shift+ArrowUp":()=>{let k=d.get(_i);S.extend({cellId:e,allCellIds:k});let N=k.findWithId(e).before(e);return N&&S.extend({cellId:N,allCellIds:k}),c.focusCell({cellId:e,where:"before"}),!0},"Shift+ArrowDown":()=>{let k=d.get(_i);S.extend({cellId:e,allCellIds:k});let N=k.findWithId(e).after(e);return N&&S.extend({cellId:N,allCellIds:k}),c.focusCell({cellId:e,where:"after"}),!0},Escape:()=>E?(S.clear(),!0):!1,Enter:()=>(f.add(e),Ti(d,e),S.clear(),!0),s:()=>(i(),!0)};for(let[k,N]of Object.entries(G))if(Hn(k)(P)&&N()){P.preventDefault();return}let ne={"cell.run":Ye(k=>(h(k),!0)),"cell.runAndNewBelow":Ye(k=>{h(k);let N=k[k.length-1];return c.moveToNextCell({cellId:N,before:!1}),!0}),"cell.runAndNewAbove":Ye(k=>{h(k);let N=k[0];return c.moveToNextCell({cellId:N,before:!0}),!0}),"cell.createAbove":k=>(c.createNewCell({cellId:k,before:!0}),!0),"cell.createBelow":k=>(c.createNewCell({cellId:k,before:!1}),!0),"cell.moveUp":Ye(k=>{let N=k[0];return d.get(nt).cellIds.findWithId(N).first()===N?!1:(k.forEach(V=>{c.moveCell({cellId:V,before:!0})}),!0)}),"cell.moveDown":Ye(k=>{let N=k[k.length-1];return d.get(nt).cellIds.findWithId(N).last()===N?!1:([...k].reverse().forEach(V=>{c.moveCell({cellId:V,before:!1})}),!0)}),"cell.moveLeft":pi(k=>n?(c.moveCell({cellId:k,direction:"left"}),!0):!1),"cell.moveRight":pi(k=>n?(c.moveCell({cellId:k,direction:"right"}),!0):!1),"cell.hideCode":Ye(k=>{var V;let N=!k.map(U=>{var q;return((q=d.get(nt).cellData[U])==null?void 0:q.config)||null}).every(lf);s({configs:Object.fromEntries(k.map(U=>[U,{hide_code:N}]))});for(let U of k)c.updateCellConfig({cellId:U,config:{hide_code:N}});if(k.length===1){let U=k[0];c.focusCell({cellId:U,where:"after"}),N?((V=o.current)==null||V.contentDOM.blur(),Fi(U)):Ti(d,U)}return!0}),"cell.focusDown":k=>(c.focusCell({cellId:k,where:"after"}),!0),"cell.focusUp":k=>(c.focusCell({cellId:k,where:"before"}),!0),"cell.sendToBottom":Ye(k=>(k.forEach(N=>{c.sendToBottom({cellId:N})}),!0)),"cell.sendToTop":Ye(k=>([...k].reverse().forEach(N=>{c.sendToTop({cellId:N})}),!0)),"cell.aiCompletion":k=>{var V;let N=!1;return l(U=>(U==null?void 0:U.cellId)===k?(N=!0,null):{cellId:k}),N&&((V=o.current)==null||V.focus()),!0},"cell.cellActions":()=>{var k;return(k=a.current)==null||k.toggle(),!0},"command.copyCell":Ye(k=>(g(k),!0)),"command.pasteCell":k=>(b(k),!0),"command.createCellBefore":k=>zn.hasModifier(P)?!1:(c.createNewCell({cellId:k,before:!0,autoFocus:!0}),!0),"command.createCellAfter":k=>zn.hasModifier(P)?!1:(c.createNewCell({cellId:k,before:!1,autoFocus:!0}),!0),"cell.delete":()=>{if(!M.keymap.destructive_delete)return!1;let k=ue.size>=2?[...ue]:[e],N=d.get(nt);return k.some(V=>{let{status:U}=N.cellRuntime[V];return U==="running"||U==="queued"})?!1:C.idle?(C.submit(k),!0):(B({cellIds:k}),C.clear(),!0)}},ue=rf(d);if(m==="vim"&&af(P.nativeEvent||P,{j:G.ArrowDown,k:G.ArrowUp,h:G.ArrowLeft,l:G.ArrowRight,i:G.Enter,"shift+j":G["Shift+ArrowDown"],"shift+k":G["Shift+ArrowUp"],"g g":G["Mod+ArrowUp"],"shift+g":G["Mod+ArrowDown"],"d d":()=>ne["cell.delete"](),"y y":()=>(g(ue.size>=2?[...ue]:[e]),!0),p:()=>(b(e,{before:!1}),!0),"shift+p":()=>(b(e,{before:!0}),!0),o:()=>(c.createNewCell({cellId:e,before:!1,autoFocus:!0}),!0),"shift+o":()=>(c.createNewCell({cellId:e,before:!0,autoFocus:!0}),!0),u:()=>(c.undoDeleteCell(),!0)})){P.preventDefault();return}for(let[k,N]of Object.entries(ne))if(R(k,P)){if(N instanceof Function){if(N(e)){P.preventDefault();return}}else if(ue.size>=2?N.bulkHandle([...ue]):N.handle(e)){P.preventDefault();return}return}P.continuePropagation()}},r[5]=c,r[6]=n,r[7]=a,r[8]=e,r[9]=g,r[10]=B,r[11]=o,r[12]=E,r[13]=R,r[14]=m,r[15]=b,r[16]=C,r[17]=h,r[18]=s,r[19]=i,r[20]=S,r[21]=l,r[22]=d,r[23]=f,r[24]=M,r[25]=T):T=r[25];let{keyboardProps:$}=Qi(T),ce;return r[26]!==Z||r[27]!==E||r[28]!==$?(ce=wh(Z,$,{"data-selected":E,className:"data-[selected=true]:ring-1 data-[selected=true]:ring-(--blue-8) data-[selected=true]:ring-offset-1"}),r[26]=Z,r[27]=E,r[28]=$,r[29]=ce):ce=r[29],ce};function lf(e){return e==null?void 0:e.hide_code}function cf(e,t){let r=(0,_n.c)(12),n=er(),o=le(Ji),a=le(Gi),i;if(r[0]!==a){let g=a.getHotkey("command.vimEnterCommandMode");i=Hn(g.key),r[0]=a,r[1]=i}else i=r[1];let s=i,l;r[2]!==e||r[3]!==n?(l=()=>{n.remove(e),Fi(e)},r[2]=e,r[3]=n,r[4]=l):l=r[4];let c=l,d;r[5]!==t||r[6]!==c?(d=()=>{if(!t.current){c();return}let g=t.current,b=g.state;if(!b.selection.main.empty){g.dispatch({selection:ft.single(b.selection.main.from)});return}if(Xt(b)!==null){Xm(g);return}c()},r[5]=t,r[6]=c,r[7]=d):d=r[7];let f=d,h;r[8]!==f||r[9]!==o||r[10]!==s?(h={onKeyDown:g=>{o==="vim"?s(g)&&f():g.key==="Escape"&&f(),g.continuePropagation()}},r[8]=f,r[9]=o,r[10]=s,r[11]=h):h=r[11];let{keyboardProps:m}=Qi(h);return m}function bi(e,t){let r=document.getElementById(Pi.create(e));if(!r)return t.first();let n=r.getBoundingClientRect();for(let o of t.topLevelIds){let a=document.getElementById(Pi.create(o));if(a){let i=a.getBoundingClientRect();if(n.top<=i.bottom&&n.bottom>=i.top)return o}}return t.last()}var yi=ge(Ve());const uf=e=>{let t=(0,yi.c)(24),{editorView:r,code:n,currentLanguageAdapter:o,onAfterToggle:a}=e,i;t[0]===n?i=t[1]:(i=Ui.markdown.isSupported(n)||n.trim()==="",t[0]=n,t[1]=i);let s=i,l;t[2]===n?l=t[3]:(l=Ui.sql.isSupported(n)||n.trim()==="",t[2]=n,t[3]=l);let c=l&&o==="python",d;t[4]===Symbol.for("react.memo_cache_sentinel")?(d=(0,w.jsx)(Cf,{color:"var(--sky-11)",strokeWidth:2.5,className:"w-4 h-4"}),t[4]=d):d=t[4];let f;t[5]!==o||t[6]!==r||t[7]!==a||t[8]!==c?(f=(0,w.jsx)(Mn,{editorView:r,currentLanguageAdapter:o,canSwitchToLanguage:c,icon:d,toType:"sql",displayName:"SQL",onAfterToggle:a}),t[5]=o,t[6]=r,t[7]=a,t[8]=c,t[9]=f):f=t[9];let h=s&&o==="python",m;t[10]===Symbol.for("react.memo_cache_sentinel")?(m=(0,w.jsx)(Bh,{fill:"var(--sky-11)",color:"black",className:"w-4 h-4"}),t[10]=m):m=t[10];let g;t[11]!==o||t[12]!==r||t[13]!==a||t[14]!==h?(g=(0,w.jsx)(Mn,{editorView:r,currentLanguageAdapter:o,canSwitchToLanguage:h,icon:m,toType:"markdown",displayName:"Markdown",onAfterToggle:a}),t[11]=o,t[12]=r,t[13]=a,t[14]=h,t[15]=g):g=t[15];let b;t[16]===Symbol.for("react.memo_cache_sentinel")?(b=(0,w.jsx)(Oh,{fill:"var(--sky-11)",color:"black",className:"w-4 h-4"}),t[16]=b):b=t[16];let y;t[17]!==o||t[18]!==r?(y=(0,w.jsx)(Mn,{editorView:r,currentLanguageAdapter:o,canSwitchToLanguage:!0,icon:b,toType:"python",displayName:"Python",onAfterToggle:rm.NOOP}),t[17]=o,t[18]=r,t[19]=y):y=t[19];let E;return t[20]!==y||t[21]!==f||t[22]!==g?(E=(0,w.jsxs)("div",{className:"absolute right-3 top-2 z-20 flex hover-action gap-1",children:[f,g,y]}),t[20]=y,t[21]=f,t[22]=g,t[23]=E):E=t[23],E},Mn=e=>{let t=(0,yi.c)(10),{editorView:r,currentLanguageAdapter:n,canSwitchToLanguage:o,icon:a,toType:i,displayName:s,onAfterToggle:l}=e,c;t[0]!==r||t[1]!==l||t[2]!==i?(c=()=>{r&&(Wt(r,{language:i}),l())},t[0]=r,t[1]=l,t[2]=i,t[3]=c):c=t[3];let d=c;if(!o||n===i)return null;let f=`View as ${s}`,h;t[4]!==d||t[5]!==a?(h=(0,w.jsx)(Ze,{"data-testid":"language-toggle-button",variant:"text",size:"xs",className:"opacity-80 px-1",onClick:d,children:a}),t[4]=d,t[5]=a,t[6]=h):h=t[6];let m;return t[7]!==f||t[8]!==h?(m=(0,w.jsx)(Qt,{content:f,children:h}),t[7]=f,t[8]=h,t[9]=m):m=t[9],m};var wi=ge(Ve()),vi=({theme:e,showPlaceholder:t,id:r,config:n,code:o,status:a,serializedEditorState:i,setEditorView:s,runCell:l,userConfig:c,editorViewRef:d,editorViewParentRef:f,hidden:h,hasOutput:m,showHiddenCode:g,languageAdapter:b,setLanguageAdapter:y,showLanguageToggles:E=!0})=>{var we;let[C,B]=Pr(ls),M=Zi(),{saveOrNameNotebook:D}=An(),S=Kr(),{saveCellConfig:x}=Yt(),H=a==="running"||a==="queued",R=jr(),Z=Jh(),T=b==="markdown",$=de(()=>H?!1:S.idle&&c.keymap.destructive_delete?(S.submit([r]),!0):(M({cellId:r}),!0)),ce=de(()=>H?!1:(l(),!0)),P=de(()=>{let F=!n.hide_code;return x({configs:{[r]:{hide_code:F}}}),R.updateCellConfig({cellId:r,config:{hide_code:F}}),F}),G=le(om),ne=de(()=>{Lh({autoInstantiate:G,createNewCell:R.createNewCell})}),ue=am(c),k=(0,L.useMemo)(()=>{let F=xu({cellId:r,showPlaceholder:t,enableAI:ue,cellActions:{...R,afterToggleMarkdown:ne,onRun:ce,deleteCell:$,saveNotebook:D,createManyBelow:I=>{for(let j of[...I].reverse())R.createNewCell({code:j,before:!1,cellId:r,skipIfCodeExists:!0})},splitCell:Z,toggleHideCode:P,aiCellCompletion:()=>{let I=!1;return B(j=>(j==null?void 0:j.cellId)===r?(I=!0,null):{cellId:r}),I}},completionConfig:c.completion,keymapConfig:c.keymap,lspConfig:c.language_servers,theme:e,hotkeys:new Ri(c.keymap.overrides??{}),diagnosticsConfig:c.diagnostics,displayConfig:c.display});return F.push($e.define(I=>{let j=I.state.field(Gr);return y(j.type),{update(At){let oe=At.state.field(Gr);y(oe.type)}}}),O.updateListener.of(I=>{I.selectionSet&&I.state.selection.ranges.some(j=>j.from!==j.to)&&g({focus:!1})}),O.domEventHandlers({focus:()=>{g({focus:!1})}})),F},[r,c.keymap,c.completion,c.language_servers,c.display,c.diagnostics,ue,e,t,R,Z,P,$,ce,B,ne,y,g,D]),N=jn(),V=de(()=>{if(N){let I=vn(r,j=>{R.updateCellCode({cellId:r,code:j,formattingChange:!0})},o);k.push(I.extension),o=I.code}let F=new O({state:qt.create({doc:o,extensions:k})});s(F),N||Wt(F,{language:$n(F.state).type})}),U=de(()=>{if($t(d.current!==null,"Editor view is not initialized"),N){let F=vn(r,I=>{R.updateCellCode({cellId:r,code:I,formattingChange:!0})});k.push(F.extension)}d.current.dispatch({effects:[te.reconfigure.of([k]),Ff(d.current,{completionConfig:c.completion,hotkeysProvider:new Ri(c.keymap.overrides??{}),lspConfig:{...c.language_servers,diagnostics:c.diagnostics}})]})}),q=de(()=>{if($t(i,"Editor view is not initialized"),N){let I=vn(r,j=>{R.updateCellCode({cellId:r,code:j,formattingChange:!0})},o);k.push(I.extension),o=I.code}let F=new O({state:qt.fromJSON(i,{doc:o,extensions:k},{history:Rm})});N||Wt(F,{language:$n(F.state).type}),s(F),R.clearSerializedEditorState({cellId:r})});(0,L.useEffect)(()=>{i===null?d.current===null?V():U():q(),d.current!==null&&f&&f.current!==null&&f.current.replaceChildren(d.current.dom)},[V,U,q,d,f,i,k]),(0,L.useEffect)(()=>{let F=d.current;return()=>{F==null||F.destroy()}},[d]);let Je=cf(r,d),he=h&&!T||h&&T&&!m,be="";return T&&h&&m?be="h-0 overflow-hidden":h&&(be="opacity-20 h-8 [&>div.cm-editor]:h-full [&>div.cm-editor]:overflow-hidden [&_.cm-panels]:hidden"),(0,w.jsx)($d,{enabled:(C==null?void 0:C.cellId)===r,initialPrompt:C==null?void 0:C.initialPrompt,currentCode:((we=d.current)==null?void 0:we.state.doc.toString())??o,currentLanguageAdapter:b,declineChange:de(()=>{var F;B(null),(F=d.current)==null||F.focus()}),onChange:de(F=>{var I;(I=d.current)==null||I.dispatch({changes:{from:0,to:d.current.state.doc.length,insert:F}})}),acceptChange:de(F=>{var I,j;(I=d.current)==null||I.dispatch({changes:{from:0,to:d.current.state.doc.length,insert:F}}),(j=d.current)==null||j.focus(),B(null)}),children:(0,w.jsxs)("div",{className:"relative w-full",...Je,children:[he&&(0,w.jsx)(yh,{tooltip:"Edit code",className:"absolute inset-0 z-10",onClick:g}),(0,w.jsx)(Ei,{className:be,editorView:d.current,ref:f}),!h&&E&&(0,w.jsx)("div",{className:"absolute top-1 right-5",children:(0,w.jsx)(uf,{code:o,editorView:d.current,currentLanguageAdapter:b,onAfterToggle:ne})})]})})},Ei=L.forwardRef((e,t)=>{let r=(0,wi.c)(10),{className:n,editorView:o}=e,a=(0,L.useRef)(null),i,s;r[0]===o?(i=r[1],s=r[2]):(i=()=>{o!==null&&a.current!==null&&a.current.children.length===0&&a.current.append(o.dom)},s=[o,a],r[0]=o,r[1]=i,r[2]=s),(0,L.useEffect)(i,s);let l;r[3]===n?l=r[4]:(l=Ht("cm mathjax_ignore",n),r[3]=n,r[4]=l);let c;r[5]===t?c=r[6]:(c=f=>{t?zr(t,a)(f):zr(a)(f)},r[5]=t,r[6]=c);let d;return r[7]!==l||r[8]!==c?(d=(0,w.jsx)("div",{className:l,ref:c,"data-testid":"cell-editor"}),r[7]=l,r[8]=c,r[9]=d):d=r[9],d});Ei.displayName="CellCodeMirrorEditor";function df(e){let t=r=>{let n=(0,wi.c)(5),o=le(mt),[a,i]=Pr(ht);if(o.state===tt.CONNECTING||a===void 0){let l;n[0]===Symbol.for("react.memo_cache_sentinel")?(l=(0,w.jsx)("span",{children:"Waiting for real-time collaboration connection..."}),n[0]=l):l=n[0];let c;return n[1]===i?c=n[2]:(c=(0,w.jsx)("div",{className:"flex h-full w-full items-baseline p-4",children:(0,w.jsxs)(Vm,{milliseconds:1e3,fallback:null,children:[l,(0,w.jsx)(Ze,{variant:"link",onClick:()=>{i("disabled")},children:"Turn off real-time collaboration"})]})}),n[1]=i,n[2]=c),c}let s;return n[3]===r?s=n[4]:(s=(0,w.jsx)(e,{...r}),n[3]=r,n[4]=s),s};return t.displayName=`WithWaitUntilConnected(${e.displayName})`,t}ks=jn()?df((0,L.memo)(vi)):(0,L.memo)(vi)});export{gs as _,Kh as __tla,to as a,ps as c,ht as d,bs as f,Hr as g,ro as h,er as i,qr as l,Ee as m,ys as n,ws as o,vs as p,Es as r,zr as s,ks as t,no as u,Kr as v};
|
|
23
|
+
`);await navigator.clipboard.writeText(s),di(a.length)}catch{zd()}}}),r=de(async(n,o)=>{let{before:a=!1}=o??{};try{let i=await navigator.clipboard.read();for(let l of i)if(l.types.includes(Dn)){let c=await(await l.getType(Dn)).text();try{let d=Hd.parse(JSON.parse(c));if(d.cells.length===0)break;let f=n,h=d.cells.reverse();for(let m of h)e.createNewCell({cellId:f,before:a,code:m.code,autoFocus:!0});return}catch(d){Ze.warn("Failed to parse clipboard cell data",d)}}let s=await navigator.clipboard.readText();s.trim()?e.createNewCell({cellId:n,before:a,code:s,autoFocus:!0}):Kd()}catch(i){Ze.error("Failed to paste from clipboard",i),Yd()}});return{copyCells:t,pasteAtCell:r}}var di=e=>{let t=e===1?"Cell":`${e} cells`;St({title:`${t} copied`,description:`${t} ${e===1?"has":"have"} been copied to clipboard.`})},zd=()=>{St({title:"Copy failed",description:"Failed to copy cells to clipboard.",variant:"danger"})},Kd=()=>{St({title:"Nothing to paste",description:"No cell or text found in clipboard.",variant:"danger"})},Yd=()=>{St({title:"Paste failed",description:"Failed to read from clipboard",variant:"danger"})},Xd=class{constructor(){p(this,"items",{})}add(e,t){return ClipboardItem.supports(e)?typeof t=="string"?(this.items[e]=new Blob([t],{type:e}),this):(this.items[e]=new Blob([JSON.stringify(t)],{type:e}),this):(Ze.warn(`ClipboardItem does not support ${e}`),this)}build(){return new ClipboardItem(this.items)}},Qd=pe(We());function fi(){return{selectionStart:null,selectionEnd:null,selected:new Set}}var{reducer:Yh,createActions:Xh,valueAtom:Un,useActions:Zd}=Xn(fi,{select:(e,t)=>({selectionStart:t.cellId,selectionEnd:t.cellId,selected:new Set([t.cellId])}),extend:(e,t)=>{if(!e.selectionStart)return{selectionStart:t.cellId,selectionEnd:t.cellId,selected:new Set([t.cellId])};let{cellId:r,allCellIds:n}=t;try{let o=n.findWithId(e.selectionStart),a=o.indexOfOrThrow(e.selectionStart),i=o.indexOfOrThrow(r),[s,l]=a<i?[a,i]:[i,a],c=o.slice(s,l+1);return{selectionStart:e.selectionStart,selectionEnd:r,selected:new Set(c)}}catch{return{selectionStart:r,selectionEnd:r,selected:new Set([r])}}},clear:e=>e.selected.size===0?e:fi()});ys=()=>le(Un);function ef(e){let t=(0,Qd.c)(2),r;return t[0]===e?r=t[1]:(r=Wt(n=>n(Un).selected.has(e)),t[0]=e,t[1]=r),le(r)}to=function(){return Zd()};function tf(e){return e.get(Un).selected}let mi,hi,gi;mi=pe(We()),{valueAtom:hi,useActions:tr}=Xn(()=>new Set,{add:(e,t)=>{let r=new Set(e);return r.add(t),r},remove:(e,t)=>{let r=new Set(e);return r.delete(t),r}}),gi=e=>Wt(t=>t(hi).has(e)),vs=function(e){let t=(0,mi.c)(2),r;return t[0]===e?r=t[1]:(r=gi(e),t[0]=e,t[1]=r),le(r)};var Vt=new WeakMap,rf=500;function nf(e){if(e.ctrlKey||e.metaKey||e.altKey)return"";let t=e.key.toLowerCase();return e.shiftKey?`shift+${t}`:t}function of(e,t){let r=nf(e),n=e.target;if(!r||!n)return!1;let o=Vt.get(n),a=r;o!=null&&o.timeout&&clearTimeout(o.timeout),o&&(a=`${o.sequence} ${r}`);let i=t[a];if(i)return Vt.delete(n),i();if(!o){let s=t[r];if(s)return s()}if(Object.keys(t).some(s=>s.startsWith(`${a} `))){let s=window.setTimeout(()=>{Vt.delete(n)},rf);return Vt.set(n,{sequence:a,timeout:s}),!0}return Vt.delete(n),!1}var _n=pe(We());function pi(e){return{handle:t=>e(t),bulkHandle:t=>{let r=!0;try{for(let n of t)r&&(r=e(n));return r}catch{return!1}}}}function Xe(e){return{handle:t=>e([t]),bulkHandle:t=>e(t)}}function af(e){let t=(0,_n.c)(11),r=Rh(),n=jr(),o=tr(),a;t[0]!==e||t[1]!==r?(a=()=>{r.focusCell({cellId:e})},t[0]=e,t[1]=r,t[2]=a):a=t[2];let i;t[3]!==n||t[4]!==e||t[5]!==r||t[6]!==o?(i=()=>{o.remove(e),n.markTouched({cellId:e}),r.blurCell()},t[3]=n,t[4]=e,t[5]=r,t[6]=o,t[7]=i):i=t[7];let s;t[8]!==a||t[9]!==i?(s={onFocusWithin:a,onBlurWithin:i},t[8]=a,t[9]=i,t[10]=s):s=t[10];let{focusWithinProps:l}=vh(s);return l}bs=function(e,t){let r=(0,_n.c)(30),{canMoveX:n,editorView:o,cellActionDropdownRef:a}=t,{saveOrNameNotebook:i}=An(),{saveCellConfig:s}=Xt(),l=xi(ss),c=jr(),d=Pn(),f=tr(),h=Gh(),m=le(Ri),{copyCells:g,pasteAtCell:b}=qd(),y=to(),E=ef(e),C=Kr(),O=Qn(),M=le(qn),B;r[0]!==C||r[1]!==y?(B={clear:()=>{C.clear(),y.clear()},extend:P=>{C.clear(),y.extend(P)},select:P=>{C.clear(),y.select(P)}},r[0]=C,r[1]=y,r[2]=B):B=r[2];let S=B,x=le(ji),H;r[3]===x?H=r[4]:(H=(P,G)=>Hn(x.getHotkey(P).key)(G.nativeEvent||G),r[3]=x,r[4]=H);let j=H,Z=af(e),T;r[5]!==c||r[6]!==n||r[7]!==a||r[8]!==e||r[9]!==g||r[10]!==O||r[11]!==o||r[12]!==E||r[13]!==j||r[14]!==m||r[15]!==b||r[16]!==C||r[17]!==h||r[18]!==s||r[19]!==i||r[20]!==S||r[21]!==l||r[22]!==d||r[23]!==f||r[24]!==M?(T={onKeyDown:P=>{if(zn.fromInput(P)){P.continuePropagation();return}let G={"Mod+ArrowUp":()=>(c.focusTopCell(),S.clear(),!0),"Mod+ArrowDown":()=>(c.focusBottomCell(),S.clear(),!0),ArrowUp:()=>(c.focusCell({cellId:e,where:"before"}),S.clear(),!0),ArrowDown:()=>(c.focusCell({cellId:e,where:"after"}),S.clear(),!0),ArrowLeft:()=>{if(n){let k=d.get(ot),N=k.cellIds.findWithId(e),V=k.cellIds.indexOf(N),D=k.cellIds.at(V-1);if(D&&D.length>0){let q=bi(e,D);return c.focusCell({cellId:q,where:"exact"}),S.clear(),!0}}return!1},ArrowRight:()=>{if(n){let k=d.get(ot),N=k.cellIds.findWithId(e),V=k.cellIds.indexOf(N),D=k.cellIds.at(V+1);if(D&&D.length>0){let q=bi(e,D);return c.focusCell({cellId:q,where:"exact"}),S.clear(),!0}}return!1},"Shift+ArrowUp":()=>{let k=d.get(Ui);S.extend({cellId:e,allCellIds:k});let N=k.findWithId(e).before(e);return N&&S.extend({cellId:N,allCellIds:k}),c.focusCell({cellId:e,where:"before"}),!0},"Shift+ArrowDown":()=>{let k=d.get(Ui);S.extend({cellId:e,allCellIds:k});let N=k.findWithId(e).after(e);return N&&S.extend({cellId:N,allCellIds:k}),c.focusCell({cellId:e,where:"after"}),!0},Escape:()=>E?(S.clear(),!0):!1,Enter:()=>(f.add(e),Si(d,e),S.clear(),!0),s:()=>(i(),!0)};for(let[k,N]of Object.entries(G))if(Hn(k)(P)&&N()){P.preventDefault();return}let ne={"cell.run":Xe(k=>(h(k),!0)),"cell.runAndNewBelow":Xe(k=>{h(k);let N=k[k.length-1];return c.moveToNextCell({cellId:N,before:!1}),!0}),"cell.runAndNewAbove":Xe(k=>{h(k);let N=k[0];return c.moveToNextCell({cellId:N,before:!0}),!0}),"cell.createAbove":k=>(c.createNewCell({cellId:k,before:!0}),!0),"cell.createBelow":k=>(c.createNewCell({cellId:k,before:!1}),!0),"cell.moveUp":Xe(k=>{let N=k[0];return d.get(ot).cellIds.findWithId(N).first()===N?!1:(k.forEach(V=>{c.moveCell({cellId:V,before:!0})}),!0)}),"cell.moveDown":Xe(k=>{let N=k[k.length-1];return d.get(ot).cellIds.findWithId(N).last()===N?!1:([...k].reverse().forEach(V=>{c.moveCell({cellId:V,before:!1})}),!0)}),"cell.moveLeft":pi(k=>n?(c.moveCell({cellId:k,direction:"left"}),!0):!1),"cell.moveRight":pi(k=>n?(c.moveCell({cellId:k,direction:"right"}),!0):!1),"cell.hideCode":Xe(k=>{var V;let N=!k.map(D=>{var q;return((q=d.get(ot).cellData[D])==null?void 0:q.config)||null}).every(sf);s({configs:Object.fromEntries(k.map(D=>[D,{hide_code:N}]))});for(let D of k)c.updateCellConfig({cellId:D,config:{hide_code:N}});if(k.length===1){let D=k[0];c.focusCell({cellId:D,where:"after"}),N?((V=o.current)==null||V.contentDOM.blur(),Ii(D)):Si(d,D)}return!0}),"cell.focusDown":k=>(c.focusCell({cellId:k,where:"after"}),!0),"cell.focusUp":k=>(c.focusCell({cellId:k,where:"before"}),!0),"cell.sendToBottom":Xe(k=>(k.forEach(N=>{c.sendToBottom({cellId:N})}),!0)),"cell.sendToTop":Xe(k=>([...k].reverse().forEach(N=>{c.sendToTop({cellId:N})}),!0)),"cell.aiCompletion":k=>{var V;let N=!1;return l(D=>(D==null?void 0:D.cellId)===k?(N=!0,null):{cellId:k}),N&&((V=o.current)==null||V.focus()),!0},"cell.cellActions":()=>{var k;return(k=a.current)==null||k.toggle(),!0},"command.copyCell":Xe(k=>(g(k),!0)),"command.pasteCell":k=>(b(k),!0),"command.createCellBefore":k=>zn.hasModifier(P)?!1:(c.createNewCell({cellId:k,before:!0,autoFocus:!0}),!0),"command.createCellAfter":k=>zn.hasModifier(P)?!1:(c.createNewCell({cellId:k,before:!1,autoFocus:!0}),!0),"cell.delete":()=>{if(!M.keymap.destructive_delete)return!1;let k=ue.size>=2?[...ue]:[e],N=d.get(ot);return k.some(V=>{let{status:D}=N.cellRuntime[V];return D==="running"||D==="queued"})?!1:C.idle?(C.submit(k),!0):(O({cellIds:k}),C.clear(),!0)}},ue=tf(d);if(m==="vim"&&of(P.nativeEvent||P,{j:G.ArrowDown,k:G.ArrowUp,h:G.ArrowLeft,l:G.ArrowRight,i:G.Enter,"shift+j":G["Shift+ArrowDown"],"shift+k":G["Shift+ArrowUp"],"g g":G["Mod+ArrowUp"],"shift+g":G["Mod+ArrowDown"],"d d":()=>ne["cell.delete"](),"y y":()=>(g(ue.size>=2?[...ue]:[e]),!0),p:()=>(b(e,{before:!1}),!0),"shift+p":()=>(b(e,{before:!0}),!0),o:()=>(c.createNewCell({cellId:e,before:!1,autoFocus:!0}),!0),"shift+o":()=>(c.createNewCell({cellId:e,before:!0,autoFocus:!0}),!0),u:()=>(c.undoDeleteCell(),!0)})){P.preventDefault();return}for(let[k,N]of Object.entries(ne))if(j(k,P)){if(N instanceof Function){if(N(e)){P.preventDefault();return}}else if(ue.size>=2?N.bulkHandle([...ue]):N.handle(e)){P.preventDefault();return}return}P.continuePropagation()}},r[5]=c,r[6]=n,r[7]=a,r[8]=e,r[9]=g,r[10]=O,r[11]=o,r[12]=E,r[13]=j,r[14]=m,r[15]=b,r[16]=C,r[17]=h,r[18]=s,r[19]=i,r[20]=S,r[21]=l,r[22]=d,r[23]=f,r[24]=M,r[25]=T):T=r[25];let{keyboardProps:$}=Xi(T),ce;return r[26]!==Z||r[27]!==E||r[28]!==$?(ce=wh(Z,$,{"data-selected":E,className:"data-[selected=true]:ring-1 data-[selected=true]:ring-(--blue-8) data-[selected=true]:ring-offset-1"}),r[26]=Z,r[27]=E,r[28]=$,r[29]=ce):ce=r[29],ce};function sf(e){return e==null?void 0:e.hide_code}function lf(e,t){let r=(0,_n.c)(12),n=tr(),o=le(Ri),a=le(ji),i;if(r[0]!==a){let g=a.getHotkey("command.vimEnterCommandMode");i=Hn(g.key),r[0]=a,r[1]=i}else i=r[1];let s=i,l;r[2]!==e||r[3]!==n?(l=()=>{n.remove(e),Ii(e)},r[2]=e,r[3]=n,r[4]=l):l=r[4];let c=l,d;r[5]!==t||r[6]!==c?(d=()=>{if(!t.current){c();return}let g=t.current,b=g.state;if(!b.selection.main.empty){g.dispatch({selection:mt.single(b.selection.main.from)});return}if(Qt(b)!==null){Xm(g);return}c()},r[5]=t,r[6]=c,r[7]=d):d=r[7];let f=d,h;r[8]!==f||r[9]!==o||r[10]!==s?(h={onKeyDown:g=>{o==="vim"?s(g)&&f():g.key==="Escape"&&f(),g.continuePropagation()}},r[8]=f,r[9]=o,r[10]=s,r[11]=h):h=r[11];let{keyboardProps:m}=Xi(h);return m}function bi(e,t){let r=document.getElementById(Ti.create(e));if(!r)return t.first();let n=r.getBoundingClientRect();for(let o of t.topLevelIds){let a=document.getElementById(Ti.create(o));if(a){let i=a.getBoundingClientRect();if(n.top<=i.bottom&&n.bottom>=i.top)return o}}return t.last()}var yi=pe(We());const cf=e=>{let t=(0,yi.c)(24),{editorView:r,code:n,currentLanguageAdapter:o,onAfterToggle:a}=e,i;t[0]===n?i=t[1]:(i=Di.markdown.isSupported(n)||n.trim()==="",t[0]=n,t[1]=i);let s=i,l;t[2]===n?l=t[3]:(l=Di.sql.isSupported(n)||n.trim()==="",t[2]=n,t[3]=l);let c=l&&o==="python",d;t[4]===Symbol.for("react.memo_cache_sentinel")?(d=(0,w.jsx)(Cf,{color:"var(--sky-11)",strokeWidth:2.5,className:"w-4 h-4"}),t[4]=d):d=t[4];let f;t[5]!==o||t[6]!==r||t[7]!==a||t[8]!==c?(f=(0,w.jsx)(Mn,{editorView:r,currentLanguageAdapter:o,canSwitchToLanguage:c,icon:d,toType:"sql",displayName:"SQL",onAfterToggle:a}),t[5]=o,t[6]=r,t[7]=a,t[8]=c,t[9]=f):f=t[9];let h=s&&o==="python",m;t[10]===Symbol.for("react.memo_cache_sentinel")?(m=(0,w.jsx)(Bh,{fill:"var(--sky-11)",color:"black",className:"w-4 h-4"}),t[10]=m):m=t[10];let g;t[11]!==o||t[12]!==r||t[13]!==a||t[14]!==h?(g=(0,w.jsx)(Mn,{editorView:r,currentLanguageAdapter:o,canSwitchToLanguage:h,icon:m,toType:"markdown",displayName:"Markdown",onAfterToggle:a}),t[11]=o,t[12]=r,t[13]=a,t[14]=h,t[15]=g):g=t[15];let b;t[16]===Symbol.for("react.memo_cache_sentinel")?(b=(0,w.jsx)(Oh,{fill:"var(--sky-11)",color:"black",className:"w-4 h-4"}),t[16]=b):b=t[16];let y;t[17]!==o||t[18]!==r?(y=(0,w.jsx)(Mn,{editorView:r,currentLanguageAdapter:o,canSwitchToLanguage:!0,icon:b,toType:"python",displayName:"Python",onAfterToggle:tm.NOOP}),t[17]=o,t[18]=r,t[19]=y):y=t[19];let E;return t[20]!==y||t[21]!==f||t[22]!==g?(E=(0,w.jsxs)("div",{className:"absolute right-3 top-2 z-20 flex hover-action gap-1",children:[f,g,y]}),t[20]=y,t[21]=f,t[22]=g,t[23]=E):E=t[23],E},Mn=e=>{let t=(0,yi.c)(10),{editorView:r,currentLanguageAdapter:n,canSwitchToLanguage:o,icon:a,toType:i,displayName:s,onAfterToggle:l}=e,c;t[0]!==r||t[1]!==l||t[2]!==i?(c=()=>{r&&($t(r,{language:i}),l())},t[0]=r,t[1]=l,t[2]=i,t[3]=c):c=t[3];let d=c;if(!o||n===i)return null;let f=`View as ${s}`,h;t[4]!==d||t[5]!==a?(h=(0,w.jsx)(et,{"data-testid":"language-toggle-button",variant:"text",size:"xs",className:"opacity-80 px-1",onClick:d,children:a}),t[4]=d,t[5]=a,t[6]=h):h=t[6];let m;return t[7]!==f||t[8]!==h?(m=(0,w.jsx)(Zt,{content:f,children:h}),t[7]=f,t[8]=h,t[9]=m):m=t[9],m};var wi=pe(We()),vi=({theme:e,showPlaceholder:t,id:r,config:n,code:o,status:a,serializedEditorState:i,setEditorView:s,runCell:l,userConfig:c,editorViewRef:d,editorViewParentRef:f,hidden:h,hasOutput:m,showHiddenCode:g,languageAdapter:b,setLanguageAdapter:y,showLanguageToggles:E=!0})=>{var ve;let[C,O]=Pr(ss),M=Qi(),{saveOrNameNotebook:B}=An(),S=Kr(),{saveCellConfig:x}=Xt(),H=a==="running"||a==="queued",j=jr(),Z=Jh(),T=b==="markdown",$=de(()=>H?!1:S.idle&&c.keymap.destructive_delete?(S.submit([r]),!0):(M({cellId:r}),!0)),ce=de(()=>H?!1:(l(),!0)),P=de(()=>{let I=!n.hide_code;return x({configs:{[r]:{hide_code:I}}}),j.updateCellConfig({cellId:r,config:{hide_code:I}}),I}),G=le(nm),ne=de(()=>{Lh({autoInstantiate:G,createNewCell:j.createNewCell})}),ue=om(c),k=(0,F.useMemo)(()=>{var U;let I=Nu({cellId:r,showPlaceholder:t,enableAI:ue,cellActions:{...j,afterToggleMarkdown:ne,onRun:ce,deleteCell:$,saveNotebook:B,createManyBelow:R=>{for(let ge of[...R].reverse())j.createNewCell({code:ge,before:!1,cellId:r,skipIfCodeExists:!0})},splitCell:Z,toggleHideCode:P,aiCellCompletion:()=>{let R=!1;return O(ge=>(ge==null?void 0:ge.cellId)===r?(R=!0,null):{cellId:r}),R}},completionConfig:c.completion,keymapConfig:c.keymap,lspConfig:c.language_servers,theme:e,hotkeys:new Pi(c.keymap.overrides??{}),diagnosticsConfig:c.diagnostics,displayConfig:c.display,inlineAiTooltip:((U=c.ai)==null?void 0:U.inline_tooltip)??!1});return I.push(He.define(R=>{let ge=R.state.field(Gr);return y(ge.type),{update(oe){let Ct=oe.state.field(Gr);y(Ct.type)}}}),L.updateListener.of(R=>{R.selectionSet&&R.state.selection.ranges.some(ge=>ge.from!==ge.to)&&g({focus:!1})}),L.domEventHandlers({focus:()=>{g({focus:!1})}})),I},[r,c.keymap,c.completion,c.language_servers,c.display,c.diagnostics,ue,e,t,j,Z,P,$,ce,O,ne,y,g,B]),N=jn(),V=de(()=>{if(N){let U=vn(r,R=>{j.updateCellCode({cellId:r,code:R,formattingChange:!0})},o);k.push(U.extension),o=U.code}let I=new L({state:zt.create({doc:o,extensions:k})});s(I),N||$t(I,{language:Wn(I.state).type})}),D=de(()=>{if(Ht(d.current!==null,"Editor view is not initialized"),N){let I=vn(r,U=>{j.updateCellCode({cellId:r,code:U,formattingChange:!0})});k.push(I.extension)}d.current.dispatch({effects:[te.reconfigure.of([k]),Ff(d.current,{completionConfig:c.completion,hotkeysProvider:new Pi(c.keymap.overrides??{}),lspConfig:{...c.language_servers,diagnostics:c.diagnostics}})]})}),q=de(()=>{if(Ht(i,"Editor view is not initialized"),N){let U=vn(r,R=>{j.updateCellCode({cellId:r,code:R,formattingChange:!0})},o);k.push(U.extension),o=U.code}let I=new L({state:zt.fromJSON(i,{doc:o,extensions:k},{history:jm})});N||$t(I,{language:Wn(I.state).type}),s(I),j.clearSerializedEditorState({cellId:r})});(0,F.useEffect)(()=>{i===null?d.current===null?V():D():q(),d.current!==null&&f&&f.current!==null&&f.current.replaceChildren(d.current.dom)},[V,D,q,d,f,i,k]),(0,F.useEffect)(()=>{let I=d.current;return()=>{I==null||I.destroy()}},[d]);let Ve=lf(r,d),he=h&&!T||h&&T&&!m,ye="";return T&&h&&m?ye="h-0 overflow-hidden":h&&(ye="opacity-20 h-8 [&>div.cm-editor]:h-full [&>div.cm-editor]:overflow-hidden [&_.cm-panels]:hidden"),(0,w.jsx)(Wd,{enabled:(C==null?void 0:C.cellId)===r,initialPrompt:C==null?void 0:C.initialPrompt,currentCode:((ve=d.current)==null?void 0:ve.state.doc.toString())??o,currentLanguageAdapter:b,declineChange:de(()=>{var I;O(null),(I=d.current)==null||I.focus()}),onChange:de(I=>{var U;(U=d.current)==null||U.dispatch({changes:{from:0,to:d.current.state.doc.length,insert:I}})}),acceptChange:de(I=>{var U,R;(U=d.current)==null||U.dispatch({changes:{from:0,to:d.current.state.doc.length,insert:I}}),(R=d.current)==null||R.focus(),O(null)}),children:(0,w.jsxs)("div",{className:"relative w-full",...Ve,children:[he&&(0,w.jsx)(yh,{tooltip:"Edit code",className:"absolute inset-0 z-10",onClick:g}),(0,w.jsx)(Ei,{className:ye,editorView:d.current,ref:f}),!h&&E&&(0,w.jsx)("div",{className:"absolute top-1 right-5",children:(0,w.jsx)(cf,{code:o,editorView:d.current,currentLanguageAdapter:b,onAfterToggle:ne})})]})})},Ei=F.forwardRef((e,t)=>{let r=(0,wi.c)(10),{className:n,editorView:o}=e,a=(0,F.useRef)(null),i,s;r[0]===o?(i=r[1],s=r[2]):(i=()=>{o!==null&&a.current!==null&&a.current.children.length===0&&a.current.append(o.dom)},s=[o,a],r[0]=o,r[1]=i,r[2]=s),(0,F.useEffect)(i,s);let l;r[3]===n?l=r[4]:(l=qt("cm mathjax_ignore",n),r[3]=n,r[4]=l);let c;r[5]===t?c=r[6]:(c=f=>{t?zr(t,a)(f):zr(a)(f)},r[5]=t,r[6]=c);let d;return r[7]!==l||r[8]!==c?(d=(0,w.jsx)("div",{className:l,ref:c,"data-testid":"cell-editor"}),r[7]=l,r[8]=c,r[9]=d):d=r[9],d});Ei.displayName="CellCodeMirrorEditor";function uf(e){let t=r=>{let n=(0,wi.c)(5),o=le(ht),[a,i]=Pr(gt);if(o.state===rt.CONNECTING||a===void 0){let l;n[0]===Symbol.for("react.memo_cache_sentinel")?(l=(0,w.jsx)("span",{children:"Waiting for real-time collaboration connection..."}),n[0]=l):l=n[0];let c;return n[1]===i?c=n[2]:(c=(0,w.jsx)("div",{className:"flex h-full w-full items-baseline p-4",children:(0,w.jsxs)(Jm,{milliseconds:1e3,fallback:null,children:[l,(0,w.jsx)(et,{variant:"link",onClick:()=>{i("disabled")},children:"Turn off real-time collaboration"})]})}),n[1]=i,n[2]=c),c}let s;return n[3]===r?s=n[4]:(s=(0,w.jsx)(e,{...r}),n[3]=r,n[4]=s),s};return t.displayName=`WithWaitUntilConnected(${e.displayName})`,t}Es=jn()?uf((0,F.memo)(vi)):(0,F.memo)(vi)});export{hs as _,Kh as __tla,to as a,gs as c,gt as d,ps as f,Hr as g,ro as h,tr as i,qr as l,ke as m,bs as n,ys as o,ws as p,vs as r,zr as s,Es as t,no as u,Kr as v};
|