decocms 2.393.2 → 2.393.4
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/client/assets/{AlertCircle-Cuw2SV6F.js → AlertCircle-Bo6MFMMw.js} +1 -1
- package/dist/client/assets/{ArrowUpRight-ClC34TM4.js → ArrowUpRight-D7W9dtLf.js} +1 -1
- package/dist/client/assets/{Check-BCUhIxA7.js → Check-DsBt8230.js} +1 -1
- package/dist/client/assets/{CheckCircle-CxRkGFf_.js → CheckCircle-heTl0Q7J.js} +1 -1
- package/dist/client/assets/{ChevronDown-DPKlPltC.js → ChevronDown-q7NXC8oS.js} +1 -1
- package/dist/client/assets/{ChevronRight-D9aRf4_R.js → ChevronRight-yHn1hA3x.js} +1 -1
- package/dist/client/assets/{ChevronUp-CAinfkBJ.js → ChevronUp-CiSterYY.js} +1 -1
- package/dist/client/assets/{Container-BIMBNbKU.js → Container-C4LtPvmX.js} +1 -1
- package/dist/client/assets/{DotsVertical-X4UEMg89.js → DotsVertical-CxmWEaUl.js} +1 -1
- package/dist/client/assets/{FilterLines-CFDwBnsv.js → FilterLines-Dyrx730Z.js} +1 -1
- package/dist/client/assets/{HardDrive-D86QBdMS.js → HardDrive-DlDHgSKt.js} +1 -1
- package/dist/client/assets/{Key01-B_a8BUQ2.js → Key01-DzKsSdjW.js} +1 -1
- package/dist/client/assets/{LinkExternal01-pVfL_xHa.js → LinkExternal01-CN7C4GHX.js} +1 -1
- package/dist/client/assets/{Lock01-O1o_RfBw.js → Lock01-DrM2m3H0.js} +1 -1
- package/dist/client/assets/{Monitor01-DF-OJKsP.js → Monitor01-Plu6mY2H.js} +1 -1
- package/dist/client/assets/{Palette-DHtqHjAS.js → Palette-BJK7Nr_A.js} +1 -1
- package/dist/client/assets/{Play-BJZELjph.js → Play-CPHeOS8L.js} +1 -1
- package/dist/client/assets/{Plus-B0LVf3QA.js → Plus-setppUqq.js} +1 -1
- package/dist/client/assets/{RefreshCcw01-DWxUoP-x.js → RefreshCcw01-Bx4SkeQv.js} +1 -1
- package/dist/client/assets/{SearchMd-BkC3SNiM.js → SearchMd-DKHRS8yM.js} +1 -1
- package/dist/client/assets/{Settings02-rvrknMco.js → Settings02-oLvqwjU6.js} +1 -1
- package/dist/client/assets/{Shield01-DMVueqrR.js → Shield01-CVCTl65y.js} +1 -1
- package/dist/client/assets/{Star01-BFyFzcou.js → Star01-P1tpcoSt.js} +1 -1
- package/dist/client/assets/{Stars02-B5lf1Mb2.js → Stars02-Dsvvd6bB.js} +1 -1
- package/dist/client/assets/{Sun-DQWCDSbP.js → Sun-BYzPnNgD.js} +1 -1
- package/dist/client/assets/{SwitchHorizontal01-BiY6DZkl.js → SwitchHorizontal01-pH6QzahZ.js} +1 -1
- package/dist/client/assets/{Tool01-Cv7ThooB.js → Tool01-DStl8lGo.js} +1 -1
- package/dist/client/assets/{Trash01-mi2XNMKw.js → Trash01-C9zdKIsH.js} +1 -1
- package/dist/client/assets/{Upload01-C_9zjkZV.js → Upload01-DLpQCuCd.js} +1 -1
- package/dist/client/assets/{User01-TY3L0cwN.js → User01-D4cPfrTO.js} +1 -1
- package/dist/client/assets/{Users01-cH_zAee_.js → Users01-BEpGduG7.js} +1 -1
- package/dist/client/assets/{Users03-BujFLjc9.js → Users03-2JRHHWqe.js} +1 -1
- package/dist/client/assets/{X-DRk1PhRt.js → X-DIKroc0l.js} +1 -1
- package/dist/client/assets/{XCircle-Bb_BNn3s.js → XCircle-BwGxaBHh.js} +1 -1
- package/dist/client/assets/{XClose-AvlHokGh.js → XClose-BjWASWLP.js} +1 -1
- package/dist/client/assets/{Zap-CuR6pNCy.js → Zap-DAtTr2jR.js} +1 -1
- package/dist/client/assets/{ZapSquare-8pO6mgDJ.js → ZapSquare-np0irmyV.js} +1 -1
- package/dist/client/assets/{access-gate-CEVkgb1w.js → access-gate-CKZjqNKp.js} +1 -1
- package/dist/client/assets/{accordion-K_eZcF1d.js → accordion-CfhmoYKb.js} +1 -1
- package/dist/client/assets/{add-section-modal-22C7gHeb.js → add-section-modal-Y_M0BfWb.js} +1 -1
- package/dist/client/assets/{agent-icon-LtrmhUhU.js → agent-icon-DT3ZoY-y.js} +1 -1
- package/dist/client/assets/{agent-icons-Dp_Dhjq8.js → agent-icons-CjWyJXBH.js} +1 -1
- package/dist/client/assets/{agents-list-kdKYeVxm.js → agents-list-oYVQIFvb.js} +1 -1
- package/dist/client/assets/{ai-providers-BKZLOjVg.js → ai-providers-Co_XFY3J.js} +1 -1
- package/dist/client/assets/{alert-Bo7r739b.js → alert-CdjLhR3O.js} +1 -1
- package/dist/client/assets/{alert-dialog-_yhGzUzO.js → alert-dialog-BrK4aQRQ.js} +1 -1
- package/dist/client/assets/{auth-catchall-BJgYcyk8.js → auth-catchall-DCoe8_wo.js} +1 -1
- package/dist/client/assets/{auth-split-layout-BAS6oCMp.js → auth-split-layout-CQTBr5Di.js} +1 -1
- package/dist/client/assets/{automation-list-row-ClD1PaDz.js → automation-list-row-D7yrZia_.js} +1 -1
- package/dist/client/assets/{automations-BBp5Zuo0.js → automations-DNnr_hAN.js} +1 -1
- package/dist/client/assets/{avatar-CnoJQ9lf.js → avatar-BN_Lyxjy.js} +1 -1
- package/dist/client/assets/{badge-xGFbntY4.js → badge-CNO8XMju.js} +1 -1
- package/dist/client/assets/{brand-context-OrXjPZJQ.js → brand-context-B9aaCNPY.js} +1 -1
- package/dist/client/assets/{calendar-BJ_DtvJs.js → calendar-Cl37gYVl.js} +1 -1
- package/dist/client/assets/{capability-load-error-4ur8s_C1.js → capability-load-error-CoYD6DH2.js} +1 -1
- package/dist/client/assets/{card-BtEZnZdS.js → card-CK95IO0o.js} +1 -1
- package/dist/client/assets/{chat-context-C34a2VI8.js → chat-context-C0VPAUT2.js} +1 -1
- package/dist/client/assets/{checkbox-ZWqntSXg.js → checkbox-DD2y-n33.js} +1 -1
- package/dist/client/assets/{cli-auth-success-BUZGpgbM.js → cli-auth-success-tWcD6oj2.js} +1 -1
- package/dist/client/assets/{collection-detail-DIuOo_96.js → collection-detail-sOcjT5aI.js} +1 -1
- package/dist/client/assets/{collection-display-button-B8cuulbC.js → collection-display-button-DrfAYMXV.js} +1 -1
- package/dist/client/assets/{collection-search-CkB4q39Y.js → collection-search-pwCSfkZ7.js} +1 -1
- package/dist/client/assets/{collection-table-wrapper-BaF2Oycj.js → collection-table-wrapper-DQYw3ucM.js} +1 -1
- package/dist/client/assets/{collection-tabs-Dp0vGAAv.js → collection-tabs-7Dpb1qzn.js} +1 -1
- package/dist/client/assets/{collections-naolYzV3.js → collections-npJcts45.js} +1 -1
- package/dist/client/assets/{command-BDnN_tbb.js → command-B4WwdpO7.js} +1 -1
- package/dist/client/assets/{connect-desktop-dialog-sl6vIyrd.js → connect-desktop-dialog-h61VXfJ_.js} +1 -1
- package/dist/client/assets/{connection-card-B3hq2qSi.js → connection-card-CTv50-CY.js} +1 -1
- package/dist/client/assets/{connection-detail-D_kwZeZ3.js → connection-detail-Bq-07uAq.js} +1 -1
- package/dist/client/assets/{connection-form-helpers-BLcTh7n5.js → connection-form-helpers-C7qYX7aE.js} +1 -1
- package/dist/client/assets/{connections-DU4aTrVT.js → connections-D4lRhB6f.js} +1 -1
- package/dist/client/assets/{constants-Dt6Fd4L9.js → constants-CZi8C3bA.js} +1 -1
- package/dist/client/assets/{decopilot-sse-pool-Dyrn5Fcv.js → decopilot-sse-pool-CzvHS6-_.js} +1 -1
- package/dist/client/assets/{dialog-HH-j4g7f.js → dialog-eNu7H7jc.js} +1 -1
- package/dist/client/assets/{domain-settings-s8upFHXK.js → domain-settings-Ccbvh0Dx.js} +1 -1
- package/dist/client/assets/{drawer-D-NV5MY-.js → drawer-DvmyIDeU.js} +1 -1
- package/dist/client/assets/{dropdown-menu-Z_F9h9Dc.js → dropdown-menu-fXlTzmNU.js} +1 -1
- package/dist/client/assets/{dynamic-plugin-layout-DLusGMD_.js → dynamic-plugin-layout-Bf3JqWER.js} +1 -1
- package/dist/client/assets/{empty-state-DnqhQPcT.js → empty-state-DAy9qdyJ.js} +1 -1
- package/dist/client/assets/{empty-state-CPucj88p.js → empty-state-QoHz8nSf.js} +1 -1
- package/dist/client/assets/{extract-connection-data-C7rjytmY.js → extract-connection-data-Bw-Ess_C.js} +1 -1
- package/dist/client/assets/{features-gM_Z0NbJ.js → features-CT0OBjwz.js} +1 -1
- package/dist/client/assets/{file-explorer-BpWrmxcv.js → file-explorer-CsyafORl.js} +1 -1
- package/dist/client/assets/{files-D5A3uLKG.js → files-CZhkX_Ot.js} +1 -1
- package/dist/client/assets/{form--IFuVFKm.js → form-D8mdpf2K.js} +1 -1
- package/dist/client/assets/{general-bMkQfsqv.js → general-JO96DHGH.js} +1 -1
- package/dist/client/assets/{generate-id-D0LnRWve.js → generate-id-mUrGpM4H.js} +1 -1
- package/dist/client/assets/{github-repo-picker-DBFXgMcC.js → github-repo-picker-C9kA0buK.js} +1 -1
- package/dist/client/assets/{hover-card-BIgp_P2Z.js → hover-card-79cYMq8Q.js} +1 -1
- package/dist/client/assets/{index-wftbEdcV.js → index-B9apEqwQ.js} +1 -1
- package/dist/client/assets/{index-ctrOhkiE.js → index-BBm8LNlE.js} +1 -1
- package/dist/client/assets/{index-COepfYz6.js → index-BDJ9yDXA.js} +4 -4
- package/dist/client/assets/{index-BblNCGsA.js → index-BHn1FBvN.js} +1 -1
- package/dist/client/assets/{index-d8FEvCB_.js → index-BawQsE7c.js} +1 -1
- package/dist/client/assets/{index-BL9_AybV.js → index-BjgqVIIV.js} +1 -1
- package/dist/client/assets/{index-CR6JRmq1.js → index-BoLgVOc1.js} +1 -1
- package/dist/client/assets/{index-DR8AviVi.js → index-Brfgp1e5.js} +1 -1
- package/dist/client/assets/{index-2SaIv82B.js → index-C8L9Z3Xj.js} +1 -1
- package/dist/client/assets/{index-DPfHba1s.js → index-CHHEIa4S.js} +1 -1
- package/dist/client/assets/{index-MvKIVY7i.js → index-CKzWikoe.js} +1 -1
- package/dist/client/assets/{index-DA9hOaBf.js → index-CXM8hce6.js} +1 -1
- package/dist/client/assets/{index-mRLAz82B.js → index-Cs5omeVE.js} +3 -3
- package/dist/client/assets/{index-DqKAxxl-.js → index-Cx_QwEcD.js} +1 -1
- package/dist/client/assets/{index-B63sWN3k.js → index-DKGPF447.js} +1 -1
- package/dist/client/assets/{index-redirect-DoIZgKgJ.js → index-redirect-DLG-ms0e.js} +1 -1
- package/dist/client/assets/{infiniteQueryObserver-DqQaPUbn.js → infiniteQueryObserver-CR26fc83.js} +1 -1
- package/dist/client/assets/{input-BM274CDh.js → input-2Ja0Quq5.js} +1 -1
- package/dist/client/assets/{integration-icon-CDgteR-X.js → integration-icon-DCANFR5a.js} +1 -1
- package/dist/client/assets/{label-DoP_EQhI.js → label-C7mnelNh.js} +1 -1
- package/dist/client/assets/{layout-3P7eyxyX.js → layout-DRk_tSrA.js} +1 -1
- package/dist/client/assets/{login-Bzuo8Gsn.js → login-DhhA73sA.js} +1 -1
- package/dist/client/assets/{members-Cdm8UiKq.js → members-CeDwZZVC.js} +1 -1
- package/dist/client/assets/{monaco-editor-Ll5xFhzI.js → monaco-editor-BRxdxZW6.js} +1 -1
- package/dist/client/assets/{monitoring-stats-row-RgpFjpYx.js → monitoring-stats-row-DVfrB1DG.js} +1 -1
- package/dist/client/assets/{oauth-callback-CO9ks-WH.js → oauth-callback-C7aAxFQD.js} +1 -1
- package/dist/client/assets/{oauth-callback-ai-provider-BxVtsEJE.js → oauth-callback-ai-provider-XO6JZ3an.js} +1 -1
- package/dist/client/assets/{onboarding-12R9ow--.js → onboarding-Bi1ig0-9.js} +1 -1
- package/dist/client/assets/{org-layout-59I5I-L2.js → org-layout-BvUwt1ls.js} +1 -1
- package/dist/client/assets/{org-plugin-layout-BqrYEvdR.js → org-plugin-layout-nQkW7cBM.js} +1 -1
- package/dist/client/assets/{pair-BnjLSfTq.js → pair-BQ0aeenr.js} +1 -1
- package/dist/client/assets/{plugin-empty-state-DSuRoIf-.js → plugin-empty-state-3mJxwIHY.js} +1 -1
- package/dist/client/assets/{plugin-header-dwOtFWVG.js → plugin-header-CqfbDhEH.js} +1 -1
- package/dist/client/assets/{plugin-layout-MR0pz15E.js → plugin-layout-DufuZ1RQ.js} +1 -1
- package/dist/client/assets/{popover-DjYZccn5.js → popover-DYOGeANv.js} +1 -1
- package/dist/client/assets/{profile-CvJIvyN_.js → profile-DlrinCNQ.js} +1 -1
- package/dist/client/assets/{project-app-view-DqpMM8xe.js → project-app-view-B77cUBzb.js} +1 -1
- package/dist/client/assets/registry-BUveUzA3.js +2 -0
- package/dist/client/assets/{registry-layout-BeYQRrNV.js → registry-layout-_8rL05YI.js} +1 -1
- package/dist/client/assets/{require-capability-CiHUtcOZ.js → require-capability-pCczy_h0.js} +1 -1
- package/dist/client/assets/{required-auth-layout-7GG06SrS.js → required-auth-layout-R47BsBA_.js} +1 -1
- package/dist/client/assets/{reset-password-H6fF399m.js → reset-password-DgDKpGln.js} +1 -1
- package/dist/client/assets/{roles-BDMku13K.js → roles-Br9ADHbd.js} +1 -1
- package/dist/client/assets/{scroll-area-D_yszDfH.js → scroll-area-BM2aIJJh.js} +1 -1
- package/dist/client/assets/{search-input-CdctRgop.js → search-input-B3L_NuKn.js} +1 -1
- package/dist/client/assets/{secrets-Dw9yHVzk.js → secrets-C7PMWWTc.js} +1 -1
- package/dist/client/assets/{sections-editor-CscLvQ5d.js → sections-editor-Bp1g_Th1.js} +1 -1
- package/dist/client/assets/{select-BtmWAJYX.js → select-CSx5oTIm.js} +1 -1
- package/dist/client/assets/{settings-layout-neHJ6ELU.js → settings-layout-BXubYnx3.js} +1 -1
- package/dist/client/assets/{settings-section-Btqr1LoX.js → settings-section-CFchXVO0.js} +1 -1
- package/dist/client/assets/{sheet-CNJcERJ7.js → sheet-DOxYYF3-.js} +1 -1
- package/dist/client/assets/{shell-controls-ntmIoVbL.js → shell-controls-Flpa58zD.js} +1 -1
- package/dist/client/assets/{shell-layout-BfS06paz.js → shell-layout-BRzFt9Zs.js} +1 -1
- package/dist/client/assets/{sidebar-dOLVVVKN.js → sidebar-fzaBba7f.js} +1 -1
- package/dist/client/assets/{skeleton-TVdLehfA.js → skeleton-B_h_pcsL.js} +1 -1
- package/dist/client/assets/{sortable.esm-BmSsBcuP.js → sortable.esm-7XhFMdfQ.js} +1 -1
- package/dist/client/assets/{spinner-BlzNCK2x.js → spinner-DUYMiFOi.js} +1 -1
- package/dist/client/assets/{sso-i1rvcWWy.js → sso-KJBRSX4x.js} +1 -1
- package/dist/client/assets/{store-BUXZGhQo.js → store-7NcZEUZS.js} +1 -1
- package/dist/client/assets/store-registry-BM_So0jk.js +2 -0
- package/dist/client/assets/{switch-B8zluu91.js → switch--jK3vdKJ.js} +1 -1
- package/dist/client/assets/{tab-id-DmAijHUB.js → tab-id-CxWhjxZl.js} +1 -1
- package/dist/client/assets/{table-C9jlUK-H.js → table-CQ2bUWHG.js} +1 -1
- package/dist/client/assets/{tabs-YAM3raZ3.js → tabs-Dy86WHxW.js} +1 -1
- package/dist/client/assets/{task-status-DztLzsSs.js → task-status-D0oKidhL.js} +1 -1
- package/dist/client/assets/{textarea-CzvhzRTr.js → textarea-CSbVTEEY.js} +1 -1
- package/dist/client/assets/{toggle-group-YP_1dOUu.js → toggle-group-Dvujl286.js} +1 -1
- package/dist/client/assets/{toolbar-yI7NraPM.js → toolbar-BRkgMBYy.js} +1 -1
- package/dist/client/assets/{tools-list-DisiKzfD.js → tools-list-BSwYNTcR.js} +1 -1
- package/dist/client/assets/{tooltip-Dd6Kv9ag.js → tooltip-Dz9_RSi2.js} +1 -1
- package/dist/client/assets/{types-BGlS1FOL.js → types-BlBflSPa.js} +1 -1
- package/dist/client/assets/{use-ai-providers-BbLJFMva.js → use-ai-providers-CTGXqYwh.js} +1 -1
- package/dist/client/assets/{use-capability-DwYX9MQg.js → use-capability-Dwd79zrY.js} +1 -1
- package/dist/client/assets/{use-collections-BqGi4INE.js → use-collections-DpgbKBvR.js} +1 -1
- package/dist/client/assets/{use-connection-vuD8jNVS.js → use-connection-DtpbuTez.js} +1 -1
- package/dist/client/assets/{use-copy-Cg8RU7ve.js → use-copy-9ghZL9py.js} +1 -1
- package/dist/client/assets/{use-create-virtual-mcp-BEml4v4n.js → use-create-virtual-mcp-CHit5s3y.js} +1 -1
- package/dist/client/assets/{use-debounced-autosave-C6mF76KD.js → use-debounced-autosave-B14ZwsSc.js} +1 -1
- package/dist/client/assets/{use-delete-connection-DxGM8YXg.js → use-delete-connection-DY-BkAT0.js} +1 -1
- package/dist/client/assets/{use-file-configs-CyqoKqFF.js → use-file-configs-Mqa8r6Zg.js} +1 -1
- package/dist/client/assets/{use-infinite-scroll-DHUU6fHJ.js → use-infinite-scroll-CJnFgFzZ.js} +1 -1
- package/dist/client/assets/{use-list-state-qVpJvNmb.js → use-list-state-a_fDvQHi.js} +1 -1
- package/dist/client/assets/{use-mcp-prompts-B8_IBi7c.js → use-mcp-prompts-DKuMg-2v.js} +1 -1
- package/dist/client/assets/{use-mcp-tools-B9HxAzvW.js → use-mcp-tools-DbnEsq34.js} +1 -1
- package/dist/client/assets/{use-members-BW004DMP.js → use-members-C2XC2JFv.js} +1 -1
- package/dist/client/assets/{use-navigate-to-agent-BopfhgYl.js → use-navigate-to-agent-CarVjaJw.js} +1 -1
- package/dist/client/assets/{use-org-auth-client-CldLPD7N.js → use-org-auth-client-DZnvifNI.js} +1 -1
- package/dist/client/assets/{use-org-sso-DKsNqZYm.js → use-org-sso-BcJLSXFo.js} +1 -1
- package/dist/client/assets/{use-organization-roles-CnQ-EKzW.js → use-organization-roles-CDA7pGc9.js} +1 -1
- package/dist/client/assets/{use-organization-settings-B2TmZbCf.js → use-organization-settings-Dgou9A6E.js} +1 -1
- package/dist/client/assets/{use-registry-connections-JD37hRja.js → use-registry-connections-lhXgVjMB.js} +1 -1
- package/dist/client/assets/{use-secrets-BPr1wMk-.js → use-secrets-BZehQnHk.js} +1 -1
- package/dist/client/assets/{use-status-sounds-DS0JHtz2.js → use-status-sounds-CIo24PDd.js} +1 -1
- package/dist/client/assets/{use-view-mode-BknVs2oa.js → use-view-mode-BDXyOFk0.js} +1 -1
- package/dist/client/assets/{use-virtual-mcp-ChOrBDZ0.js → use-virtual-mcp-C0KsF-WK.js} +1 -1
- package/dist/client/assets/useInfiniteQuery-CbbLjGWu.js +1 -0
- package/dist/client/assets/{useRouterState-r8kt1qT5.js → useRouterState-6imMbaA1.js} +1 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-ClweRri8.js +1 -0
- package/dist/client/assets/{user-C9DoGRfP.js → user-CYqMZwFh.js} +1 -1
- package/dist/client/assets/{view-mode-toggle-DUrLWifA.js → view-mode-toggle-BrXLoe9l.js} +1 -1
- package/dist/client/assets/{workflow-YhC6zi0f.js → workflow-CyT7Ecwe.js} +1 -1
- package/dist/client/assets/workflow-detail-6ZlyuBcr.js +1 -0
- package/dist/client/index.html +1 -1
- package/dist/server/cli.js +390 -390
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/OTLPExporterBase.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/OTLPExporterBase.js +2 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/OTLPExporterBase.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/convert-legacy-browser-http-options.js +2 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/convert-legacy-browser-http-options.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/convert-legacy-node-http-options.js +2 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/convert-legacy-node-http-options.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/create-legacy-browser-delegate.js +7 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/create-legacy-browser-delegate.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/legacy-base-configuration.d.ts +1 -26
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/legacy-base-configuration.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/otlp-http-configuration.d.ts +1 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/otlp-http-configuration.js +9 -9
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/otlp-http-configuration.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/shared-configuration.d.ts +1 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/shared-configuration.js +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/shared-configuration.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/export-response.d.ts +0 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/export-response.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/index-browser-http.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/index-browser-http.js +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/index-browser-http.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/is-export-retryable.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/is-export-retryable.js +3 -5
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/is-export-retryable.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/otlp-browser-http-export-delegate.d.ts +4 -0
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/otlp-browser-http-export-delegate.js +10 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/otlp-browser-http-export-delegate.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/otlp-export-delegate.js +8 -9
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/otlp-export-delegate.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/retrying-transport.js +5 -17
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/retrying-transport.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/fetch-transport.d.ts +1 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/fetch-transport.js +8 -13
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/fetch-transport.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-exporter-transport.js +4 -5
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-exporter-transport.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-transport-types.d.ts +1 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-transport-types.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-transport-utils.d.ts +2 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-transport-utils.js +14 -37
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-transport-utils.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/send-beacon-transport.d.ts +2 -4
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/send-beacon-transport.js +4 -5
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/send-beacon-transport.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/xhr-transport.d.ts +17 -0
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/xhr-transport.js +86 -0
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/xhr-transport.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/util.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/util.js +12 -10
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/util.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/version.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/version.js +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/version.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/OTLPExporterBase.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/OTLPExporterBase.js +2 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/OTLPExporterBase.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/configuration/convert-legacy-browser-http-options.js +2 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/configuration/convert-legacy-browser-http-options.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/configuration/convert-legacy-node-http-options.js +2 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/configuration/convert-legacy-node-http-options.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/configuration/create-legacy-browser-delegate.js +7 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/configuration/create-legacy-browser-delegate.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/configuration/legacy-base-configuration.d.ts +1 -26
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/configuration/legacy-base-configuration.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/configuration/otlp-http-configuration.d.ts +1 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/configuration/otlp-http-configuration.js +9 -9
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/configuration/otlp-http-configuration.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/configuration/shared-configuration.d.ts +1 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/configuration/shared-configuration.js +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/configuration/shared-configuration.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/export-response.d.ts +0 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/export-response.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/index-browser-http.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/index-browser-http.js +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/index-browser-http.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/is-export-retryable.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/is-export-retryable.js +3 -5
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/is-export-retryable.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/otlp-browser-http-export-delegate.d.ts +4 -0
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/otlp-browser-http-export-delegate.js +10 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/otlp-browser-http-export-delegate.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/otlp-export-delegate.js +8 -9
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/otlp-export-delegate.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/retrying-transport.js +5 -17
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/retrying-transport.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/transport/fetch-transport.d.ts +1 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/transport/fetch-transport.js +8 -13
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/transport/fetch-transport.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/transport/http-exporter-transport.js +4 -5
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/transport/http-exporter-transport.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/transport/http-transport-types.d.ts +1 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/transport/http-transport-types.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/transport/http-transport-utils.d.ts +2 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/transport/http-transport-utils.js +14 -37
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/transport/http-transport-utils.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/transport/send-beacon-transport.d.ts +2 -4
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/transport/send-beacon-transport.js +4 -5
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/transport/send-beacon-transport.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/transport/xhr-transport.d.ts +17 -0
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/transport/xhr-transport.js +86 -0
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/transport/xhr-transport.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/util.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/util.js +12 -10
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/util.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/version.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/version.js +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/version.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/OTLPExporterBase.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/OTLPExporterBase.js +2 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/OTLPExporterBase.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/configuration/convert-legacy-browser-http-options.js +2 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/configuration/convert-legacy-browser-http-options.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/configuration/convert-legacy-node-http-options.js +2 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/configuration/convert-legacy-node-http-options.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/configuration/create-legacy-browser-delegate.js +6 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/configuration/create-legacy-browser-delegate.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/configuration/legacy-base-configuration.d.ts +1 -26
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/configuration/legacy-base-configuration.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/configuration/otlp-http-configuration.d.ts +1 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/configuration/otlp-http-configuration.js +9 -9
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/configuration/otlp-http-configuration.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/configuration/shared-configuration.d.ts +1 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/configuration/shared-configuration.js +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/configuration/shared-configuration.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/export-response.d.ts +0 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/export-response.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/index-browser-http.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/index-browser-http.js +2 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/index-browser-http.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/is-export-retryable.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/is-export-retryable.js +5 -7
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/is-export-retryable.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/otlp-browser-http-export-delegate.d.ts +4 -0
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/otlp-browser-http-export-delegate.js +12 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/otlp-browser-http-export-delegate.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/otlp-export-delegate.js +8 -9
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/otlp-export-delegate.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/retrying-transport.js +5 -17
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/retrying-transport.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/transport/fetch-transport.d.ts +1 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/transport/fetch-transport.js +7 -12
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/transport/fetch-transport.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/transport/http-exporter-transport.js +4 -5
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/transport/http-exporter-transport.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/transport/http-transport-types.d.ts +1 -2
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/transport/http-transport-types.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/transport/http-transport-utils.d.ts +2 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/transport/http-transport-utils.js +13 -36
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/transport/http-transport-utils.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/transport/send-beacon-transport.d.ts +2 -4
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/transport/send-beacon-transport.js +4 -5
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/transport/send-beacon-transport.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/transport/xhr-transport.d.ts +17 -0
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/transport/xhr-transport.js +90 -0
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/transport/xhr-transport.js.map +1 -0
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/util.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/util.js +12 -10
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/util.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/version.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/version.js +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/version.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/package.json +6 -6
- package/dist/server/node_modules/@opentelemetry/otlp-transformer/build/esm/generated/root.js +36 -6
- package/dist/server/node_modules/@opentelemetry/otlp-transformer/build/esm/generated/root.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-transformer/build/esm/trace/internal.js +15 -0
- package/dist/server/node_modules/@opentelemetry/otlp-transformer/build/esm/trace/internal.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-transformer/build/esnext/generated/root.js +36 -6
- package/dist/server/node_modules/@opentelemetry/otlp-transformer/build/esnext/generated/root.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-transformer/build/esnext/trace/internal.js +15 -0
- package/dist/server/node_modules/@opentelemetry/otlp-transformer/build/esnext/trace/internal.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-transformer/build/src/generated/root.js +36 -6
- package/dist/server/node_modules/@opentelemetry/otlp-transformer/build/src/generated/root.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-transformer/build/src/trace/internal.js +15 -0
- package/dist/server/node_modules/@opentelemetry/otlp-transformer/build/src/trace/internal.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/otlp-transformer/package.json +12 -14
- package/dist/server/node_modules/ansi-styles/index.d.ts +236 -0
- package/dist/server/node_modules/ansi-styles/index.js +223 -0
- package/dist/server/node_modules/ansi-styles/license +9 -0
- package/dist/server/node_modules/ansi-styles/package.json +54 -0
- package/dist/server/node_modules/ansi-styles/readme.md +173 -0
- package/dist/server/node_modules/cli-truncate/index.d.ts +118 -0
- package/dist/server/node_modules/cli-truncate/index.js +168 -0
- package/dist/server/node_modules/cli-truncate/license +9 -0
- package/dist/server/node_modules/cli-truncate/package.json +52 -0
- package/dist/server/node_modules/cli-truncate/readme.md +154 -0
- package/dist/server/node_modules/indent-string/index.d.ts +38 -0
- package/dist/server/node_modules/indent-string/index.js +38 -0
- package/dist/server/node_modules/indent-string/license +9 -0
- package/dist/server/node_modules/indent-string/package.json +40 -0
- package/dist/server/node_modules/indent-string/readme.md +73 -0
- package/dist/server/node_modules/protobufjs/dist/light/protobuf.js +13 -10
- package/dist/server/node_modules/protobufjs/dist/light/protobuf.js.map +1 -1
- package/dist/server/node_modules/protobufjs/dist/light/protobuf.min.js +3 -3
- package/dist/server/node_modules/protobufjs/dist/light/protobuf.min.js.map +1 -1
- package/dist/server/node_modules/protobufjs/dist/minimal/protobuf.js +2 -2
- package/dist/server/node_modules/protobufjs/dist/minimal/protobuf.min.js +2 -2
- package/dist/server/node_modules/protobufjs/dist/protobuf.js +14 -55
- package/dist/server/node_modules/protobufjs/dist/protobuf.js.map +1 -1
- package/dist/server/node_modules/protobufjs/dist/protobuf.min.js +3 -3
- package/dist/server/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
- package/dist/server/node_modules/protobufjs/package.json +1 -1
- package/dist/server/node_modules/protobufjs/src/message.js +7 -3
- package/dist/server/node_modules/protobufjs/src/object.js +3 -6
- package/dist/server/node_modules/protobufjs/src/parse.js +1 -45
- package/dist/server/node_modules/protobufjs/src/type.js +1 -0
- package/dist/server/node_modules/widest-line/index.d.ts +12 -0
- package/dist/server/node_modules/widest-line/index.js +11 -0
- package/dist/server/node_modules/widest-line/license +9 -0
- package/dist/server/node_modules/widest-line/package.json +60 -0
- package/dist/server/node_modules/widest-line/readme.md +26 -0
- package/package.json +1 -1
- package/dist/client/assets/registry-DDaKYJ_K.js +0 -2
- package/dist/client/assets/store-registry-BTo26ihN.js +0 -2
- package/dist/client/assets/useInfiniteQuery-DQxhY8fe.js +0 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-DIUVWNw2.js +0 -1
- package/dist/client/assets/workflow-detail-CzxpFM6K.js +0 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/convert-legacy-http-options.d.ts +0 -4
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/convert-legacy-http-options.js +0 -23
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/convert-legacy-http-options.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/configuration/convert-legacy-http-options.d.ts +0 -4
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/configuration/convert-legacy-http-options.js +0 -23
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/esnext/configuration/convert-legacy-http-options.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/configuration/convert-legacy-http-options.d.ts +0 -4
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/configuration/convert-legacy-http-options.js +0 -27
- package/dist/server/node_modules/@opentelemetry/otlp-exporter-base/build/src/configuration/convert-legacy-http-options.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/sections-editor-
|
|
2
|
-
import{e as U,r as M,c as re,j as n,l as ge,q as ke,b as Es,E as Mt,f as Zt,d as Vn,g as El,p as id,L as rd,n as gi,K as $t,s as nd,o as ae,B as te,v as Tl,V as od,t as Pe,w as Rl,x as ad,y as gr,z as ci,C as ct,D as vr,F as Pl,G as ld,H as cd,I as Vo,J as hd,a as xr,M as Fi,P as Zs,Q as vt,_ as vi,R as hi,T as dd,U as ud}from"./index-mRLAz82B.js";import{C as Ae,a as fd,u as md,w as pd,b as qn,s as Hi,T as _d,t as gd,r as vd,c as xd,d as bd,g as yd,e as Sd}from"./index-DqKAxxl-.js";import{g as Gn,u as Qe,S as hs,a as Dl}from"./constants-Dt6Fd4L9.js";import{u as bt,a as wd,b as Cd}from"./use-virtual-mcp-ChOrBDZ0.js";import{u as ds,a as Qt,b as br,c as kd,d as xi,h as jd,g as Ts,e as Al,t as Nd,f as qo,i as Ed}from"./chat-context-C34a2VI8.js";import{i as bi}from"./AlertCircle-Cuw2SV6F.js";import{i as Td}from"./CheckCircle-CxRkGFf_.js";import{n as Go}from"./ZapSquare-8pO6mgDJ.js";import{i as Rd,a as Yn,b as Pd}from"./XCircle-Bb_BNn3s.js";import{s as ks}from"./XClose-AvlHokGh.js";import{c as Dd,t as Yo,M as Xn,G as Ad}from"./pair-BnjLSfTq.js";import{I as us}from"./integration-icon-CDgteR-X.js";import{a as Md}from"./Users03-BujFLjc9.js";import{u as Bd}from"./use-ai-providers-BbLJFMva.js";import{u as Id}from"./connect-desktop-dialog-sl6vIyrd.js";import{r as Ld,u as Jn,i as Od}from"./shell-layout-BfS06paz.js";import{a as $d}from"./index-wftbEdcV.js";import{u as zd}from"./sidebar-dOLVVVKN.js";import{i as Fd,S as Hd,a as Wd,b as Ud}from"./sheet-CNJcERJ7.js";import{u as Ml,T as Se,a as we,b as Ce,c as Bl}from"./tooltip-Dd6Kv9ag.js";import{i as Zn,a as yr,b as Kd,c as Vd,p as Sr,g as wr,d as Qn,e as Il,h as tn,f as Ir,j as Xo,A as Jo,k as qd,l as Gd,n as Yd,m as Xd,o as Jd,t as Zd,q as Qd,r as eu,s as Cr,u as tu,v as su,w as Ll,x as iu,y as Zo,z as ru,B as nu,C as eo,D as ou,E as ri,F as Ol,G as $l,H as au}from"./agent-icon-LtrmhUhU.js";import{u as lu}from"./use-status-sounds-DS0JHtz2.js";import{E as Zi}from"./empty-state-CPucj88p.js";import{u as cu,r as sn,a as hu,p as zl,f as Qo,b as Fl,c as du,F as uu,i as fu,d as mu,e as pu,g as _u,h as gu}from"./tab-id-DmAijHUB.js";import{T as ea,a as rn}from"./toolbar-yI7NraPM.js";import{A as vu,a as xu,b as bu,c as yu,R as Hl,d as Su,e as wu}from"./accordion-K_eZcF1d.js";import{u as kr,a as to,b as Cu}from"./use-connection-vuD8jNVS.js";import{u as jr,a as ku}from"./use-mcp-tools-B9HxAzvW.js";import{g as ju}from"./generate-id-D0LnRWve.js";import{u as Nu,g as Eu}from"./types-BGlS1FOL.js";import{U as Wl}from"./user-C9DoGRfP.js";import{T as Tu,u as Ul}from"./tools-list-DisiKzfD.js";import{u as Ru}from"./unwrap-tool-result-BYXdCQMg.js";import{s as Kl,g as Pu}from"./connection-slug-eyAPH6o3.js";import{A as Qi,a as er,b as tr,c as sr,d as ir,e as rr,f as nr,g as or}from"./alert-dialog-_yhGzUzO.js";import{D as Rs,a as Ft,b as Ht,c as fs,d as ms,e as so}from"./dialog-HH-j4g7f.js";import{C as Vl,a as nn}from"./card-BtEZnZdS.js";import{I as Ge}from"./input-BM274CDh.js";import{L as _t}from"./label-DoP_EQhI.js";import{S as Bt,a as It,b as Lt,c as Ot,d as dt}from"./select-BtmWAJYX.js";import{S as on}from"./switch-B8zluu91.js";import{T as ar}from"./textarea-CzvhzRTr.js";import{i as js}from"./Play-BJZELjph.js";import{s as zt}from"./Plus-B0LVf3QA.js";import{a as Du}from"./Settings02-rvrknMco.js";import{t as io,i as ql}from"./Tool01-Cv7ThooB.js";import{s as di}from"./Trash01-mi2XNMKw.js";import{u as lr}from"./use-debounced-autosave-C6mF76KD.js";import{P as yi,a as Si,b as wi}from"./popover-DjYZccn5.js";import{S as ro}from"./scroll-area-D_yszDfH.js";import{i as Gl}from"./SearchMd-BkC3SNiM.js";import{i as Au}from"./Upload01-C_9zjkZV.js";import{P as xt}from"./index-2SaIv82B.js";import{A as Mu}from"./sortable.esm-BmSsBcuP.js";import{C as Bu}from"./collection-tabs-Dp0vGAAv.js";import{C as Yl}from"./checkbox-ZWqntSXg.js";import{u as Iu}from"./use-mcp-prompts-B8_IBi7c.js";import{D as Lu,a as Ou,b as $u}from"./drawer-D-NV5MY-.js";import{i as Ci}from"./Check-BCUhIxA7.js";import{a as Xt,i as zu,s as Fu}from"./RefreshCcw01-DWxUoP-x.js";import{i as Xl}from"./Key01-B_a8BUQ2.js";import{S as ys}from"./skeleton-TVdLehfA.js";import{i as Hu}from"./Lock01-O1o_RfBw.js";import{s as Wu}from"./User01-TY3L0cwN.js";import{t as Uu}from"./Users01-cH_zAee_.js";import{u as Ku,a as Vu}from"./use-secrets-BPr1wMk-.js";import{G as qu}from"./github-repo-picker-DBFXgMcC.js";import{f as Gu}from"./formatDistanceToNow-Cb2QZZJn.js";import{n as Ps}from"./LinkExternal01-pVfL_xHa.js";import{T as ns,a as no,b as ni,c as oo}from"./tabs-YAM3raZ3.js";import{l as Yu,w as Xu,M as Ju}from"./monaco-editor-Ll5xFhzI.js";import{D as Ds,a as As,b as Ms,c as ht,d as ta,e as Zu,f as Qu,g as ef}from"./dropdown-menu-Z_F9h9Dc.js";import{i as tf}from"./ChevronRight-D9aRf4_R.js";import{S as Jl}from"./spinner-BlzNCK2x.js";import{t as ao}from"./ChevronDown-DPKlPltC.js";import{s as cr}from"./Star01-BFyFzcou.js";import{i as Zl}from"./Stars02-B5lf1Mb2.js";import{V as sf}from"./view-mode-toggle-DUrLWifA.js";import{i as rf}from"./X-DRk1PhRt.js";import{u as ki,a as nf,b as of,c as af,A as lf,d as cf}from"./automation-list-row-ClD1PaDz.js";import{i as hf}from"./SwitchHorizontal01-BiY6DZkl.js";import{i as ui}from"./Zap-CuR6pNCy.js";import{S as df}from"./search-input-CdctRgop.js";function Ws(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function sa(t){if(!t)return"—";const e=typeof t=="string"?new Date(t):t;return isNaN(e.getTime())?"—":e.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function uf(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function ff(t){const e=U.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(mf),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=n.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-6",children:i}),e[2]=i,e[3]=r):r=e[3],r}function mf(t){return n.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[n.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),n.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function pf(t){const e=U.c(30),{userTokens:s,assistantTokens:i,otherTokens:r}=t,o=s+i+r,a=o>0?s/o*100:0,l=o>0?i/o*100:0,h=o>0?r/o*100:0;let c;e[0]!==a?(c=a>0&&n.jsx("div",{className:"h-full bg-chart-1",style:{width:`${a}%`}}),e[0]=a,e[1]=c):c=e[1];let d;e[2]!==l?(d=l>0&&n.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=d):d=e[3];let u;e[4]!==h?(u=h>0&&n.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${h}%`}}),e[4]=h,e[5]=u):u=e[5];let f;e[6]!==c||e[7]!==d||e[8]!==u?(f=n.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[c,d,u]}),e[6]=c,e[7]=d,e[8]=u,e[9]=f):f=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=p):p=e[10];let m;e[11]!==a?(m=a.toFixed(1),e[11]=a,e[12]=m):m=e[12];let _;e[13]!==m?(_=n.jsxs("div",{className:"flex items-center gap-1.5",children:[p,n.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",m,"%"]})]}),e[13]=m,e[14]=_):_=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=g):g=e[15];let x;e[16]!==l?(x=l.toFixed(1),e[16]=l,e[17]=x):x=e[17];let y;e[18]!==x?(y=n.jsxs("div",{className:"flex items-center gap-1.5",children:[g,n.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",x,"%"]})]}),e[18]=x,e[19]=y):y=e[19];let v;e[20]!==h||e[21]!==r?(v=r>0&&n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),n.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",h.toFixed(1),"%"]})]}),e[20]=h,e[21]=r,e[22]=v):v=e[22];let b;e[23]!==y||e[24]!==v||e[25]!==_?(b=n.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[_,y,v]}),e[23]=y,e[24]=v,e[25]=_,e[26]=b):b=e[26];let C;return e[27]!==b||e[28]!==f?(C=n.jsxs("div",{className:"flex flex-col gap-2",children:[f,b]}),e[27]=b,e[28]=f,e[29]=C):C=e[29],C}function _f(t){const e=U.c(11),{agentId:s,isError:i}=t,r=bt(s),o=r?.title??"Subtask",a=r?.icon??null;let l;e[0]!==a||e[1]!==o?(l=n.jsx(us,{icon:a,name:o,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=o,e[2]=l):l=e[2];const h=i?"text-destructive":"text-foreground";let c;e[3]!==h?(c=re("shrink-0 font-medium",h),e[3]=h,e[4]=c):c=e[4];let d;e[5]!==o||e[6]!==c?(d=n.jsx("span",{className:c,children:o}),e[5]=o,e[6]=c,e[7]=d):d=e[7];let u;return e[8]!==l||e[9]!==d?(u=n.jsxs(n.Fragment,{children:[l,d]}),e[8]=l,e[9]=d,e[10]=u):u=e[10],u}function gf(t){const e=U.c(5),{isError:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(us,{icon:null,name:"Subtask",size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=i):i=e[0];const r=s?"text-destructive":"text-foreground";let o;e[1]!==r?(o=re("shrink-0 font-medium",r),e[1]=r,e[2]=o):o=e[2];let a;return e[3]!==o?(a=n.jsxs(n.Fragment,{children:[i,n.jsx("span",{className:o,children:"Subtask"})]}),e[3]=o,e[4]=a):a=e[4],a}function vf(t){const e=U.c(18),{part:s}=t,i=s.input?.agent_id,r=s.state==="input-streaming"||s.state==="input-available"||s.state==="output-available"&&s.preliminary===!0,o=s.state==="output-error",a=s.state==="approval-requested";let l;e[0]!==o?(l=n.jsx(gf,{isError:o}),e[0]=o,e[1]=l):l=e[1];let h;e[2]!==i||e[3]!==o?(h=n.jsx(_f,{agentId:i,isError:o}),e[2]=i,e[3]=o,e[4]=h):h=e[4];let c;e[5]!==l||e[6]!==h?(c=n.jsx(M.Suspense,{fallback:l,children:h}),e[5]=l,e[6]=h,e[7]=c):c=e[7];let d;e[8]!==s.input?(d=s.input?.prompt&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-muted-foreground/50",children:"·"}),n.jsx("span",{className:"truncate text-muted-foreground",children:s.input.prompt})]}),e[8]=s.input,e[9]=d):d=e[9];let u;e[10]!==a||e[11]!==o||e[12]!==r?(u=n.jsx("span",{className:"ml-auto shrink-0",children:r?n.jsx(ge,{size:12,className:"animate-spin text-muted-foreground"}):o?n.jsx(Rd,{size:12,className:"text-destructive"}):a?n.jsx(bi,{size:12,className:"text-warning"}):n.jsx(Td,{size:12,className:"text-emerald-500"})}),e[10]=a,e[11]=o,e[12]=r,e[13]=u):u=e[13];let f;return e[14]!==c||e[15]!==d||e[16]!==u?(f=n.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[c,d,u]}),e[14]=c,e[15]=d,e[16]=u,e[17]=f):f=e[17],f}function xf(t){const e=U.c(55),{onClose:s,back:i,className:r}=t,[o,a]=M.useState(null),{messages:l}=ds(),{activeTask:h}=Qt(),{selectedModel:c,selectedVirtualMcp:d}=br();let u,f,p,m,_,g,x,y;if(e[0]!==h||e[1]!==i||e[2]!==r||e[3]!==l||e[4]!==s||e[5]!==o?.id||e[6]!==c||e[7]!==d?.title){y=Symbol.for("react.early_return_sentinel");e:{const C=Dd(l),S=[...l].reverse().find(Rf),k=S?.metadata?.usage,N=S?.metadata?.modelLimits?.contextWindow??c?.limits?.contextWindow??null,P=k?.contextTokens??0,A=N&&N>0?(P/N*100).toFixed(1):null,E=l;let j;e[16]!==E?(j=E.filter(Tf).reduce(Ef,0),e[16]=E,e[17]=j):j=e[17];const w=j,T=l;let D;e[18]!==T?(D=T.filter(Nf).reduce(jf,0),e[18]=T,e[19]=D):D=e[19];const R=D,I=Math.max(0,C.totalTokens-w-R),B=l[0],H=l.at(-1),W=B?.metadata?.created_at??h?.created_at,z=H?.metadata?.created_at??h?.updated_at,O=l.filter(kf),V=l.flatMap(wf),K=c?.modelId?uf(c.modelId):"—",Q=d?.title??"Decopilot",X=[{label:"Session",value:h?.title??"New chat"},{label:"Messages",value:O.length},{label:"Agent",value:Q},{label:"Model",value:K},{label:"Context Limit",value:N?Ws(N):"—"},{label:"Session Tokens (billed)",value:C.totalTokens>0?Ws(C.totalTokens):"0"},{label:"Usage",value:A!==null?`${A}%`:"—"},{label:"Input Tokens",value:C.inputTokens>0?Ws(C.inputTokens):"0"},{label:"Output Tokens",value:C.outputTokens>0?Ws(C.outputTokens):"0"},{label:"Reasoning Tokens",value:C.reasoningTokens>0?Ws(C.reasoningTokens):"0"},{label:"Cost",value:C.cost>0?`$${C.cost<.001?C.cost.toFixed(6):C.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:sa(W)},{label:"Last Activity",value:sa(z)}];if(!h&&O.length===0){let L;e[20]!==r?(L=re("flex flex-col h-full w-full border-l border-border bg-background",r),e[20]=r,e[21]=L):L=e[21];let J;e[22]===Symbol.for("react.memo_cache_sentinel")?(J=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[22]=J):J=e[22];let Z;e[23]!==i?(Z=i?n.jsx(Go,{size:14,className:"text-muted-foreground"}):n.jsx(ks,{size:14,className:"text-muted-foreground"}),e[23]=i,e[24]=Z):Z=e[24];let F;e[25]!==s||e[26]!==Z?(F=n.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[J,n.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:Z})]}),e[25]=s,e[26]=Z,e[27]=F):F=e[27];let ne;e[28]===Symbol.for("react.memo_cache_sentinel")?(ne=n.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:n.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a conversation to see context"})}),e[28]=ne):ne=e[28];let ie;e[29]!==L||e[30]!==F?(ie=n.jsxs("div",{className:L,children:[F,ne]}),e[29]=L,e[30]=F,e[31]=ie):ie=e[31],y=ie;break e}e[32]!==r?(g=re("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",r),e[32]=r,e[33]=g):g=e[33];let q;e[34]===Symbol.for("react.memo_cache_sentinel")?(q=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[34]=q):q=e[34];let se;e[35]!==i?(se=i?n.jsx(Go,{size:14}):n.jsx(ks,{size:14}),e[35]=i,e[36]=se):se=e[36],e[37]!==s||e[38]!==se?(x=n.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[q,n.jsx("button",{type:"button",onClick:s,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:se})]}),e[37]=s,e[38]=se,e[39]=x):x=e[39],u="flex flex-col gap-8 p-6",f=V.length>0&&n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("span",{className:"text-xs text-muted-foreground",children:"Subtasks"}),n.jsx("div",{className:"flex flex-col gap-1",children:V.map(Sf)})]}),p=n.jsx(ff,{items:X});let $;e[40]===Symbol.for("react.memo_cache_sentinel")?($=n.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[40]=$):$=e[40],e[41]!==R||e[42]!==I||e[43]!==w?(m=n.jsxs("div",{className:"flex flex-col gap-3",children:[$,n.jsx(pf,{userTokens:w,assistantTokens:R,otherTokens:I})]}),e[41]=R,e[42]=I,e[43]=w,e[44]=m):m=e[44],_=O.length>0&&n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("span",{className:"text-xs text-muted-foreground",children:"Raw messages"}),n.jsx("div",{className:"flex flex-col gap-1",children:O.map(L=>{const J=L.metadata?.created_at,Z=o?.id===L.id;return n.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[n.jsxs("button",{type:"button",onClick:()=>a(Z?null:L),className:"flex items-center justify-between gap-2 px-3 py-2 text-xs hover:bg-accent/50 w-full text-left cursor-pointer",children:[n.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[n.jsx("span",{className:re("shrink-0 font-medium",L.role==="user"?"text-chart-1":"text-chart-2"),children:L.role}),n.jsx("span",{className:"text-muted-foreground",children:"•"}),n.jsx("span",{className:"truncate text-muted-foreground font-mono",children:L.id})]}),J&&n.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(J).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),Z&&n.jsxs(n.Fragment,{children:[L.role==="assistant"&&(()=>{const F=L.metadata?._request;if(!F)return null;const ne=F.systemSections??[],ie=Math.max(1,...ne.map(yf)),de=ne.reduce(bf,0);return n.jsxs("div",{className:"border-t border-border/50 px-3 py-2.5 text-xs space-y-2.5",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"font-medium text-foreground",children:"Request"}),n.jsxs("span",{className:"text-muted-foreground tabular-nums",children:[F.activeTools??0," / ",F.tools??0," ","tools active"]})]}),ne.length>0&&n.jsxs("div",{className:"space-y-1.5",children:[n.jsxs("div",{className:"text-muted-foreground",children:["System prompt"," ",n.jsxs("span",{className:"tabular-nums",children:["~",Math.round(de/4).toLocaleString()," ","tok"]})]}),ne.map((ue,_e)=>{const le=ue.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${_e}`,je=ue.chars/ie*100,Ne=Math.round(ue.chars/4);return n.jsxs("div",{className:"space-y-0.5",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("span",{className:"font-mono text-foreground truncate",children:le}),n.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:["~",Ne.toLocaleString()," tok"]})]}),n.jsx("div",{className:"h-1 w-full rounded-full bg-muted overflow-hidden",children:n.jsx("div",{className:"h-full rounded-full bg-chart-3",style:{width:`${je}%`}})})]},_e)})]})]})})(),n.jsx("pre",{className:"text-xs font-mono bg-muted px-3 py-2 overflow-auto whitespace-pre-wrap break-all border-t border-border/50 max-h-64",children:JSON.stringify(L,null,2)})]})]},L.id)})})]})}e[0]=h,e[1]=i,e[2]=r,e[3]=l,e[4]=s,e[5]=o?.id,e[6]=c,e[7]=d?.title,e[8]=u,e[9]=f,e[10]=p,e[11]=m,e[12]=_,e[13]=g,e[14]=x,e[15]=y}else u=e[8],f=e[9],p=e[10],m=e[11],_=e[12],g=e[13],x=e[14],y=e[15];if(y!==Symbol.for("react.early_return_sentinel"))return y;let v;e[45]!==u||e[46]!==f||e[47]!==p||e[48]!==m||e[49]!==_?(v=n.jsxs("div",{className:u,children:[f,p,m,_]}),e[45]=u,e[46]=f,e[47]=p,e[48]=m,e[49]=_,e[50]=v):v=e[50];let b;return e[51]!==g||e[52]!==x||e[53]!==v?(b=n.jsxs("div",{className:g,children:[x,v]}),e[51]=g,e[52]=x,e[53]=v,e[54]=b):b=e[54],b}function bf(t,e){return t+e.chars}function yf(t){return t.chars}function Sf(t,e){return n.jsx(vf,{part:t},e)}function wf(t){return(t.parts??[]).filter(Cf)}function Cf(t){return t.type==="tool-subtask"}function kf(t){return t.role!=="system"}function jf(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function Nf(t){return t.role==="assistant"}function Ef(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function Tf(t){return t.role==="user"}function Rf(t){return t.role==="assistant"&&t.metadata?.usage}function Pf(t){const e=U.c(13),{readOnly:s,identity:i,aboveRow:r,input:o,iceBreakers:a}=t,l=!s&&i?i:null;let h;e[0]!==r||e[1]!==s?(h=!s&&r?n.jsx("div",{"data-chat-above-row":"true",className:"@container/chat-bottom flex justify-start gap-1",children:r}):null,e[0]=r,e[1]=s,e[2]=h):h=e[2];let c;e[3]!==o||e[4]!==h?(c=n.jsxs("div",{className:"flex flex-col gap-2",children:[h,o]}),e[3]=o,e[4]=h,e[5]=c):c=e[5];let d;e[6]!==a||e[7]!==s?(d=!s&&a?n.jsx("div",{className:"w-full",children:a}):null,e[6]=a,e[7]=s,e[8]=d):d=e[8];let u;return e[9]!==l||e[10]!==c||e[11]!==d?(u=n.jsx("div",{"data-chat-centered":"true",className:"h-full w-full flex flex-col items-center justify-center px-4 gap-6",children:n.jsxs("div",{className:"w-full max-w-3xl flex flex-col gap-6",children:[l,c,d]})}),e[9]=l,e[10]=c,e[11]=d,e[12]=u):u=e[12],u}function Df(t){const e=U.c(25),{onOpenContextPanel:s}=t,{org:i}=ke(),{selectedVirtualMcp:r}=br();let o;e[0]!==i.id?(o=Gn(i.id),e[0]=i.id,e[1]=o):o=e[1];const l=r??o,h=bt(l.id),c=kd(),{data:d}=Es.useSession(),u=d?.user?.id,f=c?.activeTask??null,p=!!(u&&f?.created_by&&f.created_by!==u);let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(Md,{size:32}),e[2]=m):m=e[2];let _;e[3]!==l.icon||e[4]!==l.title?(_=n.jsx(us,{icon:l.icon,name:l.title,size:"lg",fallbackIcon:m,className:"size-10 min-w-10 md:size-[60px]! md:min-w-[60px] rounded-xl md:rounded-[18px]!"}),e[3]=l.icon,e[4]=l.title,e[5]=_):_=e[5];let g;e[6]!==l.title?(g=n.jsx("h3",{className:"text-base md:text-xl font-medium text-foreground",children:l.title}),e[6]=l.title,e[7]=g):g=e[7];const x=l.description??"Ask anything about configuring model providers or using MCP Mesh.";let y;e[8]!==x?(y=n.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:x}),e[8]=x,e[9]=y):y=e[9];let v;e[10]!==_||e[11]!==g||e[12]!==y?(v=n.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[_,g,y]}),e[10]=_,e[11]=g,e[12]=y,e[13]=v):v=e[13];const b=c?.currentBranch??null;let C;e[14]!==h||e[15]!==b?(C=n.jsx(fd,{virtualMcp:h,currentBranch:b}),e[14]=h,e[15]=b,e[16]=C):C=e[16];let S;e[17]!==s?(S=n.jsx(Ae.Input,{onOpenContextPanel:s}),e[17]=s,e[18]=S):S=e[18];let k;e[19]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(Ae.IceBreakers,{}),e[19]=k):k=e[19];let N;return e[20]!==p||e[21]!==S||e[22]!==v||e[23]!==C?(N=n.jsx(Pf,{readOnly:p,identity:v,aboveRow:C,input:S,iceBreakers:k}),e[20]=p,e[21]=S,e[22]=v,e[23]=C,e[24]=N):N=e[24],N}function Af(){const t=U.c(28),{org:e}=ke(),s=Bd(),{isChatEmpty:i}=ds(),[r,o]=M.useState("chat"),a=md(),{selectedVirtualMcp:l}=br();let h;t[0]!==e.id?(h=Gn(e.id),t[0]=e.id,t[1]=h):h=t[1];const u=bt((l??h).id),f=Id(),p=xi(u?.metadata);if(s.length===0&&!(p&&jd(f))){let E;return t[2]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx(Ae,{className:"animate-in fade-in-0 duration-200",children:n.jsx(Ae.Main,{className:"flex flex-col items-center",children:n.jsx(Ae.EmptyState,{children:n.jsx(Ae.NoAiProviderEmptyState,{})})})}),t[2]=E):E=t[2],E}let _;t[3]!==a.hasDecoKey||t[4]!==a.hasOnlyDecoProvider||t[5]!==a.isLoading||t[6]!==a.isZeroBalance||t[7]!==i||t[8]!==e.id?(_=a.hasDecoKey&&a.isZeroBalance&&a.hasOnlyDecoProvider&&!a.isLoading&&i&&!pd(e.id),t[3]=a.hasDecoKey,t[4]=a.hasOnlyDecoProvider,t[5]=a.isLoading,t[6]=a.isZeroBalance,t[7]=i,t[8]=e.id,t[9]=_):_=t[9];const g=_;let x;t[10]!==g?(x=g&&n.jsx(Ae.CreditsEmptyState,{}),t[10]=g,t[11]=x):x=t[11];const y=r!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let v;t[12]!==y?(v=re("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",y),t[12]=y,t[13]=v):v=t[13];let b;t[14]!==i?(b=i?n.jsx(Ae.Main,{children:n.jsx(Df,{onOpenContextPanel:()=>o("context")})}):n.jsxs(n.Fragment,{children:[n.jsx(Ae.Main,{children:n.jsx(Ae.Messages,{})}),n.jsx(Ae.Footer,{children:n.jsx(Ae.Input,{onOpenContextPanel:()=>o("context")})})]}),t[14]=i,t[15]=b):b=t[15];let C;t[16]!==v||t[17]!==b?(C=n.jsx("div",{className:v,children:b}),t[16]=v,t[17]=b,t[18]=C):C=t[18];const S=r==="context"?"opacity-100":"opacity-0 pointer-events-none";let k;t[19]!==S?(k=re("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",S),t[19]=S,t[20]=k):k=t[20];let N;t[21]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx(xf,{back:!0,onClose:()=>o("chat")}),t[21]=N):N=t[21];let P;t[22]!==k?(P=n.jsx("div",{className:k,children:N}),t[22]=k,t[23]=P):P=t[23];let A;return t[24]!==P||t[25]!==x||t[26]!==C?(A=n.jsxs(Ae,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[x,C,P]}),t[24]=P,t[25]=x,t[26]=C,t[27]=A):A=t[27],A}function Ql(){const t=U.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(Ae.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(Mt,{fallback:e,children:n.jsx(M.Suspense,{fallback:n.jsx(Ae.Skeleton,{}),children:n.jsx(Af,{})})}),t[1]=s):s=t[1],s}function Mf(t){const e=t.entityMetadata?.defaultMainView??null,s=e==null||e.type==="chat",i=t.mainParamPresent?t.mainParamValue!=="0":!s,r=s?!0:t.entityMetadata?.chatDefaultOpen??!1;return{mainOpen:i,chatOpen:r}}function ia(t,e){return t&&e?{chat:45,main:55}:t&&!e?{chat:100,main:0}:!t&&e?{chat:0,main:100}:{chat:0,main:0}}function Bf(t,e){return t===1?!0:t===0?!1:e}function If(t,e){const s=Zt(),i=Vn({strict:!1}),r=El({strict:!1}),{create:o}=cu(),{locator:a}=ke(),{virtualMcpId:l,orgSlug:h,isAgentRoute:c}=e,d=Mf({entityMetadata:t,mainParamPresent:i.main!==void 0,mainParamValue:i.main}),u=Bf(i.chat,d.chatOpen),f=d.mainOpen,p=M.useRef(crypto.randomUUID()),m=r.taskId??p.current,_="/$org/$taskId",g=P=>({org:h,taskId:P}),x=c?{virtualmcpid:l}:{},y=(P,A)=>{s({to:_,params:g(m),search:E=>({...E,...P}),replace:A?.replace??!1})},v=(P,A)=>{s({to:_,params:g(P),search:E=>{const j={};return A?j.virtualmcpid=A:c&&(j.virtualmcpid=l),j}})},b=()=>{f?y({main:"0"},{replace:!0}):y({main:sn(t)},{replace:!0})},C=()=>{y({chat:u?0:1},{replace:!0})},S=()=>{u||y({chat:1},{replace:!0})},k=async()=>{const P=crypto.randomUUID(),A=Ld(h,a,m);try{await o({id:P,virtual_mcp_id:l,...A?{branch:A}:{}})}catch{}s({to:_,params:g(P),search:E=>({...x,chat:1})})},N=P=>{y({main:P},{replace:!0})};return{taskId:m,mainOpen:f,chatOpen:u,mainParam:i.main,setTaskId:v,toggleMain:b,toggleChat:C,openChat:S,createNewTask:k,openTab:N}}const lo=45;function ec(t,e=lo){const s=typeof t=="number"?t:Number(t);return!Number.isFinite(s)||s<=0||s>=100?e:s}function Lf(t){return ec(t,lo)}function Of(){const t=U.c(6);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=rd.decoChatPanelWidth(),t[0]=e):e=t[0];const[s,i]=id(e,Lf);let r;t[1]!==s?(r=ec(s,lo),t[1]=s,t[2]=r):r=t[2];const o=r;let a;return t[3]!==i||t[4]!==o?(a=[o,i],t[3]=i,t[4]=o,t[5]=a):a=t[5],a}function $f(t){try{return JSON.parse(t)}catch{return null}}function zf(t){if(!t||typeof t!="object")return null;const e=t,s=e.content?.find(o=>o.type==="text")?.text,i=s?$f(s):null,r=e.structuredContent;return r==null?i:typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).length===0?i??r:r}function ps(t){const e=zf(t);return e===null?null:e}function co(t){if(!t)return null;const e=t.match(/\/pull\/(\d+)\b/);if(!e)return null;const s=Number(e[1]);return Number.isFinite(s)&&s>0?s:null}function Ff(t){if(!t||typeof t!="object")return null;const e=t.content?.find(r=>r.type==="text")?.text;if(!e)return null;const s=e.match(/https:\/\/github\.com\/[^\s"]+\/pull\/\d+/)?.[0],i=co(s);return!i||!s?null:{number:i,htmlUrl:s}}function Hf(t){if(!t||typeof t!="object")return null;const e=t;return e.isError?e.content?.find(i=>i.type==="text")?.text?.trim()||"GitHub MCP tool returned an error":null}function ho(t){const e=Hf(t);if(e)throw new Error(e)}function tc(t,e){for(const s of e){const i=t[s];if(typeof i=="string"&&i.length>0)return i}}function sc(t,e){for(const s of e){const i=t[s];if(typeof i=="number"&&Number.isFinite(i)&&i>0)return i;if(typeof i=="string"&&/^\d+$/.test(i)){const r=Number(i);if(r>0)return r}}}function Wf(t){const s=t.head?.ref;return typeof s=="string"&&s.length>0?s:null}function Uf(t,e){return Wf(t)===e}function ic(t){const e=ps(t);if(Array.isArray(e))return e.filter(s=>s!=null&&typeof s=="object");if(e&&typeof e=="object"){const s=e;for(const i of["pull_requests","items","data"]){const r=s[i];if(Array.isArray(r))return r.filter(o=>o!=null&&typeof o=="object")}}return[]}function Kf(t){const e=tc(t,["html_url","htmlUrl","url","URL"]),s=sc(t,["number","pullNumber"])??co(e);return!s||!e?null:{number:s,htmlUrl:e}}function Vf(t){ho(t);const e=Ff(t);if(e)return e;const s=ps(t);if(s&&typeof s=="object"){const i=tc(s,["url","URL","html_url","htmlUrl"]),r=sc(s,["number","pullNumber"])??co(i);if(r&&i)return{number:r,htmlUrl:i}}throw new Error("Failed to open pull request")}function qf(t){return/already exists|pull request already/i.test(t)}async function Gf(t,e){const s=await t.callTool({name:"list_pull_requests",arguments:{owner:e.owner,repo:e.repo,state:"open",...e.head?{head:e.head}:{},perPage:10}});return ho(s),ic(s)}async function ra(t,e){const s=[`${e.owner}:${e.branch}`,e.branch];for(const i of s){const o=(await Gf(t,{owner:e.owner,repo:e.repo,head:i})).find(l=>Uf(l,e.branch)),a=o?Kf(o):null;if(a)return a}return null}async function Yf(t,e){const s=await t.callTool({name:"create_pull_request",arguments:{owner:e.owner,repo:e.repo,title:e.title,body:e.body,head:e.head,base:e.base}});return Vf(s)}async function na(t,e){const s=await ra(t,{owner:e.owner,repo:e.repo,branch:e.branch});if(s)return s;try{return await Yf(t,{owner:e.owner,repo:e.repo,title:e.title,body:e.body,head:e.branch,base:e.base})}catch(i){const r=i instanceof Error?i.message:String(i);if(!qf(r))throw i;const o=await ra(t,{owner:e.owner,repo:e.repo,branch:e.branch});if(o)return o;throw i}}async function rc(t,e){const s=await t.callTool({name:"merge_pull_request",arguments:{owner:e.owner,repo:e.repo,pullNumber:e.pullNumber,merge_method:"squash",...e.commitTitle?{commit_title:e.commitTitle}:{}}});ho(s);const i=ps(s);if(!i||i.merged!==!0)throw new Error(i?.message??"Failed to merge pull request");return{merged:!0,message:i.message??"Pull request merged"}}const uo=6e4,fo=3e4;function mo(t){const e=U.c(15);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const i=Qe(s);let r;e[4]!==t.branch||e[5]!==t.owner?(r=t.branch?{head:`${t.owner}:${t.branch}`}:{},e[4]=t.branch,e[5]=t.owner,e[6]=r):r=e[6];let o;e[7]!==t.owner||e[8]!==t.repo||e[9]!==r?(o={owner:t.owner,repo:t.repo,state:"all",...r,perPage:1},e[7]=t.owner,e[8]=t.repo,e[9]=r,e[10]=o):o=e[10];const a=!!t.branch&&!!t.connectionId&&!!t.owner&&!!t.repo;let l;return e[11]!==i||e[12]!==o||e[13]!==a?(l={client:i,toolName:"list_pull_requests",toolArguments:o,enabled:a,refetchInterval:uo,refetchIntervalInBackground:!1,staleTime:fo,select:Xf},e[11]=i,e[12]=o,e[13]=a,e[14]=l):l=e[14],jr(l)}function Xf(t){const e=ic(t);if(e.length===0)return null;const s=e[0],i=s.base,r=s.head,o=s.user;return{number:s.number??0,title:s.title??"",body:s.body??"",state:s.state==="closed"?"closed":"open",merged:s.merged_at!=null,mergedAt:s.merged_at??null,base:i?.ref??"main",head:r?.ref??"",headSha:r?.sha??"",htmlUrl:s.html_url??"",author:o?.login??""}}function nc(t){const e=U.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const i=Qe(s),r=t.prNumber??0;let o;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(o={method:"get_check_runs",owner:t.owner,repo:t.repo,pullNumber:r},e[4]=t.owner,e[5]=t.repo,e[6]=r,e[7]=o):o=e[7];const a=!!t.prNumber;let l;return e[8]!==i||e[9]!==o||e[10]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:uo,refetchIntervalInBackground:!1,staleTime:fo,select:Jf},e[8]=i,e[9]=o,e[10]=a,e[11]=l):l=e[11],jr(l)}function Jf(t){const e=ps(t);return(Array.isArray(e)?e:e?.check_runs??[]).map(Zf)}function Zf(t){const e=t.started_at,s=t.completed_at,i=e&&s?new Date(s).getTime()-new Date(e).getTime():null;return{id:String(t.id??""),name:String(t.name??""),status:t.status??"completed",conclusion:t.conclusion??null,htmlUrl:String(t.html_url??""),durationMs:i}}function Qf(t){const e=U.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const i=Qe(s),r=t.prNumber??0;let o;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(o={method:"get_comments",owner:t.owner,repo:t.repo,pullNumber:r},e[4]=t.owner,e[5]=t.repo,e[6]=r,e[7]=o):o=e[7];const a=!!t.prNumber;let l;return e[8]!==i||e[9]!==o||e[10]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:uo,refetchIntervalInBackground:!1,staleTime:fo,select:em},e[8]=i,e[9]=o,e[10]=a,e[11]=l):l=e[11],jr(l)}function em(t){const e=ps(t);return Array.isArray(e)?e.map(tm):[]}function tm(t){const e=t.user;return{id:Number(t.id??0),author:e?.login??"",body:String(t.body??""),createdAt:String(t.created_at??""),htmlUrl:String(t.html_url??"")}}function po(t,e){const s=U.c(8),i=t?`${t.orgSlug}/${t.virtualMcpId}/${t.branch}`:"",r=e?.fetchEnabled??!0;let o;s[0]!==i?(o=$t.decofile(i),s[0]=i,s[1]=o):o=s[1];let a;s[2]!==t?(a=async()=>{const c=new URLSearchParams({path:"/.decofile"}),d=await fetch(`/api/${t.orgSlug}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/preview-fetch?${c.toString()}`);if(!d.ok)throw new Error(`Failed to fetch decofile: ${d.status}`);return await d.json()},s[2]=t,s[3]=a):a=s[3];const l=!!t&&r;let h;return s[4]!==o||s[5]!==a||s[6]!==l?(h={queryKey:o,queryFn:a,enabled:l,staleTime:3e4,retry:3,retryDelay:sm},s[4]=o,s[5]=a,s[6]=l,s[7]=h):h=s[7],gi(h)}function sm(t){return Math.min(1e3*2**t,5e3)}function _o(t,e){const s=U.c(8),i=t?`${t.orgSlug}/${t.virtualMcpId}/${t.branch}`:"",r=e?.fetchEnabled??!0;let o;s[0]!==i?(o=$t.liveMeta(i),s[0]=i,s[1]=o):o=s[1];let a;s[2]!==t?(a=async()=>{const c=new URLSearchParams({path:"/live/_meta"}),d=await fetch(`/api/${t.orgSlug}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/preview-fetch?${c.toString()}`);if(!d.ok)throw new Error(`Failed to fetch live meta: ${d.status}`);return await d.json()},s[2]=t,s[3]=a):a=s[3];const l=!!t&&r;let h;return s[4]!==o||s[5]!==a||s[6]!==l?(h={queryKey:o,queryFn:a,enabled:l,staleTime:3e5,retry:3,retryDelay:im},s[4]=o,s[5]=a,s[6]=l,s[7]=h):h=s[7],gi(h)}function im(t){return Math.min(1e3*2**t,5e3)}function rm(t){if(!t.startsWith("#")||!t.includes("@"))return null;const e=t.indexOf("@");return{moduleResolveType:t.slice(1,e),blockId:t.slice(e+1)}}function G0(t){return t.includes("@")}function oa(t){const e=t.lastIndexOf("@");return e<0||e===t.length-1?null:t.slice(e+1)}function Y0(t,e){if(t===e)return!0;const s=oa(t);return s?e===s||oa(e)===s:!1}function oc(t,e){const s=t.manifest?.blocks??{};for(const[i,r]of Object.entries(s))if(e in r)return i;return null}function ac(t,e){const s=oc(t,e);return s!==null&&s.includes("sections")}function nm(t,e){const s=oc(t,e);return s!==null&&s.includes("matchers")}function go(t){return!t.includes("/")}function lc(t){try{return decodeURIComponent(t).startsWith("Preview ")}catch{return t.startsWith("Preview ")}}const om=["website/sections/Rendering/Lazy.tsx","website/sections/Rendering/SingleDeferred.tsx"];function Nr(t){return om.some(e=>t.endsWith(e))}const am="VideoWidget";function lm(t,e){const s=e.schema??{},i=e.manifest?.blocks??{};let r={};for(const f of Object.values(i))if(f[t]){r=f[t];break}const o={...s,...r},a=o.$defs??o.definitions??{},l=f=>{const p=f.split("/").pop()??"";return a[p]??{}},h=(f,p=new Set,m=0)=>{if(m>5)return{};if(typeof f.$ref=="string"){const g=f.$ref.split("/").pop()??"";return p.has(g)?{}:h(l(f.$ref),new Set([...p,g]),m+1)}let _={};if(f.properties&&typeof f.properties=="object"&&(_={..._,...f.properties}),Array.isArray(f.required)){const g=Array.isArray(_.__required)?_.__required:[];_.__required=[...g,...f.required]}for(const g of["allOf","anyOf","oneOf"]){const x=f[g];if(Array.isArray(x))for(const y of x)_={..._,...h(y,p,m+1)}}return _},c=(f,p=0)=>{let m=f;typeof f.$ref=="string"&&(m=l(f.$ref),(f.$ref.split("/").pop()??"")===am&&!m.format&&(m={...m,format:"video-uri"}));let _;{const S=m.anyOf??m.oneOf;if(Array.isArray(S)){const k=S.filter(P=>!(P.type==="null"||P.type===null)),N=P=>{if(typeof P.const=="string"||typeof P.const=="number")return P.const;if(Array.isArray(P.enum)&&P.enum.length===1&&(typeof P.enum[0]=="string"||typeof P.enum[0]=="number"))return P.enum[0]};k.length>0&&k.every(P=>N(P)!==void 0)&&(_=k.map(P=>N(P)))}}let g,x;if(m.type)g=Array.isArray(m.type)?String(m.type.find(S=>S!=="null")??m.type[0]):String(m.type);else if(m.anyOf||m.allOf||m.oneOf){const k=(m.anyOf??m.allOf??m.oneOf).filter(N=>!(N.type==="null"||N.type===null));if(k.length===0)g="null";else if(k.length===1){const N=k[0];x=N,g=N.type?Array.isArray(N.type)?String(N.type[0]):String(N.type):typeof N.$ref=="string"?"object":"string"}else{if(_)return{type:"string",title:typeof m.title=="string"?m.title:void 0,description:typeof m.description=="string"?m.description:void 0,enum:_};const N=k.filter(A=>{const E=A.properties?.__resolveType?.enum;return Array.isArray(E)&&typeof E[0]=="string"});if(N.length>0){const A=N.map(E=>{const w=E.properties?.__resolveType?.enum??[],T=String(w[0]);return{resolveType:T,title:typeof E.title=="string"?E.title:T.split("/").pop()?.replace(/\.tsx?$/,"").replace(/[-_]/g," ")??T,description:typeof E.description=="string"?E.description:void 0,schema:p+1<6?c(E,p+1):void 0}});return{type:"block-ref",title:typeof m.title=="string"?m.title:void 0,description:typeof m.description=="string"?m.description:void 0,anyOfRefs:A}}if(k.every(A=>typeof A.$ref=="string")){const A=[];for(const E of k){const j=l(E.$ref);let w,T;if(typeof j.title=="string"){const D=rm(j.title);D&&(w=D.blockId,T=D.blockId)}if(!w&&Array.isArray(j.allOf))for(const D of j.allOf){const B=((D.properties??{}).__resolveType??{}).enum;if(Array.isArray(B)&&typeof B[0]=="string"){w=B[0];break}}w||(w=E.$ref.split("/").pop()??""),A.push({resolveType:w,title:T??(typeof j.title=="string"&&!j.title.startsWith("#")?j.title:w.split("/").pop()?.replace(/\.tsx?$/,"").replace(/[-_]/g," ")??w),description:typeof j.description=="string"?j.description:void 0,schema:p+1<6?c(j,p+1):void 0})}return{type:"block-ref",title:typeof m.title=="string"?m.title:void 0,description:typeof m.description=="string"?m.description:void 0,anyOfRefs:A}}g="object"}}else typeof f.$ref=="string"&&(g="object");let y;if(p<6){const S=h(m),k=Object.entries(S).filter(([N])=>!N.startsWith("__")&&N!=="@type");if(k.length>0){y={};for(const[N,P]of k)y[N]=c(P,p+1)}}let v;if((g==="array"||m.type==="array")&&p<6){let S=m.items;S&&(typeof S.$ref=="string"&&(S=l(S.$ref)),v=c(S,p+1))}const b=S=>{const k=x?.[S];return typeof k=="string"?k:void 0},C=()=>{if("default"in f)return f.default;if("default"in m)return m.default;if(x&&"default"in x)return x.default};return{type:g??"string",title:typeof f.title=="string"?f.title:typeof m.title=="string"?m.title:b("title"),description:typeof f.description=="string"?f.description:typeof m.description=="string"?m.description:b("description"),default:C(),enum:Array.isArray(m.enum)?m.enum:_??void 0,format:typeof m.format=="string"?m.format:b("format"),properties:y,items:v,titleBy:typeof m.titleBy=="string"?m.titleBy:b("titleBy")}},d=h(o),u={};for(const[f,p]of Object.entries(d))f.startsWith("__")||f==="@type"||(u[f]=c(p,0));return Object.keys(u).length===0?null:{type:"object",title:typeof o.title=="string"?o.title:void 0,properties:u}}function cc(t,e){const s=e.schema??{},i=e.manifest?.blocks??{};let r={};for(const c of Object.values(i))if(c[t]){r=c[t];break}const o={...s,...r},a=o.$defs??o.definitions??{},l=typeof r.$ref=="string"?a[r.$ref.split("/").pop()??""]??{}:{...s,...r},h=l.icon;return{title:typeof l.title=="string"?l.title:void 0,description:typeof l.description=="string"?l.description:void 0,icon:typeof h=="string"?h:void 0}}const X0="oklch(0.7278 0.151 289)",cm="website/matchers/always.ts",hc="website/matchers/never.ts",hm="website/flags/multivariate.ts",dm="website/flags/multivariate/section.ts";function dc(t){const e=t.split("/");return(e[e.length-1]??t).replace(/\.(tsx?|jsx?)$/,"").replace(/[-_]/g," ").replace(/\b\w/g,i=>i.toUpperCase())||t}function J0(t){return t.map(e=>`${e.resolveType}|${e.label}|${e.isHidden??!1}|${e.isSavedBlock??!1}|${e.isMultivariate??!1}|${e.isLazy??!1}`).join(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/sections-editor-Bp1g_Th1.js","assets/index-Cs5omeVE.js","assets/index-hSraEkDp.css","assets/ChevronDown-q7NXC8oS.js","assets/ChevronRight-yHn1hA3x.js","assets/ChevronUp-CiSterYY.js","assets/agent-icon-DT3ZoY-y.js","assets/AlertCircle-Bo6MFMMw.js","assets/Tool01-DStl8lGo.js","assets/SwitchHorizontal01-pH6QzahZ.js","assets/RefreshCcw01-Bx4SkeQv.js","assets/XCircle-BwGxaBHh.js","assets/ArrowUpRight-D7W9dtLf.js","assets/ZapSquare-np0irmyV.js","assets/Users03-2JRHHWqe.js","assets/CheckCircle-heTl0Q7J.js","assets/Check-DsBt8230.js","assets/DotsVertical-CxmWEaUl.js","assets/Container-C4LtPvmX.js","assets/FilterLines-Dyrx730Z.js","assets/Star01-P1tpcoSt.js","assets/Palette-BJK7Nr_A.js","assets/HardDrive-DlDHgSKt.js","assets/Stars02-Dsvvd6bB.js","assets/Key01-DzKsSdjW.js","assets/sheet-DOxYYF3-.js","assets/X-DIKroc0l.js","assets/LinkExternal01-CN7C4GHX.js","assets/Lock01-DrM2m3H0.js","assets/Monitor01-Plu6mY2H.js","assets/Sun-BYzPnNgD.js","assets/Play-CPHeOS8L.js","assets/Plus-setppUqq.js","assets/SearchMd-DKHRS8yM.js","assets/Settings02-oLvqwjU6.js","assets/Shield01-CVCTl65y.js","assets/Trash01-C9zdKIsH.js","assets/Upload01-DLpQCuCd.js","assets/User01-D4cPfrTO.js","assets/Users01-BEpGduG7.js","assets/XClose-BjWASWLP.js","assets/Zap-DAtTr2jR.js","assets/scroll-area-BM2aIJJh.js","assets/select-CSx5oTIm.js","assets/tooltip-Dz9_RSi2.js","assets/dialog-eNu7H7jc.js","assets/input-2Ja0Quq5.js","assets/dropdown-menu-fXlTzmNU.js","assets/sortable.esm-7XhFMdfQ.js","assets/connection-slug-eyAPH6o3.js","assets/connection-card-CTv50-CY.js","assets/use-registry-connections-lhXgVjMB.js","assets/use-connection-DtpbuTez.js","assets/use-collections-DpgbKBvR.js","assets/constants-CZi8C3bA.js","assets/use-organization-settings-Dgou9A6E.js","assets/useInfiniteQuery-CbbLjGWu.js","assets/infiniteQueryObserver-CR26fc83.js","assets/extract-connection-data-Bw-Ess_C.js","assets/generate-id-mUrGpM4H.js","assets/collections-npJcts45.js","assets/card-CK95IO0o.js","assets/integration-icon-DCANFR5a.js","assets/collection-search-pwCSfkZ7.js","assets/collection-tabs-7Dpb1qzn.js","assets/badge-CNO8XMju.js","assets/drawer-DvmyIDeU.js","assets/form-D8mdpf2K.js","assets/label-C7mnelNh.js","assets/textarea-CSbVTEEY.js","assets/connection-form-helpers-C7qYX7aE.js","assets/use-infinite-scroll-CJnFgFzZ.js","assets/useSuspenseInfiniteQuery-ClweRri8.js","assets/calendar-Cl37gYVl.js","assets/popover-DYOGeANv.js","assets/switch--jK3vdKJ.js","assets/skeleton-B_h_pcsL.js","assets/tabs-Dy86WHxW.js","assets/use-file-configs-Mqa8r6Zg.js","assets/unwrap-tool-result-BYXdCQMg.js","assets/command-B4WwdpO7.js","assets/index-BoLgVOc1.js","assets/add-section-modal-Y_M0BfWb.js","assets/index-Cx_QwEcD.js","assets/pair-BQ0aeenr.js","assets/format-time-Cy7tTmZp.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/use-copy-9ghZL9py.js","assets/content-blocks-o63cs2vh.js","assets/types-BlBflSPa.js","assets/chat-context-C0VPAUT2.js","assets/tab-id-CxWhjxZl.js","assets/decopilot-sse-pool-CzvHS6-_.js","assets/create-sse-subscription--G7iwTWC.js","assets/use-virtual-mcp-C0KsF-WK.js","assets/use-ai-providers-CTGXqYwh.js","assets/shell-layout-BRzFt9Zs.js","assets/avatar-BN_Lyxjy.js","assets/required-auth-layout-R47BsBA_.js","assets/useRouterState-6imMbaA1.js","assets/use-org-sso-BcJLSXFo.js","assets/use-navigate-to-agent-CarVjaJw.js","assets/use-mcp-prompts-DKuMg-2v.js","assets/spinner-DUYMiFOi.js","assets/toggle-group-Dvujl286.js","assets/agent-icons-CjWyJXBH.js","assets/checkbox-DD2y-n33.js","assets/ai-providers-logos-DD3qZ33J.js","assets/settings-section-CFchXVO0.js","assets/connect-desktop-dialog-h61VXfJ_.js","assets/index-CKzWikoe.js","assets/question-004-sINsf4GQ.js","assets/index-B9apEqwQ.js","assets/sidebar-fzaBba7f.js","assets/toolbar-BRkgMBYy.js","assets/use-create-virtual-mcp-CHit5s3y.js","assets/github-repo-picker-C9kA0buK.js","assets/use-mcp-tools-DbnEsq34.js","assets/alert-dialog-BrK4aQRQ.js","assets/index-Brfgp1e5.js","assets/use-org-auth-client-DZnvifNI.js","assets/hover-card-79cYMq8Q.js","assets/task-status-D0oKidhL.js","assets/use-status-sounds-CIo24PDd.js","assets/empty-state-QoHz8nSf.js","assets/accordion-CfhmoYKb.js","assets/user-CYqMZwFh.js","assets/tools-list-BSwYNTcR.js","assets/use-debounced-autosave-B14ZwsSc.js","assets/index-C8L9Z3Xj.js","assets/use-secrets-BZehQnHk.js","assets/formatDistanceToNow-Cb2QZZJn.js","assets/monaco-editor-BRxdxZW6.js","assets/view-mode-toggle-BrXLoe9l.js","assets/automation-list-row-D7yrZia_.js","assets/search-input-B3L_NuKn.js","assets/file-explorer-CsyafORl.js","assets/project-app-view-B77cUBzb.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{e as U,r as M,c as re,j as n,l as ge,q as ke,b as Es,E as Mt,f as Zt,d as Vn,g as El,p as id,L as rd,n as gi,K as $t,s as nd,o as ae,B as te,v as Tl,V as od,t as Pe,w as Rl,x as ad,y as gr,z as ci,C as ct,D as vr,F as Pl,G as ld,H as cd,I as Vo,J as hd,a as xr,M as Fi,P as Zs,Q as vt,_ as vi,R as hi,T as dd,U as ud}from"./index-Cs5omeVE.js";import{C as Ae,a as fd,u as md,w as pd,b as qn,s as Hi,T as _d,t as gd,r as vd,c as xd,d as bd,g as yd,e as Sd}from"./index-Cx_QwEcD.js";import{g as Gn,u as Qe,S as hs,a as Dl}from"./constants-CZi8C3bA.js";import{u as bt,a as wd,b as Cd}from"./use-virtual-mcp-C0KsF-WK.js";import{u as ds,a as Qt,b as br,c as kd,d as xi,h as jd,g as Ts,e as Al,t as Nd,f as qo,i as Ed}from"./chat-context-C0VPAUT2.js";import{i as bi}from"./AlertCircle-Bo6MFMMw.js";import{i as Td}from"./CheckCircle-heTl0Q7J.js";import{n as Go}from"./ZapSquare-np0irmyV.js";import{i as Rd,a as Yn,b as Pd}from"./XCircle-BwGxaBHh.js";import{s as ks}from"./XClose-BjWASWLP.js";import{c as Dd,t as Yo,M as Xn,G as Ad}from"./pair-BQ0aeenr.js";import{I as us}from"./integration-icon-DCANFR5a.js";import{a as Md}from"./Users03-2JRHHWqe.js";import{u as Bd}from"./use-ai-providers-CTGXqYwh.js";import{u as Id}from"./connect-desktop-dialog-h61VXfJ_.js";import{r as Ld,u as Jn,i as Od}from"./shell-layout-BRzFt9Zs.js";import{a as $d}from"./index-B9apEqwQ.js";import{u as zd}from"./sidebar-fzaBba7f.js";import{i as Fd,S as Hd,a as Wd,b as Ud}from"./sheet-DOxYYF3-.js";import{u as Ml,T as Se,a as we,b as Ce,c as Bl}from"./tooltip-Dz9_RSi2.js";import{i as Zn,a as yr,b as Kd,c as Vd,p as Sr,g as wr,d as Qn,e as Il,h as tn,f as Ir,j as Xo,A as Jo,k as qd,l as Gd,n as Yd,m as Xd,o as Jd,t as Zd,q as Qd,r as eu,s as Cr,u as tu,v as su,w as Ll,x as iu,y as Zo,z as ru,B as nu,C as eo,D as ou,E as ri,F as Ol,G as $l,H as au}from"./agent-icon-DT3ZoY-y.js";import{u as lu}from"./use-status-sounds-CIo24PDd.js";import{E as Zi}from"./empty-state-QoHz8nSf.js";import{u as cu,r as sn,a as hu,p as zl,f as Qo,b as Fl,c as du,F as uu,i as fu,d as mu,e as pu,g as _u,h as gu}from"./tab-id-CxWhjxZl.js";import{T as ea,a as rn}from"./toolbar-BRkgMBYy.js";import{A as vu,a as xu,b as bu,c as yu,R as Hl,d as Su,e as wu}from"./accordion-CfhmoYKb.js";import{u as kr,a as to,b as Cu}from"./use-connection-DtpbuTez.js";import{u as jr,a as ku}from"./use-mcp-tools-DbnEsq34.js";import{g as ju}from"./generate-id-mUrGpM4H.js";import{u as Nu,g as Eu}from"./types-BlBflSPa.js";import{U as Wl}from"./user-CYqMZwFh.js";import{T as Tu,u as Ul}from"./tools-list-BSwYNTcR.js";import{u as Ru}from"./unwrap-tool-result-BYXdCQMg.js";import{s as Kl,g as Pu}from"./connection-slug-eyAPH6o3.js";import{A as Qi,a as er,b as tr,c as sr,d as ir,e as rr,f as nr,g as or}from"./alert-dialog-BrK4aQRQ.js";import{D as Rs,a as Ft,b as Ht,c as fs,d as ms,e as so}from"./dialog-eNu7H7jc.js";import{C as Vl,a as nn}from"./card-CK95IO0o.js";import{I as Ge}from"./input-2Ja0Quq5.js";import{L as _t}from"./label-C7mnelNh.js";import{S as Bt,a as It,b as Lt,c as Ot,d as dt}from"./select-CSx5oTIm.js";import{S as on}from"./switch--jK3vdKJ.js";import{T as ar}from"./textarea-CSbVTEEY.js";import{i as js}from"./Play-CPHeOS8L.js";import{s as zt}from"./Plus-setppUqq.js";import{a as Du}from"./Settings02-oLvqwjU6.js";import{t as io,i as ql}from"./Tool01-DStl8lGo.js";import{s as di}from"./Trash01-C9zdKIsH.js";import{u as lr}from"./use-debounced-autosave-B14ZwsSc.js";import{P as yi,a as Si,b as wi}from"./popover-DYOGeANv.js";import{S as ro}from"./scroll-area-BM2aIJJh.js";import{i as Gl}from"./SearchMd-DKHRS8yM.js";import{i as Au}from"./Upload01-DLpQCuCd.js";import{P as xt}from"./index-C8L9Z3Xj.js";import{A as Mu}from"./sortable.esm-7XhFMdfQ.js";import{C as Bu}from"./collection-tabs-7Dpb1qzn.js";import{C as Yl}from"./checkbox-DD2y-n33.js";import{u as Iu}from"./use-mcp-prompts-DKuMg-2v.js";import{D as Lu,a as Ou,b as $u}from"./drawer-DvmyIDeU.js";import{i as Ci}from"./Check-DsBt8230.js";import{a as Xt,i as zu,s as Fu}from"./RefreshCcw01-Bx4SkeQv.js";import{i as Xl}from"./Key01-DzKsSdjW.js";import{S as ys}from"./skeleton-B_h_pcsL.js";import{i as Hu}from"./Lock01-DrM2m3H0.js";import{s as Wu}from"./User01-D4cPfrTO.js";import{t as Uu}from"./Users01-BEpGduG7.js";import{u as Ku,a as Vu}from"./use-secrets-BZehQnHk.js";import{G as qu}from"./github-repo-picker-C9kA0buK.js";import{f as Gu}from"./formatDistanceToNow-Cb2QZZJn.js";import{n as Ps}from"./LinkExternal01-CN7C4GHX.js";import{T as ns,a as no,b as ni,c as oo}from"./tabs-Dy86WHxW.js";import{l as Yu,w as Xu,M as Ju}from"./monaco-editor-BRxdxZW6.js";import{D as Ds,a as As,b as Ms,c as ht,d as ta,e as Zu,f as Qu,g as ef}from"./dropdown-menu-fXlTzmNU.js";import{i as tf}from"./ChevronRight-yHn1hA3x.js";import{S as Jl}from"./spinner-DUYMiFOi.js";import{t as ao}from"./ChevronDown-q7NXC8oS.js";import{s as cr}from"./Star01-P1tpcoSt.js";import{i as Zl}from"./Stars02-Dsvvd6bB.js";import{V as sf}from"./view-mode-toggle-BrXLoe9l.js";import{i as rf}from"./X-DIKroc0l.js";import{u as ki,a as nf,b as of,c as af,A as lf,d as cf}from"./automation-list-row-D7yrZia_.js";import{i as hf}from"./SwitchHorizontal01-pH6QzahZ.js";import{i as ui}from"./Zap-DAtTr2jR.js";import{S as df}from"./search-input-B3L_NuKn.js";function Ws(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function sa(t){if(!t)return"—";const e=typeof t=="string"?new Date(t):t;return isNaN(e.getTime())?"—":e.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function uf(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function ff(t){const e=U.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(mf),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=n.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-6",children:i}),e[2]=i,e[3]=r):r=e[3],r}function mf(t){return n.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[n.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),n.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function pf(t){const e=U.c(30),{userTokens:s,assistantTokens:i,otherTokens:r}=t,o=s+i+r,a=o>0?s/o*100:0,l=o>0?i/o*100:0,h=o>0?r/o*100:0;let c;e[0]!==a?(c=a>0&&n.jsx("div",{className:"h-full bg-chart-1",style:{width:`${a}%`}}),e[0]=a,e[1]=c):c=e[1];let d;e[2]!==l?(d=l>0&&n.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=d):d=e[3];let u;e[4]!==h?(u=h>0&&n.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${h}%`}}),e[4]=h,e[5]=u):u=e[5];let f;e[6]!==c||e[7]!==d||e[8]!==u?(f=n.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[c,d,u]}),e[6]=c,e[7]=d,e[8]=u,e[9]=f):f=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=p):p=e[10];let m;e[11]!==a?(m=a.toFixed(1),e[11]=a,e[12]=m):m=e[12];let _;e[13]!==m?(_=n.jsxs("div",{className:"flex items-center gap-1.5",children:[p,n.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",m,"%"]})]}),e[13]=m,e[14]=_):_=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=g):g=e[15];let x;e[16]!==l?(x=l.toFixed(1),e[16]=l,e[17]=x):x=e[17];let y;e[18]!==x?(y=n.jsxs("div",{className:"flex items-center gap-1.5",children:[g,n.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",x,"%"]})]}),e[18]=x,e[19]=y):y=e[19];let v;e[20]!==h||e[21]!==r?(v=r>0&&n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),n.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",h.toFixed(1),"%"]})]}),e[20]=h,e[21]=r,e[22]=v):v=e[22];let b;e[23]!==y||e[24]!==v||e[25]!==_?(b=n.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[_,y,v]}),e[23]=y,e[24]=v,e[25]=_,e[26]=b):b=e[26];let C;return e[27]!==b||e[28]!==f?(C=n.jsxs("div",{className:"flex flex-col gap-2",children:[f,b]}),e[27]=b,e[28]=f,e[29]=C):C=e[29],C}function _f(t){const e=U.c(11),{agentId:s,isError:i}=t,r=bt(s),o=r?.title??"Subtask",a=r?.icon??null;let l;e[0]!==a||e[1]!==o?(l=n.jsx(us,{icon:a,name:o,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=o,e[2]=l):l=e[2];const h=i?"text-destructive":"text-foreground";let c;e[3]!==h?(c=re("shrink-0 font-medium",h),e[3]=h,e[4]=c):c=e[4];let d;e[5]!==o||e[6]!==c?(d=n.jsx("span",{className:c,children:o}),e[5]=o,e[6]=c,e[7]=d):d=e[7];let u;return e[8]!==l||e[9]!==d?(u=n.jsxs(n.Fragment,{children:[l,d]}),e[8]=l,e[9]=d,e[10]=u):u=e[10],u}function gf(t){const e=U.c(5),{isError:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(us,{icon:null,name:"Subtask",size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=i):i=e[0];const r=s?"text-destructive":"text-foreground";let o;e[1]!==r?(o=re("shrink-0 font-medium",r),e[1]=r,e[2]=o):o=e[2];let a;return e[3]!==o?(a=n.jsxs(n.Fragment,{children:[i,n.jsx("span",{className:o,children:"Subtask"})]}),e[3]=o,e[4]=a):a=e[4],a}function vf(t){const e=U.c(18),{part:s}=t,i=s.input?.agent_id,r=s.state==="input-streaming"||s.state==="input-available"||s.state==="output-available"&&s.preliminary===!0,o=s.state==="output-error",a=s.state==="approval-requested";let l;e[0]!==o?(l=n.jsx(gf,{isError:o}),e[0]=o,e[1]=l):l=e[1];let h;e[2]!==i||e[3]!==o?(h=n.jsx(_f,{agentId:i,isError:o}),e[2]=i,e[3]=o,e[4]=h):h=e[4];let c;e[5]!==l||e[6]!==h?(c=n.jsx(M.Suspense,{fallback:l,children:h}),e[5]=l,e[6]=h,e[7]=c):c=e[7];let d;e[8]!==s.input?(d=s.input?.prompt&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-muted-foreground/50",children:"·"}),n.jsx("span",{className:"truncate text-muted-foreground",children:s.input.prompt})]}),e[8]=s.input,e[9]=d):d=e[9];let u;e[10]!==a||e[11]!==o||e[12]!==r?(u=n.jsx("span",{className:"ml-auto shrink-0",children:r?n.jsx(ge,{size:12,className:"animate-spin text-muted-foreground"}):o?n.jsx(Rd,{size:12,className:"text-destructive"}):a?n.jsx(bi,{size:12,className:"text-warning"}):n.jsx(Td,{size:12,className:"text-emerald-500"})}),e[10]=a,e[11]=o,e[12]=r,e[13]=u):u=e[13];let f;return e[14]!==c||e[15]!==d||e[16]!==u?(f=n.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[c,d,u]}),e[14]=c,e[15]=d,e[16]=u,e[17]=f):f=e[17],f}function xf(t){const e=U.c(55),{onClose:s,back:i,className:r}=t,[o,a]=M.useState(null),{messages:l}=ds(),{activeTask:h}=Qt(),{selectedModel:c,selectedVirtualMcp:d}=br();let u,f,p,m,_,g,x,y;if(e[0]!==h||e[1]!==i||e[2]!==r||e[3]!==l||e[4]!==s||e[5]!==o?.id||e[6]!==c||e[7]!==d?.title){y=Symbol.for("react.early_return_sentinel");e:{const C=Dd(l),S=[...l].reverse().find(Rf),k=S?.metadata?.usage,N=S?.metadata?.modelLimits?.contextWindow??c?.limits?.contextWindow??null,P=k?.contextTokens??0,A=N&&N>0?(P/N*100).toFixed(1):null,E=l;let j;e[16]!==E?(j=E.filter(Tf).reduce(Ef,0),e[16]=E,e[17]=j):j=e[17];const w=j,T=l;let D;e[18]!==T?(D=T.filter(Nf).reduce(jf,0),e[18]=T,e[19]=D):D=e[19];const R=D,I=Math.max(0,C.totalTokens-w-R),B=l[0],H=l.at(-1),W=B?.metadata?.created_at??h?.created_at,z=H?.metadata?.created_at??h?.updated_at,O=l.filter(kf),V=l.flatMap(wf),K=c?.modelId?uf(c.modelId):"—",Q=d?.title??"Decopilot",X=[{label:"Session",value:h?.title??"New chat"},{label:"Messages",value:O.length},{label:"Agent",value:Q},{label:"Model",value:K},{label:"Context Limit",value:N?Ws(N):"—"},{label:"Session Tokens (billed)",value:C.totalTokens>0?Ws(C.totalTokens):"0"},{label:"Usage",value:A!==null?`${A}%`:"—"},{label:"Input Tokens",value:C.inputTokens>0?Ws(C.inputTokens):"0"},{label:"Output Tokens",value:C.outputTokens>0?Ws(C.outputTokens):"0"},{label:"Reasoning Tokens",value:C.reasoningTokens>0?Ws(C.reasoningTokens):"0"},{label:"Cost",value:C.cost>0?`$${C.cost<.001?C.cost.toFixed(6):C.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:sa(W)},{label:"Last Activity",value:sa(z)}];if(!h&&O.length===0){let L;e[20]!==r?(L=re("flex flex-col h-full w-full border-l border-border bg-background",r),e[20]=r,e[21]=L):L=e[21];let J;e[22]===Symbol.for("react.memo_cache_sentinel")?(J=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[22]=J):J=e[22];let Z;e[23]!==i?(Z=i?n.jsx(Go,{size:14,className:"text-muted-foreground"}):n.jsx(ks,{size:14,className:"text-muted-foreground"}),e[23]=i,e[24]=Z):Z=e[24];let F;e[25]!==s||e[26]!==Z?(F=n.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[J,n.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:Z})]}),e[25]=s,e[26]=Z,e[27]=F):F=e[27];let ne;e[28]===Symbol.for("react.memo_cache_sentinel")?(ne=n.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:n.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a conversation to see context"})}),e[28]=ne):ne=e[28];let ie;e[29]!==L||e[30]!==F?(ie=n.jsxs("div",{className:L,children:[F,ne]}),e[29]=L,e[30]=F,e[31]=ie):ie=e[31],y=ie;break e}e[32]!==r?(g=re("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",r),e[32]=r,e[33]=g):g=e[33];let q;e[34]===Symbol.for("react.memo_cache_sentinel")?(q=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[34]=q):q=e[34];let se;e[35]!==i?(se=i?n.jsx(Go,{size:14}):n.jsx(ks,{size:14}),e[35]=i,e[36]=se):se=e[36],e[37]!==s||e[38]!==se?(x=n.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[q,n.jsx("button",{type:"button",onClick:s,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:se})]}),e[37]=s,e[38]=se,e[39]=x):x=e[39],u="flex flex-col gap-8 p-6",f=V.length>0&&n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("span",{className:"text-xs text-muted-foreground",children:"Subtasks"}),n.jsx("div",{className:"flex flex-col gap-1",children:V.map(Sf)})]}),p=n.jsx(ff,{items:X});let $;e[40]===Symbol.for("react.memo_cache_sentinel")?($=n.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[40]=$):$=e[40],e[41]!==R||e[42]!==I||e[43]!==w?(m=n.jsxs("div",{className:"flex flex-col gap-3",children:[$,n.jsx(pf,{userTokens:w,assistantTokens:R,otherTokens:I})]}),e[41]=R,e[42]=I,e[43]=w,e[44]=m):m=e[44],_=O.length>0&&n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("span",{className:"text-xs text-muted-foreground",children:"Raw messages"}),n.jsx("div",{className:"flex flex-col gap-1",children:O.map(L=>{const J=L.metadata?.created_at,Z=o?.id===L.id;return n.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[n.jsxs("button",{type:"button",onClick:()=>a(Z?null:L),className:"flex items-center justify-between gap-2 px-3 py-2 text-xs hover:bg-accent/50 w-full text-left cursor-pointer",children:[n.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[n.jsx("span",{className:re("shrink-0 font-medium",L.role==="user"?"text-chart-1":"text-chart-2"),children:L.role}),n.jsx("span",{className:"text-muted-foreground",children:"•"}),n.jsx("span",{className:"truncate text-muted-foreground font-mono",children:L.id})]}),J&&n.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(J).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),Z&&n.jsxs(n.Fragment,{children:[L.role==="assistant"&&(()=>{const F=L.metadata?._request;if(!F)return null;const ne=F.systemSections??[],ie=Math.max(1,...ne.map(yf)),de=ne.reduce(bf,0);return n.jsxs("div",{className:"border-t border-border/50 px-3 py-2.5 text-xs space-y-2.5",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"font-medium text-foreground",children:"Request"}),n.jsxs("span",{className:"text-muted-foreground tabular-nums",children:[F.activeTools??0," / ",F.tools??0," ","tools active"]})]}),ne.length>0&&n.jsxs("div",{className:"space-y-1.5",children:[n.jsxs("div",{className:"text-muted-foreground",children:["System prompt"," ",n.jsxs("span",{className:"tabular-nums",children:["~",Math.round(de/4).toLocaleString()," ","tok"]})]}),ne.map((ue,_e)=>{const le=ue.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${_e}`,je=ue.chars/ie*100,Ne=Math.round(ue.chars/4);return n.jsxs("div",{className:"space-y-0.5",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("span",{className:"font-mono text-foreground truncate",children:le}),n.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:["~",Ne.toLocaleString()," tok"]})]}),n.jsx("div",{className:"h-1 w-full rounded-full bg-muted overflow-hidden",children:n.jsx("div",{className:"h-full rounded-full bg-chart-3",style:{width:`${je}%`}})})]},_e)})]})]})})(),n.jsx("pre",{className:"text-xs font-mono bg-muted px-3 py-2 overflow-auto whitespace-pre-wrap break-all border-t border-border/50 max-h-64",children:JSON.stringify(L,null,2)})]})]},L.id)})})]})}e[0]=h,e[1]=i,e[2]=r,e[3]=l,e[4]=s,e[5]=o?.id,e[6]=c,e[7]=d?.title,e[8]=u,e[9]=f,e[10]=p,e[11]=m,e[12]=_,e[13]=g,e[14]=x,e[15]=y}else u=e[8],f=e[9],p=e[10],m=e[11],_=e[12],g=e[13],x=e[14],y=e[15];if(y!==Symbol.for("react.early_return_sentinel"))return y;let v;e[45]!==u||e[46]!==f||e[47]!==p||e[48]!==m||e[49]!==_?(v=n.jsxs("div",{className:u,children:[f,p,m,_]}),e[45]=u,e[46]=f,e[47]=p,e[48]=m,e[49]=_,e[50]=v):v=e[50];let b;return e[51]!==g||e[52]!==x||e[53]!==v?(b=n.jsxs("div",{className:g,children:[x,v]}),e[51]=g,e[52]=x,e[53]=v,e[54]=b):b=e[54],b}function bf(t,e){return t+e.chars}function yf(t){return t.chars}function Sf(t,e){return n.jsx(vf,{part:t},e)}function wf(t){return(t.parts??[]).filter(Cf)}function Cf(t){return t.type==="tool-subtask"}function kf(t){return t.role!=="system"}function jf(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function Nf(t){return t.role==="assistant"}function Ef(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function Tf(t){return t.role==="user"}function Rf(t){return t.role==="assistant"&&t.metadata?.usage}function Pf(t){const e=U.c(13),{readOnly:s,identity:i,aboveRow:r,input:o,iceBreakers:a}=t,l=!s&&i?i:null;let h;e[0]!==r||e[1]!==s?(h=!s&&r?n.jsx("div",{"data-chat-above-row":"true",className:"@container/chat-bottom flex justify-start gap-1",children:r}):null,e[0]=r,e[1]=s,e[2]=h):h=e[2];let c;e[3]!==o||e[4]!==h?(c=n.jsxs("div",{className:"flex flex-col gap-2",children:[h,o]}),e[3]=o,e[4]=h,e[5]=c):c=e[5];let d;e[6]!==a||e[7]!==s?(d=!s&&a?n.jsx("div",{className:"w-full",children:a}):null,e[6]=a,e[7]=s,e[8]=d):d=e[8];let u;return e[9]!==l||e[10]!==c||e[11]!==d?(u=n.jsx("div",{"data-chat-centered":"true",className:"h-full w-full flex flex-col items-center justify-center px-4 gap-6",children:n.jsxs("div",{className:"w-full max-w-3xl flex flex-col gap-6",children:[l,c,d]})}),e[9]=l,e[10]=c,e[11]=d,e[12]=u):u=e[12],u}function Df(t){const e=U.c(25),{onOpenContextPanel:s}=t,{org:i}=ke(),{selectedVirtualMcp:r}=br();let o;e[0]!==i.id?(o=Gn(i.id),e[0]=i.id,e[1]=o):o=e[1];const l=r??o,h=bt(l.id),c=kd(),{data:d}=Es.useSession(),u=d?.user?.id,f=c?.activeTask??null,p=!!(u&&f?.created_by&&f.created_by!==u);let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(Md,{size:32}),e[2]=m):m=e[2];let _;e[3]!==l.icon||e[4]!==l.title?(_=n.jsx(us,{icon:l.icon,name:l.title,size:"lg",fallbackIcon:m,className:"size-10 min-w-10 md:size-[60px]! md:min-w-[60px] rounded-xl md:rounded-[18px]!"}),e[3]=l.icon,e[4]=l.title,e[5]=_):_=e[5];let g;e[6]!==l.title?(g=n.jsx("h3",{className:"text-base md:text-xl font-medium text-foreground",children:l.title}),e[6]=l.title,e[7]=g):g=e[7];const x=l.description??"Ask anything about configuring model providers or using MCP Mesh.";let y;e[8]!==x?(y=n.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:x}),e[8]=x,e[9]=y):y=e[9];let v;e[10]!==_||e[11]!==g||e[12]!==y?(v=n.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[_,g,y]}),e[10]=_,e[11]=g,e[12]=y,e[13]=v):v=e[13];const b=c?.currentBranch??null;let C;e[14]!==h||e[15]!==b?(C=n.jsx(fd,{virtualMcp:h,currentBranch:b}),e[14]=h,e[15]=b,e[16]=C):C=e[16];let S;e[17]!==s?(S=n.jsx(Ae.Input,{onOpenContextPanel:s}),e[17]=s,e[18]=S):S=e[18];let k;e[19]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(Ae.IceBreakers,{}),e[19]=k):k=e[19];let N;return e[20]!==p||e[21]!==S||e[22]!==v||e[23]!==C?(N=n.jsx(Pf,{readOnly:p,identity:v,aboveRow:C,input:S,iceBreakers:k}),e[20]=p,e[21]=S,e[22]=v,e[23]=C,e[24]=N):N=e[24],N}function Af(){const t=U.c(28),{org:e}=ke(),s=Bd(),{isChatEmpty:i}=ds(),[r,o]=M.useState("chat"),a=md(),{selectedVirtualMcp:l}=br();let h;t[0]!==e.id?(h=Gn(e.id),t[0]=e.id,t[1]=h):h=t[1];const u=bt((l??h).id),f=Id(),p=xi(u?.metadata);if(s.length===0&&!(p&&jd(f))){let E;return t[2]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx(Ae,{className:"animate-in fade-in-0 duration-200",children:n.jsx(Ae.Main,{className:"flex flex-col items-center",children:n.jsx(Ae.EmptyState,{children:n.jsx(Ae.NoAiProviderEmptyState,{})})})}),t[2]=E):E=t[2],E}let _;t[3]!==a.hasDecoKey||t[4]!==a.hasOnlyDecoProvider||t[5]!==a.isLoading||t[6]!==a.isZeroBalance||t[7]!==i||t[8]!==e.id?(_=a.hasDecoKey&&a.isZeroBalance&&a.hasOnlyDecoProvider&&!a.isLoading&&i&&!pd(e.id),t[3]=a.hasDecoKey,t[4]=a.hasOnlyDecoProvider,t[5]=a.isLoading,t[6]=a.isZeroBalance,t[7]=i,t[8]=e.id,t[9]=_):_=t[9];const g=_;let x;t[10]!==g?(x=g&&n.jsx(Ae.CreditsEmptyState,{}),t[10]=g,t[11]=x):x=t[11];const y=r!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let v;t[12]!==y?(v=re("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",y),t[12]=y,t[13]=v):v=t[13];let b;t[14]!==i?(b=i?n.jsx(Ae.Main,{children:n.jsx(Df,{onOpenContextPanel:()=>o("context")})}):n.jsxs(n.Fragment,{children:[n.jsx(Ae.Main,{children:n.jsx(Ae.Messages,{})}),n.jsx(Ae.Footer,{children:n.jsx(Ae.Input,{onOpenContextPanel:()=>o("context")})})]}),t[14]=i,t[15]=b):b=t[15];let C;t[16]!==v||t[17]!==b?(C=n.jsx("div",{className:v,children:b}),t[16]=v,t[17]=b,t[18]=C):C=t[18];const S=r==="context"?"opacity-100":"opacity-0 pointer-events-none";let k;t[19]!==S?(k=re("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",S),t[19]=S,t[20]=k):k=t[20];let N;t[21]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx(xf,{back:!0,onClose:()=>o("chat")}),t[21]=N):N=t[21];let P;t[22]!==k?(P=n.jsx("div",{className:k,children:N}),t[22]=k,t[23]=P):P=t[23];let A;return t[24]!==P||t[25]!==x||t[26]!==C?(A=n.jsxs(Ae,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[x,C,P]}),t[24]=P,t[25]=x,t[26]=C,t[27]=A):A=t[27],A}function Ql(){const t=U.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(Ae.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(Mt,{fallback:e,children:n.jsx(M.Suspense,{fallback:n.jsx(Ae.Skeleton,{}),children:n.jsx(Af,{})})}),t[1]=s):s=t[1],s}function Mf(t){const e=t.entityMetadata?.defaultMainView??null,s=e==null||e.type==="chat",i=t.mainParamPresent?t.mainParamValue!=="0":!s,r=s?!0:t.entityMetadata?.chatDefaultOpen??!1;return{mainOpen:i,chatOpen:r}}function ia(t,e){return t&&e?{chat:45,main:55}:t&&!e?{chat:100,main:0}:!t&&e?{chat:0,main:100}:{chat:0,main:0}}function Bf(t,e){return t===1?!0:t===0?!1:e}function If(t,e){const s=Zt(),i=Vn({strict:!1}),r=El({strict:!1}),{create:o}=cu(),{locator:a}=ke(),{virtualMcpId:l,orgSlug:h,isAgentRoute:c}=e,d=Mf({entityMetadata:t,mainParamPresent:i.main!==void 0,mainParamValue:i.main}),u=Bf(i.chat,d.chatOpen),f=d.mainOpen,p=M.useRef(crypto.randomUUID()),m=r.taskId??p.current,_="/$org/$taskId",g=P=>({org:h,taskId:P}),x=c?{virtualmcpid:l}:{},y=(P,A)=>{s({to:_,params:g(m),search:E=>({...E,...P}),replace:A?.replace??!1})},v=(P,A)=>{s({to:_,params:g(P),search:E=>{const j={};return A?j.virtualmcpid=A:c&&(j.virtualmcpid=l),j}})},b=()=>{f?y({main:"0"},{replace:!0}):y({main:sn(t)},{replace:!0})},C=()=>{y({chat:u?0:1},{replace:!0})},S=()=>{u||y({chat:1},{replace:!0})},k=async()=>{const P=crypto.randomUUID(),A=Ld(h,a,m);try{await o({id:P,virtual_mcp_id:l,...A?{branch:A}:{}})}catch{}s({to:_,params:g(P),search:E=>({...x,chat:1})})},N=P=>{y({main:P},{replace:!0})};return{taskId:m,mainOpen:f,chatOpen:u,mainParam:i.main,setTaskId:v,toggleMain:b,toggleChat:C,openChat:S,createNewTask:k,openTab:N}}const lo=45;function ec(t,e=lo){const s=typeof t=="number"?t:Number(t);return!Number.isFinite(s)||s<=0||s>=100?e:s}function Lf(t){return ec(t,lo)}function Of(){const t=U.c(6);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=rd.decoChatPanelWidth(),t[0]=e):e=t[0];const[s,i]=id(e,Lf);let r;t[1]!==s?(r=ec(s,lo),t[1]=s,t[2]=r):r=t[2];const o=r;let a;return t[3]!==i||t[4]!==o?(a=[o,i],t[3]=i,t[4]=o,t[5]=a):a=t[5],a}function $f(t){try{return JSON.parse(t)}catch{return null}}function zf(t){if(!t||typeof t!="object")return null;const e=t,s=e.content?.find(o=>o.type==="text")?.text,i=s?$f(s):null,r=e.structuredContent;return r==null?i:typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).length===0?i??r:r}function ps(t){const e=zf(t);return e===null?null:e}function co(t){if(!t)return null;const e=t.match(/\/pull\/(\d+)\b/);if(!e)return null;const s=Number(e[1]);return Number.isFinite(s)&&s>0?s:null}function Ff(t){if(!t||typeof t!="object")return null;const e=t.content?.find(r=>r.type==="text")?.text;if(!e)return null;const s=e.match(/https:\/\/github\.com\/[^\s"]+\/pull\/\d+/)?.[0],i=co(s);return!i||!s?null:{number:i,htmlUrl:s}}function Hf(t){if(!t||typeof t!="object")return null;const e=t;return e.isError?e.content?.find(i=>i.type==="text")?.text?.trim()||"GitHub MCP tool returned an error":null}function ho(t){const e=Hf(t);if(e)throw new Error(e)}function tc(t,e){for(const s of e){const i=t[s];if(typeof i=="string"&&i.length>0)return i}}function sc(t,e){for(const s of e){const i=t[s];if(typeof i=="number"&&Number.isFinite(i)&&i>0)return i;if(typeof i=="string"&&/^\d+$/.test(i)){const r=Number(i);if(r>0)return r}}}function Wf(t){const s=t.head?.ref;return typeof s=="string"&&s.length>0?s:null}function Uf(t,e){return Wf(t)===e}function ic(t){const e=ps(t);if(Array.isArray(e))return e.filter(s=>s!=null&&typeof s=="object");if(e&&typeof e=="object"){const s=e;for(const i of["pull_requests","items","data"]){const r=s[i];if(Array.isArray(r))return r.filter(o=>o!=null&&typeof o=="object")}}return[]}function Kf(t){const e=tc(t,["html_url","htmlUrl","url","URL"]),s=sc(t,["number","pullNumber"])??co(e);return!s||!e?null:{number:s,htmlUrl:e}}function Vf(t){ho(t);const e=Ff(t);if(e)return e;const s=ps(t);if(s&&typeof s=="object"){const i=tc(s,["url","URL","html_url","htmlUrl"]),r=sc(s,["number","pullNumber"])??co(i);if(r&&i)return{number:r,htmlUrl:i}}throw new Error("Failed to open pull request")}function qf(t){return/already exists|pull request already/i.test(t)}async function Gf(t,e){const s=await t.callTool({name:"list_pull_requests",arguments:{owner:e.owner,repo:e.repo,state:"open",...e.head?{head:e.head}:{},perPage:10}});return ho(s),ic(s)}async function ra(t,e){const s=[`${e.owner}:${e.branch}`,e.branch];for(const i of s){const o=(await Gf(t,{owner:e.owner,repo:e.repo,head:i})).find(l=>Uf(l,e.branch)),a=o?Kf(o):null;if(a)return a}return null}async function Yf(t,e){const s=await t.callTool({name:"create_pull_request",arguments:{owner:e.owner,repo:e.repo,title:e.title,body:e.body,head:e.head,base:e.base}});return Vf(s)}async function na(t,e){const s=await ra(t,{owner:e.owner,repo:e.repo,branch:e.branch});if(s)return s;try{return await Yf(t,{owner:e.owner,repo:e.repo,title:e.title,body:e.body,head:e.branch,base:e.base})}catch(i){const r=i instanceof Error?i.message:String(i);if(!qf(r))throw i;const o=await ra(t,{owner:e.owner,repo:e.repo,branch:e.branch});if(o)return o;throw i}}async function rc(t,e){const s=await t.callTool({name:"merge_pull_request",arguments:{owner:e.owner,repo:e.repo,pullNumber:e.pullNumber,merge_method:"squash",...e.commitTitle?{commit_title:e.commitTitle}:{}}});ho(s);const i=ps(s);if(!i||i.merged!==!0)throw new Error(i?.message??"Failed to merge pull request");return{merged:!0,message:i.message??"Pull request merged"}}const uo=6e4,fo=3e4;function mo(t){const e=U.c(15);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const i=Qe(s);let r;e[4]!==t.branch||e[5]!==t.owner?(r=t.branch?{head:`${t.owner}:${t.branch}`}:{},e[4]=t.branch,e[5]=t.owner,e[6]=r):r=e[6];let o;e[7]!==t.owner||e[8]!==t.repo||e[9]!==r?(o={owner:t.owner,repo:t.repo,state:"all",...r,perPage:1},e[7]=t.owner,e[8]=t.repo,e[9]=r,e[10]=o):o=e[10];const a=!!t.branch&&!!t.connectionId&&!!t.owner&&!!t.repo;let l;return e[11]!==i||e[12]!==o||e[13]!==a?(l={client:i,toolName:"list_pull_requests",toolArguments:o,enabled:a,refetchInterval:uo,refetchIntervalInBackground:!1,staleTime:fo,select:Xf},e[11]=i,e[12]=o,e[13]=a,e[14]=l):l=e[14],jr(l)}function Xf(t){const e=ic(t);if(e.length===0)return null;const s=e[0],i=s.base,r=s.head,o=s.user;return{number:s.number??0,title:s.title??"",body:s.body??"",state:s.state==="closed"?"closed":"open",merged:s.merged_at!=null,mergedAt:s.merged_at??null,base:i?.ref??"main",head:r?.ref??"",headSha:r?.sha??"",htmlUrl:s.html_url??"",author:o?.login??""}}function nc(t){const e=U.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const i=Qe(s),r=t.prNumber??0;let o;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(o={method:"get_check_runs",owner:t.owner,repo:t.repo,pullNumber:r},e[4]=t.owner,e[5]=t.repo,e[6]=r,e[7]=o):o=e[7];const a=!!t.prNumber;let l;return e[8]!==i||e[9]!==o||e[10]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:uo,refetchIntervalInBackground:!1,staleTime:fo,select:Jf},e[8]=i,e[9]=o,e[10]=a,e[11]=l):l=e[11],jr(l)}function Jf(t){const e=ps(t);return(Array.isArray(e)?e:e?.check_runs??[]).map(Zf)}function Zf(t){const e=t.started_at,s=t.completed_at,i=e&&s?new Date(s).getTime()-new Date(e).getTime():null;return{id:String(t.id??""),name:String(t.name??""),status:t.status??"completed",conclusion:t.conclusion??null,htmlUrl:String(t.html_url??""),durationMs:i}}function Qf(t){const e=U.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const i=Qe(s),r=t.prNumber??0;let o;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(o={method:"get_comments",owner:t.owner,repo:t.repo,pullNumber:r},e[4]=t.owner,e[5]=t.repo,e[6]=r,e[7]=o):o=e[7];const a=!!t.prNumber;let l;return e[8]!==i||e[9]!==o||e[10]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:uo,refetchIntervalInBackground:!1,staleTime:fo,select:em},e[8]=i,e[9]=o,e[10]=a,e[11]=l):l=e[11],jr(l)}function em(t){const e=ps(t);return Array.isArray(e)?e.map(tm):[]}function tm(t){const e=t.user;return{id:Number(t.id??0),author:e?.login??"",body:String(t.body??""),createdAt:String(t.created_at??""),htmlUrl:String(t.html_url??"")}}function po(t,e){const s=U.c(8),i=t?`${t.orgSlug}/${t.virtualMcpId}/${t.branch}`:"",r=e?.fetchEnabled??!0;let o;s[0]!==i?(o=$t.decofile(i),s[0]=i,s[1]=o):o=s[1];let a;s[2]!==t?(a=async()=>{const c=new URLSearchParams({path:"/.decofile"}),d=await fetch(`/api/${t.orgSlug}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/preview-fetch?${c.toString()}`);if(!d.ok)throw new Error(`Failed to fetch decofile: ${d.status}`);return await d.json()},s[2]=t,s[3]=a):a=s[3];const l=!!t&&r;let h;return s[4]!==o||s[5]!==a||s[6]!==l?(h={queryKey:o,queryFn:a,enabled:l,staleTime:3e4,retry:3,retryDelay:sm},s[4]=o,s[5]=a,s[6]=l,s[7]=h):h=s[7],gi(h)}function sm(t){return Math.min(1e3*2**t,5e3)}function _o(t,e){const s=U.c(8),i=t?`${t.orgSlug}/${t.virtualMcpId}/${t.branch}`:"",r=e?.fetchEnabled??!0;let o;s[0]!==i?(o=$t.liveMeta(i),s[0]=i,s[1]=o):o=s[1];let a;s[2]!==t?(a=async()=>{const c=new URLSearchParams({path:"/live/_meta"}),d=await fetch(`/api/${t.orgSlug}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/preview-fetch?${c.toString()}`);if(!d.ok)throw new Error(`Failed to fetch live meta: ${d.status}`);return await d.json()},s[2]=t,s[3]=a):a=s[3];const l=!!t&&r;let h;return s[4]!==o||s[5]!==a||s[6]!==l?(h={queryKey:o,queryFn:a,enabled:l,staleTime:3e5,retry:3,retryDelay:im},s[4]=o,s[5]=a,s[6]=l,s[7]=h):h=s[7],gi(h)}function im(t){return Math.min(1e3*2**t,5e3)}function rm(t){if(!t.startsWith("#")||!t.includes("@"))return null;const e=t.indexOf("@");return{moduleResolveType:t.slice(1,e),blockId:t.slice(e+1)}}function G0(t){return t.includes("@")}function oa(t){const e=t.lastIndexOf("@");return e<0||e===t.length-1?null:t.slice(e+1)}function Y0(t,e){if(t===e)return!0;const s=oa(t);return s?e===s||oa(e)===s:!1}function oc(t,e){const s=t.manifest?.blocks??{};for(const[i,r]of Object.entries(s))if(e in r)return i;return null}function ac(t,e){const s=oc(t,e);return s!==null&&s.includes("sections")}function nm(t,e){const s=oc(t,e);return s!==null&&s.includes("matchers")}function go(t){return!t.includes("/")}function lc(t){try{return decodeURIComponent(t).startsWith("Preview ")}catch{return t.startsWith("Preview ")}}const om=["website/sections/Rendering/Lazy.tsx","website/sections/Rendering/SingleDeferred.tsx"];function Nr(t){return om.some(e=>t.endsWith(e))}const am="VideoWidget";function lm(t,e){const s=e.schema??{},i=e.manifest?.blocks??{};let r={};for(const f of Object.values(i))if(f[t]){r=f[t];break}const o={...s,...r},a=o.$defs??o.definitions??{},l=f=>{const p=f.split("/").pop()??"";return a[p]??{}},h=(f,p=new Set,m=0)=>{if(m>5)return{};if(typeof f.$ref=="string"){const g=f.$ref.split("/").pop()??"";return p.has(g)?{}:h(l(f.$ref),new Set([...p,g]),m+1)}let _={};if(f.properties&&typeof f.properties=="object"&&(_={..._,...f.properties}),Array.isArray(f.required)){const g=Array.isArray(_.__required)?_.__required:[];_.__required=[...g,...f.required]}for(const g of["allOf","anyOf","oneOf"]){const x=f[g];if(Array.isArray(x))for(const y of x)_={..._,...h(y,p,m+1)}}return _},c=(f,p=0)=>{let m=f;typeof f.$ref=="string"&&(m=l(f.$ref),(f.$ref.split("/").pop()??"")===am&&!m.format&&(m={...m,format:"video-uri"}));let _;{const S=m.anyOf??m.oneOf;if(Array.isArray(S)){const k=S.filter(P=>!(P.type==="null"||P.type===null)),N=P=>{if(typeof P.const=="string"||typeof P.const=="number")return P.const;if(Array.isArray(P.enum)&&P.enum.length===1&&(typeof P.enum[0]=="string"||typeof P.enum[0]=="number"))return P.enum[0]};k.length>0&&k.every(P=>N(P)!==void 0)&&(_=k.map(P=>N(P)))}}let g,x;if(m.type)g=Array.isArray(m.type)?String(m.type.find(S=>S!=="null")??m.type[0]):String(m.type);else if(m.anyOf||m.allOf||m.oneOf){const k=(m.anyOf??m.allOf??m.oneOf).filter(N=>!(N.type==="null"||N.type===null));if(k.length===0)g="null";else if(k.length===1){const N=k[0];x=N,g=N.type?Array.isArray(N.type)?String(N.type[0]):String(N.type):typeof N.$ref=="string"?"object":"string"}else{if(_)return{type:"string",title:typeof m.title=="string"?m.title:void 0,description:typeof m.description=="string"?m.description:void 0,enum:_};const N=k.filter(A=>{const E=A.properties?.__resolveType?.enum;return Array.isArray(E)&&typeof E[0]=="string"});if(N.length>0){const A=N.map(E=>{const w=E.properties?.__resolveType?.enum??[],T=String(w[0]);return{resolveType:T,title:typeof E.title=="string"?E.title:T.split("/").pop()?.replace(/\.tsx?$/,"").replace(/[-_]/g," ")??T,description:typeof E.description=="string"?E.description:void 0,schema:p+1<6?c(E,p+1):void 0}});return{type:"block-ref",title:typeof m.title=="string"?m.title:void 0,description:typeof m.description=="string"?m.description:void 0,anyOfRefs:A}}if(k.every(A=>typeof A.$ref=="string")){const A=[];for(const E of k){const j=l(E.$ref);let w,T;if(typeof j.title=="string"){const D=rm(j.title);D&&(w=D.blockId,T=D.blockId)}if(!w&&Array.isArray(j.allOf))for(const D of j.allOf){const B=((D.properties??{}).__resolveType??{}).enum;if(Array.isArray(B)&&typeof B[0]=="string"){w=B[0];break}}w||(w=E.$ref.split("/").pop()??""),A.push({resolveType:w,title:T??(typeof j.title=="string"&&!j.title.startsWith("#")?j.title:w.split("/").pop()?.replace(/\.tsx?$/,"").replace(/[-_]/g," ")??w),description:typeof j.description=="string"?j.description:void 0,schema:p+1<6?c(j,p+1):void 0})}return{type:"block-ref",title:typeof m.title=="string"?m.title:void 0,description:typeof m.description=="string"?m.description:void 0,anyOfRefs:A}}g="object"}}else typeof f.$ref=="string"&&(g="object");let y;if(p<6){const S=h(m),k=Object.entries(S).filter(([N])=>!N.startsWith("__")&&N!=="@type");if(k.length>0){y={};for(const[N,P]of k)y[N]=c(P,p+1)}}let v;if((g==="array"||m.type==="array")&&p<6){let S=m.items;S&&(typeof S.$ref=="string"&&(S=l(S.$ref)),v=c(S,p+1))}const b=S=>{const k=x?.[S];return typeof k=="string"?k:void 0},C=()=>{if("default"in f)return f.default;if("default"in m)return m.default;if(x&&"default"in x)return x.default};return{type:g??"string",title:typeof f.title=="string"?f.title:typeof m.title=="string"?m.title:b("title"),description:typeof f.description=="string"?f.description:typeof m.description=="string"?m.description:b("description"),default:C(),enum:Array.isArray(m.enum)?m.enum:_??void 0,format:typeof m.format=="string"?m.format:b("format"),properties:y,items:v,titleBy:typeof m.titleBy=="string"?m.titleBy:b("titleBy")}},d=h(o),u={};for(const[f,p]of Object.entries(d))f.startsWith("__")||f==="@type"||(u[f]=c(p,0));return Object.keys(u).length===0?null:{type:"object",title:typeof o.title=="string"?o.title:void 0,properties:u}}function cc(t,e){const s=e.schema??{},i=e.manifest?.blocks??{};let r={};for(const c of Object.values(i))if(c[t]){r=c[t];break}const o={...s,...r},a=o.$defs??o.definitions??{},l=typeof r.$ref=="string"?a[r.$ref.split("/").pop()??""]??{}:{...s,...r},h=l.icon;return{title:typeof l.title=="string"?l.title:void 0,description:typeof l.description=="string"?l.description:void 0,icon:typeof h=="string"?h:void 0}}const X0="oklch(0.7278 0.151 289)",cm="website/matchers/always.ts",hc="website/matchers/never.ts",hm="website/flags/multivariate.ts",dm="website/flags/multivariate/section.ts";function dc(t){const e=t.split("/");return(e[e.length-1]??t).replace(/\.(tsx?|jsx?)$/,"").replace(/[-_]/g," ").replace(/\b\w/g,i=>i.toUpperCase())||t}function J0(t){return t.map(e=>`${e.resolveType}|${e.label}|${e.isHidden??!1}|${e.isSavedBlock??!1}|${e.isMultivariate??!1}|${e.isLazy??!1}`).join(`
|
|
3
3
|
`)}const uc=["website/pages/Page.tsx","$live/pages/LivePage.tsx"],fc=new Set(uc),um=new Set(["site/sections/Theme/Theme.tsx"]);function vo(t){return!!(um.has(t)||Nr(t)||t.toLowerCase().includes("preview"))}function mc(t){const e=t.manifest?.blocks??{};for(const s of Object.values(e))for(const i of Object.keys(s))if(fc.has(i))return i;return uc[0]}function an(t){if(!t)return[];if(t.anyOfRefs?.length)return t.anyOfRefs;if(t.items)return an(t.items);if(t.properties){const e=[];for(const s of Object.values(t.properties))e.push(...an(s));return e}return[]}function fm(t){const e=t.manifest?.blocks??{},s=[];for(const[i,r]of Object.entries(e))if(i.includes("sections"))for(const o of Object.keys(r)){if(vo(o))continue;const a=cc(o,t);s.push({resolveType:o,title:a.title??dc(o),description:a.description,previewBlock:o,isSavedBlock:!1})}return s}function pc(t,e){const s=[];for(const[i,r]of Object.entries(e)){if(i.includes("/")||lc(i)||!r||typeof r!="object"||Array.isArray(r))continue;const o=r,a=o.__resolveType;typeof a=="string"&&(fc.has(a)||typeof o.path!="string"&&(vo(a)||ac(t,a)&&s.push({resolveType:i,title:i,description:typeof o.name=="string"?o.name:void 0,previewBlock:i,isSavedBlock:!0})))}return s}function mm(t,e){const s=go(e.resolveType),i=s?{}:cc(e.resolveType,t);return{resolveType:e.resolveType,title:e.title||i.title||dc(e.resolveType),description:e.description??i.description,previewBlock:e.resolveType,isSavedBlock:s}}function Z0(t,e){const s=mc(t),i=lm(s,t),r=an(i?.properties?.sections),o=new Map,a=l=>{if(!vo(l.resolveType)){if(go(l.resolveType)){lc(l.resolveType)||o.set(l.resolveType,l);return}ac(t,l.resolveType)&&(o.has(l.resolveType)||o.set(l.resolveType,l))}};for(const l of fm(t))a(l);for(const l of r)a(mm(t,l));for(const l of pc(t,e))a(l);return[...o.values()].sort((l,h)=>l.title.localeCompare(h.title))}function Q0(t){const e=t.site;if(!e||typeof e!="object"||Array.isArray(e))return;const s=e.theme;if(!(!s||typeof s!="object"||Array.isArray(s)))return s}function pm(t){let e=t;e.startsWith("pages-")&&(e=e.slice(6));const s=e.lastIndexOf("-");if(s>0){const i=e.slice(s+1);/^[a-f0-9]+$/i.test(i)&&i.length>=8&&(e=e.slice(0,s))}try{return decodeURIComponent(e)}catch{return e}}const _m=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function _c(t,e){return t?xo(t).length>0?!0:e?bo(t,e).length>0:!1:!1}function xo(t){const e=[];for(const[s,i]of Object.entries(t))if(i&&typeof i=="object"&&!Array.isArray(i)){const r=i;typeof r.__resolveType=="string"&&_m.has(r.__resolveType)&&typeof r.path=="string"&&e.push({key:s,name:typeof r.name=="string"?r.name:pm(s),path:r.path})}return e}function gc(t,e){if(typeof e.name=="string"){const s=e.name.trim();if(s)return s}return t.replace(/[-_]/g," ").replace(/\b\w/g,s=>s.toUpperCase())}function bo(t,e){return pc(e,t).map(s=>{const i=t[s.resolveType],r=typeof i.__resolveType=="string"?i.__resolveType:"";return{key:s.resolveType,name:s.description??gc(s.resolveType,i),resolveType:r}}).sort((s,i)=>s.name.localeCompare(i.name))}const gm={phase:null,lifecycle:{phase:"idle"},status:{state:"running"},branch:{kind:"unknown"},notFound:!1,scripts:[],activeProcesses:[],getBuffer:()=>"",hasData:()=>!1,subscribeChunks:()=>()=>{},subscribeReload:()=>()=>{}},vc=M.createContext(gm),aa=16384;class vm{data="";append(e){this.data+=e,this.data.length>aa&&(this.data=this.data.slice(this.data.length-aa))}get(){return this.data}clear(){this.data=""}}const xm=1e3,bm=3e4,ym=["lifecycle","status","tasks","scripts","branch","reload"],Sm="log";function wm({virtualMcpId:t,branch:e,enabled:s=!0,children:i}){const{org:r}=ke(),[o,a]=M.useState(null),[l,h]=M.useState({phase:"idle"}),[c,d]=M.useState({state:"running"}),[u,f]=M.useState({kind:"unknown"}),[p,m]=M.useState(!1),[_,g]=M.useState([]),[x,y]=M.useState([]),[,v]=M.useState(0),b=M.useRef(new Map),C=M.useRef(new Set),S=M.useRef(new Set),k=M.useRef(null),N=A=>{let E=b.current.get(A);return E||(E=new vm,b.current.set(A,E)),E};M.useEffect(()=>{if(a(null),h({phase:"idle"}),d({state:"running"}),f({kind:"unknown"}),k.current=null,m(!1),g([]),y([]),b.current.clear(),!t||!e||!s)return;const A=`/api/${encodeURIComponent(r.slug)}/sandbox/${encodeURIComponent(t)}/${encodeURIComponent(e)}/events`;let E=!1,j=0,w=null,T=null;const D=z=>{try{const O=JSON.parse(z.data);a(O),O.kind!=="failed"&&m(!1)}catch(O){console.warn("[vm-events] bad phase payload",O)}},R=()=>{m(!0),a(null),h({phase:"idle"}),d({state:"running"}),f({kind:"unknown"}),g([]),y([]),b.current.clear()},I=z=>{try{const O=JSON.parse(z.data);if(typeof O.data!="string")return;const V=O.data.replace(/\r?\n/g,`\r
|
|
4
4
|
`);N(O.source).append(V);for(const K of C.current)try{K(O.source,V)}catch{}v(K=>K+1)}catch{}},B=z=>{const O=z.type;try{const V=JSON.parse(z.data);switch(O){case"lifecycle":{const K=V;h(K.state);const Q=K.state.phase==="running"?K.state.port:null,X=k.current;if(k.current=Q,X!==null&&Q!==null&&X!==Q)for(const q of S.current)try{q()}catch{}return}case"status":d(V);return;case"tasks":{const Q=V.active.map(X=>X.logName??"").filter(Boolean);y(Q);return}case"scripts":g(V.scripts);return;case"branch":{const K=V.meta;f(K);return}case"reload":for(const K of S.current)try{K()}catch{}return}}catch{}};function H(){if(!E){T=new EventSource(A),T.onopen=()=>{j=0},T.onerror=()=>{T?.readyState===EventSource.CLOSED&&W()},T.addEventListener("phase",D),T.addEventListener("gone",R),T.addEventListener(Sm,I);for(const z of ym)T.addEventListener(z,B)}}function W(){if(E||w)return;const z=Math.min(xm*2**j,bm);j++,w=setTimeout(()=>{w=null,!E&&(T?.close(),H())},z)}return H(),()=>{E=!0,T?.close(),w&&clearTimeout(w)}},[t,e,r.slug,s]);const P={phase:o,lifecycle:l,status:c,branch:u,notFound:p,scripts:_,activeProcesses:x,getBuffer:A=>b.current.get(A)?.get()??"",hasData:A=>(b.current.get(A)?.get().length??0)>0,subscribeChunks:A=>(C.current.add(A),()=>{C.current.delete(A)}),subscribeReload:A=>(S.current.add(A),()=>{S.current.delete(A)})};return n.jsx(vc,{value:P,children:i})}function es(){return M.use(vc)}function Cm(t){const{subscribeChunks:e}=es(),s=M.useRef(t);s.current=t,M.useEffect(()=>e((o,a)=>{s.current?.(o,a)}),[e])}function km(t){const{subscribeReload:e}=es(),s=M.useRef(t);s.current=t,M.useEffect(()=>e(()=>{s.current?.()}),[e])}const jm={settings:Vd,automations:Kd,preview:Yn,content:yr,git:Zn};function la(t){const e=Sr(t);if(e.type==="icon"){const s=wr(e.name);return s?{kind:"component",Component:s}:null}return e.type==="url"?{kind:"url",src:e.url}:null}function Lr(t){if(t.kind==="system")return{kind:"component",Component:jm[t.tabId]};const e=la(t.iconUrl);if(e)return e;if(!t.appId)return{kind:"fallback"};const s=t.connections.find(r=>r.id===t.appId);if(!s)return{kind:"fallback"};const i=la(s.icon);return i||{kind:"fallback"}}function Nm(t){const{org:e}=ke(),s=Qe({connectionId:hs,orgId:e.id,orgSlug:e.slug}),i=Fl(),r=M.useSyncExternalStore(i.threads.subscribe,i.threads.get),o=t?r.find(l=>l.id===t)??null:null,{data:a}=nd({queryKey:$t.ensureTask(e.id,t),queryFn:async()=>{if(!t||!s)return null;try{const l=await s.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}});return(l.structuredContent??l).item??null}catch{return null}},select:l=>l?.metadata??null,staleTime:3e4});return o?.metadata??a??null}function xc(t){const e=U.c(28),s=Zt();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},e[0]=i):i=e[0];const r=Vn(i),o=bt(t.virtualMcpId),a=Nm(t.taskId),{org:l}=ke(),{currentBranch:h}=Qt();let c;e[1]!==o?(c=Ts(o),e[1]=o,e[2]=c):c=e[2];const d=c,u=d?.connectionId??"",f=d?.owner??"",p=d?.name??"",m=d?h:null;let _;e[3]!==l.id||e[4]!==l.slug||e[5]!==u||e[6]!==f||e[7]!==p||e[8]!==m?(_={orgId:l.id,orgSlug:l.slug,connectionId:u,owner:f,repo:p,branch:m},e[3]=l.id,e[4]=l.slug,e[5]=u,e[6]=f,e[7]=p,e[8]=m,e[9]=_):_=e[9];const g=mo(_),x=g.data?.state==="open",y=o?.metadata?.ui??null,v=y?.layout??null,b=v?.tabs??[],C=y?.pinnedViews??[],S=a?.expanded_tools??[],k=Al(o),N=o?.metadata;let P;e[10]!==N?(P=xi(N),e[10]=N,e[11]=P):P=e[11];const A=P;let E;e[12]===Symbol.for("react.memo_cache_sentinel")?(E={includeVirtual:!0},e[12]=E):E=e[12];const j=kr(E),T=es().lifecycle.phase==="running";let D;e[13]!==h||e[14]!==o||e[15]!==A||e[16]!==l.slug?(D=A&&o?.id&&h?{orgSlug:l.slug,virtualMcpId:o.id,branch:h}:null,e[13]=h,e[14]=o,e[15]=A,e[16]=l.slug,e[17]=D):D=e[17];const R=D;let I;e[18]!==T?(I={fetchEnabled:T},e[18]=T,e[19]=I):I=e[19];const{data:B}=po(R,I);let H;e[20]!==T?(H={fetchEnabled:T},e[20]=T,e[21]=H):H=e[21];const{data:W}=_o(R,H),z=_c(B,W),{activeTab:O,mainOpen:V}=hu({mainParam:r.main,metadata:v?{defaultMainView:v.defaultMainView??null,tabs:b.map(Tm)}:null}),K=k&&(x||g.isPending&&O==="git"),Q=v?{defaultMainView:v.defaultMainView??null,tabs:b.map(Em)}:null,X=O==="git"&&!K&&!g.isPending?sn(Q):O==="content"&&!z?sn(Q):O,q=O==="git"&&!K&&!g.isPending?!1:V,se=zl(X),$=[];A&&($.push({id:"preview",title:"Preview"}),z&&$.push({id:"content",title:"Content"})),K&&$.push({id:"git",title:"Review changes"}),$.push({id:"settings",title:"Settings"}),$.push({id:"automations",title:"Automations"});const L=new Map;for(const ie of S){const de=Qo(ie.appId,ie.toolName);L.set(de,{id:de,title:ie.toolName,appId:ie.appId,iconKey:ie.toolName})}for(const ie of C){const de=Qo(ie.connectionId,ie.toolName);L.set(de,{id:de,title:ie.label||ie.toolName,appId:ie.connectionId,iconKey:ie.toolName,iconUrl:ie.icon??null})}let J;e[22]!==j?(J=ie=>({id:ie.id,title:ie.title,kind:"agent",icon:Lr({tabId:ie.id,kind:"agent",appId:ie.view.appId,connections:j})}),e[22]=j,e[23]=J):J=e[23];const Z=[...b.map(J),...Array.from(L.values()).map(ie=>({id:ie.id,title:ie.title,kind:"expanded",icon:Lr({tabId:ie.iconKey,kind:"expanded",appId:ie.appId,iconUrl:ie.iconUrl,connections:j})})),...$.map(ie=>({id:ie.id,title:ie.title,kind:"system",icon:Lr({tabId:ie.id,kind:"system",connections:j})}))];let F;return e[24]!==X||e[25]!==q||e[26]!==s?(F=ie=>{const de=du({clickedId:ie,activeTab:X,mainOpen:q});s({to:".",search:ue=>({...ue,main:de}),replace:!0})},e[24]=X,e[25]=q,e[26]=s,e[27]=F):F=e[27],{activeTab:X,mainOpen:q,setActiveTab:F,systemTabs:$,layoutTabs:b,expandedTools:S,automationTabParsed:se,tabs:Z}}function Em(t){return{id:t.id}}function Tm(t){return{id:t.id}}function bc(t){const{managerAgentId:e,managerName:s,kind:i,id:r,instructions:o}=t,a=` to improve the instructions of ${i} "${r}". Here are its current instructions.
|
|
5
5
|
<current_instructions>${o}</current_instructions>`;return{type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Use "},{type:"mention",attrs:{id:e,name:s,char:"@",metadata:{agentId:e,title:s}}},{type:"text",text:a}]}]}}function Rm(t){const e=U.c(86),{value:s,onChange:i,onColorChange:r,name:o,size:a,className:l,avatarClassName:h,showHoverOverlay:c,disabled:d}=t,u=a===void 0?"lg":a,f=c===void 0?!0:c,p=d===void 0?!1:d,[m,_]=M.useState(!1),[g,x]=M.useState("icons"),[y,v]=M.useState(""),[b,C]=M.useState("blue");let S;e[0]!==s?(S=Sr(s),e[0]=s,e[1]=S):S=e[1];const k=S,N=k.type==="icon"||k.type==="url"&&k.color?k.color:b;let P;e[2]!==i||e[3]!==N?(P=Ie=>{i(Ir(Ie,N))},e[2]=i,e[3]=N,e[4]=P):P=e[4];const A=P;let E;e[5]!==i||e[6]!==r||e[7]!==k.name||e[8]!==k.type||e[9]!==k.url?(E=Ie=>{C(Ie),r?.(Ie),k.type==="icon"?i(Ir(k.name,Ie)):k.type==="url"&&i(Xo(k.url,Ie))},e[5]=i,e[6]=r,e[7]=k.name,e[8]=k.type,e[9]=k.url,e[10]=E):E=e[10];const j=E;let w;e[11]!==i||e[12]!==N?(w=Ie=>{i(Xo(Ie,N)),_(!1)},e[11]=i,e[12]=N,e[13]=w):w=e[13];const T=w;let D;e[14]!==i||e[15]!==N?(D=()=>{const Ie=Qn(),Tt=Ie[Math.floor(Math.random()*Ie.length)];i(Ir(Tt,N))},e[14]=i,e[15]=N,e[16]=D):D=e[16];const R=D;let I,B,H,W,z,O,V,K,Q;if(e[17]!==l||e[18]!==p||e[19]!==m||e[20]!==u){const Ie={xs:"rounded-md",sm:"rounded-lg","sm+":"rounded-xl",md:"rounded-xl",lg:"rounded-2xl",xl:"rounded-2xl"};B=yi,V=p?!1:m,K=_,I=Si,O=!0,Q="button",H="icon-picker-trigger",W=p,z=re("relative group overflow-hidden",p?"cursor-default opacity-50":"cursor-pointer",Ie[u],l),e[17]=l,e[18]=p,e[19]=m,e[20]=u,e[21]=I,e[22]=B,e[23]=H,e[24]=W,e[25]=z,e[26]=O,e[27]=V,e[28]=K,e[29]=Q}else I=e[21],B=e[22],H=e[23],W=e[24],z=e[25],O=e[26],V=e[27],K=e[28],Q=e[29];let X;e[30]!==h||e[31]!==o||e[32]!==u||e[33]!==s?(X=n.jsx(Jo,{icon:s,name:o,size:u,className:h}),e[30]=h,e[31]=o,e[32]=u,e[33]=s,e[34]=X):X=e[34];let q;e[35]!==p||e[36]!==f?(q=f&&!p&&n.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity",children:n.jsx(yr,{size:16,className:"text-white"})}),e[35]=p,e[36]=f,e[37]=q):q=e[37];let se;e[38]!==H||e[39]!==W||e[40]!==z||e[41]!==X||e[42]!==q||e[43]!==Q?(se=n.jsxs("button",{type:Q,"data-testid":H,disabled:W,className:z,children:[X,q]}),e[38]=H,e[39]=W,e[40]=z,e[41]=X,e[42]=q,e[43]=Q,e[44]=se):se=e[44];let $;e[45]!==I||e[46]!==O||e[47]!==se?($=n.jsx(I,{asChild:O,children:se}),e[45]=I,e[46]=O,e[47]=se,e[48]=$):$=e[48];let L;e[49]!==o||e[50]!==s?(L=n.jsx("div",{className:"flex items-center justify-center py-4",children:n.jsx(Jo,{icon:s,name:o,size:"xl"})}),e[49]=o,e[50]=s,e[51]=L):L=e[51];let J;e[52]===Symbol.for("react.memo_cache_sentinel")?(J=()=>x("icons"),e[52]=J):J=e[52];const Z=g==="icons"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let F;e[53]!==Z?(F=re("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",Z),e[53]=Z,e[54]=F):F=e[54];let ne;e[55]!==F?(ne=n.jsx("button",{type:"button",onClick:J,className:F,children:"Icons"}),e[55]=F,e[56]=ne):ne=e[56];let ie;e[57]===Symbol.for("react.memo_cache_sentinel")?(ie=()=>x("upload"),e[57]=ie):ie=e[57];const de=g==="upload"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let ue;e[58]!==de?(ue=re("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",de),e[58]=de,e[59]=ue):ue=e[59];let _e;e[60]!==ue?(_e=n.jsx("button",{type:"button",onClick:ie,className:ue,children:"Upload"}),e[60]=ue,e[61]=_e):_e=e[61];let le;e[62]===Symbol.for("react.memo_cache_sentinel")?(le=n.jsx("div",{className:"flex-1"}),e[62]=le):le=e[62];let je;e[63]!==ne||e[64]!==_e?(je=n.jsxs("div",{className:"flex items-center border-b border-border px-3",children:[ne,_e,le]}),e[63]=ne,e[64]=_e,e[65]=je):je=e[65];let Ne;e[66]!==j||e[67]!==R||e[68]!==A||e[69]!==T||e[70]!==k.name||e[71]!==k.type||e[72]!==y||e[73]!==N||e[74]!==g?(Ne=g==="icons"?n.jsx(Mm,{search:y,onSearchChange:v,selectedColor:N,onColorChange:j,onSelectIcon:A,onRandom:R,currentIconName:k.type==="icon"?k.name:null}):n.jsx(Bm,{onUpload:T}),e[66]=j,e[67]=R,e[68]=A,e[69]=T,e[70]=k.name,e[71]=k.type,e[72]=y,e[73]=N,e[74]=g,e[75]=Ne):Ne=e[75];let Xe;e[76]!==L||e[77]!==je||e[78]!==Ne?(Xe=n.jsx(wi,{align:"start",className:"w-80 p-0",onOpenAutoFocus:Pm,children:n.jsxs("div",{className:"flex flex-col",children:[L,je,Ne]})}),e[76]=L,e[77]=je,e[78]=Ne,e[79]=Xe):Xe=e[79];let Et;return e[80]!==B||e[81]!==V||e[82]!==K||e[83]!==$||e[84]!==Xe?(Et=n.jsxs(B,{open:V,onOpenChange:K,children:[$,Xe]}),e[80]=B,e[81]=V,e[82]=K,e[83]=$,e[84]=Xe,e[85]=Et):Et=e[85],Et}function Pm(t){return t.preventDefault()}function Dm(t){const e=U.c(27),{selectedColor:s,onColorChange:i}=t,[r,o]=M.useState(!1);let a,l,h,c,d,u,f;if(e[0]!==r||e[1]!==s){const y=Il(s);l=yi,u=r,f=o,a=Si,d=!0,h="button",c=re("h-6 w-6 rounded-full shrink-0 ring-2 ring-offset-2 ring-offset-background transition-all cursor-pointer hover:scale-110",y.dot,"ring-foreground/20"),e[0]=r,e[1]=s,e[2]=a,e[3]=l,e[4]=h,e[5]=c,e[6]=d,e[7]=u,e[8]=f}else a=e[2],l=e[3],h=e[4],c=e[5],d=e[6],u=e[7],f=e[8];let p;e[9]!==h||e[10]!==c?(p=n.jsx("button",{type:h,className:c,title:"Change color"}),e[9]=h,e[10]=c,e[11]=p):p=e[11];let m;e[12]!==a||e[13]!==d||e[14]!==p?(m=n.jsx(a,{asChild:d,children:p}),e[12]=a,e[13]=d,e[14]=p,e[15]=m):m=e[15];let _;e[16]!==i||e[17]!==s?(_=Gd.map(y=>n.jsx("button",{type:"button",onClick:()=>{i(y.name),o(!1)},className:re("h-5 w-5 rounded-full transition-all shrink-0 cursor-pointer",y.dot,s===y.name?"ring-2 ring-offset-1 ring-offset-background ring-foreground/30 scale-110":"hover:scale-110"),title:y.name},y.name)),e[16]=i,e[17]=s,e[18]=_):_=e[18];let g;e[19]!==_?(g=n.jsx(wi,{align:"start",side:"right",sideOffset:8,className:"w-auto p-2",onOpenAutoFocus:Am,children:n.jsx("div",{className:"grid grid-cols-4 gap-1",children:_})}),e[19]=_,e[20]=g):g=e[20];let x;return e[21]!==l||e[22]!==u||e[23]!==f||e[24]!==m||e[25]!==g?(x=n.jsxs(l,{open:u,onOpenChange:f,children:[m,g]}),e[21]=l,e[22]=u,e[23]=f,e[24]=m,e[25]=g,e[26]=x):x=e[26],x}function Am(t){return t.preventDefault()}function Mm(t){const e=U.c(44),{search:s,onSearchChange:i,selectedColor:r,onColorChange:o,onSelectIcon:a,onRandom:l,currentIconName:h}=t;let c,d,u,f,p,m,_;if(e[0]!==h||e[1]!==o||e[2]!==l||e[3]!==i||e[4]!==a||e[5]!==s||e[6]!==r){const b=Qn(),C=Il(r);d=s.trim()?b.filter(j=>{const w=tn(j),T=s.toLowerCase();return w.includes(T)||j.toLowerCase().includes(T)}):b,m="flex flex-col";let S;e[14]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(Gl,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[14]=S):S=e[14];let k;e[15]!==i?(k=j=>i(j.target.value),e[15]=i,e[16]=k):k=e[16];let N;e[17]!==s||e[18]!==k?(N=n.jsxs("div",{className:"relative flex-1",children:[S,n.jsx(Ge,{value:s,onChange:k,placeholder:"Filter...",className:"h-8 text-xs pl-7"})]}),e[17]=s,e[18]=k,e[19]=N):N=e[19];let P;e[20]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsx(qd,{size:14,className:"text-muted-foreground"}),e[20]=P):P=e[20];let A;e[21]!==l?(A=n.jsx("button",{type:"button",onClick:l,className:"h-8 w-8 flex items-center justify-center rounded-md border border-border hover:bg-accent transition-colors shrink-0",title:"Random icon",children:P}),e[21]=l,e[22]=A):A=e[22];let E;e[23]!==o||e[24]!==r?(E=n.jsx(Dm,{selectedColor:r,onColorChange:o}),e[23]=o,e[24]=r,e[25]=E):E=e[25],e[26]!==A||e[27]!==E||e[28]!==N?(_=n.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[N,A,E]}),e[26]=A,e[27]=E,e[28]=N,e[29]=_):_=e[29],c=ro,p="h-56",u="grid grid-cols-9 gap-0.5 px-2 pb-2",f=d.map(j=>{const w=wr(j);return w?n.jsx("button",{type:"button",onClick:()=>a(j),className:re("h-8 w-8 flex items-center justify-center rounded-md transition-colors cursor-pointer",h===j?re(C.bg,C.text):re(C.text,"hover:bg-accent")),title:j,children:n.jsx(w,{size:18})},j):null}),e[0]=h,e[1]=o,e[2]=l,e[3]=i,e[4]=a,e[5]=s,e[6]=r,e[7]=c,e[8]=d,e[9]=u,e[10]=f,e[11]=p,e[12]=m,e[13]=_}else c=e[7],d=e[8],u=e[9],f=e[10],p=e[11],m=e[12],_=e[13];let g;e[30]!==u||e[31]!==f?(g=n.jsx("div",{className:u,children:f}),e[30]=u,e[31]=f,e[32]=g):g=e[32];let x;e[33]!==d.length?(x=d.length===0&&n.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"No icons found"}),e[33]=d.length,e[34]=x):x=e[34];let y;e[35]!==c||e[36]!==p||e[37]!==g||e[38]!==x?(y=n.jsxs(c,{className:p,children:[g,x]}),e[35]=c,e[36]=p,e[37]=g,e[38]=x,e[39]=y):y=e[39];let v;return e[40]!==m||e[41]!==_||e[42]!==y?(v=n.jsxs("div",{className:m,children:[_,y]}),e[40]=m,e[41]=_,e[42]=y,e[43]=v):v=e[43],v}function Bm(t){const e=U.c(27),{onUpload:s}=t,i=M.useRef(null);let r;e[0]!==s?(r=S=>{const k=S.target.files?.[0];if(!k)return;if(k.size>2097152){ae.error("Image must be smaller than 2MB"),S.target.value="";return}const N=new FileReader;N.onerror=()=>{ae.error("Failed to read image file"),i.current&&(i.current.value="")},N.onloadend=()=>{N.readyState===FileReader.DONE&&N.result&&s(N.result),i.current&&(i.current.value="")},N.readAsDataURL(k)},e[0]=s,e[1]=r):r=e[1];const o=r,[a,l]=M.useState("");let h;e[2]!==s||e[3]!==a?(h=()=>{const S=a.trim();S&&(s(S),l(""))},e[2]=s,e[3]=a,e[4]=h):h=e[4];const c=h;let d;e[5]!==o?(d=n.jsx("input",{type:"file",ref:i,className:"hidden",accept:"image/*",onChange:o}),e[5]=o,e[6]=d):d=e[6];let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=()=>i.current?.click(),e[7]=u):u=e[7];let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsxs("button",{type:"button",onClick:u,className:"h-24 rounded-lg border-2 border-dashed border-border hover:border-foreground/50 hover:bg-accent/50 transition-colors flex flex-col items-center justify-center gap-2 text-muted-foreground hover:text-foreground",children:[n.jsx(Au,{size:20}),n.jsx("span",{className:"text-xs",children:"Click to upload an image (max 2MB)"})]}),e[8]=f):f=e[8];let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-xs text-muted-foreground",children:"or"}),n.jsx("div",{className:"flex-1 h-px bg-border"})]}),e[9]=p):p=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=S=>l(S.target.value),e[10]=m):m=e[10];let _;e[11]!==c?(_=S=>{S.key==="Enter"&&(S.preventDefault(),c())},e[11]=c,e[12]=_):_=e[12];let g;e[13]!==a||e[14]!==_?(g=n.jsx(Ge,{value:a,onChange:m,placeholder:"Paste image URL...",className:"h-8 text-xs flex-1",onKeyDown:_}),e[13]=a,e[14]=_,e[15]=g):g=e[15];let x;e[16]!==a?(x=a.trim(),e[16]=a,e[17]=x):x=e[17];const y=!x;let v;e[18]!==c||e[19]!==y?(v=n.jsx(te,{variant:"outline",size:"sm",className:"h-8 px-3 text-xs shrink-0",onClick:c,disabled:y,children:"Apply"}),e[18]=c,e[19]=y,e[20]=v):v=e[20];let b;e[21]!==v||e[22]!==g?(b=n.jsxs("div",{className:"flex items-center gap-1.5",children:[g,v]}),e[21]=v,e[22]=g,e[23]=b):b=e[23];let C;return e[24]!==b||e[25]!==d?(C=n.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[d,f,p,b]}),e[24]=b,e[25]=d,e[26]=C):C=e[26],C}function Im(t){const e=U.c(5),{value:s}=t;let i;if(e[0]!==s){i=Symbol.for("react.early_return_sentinel");e:{const o=Sr(s);if(o.type==="icon"){const a=wr(o.name);if(a){let l;e[2]!==a?(l=n.jsx(a,{size:16,className:"text-muted-foreground"}),e[2]=a,e[3]=l):l=e[3],i=l;break e}}}e[0]=s,e[1]=i}else i=e[1];if(i!==Symbol.for("react.early_return_sentinel"))return i;let r;return e[4]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(Fd,{size:16,className:"text-muted-foreground"}),e[4]=r):r=e[4],r}function Lm(t){const e=U.c(66),{value:s,onChange:i,className:r,disabled:o}=t,[a,l]=M.useState(!1),[h,c]=M.useState("");let d;e[0]!==s?(d=Sr(s),e[0]=s,e[1]=d):d=e[1];const u=d,f=u.type==="icon"?u.name:null;let p,m,_,g,x,y,v,b,C,S,k,N,P,A,E;if(e[2]!==r||e[3]!==f||e[4]!==o||e[5]!==i||e[6]!==a||e[7]!==h||e[8]!==s){const B=Qn();g=h.trim()?B.filter(Q=>{const X=h.toLowerCase();return tn(Q).includes(X)||Q.toLowerCase().includes(X)}):B,_=yi,x=o?!1:a,y=l;const H=o?"cursor-default opacity-50":"cursor-pointer hover:bg-accent";let W;e[24]!==r||e[25]!==H?(W=re("size-7 shrink-0 rounded-md transition-colors flex items-center justify-center",H,r),e[24]=r,e[25]=H,e[26]=W):W=e[26];let z;e[27]!==s?(z=n.jsx(Im,{value:s}),e[27]=s,e[28]=z):z=e[28],e[29]!==o||e[30]!==W||e[31]!==z?(v=n.jsx(Si,{asChild:!0,children:n.jsx("button",{type:"button",disabled:o,className:W,children:z})}),e[29]=o,e[30]=W,e[31]=z,e[32]=v):v=e[32],m=wi,P="start",A="w-64 p-0",E=Om,k="flex flex-col";let O;e[33]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(Gl,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[33]=O):O=e[33];let V;e[34]===Symbol.for("react.memo_cache_sentinel")?(V=Q=>c(Q.target.value),e[34]=V):V=e[34],e[35]!==h?(N=n.jsx("div",{className:"px-2 py-2",children:n.jsxs("div",{className:"relative",children:[O,n.jsx(Ge,{value:h,onChange:V,placeholder:"Filter...",className:"h-7 text-xs pl-7"})]})}),e[35]=h,e[36]=N):N=e[36],p=ro,S="h-48",b="grid grid-cols-8 gap-0.5 px-2 pb-2";let K;e[37]!==f||e[38]!==i?(K=Q=>{const X=wr(Q);return X?n.jsx("button",{type:"button",onClick:()=>{i(`icon://${Q}`),l(!1)},className:re("h-7 w-7 flex items-center justify-center rounded-md transition-colors cursor-pointer",f===Q?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),title:tn(Q),children:n.jsx(X,{size:16})},Q):null},e[37]=f,e[38]=i,e[39]=K):K=e[39],C=g.map(K),e[2]=r,e[3]=f,e[4]=o,e[5]=i,e[6]=a,e[7]=h,e[8]=s,e[9]=p,e[10]=m,e[11]=_,e[12]=g,e[13]=x,e[14]=y,e[15]=v,e[16]=b,e[17]=C,e[18]=S,e[19]=k,e[20]=N,e[21]=P,e[22]=A,e[23]=E}else p=e[9],m=e[10],_=e[11],g=e[12],x=e[13],y=e[14],v=e[15],b=e[16],C=e[17],S=e[18],k=e[19],N=e[20],P=e[21],A=e[22],E=e[23];let j;e[40]!==b||e[41]!==C?(j=n.jsx("div",{className:b,children:C}),e[40]=b,e[41]=C,e[42]=j):j=e[42];let w;e[43]!==g.length?(w=g.length===0&&n.jsx("div",{className:"flex items-center justify-center py-6 text-xs text-muted-foreground",children:"No icons found"}),e[43]=g.length,e[44]=w):w=e[44];let T;e[45]!==p||e[46]!==j||e[47]!==w||e[48]!==S?(T=n.jsxs(p,{className:S,children:[j,w]}),e[45]=p,e[46]=j,e[47]=w,e[48]=S,e[49]=T):T=e[49];let D;e[50]!==T||e[51]!==k||e[52]!==N?(D=n.jsxs("div",{className:k,children:[N,T]}),e[50]=T,e[51]=k,e[52]=N,e[53]=D):D=e[53];let R;e[54]!==m||e[55]!==D||e[56]!==P||e[57]!==A||e[58]!==E?(R=n.jsx(m,{align:P,className:A,onOpenAutoFocus:E,children:D}),e[54]=m,e[55]=D,e[56]=P,e[57]=A,e[58]=E,e[59]=R):R=e[59];let I;return e[60]!==_||e[61]!==x||e[62]!==y||e[63]!==v||e[64]!==R?(I=n.jsxs(_,{open:x,onOpenChange:y,children:[v,R]}),e[60]=_,e[61]=x,e[62]=y,e[63]=v,e[64]=R,e[65]=I):I=e[65],I}function Om(t){return t.preventDefault()}function Wi(){const t=U.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"flex items-center justify-center h-32",children:n.jsx(ge,{className:"animate-spin text-muted-foreground",size:24})}),t[0]=e):e=t[0],e}function Or(t){return({error:e})=>e?.message?.includes("Method not found")||e?.code===-32601?n.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:n.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:t})}):n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center h-full p-6 text-center space-y-4",children:[n.jsx("div",{className:"bg-destructive/10 p-3 rounded-full",children:n.jsx(Tl,{className:"h-6 w-6 text-destructive"})}),n.jsxs("div",{className:"space-y-2",children:[n.jsx("h3",{className:"text-lg font-medium",children:"Something went wrong"}),n.jsx("p",{className:"text-sm text-muted-foreground max-w-xs mx-auto",children:e?.message?e.message.length>200?`${e.message.slice(0,200)}...`:e.message:"An unexpected error occurred"})]})]})}function $m(t){const e=U.c(23),{item:s,isSelected:i,onToggle:r,disabled:o}=t,a=o?"cursor-not-allowed opacity-50":"cursor-pointer",l=i?"bg-accent/25":"hover:bg-muted/50";let h;e[0]!==a||e[1]!==l?(h=re("flex items-start gap-3 p-4 rounded-lg transition-colors",a,l),e[0]=a,e[1]=l,e[2]=h):h=e[2];let c;e[3]!==s.name?(c=n.jsx("p",{className:"text-sm font-medium leading-none truncate",children:s.name}),e[3]=s.name,e[4]=c):c=e[4];let d;e[5]!==s.tags?(d=s.tags&&n.jsx("span",{className:"shrink-0",children:s.tags}),e[5]=s.tags,e[6]=d):d=e[6];let u;e[7]!==c||e[8]!==d?(u=n.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[c,d]}),e[7]=c,e[8]=d,e[9]=u):u=e[9];let f;e[10]!==s.description?(f=s.description&&n.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:s.description}),e[10]=s.description,e[11]=f):f=e[11];let p;e[12]!==u||e[13]!==f?(p=n.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[u,f]}),e[12]=u,e[13]=f,e[14]=p):p=e[14];let m;e[15]!==o||e[16]!==i||e[17]!==r?(m=n.jsx(Yl,{checked:i,onCheckedChange:r,disabled:o,className:"mt-0.5"}),e[15]=o,e[16]=i,e[17]=r,e[18]=m):m=e[18];let _;return e[19]!==h||e[20]!==p||e[21]!==m?(_=n.jsxs("label",{className:h,children:[p,m]}),e[19]=h,e[20]=p,e[21]=m,e[22]=_):_=e[22],_}function yo(t){const e=U.c(13),{items:s,selections:i,onToggle:r,emptyMessage:o,disabled:a}=t;let l,h,c;if(e[0]!==a||e[1]!==o||e[2]!==s||e[3]!==r||e[4]!==i){c=Symbol.for("react.early_return_sentinel");e:{const u=s.map(zm);if(s.length===0){let f;e[8]!==o?(f=n.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:n.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:o})}),e[8]=o,e[9]=f):f=e[9],c=f;break e}l="flex-1 overflow-auto px-4 py-3 space-y-1",h=s.map(f=>n.jsx($m,{item:f,isSelected:i===null||i?.includes(f.id),onToggle:()=>r(f.id,u),disabled:a},f.id))}e[0]=a,e[1]=o,e[2]=s,e[3]=r,e[4]=i,e[5]=l,e[6]=h,e[7]=c}else l=e[5],h=e[6],c=e[7];if(c!==Symbol.for("react.early_return_sentinel"))return c;let d;return e[10]!==l||e[11]!==h?(d=n.jsx("div",{className:l,children:h}),e[10]=l,e[11]=h,e[12]=d):d=e[12],d}function zm(t){return t.id}function Fm(t){const e=U.c(13),{connectionId:s,selections:i,onToggle:r,disabled:o}=t,{org:a}=ke();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const h=Qe(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:d}=ku(c);let u;e[6]!==d.tools?(u=d.tools.map(Hm),e[6]=d.tools,e[7]=u):u=e[7];const f=u;let p;return e[8]!==o||e[9]!==f||e[10]!==r||e[11]!==i?(p=n.jsx(yo,{items:f,selections:i,onToggle:r,emptyMessage:"No tools available",disabled:o}),e[8]=o,e[9]=f,e[10]=r,e[11]=i,e[12]=p):p=e[12],p}function Hm(t){return{id:t.name,name:t.name,description:t.description,tags:n.jsx(Tu,{annotations:t.annotations,_meta:t._meta})}}function Wm(t){const e=U.c(13),{connectionId:s,selections:i,onToggle:r,disabled:o}=t,{org:a}=ke();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const h=Qe(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:d}=Nu(c);let u;e[6]!==d.resources?(u=d.resources.map(Um),e[6]=d.resources,e[7]=u):u=e[7];const f=u;let p;return e[8]!==o||e[9]!==f||e[10]!==r||e[11]!==i?(p=n.jsx(yo,{items:f,selections:i,onToggle:r,emptyMessage:"No resources available",disabled:o}),e[8]=o,e[9]=f,e[10]=r,e[11]=i,e[12]=p):p=e[12],p}function Um(t){return{id:t.name||t.uri,name:t.name||t.uri,description:t.description}}function Km(t){const e=U.c(13),{connectionId:s,selections:i,onToggle:r,disabled:o}=t,{org:a}=ke();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const h=Qe(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:d}=Iu(c);let u;e[6]!==d.prompts?(u=d.prompts.map(Vm),e[6]=d.prompts,e[7]=u):u=e[7];const f=u;let p;return e[8]!==o||e[9]!==f||e[10]!==r||e[11]!==i?(p=n.jsx(yo,{items:f,selections:i,onToggle:r,emptyMessage:"No prompts available",disabled:o}),e[8]=o,e[9]=f,e[10]=r,e[11]=i,e[12]=p):p=e[12],p}function Vm(t){return{id:t.name,name:t.name,description:t.description}}function qm(t){const e=U.c(54),{currentConnection:s,activeTab:i,selectedId:r,formData:o,toggleTool:a,toggleResource:l,togglePrompt:h,toggleAllTools:c,toggleAllResources:d,toggleAllPrompts:u,onTabChange:f}=t,p=o[r],m=i==="tools"?p?.tools===null:i==="resources"?p?.resources===null:p?.prompts===null;let _;e[0]!==i||e[1]!==r||e[2]!==u||e[3]!==d||e[4]!==c?(_=()=>{i==="tools"?c(r):i==="resources"?d(r):u(r)},e[0]=i,e[1]=r,e[2]=u,e[3]=d,e[4]=c,e[5]=_):_=e[5];const g=_;let x;e[6]!==s.icon||e[7]!==s.title?(x=n.jsx(us,{icon:s.icon,name:s.title,size:"sm",className:"shrink-0"}),e[6]=s.icon,e[7]=s.title,e[8]=x):x=e[8];let y;e[9]!==s.title?(y=n.jsx("h2",{className:"text-base font-semibold truncate",children:s.title}),e[9]=s.title,e[10]=y):y=e[10];let v;e[11]!==s.description?(v=s.description&&n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.description}),e[11]=s.description,e[12]=v):v=e[12];let b;e[13]!==y||e[14]!==v?(b=n.jsxs("div",{className:"flex-1 min-w-0",children:[y,v]}),e[13]=y,e[14]=v,e[15]=b):b=e[15];let C;e[16]!==x||e[17]!==b?(C=n.jsx("div",{className:"px-6 pt-5 pb-4 shrink-0",children:n.jsxs("div",{className:"flex items-center gap-3",children:[x,b]})}),e[16]=x,e[17]=b,e[18]=C):C=e[18];let S;e[19]===Symbol.for("react.memo_cache_sentinel")?(S=[{id:"tools",label:"Tools"},{id:"resources",label:"Resources"},{id:"prompts",label:"Prompts"}],e[19]=S):S=e[19];let k;e[20]!==f?(k=I=>f(I),e[20]=f,e[21]=k):k=e[21];let N;e[22]!==i||e[23]!==k?(N=n.jsx(Bu,{tabs:S,activeTab:i,onTabChange:k}),e[22]=i,e[23]=k,e[24]=N):N=e[24];const P=m?"Deselect all":"Select all";let A;e[25]!==g||e[26]!==P?(A=n.jsx("button",{type:"button",onClick:g,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:P}),e[25]=g,e[26]=P,e[27]=A):A=e[27];let E;e[28]!==A||e[29]!==N?(E=n.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-t border-border shrink-0",children:[N,A]}),e[28]=A,e[29]=N,e[30]=E):E=e[30];let j;e[31]!==i||e[32]!==o||e[33]!==r||e[34]!==a?(j=i==="tools"&&n.jsx(Mt,{fallback:Or("Tools not supported by this server"),children:n.jsx(M.Suspense,{fallback:n.jsx(Wi,{}),children:n.jsx(Fm,{connectionId:r,selections:o[r]?o[r].tools:[],onToggle:(I,B)=>a(r,I,B)})})}),e[31]=i,e[32]=o,e[33]=r,e[34]=a,e[35]=j):j=e[35];let w;e[36]!==i||e[37]!==o||e[38]!==r||e[39]!==l?(w=i==="resources"&&n.jsx(Mt,{fallback:Or("Resources not supported by this server"),children:n.jsx(M.Suspense,{fallback:n.jsx(Wi,{}),children:n.jsx(Wm,{connectionId:r,selections:o[r]?o[r].resources:[],onToggle:(I,B)=>l(r,I,B)})})}),e[36]=i,e[37]=o,e[38]=r,e[39]=l,e[40]=w):w=e[40];let T;e[41]!==i||e[42]!==o||e[43]!==r||e[44]!==h?(T=i==="prompts"&&n.jsx(Mt,{fallback:Or("Prompts not supported by this server"),children:n.jsx(M.Suspense,{fallback:n.jsx(Wi,{}),children:n.jsx(Km,{connectionId:r,selections:o[r]?o[r].prompts:[],onToggle:(I,B)=>h(r,I,B)})})}),e[41]=i,e[42]=o,e[43]=r,e[44]=h,e[45]=T):T=e[45];let D;e[46]!==j||e[47]!==w||e[48]!==T?(D=n.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[j,w,T]}),e[46]=j,e[47]=w,e[48]=T,e[49]=D):D=e[49];let R;return e[50]!==E||e[51]!==D||e[52]!==C?(R=n.jsxs(n.Fragment,{children:[C,E,D]}),e[50]=E,e[51]=D,e[52]=C,e[53]=R):R=e[53],R}function Gm(t){const e=U.c(11),{connectionId:s,onAuthenticate:i,children:r}=t;let o;e[0]!==s?(o={connectionId:s},e[0]=s,e[1]=o):o=e[1];const a=Ul(o);if(a.supportsOAuth&&!a.isAuthenticated){let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx("div",{className:"flex items-center justify-center size-12 rounded-full bg-muted",children:n.jsx(Yd,{size:22,className:"text-muted-foreground"})}),e[2]=c):c=e[2];let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsxs("div",{className:"space-y-1",children:[n.jsx("p",{className:"text-sm font-medium",children:"Authorization required"}),n.jsx("p",{className:"text-xs text-muted-foreground max-w-xs",children:"This connection needs to be authorized before you can configure its tools and resources."})]}),e[3]=d):d=e[3];let u;e[4]!==s||e[5]!==i?(u=i&&n.jsx(te,{variant:"outline",size:"sm",onClick:()=>i(s),children:"Authorize"}),e[4]=s,e[5]=i,e[6]=u):u=e[6];let f;return e[7]!==u?(f=n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-8 text-center",children:[c,d,u]}),e[7]=u,e[8]=f):f=e[8],f}let h;return e[9]!==r?(h=n.jsx(n.Fragment,{children:r}),e[9]=r,e[10]=h):h=e[10],h}function Ym(t){const e={};for(const s of t)e[s.connection_id]={tools:s.selected_tools,resources:s.selected_resources??null,prompts:s.selected_prompts??null};return e}function ca(t){return Object.entries(t).map(([e,s])=>({connection_id:e,selected_tools:s.tools,selected_resources:s.resources,selected_prompts:s.prompts}))}function Xm(t,e){return e.type==="SET_ACTIVE_TAB"?{...t,activeTab:e.payload}:t}function Jm(t){const e=U.c(49),{open:s,onOpenChange:i,selectedId:r,form:o,connections:a,onAuthenticate:l}=t;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h={activeTab:"tools"},e[0]=h):h=e[0];const[c,d]=M.useReducer(Xm,h),u=to(r??"");let f;e[1]!==a?(f=a??[],e[1]=a,e[2]=f):f=e[2];let p;e[3]!==f?(p=Ym(f),e[3]=f,e[4]=p):p=e[4];const m=p;let _;e[5]!==o||e[6]!==m?(_=(O,V,K,Q)=>{const X=m[O]?.[V];let q;X===null?q=Q.filter($=>$!==K):X?.includes(K)?q=X.filter($=>$!==K):(q=[...X??[],K],q.length===Q.length&&(q=null));const se={...m};se[O]?se[O]={...se[O]}:se[O]={tools:null,resources:null,prompts:null},se[O][V]=q,o.setValue("connections",ca(se),{shouldDirty:!0,shouldTouch:!0})},e[5]=o,e[6]=m,e[7]=_):_=e[7];const g=_;let x;e[8]!==o||e[9]!==m?(x=(O,V)=>{const Q=m[O]?.[V]===null?[]:null,X={...m};X[O]?X[O]={...X[O]}:X[O]={tools:null,resources:null,prompts:null},X[O][V]=Q,o.setValue("connections",ca(X),{shouldDirty:!0,shouldTouch:!0})},e[8]=o,e[9]=m,e[10]=x):x=e[10];const y=x;let v;e[11]!==g?(v=(O,V,K)=>g(O,"tools",V,K),e[11]=g,e[12]=v):v=e[12];const b=v;let C;e[13]!==g?(C=(O,V,K)=>g(O,"resources",V,K),e[13]=g,e[14]=C):C=e[14];const S=C;let k;e[15]!==g?(k=(O,V,K)=>g(O,"prompts",V,K),e[15]=g,e[16]=k):k=e[16];const N=k;let P;e[17]!==y?(P=O=>y(O,"tools"),e[17]=y,e[18]=P):P=e[18];const A=P;let E;e[19]!==y?(E=O=>y(O,"resources"),e[19]=y,e[20]=E):E=e[20];const j=E;let w;e[21]!==y?(w=O=>y(O,"prompts"),e[21]=y,e[22]=w):w=e[22];const T=w;if(!r||!u)return null;let D;e[23]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsx(Wi,{}),e[23]=D):D=e[23];let R;e[24]===Symbol.for("react.memo_cache_sentinel")?(R=O=>d({type:"SET_ACTIVE_TAB",payload:O}),e[24]=R):R=e[24];let I;e[25]!==u||e[26]!==c.activeTab||e[27]!==m||e[28]!==r||e[29]!==T||e[30]!==j||e[31]!==A||e[32]!==N||e[33]!==S||e[34]!==b?(I=n.jsx(qm,{currentConnection:u,activeTab:c.activeTab,selectedId:r,formData:m,toggleTool:b,toggleResource:S,togglePrompt:N,toggleAllTools:A,toggleAllResources:j,toggleAllPrompts:T,onTabChange:R},r),e[25]=u,e[26]=c.activeTab,e[27]=m,e[28]=r,e[29]=T,e[30]=j,e[31]=A,e[32]=N,e[33]=S,e[34]=b,e[35]=I):I=e[35];let B;e[36]!==l||e[37]!==r||e[38]!==I?(B=n.jsx(M.Suspense,{fallback:D,children:n.jsx(Gm,{connectionId:r,onAuthenticate:l,children:I})}),e[36]=l,e[37]=r,e[38]=I,e[39]=B):B=e[39];let H;e[40]!==i?(H=n.jsx(Rs,{className:"px-6 py-4 border-t border-border shrink-0",children:n.jsx(te,{variant:"outline",onClick:()=>i(!1),children:"Done"})}),e[40]=i,e[41]=H):H=e[41];let W;e[42]!==B||e[43]!==H?(W=n.jsxs(Ft,{className:"sm:max-w-2xl h-[75vh] max-h-[75vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[B,H]}),e[42]=B,e[43]=H,e[44]=W):W=e[44];let z;return e[45]!==i||e[46]!==s||e[47]!==W?(z=n.jsx(Ht,{open:s,onOpenChange:i,children:W}),e[45]=i,e[46]=s,e[47]=W,e[48]=z):z=e[48],z}const $r={tools:null,resources:null,prompts:null},Zm=od.pick({status:!0,title:!0,description:!0,icon:!0,metadata:!0,connections:!0});function Qm(t){const s=new TextEncoder().encode(t),i=Array.from(s,r=>String.fromCharCode(r)).join("");return btoa(i)}function ep(t){const e=U.c(11),{url:s,agentId:i}=t,[r,o]=M.useState(!1);let a;e[0]!==i||e[1]!==s?(a=async()=>{Pe("agent_connect_action",{agent_id:i,action:"copy_url"}),await navigator.clipboard.writeText(s),o(!0),ae.success("Agent URL copied to clipboard"),setTimeout(()=>o(!1),2e3)},e[0]=i,e[1]=s,e[2]=a):a=e[2];const l=a;let h;e[3]!==r?(h=r?n.jsx(Ci,{size:20,className:"text-green-600"}):n.jsx(Xt,{size:20}),e[3]=r,e[4]=h):h=e[4];const c=r?"Copied!":"Copy URL";let d;e[5]!==c?(d=n.jsx("span",{className:"text-xs font-medium",children:c}),e[5]=c,e[6]=d):d=e[6];let u;return e[7]!==l||e[8]!==h||e[9]!==d?(u=n.jsxs(te,{type:"button",variant:"outline",onClick:l,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[h,d]}),e[7]=l,e[8]=h,e[9]=d,e[10]=u):u=e[10],u}function tp(t){const e=U.c(8),{url:s,serverName:i,agentId:r}=t;let o;e[0]!==r||e[1]!==i||e[2]!==s?(o=()=>{Pe("agent_connect_action",{agent_id:r,action:"install_cursor"});const d=Kl(i),f=Qm(JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Cursor"}},null,2)),p=`cursor://anysphere.cursor-deeplink/mcp/install?name=${encodeURIComponent(d)}&config=${encodeURIComponent(f)}`;window.open(p,"_blank"),ae.success("Opening Cursor...")},e[0]=r,e[1]=i,e[2]=s,e[3]=o):o=e[3];const a=o;let l,h;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx("img",{src:"/logos/cursor.svg",alt:"Cursor",className:"h-5 w-5",style:{filter:"brightness(0) saturate(100%) invert(11%) sepia(8%) saturate(785%) hue-rotate(1deg) brightness(95%) contrast(89%)"}}),h=n.jsx("span",{className:"text-xs font-medium",children:"Install on Cursor"}),e[4]=l,e[5]=h):(l=e[4],h=e[5]);let c;return e[6]!==a?(c=n.jsxs(te,{type:"button",variant:"outline",onClick:a,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[l,h]}),e[6]=a,e[7]=c):c=e[7],c}function sp(t){const e=U.c(12),{url:s,serverName:i,agentId:r}=t,[o,a]=M.useState(!1);let l;e[0]!==r||e[1]!==i||e[2]!==s?(l=async()=>{Pe("agent_connect_action",{agent_id:r,action:"install_claude_code"});const p=Kl(i),_=JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Claude Code"}},null,2),g=`claude mcp add-json "${p}" '${_.replace(/'/g,"'\\''")}' --scope user`;await navigator.clipboard.writeText(g),a(!0),ae.success("Claude Code command copied to clipboard"),setTimeout(()=>a(!1),2e3)},e[0]=r,e[1]=i,e[2]=s,e[3]=l):l=e[3];const h=l;let c;e[4]!==o?(c=o?n.jsx(Ci,{size:20,className:"text-green-600"}):n.jsx("img",{src:"/logos/Claude Code.svg",alt:"Claude Code",className:"h-5 w-5",style:{filter:"brightness(0) saturate(100%) invert(55%) sepia(31%) saturate(1264%) hue-rotate(331deg) brightness(92%) contrast(86%)"}}),e[4]=o,e[5]=c):c=e[5];const d=o?"Copied!":"Install on Claude Code";let u;e[6]!==d?(u=n.jsx("span",{className:"text-xs font-medium",children:d}),e[6]=d,e[7]=u):u=e[7];let f;return e[8]!==h||e[9]!==c||e[10]!==u?(f=n.jsxs(te,{type:"button",variant:"outline",onClick:h,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[c,u]}),e[8]=h,e[9]=c,e[10]=u,e[11]=f):f=e[11],f}function ip({virtualMcp:t}){const{org:e}=ke(),s=Qe({connectionId:hs,orgId:e.id,orgSlug:e.slug}),[i,r]=M.useState(null),[o,a]=M.useState(!1),[l,h]=M.useState(!1),c=t.id,d=t.title||`agent-${c.slice(0,8)}`,u=i?`bunx @decocms/typegen@latest --mcp ${c} --key ${i} --output client.ts`:`bunx @decocms/typegen@latest --mcp ${c} --key <api-key> --output client.ts`,f=async()=>{a(!0);try{const _=(await s.callTool({name:"API_KEY_CREATE",arguments:{name:`typegen-${d}`,permissions:{[c]:["*"]}}})).structuredContent?.key;if(!_)throw new Error("No key in response");r(_),Pe("agent_typegen_key_generated",{agent_id:c})}catch{Pe("agent_typegen_key_failed",{agent_id:c}),ae.error("Failed to generate API key")}finally{a(!1)}},p=async()=>{Pe("agent_connect_action",{agent_id:c,action:"typegen_copy_command",has_api_key:!!i}),await navigator.clipboard.writeText(u),h(!0),ae.success("Command copied to clipboard"),setTimeout(()=>h(!1),2e3)};return n.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[n.jsxs("div",{className:"flex items-start justify-between gap-3",children:[n.jsxs("div",{className:"flex flex-col gap-0.5",children:[n.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Generate typed client"}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Introspects this agent and writes a typed"," ",n.jsx("code",{className:"font-mono",children:"client.ts"})," you can import directly."]})]}),!i&&n.jsxs(te,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:f,disabled:o,children:[o?n.jsx(ge,{size:14,className:"animate-spin"}):n.jsx(Xl,{size:14}),n.jsx("span",{children:o?"Generating…":"Generate API key"})]})]}),i&&n.jsx("p",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-700",children:"Store this key securely — it won't be shown again."}),n.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Generate client"}),n.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx("code",{className:"min-w-0 flex-1 break-all font-mono text-xs text-muted-foreground",children:u}),n.jsx(te,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:p,children:l?n.jsx(Ci,{size:12,className:"text-green-600"}):n.jsx(Xt,{size:12})})]})}),n.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Runtime variables"}),n.jsx(rp,{apiKey:i,agentId:c})]})}function rp(t){const e=U.c(21),{apiKey:s,agentId:i}=t,[r,o]=M.useState(!1),a=window.location.origin,l=s?`MESH_API_KEY=${s}`:"MESH_API_KEY=<api-key>",h=`MESH_BASE_URL=${a}`,c=`${l}
|
|
@@ -285,7 +285,7 @@ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){t
|
|
|
285
285
|
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(t){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Mo&&t&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(t){let e=this._getMouseBufferCoords(t),s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i||!e?!1:this._areCoordsInSelection(e,s,i)}isCellInSelection(t,e){let s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i?!1:this._areCoordsInSelection([t,e],s,i)}_areCoordsInSelection(t,e,s){return t[1]>e[1]&&t[1]<s[1]||e[1]===s[1]&&t[1]===e[1]&&t[0]>=e[0]&&t[0]<s[0]||e[1]<s[1]&&t[1]===s[1]&&t[0]<s[0]||e[1]<s[1]&&t[1]===e[1]&&t[0]>=e[0]}_selectWordAtCursor(t,e){let s=this._linkifier.currentLink?.link?.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=Wa(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let i=this._getMouseBufferCoords(t);return i?(this._selectWordAt(i,e),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(t,e){this._model.clearSelection(),t=Math.max(t,0),e=Math.min(e,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,t],this._model.selectionEnd=[this._bufferService.cols,e],this.refresh(),this._onSelectionChange.fire()}_handleTrim(t){this._model.handleTrim(t)&&this.refresh()}_getMouseBufferCoords(t){let e=this._mouseService.getCoords(t,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(e)return e[0]--,e[1]--,e[1]+=this._bufferService.buffer.ydisp,e}_getMouseEventScrollAmount(t){let e=Ao(this._coreBrowserService.window,t,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return e>=0&&e<=s?0:(e>s&&(e-=s),e=Math.min(Math.max(e,-Gr),Gr),e/=Gr,e/Math.abs(e)+Math.round(e*(p1-1)))}shouldForceSelection(t){return mr?t.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:t.shiftKey}handleMouseDown(t){if(this._mouseDownTimeStamp=t.timeStamp,!(t.button===2&&this.hasSelection)&&t.button===0){if(!this._enabled){if(!this.shouldForceSelection(t))return;t.stopPropagation()}t.preventDefault(),this._dragScrollAmount=0,this._enabled&&t.shiftKey?this._handleIncrementalClick(t):t.detail===1?this._handleSingleClick(t):t.detail===2?this._handleDoubleClick(t):t.detail===3&&this._handleTripleClick(t),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),_1)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(t){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(t))}_handleSingleClick(t){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(t)?3:0,this._model.selectionStart=this._getMouseBufferCoords(t),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let e=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);e&&e.length!==this._model.selectionStart[0]&&e.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(t){this._selectWordAtCursor(t,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(t){let e=this._getMouseBufferCoords(t);e&&(this._activeSelectionMode=2,this._selectLineAt(e[1]))}shouldColumnSelect(t){return t.altKey&&!(mr&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(t){if(t.stopImmediatePropagation(),!this._model.selectionStart)return;let e=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(t),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(t),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let i=s.lines.get(this._model.selectionEnd[1]);i&&i.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!e||e[0]!==this._model.selectionEnd[0]||e[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let t=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(t.ydisp+this._bufferService.rows,t.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=t.ydisp),this.refresh()}}_handleMouseUp(t){let e=t.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&e<g1&&t.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let s=this._mouseService.getCoords(t,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(s&&s[0]!==void 0&&s[1]!==void 0){let i=a1(s[0]-1,s[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(i,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let t=this._model.finalSelectionStart,e=this._model.finalSelectionEnd,s=!!t&&!!e&&(t[0]!==e[0]||t[1]!==e[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(t,e,s);return}!t||!e||(!this._oldSelectionStart||!this._oldSelectionEnd||t[0]!==this._oldSelectionStart[0]||t[1]!==this._oldSelectionStart[1]||e[0]!==this._oldSelectionEnd[0]||e[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(t,e,s)}_fireOnSelectionChange(t,e,s){this._oldSelectionStart=t,this._oldSelectionEnd=e,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(t){this.clearSelection(),this._trimListener.dispose(),this._trimListener=t.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(t,e){let s=e;for(let i=0;e>=i;i++){let r=t.loadCell(i,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:r>1&&e!==i&&(s+=r-1)}return s}setSelection(t,e,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[t,e],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(t){this._isClickInSelection(t)||(this._selectWordAtCursor(t,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(t,e,s=!0,i=!0){if(t[0]>=this._bufferService.cols)return;let r=this._bufferService.buffer,o=r.lines.get(t[1]);if(!o)return;let a=r.translateBufferLineToString(t[1],!1),l=this._convertViewportColToCharacterIndex(o,t[0]),h=l,c=t[0]-l,d=0,u=0,f=0,p=0;if(a.charAt(l)===" "){for(;l>0&&a.charAt(l-1)===" ";)l--;for(;h<a.length&&a.charAt(h+1)===" ";)h++}else{let g=t[0],x=t[0];o.getWidth(g)===0&&(d++,g--),o.getWidth(x)===2&&(u++,x++);let y=o.getString(x).length;for(y>1&&(p+=y-1,h+=y-1);g>0&&l>0&&!this._isCharWordSeparator(o.loadCell(g-1,this._workCell));){o.loadCell(g-1,this._workCell);let v=this._workCell.getChars().length;this._workCell.getWidth()===0?(d++,g--):v>1&&(f+=v-1,l-=v-1),l--,g--}for(;x<o.length&&h+1<a.length&&!this._isCharWordSeparator(o.loadCell(x+1,this._workCell));){o.loadCell(x+1,this._workCell);let v=this._workCell.getChars().length;this._workCell.getWidth()===2?(u++,x++):v>1&&(p+=v-1,h+=v-1),h++,x++}}h++;let m=l+c-d+f,_=Math.min(this._bufferService.cols,h-l+d+u-f-p);if(!(!e&&a.slice(l,h).trim()==="")){if(s&&m===0&&o.getCodePoint(0)!==32){let g=r.lines.get(t[1]-1);if(g&&o.isWrapped&&g.getCodePoint(this._bufferService.cols-1)!==32){let x=this._getWordAt([this._bufferService.cols-1,t[1]-1],!1,!0,!1);if(x){let y=this._bufferService.cols-x.start;m-=y,_+=y}}}if(i&&m+_===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let g=r.lines.get(t[1]+1);if(g?.isWrapped&&g.getCodePoint(0)!==32){let x=this._getWordAt([0,t[1]+1],!1,!1,!0);x&&(_+=x.length)}}return{start:m,length:_}}}_selectWordAt(t,e){let s=this._getWordAt(t,e);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,t[1]--;this._model.selectionStart=[s.start,t[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(t){let e=this._getWordAt(t,!0);if(e){let s=t[1];for(;e.start<0;)e.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;e.start+e.length>this._bufferService.cols;)e.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?e.start:e.start+e.length,s]}}_isCharWordSeparator(t){return t.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(t.getChars())>=0}_selectLineAt(t){let e=this._bufferService.buffer.getWrappedRangeForLine(t),s={start:{x:0,y:e.first},end:{x:this._bufferService.cols-1,y:e.last}};this._model.selectionStart=[0,e.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Wa(s,this._bufferService.cols)}};Bn=Be([oe(3,st),oe(4,gs),oe(5,jo),oe(6,it),oe(7,Ut),oe(8,Wt)],Bn);var Ua=class{constructor(){this._data={}}set(t,e,s){this._data[t]||(this._data[t]={}),this._data[t][e]=s}get(t,e){return this._data[t]?this._data[t][e]:void 0}clear(){this._data={}}},Ka=class{constructor(){this._color=new Ua,this._css=new Ua}setCss(t,e,s){this._css.set(t,e,s)}getCss(t,e){return this._css.get(t,e)}setColor(t,e,s){this._color.set(t,e,s)}getColor(t,e){return this._color.get(t,e)}clear(){this._color.clear(),this._css.clear()}},Fe=Object.freeze((()=>{let t=[Re.toColor("#2e3436"),Re.toColor("#cc0000"),Re.toColor("#4e9a06"),Re.toColor("#c4a000"),Re.toColor("#3465a4"),Re.toColor("#75507b"),Re.toColor("#06989a"),Re.toColor("#d3d7cf"),Re.toColor("#555753"),Re.toColor("#ef2929"),Re.toColor("#8ae234"),Re.toColor("#fce94f"),Re.toColor("#729fcf"),Re.toColor("#ad7fa8"),Re.toColor("#34e2e2"),Re.toColor("#eeeeec")],e=[0,95,135,175,215,255];for(let s=0;s<216;s++){let i=e[s/36%6|0],r=e[s/6%6|0],o=e[s%6];t.push({css:ze.toCss(i,r,o),rgba:ze.toRgba(i,r,o)})}for(let s=0;s<24;s++){let i=8+s*10;t.push({css:ze.toCss(i,i,i),rgba:ze.toRgba(i,i,i)})}return t})()),ss=Re.toColor("#ffffff"),ei=Re.toColor("#000000"),Va=Re.toColor("#ffffff"),qa=ei,Vs={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},b1=ss,In=class extends pe{constructor(t){super(),this._optionsService=t,this._contrastCache=new Ka,this._halfContrastCache=new Ka,this._onChangeColors=this._register(new ee),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:ss,background:ei,cursor:Va,cursorAccent:qa,selectionForeground:void 0,selectionBackgroundTransparent:Vs,selectionBackgroundOpaque:ye.blend(ei,Vs),selectionInactiveBackgroundTransparent:Vs,selectionInactiveBackgroundOpaque:ye.blend(ei,Vs),scrollbarSliderBackground:ye.opacity(ss,.2),scrollbarSliderHoverBackground:ye.opacity(ss,.4),scrollbarSliderActiveBackground:ye.opacity(ss,.5),overviewRulerBorder:ss,ansi:Fe.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(t={}){let e=this._colors;if(e.foreground=be(t.foreground,ss),e.background=be(t.background,ei),e.cursor=ye.blend(e.background,be(t.cursor,Va)),e.cursorAccent=ye.blend(e.background,be(t.cursorAccent,qa)),e.selectionBackgroundTransparent=be(t.selectionBackground,Vs),e.selectionBackgroundOpaque=ye.blend(e.background,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundTransparent=be(t.selectionInactiveBackground,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundOpaque=ye.blend(e.background,e.selectionInactiveBackgroundTransparent),e.selectionForeground=t.selectionForeground?be(t.selectionForeground,za):void 0,e.selectionForeground===za&&(e.selectionForeground=void 0),ye.isOpaque(e.selectionBackgroundTransparent)&&(e.selectionBackgroundTransparent=ye.opacity(e.selectionBackgroundTransparent,.3)),ye.isOpaque(e.selectionInactiveBackgroundTransparent)&&(e.selectionInactiveBackgroundTransparent=ye.opacity(e.selectionInactiveBackgroundTransparent,.3)),e.scrollbarSliderBackground=be(t.scrollbarSliderBackground,ye.opacity(e.foreground,.2)),e.scrollbarSliderHoverBackground=be(t.scrollbarSliderHoverBackground,ye.opacity(e.foreground,.4)),e.scrollbarSliderActiveBackground=be(t.scrollbarSliderActiveBackground,ye.opacity(e.foreground,.5)),e.overviewRulerBorder=be(t.overviewRulerBorder,b1),e.ansi=Fe.slice(),e.ansi[0]=be(t.black,Fe[0]),e.ansi[1]=be(t.red,Fe[1]),e.ansi[2]=be(t.green,Fe[2]),e.ansi[3]=be(t.yellow,Fe[3]),e.ansi[4]=be(t.blue,Fe[4]),e.ansi[5]=be(t.magenta,Fe[5]),e.ansi[6]=be(t.cyan,Fe[6]),e.ansi[7]=be(t.white,Fe[7]),e.ansi[8]=be(t.brightBlack,Fe[8]),e.ansi[9]=be(t.brightRed,Fe[9]),e.ansi[10]=be(t.brightGreen,Fe[10]),e.ansi[11]=be(t.brightYellow,Fe[11]),e.ansi[12]=be(t.brightBlue,Fe[12]),e.ansi[13]=be(t.brightMagenta,Fe[13]),e.ansi[14]=be(t.brightCyan,Fe[14]),e.ansi[15]=be(t.brightWhite,Fe[15]),t.extendedAnsi){let s=Math.min(e.ansi.length-16,t.extendedAnsi.length);for(let i=0;i<s;i++)e.ansi[i+16]=be(t.extendedAnsi[i],Fe[i+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(t){this._restoreColor(t),this._onChangeColors.fire(this.colors)}_restoreColor(t){if(t===void 0){for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];return}switch(t){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[t]=this._restoreColors.ansi[t]}}modifyColors(t){t(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};In=Be([oe(0,it)],In);function be(t,e){if(t!==void 0)try{return Re.toColor(t)}catch{}return e}var y1=class{constructor(...t){this._entries=new Map;for(let[e,s]of t)this.set(e,s)}set(t,e){let s=this._entries.get(t);return this._entries.set(t,e),s}forEach(t){for(let[e,s]of this._entries.entries())t(e,s)}has(t){return this._entries.has(t)}get(t){return this._entries.get(t)}},S1=class{constructor(){this._services=new y1,this._services.set(ko,this)}setService(t,e){this._services.set(t,e)}getService(t){return this._services.get(t)}createInstance(t,...e){let s=pg(t).sort((o,a)=>o.index-a.index),i=[];for(let o of s){let a=this._services.get(o.id);if(!a)throw new Error(`[createInstance] ${t.name} depends on UNKNOWN service ${o.id._id}.`);i.push(a)}let r=s.length>0?s[0].index:e.length;if(e.length!==r)throw new Error(`[createInstance] First service dependency of ${t.name} at position ${r+1} conflicts with ${e.length} static arguments`);return new t(...e,...i)}},w1={trace:0,debug:1,info:2,warn:3,error:4,off:5},C1="xterm.js: ",Ln=class extends pe{constructor(t){super(),this._optionsService=t,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=w1[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(t){for(let e=0;e<t.length;e++)typeof t[e]=="function"&&(t[e]=t[e]())}_log(t,e,s){this._evalLazyOptionalParams(s),t.call(console,(this._optionsService.options.logger?"":C1)+e,...s)}trace(t,...e){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,t,e)}debug(t,...e){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,t,e)}info(t,...e){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,t,e)}warn(t,...e){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,t,e)}error(t,...e){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,t,e)}};Ln=Be([oe(0,it)],Ln);var Ga=class extends pe{constructor(t){super(),this._maxLength=t,this.onDeleteEmitter=this._register(new ee),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new ee),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new ee),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(t){if(this._maxLength===t)return;let e=new Array(t);for(let s=0;s<Math.min(t,this.length);s++)e[s]=this._array[this._getCyclicIndex(s)];this._array=e,this._maxLength=t,this._startIndex=0}get length(){return this._length}set length(t){if(t>this._length)for(let e=this._length;e<t;e++)this._array[e]=void 0;this._length=t}get(t){return this._array[this._getCyclicIndex(t)]}set(t,e){this._array[this._getCyclicIndex(t)]=e}push(t){this._array[this._getCyclicIndex(this._length)]=t,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(t,e,...s){if(e){for(let i=t;i<this._length-e;i++)this._array[this._getCyclicIndex(i)]=this._array[this._getCyclicIndex(i+e)];this._length-=e,this.onDeleteEmitter.fire({index:t,amount:e})}for(let i=this._length-1;i>=t;i--)this._array[this._getCyclicIndex(i+s.length)]=this._array[this._getCyclicIndex(i)];for(let i=0;i<s.length;i++)this._array[this._getCyclicIndex(t+i)]=s[i];if(s.length&&this.onInsertEmitter.fire({index:t,amount:s.length}),this._length+s.length>this._maxLength){let i=this._length+s.length-this._maxLength;this._startIndex+=i,this._length=this._maxLength,this.onTrimEmitter.fire(i)}else this._length+=s.length}trimStart(t){t>this._length&&(t=this._length),this._startIndex+=t,this._length-=t,this.onTrimEmitter.fire(t)}shiftElements(t,e,s){if(!(e<=0)){if(t<0||t>=this._length)throw new Error("start argument out of range");if(t+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let r=e-1;r>=0;r--)this.set(t+r+s,this.get(t+r));let i=t+e+s-this._length;if(i>0)for(this._length+=i;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let i=0;i<e;i++)this.set(t+i+s,this.get(t+i))}}_getCyclicIndex(t){return(this._startIndex+t)%this._maxLength}},me=3,$e=Object.freeze(new ji),zi=0,Yr=2,ti=class kh{constructor(e,s,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*me);let r=s||gt.fromCharData([0,Uc,1,0]);for(let o=0;o<e;++o)this.setCell(o,r);this.length=e}get(e){let s=this._data[e*me+0],i=s&2097151;return[this._data[e*me+1],s&2097152?this._combined[e]:i?Gt(i):"",s>>22,s&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):i]}set(e,s){this._data[e*me+1]=s[0],s[1].length>1?(this._combined[e]=s[1],this._data[e*me+0]=e|2097152|s[2]<<22):this._data[e*me+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(e){return this._data[e*me+0]>>22}hasWidth(e){return this._data[e*me+0]&12582912}getFg(e){return this._data[e*me+1]}getBg(e){return this._data[e*me+2]}hasContent(e){return this._data[e*me+0]&4194303}getCodePoint(e){let s=this._data[e*me+0];return s&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):s&2097151}isCombined(e){return this._data[e*me+0]&2097152}getString(e){let s=this._data[e*me+0];return s&2097152?this._combined[e]:s&2097151?Gt(s&2097151):""}isProtected(e){return this._data[e*me+2]&536870912}loadCell(e,s){return zi=e*me,s.content=this._data[zi+0],s.fg=this._data[zi+1],s.bg=this._data[zi+2],s.content&2097152&&(s.combinedData=this._combined[e]),s.bg&268435456&&(s.extended=this._extendedAttrs[e]),s}setCell(e,s){s.content&2097152&&(this._combined[e]=s.combinedData),s.bg&268435456&&(this._extendedAttrs[e]=s.extended),this._data[e*me+0]=s.content,this._data[e*me+1]=s.fg,this._data[e*me+2]=s.bg}setCellFromCodepoint(e,s,i,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*me+0]=s|i<<22,this._data[e*me+1]=r.fg,this._data[e*me+2]=r.bg}addCodepointToCell(e,s,i){let r=this._data[e*me+0];r&2097152?this._combined[e]+=Gt(s):r&2097151?(this._combined[e]=Gt(r&2097151)+Gt(s),r&=-2097152,r|=2097152):r=s|1<<22,i&&(r&=-12582913,r|=i<<22),this._data[e*me+0]=r}insertCells(e,s,i){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,i),s<this.length-e){let r=new gt;for(let o=this.length-e-s-1;o>=0;--o)this.setCell(e+s+o,this.loadCell(e+o,r));for(let o=0;o<s;++o)this.setCell(e+o,i)}else for(let r=e;r<this.length;++r)this.setCell(r,i);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,i)}deleteCells(e,s,i){if(e%=this.length,s<this.length-e){let r=new gt;for(let o=0;o<this.length-e-s;++o)this.setCell(e+o,this.loadCell(e+s+o,r));for(let o=this.length-s;o<this.length;++o)this.setCell(o,i)}else for(let r=e;r<this.length;++r)this.setCell(r,i);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,i),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,i)}replaceCells(e,s,i,r=!1){if(r){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&!this.isProtected(s)&&this.setCellFromCodepoint(s,0,1,i);e<s&&e<this.length;)this.isProtected(e)||this.setCell(e,i),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&this.setCellFromCodepoint(s,0,1,i);e<s&&e<this.length;)this.setCell(e++,i)}resize(e,s){if(e===this.length)return this._data.length*4*Yr<this._data.buffer.byteLength;let i=e*me;if(e>this.length){if(this._data.buffer.byteLength>=i*4)this._data=new Uint32Array(this._data.buffer,0,i);else{let r=new Uint32Array(i);r.set(this._data),this._data=r}for(let r=this.length;r<e;++r)this.setCell(r,s)}else{this._data=this._data.subarray(0,i);let r=Object.keys(this._combined);for(let a=0;a<r.length;a++){let l=parseInt(r[a],10);l>=e&&delete this._combined[l]}let o=Object.keys(this._extendedAttrs);for(let a=0;a<o.length;a++){let l=parseInt(o[a],10);l>=e&&delete this._extendedAttrs[l]}}return this.length=e,i*4*Yr<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Yr<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,s=!1){if(s){for(let i=0;i<this.length;++i)this.isProtected(i)||this.setCell(i,e);return}this._combined={},this._extendedAttrs={};for(let i=0;i<this.length;++i)this.setCell(i,e)}copyFrom(e){this.length!==e.length?this._data=new Uint32Array(e._data):this._data.set(e._data),this.length=e.length,this._combined={};for(let s in e._combined)this._combined[s]=e._combined[s];this._extendedAttrs={};for(let s in e._extendedAttrs)this._extendedAttrs[s]=e._extendedAttrs[s];this.isWrapped=e.isWrapped}clone(){let e=new kh(0);e._data=new Uint32Array(this._data),e.length=this.length;for(let s in this._combined)e._combined[s]=this._combined[s];for(let s in this._extendedAttrs)e._extendedAttrs[s]=this._extendedAttrs[s];return e.isWrapped=this.isWrapped,e}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*me+0]&4194303)return e+(this._data[e*me+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*me+0]&4194303||this._data[e*me+2]&50331648)return e+(this._data[e*me+0]>>22);return 0}copyCellsFrom(e,s,i,r,o){let a=e._data;if(o)for(let h=r-1;h>=0;h--){for(let c=0;c<me;c++)this._data[(i+h)*me+c]=a[(s+h)*me+c];a[(s+h)*me+2]&268435456&&(this._extendedAttrs[i+h]=e._extendedAttrs[s+h])}else for(let h=0;h<r;h++){for(let c=0;c<me;c++)this._data[(i+h)*me+c]=a[(s+h)*me+c];a[(s+h)*me+2]&268435456&&(this._extendedAttrs[i+h]=e._extendedAttrs[s+h])}let l=Object.keys(e._combined);for(let h=0;h<l.length;h++){let c=parseInt(l[h],10);c>=s&&(this._combined[c-s+i]=e._combined[c])}}translateToString(e,s,i,r){s=s??0,i=i??this.length,e&&(i=Math.min(i,this.getTrimmedLength())),r&&(r.length=0);let o="";for(;s<i;){let a=this._data[s*me+0],l=a&2097151,h=a&2097152?this._combined[s]:l?Gt(l):Yt;if(o+=h,r)for(let c=0;c<h.length;++c)r.push(s);s+=a>>22||1}return r&&r.push(s),o}};function k1(t,e,s,i,r,o){let a=[];for(let l=0;l<t.length-1;l++){let h=l,c=t.get(++h);if(!c.isWrapped)continue;let d=[t.get(l)];for(;h<t.length&&c.isWrapped;)d.push(c),c=t.get(++h);if(!o&&i>=l&&i<h){l+=d.length-1;continue}let u=0,f=_i(d,u,e),p=1,m=0;for(;p<d.length;){let g=_i(d,p,e),x=g-m,y=s-f,v=Math.min(x,y);d[u].copyCellsFrom(d[p],m,f,v,!1),f+=v,f===s&&(u++,f=0),m+=v,m===g&&(p++,m=0),f===0&&u!==0&&d[u-1].getWidth(s-1)===2&&(d[u].copyCellsFrom(d[u-1],s-1,f++,1,!1),d[u-1].setCell(s-1,r))}d[u].replaceCells(f,s,r);let _=0;for(let g=d.length-1;g>0&&(g>u||d[g].getTrimmedLength()===0);g--)_++;_>0&&(a.push(l+d.length-_),a.push(_)),l+=d.length-1}return a}function j1(t,e){let s=[],i=0,r=e[i],o=0;for(let a=0;a<t.length;a++)if(r===a){let l=e[++i];t.onDeleteEmitter.fire({index:a-o,amount:l}),a+=l-1,o+=l,r=e[++i]}else s.push(a);return{layout:s,countRemoved:o}}function N1(t,e){let s=[];for(let i=0;i<e.length;i++)s.push(t.get(e[i]));for(let i=0;i<s.length;i++)t.set(i,s[i]);t.length=e.length}function E1(t,e,s){let i=[],r=t.map((h,c)=>_i(t,c,e)).reduce((h,c)=>h+c),o=0,a=0,l=0;for(;l<r;){if(r-l<s){i.push(r-l);break}o+=s;let h=_i(t,a,e);o>h&&(o-=h,a++);let c=t[a].getWidth(o-1)===2;c&&o--;let d=c?s-1:s;i.push(d),l+=d}return i}function _i(t,e,s){if(e===t.length-1)return t[e].getTrimmedLength();let i=!t[e].hasContent(s-1)&&t[e].getWidth(s-1)===1,r=t[e+1].getWidth(0)===2;return i&&r?s-1:s}var jh=class Nh{constructor(e){this.line=e,this.isDisposed=!1,this._disposables=[],this._id=Nh._nextId++,this._onDispose=this.register(new ee),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),ls(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};jh._nextId=1;var T1=jh,We={},is=We.B;We[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};We.A={"#":"£"};We.B=void 0;We[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};We.C=We[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};We.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};We.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};We.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};We.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};We.E=We[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};We.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};We.H=We[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};We["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Ya=4294967295,Xa=class{constructor(t,e,s){this._hasScrollback=t,this._optionsService=e,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=$e.clone(),this.savedCharset=is,this.markers=[],this._nullCell=gt.fromCharData([0,Uc,1,0]),this._whitespaceCell=gt.fromCharData([0,Yt,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new pr,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Ga(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(t){return t?(this._nullCell.fg=t.fg,this._nullCell.bg=t.bg,this._nullCell.extended=t.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new dr),this._nullCell}getWhitespaceCell(t){return t?(this._whitespaceCell.fg=t.fg,this._whitespaceCell.bg=t.bg,this._whitespaceCell.extended=t.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new dr),this._whitespaceCell}getBlankLine(t,e){return new ti(this._bufferService.cols,this.getNullCell(t),e)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let t=this.ybase+this.y-this.ydisp;return t>=0&&t<this._rows}_getCorrectBufferLength(t){if(!this._hasScrollback)return t;let e=t+this._optionsService.rawOptions.scrollback;return e>Ya?Ya:e}fillViewportRows(t){if(this.lines.length===0){t===void 0&&(t=$e);let e=this._rows;for(;e--;)this.lines.push(this.getBlankLine(t))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new Ga(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(t,e){let s=this.getNullCell($e),i=0,r=this._getCorrectBufferLength(e);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols<t)for(let a=0;a<this.lines.length;a++)i+=+this.lines.get(a).resize(t,s);let o=0;if(this._rows<e)for(let a=this._rows;a<e;a++)this.lines.length<e+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new ti(t,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new ti(t,s)));else for(let a=this._rows;a>e;a--)this.lines.length>e+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(r<this.lines.maxLength){let a=this.lines.length-r;a>0&&(this.lines.trimStart(a),this.ybase=Math.max(this.ybase-a,0),this.ydisp=Math.max(this.ydisp-a,0),this.savedY=Math.max(this.savedY-a,0)),this.lines.maxLength=r}this.x=Math.min(this.x,t-1),this.y=Math.min(this.y,e-1),o&&(this.y+=o),this.savedX=Math.min(this.savedX,t-1),this.scrollTop=0}if(this.scrollBottom=e-1,this._isReflowEnabled&&(this._reflow(t,e),this._cols>t))for(let o=0;o<this.lines.length;o++)i+=+this.lines.get(o).resize(t,s);this._cols=t,this._rows=e,this._memoryCleanupQueue.clear(),i>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let t=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,t=!1);let e=0;for(;this._memoryCleanupPosition<this.lines.length;)if(e+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),e>100)return!0;return t}get _isReflowEnabled(){let t=this._optionsService.rawOptions.windowsPty;return t&&t.buildNumber?this._hasScrollback&&t.backend==="conpty"&&t.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(t,e){this._cols!==t&&(t>this._cols?this._reflowLarger(t,e):this._reflowSmaller(t,e))}_reflowLarger(t,e){let s=this._optionsService.rawOptions.reflowCursorLine,i=k1(this.lines,this._cols,t,this.ybase+this.y,this.getNullCell($e),s);if(i.length>0){let r=j1(this.lines,i);N1(this.lines,r.layout),this._reflowLargerAdjustViewport(t,e,r.countRemoved)}}_reflowLargerAdjustViewport(t,e,s){let i=this.getNullCell($e),r=s;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<e&&this.lines.push(new ti(t,i))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s,0)}_reflowSmaller(t,e){let s=this._optionsService.rawOptions.reflowCursorLine,i=this.getNullCell($e),r=[],o=0;for(let a=this.lines.length-1;a>=0;a--){let l=this.lines.get(a);if(!l||!l.isWrapped&&l.getTrimmedLength()<=t)continue;let h=[l];for(;l.isWrapped&&a>0;)l=this.lines.get(--a),h.unshift(l);if(!s){let v=this.ybase+this.y;if(v>=a&&v<a+h.length)continue}let c=h[h.length-1].getTrimmedLength(),d=E1(h,this._cols,t),u=d.length-h.length,f;this.ybase===0&&this.y!==this.lines.length-1?f=Math.max(0,this.y-this.lines.maxLength+u):f=Math.max(0,this.lines.length-this.lines.maxLength+u);let p=[];for(let v=0;v<u;v++){let b=this.getBlankLine($e,!0);p.push(b)}p.length>0&&(r.push({start:a+h.length+o,newLines:p}),o+=p.length),h.push(...p);let m=d.length-1,_=d[m];_===0&&(m--,_=d[m]);let g=h.length-u-1,x=c;for(;g>=0;){let v=Math.min(x,_);if(h[m]===void 0)break;if(h[m].copyCellsFrom(h[g],x-v,_-v,v,!0),_-=v,_===0&&(m--,_=d[m]),x-=v,x===0){g--;let b=Math.max(g,0);x=_i(h,b,this._cols)}}for(let v=0;v<h.length;v++)d[v]<t&&h[v].setCell(d[v],i);let y=u-f;for(;y-- >0;)this.ybase===0?this.y<e-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+o)-e&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+u,this.ybase+e-1)}if(r.length>0){let a=[],l=[];for(let _=0;_<this.lines.length;_++)l.push(this.lines.get(_));let h=this.lines.length,c=h-1,d=0,u=r[d];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let f=0;for(let _=Math.min(this.lines.maxLength-1,h+o-1);_>=0;_--)if(u&&u.start>c+f){for(let g=u.newLines.length-1;g>=0;g--)this.lines.set(_--,u.newLines[g]);_++,a.push({index:c+1,amount:u.newLines.length}),f+=u.newLines.length,u=r[++d]}else this.lines.set(_,l[c--]);let p=0;for(let _=a.length-1;_>=0;_--)a[_].index+=p,this.lines.onInsertEmitter.fire(a[_]),p+=a[_].amount;let m=Math.max(0,h+o-this.lines.maxLength);m>0&&this.lines.onTrimEmitter.fire(m)}}translateBufferLineToString(t,e,s=0,i){let r=this.lines.get(t);return r?r.translateToString(e,s,i):""}getWrappedRangeForLine(t){let e=t,s=t;for(;e>0&&this.lines.get(e).isWrapped;)e--;for(;s+1<this.lines.length&&this.lines.get(s+1).isWrapped;)s++;return{first:e,last:s}}setupTabStops(t){for(t!=null?this.tabs[t]||(t=this.prevStop(t)):(this.tabs={},t=0);t<this._cols;t+=this._optionsService.rawOptions.tabStopWidth)this.tabs[t]=!0}prevStop(t){for(t==null&&(t=this.x);!this.tabs[--t]&&t>0;);return t>=this._cols?this._cols-1:t<0?0:t}nextStop(t){for(t==null&&(t=this.x);!this.tabs[++t]&&t<this._cols;);return t>=this._cols?this._cols-1:t<0?0:t}clearMarkers(t){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].line===t&&(this.markers[e].dispose(),this.markers.splice(e--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].dispose();this.markers.length=0,this._isClearing=!1}addMarker(t){let e=new T1(t);return this.markers.push(e),e.register(this.lines.onTrim(s=>{e.line-=s,e.line<0&&e.dispose()})),e.register(this.lines.onInsert(s=>{e.line>=s.index&&(e.line+=s.amount)})),e.register(this.lines.onDelete(s=>{e.line>=s.index&&e.line<s.index+s.amount&&e.dispose(),e.line>s.index&&(e.line-=s.amount)})),e.register(e.onDispose(()=>this._removeMarker(e))),e}_removeMarker(t){this._isClearing||this.markers.splice(this.markers.indexOf(t),1)}},R1=class extends pe{constructor(t,e){super(),this._optionsService=t,this._bufferService=e,this._onBufferActivate=this._register(new ee),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new Xa(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Xa(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(t){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(t),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(t,e){this._normal.resize(t,e),this._alt.resize(t,e),this.setupTabStops(t)}setupTabStops(t){this._normal.setupTabStops(t),this._alt.setupTabStops(t)}},Eh=2,Th=1,On=class extends pe{constructor(t){super(),this.isUserScrolling=!1,this._onResize=this._register(new ee),this.onResize=this._onResize.event,this._onScroll=this._register(new ee),this.onScroll=this._onScroll.event,this.cols=Math.max(t.rawOptions.cols||0,Eh),this.rows=Math.max(t.rawOptions.rows||0,Th),this.buffers=this._register(new R1(t,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(t,e){let s=this.cols!==t,i=this.rows!==e;this.cols=t,this.rows=e,this.buffers.resize(t,e),this._onResize.fire({cols:t,rows:e,colsChanged:s,rowsChanged:i})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(t,e=!1){let s=this.buffer,i;i=this._cachedBlankLine,(!i||i.length!==this.cols||i.getFg(0)!==t.fg||i.getBg(0)!==t.bg)&&(i=s.getBlankLine(t,e),this._cachedBlankLine=i),i.isWrapped=e;let r=s.ybase+s.scrollTop,o=s.ybase+s.scrollBottom;if(s.scrollTop===0){let a=s.lines.isFull;o===s.lines.length-1?a?s.lines.recycle().copyFrom(i):s.lines.push(i.clone()):s.lines.splice(o+1,0,i.clone()),a?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let a=o-r+1;s.lines.shiftElements(r+1,a-1,-1),s.lines.set(o,i.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(t,e){let s=this.buffer;if(t<0){if(s.ydisp===0)return;this.isUserScrolling=!0}else t+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let i=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+t,s.ybase),0),i!==s.ydisp&&(e||this._onScroll.fire(s.ydisp))}};On=Be([oe(0,it)],On);var bs={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:mr,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},P1=["normal","bold","100","200","300","400","500","600","700","800","900"],D1=class extends pe{constructor(t){super(),this._onOptionChange=this._register(new ee),this.onOptionChange=this._onOptionChange.event;let e={...bs};for(let s in t)if(s in e)try{let i=t[s];e[s]=this._sanitizeAndValidateOption(s,i)}catch(i){console.error(i)}this.rawOptions=e,this.options={...e},this._setupOptions(),this._register(Ee(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(t,e){return this.onOptionChange(s=>{s===t&&e(this.rawOptions[t])})}onMultipleOptionChange(t,e){return this.onOptionChange(s=>{t.indexOf(s)!==-1&&e()})}_setupOptions(){let t=s=>{if(!(s in bs))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},e=(s,i)=>{if(!(s in bs))throw new Error(`No option with key "${s}"`);i=this._sanitizeAndValidateOption(s,i),this.rawOptions[s]!==i&&(this.rawOptions[s]=i,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let i={get:t.bind(this,s),set:e.bind(this,s)};Object.defineProperty(this.options,s,i)}}_sanitizeAndValidateOption(t,e){switch(t){case"cursorStyle":if(e||(e=bs[t]),!A1(e))throw new Error(`"${e}" is not a valid value for ${t}`);break;case"wordSeparator":e||(e=bs[t]);break;case"fontWeight":case"fontWeightBold":if(typeof e=="number"&&1<=e&&e<=1e3)break;e=P1.includes(e)?e:bs[t];break;case"cursorWidth":e=Math.floor(e);case"lineHeight":case"tabStopWidth":if(e<1)throw new Error(`${t} cannot be less than 1, value: ${e}`);break;case"minimumContrastRatio":e=Math.max(1,Math.min(21,Math.round(e*10)/10));break;case"scrollback":if(e=Math.min(e,4294967295),e<0)throw new Error(`${t} cannot be less than 0, value: ${e}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(e<=0)throw new Error(`${t} cannot be less than or equal to 0, value: ${e}`);break;case"rows":case"cols":if(!e&&e!==0)throw new Error(`${t} must be numeric, value: ${e}`);break;case"windowsPty":e=e??{};break}return e}};function A1(t){return t==="block"||t==="underline"||t==="bar"}function si(t,e=5){if(typeof t!="object")return t;let s=Array.isArray(t)?[]:{};for(let i in t)s[i]=e<=1?t[i]:t[i]&&si(t[i],e-1);return s}var Ja=Object.freeze({insertMode:!1}),Za=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),$n=class extends pe{constructor(t,e,s){super(),this._bufferService=t,this._logService=e,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new ee),this.onData=this._onData.event,this._onUserInput=this._register(new ee),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new ee),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new ee),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=si(Ja),this.decPrivateModes=si(Za)}reset(){this.modes=si(Ja),this.decPrivateModes=si(Za)}triggerDataEvent(t,e=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;e&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),e&&this._onUserInput.fire(),this._logService.debug(`sending data "${t}"`),this._logService.trace("sending data (codes)",()=>t.split("").map(i=>i.charCodeAt(0))),this._onData.fire(t)}triggerBinaryEvent(t){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${t}"`),this._logService.trace("sending binary (codes)",()=>t.split("").map(e=>e.charCodeAt(0))),this._onBinary.fire(t))}};$n=Be([oe(0,st),oe(1,Yc),oe(2,it)],$n);var Qa={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:t=>t.button===4||t.action!==1?!1:(t.ctrl=!1,t.alt=!1,t.shift=!1,!0)},VT200:{events:19,restrict:t=>t.action!==32},DRAG:{events:23,restrict:t=>!(t.action===32&&t.button===3)},ANY:{events:31,restrict:t=>!0}};function Xr(t,e){let s=(t.ctrl?16:0)|(t.shift?4:0)|(t.alt?8:0);return t.button===4?(s|=64,s|=t.action):(s|=t.button&3,t.button&4&&(s|=64),t.button&8&&(s|=128),t.action===32?s|=32:t.action===0&&!e&&(s|=3)),s}var Jr=String.fromCharCode,el={DEFAULT:t=>{let e=[Xr(t,!1)+32,t.col+32,t.row+32];return e[0]>255||e[1]>255||e[2]>255?"":`\x1B[M${Jr(e[0])}${Jr(e[1])}${Jr(e[2])}`},SGR:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${Xr(t,!0)};${t.col};${t.row}${e}`},SGR_PIXELS:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${Xr(t,!0)};${t.x};${t.y}${e}`}},zn=class extends pe{constructor(t,e,s){super(),this._bufferService=t,this._coreService=e,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new ee),this.onProtocolChange=this._onProtocolChange.event;for(let i of Object.keys(Qa))this.addProtocol(i,Qa[i]);for(let i of Object.keys(el))this.addEncoding(i,el[i]);this.reset()}addProtocol(t,e){this._protocols[t]=e}addEncoding(t,e){this._encodings[t]=e}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(t){if(!this._protocols[t])throw new Error(`unknown protocol "${t}"`);this._activeProtocol=t,this._onProtocolChange.fire(this._protocols[t].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(t){if(!this._encodings[t])throw new Error(`unknown encoding "${t}"`);this._activeEncoding=t}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(t,e,s){if(t.deltaY===0||t.shiftKey||e===void 0||s===void 0)return 0;let i=e/s,r=this._applyScrollModifier(t.deltaY,t);return t.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=i+0,Math.abs(t.deltaY)<50&&(r*=.3),this._wheelPartialScroll+=r,r=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):t.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(r*=this._bufferService.rows),r}_applyScrollModifier(t,e){return e.altKey||e.ctrlKey||e.shiftKey?t*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:t*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(t){if(t.col<0||t.col>=this._bufferService.cols||t.row<0||t.row>=this._bufferService.rows||t.button===4&&t.action===32||t.button===3&&t.action!==32||t.button!==4&&(t.action===2||t.action===3)||(t.col++,t.row++,t.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,t,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(t))return!1;let e=this._encodings[this._activeEncoding](t);return e&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(e):this._coreService.triggerDataEvent(e,!0)),this._lastEvent=t,!0}explainEvents(t){return{down:!!(t&1),up:!!(t&2),drag:!!(t&4),move:!!(t&8),wheel:!!(t&16)}}_equalEvents(t,e,s){if(s){if(t.x!==e.x||t.y!==e.y)return!1}else if(t.col!==e.col||t.row!==e.row)return!1;return!(t.button!==e.button||t.action!==e.action||t.ctrl!==e.ctrl||t.alt!==e.alt||t.shift!==e.shift)}};zn=Be([oe(0,st),oe(1,gs),oe(2,it)],zn);var Zr=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],M1=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],He;function B1(t,e){let s=0,i=e.length-1,r;if(t<e[0][0]||t>e[i][1])return!1;for(;i>=s;)if(r=s+i>>1,t>e[r][1])s=r+1;else if(t<e[r][0])i=r-1;else return!0;return!1}var I1=class{constructor(){if(this.version="6",!He){He=new Uint8Array(65536),He.fill(1),He[0]=0,He.fill(0,1,32),He.fill(0,127,160),He.fill(2,4352,4448),He[9001]=2,He[9002]=2,He.fill(2,11904,42192),He[12351]=1,He.fill(2,44032,55204),He.fill(2,63744,64256),He.fill(2,65040,65050),He.fill(2,65072,65136),He.fill(2,65280,65377),He.fill(2,65504,65511);for(let t=0;t<Zr.length;++t)He.fill(0,Zr[t][0],Zr[t][1]+1)}}wcwidth(t){return t<32?0:t<127?1:t<65536?He[t]:B1(t,M1)?0:t>=131072&&t<=196605||t>=196608&&t<=262141?2:1}charProperties(t,e){let s=this.wcwidth(t),i=s===0&&e!==0;if(i){let r=rs.extractWidth(e);r===0?i=!1:r>s&&(s=r)}return rs.createPropertyValue(0,s,i)}},rs=class Xi{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new ee,this.onChange=this._onChange.event;let e=new I1;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(e&1)!==0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,s,i=!1){return(e&16777215)<<3|(s&3)<<1|(i?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw new Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(e){let s=0,i=0,r=e.length;for(let o=0;o<r;++o){let a=e.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=r)return s+this.wcwidth(a);let c=e.charCodeAt(o);56320<=c&&c<=57343?a=(a-55296)*1024+c-56320+65536:s+=this.wcwidth(c)}let l=this.charProperties(a,i),h=Xi.extractWidth(l);Xi.extractShouldJoin(l)&&(h-=Xi.extractWidth(i)),s+=h,i=l}return s}charProperties(e,s){return this._activeProvider.charProperties(e,s)}},L1=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(t){this.glevel=t,this.charset=this._charsets[t]}setgCharset(t,e){this._charsets[t]=e,this.glevel===t&&(this.charset=e)}};function tl(t){let e=t.buffer.lines.get(t.buffer.ybase+t.buffer.y-1)?.get(t.cols-1),s=t.buffer.lines.get(t.buffer.ybase+t.buffer.y);s&&e&&(s.isWrapped=e[3]!==0&&e[3]!==32)}var qs=2147483647,O1=256,Rh=class Fn{constructor(e=32,s=32){if(this.maxLength=e,this.maxSubParamsLength=s,s>O1)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(s),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(e){let s=new Fn;if(!e.length)return s;for(let i=Array.isArray(e[0])?1:0;i<e.length;++i){let r=e[i];if(Array.isArray(r))for(let o=0;o<r.length;++o)s.addSubParam(r[o]);else s.addParam(r)}return s}clone(){let e=new Fn(this.maxLength,this.maxSubParamsLength);return e.params.set(this.params),e.length=this.length,e._subParams.set(this._subParams),e._subParamsLength=this._subParamsLength,e._subParamsIdx.set(this._subParamsIdx),e._rejectDigits=this._rejectDigits,e._rejectSubDigits=this._rejectSubDigits,e._digitIsSub=this._digitIsSub,e}toArray(){let e=[];for(let s=0;s<this.length;++s){e.push(this.params[s]);let i=this._subParamsIdx[s]>>8,r=this._subParamsIdx[s]&255;r-i>0&&e.push(Array.prototype.slice.call(this._subParams,i,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>qs?qs:e}addSubParam(e){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=e>qs?qs:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let s=this._subParamsIdx[e]>>8,i=this._subParamsIdx[e]&255;return i-s>0?this._subParams.subarray(s,i):null}getSubParamsAll(){let e={};for(let s=0;s<this.length;++s){let i=this._subParamsIdx[s]>>8,r=this._subParamsIdx[s]&255;r-i>0&&(e[s]=this._subParams.slice(i,r))}return e}addDigit(e){let s;if(this._rejectDigits||!(s=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let i=this._digitIsSub?this._subParams:this.params,r=i[s-1];i[s-1]=~r?Math.min(r*10+e,qs):e}},Gs=[],$1=class{constructor(){this._state=0,this._active=Gs,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(t,e){this._handlers[t]===void 0&&(this._handlers[t]=[]);let s=this._handlers[t];return s.push(e),{dispose:()=>{let i=s.indexOf(e);i!==-1&&s.splice(i,1)}}}clearHandler(t){this._handlers[t]&&delete this._handlers[t]}setHandlerFallback(t){this._handlerFb=t}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Gs}reset(){if(this._state===2)for(let t=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;t>=0;--t)this._active[t].end(!1);this._stack.paused=!1,this._active=Gs,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Gs,!this._active.length)this._handlerFb(this._id,"START");else for(let t=this._active.length-1;t>=0;t--)this._active[t].start()}_put(t,e,s){if(!this._active.length)this._handlerFb(this._id,"PUT",Tr(t,e,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(t,e,s)}start(){this.reset(),this._state=1}put(t,e,s){if(this._state!==3){if(this._state===1)for(;e<s;){let i=t[e++];if(i===59){this._state=2,this._start();break}if(i<48||57<i){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+i-48}this._state===2&&s-e>0&&this._put(t,e,s)}}end(t,e=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",t);else{let s=!1,i=this._active.length-1,r=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=e,r=this._stack.fallThrough,this._stack.paused=!1),!r&&s===!1){for(;i>=0&&(s=this._active[i].end(t),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=Gs,this._id=-1,this._state=0}}},at=class{constructor(t){this._handler=t,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(t,e,s){this._hitLimit||(this._data+=Tr(t,e,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(t){let e=!1;if(this._hitLimit)e=!1;else if(t&&(e=this._handler(this._data),e instanceof Promise))return e.then(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,e}},Ys=[],z1=class{constructor(){this._handlers=Object.create(null),this._active=Ys,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Ys}registerHandler(t,e){this._handlers[t]===void 0&&(this._handlers[t]=[]);let s=this._handlers[t];return s.push(e),{dispose:()=>{let i=s.indexOf(e);i!==-1&&s.splice(i,1)}}}clearHandler(t){this._handlers[t]&&delete this._handlers[t]}setHandlerFallback(t){this._handlerFb=t}reset(){if(this._active.length)for(let t=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;t>=0;--t)this._active[t].unhook(!1);this._stack.paused=!1,this._active=Ys,this._ident=0}hook(t,e){if(this.reset(),this._ident=t,this._active=this._handlers[t]||Ys,!this._active.length)this._handlerFb(this._ident,"HOOK",e);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(e)}put(t,e,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",Tr(t,e,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(t,e,s)}unhook(t,e=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",t);else{let s=!1,i=this._active.length-1,r=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=e,r=this._stack.fallThrough,this._stack.paused=!1),!r&&s===!1){for(;i>=0&&(s=this._active[i].unhook(t),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=Ys,this._ident=0}},ii=new Rh;ii.addParam(0);var sl=class{constructor(t){this._handler=t,this._data="",this._params=ii,this._hitLimit=!1}hook(t){this._params=t.length>1||t.params[0]?t.clone():ii,this._data="",this._hitLimit=!1}put(t,e,s){this._hitLimit||(this._data+=Tr(t,e,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(t){let e=!1;if(this._hitLimit)e=!1;else if(t&&(e=this._handler(this._data,this._params),e instanceof Promise))return e.then(s=>(this._params=ii,this._data="",this._hitLimit=!1,s));return this._params=ii,this._data="",this._hitLimit=!1,e}},F1=class{constructor(t){this.table=new Uint8Array(t)}setDefault(t,e){this.table.fill(t<<4|e)}add(t,e,s,i){this.table[e<<8|t]=s<<4|i}addMany(t,e,s,i){for(let r=0;r<t.length;r++)this.table[e<<8|t[r]]=s<<4|i}},pt=160,H1=(function(){let t=new F1(4095),e=Array.apply(null,Array(256)).map((l,h)=>h),s=(l,h)=>e.slice(l,h),i=s(32,127),r=s(0,24);r.push(25),r.push.apply(r,s(28,32));let o=s(0,14),a;t.setDefault(1,0),t.addMany(i,0,2,0);for(a in o)t.addMany([24,26,153,154],a,3,0),t.addMany(s(128,144),a,3,0),t.addMany(s(144,152),a,3,0),t.add(156,a,0,0),t.add(27,a,11,1),t.add(157,a,4,8),t.addMany([152,158,159],a,0,7),t.add(155,a,11,3),t.add(144,a,11,9);return t.addMany(r,0,3,0),t.addMany(r,1,3,1),t.add(127,1,0,1),t.addMany(r,8,0,8),t.addMany(r,3,3,3),t.add(127,3,0,3),t.addMany(r,4,3,4),t.add(127,4,0,4),t.addMany(r,6,3,6),t.addMany(r,5,3,5),t.add(127,5,0,5),t.addMany(r,2,3,2),t.add(127,2,0,2),t.add(93,1,4,8),t.addMany(i,8,5,8),t.add(127,8,5,8),t.addMany([156,27,24,26,7],8,6,0),t.addMany(s(28,32),8,0,8),t.addMany([88,94,95],1,0,7),t.addMany(i,7,0,7),t.addMany(r,7,0,7),t.add(156,7,0,0),t.add(127,7,0,7),t.add(91,1,11,3),t.addMany(s(64,127),3,7,0),t.addMany(s(48,60),3,8,4),t.addMany([60,61,62,63],3,9,4),t.addMany(s(48,60),4,8,4),t.addMany(s(64,127),4,7,0),t.addMany([60,61,62,63],4,0,6),t.addMany(s(32,64),6,0,6),t.add(127,6,0,6),t.addMany(s(64,127),6,0,0),t.addMany(s(32,48),3,9,5),t.addMany(s(32,48),5,9,5),t.addMany(s(48,64),5,0,6),t.addMany(s(64,127),5,7,0),t.addMany(s(32,48),4,9,5),t.addMany(s(32,48),1,9,2),t.addMany(s(32,48),2,9,2),t.addMany(s(48,127),2,10,0),t.addMany(s(48,80),1,10,0),t.addMany(s(81,88),1,10,0),t.addMany([89,90,92],1,10,0),t.addMany(s(96,127),1,10,0),t.add(80,1,11,9),t.addMany(r,9,0,9),t.add(127,9,0,9),t.addMany(s(28,32),9,0,9),t.addMany(s(32,48),9,9,12),t.addMany(s(48,60),9,8,10),t.addMany([60,61,62,63],9,9,10),t.addMany(r,11,0,11),t.addMany(s(32,128),11,0,11),t.addMany(s(28,32),11,0,11),t.addMany(r,10,0,10),t.add(127,10,0,10),t.addMany(s(28,32),10,0,10),t.addMany(s(48,60),10,8,10),t.addMany([60,61,62,63],10,0,11),t.addMany(s(32,48),10,9,12),t.addMany(r,12,0,12),t.add(127,12,0,12),t.addMany(s(28,32),12,0,12),t.addMany(s(32,48),12,9,12),t.addMany(s(48,64),12,0,11),t.addMany(s(64,127),12,12,13),t.addMany(s(64,127),10,12,13),t.addMany(s(64,127),9,12,13),t.addMany(r,13,13,13),t.addMany(i,13,13,13),t.add(127,13,0,13),t.addMany([27,156,24,26],13,14,0),t.add(pt,0,2,0),t.add(pt,8,5,8),t.add(pt,6,0,6),t.add(pt,11,0,11),t.add(pt,13,13,13),t})(),W1=class extends pe{constructor(t=H1){super(),this._transitions=t,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new Rh,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,s,i)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,s)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(Ee(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new $1),this._dcsParser=this._register(new z1),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(t,e=[64,126]){let s=0;if(t.prefix){if(t.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=t.prefix.charCodeAt(0),s&&60>s||s>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(t.intermediates){if(t.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let r=0;r<t.intermediates.length;++r){let o=t.intermediates.charCodeAt(r);if(32>o||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=o}}if(t.final.length!==1)throw new Error("final must be a single byte");let i=t.final.charCodeAt(0);if(e[0]>i||i>e[1])throw new Error(`final must be in range ${e[0]} .. ${e[1]}`);return s<<=8,s|=i,s}identToString(t){let e=[];for(;t;)e.push(String.fromCharCode(t&255)),t>>=8;return e.reverse().join("")}setPrintHandler(t){this._printHandler=t}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(t,e){let s=this._identifier(t,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let i=this._escHandlers[s];return i.push(e),{dispose:()=>{let r=i.indexOf(e);r!==-1&&i.splice(r,1)}}}clearEscHandler(t){this._escHandlers[this._identifier(t,[48,126])]&&delete this._escHandlers[this._identifier(t,[48,126])]}setEscHandlerFallback(t){this._escHandlerFb=t}setExecuteHandler(t,e){this._executeHandlers[t.charCodeAt(0)]=e}clearExecuteHandler(t){this._executeHandlers[t.charCodeAt(0)]&&delete this._executeHandlers[t.charCodeAt(0)]}setExecuteHandlerFallback(t){this._executeHandlerFb=t}registerCsiHandler(t,e){let s=this._identifier(t);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let i=this._csiHandlers[s];return i.push(e),{dispose:()=>{let r=i.indexOf(e);r!==-1&&i.splice(r,1)}}}clearCsiHandler(t){this._csiHandlers[this._identifier(t)]&&delete this._csiHandlers[this._identifier(t)]}setCsiHandlerFallback(t){this._csiHandlerFb=t}registerDcsHandler(t,e){return this._dcsParser.registerHandler(this._identifier(t),e)}clearDcsHandler(t){this._dcsParser.clearHandler(this._identifier(t))}setDcsHandlerFallback(t){this._dcsParser.setHandlerFallback(t)}registerOscHandler(t,e){return this._oscParser.registerHandler(t,e)}clearOscHandler(t){this._oscParser.clearHandler(t)}setOscHandlerFallback(t){this._oscParser.setHandlerFallback(t)}setErrorHandler(t){this._errorHandler=t}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(t,e,s,i,r){this._parseStack.state=t,this._parseStack.handlers=e,this._parseStack.handlerPos=s,this._parseStack.transition=i,this._parseStack.chunkPos=r}parse(t,e,s){let i=0,r=0,o=0,a;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let l=this._parseStack.handlers,h=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](this._params),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 4:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 6:if(i=t[this._parseStack.chunkPos],a=this._dcsParser.unhook(i!==24&&i!==26,s),a)return a;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(i=t[this._parseStack.chunkPos],a=this._oscParser.end(i!==24&&i!==26,s),a)return a;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let l=o;l<e;++l){switch(i=t[l],r=this._transitions.table[this.currentState<<8|(i<160?i:pt)],r>>4){case 2:for(let f=l+1;;++f){if(f>=e||(i=t[f])<32||i>126&&i<pt){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(i=t[f])<32||i>126&&i<pt){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(i=t[f])<32||i>126&&i<pt){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(i=t[f])<32||i>126&&i<pt){this._printHandler(t,l,f),l=f-1;break}}break;case 3:this._executeHandlers[i]?this._executeHandlers[i]():this._executeHandlerFb(i),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:l,code:i,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let h=this._csiHandlers[this._collect<<8|i],c=h?h.length-1:-1;for(;c>=0&&(a=h[c](this._params),a!==!0);c--)if(a instanceof Promise)return this._preserveStack(3,h,c,r,l),a;c<0&&this._csiHandlerFb(this._collect<<8|i,this._params),this.precedingJoinState=0;break;case 8:do switch(i){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(i-48)}while(++l<e&&(i=t[l])>47&&i<60);l--;break;case 9:this._collect<<=8,this._collect|=i;break;case 10:let d=this._escHandlers[this._collect<<8|i],u=d?d.length-1:-1;for(;u>=0&&(a=d[u](),a!==!0);u--)if(a instanceof Promise)return this._preserveStack(4,d,u,r,l),a;u<0&&this._escHandlerFb(this._collect<<8|i),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|i,this._params);break;case 13:for(let f=l+1;;++f)if(f>=e||(i=t[f])===24||i===26||i===27||i>127&&i<pt){this._dcsParser.put(t,l,f),l=f-1;break}break;case 14:if(a=this._dcsParser.unhook(i!==24&&i!==26),a)return this._preserveStack(6,[],0,r,l),a;i===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let f=l+1;;f++)if(f>=e||(i=t[f])<32||i>127&&i<pt){this._oscParser.put(t,l,f),l=f-1;break}break;case 6:if(a=this._oscParser.end(i!==24&&i!==26),a)return this._preserveStack(5,[],0,r,l),a;i===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=r&15}}},U1=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,K1=/^[\da-f]+$/;function il(t){if(!t)return;let e=t.toLowerCase();if(e.indexOf("rgb:")===0){e=e.slice(4);let s=U1.exec(e);if(s){let i=s[1]?15:s[4]?255:s[7]?4095:65535;return[Math.round(parseInt(s[1]||s[4]||s[7]||s[10],16)/i*255),Math.round(parseInt(s[2]||s[5]||s[8]||s[11],16)/i*255),Math.round(parseInt(s[3]||s[6]||s[9]||s[12],16)/i*255)]}}else if(e.indexOf("#")===0&&(e=e.slice(1),K1.exec(e)&&[3,6,9,12].includes(e.length))){let s=e.length/3,i=[0,0,0];for(let r=0;r<3;++r){let o=parseInt(e.slice(s*r,s*r+s),16);i[r]=s===1?o<<4:s===2?o:s===3?o>>4:o>>8}return i}}function Qr(t,e){let s=t.toString(16),i=s.length<2?"0"+s:s;switch(e){case 4:return s[0];case 8:return i;case 12:return(i+i).slice(0,3);default:return i+i}}function V1(t,e=16){let[s,i,r]=t;return`rgb:${Qr(s,e)}/${Qr(i,e)}/${Qr(r,e)}`}var q1={"(":0,")":1,"*":2,"+":3,"-":1,".":2},qt=131072,rl=10;function nl(t,e){if(t>24)return e.setWinLines||!1;switch(t){case 1:return!!e.restoreWin;case 2:return!!e.minimizeWin;case 3:return!!e.setWinPosition;case 4:return!!e.setWinSizePixels;case 5:return!!e.raiseWin;case 6:return!!e.lowerWin;case 7:return!!e.refreshWin;case 8:return!!e.setWinSizeChars;case 9:return!!e.maximizeWin;case 10:return!!e.fullscreenWin;case 11:return!!e.getWinState;case 13:return!!e.getWinPosition;case 14:return!!e.getWinSizePixels;case 15:return!!e.getScreenSizePixels;case 16:return!!e.getCellSizePixels;case 18:return!!e.getWinSizeChars;case 19:return!!e.getScreenSizeChars;case 20:return!!e.getIconTitle;case 21:return!!e.getWinTitle;case 22:return!!e.pushTitle;case 23:return!!e.popTitle;case 24:return!!e.setWinLines}return!1}var ol=5e3,al=0,G1=class extends pe{constructor(t,e,s,i,r,o,a,l,h=new W1){super(),this._bufferService=t,this._charsetService=e,this._coreService=s,this._logService=i,this._optionsService=r,this._oscLinkService=o,this._coreMouseService=a,this._unicodeService=l,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new fg,this._utf8Decoder=new mg,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=$e.clone(),this._eraseAttrDataInternal=$e.clone(),this._onRequestBell=this._register(new ee),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new ee),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new ee),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new ee),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new ee),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new ee),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new ee),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new ee),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new ee),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new ee),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new ee),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new ee),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new ee),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new Hn(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(c=>this._activeBuffer=c.activeBuffer)),this._parser.setCsiHandlerFallback((c,d)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(c),params:d.toArray()})}),this._parser.setEscHandlerFallback(c=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(c)})}),this._parser.setExecuteHandlerFallback(c=>{this._logService.debug("Unknown EXECUTE code: ",{code:c})}),this._parser.setOscHandlerFallback((c,d,u)=>{this._logService.debug("Unknown OSC code: ",{identifier:c,action:d,data:u})}),this._parser.setDcsHandlerFallback((c,d,u)=>{d==="HOOK"&&(u=u.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(c),action:d,payload:u})}),this._parser.setPrintHandler((c,d,u)=>this.print(c,d,u)),this._parser.registerCsiHandler({final:"@"},c=>this.insertChars(c)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},c=>this.scrollLeft(c)),this._parser.registerCsiHandler({final:"A"},c=>this.cursorUp(c)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},c=>this.scrollRight(c)),this._parser.registerCsiHandler({final:"B"},c=>this.cursorDown(c)),this._parser.registerCsiHandler({final:"C"},c=>this.cursorForward(c)),this._parser.registerCsiHandler({final:"D"},c=>this.cursorBackward(c)),this._parser.registerCsiHandler({final:"E"},c=>this.cursorNextLine(c)),this._parser.registerCsiHandler({final:"F"},c=>this.cursorPrecedingLine(c)),this._parser.registerCsiHandler({final:"G"},c=>this.cursorCharAbsolute(c)),this._parser.registerCsiHandler({final:"H"},c=>this.cursorPosition(c)),this._parser.registerCsiHandler({final:"I"},c=>this.cursorForwardTab(c)),this._parser.registerCsiHandler({final:"J"},c=>this.eraseInDisplay(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},c=>this.eraseInDisplay(c,!0)),this._parser.registerCsiHandler({final:"K"},c=>this.eraseInLine(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},c=>this.eraseInLine(c,!0)),this._parser.registerCsiHandler({final:"L"},c=>this.insertLines(c)),this._parser.registerCsiHandler({final:"M"},c=>this.deleteLines(c)),this._parser.registerCsiHandler({final:"P"},c=>this.deleteChars(c)),this._parser.registerCsiHandler({final:"S"},c=>this.scrollUp(c)),this._parser.registerCsiHandler({final:"T"},c=>this.scrollDown(c)),this._parser.registerCsiHandler({final:"X"},c=>this.eraseChars(c)),this._parser.registerCsiHandler({final:"Z"},c=>this.cursorBackwardTab(c)),this._parser.registerCsiHandler({final:"`"},c=>this.charPosAbsolute(c)),this._parser.registerCsiHandler({final:"a"},c=>this.hPositionRelative(c)),this._parser.registerCsiHandler({final:"b"},c=>this.repeatPrecedingCharacter(c)),this._parser.registerCsiHandler({final:"c"},c=>this.sendDeviceAttributesPrimary(c)),this._parser.registerCsiHandler({prefix:">",final:"c"},c=>this.sendDeviceAttributesSecondary(c)),this._parser.registerCsiHandler({final:"d"},c=>this.linePosAbsolute(c)),this._parser.registerCsiHandler({final:"e"},c=>this.vPositionRelative(c)),this._parser.registerCsiHandler({final:"f"},c=>this.hVPosition(c)),this._parser.registerCsiHandler({final:"g"},c=>this.tabClear(c)),this._parser.registerCsiHandler({final:"h"},c=>this.setMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"h"},c=>this.setModePrivate(c)),this._parser.registerCsiHandler({final:"l"},c=>this.resetMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"l"},c=>this.resetModePrivate(c)),this._parser.registerCsiHandler({final:"m"},c=>this.charAttributes(c)),this._parser.registerCsiHandler({final:"n"},c=>this.deviceStatus(c)),this._parser.registerCsiHandler({prefix:"?",final:"n"},c=>this.deviceStatusPrivate(c)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},c=>this.softReset(c)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},c=>this.setCursorStyle(c)),this._parser.registerCsiHandler({final:"r"},c=>this.setScrollRegion(c)),this._parser.registerCsiHandler({final:"s"},c=>this.saveCursor(c)),this._parser.registerCsiHandler({final:"t"},c=>this.windowOptions(c)),this._parser.registerCsiHandler({final:"u"},c=>this.restoreCursor(c)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},c=>this.insertColumns(c)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},c=>this.deleteColumns(c)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},c=>this.selectProtected(c)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},c=>this.requestMode(c,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},c=>this.requestMode(c,!1)),this._parser.setExecuteHandler(G.BEL,()=>this.bell()),this._parser.setExecuteHandler(G.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(G.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(G.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(G.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(G.BS,()=>this.backspace()),this._parser.setExecuteHandler(G.HT,()=>this.tab()),this._parser.setExecuteHandler(G.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(G.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Gi.IND,()=>this.index()),this._parser.setExecuteHandler(Gi.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Gi.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new at(c=>(this.setTitle(c),this.setIconName(c),!0))),this._parser.registerOscHandler(1,new at(c=>this.setIconName(c))),this._parser.registerOscHandler(2,new at(c=>this.setTitle(c))),this._parser.registerOscHandler(4,new at(c=>this.setOrReportIndexedColor(c))),this._parser.registerOscHandler(8,new at(c=>this.setHyperlink(c))),this._parser.registerOscHandler(10,new at(c=>this.setOrReportFgColor(c))),this._parser.registerOscHandler(11,new at(c=>this.setOrReportBgColor(c))),this._parser.registerOscHandler(12,new at(c=>this.setOrReportCursorColor(c))),this._parser.registerOscHandler(104,new at(c=>this.restoreIndexedColor(c))),this._parser.registerOscHandler(110,new at(c=>this.restoreFgColor(c))),this._parser.registerOscHandler(111,new at(c=>this.restoreBgColor(c))),this._parser.registerOscHandler(112,new at(c=>this.restoreCursorColor(c))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let c in We)this._parser.registerEscHandler({intermediates:"(",final:c},()=>this.selectCharset("("+c)),this._parser.registerEscHandler({intermediates:")",final:c},()=>this.selectCharset(")"+c)),this._parser.registerEscHandler({intermediates:"*",final:c},()=>this.selectCharset("*"+c)),this._parser.registerEscHandler({intermediates:"+",final:c},()=>this.selectCharset("+"+c)),this._parser.registerEscHandler({intermediates:"-",final:c},()=>this.selectCharset("-"+c)),this._parser.registerEscHandler({intermediates:".",final:c},()=>this.selectCharset("."+c)),this._parser.registerEscHandler({intermediates:"/",final:c},()=>this.selectCharset("/"+c));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(c=>(this._logService.error("Parsing error: ",c),c)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new sl((c,d)=>this.requestStatusString(c,d)))}getAttrData(){return this._curAttrData}_preserveStack(t,e,s,i){this._parseStack.paused=!0,this._parseStack.cursorStartX=t,this._parseStack.cursorStartY=e,this._parseStack.decodedLength=s,this._parseStack.position=i}_logSlowResolvingAsync(t){this._logService.logLevel<=3&&Promise.race([t,new Promise((e,s)=>setTimeout(()=>s("#SLOW_TIMEOUT"),ol))]).catch(e=>{if(e!=="#SLOW_TIMEOUT")throw e;console.warn(`async parser handler taking longer than ${ol} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(t,e){let s,i=this._activeBuffer.x,r=this._activeBuffer.y,o=0,a=this._parseStack.paused;if(a){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,e))return this._logSlowResolvingAsync(s),s;i=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,t.length>qt&&(o=this._parseStack.position+qt)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof t=="string"?` "${t}"`:` "${Array.prototype.map.call(t,c=>String.fromCharCode(c)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof t=="string"?t.split("").map(c=>c.charCodeAt(0)):t),this._parseBuffer.length<t.length&&this._parseBuffer.length<qt&&(this._parseBuffer=new Uint32Array(Math.min(t.length,qt))),a||this._dirtyRowTracker.clearRange(),t.length>qt)for(let c=o;c<t.length;c+=qt){let d=c+qt<t.length?c+qt:t.length,u=typeof t=="string"?this._stringDecoder.decode(t.substring(c,d),this._parseBuffer):this._utf8Decoder.decode(t.subarray(c,d),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,u))return this._preserveStack(i,r,u,c),this._logSlowResolvingAsync(s),s}else if(!a){let c=typeof t=="string"?this._stringDecoder.decode(t,this._parseBuffer):this._utf8Decoder.decode(t,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,c))return this._preserveStack(i,r,c,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==i||this._activeBuffer.y!==r)&&this._onCursorMove.fire();let l=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),h=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);h<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(h,this._bufferService.rows-1),end:Math.min(l,this._bufferService.rows-1)})}print(t,e,s){let i,r,o=this._charsetService.charset,a=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,h=this._coreService.decPrivateModes.wraparound,c=this._coreService.modes.insertMode,d=this._curAttrData,u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-e>0&&u.getWidth(this._activeBuffer.x-1)===2&&u.setCellFromCodepoint(this._activeBuffer.x-1,0,1,d);let f=this._parser.precedingJoinState;for(let p=e;p<s;++p){if(i=t[p],i<127&&o){let x=o[String.fromCharCode(i)];x&&(i=x.charCodeAt(0))}let m=this._unicodeService.charProperties(i,f);r=rs.extractWidth(m);let _=rs.extractShouldJoin(m),g=_?rs.extractWidth(f):0;if(f=m,a&&this._onA11yChar.fire(Gt(i)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-g>l){if(h){let x=u,y=this._activeBuffer.x-g;for(this._activeBuffer.x=g,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),g>0&&u instanceof ti&&u.copyCellsFrom(x,y,0,g,!1);y<l;)x.setCellFromCodepoint(y++,0,1,d)}else if(this._activeBuffer.x=l-1,r===2)continue}if(_&&this._activeBuffer.x){let x=u.getWidth(this._activeBuffer.x-1)?1:2;u.addCodepointToCell(this._activeBuffer.x-x,i,r);for(let y=r-g;--y>=0;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,d);continue}if(c&&(u.insertCells(this._activeBuffer.x,r-g,this._activeBuffer.getNullCell(d)),u.getWidth(l-1)===2&&u.setCellFromCodepoint(l-1,0,1,d)),u.setCellFromCodepoint(this._activeBuffer.x++,i,r,d),r>0)for(;--r;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,d)}this._parser.precedingJoinState=f,this._activeBuffer.x<l&&s-e>0&&u.getWidth(this._activeBuffer.x)===0&&!u.hasContent(this._activeBuffer.x)&&u.setCellFromCodepoint(this._activeBuffer.x,0,1,d),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(t,e){return t.final==="t"&&!t.prefix&&!t.intermediates?this._parser.registerCsiHandler(t,s=>nl(s.params[0],this._optionsService.rawOptions.windowOptions)?e(s):!0):this._parser.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._parser.registerDcsHandler(t,new sl(e))}registerEscHandler(t,e){return this._parser.registerEscHandler(t,e)}registerOscHandler(t,e){return this._parser.registerOscHandler(t,new at(e))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-t),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(t=this._bufferService.cols-1){this._activeBuffer.x=Math.min(t,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(t,e){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=t,this._activeBuffer.y=this._activeBuffer.scrollTop+e):(this._activeBuffer.x=t,this._activeBuffer.y=e),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(t,e){this._restrictCursor(),this._setCursor(this._activeBuffer.x+t,this._activeBuffer.y+e)}cursorUp(t){let e=this._activeBuffer.y-this._activeBuffer.scrollTop;return e>=0?this._moveCursor(0,-Math.min(e,t.params[0]||1)):this._moveCursor(0,-(t.params[0]||1)),!0}cursorDown(t){let e=this._activeBuffer.scrollBottom-this._activeBuffer.y;return e>=0?this._moveCursor(0,Math.min(e,t.params[0]||1)):this._moveCursor(0,t.params[0]||1),!0}cursorForward(t){return this._moveCursor(t.params[0]||1,0),!0}cursorBackward(t){return this._moveCursor(-(t.params[0]||1),0),!0}cursorNextLine(t){return this.cursorDown(t),this._activeBuffer.x=0,!0}cursorPrecedingLine(t){return this.cursorUp(t),this._activeBuffer.x=0,!0}cursorCharAbsolute(t){return this._setCursor((t.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(t){return this._setCursor(t.length>=2?(t.params[1]||1)-1:0,(t.params[0]||1)-1),!0}charPosAbsolute(t){return this._setCursor((t.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(t){return this._moveCursor(t.params[0]||1,0),!0}linePosAbsolute(t){return this._setCursor(this._activeBuffer.x,(t.params[0]||1)-1),!0}vPositionRelative(t){return this._moveCursor(0,t.params[0]||1),!0}hVPosition(t){return this.cursorPosition(t),!0}tabClear(t){let e=t.params[0];return e===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:e===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(t){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=t.params[0]||1;for(;e--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(t){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=t.params[0]||1;for(;e--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(t){let e=t.params[0];return e===1&&(this._curAttrData.bg|=536870912),(e===2||e===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(t,e,s,i=!1,r=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);o.replaceCells(e,s,this._activeBuffer.getNullCell(this._eraseAttrData()),r),i&&(o.isWrapped=!1)}_resetBufferLine(t,e=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),e),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+t),s.isWrapped=!1)}eraseInDisplay(t,e=!1){this._restrictCursor(this._bufferService.cols);let s;switch(t.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,e);s<this._bufferService.rows;s++)this._resetBufferLine(s,e);this._dirtyRowTracker.markDirty(s);break;case 1:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s,0,this._activeBuffer.x+1,!0,e),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,e);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+s)?.getTrimmedLength(););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,e);this._dirtyRowTracker.markDirty(0)}break;case 3:let i=this._activeBuffer.lines.length-this._bufferService.rows;i>0&&(this._activeBuffer.lines.trimStart(i),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-i,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-i,0),this._onScroll.fire(0));break}return!0}eraseInLine(t,e=!1){switch(this._restrictCursor(this._bufferService.cols),t.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,e);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,e);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,e);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(t){this._restrictCursor();let e=t.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-i+1;for(;e--;)this._activeBuffer.lines.splice(r-1,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(t){this._restrictCursor();let e=t.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i;for(i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-i;e--;)this._activeBuffer.lines.splice(s,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.insertCells(this._activeBuffer.x,t.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.deleteCells(this._activeBuffer.x,t.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(t){let e=t.params[0]||1;for(;e--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(t){let e=t.params[0]||1;for(;e--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine($e));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(0,e,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(0,e,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(this._activeBuffer.x,e,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(this._activeBuffer.x,e,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(t.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(t){let e=this._parser.precedingJoinState;if(!e)return!0;let s=t.params[0]||1,i=rs.extractWidth(e),r=this._activeBuffer.x-i,o=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),a=new Uint32Array(o.length*s),l=0;for(let c=0;c<o.length;){let d=o.codePointAt(c)||0;a[l++]=d,c+=d>65535?2:1}let h=l;for(let c=1;c<s;++c)a.copyWithin(h,0,l),h+=l;return this.print(a,0,h),!0}sendDeviceAttributesPrimary(t){return t.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(G.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(G.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(t){return t.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(G.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(G.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(t.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(G.ESC+"[>83;40003;0c")),!0}_is(t){return(this._optionsService.rawOptions.termName+"").indexOf(t)===0}setMode(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,is),this._charsetService.setgCharset(1,is),this._charsetService.setgCharset(2,is),this._charsetService.setgCharset(3,is);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),t.params[e]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(t,e){let s;(_=>(_[_.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",_[_.SET=1]="SET",_[_.RESET=2]="RESET",_[_.PERMANENTLY_SET=3]="PERMANENTLY_SET",_[_.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(s||={});let i=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:o}=this._coreMouseService,a=this._coreService,{buffers:l,cols:h}=this._bufferService,{active:c,alt:d}=l,u=this._optionsService.rawOptions,f=(_,g)=>(a.triggerDataEvent(`${G.ESC}[${e?"":"?"}${_};${g}$y`),!0),p=_=>_?1:2,m=t.params[0];return e?m===2?f(m,4):m===4?f(m,p(a.modes.insertMode)):m===12?f(m,3):m===20?f(m,p(u.convertEol)):f(m,0):m===1?f(m,p(i.applicationCursorKeys)):m===3?f(m,u.windowOptions.setWinLines?h===80?2:h===132?1:0:0):m===6?f(m,p(i.origin)):m===7?f(m,p(i.wraparound)):m===8?f(m,3):m===9?f(m,p(r==="X10")):m===12?f(m,p(u.cursorBlink)):m===25?f(m,p(!a.isCursorHidden)):m===45?f(m,p(i.reverseWraparound)):m===66?f(m,p(i.applicationKeypad)):m===67?f(m,4):m===1e3?f(m,p(r==="VT200")):m===1002?f(m,p(r==="DRAG")):m===1003?f(m,p(r==="ANY")):m===1004?f(m,p(i.sendFocus)):m===1005?f(m,4):m===1006?f(m,p(o==="SGR")):m===1015?f(m,4):m===1016?f(m,p(o==="SGR_PIXELS")):m===1048?f(m,1):m===47||m===1047||m===1049?f(m,p(c===d)):m===2004?f(m,p(i.bracketedPasteMode)):m===2026?f(m,p(i.synchronizedOutput)):f(m,0)}_updateAttrColor(t,e,s,i,r){return e===2?(t|=50331648,t&=-16777216,t|=ji.fromColorRGB([s,i,r])):e===5&&(t&=-50331904,t|=33554432|s&255),t}_extractColor(t,e,s){let i=[0,0,-1,0,0,0],r=0,o=0;do{if(i[o+r]=t.params[e+o],t.hasSubParams(e+o)){let a=t.getSubParams(e+o),l=0;do i[1]===5&&(r=1),i[o+l+1+r]=a[l];while(++l<a.length&&l+o+1+r<i.length);break}if(i[1]===5&&o+r>=2||i[1]===2&&o+r>=5)break;i[1]&&(r=1)}while(++o+e<t.length&&o+r<i.length);for(let a=2;a<i.length;++a)i[a]===-1&&(i[a]=0);switch(i[0]){case 38:s.fg=this._updateAttrColor(s.fg,i[1],i[3],i[4],i[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,i[1],i[3],i[4],i[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,i[1],i[3],i[4],i[5])}return o}_processUnderline(t,e){e.extended=e.extended.clone(),(!~t||t>5)&&(t=1),e.extended.underlineStyle=t,e.fg|=268435456,t===0&&(e.fg&=-268435457),e.updateExtended()}_processSGR0(t){t.fg=$e.fg,t.bg=$e.bg,t.extended=t.extended.clone(),t.extended.underlineStyle=0,t.extended.underlineColor&=-67108864,t.updateExtended()}charAttributes(t){if(t.length===1&&t.params[0]===0)return this._processSGR0(this._curAttrData),!0;let e=t.length,s,i=this._curAttrData;for(let r=0;r<e;r++)s=t.params[r],s>=30&&s<=37?(i.fg&=-50331904,i.fg|=16777216|s-30):s>=40&&s<=47?(i.bg&=-50331904,i.bg|=16777216|s-40):s>=90&&s<=97?(i.fg&=-50331904,i.fg|=16777216|s-90|8):s>=100&&s<=107?(i.bg&=-50331904,i.bg|=16777216|s-100|8):s===0?this._processSGR0(i):s===1?i.fg|=134217728:s===3?i.bg|=67108864:s===4?(i.fg|=268435456,this._processUnderline(t.hasSubParams(r)?t.getSubParams(r)[0]:1,i)):s===5?i.fg|=536870912:s===7?i.fg|=67108864:s===8?i.fg|=1073741824:s===9?i.fg|=2147483648:s===2?i.bg|=134217728:s===21?this._processUnderline(2,i):s===22?(i.fg&=-134217729,i.bg&=-134217729):s===23?i.bg&=-67108865:s===24?(i.fg&=-268435457,this._processUnderline(0,i)):s===25?i.fg&=-536870913:s===27?i.fg&=-67108865:s===28?i.fg&=-1073741825:s===29?i.fg&=2147483647:s===39?(i.fg&=-67108864,i.fg|=$e.fg&16777215):s===49?(i.bg&=-67108864,i.bg|=$e.bg&16777215):s===38||s===48||s===58?r+=this._extractColor(t,r,i):s===53?i.bg|=1073741824:s===55?i.bg&=-1073741825:s===59?(i.extended=i.extended.clone(),i.extended.underlineColor=-1,i.updateExtended()):s===100?(i.fg&=-67108864,i.fg|=$e.fg&16777215,i.bg&=-67108864,i.bg|=$e.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(t){switch(t.params[0]){case 5:this._coreService.triggerDataEvent(`${G.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${G.ESC}[${e};${s}R`);break}return!0}deviceStatusPrivate(t){if(t.params[0]===6){let e=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${G.ESC}[?${e};${s}R`)}return!0}softReset(t){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=$e.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(t){let e=t.length===0?1:t.params[0];if(e===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(e){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let s=e%2===1;this._coreService.decPrivateModes.cursorBlink=s}return!0}setScrollRegion(t){let e=t.params[0]||1,s;return(t.length<2||(s=t.params[1])>this._bufferService.rows||s===0)&&(s=this._bufferService.rows),s>e&&(this._activeBuffer.scrollTop=e-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(t){if(!nl(t.params[0],this._optionsService.rawOptions.windowOptions))return!0;let e=t.length>1?t.params[1]:0;switch(t.params[0]){case 14:e!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${G.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(e===0||e===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>rl&&this._windowTitleStack.shift()),(e===0||e===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>rl&&this._iconNameStack.shift());break;case 23:(e===0||e===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(e===0||e===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(t){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(t){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(t){return this._windowTitle=t,this._onTitleChange.fire(t),!0}setIconName(t){return this._iconName=t,!0}setOrReportIndexedColor(t){let e=[],s=t.split(";");for(;s.length>1;){let i=s.shift(),r=s.shift();if(/^\d+$/.exec(i)){let o=parseInt(i);if(ll(o))if(r==="?")e.push({type:0,index:o});else{let a=il(r);a&&e.push({type:1,index:o,color:a})}}}return e.length&&this._onColor.fire(e),!0}setHyperlink(t){let e=t.indexOf(";");if(e===-1)return!0;let s=t.slice(0,e).trim(),i=t.slice(e+1);return i?this._createHyperlink(s,i):s.trim()?!1:this._finishHyperlink()}_createHyperlink(t,e){this._getCurrentLinkId()&&this._finishHyperlink();let s=t.split(":"),i,r=s.findIndex(o=>o.startsWith("id="));return r!==-1&&(i=s[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:i,uri:e}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(t,e){let s=t.split(";");for(let i=0;i<s.length&&!(e>=this._specialColors.length);++i,++e)if(s[i]==="?")this._onColor.fire([{type:0,index:this._specialColors[e]}]);else{let r=il(s[i]);r&&this._onColor.fire([{type:1,index:this._specialColors[e],color:r}])}return!0}setOrReportFgColor(t){return this._setOrReportSpecialColor(t,0)}setOrReportBgColor(t){return this._setOrReportSpecialColor(t,1)}setOrReportCursorColor(t){return this._setOrReportSpecialColor(t,2)}restoreIndexedColor(t){if(!t)return this._onColor.fire([{type:2}]),!0;let e=[],s=t.split(";");for(let i=0;i<s.length;++i)if(/^\d+$/.exec(s[i])){let r=parseInt(s[i]);ll(r)&&e.push({type:2,index:r})}return e.length&&this._onColor.fire(e),!0}restoreFgColor(t){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(t){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(t){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,is),!0}selectCharset(t){return t.length!==2?(this.selectDefaultCharset(),!0):(t[0]==="/"||this._charsetService.setgCharset(q1[t[0]],We[t[1]]||is),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let t=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,t,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=$e.clone(),this._eraseAttrDataInternal=$e.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(t){return this._charsetService.setgLevel(t),!0}screenAlignmentPattern(){let t=new gt;t.content=1<<22|69,t.fg=this._curAttrData.fg,t.bg=this._curAttrData.bg,this._setCursor(0,0);for(let e=0;e<this._bufferService.rows;++e){let s=this._activeBuffer.ybase+this._activeBuffer.y+e,i=this._activeBuffer.lines.get(s);i&&(i.fill(t),i.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(t,e){let s=a=>(this._coreService.triggerDataEvent(`${G.ESC}${a}${G.ESC}\\`),!0),i=this._bufferService.buffer,r=this._optionsService.rawOptions;return s(t==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:t==='"p'?'P1$r61;1"p':t==="r"?`P1$r${i.scrollTop+1};${i.scrollBottom+1}r`:t==="m"?"P1$r0m":t===" q"?`P1$r${{block:2,underline:4,bar:6}[r.cursorStyle]-(r.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(t,e){this._dirtyRowTracker.markRangeDirty(t,e)}},Hn=class{constructor(t){this._bufferService=t,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(t){t<this.start?this.start=t:t>this.end&&(this.end=t)}markRangeDirty(t,e){t>e&&(al=t,t=e,e=al),t<this.start&&(this.start=t),e>this.end&&(this.end=e)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Hn=Be([oe(0,st)],Hn);function ll(t){return 0<=t&&t<256}var Y1=5e7,cl=12,X1=50,J1=class extends pe{constructor(t){super(),this._action=t,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new ee),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(t,e){if(e!==void 0&&this._syncCalls>e){this._syncCalls=0;return}if(this._pendingData+=t.length,this._writeBuffer.push(t),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let s;for(;s=this._writeBuffer.shift();){this._action(s);let i=this._callbacks.shift();i&&i()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(t,e){if(this._pendingData>Y1)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=t.length,this._writeBuffer.push(t),this._callbacks.push(e),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=t.length,this._writeBuffer.push(t),this._callbacks.push(e)}_innerWrite(t=0,e=!0){let s=t||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let i=this._writeBuffer[this._bufferOffset],r=this._action(i,e);if(r){let a=l=>performance.now()-s>=cl?setTimeout(()=>this._innerWrite(0,l)):this._innerWrite(s,l);r.catch(l=>(queueMicrotask(()=>{throw l}),Promise.resolve(!1))).then(a);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=i.length,performance.now()-s>=cl)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>X1&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},Wn=class{constructor(t){this._bufferService=t,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(t){let e=this._bufferService.buffer;if(t.id===void 0){let l=e.addMarker(e.ybase+e.y),h={data:t,id:this._nextId++,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(h,l)),this._dataByLinkId.set(h.id,h),h.id}let s=t,i=this._getEntryIdKey(s),r=this._entriesWithId.get(i);if(r)return this.addLineToLink(r.id,e.ybase+e.y),r.id;let o=e.addMarker(e.ybase+e.y),a={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(a,o)),this._entriesWithId.set(a.key,a),this._dataByLinkId.set(a.id,a),a.id}addLineToLink(t,e){let s=this._dataByLinkId.get(t);if(s&&s.lines.every(i=>i.line!==e)){let i=this._bufferService.buffer.addMarker(e);s.lines.push(i),i.onDispose(()=>this._removeMarkerFromLink(s,i))}}getLinkData(t){return this._dataByLinkId.get(t)?.data}_getEntryIdKey(t){return`${t.id};;${t.uri}`}_removeMarkerFromLink(t,e){let s=t.lines.indexOf(e);s!==-1&&(t.lines.splice(s,1),t.lines.length===0&&(t.data.id!==void 0&&this._entriesWithId.delete(t.key),this._dataByLinkId.delete(t.id)))}};Wn=Be([oe(0,st)],Wn);var hl=!1,Z1=class extends pe{constructor(t){super(),this._windowsWrappingHeuristics=this._register(new Ns),this._onBinary=this._register(new ee),this.onBinary=this._onBinary.event,this._onData=this._register(new ee),this.onData=this._onData.event,this._onLineFeed=this._register(new ee),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new ee),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new ee),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new ee),this._instantiationService=new S1,this.optionsService=this._register(new D1(t)),this._instantiationService.setService(it,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(On)),this._instantiationService.setService(st,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Ln)),this._instantiationService.setService(Yc,this._logService),this.coreService=this._register(this._instantiationService.createInstance($n)),this._instantiationService.setService(gs,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(zn)),this._instantiationService.setService(Gc,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(rs)),this._instantiationService.setService(vg,this.unicodeService),this._charsetService=this._instantiationService.createInstance(L1),this._instantiationService.setService(gg,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Wn),this._instantiationService.setService(Xc,this._oscLinkService),this._inputHandler=this._register(new G1(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Ze.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Ze.forward(this._bufferService.onResize,this._onResize)),this._register(Ze.forward(this.coreService.onData,this._onData)),this._register(Ze.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new J1((e,s)=>this._inputHandler.parse(e,s))),this._register(Ze.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new ee),this._onScroll.event(t=>{this._onScrollApi?.fire(t.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(t){for(let e in t)this.optionsService.options[e]=t[e]}write(t,e){this._writeBuffer.write(t,e)}writeSync(t,e){this._logService.logLevel<=3&&!hl&&(this._logService.warn("writeSync is unreliable and will be removed soon."),hl=!0),this._writeBuffer.writeSync(t,e)}input(t,e=!0){this.coreService.triggerDataEvent(t,e)}resize(t,e){isNaN(t)||isNaN(e)||(t=Math.max(t,Eh),e=Math.max(e,Th),this._bufferService.resize(t,e))}scroll(t,e=!1){this._bufferService.scroll(t,e)}scrollLines(t,e){this._bufferService.scrollLines(t,e)}scrollPages(t){this.scrollLines(t*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(t){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(t){let e=t-this._bufferService.buffer.ydisp;e!==0&&this.scrollLines(e)}registerEscHandler(t,e){return this._inputHandler.registerEscHandler(t,e)}registerDcsHandler(t,e){return this._inputHandler.registerDcsHandler(t,e)}registerCsiHandler(t,e){return this._inputHandler.registerCsiHandler(t,e)}registerOscHandler(t,e){return this._inputHandler.registerOscHandler(t,e)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let t=!1,e=this.optionsService.rawOptions.windowsPty;e&&e.buildNumber!==void 0&&e.buildNumber!==void 0?t=e.backend==="conpty"&&e.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(t=!0),t?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let t=[];t.push(this.onLineFeed(tl.bind(null,this._bufferService))),t.push(this.registerCsiHandler({final:"H"},()=>(tl(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Ee(()=>{for(let e of t)e.dispose()})}}},Q1={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function ex(t,e,s,i){let r={type:0,cancel:!1,key:void 0},o=(t.shiftKey?1:0)|(t.altKey?2:0)|(t.ctrlKey?4:0)|(t.metaKey?8:0);switch(t.keyCode){case 0:t.key==="UIKeyInputUpArrow"?e?r.key=G.ESC+"OA":r.key=G.ESC+"[A":t.key==="UIKeyInputLeftArrow"?e?r.key=G.ESC+"OD":r.key=G.ESC+"[D":t.key==="UIKeyInputRightArrow"?e?r.key=G.ESC+"OC":r.key=G.ESC+"[C":t.key==="UIKeyInputDownArrow"&&(e?r.key=G.ESC+"OB":r.key=G.ESC+"[B");break;case 8:r.key=t.ctrlKey?"\b":G.DEL,t.altKey&&(r.key=G.ESC+r.key);break;case 9:if(t.shiftKey){r.key=G.ESC+"[Z";break}r.key=G.HT,r.cancel=!0;break;case 13:r.key=t.altKey?G.ESC+G.CR:G.CR,r.cancel=!0;break;case 27:r.key=G.ESC,t.altKey&&(r.key=G.ESC+G.ESC),r.cancel=!0;break;case 37:if(t.metaKey)break;o?r.key=G.ESC+"[1;"+(o+1)+"D":e?r.key=G.ESC+"OD":r.key=G.ESC+"[D";break;case 39:if(t.metaKey)break;o?r.key=G.ESC+"[1;"+(o+1)+"C":e?r.key=G.ESC+"OC":r.key=G.ESC+"[C";break;case 38:if(t.metaKey)break;o?r.key=G.ESC+"[1;"+(o+1)+"A":e?r.key=G.ESC+"OA":r.key=G.ESC+"[A";break;case 40:if(t.metaKey)break;o?r.key=G.ESC+"[1;"+(o+1)+"B":e?r.key=G.ESC+"OB":r.key=G.ESC+"[B";break;case 45:!t.shiftKey&&!t.ctrlKey&&(r.key=G.ESC+"[2~");break;case 46:o?r.key=G.ESC+"[3;"+(o+1)+"~":r.key=G.ESC+"[3~";break;case 36:o?r.key=G.ESC+"[1;"+(o+1)+"H":e?r.key=G.ESC+"OH":r.key=G.ESC+"[H";break;case 35:o?r.key=G.ESC+"[1;"+(o+1)+"F":e?r.key=G.ESC+"OF":r.key=G.ESC+"[F";break;case 33:t.shiftKey?r.type=2:t.ctrlKey?r.key=G.ESC+"[5;"+(o+1)+"~":r.key=G.ESC+"[5~";break;case 34:t.shiftKey?r.type=3:t.ctrlKey?r.key=G.ESC+"[6;"+(o+1)+"~":r.key=G.ESC+"[6~";break;case 112:o?r.key=G.ESC+"[1;"+(o+1)+"P":r.key=G.ESC+"OP";break;case 113:o?r.key=G.ESC+"[1;"+(o+1)+"Q":r.key=G.ESC+"OQ";break;case 114:o?r.key=G.ESC+"[1;"+(o+1)+"R":r.key=G.ESC+"OR";break;case 115:o?r.key=G.ESC+"[1;"+(o+1)+"S":r.key=G.ESC+"OS";break;case 116:o?r.key=G.ESC+"[15;"+(o+1)+"~":r.key=G.ESC+"[15~";break;case 117:o?r.key=G.ESC+"[17;"+(o+1)+"~":r.key=G.ESC+"[17~";break;case 118:o?r.key=G.ESC+"[18;"+(o+1)+"~":r.key=G.ESC+"[18~";break;case 119:o?r.key=G.ESC+"[19;"+(o+1)+"~":r.key=G.ESC+"[19~";break;case 120:o?r.key=G.ESC+"[20;"+(o+1)+"~":r.key=G.ESC+"[20~";break;case 121:o?r.key=G.ESC+"[21;"+(o+1)+"~":r.key=G.ESC+"[21~";break;case 122:o?r.key=G.ESC+"[23;"+(o+1)+"~":r.key=G.ESC+"[23~";break;case 123:o?r.key=G.ESC+"[24;"+(o+1)+"~":r.key=G.ESC+"[24~";break;default:if(t.ctrlKey&&!t.shiftKey&&!t.altKey&&!t.metaKey)t.keyCode>=65&&t.keyCode<=90?r.key=String.fromCharCode(t.keyCode-64):t.keyCode===32?r.key=G.NUL:t.keyCode>=51&&t.keyCode<=55?r.key=String.fromCharCode(t.keyCode-51+27):t.keyCode===56?r.key=G.DEL:t.keyCode===219?r.key=G.ESC:t.keyCode===220?r.key=G.FS:t.keyCode===221&&(r.key=G.GS);else if((!s||i)&&t.altKey&&!t.metaKey){let a=Q1[t.keyCode]?.[t.shiftKey?1:0];if(a)r.key=G.ESC+a;else if(t.keyCode>=65&&t.keyCode<=90){let l=t.ctrlKey?t.keyCode-64:t.keyCode+32,h=String.fromCharCode(l);t.shiftKey&&(h=h.toUpperCase()),r.key=G.ESC+h}else if(t.keyCode===32)r.key=G.ESC+(t.ctrlKey?G.NUL:" ");else if(t.key==="Dead"&&t.code.startsWith("Key")){let l=t.code.slice(3,4);t.shiftKey||(l=l.toLowerCase()),r.key=G.ESC+l,r.cancel=!0}}else s&&!t.altKey&&!t.ctrlKey&&!t.shiftKey&&t.metaKey?t.keyCode===65&&(r.type=1):t.key&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&t.keyCode>=48&&t.key.length===1?r.key=t.key:t.key&&t.ctrlKey&&(t.key==="_"&&(r.key=G.US),t.key==="@"&&(r.key=G.NUL));break}return r}var Oe=0,tx=class{constructor(t){this._getKey=t,this._array=[],this._insertedValues=[],this._flushInsertedTask=new pr,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new pr,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(t){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(t)}_flushInserted(){let t=this._insertedValues.sort((r,o)=>this._getKey(r)-this._getKey(o)),e=0,s=0,i=new Array(this._array.length+this._insertedValues.length);for(let r=0;r<i.length;r++)s>=this._array.length||this._getKey(t[e])<=this._getKey(this._array[s])?(i[r]=t[e],e++):i[r]=this._array[s++];this._array=i,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(t){if(this._flushCleanupInserted(),this._array.length===0)return!1;let e=this._getKey(t);if(e===void 0||(Oe=this._search(e),Oe===-1)||this._getKey(this._array[Oe])!==e)return!1;do if(this._array[Oe]===t)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Oe),!0;while(++Oe<this._array.length&&this._getKey(this._array[Oe])===e);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let t=this._deletedIndices.sort((r,o)=>r-o),e=0,s=new Array(this._array.length-t.length),i=0;for(let r=0;r<this._array.length;r++)t[e]===r?e++:s[i++]=this._array[r];this._array=s,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Oe=this._search(t),!(Oe<0||Oe>=this._array.length)&&this._getKey(this._array[Oe])===t))do yield this._array[Oe];while(++Oe<this._array.length&&this._getKey(this._array[Oe])===t)}forEachByKey(t,e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Oe=this._search(t),!(Oe<0||Oe>=this._array.length)&&this._getKey(this._array[Oe])===t))do e(this._array[Oe]);while(++Oe<this._array.length&&this._getKey(this._array[Oe])===t)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(t){let e=0,s=this._array.length-1;for(;s>=e;){let i=e+s>>1,r=this._getKey(this._array[i]);if(r>t)s=i-1;else if(r<t)e=i+1;else{for(;i>0&&this._getKey(this._array[i-1])===t;)i--;return i}}return e}},en=0,dl=0,sx=class extends pe{constructor(){super(),this._decorations=new tx(t=>t?.marker.line),this._onDecorationRegistered=this._register(new ee),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new ee),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Ee(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(t){if(t.marker.isDisposed)return;let e=new ix(t);if(e){let s=e.marker.onDispose(()=>e.dispose()),i=e.onDispose(()=>{i.dispose(),e&&(this._decorations.delete(e)&&this._onDecorationRemoved.fire(e),s.dispose())});this._decorations.insert(e),this._onDecorationRegistered.fire(e)}return e}reset(){for(let t of this._decorations.values())t.dispose();this._decorations.clear()}*getDecorationsAtCell(t,e,s){let i=0,r=0;for(let o of this._decorations.getKeyIterator(e))i=o.options.x??0,r=i+(o.options.width??1),t>=i&&t<r&&(!s||(o.options.layer??"bottom")===s)&&(yield o)}forEachDecorationAtCell(t,e,s,i){this._decorations.forEachByKey(e,r=>{en=r.options.x??0,dl=en+(r.options.width??1),t>=en&&t<dl&&(!s||(r.options.layer??"bottom")===s)&&i(r)})}},ix=class extends Jt{constructor(t){super(),this.options=t,this.onRenderEmitter=this.add(new ee),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new ee),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=t.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=Re.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Re.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},rx=1e3,nx=class{constructor(t,e=rx){this._renderCallback=t,this._debounceThresholdMS=e,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(t,e,s){this._rowCount=s,t=t!==void 0?t:0,e=e!==void 0?e:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,t):t,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,e):e;let i=performance.now();if(i-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=i,this._innerRefresh();else if(!this._additionalRefreshRequested){let r=i-this._lastRefreshMs,o=this._debounceThresholdMS-r;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},o)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let t=Math.max(this._rowStart,0),e=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(t,e)}},ul=20,_r=class extends pe{constructor(t,e,s,i){super(),this._terminal=t,this._coreBrowserService=s,this._renderService=i,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let r=this._coreBrowserService.mainDocument;this._accessibilityContainer=r.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=r.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let o=0;o<this._terminal.rows;o++)this._rowElements[o]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[o]);if(this._topBoundaryFocusListener=o=>this._handleBoundaryFocus(o,0),this._bottomBoundaryFocusListener=o=>this._handleBoundaryFocus(o,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=r.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new nx(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(o=>this._handleResize(o.rows))),this._register(this._terminal.onRender(o=>this._refreshRows(o.start,o.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(o=>this._handleChar(o))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
286
286
|
`))),this._register(this._terminal.onA11yTab(o=>this._handleTab(o))),this._register(this._terminal.onKey(o=>this._handleKey(o.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(he(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Ee(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(t){for(let e=0;e<t;e++)this._handleChar(" ")}_handleChar(t){this._liveRegionLineCount<ul+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==t&&(this._charsToAnnounce+=t):this._charsToAnnounce+=t,t===`
|
|
287
287
|
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===ul+1&&(this._liveRegion.textContent+=cn.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(t){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(t)||this._charsToConsume.push(t)}_refreshRows(t,e){this._liveRegionDebouncer.refresh(t,e,this._terminal.rows)}_renderRows(t,e){let s=this._terminal.buffer,i=s.lines.length.toString();for(let r=t;r<=e;r++){let o=s.lines.get(s.ydisp+r),a=[],l=o?.translateToString(!0,void 0,void 0,a)||"",h=(s.ydisp+r+1).toString(),c=this._rowElements[r];c&&(l.length===0?(c.textContent=" ",this._rowColumns.set(c,[0,1])):(c.textContent=l,this._rowColumns.set(c,a)),c.setAttribute("aria-posinset",h),c.setAttribute("aria-setsize",i),this._alignRowWidth(c))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(t,e){let s=t.target,i=this._rowElements[e===0?1:this._rowElements.length-2],r=s.getAttribute("aria-posinset"),o=e===0?"1":`${this._terminal.buffer.lines.length}`;if(r===o||t.relatedTarget!==i)return;let a,l;if(e===0?(a=s,l=this._rowElements.pop(),this._rowContainer.removeChild(l)):(a=this._rowElements.shift(),l=s,this._rowContainer.removeChild(a)),a.removeEventListener("focus",this._topBoundaryFocusListener),l.removeEventListener("focus",this._bottomBoundaryFocusListener),e===0){let h=this._createAccessibilityTreeNode();this._rowElements.unshift(h),this._rowContainer.insertAdjacentElement("afterbegin",h)}else{let h=this._createAccessibilityTreeNode();this._rowElements.push(h),this._rowContainer.appendChild(h)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(e===0?-1:1),this._rowElements[e===0?1:this._rowElements.length-2].focus(),t.preventDefault(),t.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let t=this._coreBrowserService.mainDocument.getSelection();if(!t)return;if(t.isCollapsed){this._rowContainer.contains(t.anchorNode)&&this._terminal.clearSelection();return}if(!t.anchorNode||!t.focusNode){console.error("anchorNode and/or focusNode are null");return}let e={node:t.anchorNode,offset:t.anchorOffset},s={node:t.focusNode,offset:t.focusOffset};if((e.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||e.node===s.node&&e.offset>s.offset)&&([e,s]=[s,e]),e.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(e={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(e.node))return;let i=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(i)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:i,offset:i.textContent?.length??0}),!this._rowContainer.contains(s.node))return;let r=({node:l,offset:h})=>{let c=l instanceof Text?l.parentNode:l,d=parseInt(c?.getAttribute("aria-posinset"),10)-1;if(isNaN(d))return console.warn("row is invalid. Race condition?"),null;let u=this._rowColumns.get(c);if(!u)return console.warn("columns is null. Race condition?"),null;let f=h<u.length?u[h]:u.slice(-1)[0]+1;return f>=this._terminal.cols&&(++d,f=0),{row:d,column:f}},o=r(e),a=r(s);if(!(!o||!a)){if(o.row>a.row||o.row===a.row&&o.column>=a.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(a.row-o.row)*this._terminal.cols-o.column+a.column)}}_handleResize(t){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let t=this._coreBrowserService.mainDocument.createElement("div");return t.setAttribute("role","listitem"),t.tabIndex=-1,this._refreshRowDimensions(t),t}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let t=0;t<this._terminal.rows;t++)this._refreshRowDimensions(this._rowElements[t]),this._alignRowWidth(this._rowElements[t])}}_refreshRowDimensions(t){t.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(t){t.style.transform="";let e=t.getBoundingClientRect().width,s=this._rowColumns.get(t)?.slice(-1)?.[0];if(!s)return;let i=s*this._renderService.dimensions.css.cell.width;t.style.transform=`scaleX(${i/e})`}};_r=Be([oe(1,ko),oe(2,Wt),oe(3,Ut)],_r);var Un=class extends pe{constructor(t,e,s,i,r){super(),this._element=t,this._mouseService=e,this._renderService=s,this._bufferService=i,this._linkProviderService=r,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new ee),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new ee),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Ee(()=>{ls(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(he(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(he(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(he(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(he(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(t){this._lastMouseEvent=t;let e=this._positionFromMouseEvent(t,this._element,this._mouseService);if(!e)return;this._isMouseOut=!1;let s=t.composedPath();for(let i=0;i<s.length;i++){let r=s[i];if(r.classList.contains("xterm"))break;if(r.classList.contains("xterm-hover"))return}(!this._lastBufferCell||e.x!==this._lastBufferCell.x||e.y!==this._lastBufferCell.y)&&(this._handleHover(e),this._lastBufferCell=e)}_handleHover(t){if(this._activeLine!==t.y||this._wasResized){this._clearCurrentLink(),this._askForLink(t,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,t)||(this._clearCurrentLink(),this._askForLink(t,!0))}_askForLink(t,e){(!this._activeProviderReplies||!e)&&(this._activeProviderReplies?.forEach(i=>{i?.forEach(r=>{r.link.dispose&&r.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=t.y);let s=!1;for(let[i,r]of this._linkProviderService.linkProviders.entries())e?this._activeProviderReplies?.get(i)&&(s=this._checkLinkProviderResult(i,t,s)):r.provideLinks(t.y,o=>{if(this._isMouseOut)return;let a=o?.map(l=>({link:l}));this._activeProviderReplies?.set(i,a),s=this._checkLinkProviderResult(i,t,s),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(t.y,this._activeProviderReplies)})}_removeIntersectingLinks(t,e){let s=new Set;for(let i=0;i<e.size;i++){let r=e.get(i);if(r)for(let o=0;o<r.length;o++){let a=r[o],l=a.link.range.start.y<t?0:a.link.range.start.x,h=a.link.range.end.y>t?this._bufferService.cols:a.link.range.end.x;for(let c=l;c<=h;c++){if(s.has(c)){r.splice(o--,1);break}s.add(c)}}}}_checkLinkProviderResult(t,e,s){if(!this._activeProviderReplies)return s;let i=this._activeProviderReplies.get(t),r=!1;for(let o=0;o<t;o++)(!this._activeProviderReplies.has(o)||this._activeProviderReplies.get(o))&&(r=!0);if(!r&&i){let o=i.find(a=>this._linkAtPosition(a.link,e));o&&(s=!0,this._handleNewLink(o))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let o=0;o<this._activeProviderReplies.size;o++){let a=this._activeProviderReplies.get(o)?.find(l=>this._linkAtPosition(l.link,e));if(a){s=!0,this._handleNewLink(a);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(t){if(!this._currentLink)return;let e=this._positionFromMouseEvent(t,this._element,this._mouseService);e&&this._mouseDownLink&&ox(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,e)&&this._currentLink.link.activate(t,this._currentLink.link.text)}_clearCurrentLink(t,e){!this._currentLink||!this._lastMouseEvent||(!t||!e||this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=e)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,ls(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(t){if(!this._lastMouseEvent)return;let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._linkAtPosition(t.link,e)&&(this._currentLink=t,this._currentLink.state={decorations:{underline:t.link.decorations===void 0?!0:t.link.decorations.underline,pointerCursor:t.link.decorations===void 0?!0:t.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,t.link,this._lastMouseEvent),t.link.decorations={},Object.defineProperties(t.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:s=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==s&&(this._currentLink.state.decorations.pointerCursor=s,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",s))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:s=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==s&&(this._currentLink.state.decorations.underline=s,this._currentLink.state.isHovered&&this._fireUnderlineEvent(t.link,s))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(s=>{if(!this._currentLink)return;let i=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(i,r),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._askForLink(o,!1)}})))}_linkHover(t,e,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!0),this._currentLink.state.decorations.pointerCursor&&t.classList.add("xterm-cursor-pointer")),e.hover&&e.hover(s,e.text)}_fireUnderlineEvent(t,e){let s=t.range,i=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-i-1,s.end.x,s.end.y-i-1,void 0);(e?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_linkLeave(t,e,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!1),this._currentLink.state.decorations.pointerCursor&&t.classList.remove("xterm-cursor-pointer")),e.leave&&e.leave(s,e.text)}_linkAtPosition(t,e){let s=t.range.start.y*this._bufferService.cols+t.range.start.x,i=t.range.end.y*this._bufferService.cols+t.range.end.x,r=e.y*this._bufferService.cols+e.x;return s<=r&&r<=i}_positionFromMouseEvent(t,e,s){let i=s.getCoords(t,e,this._bufferService.cols,this._bufferService.rows);if(i)return{x:i[0],y:i[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(t,e,s,i,r){return{x1:t,y1:e,x2:s,y2:i,cols:this._bufferService.cols,fg:r}}};Un=Be([oe(1,jo),oe(2,Ut),oe(3,st),oe(4,Zc)],Un);function ox(t,e){return t.text===e.text&&t.range.start.x===e.range.start.x&&t.range.start.y===e.range.start.y&&t.range.end.x===e.range.end.x&&t.range.end.y===e.range.end.y}var ax=class extends Z1{constructor(t={}){super(t),this._linkifier=this._register(new Ns),this.browser=gh,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Ns),this._onCursorMove=this._register(new ee),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new ee),this.onKey=this._onKey.event,this._onRender=this._register(new ee),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new ee),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new ee),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new ee),this.onBell=this._onBell.event,this._onFocus=this._register(new ee),this._onBlur=this._register(new ee),this._onA11yCharEmitter=this._register(new ee),this._onA11yTabEmitter=this._register(new ee),this._onWillOpen=this._register(new ee),this._setup(),this._decorationService=this._instantiationService.createInstance(sx),this._instantiationService.setService(Ni,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Xv),this._instantiationService.setService(Zc,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(dn)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(Ze.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Ze.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Ze.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Ze.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(Ee(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(t){if(this._themeService)for(let e of t){let s,i="";switch(e.index){case 256:s="foreground",i="10";break;case 257:s="background",i="11";break;case 258:s="cursor",i="12";break;default:s="ansi",i="4;"+e.index}switch(e.type){case 0:let r=ye.toColorRGB(s==="ansi"?this._themeService.colors.ansi[e.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${G.ESC}]${i};${V1(r)}${ph.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(o=>o.ansi[e.index]=ze.toColor(...e.color));else{let o=s;this._themeService.modifyColors(a=>a[o]=ze.toColor(...e.color))}break;case 2:this._themeService.restoreColor(e.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(t){t?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(_r,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(t){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(G.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(G.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let t=this.buffer.ybase+this.buffer.y,e=this.buffer.lines.get(t);if(!e)return;let s=Math.min(this.buffer.x,this.cols-1),i=this._renderService.dimensions.css.cell.height,r=e.getWidth(s),o=this._renderService.dimensions.css.cell.width*r,a=this.buffer.y*this._renderService.dimensions.css.cell.height,l=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=a+"px",this.textarea.style.width=o+"px",this.textarea.style.height=i+"px",this.textarea.style.lineHeight=i+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(he(this.element,"copy",e=>{this.hasSelection()&&dg(e,this._selectionService)}));let t=e=>ug(e,this.textarea,this.coreService,this.optionsService);this._register(he(this.textarea,"paste",t)),this._register(he(this.element,"paste",t)),vh?this._register(he(this.element,"mousedown",e=>{e.button===2&&Sa(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(he(this.element,"contextmenu",e=>{Sa(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Mo&&this._register(he(this.element,"auxclick",e=>{e.button===1&&Wc(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(he(this.textarea,"keyup",t=>this._keyUp(t),!0)),this._register(he(this.textarea,"keydown",t=>this._keyDown(t),!0)),this._register(he(this.textarea,"keypress",t=>this._keyPress(t),!0)),this._register(he(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(he(this.textarea,"compositionupdate",t=>this._compositionHelper.compositionupdate(t))),this._register(he(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(he(this.textarea,"input",t=>this._inputEvent(t),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(t){if(!t)throw new Error("Terminal requires a parent element.");if(t.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=t.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),t.appendChild(this.element);let e=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),e.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(he(this.screenElement,"mousemove",r=>this.updateCursorStyle(r))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),e.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",ln.get()),yh||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(Gv,this.textarea,t.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Wt,this._coreBrowserService),this._register(he(this.textarea,"focus",r=>this._handleTextAreaFocus(r))),this._register(he(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Dn,this._document,this._helperContainer),this._instantiationService.setService(Rr,this._charSizeService),this._themeService=this._instantiationService.createInstance(In),this._instantiationService.setService(Os,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(fr),this._instantiationService.setService(Jc,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Mn,this.rows,this.screenElement)),this._instantiationService.setService(Ut,this._renderService),this._register(this._renderService.onRenderedViewportChange(r=>this._onRender.fire(r))),this.onResize(r=>this._renderService.resize(r.cols,r.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Tn,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(An),this._instantiationService.setService(jo,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(Un,this.screenElement));this.element.appendChild(e);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(Nn,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(r=>{super.scrollLines(r,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Bn,this.element,this.screenElement,i)),this._instantiationService.setService(bg,this._selectionService),this._register(this._selectionService.onRequestScrollLines(r=>this.scrollLines(r.amount,r.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(r=>this._renderService.handleSelectionChanged(r.start,r.end,r.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(r=>{this.textarea.value=r,this.textarea.focus(),this.textarea.select()})),this._register(Ze.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(En,this.screenElement)),this._register(he(this.element,"mousedown",r=>this._selectionService.handleMouseDown(r))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(_r,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",r=>this._handleScreenReaderModeOptionChange(r))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ur,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",r=>{!this._overviewRulerRenderer&&r&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ur,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Pn,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let t=this,e=this.element;function s(o){let a=t._mouseService.getMouseReportCoords(o,t.screenElement);if(!a)return!1;let l,h;switch(o.overrideType||o.type){case"mousemove":h=32,o.buttons===void 0?(l=3,o.button!==void 0&&(l=o.button<3?o.button:3)):l=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":h=0,l=o.button<3?o.button:3;break;case"mousedown":h=1,l=o.button<3?o.button:3;break;case"wheel":if(t._customWheelEventHandler&&t._customWheelEventHandler(o)===!1)return!1;let c=o.deltaY;if(c===0||t.coreMouseService.consumeWheelEvent(o,t._renderService?.dimensions?.device?.cell?.height,t._coreBrowserService?.dpr)===0)return!1;h=c<0?0:1,l=4;break;default:return!1}return h===void 0||l===void 0||l>4?!1:t.coreMouseService.triggerMouseEvent({col:a.col,row:a.row,x:a.x,y:a.y,button:l,action:h,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let i={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:o=>(s(o),o.buttons||(this._document.removeEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.removeEventListener("mousemove",i.mousedrag)),this.cancel(o)),wheel:o=>(s(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&s(o)},mousemove:o=>{o.buttons||s(o)}};this._register(this.coreMouseService.onProtocolChange(o=>{o?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(o)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),o&8?i.mousemove||(e.addEventListener("mousemove",r.mousemove),i.mousemove=r.mousemove):(e.removeEventListener("mousemove",i.mousemove),i.mousemove=null),o&16?i.wheel||(e.addEventListener("wheel",r.wheel,{passive:!1}),i.wheel=r.wheel):(e.removeEventListener("wheel",i.wheel),i.wheel=null),o&2?i.mouseup||(i.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",i.mouseup),i.mouseup=null),o&4?i.mousedrag||(i.mousedrag=r.mousedrag):(this._document.removeEventListener("mousemove",i.mousedrag),i.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(he(e,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return s(o),i.mouseup&&this._document.addEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.addEventListener("mousemove",i.mousedrag),this.cancel(o)})),this._register(he(e,"wheel",o=>{if(!i.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(o)===!1)return!1;if(!this.buffer.hasScrollback){if(o.deltaY===0)return!1;if(t.coreMouseService.consumeWheelEvent(o,t._renderService?.dimensions?.device?.cell?.height,t._coreBrowserService?.dpr)===0)return this.cancel(o,!0);let a=G.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(a,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(t,e){this._renderService?.refreshRows(t,e)}updateCursorStyle(t){this._selectionService?.shouldColumnSelect(t)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(t,e){this._viewport?this._viewport.scrollLines(t):super.scrollLines(t,e),this.refresh(0,this.rows-1)}scrollPages(t){this.scrollLines(t*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(t){t&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(t){let e=t-this._bufferService.buffer.ydisp;e!==0&&this.scrollLines(e)}paste(t){Hc(t,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(t){this._customKeyEventHandler=t}attachCustomWheelEventHandler(t){this._customWheelEventHandler=t}registerLinkProvider(t){return this._linkProviderService.registerLinkProvider(t)}registerCharacterJoiner(t){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let e=this._characterJoinerService.register(t);return this.refresh(0,this.rows-1),e}deregisterCharacterJoiner(t){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(t)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(t){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+t)}registerDecoration(t){return this._decorationService.registerDecoration(t)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(t,e,s){this._selectionService.setSelection(t,e,s)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(t,e){this._selectionService?.selectLines(t,e)}_keyDown(t){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(t)===!1)return!1;let e=this.browser.isMac&&this.options.macOptionIsMeta&&t.altKey;if(!e&&!this._compositionHelper.keydown(t))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!e&&(t.key==="Dead"||t.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let s=ex(t,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(t),s.type===3||s.type===2){let i=this.rows-1;return this.scrollLines(s.type===2?-i:i),this.cancel(t,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,t)||(s.cancel&&this.cancel(t,!0),!s.key)||t.key&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&t.key.length===1&&t.key.charCodeAt(0)>=65&&t.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((s.key===G.ETX||s.key===G.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:t}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||t.altKey||t.ctrlKey)return this.cancel(t,!0);this._keyDownHandled=!0}_isThirdLevelShift(t,e){let s=t.isMac&&!this.options.macOptionIsMeta&&e.altKey&&!e.ctrlKey&&!e.metaKey||t.isWindows&&e.altKey&&e.ctrlKey&&!e.metaKey||t.isWindows&&e.getModifierState("AltGraph");return e.type==="keypress"?s:s&&(!e.keyCode||e.keyCode>47)}_keyUp(t){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(t)===!1)&&(lx(t)||this.focus(),this.updateCursorStyle(t),this._keyPressHandled=!1)}_keyPress(t){let e;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(t)===!1)return!1;if(this.cancel(t),t.charCode)e=t.charCode;else if(t.which===null||t.which===void 0)e=t.keyCode;else if(t.which!==0&&t.charCode!==0)e=t.which;else return!1;return!e||(t.altKey||t.ctrlKey||t.metaKey)&&!this._isThirdLevelShift(this.browser,t)?!1:(e=String.fromCharCode(e),this._onKey.fire({key:e,domEvent:t}),this._showCursor(),this.coreService.triggerDataEvent(e,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(t){if(t.data&&t.inputType==="insertText"&&(!t.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let e=t.data;return this.coreService.triggerDataEvent(e,!0),this.cancel(t),!0}return!1}resize(t,e){if(t===this.cols&&e===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(t,e)}_afterResize(t,e){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let t=1;t<this.rows;t++)this.buffer.lines.push(this.buffer.getBlankLine($e));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let t=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=t,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(G.ESC+"[I"):this.coreService.triggerDataEvent(G.ESC+"[O")}_reportWindowsOptions(t){if(this._renderService)switch(t){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${G.ESC}[4;${s};${e}t`);break;case 1:let i=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${G.ESC}[6;${r};${i}t`);break}}cancel(t,e){if(!(!this.options.cancelEvents&&!e))return t.preventDefault(),t.stopPropagation(),!1}};function lx(t){return t.keyCode===16||t.keyCode===17||t.keyCode===18}var cx=class{constructor(){this._addons=[]}dispose(){for(let t=this._addons.length-1;t>=0;t--)this._addons[t].instance.dispose()}loadAddon(t,e){let s={instance:e,dispose:e.dispose,isDisposed:!1};this._addons.push(s),e.dispose=()=>this._wrappedAddonDispose(s),e.activate(t)}_wrappedAddonDispose(t){if(t.isDisposed)return;let e=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===t){e=s;break}if(e===-1)throw new Error("Could not dispose an addon that has not been loaded");t.isDisposed=!0,t.dispose.apply(t.instance),this._addons.splice(e,1)}},hx=class{constructor(t){this._line=t}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(t,e){if(!(t<0||t>=this._line.length))return e?(this._line.loadCell(t,e),e):this._line.loadCell(t,new gt)}translateToString(t,e,s){return this._line.translateToString(t,e,s)}},fl=class{constructor(t,e){this._buffer=t,this.type=e}init(t){return this._buffer=t,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(t){let e=this._buffer.lines.get(t);if(e)return new hx(e)}getNullCell(){return new gt}},dx=class extends pe{constructor(t){super(),this._core=t,this._onBufferChange=this._register(new ee),this.onBufferChange=this._onBufferChange.event,this._normal=new fl(this._core.buffers.normal,"normal"),this._alternate=new fl(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},ux=class{constructor(t){this._core=t}registerCsiHandler(t,e){return this._core.registerCsiHandler(t,s=>e(s.toArray()))}addCsiHandler(t,e){return this.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._core.registerDcsHandler(t,(s,i)=>e(s,i.toArray()))}addDcsHandler(t,e){return this.registerDcsHandler(t,e)}registerEscHandler(t,e){return this._core.registerEscHandler(t,e)}addEscHandler(t,e){return this.registerEscHandler(t,e)}registerOscHandler(t,e){return this._core.registerOscHandler(t,e)}addOscHandler(t,e){return this.registerOscHandler(t,e)}},fx=class{constructor(t){this._core=t}register(t){this._core.unicodeService.register(t)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(t){this._core.unicodeService.activeVersion=t}},mx=["cols","rows"],St=0,px=class extends pe{constructor(t){super(),this._core=this._register(new ax(t)),this._addonManager=this._register(new cx),this._publicOptions={...this._core.options};let e=i=>this._core.options[i],s=(i,r)=>{this._checkReadonlyOptions(i),this._core.options[i]=r};for(let i in this._core.options){let r={get:e.bind(this,i),set:s.bind(this,i)};Object.defineProperty(this._publicOptions,i,r)}}_checkReadonlyOptions(t){if(mx.includes(t))throw new Error(`Option "${t}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new ux(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new fx(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new dx(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let t=this._core.coreService.decPrivateModes,e="none";switch(this._core.coreMouseService.activeProtocol){case"X10":e="x10";break;case"VT200":e="vt200";break;case"DRAG":e="drag";break;case"ANY":e="any";break}return{applicationCursorKeysMode:t.applicationCursorKeys,applicationKeypadMode:t.applicationKeypad,bracketedPasteMode:t.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:e,originMode:t.origin,reverseWraparoundMode:t.reverseWraparound,sendFocusMode:t.sendFocus,synchronizedOutputMode:t.synchronizedOutput,wraparoundMode:t.wraparound}}get options(){return this._publicOptions}set options(t){for(let e in t)this._publicOptions[e]=t[e]}blur(){this._core.blur()}focus(){this._core.focus()}input(t,e=!0){this._core.input(t,e)}resize(t,e){this._verifyIntegers(t,e),this._core.resize(t,e)}open(t){this._core.open(t)}attachCustomKeyEventHandler(t){this._core.attachCustomKeyEventHandler(t)}attachCustomWheelEventHandler(t){this._core.attachCustomWheelEventHandler(t)}registerLinkProvider(t){return this._core.registerLinkProvider(t)}registerCharacterJoiner(t){return this._checkProposedApi(),this._core.registerCharacterJoiner(t)}deregisterCharacterJoiner(t){this._checkProposedApi(),this._core.deregisterCharacterJoiner(t)}registerMarker(t=0){return this._verifyIntegers(t),this._core.registerMarker(t)}registerDecoration(t){return this._checkProposedApi(),this._verifyPositiveIntegers(t.x??0,t.width??0,t.height??0),this._core.registerDecoration(t)}hasSelection(){return this._core.hasSelection()}select(t,e,s){this._verifyIntegers(t,e,s),this._core.select(t,e,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(t,e){this._verifyIntegers(t,e),this._core.selectLines(t,e)}dispose(){super.dispose()}scrollLines(t){this._verifyIntegers(t),this._core.scrollLines(t)}scrollPages(t){this._verifyIntegers(t),this._core.scrollPages(t)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(t){this._verifyIntegers(t),this._core.scrollToLine(t)}clear(){this._core.clear()}write(t,e){this._core.write(t,e)}writeln(t,e){this._core.write(t),this._core.write(`\r
|
|
288
|
-
`,e)}paste(t){this._core.paste(t)}refresh(t,e){this._verifyIntegers(t,e),this._core.refresh(t,e)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(t){this._addonManager.loadAddon(this,t)}static get strings(){return{get promptLabel(){return ln.get()},set promptLabel(t){ln.set(t)},get tooMuchOutput(){return cn.get()},set tooMuchOutput(t){cn.set(t)}}}_verifyIntegers(...t){for(St of t)if(St===1/0||isNaN(St)||St%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(St of t)if(St&&(St===1/0||isNaN(St)||St%1!==0||St<0))throw new Error("This API only accepts positive integers")}};var _x=2,gx=1,vx=class{activate(t){this._terminal=t}dispose(){}fit(){let t=this.proposeDimensions();if(!t||!this._terminal||isNaN(t.cols)||isNaN(t.rows))return;let e=this._terminal._core;(this._terminal.rows!==t.rows||this._terminal.cols!==t.cols)&&(e._renderService.clear(),this._terminal.resize(t.cols,t.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let t=this._terminal._core._renderService.dimensions;if(t.css.cell.width===0||t.css.cell.height===0)return;let e=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,s=window.getComputedStyle(this._terminal.element.parentElement),i=parseInt(s.getPropertyValue("height")),r=Math.max(0,parseInt(s.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),a={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},l=a.top+a.bottom,h=a.right+a.left,c=i-l,d=r-h-e;return{cols:Math.max(_x,Math.floor(d/t.css.cell.width)),rows:Math.max(gx,Math.floor(c/t.css.cell.height))}}};function xx({source:t,onReady:e,onSelectionChange:s,className:i}){const r=M.useRef(null),o=M.useRef(null),a=M.useRef(s);a.current=s;const l=es(),h=M.useRef(t);return h.current=t,Cm((c,d)=>{c===h.current&&o.current?.write(d)}),M.useEffect(()=>{const c=r.current;if(!c)return;const d=getComputedStyle(document.documentElement),u=x=>d.getPropertyValue(x).trim()||void 0,f=new px({allowTransparency:!1,fontFamily:u("--font-mono")||"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:12.5,lineHeight:1.5,scrollback:5e3,cursorBlink:!1,disableStdin:!0,theme:{background:u("--sidebar")||u("--card")||u("--background")||"#1e1e1e",cursor:"transparent",foreground:u("--foreground")||"#d4d4d4",selectionBackground:u("--accent"),selectionForeground:u("--accent-foreground"),black:u("--muted"),red:u("--destructive"),green:u("--success"),yellow:u("--warning"),blue:u("--chart-1"),magenta:u("--chart-3"),cyan:u("--chart-5"),white:u("--foreground"),brightBlack:u("--muted-foreground"),brightRed:u("--destructive"),brightGreen:u("--success"),brightYellow:u("--warning"),brightBlue:u("--chart-1"),brightMagenta:u("--chart-3"),brightCyan:u("--chart-5"),brightWhite:u("--foreground")}}),p=new vx;f.loadAddon(p),f.open(c),p.fit();const m=l.getBuffer(t);m&&f.write(m),o.current=f,e?.(f);const _=f.onSelectionChange(()=>{const x=!!f.getSelection();a.current?.(x,()=>f.getSelection())}),g=new ResizeObserver(()=>{p.fit()});return g.observe(c),()=>{_.dispose(),g.disconnect(),o.current=null,f.dispose()}},[]),n.jsx("div",{className:re("h-full bg-sidebar p-3",i),children:n.jsx("div",{ref:r,className:"h-full"})})}function bx(t){const e=es(),[s,i]=M.useState(os),[r,o]=M.useState([]),[a,l]=M.useState(new Set),h=M.useRef(!1);if(!h.current&&e.scripts.length>0){const b=eg.find(C=>e.scripts.includes(C));b&&(h.current=!0,o(C=>C.includes(b)?C:[...C,b]),i(b))}if(a.size>0){let b=!1;const C=new Set(a);for(const S of a)e.activeProcesses.includes(S)||(C.delete(S),b=!0);b&&l(C)}const c=()=>t.onOpenChange(!t.open),d=b=>{i(b),t.open||t.onOpenChange(!0)},u=b=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(`/api/${encodeURIComponent(t.orgSlug)}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/exec/${encodeURIComponent(b)}`,{method:"POST"}),f=b=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(`/api/${encodeURIComponent(t.orgSlug)}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/exec/${encodeURIComponent(b)}/kill`,{method:"POST"}),p=async b=>{o(C=>C.includes(b)?C:[...C,b]),i(b),t.onOpenChange(!0);try{const C=await u(b);if(C===null)return;if(!C.ok)throw new Error(`Exec failed: ${C.statusText}`)}catch{ae.error("Failed to run "+b)}},m=async b=>{await f(b),o(C=>C.filter(S=>S!==b)),s===b&&i(os)},_=async()=>{const b=e.activeProcesses.includes(s);try{const C=await u(s);if(C===null)return;if(!C.ok)throw new Error(`Exec failed: ${C.statusText}`)}catch{ae.error((b?"Failed to restart ":"Failed to run ")+s)}},g=async()=>{if(!a.has(s)){l(b=>new Set(b).add(s));try{const b=await f(s);if(b===null){l(C=>{const S=new Set(C);return S.delete(s),S});return}if(!b.ok)throw new Error(`Kill failed: ${b.statusText}`)}catch{l(b=>{const C=new Set(b);return C.delete(s),C}),ae.error("Failed to stop "+s)}}},x=s!==os&&r.includes(s),y=x&&e.activeProcesses.includes(s),v=x&&a.has(s);return n.jsxs("div",{className:"flex shrink-0 flex-col",style:{height:t.open?"50%":"auto"},children:[n.jsx(tg,{status:t.status,open:t.open,onToggle:c,onStart:t.status==="idle"?t.onStart:void 0,onStop:t.status==="running"||t.status==="starting"?t.onStop:void 0,onRestart:t.status==="running"?t.onRestart:void 0,onResume:t.status==="suspended"?t.onResume:void 0,onRetry:t.status==="errored"?t.onRetry:void 0,scripts:t.scripts,active:s,scriptTabs:r,onSelectTab:d,onAddScript:p,onCloseScript:m,showScriptControls:x,scriptIsRunning:y,scriptIsKilling:v,onRunActiveScript:_,onStopActiveScript:g}),t.open&&n.jsx("div",{className:"flex-1 overflow-hidden",children:n.jsx(yx,{vmId:t.vmId,active:s,hasData:e.hasData(s),onRunActive:_})})]})}function yx(t){const e=U.c(10),{vmId:s,active:i,hasData:r,onRunActive:o}=t;if(!s)return null;if(i===os||r){let d;return e[0]!==i?(d=n.jsx(xx,{source:i,className:"h-full"},i),e[0]=i,e[1]=d):d=e[1],d}let a;e[2]!==i?(a=n.jsxs("p",{children:['Script "',n.jsx("span",{className:"font-mono text-foreground",children:i}),'" not running']}),e[2]=i,e[3]=a):a=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(js,{className:"size-3.5"}),e[4]=l):l=e[4];let h;e[5]!==o?(h=n.jsxs("button",{type:"button",onClick:o,className:"flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs text-foreground hover:bg-accent",children:[l," Run"]}),e[5]=o,e[6]=h):h=e[6];let c;return e[7]!==a||e[8]!==h?(c=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 text-sm text-muted-foreground",children:[a,h]}),e[7]=a,e[8]=h,e[9]=c):c=e[9],c}const Ph=t=>`preview-drawer:${t}`;function Sx(t){try{const e=localStorage.getItem(Ph(t));return e?!!JSON.parse(e).open:!1}catch{return!1}}function wx(t,e){try{localStorage.setItem(Ph(t),JSON.stringify({open:e}))}catch{}}const Cx=M.lazy(()=>vi(()=>import("./sections-editor-CscLvQ5d.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135])).then(t=>({default:t.SectionsEditor}))),kx=M.lazy(()=>vi(()=>import("./file-explorer-BpWrmxcv.js"),__vite__mapDeps([136,1,2,132,103,3,4,6,7,8,9,10,11,12,13,14,15,16,5,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,90,91,54,92,93,94,53,95,55,96,97,45,98,99,100,83,84,85,86,87,88,89,62,101,52,102,67,68,46,66,63,77,104,105,106,76,107,108,61,109,79,74,80,81,56,57,110,47,111,48,49,50,51,58,59,60,64,65,69,70,71,72,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,75,128,129,130,131,133,134,135])).then(t=>({default:t.FileExplorer}))),ml=500;function jx(t){switch(t.kind){case"suspended":return"suspended";case"iframe":return"running";case"starting":return"starting"}}function Nx(){const t=Io(),{data:e}=Es.useSession(),{taskId:s,currentBranch:i,setCurrentTaskBranch:r}=Qt(),[o,a]=M.useState("preview"),[l,h]=M.useState(null),c=M.useRef(null),d=o==="cms",[u,f]=M.useState(null),[p,m]=M.useState(384),_=M.useRef(!1),g=M.useRef(0),x=M.useRef(0),y=M.useRef(null),[v,b]=M.useState(!1),[C,S]=M.useState(""),k=M.useRef(null),[N,P]=M.useState(!1),[A,E]=M.useState(),[j,w]=M.useState(null),[T,D]=M.useState(null),[R,I]=M.useState("/"),B=e?.user?.id,H=t?.entity?.metadata,W=B&&i?hi(H?.sandboxMap?.[B]?.[i]):{},z=Object.values(W),O=z.find(Y=>Y.sandboxProviderKind!=="user-desktop")??z[0],V=O?.previewUrl??null,K=t?.entity?.id??null,{org:Q}=ke(),X=es(),q=X.lifecycle.phase,se=q==="running",$=K&&i&&se?{orgSlug:Q.slug,virtualMcpId:K,branch:i}:null,{data:L}=po($,{fetchEnabled:se}),{data:J}=_o($,{fetchEnabled:se}),Z=K&&i?{orgSlug:Q.slug,virtualMcpId:K,branch:i}:null,F=R_(Z),ne=L?xo(L).sort((Y,ce)=>Y.name.localeCompare(ce.name)):[],ie=L&&J?bo(L,J):[],de=oi,ue=ne.filter(Y=>{if(!C)return!0;const ce=C.toLowerCase();return Y.name.toLowerCase().includes(ce)||Y.path.toLowerCase().includes(ce)}),_e=ie.filter(Y=>{if(!C)return!0;const ce=C.toLowerCase();return Y.name.toLowerCase().includes(ce)||Y.key.toLowerCase().includes(ce)||Y.resolveType.toLowerCase().includes(ce)}),le=j?j.name:ne.find(Y=>de(Y.path)===de(R))?.name,je=M.useRef(null),Ne=M.useRef(null);km(()=>{const Y=c.current,ce=je.current;!Y||!ce||(Y.src=ce)});const Xe=X.status.state==="paused",Et=Qe({connectionId:hs,orgId:t?.entity?.organization_id??"",orgSlug:Q.slug}),Ie=qn(Et),Tt=M.useRef(null),zs=M.useRef(null),Fs=X.phase,fe=Oc({claimPhase:Fs,lifecycle:X.lifecycle}),xe=!!K&&!!i&&Hi.isStopped(K,i),ve=Ic({previewUrl:V,appPaused:Xe,userStopped:xe}),Le=ve.kind==="iframe"?T??new URL(R,ve.previewUrl).href:null,[rt,Fh]=M.useState(null);if(ve.kind==="iframe"&&rt!==ve.previewUrl){const Y=rt!==null;Fh(ve.previewUrl),Y&&(Ne.current=null,I("/"),D(null),w(null))}je.current=Le;const Lo=!!K&&!!i&&!X.notFound&&!xe&&!Xe&&(Fs?.kind==="ready"||q!=="idle"),Ar=ve.kind!=="iframe"&&(o==="visual"||o==="cms")?"preview":o,Mr=Y=>{if(!K)return;const ce={virtualMcpId:K};i&&(ce.branch=i),Ie.mutate(ce,{onSuccess:De=>{De?.branch&&!i&&r(De.branch)},onError:De=>{console.error(`[preview] ${Y} SANDBOX_START failed`,De)}})},Hs=M.useRef(Mr);Hs.current=Mr,s&&O&&Tt.current!==s&&(Tt.current=s);const Oo=!!s&&!!K&&!!B&&!!i&&!O&&!xe&&!Ie.isPending&&Tt.current!==s;M.useEffect(()=>{!Oo||!s||(Tt.current=s,Hs.current("auto-start"))},[Oo,s,xe]);const Pi=X.notFound?O?.sandboxHandle??null:null;M.useEffect(()=>{!Pi||!K||Ie.isPending||zs.current!==Pi&&(i&&Hi.isStopped(K,i)||(zs.current=Pi,Hs.current("self-heal")))},[Pi,K,Ie.isPending,i]);const Br=()=>{Tt.current=null,zs.current=null,Ie.reset(),Hs.current("auto-start")},Hh=vr(),Di=K??"__no-vmcp__",[Wh,$o]=M.useState(null),zo=M.useRef(null);zo.current!==Di&&(zo.current=Di,$o(Sx(Di)));const Uh=ve.kind==="starting"?!1:Wh??!1,Kh=Y=>{$o(Y),wx(Di,Y)},Fo=async()=>{if(!K)return;const Y=i;if(!Y)return;const ce=O?.sandboxProviderKind;if(ce){Hi.mark(K,Y);try{await Et.callTool({name:"SANDBOX_DELETE",arguments:{virtualMcpId:K,branch:Y,sandboxProviderKind:ce}})}catch{}dd(Hh)}},Vh=async()=>{await Fo(),Hs.current("auto-start")};M.useEffect(()=>{if(!V)return;let Y;try{Y=new URL(V,window.location.href).origin}catch{return}const ce=De=>{if(De.origin===Y){if(De.data?.type==="visual-editor::element-clicked"){const Je=D_.safeParse(De.data.payload);Je.success&&h(Je.data)}else if(De.data?.type==="cms-editor::section-clicked"){const Je=M_.safeParse(De.data.payload);Je.success&&f(Je.data.sectionIndex)}}};return window.addEventListener("message",ce),()=>window.removeEventListener("message",ce)},[V]),M.useEffect(()=>{if(!v)return;const Y=ce=>{k.current?.contains(ce.target)||(b(!1),S(""))};return document.addEventListener("pointerdown",Y),()=>document.removeEventListener("pointerdown",Y)},[v]),M.useEffect(()=>{if(!d)return;const Y=De=>{const Je=De.target;Je&&Je!==c.current&&(y.current=Je)},ce=()=>{requestAnimationFrame(()=>{const De=document.activeElement;(De===document.body||De===c.current)&&y.current&&y.current.focus()})};return document.addEventListener("focusin",Y),document.addEventListener("blur",ce,!0),()=>{document.removeEventListener("focusin",Y),document.removeEventListener("blur",ce,!0)}},[d]);const Ho=()=>{const Y=c.current?.contentWindow;Y&&Y.postMessage({type:"visual-editor::activate",script:A_},"*")},qh=()=>{const Y=c.current?.contentWindow;Y&&Y.postMessage({type:"visual-editor::deactivate"},"*")},Wo=()=>{const Y=c.current?.contentWindow;Y&&Y.postMessage({type:"visual-editor::activate",script:B_},"*")},Gh=()=>{const Y=c.current?.contentWindow;Y&&Y.postMessage({type:"cms-editor::deactivate"},"*")},Uo=Y=>{const ce=o;a(Y),h(null),Y!=="cms"&&f(null),ce==="visual"&&qh(),ce==="cms"&&Gh(),Y==="visual"&&Ho(),Y==="cms"&&Wo()},Yh=()=>{if(!c.current||!Le)return;const Y=c.current;Y.src=Le},Xh=()=>{if(!c.current||!Le)return;const Y=Le.includes("?")?"&":"?";c.current.src=`${Le}${Y}_r=${Date.now()}`},Jh=()=>{const Y=c.current?.contentWindow?.location?.href??Le??V;Y&&navigator.clipboard.writeText(Y)},Zh=(()=>{if(!V)return"No server running";if(j)return j.name;try{const Y=new URL(V),ce=R==="/"?"":R;return`${Y.host}${ce}`}catch{return V}})(),Ko=Y=>{Ne.current=Y,w(null),D(null),I(Y),f(null)},Qh=Y=>{if(!V||!J){ae.error("Preview metadata not ready yet");return}Ne.current=null;const ce=mc(J),De=k_(V,ce,Y.key);w(Y),D(De),f(null)},ed=async({name:Y,path:ce})=>{if(!K||!i)return;const De=wo(ce);if(De){E(De);return}const Je=ce.trim().startsWith("/")?ce.trim():`/${ce.trim()}`;if(ne.some(Rt=>de(Rt.path)===de(Je))){E(`A page with path "${Je}" already exists.`);return}E(void 0);try{const Rt=await F.mutateAsync({name:Y,path:Je});P(!1),ae.success(`Page "${Y}" created`),await new Promise(sd=>setTimeout(sd,ml)),Ko(Rt.path),Uo("cms")}catch(Rt){E(Rt instanceof Error?Rt.message:"Failed to create page")}},td=[{value:"preview",icon:n.jsx(iu,{size:14}),tooltip:"Interactive"},...ve.kind==="iframe"?[{value:"visual",icon:n.jsx(Zo,{size:14}),tooltip:"Visual editor"}]:[],...ve.kind==="iframe"&&_c(L,J)?[{value:"cms",icon:n.jsx(ru,{size:14}),tooltip:"Sections editor"}]:[],{value:"code",icon:n.jsx(nu,{size:14}),tooltip:"Code editor"}];return n.jsxs("div",{className:"flex flex-col w-full h-full",children:[Lo&&n.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-4 border-b border-border/60 px-3 md:px-4",children:[n.jsx("div",{className:"flex shrink-0 items-center gap-1",children:n.jsx(sf,{value:Ar,onValueChange:Uo,options:td,size:"sm",className:"shrink-0 bg-foreground/4.5"})}),ve.kind==="iframe"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:re("flex min-w-0 flex-1 items-center gap-0.5",o==="code"&&"hidden"),children:[n.jsxs(Ce,{children:[n.jsx(Se,{asChild:!0,children:n.jsx(te,{variant:"ghost",size:"icon",onClick:Yh,children:n.jsx(ci,{size:14})})}),n.jsx(we,{side:"bottom",children:"Refresh"})]}),n.jsxs("div",{ref:k,className:"relative min-w-0 flex-1",children:[n.jsxs("button",{type:"button",className:"flex h-8 w-full min-w-0 items-center gap-1 rounded-md bg-background px-2 transition-colors duration-200 hover:bg-accent",onClick:()=>b(Y=>!Y),children:[j&&n.jsxs("span",{className:"shrink-0 inline-flex items-center gap-1 rounded bg-global-section/14 px-1.5 py-0.5 text-[11px] font-medium text-global-section-fg dark:text-global-section-fg-dark",children:[n.jsx(cr,{size:11}),"Global"]}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-left text-[12px] text-foreground/88",children:Zh}),le&&!j&&n.jsx("span",{className:"shrink-0 text-[12px] text-muted-foreground",children:le}),n.jsx(ao,{size:12,className:re("shrink-0 text-muted-foreground transition-transform",v&&"rotate-180")})]}),v&&n.jsxs("div",{className:"absolute left-0 right-0 top-full z-50 mt-1.5 overflow-hidden rounded-lg border bg-popover shadow-lg",children:[n.jsxs("div",{className:"px-2 h-10 flex items-center gap-2 border-b",children:[n.jsx(Zl,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),n.jsx("input",{type:"text",value:C,onChange:Y=>S(Y.target.value),placeholder:"Search pages and components...",className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground",autoFocus:!0})]}),n.jsx("div",{className:"p-1.5 border-b",children:n.jsxs("button",{type:"button",className:"flex w-full items-center gap-2.5 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:Y=>{Y.preventDefault(),b(!1),S(""),E(void 0),P(!0)},children:[n.jsx(zt,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"flex-1 font-medium",children:"Create new page"})]})}),ue.length===0&&_e.length===0?n.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:ne.length===0&&ie.length===0?"No pages found in this site.":"No results match your search."}):n.jsxs("div",{className:"max-h-80 overflow-y-auto overscroll-contain",children:[ue.length>0&&n.jsx("div",{className:"p-1.5",children:ue.map(Y=>n.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:ce=>{ce.preventDefault(),b(!1),S(""),Ko(Y.path)},children:[n.jsx(eo,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:Y.name}),n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:Y.path})]},Y.key))}),_e.length>0&&n.jsxs("div",{className:re("p-1.5",ue.length>0&&"border-t"),children:[n.jsx("div",{className:"px-3 py-2 text-xs font-medium text-muted-foreground",children:"Global components"}),_e.map(Y=>n.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:ce=>{ce.preventDefault(),b(!1),S(""),Qh(Y)},children:[n.jsx(cr,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:Y.name}),n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:Y.resolveType.split("/").pop()?.replace(/\.tsx?$/,"")})]},Y.key))]})]})]})]})]}),n.jsxs("div",{className:re("flex shrink-0 items-center gap-0.5",o==="code"&&"hidden"),children:[n.jsxs(Ce,{children:[n.jsx(Se,{asChild:!0,children:n.jsx(te,{variant:"ghost",size:"icon",onClick:()=>{const Y=Le??ve.previewUrl;Y&&window.open(Y,"_blank","noopener")},children:n.jsx(Ps,{size:14})})}),n.jsx(we,{side:"bottom",children:"Open in new tab"})]}),n.jsxs(Ds,{children:[n.jsx(As,{asChild:!0,children:n.jsx(te,{variant:"ghost",size:"icon",children:n.jsx(Cr,{size:14})})}),n.jsxs(Ms,{align:"end",children:[n.jsx(ht,{onClick:Xh,children:"Hard Reload"}),n.jsx(ht,{onClick:Jh,children:"Copy Current URL"})]})]})]})]})]}),n.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[d&&V&&i&&K&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"shrink-0 border-r overflow-hidden",style:{width:p},children:n.jsx(M.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(Cx,{orgSlug:Q.slug,virtualMcpId:K,branch:i,previewReady:se,previewUrl:V,currentPath:R,activeGlobalBlockKey:j?.key??null,externalSelectedIndex:j?null:u,onSaved:()=>{setTimeout(()=>{const Y=c.current;if(!Y)return;const ce=document.activeElement,De=Y.tabIndex;Y.tabIndex=-1,Y.style.pointerEvents="none",Y.blur();try{Y.contentWindow?.location.reload()}catch{const Rt=je.current;Rt&&(Y.src=Rt)}const Je=()=>{Y.tabIndex=De,Y.style.pointerEvents="",ce?.focus(),Y.removeEventListener("load",Je)};Y.addEventListener("load",Je),setTimeout(Je,3e3)},ml)}})})}),n.jsx("div",{className:"w-1 shrink-0 cursor-col-resize bg-transparent hover:bg-border transition-colors",onPointerDown:Y=>{_.current=!0,g.current=Y.clientX,x.current=p,Y.currentTarget.setPointerCapture(Y.pointerId)},onPointerMove:Y=>{if(!_.current)return;const ce=Y.clientX-g.current;m(Math.max(240,Math.min(640,x.current+ce)))},onPointerUp:()=>{_.current=!1}})]}),n.jsxs("div",{className:"flex-1 relative overflow-hidden",children:[ve.kind==="starting"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(hr,{kind:"starting",progress:fe,claimPhase:Fs})}),ve.kind==="suspended"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(hr,{kind:"suspended",onResume:Br})}),Ar==="visual"&&!l&&n.jsxs("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 z-20 flex items-center gap-1.5 rounded-full border border-violet-400/40 bg-violet-500/90 px-3 py-1 text-xs font-medium text-white shadow-md backdrop-blur-sm pointer-events-none select-none",children:[n.jsx(Zo,{size:12}),"Click any element to ask the AI"]}),Ar==="visual"&&l&&n.jsx(O_,{element:l,onDismiss:()=>h(null)}),o==="code"&&Lo&&K&&i&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(M.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(kx,{orgSlug:Q.slug,virtualMcpId:K,branch:i})})}),ve.kind==="iframe"&&Le&&n.jsx("iframe",{ref:c,src:Le,className:re("w-full h-full border-0",o==="code"&&"invisible"),title:"Dev Server Preview",tabIndex:d?-1:void 0,onLoad:()=>{if(Pe("vm_preview_loaded",{view_mode:o,vm_id:O?.sandboxHandle??null}),!j)try{const Y=c.current?.contentWindow?.location?.pathname;if(!Y)return;const ce=Ne.current;if(ce!==null){Ne.current=null,de(Y)===de(ce)&&I(Y);return}I(Y)}catch{}o==="visual"&&Ho(),o==="cms"&&Wo()}},ve.previewUrl)]})]}),n.jsx(bx,{vmId:O?.sandboxHandle??null,orgSlug:Q.slug,virtualMcpId:K,branch:i,status:jx(ve),scripts:X.scripts,open:Uh,onOpenChange:Kh,onStart:()=>Mr("auto-start"),onStop:Fo,onRestart:Vh,onResume:Br,onRetry:Br},O?.sandboxHandle??"no-vm"),n.jsx(P_,{open:N,onOpenChange:P,isPending:F.isPending,error:A,onSubmit:ed})]})}function Ex(t){const e=U.c(2),{virtualMcpId:s}=t,i=bt(s);if(!xi(i?.metadata)){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground p-6",children:[n.jsx(bi,{size:24,className:"text-muted-foreground/60"}),n.jsx("div",{children:"No source to preview."}),n.jsx("div",{className:"text-xs text-muted-foreground/80",children:"Connect a GitHub repository from the Connections tab to enable Preview."})]}),e[0]=a):a=e[0],a}let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(Nx,{}),e[1]=o):o=e[1],o}function Tx({orgSlug:t,virtualMcpId:e,branch:s}){const i=vr();return xr({mutationFn:async({blockKey:r})=>{const o=Mc(r),a=await fetch(`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/unlink`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:o})});if(!a.ok){const l=await a.json().catch(()=>({}));throw new Error(l.error??`Delete failed (${a.status})`)}return a.json()},onMutate:async({blockKey:r})=>{const o=`${t}/${e}/${s}`,a=$t.decofile(o);await i.cancelQueries({queryKey:a});const l=i.getQueryData(a);return i.setQueryData(a,h=>{if(!h)return h;const{[r]:c,...d}=h;return d}),{previous:l,queryKey:a}},onError:(r,o,a)=>{a?.queryKey&&i.setQueryData(a.queryKey,a.previous)},onSuccess:()=>{const r=`${t}/${e}/${s}`;i.invalidateQueries({queryKey:$t.liveMeta(r)})}})}const Rx=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function Px(t){return t.includes("matchers")||t.includes("Match")}function Dx(t,e){const s=t.__resolveType;return typeof s!="string"||!s||Rx.has(s)?!1:e?nm(e,s):Px(s)}function Ri(t,e,s){if(!t)return!1;const i=t.__resolveType;if(typeof i!="string"||!go(i)||!Object.hasOwn(e,i))return!1;const r=e[i];return!r||typeof r!="object"||Array.isArray(r)?!1:Dx(r,s)}function oS(t,e,s){return Ri(t,e,s)?t?.__resolveType??null:null}function Dh(t,e,s){if(!t)return null;const i=t.__resolveType??"";if(!i)return null;if(Ri(t,e,s)){const a=e[i]??{},l=a.__resolveType??i,{__resolveType:h,name:c,...d}=a;return{resolveType:l,data:d,blockKey:i}}const{__resolveType:r,...o}=t;return{resolveType:i,data:o}}function Ax(t,e,s){const i=Dh(t,e,s);return i?{__resolveType:i.resolveType,...i.data}:{__resolveType:""}}function aS(t,e,s){if(t)return Ri(t,e,s)?Ax(t,e,s):t}function Mx(t,e,s,i){if(!t)return"Default";if(Ri(t,e,i)){const r=t.__resolveType??"",o=e[r];return gc(r,o)}return s(t)}function lS(t,e,s){return{__resolveType:t,...e,name:s}}function cS(t){return{__resolveType:t}}function hS(t,e,s){const i=Dh(t,e,s);return i?{resolveType:i.resolveType,formValue:i.data}:{resolveType:"",formValue:{}}}function dS(t){return{__resolveType:dm,variants:[{value:t,rule:{__resolveType:hc}}]}}function uS(t){const r=(Nr(t.__resolveType)?t.section:t)?.variants?.[0];return r?.rule?.__resolveType!==hc?null:r?.value??null}const Bx=["website/matchers/always.ts","$live/matchers/MatchAlways.ts"];function Ah(t){if(!t)return!1;const e=t.__resolveType??"";return e===""?Object.keys(t).length===0:Bx.includes(e)||e.includes("always")}function Ix(t){const e=t.variants??[];if(e.length===0)return-1;const s=e.findIndex(i=>Ah(i.rule));return s!==-1?s:e.length-1}function fS(t,e,s){const i=s.variants??[];if(i.length===0)return null;const r=Ix(s),o=i[r]?.value;if(!o)return null;const a=structuredClone(o);return e.isLazy?{...t,section:a}:a}function mS(t,e){return e.isMultivariate?e.isLazy?t.section??null:t:null}function pS(t,e){return Array.isArray(t.variants)?t.variants.map((s,i)=>({label:e(s.rule)||`Variant ${i+1}`,value:s.value??{},rule:s.rule})):[]}function _S(t,e){const s=t.__resolveType??"";if(!s)return null;if(Nr(s)){const i=t.section??t,r=i.__resolveType??s;if(!r.includes("/")&&r in e){const o=e[r]??{};return{data:{...o},resolveType:o.__resolveType??r}}return{data:{...i},resolveType:r}}if(!s.includes("/")&&s in e){const i=e[s]??{};return{data:{...i},resolveType:i.__resolveType??s}}return{data:{...t},resolveType:s}}function Lx(t,e){const s=t.__resolveType??"";return Nr(s)?{...t,section:e}:e}function gS(t,e,s){return e.isLazy?{...t,section:s}:s}function vS(t,e,s){const i=[...t.variants??[]],r=i[e];if(!r)return t;const o=r.value??{};return i[e]={...r,value:Lx(o,s)},{...t,variants:i}}function xS(t,e,s){const i=[...t.variants??[]];return i[e]?(i[e]={...i[e],rule:s},{...t,variants:i}):t}function bS(t,e){const s=[...t.variants??[]],i=s[e];return i?(s.splice(e+1,0,structuredClone(i)),{...t,variants:s}):t}function yS(t,e){const s=[...t.variants??[]];return s.length<=1?null:(s.splice(e,1),{...t,variants:s})}const Ox=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function $x(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t;return typeof e.__resolveType=="string"&&Ox.has(e.__resolveType)&&typeof e.path=="string"}function Mh(t,e){const i=t[e]?.sections;if(!i||Array.isArray(i))return 1;const r=i;return Array.isArray(r.variants)?r.variants.length:1}function zx(t,e,s){const r=t[e]?.sections;if(Array.isArray(r))return s===0?r:[];if(r&&typeof r=="object"){const o=r.variants;if(Array.isArray(o)){const a=o[s];return Array.isArray(a?.value)?a.value:[]}}return[]}function SS(t,e,s){if(Array.isArray(t))return[{label:"Default",sections:t}];if(t&&typeof t=="object"){const i=t;if(Array.isArray(i.variants)){const r=i.variants,o=r.map(h=>Mx(h.rule,e,s)),a=o.reduce((h,c)=>(h[c]=(h[c]??0)+1,h),{}),l={};return r.map((h,c)=>{const d=o[c]??`Variant ${c+1}`,u=a[d]??1;let f=d;return u>1&&(l[d]=(l[d]??0)+1,f=`${d} ${l[d]}`),{label:f||`Variant ${c+1}`,sections:Array.isArray(h.value)?h.value:[],rule:h.rule}})}}return[]}function Fx(){return{__resolveType:cm}}function Xs(t){return{rule:Fx(),value:t}}function Cs(t,e){return{...e,__resolveType:hm,variants:t}}function Hx(t,e){const s=structuredClone(e);if(Array.isArray(t))return Cs([Xs(t),Xs(s)]);if(t&&typeof t=="object"){const i=t;return Array.isArray(i.variants)?Cs([...i.variants,Xs(s)],i):null}return Cs([Xs([]),Xs(s)])}function wS(t){const e=t.variants;return Array.isArray(e)?e.length-1:1}function CS(t,e){if(e.length===0)return Cs([],t);if(e.length===1){const s=e[0],i=s?.rule;if(!Ah(i))return Cs(e,t);if(Array.isArray(s?.value))return s.value}return Cs(e,t)}function Wx(t,e){for(const[s,i]of Object.entries(t)){if(!$x(i))continue;const r=i.sections;if(Array.isArray(r)){e(void 0,s,0);continue}if(!r||typeof r!="object")continue;const o=r.variants;if(Array.isArray(o))for(let a=0;a<o.length;a++){const l=o[a];e(l?.rule,s,a)}}}function kS(t,e,s){let i=0;return Wx(t,r=>{if(!r)return;(r.__resolveType??"")===e&&Ri(r,t,s)&&i++}),i}function pl(t,e){const s=e.replace(/\s*\(copy(?:\s+\d+)?\)\s*$/,"").trim(),i=`${s} (copy)`;if(!t.has(i))return i;for(let r=2;r<1e3;r++){const o=`${s} (copy ${r})`;if(!t.has(o))return o}return`${s} (copy ${Date.now()})`}function Ux(t,e){const s=oi,i=e.replace(/-copy(?:-\d+)?$/,""),r=`${i}-copy`;if(!t.has(s(r)))return r;for(let o=2;o<1e3;o++){const a=`${i}-copy-${o}`;if(!t.has(s(a)))return a}return`${i}-copy-${Date.now()}`}function _l(t,e){const s=e.replace(/_copy(?:_\d+)?$/,""),i=`${s}_copy`;if(!Object.hasOwn(t,i))return i;for(let r=2;r<1e3;r++){const o=`${s}_copy_${r}`;if(!Object.hasOwn(t,o))return o}return`${s}_copy_${Date.now()}`}function Kx(t){const e=Co(t.newName),s={...t.source,name:t.newName,path:t.newPath};return{key:e,data:s}}function Vx(t,e){return Ac(t,e)}const qx=1e3;function Gx(t,e){for(let s=0;s<qx;s++){const i=Co(e);if(!Object.hasOwn(t,i))return i}throw new Error("Could not generate a unique page block key")}const Yx={create:"Create new page",duplicate:"Duplicate page",rename:"Rename page"},Xx={create:"Create",duplicate:"Duplicate",rename:"Save"},Jx={create:"Creating…",duplicate:"Duplicating…",rename:"Saving…"};function Zx(t){const e=U.c(54),{open:s,mode:i,initialName:r,initialPath:o,isPending:a,error:l,validate:h,onSubmit:c,onOpenChange:d}=t,u=a===void 0?!1:a,[f,p]=M.useState(r),[m,_]=M.useState(o),[g,x]=M.useState(null),[y,v]=M.useState(s);s!==y&&(v(s),s&&(p(r),_(o),x(null)));let b;e[0]!==u||e[1]!==d?(b=q=>{!q&&!u&&(x(null),d(!1))},e[0]=u,e[1]=d,e[2]=b):b=e[2];const C=b;let S;e[3]!==u||e[4]!==f||e[5]!==c||e[6]!==m||e[7]!==h?(S=async q=>{q.preventDefault();const se=f.trim(),$=m.trim();if(!se||!$||u)return;const L=wo($);if(L){x(L);return}const J=h?.({name:se,path:$});if(J){x(J);return}x(null),await c({name:se,path:$})},e[3]=u,e[4]=f,e[5]=c,e[6]=m,e[7]=h,e[8]=S):S=e[8];const k=S,N=g??l,P=Yx[i];let A;e[9]!==P?(A=n.jsx(fs,{children:n.jsx(ms,{children:P})}),e[9]=P,e[10]=A):A=e[10];let E;e[11]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx("label",{htmlFor:"page-form-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[11]=E):E=e[11];let j;e[12]===Symbol.for("react.memo_cache_sentinel")?(j=q=>p(q.target.value),e[12]=j):j=e[12];let w;e[13]!==u||e[14]!==f?(w=n.jsxs("div",{className:"space-y-1.5",children:[E,n.jsx(Ge,{id:"page-form-name",value:f,onChange:j,placeholder:"My page",autoFocus:!0,disabled:u})]}),e[13]=u,e[14]=f,e[15]=w):w=e[15];let T;e[16]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsx("label",{htmlFor:"page-form-path",className:"text-xs font-medium text-muted-foreground",children:"Path"}),e[16]=T):T=e[16];let D;e[17]===Symbol.for("react.memo_cache_sentinel")?(D=q=>_(q.target.value),e[17]=D):D=e[17];let R;e[18]!==u||e[19]!==m?(R=n.jsxs("div",{className:"space-y-1.5",children:[T,n.jsx(Ge,{id:"page-form-path",value:m,onChange:D,placeholder:"/example",disabled:u})]}),e[18]=u,e[19]=m,e[20]=R):R=e[20];let I;e[21]!==N?(I=N&&n.jsx("p",{className:"text-xs text-destructive",children:N}),e[21]=N,e[22]=I):I=e[22];let B;e[23]!==R||e[24]!==I||e[25]!==w?(B=n.jsxs("div",{className:"space-y-4 py-4",children:[w,R,I]}),e[23]=R,e[24]=I,e[25]=w,e[26]=B):B=e[26];let H;e[27]!==d?(H=()=>d(!1),e[27]=d,e[28]=H):H=e[28];let W;e[29]!==u||e[30]!==H?(W=n.jsx(te,{type:"button",variant:"outline",onClick:H,disabled:u,children:"Cancel"}),e[29]=u,e[30]=H,e[31]=W):W=e[31];let z;e[32]!==u||e[33]!==f||e[34]!==m?(z=!f.trim()||!m.trim()||u,e[32]=u,e[33]=f,e[34]=m,e[35]=z):z=e[35];let O;e[36]!==u||e[37]!==i?(O=u?n.jsxs(n.Fragment,{children:[n.jsx(ge,{size:14,className:"animate-spin"}),Jx[i]]}):Xx[i],e[36]=u,e[37]=i,e[38]=O):O=e[38];let V;e[39]!==z||e[40]!==O?(V=n.jsx(te,{type:"submit",disabled:z,children:O}),e[39]=z,e[40]=O,e[41]=V):V=e[41];let K;e[42]!==W||e[43]!==V?(K=n.jsxs(Rs,{children:[W,V]}),e[42]=W,e[43]=V,e[44]=K):K=e[44];let Q;e[45]!==k||e[46]!==B||e[47]!==K||e[48]!==A?(Q=n.jsx(Ft,{className:"sm:max-w-md",children:n.jsxs("form",{onSubmit:k,children:[A,B,K]})}),e[45]=k,e[46]=B,e[47]=K,e[48]=A,e[49]=Q):Q=e[49];let X;return e[50]!==C||e[51]!==s||e[52]!==Q?(X=n.jsx(Ht,{open:s,onOpenChange:C,children:Q}),e[50]=C,e[51]=s,e[52]=Q,e[53]=X):X=e[53],X}function Qx(t){const e=U.c(43),{open:s,blockKey:i,initialName:r,isPending:o,onSubmit:a,onOpenChange:l}=t,h=o===void 0?!1:o,[c,d]=M.useState(r),[u,f]=M.useState(s);s!==u&&(f(s),s&&d(r));let p;e[0]!==h||e[1]!==l?(p=R=>{!R&&!h&&l(!1)},e[0]=h,e[1]=l,e[2]=p):p=e[2];const m=p;let _;e[3]!==h||e[4]!==c||e[5]!==a?(_=async R=>{R.preventDefault();const I=c.trim();!I||h||await a(I)},e[3]=h,e[4]=c,e[5]=a,e[6]=_):_=e[6];const g=_;let x;e[7]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsxs(fs,{children:[n.jsx(ms,{children:"Rename section"}),n.jsx(so,{children:"Updates the display name. The internal key stays the same so pages referencing this section keep working."})]}),e[7]=x):x=e[7];let y;e[8]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx("label",{htmlFor:"section-rename-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[8]=y):y=e[8];let v;e[9]===Symbol.for("react.memo_cache_sentinel")?(v=R=>d(R.target.value),e[9]=v):v=e[9];let b;e[10]!==h||e[11]!==c?(b=n.jsxs("div",{className:"space-y-1.5",children:[y,n.jsx(Ge,{id:"section-rename-name",value:c,onChange:v,autoFocus:!0,disabled:h})]}),e[10]=h,e[11]=c,e[12]=b):b=e[12];let C;e[13]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Key"}),e[13]=C):C=e[13];let S;e[14]!==i?(S=n.jsxs("div",{className:"space-y-1.5",children:[C,n.jsx(Ge,{value:i,readOnly:!0,disabled:!0,className:"font-mono"})]}),e[14]=i,e[15]=S):S=e[15];let k;e[16]!==b||e[17]!==S?(k=n.jsxs("div",{className:"space-y-4 py-4",children:[b,S]}),e[16]=b,e[17]=S,e[18]=k):k=e[18];let N;e[19]!==l?(N=()=>l(!1),e[19]=l,e[20]=N):N=e[20];let P;e[21]!==h||e[22]!==N?(P=n.jsx(te,{type:"button",variant:"outline",onClick:N,disabled:h,children:"Cancel"}),e[21]=h,e[22]=N,e[23]=P):P=e[23];let A;e[24]!==h||e[25]!==c?(A=!c.trim()||h,e[24]=h,e[25]=c,e[26]=A):A=e[26];let E;e[27]!==h?(E=h?n.jsxs(n.Fragment,{children:[n.jsx(ge,{size:14,className:"animate-spin"}),"Saving…"]}):"Save",e[27]=h,e[28]=E):E=e[28];let j;e[29]!==A||e[30]!==E?(j=n.jsx(te,{type:"submit",disabled:A,children:E}),e[29]=A,e[30]=E,e[31]=j):j=e[31];let w;e[32]!==P||e[33]!==j?(w=n.jsxs(Rs,{children:[P,j]}),e[32]=P,e[33]=j,e[34]=w):w=e[34];let T;e[35]!==g||e[36]!==k||e[37]!==w?(T=n.jsx(Ft,{className:"sm:max-w-md",children:n.jsxs("form",{onSubmit:g,children:[x,k,w]})}),e[35]=g,e[36]=k,e[37]=w,e[38]=T):T=e[38];let D;return e[39]!==m||e[40]!==s||e[41]!==T?(D=n.jsx(Ht,{open:s,onOpenChange:m,children:T}),e[39]=m,e[40]=s,e[41]=T,e[42]=D):D=e[42],D}const eb=M.lazy(()=>vi(()=>import("./sections-editor-CscLvQ5d.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135])).then(t=>({default:t.SectionsEditor}))),tb=M.lazy(()=>vi(()=>import("./add-section-modal-22C7gHeb.js"),__vite__mapDeps([82,1,2,6,7,8,9,10,11,12,13,14,15,16,3,4,5,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,45,46,83,84,85,86,42,43,44,87,88,89,54,90,91,92,93,94,53,95,55,96,97,98,99,100,62,101,52,102,67,68,103,66,63,77,104,105,106,76,107,108,61,109,79,74,80,81,56,57,110,47,111,48,49,50,51,58,59,60,64,65,69,70,71,72,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,75,128,129,130,131,132,133,134,135])).then(t=>({default:t.AddSectionModal}))),Kn="oklch(0.65 0.15 160)";function sb(){const t=U.c(18),e=Io(),{data:s}=Es.useSession(),{currentBranch:i}=Qt(),{org:r}=ke(),o=e?.entity?.id??null,a=s?.user?.id,l=e?.entity?.metadata,h=a&&i?hi(l?.sandboxMap?.[a]?.[i]):{},c=Object.values(h),u=(c.find(ib)??c[0])?.previewUrl??null,f=es(),p=e?.entity?.organization_id??"";let m;t[0]!==r.slug||t[1]!==p?(m={connectionId:hs,orgId:p,orgSlug:r.slug},t[0]=r.slug,t[1]=p,t[2]=m):m=t[2];const _=Qe(m),g=qn(_);let x;t[3]!==i||t[4]!==g||t[5]!==o?(x=()=>{if(!o)return;const S={virtualMcpId:o};i&&(S.branch=i),g.mutate(S)},t[3]=i,t[4]=g,t[5]=o,t[6]=x):x=t[6];const y=x,v=!!o&&!!i&&Hi.isStopped(o,i),b=Ic({previewUrl:u,appPaused:f.status.state==="paused",userStopped:v});if(b.kind!=="iframe"){let S;return t[7]!==b||t[8]!==y||t[9]!==f.lifecycle||t[10]!==f.phase?(S=n.jsx(lb,{state:b,claimPhase:f.phase,lifecycle:f.lifecycle,onStart:y}),t[7]=b,t[8]=y,t[9]=f.lifecycle,t[10]=f.phase,t[11]=S):S=t[11],S}if(!o||!i){let S;return t[12]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(Ji,{title:"Waiting for sandbox context…"}),t[12]=S):S=t[12],S}let C;return t[13]!==i||t[14]!==r.slug||t[15]!==u||t[16]!==o?(C=n.jsx(rb,{orgSlug:r.slug,virtualMcpId:o,branch:i,previewUrl:u}),t[13]=i,t[14]=r.slug,t[15]=u,t[16]=o,t[17]=C):C=t[17],C}function ib(t){return t.sandboxProviderKind!=="user-desktop"}function rb({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:i}){const r={orgSlug:t,virtualMcpId:e,branch:s},{data:o,isLoading:a}=po(r),{data:l,isLoading:h}=_o(r),c=Bc(r),d=Tx(r),[u,f]=M.useState("pages"),[p,m]=M.useState(null),[_,g]=M.useState(""),[x,y]=M.useState(u);x!==u&&(y(u),g(""));const[v,b]=M.useState(null),[C,S]=M.useState(),[k,N]=M.useState(!1),[P,A]=M.useState(null),[E,j]=M.useState(null);if(a||h)return n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})});if(!o||!l)return n.jsx(Ji,{title:"Could not load site data."});const w=xo(o).sort(($,L)=>$.name.localeCompare(L.name)),T=bo(o,l);if(w.length===0&&T.length===0)return n.jsx(Ji,{icon:bi,title:"No editable content",description:"This project doesn't expose any Deco pages or sections."});const D={pages:w.length,sections:T.length},R=new Set(w.map($=>oi($.path))),I=new Set(w.map($=>$.name)),B=new Set(T.map($=>$.name)),H=async $=>{const L=o[$.key];if(!L)return;const J=Mh(o,$.key),Z=zx(o,$.key,Math.max(0,J-1)),F=Hx(L.sections,Z);if(F)try{await c.mutateAsync({blockKey:$.key,data:{...L,sections:F}}),ae.success(`Variant added to "${$.name}"`),m({collection:"pages",key:$.key,path:$.path})}catch(ne){ae.error(ne instanceof Error?ne.message:"Could not add variant")}},W=()=>{S(void 0),b({mode:"create",sourceKey:null,initialName:"My new page",initialPath:"/example"})},z=$=>{S(void 0),b({mode:"duplicate",sourceKey:$.key,initialName:pl(I,$.name),initialPath:Ux(R,$.path)})},O=$=>{S(void 0),b({mode:"rename",sourceKey:$.key,initialName:$.name,initialPath:$.path})},V=async $=>{if(!v)return;const{mode:L,sourceKey:J}=v;try{if(L==="create"){const Z=Vx($.name,$.path),F=Gx(o,$.name);await c.mutateAsync({blockKey:F,data:Z}),ae.success(`Created "${$.name}"`),m({collection:"pages",key:F,path:$.path})}else if(L==="duplicate"&&J){const Z=o[J];if(!Z)throw new Error("Source page not found");const{key:F,data:ne}=Kx({source:Z,pages:w,newName:$.name,newPath:$.path});await c.mutateAsync({blockKey:F,data:ne}),ae.success(`Duplicated as "${$.name}"`),m({collection:"pages",key:F,path:$.path})}else if(L==="rename"&&J){const Z=o[J];if(!Z)throw new Error("Page not found");const F={...Z,name:$.name,path:$.path};await c.mutateAsync({blockKey:J,data:F}),ae.success("Page updated"),p?.collection==="pages"&&p.key===J&&m({collection:"pages",key:J,path:$.path})}b(null)}catch(Z){S(Z instanceof Error?Z.message:"Save failed")}},K=({path:$})=>{if(!v)return null;const L=oi($);return(v.mode==="rename"?oi(v.initialPath):null)!==L&&R.has(L)?`A page with path "${$}" already exists.`:null},Q=async $=>{const L=($.title||$.resolveType.split("/").pop()||"").replace(/\.(tsx?|jsx?)$/,"").replace(/[^A-Za-z0-9_-]/g,""),J=/^[A-Za-z]/.test(L)&&L.length>0?L:"Section",Z=_l(o,J),F={__resolveType:$.resolveType,name:Z};try{await c.mutateAsync({blockKey:Z,data:F}),ae.success(`Created section "${Z}"`),N(!1),m({collection:"sections",key:Z})}catch(ne){ae.error(ne instanceof Error?ne.message:"Could not create section")}},X=async $=>{const L=o[$.key];if(!L){ae.error("Section not found.");return}const J=_l(o,$.key),Z=pl(B,$.name),F={...L,name:Z};try{await c.mutateAsync({blockKey:J,data:F}),ae.success(`Duplicated "${$.name}"`),m({collection:"sections",key:J})}catch(ne){ae.error(ne instanceof Error?ne.message:"Duplicate failed")}},q=async $=>{if(!P)return;const L=o[P];if(!L){ae.error("Section not found.");return}try{await c.mutateAsync({blockKey:P,data:{...L,name:$}}),ae.success("Section renamed"),A(null)}catch(J){ae.error(J instanceof Error?J.message:"Rename failed")}},se=async()=>{if(!E)return;const{kind:$,key:L,label:J}=E;try{await d.mutateAsync({blockKey:L}),ae.success(`Deleted "${J}"`),$==="page"?p?.collection==="pages"&&p.key===L&&m(null):p?.collection==="sections"&&p.key===L&&m(null),j(null)}catch(Z){ae.error(Z instanceof Error?Z.message:"Delete failed")}};return n.jsxs("div",{className:"flex h-full w-full",children:[n.jsx(nb,{active:u,counts:D,onSelect:$=>{f($),m(null)}}),n.jsx(ob,{activeCollection:u,pages:w,sections:T,decofile:o,searchQuery:_,onSearchChange:g,selection:p,onSelect:m,previewUrl:i,onCreate:()=>{u==="pages"?W():i?N(!0):ae.error("Start the preview dev server to add sections.")},onDuplicatePage:z,onRenamePage:O,onAddPageVariant:H,onDeletePage:$=>j({kind:"page",key:$.key,label:$.name}),onDuplicateSection:X,onRenameSection:$=>A($.key),onDeleteSection:$=>j({kind:"section",key:$.key,label:$.name})}),n.jsx("div",{className:"flex-1 min-w-0",children:p?n.jsx(M.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(eb,{orgSlug:t,virtualMcpId:e,branch:s,previewReady:!0,previewUrl:i??void 0,currentPath:p.collection==="pages"?p.path:"/",activePageBlockKey:p.collection==="pages"?p.key:null,activeGlobalBlockKey:p.collection==="sections"?p.key:null},p.collection==="pages"?`page:${p.key}`:`section:${p.key}`)}):n.jsx(Ji,{title:u==="pages"?"Select a page to edit":"Select a section to edit",description:u==="pages"?'Pick a page from the list, or click "+ New" to create one.':'Pick a section from the list, or click "+ New" to create one.'})}),v&&n.jsx(Zx,{open:!!v,mode:v.mode,initialName:v.initialName,initialPath:v.initialPath,isPending:c.isPending,error:C,validate:K,onSubmit:V,onOpenChange:$=>{$||(b(null),S(void 0))}}),P&&n.jsx(Qx,{open:!!P,blockKey:P,initialName:T.find($=>$.key===P)?.name??P,isPending:c.isPending,onSubmit:q,onOpenChange:$=>{$||A(null)}}),k&&i&&n.jsx(M.Suspense,{fallback:null,children:n.jsx(tb,{open:k,onOpenChange:N,meta:l,decofile:o,previewBaseUrl:i,onSelect:Q})}),n.jsx(Qi,{open:!!E,onOpenChange:$=>{!$&&!d.isPending&&j(null)},children:n.jsxs(er,{children:[n.jsxs(tr,{children:[n.jsxs(sr,{children:["Delete ",E?.kind==="page"?"page":"section","?"]}),n.jsx(ir,{children:E?.kind==="page"?`"${E.label}" will be removed permanently. This can't be undone.`:E?.kind==="section"?`"${E.label}" will be removed. Pages that still reference it will lose this section.`:null})]}),n.jsxs(rr,{children:[n.jsx(nr,{disabled:d.isPending,children:"Cancel"}),n.jsx(or,{onClick:$=>{$.preventDefault(),se()},disabled:d.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:d.isPending?n.jsxs(n.Fragment,{children:[n.jsx(ge,{size:14,className:"animate-spin"}),"Deleting…"]}):"Delete"})]})]})})]})}function nb(t){const e=U.c(12),{active:s,counts:i,onSelect:r}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("div",{className:"px-3 h-12 flex items-center border-b shrink-0",children:n.jsx("span",{className:"text-sm font-medium",children:"Content"})}),e[0]=o):o=e[0];const a=s==="pages";let l;e[1]!==i.pages||e[2]!==r||e[3]!==a?(l=n.jsx(gl,{id:"pages",icon:eo,label:"Pages",count:i.pages,active:a,onSelect:r}),e[1]=i.pages,e[2]=r,e[3]=a,e[4]=l):l=e[4];const h=s==="sections";let c;e[5]!==i.sections||e[6]!==r||e[7]!==h?(c=n.jsx(gl,{id:"sections",icon:cr,label:"Sections",count:i.sections,active:h,onSelect:r}),e[5]=i.sections,e[6]=r,e[7]=h,e[8]=c):c=e[8];let d;return e[9]!==l||e[10]!==c?(d=n.jsxs("div",{className:"w-[208px] shrink-0 border-r flex flex-col",children:[o,n.jsxs("nav",{className:"flex flex-col p-1.5 gap-0.5",children:[l,c]})]}),e[9]=l,e[10]=c,e[11]=d):d=e[11],d}function gl(t){const e=U.c(20),{id:s,icon:i,label:r,count:o,active:a,onSelect:l}=t;let h;e[0]!==s||e[1]!==l?(h=()=>l(s),e[0]=s,e[1]=l,e[2]=h):h=e[2];const c=a?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground";let d;e[3]!==c?(d=re("flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors cursor-pointer",c),e[3]=c,e[4]=d):d=e[4];let u;e[5]!==i?(u=n.jsx(i,{size:16,className:"shrink-0"}),e[5]=i,e[6]=u):u=e[6];let f;e[7]!==r?(f=n.jsx("span",{className:"flex-1 truncate",children:r}),e[7]=r,e[8]=f):f=e[8];const p=a?"text-accent-foreground/70":"text-muted-foreground/70";let m;e[9]!==p?(m=re("shrink-0 text-xs tabular-nums",p),e[9]=p,e[10]=m):m=e[10];let _;e[11]!==o||e[12]!==m?(_=n.jsx("span",{className:m,children:o}),e[11]=o,e[12]=m,e[13]=_):_=e[13];let g;return e[14]!==h||e[15]!==d||e[16]!==u||e[17]!==f||e[18]!==_?(g=n.jsxs("button",{type:"button",onClick:h,className:d,children:[u,f,_]}),e[14]=h,e[15]=d,e[16]=u,e[17]=f,e[18]=_,e[19]=g):g=e[19],g}function ob(t){const e=U.c(54),{activeCollection:s,pages:i,sections:r,decofile:o,previewUrl:a,searchQuery:l,onSearchChange:h,selection:c,onSelect:d,onCreate:u,onDuplicatePage:f,onRenamePage:p,onAddPageVariant:m,onDeletePage:_,onDuplicateSection:g,onRenameSection:x,onDeleteSection:y}=t;let v,b,C,S,k,N;if(e[0]!==s||e[1]!==o||e[2]!==m||e[3]!==u||e[4]!==_||e[5]!==y||e[6]!==f||e[7]!==g||e[8]!==p||e[9]!==x||e[10]!==h||e[11]!==d||e[12]!==i||e[13]!==a||e[14]!==l||e[15]!==r||e[16]!==c){const j=l.toLowerCase(),w=i.filter(q=>!j||q.name.toLowerCase().includes(j)||q.path.toLowerCase().includes(j)),T=r.filter(q=>!j||q.name.toLowerCase().includes(j)||q.key.toLowerCase().includes(j)||q.resolveType.toLowerCase().includes(j)),D=s==="pages"?"Search pages…":"Search sections…",R=s==="pages"?"Create new page":"Create new section",I=s==="sections"&&!a,B=I?"Start the preview dev server to add sections":void 0;k="w-[300px] shrink-0 border-r flex flex-col min-h-0";let H;e[23]===Symbol.for("react.memo_cache_sentinel")?(H=n.jsx(Zl,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),e[23]=H):H=e[23];let W;e[24]!==h?(W=q=>h(q.target.value),e[24]=h,e[25]=W):W=e[25];let z;e[26]!==D||e[27]!==l||e[28]!==W?(z=n.jsxs("div",{className:"flex flex-1 items-center gap-2 pl-1",children:[H,n.jsx("input",{type:"text",value:l,onChange:W,placeholder:D,"aria-label":D,className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),e[26]=D,e[27]=l,e[28]=W,e[29]=z):z=e[29];let O;e[30]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(zt,{size:14}),e[30]=O):O=e[30];let V;e[31]!==R||e[32]!==u||e[33]!==I?(V=n.jsx(Se,{asChild:!0,children:n.jsx(te,{variant:"ghost",size:"icon",onClick:u,disabled:I,"aria-label":R,"aria-disabled":I,children:O})}),e[31]=R,e[32]=u,e[33]=I,e[34]=V):V=e[34];const K=B??R;let Q;e[35]!==K?(Q=n.jsx(we,{side:"bottom",children:K}),e[35]=K,e[36]=Q):Q=e[36];let X;e[37]!==V||e[38]!==Q?(X=n.jsxs(Ce,{children:[V,Q]}),e[37]=V,e[38]=Q,e[39]=X):X=e[39],e[40]!==X||e[41]!==z?(N=n.jsxs("div",{className:"px-2 h-12 flex items-center gap-1 border-b shrink-0",children:[z,X]}),e[40]=X,e[41]=z,e[42]=N):N=e[42],v=ro,S="flex-1 min-h-0",b="flex flex-col gap-1 p-1.5",C=s==="pages"?w.length===0?n.jsx(bl,{hasItems:i.length>0,emptyLabel:"No pages yet.",emptyHint:'Click "+" to create your first page.'}):w.map(q=>{const se=c?.collection==="pages"&&c.key===q.key,$=Mh(o,q.key);return n.jsx(vl,{icon:eo,title:q.name,subtitle:q.path,active:se,variantCount:$,onClick:()=>d({collection:"pages",key:q.key,path:q.path}),menu:n.jsx(xl,{onDuplicate:()=>f(q),onRename:()=>p(q),onAddVariant:()=>m(q),onDelete:()=>_(q)})},q.key)}):T.length===0?n.jsx(bl,{hasItems:r.length>0,emptyLabel:"No saved sections yet.",emptyHint:'Click "+" to create one, or save a section from a page.'}):T.map(q=>{const se=c?.collection==="sections"&&c.key===q.key,$=q.resolveType.split("/").pop()?.replace(/\.tsx?$/,"");return n.jsx(vl,{icon:cr,title:q.name,subtitle:$??q.resolveType,active:se,onClick:()=>d({collection:"sections",key:q.key}),menu:n.jsx(xl,{onDuplicate:()=>g(q),onRename:()=>x(q),onDelete:()=>y(q)})},q.key)}),e[0]=s,e[1]=o,e[2]=m,e[3]=u,e[4]=_,e[5]=y,e[6]=f,e[7]=g,e[8]=p,e[9]=x,e[10]=h,e[11]=d,e[12]=i,e[13]=a,e[14]=l,e[15]=r,e[16]=c,e[17]=v,e[18]=b,e[19]=C,e[20]=S,e[21]=k,e[22]=N}else v=e[17],b=e[18],C=e[19],S=e[20],k=e[21],N=e[22];let P;e[43]!==b||e[44]!==C?(P=n.jsx("div",{className:b,children:C}),e[43]=b,e[44]=C,e[45]=P):P=e[45];let A;e[46]!==v||e[47]!==S||e[48]!==P?(A=n.jsx(v,{className:S,children:P}),e[46]=v,e[47]=S,e[48]=P,e[49]=A):A=e[49];let E;return e[50]!==k||e[51]!==N||e[52]!==A?(E=n.jsxs("div",{className:k,children:[N,A]}),e[50]=k,e[51]=N,e[52]=A,e[53]=E):E=e[53],E}function vl(t){const e=U.c(27),{icon:s,title:i,subtitle:r,active:o,variantCount:a,onClick:l,menu:h}=t,c=o?"bg-accent text-accent-foreground":"hover:bg-muted";let d;e[0]!==c?(d=re("group relative flex items-center rounded-md transition-colors",c),e[0]=c,e[1]=d):d=e[1];let u;e[2]!==s||e[3]!==o||e[4]!==a?(u=a&&a>1?n.jsxs(Ce,{children:[n.jsx(Se,{asChild:!0,children:n.jsx(s,{size:16,className:"shrink-0",style:{color:Kn}})}),n.jsxs(we,{side:"right",children:[a," variants"]})]}):n.jsx(s,{size:16,className:re("shrink-0",o?"text-accent-foreground":"text-muted-foreground")}),e[2]=s,e[3]=o,e[4]=a,e[5]=u):u=e[5];let f;e[6]!==i?(f=n.jsx("span",{className:"block truncate text-sm font-medium",children:i}),e[6]=i,e[7]=f):f=e[7];const p=o?"text-accent-foreground/70":"text-muted-foreground";let m;e[8]!==p?(m=re("block truncate text-xs",p),e[8]=p,e[9]=m):m=e[9];let _;e[10]!==r||e[11]!==m?(_=n.jsx("span",{className:m,children:r}),e[10]=r,e[11]=m,e[12]=_):_=e[12];let g;e[13]!==f||e[14]!==_?(g=n.jsxs("span",{className:"min-w-0 flex-1",children:[f,_]}),e[13]=f,e[14]=_,e[15]=g):g=e[15];let x;e[16]!==l||e[17]!==u||e[18]!==g?(x=n.jsxs("button",{type:"button",onClick:l,className:"flex min-w-0 flex-1 items-center gap-2.5 rounded-md px-2.5 py-2 text-left cursor-pointer",children:[u,g]}),e[16]=l,e[17]=u,e[18]=g,e[19]=x):x=e[19];let y;e[20]!==o||e[21]!==h?(y=h&&n.jsx("div",{className:re("pr-1 opacity-0 transition-opacity group-hover:opacity-100",o&&"opacity-100"),children:h}),e[20]=o,e[21]=h,e[22]=y):y=e[22];let v;return e[23]!==y||e[24]!==d||e[25]!==x?(v=n.jsxs("div",{className:d,children:[x,y]}),e[23]=y,e[24]=d,e[25]=x,e[26]=v):v=e[26],v}function xl(t){const e=U.c(18),{onDuplicate:s,onRename:i,onAddVariant:r,onDelete:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(As,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":"More actions",className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-background hover:text-foreground cursor-pointer",onClick:ab,children:n.jsx(Cr,{size:14})})}),e[0]=a):a=e[0];let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(ql,{size:14}),e[1]=l):l=e[1];let h;e[2]!==i?(h=n.jsxs(ht,{onClick:i,children:[l,"Rename"]}),e[2]=i,e[3]=h):h=e[3];let c;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Xt,{size:14}),e[4]=c):c=e[4];let d;e[5]!==s?(d=n.jsxs(ht,{onClick:s,children:[c,"Duplicate"]}),e[5]=s,e[6]=d):d=e[6];let u;e[7]!==r?(u=r&&n.jsxs(n.Fragment,{children:[n.jsx(ta,{}),n.jsxs(ht,{onClick:r,className:"cursor-pointer",style:{color:Kn},children:[n.jsx(ou,{size:14,style:{color:Kn}}),"Add variant"]})]}),e[7]=r,e[8]=u):u=e[8];let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(ta,{}),e[9]=f):f=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(di,{size:14}),e[10]=p):p=e[10];let m;e[11]!==o?(m=n.jsxs(ht,{onClick:o,className:"text-destructive focus:text-destructive",children:[p,"Delete"]}),e[11]=o,e[12]=m):m=e[12];let _;return e[13]!==h||e[14]!==d||e[15]!==u||e[16]!==m?(_=n.jsxs(Ds,{children:[a,n.jsxs(Ms,{align:"end",className:"w-44",children:[h,d,u,f,m]})]}),e[13]=h,e[14]=d,e[15]=u,e[16]=m,e[17]=_):_=e[17],_}function ab(t){return t.stopPropagation()}function bl(t){const e=U.c(6),{hasItems:s,emptyLabel:i,emptyHint:r}=t;let o;e[0]!==r||e[1]!==i||e[2]!==s?(o=s?"No results match your search.":n.jsxs(n.Fragment,{children:[n.jsx("div",{children:i}),n.jsx("div",{className:"mt-1 text-muted-foreground/80",children:r})]}),e[0]=r,e[1]=i,e[2]=s,e[3]=o):o=e[3];let a;return e[4]!==o?(a=n.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o}),e[4]=o,e[5]=a):a=e[5],a}function lb(t){const e=U.c(8),{state:s,claimPhase:i,lifecycle:r,onStart:o}=t;switch(s.kind){case"starting":{let a;e[0]!==i||e[1]!==r?(a=Oc({claimPhase:i,lifecycle:r}),e[0]=i,e[1]=r,e[2]=a):a=e[2];let l;return e[3]!==i||e[4]!==a?(l=n.jsx(hr,{kind:"starting",progress:a,claimPhase:i}),e[3]=i,e[4]=a,e[5]=l):l=e[5],l}case"suspended":{let a;return e[6]!==o?(a=n.jsx(hr,{kind:"suspended",onResume:o}),e[6]=o,e[7]=a):a=e[7],a}}}function Ji(t){const e=U.c(10),{icon:s,title:i,description:r}=t;let o;e[0]!==s?(o=s&&n.jsx(s,{size:24,className:"text-muted-foreground/60"}),e[0]=s,e[1]=o):o=e[1];let a;e[2]!==i?(a=n.jsx("div",{children:i}),e[2]=i,e[3]=a):a=e[3];let l;e[4]!==r?(l=r&&n.jsx("div",{className:"text-xs text-muted-foreground/80 max-w-sm",children:r}),e[4]=r,e[5]=l):l=e[5];let h;return e[6]!==o||e[7]!==a||e[8]!==l?(h=n.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 p-6 text-center text-sm text-muted-foreground",children:[o,a,l]}),e[6]=o,e[7]=a,e[8]=l,e[9]=h):h=e[9],h}function cb(t){const e=U.c(2),{virtualMcpId:s}=t,i=bt(s);if(!xi(i?.metadata)){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground p-6",children:[n.jsx(bi,{size:24,className:"text-muted-foreground/60"}),n.jsx("div",{children:"No content to edit."}),n.jsx("div",{className:"text-xs text-muted-foreground/80",children:"Connect a GitHub repository from the Settings tab to enable Content."})]}),e[0]=a):a=e[0],a}let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(sb,{}),e[1]=o):o=e[1],o}function hb(t){const e=U.c(3),{tier:s,onSelect:i}=t;let r;return e[0]!==i||e[1]!==s?(r=n.jsx(_d,{tier:s,subtitleFor:db,iconFor:gd,onSelect:i}),e[0]=i,e[1]=s,e[2]=r):r=e[2],r}function db(t){return vd("cloud-decopilot",t)}function li(t){const e=t.trim().split(/\s+/);return e.length!==5?!1:e.every(s=>/^[\d*/,-]+$/.test(s))}function ub(t){if(!t)return"Unknown schedule";const e=t.trim();if(e==="* * * * *")return"Every minute";if(e==="0 * * * *")return"Every hour";if(e==="0 0 * * *")return"Every day";if(e==="0 0 * * 1")return"Every week";const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return`Every ${s[1]} minutes`;const i=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(i)return`Every ${i[1]} hours`;const r=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);if(r){const l=parseInt(r[1]??"1");return l%7===0?`Every ${l/7} weeks`:`Every ${l} days`}const o=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+\*$/);if(o){const l=(o[2]??"0").padStart(2,"0"),h=(o[1]??"0").padStart(2,"0");return`Every day at ${l}:${h} UTC`}const a=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+(\d)$/);if(a){const h=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][parseInt(a[3]??"0")]??"day",c=(a[2]??"0").padStart(2,"0"),d=(a[1]??"0").padStart(2,"0");return`Every ${h} at ${c}:${d} UTC`}return t}function fb(t,e){const s=Math.max(1,t);switch(e){case"minutes":return s===1?"* * * * *":`*/${s} * * * *`;case"hours":return s===1?"0 * * * *":`0 */${s} * * *`;case"days":return s===1?"0 0 * * *":`0 0 */${s} * *`;case"weeks":return s===1?"0 0 * * 1":`0 0 */${s*7} * *`}}function mb(t){const e=t.trim();if(e==="* * * * *")return{count:1,unit:"minutes"};if(e==="0 * * * *")return{count:1,unit:"hours"};if(e==="0 0 * * *")return{count:1,unit:"days"};if(e==="0 0 * * 1")return{count:1,unit:"weeks"};const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return{count:parseInt(s[1]),unit:"minutes"};const i=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(i)return{count:parseInt(i[1]),unit:"hours"};const r=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);if(r){const o=parseInt(r[1]);return o%7===0?{count:o/7,unit:"weeks"}:{count:o,unit:"days"}}return null}function pb(t,e){return e===1?{minutes:"minute",hours:"hour",days:"day",weeks:"week"}[t]??t:t}const _b=[{label:"5 minutes",cron:"*/5 * * * *"},{label:"Hour",cron:"0 * * * *"},{label:"Day",cron:"0 0 * * *"},{label:"Week",cron:"0 0 * * 1"}];function gb({automationId:t,open:e,onOpenChange:s,onCustomSelect:i,onEventSelect:r,onWebhookCreated:o}){const{triggerAdd:a}=ki(),[l,h]=M.useState(!1),c=e??l,d=p=>{s?s(p):h(p)},u=async p=>{try{await a.mutateAsync({automation_id:t,type:"cron",cron_expression:p}),ae.success("Starter added"),d(!1)}catch(m){const _=m instanceof Error?m.message:"Failed to add starter";ae.error(_)}},f=async()=>{try{const p=await a.mutateAsync({automation_id:t,type:"webhook"});d(!1),p.webhook?o?.(p.webhook):ae.success("Webhook starter added")}catch(p){const m=p instanceof Error?p.message:"Failed to add webhook starter";ae.error(m)}};return n.jsxs(Ds,{open:c,onOpenChange:d,children:[n.jsx(As,{asChild:!0,children:n.jsxs(te,{variant:"outline",size:"sm",children:[n.jsx(zt,{size:14}),"Add Starter"]})}),n.jsxs(Ms,{align:"end",className:"w-[200px]",children:[n.jsxs(Zu,{children:[n.jsxs(Qu,{className:"gap-2.5",children:[n.jsx(ri,{size:14,className:"text-muted-foreground shrink-0"}),"Every..."]}),n.jsx(ef,{className:"w-[160px]",children:_b.map(p=>n.jsxs(ht,{className:"gap-2.5",onSelect:()=>u(p.cron),disabled:a.isPending,children:[n.jsx(ri,{size:14,className:"text-muted-foreground shrink-0"}),"Every ",p.label]},p.cron))})]}),n.jsxs(ht,{className:"gap-2.5",onSelect:()=>{d(!1),i?.()},children:[n.jsx(ri,{size:14,className:"text-muted-foreground shrink-0"}),"Custom (cron)"]}),n.jsxs(ht,{className:"gap-2.5",onSelect:()=>{d(!1),r?.()},children:[n.jsx(ui,{size:14,className:"text-muted-foreground shrink-0"}),"Event"]}),n.jsxs(ht,{className:"gap-2.5",onSelect:()=>{f()},disabled:a.isPending,children:[n.jsx(Yn,{size:14,className:"text-muted-foreground shrink-0"}),"Webhook"]})]})]})}function Bh(t){const e=U.c(31),{open:s,onOpenChange:i,url:r,token:o,title:a,description:l}=t,h=a===void 0?"Webhook ready":a,c=l===void 0?"Send a POST to this URL with the bearer token to fire the automation. The token is shown once — copy it now.":l,[d,u]=M.useState(null),[f,p]=M.useState("curl"),[m,_]=M.useState("header"),g=M.useId();let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=async(D,R)=>{try{await navigator.clipboard.writeText(D),u(R),ae.success("Copied"),setTimeout(()=>u(null),1500)}catch{ae.error("Failed to copy")}},e[0]=x):x=e[0];const y=x;let v;e[1]!==m||e[2]!==o||e[3]!==r?(v=r&&o&&m==="url"?`${r.replace(/\/$/,"")}/${o}`:r??"",e[1]=m,e[2]=o,e[3]=r,e[4]=v):v=e[4];const b=v,C=r&&o?m==="header"?`curl -X POST "${b}" \\
|
|
288
|
+
`,e)}paste(t){this._core.paste(t)}refresh(t,e){this._verifyIntegers(t,e),this._core.refresh(t,e)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(t){this._addonManager.loadAddon(this,t)}static get strings(){return{get promptLabel(){return ln.get()},set promptLabel(t){ln.set(t)},get tooMuchOutput(){return cn.get()},set tooMuchOutput(t){cn.set(t)}}}_verifyIntegers(...t){for(St of t)if(St===1/0||isNaN(St)||St%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(St of t)if(St&&(St===1/0||isNaN(St)||St%1!==0||St<0))throw new Error("This API only accepts positive integers")}};var _x=2,gx=1,vx=class{activate(t){this._terminal=t}dispose(){}fit(){let t=this.proposeDimensions();if(!t||!this._terminal||isNaN(t.cols)||isNaN(t.rows))return;let e=this._terminal._core;(this._terminal.rows!==t.rows||this._terminal.cols!==t.cols)&&(e._renderService.clear(),this._terminal.resize(t.cols,t.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let t=this._terminal._core._renderService.dimensions;if(t.css.cell.width===0||t.css.cell.height===0)return;let e=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,s=window.getComputedStyle(this._terminal.element.parentElement),i=parseInt(s.getPropertyValue("height")),r=Math.max(0,parseInt(s.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),a={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},l=a.top+a.bottom,h=a.right+a.left,c=i-l,d=r-h-e;return{cols:Math.max(_x,Math.floor(d/t.css.cell.width)),rows:Math.max(gx,Math.floor(c/t.css.cell.height))}}};function xx({source:t,onReady:e,onSelectionChange:s,className:i}){const r=M.useRef(null),o=M.useRef(null),a=M.useRef(s);a.current=s;const l=es(),h=M.useRef(t);return h.current=t,Cm((c,d)=>{c===h.current&&o.current?.write(d)}),M.useEffect(()=>{const c=r.current;if(!c)return;const d=getComputedStyle(document.documentElement),u=x=>d.getPropertyValue(x).trim()||void 0,f=new px({allowTransparency:!1,fontFamily:u("--font-mono")||"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:12.5,lineHeight:1.5,scrollback:5e3,cursorBlink:!1,disableStdin:!0,theme:{background:u("--sidebar")||u("--card")||u("--background")||"#1e1e1e",cursor:"transparent",foreground:u("--foreground")||"#d4d4d4",selectionBackground:u("--accent"),selectionForeground:u("--accent-foreground"),black:u("--muted"),red:u("--destructive"),green:u("--success"),yellow:u("--warning"),blue:u("--chart-1"),magenta:u("--chart-3"),cyan:u("--chart-5"),white:u("--foreground"),brightBlack:u("--muted-foreground"),brightRed:u("--destructive"),brightGreen:u("--success"),brightYellow:u("--warning"),brightBlue:u("--chart-1"),brightMagenta:u("--chart-3"),brightCyan:u("--chart-5"),brightWhite:u("--foreground")}}),p=new vx;f.loadAddon(p),f.open(c),p.fit();const m=l.getBuffer(t);m&&f.write(m),o.current=f,e?.(f);const _=f.onSelectionChange(()=>{const x=!!f.getSelection();a.current?.(x,()=>f.getSelection())}),g=new ResizeObserver(()=>{p.fit()});return g.observe(c),()=>{_.dispose(),g.disconnect(),o.current=null,f.dispose()}},[]),n.jsx("div",{className:re("h-full bg-sidebar p-3",i),children:n.jsx("div",{ref:r,className:"h-full"})})}function bx(t){const e=es(),[s,i]=M.useState(os),[r,o]=M.useState([]),[a,l]=M.useState(new Set),h=M.useRef(!1);if(!h.current&&e.scripts.length>0){const b=eg.find(C=>e.scripts.includes(C));b&&(h.current=!0,o(C=>C.includes(b)?C:[...C,b]),i(b))}if(a.size>0){let b=!1;const C=new Set(a);for(const S of a)e.activeProcesses.includes(S)||(C.delete(S),b=!0);b&&l(C)}const c=()=>t.onOpenChange(!t.open),d=b=>{i(b),t.open||t.onOpenChange(!0)},u=b=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(`/api/${encodeURIComponent(t.orgSlug)}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/exec/${encodeURIComponent(b)}`,{method:"POST"}),f=b=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(`/api/${encodeURIComponent(t.orgSlug)}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/exec/${encodeURIComponent(b)}/kill`,{method:"POST"}),p=async b=>{o(C=>C.includes(b)?C:[...C,b]),i(b),t.onOpenChange(!0);try{const C=await u(b);if(C===null)return;if(!C.ok)throw new Error(`Exec failed: ${C.statusText}`)}catch{ae.error("Failed to run "+b)}},m=async b=>{await f(b),o(C=>C.filter(S=>S!==b)),s===b&&i(os)},_=async()=>{const b=e.activeProcesses.includes(s);try{const C=await u(s);if(C===null)return;if(!C.ok)throw new Error(`Exec failed: ${C.statusText}`)}catch{ae.error((b?"Failed to restart ":"Failed to run ")+s)}},g=async()=>{if(!a.has(s)){l(b=>new Set(b).add(s));try{const b=await f(s);if(b===null){l(C=>{const S=new Set(C);return S.delete(s),S});return}if(!b.ok)throw new Error(`Kill failed: ${b.statusText}`)}catch{l(b=>{const C=new Set(b);return C.delete(s),C}),ae.error("Failed to stop "+s)}}},x=s!==os&&r.includes(s),y=x&&e.activeProcesses.includes(s),v=x&&a.has(s);return n.jsxs("div",{className:"flex shrink-0 flex-col",style:{height:t.open?"50%":"auto"},children:[n.jsx(tg,{status:t.status,open:t.open,onToggle:c,onStart:t.status==="idle"?t.onStart:void 0,onStop:t.status==="running"||t.status==="starting"?t.onStop:void 0,onRestart:t.status==="running"?t.onRestart:void 0,onResume:t.status==="suspended"?t.onResume:void 0,onRetry:t.status==="errored"?t.onRetry:void 0,scripts:t.scripts,active:s,scriptTabs:r,onSelectTab:d,onAddScript:p,onCloseScript:m,showScriptControls:x,scriptIsRunning:y,scriptIsKilling:v,onRunActiveScript:_,onStopActiveScript:g}),t.open&&n.jsx("div",{className:"flex-1 overflow-hidden",children:n.jsx(yx,{vmId:t.vmId,active:s,hasData:e.hasData(s),onRunActive:_})})]})}function yx(t){const e=U.c(10),{vmId:s,active:i,hasData:r,onRunActive:o}=t;if(!s)return null;if(i===os||r){let d;return e[0]!==i?(d=n.jsx(xx,{source:i,className:"h-full"},i),e[0]=i,e[1]=d):d=e[1],d}let a;e[2]!==i?(a=n.jsxs("p",{children:['Script "',n.jsx("span",{className:"font-mono text-foreground",children:i}),'" not running']}),e[2]=i,e[3]=a):a=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(js,{className:"size-3.5"}),e[4]=l):l=e[4];let h;e[5]!==o?(h=n.jsxs("button",{type:"button",onClick:o,className:"flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs text-foreground hover:bg-accent",children:[l," Run"]}),e[5]=o,e[6]=h):h=e[6];let c;return e[7]!==a||e[8]!==h?(c=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 text-sm text-muted-foreground",children:[a,h]}),e[7]=a,e[8]=h,e[9]=c):c=e[9],c}const Ph=t=>`preview-drawer:${t}`;function Sx(t){try{const e=localStorage.getItem(Ph(t));return e?!!JSON.parse(e).open:!1}catch{return!1}}function wx(t,e){try{localStorage.setItem(Ph(t),JSON.stringify({open:e}))}catch{}}const Cx=M.lazy(()=>vi(()=>import("./sections-editor-Bp1g_Th1.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135])).then(t=>({default:t.SectionsEditor}))),kx=M.lazy(()=>vi(()=>import("./file-explorer-CsyafORl.js"),__vite__mapDeps([136,1,2,132,103,3,4,6,7,8,9,10,11,12,13,14,15,16,5,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,90,91,54,92,93,94,53,95,55,96,97,45,98,99,100,83,84,85,86,87,88,89,62,101,52,102,67,68,46,66,63,77,104,105,106,76,107,108,61,109,79,74,80,81,56,57,110,47,111,48,49,50,51,58,59,60,64,65,69,70,71,72,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,75,128,129,130,131,133,134,135])).then(t=>({default:t.FileExplorer}))),ml=500;function jx(t){switch(t.kind){case"suspended":return"suspended";case"iframe":return"running";case"starting":return"starting"}}function Nx(){const t=Io(),{data:e}=Es.useSession(),{taskId:s,currentBranch:i,setCurrentTaskBranch:r}=Qt(),[o,a]=M.useState("preview"),[l,h]=M.useState(null),c=M.useRef(null),d=o==="cms",[u,f]=M.useState(null),[p,m]=M.useState(384),_=M.useRef(!1),g=M.useRef(0),x=M.useRef(0),y=M.useRef(null),[v,b]=M.useState(!1),[C,S]=M.useState(""),k=M.useRef(null),[N,P]=M.useState(!1),[A,E]=M.useState(),[j,w]=M.useState(null),[T,D]=M.useState(null),[R,I]=M.useState("/"),B=e?.user?.id,H=t?.entity?.metadata,W=B&&i?hi(H?.sandboxMap?.[B]?.[i]):{},z=Object.values(W),O=z.find(Y=>Y.sandboxProviderKind!=="user-desktop")??z[0],V=O?.previewUrl??null,K=t?.entity?.id??null,{org:Q}=ke(),X=es(),q=X.lifecycle.phase,se=q==="running",$=K&&i&&se?{orgSlug:Q.slug,virtualMcpId:K,branch:i}:null,{data:L}=po($,{fetchEnabled:se}),{data:J}=_o($,{fetchEnabled:se}),Z=K&&i?{orgSlug:Q.slug,virtualMcpId:K,branch:i}:null,F=R_(Z),ne=L?xo(L).sort((Y,ce)=>Y.name.localeCompare(ce.name)):[],ie=L&&J?bo(L,J):[],de=oi,ue=ne.filter(Y=>{if(!C)return!0;const ce=C.toLowerCase();return Y.name.toLowerCase().includes(ce)||Y.path.toLowerCase().includes(ce)}),_e=ie.filter(Y=>{if(!C)return!0;const ce=C.toLowerCase();return Y.name.toLowerCase().includes(ce)||Y.key.toLowerCase().includes(ce)||Y.resolveType.toLowerCase().includes(ce)}),le=j?j.name:ne.find(Y=>de(Y.path)===de(R))?.name,je=M.useRef(null),Ne=M.useRef(null);km(()=>{const Y=c.current,ce=je.current;!Y||!ce||(Y.src=ce)});const Xe=X.status.state==="paused",Et=Qe({connectionId:hs,orgId:t?.entity?.organization_id??"",orgSlug:Q.slug}),Ie=qn(Et),Tt=M.useRef(null),zs=M.useRef(null),Fs=X.phase,fe=Oc({claimPhase:Fs,lifecycle:X.lifecycle}),xe=!!K&&!!i&&Hi.isStopped(K,i),ve=Ic({previewUrl:V,appPaused:Xe,userStopped:xe}),Le=ve.kind==="iframe"?T??new URL(R,ve.previewUrl).href:null,[rt,Fh]=M.useState(null);if(ve.kind==="iframe"&&rt!==ve.previewUrl){const Y=rt!==null;Fh(ve.previewUrl),Y&&(Ne.current=null,I("/"),D(null),w(null))}je.current=Le;const Lo=!!K&&!!i&&!X.notFound&&!xe&&!Xe&&(Fs?.kind==="ready"||q!=="idle"),Ar=ve.kind!=="iframe"&&(o==="visual"||o==="cms")?"preview":o,Mr=Y=>{if(!K)return;const ce={virtualMcpId:K};i&&(ce.branch=i),Ie.mutate(ce,{onSuccess:De=>{De?.branch&&!i&&r(De.branch)},onError:De=>{console.error(`[preview] ${Y} SANDBOX_START failed`,De)}})},Hs=M.useRef(Mr);Hs.current=Mr,s&&O&&Tt.current!==s&&(Tt.current=s);const Oo=!!s&&!!K&&!!B&&!!i&&!O&&!xe&&!Ie.isPending&&Tt.current!==s;M.useEffect(()=>{!Oo||!s||(Tt.current=s,Hs.current("auto-start"))},[Oo,s,xe]);const Pi=X.notFound?O?.sandboxHandle??null:null;M.useEffect(()=>{!Pi||!K||Ie.isPending||zs.current!==Pi&&(i&&Hi.isStopped(K,i)||(zs.current=Pi,Hs.current("self-heal")))},[Pi,K,Ie.isPending,i]);const Br=()=>{Tt.current=null,zs.current=null,Ie.reset(),Hs.current("auto-start")},Hh=vr(),Di=K??"__no-vmcp__",[Wh,$o]=M.useState(null),zo=M.useRef(null);zo.current!==Di&&(zo.current=Di,$o(Sx(Di)));const Uh=ve.kind==="starting"?!1:Wh??!1,Kh=Y=>{$o(Y),wx(Di,Y)},Fo=async()=>{if(!K)return;const Y=i;if(!Y)return;const ce=O?.sandboxProviderKind;if(ce){Hi.mark(K,Y);try{await Et.callTool({name:"SANDBOX_DELETE",arguments:{virtualMcpId:K,branch:Y,sandboxProviderKind:ce}})}catch{}dd(Hh)}},Vh=async()=>{await Fo(),Hs.current("auto-start")};M.useEffect(()=>{if(!V)return;let Y;try{Y=new URL(V,window.location.href).origin}catch{return}const ce=De=>{if(De.origin===Y){if(De.data?.type==="visual-editor::element-clicked"){const Je=D_.safeParse(De.data.payload);Je.success&&h(Je.data)}else if(De.data?.type==="cms-editor::section-clicked"){const Je=M_.safeParse(De.data.payload);Je.success&&f(Je.data.sectionIndex)}}};return window.addEventListener("message",ce),()=>window.removeEventListener("message",ce)},[V]),M.useEffect(()=>{if(!v)return;const Y=ce=>{k.current?.contains(ce.target)||(b(!1),S(""))};return document.addEventListener("pointerdown",Y),()=>document.removeEventListener("pointerdown",Y)},[v]),M.useEffect(()=>{if(!d)return;const Y=De=>{const Je=De.target;Je&&Je!==c.current&&(y.current=Je)},ce=()=>{requestAnimationFrame(()=>{const De=document.activeElement;(De===document.body||De===c.current)&&y.current&&y.current.focus()})};return document.addEventListener("focusin",Y),document.addEventListener("blur",ce,!0),()=>{document.removeEventListener("focusin",Y),document.removeEventListener("blur",ce,!0)}},[d]);const Ho=()=>{const Y=c.current?.contentWindow;Y&&Y.postMessage({type:"visual-editor::activate",script:A_},"*")},qh=()=>{const Y=c.current?.contentWindow;Y&&Y.postMessage({type:"visual-editor::deactivate"},"*")},Wo=()=>{const Y=c.current?.contentWindow;Y&&Y.postMessage({type:"visual-editor::activate",script:B_},"*")},Gh=()=>{const Y=c.current?.contentWindow;Y&&Y.postMessage({type:"cms-editor::deactivate"},"*")},Uo=Y=>{const ce=o;a(Y),h(null),Y!=="cms"&&f(null),ce==="visual"&&qh(),ce==="cms"&&Gh(),Y==="visual"&&Ho(),Y==="cms"&&Wo()},Yh=()=>{if(!c.current||!Le)return;const Y=c.current;Y.src=Le},Xh=()=>{if(!c.current||!Le)return;const Y=Le.includes("?")?"&":"?";c.current.src=`${Le}${Y}_r=${Date.now()}`},Jh=()=>{const Y=c.current?.contentWindow?.location?.href??Le??V;Y&&navigator.clipboard.writeText(Y)},Zh=(()=>{if(!V)return"No server running";if(j)return j.name;try{const Y=new URL(V),ce=R==="/"?"":R;return`${Y.host}${ce}`}catch{return V}})(),Ko=Y=>{Ne.current=Y,w(null),D(null),I(Y),f(null)},Qh=Y=>{if(!V||!J){ae.error("Preview metadata not ready yet");return}Ne.current=null;const ce=mc(J),De=k_(V,ce,Y.key);w(Y),D(De),f(null)},ed=async({name:Y,path:ce})=>{if(!K||!i)return;const De=wo(ce);if(De){E(De);return}const Je=ce.trim().startsWith("/")?ce.trim():`/${ce.trim()}`;if(ne.some(Rt=>de(Rt.path)===de(Je))){E(`A page with path "${Je}" already exists.`);return}E(void 0);try{const Rt=await F.mutateAsync({name:Y,path:Je});P(!1),ae.success(`Page "${Y}" created`),await new Promise(sd=>setTimeout(sd,ml)),Ko(Rt.path),Uo("cms")}catch(Rt){E(Rt instanceof Error?Rt.message:"Failed to create page")}},td=[{value:"preview",icon:n.jsx(iu,{size:14}),tooltip:"Interactive"},...ve.kind==="iframe"?[{value:"visual",icon:n.jsx(Zo,{size:14}),tooltip:"Visual editor"}]:[],...ve.kind==="iframe"&&_c(L,J)?[{value:"cms",icon:n.jsx(ru,{size:14}),tooltip:"Sections editor"}]:[],{value:"code",icon:n.jsx(nu,{size:14}),tooltip:"Code editor"}];return n.jsxs("div",{className:"flex flex-col w-full h-full",children:[Lo&&n.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-4 border-b border-border/60 px-3 md:px-4",children:[n.jsx("div",{className:"flex shrink-0 items-center gap-1",children:n.jsx(sf,{value:Ar,onValueChange:Uo,options:td,size:"sm",className:"shrink-0 bg-foreground/4.5"})}),ve.kind==="iframe"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:re("flex min-w-0 flex-1 items-center gap-0.5",o==="code"&&"hidden"),children:[n.jsxs(Ce,{children:[n.jsx(Se,{asChild:!0,children:n.jsx(te,{variant:"ghost",size:"icon",onClick:Yh,children:n.jsx(ci,{size:14})})}),n.jsx(we,{side:"bottom",children:"Refresh"})]}),n.jsxs("div",{ref:k,className:"relative min-w-0 flex-1",children:[n.jsxs("button",{type:"button",className:"flex h-8 w-full min-w-0 items-center gap-1 rounded-md bg-background px-2 transition-colors duration-200 hover:bg-accent",onClick:()=>b(Y=>!Y),children:[j&&n.jsxs("span",{className:"shrink-0 inline-flex items-center gap-1 rounded bg-global-section/14 px-1.5 py-0.5 text-[11px] font-medium text-global-section-fg dark:text-global-section-fg-dark",children:[n.jsx(cr,{size:11}),"Global"]}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-left text-[12px] text-foreground/88",children:Zh}),le&&!j&&n.jsx("span",{className:"shrink-0 text-[12px] text-muted-foreground",children:le}),n.jsx(ao,{size:12,className:re("shrink-0 text-muted-foreground transition-transform",v&&"rotate-180")})]}),v&&n.jsxs("div",{className:"absolute left-0 right-0 top-full z-50 mt-1.5 overflow-hidden rounded-lg border bg-popover shadow-lg",children:[n.jsxs("div",{className:"px-2 h-10 flex items-center gap-2 border-b",children:[n.jsx(Zl,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),n.jsx("input",{type:"text",value:C,onChange:Y=>S(Y.target.value),placeholder:"Search pages and components...",className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground",autoFocus:!0})]}),n.jsx("div",{className:"p-1.5 border-b",children:n.jsxs("button",{type:"button",className:"flex w-full items-center gap-2.5 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:Y=>{Y.preventDefault(),b(!1),S(""),E(void 0),P(!0)},children:[n.jsx(zt,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"flex-1 font-medium",children:"Create new page"})]})}),ue.length===0&&_e.length===0?n.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:ne.length===0&&ie.length===0?"No pages found in this site.":"No results match your search."}):n.jsxs("div",{className:"max-h-80 overflow-y-auto overscroll-contain",children:[ue.length>0&&n.jsx("div",{className:"p-1.5",children:ue.map(Y=>n.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:ce=>{ce.preventDefault(),b(!1),S(""),Ko(Y.path)},children:[n.jsx(eo,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:Y.name}),n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:Y.path})]},Y.key))}),_e.length>0&&n.jsxs("div",{className:re("p-1.5",ue.length>0&&"border-t"),children:[n.jsx("div",{className:"px-3 py-2 text-xs font-medium text-muted-foreground",children:"Global components"}),_e.map(Y=>n.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:ce=>{ce.preventDefault(),b(!1),S(""),Qh(Y)},children:[n.jsx(cr,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:Y.name}),n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:Y.resolveType.split("/").pop()?.replace(/\.tsx?$/,"")})]},Y.key))]})]})]})]})]}),n.jsxs("div",{className:re("flex shrink-0 items-center gap-0.5",o==="code"&&"hidden"),children:[n.jsxs(Ce,{children:[n.jsx(Se,{asChild:!0,children:n.jsx(te,{variant:"ghost",size:"icon",onClick:()=>{const Y=Le??ve.previewUrl;Y&&window.open(Y,"_blank","noopener")},children:n.jsx(Ps,{size:14})})}),n.jsx(we,{side:"bottom",children:"Open in new tab"})]}),n.jsxs(Ds,{children:[n.jsx(As,{asChild:!0,children:n.jsx(te,{variant:"ghost",size:"icon",children:n.jsx(Cr,{size:14})})}),n.jsxs(Ms,{align:"end",children:[n.jsx(ht,{onClick:Xh,children:"Hard Reload"}),n.jsx(ht,{onClick:Jh,children:"Copy Current URL"})]})]})]})]})]}),n.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[d&&V&&i&&K&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"shrink-0 border-r overflow-hidden",style:{width:p},children:n.jsx(M.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(Cx,{orgSlug:Q.slug,virtualMcpId:K,branch:i,previewReady:se,previewUrl:V,currentPath:R,activeGlobalBlockKey:j?.key??null,externalSelectedIndex:j?null:u,onSaved:()=>{setTimeout(()=>{const Y=c.current;if(!Y)return;const ce=document.activeElement,De=Y.tabIndex;Y.tabIndex=-1,Y.style.pointerEvents="none",Y.blur();try{Y.contentWindow?.location.reload()}catch{const Rt=je.current;Rt&&(Y.src=Rt)}const Je=()=>{Y.tabIndex=De,Y.style.pointerEvents="",ce?.focus(),Y.removeEventListener("load",Je)};Y.addEventListener("load",Je),setTimeout(Je,3e3)},ml)}})})}),n.jsx("div",{className:"w-1 shrink-0 cursor-col-resize bg-transparent hover:bg-border transition-colors",onPointerDown:Y=>{_.current=!0,g.current=Y.clientX,x.current=p,Y.currentTarget.setPointerCapture(Y.pointerId)},onPointerMove:Y=>{if(!_.current)return;const ce=Y.clientX-g.current;m(Math.max(240,Math.min(640,x.current+ce)))},onPointerUp:()=>{_.current=!1}})]}),n.jsxs("div",{className:"flex-1 relative overflow-hidden",children:[ve.kind==="starting"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(hr,{kind:"starting",progress:fe,claimPhase:Fs})}),ve.kind==="suspended"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(hr,{kind:"suspended",onResume:Br})}),Ar==="visual"&&!l&&n.jsxs("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 z-20 flex items-center gap-1.5 rounded-full border border-violet-400/40 bg-violet-500/90 px-3 py-1 text-xs font-medium text-white shadow-md backdrop-blur-sm pointer-events-none select-none",children:[n.jsx(Zo,{size:12}),"Click any element to ask the AI"]}),Ar==="visual"&&l&&n.jsx(O_,{element:l,onDismiss:()=>h(null)}),o==="code"&&Lo&&K&&i&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(M.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(kx,{orgSlug:Q.slug,virtualMcpId:K,branch:i})})}),ve.kind==="iframe"&&Le&&n.jsx("iframe",{ref:c,src:Le,className:re("w-full h-full border-0",o==="code"&&"invisible"),title:"Dev Server Preview",tabIndex:d?-1:void 0,onLoad:()=>{if(Pe("vm_preview_loaded",{view_mode:o,vm_id:O?.sandboxHandle??null}),!j)try{const Y=c.current?.contentWindow?.location?.pathname;if(!Y)return;const ce=Ne.current;if(ce!==null){Ne.current=null,de(Y)===de(ce)&&I(Y);return}I(Y)}catch{}o==="visual"&&Ho(),o==="cms"&&Wo()}},ve.previewUrl)]})]}),n.jsx(bx,{vmId:O?.sandboxHandle??null,orgSlug:Q.slug,virtualMcpId:K,branch:i,status:jx(ve),scripts:X.scripts,open:Uh,onOpenChange:Kh,onStart:()=>Mr("auto-start"),onStop:Fo,onRestart:Vh,onResume:Br,onRetry:Br},O?.sandboxHandle??"no-vm"),n.jsx(P_,{open:N,onOpenChange:P,isPending:F.isPending,error:A,onSubmit:ed})]})}function Ex(t){const e=U.c(2),{virtualMcpId:s}=t,i=bt(s);if(!xi(i?.metadata)){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground p-6",children:[n.jsx(bi,{size:24,className:"text-muted-foreground/60"}),n.jsx("div",{children:"No source to preview."}),n.jsx("div",{className:"text-xs text-muted-foreground/80",children:"Connect a GitHub repository from the Connections tab to enable Preview."})]}),e[0]=a):a=e[0],a}let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(Nx,{}),e[1]=o):o=e[1],o}function Tx({orgSlug:t,virtualMcpId:e,branch:s}){const i=vr();return xr({mutationFn:async({blockKey:r})=>{const o=Mc(r),a=await fetch(`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/unlink`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:o})});if(!a.ok){const l=await a.json().catch(()=>({}));throw new Error(l.error??`Delete failed (${a.status})`)}return a.json()},onMutate:async({blockKey:r})=>{const o=`${t}/${e}/${s}`,a=$t.decofile(o);await i.cancelQueries({queryKey:a});const l=i.getQueryData(a);return i.setQueryData(a,h=>{if(!h)return h;const{[r]:c,...d}=h;return d}),{previous:l,queryKey:a}},onError:(r,o,a)=>{a?.queryKey&&i.setQueryData(a.queryKey,a.previous)},onSuccess:()=>{const r=`${t}/${e}/${s}`;i.invalidateQueries({queryKey:$t.liveMeta(r)})}})}const Rx=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function Px(t){return t.includes("matchers")||t.includes("Match")}function Dx(t,e){const s=t.__resolveType;return typeof s!="string"||!s||Rx.has(s)?!1:e?nm(e,s):Px(s)}function Ri(t,e,s){if(!t)return!1;const i=t.__resolveType;if(typeof i!="string"||!go(i)||!Object.hasOwn(e,i))return!1;const r=e[i];return!r||typeof r!="object"||Array.isArray(r)?!1:Dx(r,s)}function oS(t,e,s){return Ri(t,e,s)?t?.__resolveType??null:null}function Dh(t,e,s){if(!t)return null;const i=t.__resolveType??"";if(!i)return null;if(Ri(t,e,s)){const a=e[i]??{},l=a.__resolveType??i,{__resolveType:h,name:c,...d}=a;return{resolveType:l,data:d,blockKey:i}}const{__resolveType:r,...o}=t;return{resolveType:i,data:o}}function Ax(t,e,s){const i=Dh(t,e,s);return i?{__resolveType:i.resolveType,...i.data}:{__resolveType:""}}function aS(t,e,s){if(t)return Ri(t,e,s)?Ax(t,e,s):t}function Mx(t,e,s,i){if(!t)return"Default";if(Ri(t,e,i)){const r=t.__resolveType??"",o=e[r];return gc(r,o)}return s(t)}function lS(t,e,s){return{__resolveType:t,...e,name:s}}function cS(t){return{__resolveType:t}}function hS(t,e,s){const i=Dh(t,e,s);return i?{resolveType:i.resolveType,formValue:i.data}:{resolveType:"",formValue:{}}}function dS(t){return{__resolveType:dm,variants:[{value:t,rule:{__resolveType:hc}}]}}function uS(t){const r=(Nr(t.__resolveType)?t.section:t)?.variants?.[0];return r?.rule?.__resolveType!==hc?null:r?.value??null}const Bx=["website/matchers/always.ts","$live/matchers/MatchAlways.ts"];function Ah(t){if(!t)return!1;const e=t.__resolveType??"";return e===""?Object.keys(t).length===0:Bx.includes(e)||e.includes("always")}function Ix(t){const e=t.variants??[];if(e.length===0)return-1;const s=e.findIndex(i=>Ah(i.rule));return s!==-1?s:e.length-1}function fS(t,e,s){const i=s.variants??[];if(i.length===0)return null;const r=Ix(s),o=i[r]?.value;if(!o)return null;const a=structuredClone(o);return e.isLazy?{...t,section:a}:a}function mS(t,e){return e.isMultivariate?e.isLazy?t.section??null:t:null}function pS(t,e){return Array.isArray(t.variants)?t.variants.map((s,i)=>({label:e(s.rule)||`Variant ${i+1}`,value:s.value??{},rule:s.rule})):[]}function _S(t,e){const s=t.__resolveType??"";if(!s)return null;if(Nr(s)){const i=t.section??t,r=i.__resolveType??s;if(!r.includes("/")&&r in e){const o=e[r]??{};return{data:{...o},resolveType:o.__resolveType??r}}return{data:{...i},resolveType:r}}if(!s.includes("/")&&s in e){const i=e[s]??{};return{data:{...i},resolveType:i.__resolveType??s}}return{data:{...t},resolveType:s}}function Lx(t,e){const s=t.__resolveType??"";return Nr(s)?{...t,section:e}:e}function gS(t,e,s){return e.isLazy?{...t,section:s}:s}function vS(t,e,s){const i=[...t.variants??[]],r=i[e];if(!r)return t;const o=r.value??{};return i[e]={...r,value:Lx(o,s)},{...t,variants:i}}function xS(t,e,s){const i=[...t.variants??[]];return i[e]?(i[e]={...i[e],rule:s},{...t,variants:i}):t}function bS(t,e){const s=[...t.variants??[]],i=s[e];return i?(s.splice(e+1,0,structuredClone(i)),{...t,variants:s}):t}function yS(t,e){const s=[...t.variants??[]];return s.length<=1?null:(s.splice(e,1),{...t,variants:s})}const Ox=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function $x(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t;return typeof e.__resolveType=="string"&&Ox.has(e.__resolveType)&&typeof e.path=="string"}function Mh(t,e){const i=t[e]?.sections;if(!i||Array.isArray(i))return 1;const r=i;return Array.isArray(r.variants)?r.variants.length:1}function zx(t,e,s){const r=t[e]?.sections;if(Array.isArray(r))return s===0?r:[];if(r&&typeof r=="object"){const o=r.variants;if(Array.isArray(o)){const a=o[s];return Array.isArray(a?.value)?a.value:[]}}return[]}function SS(t,e,s){if(Array.isArray(t))return[{label:"Default",sections:t}];if(t&&typeof t=="object"){const i=t;if(Array.isArray(i.variants)){const r=i.variants,o=r.map(h=>Mx(h.rule,e,s)),a=o.reduce((h,c)=>(h[c]=(h[c]??0)+1,h),{}),l={};return r.map((h,c)=>{const d=o[c]??`Variant ${c+1}`,u=a[d]??1;let f=d;return u>1&&(l[d]=(l[d]??0)+1,f=`${d} ${l[d]}`),{label:f||`Variant ${c+1}`,sections:Array.isArray(h.value)?h.value:[],rule:h.rule}})}}return[]}function Fx(){return{__resolveType:cm}}function Xs(t){return{rule:Fx(),value:t}}function Cs(t,e){return{...e,__resolveType:hm,variants:t}}function Hx(t,e){const s=structuredClone(e);if(Array.isArray(t))return Cs([Xs(t),Xs(s)]);if(t&&typeof t=="object"){const i=t;return Array.isArray(i.variants)?Cs([...i.variants,Xs(s)],i):null}return Cs([Xs([]),Xs(s)])}function wS(t){const e=t.variants;return Array.isArray(e)?e.length-1:1}function CS(t,e){if(e.length===0)return Cs([],t);if(e.length===1){const s=e[0],i=s?.rule;if(!Ah(i))return Cs(e,t);if(Array.isArray(s?.value))return s.value}return Cs(e,t)}function Wx(t,e){for(const[s,i]of Object.entries(t)){if(!$x(i))continue;const r=i.sections;if(Array.isArray(r)){e(void 0,s,0);continue}if(!r||typeof r!="object")continue;const o=r.variants;if(Array.isArray(o))for(let a=0;a<o.length;a++){const l=o[a];e(l?.rule,s,a)}}}function kS(t,e,s){let i=0;return Wx(t,r=>{if(!r)return;(r.__resolveType??"")===e&&Ri(r,t,s)&&i++}),i}function pl(t,e){const s=e.replace(/\s*\(copy(?:\s+\d+)?\)\s*$/,"").trim(),i=`${s} (copy)`;if(!t.has(i))return i;for(let r=2;r<1e3;r++){const o=`${s} (copy ${r})`;if(!t.has(o))return o}return`${s} (copy ${Date.now()})`}function Ux(t,e){const s=oi,i=e.replace(/-copy(?:-\d+)?$/,""),r=`${i}-copy`;if(!t.has(s(r)))return r;for(let o=2;o<1e3;o++){const a=`${i}-copy-${o}`;if(!t.has(s(a)))return a}return`${i}-copy-${Date.now()}`}function _l(t,e){const s=e.replace(/_copy(?:_\d+)?$/,""),i=`${s}_copy`;if(!Object.hasOwn(t,i))return i;for(let r=2;r<1e3;r++){const o=`${s}_copy_${r}`;if(!Object.hasOwn(t,o))return o}return`${s}_copy_${Date.now()}`}function Kx(t){const e=Co(t.newName),s={...t.source,name:t.newName,path:t.newPath};return{key:e,data:s}}function Vx(t,e){return Ac(t,e)}const qx=1e3;function Gx(t,e){for(let s=0;s<qx;s++){const i=Co(e);if(!Object.hasOwn(t,i))return i}throw new Error("Could not generate a unique page block key")}const Yx={create:"Create new page",duplicate:"Duplicate page",rename:"Rename page"},Xx={create:"Create",duplicate:"Duplicate",rename:"Save"},Jx={create:"Creating…",duplicate:"Duplicating…",rename:"Saving…"};function Zx(t){const e=U.c(54),{open:s,mode:i,initialName:r,initialPath:o,isPending:a,error:l,validate:h,onSubmit:c,onOpenChange:d}=t,u=a===void 0?!1:a,[f,p]=M.useState(r),[m,_]=M.useState(o),[g,x]=M.useState(null),[y,v]=M.useState(s);s!==y&&(v(s),s&&(p(r),_(o),x(null)));let b;e[0]!==u||e[1]!==d?(b=q=>{!q&&!u&&(x(null),d(!1))},e[0]=u,e[1]=d,e[2]=b):b=e[2];const C=b;let S;e[3]!==u||e[4]!==f||e[5]!==c||e[6]!==m||e[7]!==h?(S=async q=>{q.preventDefault();const se=f.trim(),$=m.trim();if(!se||!$||u)return;const L=wo($);if(L){x(L);return}const J=h?.({name:se,path:$});if(J){x(J);return}x(null),await c({name:se,path:$})},e[3]=u,e[4]=f,e[5]=c,e[6]=m,e[7]=h,e[8]=S):S=e[8];const k=S,N=g??l,P=Yx[i];let A;e[9]!==P?(A=n.jsx(fs,{children:n.jsx(ms,{children:P})}),e[9]=P,e[10]=A):A=e[10];let E;e[11]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx("label",{htmlFor:"page-form-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[11]=E):E=e[11];let j;e[12]===Symbol.for("react.memo_cache_sentinel")?(j=q=>p(q.target.value),e[12]=j):j=e[12];let w;e[13]!==u||e[14]!==f?(w=n.jsxs("div",{className:"space-y-1.5",children:[E,n.jsx(Ge,{id:"page-form-name",value:f,onChange:j,placeholder:"My page",autoFocus:!0,disabled:u})]}),e[13]=u,e[14]=f,e[15]=w):w=e[15];let T;e[16]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsx("label",{htmlFor:"page-form-path",className:"text-xs font-medium text-muted-foreground",children:"Path"}),e[16]=T):T=e[16];let D;e[17]===Symbol.for("react.memo_cache_sentinel")?(D=q=>_(q.target.value),e[17]=D):D=e[17];let R;e[18]!==u||e[19]!==m?(R=n.jsxs("div",{className:"space-y-1.5",children:[T,n.jsx(Ge,{id:"page-form-path",value:m,onChange:D,placeholder:"/example",disabled:u})]}),e[18]=u,e[19]=m,e[20]=R):R=e[20];let I;e[21]!==N?(I=N&&n.jsx("p",{className:"text-xs text-destructive",children:N}),e[21]=N,e[22]=I):I=e[22];let B;e[23]!==R||e[24]!==I||e[25]!==w?(B=n.jsxs("div",{className:"space-y-4 py-4",children:[w,R,I]}),e[23]=R,e[24]=I,e[25]=w,e[26]=B):B=e[26];let H;e[27]!==d?(H=()=>d(!1),e[27]=d,e[28]=H):H=e[28];let W;e[29]!==u||e[30]!==H?(W=n.jsx(te,{type:"button",variant:"outline",onClick:H,disabled:u,children:"Cancel"}),e[29]=u,e[30]=H,e[31]=W):W=e[31];let z;e[32]!==u||e[33]!==f||e[34]!==m?(z=!f.trim()||!m.trim()||u,e[32]=u,e[33]=f,e[34]=m,e[35]=z):z=e[35];let O;e[36]!==u||e[37]!==i?(O=u?n.jsxs(n.Fragment,{children:[n.jsx(ge,{size:14,className:"animate-spin"}),Jx[i]]}):Xx[i],e[36]=u,e[37]=i,e[38]=O):O=e[38];let V;e[39]!==z||e[40]!==O?(V=n.jsx(te,{type:"submit",disabled:z,children:O}),e[39]=z,e[40]=O,e[41]=V):V=e[41];let K;e[42]!==W||e[43]!==V?(K=n.jsxs(Rs,{children:[W,V]}),e[42]=W,e[43]=V,e[44]=K):K=e[44];let Q;e[45]!==k||e[46]!==B||e[47]!==K||e[48]!==A?(Q=n.jsx(Ft,{className:"sm:max-w-md",children:n.jsxs("form",{onSubmit:k,children:[A,B,K]})}),e[45]=k,e[46]=B,e[47]=K,e[48]=A,e[49]=Q):Q=e[49];let X;return e[50]!==C||e[51]!==s||e[52]!==Q?(X=n.jsx(Ht,{open:s,onOpenChange:C,children:Q}),e[50]=C,e[51]=s,e[52]=Q,e[53]=X):X=e[53],X}function Qx(t){const e=U.c(43),{open:s,blockKey:i,initialName:r,isPending:o,onSubmit:a,onOpenChange:l}=t,h=o===void 0?!1:o,[c,d]=M.useState(r),[u,f]=M.useState(s);s!==u&&(f(s),s&&d(r));let p;e[0]!==h||e[1]!==l?(p=R=>{!R&&!h&&l(!1)},e[0]=h,e[1]=l,e[2]=p):p=e[2];const m=p;let _;e[3]!==h||e[4]!==c||e[5]!==a?(_=async R=>{R.preventDefault();const I=c.trim();!I||h||await a(I)},e[3]=h,e[4]=c,e[5]=a,e[6]=_):_=e[6];const g=_;let x;e[7]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsxs(fs,{children:[n.jsx(ms,{children:"Rename section"}),n.jsx(so,{children:"Updates the display name. The internal key stays the same so pages referencing this section keep working."})]}),e[7]=x):x=e[7];let y;e[8]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx("label",{htmlFor:"section-rename-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[8]=y):y=e[8];let v;e[9]===Symbol.for("react.memo_cache_sentinel")?(v=R=>d(R.target.value),e[9]=v):v=e[9];let b;e[10]!==h||e[11]!==c?(b=n.jsxs("div",{className:"space-y-1.5",children:[y,n.jsx(Ge,{id:"section-rename-name",value:c,onChange:v,autoFocus:!0,disabled:h})]}),e[10]=h,e[11]=c,e[12]=b):b=e[12];let C;e[13]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Key"}),e[13]=C):C=e[13];let S;e[14]!==i?(S=n.jsxs("div",{className:"space-y-1.5",children:[C,n.jsx(Ge,{value:i,readOnly:!0,disabled:!0,className:"font-mono"})]}),e[14]=i,e[15]=S):S=e[15];let k;e[16]!==b||e[17]!==S?(k=n.jsxs("div",{className:"space-y-4 py-4",children:[b,S]}),e[16]=b,e[17]=S,e[18]=k):k=e[18];let N;e[19]!==l?(N=()=>l(!1),e[19]=l,e[20]=N):N=e[20];let P;e[21]!==h||e[22]!==N?(P=n.jsx(te,{type:"button",variant:"outline",onClick:N,disabled:h,children:"Cancel"}),e[21]=h,e[22]=N,e[23]=P):P=e[23];let A;e[24]!==h||e[25]!==c?(A=!c.trim()||h,e[24]=h,e[25]=c,e[26]=A):A=e[26];let E;e[27]!==h?(E=h?n.jsxs(n.Fragment,{children:[n.jsx(ge,{size:14,className:"animate-spin"}),"Saving…"]}):"Save",e[27]=h,e[28]=E):E=e[28];let j;e[29]!==A||e[30]!==E?(j=n.jsx(te,{type:"submit",disabled:A,children:E}),e[29]=A,e[30]=E,e[31]=j):j=e[31];let w;e[32]!==P||e[33]!==j?(w=n.jsxs(Rs,{children:[P,j]}),e[32]=P,e[33]=j,e[34]=w):w=e[34];let T;e[35]!==g||e[36]!==k||e[37]!==w?(T=n.jsx(Ft,{className:"sm:max-w-md",children:n.jsxs("form",{onSubmit:g,children:[x,k,w]})}),e[35]=g,e[36]=k,e[37]=w,e[38]=T):T=e[38];let D;return e[39]!==m||e[40]!==s||e[41]!==T?(D=n.jsx(Ht,{open:s,onOpenChange:m,children:T}),e[39]=m,e[40]=s,e[41]=T,e[42]=D):D=e[42],D}const eb=M.lazy(()=>vi(()=>import("./sections-editor-Bp1g_Th1.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135])).then(t=>({default:t.SectionsEditor}))),tb=M.lazy(()=>vi(()=>import("./add-section-modal-Y_M0BfWb.js"),__vite__mapDeps([82,1,2,6,7,8,9,10,11,12,13,14,15,16,3,4,5,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,45,46,83,84,85,86,42,43,44,87,88,89,54,90,91,92,93,94,53,95,55,96,97,98,99,100,62,101,52,102,67,68,103,66,63,77,104,105,106,76,107,108,61,109,79,74,80,81,56,57,110,47,111,48,49,50,51,58,59,60,64,65,69,70,71,72,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,75,128,129,130,131,132,133,134,135])).then(t=>({default:t.AddSectionModal}))),Kn="oklch(0.65 0.15 160)";function sb(){const t=U.c(18),e=Io(),{data:s}=Es.useSession(),{currentBranch:i}=Qt(),{org:r}=ke(),o=e?.entity?.id??null,a=s?.user?.id,l=e?.entity?.metadata,h=a&&i?hi(l?.sandboxMap?.[a]?.[i]):{},c=Object.values(h),u=(c.find(ib)??c[0])?.previewUrl??null,f=es(),p=e?.entity?.organization_id??"";let m;t[0]!==r.slug||t[1]!==p?(m={connectionId:hs,orgId:p,orgSlug:r.slug},t[0]=r.slug,t[1]=p,t[2]=m):m=t[2];const _=Qe(m),g=qn(_);let x;t[3]!==i||t[4]!==g||t[5]!==o?(x=()=>{if(!o)return;const S={virtualMcpId:o};i&&(S.branch=i),g.mutate(S)},t[3]=i,t[4]=g,t[5]=o,t[6]=x):x=t[6];const y=x,v=!!o&&!!i&&Hi.isStopped(o,i),b=Ic({previewUrl:u,appPaused:f.status.state==="paused",userStopped:v});if(b.kind!=="iframe"){let S;return t[7]!==b||t[8]!==y||t[9]!==f.lifecycle||t[10]!==f.phase?(S=n.jsx(lb,{state:b,claimPhase:f.phase,lifecycle:f.lifecycle,onStart:y}),t[7]=b,t[8]=y,t[9]=f.lifecycle,t[10]=f.phase,t[11]=S):S=t[11],S}if(!o||!i){let S;return t[12]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(Ji,{title:"Waiting for sandbox context…"}),t[12]=S):S=t[12],S}let C;return t[13]!==i||t[14]!==r.slug||t[15]!==u||t[16]!==o?(C=n.jsx(rb,{orgSlug:r.slug,virtualMcpId:o,branch:i,previewUrl:u}),t[13]=i,t[14]=r.slug,t[15]=u,t[16]=o,t[17]=C):C=t[17],C}function ib(t){return t.sandboxProviderKind!=="user-desktop"}function rb({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:i}){const r={orgSlug:t,virtualMcpId:e,branch:s},{data:o,isLoading:a}=po(r),{data:l,isLoading:h}=_o(r),c=Bc(r),d=Tx(r),[u,f]=M.useState("pages"),[p,m]=M.useState(null),[_,g]=M.useState(""),[x,y]=M.useState(u);x!==u&&(y(u),g(""));const[v,b]=M.useState(null),[C,S]=M.useState(),[k,N]=M.useState(!1),[P,A]=M.useState(null),[E,j]=M.useState(null);if(a||h)return n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})});if(!o||!l)return n.jsx(Ji,{title:"Could not load site data."});const w=xo(o).sort(($,L)=>$.name.localeCompare(L.name)),T=bo(o,l);if(w.length===0&&T.length===0)return n.jsx(Ji,{icon:bi,title:"No editable content",description:"This project doesn't expose any Deco pages or sections."});const D={pages:w.length,sections:T.length},R=new Set(w.map($=>oi($.path))),I=new Set(w.map($=>$.name)),B=new Set(T.map($=>$.name)),H=async $=>{const L=o[$.key];if(!L)return;const J=Mh(o,$.key),Z=zx(o,$.key,Math.max(0,J-1)),F=Hx(L.sections,Z);if(F)try{await c.mutateAsync({blockKey:$.key,data:{...L,sections:F}}),ae.success(`Variant added to "${$.name}"`),m({collection:"pages",key:$.key,path:$.path})}catch(ne){ae.error(ne instanceof Error?ne.message:"Could not add variant")}},W=()=>{S(void 0),b({mode:"create",sourceKey:null,initialName:"My new page",initialPath:"/example"})},z=$=>{S(void 0),b({mode:"duplicate",sourceKey:$.key,initialName:pl(I,$.name),initialPath:Ux(R,$.path)})},O=$=>{S(void 0),b({mode:"rename",sourceKey:$.key,initialName:$.name,initialPath:$.path})},V=async $=>{if(!v)return;const{mode:L,sourceKey:J}=v;try{if(L==="create"){const Z=Vx($.name,$.path),F=Gx(o,$.name);await c.mutateAsync({blockKey:F,data:Z}),ae.success(`Created "${$.name}"`),m({collection:"pages",key:F,path:$.path})}else if(L==="duplicate"&&J){const Z=o[J];if(!Z)throw new Error("Source page not found");const{key:F,data:ne}=Kx({source:Z,pages:w,newName:$.name,newPath:$.path});await c.mutateAsync({blockKey:F,data:ne}),ae.success(`Duplicated as "${$.name}"`),m({collection:"pages",key:F,path:$.path})}else if(L==="rename"&&J){const Z=o[J];if(!Z)throw new Error("Page not found");const F={...Z,name:$.name,path:$.path};await c.mutateAsync({blockKey:J,data:F}),ae.success("Page updated"),p?.collection==="pages"&&p.key===J&&m({collection:"pages",key:J,path:$.path})}b(null)}catch(Z){S(Z instanceof Error?Z.message:"Save failed")}},K=({path:$})=>{if(!v)return null;const L=oi($);return(v.mode==="rename"?oi(v.initialPath):null)!==L&&R.has(L)?`A page with path "${$}" already exists.`:null},Q=async $=>{const L=($.title||$.resolveType.split("/").pop()||"").replace(/\.(tsx?|jsx?)$/,"").replace(/[^A-Za-z0-9_-]/g,""),J=/^[A-Za-z]/.test(L)&&L.length>0?L:"Section",Z=_l(o,J),F={__resolveType:$.resolveType,name:Z};try{await c.mutateAsync({blockKey:Z,data:F}),ae.success(`Created section "${Z}"`),N(!1),m({collection:"sections",key:Z})}catch(ne){ae.error(ne instanceof Error?ne.message:"Could not create section")}},X=async $=>{const L=o[$.key];if(!L){ae.error("Section not found.");return}const J=_l(o,$.key),Z=pl(B,$.name),F={...L,name:Z};try{await c.mutateAsync({blockKey:J,data:F}),ae.success(`Duplicated "${$.name}"`),m({collection:"sections",key:J})}catch(ne){ae.error(ne instanceof Error?ne.message:"Duplicate failed")}},q=async $=>{if(!P)return;const L=o[P];if(!L){ae.error("Section not found.");return}try{await c.mutateAsync({blockKey:P,data:{...L,name:$}}),ae.success("Section renamed"),A(null)}catch(J){ae.error(J instanceof Error?J.message:"Rename failed")}},se=async()=>{if(!E)return;const{kind:$,key:L,label:J}=E;try{await d.mutateAsync({blockKey:L}),ae.success(`Deleted "${J}"`),$==="page"?p?.collection==="pages"&&p.key===L&&m(null):p?.collection==="sections"&&p.key===L&&m(null),j(null)}catch(Z){ae.error(Z instanceof Error?Z.message:"Delete failed")}};return n.jsxs("div",{className:"flex h-full w-full",children:[n.jsx(nb,{active:u,counts:D,onSelect:$=>{f($),m(null)}}),n.jsx(ob,{activeCollection:u,pages:w,sections:T,decofile:o,searchQuery:_,onSearchChange:g,selection:p,onSelect:m,previewUrl:i,onCreate:()=>{u==="pages"?W():i?N(!0):ae.error("Start the preview dev server to add sections.")},onDuplicatePage:z,onRenamePage:O,onAddPageVariant:H,onDeletePage:$=>j({kind:"page",key:$.key,label:$.name}),onDuplicateSection:X,onRenameSection:$=>A($.key),onDeleteSection:$=>j({kind:"section",key:$.key,label:$.name})}),n.jsx("div",{className:"flex-1 min-w-0",children:p?n.jsx(M.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(eb,{orgSlug:t,virtualMcpId:e,branch:s,previewReady:!0,previewUrl:i??void 0,currentPath:p.collection==="pages"?p.path:"/",activePageBlockKey:p.collection==="pages"?p.key:null,activeGlobalBlockKey:p.collection==="sections"?p.key:null},p.collection==="pages"?`page:${p.key}`:`section:${p.key}`)}):n.jsx(Ji,{title:u==="pages"?"Select a page to edit":"Select a section to edit",description:u==="pages"?'Pick a page from the list, or click "+ New" to create one.':'Pick a section from the list, or click "+ New" to create one.'})}),v&&n.jsx(Zx,{open:!!v,mode:v.mode,initialName:v.initialName,initialPath:v.initialPath,isPending:c.isPending,error:C,validate:K,onSubmit:V,onOpenChange:$=>{$||(b(null),S(void 0))}}),P&&n.jsx(Qx,{open:!!P,blockKey:P,initialName:T.find($=>$.key===P)?.name??P,isPending:c.isPending,onSubmit:q,onOpenChange:$=>{$||A(null)}}),k&&i&&n.jsx(M.Suspense,{fallback:null,children:n.jsx(tb,{open:k,onOpenChange:N,meta:l,decofile:o,previewBaseUrl:i,onSelect:Q})}),n.jsx(Qi,{open:!!E,onOpenChange:$=>{!$&&!d.isPending&&j(null)},children:n.jsxs(er,{children:[n.jsxs(tr,{children:[n.jsxs(sr,{children:["Delete ",E?.kind==="page"?"page":"section","?"]}),n.jsx(ir,{children:E?.kind==="page"?`"${E.label}" will be removed permanently. This can't be undone.`:E?.kind==="section"?`"${E.label}" will be removed. Pages that still reference it will lose this section.`:null})]}),n.jsxs(rr,{children:[n.jsx(nr,{disabled:d.isPending,children:"Cancel"}),n.jsx(or,{onClick:$=>{$.preventDefault(),se()},disabled:d.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:d.isPending?n.jsxs(n.Fragment,{children:[n.jsx(ge,{size:14,className:"animate-spin"}),"Deleting…"]}):"Delete"})]})]})})]})}function nb(t){const e=U.c(12),{active:s,counts:i,onSelect:r}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("div",{className:"px-3 h-12 flex items-center border-b shrink-0",children:n.jsx("span",{className:"text-sm font-medium",children:"Content"})}),e[0]=o):o=e[0];const a=s==="pages";let l;e[1]!==i.pages||e[2]!==r||e[3]!==a?(l=n.jsx(gl,{id:"pages",icon:eo,label:"Pages",count:i.pages,active:a,onSelect:r}),e[1]=i.pages,e[2]=r,e[3]=a,e[4]=l):l=e[4];const h=s==="sections";let c;e[5]!==i.sections||e[6]!==r||e[7]!==h?(c=n.jsx(gl,{id:"sections",icon:cr,label:"Sections",count:i.sections,active:h,onSelect:r}),e[5]=i.sections,e[6]=r,e[7]=h,e[8]=c):c=e[8];let d;return e[9]!==l||e[10]!==c?(d=n.jsxs("div",{className:"w-[208px] shrink-0 border-r flex flex-col",children:[o,n.jsxs("nav",{className:"flex flex-col p-1.5 gap-0.5",children:[l,c]})]}),e[9]=l,e[10]=c,e[11]=d):d=e[11],d}function gl(t){const e=U.c(20),{id:s,icon:i,label:r,count:o,active:a,onSelect:l}=t;let h;e[0]!==s||e[1]!==l?(h=()=>l(s),e[0]=s,e[1]=l,e[2]=h):h=e[2];const c=a?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground";let d;e[3]!==c?(d=re("flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors cursor-pointer",c),e[3]=c,e[4]=d):d=e[4];let u;e[5]!==i?(u=n.jsx(i,{size:16,className:"shrink-0"}),e[5]=i,e[6]=u):u=e[6];let f;e[7]!==r?(f=n.jsx("span",{className:"flex-1 truncate",children:r}),e[7]=r,e[8]=f):f=e[8];const p=a?"text-accent-foreground/70":"text-muted-foreground/70";let m;e[9]!==p?(m=re("shrink-0 text-xs tabular-nums",p),e[9]=p,e[10]=m):m=e[10];let _;e[11]!==o||e[12]!==m?(_=n.jsx("span",{className:m,children:o}),e[11]=o,e[12]=m,e[13]=_):_=e[13];let g;return e[14]!==h||e[15]!==d||e[16]!==u||e[17]!==f||e[18]!==_?(g=n.jsxs("button",{type:"button",onClick:h,className:d,children:[u,f,_]}),e[14]=h,e[15]=d,e[16]=u,e[17]=f,e[18]=_,e[19]=g):g=e[19],g}function ob(t){const e=U.c(54),{activeCollection:s,pages:i,sections:r,decofile:o,previewUrl:a,searchQuery:l,onSearchChange:h,selection:c,onSelect:d,onCreate:u,onDuplicatePage:f,onRenamePage:p,onAddPageVariant:m,onDeletePage:_,onDuplicateSection:g,onRenameSection:x,onDeleteSection:y}=t;let v,b,C,S,k,N;if(e[0]!==s||e[1]!==o||e[2]!==m||e[3]!==u||e[4]!==_||e[5]!==y||e[6]!==f||e[7]!==g||e[8]!==p||e[9]!==x||e[10]!==h||e[11]!==d||e[12]!==i||e[13]!==a||e[14]!==l||e[15]!==r||e[16]!==c){const j=l.toLowerCase(),w=i.filter(q=>!j||q.name.toLowerCase().includes(j)||q.path.toLowerCase().includes(j)),T=r.filter(q=>!j||q.name.toLowerCase().includes(j)||q.key.toLowerCase().includes(j)||q.resolveType.toLowerCase().includes(j)),D=s==="pages"?"Search pages…":"Search sections…",R=s==="pages"?"Create new page":"Create new section",I=s==="sections"&&!a,B=I?"Start the preview dev server to add sections":void 0;k="w-[300px] shrink-0 border-r flex flex-col min-h-0";let H;e[23]===Symbol.for("react.memo_cache_sentinel")?(H=n.jsx(Zl,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),e[23]=H):H=e[23];let W;e[24]!==h?(W=q=>h(q.target.value),e[24]=h,e[25]=W):W=e[25];let z;e[26]!==D||e[27]!==l||e[28]!==W?(z=n.jsxs("div",{className:"flex flex-1 items-center gap-2 pl-1",children:[H,n.jsx("input",{type:"text",value:l,onChange:W,placeholder:D,"aria-label":D,className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),e[26]=D,e[27]=l,e[28]=W,e[29]=z):z=e[29];let O;e[30]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(zt,{size:14}),e[30]=O):O=e[30];let V;e[31]!==R||e[32]!==u||e[33]!==I?(V=n.jsx(Se,{asChild:!0,children:n.jsx(te,{variant:"ghost",size:"icon",onClick:u,disabled:I,"aria-label":R,"aria-disabled":I,children:O})}),e[31]=R,e[32]=u,e[33]=I,e[34]=V):V=e[34];const K=B??R;let Q;e[35]!==K?(Q=n.jsx(we,{side:"bottom",children:K}),e[35]=K,e[36]=Q):Q=e[36];let X;e[37]!==V||e[38]!==Q?(X=n.jsxs(Ce,{children:[V,Q]}),e[37]=V,e[38]=Q,e[39]=X):X=e[39],e[40]!==X||e[41]!==z?(N=n.jsxs("div",{className:"px-2 h-12 flex items-center gap-1 border-b shrink-0",children:[z,X]}),e[40]=X,e[41]=z,e[42]=N):N=e[42],v=ro,S="flex-1 min-h-0",b="flex flex-col gap-1 p-1.5",C=s==="pages"?w.length===0?n.jsx(bl,{hasItems:i.length>0,emptyLabel:"No pages yet.",emptyHint:'Click "+" to create your first page.'}):w.map(q=>{const se=c?.collection==="pages"&&c.key===q.key,$=Mh(o,q.key);return n.jsx(vl,{icon:eo,title:q.name,subtitle:q.path,active:se,variantCount:$,onClick:()=>d({collection:"pages",key:q.key,path:q.path}),menu:n.jsx(xl,{onDuplicate:()=>f(q),onRename:()=>p(q),onAddVariant:()=>m(q),onDelete:()=>_(q)})},q.key)}):T.length===0?n.jsx(bl,{hasItems:r.length>0,emptyLabel:"No saved sections yet.",emptyHint:'Click "+" to create one, or save a section from a page.'}):T.map(q=>{const se=c?.collection==="sections"&&c.key===q.key,$=q.resolveType.split("/").pop()?.replace(/\.tsx?$/,"");return n.jsx(vl,{icon:cr,title:q.name,subtitle:$??q.resolveType,active:se,onClick:()=>d({collection:"sections",key:q.key}),menu:n.jsx(xl,{onDuplicate:()=>g(q),onRename:()=>x(q),onDelete:()=>y(q)})},q.key)}),e[0]=s,e[1]=o,e[2]=m,e[3]=u,e[4]=_,e[5]=y,e[6]=f,e[7]=g,e[8]=p,e[9]=x,e[10]=h,e[11]=d,e[12]=i,e[13]=a,e[14]=l,e[15]=r,e[16]=c,e[17]=v,e[18]=b,e[19]=C,e[20]=S,e[21]=k,e[22]=N}else v=e[17],b=e[18],C=e[19],S=e[20],k=e[21],N=e[22];let P;e[43]!==b||e[44]!==C?(P=n.jsx("div",{className:b,children:C}),e[43]=b,e[44]=C,e[45]=P):P=e[45];let A;e[46]!==v||e[47]!==S||e[48]!==P?(A=n.jsx(v,{className:S,children:P}),e[46]=v,e[47]=S,e[48]=P,e[49]=A):A=e[49];let E;return e[50]!==k||e[51]!==N||e[52]!==A?(E=n.jsxs("div",{className:k,children:[N,A]}),e[50]=k,e[51]=N,e[52]=A,e[53]=E):E=e[53],E}function vl(t){const e=U.c(27),{icon:s,title:i,subtitle:r,active:o,variantCount:a,onClick:l,menu:h}=t,c=o?"bg-accent text-accent-foreground":"hover:bg-muted";let d;e[0]!==c?(d=re("group relative flex items-center rounded-md transition-colors",c),e[0]=c,e[1]=d):d=e[1];let u;e[2]!==s||e[3]!==o||e[4]!==a?(u=a&&a>1?n.jsxs(Ce,{children:[n.jsx(Se,{asChild:!0,children:n.jsx(s,{size:16,className:"shrink-0",style:{color:Kn}})}),n.jsxs(we,{side:"right",children:[a," variants"]})]}):n.jsx(s,{size:16,className:re("shrink-0",o?"text-accent-foreground":"text-muted-foreground")}),e[2]=s,e[3]=o,e[4]=a,e[5]=u):u=e[5];let f;e[6]!==i?(f=n.jsx("span",{className:"block truncate text-sm font-medium",children:i}),e[6]=i,e[7]=f):f=e[7];const p=o?"text-accent-foreground/70":"text-muted-foreground";let m;e[8]!==p?(m=re("block truncate text-xs",p),e[8]=p,e[9]=m):m=e[9];let _;e[10]!==r||e[11]!==m?(_=n.jsx("span",{className:m,children:r}),e[10]=r,e[11]=m,e[12]=_):_=e[12];let g;e[13]!==f||e[14]!==_?(g=n.jsxs("span",{className:"min-w-0 flex-1",children:[f,_]}),e[13]=f,e[14]=_,e[15]=g):g=e[15];let x;e[16]!==l||e[17]!==u||e[18]!==g?(x=n.jsxs("button",{type:"button",onClick:l,className:"flex min-w-0 flex-1 items-center gap-2.5 rounded-md px-2.5 py-2 text-left cursor-pointer",children:[u,g]}),e[16]=l,e[17]=u,e[18]=g,e[19]=x):x=e[19];let y;e[20]!==o||e[21]!==h?(y=h&&n.jsx("div",{className:re("pr-1 opacity-0 transition-opacity group-hover:opacity-100",o&&"opacity-100"),children:h}),e[20]=o,e[21]=h,e[22]=y):y=e[22];let v;return e[23]!==y||e[24]!==d||e[25]!==x?(v=n.jsxs("div",{className:d,children:[x,y]}),e[23]=y,e[24]=d,e[25]=x,e[26]=v):v=e[26],v}function xl(t){const e=U.c(18),{onDuplicate:s,onRename:i,onAddVariant:r,onDelete:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(As,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":"More actions",className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-background hover:text-foreground cursor-pointer",onClick:ab,children:n.jsx(Cr,{size:14})})}),e[0]=a):a=e[0];let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(ql,{size:14}),e[1]=l):l=e[1];let h;e[2]!==i?(h=n.jsxs(ht,{onClick:i,children:[l,"Rename"]}),e[2]=i,e[3]=h):h=e[3];let c;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Xt,{size:14}),e[4]=c):c=e[4];let d;e[5]!==s?(d=n.jsxs(ht,{onClick:s,children:[c,"Duplicate"]}),e[5]=s,e[6]=d):d=e[6];let u;e[7]!==r?(u=r&&n.jsxs(n.Fragment,{children:[n.jsx(ta,{}),n.jsxs(ht,{onClick:r,className:"cursor-pointer",style:{color:Kn},children:[n.jsx(ou,{size:14,style:{color:Kn}}),"Add variant"]})]}),e[7]=r,e[8]=u):u=e[8];let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(ta,{}),e[9]=f):f=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(di,{size:14}),e[10]=p):p=e[10];let m;e[11]!==o?(m=n.jsxs(ht,{onClick:o,className:"text-destructive focus:text-destructive",children:[p,"Delete"]}),e[11]=o,e[12]=m):m=e[12];let _;return e[13]!==h||e[14]!==d||e[15]!==u||e[16]!==m?(_=n.jsxs(Ds,{children:[a,n.jsxs(Ms,{align:"end",className:"w-44",children:[h,d,u,f,m]})]}),e[13]=h,e[14]=d,e[15]=u,e[16]=m,e[17]=_):_=e[17],_}function ab(t){return t.stopPropagation()}function bl(t){const e=U.c(6),{hasItems:s,emptyLabel:i,emptyHint:r}=t;let o;e[0]!==r||e[1]!==i||e[2]!==s?(o=s?"No results match your search.":n.jsxs(n.Fragment,{children:[n.jsx("div",{children:i}),n.jsx("div",{className:"mt-1 text-muted-foreground/80",children:r})]}),e[0]=r,e[1]=i,e[2]=s,e[3]=o):o=e[3];let a;return e[4]!==o?(a=n.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o}),e[4]=o,e[5]=a):a=e[5],a}function lb(t){const e=U.c(8),{state:s,claimPhase:i,lifecycle:r,onStart:o}=t;switch(s.kind){case"starting":{let a;e[0]!==i||e[1]!==r?(a=Oc({claimPhase:i,lifecycle:r}),e[0]=i,e[1]=r,e[2]=a):a=e[2];let l;return e[3]!==i||e[4]!==a?(l=n.jsx(hr,{kind:"starting",progress:a,claimPhase:i}),e[3]=i,e[4]=a,e[5]=l):l=e[5],l}case"suspended":{let a;return e[6]!==o?(a=n.jsx(hr,{kind:"suspended",onResume:o}),e[6]=o,e[7]=a):a=e[7],a}}}function Ji(t){const e=U.c(10),{icon:s,title:i,description:r}=t;let o;e[0]!==s?(o=s&&n.jsx(s,{size:24,className:"text-muted-foreground/60"}),e[0]=s,e[1]=o):o=e[1];let a;e[2]!==i?(a=n.jsx("div",{children:i}),e[2]=i,e[3]=a):a=e[3];let l;e[4]!==r?(l=r&&n.jsx("div",{className:"text-xs text-muted-foreground/80 max-w-sm",children:r}),e[4]=r,e[5]=l):l=e[5];let h;return e[6]!==o||e[7]!==a||e[8]!==l?(h=n.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 p-6 text-center text-sm text-muted-foreground",children:[o,a,l]}),e[6]=o,e[7]=a,e[8]=l,e[9]=h):h=e[9],h}function cb(t){const e=U.c(2),{virtualMcpId:s}=t,i=bt(s);if(!xi(i?.metadata)){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground p-6",children:[n.jsx(bi,{size:24,className:"text-muted-foreground/60"}),n.jsx("div",{children:"No content to edit."}),n.jsx("div",{className:"text-xs text-muted-foreground/80",children:"Connect a GitHub repository from the Settings tab to enable Content."})]}),e[0]=a):a=e[0],a}let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(sb,{}),e[1]=o):o=e[1],o}function hb(t){const e=U.c(3),{tier:s,onSelect:i}=t;let r;return e[0]!==i||e[1]!==s?(r=n.jsx(_d,{tier:s,subtitleFor:db,iconFor:gd,onSelect:i}),e[0]=i,e[1]=s,e[2]=r):r=e[2],r}function db(t){return vd("cloud-decopilot",t)}function li(t){const e=t.trim().split(/\s+/);return e.length!==5?!1:e.every(s=>/^[\d*/,-]+$/.test(s))}function ub(t){if(!t)return"Unknown schedule";const e=t.trim();if(e==="* * * * *")return"Every minute";if(e==="0 * * * *")return"Every hour";if(e==="0 0 * * *")return"Every day";if(e==="0 0 * * 1")return"Every week";const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return`Every ${s[1]} minutes`;const i=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(i)return`Every ${i[1]} hours`;const r=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);if(r){const l=parseInt(r[1]??"1");return l%7===0?`Every ${l/7} weeks`:`Every ${l} days`}const o=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+\*$/);if(o){const l=(o[2]??"0").padStart(2,"0"),h=(o[1]??"0").padStart(2,"0");return`Every day at ${l}:${h} UTC`}const a=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+(\d)$/);if(a){const h=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][parseInt(a[3]??"0")]??"day",c=(a[2]??"0").padStart(2,"0"),d=(a[1]??"0").padStart(2,"0");return`Every ${h} at ${c}:${d} UTC`}return t}function fb(t,e){const s=Math.max(1,t);switch(e){case"minutes":return s===1?"* * * * *":`*/${s} * * * *`;case"hours":return s===1?"0 * * * *":`0 */${s} * * *`;case"days":return s===1?"0 0 * * *":`0 0 */${s} * *`;case"weeks":return s===1?"0 0 * * 1":`0 0 */${s*7} * *`}}function mb(t){const e=t.trim();if(e==="* * * * *")return{count:1,unit:"minutes"};if(e==="0 * * * *")return{count:1,unit:"hours"};if(e==="0 0 * * *")return{count:1,unit:"days"};if(e==="0 0 * * 1")return{count:1,unit:"weeks"};const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return{count:parseInt(s[1]),unit:"minutes"};const i=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(i)return{count:parseInt(i[1]),unit:"hours"};const r=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);if(r){const o=parseInt(r[1]);return o%7===0?{count:o/7,unit:"weeks"}:{count:o,unit:"days"}}return null}function pb(t,e){return e===1?{minutes:"minute",hours:"hour",days:"day",weeks:"week"}[t]??t:t}const _b=[{label:"5 minutes",cron:"*/5 * * * *"},{label:"Hour",cron:"0 * * * *"},{label:"Day",cron:"0 0 * * *"},{label:"Week",cron:"0 0 * * 1"}];function gb({automationId:t,open:e,onOpenChange:s,onCustomSelect:i,onEventSelect:r,onWebhookCreated:o}){const{triggerAdd:a}=ki(),[l,h]=M.useState(!1),c=e??l,d=p=>{s?s(p):h(p)},u=async p=>{try{await a.mutateAsync({automation_id:t,type:"cron",cron_expression:p}),ae.success("Starter added"),d(!1)}catch(m){const _=m instanceof Error?m.message:"Failed to add starter";ae.error(_)}},f=async()=>{try{const p=await a.mutateAsync({automation_id:t,type:"webhook"});d(!1),p.webhook?o?.(p.webhook):ae.success("Webhook starter added")}catch(p){const m=p instanceof Error?p.message:"Failed to add webhook starter";ae.error(m)}};return n.jsxs(Ds,{open:c,onOpenChange:d,children:[n.jsx(As,{asChild:!0,children:n.jsxs(te,{variant:"outline",size:"sm",children:[n.jsx(zt,{size:14}),"Add Starter"]})}),n.jsxs(Ms,{align:"end",className:"w-[200px]",children:[n.jsxs(Zu,{children:[n.jsxs(Qu,{className:"gap-2.5",children:[n.jsx(ri,{size:14,className:"text-muted-foreground shrink-0"}),"Every..."]}),n.jsx(ef,{className:"w-[160px]",children:_b.map(p=>n.jsxs(ht,{className:"gap-2.5",onSelect:()=>u(p.cron),disabled:a.isPending,children:[n.jsx(ri,{size:14,className:"text-muted-foreground shrink-0"}),"Every ",p.label]},p.cron))})]}),n.jsxs(ht,{className:"gap-2.5",onSelect:()=>{d(!1),i?.()},children:[n.jsx(ri,{size:14,className:"text-muted-foreground shrink-0"}),"Custom (cron)"]}),n.jsxs(ht,{className:"gap-2.5",onSelect:()=>{d(!1),r?.()},children:[n.jsx(ui,{size:14,className:"text-muted-foreground shrink-0"}),"Event"]}),n.jsxs(ht,{className:"gap-2.5",onSelect:()=>{f()},disabled:a.isPending,children:[n.jsx(Yn,{size:14,className:"text-muted-foreground shrink-0"}),"Webhook"]})]})]})}function Bh(t){const e=U.c(31),{open:s,onOpenChange:i,url:r,token:o,title:a,description:l}=t,h=a===void 0?"Webhook ready":a,c=l===void 0?"Send a POST to this URL with the bearer token to fire the automation. The token is shown once — copy it now.":l,[d,u]=M.useState(null),[f,p]=M.useState("curl"),[m,_]=M.useState("header"),g=M.useId();let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=async(D,R)=>{try{await navigator.clipboard.writeText(D),u(R),ae.success("Copied"),setTimeout(()=>u(null),1500)}catch{ae.error("Failed to copy")}},e[0]=x):x=e[0];const y=x;let v;e[1]!==m||e[2]!==o||e[3]!==r?(v=r&&o&&m==="url"?`${r.replace(/\/$/,"")}/${o}`:r??"",e[1]=m,e[2]=o,e[3]=r,e[4]=v):v=e[4];const b=v,C=r&&o?m==="header"?`curl -X POST "${b}" \\
|
|
289
289
|
-H "Authorization: Bearer ${o}" \\
|
|
290
290
|
-H "Content-Type: application/json" \\
|
|
291
291
|
-d '{"hello":"world"}'`:`curl -X POST "${b}" \\
|
|
@@ -304,6 +304,6 @@ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){t
|
|
|
304
304
|
},
|
|
305
305
|
body: JSON.stringify({ hello: "world" }),
|
|
306
306
|
});`:"",k=f==="curl"?C:S;let N;e[5]!==h?(N=n.jsx(ms,{children:h}),e[5]=h,e[6]=N):N=e[6];let P;e[7]!==c?(P=n.jsx(so,{children:c}),e[7]=c,e[8]=P):P=e[8];let A;e[9]!==N||e[10]!==P?(A=n.jsxs(fs,{children:[N,P]}),e[9]=N,e[10]=P,e[11]=A):A=e[11];let E;e[12]!==m||e[13]!==d||e[14]!==b||e[15]!==f||e[16]!==k||e[17]!==o||e[18]!==g||e[19]!==r?(E=r&&o?n.jsxs("div",{className:"flex flex-col gap-3 min-w-0",children:[n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:"URL"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("code",{className:"flex-1 min-w-0 text-xs font-mono bg-muted rounded-md px-2 py-1.5 truncate",children:b}),n.jsxs(te,{size:"sm",variant:"outline",onClick:()=>y(b,"url"),children:[n.jsx(Xt,{size:13}),d==="url"?"Copied":"Copy"]})]})]}),n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:"Token (shown once)"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("code",{className:"flex-1 min-w-0 text-xs font-mono bg-muted rounded-md px-2 py-1.5 truncate",children:o}),n.jsxs(te,{size:"sm",variant:"outline",onClick:()=>y(o,"token"),children:[n.jsx(Xt,{size:13}),d==="token"?"Copied":"Copy"]})]})]}),n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:"Snippet"}),n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(oo,{value:f,onValueChange:D=>p(D),children:n.jsxs(no,{className:"h-8 p-[2px]",children:[n.jsx(ns,{value:"curl",className:"h-7 px-2.5 text-xs",children:"curl"}),n.jsx(ns,{value:"fetch",className:"h-7 px-2.5 text-xs",children:"fetch"})]})}),n.jsxs("label",{htmlFor:g,className:"flex items-center gap-1.5 text-xs text-muted-foreground cursor-pointer select-none",children:[n.jsx(Yl,{id:g,checked:m==="url",onCheckedChange:D=>_(D?"url":"header")}),"Token in URL"]})]}),n.jsxs(te,{size:"sm",variant:"outline",onClick:()=>y(k,"example"),children:[n.jsx(Xt,{size:13}),d==="example"?"Copied":"Copy"]})]}),n.jsx("div",{className:"rounded-md border overflow-hidden min-w-0",children:n.jsx(Ju,{code:k,language:f==="curl"?"shell":"typescript",readOnly:!0,disableDiagnostics:!0,height:180})})]})]}):null,e[12]=m,e[13]=d,e[14]=b,e[15]=f,e[16]=k,e[17]=o,e[18]=g,e[19]=r,e[20]=E):E=e[20];let j;e[21]!==i?(j=n.jsx(Rs,{children:n.jsx(te,{onClick:()=>i(!1),children:"Done"})}),e[21]=i,e[22]=j):j=e[22];let w;e[23]!==A||e[24]!==E||e[25]!==j?(w=n.jsxs(Ft,{className:"max-w-lg",children:[A,E,j]}),e[23]=A,e[24]=E,e[25]=j,e[26]=w):w=e[26];let T;return e[27]!==i||e[28]!==s||e[29]!==w?(T=n.jsx(Ht,{open:s,onOpenChange:i,children:w}),e[27]=i,e[28]=s,e[29]=w,e[30]=T):T=e[30],T}function vb(t){const e=U.c(83),{trigger:s,automationId:i,connectionName:r}=t,{triggerAdd:o,triggerRemove:a,triggerRotateToken:l}=ki(),[h,c]=M.useState(!1),[d,u]=M.useState(!1),[f,p]=M.useState(null);let m;e[0]!==s.cron_expression?(m=s.cron_expression?mb(s.cron_expression):null,e[0]=s.cron_expression,e[1]=m):m=e[1];const _=m,[g,x]=M.useState(_?.count??1),[y,v]=M.useState(!1),[b,C]=M.useState(s.cron_expression??""),S=a.isPending||o.isPending||l.isPending,k=s.type==="cron",N=s.type==="webhook";let P;e[2]!==i||e[3]!==a||e[4]!==s.id?(P=async()=>{try{await a.mutateAsync({trigger_id:s.id,automation_id:i}),ae.success("Starter removed")}catch{ae.error("Failed to remove starter")}c(!1)},e[2]=i,e[3]=a,e[4]=s.id,e[5]=P):P=e[5];const A=P;let E;e[6]!==o||e[7]!==i||e[8]!==b||e[9]!==a||e[10]!==s.cron_expression||e[11]!==s.id?(E=async()=>{const le=b.trim();if(!le||!li(le)||le===s.cron_expression){v(!1),C(s.cron_expression??"");return}try{await o.mutateAsync({automation_id:i,type:"cron",cron_expression:le}),await a.mutateAsync({trigger_id:s.id,automation_id:i}),v(!1)}catch{ae.error("Failed to update starter"),C(s.cron_expression??""),v(!1)}},e[6]=o,e[7]=i,e[8]=b,e[9]=a,e[10]=s.cron_expression,e[11]=s.id,e[12]=E):E=e[12];const j=E;let w;e[13]!==i||e[14]!==l||e[15]!==s.id?(w=async()=>{u(!1);try{const le=await l.mutateAsync({trigger_id:s.id,automation_id:i});p({url:le.url,token:le.token})}catch(le){const je=le,Ne=je instanceof Error?je.message:"Failed to rotate token";ae.error(Ne)}},e[13]=i,e[14]=l,e[15]=s.id,e[16]=w):w=e[16];const T=w;let D;e[17]!==o||e[18]!==i||e[19]!==_||e[20]!==a||e[21]!==s.cron_expression||e[22]!==s.id?(D=async le=>{if(!_)return;const je=_.unit==="minutes"?5:1,Ne=Math.max(je,le);Ne!==le&&x(Ne);const Xe=fb(Ne,_.unit);if(Xe!==s.cron_expression)try{await o.mutateAsync({automation_id:i,type:"cron",cron_expression:Xe}),await a.mutateAsync({trigger_id:s.id,automation_id:i})}catch{ae.error("Failed to update starter"),x(_.count)}},e[17]=o,e[18]=i,e[19]=_,e[20]=a,e[21]=s.cron_expression,e[22]=s.id,e[23]=D):D=e[23];const R=D;let I;e[24]!==k||e[25]!==N?(I=k?n.jsx(ri,{size:14,className:"text-muted-foreground shrink-0"}):N?n.jsx(Yn,{size:14,className:"text-muted-foreground shrink-0"}):n.jsx(ui,{size:14,className:"text-muted-foreground shrink-0"}),e[24]=k,e[25]=N,e[26]=I):I=e[26];let B;e[27]!==r||e[28]!==g||e[29]!==b||e[30]!==R||e[31]!==j||e[32]!==_||e[33]!==k||e[34]!==y||e[35]!==S||e[36]!==N||e[37]!==s.cron_expression||e[38]!==s.event_type||e[39]!==s.params?(B=_&&k?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-sm text-muted-foreground",children:"Every"}),n.jsx("input",{type:"number",min:_.unit==="minutes"?5:1,value:g,onChange:le=>x(parseInt(le.target.value)||1),onBlur:()=>R(g),onKeyDown:le=>{le.key==="Enter"&&le.target.blur(),le.key==="Escape"&&x(_.count)},disabled:S,className:"w-12 text-center text-sm h-7 border border-border rounded-md bg-background px-1 focus:outline-none focus:ring-1 focus:ring-ring"}),n.jsx("span",{className:"text-sm",children:pb(_.unit,g)})]}):k&&y?n.jsxs(n.Fragment,{children:[n.jsx("input",{type:"text",value:b,onChange:le=>C(le.target.value),onBlur:j,onKeyDown:le=>{le.key==="Enter"&&le.target.blur(),le.key==="Escape"&&(v(!1),C(s.cron_expression??""))},className:"flex-1 text-sm font-mono bg-transparent outline-none",autoFocus:!0}),b&&!li(b)&&n.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"})]}):n.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[n.jsx("span",{className:"text-sm font-mono text-xs text-muted-foreground truncate",children:k?ub(s.cron_expression??""):N?"Webhook · POST to fire":`${s.event_type}${r?` · ${r}`:""}`}),!k&&!N&&s.params&&Object.keys(s.params).length>0&&n.jsx("span",{className:"text-xs text-muted-foreground/60 truncate",children:Object.entries(s.params).map(xb).join(", ")})]}),e[27]=r,e[28]=g,e[29]=b,e[30]=R,e[31]=j,e[32]=_,e[33]=k,e[34]=y,e[35]=S,e[36]=N,e[37]=s.cron_expression,e[38]=s.event_type,e[39]=s.params,e[40]=B):B=e[40];let H;e[41]!==S?(H=S&&n.jsx(ge,{size:13,className:"animate-spin text-muted-foreground"}),e[41]=S,e[42]=H):H=e[42];let W;e[43]!==_||e[44]!==k||e[45]!==y||e[46]!==s.cron_expression?(W=k&&!_&&!y&&n.jsx(te,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{C(s.cron_expression??""),v(!0)},children:n.jsx(ql,{size:13,className:"text-muted-foreground"})}),e[43]=_,e[44]=k,e[45]=y,e[46]=s.cron_expression,e[47]=W):W=e[47];let z;e[48]!==N?(z=N&&n.jsx(te,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",title:"Rotate token",onClick:()=>u(!0),children:n.jsx(ci,{size:13,className:"text-muted-foreground"})}),e[48]=N,e[49]=z):z=e[49];let O;e[50]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(te,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>c(!0),children:n.jsx(ks,{size:13,className:"text-muted-foreground"})}),e[50]=O):O=e[50];let V;e[51]!==z||e[52]!==H||e[53]!==W?(V=n.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[H,W,z,O]}),e[51]=z,e[52]=H,e[53]=W,e[54]=V):V=e[54];let K;e[55]!==V||e[56]!==I||e[57]!==B?(K=n.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[I,B,V]}),e[55]=V,e[56]=I,e[57]=B,e[58]=K):K=e[58];let Q;e[59]===Symbol.for("react.memo_cache_sentinel")?(Q=n.jsxs(tr,{children:[n.jsx(sr,{children:"Remove Starter"}),n.jsx(ir,{children:"Are you sure you want to remove this starter?"})]}),e[59]=Q):Q=e[59];let X;e[60]===Symbol.for("react.memo_cache_sentinel")?(X=n.jsx(nr,{children:"Cancel"}),e[60]=X):X=e[60];let q;e[61]!==A?(q=n.jsxs(er,{children:[Q,n.jsxs(rr,{children:[X,n.jsx(or,{onClick:A,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]}),e[61]=A,e[62]=q):q=e[62];let se;e[63]!==h||e[64]!==q?(se=n.jsx(Qi,{open:h,onOpenChange:c,children:q}),e[63]=h,e[64]=q,e[65]=se):se=e[65];let $;e[66]===Symbol.for("react.memo_cache_sentinel")?($=n.jsxs(tr,{children:[n.jsx(sr,{children:"Rotate webhook token"}),n.jsx(ir,{children:"A new token will be generated and the current token will stop working. Any senders using the old token must be updated."})]}),e[66]=$):$=e[66];let L;e[67]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx(nr,{children:"Cancel"}),e[67]=L):L=e[67];let J;e[68]!==T?(J=n.jsxs(er,{children:[$,n.jsxs(rr,{children:[L,n.jsx(or,{onClick:T,children:"Rotate"})]})]}),e[68]=T,e[69]=J):J=e[69];let Z;e[70]!==d||e[71]!==J?(Z=n.jsx(Qi,{open:d,onOpenChange:u,children:J}),e[70]=d,e[71]=J,e[72]=Z):Z=e[72];const F=f!==null;let ne;e[73]===Symbol.for("react.memo_cache_sentinel")?(ne=le=>{le||p(null)},e[73]=ne):ne=e[73];const ie=f?.url??null,de=f?.token??null;let ue;e[74]!==F||e[75]!==ie||e[76]!==de?(ue=n.jsx(Bh,{open:F,onOpenChange:ne,url:ie,token:de,title:"New webhook token",description:"The previous token has been revoked. Copy the new token now — it will not be shown again."}),e[74]=F,e[75]=ie,e[76]=de,e[77]=ue):ue=e[77];let _e;return e[78]!==K||e[79]!==se||e[80]!==Z||e[81]!==ue?(_e=n.jsxs(n.Fragment,{children:[K,se,Z,ue]}),e[78]=K,e[79]=se,e[80]=Z,e[81]=ue,e[82]=_e):_e=e[82],_e}function xb(t){const[e,s]=t;return`${e}: ${s}`}function bb(t,e){switch(e.type){case"accumulate":{const s=t??{start:e.now,fields:new Set,saveCount:0},i=new Set(s.fields);for(const r of e.fields)i.add(r);return{...s,fields:i,saveCount:s.saveCount+1}}case"reset":return null}}function yb(t){const e=U.c(55),{automationId:s,onDone:i}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={binding:"TRIGGER"},e[0]=r):r=e[0];const o=kr(r),[a,l]=M.useState(),[h,c]=M.useState();let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d={},e[1]=d):d=e[1];const[u,f]=M.useState(d),{triggerAdd:p}=ki(),{data:m,isLoading:_}=nf(a);let g,x,y,v,b,C;if(e[2]!==p||e[3]!==s||e[4]!==a||e[5]!==h||e[6]!==_||e[7]!==i||e[8]!==u||e[9]!==o||e[10]!==m){const N=m?.find(B=>B.type===h);let P;e[17]!==p||e[18]!==s||e[19]!==a||e[20]!==h||e[21]!==i||e[22]!==u?(P=async()=>{if(!(!a||!h))try{await p.mutateAsync({automation_id:s,type:"event",event_type:h,connection_id:a,params:u}),Pe("automation_trigger_added",{automation_id:s,trigger_type:"event",connection_id:a,event_type:h}),ae.success("Event trigger added"),i()}catch{ae.error("Failed to add event trigger")}},e[17]=p,e[18]=s,e[19]=a,e[20]=h,e[21]=i,e[22]=u,e[23]=P):P=e[23],g=P,x="flex flex-col gap-3 px-3 py-3 rounded-lg border border-border bg-background";let A,E;e[24]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx(ui,{size:14,className:"text-muted-foreground shrink-0"}),A=n.jsx("span",{className:"text-sm font-medium",children:"Event trigger"}),e[24]=A,e[25]=E):(A=e[24],E=e[25]);let j;e[26]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx(ks,{size:13}),e[26]=j):j=e[26],e[27]!==i?(y=n.jsxs("div",{className:"flex items-center gap-2",children:[E,A,n.jsx("button",{type:"button",className:"ml-auto shrink-0 p-0.5 rounded text-muted-foreground hover:text-foreground",onClick:i,children:j})]}),e[27]=i,e[28]=y):y=e[28];const w=a??"";let T;e[29]===Symbol.for("react.memo_cache_sentinel")?(T=B=>{l(B),c(void 0),f({})},e[29]=T):T=e[29];let D;e[30]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsx(It,{className:"w-full",children:n.jsx(Lt,{placeholder:"Select connection..."})}),e[30]=D):D=e[30];let R;e[31]!==o?(R=o.length===0?n.jsx("div",{className:"px-2 py-3 text-center text-xs text-muted-foreground",children:"No connections with trigger support"}):o.map(Cb),e[31]=o,e[32]=R):R=e[32];let I;e[33]!==R?(I=n.jsx(Ot,{children:R}),e[33]=R,e[34]=I):I=e[34],e[35]!==w||e[36]!==I?(v=n.jsxs(Bt,{value:w,onValueChange:T,children:[D,I]}),e[35]=w,e[36]=I,e[37]=v):v=e[37],e[38]!==a||e[39]!==h||e[40]!==_||e[41]!==m?(b=a&&n.jsxs(Bt,{value:h??"",onValueChange:B=>{c(B),f({})},children:[n.jsx(It,{className:"w-full",children:_?n.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[n.jsx(ge,{size:13,className:"animate-spin"}),"Loading events..."]}):n.jsx(Lt,{placeholder:"Select event type...",children:h??"Select event type..."})}),n.jsx(Ot,{children:m?.map(wb)})]}),e[38]=a,e[39]=h,e[40]=_,e[41]=m,e[42]=b):b=e[42],C=N?.paramsSchema&&Object.keys(N.paramsSchema).length>0&&n.jsx("div",{className:"flex flex-col gap-2",children:Object.entries(N.paramsSchema).map(B=>{const[H,W]=B;return n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsxs("label",{className:"text-xs text-muted-foreground",children:[H,W.description&&n.jsxs("span",{className:"text-muted-foreground/60",children:[" ","— ",W.description]})]}),W.enum?n.jsxs(Bt,{value:u[H]??"",onValueChange:z=>f(O=>({...O,[H]:z})),children:[n.jsx(It,{className:"w-full",children:n.jsx(Lt,{placeholder:`Select ${H}...`})}),n.jsx(Ot,{children:W.enum.map(Sb)})]}):n.jsx("input",{type:"text",value:u[H]??"",onChange:z=>f(O=>({...O,[H]:z.target.value})),placeholder:W.description??H,className:"text-sm border border-border rounded-md bg-background px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-ring"})]},H)})}),e[2]=p,e[3]=s,e[4]=a,e[5]=h,e[6]=_,e[7]=i,e[8]=u,e[9]=o,e[10]=m,e[11]=g,e[12]=x,e[13]=y,e[14]=v,e[15]=b,e[16]=C}else g=e[11],x=e[12],y=e[13],v=e[14],b=e[15],C=e[16];let S;e[43]!==p||e[44]!==a||e[45]!==h||e[46]!==g?(S=a&&h&&n.jsx(te,{size:"sm",onClick:g,disabled:p.isPending,children:p.isPending?n.jsx(ge,{size:13,className:"animate-spin"}):"Add trigger"}),e[43]=p,e[44]=a,e[45]=h,e[46]=g,e[47]=S):S=e[47];let k;return e[48]!==x||e[49]!==y||e[50]!==v||e[51]!==b||e[52]!==C||e[53]!==S?(k=n.jsxs("div",{className:x,children:[y,v,b,C,S]}),e[48]=x,e[49]=y,e[50]=v,e[51]=b,e[52]=C,e[53]=S,e[54]=k):k=e[54],k}function Sb(t){return n.jsx(dt,{value:t,children:t},t)}function wb(t){return n.jsx(dt,{value:t.type,children:n.jsxs("div",{className:"flex flex-col",children:[n.jsx("span",{children:t.type}),n.jsx("span",{className:"text-xs text-muted-foreground",children:t.description})]})},t.type)}function Cb(t){return n.jsx(dt,{value:t.id,children:t.title},t.id)}function kb({automationId:t,automation:e,onBack:s,onDelete:i}){const r=e.virtual_mcp_id,{org:o}=ke(),{update:a,triggerAdd:l}=ki(),h=kr(),c=new Map(h.map(F=>[F.id,F.title])),{createTaskWithMessage:d}=Qt(),{setSimpleModeTier:u}=br(),{setChatOpen:f}=Jn(),{sendMessage:p}=ds(),[m,_]=ud(),g=e.messages?.[0]?.metadata?.tiptapDoc??void 0,[x,y]=M.useState(g),[v,b]=M.useState(!1),[C,S]=M.useState(!1),[k,N]=M.useState(""),[P,A]=M.useState(!1),[E,j]=M.useState(null),[w,T]=M.useState(!1),[D,R]=M.useState(!1),[I,B]=M.useState(!1),H=async()=>{if(w)return;const ne=qo(x).filter(ie=>ie.type==="text").map(ie=>ie.text).join(`
|
|
307
|
-
`);if(ne.trim()){T(!0);try{L(),Pe("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:ne.length}),f(!0),await p({tiptapDoc:bc({managerAgentId:Dl.AUTOMATION_MANAGER(o.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:ne})})}finally{T(!1)}}},W=e.models?.tier??"smart",z=Pl({defaultValues:{name:e.name,active:e.active,tier:W}}),O=z.watch("active"),[V,K]=M.useReducer(bb,null),Q=()=>{V!==null&&(Pe("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(V.fields),save_count:V.saveCount,edit_duration_ms:Date.now()-V.start}),K({type:"reset"}))},X=async()=>{const F=z.control._formState.dirtyFields,ne=Object.keys(F);if(ne.length===0&&!I)return!0;const ie=z.getValues(),de=z.control._defaultValues;z.reset(ie,{keepValues:!0});const ue=I;B(!1);const _e={id:t,name:ie.name,active:ie.active,models:{tier:ie.tier},messages:Nd(x),temperature:0};try{await a.mutateAsync(_e)}catch{return z.reset(de,{keepValues:!0}),ue&&B(!0),!1}const le=[...ne];return ue&&le.push("messages"),K({type:"accumulate",now:Date.now(),fields:le}),$(),!0},{schedule:q,flush:se}=lr({save:X}),{schedule:$,flush:L}=lr({delayMs:3e4,save:async()=>Q()});M.useEffect(()=>{const F=z.watch(()=>q());return()=>F.unsubscribe()},[]);const J=F=>{if(y(F),!D){R(!0);return}B(!0),q()},Z=async()=>{Pe("automation_test_clicked",{automation_id:t,agent_id:r});const F=await se();if(L(),!F)return;if(!x){ae.error("No instructions configured for this automation");return}u(z.getValues("tier")),f(!0),_({...m,toolApprovalLevel:"auto"});const ne=qo(x);d({message:{tiptapDoc:x,parts:ne},virtualMcpId:r||void 0})};return n.jsxs(n.Fragment,{children:[s&&n.jsx("div",{className:"flex items-center pb-4 shrink-0",children:n.jsxs(te,{variant:"ghost",size:"sm",onClick:s,children:[n.jsx(zu,{size:14}),"Back to list"]})}),n.jsxs("div",{className:"flex flex-col gap-8",children:[n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsxs("div",{className:"flex items-center justify-between gap-4",children:[n.jsx(ct,{control:z.control,name:"name",render:({field:F})=>n.jsx(Ge,{...F,placeholder:"Automation name",className:"border border-transparent shadow-none px-0 text-lg font-medium h-auto focus-visible:ring-0 focus-visible:border-border bg-transparent flex-1",style:{boxShadow:"none"}})}),i&&n.jsx(te,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:i,children:n.jsx(di,{size:14})})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ct,{control:z.control,name:"active",render:({field:F})=>n.jsx(on,{checked:F.value,onCheckedChange:ne=>{F.onChange(ne),se()},className:"cursor-pointer"})}),n.jsx("span",{className:"text-sm text-muted-foreground",children:O?"Active":"Inactive"}),n.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),n.jsx(Wl,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),n.jsxs("div",{className:"flex flex-col gap-2.5",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),n.jsx(gb,{automationId:t,open:v,onOpenChange:b,onCustomSelect:()=>{S(!0),A(!1),N("")},onEventSelect:()=>{A(!0),S(!1)},onWebhookCreated:F=>{Pe("automation_trigger_added",{automation_id:t,trigger_type:"webhook"}),j(F)}})]}),e.triggers.length===0&&!C?n.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:n.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",n.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>b(!0),children:"Add a starter"})," ","to get going."]})}):n.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(F=>n.jsx(vb,{trigger:F,automationId:t,connectionName:F.connection_id?c.get(F.connection_id):void 0},F.id))}),C&&n.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[n.jsx(ri,{size:14,className:"text-muted-foreground shrink-0"}),n.jsx("input",{type:"text",value:k,onChange:F=>N(F.target.value),onBlur:async()=>{const F=k.trim();if(!(!F||!li(F)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:F}),Pe("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),ae.success("Starter added"),S(!1),N("")}catch{ae.error("Failed to add starter")}},onKeyDown:async F=>{const ne=k.trim();F.key==="Enter"&&ne&&li(ne)&&F.target.blur(),F.key==="Escape"&&(S(!1),N(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),k&&!li(k)&&n.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&n.jsx(ge,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),n.jsx("button",{type:"button",className:"shrink-0 p-0.5 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-foreground transition-opacity",onClick:()=>{S(!1),N("")},children:n.jsx(ks,{size:13})})]}),P&&n.jsx(M.Suspense,{fallback:n.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[n.jsx(ge,{size:13,className:"animate-spin text-muted-foreground"}),n.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:n.jsx(yb,{automationId:t,onDone:()=>A(!1)})}),n.jsx(Bh,{open:E!==null,onOpenChange:F=>{F||j(null)},url:E?.url??null,token:E?.token??null})]}),n.jsxs("div",{className:"flex flex-col gap-2.5",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),n.jsxs(te,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:w||!x,onClick:H,children:[n.jsx(io,{size:13}),"Improve"]})]}),n.jsx(xd,{tiptapDoc:x,setTiptapDoc:J,placeholder:"What should this automation do?",children:n.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[n.jsx(bd,{virtualMcpId:r||null,className:"max-h-[45vh]"}),n.jsxs("div",{className:"@container/chat-bottom flex items-center justify-end gap-1.5 p-2.5",children:[n.jsx(hb,{tier:z.watch("tier"),onSelect:F=>z.setValue("tier",F,{shouldDirty:!0})}),n.jsxs(Ce,{children:[n.jsx(Se,{asChild:!0,children:n.jsxs(te,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:Z,disabled:!r,children:[n.jsx(hf,{size:16}),"Test"]})}),n.jsx(we,{children:"Test Automation"})]})]})]})})]})]})]})}function jb(t){const e=U.c(5),{tabId:s}=t;let i;e[0]!==s?(i=zl(s),e[0]=s,e[1]=i):i=e[1];const r=i;if(!r)return null;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=o):o=e[2];let a;return e[3]!==r.id?(a=n.jsx(xt,{children:n.jsx(xt.Content,{children:n.jsx(xt.Body,{children:n.jsx(M.Suspense,{fallback:o,children:n.jsx(Nb,{id:r.id})})})})}),e[3]=r.id,e[4]=a):a=e[4],a}function Nb(t){const e=U.c(8),{id:s}=t,i=Zt(),{data:r,isLoading:o}=of(s);let a;e[0]!==i?(a=()=>{i({to:".",search:Eb,replace:!0})},e[0]=i,e[1]=a):a=e[1];const l=a;if(o){let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=c):c=e[2],c}if(!r){let c;return e[3]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=c):c=e[3],c}let h;return e[4]!==r||e[5]!==s||e[6]!==l?(h=n.jsx(kb,{automationId:s,automation:r,onBack:l}),e[4]=r,e[5]=s,e[6]=l,e[7]=h):h=e[7],h}function Eb(t){return{...t,main:"automations"}}function Tb(t){const e=U.c(20),{virtualMcpId:s}=t,i=Zt(),{data:r}=af(s),o=r===void 0?[]:r,{create:a}=ki(),[l,h]=M.useState(""),c=l.toLowerCase(),d=o.filter(E=>E.name.toLowerCase().includes(c));let u;e[0]!==i?(u=E=>i({to:".",search:j=>({...j,main:"automation:"+E}),replace:!0}),e[0]=i,e[1]=u):u=e[1];const f=u,p=async()=>{if(a.isPending)return;Pe("automation_new_clicked",{virtual_mcp_id:s,existing_count:o.length});const E=await a.mutateAsync(cf(s));f(E.id)};let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(zt,{size:14}),e[2]=m):m=e[2];let _;e[3]!==a.isPending||e[4]!==p?(_=n.jsxs(te,{size:"sm",onClick:p,disabled:a.isPending,children:[m,"New automation"]}),e[3]=a.isPending,e[4]=p,e[5]=_):_=e[5];const g=_,x=xt,y=xt,v=xt;let b;e[6]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(xt.Title,{children:"Automations"}),e[6]=b):b=e[6];const C=o.length>0&&n.jsx(df,{value:l,onChange:h,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let S;e[7]!==g||e[8]!==C?(S=n.jsxs("div",{className:"flex flex-col gap-6",children:[b,n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[C,g]})]}),e[7]=g,e[8]=C,e[9]=S):S=e[9];const k=o.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(Zi,{image:n.jsx(ui,{size:48,className:"text-muted-foreground"}),title:"No automations yet",description:"Create your first automation to run this agent on a schedule or in response to events.",actions:g})}):d.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(Zi,{image:n.jsx(ui,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${l}"`})}):n.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:d.map(E=>n.jsx(lf,{automation:E,onClick:()=>f(E.id)},E.id))});let N;e[10]!==k||e[11]!==v.Body||e[12]!==S?(N=n.jsxs(v.Body,{children:[S,k]}),e[10]=k,e[11]=v.Body,e[12]=S,e[13]=N):N=e[13];let P;e[14]!==N||e[15]!==y.Content?(P=n.jsx(y.Content,{children:N}),e[14]=N,e[15]=y.Content,e[16]=P):P=e[16];let A;return e[17]!==x||e[18]!==P?(A=n.jsx(x,{children:P}),e[17]=x,e[18]=P,e[19]=A):A=e[19],A}function Rb(t){const e=U.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsx(M.Suspense,{fallback:i,children:n.jsx(Tb,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}const yl=300;function Ih(){const t=U.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(ys,{className:"h-6 w-2/3"}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("div",{className:"flex h-full w-full items-center justify-center bg-white",children:n.jsxs("div",{className:"flex w-3/4 max-w-md flex-col gap-3 p-6",children:[e,n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsx(ys,{className:"h-3 w-full"}),n.jsx(ys,{className:"h-3 w-5/6"}),n.jsx(ys,{className:"h-3 w-2/3"})]}),n.jsx(ys,{className:"mt-2 h-8 w-24"})]})}),t[1]=s):s=t[1],s}function Pb(t){const e=U.c(14),{url:s,title:i}=t,[r,o]=M.useState(!1),[a,l]=M.useState(!0);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=()=>o(!0),e[0]=h):h=e[0];const c=r?"opacity-100":"opacity-0";let d;e[1]!==c?(d=re("absolute inset-0 block w-full h-full bg-white","transition-opacity ease-out",c),e[1]=c,e[2]=d):d=e[2];let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u={transitionDuration:`${yl}ms`},e[3]=u):u=e[3];let f;e[4]!==d||e[5]!==i||e[6]!==s?(f=n.jsx("iframe",{src:s,onLoad:h,sandbox:"allow-scripts",className:d,style:u,title:i}),e[4]=d,e[5]=i,e[6]=s,e[7]=f):f=e[7];let p;e[8]!==r||e[9]!==a?(p=a&&n.jsx("div",{className:re("absolute inset-0 transition-opacity ease-out",r?"opacity-0 pointer-events-none":"opacity-100"),style:{transitionDuration:`${yl}ms`},onTransitionEnd:_=>{_.propertyName==="opacity"&&r&&l(!1)},children:n.jsx(Ih,{})}),e[8]=r,e[9]=a,e[10]=p):p=e[10];let m;return e[11]!==f||e[12]!==p?(m=n.jsxs("div",{className:"relative h-full w-full bg-background",children:[f,p]}),e[11]=f,e[12]=p,e[13]=m):m=e[13],m}function Db(t,e){for(let s=t.length-1;s>=0;s--){const i=t[s]?.parts;if(i)for(let r=i.length-1;r>=0;r--){const o=i[r];if(!o||o.type!=="data-html-page-published")continue;const a=o.data;if(a&&a.slug===e)return a}}return null}function Ab(t){const e=U.c(32),{url:s}=t,[i,r]=M.useState(!1);let o;e[0]!==s?(o=()=>{navigator.clipboard.writeText(s),r(!0),window.setTimeout(()=>r(!1),1500)},e[0]=s,e[1]=o):o=e[1];const a=o;let l;e[2]!==s?(l=()=>window.open(s,"_blank","noopener"),e[2]=s,e[3]=l):l=e[3];let h;e[4]!==s?(h=n.jsx("span",{className:"truncate",children:s}),e[4]=s,e[5]=h):h=e[5];let c;e[6]!==l||e[7]!==h||e[8]!==s?(c=n.jsx("button",{type:"button",onClick:l,className:"flex min-w-0 flex-1 items-center rounded-md px-2 py-1 text-left text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",title:s,children:h}),e[6]=l,e[7]=h,e[8]=s,e[9]=c):c=e[9];let d;e[10]!==i?(d=i?n.jsx(Ci,{size:14}):n.jsx(Xt,{size:14}),e[10]=i,e[11]=d):d=e[11];let u;e[12]!==a||e[13]!==d?(u=n.jsx(Se,{asChild:!0,children:n.jsx(te,{variant:"ghost",size:"icon",onClick:a,children:d})}),e[12]=a,e[13]=d,e[14]=u):u=e[14];const f=i?"Copied":"Copy URL";let p;e[15]!==f?(p=n.jsx(we,{side:"bottom",children:f}),e[15]=f,e[16]=p):p=e[16];let m;e[17]!==u||e[18]!==p?(m=n.jsxs(Ce,{children:[u,p]}),e[17]=u,e[18]=p,e[19]=m):m=e[19];let _;e[20]!==s?(_=()=>window.open(s,"_blank","noopener"),e[20]=s,e[21]=_):_=e[21];let g;e[22]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(Ps,{size:14}),e[22]=g):g=e[22];let x;e[23]!==_?(x=n.jsx(Se,{asChild:!0,children:n.jsx(te,{variant:"ghost",size:"icon",onClick:_,children:g})}),e[23]=_,e[24]=x):x=e[24];let y;e[25]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(we,{side:"bottom",children:"Open in new tab"}),e[25]=y):y=e[25];let v;e[26]!==x?(v=n.jsxs(Ce,{children:[x,y]}),e[26]=x,e[27]=v):v=e[27];let b;return e[28]!==v||e[29]!==c||e[30]!==m?(b=n.jsxs("div",{className:"flex h-9 shrink-0 items-center gap-1 border-b border-border/60 px-2",children:[c,m,v]}),e[28]=v,e[29]=c,e[30]=m,e[31]=b):b=e[31],b}function Mb(t){const e=U.c(15),{slug:s}=t,i=Ed();let r,o,a,l;if(e[0]!==s||e[1]!==i?.messages){l=Symbol.for("react.early_return_sentinel");e:{const p=i?.messages??[];if(r=Db(p,s),!r){let m;e[6]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx("div",{className:"h-full w-full bg-background",children:n.jsx(Ih,{})}),e[6]=m):m=e[6],l=m;break e}o=r.url,a=r.url.includes("?")?"&":"?"}e[0]=s,e[1]=i?.messages,e[2]=r,e[3]=o,e[4]=a,e[5]=l}else r=e[2],o=e[3],a=e[4],l=e[5];if(l!==Symbol.for("react.early_return_sentinel"))return l;const h=`${o}${a}v=${r.bytes}`;let c;e[7]!==r.url?(c=n.jsx(Ab,{url:r.url}),e[7]=r.url,e[8]=c):c=e[8];const d=`${s}.html`;let u;e[9]!==h||e[10]!==d?(u=n.jsx("div",{className:"relative flex-1",children:n.jsx(Pb,{url:h,title:d})}),e[9]=h,e[10]=d,e[11]=u):u=e[11];let f;return e[12]!==c||e[13]!==u?(f=n.jsxs("div",{className:"flex h-full w-full flex-col bg-background",children:[c,u]}),e[12]=c,e[13]=u,e[14]=f):f=e[14],f}const Sl=M.lazy(()=>vi(()=>import("./project-app-view-DqpMM8xe.js"),__vite__mapDeps([137,1,2,84,6,7,8,9,10,11,12,13,14,15,16,3,4,5,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,85,86,42,43,44,87,45,88,89,54,90,91,92,93,94,53,95,55,96,97,98,99,100,62,101,52,102,67,68,46,103,117])).then(t=>({default:t.AppViewContent})));function Lh(t){const e=U.c(47),{taskId:s,virtualMcpId:i}=t;let r;e[0]!==s||e[1]!==i?(r={virtualMcpId:i,taskId:s},e[0]=s,e[1]=i,e[2]=r):r=e[2];const{activeTab:o,layoutTabs:a,expandedTools:l,automationTabParsed:h}=xc(r);if(fu(o)){let g;return e[3]!==i?(g=n.jsx(fa,{virtualMcpId:i}),e[3]=i,e[4]=g):g=e[4],g}if(o==="git"){let g;return e[5]!==i?(g=n.jsx(y_,{virtualMcpId:i}),e[5]=i,e[6]=g):g=e[6],g}if(o==="automations"){let g;return e[7]!==i?(g=n.jsx(Rb,{virtualMcpId:i}),e[7]=i,e[8]=g):g=e[8],g}if(o==="preview"){let g;return e[9]!==i?(g=n.jsx(Ex,{virtualMcpId:i}),e[9]=i,e[10]=g):g=e[10],g}if(o==="content"){let g;return e[11]!==i?(g=n.jsx(cb,{virtualMcpId:i}),e[11]=i,e[12]=g):g=e[12],g}if(h){let g;return e[13]!==o?(g=n.jsx(jb,{tabId:o}),e[13]=o,e[14]=g):g=e[14],g}let c;e[15]!==o?(c=mu(o),e[15]=o,e[16]=c):c=e[16];const d=c;if(d){let g;return e[17]!==d.slug?(g=n.jsx(Mb,{slug:d.slug}),e[17]=d.slug,e[18]=g):g=e[18],g}let u;e[19]!==o?(u=pu(o),e[19]=o,e[20]=u):u=e[20];const f=u;if(f){let g;if(e[21]!==l||e[22]!==f.connectionId||e[23]!==f.toolName){let C;e[25]!==f.connectionId||e[26]!==f.toolName?(C=S=>S.appId===f.connectionId&&S.toolName===f.toolName,e[25]=f.connectionId,e[26]=f.toolName,e[27]=C):C=e[27],g=l.find(C),e[21]=l,e[22]=f.connectionId,e[23]=f.toolName,e[24]=g}else g=e[24];const x=g;let y;e[28]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})}),e[28]=y):y=e[28];const v=x?.args;let b;return e[29]!==o||e[30]!==f.connectionId||e[31]!==f.toolName||e[32]!==v?(b=n.jsx(M.Suspense,{fallback:y,children:n.jsx(Sl,{connectionId:f.connectionId,toolName:f.toolName,args:v},o)}),e[29]=o,e[30]=f.connectionId,e[31]=f.toolName,e[32]=v,e[33]=b):b=e[33],b}let p;if(e[34]!==o||e[35]!==a){let g;e[37]!==o?(g=x=>x.id===o,e[37]=o,e[38]=g):g=e[38],p=a.find(g),e[34]=o,e[35]=a,e[36]=p}else p=e[36];const m=p;if(m){let g;e[39]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})}),e[39]=g):g=e[39];let x;return e[40]!==o||e[41]!==m.id||e[42]!==m.view.appId||e[43]!==m.view.args?(x=n.jsx(M.Suspense,{fallback:g,children:n.jsx(Sl,{connectionId:m.view.appId,toolName:m.id,args:m.view.args},o)}),e[40]=o,e[41]=m.id,e[42]=m.view.appId,e[43]=m.view.args,e[44]=x):x=e[44],x}let _;return e[45]!==i?(_=n.jsx(fa,{virtualMcpId:i}),e[45]=i,e[46]=_):_=e[46],_}function Bb(t){const e=U.c(9),{children:s,defaultSize:i,chatOpen:r,chatPanelWidth:o,onChatPanelResize:a}=t,[,l]=M.useTransition(),h=i>0&&i<100?o:i;let c;e[0]!==a?(c=m=>l(()=>{m>0&&m<100&&a(m)}),e[0]=a,e[1]=c):c=e[1];const d=c,u=r?"min-w-[348px]":"min-w-0";let f;e[2]!==u?(f=re("overflow-hidden bg-sidebar",u),e[2]=u,e[3]=f):f=e[3];let p;return e[4]!==s||e[5]!==h||e[6]!==d||e[7]!==f?(p=n.jsx(Hl,{defaultSize:h,minSize:20,collapsible:!0,collapsedSize:0,className:f,onResize:d,order:1,children:s}),e[4]=s,e[5]=h,e[6]=d,e[7]=f,e[8]=p):p=e[8],p}function Ib(t){const e=U.c(32),{virtualMcpId:s,taskId:i,chatOpen:r,mainOpen:o,chatContent:a}=t;let l;e[0]!==r||e[1]!==o?(l=ia(r,o),e[0]=r,e[1]=o,e[2]=l):l=e[2];const h=l,[c,d]=Of(),u=M.useRef(null);let f,p;e[3]!==r||e[4]!==c||e[5]!==o?(f=()=>{const A=u.current;if(!A)return;const E=ia(r,o),j=E.chat>0&&E.chat<100?c:E.chat,w=E.chat>0&&E.chat<100?100-c:E.main;A.setLayout([j,w])},p=[r,o,c],e[3]=r,e[4]=c,e[5]=o,e[6]=f,e[7]=p):(f=e[6],p=e[7]),M.useEffect(f,p);const m=`${s}-${i}`;let _;e[8]===Symbol.for("react.memo_cache_sentinel")?(_={overflow:"visible"},e[8]=_):_=e[8];let g;e[9]!==a?(g=a??n.jsx(Ql,{}),e[9]=a,e[10]=g):g=e[10];let x;e[11]!==g?(x=n.jsx("div",{className:"h-full p-0.5 pt-0.25",children:n.jsx("div",{className:"h-full bg-background rounded-[0.75rem] overflow-hidden card-shadow",children:g})}),e[11]=g,e[12]=x):x=e[12];let y;e[13]!==r||e[14]!==c||e[15]!==d||e[16]!==h.chat||e[17]!==x?(y=n.jsx(Bb,{defaultSize:h.chat,chatOpen:r,chatPanelWidth:c,onChatPanelResize:d,children:x}),e[13]=r,e[14]=c,e[15]=d,e[16]=h.chat,e[17]=x,e[18]=y):y=e[18];let v;e[19]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(Su,{className:"bg-sidebar"}),e[19]=v):v=e[19];const b=h.main;let C;e[20]===Symbol.for("react.memo_cache_sentinel")?(C={overflow:"visible"},e[20]=C):C=e[20];let S;e[21]===Symbol.for("react.memo_cache_sentinel")?(S=re("flex flex-col h-full min-h-0 bg-background overflow-hidden","card-shadow","transition-[border-radius] duration-200 ease-[var(--ease-out-quart)]","rounded-[0.75rem]"),e[21]=S):S=e[21];let k;e[22]!==i||e[23]!==s?(k=n.jsx("div",{className:"h-full p-0.5 pt-0.25",children:n.jsx("div",{className:S,children:n.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.jsx(Mt,{children:n.jsx(Lh,{taskId:i,virtualMcpId:s})})})})}),e[22]=i,e[23]=s,e[24]=k):k=e[24];let N;e[25]!==h.main||e[26]!==k?(N=n.jsx(Hl,{className:"min-w-0 flex flex-col",order:2,defaultSize:b,style:C,collapsible:!0,collapsedSize:0,minSize:20,children:k}),e[25]=h.main,e[26]=k,e[27]=N):N=e[27];let P;return e[28]!==N||e[29]!==m||e[30]!==y?(P=n.jsxs(wu,{ref:u,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:_,children:[y,v,N]},m),e[28]=N,e[29]=m,e[30]=y,e[31]=P):P=e[31],P}function Lb(t){const e=U.c(15),{chatOpen:s,toggleChat:i,onNewTask:r}=t;let o;e[0]!==s||e[1]!==i?(o=()=>{Pe("agent_toolbar_toggled",{button:"chat",next_state:s?"closed":"open"}),i()},e[0]=s,e[1]=i,e[2]=o):o=e[2];let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(Ol,{size:16}),e[3]=a):a=e[3];let l;e[4]!==s||e[5]!==o?(l=n.jsx(Se,{asChild:!0,children:n.jsx(ea,{onClick:o,"aria-pressed":s,"aria-label":"Chat",active:s,children:a})}),e[4]=s,e[5]=o,e[6]=l):l=e[6];let h;e[7]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(we,{side:"bottom",children:"Chat"}),e[7]=h):h=e[7];let c;e[8]!==l?(c=n.jsxs(Ce,{delayDuration:300,children:[l,h]}),e[8]=l,e[9]=c):c=e[9];let d;e[10]!==r?(d=r&&n.jsxs(Ce,{delayDuration:300,children:[n.jsx(Se,{asChild:!0,children:n.jsx(ea,{onClick:r,"aria-label":"New task",children:n.jsx(yr,{size:16})})}),n.jsx(we,{side:"bottom",children:"New task"})]}),e[10]=r,e[11]=d):d=e[11];let u;return e[12]!==c||e[13]!==d?(u=n.jsxs(n.Fragment,{children:[c,d]}),e[12]=c,e[13]=d,e[14]=u):u=e[14],u}function Ob(t,e,s){if(t.length<=s)return{visible:t,overflow:[]};const i=t.slice(0,s),r=t.slice(s);if(e==null)return{visible:i,overflow:r};if(i.some(u=>u.id===e))return{visible:i,overflow:r};const a=r.findIndex(u=>u.id===e);if(a===-1)return{visible:i,overflow:r};const l=i[i.length-1],h=r[a],c=[...i.slice(0,-1),h],d=[l,...r.slice(0,a),...r.slice(a+1)];return{visible:c,overflow:d}}function $b(t){const e=U.c(13),{title:s,icon:i,active:r,onClick:o}=t,a=r?"bg-sidebar-accent text-sidebar-foreground":"text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";let l;e[0]!==a?(l=re("shrink-0 flex items-center gap-1.5 h-8 rounded-md px-2","[transition:background-color_180ms_ease,color_180ms_ease]",a),e[0]=a,e[1]=l):l=e[1];let h;e[2]!==i?(h=n.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:n.jsx(zb,{icon:i})}),e[2]=i,e[3]=h):h=e[3];let c;e[4]!==s?(c=n.jsx("span",{className:"whitespace-nowrap text-sm font-medium leading-none",children:s}),e[4]=s,e[5]=c):c=e[5];let d;return e[6]!==r||e[7]!==o||e[8]!==l||e[9]!==h||e[10]!==c||e[11]!==s?(d=n.jsxs("button",{type:"button",onClick:o,"aria-pressed":r,"aria-label":s,className:l,children:[h,c]}),e[6]=r,e[7]=o,e[8]=l,e[9]=h,e[10]=c,e[11]=s,e[12]=d):d=e[12],d}function zb(t){const e=U.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let o;return e[0]!==r?(o=n.jsx(r,{className:"size-4"}),e[0]=r,e[1]=o):o=e[1],o}if(s.kind==="url"){let r;return e[2]!==s.src?(r=n.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=r):r=e[3],r}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx($l,{className:"size-4"}),e[4]=i):i=e[4],i}function Fb(t){const e=U.c(13),{overflow:s,onSelect:i}=t,[r,o]=M.useState(!1);let a;e[0]!==i?(a=f=>{o(!1),i(f)},e[0]=i,e[1]=a):a=e[1];const l=a;let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Si,{asChild:!0,children:n.jsx("button",{type:"button",title:"More tabs","aria-label":"More tabs",className:"shrink-0 flex size-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",children:n.jsx(Cr,{className:"size-4"})})}),e[2]=h):h=e[2];let c;if(e[3]!==l||e[4]!==s){let f;e[6]!==l?(f=p=>n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>l(p.id),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md hover:bg-accent text-sm text-foreground",children:[n.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:n.jsx(Hb,{icon:p.icon})}),n.jsx("span",{className:"truncate",children:p.title})]})},p.id),e[6]=l,e[7]=f):f=e[7],c=s.map(f),e[3]=l,e[4]=s,e[5]=c}else c=e[5];let d;e[8]!==c?(d=n.jsx(wi,{align:"end",className:"w-56 p-1",children:n.jsx("ul",{className:"flex flex-col",children:c})}),e[8]=c,e[9]=d):d=e[9];let u;return e[10]!==r||e[11]!==d?(u=n.jsxs(yi,{open:r,onOpenChange:o,children:[h,d]}),e[10]=r,e[11]=d,e[12]=u):u=e[12],u}function Hb(t){const e=U.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let o;return e[0]!==r?(o=n.jsx(r,{className:"size-4"}),e[0]=r,e[1]=o):o=e[1],o}if(s.kind==="url"){let r;return e[2]!==s.src?(r=n.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=r):r=e[3],r}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx($l,{className:"size-4"}),e[4]=i):i=e[4],i}const Wb=6;function Oh(t){const e=U.c(20),{virtualMcpId:s,taskId:i}=t,r=Zt();let o;e[0]!==i||e[1]!==s?(o={virtualMcpId:s,taskId:i},e[0]=i,e[1]=s,e[2]=o):o=e[2];const{tabs:a,activeTab:l,mainOpen:h,setActiveTab:c}=xc(o);let d,u,f,p;if(e[3]!==l||e[4]!==h||e[5]!==r||e[6]!==c||e[7]!==a||e[8]!==s){const g=_u({activeTab:l,mainOpen:h}),x=S=>S.id==="automations"?g:h&&S.id===l,v=a.find(S=>x(S))?.id??null,{visible:b,overflow:C}=Ob(a,v,Wb);u=C,d=S=>{const k=a.find(P=>P.id===S),N=v===S&&h;if(Pe("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:S,tab_kind:k?.kind??null,was_active:N}),S==="automations"){const P=gu({activeTab:l,mainOpen:h});r({to:".",search:A=>({...A,main:P}),replace:!0});return}c(S)},f="flex items-center min-w-0 gap-0.5",p=b.map(S=>n.jsx($b,{title:S.title,icon:S.icon,active:x(S),onClick:()=>d(S.id)},S.id)),e[3]=l,e[4]=h,e[5]=r,e[6]=c,e[7]=a,e[8]=s,e[9]=d,e[10]=u,e[11]=f,e[12]=p}else d=e[9],u=e[10],f=e[11],p=e[12];let m;e[13]!==d||e[14]!==u?(m=u.length>0&&n.jsx(Fb,{overflow:u,onSelect:d}),e[13]=d,e[14]=u,e[15]=m):m=e[15];let _;return e[16]!==f||e[17]!==p||e[18]!==m?(_=n.jsxs("div",{className:f,children:[p,m]}),e[16]=f,e[17]=p,e[18]=m,e[19]=_):_=e[19],_}const wl=3e3,Ub=6e4;function Kb(t){const e=U.c(12),{orgSlug:s,virtualMcpId:i,branch:r,enabled:o}=t,a=o===void 0?!0:o,l=r??"";let h;e[0]!==s||e[1]!==l||e[2]!==i?(h=qp(s,i,l),e[0]=s,e[1]=l,e[2]=i,e[3]=h):h=e[3];let c;e[4]!==r||e[5]!==s||e[6]!==i?(c=()=>Ui(s,i,r),e[4]=r,e[5]=s,e[6]=i,e[7]=c):c=e[7];const d=a&&!!r;let u;return e[8]!==h||e[9]!==c||e[10]!==d?(u={queryKey:h,queryFn:c,enabled:d,refetchInterval:qb,retry:Vb,staleTime:1e3},e[8]=h,e[9]=c,e[10]=d,e[11]=u):u=e[11],gi(u)}function Vb(t,e){return!kc(e)}function qb(t){if(!kc(t.state.error))return wl;const e=t.state.fetchFailureCount;return Math.min(wl*2**e,Ub)}const Gb=new Set(["main","master"]);function Bo(t){return Gb.has(t.trim().toLowerCase())?"Publish to production":"Publish"}function Yb(t){const e=U.c(24),{baseBranch:s,disabled:i,loading:r,onPublish:o,onReview:a}=t,l=r===void 0?!1:r;let h;e[0]!==s?(h=Bo(s),e[0]=s,e[1]=h):h=e[1];const c=h;let d;e[2]!==o?(d=()=>{o()},e[2]=o,e[3]=d):d=e[3];let u;e[4]!==l?(u=l?n.jsx(Jl,{size:"xs",variant:"default"}):null,e[4]=l,e[5]=u):u=e[5];let f;e[6]!==i||e[7]!==c||e[8]!==d||e[9]!==u?(f=n.jsxs(te,{size:"sm",variant:"success",className:"rounded-r-none border-r border-success-foreground/20",disabled:i,onClick:d,children:[u,c]}),e[6]=i,e[7]=c,e[8]=d,e[9]=u,e[10]=f):f=e[10];let p;e[11]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(ao,{className:"h-3.5 w-3.5"}),e[11]=p):p=e[11];let m;e[12]!==i?(m=n.jsx(As,{asChild:!0,children:n.jsx(te,{size:"sm",variant:"success",className:"rounded-l-none px-2",disabled:i,"aria-label":"More actions",children:p})}),e[12]=i,e[13]=m):m=e[13];let _;e[14]!==a?(_=a?n.jsx(ht,{onClick:a,children:"Review"}):null,e[14]=a,e[15]=_):_=e[15];let g;e[16]!==_?(g=n.jsx(Ms,{align:"end",children:_}),e[16]=_,e[17]=g):g=e[17];let x;e[18]!==m||e[19]!==g?(x=n.jsxs(Ds,{children:[m,g]}),e[18]=m,e[19]=g,e[20]=x):x=e[20];let y;return e[21]!==x||e[22]!==f?(y=n.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[f,x]}),e[21]=x,e[22]=f,e[23]=y):y=e[23],y}class Js extends Error{constructor(e,s,i){super(e),this.step=s,this.pr=i,this.name="PublishFlowError"}step;pr}function Xb(t){const e=U.c(10),[s,i]=M.useState(0);let r;e[0]!==t?(r=h=>{h&&i(Jb),t.onOpenChange(h)},e[0]=t,e[1]=r):r=e[1];const o=r;let a;e[2]!==o||e[3]!==t||e[4]!==s?(a=t.open?n.jsx(Zb,{...t,onOpenChange:o},s):null,e[2]=o,e[3]=t,e[4]=s,e[5]=a):a=e[5];let l;return e[6]!==o||e[7]!==t.open||e[8]!==a?(l=n.jsx(Ht,{open:t.open,onOpenChange:o,children:a}),e[6]=o,e[7]=t.open,e[8]=a,e[9]=l):l=e[9],l}function Jb(t){return t+1}function Zb({onOpenChange:t,orgSlug:e,orgId:s,virtualMcpId:i,branch:r,baseBranch:o,githubConnectionId:a,owner:l,repo:h,previewUrl:c,dialogIntent:d="publish",headSha:u=null,openPullRequest:f=null,onPullRequestChanged:p,onPublished:m}){const _=Qe({connectionId:a,orgId:s,orgSlug:e}),g=f?.state==="open",x=d==="publish",y=d==="open-pr"&&!g,[v,b]=M.useState(null),[C,S]=M.useState(null),[k,N]=M.useState(!0),[P,A]=M.useState(!1),[E,j]=M.useState(""),[w,T]=M.useState(""),[D,R]=M.useState(),[I,B]=M.useState(!1),[H,W]=M.useState(!1),[z,O]=M.useState(),[V,K]=M.useState(),[Q,X]=M.useState(!1),[q,se]=M.useState(!1),[$,L]=M.useState(!1),J=M.useRef(!1);J.current||(J.current=!0,(async()=>{N(!0),R(void 0),S(null),j(""),T(""),O(void 0),K(void 0);try{const fe=y?{base:o,...u?{headSha:u}:{}}:void 0,[xe,ve]=await Promise.all([Ui(e,i,r),jc(e,i,r,fe)]);b(xe),S(ve),j(`Changes from ${xe.current??r}`),L(!0),pa(e,i,r,{status:xe,diff:ve}).then(Le=>{j(Le.title),T(Le.body)}).catch(()=>{}).finally(()=>L(!1))}catch(fe){R(fe instanceof Error?fe.message:"Failed to load changes.")}finally{N(!1)}})());const Z=So(v)??r,F=Bo(o),ne=()=>{!v||!C||(L(!0),pa(e,i,r,{status:v,diff:C}).then(fe=>{j(fe.title),T(fe.body)}).catch(()=>{}).finally(()=>L(!1)))},ie=Nc(v),de=C?Object.keys(C.diffs).length:ie,ue=y?Tc(v):Gp(v,C),_e=!k&&(x?ue:ue||y),le=_e&&_a(C),je=_e&&!_a(C)?Kp:null,Ne=()=>[E.trim(),w.trim()].filter(Boolean).join(`
|
|
307
|
+
`);if(ne.trim()){T(!0);try{L(),Pe("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:ne.length}),f(!0),await p({tiptapDoc:bc({managerAgentId:Dl.AUTOMATION_MANAGER(o.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:ne})})}finally{T(!1)}}},W=e.models?.tier??"smart",z=Pl({defaultValues:{name:e.name,active:e.active,tier:W}}),O=z.watch("active"),[V,K]=M.useReducer(bb,null),Q=()=>{V!==null&&(Pe("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(V.fields),save_count:V.saveCount,edit_duration_ms:Date.now()-V.start}),K({type:"reset"}))},X=async()=>{const F=z.control._formState.dirtyFields,ne=Object.keys(F);if(ne.length===0&&!I)return!0;const ie=z.getValues(),de=z.control._defaultValues;z.reset(ie,{keepValues:!0});const ue=I;B(!1);const _e={id:t,name:ie.name,active:ie.active,models:{tier:ie.tier},messages:Nd(x),temperature:0};try{await a.mutateAsync(_e)}catch{return z.reset(de,{keepValues:!0}),ue&&B(!0),!1}const le=[...ne];return ue&&le.push("messages"),K({type:"accumulate",now:Date.now(),fields:le}),$(),!0},{schedule:q,flush:se}=lr({save:X}),{schedule:$,flush:L}=lr({delayMs:3e4,save:async()=>Q()});M.useEffect(()=>{const F=z.watch(()=>q());return()=>F.unsubscribe()},[]);const J=F=>{if(y(F),!D){R(!0);return}B(!0),q()},Z=async()=>{Pe("automation_test_clicked",{automation_id:t,agent_id:r});const F=await se();if(L(),!F)return;if(!x){ae.error("No instructions configured for this automation");return}u(z.getValues("tier")),f(!0),_({...m,toolApprovalLevel:"auto"});const ne=qo(x);d({message:{tiptapDoc:x,parts:ne},virtualMcpId:r||void 0})};return n.jsxs(n.Fragment,{children:[s&&n.jsx("div",{className:"flex items-center pb-4 shrink-0",children:n.jsxs(te,{variant:"ghost",size:"sm",onClick:s,children:[n.jsx(zu,{size:14}),"Back to list"]})}),n.jsxs("div",{className:"flex flex-col gap-8",children:[n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsxs("div",{className:"flex items-center justify-between gap-4",children:[n.jsx(ct,{control:z.control,name:"name",render:({field:F})=>n.jsx(Ge,{...F,placeholder:"Automation name",className:"border border-transparent shadow-none px-0 text-lg font-medium h-auto focus-visible:ring-0 focus-visible:border-border bg-transparent flex-1",style:{boxShadow:"none"}})}),i&&n.jsx(te,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:i,children:n.jsx(di,{size:14})})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ct,{control:z.control,name:"active",render:({field:F})=>n.jsx(on,{checked:F.value,onCheckedChange:ne=>{F.onChange(ne),se()},className:"cursor-pointer"})}),n.jsx("span",{className:"text-sm text-muted-foreground",children:O?"Active":"Inactive"}),n.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),n.jsx(Wl,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),n.jsxs("div",{className:"flex flex-col gap-2.5",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),n.jsx(gb,{automationId:t,open:v,onOpenChange:b,onCustomSelect:()=>{S(!0),A(!1),N("")},onEventSelect:()=>{A(!0),S(!1)},onWebhookCreated:F=>{Pe("automation_trigger_added",{automation_id:t,trigger_type:"webhook"}),j(F)}})]}),e.triggers.length===0&&!C?n.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:n.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",n.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>b(!0),children:"Add a starter"})," ","to get going."]})}):n.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(F=>n.jsx(vb,{trigger:F,automationId:t,connectionName:F.connection_id?c.get(F.connection_id):void 0},F.id))}),C&&n.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[n.jsx(ri,{size:14,className:"text-muted-foreground shrink-0"}),n.jsx("input",{type:"text",value:k,onChange:F=>N(F.target.value),onBlur:async()=>{const F=k.trim();if(!(!F||!li(F)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:F}),Pe("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),ae.success("Starter added"),S(!1),N("")}catch{ae.error("Failed to add starter")}},onKeyDown:async F=>{const ne=k.trim();F.key==="Enter"&&ne&&li(ne)&&F.target.blur(),F.key==="Escape"&&(S(!1),N(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),k&&!li(k)&&n.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&n.jsx(ge,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),n.jsx("button",{type:"button",className:"shrink-0 p-0.5 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-foreground transition-opacity",onClick:()=>{S(!1),N("")},children:n.jsx(ks,{size:13})})]}),P&&n.jsx(M.Suspense,{fallback:n.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[n.jsx(ge,{size:13,className:"animate-spin text-muted-foreground"}),n.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:n.jsx(yb,{automationId:t,onDone:()=>A(!1)})}),n.jsx(Bh,{open:E!==null,onOpenChange:F=>{F||j(null)},url:E?.url??null,token:E?.token??null})]}),n.jsxs("div",{className:"flex flex-col gap-2.5",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),n.jsxs(te,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:w||!x,onClick:H,children:[n.jsx(io,{size:13}),"Improve"]})]}),n.jsx(xd,{tiptapDoc:x,setTiptapDoc:J,placeholder:"What should this automation do?",children:n.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[n.jsx(bd,{virtualMcpId:r||null,className:"max-h-[45vh]"}),n.jsxs("div",{className:"@container/chat-bottom flex items-center justify-end gap-1.5 p-2.5",children:[n.jsx(hb,{tier:z.watch("tier"),onSelect:F=>z.setValue("tier",F,{shouldDirty:!0})}),n.jsxs(Ce,{children:[n.jsx(Se,{asChild:!0,children:n.jsxs(te,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:Z,disabled:!r,children:[n.jsx(hf,{size:16}),"Test"]})}),n.jsx(we,{children:"Test Automation"})]})]})]})})]})]})]})}function jb(t){const e=U.c(5),{tabId:s}=t;let i;e[0]!==s?(i=zl(s),e[0]=s,e[1]=i):i=e[1];const r=i;if(!r)return null;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=o):o=e[2];let a;return e[3]!==r.id?(a=n.jsx(xt,{children:n.jsx(xt.Content,{children:n.jsx(xt.Body,{children:n.jsx(M.Suspense,{fallback:o,children:n.jsx(Nb,{id:r.id})})})})}),e[3]=r.id,e[4]=a):a=e[4],a}function Nb(t){const e=U.c(8),{id:s}=t,i=Zt(),{data:r,isLoading:o}=of(s);let a;e[0]!==i?(a=()=>{i({to:".",search:Eb,replace:!0})},e[0]=i,e[1]=a):a=e[1];const l=a;if(o){let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=c):c=e[2],c}if(!r){let c;return e[3]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=c):c=e[3],c}let h;return e[4]!==r||e[5]!==s||e[6]!==l?(h=n.jsx(kb,{automationId:s,automation:r,onBack:l}),e[4]=r,e[5]=s,e[6]=l,e[7]=h):h=e[7],h}function Eb(t){return{...t,main:"automations"}}function Tb(t){const e=U.c(20),{virtualMcpId:s}=t,i=Zt(),{data:r}=af(s),o=r===void 0?[]:r,{create:a}=ki(),[l,h]=M.useState(""),c=l.toLowerCase(),d=o.filter(E=>E.name.toLowerCase().includes(c));let u;e[0]!==i?(u=E=>i({to:".",search:j=>({...j,main:"automation:"+E}),replace:!0}),e[0]=i,e[1]=u):u=e[1];const f=u,p=async()=>{if(a.isPending)return;Pe("automation_new_clicked",{virtual_mcp_id:s,existing_count:o.length});const E=await a.mutateAsync(cf(s));f(E.id)};let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(zt,{size:14}),e[2]=m):m=e[2];let _;e[3]!==a.isPending||e[4]!==p?(_=n.jsxs(te,{size:"sm",onClick:p,disabled:a.isPending,children:[m,"New automation"]}),e[3]=a.isPending,e[4]=p,e[5]=_):_=e[5];const g=_,x=xt,y=xt,v=xt;let b;e[6]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(xt.Title,{children:"Automations"}),e[6]=b):b=e[6];const C=o.length>0&&n.jsx(df,{value:l,onChange:h,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let S;e[7]!==g||e[8]!==C?(S=n.jsxs("div",{className:"flex flex-col gap-6",children:[b,n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[C,g]})]}),e[7]=g,e[8]=C,e[9]=S):S=e[9];const k=o.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(Zi,{image:n.jsx(ui,{size:48,className:"text-muted-foreground"}),title:"No automations yet",description:"Create your first automation to run this agent on a schedule or in response to events.",actions:g})}):d.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(Zi,{image:n.jsx(ui,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${l}"`})}):n.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:d.map(E=>n.jsx(lf,{automation:E,onClick:()=>f(E.id)},E.id))});let N;e[10]!==k||e[11]!==v.Body||e[12]!==S?(N=n.jsxs(v.Body,{children:[S,k]}),e[10]=k,e[11]=v.Body,e[12]=S,e[13]=N):N=e[13];let P;e[14]!==N||e[15]!==y.Content?(P=n.jsx(y.Content,{children:N}),e[14]=N,e[15]=y.Content,e[16]=P):P=e[16];let A;return e[17]!==x||e[18]!==P?(A=n.jsx(x,{children:P}),e[17]=x,e[18]=P,e[19]=A):A=e[19],A}function Rb(t){const e=U.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsx(M.Suspense,{fallback:i,children:n.jsx(Tb,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}const yl=300;function Ih(){const t=U.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(ys,{className:"h-6 w-2/3"}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("div",{className:"flex h-full w-full items-center justify-center bg-white",children:n.jsxs("div",{className:"flex w-3/4 max-w-md flex-col gap-3 p-6",children:[e,n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsx(ys,{className:"h-3 w-full"}),n.jsx(ys,{className:"h-3 w-5/6"}),n.jsx(ys,{className:"h-3 w-2/3"})]}),n.jsx(ys,{className:"mt-2 h-8 w-24"})]})}),t[1]=s):s=t[1],s}function Pb(t){const e=U.c(14),{url:s,title:i}=t,[r,o]=M.useState(!1),[a,l]=M.useState(!0);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=()=>o(!0),e[0]=h):h=e[0];const c=r?"opacity-100":"opacity-0";let d;e[1]!==c?(d=re("absolute inset-0 block w-full h-full bg-white","transition-opacity ease-out",c),e[1]=c,e[2]=d):d=e[2];let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u={transitionDuration:`${yl}ms`},e[3]=u):u=e[3];let f;e[4]!==d||e[5]!==i||e[6]!==s?(f=n.jsx("iframe",{src:s,onLoad:h,sandbox:"allow-scripts",className:d,style:u,title:i}),e[4]=d,e[5]=i,e[6]=s,e[7]=f):f=e[7];let p;e[8]!==r||e[9]!==a?(p=a&&n.jsx("div",{className:re("absolute inset-0 transition-opacity ease-out",r?"opacity-0 pointer-events-none":"opacity-100"),style:{transitionDuration:`${yl}ms`},onTransitionEnd:_=>{_.propertyName==="opacity"&&r&&l(!1)},children:n.jsx(Ih,{})}),e[8]=r,e[9]=a,e[10]=p):p=e[10];let m;return e[11]!==f||e[12]!==p?(m=n.jsxs("div",{className:"relative h-full w-full bg-background",children:[f,p]}),e[11]=f,e[12]=p,e[13]=m):m=e[13],m}function Db(t,e){for(let s=t.length-1;s>=0;s--){const i=t[s]?.parts;if(i)for(let r=i.length-1;r>=0;r--){const o=i[r];if(!o||o.type!=="data-html-page-published")continue;const a=o.data;if(a&&a.slug===e)return a}}return null}function Ab(t){const e=U.c(32),{url:s}=t,[i,r]=M.useState(!1);let o;e[0]!==s?(o=()=>{navigator.clipboard.writeText(s),r(!0),window.setTimeout(()=>r(!1),1500)},e[0]=s,e[1]=o):o=e[1];const a=o;let l;e[2]!==s?(l=()=>window.open(s,"_blank","noopener"),e[2]=s,e[3]=l):l=e[3];let h;e[4]!==s?(h=n.jsx("span",{className:"truncate",children:s}),e[4]=s,e[5]=h):h=e[5];let c;e[6]!==l||e[7]!==h||e[8]!==s?(c=n.jsx("button",{type:"button",onClick:l,className:"flex min-w-0 flex-1 items-center rounded-md px-2 py-1 text-left text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",title:s,children:h}),e[6]=l,e[7]=h,e[8]=s,e[9]=c):c=e[9];let d;e[10]!==i?(d=i?n.jsx(Ci,{size:14}):n.jsx(Xt,{size:14}),e[10]=i,e[11]=d):d=e[11];let u;e[12]!==a||e[13]!==d?(u=n.jsx(Se,{asChild:!0,children:n.jsx(te,{variant:"ghost",size:"icon",onClick:a,children:d})}),e[12]=a,e[13]=d,e[14]=u):u=e[14];const f=i?"Copied":"Copy URL";let p;e[15]!==f?(p=n.jsx(we,{side:"bottom",children:f}),e[15]=f,e[16]=p):p=e[16];let m;e[17]!==u||e[18]!==p?(m=n.jsxs(Ce,{children:[u,p]}),e[17]=u,e[18]=p,e[19]=m):m=e[19];let _;e[20]!==s?(_=()=>window.open(s,"_blank","noopener"),e[20]=s,e[21]=_):_=e[21];let g;e[22]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(Ps,{size:14}),e[22]=g):g=e[22];let x;e[23]!==_?(x=n.jsx(Se,{asChild:!0,children:n.jsx(te,{variant:"ghost",size:"icon",onClick:_,children:g})}),e[23]=_,e[24]=x):x=e[24];let y;e[25]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(we,{side:"bottom",children:"Open in new tab"}),e[25]=y):y=e[25];let v;e[26]!==x?(v=n.jsxs(Ce,{children:[x,y]}),e[26]=x,e[27]=v):v=e[27];let b;return e[28]!==v||e[29]!==c||e[30]!==m?(b=n.jsxs("div",{className:"flex h-9 shrink-0 items-center gap-1 border-b border-border/60 px-2",children:[c,m,v]}),e[28]=v,e[29]=c,e[30]=m,e[31]=b):b=e[31],b}function Mb(t){const e=U.c(15),{slug:s}=t,i=Ed();let r,o,a,l;if(e[0]!==s||e[1]!==i?.messages){l=Symbol.for("react.early_return_sentinel");e:{const p=i?.messages??[];if(r=Db(p,s),!r){let m;e[6]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx("div",{className:"h-full w-full bg-background",children:n.jsx(Ih,{})}),e[6]=m):m=e[6],l=m;break e}o=r.url,a=r.url.includes("?")?"&":"?"}e[0]=s,e[1]=i?.messages,e[2]=r,e[3]=o,e[4]=a,e[5]=l}else r=e[2],o=e[3],a=e[4],l=e[5];if(l!==Symbol.for("react.early_return_sentinel"))return l;const h=`${o}${a}v=${r.bytes}`;let c;e[7]!==r.url?(c=n.jsx(Ab,{url:r.url}),e[7]=r.url,e[8]=c):c=e[8];const d=`${s}.html`;let u;e[9]!==h||e[10]!==d?(u=n.jsx("div",{className:"relative flex-1",children:n.jsx(Pb,{url:h,title:d})}),e[9]=h,e[10]=d,e[11]=u):u=e[11];let f;return e[12]!==c||e[13]!==u?(f=n.jsxs("div",{className:"flex h-full w-full flex-col bg-background",children:[c,u]}),e[12]=c,e[13]=u,e[14]=f):f=e[14],f}const Sl=M.lazy(()=>vi(()=>import("./project-app-view-B77cUBzb.js"),__vite__mapDeps([137,1,2,84,6,7,8,9,10,11,12,13,14,15,16,3,4,5,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,85,86,42,43,44,87,45,88,89,54,90,91,92,93,94,53,95,55,96,97,98,99,100,62,101,52,102,67,68,46,103,117])).then(t=>({default:t.AppViewContent})));function Lh(t){const e=U.c(47),{taskId:s,virtualMcpId:i}=t;let r;e[0]!==s||e[1]!==i?(r={virtualMcpId:i,taskId:s},e[0]=s,e[1]=i,e[2]=r):r=e[2];const{activeTab:o,layoutTabs:a,expandedTools:l,automationTabParsed:h}=xc(r);if(fu(o)){let g;return e[3]!==i?(g=n.jsx(fa,{virtualMcpId:i}),e[3]=i,e[4]=g):g=e[4],g}if(o==="git"){let g;return e[5]!==i?(g=n.jsx(y_,{virtualMcpId:i}),e[5]=i,e[6]=g):g=e[6],g}if(o==="automations"){let g;return e[7]!==i?(g=n.jsx(Rb,{virtualMcpId:i}),e[7]=i,e[8]=g):g=e[8],g}if(o==="preview"){let g;return e[9]!==i?(g=n.jsx(Ex,{virtualMcpId:i}),e[9]=i,e[10]=g):g=e[10],g}if(o==="content"){let g;return e[11]!==i?(g=n.jsx(cb,{virtualMcpId:i}),e[11]=i,e[12]=g):g=e[12],g}if(h){let g;return e[13]!==o?(g=n.jsx(jb,{tabId:o}),e[13]=o,e[14]=g):g=e[14],g}let c;e[15]!==o?(c=mu(o),e[15]=o,e[16]=c):c=e[16];const d=c;if(d){let g;return e[17]!==d.slug?(g=n.jsx(Mb,{slug:d.slug}),e[17]=d.slug,e[18]=g):g=e[18],g}let u;e[19]!==o?(u=pu(o),e[19]=o,e[20]=u):u=e[20];const f=u;if(f){let g;if(e[21]!==l||e[22]!==f.connectionId||e[23]!==f.toolName){let C;e[25]!==f.connectionId||e[26]!==f.toolName?(C=S=>S.appId===f.connectionId&&S.toolName===f.toolName,e[25]=f.connectionId,e[26]=f.toolName,e[27]=C):C=e[27],g=l.find(C),e[21]=l,e[22]=f.connectionId,e[23]=f.toolName,e[24]=g}else g=e[24];const x=g;let y;e[28]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})}),e[28]=y):y=e[28];const v=x?.args;let b;return e[29]!==o||e[30]!==f.connectionId||e[31]!==f.toolName||e[32]!==v?(b=n.jsx(M.Suspense,{fallback:y,children:n.jsx(Sl,{connectionId:f.connectionId,toolName:f.toolName,args:v},o)}),e[29]=o,e[30]=f.connectionId,e[31]=f.toolName,e[32]=v,e[33]=b):b=e[33],b}let p;if(e[34]!==o||e[35]!==a){let g;e[37]!==o?(g=x=>x.id===o,e[37]=o,e[38]=g):g=e[38],p=a.find(g),e[34]=o,e[35]=a,e[36]=p}else p=e[36];const m=p;if(m){let g;e[39]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})}),e[39]=g):g=e[39];let x;return e[40]!==o||e[41]!==m.id||e[42]!==m.view.appId||e[43]!==m.view.args?(x=n.jsx(M.Suspense,{fallback:g,children:n.jsx(Sl,{connectionId:m.view.appId,toolName:m.id,args:m.view.args},o)}),e[40]=o,e[41]=m.id,e[42]=m.view.appId,e[43]=m.view.args,e[44]=x):x=e[44],x}let _;return e[45]!==i?(_=n.jsx(fa,{virtualMcpId:i}),e[45]=i,e[46]=_):_=e[46],_}function Bb(t){const e=U.c(9),{children:s,defaultSize:i,chatOpen:r,chatPanelWidth:o,onChatPanelResize:a}=t,[,l]=M.useTransition(),h=i>0&&i<100?o:i;let c;e[0]!==a?(c=m=>l(()=>{m>0&&m<100&&a(m)}),e[0]=a,e[1]=c):c=e[1];const d=c,u=r?"min-w-[348px]":"min-w-0";let f;e[2]!==u?(f=re("overflow-hidden bg-sidebar",u),e[2]=u,e[3]=f):f=e[3];let p;return e[4]!==s||e[5]!==h||e[6]!==d||e[7]!==f?(p=n.jsx(Hl,{defaultSize:h,minSize:20,collapsible:!0,collapsedSize:0,className:f,onResize:d,order:1,children:s}),e[4]=s,e[5]=h,e[6]=d,e[7]=f,e[8]=p):p=e[8],p}function Ib(t){const e=U.c(32),{virtualMcpId:s,taskId:i,chatOpen:r,mainOpen:o,chatContent:a}=t;let l;e[0]!==r||e[1]!==o?(l=ia(r,o),e[0]=r,e[1]=o,e[2]=l):l=e[2];const h=l,[c,d]=Of(),u=M.useRef(null);let f,p;e[3]!==r||e[4]!==c||e[5]!==o?(f=()=>{const A=u.current;if(!A)return;const E=ia(r,o),j=E.chat>0&&E.chat<100?c:E.chat,w=E.chat>0&&E.chat<100?100-c:E.main;A.setLayout([j,w])},p=[r,o,c],e[3]=r,e[4]=c,e[5]=o,e[6]=f,e[7]=p):(f=e[6],p=e[7]),M.useEffect(f,p);const m=`${s}-${i}`;let _;e[8]===Symbol.for("react.memo_cache_sentinel")?(_={overflow:"visible"},e[8]=_):_=e[8];let g;e[9]!==a?(g=a??n.jsx(Ql,{}),e[9]=a,e[10]=g):g=e[10];let x;e[11]!==g?(x=n.jsx("div",{className:"h-full p-0.5 pt-0.25",children:n.jsx("div",{className:"h-full bg-background rounded-[0.75rem] overflow-hidden card-shadow",children:g})}),e[11]=g,e[12]=x):x=e[12];let y;e[13]!==r||e[14]!==c||e[15]!==d||e[16]!==h.chat||e[17]!==x?(y=n.jsx(Bb,{defaultSize:h.chat,chatOpen:r,chatPanelWidth:c,onChatPanelResize:d,children:x}),e[13]=r,e[14]=c,e[15]=d,e[16]=h.chat,e[17]=x,e[18]=y):y=e[18];let v;e[19]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(Su,{className:"bg-sidebar"}),e[19]=v):v=e[19];const b=h.main;let C;e[20]===Symbol.for("react.memo_cache_sentinel")?(C={overflow:"visible"},e[20]=C):C=e[20];let S;e[21]===Symbol.for("react.memo_cache_sentinel")?(S=re("flex flex-col h-full min-h-0 bg-background overflow-hidden","card-shadow","transition-[border-radius] duration-200 ease-[var(--ease-out-quart)]","rounded-[0.75rem]"),e[21]=S):S=e[21];let k;e[22]!==i||e[23]!==s?(k=n.jsx("div",{className:"h-full p-0.5 pt-0.25",children:n.jsx("div",{className:S,children:n.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.jsx(Mt,{children:n.jsx(Lh,{taskId:i,virtualMcpId:s})})})})}),e[22]=i,e[23]=s,e[24]=k):k=e[24];let N;e[25]!==h.main||e[26]!==k?(N=n.jsx(Hl,{className:"min-w-0 flex flex-col",order:2,defaultSize:b,style:C,collapsible:!0,collapsedSize:0,minSize:20,children:k}),e[25]=h.main,e[26]=k,e[27]=N):N=e[27];let P;return e[28]!==N||e[29]!==m||e[30]!==y?(P=n.jsxs(wu,{ref:u,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:_,children:[y,v,N]},m),e[28]=N,e[29]=m,e[30]=y,e[31]=P):P=e[31],P}function Lb(t){const e=U.c(15),{chatOpen:s,toggleChat:i,onNewTask:r}=t;let o;e[0]!==s||e[1]!==i?(o=()=>{Pe("agent_toolbar_toggled",{button:"chat",next_state:s?"closed":"open"}),i()},e[0]=s,e[1]=i,e[2]=o):o=e[2];let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(Ol,{size:16}),e[3]=a):a=e[3];let l;e[4]!==s||e[5]!==o?(l=n.jsx(Se,{asChild:!0,children:n.jsx(ea,{onClick:o,"aria-pressed":s,"aria-label":"Chat",active:s,children:a})}),e[4]=s,e[5]=o,e[6]=l):l=e[6];let h;e[7]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(we,{side:"bottom",children:"Chat"}),e[7]=h):h=e[7];let c;e[8]!==l?(c=n.jsxs(Ce,{delayDuration:300,children:[l,h]}),e[8]=l,e[9]=c):c=e[9];let d;e[10]!==r?(d=r&&n.jsxs(Ce,{delayDuration:300,children:[n.jsx(Se,{asChild:!0,children:n.jsx(ea,{onClick:r,"aria-label":"New task",children:n.jsx(yr,{size:16})})}),n.jsx(we,{side:"bottom",children:"New task"})]}),e[10]=r,e[11]=d):d=e[11];let u;return e[12]!==c||e[13]!==d?(u=n.jsxs(n.Fragment,{children:[c,d]}),e[12]=c,e[13]=d,e[14]=u):u=e[14],u}function Ob(t,e,s){if(t.length<=s)return{visible:t,overflow:[]};const i=t.slice(0,s),r=t.slice(s);if(e==null)return{visible:i,overflow:r};if(i.some(u=>u.id===e))return{visible:i,overflow:r};const a=r.findIndex(u=>u.id===e);if(a===-1)return{visible:i,overflow:r};const l=i[i.length-1],h=r[a],c=[...i.slice(0,-1),h],d=[l,...r.slice(0,a),...r.slice(a+1)];return{visible:c,overflow:d}}function $b(t){const e=U.c(13),{title:s,icon:i,active:r,onClick:o}=t,a=r?"bg-sidebar-accent text-sidebar-foreground":"text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";let l;e[0]!==a?(l=re("shrink-0 flex items-center gap-1.5 h-8 rounded-md px-2","[transition:background-color_180ms_ease,color_180ms_ease]",a),e[0]=a,e[1]=l):l=e[1];let h;e[2]!==i?(h=n.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:n.jsx(zb,{icon:i})}),e[2]=i,e[3]=h):h=e[3];let c;e[4]!==s?(c=n.jsx("span",{className:"whitespace-nowrap text-sm font-medium leading-none",children:s}),e[4]=s,e[5]=c):c=e[5];let d;return e[6]!==r||e[7]!==o||e[8]!==l||e[9]!==h||e[10]!==c||e[11]!==s?(d=n.jsxs("button",{type:"button",onClick:o,"aria-pressed":r,"aria-label":s,className:l,children:[h,c]}),e[6]=r,e[7]=o,e[8]=l,e[9]=h,e[10]=c,e[11]=s,e[12]=d):d=e[12],d}function zb(t){const e=U.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let o;return e[0]!==r?(o=n.jsx(r,{className:"size-4"}),e[0]=r,e[1]=o):o=e[1],o}if(s.kind==="url"){let r;return e[2]!==s.src?(r=n.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=r):r=e[3],r}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx($l,{className:"size-4"}),e[4]=i):i=e[4],i}function Fb(t){const e=U.c(13),{overflow:s,onSelect:i}=t,[r,o]=M.useState(!1);let a;e[0]!==i?(a=f=>{o(!1),i(f)},e[0]=i,e[1]=a):a=e[1];const l=a;let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Si,{asChild:!0,children:n.jsx("button",{type:"button",title:"More tabs","aria-label":"More tabs",className:"shrink-0 flex size-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",children:n.jsx(Cr,{className:"size-4"})})}),e[2]=h):h=e[2];let c;if(e[3]!==l||e[4]!==s){let f;e[6]!==l?(f=p=>n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>l(p.id),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md hover:bg-accent text-sm text-foreground",children:[n.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:n.jsx(Hb,{icon:p.icon})}),n.jsx("span",{className:"truncate",children:p.title})]})},p.id),e[6]=l,e[7]=f):f=e[7],c=s.map(f),e[3]=l,e[4]=s,e[5]=c}else c=e[5];let d;e[8]!==c?(d=n.jsx(wi,{align:"end",className:"w-56 p-1",children:n.jsx("ul",{className:"flex flex-col",children:c})}),e[8]=c,e[9]=d):d=e[9];let u;return e[10]!==r||e[11]!==d?(u=n.jsxs(yi,{open:r,onOpenChange:o,children:[h,d]}),e[10]=r,e[11]=d,e[12]=u):u=e[12],u}function Hb(t){const e=U.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let o;return e[0]!==r?(o=n.jsx(r,{className:"size-4"}),e[0]=r,e[1]=o):o=e[1],o}if(s.kind==="url"){let r;return e[2]!==s.src?(r=n.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=r):r=e[3],r}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx($l,{className:"size-4"}),e[4]=i):i=e[4],i}const Wb=6;function Oh(t){const e=U.c(20),{virtualMcpId:s,taskId:i}=t,r=Zt();let o;e[0]!==i||e[1]!==s?(o={virtualMcpId:s,taskId:i},e[0]=i,e[1]=s,e[2]=o):o=e[2];const{tabs:a,activeTab:l,mainOpen:h,setActiveTab:c}=xc(o);let d,u,f,p;if(e[3]!==l||e[4]!==h||e[5]!==r||e[6]!==c||e[7]!==a||e[8]!==s){const g=_u({activeTab:l,mainOpen:h}),x=S=>S.id==="automations"?g:h&&S.id===l,v=a.find(S=>x(S))?.id??null,{visible:b,overflow:C}=Ob(a,v,Wb);u=C,d=S=>{const k=a.find(P=>P.id===S),N=v===S&&h;if(Pe("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:S,tab_kind:k?.kind??null,was_active:N}),S==="automations"){const P=gu({activeTab:l,mainOpen:h});r({to:".",search:A=>({...A,main:P}),replace:!0});return}c(S)},f="flex items-center min-w-0 gap-0.5",p=b.map(S=>n.jsx($b,{title:S.title,icon:S.icon,active:x(S),onClick:()=>d(S.id)},S.id)),e[3]=l,e[4]=h,e[5]=r,e[6]=c,e[7]=a,e[8]=s,e[9]=d,e[10]=u,e[11]=f,e[12]=p}else d=e[9],u=e[10],f=e[11],p=e[12];let m;e[13]!==d||e[14]!==u?(m=u.length>0&&n.jsx(Fb,{overflow:u,onSelect:d}),e[13]=d,e[14]=u,e[15]=m):m=e[15];let _;return e[16]!==f||e[17]!==p||e[18]!==m?(_=n.jsxs("div",{className:f,children:[p,m]}),e[16]=f,e[17]=p,e[18]=m,e[19]=_):_=e[19],_}const wl=3e3,Ub=6e4;function Kb(t){const e=U.c(12),{orgSlug:s,virtualMcpId:i,branch:r,enabled:o}=t,a=o===void 0?!0:o,l=r??"";let h;e[0]!==s||e[1]!==l||e[2]!==i?(h=qp(s,i,l),e[0]=s,e[1]=l,e[2]=i,e[3]=h):h=e[3];let c;e[4]!==r||e[5]!==s||e[6]!==i?(c=()=>Ui(s,i,r),e[4]=r,e[5]=s,e[6]=i,e[7]=c):c=e[7];const d=a&&!!r;let u;return e[8]!==h||e[9]!==c||e[10]!==d?(u={queryKey:h,queryFn:c,enabled:d,refetchInterval:qb,retry:Vb,staleTime:1e3},e[8]=h,e[9]=c,e[10]=d,e[11]=u):u=e[11],gi(u)}function Vb(t,e){return!kc(e)}function qb(t){if(!kc(t.state.error))return wl;const e=t.state.fetchFailureCount;return Math.min(wl*2**e,Ub)}const Gb=new Set(["main","master"]);function Bo(t){return Gb.has(t.trim().toLowerCase())?"Publish to production":"Publish"}function Yb(t){const e=U.c(24),{baseBranch:s,disabled:i,loading:r,onPublish:o,onReview:a}=t,l=r===void 0?!1:r;let h;e[0]!==s?(h=Bo(s),e[0]=s,e[1]=h):h=e[1];const c=h;let d;e[2]!==o?(d=()=>{o()},e[2]=o,e[3]=d):d=e[3];let u;e[4]!==l?(u=l?n.jsx(Jl,{size:"xs",variant:"default"}):null,e[4]=l,e[5]=u):u=e[5];let f;e[6]!==i||e[7]!==c||e[8]!==d||e[9]!==u?(f=n.jsxs(te,{size:"sm",variant:"success",className:"rounded-r-none border-r border-success-foreground/20",disabled:i,onClick:d,children:[u,c]}),e[6]=i,e[7]=c,e[8]=d,e[9]=u,e[10]=f):f=e[10];let p;e[11]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(ao,{className:"h-3.5 w-3.5"}),e[11]=p):p=e[11];let m;e[12]!==i?(m=n.jsx(As,{asChild:!0,children:n.jsx(te,{size:"sm",variant:"success",className:"rounded-l-none px-2",disabled:i,"aria-label":"More actions",children:p})}),e[12]=i,e[13]=m):m=e[13];let _;e[14]!==a?(_=a?n.jsx(ht,{onClick:a,children:"Review"}):null,e[14]=a,e[15]=_):_=e[15];let g;e[16]!==_?(g=n.jsx(Ms,{align:"end",children:_}),e[16]=_,e[17]=g):g=e[17];let x;e[18]!==m||e[19]!==g?(x=n.jsxs(Ds,{children:[m,g]}),e[18]=m,e[19]=g,e[20]=x):x=e[20];let y;return e[21]!==x||e[22]!==f?(y=n.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[f,x]}),e[21]=x,e[22]=f,e[23]=y):y=e[23],y}class Js extends Error{constructor(e,s,i){super(e),this.step=s,this.pr=i,this.name="PublishFlowError"}step;pr}function Xb(t){const e=U.c(10),[s,i]=M.useState(0);let r;e[0]!==t?(r=h=>{h&&i(Jb),t.onOpenChange(h)},e[0]=t,e[1]=r):r=e[1];const o=r;let a;e[2]!==o||e[3]!==t||e[4]!==s?(a=t.open?n.jsx(Zb,{...t,onOpenChange:o},s):null,e[2]=o,e[3]=t,e[4]=s,e[5]=a):a=e[5];let l;return e[6]!==o||e[7]!==t.open||e[8]!==a?(l=n.jsx(Ht,{open:t.open,onOpenChange:o,children:a}),e[6]=o,e[7]=t.open,e[8]=a,e[9]=l):l=e[9],l}function Jb(t){return t+1}function Zb({onOpenChange:t,orgSlug:e,orgId:s,virtualMcpId:i,branch:r,baseBranch:o,githubConnectionId:a,owner:l,repo:h,previewUrl:c,dialogIntent:d="publish",headSha:u=null,openPullRequest:f=null,onPullRequestChanged:p,onPublished:m}){const _=Qe({connectionId:a,orgId:s,orgSlug:e}),g=f?.state==="open",x=d==="publish",y=d==="open-pr"&&!g,[v,b]=M.useState(null),[C,S]=M.useState(null),[k,N]=M.useState(!0),[P,A]=M.useState(!1),[E,j]=M.useState(""),[w,T]=M.useState(""),[D,R]=M.useState(),[I,B]=M.useState(!1),[H,W]=M.useState(!1),[z,O]=M.useState(),[V,K]=M.useState(),[Q,X]=M.useState(!1),[q,se]=M.useState(!1),[$,L]=M.useState(!1),J=M.useRef(!1);J.current||(J.current=!0,(async()=>{N(!0),R(void 0),S(null),j(""),T(""),O(void 0),K(void 0);try{const fe=y?{base:o,...u?{headSha:u}:{}}:void 0,[xe,ve]=await Promise.all([Ui(e,i,r),jc(e,i,r,fe)]);b(xe),S(ve),j(`Changes from ${xe.current??r}`),L(!0),pa(e,i,r,{status:xe,diff:ve}).then(Le=>{j(Le.title),T(Le.body)}).catch(()=>{}).finally(()=>L(!1))}catch(fe){R(fe instanceof Error?fe.message:"Failed to load changes.")}finally{N(!1)}})());const Z=So(v)??r,F=Bo(o),ne=()=>{!v||!C||(L(!0),pa(e,i,r,{status:v,diff:C}).then(fe=>{j(fe.title),T(fe.body)}).catch(()=>{}).finally(()=>L(!1)))},ie=Nc(v),de=C?Object.keys(C.diffs).length:ie,ue=y?Tc(v):Gp(v,C),_e=!k&&(x?ue:ue||y),le=_e&&_a(C),je=_e&&!_a(C)?Kp:null,Ne=()=>[E.trim(),w.trim()].filter(Boolean).join(`
|
|
308
308
|
|
|
309
309
|
`),Xe=fe=>{P||I||H||t(fe)},Et=async()=>{W(!0),K(void 0);try{const fe=Ne()||E.trim()||`Changes from ${Z}`;await Fr(e,i,r,fe),ae.success(f?`Saved changes to PR #${f.number}`:"Changes saved"),Xe(!1),await p?.()}catch(fe){K(fe instanceof Error?fe.message:"Failed to save changes")}finally{W(!1)}},Ie=async()=>{A(!0),R(void 0);let fe;try{const xe=E.trim()||`Changes from ${Z}`,ve=w.trim()||void 0,Le=Ne()||xe;if(ue)try{await Fr(e,i,r,Le)}catch(rt){throw new Js(rt instanceof Error?rt.message:"Failed to push changes","push")}try{await Up(e,i,r,o)}catch(rt){throw new Js(rt instanceof Error?rt.message:"Failed to rebase onto base","rebase")}try{fe=await na(_,{owner:l,repo:h,branch:Z,title:xe,body:ve,base:o})}catch(rt){throw new Js(rt instanceof Error?rt.message:"Failed to open pull request","open-pr")}try{await rc(_,{owner:l,repo:h,pullNumber:fe.number,commitTitle:xe})}catch(rt){throw new Js(rt instanceof Error?rt.message:"Failed to merge pull request","merge",fe)}ae.success(`Published to ${o}`),Xe(!1),S(null),j(""),T(""),await p?.(),await m?.()}catch(xe){if(xe instanceof Js&&xe.step==="merge"&&xe.pr){const ve=`Changes were pushed and PR #${xe.pr.number} is open, but merge failed: ${xe.message}`;R(ve),ae.error(ve,{action:{label:"View PR",onClick:()=>window.open(xe.pr.htmlUrl,"_blank","noopener,noreferrer")}}),await p?.();return}R(xe instanceof Error?xe.message:"Failed to publish")}finally{A(!1)}},Tt=async fe=>{try{await ga(e,i,r,[fe]),ae.success(`Discarded changes to ${fe}`),S(ve=>{if(!ve)return ve;const Le={...ve,diffs:{...ve.diffs}};return delete Le.diffs[fe],Le});const xe=await Ui(e,i,r);b(xe)}catch(xe){ae.error(xe instanceof Error?xe.message:"Failed to discard changes")}},zs=async()=>{if(C){X(!1),se(!0);try{const fe=Object.keys(C.diffs);if(fe.length===0)return;await ga(e,i,r,fe),ae.success("All changes discarded"),S(null);const xe=await Ui(e,i,r);b(xe),Xe(!1)}catch(fe){ae.error(fe instanceof Error?fe.message:"Failed to discard changes")}finally{se(!1)}}},Fs=async()=>{B(!0),O(void 0);try{const fe=E.trim()||`Changes from ${Z}`,xe=w.trim()||void 0,ve=Ne()||fe;ue&&await Fr(e,i,r,ve);const Le=await na(_,{owner:l,repo:h,branch:Z,title:fe,body:xe,base:o});ae.success(`Submitted pull request #${Le.number} for review`,{action:{label:"View on GitHub",onClick:()=>window.open(Le.htmlUrl,"_blank","noopener,noreferrer")}}),Xe(!1),await p?.()}catch(fe){O(fe instanceof Error?fe.message:"Failed to submit for review")}finally{B(!1)}};return n.jsx(Ft,{className:"top-14 left-auto right-4 flex h-[90%] max-h-[85vh] w-[90vw] max-w-[600px] translate-x-0 translate-y-0 flex-col gap-0 overflow-hidden p-0",children:n.jsxs(oo,{defaultValue:"description",className:"flex h-full flex-col gap-0",children:[n.jsxs("div",{className:"shrink-0 space-y-3 px-6 pt-5 pb-4",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:x?"Save changes":y?"Submit for review":F}),n.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[n.jsx("span",{className:"inline-block h-2.5 w-2.5 shrink-0 rounded-full bg-green-500"}),de," ",de===1?"change":"changes"," ",x?"to save":y?"in this PR":"to publish"]})]}),Q?n.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md bg-destructive/5 px-3 py-2",children:[n.jsx("span",{className:"text-xs text-destructive",children:"Discard all changes? This cannot be undone."}),n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[n.jsx(te,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>X(!1),children:"Cancel"}),n.jsxs(te,{type:"button",size:"sm",className:"h-7 bg-destructive px-2 text-xs text-destructive-foreground hover:bg-destructive/90",onClick:zs,disabled:q,children:[q?n.jsx(ge,{className:"h-3 w-3 animate-spin"}):null,"Discard all"]})]})]}):n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs(no,{className:"h-8 w-auto",variant:"pill",children:[n.jsx(ns,{value:"description",className:"px-3 text-xs",children:"Description"}),n.jsx(ns,{value:"changes",className:"px-3 text-xs",children:"Changes"})]}),de>0&&!y&&n.jsx("button",{type:"button",className:"text-xs text-muted-foreground transition-colors hover:text-destructive disabled:opacity-50",onClick:()=>X(!0),disabled:P||q||H,children:"Discard all"})]})]}),n.jsx("div",{className:"border-t"}),n.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:k?n.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-muted-foreground",children:[n.jsx(ge,{className:"h-4 w-4 animate-spin"}),n.jsx("span",{className:"text-sm",children:"Loading changes…"})]}):n.jsxs(n.Fragment,{children:[n.jsx(ni,{value:"description",className:"mt-0 px-6 py-5",children:n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("p",{className:"text-sm font-medium",children:y?"Pull request":"Commit message"}),n.jsxs("button",{type:"button",className:"flex items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground disabled:opacity-50",disabled:$||P||I||H,onClick:ne,children:[$?n.jsx(ge,{className:"h-3 w-3 animate-spin"}):n.jsx(io,{className:"h-3 w-3"}),$?"Generating…":"Regenerate"]})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx("label",{htmlFor:"publish-title",className:"text-xs font-medium text-muted-foreground",children:"Title"}),n.jsx(Ge,{id:"publish-title",value:E,onChange:fe=>j(fe.target.value),placeholder:$?"Generating…":"Commit title…",disabled:P||I||H||$,className:"text-sm"})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx("label",{htmlFor:"publish-body",className:"text-xs font-medium text-muted-foreground",children:"Description"}),n.jsx(ar,{id:"publish-body",value:w,onChange:fe=>T(fe.target.value),placeholder:$?"Generating…":"Description (optional)…",disabled:P||I||H||$,rows:5,className:"resize-none text-sm"})]}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Branch: ",n.jsx("span",{className:"font-mono",children:r}),x?n.jsxs(n.Fragment,{children:[" · ",n.jsx("span",{className:"text-foreground/80",children:g?`Commits and pushes to update open PR #${f.number}.`:"Commits and pushes to the branch without opening a pull request."})]}):n.jsxs(n.Fragment,{children:[" → ",n.jsx("span",{className:"font-mono",children:o})," · ",n.jsxs("span",{className:"text-foreground/80",children:["Submit for review keeps changes on the branch;"," ",F," squash-merges into ",o,"."]})]})]})]})}),n.jsx(ni,{value:"changes",className:"mt-0",children:n.jsx(Pc,{diff:C,onDiscardFile:Tt})})]})}),n.jsx("div",{className:"shrink-0 border-t",children:n.jsxs("button",{type:"button",className:"flex w-full items-center justify-between px-6 py-3.5 text-sm transition-colors hover:bg-muted/50 disabled:opacity-50",onClick:()=>{c&&window.open(c,"_blank","noopener,noreferrer")},disabled:!c,children:[n.jsxs("span",{className:"flex items-center gap-3",children:[n.jsx(Fu,{className:"h-4 w-4 text-muted-foreground"}),"Visit preview"]}),n.jsx(Pd,{className:"h-4 w-4 text-muted-foreground"})]})}),n.jsx("div",{className:"shrink-0 border-t px-6 py-3",children:x?n.jsxs(n.Fragment,{children:[n.jsxs(te,{type:"button",className:"w-full",onClick:Et,disabled:!_e||H,children:[H?n.jsx(ge,{className:"h-4 w-4 animate-spin"}):null,"Save changes"]}),V&&n.jsx("p",{className:"mt-2 text-xs text-destructive",children:V})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsxs(te,{type:"button",variant:"outline",className:"flex-1",onClick:Fs,disabled:!_e||I||P,children:[I?n.jsx(ge,{className:"h-4 w-4 animate-spin"}):n.jsx(Zn,{className:"h-4 w-4"}),"Submit for review"]}),n.jsx(Qb,{label:F,canPublish:le,disabledReason:je,isPublishing:P,isSubmittingForReview:I,onPublish:Ie})]}),z&&n.jsx("p",{className:"mt-2 text-xs text-destructive",children:z}),D&&n.jsx("p",{className:"mt-2 text-xs text-destructive",children:D})]})})]})})}function Qb(t){const e=U.c(14),{label:s,canPublish:i,disabledReason:r,isPublishing:o,isSubmittingForReview:a,onPublish:l}=t,h=!i||o||a;let c;e[0]!==o?(c=o?n.jsx(ge,{className:"h-4 w-4 animate-spin"}):null,e[0]=o,e[1]=c):c=e[1];let d;e[2]!==s||e[3]!==l||e[4]!==h||e[5]!==c?(d=n.jsxs(te,{type:"button",variant:"success",className:"flex-1",onClick:l,disabled:h,children:[c,s]}),e[2]=s,e[3]=l,e[4]=h,e[5]=c,e[6]=d):d=e[6];const u=d;if(!r)return u;let f;e[7]!==u?(f=n.jsx(Se,{asChild:!0,children:n.jsx("span",{className:"flex flex-1",children:u})}),e[7]=u,e[8]=f):f=e[8];let p;e[9]!==r?(p=n.jsx(we,{children:r}),e[9]=r,e[10]=p):p=e[10];let m;return e[11]!==f||e[12]!==p?(m=n.jsx(Bl,{children:n.jsxs(Ce,{children:[f,p]})}),e[11]=f,e[12]=p,e[13]=m):m=e[13],m}function ey(){return!1}function $h(t,e){ey()&&console.log(`[github-header] ${t}`,e??"")}function ty(t){if(!(t==="claiming"||t==="ready"||t==="failed"))return Lc[t].short}const sy=new Set(["failure","timed_out","cancelled","action_required"]);function iy(t){return t.status==="completed"&&sy.has(t.conclusion)}function ry(t){return t.status==="queued"||t.status==="in_progress"}function ny(t){const{lifecycle:e,branch:s,pr:i,checks:r,reviews:o,loading:a}=t;if(a)return{label:"Loading…",disabled:!0,loading:!0,variant:"outline",tooltip:"Loading branch and pull request status"};switch(e.phase){case"idle":return{label:t.claimPhase&&ty(t.claimPhase.kind)||"Starting sandbox…",disabled:!0,loading:!0,variant:"outline",tooltip:"Waiting for the sandbox daemon to come online"};case"cloning":return{label:"Cloning repo…",disabled:!0,loading:!0,variant:"outline",tooltip:"Cloning the project repository"};case"clone-failed":return{label:"Clone failed",disabled:!0,variant:"outline",tooltip:e.error||"git clone failed — see setup logs"};case"checking-out":return{label:`Switching to ${e.to}…`,disabled:!0,loading:!0,variant:"outline",tooltip:`Checking out ${e.to}`}}if(s.kind!=="ready")return{label:"Loading branch…",disabled:!0,loading:!0,variant:"outline",tooltip:"Waiting for branch metadata from the sandbox daemon"};const l=s;if(l.workingTreeDirty||l.unpushed>0)return{label:"Save changes",action:"commit-and-push",variant:"default",tooltip:"Commit and push local changes"};if($h("no local work — checking PR/sync state",{workingTreeDirty:l.workingTreeDirty,unpushed:l.unpushed,aheadOfBase:l.aheadOfBase,behindBase:l.behindBase,branch:l.branch,base:l.base,prMerged:i?.merged??null,prState:i?.state??null}),i?.merged)return!!l.headSha&&!!i.headSha&&l.headSha!==i.headSha?{label:"Continue",action:"create-pr",variant:"special",tooltip:"Open a new PR with the latest commits"}:{label:"Published",disabled:!0,variant:"outline",tooltip:`PR #${i.number} merged into ${i.base}`};if(l.aheadOfBase>0){if(i&&i.state==="closed"&&!i.merged)return{label:"Reopen",action:"reopen",variant:"default",tooltip:`Reopen PR #${i.number}`};if(!i)return{label:"Submit for review",action:"create-pr",variant:"default",tooltip:`Open a PR for ${l.branch} → ${l.base}`};if((o?.mergeableState??"unknown")==="dirty")return{label:`Sync with ${i.base}`,action:"rebase",variant:"default",tooltip:`Resolve conflicts with ${i.base} before merging`};const d=r.filter(iy).map(p=>p.name);if(d.length>0)return{label:"Fix tests",action:"fix-checks",variant:"default",tooltip:`Failing: ${d.join(", ")}`,meta:{failingChecks:d}};const u=r.filter(ry);if(u.length>0)return{label:"Running tests…",disabled:!0,loading:!0,variant:"outline",tooltip:`Waiting on ${u.length} check${u.length===1?"":"s"} to finish`};if(o?.draft)return{label:"Mark ready",action:"mark-ready",variant:"default",tooltip:"Mark draft PR ready for review"};const f=o?.unresolvedConversations??0;return f>0?{label:"Address feedback",action:"resolve-comments",variant:"default",tooltip:`${f} unresolved conversation${f===1?"":"s"}`}:o?.missingRequiredApprovals?{label:"Awaiting review",disabled:!0,variant:"outline",tooltip:"Waiting for required approvals"}:{label:Bo(i.base),action:"merge-split",variant:"success",tooltip:`Squash-merge PR #${i.number} into ${i.base}`}}return{label:"Up to date",disabled:!0,variant:"outline",tooltip:`Branch is in sync with ${l.base}`}}function oy(t,e,s){if(!e)return s??null;const i=t?.[e];if(!i)return s??null;if(s&&i[s])return s;for(const[r,o]of Object.entries(i))if(o&&Object.keys(o).length>0)return r;return s??null}const ay=6e4,ly=3e4;function cy(t){const e=U.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const i=Qe(s),r=t.prNumber??0;let o;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(o={method:"get",owner:t.owner,repo:t.repo,pullNumber:r},e[4]=t.owner,e[5]=t.repo,e[6]=r,e[7]=o):o=e[7];const a=!!t.prNumber;let l;return e[8]!==i||e[9]!==o||e[10]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:ay,refetchIntervalInBackground:!1,staleTime:ly,select:hy},e[8]=i,e[9]=o,e[10]=a,e[11]=l):l=e[11],jr(l)}function hy(t){const e=ps(t);if(!e)return null;const s=e.mergeable_state??"unknown",i=!!(e.draft??!1),r=Number(e.review_comments??0),o=s==="blocked"&&r>0?r:0;return{draft:i,mergeableState:s,unresolvedConversations:o,missingRequiredApprovals:s==="blocked"&&o===0}}const dy={label:"Loading branch…",disabled:!0,loading:!0,variant:"outline",tooltip:"Waiting for sandbox branch"};function uy({virtualMcpId:t}){const{org:e}=ke(),{data:s}=Es.useSession(),i=bt(t),{currentBranch:r,setCurrentTaskBranch:o}=Qt(),a=ds(),[l,h]=M.useState(!1),[c,d]=M.useState("publish"),[u,f]=M.useState(!1),p=M.useRef(""),m=Ts(i),_=s?.user?.id,g=Qe({connectionId:m?.connectionId??"",orgId:e.id,orgSlug:e.slug}),{lifecycle:x,branch:y,phase:v,notFound:b}=es(),C=y.kind==="ready"?y.branch:null,S=oy(i?.metadata?.sandboxMap,_,r??C),k=r??C??S??void 0,N=Kb({orgSlug:e.slug,virtualMcpId:t,branch:k??null,enabled:!!m&&!!k&&!b}),P=So(N.data)??k??null,A=mo({orgId:e.id,orgSlug:e.slug,connectionId:m?.connectionId??"",owner:m?.owner??"",repo:m?.name??"",branch:P}),E=A.data??null,j=nc({orgId:e.id,orgSlug:e.slug,connectionId:m?.connectionId??"",owner:m?.owner??"",repo:m?.name??"",prNumber:E&&E.state==="open"?E.number:null}),w=cy({orgId:e.id,orgSlug:e.slug,connectionId:m?.connectionId??"",owner:m?.owner??"",repo:m?.name??"",prNumber:E&&E.state==="open"?E.number:null}),T=Zp(y,N.data);if(!m)return null;const D=_&&P?hi(i?.metadata?.sandboxMap?.[_]?.[P]):{},R=Object.values(D),B=(R.find($=>$.sandboxProviderKind!=="user-desktop")??R[0])?.previewUrl??null,H=P?ny({lifecycle:x,branch:T,claimPhase:v,pr:E,checks:j.data??[],reviews:w.data??null,loading:A.isPending}):dy,W=JSON.stringify({label:H.label,branchKind:T.kind,workingTreeDirty:T.kind==="ready"?T.workingTreeDirty:null,gitModifiedCount:N.data?.modified.length??null,unpushed:T.kind==="ready"?T.unpushed:null,aheadOfBase:T.kind==="ready"?T.aheadOfBase:null,lifecycle:x.phase,githubHeadBranch:P});p.current!==W&&(p.current=W,$h("header button",{label:H.label,tooltip:H.tooltip,action:H.action,chatBranch:r,sandboxBranch:C,sandboxMapBranch:S,sandboxRouteBranch:k,githubHeadBranch:P,branchMeta:y,effectiveBranchMeta:T,gitStatus:N.data??null,lifecyclePhase:x.phase,prNumber:E?.number??null,prState:E?.state??null}));const z=$=>a.sendMessage({parts:[{type:"text",text:$}]}),O=a.isStreaming,V=T.kind==="ready"?T.base:"main",K=async()=>{await Promise.all([A.refetch(),N.refetch(),j.refetch(),w.refetch()])},Q=async()=>{const $=yd();await o($)},X=async $=>{if(!(!m?.connectionId||u)){f(!0);try{await rc(g,{owner:m.owner,repo:m.name,pullNumber:$}),ae.success(`Published PR #${$}`),await K(),await Q()}catch(L){ae.error(L instanceof Error?L.message:"Failed to merge pull request")}finally{f(!1)}}},q=$=>{if(!(!$||!P))switch($){case"commit-and-push":d("publish"),h(!0);return;case"create-pr":d("open-pr"),h(!0);return;case"reopen":if(O)return;E&&z(n_({prNumber:E.number}));return;case"rebase":if(O)return;z(o_({branch:P}));return;case"fix-checks":if(O)return;E&&z(l_({prNumber:E.number,failingChecks:H.meta?.failingChecks??[]}));return;case"mark-ready":if(O)return;E&&z(c_({prNumber:E.number}));return;case"resolve-comments":if(O)return;E&&z(h_({prNumber:E.number}));return;case"merge-split":return}},se=u||O;return n.jsxs(n.Fragment,{children:[n.jsx(fy,{button:H,actionBusy:se,githubActionPending:u,onActivate:q,prNumber:E?.number,prBase:E?.base,onSquashMerge:X,onReview:E?()=>{O||z(d_({prNumber:E.number}))}:void 0}),k&&n.jsx(Xb,{open:l,onOpenChange:h,orgSlug:e.slug,orgId:e.id,virtualMcpId:t,branch:k,baseBranch:V,githubConnectionId:m.connectionId??"",owner:m.owner,repo:m.name,previewUrl:B,dialogIntent:c,headSha:T.kind==="ready"?T.headSha:null,openPullRequest:E?.state==="open"?E:null,onPullRequestChanged:K,onPublished:Q})]})}function fy(t){const e=U.c(25),{button:s,actionBusy:i,githubActionPending:r}=t,o=i&&s.action!=="create-pr"&&s.action!=="commit-and-push"&&s.action!=="merge-split",a=!!s.disabled||o||r&&s.action==="merge-split",l=!!s.loading||r&&s.action==="merge-split",h=o?"Chat is running":s.tooltip??null;if(s.action==="merge-split"&&t.prNumber!=null&&t.prBase!=null){let p;e[0]!==t?(p=()=>t.onSquashMerge(t.prNumber),e[0]=t,e[1]=p):p=e[1];let m;e[2]!==a||e[3]!==l||e[4]!==t.onReview||e[5]!==t.prBase||e[6]!==p?(m=n.jsx(Yb,{baseBranch:t.prBase,disabled:a,loading:l,onPublish:p,onReview:t.onReview}),e[2]=a,e[3]=l,e[4]=t.onReview,e[5]=t.prBase,e[6]=p,e[7]=m):m=e[7];let _;return e[8]!==m||e[9]!==h?(_=n.jsx(Cl,{label:h,children:m}),e[8]=m,e[9]=h,e[10]=_):_=e[10],_}let c;e[11]!==s.action||e[12]!==t?(c=()=>{s.action&&t.onActivate(s.action)},e[11]=s.action,e[12]=t,e[13]=c):c=e[13];let d;e[14]!==l?(d=l?n.jsx(Jl,{size:"xs",variant:"default"}):null,e[14]=l,e[15]=d):d=e[15];let u;e[16]!==s.label||e[17]!==s.variant||e[18]!==a||e[19]!==c||e[20]!==d?(u=n.jsxs(te,{size:"sm",variant:s.variant,disabled:a,onClick:c,children:[d,s.label]}),e[16]=s.label,e[17]=s.variant,e[18]=a,e[19]=c,e[20]=d,e[21]=u):u=e[21];let f;return e[22]!==u||e[23]!==h?(f=n.jsx(Cl,{label:h,children:u}),e[22]=u,e[23]=h,e[24]=f):f=e[24],f}function Cl(t){const e=U.c(9),{label:s,children:i}=t;if(!s){let l;return e[0]!==i?(l=n.jsx(n.Fragment,{children:i}),e[0]=i,e[1]=l):l=e[1],l}let r;e[2]!==i?(r=n.jsx(Se,{asChild:!0,children:n.jsx("span",{children:i})}),e[2]=i,e[3]=r):r=e[3];let o;e[4]!==s?(o=n.jsx(we,{children:s}),e[4]=s,e[5]=o):o=e[5];let a;return e[6]!==r||e[7]!==o?(a=n.jsx(Bl,{children:n.jsxs(Ce,{children:[r,o]})}),e[6]=r,e[7]=o,e[8]=a):a=e[8],a}function zh(t){const e=U.c(4),{virtualMcp:s,inline:i}=t,r=i===void 0?!1:i;if(!Ts(s))return null;let a;e[0]!==s.id?(a=n.jsx(uy,{virtualMcpId:s.id}),e[0]=s.id,e[1]=a):a=e[1];const l=a;if(r)return l;let h;return e[2]!==l?(h=n.jsx(rn.Right,{children:l}),e[2]=l,e[3]=h):h=e[3],h}function my(t,e){const s=U.c(34),i=Fl(),r=M.useSyncExternalStore(i.threads.subscribe,i.threads.get),o=M.useSyncExternalStore(i.threadsStatus.subscribe,i.threadsStatus.get);let a;s[0]!==t||s[1]!==r?(a=t?r.find(v=>v.id===t)??null:null,s[0]=t,s[1]=r,s[2]=a):a=s[2];const l=a,[h,c]=M.useState(void 0);let d;s[3]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{c(void 0)},s[3]=d):d=s[3];let u;s[4]!==t?(u=[t],s[4]=t,s[5]=u):u=s[5],M.useEffect(d,u);let f,p;s[6]!==h||s[7]!==t||s[8]!==l||s[9]!==i||s[10]!==o.kind?(f=()=>{t&&(l||o.kind!=="loading"&&h===void 0&&(c("pending"),i.fetchThread(t).then(v=>{c(v)})))},p=[t,l,o.kind,h,i],s[6]=h,s[7]=t,s[8]=l,s[9]=i,s[10]=o.kind,s[11]=f,s[12]=p):(f=s[11],p=s[12]),M.useEffect(f,p);let m;s[13]!==i||s[14]!==e?(m={mutationFn:async v=>i.create({id:v,virtual_mcp_id:e})},s[13]=i,s[14]=e,s[15]=m):m=s[15];const _=xr(m);let g,x;if(s[16]!==_||s[17]!==h||s[18]!==t||s[19]!==l||s[20]!==o.kind?(g=()=>{t&&(l||h===null&&o.kind!=="loading"&&(_.isPending||_.variables!==t&&_.mutate(t)))},x=[t,l,h,o.kind,_],s[16]=_,s[17]=h,s[18]=t,s[19]=l,s[20]=o.kind,s[21]=g,s[22]=x):(g=s[21],x=s[22]),M.useEffect(g,x),!t){let v;return s[23]===Symbol.for("react.memo_cache_sentinel")?(v={status:"ready",task:null},s[23]=v):v=s[23],v}if(l){let v;return s[24]!==l?(v={status:"ready",task:l},s[24]=l,s[25]=v):v=s[25],v}if(h&&typeof h=="object"){let v;return s[26]!==h?(v={status:"ready",task:h},s[26]=h,s[27]=v):v=s[27],v}if(_.data){let v;return s[28]!==_.data?(v={status:"ready",task:_.data},s[28]=_.data,s[29]=v):v=s[29],v}if(_.isError){let v;return s[30]!==_.error?(v={status:"error",error:_.error},s[30]=_.error,s[31]=v):v=s[31],v}if(_.isPending||o.kind!=="loading"){let v;return s[32]===Symbol.for("react.memo_cache_sentinel")?(v={status:"creating"},s[32]=v):v=s[32],v}let y;return s[33]===Symbol.for("react.memo_cache_sentinel")?(y={status:"loading"},s[33]=y):y=s[33],y}const Ss=M.createContext(null);function Io(){return M.use(Ss)}function kl(t){const e=U.c(6),{children:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Something went wrong loading the chat. Try refreshing."}),e[0]=i):i=e[0];let r;e[1]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(Ae.Skeleton,{}),e[1]=r):r=e[1];let o;e[2]!==s?(o=s??n.jsx(Ql,{}),e[2]=s,e[3]=o):o=e[3];let a;return e[4]!==o?(a=n.jsx(Mt,{fallback:i,children:n.jsx(M.Suspense,{fallback:r,children:o})}),e[4]=o,e[5]=a):a=e[5],a}function jl(t){const e=U.c(3),{onNewTaskRef:s,createNewTask:i}=t;let r;return e[0]!==i||e[1]!==s?(r=()=>(s.current=i,()=>{s.current=null}),e[0]=i,e[1]=s,e[2]=r):r=e[2],M.useLayoutEffect(r),null}function py(t){const e=U.c(27),{onOpenSidebar:s,virtualMcpId:i,taskId:r,mainOpen:o,onToggleMain:a,onNewTask:l,entity:h,hasActiveGithubRepo:c}=t;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(au,{size:20}),e[0]=d):d=e[0];let u;e[1]!==s?(u=n.jsx("button",{type:"button",onClick:s,className:"flex size-8 shrink-0 items-center justify-center rounded-md text-foreground/60 hover:bg-accent hover:text-foreground transition-colors","aria-label":"Open menu",children:d}),e[1]=s,e[2]=u):u=e[2];let f;e[3]!==r||e[4]!==i?(f=n.jsx("div",{className:"flex-1 min-w-0 overflow-x-auto [scrollbar-width:none]",children:n.jsx(Oh,{virtualMcpId:i,taskId:r})}),e[3]=r,e[4]=i,e[5]=f):f=e[5];let p;e[6]!==h||e[7]!==c?(p=h&&c?n.jsx(zh,{virtualMcp:h,inline:!0}):null,e[6]=h,e[7]=c,e[8]=p):p=e[8];const m=!o,_=o?"text-foreground/60 hover:bg-accent hover:text-foreground":"bg-accent text-foreground";let g;e[9]!==_?(g=re("flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",_),e[9]=_,e[10]=g):g=e[10];let x;e[11]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(Ol,{size:16}),e[11]=x):x=e[11];let y;e[12]!==a||e[13]!==m||e[14]!==g?(y=n.jsx("button",{type:"button",onClick:a,"aria-pressed":m,className:g,title:"Chat",children:x}),e[12]=a,e[13]=m,e[14]=g,e[15]=y):y=e[15];let v;e[16]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(yr,{size:16}),e[16]=v):v=e[16];let b;e[17]!==l?(b=n.jsx("button",{type:"button",onClick:l,className:"flex size-7 shrink-0 items-center justify-center rounded-md text-foreground/60 hover:bg-accent hover:text-foreground transition-colors",title:"New task",children:v}),e[17]=l,e[18]=b):b=e[18];let C;e[19]!==b||e[20]!==p||e[21]!==y?(C=n.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[p,y,b]}),e[19]=b,e[20]=p,e[21]=y,e[22]=C):C=e[22];let S;return e[23]!==C||e[24]!==u||e[25]!==f?(S=n.jsxs("div",{className:"shrink-0 flex items-center gap-1 px-2 h-12 bg-background border-b border-border",children:[u,f,C]}),e[23]=C,e[24]=u,e[25]=f,e[26]=S):S=e[26],S}function Nl(t){const e=U.c(24),{virtualMcpId:s,hasActiveGithubRepo:i,sandboxMap:r,children:o}=t,{org:a}=ke(),{currentBranch:l}=Qt(),{data:h}=Es.useSession(),c=h?.user?.id;let d;e[0]!==a.id||e[1]!==a.slug?(d={connectionId:hs,orgId:a.id,orgSlug:a.slug},e[0]=a.id,e[1]=a.slug,e[2]=d):d=e[2];const u=Qe(d),{mutate:f}=qn(u);let p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p=new Set,e[3]=p):p=e[3];const m=M.useRef(p);let _,g;e[4]!==l||e[5]!==i||e[6]!==r||e[7]!==f||e[8]!==c||e[9]!==s?(_=()=>{if(!i||!c||!l)return;const N=hi(r?.[c]?.[l]);if(Object.keys(N).length>0){m.current.add(l);return}m.current.has(l)||(m.current.add(l),f({virtualMcpId:s,branch:l},{onError:_y}))},g=[i,c,l,r,s,f],e[4]=l,e[5]=i,e[6]=r,e[7]=f,e[8]=c,e[9]=s,e[10]=_,e[11]=g):(_=e[10],g=e[11]),M.useEffect(_,g);const x=Sd(s,l??void 0);let y;e[12]!==l||e[13]!==r||e[14]!==c?(y=c&&l?hi(r?.[c]?.[l]):{},e[12]=l,e[13]=r,e[14]=c,e[15]=y):y=e[15];const v=y;let b;e[16]!==v||e[17]!==x?(b=Object.keys(v).length>0||x,e[16]=v,e[17]=x,e[18]=b):b=e[18];const C=b,S=l??null;let k;return e[19]!==o||e[20]!==C||e[21]!==S||e[22]!==s?(k=n.jsx(wm,{virtualMcpId:s,branch:S,enabled:C,children:o}),e[19]=o,e[20]=C,e[21]=S,e[22]=s,e[23]=k):k=e[23],k}function _y(t){console.error("[auto-start-vm] failed:",t)}function gy(){const t=U.c(116),e=Ml(),s=Zt(),{org:i}=ke();lu(i.slug);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={strict:!1},t[0]=r):r=t[0];const o=El(r),a=o.org??"";let l;t[1]===Symbol.for("react.memo_cache_sentinel")?(l={strict:!1},t[1]=l):l=t[1];const h=Vn(l);let c;t[2]!==i.id||t[3]!==h.virtualmcpid?(c=h.virtualmcpid??Gn(i.id).id,t[2]=i.id,t[3]=h.virtualmcpid,t[4]=c):c=t[4];const d=c,u=my(o.taskId??"",d),f=bt(d),p=f?.metadata?.ui?.layout??null;let m;t[5]!==p?(m=p?{defaultMainView:p.defaultMainView??null,chatDefaultOpen:p.chatDefaultOpen??null}:null,t[5]=p,t[6]=m):m=t[6];const _=m;let g;t[7]!==f?(g=f&&Ts(f),t[7]=f,t[8]=g):g=t[8];const x=!!g;let y;t[9]!==a||t[10]!==d?(y={virtualMcpId:d,orgSlug:a,isAgentRoute:!0},t[9]=a,t[10]=d,t[11]=y):y=t[11];const v=If(_,y),{setOpenMobile:b,openMobile:C}=zd(),S=b,k=M.useRef(null);let N,P;t[12]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{const X=q=>{Od(q)&&q.shiftKey&&q.code==="KeyS"&&!q.repeat&&(q.preventDefault(),k.current?.())};return document.addEventListener("keydown",X),()=>document.removeEventListener("keydown",X)},P=[],t[12]=N,t[13]=P):(N=t[12],P=t[13]),M.useEffect(N,P);const A=d;let E;t[14]!==f||t[15]!==d?(E={virtualMcpId:d,entity:f},t[14]=f,t[15]=d,t[16]=E):E=t[16];const j=E;if(u.status==="creating"||u.status==="loading"){let X;t[17]===Symbol.for("react.memo_cache_sentinel")?(X=n.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:n.jsxs("div",{className:"flex h-full items-center justify-center bg-background card-shadow rounded-[0.75rem] text-sm text-muted-foreground",children:[n.jsx(ge,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[17]=X):X=t[17];let q;return t[18]!==j?(q=n.jsx(Ss,{value:j,children:X}),t[18]=j,t[19]=q):q=t[19],q}if(u.status==="error"){let X;t[20]===Symbol.for("react.memo_cache_sentinel")?(X=n.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[20]=X):X=t[20];let q;t[21]!==u.error.message?(q=n.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:n.jsxs("div",{className:"flex flex-col h-full items-center justify-center gap-2 bg-background card-shadow rounded-[0.75rem] p-8 text-sm",children:[X,n.jsx("div",{className:"text-muted-foreground",children:u.error.message})]})}),t[21]=u.error.message,t[22]=q):q=t[22];let se;return t[23]!==j||t[24]!==q?(se=n.jsx(Ss,{value:j,children:q}),t[23]=j,t[24]=q,t[25]=se):se=t[25],se}if(!f){let X;t[26]===Symbol.for("react.memo_cache_sentinel")?(X=n.jsx(bi,{size:48,className:"text-muted-foreground"}),t[26]=X):X=t[26];const q=`The agent "${d}" does not exist in this organization.`;let se;t[27]!==s||t[28]!==a?(se=n.jsx(te,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:a}}),children:"Go to organization home"}),t[27]=s,t[28]=a,t[29]=se):se=t[29];let $;t[30]!==q||t[31]!==se?($=n.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:n.jsx("div",{className:"flex flex-col h-full bg-background overflow-hidden card-shadow rounded-[0.75rem]",children:n.jsx(Zi,{image:X,title:"Agent not found",description:q,actions:se})})}),t[30]=q,t[31]=se,t[32]=$):$=t[32];let L;return t[33]!==j||t[34]!==$?(L=n.jsx(Ss,{value:j,children:$}),t[33]=j,t[34]=$,t[35]=L):L=t[35],L}if(e){let X;t[36]===Symbol.for("react.memo_cache_sentinel")?(X=n.jsx(Hd,{className:"sr-only",children:"Navigation"}),t[36]=X):X=t[36];let q;t[37]!==S?(q=n.jsxs(Wd,{side:"left",hideCloseButton:!0,className:"w-[calc(100vw-3rem)] sm:max-w-md! p-0",children:[X,n.jsx("div",{className:"flex h-full",children:n.jsx("div",{className:"w-full bg-sidebar flex flex-col overflow-y-auto group/sidebar","data-state":"expanded",children:n.jsx($d,{onClose:()=>S(!1)})})})]}),t[37]=S,t[38]=q):q=t[38];let se;t[39]!==C||t[40]!==S||t[41]!==q?(se=n.jsx(Ud,{open:C,onOpenChange:S,children:q}),t[39]=C,t[40]=S,t[41]=q,t[42]=se):se=t[42];const $=se,L=u.status==="ready"?u.task:null,J=f?.metadata?.sandboxMap;let Z;t[43]!==v.createNewTask?(Z=n.jsx(jl,{onNewTaskRef:k,createNewTask:v.createNewTask}),t[43]=v.createNewTask,t[44]=Z):Z=t[44];let F;t[45]!==S?(F=()=>S(!0),t[45]=S,t[46]=F):F=t[46];let ne;t[47]!==A||t[48]!==f||t[49]!==x||t[50]!==v.createNewTask||t[51]!==v.mainOpen||t[52]!==v.taskId||t[53]!==v.toggleMain||t[54]!==F?(ne=n.jsx(py,{onOpenSidebar:F,virtualMcpId:A,taskId:v.taskId,mainOpen:v.mainOpen,onToggleMain:v.toggleMain,onNewTask:v.createNewTask,entity:f,hasActiveGithubRepo:x}),t[47]=A,t[48]=f,t[49]=x,t[50]=v.createNewTask,t[51]=v.mainOpen,t[52]=v.taskId,t[53]=v.toggleMain,t[54]=F,t[55]=ne):ne=t[55];let ie;t[56]===Symbol.for("react.memo_cache_sentinel")?(ie=n.jsx(Ae.Skeleton,{}),t[56]=ie):ie=t[56];let de;t[57]!==A||t[58]!==v.mainOpen||t[59]!==v.taskId?(de=n.jsx(M.Suspense,{fallback:ie,children:n.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:v.mainOpen?n.jsx(Mt,{fallback:n.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Something went wrong. Try refreshing."}),children:n.jsx(M.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(Lh,{taskId:v.taskId,virtualMcpId:A})})}):n.jsx(kl,{})})}),t[57]=A,t[58]=v.mainOpen,t[59]=v.taskId,t[60]=de):de=t[60];let ue;t[61]!==v.taskId||t[62]!==ne||t[63]!==de?(ue=n.jsxs(Ae.ActiveTaskProvider,{taskId:v.taskId,children:[ne,de]},v.taskId),t[61]=v.taskId,t[62]=ne,t[63]=de,t[64]=ue):ue=t[64];let _e;t[65]!==x||t[66]!==$||t[67]!==J||t[68]!==Z||t[69]!==ue||t[70]!==d?(_e=n.jsxs(Nl,{virtualMcpId:d,hasActiveGithubRepo:x,sandboxMap:J,children:[Z,ue,$]}),t[65]=x,t[66]=$,t[67]=J,t[68]=Z,t[69]=ue,t[70]=d,t[71]=_e):_e=t[71];let le;t[72]!==A||t[73]!==L||t[74]!==_e?(le=n.jsx("div",{className:"flex flex-col flex-1 min-w-0 bg-background min-h-0",children:n.jsx(Ae.Provider,{virtualMcpId:A,task:L,children:_e},A)}),t[72]=A,t[73]=L,t[74]=_e,t[75]=le):le=t[75];let je;return t[76]!==j||t[77]!==le?(je=n.jsx(Ss,{value:j,children:le}),t[76]=j,t[77]=le,t[78]=je):je=t[78],je}let w;t[79]!==v.chatOpen||t[80]!==v.createNewTask||t[81]!==v.toggleChat?(w=n.jsx(rn.Toggles,{children:n.jsx(Lb,{chatOpen:v.chatOpen,toggleChat:v.toggleChat,onNewTask:v.createNewTask})}),t[79]=v.chatOpen,t[80]=v.createNewTask,t[81]=v.toggleChat,t[82]=w):w=t[82];const T=u.status==="ready"?u.task:null,D=f?.metadata?.sandboxMap;let R;t[83]!==v.taskId||t[84]!==d?(R=n.jsx(rn.Tabs,{children:n.jsx(Oh,{virtualMcpId:d,taskId:v.taskId})}),t[83]=v.taskId,t[84]=d,t[85]=R):R=t[85];let I;t[86]!==v.createNewTask?(I=n.jsx(jl,{onNewTaskRef:k,createNewTask:v.createNewTask}),t[86]=v.createNewTask,t[87]=I):I=t[87];let B;t[88]!==f?(B=n.jsx(zh,{virtualMcp:f}),t[88]=f,t[89]=B):B=t[89];let H;t[90]===Symbol.for("react.memo_cache_sentinel")?(H=n.jsx(Ae.Skeleton,{}),t[90]=H):H=t[90];let W;t[91]===Symbol.for("react.memo_cache_sentinel")?(W=n.jsx(kl,{}),t[91]=W):W=t[91];let z;t[92]!==v.chatOpen||t[93]!==v.mainOpen||t[94]!==v.taskId||t[95]!==d?(z=n.jsx(M.Suspense,{fallback:H,children:n.jsx(Ib,{virtualMcpId:d,taskId:v.taskId,chatOpen:v.chatOpen,mainOpen:v.mainOpen,chatContent:W})}),t[92]=v.chatOpen,t[93]=v.mainOpen,t[94]=v.taskId,t[95]=d,t[96]=z):z=t[96];let O;t[97]!==v.taskId||t[98]!==B||t[99]!==z?(O=n.jsxs(Ae.ActiveTaskProvider,{taskId:v.taskId,children:[B,z]},v.taskId),t[97]=v.taskId,t[98]=B,t[99]=z,t[100]=O):O=t[100];let V;t[101]!==x||t[102]!==D||t[103]!==R||t[104]!==I||t[105]!==O||t[106]!==d?(V=n.jsxs(Nl,{virtualMcpId:d,hasActiveGithubRepo:x,sandboxMap:D,children:[R,I,O]}),t[101]=x,t[102]=D,t[103]=R,t[104]=I,t[105]=O,t[106]=d,t[107]=V):V=t[107];let K;t[108]!==A||t[109]!==T||t[110]!==V?(K=n.jsx(Ae.Provider,{virtualMcpId:A,task:T,children:V},A),t[108]=A,t[109]=T,t[110]=V,t[111]=K):K=t[111];let Q;return t[112]!==j||t[113]!==K||t[114]!==w?(Q=n.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:n.jsxs(Ss,{value:j,children:[w,K]})}),t[112]=j,t[113]=K,t[114]=w,t[115]=Q):Q=t[115],Q}function vy(){const t=U.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(M.Suspense,{fallback:n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(gy,{})}),t[0]=e):e=t[0],e}const jS=Object.freeze(Object.defineProperty({__proto__:null,default:vy,useInsetContext:Io},Symbol.toStringTag,{value:"Module"}));export{sS as $,fS as A,yS as B,gS as C,bS as D,uS as E,dS as F,X0 as G,Ax as H,Dh as I,lS as J,cS as K,CS as L,xS as M,hc as N,vS as O,hm as P,kS as Q,cm as R,dm as S,Z0 as T,mc as U,Q0 as V,iS as W,tS as X,s_ as Y,t_ as Z,eS as _,G0 as a,$h as a0,qp as a1,Ui as a2,jS as a3,aS as b,po as c,_o as d,oa as e,Bc as f,Tx as g,xo as h,Nr as i,gc as j,lm as k,dc as l,hS as m,mS as n,Mx as o,pS as p,Ri as q,cc as r,J0 as s,oi as t,Y0 as u,SS as v,_S as w,Hx as x,wS as y,oS as z};
|