decocms 2.339.0 → 2.339.1
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-CJ_imV3m.js → AlertCircle-B_YmhCpp.js} +1 -1
- package/dist/client/assets/{Archive-WVJsBJzo.js → Archive-DZ9aGmbx.js} +1 -1
- package/dist/client/assets/{ArrowNarrowLeft-DEGnbMa_.js → ArrowNarrowLeft-BWm-AMm4.js} +1 -1
- package/dist/client/assets/{ArrowUpRight-B2qmWVMR.js → ArrowUpRight-BjQLVEJQ.js} +1 -1
- package/dist/client/assets/{Check-Cvjf7hnA.js → Check-DbV-F2MF.js} +1 -1
- package/dist/client/assets/{CheckCircle-vPV0tRYO.js → CheckCircle-CPcc_HzK.js} +1 -1
- package/dist/client/assets/{ChevronDown-DIoOnkaF.js → ChevronDown-CFuI54BG.js} +1 -1
- package/dist/client/assets/{ChevronRight-DAr6G33f.js → ChevronRight-DSjqApfg.js} +1 -1
- package/dist/client/assets/{ChevronUp-CJpV7oTT.js → ChevronUp-Do0GES9S.js} +1 -1
- package/dist/client/assets/{Container-BWQIoJze.js → Container-DnQ-V0vf.js} +1 -1
- package/dist/client/assets/{DotsVertical-BG7rmvwp.js → DotsVertical-CBu0rfx5.js} +1 -1
- package/dist/client/assets/{Key01-etdhr-4G.js → Key01-C7u5tKD0.js} +1 -1
- package/dist/client/assets/{LayoutLeft-C8PVq2Qs.js → LayoutLeft-DcnMGouH.js} +1 -1
- package/dist/client/assets/{LinkExternal01-g1vEyCDg.js → LinkExternal01-BJS4Dy91.js} +1 -1
- package/dist/client/assets/{Lock01-B762FFJA.js → Lock01-C9MGcsTR.js} +1 -1
- package/dist/client/assets/{Palette-DvfFImfG.js → Palette-B5PaE3Rq.js} +1 -1
- package/dist/client/assets/{Play-DMF3Xc70.js → Play-B8BnOy3i.js} +1 -1
- package/dist/client/assets/{Plus-BgmWF0s6.js → Plus-DpifZcWW.js} +1 -1
- package/dist/client/assets/{RefreshCcw01-Bv_ZYBkO.js → RefreshCcw01-D202N5g5.js} +1 -1
- package/dist/client/assets/{SearchMd-CkzE05NA.js → SearchMd-B-JvZSXk.js} +1 -1
- package/dist/client/assets/{Settings02-MFm4VQgV.js → Settings02-BZ4NUngl.js} +1 -1
- package/dist/client/assets/{Shield01-szDq2vKW.js → Shield01-y2jg0f2l.js} +1 -1
- package/dist/client/assets/{Star01-B7uWtuMN.js → Star01-BGA57956.js} +1 -1
- package/dist/client/assets/{Sun-Bk40YXd5.js → Sun-BnzHtNJd.js} +1 -1
- package/dist/client/assets/{Tool01-CBI3b59M.js → Tool01-R-t45iSM.js} +1 -1
- package/dist/client/assets/{Trash01-_MTXzWmC.js → Trash01-MANg2hp9.js} +1 -1
- package/dist/client/assets/{Upload01-CbbVgbGf.js → Upload01-D1-e29YJ.js} +1 -1
- package/dist/client/assets/{User01-CrRc-Y_s.js → User01-BjiH1weJ.js} +1 -1
- package/dist/client/assets/{Users01-DC9jbA8R.js → Users01-BldrmsRS.js} +1 -1
- package/dist/client/assets/{Users03-DRUOncwe.js → Users03-D7eVSXn9.js} +1 -1
- package/dist/client/assets/{X-CLTZLxw4.js → X-PJ44Wfoc.js} +1 -1
- package/dist/client/assets/{XCircle-CCY5DUN0.js → XCircle-DdlmiVIz.js} +1 -1
- package/dist/client/assets/{XClose-DcZl70IB.js → XClose-o95wsJTh.js} +1 -1
- package/dist/client/assets/{Zap-DiQs7uBH.js → Zap-B0TzxL73.js} +1 -1
- package/dist/client/assets/{ZapSquare-Yqh6kfEb.js → ZapSquare-CJBiolSd.js} +1 -1
- package/dist/client/assets/{accordion-CVzn69yt.js → accordion-BhMqpwsw.js} +1 -1
- package/dist/client/assets/{agent-icon-CiDXBIEY.js → agent-icon-CfsoOk3Y.js} +1 -1
- package/dist/client/assets/{agents-list-DxmnrYMM.js → agents-list-CnGliBYW.js} +1 -1
- package/dist/client/assets/{ai-providers-BKi2qyCb.js → ai-providers-m2e8f-Ej.js} +1 -1
- package/dist/client/assets/{alert-dialog-D44pjeug.js → alert-dialog-Bpf8lBsH.js} +1 -1
- package/dist/client/assets/{auth-catchall-DrNzd91I.js → auth-catchall-CmQTqipz.js} +1 -1
- package/dist/client/assets/{auth-split-layout-DzsU1Nwl.js → auth-split-layout-CVLWYo31.js} +1 -1
- package/dist/client/assets/{automation-list-row-B_c98AAD.js → automation-list-row-3GgRNA4X.js} +1 -1
- package/dist/client/assets/{automations-DNXAyDll.js → automations-Dh7iQg5R.js} +1 -1
- package/dist/client/assets/{avatar-Bai1aI8K.js → avatar-Cx7XLB5Y.js} +1 -1
- package/dist/client/assets/{badge-DShCeQ44.js → badge-DRrnUUdf.js} +1 -1
- package/dist/client/assets/{brand-context-DMTJ4eoZ.js → brand-context-B-H-gI0d.js} +1 -1
- package/dist/client/assets/{card-Dl5Tqdaj.js → card-pSH7d2d1.js} +1 -1
- package/dist/client/assets/{chat-context-DpzF1H11.js → chat-context-CwbmMG2J.js} +1 -1
- package/dist/client/assets/{checkbox-B_0TJdoc.js → checkbox-C7NHZ7qY.js} +1 -1
- package/dist/client/assets/{collection-detail-BYQWTuZi.js → collection-detail-DWR25Zoe.js} +1 -1
- package/dist/client/assets/{collection-display-button-BWyf4_zw.js → collection-display-button-Byakiqrw.js} +1 -1
- package/dist/client/assets/{collection-search-BBny54WG.js → collection-search-BqHGaRq0.js} +1 -1
- package/dist/client/assets/{collection-search-CbXrUWvb.js → collection-search-D-c8AzQQ.js} +1 -1
- package/dist/client/assets/{collection-table-wrapper-DQHk7Sbl.js → collection-table-wrapper-BCmO0Ear.js} +1 -1
- package/dist/client/assets/{collection-tabs-BLwNPyei.js → collection-tabs-yJ1sNpjE.js} +1 -1
- package/dist/client/assets/{collections-urQHq5jP.js → collections-Ca0YTtNu.js} +1 -1
- package/dist/client/assets/{command-BPMvKg3I.js → command-BJgDzZ7y.js} +1 -1
- package/dist/client/assets/{connection-card-BxZAR29n.js → connection-card-DCCJSa01.js} +1 -1
- package/dist/client/assets/{connection-detail-M97K6OtH.js → connection-detail-BGGXBs5h.js} +1 -1
- package/dist/client/assets/{connection-form-helpers-DPuB-IPo.js → connection-form-helpers-BzCkC1Te.js} +1 -1
- package/dist/client/assets/{connections-C8hNMr0j.js → connections-uw4IEaQ9.js} +1 -1
- package/dist/client/assets/{constants-CqClUFzZ.js → constants-CA7gkjCv.js} +1 -1
- package/dist/client/assets/{constants-Cz6MSKkF.js → constants-VqUK6eVM.js} +1 -1
- package/dist/client/assets/{decopilot-sse-pool-B4ohEQ_q.js → decopilot-sse-pool-D2FvP5mN.js} +1 -1
- package/dist/client/assets/{dialog-BvOKPwhc.js → dialog-s2De3tVa.js} +1 -1
- package/dist/client/assets/{domain-settings-DSs6JU9l.js → domain-settings-EruN4y8r.js} +1 -1
- package/dist/client/assets/{drawer-CWSEhQ-2.js → drawer-DctzDnYu.js} +1 -1
- package/dist/client/assets/{dropdown-menu-CtHZqdUp.js → dropdown-menu-DlP8Zgk8.js} +1 -1
- package/dist/client/assets/{dynamic-plugin-layout-CgScXPMz.js → dynamic-plugin-layout-C2vqr7l3.js} +1 -1
- package/dist/client/assets/{empty-state-C4_UrTxv.js → empty-state-JrG6K6vM.js} +1 -1
- package/dist/client/assets/{empty-state-DAuMay-T.js → empty-state-_VG9orFz.js} +1 -1
- package/dist/client/assets/{extract-connection-data-DH8BDq4V.js → extract-connection-data-DYLiTjJW.js} +1 -1
- package/dist/client/assets/{features-CFldbpqu.js → features-C5F_G4aN.js} +1 -1
- package/dist/client/assets/{file-explorer-ENlS4PGn.js → file-explorer-D4u2-UUk.js} +1 -1
- package/dist/client/assets/{form-CHsQnogB.js → form-RSI6Xm7k.js} +1 -1
- package/dist/client/assets/{general-riyR-aVZ.js → general-BaRInTAo.js} +1 -1
- package/dist/client/assets/{hooks-BMwOK54h.js → hooks-Bd6LwLvD.js} +1 -1
- package/dist/client/assets/{index-DpcJ3A4O.js → index-9PR-X1Vz.js} +1 -1
- package/dist/client/assets/{index-P661SBTh.js → index-B8rABvK_.js} +1 -1
- package/dist/client/assets/{index-_kJX6VkK.js → index-B9ZyEnvi.js} +1 -1
- package/dist/client/assets/{index-bn_fkVx-.js → index-BCY8PZey.js} +1 -1
- package/dist/client/assets/{index-BzDY-tSP.js → index-Bc6TMNkC.js} +1 -1
- package/dist/client/assets/{index-DaY9yoJe.js → index-BqFKFoUR.js} +1 -1
- package/dist/client/assets/index-C0o1G0Xk.js +1 -0
- package/dist/client/assets/{index-BEvDmdoe.js → index-Cntm0Edj.js} +1 -1
- package/dist/client/assets/{index-BrmShR68.js → index-CvimJi4c.js} +1 -1
- package/dist/client/assets/{index-CyT5Gmzn.js → index-D6QjTTqJ.js} +2 -2
- package/dist/client/assets/{index-DDwZHZ9M.js → index-D7A87uI3.js} +1 -1
- package/dist/client/assets/{index-C_BksVU1.js → index-DMHsj289.js} +1 -1
- package/dist/client/assets/{index-BYLBJUl2.js → index-DaX_ohCq.js} +1 -1
- package/dist/client/assets/{index-DEVJtPY-.js → index-DeRB6kmx.js} +1 -1
- package/dist/client/assets/{index-Dqo9jLHq.js → index-DlMYwR85.js} +1 -1
- package/dist/client/assets/{index-kMm-oYDI.js → index-DrCnDXy3.js} +1 -1
- package/dist/client/assets/index-KAiEcabG.css +1 -0
- package/dist/client/assets/{index-6GEZGWOJ.js → index-LCs5OReL.js} +121 -20
- package/dist/client/assets/{infiniteQueryObserver-hQjRS94o.js → infiniteQueryObserver-Bw9VTL3u.js} +1 -1
- package/dist/client/assets/{input-D2jK2nww.js → input-ByXVDv8X.js} +1 -1
- package/dist/client/assets/{integration-icon-CLJQqC-I.js → integration-icon-ChuHi82q.js} +1 -1
- package/dist/client/assets/{label-DBNWSOSa.js → label-DpsSn4NO.js} +1 -1
- package/dist/client/assets/{layout-Bmq02Jn1.js → layout-sOw82kEj.js} +1 -1
- package/dist/client/assets/{lean-canvas-recruit-modal-B5lshz4v.js → lean-canvas-recruit-modal-DFOchrjh.js} +1 -1
- package/dist/client/assets/{login-0Euu2LZl.js → login-DtAEPz9t.js} +1 -1
- package/dist/client/assets/{members-BI5YjhIC.js → members-DKbYsDoo.js} +1 -1
- package/dist/client/assets/{monaco-editor-DawE8dWK.js → monaco-editor-DWJrfKkz.js} +1 -1
- package/dist/client/assets/{monitoring-stats-row-BiXt3xBt.js → monitoring-stats-row-DplfAe6h.js} +1 -1
- package/dist/client/assets/{oauth-callback-Oc-DDbq6.js → oauth-callback-Cgnr_XvI.js} +1 -1
- package/dist/client/assets/{oauth-callback-ai-provider-BRNA_FKw.js → oauth-callback-ai-provider-DV5FqVIU.js} +1 -1
- package/dist/client/assets/{onboarding-Bi2iam8V.js → onboarding-CLQ6n6zs.js} +1 -1
- package/dist/client/assets/{org-layout-SbyEeX0q.js → org-layout-D0zs0USI.js} +1 -1
- package/dist/client/assets/{org-plugin-layout-BL1Hdhdg.js → org-plugin-layout-5HyAYuOZ.js} +1 -1
- package/dist/client/assets/{pair-C0WTHF98.js → pair-w9BJ67Dj.js} +1 -1
- package/dist/client/assets/{plugin-empty-state-oS6INCp7.js → plugin-empty-state-Dt2wnLHi.js} +1 -1
- package/dist/client/assets/{plugin-header-0fVXz7lN.js → plugin-header-BPZM6LHe.js} +1 -1
- package/dist/client/assets/{plugin-layout-Cc2aTWRe.js → plugin-layout-BtFVz7Xk.js} +1 -1
- package/dist/client/assets/{popover-C42-PtSd.js → popover-B2weHany.js} +1 -1
- package/dist/client/assets/{profile-uqpxmonW.js → profile-WGLhmdJg.js} +1 -1
- package/dist/client/assets/{project-app-view-C1aTqtaY.js → project-app-view-0puAiHFx.js} +1 -1
- package/dist/client/assets/registry-l74KwwmM.js +2 -0
- package/dist/client/assets/{registry-layout-CYWM9kwe.js → registry-layout-BZN3bST_.js} +1 -1
- package/dist/client/assets/{required-auth-layout-BtGqP7ks.js → required-auth-layout-DOYU6ZrF.js} +1 -1
- package/dist/client/assets/{reset-password-Bg7y47In.js → reset-password-C-ePcRxe.js} +1 -1
- package/dist/client/assets/{roles-DGrbNCWW.js → roles-BIfIrd7m.js} +1 -1
- package/dist/client/assets/{scroll-area-CKtMTQYf.js → scroll-area-Oi-1lw3K.js} +1 -1
- package/dist/client/assets/{search-input-IB-Ydlwu.js → search-input-B4tnw2Dh.js} +1 -1
- package/dist/client/assets/{secrets-B79kBjyk.js → secrets-CBM_AuXa.js} +1 -1
- package/dist/client/assets/sections-editor-mCI01e08.js +1 -0
- package/dist/client/assets/{select-jojObnt9.js → select-DvLGp7Fe.js} +1 -1
- package/dist/client/assets/{select-model-_LL7onpi.js → select-model-CMV07_l8.js} +1 -1
- package/dist/client/assets/{settings-layout-BNMSxxaS.js → settings-layout-BJPqPjYP.js} +1 -1
- package/dist/client/assets/{settings-section-C3eBQ5US.js → settings-section-BiADvCcv.js} +1 -1
- package/dist/client/assets/{shell-layout-C1X1-JG8.js → shell-layout-B3MT5Ip4.js} +1 -1
- package/dist/client/assets/{sidebar-C_hRR4KF.js → sidebar-DjYuMiBY.js} +1 -1
- package/dist/client/assets/{skeleton-n8o43rJX.js → skeleton-BECSxU-k.js} +1 -1
- package/dist/client/assets/{spinner-BaC6n1xb.js → spinner-BDiar_Qs.js} +1 -1
- package/dist/client/assets/{sso-Ox9HYijQ.js → sso-N4YcSgWy.js} +1 -1
- package/dist/client/assets/{store-Bu8xGiJ5.js → store-DA7ZlNUb.js} +1 -1
- package/dist/client/assets/store-registry-jAkq8nDn.js +2 -0
- package/dist/client/assets/{switch-BZLSGFBx.js → switch-TizQbIhD.js} +1 -1
- package/dist/client/assets/{table-7BOsHRtX.js → table-Y-svmHTv.js} +1 -1
- package/dist/client/assets/{tabs-KcBzFTjC.js → tabs-DJRUo-0B.js} +1 -1
- package/dist/client/assets/{task-status-CDMxK9EE.js → task-status-DJ48SE9o.js} +1 -1
- package/dist/client/assets/{textarea-DHobPsXZ.js → textarea-UEW8mFM6.js} +1 -1
- package/dist/client/assets/{toggle-group-lOnZMTcx.js → toggle-group-BHBQNNIa.js} +1 -1
- package/dist/client/assets/{tools-list-DiRO7kVk.js → tools-list-DTwH0BKs.js} +1 -1
- package/dist/client/assets/{tooltip-DZLc9WZT.js → tooltip-BxAcRSdf.js} +1 -1
- package/dist/client/assets/{types-Jt6MSTlH.js → types-j_q-ovJc.js} +1 -1
- package/dist/client/assets/{use-ai-providers-BiHxHp_8.js → use-ai-providers-DmiZTNMs.js} +1 -1
- package/dist/client/assets/{use-collections-BIjIKatp.js → use-collections--I8gVq9B.js} +1 -1
- package/dist/client/assets/{use-connection-DM6P3Tgy.js → use-connection-BK2Nw2jO.js} +1 -1
- package/dist/client/assets/{use-copy-B2jsaiGq.js → use-copy-CnthzbKT.js} +1 -1
- package/dist/client/assets/{use-create-virtual-mcp-BWIPT1Xe.js → use-create-virtual-mcp-GbUB67wE.js} +1 -1
- package/dist/client/assets/{use-create-website-agent-CEdKczXM.js → use-create-website-agent-DTQa-l0O.js} +1 -1
- package/dist/client/assets/{use-debounced-autosave-CliGR6xs.js → use-debounced-autosave-CFS7j0go.js} +1 -1
- package/dist/client/assets/{use-delete-connection-CsKPetdz.js → use-delete-connection-CQTnP_H4.js} +1 -1
- package/dist/client/assets/{use-infinite-scroll-tLOnMNJB.js → use-infinite-scroll-DF-89Vhi.js} +1 -1
- package/dist/client/assets/{use-list-state-DYxyRQGt.js → use-list-state-ZMtnaV6Q.js} +1 -1
- package/dist/client/assets/{use-mcp-tools-DQBvL0Nz.js → use-mcp-tools-DAGpG90W.js} +1 -1
- package/dist/client/assets/{use-members-BfR5Rdrh.js → use-members-DPT2ceJk.js} +1 -1
- package/dist/client/assets/{use-navigate-to-agent-CiB4ahid.js → use-navigate-to-agent-DxVatZQd.js} +1 -1
- package/dist/client/assets/{use-org-auth-client-DuyLuOxM.js → use-org-auth-client-DT4qqk1d.js} +1 -1
- package/dist/client/assets/{use-org-sso-B7CuX_bO.js → use-org-sso-Dqe4HQMo.js} +1 -1
- package/dist/client/assets/{use-organization-roles-DExcu2Af.js → use-organization-roles-CooyIwSv.js} +1 -1
- package/dist/client/assets/{use-organization-settings-DpCRkXfB.js → use-organization-settings-i-QaGb_R.js} +1 -1
- package/dist/client/assets/{use-registry-connections-nqNpA01_.js → use-registry-connections-CZIRvS5a.js} +1 -1
- package/dist/client/assets/{use-secrets-BgdL1wGU.js → use-secrets-C5cxFCvW.js} +1 -1
- package/dist/client/assets/{use-status-sounds-DmAOH-qX.js → use-status-sounds-MRdiA7zs.js} +1 -1
- package/dist/client/assets/{use-view-mode-D1MKhL5y.js → use-view-mode-BWKMnTCI.js} +1 -1
- package/dist/client/assets/{use-virtual-mcp-C_B_ZPRv.js → use-virtual-mcp-Douh_VO1.js} +1 -1
- package/dist/client/assets/useInfiniteQuery-DFJcGKpk.js +1 -0
- package/dist/client/assets/{useRouterState-CXu1ag2N.js → useRouterState-x30cArYP.js} +1 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-C4KG05Xu.js +1 -0
- package/dist/client/assets/{user-DLR2GbIM.js → user-ChYpg8M2.js} +1 -1
- package/dist/client/assets/view-mode-toggle-Csc_uwsV.js +1 -0
- package/dist/client/assets/workflow-detail-CUh-ANJ6.js +1 -0
- package/dist/client/assets/{workflow-BelN8AKd.js → workflow-yZfSUoyH.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/server/cli.js +310 -250
- 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/@protobufjs/eventemitter/LICENSE +26 -0
- package/dist/server/node_modules/@protobufjs/eventemitter/README.md +22 -0
- package/dist/server/node_modules/@protobufjs/eventemitter/index.d.ts +43 -0
- package/dist/server/node_modules/@protobufjs/eventemitter/index.js +76 -0
- package/dist/server/node_modules/@protobufjs/eventemitter/package.json +21 -0
- package/dist/server/node_modules/@protobufjs/eventemitter/tests/index.js +47 -0
- package/dist/server/node_modules/@protobufjs/float/LICENSE +26 -0
- package/dist/server/node_modules/@protobufjs/float/README.md +102 -0
- package/dist/server/node_modules/@protobufjs/float/bench/index.js +87 -0
- package/dist/server/node_modules/@protobufjs/float/bench/suite.js +46 -0
- package/dist/server/node_modules/@protobufjs/float/index.d.ts +83 -0
- package/dist/server/node_modules/@protobufjs/float/index.js +335 -0
- package/dist/server/node_modules/@protobufjs/float/package.json +26 -0
- package/dist/server/node_modules/@protobufjs/float/tests/index.js +100 -0
- package/dist/server/node_modules/@protobufjs/inquire/LICENSE +26 -0
- package/dist/server/node_modules/@protobufjs/inquire/README.md +13 -0
- package/dist/server/node_modules/@protobufjs/inquire/index.d.ts +9 -0
- package/dist/server/node_modules/@protobufjs/inquire/index.js +37 -0
- package/dist/server/node_modules/@protobufjs/inquire/package.json +21 -0
- package/dist/server/node_modules/@protobufjs/inquire/tests/data/array.js +1 -0
- package/dist/server/node_modules/@protobufjs/inquire/tests/data/emptyArray.js +1 -0
- package/dist/server/node_modules/@protobufjs/inquire/tests/data/emptyObject.js +1 -0
- package/dist/server/node_modules/@protobufjs/inquire/tests/data/object.js +1 -0
- package/dist/server/node_modules/@protobufjs/inquire/tests/index.js +20 -0
- package/dist/server/node_modules/@protobufjs/pool/LICENSE +26 -0
- package/dist/server/node_modules/@protobufjs/pool/README.md +13 -0
- package/dist/server/node_modules/@protobufjs/pool/index.d.ts +32 -0
- package/dist/server/node_modules/@protobufjs/pool/index.js +48 -0
- package/dist/server/node_modules/@protobufjs/pool/package.json +21 -0
- package/dist/server/node_modules/@protobufjs/pool/tests/index.js +33 -0
- package/dist/server/server.js +63 -3
- package/package.json +1 -1
- package/dist/client/assets/index-B4_LNl6N.css +0 -1
- package/dist/client/assets/index-B9z25Qug.js +0 -1
- package/dist/client/assets/registry-D3LYzawW.js +0 -2
- package/dist/client/assets/sections-editor-Cf97i73N.js +0 -1
- package/dist/client/assets/store-registry-CtstkjaL.js +0 -2
- package/dist/client/assets/useInfiniteQuery-yVqtzjHb.js +0 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-BFIEfRVg.js +0 -1
- package/dist/client/assets/view-mode-toggle-C6I0Zff2.js +0 -1
- package/dist/client/assets/workflow-detail-DWahmUDT.js +0 -1
- package/dist/server/node_modules/@opentelemetry/core/LICENSE +0 -201
- package/dist/server/node_modules/@opentelemetry/core/README.md +0 -73
- package/dist/server/node_modules/@opentelemetry/core/build/esm/ExportResult.d.ts +0 -9
- package/dist/server/node_modules/@opentelemetry/core/build/esm/ExportResult.js +0 -21
- package/dist/server/node_modules/@opentelemetry/core/build/esm/ExportResult.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/baggage/constants.d.ts +0 -8
- package/dist/server/node_modules/@opentelemetry/core/build/esm/baggage/constants.js +0 -27
- package/dist/server/node_modules/@opentelemetry/core/build/esm/baggage/constants.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/baggage/propagation/W3CBaggagePropagator.d.ts +0 -13
- package/dist/server/node_modules/@opentelemetry/core/build/esm/baggage/propagation/W3CBaggagePropagator.js +0 -72
- package/dist/server/node_modules/@opentelemetry/core/build/esm/baggage/propagation/W3CBaggagePropagator.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/baggage/utils.d.ts +0 -16
- package/dist/server/node_modules/@opentelemetry/core/build/esm/baggage/utils.js +0 -69
- package/dist/server/node_modules/@opentelemetry/core/build/esm/baggage/utils.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/anchored-clock.d.ts +0 -41
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/anchored-clock.js +0 -57
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/anchored-clock.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/attributes.d.ts +0 -5
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/attributes.js +0 -87
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/attributes.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/global-error-handler.d.ts +0 -13
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/global-error-handler.js +0 -36
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/global-error-handler.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/logging-error-handler.d.ts +0 -7
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/logging-error-handler.js +0 -59
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/logging-error-handler.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/time.d.ts +0 -59
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/time.js +0 -156
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/time.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/timer-util.d.ts +0 -8
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/timer-util.js +0 -25
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/timer-util.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/types.d.ts +0 -33
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/types.js +0 -17
- package/dist/server/node_modules/@opentelemetry/core/build/esm/common/types.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/index.d.ts +0 -30
- package/dist/server/node_modules/@opentelemetry/core/build/esm/index.js +0 -40
- package/dist/server/node_modules/@opentelemetry/core/build/esm/index.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/internal/exporter.d.ts +0 -10
- package/dist/server/node_modules/@opentelemetry/core/build/esm/internal/exporter.js +0 -32
- package/dist/server/node_modules/@opentelemetry/core/build/esm/internal/exporter.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/internal/validators.d.ts +0 -15
- package/dist/server/node_modules/@opentelemetry/core/build/esm/internal/validators.js +0 -41
- package/dist/server/node_modules/@opentelemetry/core/build/esm/internal/validators.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/browser/environment.d.ts +0 -5
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/browser/environment.js +0 -28
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/browser/environment.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/browser/globalThis.d.ts +0 -10
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/browser/globalThis.js +0 -35
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/browser/globalThis.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/browser/index.d.ts +0 -5
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/browser/index.js +0 -20
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/browser/index.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/browser/performance.d.ts +0 -5
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/browser/performance.js +0 -17
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/browser/performance.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/browser/sdk-info.d.ts +0 -8
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/browser/sdk-info.js +0 -26
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/browser/sdk-info.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/index.d.ts +0 -2
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/index.js +0 -17
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/index.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/node/environment.d.ts +0 -40
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/node/environment.js +0 -97
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/node/environment.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/node/globalThis.d.ts +0 -3
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/node/globalThis.js +0 -19
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/node/globalThis.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/node/index.d.ts +0 -5
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/node/index.js +0 -20
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/node/index.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/node/performance.d.ts +0 -5
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/node/performance.js +0 -18
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/node/performance.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/node/sdk-info.d.ts +0 -8
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/node/sdk-info.js +0 -26
- package/dist/server/node_modules/@opentelemetry/core/build/esm/platform/node/sdk-info.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/propagation/composite.d.ts +0 -43
- package/dist/server/node_modules/@opentelemetry/core/build/esm/propagation/composite.js +0 -77
- package/dist/server/node_modules/@opentelemetry/core/build/esm/propagation/composite.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/semconv.d.ts +0 -9
- package/dist/server/node_modules/@opentelemetry/core/build/esm/semconv.js +0 -29
- package/dist/server/node_modules/@opentelemetry/core/build/esm/semconv.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/trace/TraceState.d.ts +0 -22
- package/dist/server/node_modules/@opentelemetry/core/build/esm/trace/TraceState.js +0 -99
- package/dist/server/node_modules/@opentelemetry/core/build/esm/trace/TraceState.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/trace/W3CTraceContextPropagator.d.ts +0 -26
- package/dist/server/node_modules/@opentelemetry/core/build/esm/trace/W3CTraceContextPropagator.js +0 -99
- package/dist/server/node_modules/@opentelemetry/core/build/esm/trace/W3CTraceContextPropagator.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/trace/rpc-metadata.d.ts +0 -18
- package/dist/server/node_modules/@opentelemetry/core/build/esm/trace/rpc-metadata.js +0 -31
- package/dist/server/node_modules/@opentelemetry/core/build/esm/trace/rpc-metadata.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/trace/suppress-tracing.d.ts +0 -5
- package/dist/server/node_modules/@opentelemetry/core/build/esm/trace/suppress-tracing.js +0 -27
- package/dist/server/node_modules/@opentelemetry/core/build/esm/trace/suppress-tracing.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/callback.d.ts +0 -14
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/callback.js +0 -48
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/callback.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/configuration.d.ts +0 -7
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/configuration.js +0 -42
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/configuration.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/lodash.merge.d.ts +0 -30
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/lodash.merge.js +0 -153
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/lodash.merge.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/merge.d.ts +0 -6
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/merge.js +0 -158
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/merge.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/promise.d.ts +0 -10
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/promise.js +0 -36
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/promise.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/timeout.d.ts +0 -17
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/timeout.js +0 -51
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/timeout.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/url.d.ts +0 -8
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/url.js +0 -40
- package/dist/server/node_modules/@opentelemetry/core/build/esm/utils/url.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esm/version.d.ts +0 -2
- package/dist/server/node_modules/@opentelemetry/core/build/esm/version.js +0 -18
- package/dist/server/node_modules/@opentelemetry/core/build/esm/version.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/ExportResult.d.ts +0 -9
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/ExportResult.js +0 -21
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/ExportResult.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/baggage/constants.d.ts +0 -8
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/baggage/constants.js +0 -27
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/baggage/constants.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/baggage/propagation/W3CBaggagePropagator.d.ts +0 -13
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/baggage/propagation/W3CBaggagePropagator.js +0 -72
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/baggage/propagation/W3CBaggagePropagator.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/baggage/utils.d.ts +0 -16
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/baggage/utils.js +0 -69
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/baggage/utils.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/anchored-clock.d.ts +0 -41
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/anchored-clock.js +0 -57
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/anchored-clock.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/attributes.d.ts +0 -5
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/attributes.js +0 -87
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/attributes.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/global-error-handler.d.ts +0 -13
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/global-error-handler.js +0 -36
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/global-error-handler.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/logging-error-handler.d.ts +0 -7
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/logging-error-handler.js +0 -59
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/logging-error-handler.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/time.d.ts +0 -59
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/time.js +0 -156
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/time.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/timer-util.d.ts +0 -8
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/timer-util.js +0 -25
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/timer-util.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/types.d.ts +0 -33
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/types.js +0 -17
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/common/types.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/index.d.ts +0 -30
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/index.js +0 -40
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/index.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/internal/exporter.d.ts +0 -10
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/internal/exporter.js +0 -32
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/internal/exporter.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/internal/validators.d.ts +0 -15
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/internal/validators.js +0 -41
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/internal/validators.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/browser/environment.d.ts +0 -5
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/browser/environment.js +0 -28
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/browser/environment.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/browser/globalThis.d.ts +0 -10
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/browser/globalThis.js +0 -35
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/browser/globalThis.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/browser/index.d.ts +0 -5
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/browser/index.js +0 -20
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/browser/index.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/browser/performance.d.ts +0 -5
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/browser/performance.js +0 -17
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/browser/performance.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/browser/sdk-info.d.ts +0 -8
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/browser/sdk-info.js +0 -26
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/browser/sdk-info.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/index.d.ts +0 -2
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/index.js +0 -17
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/index.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/node/environment.d.ts +0 -40
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/node/environment.js +0 -97
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/node/environment.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/node/globalThis.d.ts +0 -3
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/node/globalThis.js +0 -19
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/node/globalThis.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/node/index.d.ts +0 -5
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/node/index.js +0 -20
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/node/index.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/node/performance.d.ts +0 -5
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/node/performance.js +0 -18
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/node/performance.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/node/sdk-info.d.ts +0 -8
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/node/sdk-info.js +0 -26
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/platform/node/sdk-info.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/propagation/composite.d.ts +0 -43
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/propagation/composite.js +0 -77
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/propagation/composite.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/semconv.d.ts +0 -9
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/semconv.js +0 -29
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/semconv.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/trace/TraceState.d.ts +0 -22
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/trace/TraceState.js +0 -99
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/trace/TraceState.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/trace/W3CTraceContextPropagator.d.ts +0 -26
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/trace/W3CTraceContextPropagator.js +0 -99
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/trace/W3CTraceContextPropagator.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/trace/rpc-metadata.d.ts +0 -18
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/trace/rpc-metadata.js +0 -31
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/trace/rpc-metadata.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/trace/suppress-tracing.d.ts +0 -5
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/trace/suppress-tracing.js +0 -27
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/trace/suppress-tracing.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/callback.d.ts +0 -14
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/callback.js +0 -48
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/callback.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/configuration.d.ts +0 -7
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/configuration.js +0 -42
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/configuration.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/lodash.merge.d.ts +0 -30
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/lodash.merge.js +0 -153
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/lodash.merge.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/merge.d.ts +0 -6
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/merge.js +0 -158
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/merge.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/promise.d.ts +0 -10
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/promise.js +0 -36
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/promise.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/timeout.d.ts +0 -17
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/timeout.js +0 -51
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/timeout.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/url.d.ts +0 -8
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/url.js +0 -40
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/utils/url.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/version.d.ts +0 -2
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/version.js +0 -18
- package/dist/server/node_modules/@opentelemetry/core/build/esnext/version.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/ExportResult.d.ts +0 -9
- package/dist/server/node_modules/@opentelemetry/core/build/src/ExportResult.js +0 -24
- package/dist/server/node_modules/@opentelemetry/core/build/src/ExportResult.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/baggage/constants.d.ts +0 -8
- package/dist/server/node_modules/@opentelemetry/core/build/src/baggage/constants.js +0 -30
- package/dist/server/node_modules/@opentelemetry/core/build/src/baggage/constants.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/baggage/propagation/W3CBaggagePropagator.d.ts +0 -13
- package/dist/server/node_modules/@opentelemetry/core/build/src/baggage/propagation/W3CBaggagePropagator.js +0 -76
- package/dist/server/node_modules/@opentelemetry/core/build/src/baggage/propagation/W3CBaggagePropagator.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/baggage/utils.d.ts +0 -16
- package/dist/server/node_modules/@opentelemetry/core/build/src/baggage/utils.js +0 -76
- package/dist/server/node_modules/@opentelemetry/core/build/src/baggage/utils.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/anchored-clock.d.ts +0 -41
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/anchored-clock.js +0 -61
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/anchored-clock.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/attributes.d.ts +0 -5
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/attributes.js +0 -93
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/attributes.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/global-error-handler.d.ts +0 -13
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/global-error-handler.js +0 -41
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/global-error-handler.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/logging-error-handler.d.ts +0 -7
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/logging-error-handler.js +0 -63
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/logging-error-handler.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/time.d.ts +0 -59
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/time.js +0 -171
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/time.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/timer-util.d.ts +0 -8
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/timer-util.js +0 -29
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/timer-util.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/types.d.ts +0 -33
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/types.js +0 -18
- package/dist/server/node_modules/@opentelemetry/core/build/src/common/types.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/index.d.ts +0 -30
- package/dist/server/node_modules/@opentelemetry/core/build/src/index.js +0 -92
- package/dist/server/node_modules/@opentelemetry/core/build/src/index.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/internal/exporter.d.ts +0 -10
- package/dist/server/node_modules/@opentelemetry/core/build/src/internal/exporter.js +0 -36
- package/dist/server/node_modules/@opentelemetry/core/build/src/internal/exporter.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/internal/validators.d.ts +0 -15
- package/dist/server/node_modules/@opentelemetry/core/build/src/internal/validators.js +0 -46
- package/dist/server/node_modules/@opentelemetry/core/build/src/internal/validators.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/browser/environment.d.ts +0 -5
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/browser/environment.js +0 -35
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/browser/environment.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/browser/globalThis.d.ts +0 -10
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/browser/globalThis.js +0 -38
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/browser/globalThis.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/browser/index.d.ts +0 -5
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/browser/index.js +0 -30
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/browser/index.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/browser/performance.d.ts +0 -5
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/browser/performance.js +0 -20
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/browser/performance.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/browser/sdk-info.d.ts +0 -8
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/browser/sdk-info.js +0 -29
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/browser/sdk-info.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/index.d.ts +0 -2
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/index.js +0 -27
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/index.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/node/environment.d.ts +0 -40
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/node/environment.js +0 -104
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/node/environment.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/node/globalThis.d.ts +0 -3
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/node/globalThis.js +0 -22
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/node/globalThis.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/node/index.d.ts +0 -5
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/node/index.js +0 -30
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/node/index.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/node/performance.d.ts +0 -5
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/node/performance.js +0 -21
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/node/performance.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/node/sdk-info.d.ts +0 -8
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/node/sdk-info.js +0 -29
- package/dist/server/node_modules/@opentelemetry/core/build/src/platform/node/sdk-info.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/propagation/composite.d.ts +0 -43
- package/dist/server/node_modules/@opentelemetry/core/build/src/propagation/composite.js +0 -81
- package/dist/server/node_modules/@opentelemetry/core/build/src/propagation/composite.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/semconv.d.ts +0 -9
- package/dist/server/node_modules/@opentelemetry/core/build/src/semconv.js +0 -32
- package/dist/server/node_modules/@opentelemetry/core/build/src/semconv.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/trace/TraceState.d.ts +0 -22
- package/dist/server/node_modules/@opentelemetry/core/build/src/trace/TraceState.js +0 -103
- package/dist/server/node_modules/@opentelemetry/core/build/src/trace/TraceState.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/trace/W3CTraceContextPropagator.d.ts +0 -26
- package/dist/server/node_modules/@opentelemetry/core/build/src/trace/W3CTraceContextPropagator.js +0 -104
- package/dist/server/node_modules/@opentelemetry/core/build/src/trace/W3CTraceContextPropagator.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/trace/rpc-metadata.d.ts +0 -18
- package/dist/server/node_modules/@opentelemetry/core/build/src/trace/rpc-metadata.js +0 -37
- package/dist/server/node_modules/@opentelemetry/core/build/src/trace/rpc-metadata.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/trace/suppress-tracing.d.ts +0 -5
- package/dist/server/node_modules/@opentelemetry/core/build/src/trace/suppress-tracing.js +0 -33
- package/dist/server/node_modules/@opentelemetry/core/build/src/trace/suppress-tracing.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/callback.d.ts +0 -14
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/callback.js +0 -52
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/callback.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/configuration.d.ts +0 -7
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/configuration.js +0 -46
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/configuration.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/lodash.merge.d.ts +0 -30
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/lodash.merge.js +0 -157
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/lodash.merge.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/merge.d.ts +0 -6
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/merge.js +0 -162
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/merge.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/promise.d.ts +0 -10
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/promise.js +0 -40
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/promise.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/timeout.d.ts +0 -17
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/timeout.js +0 -56
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/timeout.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/url.d.ts +0 -8
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/url.js +0 -45
- package/dist/server/node_modules/@opentelemetry/core/build/src/utils/url.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/build/src/version.d.ts +0 -2
- package/dist/server/node_modules/@opentelemetry/core/build/src/version.js +0 -21
- package/dist/server/node_modules/@opentelemetry/core/build/src/version.js.map +0 -1
- package/dist/server/node_modules/@opentelemetry/core/package.json +0 -93
- package/dist/server/node_modules/deepmerge/.editorconfig +0 -7
- package/dist/server/node_modules/deepmerge/.eslintcache +0 -1
- package/dist/server/node_modules/deepmerge/changelog.md +0 -167
- package/dist/server/node_modules/deepmerge/dist/cjs.js +0 -133
- package/dist/server/node_modules/deepmerge/dist/umd.js +0 -139
- package/dist/server/node_modules/deepmerge/index.d.ts +0 -20
- package/dist/server/node_modules/deepmerge/index.js +0 -106
- package/dist/server/node_modules/deepmerge/license.txt +0 -21
- package/dist/server/node_modules/deepmerge/package.json +0 -42
- package/dist/server/node_modules/deepmerge/readme.md +0 -264
- package/dist/server/node_modules/deepmerge/rollup.config.js +0 -22
- package/dist/server/node_modules/indent-string/index.d.ts +0 -38
- package/dist/server/node_modules/indent-string/index.js +0 -38
- package/dist/server/node_modules/indent-string/license +0 -9
- package/dist/server/node_modules/indent-string/package.json +0 -40
- package/dist/server/node_modules/indent-string/readme.md +0 -73
- package/dist/server/node_modules/widest-line/index.d.ts +0 -12
- package/dist/server/node_modules/widest-line/index.js +0 -11
- package/dist/server/node_modules/widest-line/license +0 -9
- package/dist/server/node_modules/widest-line/package.json +0 -60
- package/dist/server/node_modules/widest-line/readme.md +0 -26
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/sections-editor-
|
|
2
|
-
import{p as _s,r as A,q as nc,s as oc,e as z,c as te,j as n,l as Ae,B as se,E as Rt,v as me,b as Li,a as na,w as oa,f as is,d as aa,x as ac,K as us,o as he,y as Ni,V as lc,t as ve,z as la,C as cc,D as zs,F as rt,G as ca,H as hc,I as dc,J as Ln,n as ha,L as uc,M as Yi,P as oi,Q as gt,_ as ln,R as fc,T as da,U as ua,W as mc,g as _c}from"./index-CyT5Gmzn.js";import{C as Ne,b as pc,w as gc,A as vc,c as xc,d as bc,S as Sc,e as On,u as yc,a as xr,f as wc,g as Cc}from"./index-DaY9yoJe.js";import{I as Ct}from"./integration-icon-CLJQqC-I.js";import{u as Ue,K as kc,g as fa,S as Ft,a as ma}from"./constants-CqClUFzZ.js";import{u as Pt,a as Nc}from"./use-virtual-mcp-C_B_ZPRv.js";import{a as jc}from"./Users03-DRUOncwe.js";import{u as rs,a as Ht,b as cn,t as Ec,d as $n}from"./chat-context-DpzF1H11.js";import{i as hn}from"./AlertCircle-CJ_imV3m.js";import{i as Tc}from"./CheckCircle-vPV0tRYO.js";import{a as zn,n as Rc}from"./ZapSquare-Yqh6kfEb.js";import{i as Dc,a as Pc,b as dn,c as Ic,d as un}from"./XCircle-CCY5DUN0.js";import{s as fs,i as Fn}from"./XClose-DcZl70IB.js";import{c as Mc,r as Ac,p as _a,f as Hn,a as Bc,F as Lc,t as Wn,M as fn,G as Oc,i as $c,b as zc,d as Fc,e as Hc}from"./pair-C0WTHF98.js";import{C as ji,a as Ei,b as Wc,c as mn,d as _n,e as pn,f as gn}from"./command-BPMvKg3I.js";import{P as Wt,a as Ut,b as Vt}from"./popover-C42-PtSd.js";import{i as As,a as Uc,b as Vc,p as Oi,g as $i,c as vn,d as pa,h as br,e as Xi,f as Un,A as Vn,j as xn,k as Kc,l as qc,n as Gc,m as Yc,o as Xc,t as Jc,q as Zc,s as Qc,r as ga,u as va,v as xa,w as eh,x as ba,y as Kn,z as Sa,B as th,C as Bs,D as sh,E as ya,F as wa}from"./agent-icon-CiDXBIEY.js";import{u as ih}from"./useInfiniteQuery-yVqtzjHb.js";import{u as rh}from"./use-ai-providers-BiHxHp_8.js";import{g as Zt,a as nh,T as oh}from"./index-BzDY-tSP.js";import{u as bn,i as ah}from"./shell-layout-C1X1-JG8.js";import{u as lh,c as ch,d as hh,e as dh}from"./sidebar-C_hRR4KF.js";import{u as Ca,T as xe,a as be,b as Se,c as uh}from"./tooltip-DZLc9WZT.js";import{u as fh}from"./use-status-sounds-DmAOH-qX.js";import{E as Ti}from"./empty-state-DAuMay-T.js";import{A as mh,a as _h,b as ph,c as gh,R as ka,d as vh,e as xh}from"./accordion-CVzn69yt.js";import{u as qs,a as Sn,b as bh}from"./use-connection-DM6P3Tgy.js";import{u as Na}from"./hooks-BMwOK54h.js";import{g as Sh}from"./constants-Cz6MSKkF.js";import{u as yh,g as wh}from"./types-Jt6MSTlH.js";import{G as Ch,u as ja}from"./lean-canvas-recruit-modal-B5lshz4v.js";import{U as Ea}from"./user-DLR2GbIM.js";import{T as kh,u as Ta}from"./tools-list-DiRO7kVk.js";import{u as Nh}from"./unwrap-tool-result-BYXdCQMg.js";import{s as Ra,g as jh}from"./connection-slug-eyAPH6o3.js";import{A as Da,a as Pa,b as Ia,c as Ma,d as Aa,e as Ba,f as La,g as Oa}from"./alert-dialog-D44pjeug.js";import{D as $a,a as zi,b as Fi,c as yn,d as wn,e as Eh}from"./dialog-BvOKPwhc.js";import{C as za,a as Sr}from"./card-Dl5Tqdaj.js";import{I as nt}from"./input-D2jK2nww.js";import{L as Je}from"./label-DBNWSOSa.js";import{S as ut,a as ft,b as mt,c as _t,d as Ge}from"./select-jojObnt9.js";import{S as yr}from"./switch-BZLSGFBx.js";import{T as Fs}from"./textarea-DHobPsXZ.js";import{i as Qt}from"./Play-DMF3Xc70.js";import{s as es}from"./Plus-BgmWF0s6.js";import{a as Th}from"./Settings02-MFm4VQgV.js";import{t as Cn,i as Rh}from"./Tool01-CBI3b59M.js";import{s as Ri}from"./Trash01-_MTXzWmC.js";import{u as Ls}from"./use-debounced-autosave-CliGR6xs.js";import{S as kn}from"./scroll-area-CKtMTQYf.js";import{i as Fa}from"./SearchMd-CkzE05NA.js";import{i as Dh}from"./Upload01-CbbVgbGf.js";import{i as Ph}from"./LayoutLeft-C8PVq2Qs.js";import{P as dt}from"./index-DEVJtPY-.js";import{C as Ih}from"./collection-tabs-BLwNPyei.js";import{C as Mh}from"./checkbox-B_0TJdoc.js";import{u as Ah,a as Gs,b as Ha}from"./use-mcp-tools-DQBvL0Nz.js";import{u as Bh,T as Ji,a as Lh,b as Oh,c as Zi}from"./tabs-KcBzFTjC.js";import{D as $h,a as zh,b as Fh}from"./drawer-CWSEhQ-2.js";import{i as ps}from"./Check-Cvjf7hnA.js";import{i as Wa}from"./Key01-etdhr-4G.js";import{S as Hh}from"./skeleton-n8o43rJX.js";import{i as Wh}from"./Lock01-B762FFJA.js";import{s as Uh}from"./User01-CrRc-Y_s.js";import{t as Vh}from"./Users01-DC9jbA8R.js";import{u as Kh,a as qh}from"./use-secrets-BgdL1wGU.js";import{n as gs}from"./LinkExternal01-g1vEyCDg.js";import{S as Gh}from"./spinner-BaC6n1xb.js";import{D as Ys,a as Xs,b as Js,c as Dt,d as Yh,e as Xh,f as Jh}from"./dropdown-menu-CtHZqdUp.js";import{t as vs}from"./ChevronDown-DIoOnkaF.js";import{i as Ua}from"./RefreshCcw01-Bv_ZYBkO.js";import{V as Zh}from"./view-mode-toggle-C6I0Zff2.js";import{i as Qh}from"./X-CLTZLxw4.js";import{u as Zs,a as ed,b as td,c as sd,A as id,d as rd,e as nd}from"./automation-list-row-B_c98AAD.js";import{i as Hs}from"./Zap-DiQs7uBH.js";import{S as od}from"./search-input-IB-Ydlwu.js";function ad(t,e){const s=_s(e);return ld({filters:{...t,status:"pending"}},s).length}function qn(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function ld(t={},e){const s=_s(e).getMutationCache(),i=A.useRef(t),r=A.useRef(null);return r.current===null&&(r.current=qn(s,t)),A.useEffect(()=>{i.current=t}),A.useSyncExternalStore(A.useCallback(o=>s.subscribe(()=>{const a=nc(r.current,qn(s,i.current));r.current!==a&&(r.current=a,oc.schedule(o))}),[s]),()=>r.current,()=>r.current)}function ys(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function Gn(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 cd(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function hd(t){const e=z.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(dd),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 dd(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 ud(t){const e=z.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 m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=m):m=e[10];let _;e[11]!==a?(_=a.toFixed(1),e[11]=a,e[12]=_):_=e[12];let p;e[13]!==_?(p=n.jsxs("div",{className:"flex items-center gap-1.5",children:[m,n.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",_,"%"]})]}),e[13]=_,e[14]=p):p=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 v;e[16]!==l?(v=l.toFixed(1),e[16]=l,e[17]=v):v=e[17];let x;e[18]!==v?(x=n.jsxs("div",{className:"flex items-center gap-1.5",children:[g,n.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",v,"%"]})]}),e[18]=v,e[19]=x):x=e[19];let b;e[20]!==h||e[21]!==r?(b=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]=b):b=e[22];let S;e[23]!==x||e[24]!==b||e[25]!==p?(S=n.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[p,x,b]}),e[23]=x,e[24]=b,e[25]=p,e[26]=S):S=e[26];let w;return e[27]!==S||e[28]!==f?(w=n.jsxs("div",{className:"flex flex-col gap-2",children:[f,S]}),e[27]=S,e[28]=f,e[29]=w):w=e[29],w}function fd(t){const e=z.c(11),{agentId:s,isError:i}=t,r=Pt(s),o=r?.title??"Subtask",a=r?.icon??null;let l;e[0]!==a||e[1]!==o?(l=n.jsx(Ct,{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=te("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 md(t){const e=z.c(5),{isError:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Ct,{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=te("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 _d(t){const e=z.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(md,{isError:o}),e[0]=o,e[1]=l):l=e[1];let h;e[2]!==i||e[3]!==o?(h=n.jsx(fd,{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(A.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(Ae,{size:12,className:"animate-spin text-muted-foreground"}):o?n.jsx(Dc,{size:12,className:"text-destructive"}):a?n.jsx(hn,{size:12,className:"text-warning"}):n.jsx(Tc,{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 pd(t){const e=z.c(55),{onClose:s,back:i,className:r}=t,[o,a]=A.useState(null),{messages:l}=rs(),{activeTask:h}=Ht(),{selectedModel:c,selectedVirtualMcp:d}=cn();let u,f,m,_,p,g,v,x;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){x=Symbol.for("react.early_return_sentinel");e:{const w=Mc(l),k=[...l].reverse().find(jd),C=k?.metadata?.usage,E=k?.metadata?.modelLimits?.contextWindow??c?.limits?.contextWindow??null,T=C?.contextTokens??C?.totalTokens??0,B=E&&E>0?(T/E*100).toFixed(1):null,I=l;let R;e[16]!==I?(R=I.filter(Nd).reduce(kd,0),e[16]=I,e[17]=R):R=e[17];const y=R,D=l;let N;e[18]!==D?(N=D.filter(Cd).reduce(wd,0),e[18]=D,e[19]=N):N=e[19];const j=N,M=Math.max(0,w.totalTokens-y-j),P=l[0],F=l.at(-1),W=P?.metadata?.created_at??h?.created_at,O=F?.metadata?.created_at??h?.updated_at,$=l.filter(yd),H=l.flatMap(bd),V=c?.modelId?cd(c.modelId):"—",re=d?.title??"Decopilot",X=[{label:"Session",value:h?.title??"New chat"},{label:"Messages",value:$.length},{label:"Agent",value:re},{label:"Model",value:V},{label:"Context Limit",value:E?ys(E):"—"},{label:"Session Tokens (billed)",value:w.totalTokens>0?ys(w.totalTokens):"0"},{label:"Usage",value:B!==null?`${B}%`:"—"},{label:"Input Tokens",value:w.inputTokens>0?ys(w.inputTokens):"0"},{label:"Output Tokens",value:w.outputTokens>0?ys(w.outputTokens):"0"},{label:"Reasoning Tokens",value:w.reasoningTokens>0?ys(w.reasoningTokens):"0"},{label:"Cost",value:w.cost>0?`$${w.cost<.001?w.cost.toFixed(6):w.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:Gn(W)},{label:"Last Activity",value:Gn(O)}];if(!h&&$.length===0){let K;e[20]!==r?(K=te("flex flex-col h-full w-full border-l border-border bg-background",r),e[20]=r,e[21]=K):K=e[21];let Q;e[22]===Symbol.for("react.memo_cache_sentinel")?(Q=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[22]=Q):Q=e[22];let G;e[23]!==i?(G=i?n.jsx(zn,{size:14,className:"text-muted-foreground"}):n.jsx(fs,{size:14,className:"text-muted-foreground"}),e[23]=i,e[24]=G):G=e[24];let ee;e[25]!==s||e[26]!==G?(ee=n.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[Q,n.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:G})]}),e[25]=s,e[26]=G,e[27]=ee):ee=e[27];let oe;e[28]===Symbol.for("react.memo_cache_sentinel")?(oe=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]=oe):oe=e[28];let _e;e[29]!==K||e[30]!==ee?(_e=n.jsxs("div",{className:K,children:[ee,oe]}),e[29]=K,e[30]=ee,e[31]=_e):_e=e[31],x=_e;break e}e[32]!==r?(g=te("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 J;e[34]===Symbol.for("react.memo_cache_sentinel")?(J=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[34]=J):J=e[34];let Z;e[35]!==i?(Z=i?n.jsx(zn,{size:14}):n.jsx(fs,{size:14}),e[35]=i,e[36]=Z):Z=e[36],e[37]!==s||e[38]!==Z?(v=n.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[J,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:Z})]}),e[37]=s,e[38]=Z,e[39]=v):v=e[39],u="flex flex-col gap-8 p-6",f=H.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:H.map(xd)})]}),m=n.jsx(hd,{items:X});let L;e[40]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[40]=L):L=e[40],e[41]!==j||e[42]!==M||e[43]!==y?(_=n.jsxs("div",{className:"flex flex-col gap-3",children:[L,n.jsx(ud,{userTokens:y,assistantTokens:j,otherTokens:M})]}),e[41]=j,e[42]=M,e[43]=y,e[44]=_):_=e[44],p=$.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:$.map(K=>{const Q=K.metadata?.created_at,G=o?.id===K.id;return n.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[n.jsxs("button",{type:"button",onClick:()=>a(G?null:K),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:te("shrink-0 font-medium",K.role==="user"?"text-chart-1":"text-chart-2"),children:K.role}),n.jsx("span",{className:"text-muted-foreground",children:"•"}),n.jsx("span",{className:"truncate text-muted-foreground font-mono",children:K.id})]}),Q&&n.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(Q).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),G&&n.jsxs(n.Fragment,{children:[K.role==="assistant"&&(()=>{const ee=K.metadata?._request;if(!ee)return null;const oe=ee.systemSections??[],_e=Math.max(1,...oe.map(vd)),ge=oe.reduce(gd,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:[ee.activeTools??0," / ",ee.tools??0," ","tools active"]})]}),oe.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(ge/4).toLocaleString()," ","tok"]})]}),oe.map((we,je)=>{const De=we.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${je}`,ne=we.chars/_e*100,le=Math.round(we.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:De}),n.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:["~",le.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:`${ne}%`}})})]},je)})]})]})})(),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(K,null,2)})]})]},K.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]=m,e[11]=_,e[12]=p,e[13]=g,e[14]=v,e[15]=x}else u=e[8],f=e[9],m=e[10],_=e[11],p=e[12],g=e[13],v=e[14],x=e[15];if(x!==Symbol.for("react.early_return_sentinel"))return x;let b;e[45]!==u||e[46]!==f||e[47]!==m||e[48]!==_||e[49]!==p?(b=n.jsxs("div",{className:u,children:[f,m,_,p]}),e[45]=u,e[46]=f,e[47]=m,e[48]=_,e[49]=p,e[50]=b):b=e[50];let S;return e[51]!==g||e[52]!==v||e[53]!==b?(S=n.jsxs("div",{className:g,children:[v,b]}),e[51]=g,e[52]=v,e[53]=b,e[54]=S):S=e[54],S}function gd(t,e){return t+e.chars}function vd(t){return t.chars}function xd(t,e){return n.jsx(_d,{part:t},e)}function bd(t){return(t.parts??[]).filter(Sd)}function Sd(t){return t.type==="tool-subtask"}function yd(t){return t.role!=="system"}function wd(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function Cd(t){return t.role==="assistant"}function kd(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function Nd(t){return t.role==="user"}function jd(t){return t.role==="assistant"&&t.metadata?.usage}const Yn=["amber","bold","bright","calm","crimson","coral","daring","deep","dusty","eager","faint","fierce","frozen","gentle","golden","grand","green","hollow","iron","ivory","keen","lasting","lunar","mellow","misty","noble","olive","pale","prime","quiet","rapid","rustic","serene","sharp","silver","sleek","solar","stark","still","swift","tawny","tender","thin","true","vast","velvet","warm","wild","young","zen"],Xn=["anchor","birch","brook","cedar","cliff","cove","crane","dune","echo","ember","falcon","fern","flint","forge","frost","glade","grove","harbor","hawk","iris","jade","lark","maple","marsh","mesa","opal","orbit","peak","pine","plume","quartz","rapids","reef","ridge","river","sage","shore","slate","spruce","stone","summit","thorn","tide","trail","vale","wren","aspen","delta","crest","spark"];function Ed(){const t=Yn[Math.floor(Math.random()*Yn.length)],e=Xn[Math.floor(Math.random()*Xn.length)];return`deco/${t}-${e}`}const gi=100;function Td(t,e,s){const i=e.trim().toLowerCase();return i?(t??[]).some(r=>r.branches.some(o=>typeof o.name=="string"&&!s.has(o.name)&&o.name.toLowerCase().includes(i))):!0}function Rd(t,e){const s=e.trim().toLowerCase();return s?[...t].some(i=>i.toLowerCase().includes(s)):!0}function Dd(t){const e=t;if(e.structuredContent)return e.structuredContent;const s=e.content?.find(i=>i.type==="text")?.text;if(s)try{return JSON.parse(s)}catch{return[]}return[]}function Pd(t){const e=z.c(48),{orgId:s,orgSlug:i,userId:r,connectionId:o,vmMap:a,owner:l,repo:h,enabled:c}=t,d=c===void 0?!0:c,u=o??null;let f;e[0]!==s||e[1]!==i||e[2]!==u?(f={connectionId:u,orgId:s,orgSlug:i},e[0]=s,e[1]=i,e[2]=u,e[3]=f):f=e[3];const m=Ue(f);let _;e[4]!==o||e[5]!==s||e[6]!==i||e[7]!==l||e[8]!==h?(_=kc.githubBranches(s,i,o,l,h),e[4]=o,e[5]=s,e[6]=i,e[7]=l,e[8]=h,e[9]=_):_=e[9];const p=d&&!!o&&!!l&&!!h;let g;e[10]!==m||e[11]!==l||e[12]!==h?(g=async O=>{const{pageParam:$,signal:H}=O,V=Number($),re=await m.callTool({name:"list_branches",arguments:{owner:l,repo:h,page:V,perPage:gi}},void 0,{signal:H}),X=Dd(re);return{branches:Array.isArray(X)?X:X.branches??[],default_branch:Array.isArray(X)?null:X.default_branch??null,page:V}},e[10]=m,e[11]=l,e[12]=h,e[13]=g):g=e[13];let v;e[14]!==_||e[15]!==p||e[16]!==g?(v={queryKey:_,enabled:p,staleTime:3e4,retry:!1,initialPageParam:1,queryFn:g,getNextPageParam:Od},e[14]=_,e[15]=p,e[16]=g,e[17]=v):v=e[17];const{data:x,isLoading:b,isError:S,hasNextPage:w,isFetchingNextPage:k,fetchNextPage:C}=ih(v);let E,T;e[18]!==r||e[19]!==a?(T=new Set(Object.keys(a?.[r]??{})),E=[...T].sort().map(Ld),e[18]=r,e[19]=a,e[20]=E,e[21]=T):(E=e[20],T=e[21]);const B=E;let I;if(e[22]!==x?.pages){const O=new Map;for(const H of x?.pages??[])for(const V of H.branches)typeof V.name=="string"&&O.set(V.name,V);I=[...O.values()].filter(Bd),e[22]=x?.pages,e[23]=I}else I=e[23];let R;e[24]!==I||e[25]!==T?(R=I.filter(O=>!T.has(O.name)).map(Ad),e[24]=I,e[25]=T,e[26]=R):R=e[26];const y=R;let D;e[27]!==x?.pages?(D=x?.pages.find(Md)?.default_branch??null,e[27]=x?.pages,e[28]=D):D=e[28];const N=D;let j;e[29]!==x?.pages||e[30]!==C||e[31]!==k||e[32]!==T?(j=async(O,$)=>{const H=$===void 0?Id:$;if(!H()||Rd(T,O)||k)return;let V=x?.pages??[];for(;H()&&!Td(V,O,T)&&(V.at(-1)?.branches.length??gi)>=gi;){const re=await C();if(!H())break;const X=re.data?.pages??V;if(X.length===V.length)break;V=X}},e[29]=x?.pages,e[30]=C,e[31]=k,e[32]=T,e[33]=j):j=e[33];const M=j,P=w??!1;let F;e[34]!==C||e[35]!==w||e[36]!==k?(F=()=>{w&&!k&&C()},e[34]=C,e[35]=w,e[36]=k,e[37]=F):F=e[37];let W;return e[38]!==N||e[39]!==M||e[40]!==S||e[41]!==k||e[42]!==b||e[43]!==y||e[44]!==P||e[45]!==F||e[46]!==B?(W={yours:B,others:y,defaultBase:N,isLoading:b,isError:S,hasMore:P,isFetchingMore:k,fetchMore:F,fetchUntilMatch:M},e[38]=N,e[39]=M,e[40]=S,e[41]=k,e[42]=b,e[43]=y,e[44]=P,e[45]=F,e[46]=B,e[47]=W):W=e[47],W}function Id(){return!0}function Md(t){return t.default_branch}function Ad(t){return{name:t.name,source:"other",author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function Bd(t){return typeof t.name=="string"}function Ld(t){return{name:t,source:"yours"}}function Od(t){if(!(t.branches.length<gi))return t.page+1}function $d(t){const e=z.c(61),{orgId:s,orgSlug:i,userId:r,connectionId:o,owner:a,repo:l,vmMap:h,value:c,onChange:d}=t,[u,f]=A.useState(!1),[m,_]=A.useState(""),[p,g]=A.useState(!1),v=A.useRef(0);let x;e[0]!==o||e[1]!==u||e[2]!==s||e[3]!==i||e[4]!==a||e[5]!==l||e[6]!==r||e[7]!==h?(x={orgId:s,orgSlug:i,userId:r,connectionId:o,vmMap:h,owner:a,repo:l,enabled:u},e[0]=o,e[1]=u,e[2]=s,e[3]=i,e[4]=a,e[5]=l,e[6]=r,e[7]=h,e[8]=x):x=e[8];const{yours:b,others:S,isLoading:w,isError:k,hasMore:C,isFetchingMore:E,fetchMore:T,fetchUntilMatch:B}=Pd(x);let I;e[9]!==d?(I=G=>{d(G),f(!1)},e[9]=d,e[10]=I):I=e[10];const R=I,y=c??"Select branch…";let D;e[11]!==B?(D=G=>{_(G),v.current=v.current+1;const ee=v.current,oe=G.trim();if(!oe){g(!1);return}g(!0),B(oe,()=>ee===v.current).finally(()=>{ee===v.current&&g(!1)})},e[11]=B,e[12]=D):D=e[12];const N=D;let j;e[13]!==T?(j=G=>{const ee=G.currentTarget;ee.scrollHeight-ee.scrollTop-ee.clientHeight<48&&T()},e[13]=T,e[14]=j):j=e[14];const M=j;let P;e[15]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsx(As,{className:"h-3.5 w-3.5"}),e[15]=P):P=e[15];let F;e[16]!==y?(F=n.jsx(Wt,{asChild:!0,children:n.jsxs(se,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 font-mono text-xs",children:[P,n.jsx("span",{className:"max-w-[200px] truncate",children:y})]})}),e[16]=y,e[17]=F):F=e[17];let W;e[18]!==N||e[19]!==m?(W=n.jsx(mn,{placeholder:"Search loaded branches…",value:m,onValueChange:N}),e[18]=N,e[19]=m,e[20]=W):W=e[20];let O;e[21]!==R?(O=n.jsx(se,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>R(Ed()),children:"New"}),e[21]=R,e[22]=O):O=e[22];let $;e[23]!==W||e[24]!==O?($=n.jsxs("div",{className:"*:data-[slot=command-input-wrapper]:flex-1 *:data-[slot=command-input-wrapper]:border-b-0 flex items-center border-b pr-2",children:[W,O]}),e[23]=W,e[24]=O,e[25]=$):$=e[25];let H;e[26]!==k?(H=k&&n.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:"Couldn't load branches from GitHub. You can still pick from your branches."}),e[26]=k,e[27]=H):H=e[27];let V;e[28]!==C||e[29]!==k||e[30]!==w?(V=!k&&!w&&n.jsx(_n,{children:C?"Looking through more branches...":"No branches found."}),e[28]=C,e[29]=k,e[30]=w,e[31]=V):V=e[31];let re;e[32]!==R||e[33]!==b?(re=b.length>0&&n.jsx(ji,{heading:"Your branches",children:b.map(G=>n.jsxs(Ei,{value:G.name,onSelect:()=>R(G.name),children:[n.jsx(As,{className:"mr-2 h-4 w-4"}),n.jsx("span",{className:"flex-1 truncate",children:G.name})]},G.name))}),e[32]=R,e[33]=b,e[34]=re):re=e[34];let X;e[35]!==S||e[36]!==R?(X=S.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(Wc,{}),n.jsx(ji,{heading:"Other branches in repo",children:S.map(G=>n.jsxs(Ei,{value:G.name,onSelect:()=>R(G.name),children:[n.jsx(As,{className:"mr-2 h-4 w-4"}),n.jsx("span",{className:"flex-1 truncate",children:G.name}),G.author&&n.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",G.author]})]},G.name))})]}),e[35]=S,e[36]=R,e[37]=X):X=e[37];let J;e[38]!==T||e[39]!==C||e[40]!==E||e[41]!==p?(J=C&&n.jsx("div",{className:"border-t p-2",children:n.jsx(se,{variant:"ghost",size:"sm",className:"h-7 w-full text-xs",disabled:E,onClick:T,children:E||p?"Loading more…":"Load more branches"})}),e[38]=T,e[39]=C,e[40]=E,e[41]=p,e[42]=J):J=e[42];let Z;e[43]!==C||e[44]!==S.length?(Z=!C&&S.length>0&&n.jsx("div",{className:"border-t p-2 text-center text-xs text-muted-foreground",children:"All loaded"}),e[43]=C,e[44]=S.length,e[45]=Z):Z=e[45];let L;e[46]!==M||e[47]!==H||e[48]!==V||e[49]!==re||e[50]!==X||e[51]!==J||e[52]!==Z?(L=n.jsxs(pn,{onScroll:M,children:[H,V,re,X,J,Z]}),e[46]=M,e[47]=H,e[48]=V,e[49]=re,e[50]=X,e[51]=J,e[52]=Z,e[53]=L):L=e[53];let K;e[54]!==L||e[55]!==$?(K=n.jsx(Ut,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:n.jsxs(gn,{children:[$,L]})}),e[54]=L,e[55]=$,e[56]=K):K=e[56];let Q;return e[57]!==u||e[58]!==K||e[59]!==F?(Q=n.jsxs(Vt,{open:u,onOpenChange:f,children:[F,K]}),e[57]=u,e[58]=K,e[59]=F,e[60]=Q):Q=e[60],Q}function zd(){const t=z.c(27),{org:e}=me(),{selectedVirtualMcp:s}=cn(),{data:i}=Li.useSession(),{currentBranch:r,setCurrentTaskBranch:o}=Ht();let a;t[0]!==e.id?(a=fa(e.id),t[0]=e.id,t[1]=a):a=t[1];const h=s??a,c=Pt(h.id),d=i?.user?.id??"",u=c?.metadata?.githubRepo??null,f=!!u?.connectionId&&!!d;let m;t[2]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(jc,{size:32}),t[2]=m):m=t[2];let _;t[3]!==h.icon||t[4]!==h.title?(_=n.jsx(Ct,{icon:h.icon,name:h.title,size:"lg",fallbackIcon:m,className:"size-10 min-w-10 md:size-[60px]! md:min-w-[60px] rounded-xl md:rounded-[18px]!"}),t[3]=h.icon,t[4]=h.title,t[5]=_):_=t[5];let p;t[6]!==h.title?(p=n.jsx("h3",{className:"text-base md:text-xl font-medium text-foreground",children:h.title}),t[6]=h.title,t[7]=p):p=t[7];const g=h.description??"Ask anything about configuring model providers or using MCP Mesh.";let v;t[8]!==g?(v=n.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:g}),t[8]=g,t[9]=v):v=t[9];let x;t[10]!==r||t[11]!==c?.metadata?.vmMap||t[12]!==u||t[13]!==e.id||t[14]!==e.slug||t[15]!==o||t[16]!==f||t[17]!==d?(x=f&&n.jsx("div",{className:"mt-2",children:n.jsx($d,{orgId:e.id,orgSlug:e.slug,userId:d,connectionId:u.connectionId,owner:u.owner,repo:u.name,vmMap:c?.metadata?.vmMap,value:r??void 0,onChange:o})}),t[10]=r,t[11]=c?.metadata?.vmMap,t[12]=u,t[13]=e.id,t[14]=e.slug,t[15]=o,t[16]=f,t[17]=d,t[18]=x):x=t[18];let b;t[19]!==_||t[20]!==p||t[21]!==v||t[22]!==x?(b=n.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[_,p,v,x]}),t[19]=_,t[20]=p,t[21]=v,t[22]=x,t[23]=b):b=t[23];let S;t[24]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx("div",{className:"w-full max-w-3xl mx-auto",children:n.jsx(Ne.IceBreakers,{})}),t[24]=S):S=t[24];let w;return t[25]!==b?(w=n.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center gap-6 px-4",children:[b,S]}),t[25]=b,t[26]=w):w=t[26],w}function Fd(){const t=z.c(26),{org:e}=me(),s=rh(),{isChatEmpty:i}=rs(),[r,o]=A.useState("chat"),a=pc();if(s.length===0){let b;return t[0]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(Ne,{className:"animate-in fade-in-0 duration-200",children:n.jsx(Ne.Main,{className:"flex flex-col items-center",children:n.jsx(Ne.EmptyState,{children:n.jsx(Ne.NoAiProviderEmptyState,{})})})}),t[0]=b):b=t[0],b}let l;t[1]!==a.hasDecoKey||t[2]!==a.hasOnlyDecoProvider||t[3]!==a.isLoading||t[4]!==a.isZeroBalance||t[5]!==i||t[6]!==e?(l=a.hasDecoKey&&a.isZeroBalance&&a.hasOnlyDecoProvider&&!a.isLoading&&i&&!gc(e.id),t[1]=a.hasDecoKey,t[2]=a.hasOnlyDecoProvider,t[3]=a.isLoading,t[4]=a.isZeroBalance,t[5]=i,t[6]=e,t[7]=l):l=t[7];const h=l;let c;t[8]!==h?(c=h&&n.jsx(Ne.CreditsEmptyState,{}),t[8]=h,t[9]=c):c=t[9];const d=r!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let u;t[10]!==d?(u=te("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",d),t[10]=d,t[11]=u):u=t[11];let f;t[12]!==i?(f=i?n.jsxs(n.Fragment,{children:[n.jsx(Ne.Main,{children:n.jsx(zd,{})}),n.jsx(Ne.Footer,{children:n.jsx(Ne.Input,{onOpenContextPanel:()=>o("context")})})]}):n.jsxs(n.Fragment,{children:[n.jsx(Ne.Main,{children:n.jsx(Ne.Messages,{})}),n.jsx(Ne.Footer,{children:n.jsx(Ne.Input,{onOpenContextPanel:()=>o("context")})})]}),t[12]=i,t[13]=f):f=t[13];let m;t[14]!==u||t[15]!==f?(m=n.jsx("div",{className:u,children:f}),t[14]=u,t[15]=f,t[16]=m):m=t[16];const _=r==="context"?"opacity-100":"opacity-0 pointer-events-none";let p;t[17]!==_?(p=te("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",_),t[17]=_,t[18]=p):p=t[18];let g;t[19]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(pd,{back:!0,onClose:()=>o("chat")}),t[19]=g):g=t[19];let v;t[20]!==p?(v=n.jsx("div",{className:p,children:g}),t[20]=p,t[21]=v):v=t[21];let x;return t[22]!==c||t[23]!==m||t[24]!==v?(x=n.jsxs(Ne,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[c,m,v]}),t[22]=c,t[23]=m,t[24]=v,t[25]=x):x=t[25],x}function Va(){const t=z.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(Ne.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(Rt,{fallback:e,children:n.jsx(A.Suspense,{fallback:n.jsx(Ne.Skeleton,{}),children:n.jsx(Fd,{})})}),t[1]=s):s=t[1],s}async function Hd(t,e,s){const i=await t.callTool({name:e,arguments:s});if(i.isError){const r=i.content?.[0]?.text??`Tool ${e} failed without a message`;throw new Error(r)}return i}const Ka=["VM_START"],ai=new Map,Wd=t=>`${t.virtualMcpId}::${t.branch??""}`,Qi=new Set,vi={mark:(t,e)=>Qi.add(`${t}::${e}`),clear:(t,e)=>Qi.delete(`${t}::${e}`),isStopped:(t,e)=>Qi.has(`${t}::${e}`)};function qa(t){const e=_s();return na({mutationKey:Ka,mutationFn:async s=>{s.branch&&vi.clear(s.virtualMcpId,s.branch);const i=Wd(s),r=ai.get(i);if(r)return r;const o=(async()=>(await Hd(t,"VM_START",s)).structuredContent)();ai.set(i,o);try{return await o}finally{ai.get(i)===o&&ai.delete(i)}},onSuccess:()=>{oa(e)}})}function Ud(t,e){const s=z.c(3);let i;return s[0]!==e||s[1]!==t?(i={mutationKey:Ka,predicate:o=>{if(!t)return!1;const a=o.state.variables;return!a||a.virtualMcpId!==t?!1:(a.branch??"")===(e??"")}},s[0]=e,s[1]=t,s[2]=i):i=s[2],ad(i)>0}const Vd={settings:Vc,automations:Uc,preview:Pc,git:As};function Jn(t){const e=Oi(t);if(e.type==="icon"){const s=$i(e.name);return s?{kind:"component",Component:s}:null}return e.type==="url"?{kind:"url",src:e.url}:null}function er(t){if(t.kind==="system")return{kind:"component",Component:Vd[t.tabId]};const e=Jn(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=Jn(s.icon);return i||{kind:"fallback"}}function Kd(t){const{org:e}=me(),s=Ue({connectionId:Ft,orgId:e.id,orgSlug:e.slug}),i=Na(),r=A.useSyncExternalStore(i.threads.subscribe,i.threads.get),o=t?r.find(l=>l.id===t)??null:null,{data:a}=ac({queryKey:us.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 Ga(t){const e=z.c(8),s=is();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},e[0]=i):i=e[0];const r=aa(i),o=Pt(t.virtualMcpId),a=Kd(t.taskId),{currentBranch:l}=Ht(),h=o?.metadata?.ui??null,c=h?.layout??null,d=c?.tabs??[],u=h?.pinnedViews??[],f=a?.expanded_tools??[],m=!!(o&&Zt(o));let _;e[1]===Symbol.for("react.memo_cache_sentinel")?(_={includeVirtual:!0},e[1]=_):_=e[1];const p=qs(_),{activeTab:g,mainOpen:v}=Ac({mainParam:r.main,metadata:c?{defaultMainView:c.defaultMainView??null,tabs:d.map(qd)}:null}),x=_a(g),b=[];m&&(b.push({id:"preview",title:"Preview"}),b.push({id:"git",title:l??"git"})),b.push({id:"settings",title:"Settings"}),b.push({id:"automations",title:"Automations"});const S=new Map;for(const T of f){const B=Hn(T.appId,T.toolName);S.set(B,{id:B,title:T.toolName,appId:T.appId,iconKey:T.toolName})}for(const T of u){const B=Hn(T.connectionId,T.toolName);S.set(B,{id:B,title:T.label||T.toolName,appId:T.connectionId,iconKey:T.toolName,iconUrl:T.icon??null})}let w;e[2]!==p?(w=T=>({id:T.id,title:T.title,kind:"agent",icon:er({tabId:T.id,kind:"agent",appId:T.view.appId,connections:p})}),e[2]=p,e[3]=w):w=e[3];const k=[...d.map(w),...Array.from(S.values()).map(T=>({id:T.id,title:T.title,kind:"expanded",icon:er({tabId:T.iconKey,kind:"expanded",appId:T.appId,iconUrl:T.iconUrl,connections:p})})),...b.map(T=>({id:T.id,title:T.title,kind:"system",icon:er({tabId:T.id,kind:"system",connections:p})}))];let C;return e[4]!==g||e[5]!==v||e[6]!==s?(C=T=>{const B=Bc({clickedId:T,activeTab:g,mainOpen:v});s({to:".",search:I=>({...I,main:B}),replace:!0})},e[4]=g,e[5]=v,e[6]=s,e[7]=C):C=e[7],{activeTab:g,mainOpen:v,setActiveTab:C,systemTabs:b,layoutTabs:d,expandedTools:f,automationTabParsed:x,tabs:k}}function qd(t){return{id:t.id}}function Ya(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.
|
|
3
|
-
<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 Gd(t){const e=z.c(84),{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,m=d===void 0?!1:d,[_,p]=A.useState(!1),[g,v]=A.useState("icons"),[x,b]=A.useState(""),[S,w]=A.useState("blue");let k;e[0]!==s?(k=Oi(s),e[0]=s,e[1]=k):k=e[1];const C=k,E=C.type==="icon"||C.type==="url"&&C.color?C.color:S;let T;e[2]!==i||e[3]!==E?(T=$e=>{i(Xi($e,E))},e[2]=i,e[3]=E,e[4]=T):T=e[4];const B=T;let I;e[5]!==i||e[6]!==r||e[7]!==C.name||e[8]!==C.type||e[9]!==C.url?(I=$e=>{w($e),r?.($e),C.type==="icon"?i(Xi(C.name,$e)):C.type==="url"&&i(Un(C.url,$e))},e[5]=i,e[6]=r,e[7]=C.name,e[8]=C.type,e[9]=C.url,e[10]=I):I=e[10];const R=I;let y;e[11]!==i||e[12]!==E?(y=$e=>{i(Un($e,E)),p(!1)},e[11]=i,e[12]=E,e[13]=y):y=e[13];const D=y;let N;e[14]!==i||e[15]!==E?(N=()=>{const $e=vn(),os=$e[Math.floor(Math.random()*$e.length)];i(Xi(os,E))},e[14]=i,e[15]=E,e[16]=N):N=e[16];const j=N;let M,P,F,W,O,$,H,V;if(e[17]!==l||e[18]!==m||e[19]!==_||e[20]!==u){const $e={xs:"rounded-md",sm:"rounded-lg","sm+":"rounded-xl",md:"rounded-xl",lg:"rounded-2xl",xl:"rounded-2xl"};P=Vt,$=m?!1:_,H=p,M=Wt,O=!0,V="button",F=m,W=te("relative group overflow-hidden",m?"cursor-default opacity-50":"cursor-pointer",$e[u],l),e[17]=l,e[18]=m,e[19]=_,e[20]=u,e[21]=M,e[22]=P,e[23]=F,e[24]=W,e[25]=O,e[26]=$,e[27]=H,e[28]=V}else M=e[21],P=e[22],F=e[23],W=e[24],O=e[25],$=e[26],H=e[27],V=e[28];let re;e[29]!==h||e[30]!==o||e[31]!==u||e[32]!==s?(re=n.jsx(Vn,{icon:s,name:o,size:u,className:h}),e[29]=h,e[30]=o,e[31]=u,e[32]=s,e[33]=re):re=e[33];let X;e[34]!==m||e[35]!==f?(X=f&&!m&&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(xn,{size:16,className:"text-white"})}),e[34]=m,e[35]=f,e[36]=X):X=e[36];let J;e[37]!==F||e[38]!==W||e[39]!==re||e[40]!==X||e[41]!==V?(J=n.jsxs("button",{type:V,disabled:F,className:W,children:[re,X]}),e[37]=F,e[38]=W,e[39]=re,e[40]=X,e[41]=V,e[42]=J):J=e[42];let Z;e[43]!==M||e[44]!==O||e[45]!==J?(Z=n.jsx(M,{asChild:O,children:J}),e[43]=M,e[44]=O,e[45]=J,e[46]=Z):Z=e[46];let L;e[47]!==o||e[48]!==s?(L=n.jsx("div",{className:"flex items-center justify-center py-4",children:n.jsx(Vn,{icon:s,name:o,size:"xl"})}),e[47]=o,e[48]=s,e[49]=L):L=e[49];let K;e[50]===Symbol.for("react.memo_cache_sentinel")?(K=()=>v("icons"),e[50]=K):K=e[50];const Q=g==="icons"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let G;e[51]!==Q?(G=te("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",Q),e[51]=Q,e[52]=G):G=e[52];let ee;e[53]!==G?(ee=n.jsx("button",{type:"button",onClick:K,className:G,children:"Icons"}),e[53]=G,e[54]=ee):ee=e[54];let oe;e[55]===Symbol.for("react.memo_cache_sentinel")?(oe=()=>v("upload"),e[55]=oe):oe=e[55];const _e=g==="upload"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let ge;e[56]!==_e?(ge=te("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",_e),e[56]=_e,e[57]=ge):ge=e[57];let we;e[58]!==ge?(we=n.jsx("button",{type:"button",onClick:oe,className:ge,children:"Upload"}),e[58]=ge,e[59]=we):we=e[59];let je;e[60]===Symbol.for("react.memo_cache_sentinel")?(je=n.jsx("div",{className:"flex-1"}),e[60]=je):je=e[60];let De;e[61]!==ee||e[62]!==we?(De=n.jsxs("div",{className:"flex items-center border-b border-border px-3",children:[ee,we,je]}),e[61]=ee,e[62]=we,e[63]=De):De=e[63];let ne;e[64]!==R||e[65]!==j||e[66]!==B||e[67]!==D||e[68]!==C.name||e[69]!==C.type||e[70]!==x||e[71]!==E||e[72]!==g?(ne=g==="icons"?n.jsx(Zd,{search:x,onSearchChange:b,selectedColor:E,onColorChange:R,onSelectIcon:B,onRandom:j,currentIconName:C.type==="icon"?C.name:null}):n.jsx(Qd,{onUpload:D}),e[64]=R,e[65]=j,e[66]=B,e[67]=D,e[68]=C.name,e[69]=C.type,e[70]=x,e[71]=E,e[72]=g,e[73]=ne):ne=e[73];let le;e[74]!==L||e[75]!==De||e[76]!==ne?(le=n.jsx(Ut,{align:"start",className:"w-80 p-0",onOpenAutoFocus:Yd,children:n.jsxs("div",{className:"flex flex-col",children:[L,De,ne]})}),e[74]=L,e[75]=De,e[76]=ne,e[77]=le):le=e[77];let Ee;return e[78]!==P||e[79]!==$||e[80]!==H||e[81]!==Z||e[82]!==le?(Ee=n.jsxs(P,{open:$,onOpenChange:H,children:[Z,le]}),e[78]=P,e[79]=$,e[80]=H,e[81]=Z,e[82]=le,e[83]=Ee):Ee=e[83],Ee}function Yd(t){return t.preventDefault()}function Xd(t){const e=z.c(27),{selectedColor:s,onColorChange:i}=t,[r,o]=A.useState(!1);let a,l,h,c,d,u,f;if(e[0]!==r||e[1]!==s){const x=pa(s);l=Vt,u=r,f=o,a=Wt,d=!0,h="button",c=te("h-6 w-6 rounded-full shrink-0 ring-2 ring-offset-2 ring-offset-background transition-all cursor-pointer hover:scale-110",x.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 m;e[9]!==h||e[10]!==c?(m=n.jsx("button",{type:h,className:c,title:"Change color"}),e[9]=h,e[10]=c,e[11]=m):m=e[11];let _;e[12]!==a||e[13]!==d||e[14]!==m?(_=n.jsx(a,{asChild:d,children:m}),e[12]=a,e[13]=d,e[14]=m,e[15]=_):_=e[15];let p;e[16]!==i||e[17]!==s?(p=qc.map(x=>n.jsx("button",{type:"button",onClick:()=>{i(x.name),o(!1)},className:te("h-5 w-5 rounded-full transition-all shrink-0 cursor-pointer",x.dot,s===x.name?"ring-2 ring-offset-1 ring-offset-background ring-foreground/30 scale-110":"hover:scale-110"),title:x.name},x.name)),e[16]=i,e[17]=s,e[18]=p):p=e[18];let g;e[19]!==p?(g=n.jsx(Ut,{align:"start",side:"right",sideOffset:8,className:"w-auto p-2",onOpenAutoFocus:Jd,children:n.jsx("div",{className:"grid grid-cols-4 gap-1",children:p})}),e[19]=p,e[20]=g):g=e[20];let v;return e[21]!==l||e[22]!==u||e[23]!==f||e[24]!==_||e[25]!==g?(v=n.jsxs(l,{open:u,onOpenChange:f,children:[_,g]}),e[21]=l,e[22]=u,e[23]=f,e[24]=_,e[25]=g,e[26]=v):v=e[26],v}function Jd(t){return t.preventDefault()}function Zd(t){const e=z.c(44),{search:s,onSearchChange:i,selectedColor:r,onColorChange:o,onSelectIcon:a,onRandom:l,currentIconName:h}=t;let c,d,u,f,m,_,p;if(e[0]!==h||e[1]!==o||e[2]!==l||e[3]!==i||e[4]!==a||e[5]!==s||e[6]!==r){const S=vn(),w=pa(r);d=s.trim()?S.filter(R=>{const y=br(R),D=s.toLowerCase();return y.includes(D)||R.toLowerCase().includes(D)}):S,_="flex flex-col";let k;e[14]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(Fa,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[14]=k):k=e[14];let C;e[15]!==i?(C=R=>i(R.target.value),e[15]=i,e[16]=C):C=e[16];let E;e[17]!==s||e[18]!==C?(E=n.jsxs("div",{className:"relative flex-1",children:[k,n.jsx(nt,{value:s,onChange:C,placeholder:"Filter...",className:"h-8 text-xs pl-7"})]}),e[17]=s,e[18]=C,e[19]=E):E=e[19];let T;e[20]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsx(Kc,{size:14,className:"text-muted-foreground"}),e[20]=T):T=e[20];let B;e[21]!==l?(B=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:T}),e[21]=l,e[22]=B):B=e[22];let I;e[23]!==o||e[24]!==r?(I=n.jsx(Xd,{selectedColor:r,onColorChange:o}),e[23]=o,e[24]=r,e[25]=I):I=e[25],e[26]!==B||e[27]!==I||e[28]!==E?(p=n.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[E,B,I]}),e[26]=B,e[27]=I,e[28]=E,e[29]=p):p=e[29],c=kn,m="h-56",u="grid grid-cols-9 gap-0.5 px-2 pb-2",f=d.map(R=>{const y=$i(R);return y?n.jsx("button",{type:"button",onClick:()=>a(R),className:te("h-8 w-8 flex items-center justify-center rounded-md transition-colors cursor-pointer",h===R?te(w.bg,w.text):te(w.text,"hover:bg-accent")),title:R,children:n.jsx(y,{size:18})},R):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]=m,e[12]=_,e[13]=p}else c=e[7],d=e[8],u=e[9],f=e[10],m=e[11],_=e[12],p=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 v;e[33]!==d.length?(v=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]=v):v=e[34];let x;e[35]!==c||e[36]!==m||e[37]!==g||e[38]!==v?(x=n.jsxs(c,{className:m,children:[g,v]}),e[35]=c,e[36]=m,e[37]=g,e[38]=v,e[39]=x):x=e[39];let b;return e[40]!==_||e[41]!==p||e[42]!==x?(b=n.jsxs("div",{className:_,children:[p,x]}),e[40]=_,e[41]=p,e[42]=x,e[43]=b):b=e[43],b}function Qd(t){const e=z.c(27),{onUpload:s}=t,i=A.useRef(null);let r;e[0]!==s?(r=k=>{const C=k.target.files?.[0];if(!C)return;if(C.size>2097152){he.error("Image must be smaller than 2MB"),k.target.value="";return}const E=new FileReader;E.onerror=()=>{he.error("Failed to read image file"),i.current&&(i.current.value="")},E.onloadend=()=>{E.readyState===FileReader.DONE&&E.result&&s(E.result),i.current&&(i.current.value="")},E.readAsDataURL(C)},e[0]=s,e[1]=r):r=e[1];const o=r,[a,l]=A.useState("");let h;e[2]!==s||e[3]!==a?(h=()=>{const k=a.trim();k&&(s(k),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(Dh,{size:20}),n.jsx("span",{className:"text-xs",children:"Click to upload an image (max 2MB)"})]}),e[8]=f):f=e[8];let m;e[9]===Symbol.for("react.memo_cache_sentinel")?(m=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]=m):m=e[9];let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=k=>l(k.target.value),e[10]=_):_=e[10];let p;e[11]!==c?(p=k=>{k.key==="Enter"&&(k.preventDefault(),c())},e[11]=c,e[12]=p):p=e[12];let g;e[13]!==a||e[14]!==p?(g=n.jsx(nt,{value:a,onChange:_,placeholder:"Paste image URL...",className:"h-8 text-xs flex-1",onKeyDown:p}),e[13]=a,e[14]=p,e[15]=g):g=e[15];let v;e[16]!==a?(v=a.trim(),e[16]=a,e[17]=v):v=e[17];const x=!v;let b;e[18]!==c||e[19]!==x?(b=n.jsx(se,{variant:"outline",size:"sm",className:"h-8 px-3 text-xs shrink-0",onClick:c,disabled:x,children:"Apply"}),e[18]=c,e[19]=x,e[20]=b):b=e[20];let S;e[21]!==b||e[22]!==g?(S=n.jsxs("div",{className:"flex items-center gap-1.5",children:[g,b]}),e[21]=b,e[22]=g,e[23]=S):S=e[23];let w;return e[24]!==S||e[25]!==d?(w=n.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[d,f,m,S]}),e[24]=S,e[25]=d,e[26]=w):w=e[26],w}function eu(t){const e=z.c(5),{value:s}=t;let i;if(e[0]!==s){i=Symbol.for("react.early_return_sentinel");e:{const o=Oi(s);if(o.type==="icon"){const a=$i(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(Ph,{size:16,className:"text-muted-foreground"}),e[4]=r):r=e[4],r}function tu(t){const e=z.c(66),{value:s,onChange:i,className:r,disabled:o}=t,[a,l]=A.useState(!1),[h,c]=A.useState("");let d;e[0]!==s?(d=Oi(s),e[0]=s,e[1]=d):d=e[1];const u=d,f=u.type==="icon"?u.name:null;let m,_,p,g,v,x,b,S,w,k,C,E,T,B,I;if(e[2]!==r||e[3]!==f||e[4]!==o||e[5]!==i||e[6]!==a||e[7]!==h||e[8]!==s){const P=vn();g=h.trim()?P.filter(re=>{const X=h.toLowerCase();return br(re).includes(X)||re.toLowerCase().includes(X)}):P,p=Vt,v=o?!1:a,x=l;const F=o?"cursor-default opacity-50":"cursor-pointer hover:bg-accent";let W;e[24]!==r||e[25]!==F?(W=te("size-7 shrink-0 rounded-md transition-colors flex items-center justify-center",F,r),e[24]=r,e[25]=F,e[26]=W):W=e[26];let O;e[27]!==s?(O=n.jsx(eu,{value:s}),e[27]=s,e[28]=O):O=e[28],e[29]!==o||e[30]!==W||e[31]!==O?(b=n.jsx(Wt,{asChild:!0,children:n.jsx("button",{type:"button",disabled:o,className:W,children:O})}),e[29]=o,e[30]=W,e[31]=O,e[32]=b):b=e[32],_=Ut,T="start",B="w-64 p-0",I=su,C="flex flex-col";let $;e[33]===Symbol.for("react.memo_cache_sentinel")?($=n.jsx(Fa,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[33]=$):$=e[33];let H;e[34]===Symbol.for("react.memo_cache_sentinel")?(H=re=>c(re.target.value),e[34]=H):H=e[34],e[35]!==h?(E=n.jsx("div",{className:"px-2 py-2",children:n.jsxs("div",{className:"relative",children:[$,n.jsx(nt,{value:h,onChange:H,placeholder:"Filter...",className:"h-7 text-xs pl-7"})]})}),e[35]=h,e[36]=E):E=e[36],m=kn,k="h-48",S="grid grid-cols-8 gap-0.5 px-2 pb-2";let V;e[37]!==f||e[38]!==i?(V=re=>{const X=$i(re);return X?n.jsx("button",{type:"button",onClick:()=>{i(`icon://${re}`),l(!1)},className:te("h-7 w-7 flex items-center justify-center rounded-md transition-colors cursor-pointer",f===re?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),title:br(re),children:n.jsx(X,{size:16})},re):null},e[37]=f,e[38]=i,e[39]=V):V=e[39],w=g.map(V),e[2]=r,e[3]=f,e[4]=o,e[5]=i,e[6]=a,e[7]=h,e[8]=s,e[9]=m,e[10]=_,e[11]=p,e[12]=g,e[13]=v,e[14]=x,e[15]=b,e[16]=S,e[17]=w,e[18]=k,e[19]=C,e[20]=E,e[21]=T,e[22]=B,e[23]=I}else m=e[9],_=e[10],p=e[11],g=e[12],v=e[13],x=e[14],b=e[15],S=e[16],w=e[17],k=e[18],C=e[19],E=e[20],T=e[21],B=e[22],I=e[23];let R;e[40]!==S||e[41]!==w?(R=n.jsx("div",{className:S,children:w}),e[40]=S,e[41]=w,e[42]=R):R=e[42];let y;e[43]!==g.length?(y=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]=y):y=e[44];let D;e[45]!==m||e[46]!==R||e[47]!==y||e[48]!==k?(D=n.jsxs(m,{className:k,children:[R,y]}),e[45]=m,e[46]=R,e[47]=y,e[48]=k,e[49]=D):D=e[49];let N;e[50]!==D||e[51]!==C||e[52]!==E?(N=n.jsxs("div",{className:C,children:[E,D]}),e[50]=D,e[51]=C,e[52]=E,e[53]=N):N=e[53];let j;e[54]!==_||e[55]!==N||e[56]!==T||e[57]!==B||e[58]!==I?(j=n.jsx(_,{align:T,className:B,onOpenAutoFocus:I,children:N}),e[54]=_,e[55]=N,e[56]=T,e[57]=B,e[58]=I,e[59]=j):j=e[59];let M;return e[60]!==p||e[61]!==v||e[62]!==x||e[63]!==b||e[64]!==j?(M=n.jsxs(p,{open:v,onOpenChange:x,children:[b,j]}),e[60]=p,e[61]=v,e[62]=x,e[63]=b,e[64]=j,e[65]=M):M=e[65],M}function su(t){return t.preventDefault()}function xi(){const t=z.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(Ae,{className:"animate-spin text-muted-foreground",size:24})}),t[0]=e):e=t[0],e}function tr(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(Ni,{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 iu(t){const e=z.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=te("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 m;e[12]!==u||e[13]!==f?(m=n.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[u,f]}),e[12]=u,e[13]=f,e[14]=m):m=e[14];let _;e[15]!==o||e[16]!==i||e[17]!==r?(_=n.jsx(Mh,{checked:i,onCheckedChange:r,disabled:o,className:"mt-0.5"}),e[15]=o,e[16]=i,e[17]=r,e[18]=_):_=e[18];let p;return e[19]!==h||e[20]!==m||e[21]!==_?(p=n.jsxs("label",{className:h,children:[m,_]}),e[19]=h,e[20]=m,e[21]=_,e[22]=p):p=e[22],p}function Nn(t){const e=z.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(ru);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(iu,{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 ru(t){return t.id}function nu(t){const e=z.c(13),{connectionId:s,selections:i,onToggle:r,disabled:o}=t,{org:a}=me();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=Ue(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:d}=Ah(c);let u;e[6]!==d.tools?(u=d.tools.map(ou),e[6]=d.tools,e[7]=u):u=e[7];const f=u;let m;return e[8]!==o||e[9]!==f||e[10]!==r||e[11]!==i?(m=n.jsx(Nn,{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]=m):m=e[12],m}function ou(t){return{id:t.name,name:t.name,description:t.description,tags:n.jsx(kh,{annotations:t.annotations,_meta:t._meta})}}function au(t){const e=z.c(13),{connectionId:s,selections:i,onToggle:r,disabled:o}=t,{org:a}=me();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=Ue(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:d}=yh(c);let u;e[6]!==d.resources?(u=d.resources.map(lu),e[6]=d.resources,e[7]=u):u=e[7];const f=u;let m;return e[8]!==o||e[9]!==f||e[10]!==r||e[11]!==i?(m=n.jsx(Nn,{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]=m):m=e[12],m}function lu(t){return{id:t.name||t.uri,name:t.name||t.uri,description:t.description}}function cu(t){const e=z.c(13),{connectionId:s,selections:i,onToggle:r,disabled:o}=t,{org:a}=me();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=Ue(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:d}=Bh(c);let u;e[6]!==d.prompts?(u=d.prompts.map(hu),e[6]=d.prompts,e[7]=u):u=e[7];const f=u;let m;return e[8]!==o||e[9]!==f||e[10]!==r||e[11]!==i?(m=n.jsx(Nn,{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]=m):m=e[12],m}function hu(t){return{id:t.name,name:t.name,description:t.description}}function du(t){const e=z.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,m=o[r],_=i==="tools"?m?.tools===null:i==="resources"?m?.resources===null:m?.prompts===null;let p;e[0]!==i||e[1]!==r||e[2]!==u||e[3]!==d||e[4]!==c?(p=()=>{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]=p):p=e[5];const g=p;let v;e[6]!==s.icon||e[7]!==s.title?(v=n.jsx(Ct,{icon:s.icon,name:s.title,size:"sm",className:"shrink-0"}),e[6]=s.icon,e[7]=s.title,e[8]=v):v=e[8];let x;e[9]!==s.title?(x=n.jsx("h2",{className:"text-base font-semibold truncate",children:s.title}),e[9]=s.title,e[10]=x):x=e[10];let b;e[11]!==s.description?(b=s.description&&n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.description}),e[11]=s.description,e[12]=b):b=e[12];let S;e[13]!==x||e[14]!==b?(S=n.jsxs("div",{className:"flex-1 min-w-0",children:[x,b]}),e[13]=x,e[14]=b,e[15]=S):S=e[15];let w;e[16]!==v||e[17]!==S?(w=n.jsx("div",{className:"px-6 pt-5 pb-4 shrink-0",children:n.jsxs("div",{className:"flex items-center gap-3",children:[v,S]})}),e[16]=v,e[17]=S,e[18]=w):w=e[18];let k;e[19]===Symbol.for("react.memo_cache_sentinel")?(k=[{id:"tools",label:"Tools"},{id:"resources",label:"Resources"},{id:"prompts",label:"Prompts"}],e[19]=k):k=e[19];let C;e[20]!==f?(C=M=>f(M),e[20]=f,e[21]=C):C=e[21];let E;e[22]!==i||e[23]!==C?(E=n.jsx(Ih,{tabs:k,activeTab:i,onTabChange:C}),e[22]=i,e[23]=C,e[24]=E):E=e[24];const T=_?"Deselect all":"Select all";let B;e[25]!==g||e[26]!==T?(B=n.jsx("button",{type:"button",onClick:g,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:T}),e[25]=g,e[26]=T,e[27]=B):B=e[27];let I;e[28]!==B||e[29]!==E?(I=n.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-t border-border shrink-0",children:[E,B]}),e[28]=B,e[29]=E,e[30]=I):I=e[30];let R;e[31]!==i||e[32]!==o||e[33]!==r||e[34]!==a?(R=i==="tools"&&n.jsx(Rt,{fallback:tr("Tools not supported by this server"),children:n.jsx(A.Suspense,{fallback:n.jsx(xi,{}),children:n.jsx(nu,{connectionId:r,selections:o[r]?o[r].tools:[],onToggle:(M,P)=>a(r,M,P)})})}),e[31]=i,e[32]=o,e[33]=r,e[34]=a,e[35]=R):R=e[35];let y;e[36]!==i||e[37]!==o||e[38]!==r||e[39]!==l?(y=i==="resources"&&n.jsx(Rt,{fallback:tr("Resources not supported by this server"),children:n.jsx(A.Suspense,{fallback:n.jsx(xi,{}),children:n.jsx(au,{connectionId:r,selections:o[r]?o[r].resources:[],onToggle:(M,P)=>l(r,M,P)})})}),e[36]=i,e[37]=o,e[38]=r,e[39]=l,e[40]=y):y=e[40];let D;e[41]!==i||e[42]!==o||e[43]!==r||e[44]!==h?(D=i==="prompts"&&n.jsx(Rt,{fallback:tr("Prompts not supported by this server"),children:n.jsx(A.Suspense,{fallback:n.jsx(xi,{}),children:n.jsx(cu,{connectionId:r,selections:o[r]?o[r].prompts:[],onToggle:(M,P)=>h(r,M,P)})})}),e[41]=i,e[42]=o,e[43]=r,e[44]=h,e[45]=D):D=e[45];let N;e[46]!==R||e[47]!==y||e[48]!==D?(N=n.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[R,y,D]}),e[46]=R,e[47]=y,e[48]=D,e[49]=N):N=e[49];let j;return e[50]!==I||e[51]!==N||e[52]!==w?(j=n.jsxs(n.Fragment,{children:[w,I,N]}),e[50]=I,e[51]=N,e[52]=w,e[53]=j):j=e[53],j}function uu(t){const e=z.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=Ta(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(Gc,{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(se,{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 fu(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 Zn(t){return Object.entries(t).map(([e,s])=>({connection_id:e,selected_tools:s.tools,selected_resources:s.resources,selected_prompts:s.prompts}))}function mu(t,e){return e.type==="SET_ACTIVE_TAB"?{...t,activeTab:e.payload}:t}function _u(t){const e=z.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]=A.useReducer(mu,h),u=Sn(r??"");let f;e[1]!==a?(f=a??[],e[1]=a,e[2]=f):f=e[2];let m;e[3]!==f?(m=fu(f),e[3]=f,e[4]=m):m=e[4];const _=m;let p;e[5]!==o||e[6]!==_?(p=($,H,V,re)=>{const X=_[$]?.[H];let J;X===null?J=re.filter(L=>L!==V):X?.includes(V)?J=X.filter(L=>L!==V):(J=[...X??[],V],J.length===re.length&&(J=null));const Z={..._};Z[$]?Z[$]={...Z[$]}:Z[$]={tools:null,resources:null,prompts:null},Z[$][H]=J,o.setValue("connections",Zn(Z),{shouldDirty:!0,shouldTouch:!0})},e[5]=o,e[6]=_,e[7]=p):p=e[7];const g=p;let v;e[8]!==o||e[9]!==_?(v=($,H)=>{const re=_[$]?.[H]===null?[]:null,X={..._};X[$]?X[$]={...X[$]}:X[$]={tools:null,resources:null,prompts:null},X[$][H]=re,o.setValue("connections",Zn(X),{shouldDirty:!0,shouldTouch:!0})},e[8]=o,e[9]=_,e[10]=v):v=e[10];const x=v;let b;e[11]!==g?(b=($,H,V)=>g($,"tools",H,V),e[11]=g,e[12]=b):b=e[12];const S=b;let w;e[13]!==g?(w=($,H,V)=>g($,"resources",H,V),e[13]=g,e[14]=w):w=e[14];const k=w;let C;e[15]!==g?(C=($,H,V)=>g($,"prompts",H,V),e[15]=g,e[16]=C):C=e[16];const E=C;let T;e[17]!==x?(T=$=>x($,"tools"),e[17]=x,e[18]=T):T=e[18];const B=T;let I;e[19]!==x?(I=$=>x($,"resources"),e[19]=x,e[20]=I):I=e[20];const R=I;let y;e[21]!==x?(y=$=>x($,"prompts"),e[21]=x,e[22]=y):y=e[22];const D=y;if(!r||!u)return null;let N;e[23]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx(xi,{}),e[23]=N):N=e[23];let j;e[24]===Symbol.for("react.memo_cache_sentinel")?(j=$=>d({type:"SET_ACTIVE_TAB",payload:$}),e[24]=j):j=e[24];let M;e[25]!==u||e[26]!==c.activeTab||e[27]!==_||e[28]!==r||e[29]!==D||e[30]!==R||e[31]!==B||e[32]!==E||e[33]!==k||e[34]!==S?(M=n.jsx(du,{currentConnection:u,activeTab:c.activeTab,selectedId:r,formData:_,toggleTool:S,toggleResource:k,togglePrompt:E,toggleAllTools:B,toggleAllResources:R,toggleAllPrompts:D,onTabChange:j},r),e[25]=u,e[26]=c.activeTab,e[27]=_,e[28]=r,e[29]=D,e[30]=R,e[31]=B,e[32]=E,e[33]=k,e[34]=S,e[35]=M):M=e[35];let P;e[36]!==l||e[37]!==r||e[38]!==M?(P=n.jsx(A.Suspense,{fallback:N,children:n.jsx(uu,{connectionId:r,onAuthenticate:l,children:M})}),e[36]=l,e[37]=r,e[38]=M,e[39]=P):P=e[39];let F;e[40]!==i?(F=n.jsx($a,{className:"px-6 py-4 border-t border-border shrink-0",children:n.jsx(se,{variant:"outline",onClick:()=>i(!1),children:"Done"})}),e[40]=i,e[41]=F):F=e[41];let W;e[42]!==P||e[43]!==F?(W=n.jsxs(zi,{className:"sm:max-w-2xl h-[75vh] max-h-[75vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[P,F]}),e[42]=P,e[43]=F,e[44]=W):W=e[44];let O;return e[45]!==i||e[46]!==s||e[47]!==W?(O=n.jsx(Fi,{open:s,onOpenChange:i,children:W}),e[45]=i,e[46]=s,e[47]=W,e[48]=O):O=e[48],O}const sr={tools:null,resources:null,prompts:null},pu=lc.pick({status:!0,title:!0,description:!0,icon:!0,metadata:!0,connections:!0});function gu(t){const s=new TextEncoder().encode(t),i=Array.from(s,r=>String.fromCharCode(r)).join("");return btoa(i)}function vu(t){const e=z.c(11),{url:s,agentId:i}=t,[r,o]=A.useState(!1);let a;e[0]!==i||e[1]!==s?(a=async()=>{ve("agent_connect_action",{agent_id:i,action:"copy_url"}),await navigator.clipboard.writeText(s),o(!0),he.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(ps,{size:20,className:"text-green-600"}):n.jsx(dn,{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(se,{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 xu(t){const e=z.c(8),{url:s,serverName:i,agentId:r}=t;let o;e[0]!==r||e[1]!==i||e[2]!==s?(o=()=>{ve("agent_connect_action",{agent_id:r,action:"install_cursor"});const d=Ra(i),f=gu(JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Cursor"}},null,2)),m=`cursor://anysphere.cursor-deeplink/mcp/install?name=${encodeURIComponent(d)}&config=${encodeURIComponent(f)}`;window.open(m,"_blank"),he.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(se,{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 bu(t){const e=z.c(12),{url:s,serverName:i,agentId:r}=t,[o,a]=A.useState(!1);let l;e[0]!==r||e[1]!==i||e[2]!==s?(l=async()=>{ve("agent_connect_action",{agent_id:r,action:"install_claude_code"});const m=Ra(i),p=JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Claude Code"}},null,2),g=`claude mcp add-json "${m}" '${p.replace(/'/g,"'\\''")}' --scope user`;await navigator.clipboard.writeText(g),a(!0),he.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(ps,{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(se,{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 Su({virtualMcp:t}){const{org:e}=me(),s=Ue({connectionId:Ft,orgId:e.id,orgSlug:e.slug}),[i,r]=A.useState(null),[o,a]=A.useState(!1),[l,h]=A.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 p=(await s.callTool({name:"API_KEY_CREATE",arguments:{name:`typegen-${d}`,permissions:{[c]:["*"]}}})).structuredContent?.key;if(!p)throw new Error("No key in response");r(p),ve("agent_typegen_key_generated",{agent_id:c})}catch{ve("agent_typegen_key_failed",{agent_id:c}),he.error("Failed to generate API key")}finally{a(!1)}},m=async()=>{ve("agent_connect_action",{agent_id:c,action:"typegen_copy_command",has_api_key:!!i}),await navigator.clipboard.writeText(u),h(!0),he.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(se,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:f,disabled:o,children:[o?n.jsx(Ae,{size:14,className:"animate-spin"}):n.jsx(Wa,{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(se,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:m,children:l?n.jsx(ps,{size:12,className:"text-green-600"}):n.jsx(dn,{size:12})})]})}),n.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Runtime variables"}),n.jsx(yu,{apiKey:i,agentId:c})]})}function yu(t){const e=z.c(21),{apiKey:s,agentId:i}=t,[r,o]=A.useState(!1),a=window.location.origin,l=s?`MESH_API_KEY=${s}`:"MESH_API_KEY=<api-key>",h=`MESH_BASE_URL=${a}`,c=`${l}
|
|
4
|
-
${h}`;let d;e[0]!==i||e[1]!==s||e[2]!==c?(d=async()=>{ve("agent_connect_action",{agent_id:i,action:"typegen_copy_env",has_api_key:!!s}),await navigator.clipboard.writeText(c),o(!0),setTimeout(()=>o(!1),2e3)},e[0]=i,e[1]=s,e[2]=c,e[3]=d):d=e[3];const u=d,f=!s;let m;e[4]!==f?(m=te({"opacity-50":f}),e[4]=f,e[5]=m):m=e[5];let _;e[6]!==l||e[7]!==m?(_=n.jsx("span",{className:m,children:l}),e[6]=l,e[7]=m,e[8]=_):_=e[8];let p,g;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx("br",{}),g=n.jsx("span",{children:h}),e[9]=p,e[10]=g):(p=e[9],g=e[10]);let v;e[11]!==_?(v=n.jsxs("code",{className:"min-w-0 flex-1 font-mono text-xs text-muted-foreground",children:[_,p,g]}),e[11]=_,e[12]=v):v=e[12];let x;e[13]!==r?(x=r?n.jsx(ps,{size:12,className:"text-green-600"}):n.jsx(dn,{size:12}),e[13]=r,e[14]=x):x=e[14];let b;e[15]!==u||e[16]!==x?(b=n.jsx(se,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:u,children:x}),e[15]=u,e[16]=x,e[17]=b):b=e[17];let S;return e[18]!==v||e[19]!==b?(S=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:[v,b]})}),e[18]=v,e[19]=b,e[20]=S):S=e[20],S}function wu(t){const e=z.c(3),{virtualMcp:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"h-20 animate-pulse rounded-md bg-muted"}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsx(A.Suspense,{fallback:i,children:n.jsx(Su,{virtualMcp:s})}),e[1]=s,e[2]=r):r=e[2],r}function Cu(t){const e=z.c(37),{open:s,onOpenChange:i,virtualMcp:r}=t,{org:o}=me(),a=`/api/${o.slug}/mcp/virtual-mcp/${r.id}`;let l;e[0]!==a?(l=new URL(a,window.location.origin),e[0]=a,e[1]=l):l=e[1];const h=l;let c;e[2]!==r.id||e[3]!==r.title?(c=r.title||`agent-${r.id?.slice(0,8)??"default"}`,e[2]=r.id,e[3]=r.title,e[4]=c):c=e[4];const d=c,u=Ca();let f;e[5]!==r.id||e[6]!==h.href?(f=n.jsx(vu,{url:h.href,agentId:r.id}),e[5]=r.id,e[6]=h.href,e[7]=f):f=e[7];let m,_;e[8]!==d||e[9]!==r.id||e[10]!==h.href?(m=n.jsx(xu,{url:h.href,serverName:d,agentId:r.id}),_=n.jsx(bu,{url:h.href,serverName:d,agentId:r.id}),e[8]=d,e[9]=r.id,e[10]=h.href,e[11]=m,e[12]=_):(m=e[11],_=e[12]);let p;e[13]!==f||e[14]!==m||e[15]!==_?(p=n.jsx("div",{className:"flex flex-col gap-3 pt-2",children:n.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[f,m,_]})}),e[13]=f,e[14]=m,e[15]=_,e[16]=p):p=e[16];let g;e[17]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("div",{className:"border-t border-border"}),e[17]=g):g=e[17];let v;e[18]!==r?(v=n.jsx(wu,{virtualMcp:r}),e[18]=r,e[19]=v):v=e[19];let x;e[20]!==p||e[21]!==v?(x=n.jsxs("div",{className:"flex flex-col gap-6",children:[p,g,v]}),e[20]=p,e[21]=v,e[22]=x):x=e[22];const b=x;if(u){let C;e[23]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx($h,{className:"mt-4 mb-4 text-base font-semibold",children:"Connect"}),e[23]=C):C=e[23];let E;e[24]!==b?(E=n.jsx(zh,{children:n.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-6 [touch-action:pan-y]",children:[C,b]})}),e[24]=b,e[25]=E):E=e[25];let T;return e[26]!==i||e[27]!==s||e[28]!==E?(T=n.jsx(Fh,{open:s,onOpenChange:i,children:E}),e[26]=i,e[27]=s,e[28]=E,e[29]=T):T=e[29],T}let S;e[30]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(yn,{children:n.jsx(wn,{children:"Connect"})}),e[30]=S):S=e[30];let w;e[31]!==b?(w=n.jsxs(zi,{className:"max-h-[80vh] overflow-y-auto sm:max-w-2xl",children:[S,b]}),e[31]=b,e[32]=w):w=e[32];let k;return e[33]!==i||e[34]!==s||e[35]!==w?(k=n.jsx(Fi,{open:s,onOpenChange:i,children:w}),e[33]=i,e[34]=s,e[35]=w,e[36]=k):k=e[36],k}const ku=/^[A-Za-z_][A-Za-z0-9_]*$/;function Nu(t){const e={},s=t.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=(s[i]??"").trim();if(!r||r.startsWith("#"))continue;r.startsWith("export ")&&(r=r.slice(7).trim());const o=r.indexOf("=");if(o<0)throw new Error(`Line ${i+1}: missing '='`);const a=r.slice(0,o).trim();if(!ku.test(a))throw new Error(`Line ${i+1}: invalid key "${a}"`);let l=r.slice(o+1).trim();l.length>=2&&(l.startsWith('"')&&l.endsWith('"')||l.startsWith("'")&&l.endsWith("'"))&&(l=l.slice(1,-1)),e[a]=l}return e}const ju=/^[A-Za-z_][A-Za-z0-9_]*$/,Eu=/^[A-Za-z0-9_.-]+$/;function Tu(t){const e=z.c(14),{control:s,form:i,virtualMcpId:r,orgSlug:o}=t;let a,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("div",{className:"flex items-baseline justify-between gap-2",children:n.jsx(Je,{className:"font-normal text-foreground",children:"Environment variables"})}),l=n.jsx("p",{className:"text-xs text-muted-foreground",children:"Injected into the sandbox on every start. Reference an org/user secret to keep values out of metadata; literals are stored inline."}),e[0]=a,e[1]=l):(a=e[0],l=e[1]);let h;e[2]!==s||e[3]!==i||e[4]!==o||e[5]!==r?(h=n.jsx(Du,{control:s,form:i,virtualMcpId:r,orgSlug:o}),e[2]=s,e[3]=i,e[4]=o,e[5]=r,e[6]=h):h=e[6];let c;e[7]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Hh,{className:"h-9 w-full"}),e[7]=c):c=e[7];let d;e[8]!==s||e[9]!==i?(d=n.jsx(Rt,{fallback:Ru,children:n.jsx(A.Suspense,{fallback:c,children:n.jsx(Iu,{control:s,form:i})})}),e[8]=s,e[9]=i,e[10]=d):d=e[10];let u;return e[11]!==h||e[12]!==d?(u=n.jsxs("div",{className:"space-y-2",children:[a,l,h,d]}),e[11]=h,e[12]=d,e[13]=u):u=e[13],u}function Ru(t){const{error:e}=t;return n.jsx("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-xs text-destructive",children:e?.message??"Failed to load secrets"})}function Du(t){const e=z.c(22),{control:s,form:i,virtualMcpId:r,orgSlug:o}=t,l=Li.useSession().data?.user?.id,h="metadata.runtime.env",c="metadata.vmMap";let d;e[0]!==i?(d=()=>JSON.stringify(i.getValues(h)??[]),e[0]=i,e[1]=d):d=e[1];const[u,f]=A.useState(d);let m;e[2]!==s?(m={control:s,name:h},e[2]=s,e[3]=m):m=e[3];const _=la(m),p=JSON.stringify(_??[])!==u;let g;e[4]!==i?(g=i.getValues(c),e[4]=i,e[5]=g):g=e[5];const v=g;let x;e[6]!==l||e[7]!==v?(x=l?Object.keys(v?.[l]??{}):[],e[6]=l,e[7]=v,e[8]=x):x=e[8];const b=x,S=b.length>0,[w,k]=A.useState(!1);if(!p||!S)return null;let C;e[9]!==i||e[10]!==o||e[11]!==b||e[12]!==r?(C=async()=>{k(!0);const y=await Promise.allSettled(b.map(async N=>{const j=`/api/${encodeURIComponent(o)}/vm/${encodeURIComponent(r)}/${encodeURIComponent(N)}/setup/start`,M=await fetch(j,{method:"POST"});if(!M.ok){const P=await M.text().catch(()=>M.statusText);throw new Error(P||M.statusText)}}));k(!1);const D=y.filter(Pu).length;D===0?(f(JSON.stringify(i.getValues(h)??[])),he.success(b.length===1?"Restarted dev with new env":`Restarted ${b.length} branches with new env`)):he.error(`Failed to restart ${D} of ${b.length} branch(es)`)},e[9]=i,e[10]=o,e[11]=b,e[12]=r,e[13]=C):C=e[13];const E=C;let T;e[14]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-amber-900 dark:text-amber-200",children:[n.jsx(Ni,{className:"size-3.5 shrink-0"}),n.jsx("span",{className:"truncate",children:"Your sandbox is running. Restart the dev script to apply the new env."})]}),e[14]=T):T=e[14];let B;e[15]!==w?(B=w?n.jsx(Ae,{className:"size-3.5 animate-spin"}):n.jsx(zs,{className:"size-3.5"}),e[15]=w,e[16]=B):B=e[16];const I=w?"Restarting…":"Restart dev";let R;return e[17]!==E||e[18]!==w||e[19]!==B||e[20]!==I?(R=n.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs dark:border-amber-900/40 dark:bg-amber-950/30",children:[T,n.jsxs(se,{type:"button",variant:"outline",size:"sm",onClick:E,disabled:w,className:"shrink-0",children:[B,I]})]}),e[17]=E,e[18]=w,e[19]=B,e[20]=I,e[21]=R):R=e[21],R}function Pu(t){return t.status==="rejected"}function Iu(t){const e=z.c(48),{control:s,form:i}=t,r="metadata.runtime.env";let o;e[0]!==s?(o={control:s,name:r},e[0]=s,e[1]=o):o=e[1];const a=cc(o),{fields:l,append:h,remove:c}=a;let d;e[2]!==i?(d=(N,j)=>{i.setValue(`${r}.${N}`,j,{shouldDirty:!0,shouldTouch:!0})},e[2]=i,e[3]=d):d=e[3];const u=d,f=Kh();let m;if(e[4]!==f){m=new Map;for(const N of f)m.set(N.id,N);e[4]=f,e[5]=m}else m=e[5];const[_,p]=A.useState(null);let g;e[6]!==h?(g=()=>{h({key:"",kind:"literal",value:""})},e[6]=h,e[7]=g):g=e[7];const v=g;let x;e[8]!==h||e[9]!==i?(x=async()=>{let N;try{N=await navigator.clipboard.readText()}catch{he.error("Couldn't read clipboard");return}if(!N.trim()){he.error("Clipboard is empty");return}let j;try{j=Nu(N)}catch($){const H=$;he.error(H.message);return}const M=Object.entries(j);if(M.length===0){he.error("Nothing to add");return}const P=i.getValues(r)??[],F=new Set;for(const $ of P){const H=($.key??"").trim();H&&F.add(H)}let W=0,O=0;for(const[$,H]of M){if(F.has($)){O++;continue}h({key:$,kind:"literal",value:H}),F.add($),W++}W===0&&O>0?he.message(`All ${O} key${O===1?"":"s"} already exist`):he.success(O>0?`Added ${W} var${W===1?"":"s"} (${O} already existed)`:`Added ${W} var${W===1?"":"s"}`)},e[8]=h,e[9]=i,e[10]=x):x=e[10];const b=x;let S;if(e[11]!==s||e[12]!==l||e[13]!==i||e[14]!==c||e[15]!==m||e[16]!==f||e[17]!==u){let N;e[19]!==s||e[20]!==i||e[21]!==c||e[22]!==m||e[23]!==f||e[24]!==u?(N=(j,M)=>n.jsx("li",{className:"rounded-md border border-border bg-background",children:n.jsx(Mu,{index:M,control:s,form:i,onUpdateEntry:u,fieldPath:r,secrets:f,secretById:m,onSaveAsSecret:(P,F)=>p({kind:"save-literal",index:M,presetKey:P,presetValue:F}),onCreateNewSecret:P=>p({kind:"create-new",index:M,presetKey:P}),onRemove:()=>c(M)})},j.id),e[19]=s,e[20]=i,e[21]=c,e[22]=m,e[23]=f,e[24]=u,e[25]=N):N=e[25],S=l.map(N),e[11]=s,e[12]=l,e[13]=i,e[14]=c,e[15]=m,e[16]=f,e[17]=u,e[18]=S}else S=e[18];let w;e[26]!==S?(w=n.jsx("ul",{className:"space-y-2",children:S}),e[26]=S,e[27]=w):w=e[27];let k;e[28]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(es,{className:"size-3.5"}),e[28]=k):k=e[28];let C;e[29]!==v?(C=n.jsxs(se,{type:"button",variant:"outline",size:"sm",onClick:v,className:"flex-1",children:[k,"Add env var"]}),e[29]=v,e[30]=C):C=e[30];let E;e[31]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx(Yc,{className:"size-3.5"}),e[31]=E):E=e[31];let T;e[32]!==b?(T=n.jsx(xe,{asChild:!0,children:n.jsxs(se,{type:"button",variant:"outline",size:"sm",onClick:b,"aria-label":"Paste .env",children:[E,"Paste .env"]})}),e[32]=b,e[33]=T):T=e[33];let B;e[34]===Symbol.for("react.memo_cache_sentinel")?(B=n.jsx(be,{children:"Read a .env blob from the clipboard. Each pair is staged as a literal — save individual rows as secrets after."}),e[34]=B):B=e[34];let I;e[35]!==T?(I=n.jsxs(Se,{children:[T,B]}),e[35]=T,e[36]=I):I=e[36];let R;e[37]!==I||e[38]!==C?(R=n.jsxs("div",{className:"flex items-center gap-2",children:[C,I]}),e[37]=I,e[38]=C,e[39]=R):R=e[39];let y;e[40]!==_||e[41]!==i||e[42]!==u?(y=_!==null?n.jsx(Lu,{mode:_,onClose:()=>p(null),onSaved:N=>{const j=i.getValues(`${r}.${_.index}.key`)?.trim()??"";u(_.index,{key:j,kind:"secret",secretId:N}),p(null)}}):null,e[40]=_,e[41]=i,e[42]=u,e[43]=y):y=e[43];let D;return e[44]!==R||e[45]!==y||e[46]!==w?(D=n.jsxs("div",{className:"space-y-2",children:[w,R,y]}),e[44]=R,e[45]=y,e[46]=w,e[47]=D):D=e[47],D}function Mu(t){const e=z.c(55),{index:s,control:i,form:r,onUpdateEntry:o,fieldPath:a,secrets:l,secretById:h,onSaveAsSecret:c,onCreateNewSecret:d,onRemove:u}=t,f=`${a}.${s}.key`,m=`${a}.${s}.value`,_=`${a}.${s}.secretId`,p=`${a}.${s}.kind`;let g;e[0]!==i||e[1]!==p?(g={control:i,name:p},e[0]=i,e[1]=p,e[2]=g):g=e[2];const x=la(g)==="secret"?"secret":"literal";let b;e[3]!==r||e[4]!==s||e[5]!==f||e[6]!==c||e[7]!==o||e[8]!==m?(b=W=>{const O=r.getValues(f)?.trim()??"";if(W==="literal"){o(s,{key:O,kind:"literal",value:""});return}const $=r.getValues(m)??"";if($.length>0){c(O,$);return}o(s,{key:O,kind:"secret",secretId:""})},e[3]=r,e[4]=s,e[5]=f,e[6]=c,e[7]=o,e[8]=m,e[9]=b):b=e[9];const S=b;let w;e[10]!==s?(w=W=>{const{field:O}=W;return n.jsx(nt,{...O,value:O.value??"",placeholder:"KEY",spellCheck:!1,autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",className:"font-mono","aria-label":`Env var ${s+1} key`,onBlur:$=>{const H=$.target.value.trim();O.onChange(H),O.onBlur()}})},e[10]=s,e[11]=w):w=e[11];let k;e[12]!==i||e[13]!==f||e[14]!==w?(k=n.jsx("div",{className:"flex-1 min-w-0",children:n.jsx(rt,{control:i,name:f,render:w})}),e[12]=i,e[13]=f,e[14]=w,e[15]=k):k=e[15];let C;e[16]!==S?(C=W=>S(W),e[16]=S,e[17]=C):C=e[17];let E;e[18]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx(ft,{className:"h-9 w-[110px]",children:n.jsx(mt,{})}),e[18]=E):E=e[18];let T;e[19]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsx(Ge,{value:"literal",children:n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx(Wa,{className:"size-3.5"}),"Literal"]})}),e[19]=T):T=e[19];let B;e[20]===Symbol.for("react.memo_cache_sentinel")?(B=n.jsxs(_t,{children:[T,n.jsx(Ge,{value:"secret",children:n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx(Wh,{className:"size-3.5"}),"Secret"]})})]}),e[20]=B):B=e[20];let I;e[21]!==x||e[22]!==C?(I=n.jsx("div",{className:"shrink-0",children:n.jsxs(ut,{value:x,onValueChange:C,children:[E,B]})}),e[21]=x,e[22]=C,e[23]=I):I=e[23];let R;e[24]!==i||e[25]!==r||e[26]!==s||e[27]!==f||e[28]!==x||e[29]!==d||e[30]!==h||e[31]!==_||e[32]!==l||e[33]!==m?(R=n.jsx("div",{className:"flex flex-[2] min-w-0 items-center gap-1",children:x==="literal"?n.jsx(rt,{control:i,name:m,render:W=>{const{field:O}=W;return n.jsx(nt,{...O,value:O.value??"",type:"password",placeholder:"value",spellCheck:!1,autoComplete:"off",className:"font-mono","aria-label":`Env var ${s+1} value`,onBlur:$=>{O.onChange($.target.value),O.onBlur()}})}}):n.jsxs(n.Fragment,{children:[n.jsx(rt,{control:i,name:_,render:W=>{const{field:O}=W;return n.jsxs(ut,{value:O.value||"",onValueChange:$=>O.onChange($),children:[n.jsx(ft,{className:te("h-9 w-full",!O.value&&"text-muted-foreground"),children:n.jsx(mt,{placeholder:"Pick a secret…",children:n.jsx(Bu,{field:O,secretById:h})})}),n.jsx(_t,{children:l.length===0?n.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:"No secrets yet. Use the “+” to create one."}):l.map(Au)})]})}}),n.jsxs(Se,{children:[n.jsx(xe,{asChild:!0,children:n.jsx(se,{type:"button",variant:"ghost",size:"icon","aria-label":"Create new secret",onClick:()=>{const W=r.getValues(f)?.trim()??"";d(W)},children:n.jsx(es,{className:"size-3.5"})})}),n.jsx(be,{children:"Create new secret"})]})]})}),e[24]=i,e[25]=r,e[26]=s,e[27]=f,e[28]=x,e[29]=d,e[30]=h,e[31]=_,e[32]=l,e[33]=m,e[34]=R):R=e[34];let y;e[35]!==r||e[36]!==f||e[37]!==x||e[38]!==c||e[39]!==m?(y=x==="literal"?n.jsxs(Se,{children:[n.jsx(xe,{asChild:!0,children:n.jsx(se,{type:"button",variant:"ghost",size:"icon","aria-label":"Save value as secret",onClick:()=>{const W=r.getValues(f)?.trim()??"",O=r.getValues(m)??"";c(W,O)},children:n.jsx(Xc,{className:"size-3.5"})})}),n.jsx(be,{children:"Save value as secret"})]}):null,e[35]=r,e[36]=f,e[37]=x,e[38]=c,e[39]=m,e[40]=y):y=e[40];let D;e[41]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsx(Ri,{className:"size-3.5"}),e[41]=D):D=e[41];let N;e[42]!==u?(N=n.jsx(xe,{asChild:!0,children:n.jsx(se,{type:"button",variant:"ghost",size:"icon","aria-label":"Remove env var",onClick:u,children:D})}),e[42]=u,e[43]=N):N=e[43];let j;e[44]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx(be,{children:"Remove"}),e[44]=j):j=e[44];let M;e[45]!==N?(M=n.jsxs(Se,{children:[N,j]}),e[45]=N,e[46]=M):M=e[46];let P;e[47]!==y||e[48]!==M?(P=n.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[y,M]}),e[47]=y,e[48]=M,e[49]=P):P=e[49];let F;return e[50]!==R||e[51]!==P||e[52]!==k||e[53]!==I?(F=n.jsxs("div",{className:"flex flex-col gap-2 p-2 sm:flex-row sm:items-center",children:[k,I,R,P]}),e[50]=R,e[51]=P,e[52]=k,e[53]=I,e[54]=F):F=e[54],F}function Au(t){return n.jsx(Ge,{value:t.id,children:n.jsxs("span",{className:"inline-flex items-center gap-2",children:[n.jsx(Xa,{scope:t.scope}),n.jsx("span",{className:"font-mono",children:t.name})]})},t.id)}function Bu(t){const e=z.c(12),{field:s,secretById:i}=t,r=s.value||"";if(!r)return null;let o;e[0]!==r||e[1]!==i?(o=i.get(r),e[0]=r,e[1]=i,e[2]=o):o=e[2];const a=o;if(!a){let d;return e[3]!==r?(d=n.jsxs("span",{className:"text-destructive",children:["Missing secret (",r,")"]}),e[3]=r,e[4]=d):d=e[4],d}let l;e[5]!==a.scope?(l=n.jsx(Xa,{scope:a.scope}),e[5]=a.scope,e[6]=l):l=e[6];let h;e[7]!==a.name?(h=n.jsx("span",{className:"truncate font-mono",children:a.name}),e[7]=a.name,e[8]=h):h=e[8];let c;return e[9]!==l||e[10]!==h?(c=n.jsxs("span",{className:"inline-flex items-center gap-1.5 truncate",children:[l,h]}),e[9]=l,e[10]=h,e[11]=c):c=e[11],c}function Xa(t){const e=z.c(2),{scope:s}=t,i=s==="user"?Uh:Vh;let r;return e[0]!==i?(r=n.jsx(i,{className:"size-3 text-muted-foreground"}),e[0]=i,e[1]=r):r=e[1],r}function Lu({mode:t,onClose:e,onSaved:s}){const i=t.kind==="save-literal"?t.presetValue:"",r=t.presetKey,[o,a]=A.useState(()=>Ou(r)),[l,h]=A.useState("organization"),[c,d]=A.useState(i),[u,f]=A.useState(""),m=qh(),_=o.trim(),p=c.length>0&&_.length>0&&Eu.test(_),g=async b=>{if(b.preventDefault(),!!p)try{const S=await m.mutateAsync({scope:l,name:_,value:c,description:u.trim()||void 0});he.success(`Saved secret "${S.name}"`),s(S.id)}catch(S){he.error(S instanceof Error?S.message:"Failed to save")}},v=t.kind==="save-literal"?"Save value as secret":"Create new secret",x=t.kind==="save-literal"?"Move this value into the encrypted vault. The env var will then reference the secret by id — its value never leaves the server.":"Stored encrypted in the credential vault. The env var will reference the new secret by id.";return n.jsx(Fi,{open:!0,onOpenChange:b=>{b||e()},children:n.jsxs(zi,{className:"sm:max-w-md",children:[n.jsxs(yn,{children:[n.jsx(wn,{children:v}),n.jsx(Eh,{children:x})]}),n.jsxs("form",{onSubmit:g,className:"space-y-4",children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Je,{htmlFor:"save-secret-scope",children:"Scope"}),n.jsxs(ut,{value:l,onValueChange:b=>h(b),children:[n.jsx(ft,{id:"save-secret-scope",children:n.jsx(mt,{})}),n.jsxs(_t,{children:[n.jsx(Ge,{value:"organization",children:"Organization — visible to all members"}),n.jsx(Ge,{value:"user",children:"Private — only visible to me"})]})]})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Je,{htmlFor:"save-secret-name",children:"Name"}),n.jsx(nt,{id:"save-secret-name",value:o,onChange:b=>a(b.target.value),placeholder:"STRIPE_API_KEY",autoComplete:"off",required:!0}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Letters, digits, underscore, dot, hyphen. Independent of the env var key."})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Je,{htmlFor:"save-secret-value",children:"Value"}),n.jsx(nt,{id:"save-secret-value",type:"password",value:c,onChange:b=>d(b.target.value),placeholder:"secret value",autoComplete:"new-password",required:!0})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Je,{htmlFor:"save-secret-description",children:"Description (optional)"}),n.jsx(Fs,{id:"save-secret-description",value:u,onChange:b=>f(b.target.value),rows:2,placeholder:"What is this secret used for?"})]}),n.jsxs($a,{children:[n.jsx(se,{type:"button",variant:"outline",onClick:e,disabled:m.isPending,children:"Cancel"}),n.jsx(se,{type:"submit",disabled:!p||m.isPending,children:m.isPending?"Saving…":"Save secret"})]})]})]})})}function Ou(t){const e=t.trim();return e&&ju.test(e)?e:""}function $u(t){const e=z.c(12),{repo:s,className:i}=t;let r;e[0]!==i?(r=te("space-y-2",i),e[0]=i,e[1]=r):r=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(Je,{children:"Repository"}),e[2]=o):o=e[2];let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(Ch,{size:20,className:"shrink-0 text-foreground/60"}),e[3]=a):a=e[3];let l;e[4]!==s?(l=n.jsx(xe,{asChild:!0,children:n.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border bg-background px-4 py-3",tabIndex:0,children:[a,n.jsx("div",{className:"min-w-0 flex-1",children:s?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"truncate text-sm font-medium",children:[s.owner,"/",s.name]}),n.jsx("div",{className:"truncate text-xs text-muted-foreground",children:s.url})]}):n.jsx("div",{className:"text-sm text-muted-foreground",children:"No repository connected"})})]})}),e[4]=s,e[5]=l):l=e[5];let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(be,{children:"The connected GitHub repository for this agent. Manage in Connections."}),e[6]=h):h=e[6];let c;e[7]!==l?(c=n.jsxs(Se,{children:[l,h]}),e[7]=l,e[8]=c):c=e[8];let d;return e[9]!==r||e[10]!==c?(d=n.jsxs("div",{className:r,children:[o,c]}),e[9]=r,e[10]=c,e[11]=d):d=e[11],d}const zu={npm:{install:"npm install",run:t=>`npm run ${t}`,runtime:"node"},pnpm:{install:"pnpm install",run:t=>`pnpm run ${t}`,runtime:"node"},yarn:{install:"yarn install",run:t=>`yarn run ${t}`,runtime:"node"},bun:{install:"bun install",run:t=>`bun run ${t}`,runtime:"bun"},deno:{install:"deno install",run:t=>`deno task ${t}`,runtime:"deno"}};function Fu(t){const e=t.trim();if(e==="")return{ok:!0,value:null};if(!/^\d+$/.test(e))return{ok:!1};const s=Number(e);return s<1||s>65535?{ok:!1}:{ok:!0,value:String(s)}}const Hu=Object.keys(zu),ir="__none__";function Wu(t){const e=z.c(20),{control:s}=t,i=A.useRef(null);let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(Je,{htmlFor:"runtime-pm",children:"Package manager"}),e[0]=r):r=e[0];let o;e[1]!==s?(o=n.jsxs("div",{className:"space-y-2",children:[r,n.jsx(rt,{control:s,name:"metadata.runtime.selected",render:Vu})]}),e[1]=s,e[2]=o):o=e[2];let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(Je,{htmlFor:"runtime-path",children:"Package path"}),e[3]=a):a=e[3];let l;e[4]!==s?(l=n.jsx(rt,{control:s,name:"metadata.runtime.path",render:Uu}),e[4]=s,e[5]=l):l=e[5];let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx("p",{className:"text-xs text-muted-foreground",children:"Path (relative to repo root) to the directory containing package.json. Leave blank for the repo root."}),e[6]=h):h=e[6];let c;e[7]!==l?(c=n.jsxs("div",{className:"space-y-2",children:[a,l,h]}),e[7]=l,e[8]=c):c=e[8];let d;e[9]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Je,{htmlFor:"runtime-port",children:"Dev server port"}),e[9]=d):d=e[9];let u;e[10]===Symbol.for("react.memo_cache_sentinel")?(u=g=>{const{field:v}=g;return n.jsx(nt,{ref:i,id:"runtime-port",inputMode:"numeric",placeholder:"Auto",defaultValue:v.value??"",onBlur:x=>{const b=Fu(x.target.value);b.ok?v.onChange(b.value):i.current&&(i.current.value=v.value??"")}})},e[10]=u):u=e[10];let f;e[11]!==s?(f=n.jsx(rt,{control:s,name:"metadata.runtime.port",render:u}),e[11]=s,e[12]=f):f=e[12];let m;e[13]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx("p",{className:"text-xs text-muted-foreground",children:"Leave blank to let the runner pick."}),e[13]=m):m=e[13];let _;e[14]!==f?(_=n.jsxs("div",{className:"space-y-2",children:[d,f,m]}),e[14]=f,e[15]=_):_=e[15];let p;return e[16]!==_||e[17]!==o||e[18]!==c?(p=n.jsxs("div",{className:"space-y-5",children:[o,c,_]}),e[16]=_,e[17]=o,e[18]=c,e[19]=p):p=e[19],p}function Uu(t){const{field:e}=t;return n.jsx(nt,{id:"runtime-path",placeholder:".",defaultValue:e.value??"",onBlur:s=>{const i=s.target.value.trim();e.onChange(i===""?null:i)}})}function Vu(t){const{field:e}=t;return n.jsxs(ut,{value:e.value??ir,onValueChange:s=>e.onChange(s===ir?null:s),children:[n.jsx(ft,{id:"runtime-pm",children:n.jsx(mt,{placeholder:"Auto-detect"})}),n.jsxs(_t,{children:[n.jsx(Ge,{value:ir,children:"Auto-detect"}),Hu.map(Ku)]})]})}function Ku(t){return n.jsx(Ge,{value:t,children:t},t)}function qu(t,e){switch(e.type){case"SET_SHARE_DIALOG_OPEN":return{...t,shareDialogOpen:e.payload};case"SET_ADD_DIALOG_OPEN":return{...t,addDialogOpen:e.payload};case"OPEN_SETTINGS":return{...t,settingsDialogOpen:!0,settingsConnectionId:e.payload};case"CLOSE_SETTINGS":return{...t,settingsDialogOpen:!1,settingsConnectionId:null};default:return t}}function Gu(t,e){switch(e.type){case"accumulate":{const s=t??{start:e.now,fields:new Set,saveCount:0,instructionsLength:null},i=new Set(s.fields);for(const r of e.fields)i.add(r);return{...s,fields:i,saveCount:s.saveCount+1,instructionsLength:e.instructionsLength??s.instructionsLength}}case"reset":return null}}function Yu(t){const e=t.metadata?.runtime?.env;if(!e||e.length===0)return t;const s=e.filter(i=>!i||typeof i!="object"||!(i.key??"").trim()?!1:i.kind==="literal"?!0:i.kind==="secret"?!!i.secretId:!1);return s.length===e.length?t:{...t,metadata:{...t.metadata,runtime:{...t.metadata?.runtime??{},env:s}}}}function Xu(t){const e=z.c(22),{connection_id:s,usedConnectionIds:i,onOpenSettings:r,onRemove:o,onAuthenticate:a,onSwitchInstance:l,onNewInstance:h}=t,c=Sn(s),{org:d}=me();if(!c)return null;let u;e[0]!==c?(u=jh(c),e[0]=c,e[1]=u):u=e[1];const f=u;let m;e[2]!==s?(m=n.jsx(ef,{connection_id:s}),e[2]=s,e[3]=m):m=e[3];let _;e[4]!==c.app_name||e[5]!==c.connection_type||e[6]!==c.description||e[7]!==c.icon||e[8]!==c.title||e[9]!==s||e[10]!==a||e[11]!==h||e[12]!==r||e[13]!==o||e[14]!==l||e[15]!==d.slug||e[16]!==f||e[17]!==i?(_=n.jsx(Qu,{connection_id:s,connectionTitle:c.title,connectionDescription:c.description,connectionIcon:c.icon,connectionType:c.connection_type,slug:f,orgSlug:d.slug,appName:c.app_name,usedConnectionIds:i,onOpenSettings:r,onRemove:o,onAuthenticate:a,onSwitchInstance:l,onNewInstance:h}),e[4]=c.app_name,e[5]=c.connection_type,e[6]=c.description,e[7]=c.icon,e[8]=c.title,e[9]=s,e[10]=a,e[11]=h,e[12]=r,e[13]=o,e[14]=l,e[15]=d.slug,e[16]=f,e[17]=i,e[18]=_):_=e[18];let p;return e[19]!==m||e[20]!==_?(p=n.jsx(A.Suspense,{fallback:m,children:_}),e[19]=m,e[20]=_,e[21]=p):p=e[21],p}const Qn="__new_instance__";async function Ju(t,e){const s=t?.idToken??null;if(s){const r=eo(s);if(r)return r}const i=t?.userinfoEndpoint??null;if(i)try{const r=await fetch(i,{headers:{Authorization:`Bearer ${e}`}});if(r.ok){const o=await r.json(),a=typeof o.email=="string"?o.email:typeof o.upn=="string"?o.upn:typeof o.preferred_username=="string"?o.preferred_username:null;if(a)return a}}catch{}return eo(e)}function eo(t){try{const e=t.split(".");if(e.length===3&&e[1]){const s=JSON.parse(atob(e[1].replace(/-/g,"+").replace(/_/g,"/")));if(typeof s.email=="string")return s.email;if(typeof s.upn=="string")return s.upn;if(typeof s.preferred_username=="string")return s.preferred_username}}catch{}return null}function Zu(t){const e=z.c(23),{appName:s,connectionId:i,usedConnectionIds:r,onSwitchInstance:o,onNewInstance:a}=t;let l;e[0]!==s?(l={filters:[{column:"app_name",value:s}]},e[0]=s,e[1]=l):l=e[1];const h=qs(l);if(h.length<=1)return null;let c;e[2]!==i||e[3]!==a||e[4]!==o?(c=p=>{p===Qn?a?.():o(i,p)},e[2]=i,e[3]=a,e[4]=o,e[5]=c):c=e[5];let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(ft,{size:"sm",className:"w-auto text-xs gap-1 px-2 shadow-none",children:n.jsx(mt,{})}),e[6]=d):d=e[6];let u;if(e[7]!==i||e[8]!==h||e[9]!==r){let p;e[11]!==i||e[12]!==r?(p=g=>n.jsx(Ge,{value:g.id,className:"text-xs",disabled:g.id!==i&&r.has(g.id),children:g.title},g.id),e[11]=i,e[12]=r,e[13]=p):p=e[13],u=h.map(p),e[7]=i,e[8]=h,e[9]=r,e[10]=u}else u=e[10];let f;e[14]!==a?(f=a&&n.jsx(Ge,{value:Qn,className:"text-xs text-muted-foreground",children:"+ New instance"}),e[14]=a,e[15]=f):f=e[15];let m;e[16]!==u||e[17]!==f?(m=n.jsxs(_t,{children:[u,f]}),e[16]=u,e[17]=f,e[18]=m):m=e[18];let _;return e[19]!==i||e[20]!==c||e[21]!==m?(_=n.jsxs(ut,{value:i,onValueChange:c,children:[d,m]}),e[19]=i,e[20]=c,e[21]=m,e[22]=_):_=e[22],_}function Qu(t){const e=z.c(55),{connection_id:s,connectionTitle:i,connectionDescription:r,connectionIcon:o,connectionType:a,slug:l,orgSlug:h,appName:c,usedConnectionIds:d,onOpenSettings:u,onRemove:f,onAuthenticate:m,onSwitchInstance:_,onNewInstance:p}=t;let g;e[0]!==s?(g={connectionId:s},e[0]=s,e[1]=g):g=e[1];const v=Ta(g),b=!(a==="VIRTUAL")&&v.supportsOAuth&&!v.isAuthenticated,S=b?"border-destructive/50 bg-destructive/5":"border-border";let w;e[2]!==S?(w=te("rounded-xl border overflow-hidden transition-colors",S),e[2]=S,e[3]=w):w=e[3];let k;e[4]!==h||e[5]!==l?(k={org:h,appSlug:l},e[4]=h,e[5]=l,e[6]=k):k=e[6];let C;e[7]!==o||e[8]!==i?(C=n.jsx(Ct,{icon:o,name:i,size:"sm",className:"shrink-0"}),e[7]=o,e[8]=i,e[9]=C):C=e[9];let E;e[10]!==i?(E=n.jsx("p",{className:"text-sm font-medium truncate",children:i}),e[10]=i,e[11]=E):E=e[11];let T;e[12]!==r||e[13]!==b?(T=b?n.jsx("span",{className:"text-xs text-destructive font-medium",children:"Needs authorization"}):r&&n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:r}),e[12]=r,e[13]=b,e[14]=T):T=e[14];let B;e[15]!==E||e[16]!==T?(B=n.jsxs("div",{className:"flex-1 min-w-0",children:[E,T]}),e[15]=E,e[16]=T,e[17]=B):B=e[17];let I;e[18]!==s||e[19]!==b||e[20]!==m?(I=b?n.jsx(se,{variant:"outline",size:"sm",className:"h-7 text-xs shrink-0",onClick:re=>{re.preventDefault(),re.stopPropagation(),m(s)},children:"Authorize"}):n.jsxs(Se,{delayDuration:0,children:[n.jsx(xe,{asChild:!0,children:n.jsx("span",{className:"inline-flex items-center justify-center rounded-md h-7 w-7 hover:bg-accent text-muted-foreground shrink-0 transition-colors",children:n.jsx(Th,{size:16})})}),n.jsx(be,{side:"bottom",children:"Connection settings"})]}),e[18]=s,e[19]=b,e[20]=m,e[21]=I):I=e[21];let R;e[22]!==k||e[23]!==C||e[24]!==B||e[25]!==I?(R=n.jsxs(uc,{to:"/$org/settings/connections/$appSlug",params:k,className:"flex items-center gap-3 px-4 py-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[C,B,I]}),e[22]=k,e[23]=C,e[24]=B,e[25]=I,e[26]=R):R=e[26];let y;e[27]!==c||e[28]!==s||e[29]!==p||e[30]!==_||e[31]!==d?(y=c&&n.jsx(Zu,{appName:c,connectionId:s,usedConnectionIds:d,onSwitchInstance:_,onNewInstance:p}),e[27]=c,e[28]=s,e[29]=p,e[30]=_,e[31]=d,e[32]=y):y=e[32];let D;e[33]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsx(Zc,{size:13}),e[33]=D):D=e[33];let N;e[34]!==u?(N=n.jsx(xe,{asChild:!0,children:n.jsx(se,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:u,"aria-label":"Configure resources",children:D})}),e[34]=u,e[35]=N):N=e[35];let j;e[36]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx(be,{side:"bottom",children:"Configure resources"}),e[36]=j):j=e[36];let M;e[37]!==N?(M=n.jsxs(Se,{delayDuration:0,children:[N,j]}),e[37]=N,e[38]=M):M=e[38];let P;e[39]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsx(fs,{size:13}),e[39]=P):P=e[39];let F;e[40]!==f?(F=n.jsx(xe,{asChild:!0,children:n.jsx(se,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:f,"aria-label":"Remove connection",children:P})}),e[40]=f,e[41]=F):F=e[41];let W;e[42]===Symbol.for("react.memo_cache_sentinel")?(W=n.jsx(be,{side:"bottom",children:"Remove"}),e[42]=W):W=e[42];let O;e[43]!==F?(O=n.jsxs(Se,{delayDuration:0,children:[F,W]}),e[43]=F,e[44]=O):O=e[44];let $;e[45]!==M||e[46]!==O?($=n.jsxs("div",{className:"flex items-center gap-0.5 ml-auto",children:[M,O]}),e[45]=M,e[46]=O,e[47]=$):$=e[47];let H;e[48]!==y||e[49]!==$?(H=n.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 border-t border-border bg-muted/25",children:[y,$]}),e[48]=y,e[49]=$,e[50]=H):H=e[50];let V;return e[51]!==R||e[52]!==H||e[53]!==w?(V=n.jsxs("div",{className:w,children:[R,H]}),e[51]=R,e[52]=H,e[53]=w,e[54]=V):V=e[54],V}function ef(t){const e=z.c(17),{connection_id:s}=t,i=Sn(s);if(!i){let u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(Ja,{}),e[0]=u):u=e[0],u}let r;e[1]!==i.icon||e[2]!==i.title?(r=n.jsx(Ct,{icon:i.icon,name:i.title,size:"sm",className:"shrink-0"}),e[1]=i.icon,e[2]=i.title,e[3]=r):r=e[3];let o;e[4]!==i.title?(o=n.jsx("p",{className:"text-sm font-medium truncate",children:i.title}),e[4]=i.title,e[5]=o):o=e[5];let a;e[6]!==i.description?(a=i.description&&n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:i.description}),e[6]=i.description,e[7]=a):a=e[7];let l;e[8]!==o||e[9]!==a?(l=n.jsxs("div",{className:"flex-1 min-w-0",children:[o,a]}),e[8]=o,e[9]=a,e[10]=l):l=e[10];let h;e[11]!==r||e[12]!==l?(h=n.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[r,l]}),e[11]=r,e[12]=l,e[13]=h):h=e[13];let c;e[14]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:n.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})}),e[14]=c):c=e[14];let d;return e[15]!==h?(d=n.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[h,c]}),e[15]=h,e[16]=d):d=e[16],d}function Ja(){const t=z.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"size-8 rounded-md bg-muted animate-pulse shrink-0"}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e,n.jsxs("div",{className:"flex-1 space-y-1.5",children:[n.jsx("div",{className:"h-4 w-32 rounded bg-muted animate-pulse"}),n.jsx("div",{className:"h-3 w-48 rounded bg-muted animate-pulse"})]})]}),t[1]=s):s=t[1];let i;return t[2]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[s,n.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:n.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})})]}),t[2]=i):i=t[2],i}function tf({virtualMcpId:t,form:e,flushAndSave:s}){const{org:i}=me(),r=Ue({connectionId:Ft,orgId:i.id,orgSlug:i.slug}),o=Pt(t),a=(o?.connections??[]).map(y=>y.connection_id).sort(),{data:l}=ha({queryKey:us.projectConnectionDetails(t,a),enabled:a.length>0,queryFn:async()=>await Promise.all(a.map(async D=>{try{const N=await r.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:D}}),{item:j}=Nh(N),M=(j?.tools??[]).filter(P=>!!wh(P._meta)).map(P=>({name:P.name,description:P.description}));return{fetchOk:!0,id:D,title:j?.title??D,icon:j?.icon??null,uiTools:M}}catch{return{fetchOk:!1,id:D,title:D,icon:null,uiTools:[]}}}))}),h=(l??[]).filter(y=>y.uiTools.length>0),c=new Set(Lc),d=e.watch("metadata.ui.pinnedViews")??[],u=e.watch("metadata.ui.layout")??null,f=u?.defaultMainView??null,m=u?.chatDefaultOpen??!1,_=!f||f.type==="chat"?"chat":f.type==="instructions"||f.type==="connections"||f.type==="layout"?"settings":c.has(f.type)?f.type:`${f.type}:${f.id??""}:${f.toolName??""}`,p=y=>{const[D,N,j]=y.split(":");return D?D==="chat"?{type:D}:c.has(D)?{type:D}:D==="ext-apps"&&N?{type:"ext-apps",id:N,toolName:j||void 0}:null:null},g=y=>{e.setValue("metadata.ui.pinnedViews",y,{shouldDirty:!0})},v=y=>{e.setValue("metadata.ui.layout",{...u,...y},{shouldDirty:!0})},x=A.useRef(!1);if(l&&l.length>0&&!x.current){x.current=!0;const y=new Set((l??[]).filter(j=>j.fetchOk).map(j=>j.id)),D=new Set(h.flatMap(j=>j.uiTools.map(M=>`${j.id}:${M.name}`))),N=d.filter(j=>!y.has(j.connectionId)||D.has(`${j.connectionId}:${j.toolName}`));N.length!==d.length&&(g(N),f?.type==="ext-apps"&&!N.some(j=>j.connectionId===f.id&&j.toolName===f.toolName)&&v({defaultMainView:{type:"chat"}}))}const b=(y,D)=>{if(d.some(j=>j.connectionId===y&&j.toolName===D)){const j=d.filter(P=>!(P.connectionId===y&&P.toolName===D));g(j);const M=`ext-apps:${y}:${D}`;_===M&&v({defaultMainView:{type:"chat"}})}else g([...d,{connectionId:y,toolName:D,label:Wn(D),icon:null}]);s()},S=(y,D,N)=>{g(d.map(j=>j.connectionId===y&&j.toolName===D?{...j,label:N}:j))},w=()=>{s()},k=(y,D,N)=>{g(d.map(j=>j.connectionId===y&&j.toolName===D?{...j,icon:N}:j)),s()},C=y=>{v({defaultMainView:p(y)}),s()},E=a.length===0,T=l&&h.length===0,B=!!Zt(o),I=[{value:"chat",label:"Chat"},{value:"settings",label:"Settings"},{value:"automations",label:"Automations"}];B&&I.push({value:"preview",label:"Preview"});for(const y of d)I.push({value:`ext-apps:${y.connectionId}:${y.toolName}`,label:y.label||y.toolName});const R=h.length>0||E||T;return n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("div",{className:"flex items-center justify-between gap-3",children:n.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Layout"})}),n.jsxs(za,{className:"p-6 gap-5",children:[n.jsxs(Sr,{className:"p-0 space-y-5",children:[n.jsxs("div",{className:"flex items-center justify-between gap-4",children:[n.jsxs("div",{className:"space-y-0.5 min-w-0",children:[n.jsx(Je,{className:"font-normal text-foreground",children:"Main view"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"What users see when they first open this agent."})]}),n.jsxs(ut,{value:_,onValueChange:C,children:[n.jsx(ft,{className:"w-44 h-8 text-sm capitalize shrink-0",children:n.jsx(mt,{})}),n.jsx(_t,{children:I.map(y=>n.jsx(Ge,{value:y.value,className:"capitalize",children:y.label},y.value))})]})]}),n.jsxs("div",{className:"flex items-center justify-between gap-4",children:[n.jsxs("div",{className:"space-y-0.5 min-w-0",children:[n.jsx(Je,{className:"font-normal text-foreground",children:"Show chat"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Display the chat panel alongside the main view."})]}),n.jsxs(Se,{delayDuration:0,children:[n.jsx(xe,{asChild:!0,children:n.jsx("span",{className:"shrink-0",children:n.jsx(yr,{checked:_==="chat"?!0:m,disabled:_==="chat",onCheckedChange:y=>{v({chatDefaultOpen:y}),s()}})})}),_==="chat"&&n.jsx(be,{side:"top",children:"Chat is always shown when it is the default view"})]})]})]}),R&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"border-t border-border -mx-6"}),n.jsxs(Sr,{className:"p-0 space-y-3",children:[n.jsx("div",{className:"flex items-center justify-between gap-4",children:n.jsxs("div",{className:"space-y-0.5 min-w-0",children:[n.jsx(Je,{className:"font-normal text-foreground",children:"Pinned views"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Surface interactive tools as top-level tabs in the agent."})]})}),E&&n.jsx("p",{className:"text-xs text-muted-foreground",children:"Add a connection above to configure pinned views."}),T&&!E&&n.jsx("p",{className:"text-xs text-muted-foreground",children:"None of the connected servers expose interactive tools."}),h.length>0&&n.jsx("div",{className:"space-y-4 pt-1",children:h.map((y,D)=>n.jsxs("div",{children:[D>0&&n.jsx("div",{className:"border-t border-border -mx-6 mb-4"}),n.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[n.jsx(Ct,{icon:y.icon,name:y.title,size:"xs",className:"shrink-0"}),n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:y.title})]}),n.jsx("div",{className:"space-y-1.5",children:y.uiTools.map(N=>{const j=d.some(P=>P.connectionId===y.id&&P.toolName===N.name),M=d.find(P=>P.connectionId===y.id&&P.toolName===N.name);return n.jsxs("div",{className:te("flex items-center justify-between gap-3 px-3 py-2 rounded-lg border transition-colors",j?"bg-accent/40 border-border":"bg-transparent border-border"),children:[n.jsxs("div",{className:"min-w-0 flex-1 flex items-center gap-2",children:[n.jsx(tu,{value:M?.icon??null,onChange:P=>k(y.id,N.name,P),disabled:!j}),n.jsx(nt,{value:j&&M?M.label:Wn(N.name),onChange:P=>S(y.id,N.name,P.target.value),onBlur:w,className:"h-7 text-sm w-40",disabled:!j,readOnly:!j})]}),n.jsx(yr,{checked:j,onCheckedChange:()=>b(y.id,N.name)})]},N.name)})})]},y.id))})]})]})]})]})}function sf({virtualMcp:t,hideOwnTitle:e}){const{org:s}=me(),i=Nc(),r=bh(),o=_s(),a=Ue({connectionId:Ft,orgId:s.id,orgSlug:s.slug}),l=ca({resolver:hc(pu),defaultValues:t}),h=l.watch("connections"),c=!!Zt(t),d=Zt(t),u=d?{owner:d.owner,name:d.name,url:d.url}:null,[f,m]=A.useReducer(qu,{shareDialogOpen:!1,addDialogOpen:!1,settingsDialogOpen:!1,settingsConnectionId:null}),[_,p]=A.useState(!1),[g,v]=A.useState(!1),{createNewTask:x,setChatOpen:b}=bn(),{sendMessage:S}=rs(),w=ja(),k=async()=>{if(g)return;const L=l.getValues("metadata.instructions");if(L?.trim()){v(!0);try{R(),ve("agent_instructions_improve_clicked",{agent_id:t.id,instructions_length:L.length}),await w(["studio-agent-manager"]),b(!0),await S({tiptapDoc:Ya({managerAgentId:ma.AGENT_MANAGER(s.id),managerName:"Agent Manager",kind:"agent",id:t.id,instructions:L})})}finally{v(!1)}}},C=()=>{R(),ve("agent_test_clicked",{agent_id:t.id}),x()},[E,T]=A.useReducer(Gu,null),B=()=>{E!==null&&(ve("agent_updated",{agent_id:t.id,fields:Array.from(E.fields),instructions_length:E.instructionsLength,save_count:E.saveCount,edit_duration_ms:Date.now()-E.start}),T({type:"reset"}))},{schedule:I,flush:R}=Ls({delayMs:3e4,save:async()=>B()}),y=async()=>{const L=Object.keys(l.control._formState.dirtyFields);if(L.length===0)return;const K=L.includes("metadata"),Q=l.getValues();l.reset(Q,{keepValues:!0});const G=Yu(Q);await i.update.mutateAsync({id:t.id,data:G}),T({type:"accumulate",now:Date.now(),fields:L,instructionsLength:K?Q.metadata?.instructions?.length??0:null}),I()},{schedule:D,flush:N}=Ls({save:y});A.useEffect(()=>{const L=l.watch(()=>D());return()=>L.unsubscribe()},[]);const j=()=>{ve("connections_dialog_opened",{source:"agent_settings",mode:"add"}),m({type:"SET_ADD_DIALOG_OPEN",payload:!0})},M=async L=>{const K=l.getValues("connections");if(K.some(ee=>ee.connection_id===L))return;l.setValue("connections",[...K,{connection_id:L,selected_tools:sr.tools,selected_resources:sr.resources,selected_prompts:sr.prompts}],{shouldDirty:!0}),m({type:"SET_ADD_DIALOG_OPEN",payload:!1});const Q=new URL(`/api/${s.slug}/mcp/${L}`,window.location.origin),G=await Ln({url:Q.href,token:null,orgId:s.id});G.supportsOAuth&&!G.isAuthenticated&&await $(L)},P=L=>{const Q=l.getValues("connections").filter(G=>G.connection_id!==L);l.setValue("connections",Q,{shouldDirty:!0})},F=(L,K)=>{const Q=l.getValues("connections");if(Q.some(G=>G.connection_id===K)){he.error("This instance is already added to the agent");return}l.setValue("connections",Q.map(G=>G.connection_id===L?{...G,connection_id:K}:G),{shouldDirty:!0})},W=async L=>{if(l.getValues("connections").find(Q=>Q.connection_id===L))try{const Q=await a.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:L}}),{item:G}=Q.structuredContent??{};if(!G)return;const ee=G.title.replace(/\s*\(.*?\)\s*$/,""),oe=Sh("conn"),_e=`${ee} (${Date.now().toString(36).slice(-4)})`;await r.create.mutateAsync({id:oe,title:_e,description:G.description??null,connection_type:G.connection_type,connection_url:G.connection_url??null,connection_token:null,icon:G.icon??null,app_name:G.app_name??null,app_id:G.app_id??null,connection_headers:G.connection_headers??null});const ge=new URL(`/api/${s.slug}/mcp/${oe}`,window.location.origin),we=await Ln({url:ge.href,token:null,orgId:s.id});if(we.supportsOAuth&&!we.isAuthenticated){const je=await $(oe);if(!je){await r.delete.mutateAsync(oe);return}await r.update.mutateAsync({id:oe,data:{title:`${ee} (${je})`}})}F(L,oe),he.success("New instance created")}catch(Q){console.error("Failed to create instance:",Q),he.error("Failed to create instance")}},O=L=>{m({type:"OPEN_SETTINGS",payload:L})},$=async L=>{const{token:K,tokenInfo:Q,error:G}=await dc({connectionId:L,orgSlug:s.slug,scope:"offline_access"});if(G||!K)return he.error(`Authentication failed: ${G}`),null;if(Q)try{const oe=await fetch(`/api/${s.slug}/connections/${L}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:Q.accessToken,refreshToken:Q.refreshToken,expiresIn:Q.expiresIn,scope:Q.scope,clientId:Q.clientId,clientSecret:Q.clientSecret,tokenEndpoint:Q.tokenEndpoint})});if(!oe.ok)console.error("Failed to save OAuth token:",await oe.text()),await r.update.mutateAsync({id:L,data:{connection_token:K}});else try{await r.update.mutateAsync({id:L,data:{}})}catch(_e){console.warn("Failed to refresh connection tools after OAuth:",_e)}}catch(oe){console.error("Error saving OAuth token:",oe),await r.update.mutateAsync({id:L,data:{connection_token:K}})}else await r.update.mutateAsync({id:L,data:{connection_token:K}});const ee=new URL(`/api/${s.slug}/mcp/${L}`,window.location.origin);return await o.invalidateQueries({queryKey:us.isMCPAuthenticated(ee.href,null)}),he.success("Authentication successful"),Ju(Q,K)},H=()=>{const L=l.getValues("metadata.instructions")??"",K=`<role>
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/sections-editor-mCI01e08.js","assets/index-D6QjTTqJ.js","assets/index-KAiEcabG.css","assets/ChevronRight-DSjqApfg.js","assets/scroll-area-Oi-1lw3K.js","assets/select-DvLGp7Fe.js","assets/tooltip-BxAcRSdf.js","assets/Check-DbV-F2MF.js","assets/ChevronDown-CFuI54BG.js","assets/ChevronUp-Do0GES9S.js","assets/agent-icon-CfsoOk3Y.js","assets/AlertCircle-B_YmhCpp.js","assets/Tool01-R-t45iSM.js","assets/Archive-DZ9aGmbx.js","assets/XClose-o95wsJTh.js","assets/RefreshCcw01-D202N5g5.js","assets/ArrowNarrowLeft-BWm-AMm4.js","assets/XCircle-DdlmiVIz.js","assets/ArrowUpRight-BjQLVEJQ.js","assets/ZapSquare-CJBiolSd.js","assets/Users03-D7eVSXn9.js","assets/CheckCircle-CPcc_HzK.js","assets/DotsVertical-CBu0rfx5.js","assets/Container-DnQ-V0vf.js","assets/Star01-BGA57956.js","assets/Palette-B5PaE3Rq.js","assets/Key01-C7u5tKD0.js","assets/LayoutLeft-DcnMGouH.js","assets/LinkExternal01-BJS4Dy91.js","assets/Lock01-C9MGcsTR.js","assets/Sun-BnzHtNJd.js","assets/Play-B8BnOy3i.js","assets/Plus-DpifZcWW.js","assets/SearchMd-B-JvZSXk.js","assets/Settings02-BZ4NUngl.js","assets/Shield01-y2jg0f2l.js","assets/Trash01-MANg2hp9.js","assets/Upload01-D1-e29YJ.js","assets/User01-BjiH1weJ.js","assets/Users01-BldrmsRS.js","assets/X-PJ44Wfoc.js","assets/Zap-B0TzxL73.js","assets/collection-search-D-c8AzQQ.js","assets/input-ByXVDv8X.js","assets/textarea-UEW8mFM6.js","assets/label-DpsSn4NO.js","assets/switch-TizQbIhD.js","assets/dropdown-menu-DlP8Zgk8.js","assets/command-BJgDzZ7y.js","assets/index-BCY8PZey.js","assets/dialog-s2De3tVa.js","assets/index-BqFKFoUR.js","assets/use-connection-BK2Nw2jO.js","assets/use-collections--I8gVq9B.js","assets/constants-CA7gkjCv.js","assets/lean-canvas-recruit-modal-DFOchrjh.js","assets/use-navigate-to-agent-DxVatZQd.js","assets/use-virtual-mcp-Douh_VO1.js","assets/collection-search-BqHGaRq0.js","assets/checkbox-C7NHZ7qY.js","assets/extract-connection-data-DYLiTjJW.js","assets/constants-VqUK6eVM.js","assets/collections-Ca0YTtNu.js","assets/drawer-DctzDnYu.js","assets/integration-icon-ChuHi82q.js","assets/use-mcp-tools-DAGpG90W.js","assets/chat-context-CwbmMG2J.js","assets/hooks-Bd6LwLvD.js","assets/decopilot-sse-pool-D2FvP5mN.js","assets/create-sse-subscription-CjI9SUTI.js","assets/use-ai-providers-DmiZTNMs.js","assets/use-organization-settings-i-QaGb_R.js","assets/shell-layout-B3MT5Ip4.js","assets/required-auth-layout-DOYU6ZrF.js","assets/useRouterState-x30cArYP.js","assets/use-org-sso-Dqe4HQMo.js","assets/pair-w9BJ67Dj.js","assets/index-Cntm0Edj.js","assets/use-copy-CnthzbKT.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/content-blocks-o63cs2vh.js","assets/types-j_q-ovJc.js","assets/spinner-BDiar_Qs.js","assets/tabs-DJRUo-0B.js","assets/form-RSI6Xm7k.js","assets/toggle-group-BHBQNNIa.js","assets/select-model-CMV07_l8.js","assets/skeleton-BECSxU-k.js","assets/ai-providers-logos-DD3qZ33J.js","assets/avatar-Cx7XLB5Y.js","assets/settings-section-BiADvCcv.js","assets/card-pSH7d2d1.js","assets/unwrap-tool-result-BYXdCQMg.js","assets/index-CvimJi4c.js","assets/question-004-sINsf4GQ.js","assets/connection-slug-eyAPH6o3.js","assets/connection-card-DCCJSa01.js","assets/use-registry-connections-CZIRvS5a.js","assets/useInfiniteQuery-DFJcGKpk.js","assets/infiniteQueryObserver-Bw9VTL3u.js","assets/collection-tabs-yJ1sNpjE.js","assets/badge-DRrnUUdf.js","assets/connection-form-helpers-BzCkC1Te.js","assets/use-infinite-scroll-DF-89Vhi.js","assets/useSuspenseInfiniteQuery-C4KG05Xu.js","assets/popover-B2weHany.js","assets/index-Bc6TMNkC.js","assets/sidebar-DjYuMiBY.js","assets/alert-dialog-Bpf8lBsH.js","assets/index-DlMYwR85.js","assets/use-create-virtual-mcp-GbUB67wE.js","assets/use-create-website-agent-DTQa-l0O.js","assets/empty-state-_VG9orFz.js","assets/task-status-DJ48SE9o.js","assets/use-status-sounds-MRdiA7zs.js","assets/accordion-BhMqpwsw.js","assets/user-ChYpg8M2.js","assets/tools-list-DTwH0BKs.js","assets/use-debounced-autosave-CFS7j0go.js","assets/index-DeRB6kmx.js","assets/use-secrets-C5cxFCvW.js","assets/view-mode-toggle-Csc_uwsV.js","assets/automation-list-row-3GgRNA4X.js","assets/search-input-B4tnw2Dh.js","assets/file-explorer-D4u2-UUk.js","assets/index-DMHsj289.js","assets/project-app-view-0puAiHFx.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{p as _s,r as A,q as _c,s as pc,e as z,c as te,j as n,l as Be,B as se,E as Rt,v as ge,b as Oi,a as ua,w as fa,f as is,d as ma,x as gc,K as us,o as he,y as ji,V as vc,t as be,z as _a,C as xc,D as Hs,F as nt,G as pa,H as bc,I as Sc,J as Wn,n as ga,L as yc,M as gi,P as Ds,Q as ut,_ as cn,R as wc,T as va,U as xa,W as Cc,g as kc}from"./index-D6QjTTqJ.js";import{C as Ce,b as Nc,w as jc,A as Ec,c as Tc,d as Rc,S as Dc,e as Un,u as Pc,a as br,f as Ic,g as Mc}from"./index-BqFKFoUR.js";import{I as Ct}from"./integration-icon-ChuHi82q.js";import{u as Ue,K as Ac,g as ba,S as Ft,a as Sa}from"./constants-CA7gkjCv.js";import{u as Pt,a as Bc}from"./use-virtual-mcp-Douh_VO1.js";import{a as Lc}from"./Users03-D7eVSXn9.js";import{u as rs,a as Ht,b as hn,t as Oc,d as Vn}from"./chat-context-CwbmMG2J.js";import{i as dn}from"./AlertCircle-B_YmhCpp.js";import{i as $c}from"./CheckCircle-CPcc_HzK.js";import{a as Kn,n as zc}from"./ZapSquare-CJBiolSd.js";import{i as Fc,a as Hc,b as un,c as Wc,d as fn}from"./XCircle-DdlmiVIz.js";import{s as fs,i as qn}from"./XClose-o95wsJTh.js";import{c as Uc,r as Vc,p as ya,f as Gn,a as Kc,F as qc,t as Yn,M as mn,G as Gc,i as Yc,b as Xc,d as Jc,e as Zc}from"./pair-w9BJ67Dj.js";import{C as Ei,a as Ti,b as Qc,c as _n,d as pn,e as gn,f as vn}from"./command-BJgDzZ7y.js";import{P as Wt,a as Ut,b as Vt}from"./popover-B2weHany.js";import{i as Ls,a as eh,b as th,p as $i,g as zi,c as xn,d as wa,h as Sr,e as Ji,f as Xn,A as Jn,j as bn,k as sh,l as ih,n as rh,m as nh,o as oh,t as ah,q as lh,s as ch,r as Ca,u as ka,v as Na,w as ja,x as Zn,y as Qn,z as hh,B as dh,C as Os,D as uh,E as Ea,F as Ta}from"./agent-icon-CfsoOk3Y.js";import{u as fh}from"./useInfiniteQuery-DFJcGKpk.js";import{u as mh}from"./use-ai-providers-DmiZTNMs.js";import{g as Zt,a as _h,T as ph}from"./index-Bc6TMNkC.js";import{u as Sn,i as gh}from"./shell-layout-B3MT5Ip4.js";import{u as vh,c as xh,d as bh,e as Sh}from"./sidebar-DjYuMiBY.js";import{u as Ra,T as ke,a as Ne,b as je,c as yh}from"./tooltip-BxAcRSdf.js";import{u as wh}from"./use-status-sounds-MRdiA7zs.js";import{E as Ri}from"./empty-state-_VG9orFz.js";import{A as Ch,a as kh,b as Nh,c as jh,R as Da,d as Eh,e as Th}from"./accordion-BhMqpwsw.js";import{u as Ys,a as yn,b as Rh}from"./use-connection-BK2Nw2jO.js";import{u as Pa}from"./hooks-Bd6LwLvD.js";import{g as Dh}from"./constants-VqUK6eVM.js";import{u as Ph,g as Ih}from"./types-j_q-ovJc.js";import{G as Mh,u as Ia}from"./lean-canvas-recruit-modal-DFOchrjh.js";import{U as Ma}from"./user-ChYpg8M2.js";import{T as Ah,u as Aa}from"./tools-list-DTwH0BKs.js";import{u as Bh}from"./unwrap-tool-result-BYXdCQMg.js";import{s as Ba,g as Lh}from"./connection-slug-eyAPH6o3.js";import{A as La,a as Oa,b as $a,c as za,d as Fa,e as Ha,f as Wa,g as Ua}from"./alert-dialog-Bpf8lBsH.js";import{D as Va,a as Fi,b as Hi,c as wn,d as Cn,e as Oh}from"./dialog-s2De3tVa.js";import{C as Ka,a as yr}from"./card-pSH7d2d1.js";import{I as ot}from"./input-ByXVDv8X.js";import{L as Je}from"./label-DpsSn4NO.js";import{S as mt,a as _t,b as pt,c as gt,d as Ye}from"./select-DvLGp7Fe.js";import{S as wr}from"./switch-TizQbIhD.js";import{T as Ws}from"./textarea-UEW8mFM6.js";import{i as Qt}from"./Play-B8BnOy3i.js";import{s as es}from"./Plus-DpifZcWW.js";import{a as $h}from"./Settings02-BZ4NUngl.js";import{t as kn,i as zh}from"./Tool01-R-t45iSM.js";import{s as Di}from"./Trash01-MANg2hp9.js";import{u as $s}from"./use-debounced-autosave-CFS7j0go.js";import{S as Nn}from"./scroll-area-Oi-1lw3K.js";import{i as qa}from"./SearchMd-B-JvZSXk.js";import{i as Fh}from"./Upload01-D1-e29YJ.js";import{i as Hh}from"./LayoutLeft-DcnMGouH.js";import{P as ft}from"./index-DeRB6kmx.js";import{C as Wh}from"./collection-tabs-yJ1sNpjE.js";import{C as Uh}from"./checkbox-C7NHZ7qY.js";import{u as Vh,a as Xs,b as Ga}from"./use-mcp-tools-DAGpG90W.js";import{u as Kh,T as Zi,a as qh,b as Gh,c as Qi}from"./tabs-DJRUo-0B.js";import{D as Yh,a as Xh,b as Jh}from"./drawer-DctzDnYu.js";import{i as ps}from"./Check-DbV-F2MF.js";import{i as Ya}from"./Key01-C7u5tKD0.js";import{S as Zh}from"./skeleton-BECSxU-k.js";import{i as Qh}from"./Lock01-C9MGcsTR.js";import{s as ed}from"./User01-BjiH1weJ.js";import{t as td}from"./Users01-BldrmsRS.js";import{u as sd,a as id}from"./use-secrets-C5cxFCvW.js";import{n as gs}from"./LinkExternal01-BJS4Dy91.js";import{S as rd}from"./spinner-BDiar_Qs.js";import{D as Js,a as Zs,b as Qs,c as Dt,d as nd,e as od,f as ad}from"./dropdown-menu-DlP8Zgk8.js";import{t as vs}from"./ChevronDown-CFuI54BG.js";import{i as Xa}from"./RefreshCcw01-D202N5g5.js";import{V as ld}from"./view-mode-toggle-Csc_uwsV.js";import{i as cd}from"./X-PJ44Wfoc.js";import{u as ei,a as hd,b as dd,c as ud,A as fd,d as md,e as _d}from"./automation-list-row-3GgRNA4X.js";import{i as Us}from"./Zap-B0TzxL73.js";import{S as pd}from"./search-input-B4tnw2Dh.js";function gd(t,e){const s=_s(e);return vd({filters:{...t,status:"pending"}},s).length}function eo(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function vd(t={},e){const s=_s(e).getMutationCache(),i=A.useRef(t),r=A.useRef(null);return r.current===null&&(r.current=eo(s,t)),A.useEffect(()=>{i.current=t}),A.useSyncExternalStore(A.useCallback(o=>s.subscribe(()=>{const a=_c(r.current,eo(s,i.current));r.current!==a&&(r.current=a,pc.schedule(o))}),[s]),()=>r.current,()=>r.current)}function ws(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function to(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 xd(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function bd(t){const e=z.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(Sd),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 Sd(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 yd(t){const e=z.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 m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=m):m=e[10];let _;e[11]!==a?(_=a.toFixed(1),e[11]=a,e[12]=_):_=e[12];let p;e[13]!==_?(p=n.jsxs("div",{className:"flex items-center gap-1.5",children:[m,n.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",_,"%"]})]}),e[13]=_,e[14]=p):p=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 v;e[16]!==l?(v=l.toFixed(1),e[16]=l,e[17]=v):v=e[17];let x;e[18]!==v?(x=n.jsxs("div",{className:"flex items-center gap-1.5",children:[g,n.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",v,"%"]})]}),e[18]=v,e[19]=x):x=e[19];let b;e[20]!==h||e[21]!==r?(b=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]=b):b=e[22];let S;e[23]!==x||e[24]!==b||e[25]!==p?(S=n.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[p,x,b]}),e[23]=x,e[24]=b,e[25]=p,e[26]=S):S=e[26];let w;return e[27]!==S||e[28]!==f?(w=n.jsxs("div",{className:"flex flex-col gap-2",children:[f,S]}),e[27]=S,e[28]=f,e[29]=w):w=e[29],w}function wd(t){const e=z.c(11),{agentId:s,isError:i}=t,r=Pt(s),o=r?.title??"Subtask",a=r?.icon??null;let l;e[0]!==a||e[1]!==o?(l=n.jsx(Ct,{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=te("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 Cd(t){const e=z.c(5),{isError:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Ct,{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=te("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 kd(t){const e=z.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(Cd,{isError:o}),e[0]=o,e[1]=l):l=e[1];let h;e[2]!==i||e[3]!==o?(h=n.jsx(wd,{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(A.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(Be,{size:12,className:"animate-spin text-muted-foreground"}):o?n.jsx(Fc,{size:12,className:"text-destructive"}):a?n.jsx(dn,{size:12,className:"text-warning"}):n.jsx($c,{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 Nd(t){const e=z.c(55),{onClose:s,back:i,className:r}=t,[o,a]=A.useState(null),{messages:l}=rs(),{activeTask:h}=Ht(),{selectedModel:c,selectedVirtualMcp:d}=hn();let u,f,m,_,p,g,v,x;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){x=Symbol.for("react.early_return_sentinel");e:{const w=Uc(l),k=[...l].reverse().find(Ld),E=k?.metadata?.usage,P=k?.metadata?.modelLimits?.contextWindow??c?.limits?.contextWindow??null,R=E?.contextTokens??E?.totalTokens??0,B=P&&P>0?(R/P*100).toFixed(1):null,I=l;let T;e[16]!==I?(T=I.filter(Bd).reduce(Ad,0),e[16]=I,e[17]=T):T=e[17];const y=T,N=l;let C;e[18]!==N?(C=N.filter(Md).reduce(Id,0),e[18]=N,e[19]=C):C=e[19];const j=C,M=Math.max(0,w.totalTokens-y-j),D=l[0],F=l.at(-1),H=D?.metadata?.created_at??h?.created_at,O=F?.metadata?.created_at??h?.updated_at,$=l.filter(Pd),W=l.flatMap(Rd),K=c?.modelId?xd(c.modelId):"—",re=d?.title??"Decopilot",Z=[{label:"Session",value:h?.title??"New chat"},{label:"Messages",value:$.length},{label:"Agent",value:re},{label:"Model",value:K},{label:"Context Limit",value:P?ws(P):"—"},{label:"Session Tokens (billed)",value:w.totalTokens>0?ws(w.totalTokens):"0"},{label:"Usage",value:B!==null?`${B}%`:"—"},{label:"Input Tokens",value:w.inputTokens>0?ws(w.inputTokens):"0"},{label:"Output Tokens",value:w.outputTokens>0?ws(w.outputTokens):"0"},{label:"Reasoning Tokens",value:w.reasoningTokens>0?ws(w.reasoningTokens):"0"},{label:"Cost",value:w.cost>0?`$${w.cost<.001?w.cost.toFixed(6):w.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:to(H)},{label:"Last Activity",value:to(O)}];if(!h&&$.length===0){let q;e[20]!==r?(q=te("flex flex-col h-full w-full border-l border-border bg-background",r),e[20]=r,e[21]=q):q=e[21];let Q;e[22]===Symbol.for("react.memo_cache_sentinel")?(Q=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[22]=Q):Q=e[22];let Y;e[23]!==i?(Y=i?n.jsx(Kn,{size:14,className:"text-muted-foreground"}):n.jsx(fs,{size:14,className:"text-muted-foreground"}),e[23]=i,e[24]=Y):Y=e[24];let ee;e[25]!==s||e[26]!==Y?(ee=n.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[Q,n.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:Y})]}),e[25]=s,e[26]=Y,e[27]=ee):ee=e[27];let ae;e[28]===Symbol.for("react.memo_cache_sentinel")?(ae=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]=ae):ae=e[28];let _e;e[29]!==q||e[30]!==ee?(_e=n.jsxs("div",{className:q,children:[ee,ae]}),e[29]=q,e[30]=ee,e[31]=_e):_e=e[31],x=_e;break e}e[32]!==r?(g=te("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 J;e[34]===Symbol.for("react.memo_cache_sentinel")?(J=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[34]=J):J=e[34];let X;e[35]!==i?(X=i?n.jsx(Kn,{size:14}):n.jsx(fs,{size:14}),e[35]=i,e[36]=X):X=e[36],e[37]!==s||e[38]!==X?(v=n.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[J,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:X})]}),e[37]=s,e[38]=X,e[39]=v):v=e[39],u="flex flex-col gap-8 p-6",f=W.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:W.map(Td)})]}),m=n.jsx(bd,{items:Z});let L;e[40]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[40]=L):L=e[40],e[41]!==j||e[42]!==M||e[43]!==y?(_=n.jsxs("div",{className:"flex flex-col gap-3",children:[L,n.jsx(yd,{userTokens:y,assistantTokens:j,otherTokens:M})]}),e[41]=j,e[42]=M,e[43]=y,e[44]=_):_=e[44],p=$.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:$.map(q=>{const Q=q.metadata?.created_at,Y=o?.id===q.id;return n.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[n.jsxs("button",{type:"button",onClick:()=>a(Y?null:q),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:te("shrink-0 font-medium",q.role==="user"?"text-chart-1":"text-chart-2"),children:q.role}),n.jsx("span",{className:"text-muted-foreground",children:"•"}),n.jsx("span",{className:"truncate text-muted-foreground font-mono",children:q.id})]}),Q&&n.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(Q).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),Y&&n.jsxs(n.Fragment,{children:[q.role==="assistant"&&(()=>{const ee=q.metadata?._request;if(!ee)return null;const ae=ee.systemSections??[],_e=Math.max(1,...ae.map(Ed)),ue=ae.reduce(jd,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:[ee.activeTools??0," / ",ee.tools??0," ","tools active"]})]}),ae.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(ue/4).toLocaleString()," ","tok"]})]}),ae.map((pe,ve)=>{const Re=pe.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${ve}`,ne=pe.chars/_e*100,le=Math.round(pe.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:Re}),n.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:["~",le.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:`${ne}%`}})})]},ve)})]})]})})(),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(q,null,2)})]})]},q.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]=m,e[11]=_,e[12]=p,e[13]=g,e[14]=v,e[15]=x}else u=e[8],f=e[9],m=e[10],_=e[11],p=e[12],g=e[13],v=e[14],x=e[15];if(x!==Symbol.for("react.early_return_sentinel"))return x;let b;e[45]!==u||e[46]!==f||e[47]!==m||e[48]!==_||e[49]!==p?(b=n.jsxs("div",{className:u,children:[f,m,_,p]}),e[45]=u,e[46]=f,e[47]=m,e[48]=_,e[49]=p,e[50]=b):b=e[50];let S;return e[51]!==g||e[52]!==v||e[53]!==b?(S=n.jsxs("div",{className:g,children:[v,b]}),e[51]=g,e[52]=v,e[53]=b,e[54]=S):S=e[54],S}function jd(t,e){return t+e.chars}function Ed(t){return t.chars}function Td(t,e){return n.jsx(kd,{part:t},e)}function Rd(t){return(t.parts??[]).filter(Dd)}function Dd(t){return t.type==="tool-subtask"}function Pd(t){return t.role!=="system"}function Id(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function Md(t){return t.role==="assistant"}function Ad(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function Bd(t){return t.role==="user"}function Ld(t){return t.role==="assistant"&&t.metadata?.usage}const so=["amber","bold","bright","calm","crimson","coral","daring","deep","dusty","eager","faint","fierce","frozen","gentle","golden","grand","green","hollow","iron","ivory","keen","lasting","lunar","mellow","misty","noble","olive","pale","prime","quiet","rapid","rustic","serene","sharp","silver","sleek","solar","stark","still","swift","tawny","tender","thin","true","vast","velvet","warm","wild","young","zen"],io=["anchor","birch","brook","cedar","cliff","cove","crane","dune","echo","ember","falcon","fern","flint","forge","frost","glade","grove","harbor","hawk","iris","jade","lark","maple","marsh","mesa","opal","orbit","peak","pine","plume","quartz","rapids","reef","ridge","river","sage","shore","slate","spruce","stone","summit","thorn","tide","trail","vale","wren","aspen","delta","crest","spark"];function Od(){const t=so[Math.floor(Math.random()*so.length)],e=io[Math.floor(Math.random()*io.length)];return`deco/${t}-${e}`}const vi=100;function $d(t,e,s){const i=e.trim().toLowerCase();return i?(t??[]).some(r=>r.branches.some(o=>typeof o.name=="string"&&!s.has(o.name)&&o.name.toLowerCase().includes(i))):!0}function zd(t,e){const s=e.trim().toLowerCase();return s?[...t].some(i=>i.toLowerCase().includes(s)):!0}function Fd(t){const e=t;if(e.structuredContent)return e.structuredContent;const s=e.content?.find(i=>i.type==="text")?.text;if(s)try{return JSON.parse(s)}catch{return[]}return[]}function Hd(t){const e=z.c(48),{orgId:s,orgSlug:i,userId:r,connectionId:o,vmMap:a,owner:l,repo:h,enabled:c}=t,d=c===void 0?!0:c,u=o??null;let f;e[0]!==s||e[1]!==i||e[2]!==u?(f={connectionId:u,orgId:s,orgSlug:i},e[0]=s,e[1]=i,e[2]=u,e[3]=f):f=e[3];const m=Ue(f);let _;e[4]!==o||e[5]!==s||e[6]!==i||e[7]!==l||e[8]!==h?(_=Ac.githubBranches(s,i,o,l,h),e[4]=o,e[5]=s,e[6]=i,e[7]=l,e[8]=h,e[9]=_):_=e[9];const p=d&&!!o&&!!l&&!!h;let g;e[10]!==m||e[11]!==l||e[12]!==h?(g=async O=>{const{pageParam:$,signal:W}=O,K=Number($),re=await m.callTool({name:"list_branches",arguments:{owner:l,repo:h,page:K,perPage:vi}},void 0,{signal:W}),Z=Fd(re);return{branches:Array.isArray(Z)?Z:Z.branches??[],default_branch:Array.isArray(Z)?null:Z.default_branch??null,page:K}},e[10]=m,e[11]=l,e[12]=h,e[13]=g):g=e[13];let v;e[14]!==_||e[15]!==p||e[16]!==g?(v={queryKey:_,enabled:p,staleTime:3e4,retry:!1,initialPageParam:1,queryFn:g,getNextPageParam:Gd},e[14]=_,e[15]=p,e[16]=g,e[17]=v):v=e[17];const{data:x,isLoading:b,isError:S,hasNextPage:w,isFetchingNextPage:k,fetchNextPage:E}=fh(v);let P,R;e[18]!==r||e[19]!==a?(R=new Set(Object.keys(a?.[r]??{})),P=[...R].sort().map(qd),e[18]=r,e[19]=a,e[20]=P,e[21]=R):(P=e[20],R=e[21]);const B=P;let I;if(e[22]!==x?.pages){const O=new Map;for(const W of x?.pages??[])for(const K of W.branches)typeof K.name=="string"&&O.set(K.name,K);I=[...O.values()].filter(Kd),e[22]=x?.pages,e[23]=I}else I=e[23];let T;e[24]!==I||e[25]!==R?(T=I.filter(O=>!R.has(O.name)).map(Vd),e[24]=I,e[25]=R,e[26]=T):T=e[26];const y=T;let N;e[27]!==x?.pages?(N=x?.pages.find(Ud)?.default_branch??null,e[27]=x?.pages,e[28]=N):N=e[28];const C=N;let j;e[29]!==x?.pages||e[30]!==E||e[31]!==k||e[32]!==R?(j=async(O,$)=>{const W=$===void 0?Wd:$;if(!W()||zd(R,O)||k)return;let K=x?.pages??[];for(;W()&&!$d(K,O,R)&&(K.at(-1)?.branches.length??vi)>=vi;){const re=await E();if(!W())break;const Z=re.data?.pages??K;if(Z.length===K.length)break;K=Z}},e[29]=x?.pages,e[30]=E,e[31]=k,e[32]=R,e[33]=j):j=e[33];const M=j,D=w??!1;let F;e[34]!==E||e[35]!==w||e[36]!==k?(F=()=>{w&&!k&&E()},e[34]=E,e[35]=w,e[36]=k,e[37]=F):F=e[37];let H;return e[38]!==C||e[39]!==M||e[40]!==S||e[41]!==k||e[42]!==b||e[43]!==y||e[44]!==D||e[45]!==F||e[46]!==B?(H={yours:B,others:y,defaultBase:C,isLoading:b,isError:S,hasMore:D,isFetchingMore:k,fetchMore:F,fetchUntilMatch:M},e[38]=C,e[39]=M,e[40]=S,e[41]=k,e[42]=b,e[43]=y,e[44]=D,e[45]=F,e[46]=B,e[47]=H):H=e[47],H}function Wd(){return!0}function Ud(t){return t.default_branch}function Vd(t){return{name:t.name,source:"other",author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function Kd(t){return typeof t.name=="string"}function qd(t){return{name:t,source:"yours"}}function Gd(t){if(!(t.branches.length<vi))return t.page+1}function Yd(t){const e=z.c(61),{orgId:s,orgSlug:i,userId:r,connectionId:o,owner:a,repo:l,vmMap:h,value:c,onChange:d}=t,[u,f]=A.useState(!1),[m,_]=A.useState(""),[p,g]=A.useState(!1),v=A.useRef(0);let x;e[0]!==o||e[1]!==u||e[2]!==s||e[3]!==i||e[4]!==a||e[5]!==l||e[6]!==r||e[7]!==h?(x={orgId:s,orgSlug:i,userId:r,connectionId:o,vmMap:h,owner:a,repo:l,enabled:u},e[0]=o,e[1]=u,e[2]=s,e[3]=i,e[4]=a,e[5]=l,e[6]=r,e[7]=h,e[8]=x):x=e[8];const{yours:b,others:S,isLoading:w,isError:k,hasMore:E,isFetchingMore:P,fetchMore:R,fetchUntilMatch:B}=Hd(x);let I;e[9]!==d?(I=Y=>{d(Y),f(!1)},e[9]=d,e[10]=I):I=e[10];const T=I,y=c??"Select branch…";let N;e[11]!==B?(N=Y=>{_(Y),v.current=v.current+1;const ee=v.current,ae=Y.trim();if(!ae){g(!1);return}g(!0),B(ae,()=>ee===v.current).finally(()=>{ee===v.current&&g(!1)})},e[11]=B,e[12]=N):N=e[12];const C=N;let j;e[13]!==R?(j=Y=>{const ee=Y.currentTarget;ee.scrollHeight-ee.scrollTop-ee.clientHeight<48&&R()},e[13]=R,e[14]=j):j=e[14];const M=j;let D;e[15]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsx(Ls,{className:"h-3.5 w-3.5"}),e[15]=D):D=e[15];let F;e[16]!==y?(F=n.jsx(Wt,{asChild:!0,children:n.jsxs(se,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 font-mono text-xs",children:[D,n.jsx("span",{className:"max-w-[200px] truncate",children:y})]})}),e[16]=y,e[17]=F):F=e[17];let H;e[18]!==C||e[19]!==m?(H=n.jsx(_n,{placeholder:"Search loaded branches…",value:m,onValueChange:C}),e[18]=C,e[19]=m,e[20]=H):H=e[20];let O;e[21]!==T?(O=n.jsx(se,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>T(Od()),children:"New"}),e[21]=T,e[22]=O):O=e[22];let $;e[23]!==H||e[24]!==O?($=n.jsxs("div",{className:"*:data-[slot=command-input-wrapper]:flex-1 *:data-[slot=command-input-wrapper]:border-b-0 flex items-center border-b pr-2",children:[H,O]}),e[23]=H,e[24]=O,e[25]=$):$=e[25];let W;e[26]!==k?(W=k&&n.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:"Couldn't load branches from GitHub. You can still pick from your branches."}),e[26]=k,e[27]=W):W=e[27];let K;e[28]!==E||e[29]!==k||e[30]!==w?(K=!k&&!w&&n.jsx(pn,{children:E?"Looking through more branches...":"No branches found."}),e[28]=E,e[29]=k,e[30]=w,e[31]=K):K=e[31];let re;e[32]!==T||e[33]!==b?(re=b.length>0&&n.jsx(Ei,{heading:"Your branches",children:b.map(Y=>n.jsxs(Ti,{value:Y.name,onSelect:()=>T(Y.name),children:[n.jsx(Ls,{className:"mr-2 h-4 w-4"}),n.jsx("span",{className:"flex-1 truncate",children:Y.name})]},Y.name))}),e[32]=T,e[33]=b,e[34]=re):re=e[34];let Z;e[35]!==S||e[36]!==T?(Z=S.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(Qc,{}),n.jsx(Ei,{heading:"Other branches in repo",children:S.map(Y=>n.jsxs(Ti,{value:Y.name,onSelect:()=>T(Y.name),children:[n.jsx(Ls,{className:"mr-2 h-4 w-4"}),n.jsx("span",{className:"flex-1 truncate",children:Y.name}),Y.author&&n.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",Y.author]})]},Y.name))})]}),e[35]=S,e[36]=T,e[37]=Z):Z=e[37];let J;e[38]!==R||e[39]!==E||e[40]!==P||e[41]!==p?(J=E&&n.jsx("div",{className:"border-t p-2",children:n.jsx(se,{variant:"ghost",size:"sm",className:"h-7 w-full text-xs",disabled:P,onClick:R,children:P||p?"Loading more…":"Load more branches"})}),e[38]=R,e[39]=E,e[40]=P,e[41]=p,e[42]=J):J=e[42];let X;e[43]!==E||e[44]!==S.length?(X=!E&&S.length>0&&n.jsx("div",{className:"border-t p-2 text-center text-xs text-muted-foreground",children:"All loaded"}),e[43]=E,e[44]=S.length,e[45]=X):X=e[45];let L;e[46]!==M||e[47]!==W||e[48]!==K||e[49]!==re||e[50]!==Z||e[51]!==J||e[52]!==X?(L=n.jsxs(gn,{onScroll:M,children:[W,K,re,Z,J,X]}),e[46]=M,e[47]=W,e[48]=K,e[49]=re,e[50]=Z,e[51]=J,e[52]=X,e[53]=L):L=e[53];let q;e[54]!==L||e[55]!==$?(q=n.jsx(Ut,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:n.jsxs(vn,{children:[$,L]})}),e[54]=L,e[55]=$,e[56]=q):q=e[56];let Q;return e[57]!==u||e[58]!==q||e[59]!==F?(Q=n.jsxs(Vt,{open:u,onOpenChange:f,children:[F,q]}),e[57]=u,e[58]=q,e[59]=F,e[60]=Q):Q=e[60],Q}function Xd(){const t=z.c(27),{org:e}=ge(),{selectedVirtualMcp:s}=hn(),{data:i}=Oi.useSession(),{currentBranch:r,setCurrentTaskBranch:o}=Ht();let a;t[0]!==e.id?(a=ba(e.id),t[0]=e.id,t[1]=a):a=t[1];const h=s??a,c=Pt(h.id),d=i?.user?.id??"",u=c?.metadata?.githubRepo??null,f=!!u?.connectionId&&!!d;let m;t[2]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(Lc,{size:32}),t[2]=m):m=t[2];let _;t[3]!==h.icon||t[4]!==h.title?(_=n.jsx(Ct,{icon:h.icon,name:h.title,size:"lg",fallbackIcon:m,className:"size-10 min-w-10 md:size-[60px]! md:min-w-[60px] rounded-xl md:rounded-[18px]!"}),t[3]=h.icon,t[4]=h.title,t[5]=_):_=t[5];let p;t[6]!==h.title?(p=n.jsx("h3",{className:"text-base md:text-xl font-medium text-foreground",children:h.title}),t[6]=h.title,t[7]=p):p=t[7];const g=h.description??"Ask anything about configuring model providers or using MCP Mesh.";let v;t[8]!==g?(v=n.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:g}),t[8]=g,t[9]=v):v=t[9];let x;t[10]!==r||t[11]!==c?.metadata?.vmMap||t[12]!==u||t[13]!==e.id||t[14]!==e.slug||t[15]!==o||t[16]!==f||t[17]!==d?(x=f&&n.jsx("div",{className:"mt-2",children:n.jsx(Yd,{orgId:e.id,orgSlug:e.slug,userId:d,connectionId:u.connectionId,owner:u.owner,repo:u.name,vmMap:c?.metadata?.vmMap,value:r??void 0,onChange:o})}),t[10]=r,t[11]=c?.metadata?.vmMap,t[12]=u,t[13]=e.id,t[14]=e.slug,t[15]=o,t[16]=f,t[17]=d,t[18]=x):x=t[18];let b;t[19]!==_||t[20]!==p||t[21]!==v||t[22]!==x?(b=n.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[_,p,v,x]}),t[19]=_,t[20]=p,t[21]=v,t[22]=x,t[23]=b):b=t[23];let S;t[24]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx("div",{className:"w-full max-w-3xl mx-auto",children:n.jsx(Ce.IceBreakers,{})}),t[24]=S):S=t[24];let w;return t[25]!==b?(w=n.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center gap-6 px-4",children:[b,S]}),t[25]=b,t[26]=w):w=t[26],w}function Jd(){const t=z.c(26),{org:e}=ge(),s=mh(),{isChatEmpty:i}=rs(),[r,o]=A.useState("chat"),a=Nc();if(s.length===0){let b;return t[0]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(Ce,{className:"animate-in fade-in-0 duration-200",children:n.jsx(Ce.Main,{className:"flex flex-col items-center",children:n.jsx(Ce.EmptyState,{children:n.jsx(Ce.NoAiProviderEmptyState,{})})})}),t[0]=b):b=t[0],b}let l;t[1]!==a.hasDecoKey||t[2]!==a.hasOnlyDecoProvider||t[3]!==a.isLoading||t[4]!==a.isZeroBalance||t[5]!==i||t[6]!==e?(l=a.hasDecoKey&&a.isZeroBalance&&a.hasOnlyDecoProvider&&!a.isLoading&&i&&!jc(e.id),t[1]=a.hasDecoKey,t[2]=a.hasOnlyDecoProvider,t[3]=a.isLoading,t[4]=a.isZeroBalance,t[5]=i,t[6]=e,t[7]=l):l=t[7];const h=l;let c;t[8]!==h?(c=h&&n.jsx(Ce.CreditsEmptyState,{}),t[8]=h,t[9]=c):c=t[9];const d=r!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let u;t[10]!==d?(u=te("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",d),t[10]=d,t[11]=u):u=t[11];let f;t[12]!==i?(f=i?n.jsxs(n.Fragment,{children:[n.jsx(Ce.Main,{children:n.jsx(Xd,{})}),n.jsx(Ce.Footer,{children:n.jsx(Ce.Input,{onOpenContextPanel:()=>o("context")})})]}):n.jsxs(n.Fragment,{children:[n.jsx(Ce.Main,{children:n.jsx(Ce.Messages,{})}),n.jsx(Ce.Footer,{children:n.jsx(Ce.Input,{onOpenContextPanel:()=>o("context")})})]}),t[12]=i,t[13]=f):f=t[13];let m;t[14]!==u||t[15]!==f?(m=n.jsx("div",{className:u,children:f}),t[14]=u,t[15]=f,t[16]=m):m=t[16];const _=r==="context"?"opacity-100":"opacity-0 pointer-events-none";let p;t[17]!==_?(p=te("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",_),t[17]=_,t[18]=p):p=t[18];let g;t[19]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(Nd,{back:!0,onClose:()=>o("chat")}),t[19]=g):g=t[19];let v;t[20]!==p?(v=n.jsx("div",{className:p,children:g}),t[20]=p,t[21]=v):v=t[21];let x;return t[22]!==c||t[23]!==m||t[24]!==v?(x=n.jsxs(Ce,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[c,m,v]}),t[22]=c,t[23]=m,t[24]=v,t[25]=x):x=t[25],x}function Ja(){const t=z.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(Ce.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(Rt,{fallback:e,children:n.jsx(A.Suspense,{fallback:n.jsx(Ce.Skeleton,{}),children:n.jsx(Jd,{})})}),t[1]=s):s=t[1],s}async function Zd(t,e,s){const i=await t.callTool({name:e,arguments:s});if(i.isError){const r=i.content?.[0]?.text??`Tool ${e} failed without a message`;throw new Error(r)}return i}const Za=["VM_START"],ai=new Map,Qd=t=>`${t.virtualMcpId}::${t.branch??""}`,er=new Set,xi={mark:(t,e)=>er.add(`${t}::${e}`),clear:(t,e)=>er.delete(`${t}::${e}`),isStopped:(t,e)=>er.has(`${t}::${e}`)};function Qa(t){const e=_s();return ua({mutationKey:Za,mutationFn:async s=>{s.branch&&xi.clear(s.virtualMcpId,s.branch);const i=Qd(s),r=ai.get(i);if(r)return r;const o=(async()=>(await Zd(t,"VM_START",s)).structuredContent)();ai.set(i,o);try{return await o}finally{ai.get(i)===o&&ai.delete(i)}},onSuccess:()=>{fa(e)}})}function eu(t,e){const s=z.c(3);let i;return s[0]!==e||s[1]!==t?(i={mutationKey:Za,predicate:o=>{if(!t)return!1;const a=o.state.variables;return!a||a.virtualMcpId!==t?!1:(a.branch??"")===(e??"")}},s[0]=e,s[1]=t,s[2]=i):i=s[2],gd(i)>0}const tu={settings:th,automations:eh,preview:Hc,git:Ls};function ro(t){const e=$i(t);if(e.type==="icon"){const s=zi(e.name);return s?{kind:"component",Component:s}:null}return e.type==="url"?{kind:"url",src:e.url}:null}function tr(t){if(t.kind==="system")return{kind:"component",Component:tu[t.tabId]};const e=ro(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=ro(s.icon);return i||{kind:"fallback"}}function su(t){const{org:e}=ge(),s=Ue({connectionId:Ft,orgId:e.id,orgSlug:e.slug}),i=Pa(),r=A.useSyncExternalStore(i.threads.subscribe,i.threads.get),o=t?r.find(l=>l.id===t)??null:null,{data:a}=gc({queryKey:us.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 el(t){const e=z.c(8),s=is();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},e[0]=i):i=e[0];const r=ma(i),o=Pt(t.virtualMcpId),a=su(t.taskId),{currentBranch:l}=Ht(),h=o?.metadata?.ui??null,c=h?.layout??null,d=c?.tabs??[],u=h?.pinnedViews??[],f=a?.expanded_tools??[],m=!!(o&&Zt(o));let _;e[1]===Symbol.for("react.memo_cache_sentinel")?(_={includeVirtual:!0},e[1]=_):_=e[1];const p=Ys(_),{activeTab:g,mainOpen:v}=Vc({mainParam:r.main,metadata:c?{defaultMainView:c.defaultMainView??null,tabs:d.map(iu)}:null}),x=ya(g),b=[];m&&(b.push({id:"preview",title:"Preview"}),b.push({id:"git",title:l??"git"})),b.push({id:"settings",title:"Settings"}),b.push({id:"automations",title:"Automations"});const S=new Map;for(const R of f){const B=Gn(R.appId,R.toolName);S.set(B,{id:B,title:R.toolName,appId:R.appId,iconKey:R.toolName})}for(const R of u){const B=Gn(R.connectionId,R.toolName);S.set(B,{id:B,title:R.label||R.toolName,appId:R.connectionId,iconKey:R.toolName,iconUrl:R.icon??null})}let w;e[2]!==p?(w=R=>({id:R.id,title:R.title,kind:"agent",icon:tr({tabId:R.id,kind:"agent",appId:R.view.appId,connections:p})}),e[2]=p,e[3]=w):w=e[3];const k=[...d.map(w),...Array.from(S.values()).map(R=>({id:R.id,title:R.title,kind:"expanded",icon:tr({tabId:R.iconKey,kind:"expanded",appId:R.appId,iconUrl:R.iconUrl,connections:p})})),...b.map(R=>({id:R.id,title:R.title,kind:"system",icon:tr({tabId:R.id,kind:"system",connections:p})}))];let E;return e[4]!==g||e[5]!==v||e[6]!==s?(E=R=>{const B=Kc({clickedId:R,activeTab:g,mainOpen:v});s({to:".",search:I=>({...I,main:B}),replace:!0})},e[4]=g,e[5]=v,e[6]=s,e[7]=E):E=e[7],{activeTab:g,mainOpen:v,setActiveTab:E,systemTabs:b,layoutTabs:d,expandedTools:f,automationTabParsed:x,tabs:k}}function iu(t){return{id:t.id}}function tl(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.
|
|
3
|
+
<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 ru(t){const e=z.c(84),{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,m=d===void 0?!1:d,[_,p]=A.useState(!1),[g,v]=A.useState("icons"),[x,b]=A.useState(""),[S,w]=A.useState("blue");let k;e[0]!==s?(k=$i(s),e[0]=s,e[1]=k):k=e[1];const E=k,P=E.type==="icon"||E.type==="url"&&E.color?E.color:S;let R;e[2]!==i||e[3]!==P?(R=Ie=>{i(Ji(Ie,P))},e[2]=i,e[3]=P,e[4]=R):R=e[4];const B=R;let I;e[5]!==i||e[6]!==r||e[7]!==E.name||e[8]!==E.type||e[9]!==E.url?(I=Ie=>{w(Ie),r?.(Ie),E.type==="icon"?i(Ji(E.name,Ie)):E.type==="url"&&i(Xn(E.url,Ie))},e[5]=i,e[6]=r,e[7]=E.name,e[8]=E.type,e[9]=E.url,e[10]=I):I=e[10];const T=I;let y;e[11]!==i||e[12]!==P?(y=Ie=>{i(Xn(Ie,P)),p(!1)},e[11]=i,e[12]=P,e[13]=y):y=e[13];const N=y;let C;e[14]!==i||e[15]!==P?(C=()=>{const Ie=xn(),os=Ie[Math.floor(Math.random()*Ie.length)];i(Ji(os,P))},e[14]=i,e[15]=P,e[16]=C):C=e[16];const j=C;let M,D,F,H,O,$,W,K;if(e[17]!==l||e[18]!==m||e[19]!==_||e[20]!==u){const Ie={xs:"rounded-md",sm:"rounded-lg","sm+":"rounded-xl",md:"rounded-xl",lg:"rounded-2xl",xl:"rounded-2xl"};D=Vt,$=m?!1:_,W=p,M=Wt,O=!0,K="button",F=m,H=te("relative group overflow-hidden",m?"cursor-default opacity-50":"cursor-pointer",Ie[u],l),e[17]=l,e[18]=m,e[19]=_,e[20]=u,e[21]=M,e[22]=D,e[23]=F,e[24]=H,e[25]=O,e[26]=$,e[27]=W,e[28]=K}else M=e[21],D=e[22],F=e[23],H=e[24],O=e[25],$=e[26],W=e[27],K=e[28];let re;e[29]!==h||e[30]!==o||e[31]!==u||e[32]!==s?(re=n.jsx(Jn,{icon:s,name:o,size:u,className:h}),e[29]=h,e[30]=o,e[31]=u,e[32]=s,e[33]=re):re=e[33];let Z;e[34]!==m||e[35]!==f?(Z=f&&!m&&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(bn,{size:16,className:"text-white"})}),e[34]=m,e[35]=f,e[36]=Z):Z=e[36];let J;e[37]!==F||e[38]!==H||e[39]!==re||e[40]!==Z||e[41]!==K?(J=n.jsxs("button",{type:K,disabled:F,className:H,children:[re,Z]}),e[37]=F,e[38]=H,e[39]=re,e[40]=Z,e[41]=K,e[42]=J):J=e[42];let X;e[43]!==M||e[44]!==O||e[45]!==J?(X=n.jsx(M,{asChild:O,children:J}),e[43]=M,e[44]=O,e[45]=J,e[46]=X):X=e[46];let L;e[47]!==o||e[48]!==s?(L=n.jsx("div",{className:"flex items-center justify-center py-4",children:n.jsx(Jn,{icon:s,name:o,size:"xl"})}),e[47]=o,e[48]=s,e[49]=L):L=e[49];let q;e[50]===Symbol.for("react.memo_cache_sentinel")?(q=()=>v("icons"),e[50]=q):q=e[50];const Q=g==="icons"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let Y;e[51]!==Q?(Y=te("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",Q),e[51]=Q,e[52]=Y):Y=e[52];let ee;e[53]!==Y?(ee=n.jsx("button",{type:"button",onClick:q,className:Y,children:"Icons"}),e[53]=Y,e[54]=ee):ee=e[54];let ae;e[55]===Symbol.for("react.memo_cache_sentinel")?(ae=()=>v("upload"),e[55]=ae):ae=e[55];const _e=g==="upload"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let ue;e[56]!==_e?(ue=te("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",_e),e[56]=_e,e[57]=ue):ue=e[57];let pe;e[58]!==ue?(pe=n.jsx("button",{type:"button",onClick:ae,className:ue,children:"Upload"}),e[58]=ue,e[59]=pe):pe=e[59];let ve;e[60]===Symbol.for("react.memo_cache_sentinel")?(ve=n.jsx("div",{className:"flex-1"}),e[60]=ve):ve=e[60];let Re;e[61]!==ee||e[62]!==pe?(Re=n.jsxs("div",{className:"flex items-center border-b border-border px-3",children:[ee,pe,ve]}),e[61]=ee,e[62]=pe,e[63]=Re):Re=e[63];let ne;e[64]!==T||e[65]!==j||e[66]!==B||e[67]!==N||e[68]!==E.name||e[69]!==E.type||e[70]!==x||e[71]!==P||e[72]!==g?(ne=g==="icons"?n.jsx(lu,{search:x,onSearchChange:b,selectedColor:P,onColorChange:T,onSelectIcon:B,onRandom:j,currentIconName:E.type==="icon"?E.name:null}):n.jsx(cu,{onUpload:N}),e[64]=T,e[65]=j,e[66]=B,e[67]=N,e[68]=E.name,e[69]=E.type,e[70]=x,e[71]=P,e[72]=g,e[73]=ne):ne=e[73];let le;e[74]!==L||e[75]!==Re||e[76]!==ne?(le=n.jsx(Ut,{align:"start",className:"w-80 p-0",onOpenAutoFocus:nu,children:n.jsxs("div",{className:"flex flex-col",children:[L,Re,ne]})}),e[74]=L,e[75]=Re,e[76]=ne,e[77]=le):le=e[77];let De;return e[78]!==D||e[79]!==$||e[80]!==W||e[81]!==X||e[82]!==le?(De=n.jsxs(D,{open:$,onOpenChange:W,children:[X,le]}),e[78]=D,e[79]=$,e[80]=W,e[81]=X,e[82]=le,e[83]=De):De=e[83],De}function nu(t){return t.preventDefault()}function ou(t){const e=z.c(27),{selectedColor:s,onColorChange:i}=t,[r,o]=A.useState(!1);let a,l,h,c,d,u,f;if(e[0]!==r||e[1]!==s){const x=wa(s);l=Vt,u=r,f=o,a=Wt,d=!0,h="button",c=te("h-6 w-6 rounded-full shrink-0 ring-2 ring-offset-2 ring-offset-background transition-all cursor-pointer hover:scale-110",x.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 m;e[9]!==h||e[10]!==c?(m=n.jsx("button",{type:h,className:c,title:"Change color"}),e[9]=h,e[10]=c,e[11]=m):m=e[11];let _;e[12]!==a||e[13]!==d||e[14]!==m?(_=n.jsx(a,{asChild:d,children:m}),e[12]=a,e[13]=d,e[14]=m,e[15]=_):_=e[15];let p;e[16]!==i||e[17]!==s?(p=ih.map(x=>n.jsx("button",{type:"button",onClick:()=>{i(x.name),o(!1)},className:te("h-5 w-5 rounded-full transition-all shrink-0 cursor-pointer",x.dot,s===x.name?"ring-2 ring-offset-1 ring-offset-background ring-foreground/30 scale-110":"hover:scale-110"),title:x.name},x.name)),e[16]=i,e[17]=s,e[18]=p):p=e[18];let g;e[19]!==p?(g=n.jsx(Ut,{align:"start",side:"right",sideOffset:8,className:"w-auto p-2",onOpenAutoFocus:au,children:n.jsx("div",{className:"grid grid-cols-4 gap-1",children:p})}),e[19]=p,e[20]=g):g=e[20];let v;return e[21]!==l||e[22]!==u||e[23]!==f||e[24]!==_||e[25]!==g?(v=n.jsxs(l,{open:u,onOpenChange:f,children:[_,g]}),e[21]=l,e[22]=u,e[23]=f,e[24]=_,e[25]=g,e[26]=v):v=e[26],v}function au(t){return t.preventDefault()}function lu(t){const e=z.c(44),{search:s,onSearchChange:i,selectedColor:r,onColorChange:o,onSelectIcon:a,onRandom:l,currentIconName:h}=t;let c,d,u,f,m,_,p;if(e[0]!==h||e[1]!==o||e[2]!==l||e[3]!==i||e[4]!==a||e[5]!==s||e[6]!==r){const S=xn(),w=wa(r);d=s.trim()?S.filter(T=>{const y=Sr(T),N=s.toLowerCase();return y.includes(N)||T.toLowerCase().includes(N)}):S,_="flex flex-col";let k;e[14]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(qa,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[14]=k):k=e[14];let E;e[15]!==i?(E=T=>i(T.target.value),e[15]=i,e[16]=E):E=e[16];let P;e[17]!==s||e[18]!==E?(P=n.jsxs("div",{className:"relative flex-1",children:[k,n.jsx(ot,{value:s,onChange:E,placeholder:"Filter...",className:"h-8 text-xs pl-7"})]}),e[17]=s,e[18]=E,e[19]=P):P=e[19];let R;e[20]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx(sh,{size:14,className:"text-muted-foreground"}),e[20]=R):R=e[20];let B;e[21]!==l?(B=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:R}),e[21]=l,e[22]=B):B=e[22];let I;e[23]!==o||e[24]!==r?(I=n.jsx(ou,{selectedColor:r,onColorChange:o}),e[23]=o,e[24]=r,e[25]=I):I=e[25],e[26]!==B||e[27]!==I||e[28]!==P?(p=n.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[P,B,I]}),e[26]=B,e[27]=I,e[28]=P,e[29]=p):p=e[29],c=Nn,m="h-56",u="grid grid-cols-9 gap-0.5 px-2 pb-2",f=d.map(T=>{const y=zi(T);return y?n.jsx("button",{type:"button",onClick:()=>a(T),className:te("h-8 w-8 flex items-center justify-center rounded-md transition-colors cursor-pointer",h===T?te(w.bg,w.text):te(w.text,"hover:bg-accent")),title:T,children:n.jsx(y,{size:18})},T):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]=m,e[12]=_,e[13]=p}else c=e[7],d=e[8],u=e[9],f=e[10],m=e[11],_=e[12],p=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 v;e[33]!==d.length?(v=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]=v):v=e[34];let x;e[35]!==c||e[36]!==m||e[37]!==g||e[38]!==v?(x=n.jsxs(c,{className:m,children:[g,v]}),e[35]=c,e[36]=m,e[37]=g,e[38]=v,e[39]=x):x=e[39];let b;return e[40]!==_||e[41]!==p||e[42]!==x?(b=n.jsxs("div",{className:_,children:[p,x]}),e[40]=_,e[41]=p,e[42]=x,e[43]=b):b=e[43],b}function cu(t){const e=z.c(27),{onUpload:s}=t,i=A.useRef(null);let r;e[0]!==s?(r=k=>{const E=k.target.files?.[0];if(!E)return;if(E.size>2097152){he.error("Image must be smaller than 2MB"),k.target.value="";return}const P=new FileReader;P.onerror=()=>{he.error("Failed to read image file"),i.current&&(i.current.value="")},P.onloadend=()=>{P.readyState===FileReader.DONE&&P.result&&s(P.result),i.current&&(i.current.value="")},P.readAsDataURL(E)},e[0]=s,e[1]=r):r=e[1];const o=r,[a,l]=A.useState("");let h;e[2]!==s||e[3]!==a?(h=()=>{const k=a.trim();k&&(s(k),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(Fh,{size:20}),n.jsx("span",{className:"text-xs",children:"Click to upload an image (max 2MB)"})]}),e[8]=f):f=e[8];let m;e[9]===Symbol.for("react.memo_cache_sentinel")?(m=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]=m):m=e[9];let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=k=>l(k.target.value),e[10]=_):_=e[10];let p;e[11]!==c?(p=k=>{k.key==="Enter"&&(k.preventDefault(),c())},e[11]=c,e[12]=p):p=e[12];let g;e[13]!==a||e[14]!==p?(g=n.jsx(ot,{value:a,onChange:_,placeholder:"Paste image URL...",className:"h-8 text-xs flex-1",onKeyDown:p}),e[13]=a,e[14]=p,e[15]=g):g=e[15];let v;e[16]!==a?(v=a.trim(),e[16]=a,e[17]=v):v=e[17];const x=!v;let b;e[18]!==c||e[19]!==x?(b=n.jsx(se,{variant:"outline",size:"sm",className:"h-8 px-3 text-xs shrink-0",onClick:c,disabled:x,children:"Apply"}),e[18]=c,e[19]=x,e[20]=b):b=e[20];let S;e[21]!==b||e[22]!==g?(S=n.jsxs("div",{className:"flex items-center gap-1.5",children:[g,b]}),e[21]=b,e[22]=g,e[23]=S):S=e[23];let w;return e[24]!==S||e[25]!==d?(w=n.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[d,f,m,S]}),e[24]=S,e[25]=d,e[26]=w):w=e[26],w}function hu(t){const e=z.c(5),{value:s}=t;let i;if(e[0]!==s){i=Symbol.for("react.early_return_sentinel");e:{const o=$i(s);if(o.type==="icon"){const a=zi(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(Hh,{size:16,className:"text-muted-foreground"}),e[4]=r):r=e[4],r}function du(t){const e=z.c(66),{value:s,onChange:i,className:r,disabled:o}=t,[a,l]=A.useState(!1),[h,c]=A.useState("");let d;e[0]!==s?(d=$i(s),e[0]=s,e[1]=d):d=e[1];const u=d,f=u.type==="icon"?u.name:null;let m,_,p,g,v,x,b,S,w,k,E,P,R,B,I;if(e[2]!==r||e[3]!==f||e[4]!==o||e[5]!==i||e[6]!==a||e[7]!==h||e[8]!==s){const D=xn();g=h.trim()?D.filter(re=>{const Z=h.toLowerCase();return Sr(re).includes(Z)||re.toLowerCase().includes(Z)}):D,p=Vt,v=o?!1:a,x=l;const F=o?"cursor-default opacity-50":"cursor-pointer hover:bg-accent";let H;e[24]!==r||e[25]!==F?(H=te("size-7 shrink-0 rounded-md transition-colors flex items-center justify-center",F,r),e[24]=r,e[25]=F,e[26]=H):H=e[26];let O;e[27]!==s?(O=n.jsx(hu,{value:s}),e[27]=s,e[28]=O):O=e[28],e[29]!==o||e[30]!==H||e[31]!==O?(b=n.jsx(Wt,{asChild:!0,children:n.jsx("button",{type:"button",disabled:o,className:H,children:O})}),e[29]=o,e[30]=H,e[31]=O,e[32]=b):b=e[32],_=Ut,R="start",B="w-64 p-0",I=uu,E="flex flex-col";let $;e[33]===Symbol.for("react.memo_cache_sentinel")?($=n.jsx(qa,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[33]=$):$=e[33];let W;e[34]===Symbol.for("react.memo_cache_sentinel")?(W=re=>c(re.target.value),e[34]=W):W=e[34],e[35]!==h?(P=n.jsx("div",{className:"px-2 py-2",children:n.jsxs("div",{className:"relative",children:[$,n.jsx(ot,{value:h,onChange:W,placeholder:"Filter...",className:"h-7 text-xs pl-7"})]})}),e[35]=h,e[36]=P):P=e[36],m=Nn,k="h-48",S="grid grid-cols-8 gap-0.5 px-2 pb-2";let K;e[37]!==f||e[38]!==i?(K=re=>{const Z=zi(re);return Z?n.jsx("button",{type:"button",onClick:()=>{i(`icon://${re}`),l(!1)},className:te("h-7 w-7 flex items-center justify-center rounded-md transition-colors cursor-pointer",f===re?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),title:Sr(re),children:n.jsx(Z,{size:16})},re):null},e[37]=f,e[38]=i,e[39]=K):K=e[39],w=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]=m,e[10]=_,e[11]=p,e[12]=g,e[13]=v,e[14]=x,e[15]=b,e[16]=S,e[17]=w,e[18]=k,e[19]=E,e[20]=P,e[21]=R,e[22]=B,e[23]=I}else m=e[9],_=e[10],p=e[11],g=e[12],v=e[13],x=e[14],b=e[15],S=e[16],w=e[17],k=e[18],E=e[19],P=e[20],R=e[21],B=e[22],I=e[23];let T;e[40]!==S||e[41]!==w?(T=n.jsx("div",{className:S,children:w}),e[40]=S,e[41]=w,e[42]=T):T=e[42];let y;e[43]!==g.length?(y=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]=y):y=e[44];let N;e[45]!==m||e[46]!==T||e[47]!==y||e[48]!==k?(N=n.jsxs(m,{className:k,children:[T,y]}),e[45]=m,e[46]=T,e[47]=y,e[48]=k,e[49]=N):N=e[49];let C;e[50]!==N||e[51]!==E||e[52]!==P?(C=n.jsxs("div",{className:E,children:[P,N]}),e[50]=N,e[51]=E,e[52]=P,e[53]=C):C=e[53];let j;e[54]!==_||e[55]!==C||e[56]!==R||e[57]!==B||e[58]!==I?(j=n.jsx(_,{align:R,className:B,onOpenAutoFocus:I,children:C}),e[54]=_,e[55]=C,e[56]=R,e[57]=B,e[58]=I,e[59]=j):j=e[59];let M;return e[60]!==p||e[61]!==v||e[62]!==x||e[63]!==b||e[64]!==j?(M=n.jsxs(p,{open:v,onOpenChange:x,children:[b,j]}),e[60]=p,e[61]=v,e[62]=x,e[63]=b,e[64]=j,e[65]=M):M=e[65],M}function uu(t){return t.preventDefault()}function bi(){const t=z.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(Be,{className:"animate-spin text-muted-foreground",size:24})}),t[0]=e):e=t[0],e}function sr(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(ji,{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 fu(t){const e=z.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=te("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 m;e[12]!==u||e[13]!==f?(m=n.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[u,f]}),e[12]=u,e[13]=f,e[14]=m):m=e[14];let _;e[15]!==o||e[16]!==i||e[17]!==r?(_=n.jsx(Uh,{checked:i,onCheckedChange:r,disabled:o,className:"mt-0.5"}),e[15]=o,e[16]=i,e[17]=r,e[18]=_):_=e[18];let p;return e[19]!==h||e[20]!==m||e[21]!==_?(p=n.jsxs("label",{className:h,children:[m,_]}),e[19]=h,e[20]=m,e[21]=_,e[22]=p):p=e[22],p}function jn(t){const e=z.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(mu);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(fu,{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 mu(t){return t.id}function _u(t){const e=z.c(13),{connectionId:s,selections:i,onToggle:r,disabled:o}=t,{org:a}=ge();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=Ue(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:d}=Vh(c);let u;e[6]!==d.tools?(u=d.tools.map(pu),e[6]=d.tools,e[7]=u):u=e[7];const f=u;let m;return e[8]!==o||e[9]!==f||e[10]!==r||e[11]!==i?(m=n.jsx(jn,{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]=m):m=e[12],m}function pu(t){return{id:t.name,name:t.name,description:t.description,tags:n.jsx(Ah,{annotations:t.annotations,_meta:t._meta})}}function gu(t){const e=z.c(13),{connectionId:s,selections:i,onToggle:r,disabled:o}=t,{org:a}=ge();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=Ue(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:d}=Ph(c);let u;e[6]!==d.resources?(u=d.resources.map(vu),e[6]=d.resources,e[7]=u):u=e[7];const f=u;let m;return e[8]!==o||e[9]!==f||e[10]!==r||e[11]!==i?(m=n.jsx(jn,{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]=m):m=e[12],m}function vu(t){return{id:t.name||t.uri,name:t.name||t.uri,description:t.description}}function xu(t){const e=z.c(13),{connectionId:s,selections:i,onToggle:r,disabled:o}=t,{org:a}=ge();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=Ue(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:d}=Kh(c);let u;e[6]!==d.prompts?(u=d.prompts.map(bu),e[6]=d.prompts,e[7]=u):u=e[7];const f=u;let m;return e[8]!==o||e[9]!==f||e[10]!==r||e[11]!==i?(m=n.jsx(jn,{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]=m):m=e[12],m}function bu(t){return{id:t.name,name:t.name,description:t.description}}function Su(t){const e=z.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,m=o[r],_=i==="tools"?m?.tools===null:i==="resources"?m?.resources===null:m?.prompts===null;let p;e[0]!==i||e[1]!==r||e[2]!==u||e[3]!==d||e[4]!==c?(p=()=>{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]=p):p=e[5];const g=p;let v;e[6]!==s.icon||e[7]!==s.title?(v=n.jsx(Ct,{icon:s.icon,name:s.title,size:"sm",className:"shrink-0"}),e[6]=s.icon,e[7]=s.title,e[8]=v):v=e[8];let x;e[9]!==s.title?(x=n.jsx("h2",{className:"text-base font-semibold truncate",children:s.title}),e[9]=s.title,e[10]=x):x=e[10];let b;e[11]!==s.description?(b=s.description&&n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.description}),e[11]=s.description,e[12]=b):b=e[12];let S;e[13]!==x||e[14]!==b?(S=n.jsxs("div",{className:"flex-1 min-w-0",children:[x,b]}),e[13]=x,e[14]=b,e[15]=S):S=e[15];let w;e[16]!==v||e[17]!==S?(w=n.jsx("div",{className:"px-6 pt-5 pb-4 shrink-0",children:n.jsxs("div",{className:"flex items-center gap-3",children:[v,S]})}),e[16]=v,e[17]=S,e[18]=w):w=e[18];let k;e[19]===Symbol.for("react.memo_cache_sentinel")?(k=[{id:"tools",label:"Tools"},{id:"resources",label:"Resources"},{id:"prompts",label:"Prompts"}],e[19]=k):k=e[19];let E;e[20]!==f?(E=M=>f(M),e[20]=f,e[21]=E):E=e[21];let P;e[22]!==i||e[23]!==E?(P=n.jsx(Wh,{tabs:k,activeTab:i,onTabChange:E}),e[22]=i,e[23]=E,e[24]=P):P=e[24];const R=_?"Deselect all":"Select all";let B;e[25]!==g||e[26]!==R?(B=n.jsx("button",{type:"button",onClick:g,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:R}),e[25]=g,e[26]=R,e[27]=B):B=e[27];let I;e[28]!==B||e[29]!==P?(I=n.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-t border-border shrink-0",children:[P,B]}),e[28]=B,e[29]=P,e[30]=I):I=e[30];let T;e[31]!==i||e[32]!==o||e[33]!==r||e[34]!==a?(T=i==="tools"&&n.jsx(Rt,{fallback:sr("Tools not supported by this server"),children:n.jsx(A.Suspense,{fallback:n.jsx(bi,{}),children:n.jsx(_u,{connectionId:r,selections:o[r]?o[r].tools:[],onToggle:(M,D)=>a(r,M,D)})})}),e[31]=i,e[32]=o,e[33]=r,e[34]=a,e[35]=T):T=e[35];let y;e[36]!==i||e[37]!==o||e[38]!==r||e[39]!==l?(y=i==="resources"&&n.jsx(Rt,{fallback:sr("Resources not supported by this server"),children:n.jsx(A.Suspense,{fallback:n.jsx(bi,{}),children:n.jsx(gu,{connectionId:r,selections:o[r]?o[r].resources:[],onToggle:(M,D)=>l(r,M,D)})})}),e[36]=i,e[37]=o,e[38]=r,e[39]=l,e[40]=y):y=e[40];let N;e[41]!==i||e[42]!==o||e[43]!==r||e[44]!==h?(N=i==="prompts"&&n.jsx(Rt,{fallback:sr("Prompts not supported by this server"),children:n.jsx(A.Suspense,{fallback:n.jsx(bi,{}),children:n.jsx(xu,{connectionId:r,selections:o[r]?o[r].prompts:[],onToggle:(M,D)=>h(r,M,D)})})}),e[41]=i,e[42]=o,e[43]=r,e[44]=h,e[45]=N):N=e[45];let C;e[46]!==T||e[47]!==y||e[48]!==N?(C=n.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[T,y,N]}),e[46]=T,e[47]=y,e[48]=N,e[49]=C):C=e[49];let j;return e[50]!==I||e[51]!==C||e[52]!==w?(j=n.jsxs(n.Fragment,{children:[w,I,C]}),e[50]=I,e[51]=C,e[52]=w,e[53]=j):j=e[53],j}function yu(t){const e=z.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=Aa(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(rh,{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(se,{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 wu(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 no(t){return Object.entries(t).map(([e,s])=>({connection_id:e,selected_tools:s.tools,selected_resources:s.resources,selected_prompts:s.prompts}))}function Cu(t,e){return e.type==="SET_ACTIVE_TAB"?{...t,activeTab:e.payload}:t}function ku(t){const e=z.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]=A.useReducer(Cu,h),u=yn(r??"");let f;e[1]!==a?(f=a??[],e[1]=a,e[2]=f):f=e[2];let m;e[3]!==f?(m=wu(f),e[3]=f,e[4]=m):m=e[4];const _=m;let p;e[5]!==o||e[6]!==_?(p=($,W,K,re)=>{const Z=_[$]?.[W];let J;Z===null?J=re.filter(L=>L!==K):Z?.includes(K)?J=Z.filter(L=>L!==K):(J=[...Z??[],K],J.length===re.length&&(J=null));const X={..._};X[$]?X[$]={...X[$]}:X[$]={tools:null,resources:null,prompts:null},X[$][W]=J,o.setValue("connections",no(X),{shouldDirty:!0,shouldTouch:!0})},e[5]=o,e[6]=_,e[7]=p):p=e[7];const g=p;let v;e[8]!==o||e[9]!==_?(v=($,W)=>{const re=_[$]?.[W]===null?[]:null,Z={..._};Z[$]?Z[$]={...Z[$]}:Z[$]={tools:null,resources:null,prompts:null},Z[$][W]=re,o.setValue("connections",no(Z),{shouldDirty:!0,shouldTouch:!0})},e[8]=o,e[9]=_,e[10]=v):v=e[10];const x=v;let b;e[11]!==g?(b=($,W,K)=>g($,"tools",W,K),e[11]=g,e[12]=b):b=e[12];const S=b;let w;e[13]!==g?(w=($,W,K)=>g($,"resources",W,K),e[13]=g,e[14]=w):w=e[14];const k=w;let E;e[15]!==g?(E=($,W,K)=>g($,"prompts",W,K),e[15]=g,e[16]=E):E=e[16];const P=E;let R;e[17]!==x?(R=$=>x($,"tools"),e[17]=x,e[18]=R):R=e[18];const B=R;let I;e[19]!==x?(I=$=>x($,"resources"),e[19]=x,e[20]=I):I=e[20];const T=I;let y;e[21]!==x?(y=$=>x($,"prompts"),e[21]=x,e[22]=y):y=e[22];const N=y;if(!r||!u)return null;let C;e[23]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx(bi,{}),e[23]=C):C=e[23];let j;e[24]===Symbol.for("react.memo_cache_sentinel")?(j=$=>d({type:"SET_ACTIVE_TAB",payload:$}),e[24]=j):j=e[24];let M;e[25]!==u||e[26]!==c.activeTab||e[27]!==_||e[28]!==r||e[29]!==N||e[30]!==T||e[31]!==B||e[32]!==P||e[33]!==k||e[34]!==S?(M=n.jsx(Su,{currentConnection:u,activeTab:c.activeTab,selectedId:r,formData:_,toggleTool:S,toggleResource:k,togglePrompt:P,toggleAllTools:B,toggleAllResources:T,toggleAllPrompts:N,onTabChange:j},r),e[25]=u,e[26]=c.activeTab,e[27]=_,e[28]=r,e[29]=N,e[30]=T,e[31]=B,e[32]=P,e[33]=k,e[34]=S,e[35]=M):M=e[35];let D;e[36]!==l||e[37]!==r||e[38]!==M?(D=n.jsx(A.Suspense,{fallback:C,children:n.jsx(yu,{connectionId:r,onAuthenticate:l,children:M})}),e[36]=l,e[37]=r,e[38]=M,e[39]=D):D=e[39];let F;e[40]!==i?(F=n.jsx(Va,{className:"px-6 py-4 border-t border-border shrink-0",children:n.jsx(se,{variant:"outline",onClick:()=>i(!1),children:"Done"})}),e[40]=i,e[41]=F):F=e[41];let H;e[42]!==D||e[43]!==F?(H=n.jsxs(Fi,{className:"sm:max-w-2xl h-[75vh] max-h-[75vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[D,F]}),e[42]=D,e[43]=F,e[44]=H):H=e[44];let O;return e[45]!==i||e[46]!==s||e[47]!==H?(O=n.jsx(Hi,{open:s,onOpenChange:i,children:H}),e[45]=i,e[46]=s,e[47]=H,e[48]=O):O=e[48],O}const ir={tools:null,resources:null,prompts:null},Nu=vc.pick({status:!0,title:!0,description:!0,icon:!0,metadata:!0,connections:!0});function ju(t){const s=new TextEncoder().encode(t),i=Array.from(s,r=>String.fromCharCode(r)).join("");return btoa(i)}function Eu(t){const e=z.c(11),{url:s,agentId:i}=t,[r,o]=A.useState(!1);let a;e[0]!==i||e[1]!==s?(a=async()=>{be("agent_connect_action",{agent_id:i,action:"copy_url"}),await navigator.clipboard.writeText(s),o(!0),he.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(ps,{size:20,className:"text-green-600"}):n.jsx(un,{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(se,{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 Tu(t){const e=z.c(8),{url:s,serverName:i,agentId:r}=t;let o;e[0]!==r||e[1]!==i||e[2]!==s?(o=()=>{be("agent_connect_action",{agent_id:r,action:"install_cursor"});const d=Ba(i),f=ju(JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Cursor"}},null,2)),m=`cursor://anysphere.cursor-deeplink/mcp/install?name=${encodeURIComponent(d)}&config=${encodeURIComponent(f)}`;window.open(m,"_blank"),he.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(se,{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 Ru(t){const e=z.c(12),{url:s,serverName:i,agentId:r}=t,[o,a]=A.useState(!1);let l;e[0]!==r||e[1]!==i||e[2]!==s?(l=async()=>{be("agent_connect_action",{agent_id:r,action:"install_claude_code"});const m=Ba(i),p=JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Claude Code"}},null,2),g=`claude mcp add-json "${m}" '${p.replace(/'/g,"'\\''")}' --scope user`;await navigator.clipboard.writeText(g),a(!0),he.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(ps,{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(se,{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 Du({virtualMcp:t}){const{org:e}=ge(),s=Ue({connectionId:Ft,orgId:e.id,orgSlug:e.slug}),[i,r]=A.useState(null),[o,a]=A.useState(!1),[l,h]=A.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 p=(await s.callTool({name:"API_KEY_CREATE",arguments:{name:`typegen-${d}`,permissions:{[c]:["*"]}}})).structuredContent?.key;if(!p)throw new Error("No key in response");r(p),be("agent_typegen_key_generated",{agent_id:c})}catch{be("agent_typegen_key_failed",{agent_id:c}),he.error("Failed to generate API key")}finally{a(!1)}},m=async()=>{be("agent_connect_action",{agent_id:c,action:"typegen_copy_command",has_api_key:!!i}),await navigator.clipboard.writeText(u),h(!0),he.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(se,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:f,disabled:o,children:[o?n.jsx(Be,{size:14,className:"animate-spin"}):n.jsx(Ya,{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(se,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:m,children:l?n.jsx(ps,{size:12,className:"text-green-600"}):n.jsx(un,{size:12})})]})}),n.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Runtime variables"}),n.jsx(Pu,{apiKey:i,agentId:c})]})}function Pu(t){const e=z.c(21),{apiKey:s,agentId:i}=t,[r,o]=A.useState(!1),a=window.location.origin,l=s?`MESH_API_KEY=${s}`:"MESH_API_KEY=<api-key>",h=`MESH_BASE_URL=${a}`,c=`${l}
|
|
4
|
+
${h}`;let d;e[0]!==i||e[1]!==s||e[2]!==c?(d=async()=>{be("agent_connect_action",{agent_id:i,action:"typegen_copy_env",has_api_key:!!s}),await navigator.clipboard.writeText(c),o(!0),setTimeout(()=>o(!1),2e3)},e[0]=i,e[1]=s,e[2]=c,e[3]=d):d=e[3];const u=d,f=!s;let m;e[4]!==f?(m=te({"opacity-50":f}),e[4]=f,e[5]=m):m=e[5];let _;e[6]!==l||e[7]!==m?(_=n.jsx("span",{className:m,children:l}),e[6]=l,e[7]=m,e[8]=_):_=e[8];let p,g;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx("br",{}),g=n.jsx("span",{children:h}),e[9]=p,e[10]=g):(p=e[9],g=e[10]);let v;e[11]!==_?(v=n.jsxs("code",{className:"min-w-0 flex-1 font-mono text-xs text-muted-foreground",children:[_,p,g]}),e[11]=_,e[12]=v):v=e[12];let x;e[13]!==r?(x=r?n.jsx(ps,{size:12,className:"text-green-600"}):n.jsx(un,{size:12}),e[13]=r,e[14]=x):x=e[14];let b;e[15]!==u||e[16]!==x?(b=n.jsx(se,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:u,children:x}),e[15]=u,e[16]=x,e[17]=b):b=e[17];let S;return e[18]!==v||e[19]!==b?(S=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:[v,b]})}),e[18]=v,e[19]=b,e[20]=S):S=e[20],S}function Iu(t){const e=z.c(3),{virtualMcp:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"h-20 animate-pulse rounded-md bg-muted"}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsx(A.Suspense,{fallback:i,children:n.jsx(Du,{virtualMcp:s})}),e[1]=s,e[2]=r):r=e[2],r}function Mu(t){const e=z.c(37),{open:s,onOpenChange:i,virtualMcp:r}=t,{org:o}=ge(),a=`/api/${o.slug}/mcp/virtual-mcp/${r.id}`;let l;e[0]!==a?(l=new URL(a,window.location.origin),e[0]=a,e[1]=l):l=e[1];const h=l;let c;e[2]!==r.id||e[3]!==r.title?(c=r.title||`agent-${r.id?.slice(0,8)??"default"}`,e[2]=r.id,e[3]=r.title,e[4]=c):c=e[4];const d=c,u=Ra();let f;e[5]!==r.id||e[6]!==h.href?(f=n.jsx(Eu,{url:h.href,agentId:r.id}),e[5]=r.id,e[6]=h.href,e[7]=f):f=e[7];let m,_;e[8]!==d||e[9]!==r.id||e[10]!==h.href?(m=n.jsx(Tu,{url:h.href,serverName:d,agentId:r.id}),_=n.jsx(Ru,{url:h.href,serverName:d,agentId:r.id}),e[8]=d,e[9]=r.id,e[10]=h.href,e[11]=m,e[12]=_):(m=e[11],_=e[12]);let p;e[13]!==f||e[14]!==m||e[15]!==_?(p=n.jsx("div",{className:"flex flex-col gap-3 pt-2",children:n.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[f,m,_]})}),e[13]=f,e[14]=m,e[15]=_,e[16]=p):p=e[16];let g;e[17]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("div",{className:"border-t border-border"}),e[17]=g):g=e[17];let v;e[18]!==r?(v=n.jsx(Iu,{virtualMcp:r}),e[18]=r,e[19]=v):v=e[19];let x;e[20]!==p||e[21]!==v?(x=n.jsxs("div",{className:"flex flex-col gap-6",children:[p,g,v]}),e[20]=p,e[21]=v,e[22]=x):x=e[22];const b=x;if(u){let E;e[23]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx(Yh,{className:"mt-4 mb-4 text-base font-semibold",children:"Connect"}),e[23]=E):E=e[23];let P;e[24]!==b?(P=n.jsx(Xh,{children:n.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-6 [touch-action:pan-y]",children:[E,b]})}),e[24]=b,e[25]=P):P=e[25];let R;return e[26]!==i||e[27]!==s||e[28]!==P?(R=n.jsx(Jh,{open:s,onOpenChange:i,children:P}),e[26]=i,e[27]=s,e[28]=P,e[29]=R):R=e[29],R}let S;e[30]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(wn,{children:n.jsx(Cn,{children:"Connect"})}),e[30]=S):S=e[30];let w;e[31]!==b?(w=n.jsxs(Fi,{className:"max-h-[80vh] overflow-y-auto sm:max-w-2xl",children:[S,b]}),e[31]=b,e[32]=w):w=e[32];let k;return e[33]!==i||e[34]!==s||e[35]!==w?(k=n.jsx(Hi,{open:s,onOpenChange:i,children:w}),e[33]=i,e[34]=s,e[35]=w,e[36]=k):k=e[36],k}const Au=/^[A-Za-z_][A-Za-z0-9_]*$/;function Bu(t){const e={},s=t.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=(s[i]??"").trim();if(!r||r.startsWith("#"))continue;r.startsWith("export ")&&(r=r.slice(7).trim());const o=r.indexOf("=");if(o<0)throw new Error(`Line ${i+1}: missing '='`);const a=r.slice(0,o).trim();if(!Au.test(a))throw new Error(`Line ${i+1}: invalid key "${a}"`);let l=r.slice(o+1).trim();l.length>=2&&(l.startsWith('"')&&l.endsWith('"')||l.startsWith("'")&&l.endsWith("'"))&&(l=l.slice(1,-1)),e[a]=l}return e}const Lu=/^[A-Za-z_][A-Za-z0-9_]*$/,Ou=/^[A-Za-z0-9_.-]+$/;function $u(t){const e=z.c(14),{control:s,form:i,virtualMcpId:r,orgSlug:o}=t;let a,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("div",{className:"flex items-baseline justify-between gap-2",children:n.jsx(Je,{className:"font-normal text-foreground",children:"Environment variables"})}),l=n.jsx("p",{className:"text-xs text-muted-foreground",children:"Injected into the sandbox on every start. Reference an org/user secret to keep values out of metadata; literals are stored inline."}),e[0]=a,e[1]=l):(a=e[0],l=e[1]);let h;e[2]!==s||e[3]!==i||e[4]!==o||e[5]!==r?(h=n.jsx(Fu,{control:s,form:i,virtualMcpId:r,orgSlug:o}),e[2]=s,e[3]=i,e[4]=o,e[5]=r,e[6]=h):h=e[6];let c;e[7]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Zh,{className:"h-9 w-full"}),e[7]=c):c=e[7];let d;e[8]!==s||e[9]!==i?(d=n.jsx(Rt,{fallback:zu,children:n.jsx(A.Suspense,{fallback:c,children:n.jsx(Wu,{control:s,form:i})})}),e[8]=s,e[9]=i,e[10]=d):d=e[10];let u;return e[11]!==h||e[12]!==d?(u=n.jsxs("div",{className:"space-y-2",children:[a,l,h,d]}),e[11]=h,e[12]=d,e[13]=u):u=e[13],u}function zu(t){const{error:e}=t;return n.jsx("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-xs text-destructive",children:e?.message??"Failed to load secrets"})}function Fu(t){const e=z.c(22),{control:s,form:i,virtualMcpId:r,orgSlug:o}=t,l=Oi.useSession().data?.user?.id,h="metadata.runtime.env",c="metadata.vmMap";let d;e[0]!==i?(d=()=>JSON.stringify(i.getValues(h)??[]),e[0]=i,e[1]=d):d=e[1];const[u,f]=A.useState(d);let m;e[2]!==s?(m={control:s,name:h},e[2]=s,e[3]=m):m=e[3];const _=_a(m),p=JSON.stringify(_??[])!==u;let g;e[4]!==i?(g=i.getValues(c),e[4]=i,e[5]=g):g=e[5];const v=g;let x;e[6]!==l||e[7]!==v?(x=l?Object.keys(v?.[l]??{}):[],e[6]=l,e[7]=v,e[8]=x):x=e[8];const b=x,S=b.length>0,[w,k]=A.useState(!1);if(!p||!S)return null;let E;e[9]!==i||e[10]!==o||e[11]!==b||e[12]!==r?(E=async()=>{k(!0);const y=await Promise.allSettled(b.map(async C=>{const j=`/api/${encodeURIComponent(o)}/vm/${encodeURIComponent(r)}/${encodeURIComponent(C)}/setup/start`,M=await fetch(j,{method:"POST"});if(!M.ok){const D=await M.text().catch(()=>M.statusText);throw new Error(D||M.statusText)}}));k(!1);const N=y.filter(Hu).length;N===0?(f(JSON.stringify(i.getValues(h)??[])),he.success(b.length===1?"Restarted dev with new env":`Restarted ${b.length} branches with new env`)):he.error(`Failed to restart ${N} of ${b.length} branch(es)`)},e[9]=i,e[10]=o,e[11]=b,e[12]=r,e[13]=E):E=e[13];const P=E;let R;e[14]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-amber-900 dark:text-amber-200",children:[n.jsx(ji,{className:"size-3.5 shrink-0"}),n.jsx("span",{className:"truncate",children:"Your sandbox is running. Restart the dev script to apply the new env."})]}),e[14]=R):R=e[14];let B;e[15]!==w?(B=w?n.jsx(Be,{className:"size-3.5 animate-spin"}):n.jsx(Hs,{className:"size-3.5"}),e[15]=w,e[16]=B):B=e[16];const I=w?"Restarting…":"Restart dev";let T;return e[17]!==P||e[18]!==w||e[19]!==B||e[20]!==I?(T=n.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs dark:border-amber-900/40 dark:bg-amber-950/30",children:[R,n.jsxs(se,{type:"button",variant:"outline",size:"sm",onClick:P,disabled:w,className:"shrink-0",children:[B,I]})]}),e[17]=P,e[18]=w,e[19]=B,e[20]=I,e[21]=T):T=e[21],T}function Hu(t){return t.status==="rejected"}function Wu(t){const e=z.c(48),{control:s,form:i}=t,r="metadata.runtime.env";let o;e[0]!==s?(o={control:s,name:r},e[0]=s,e[1]=o):o=e[1];const a=xc(o),{fields:l,append:h,remove:c}=a;let d;e[2]!==i?(d=(C,j)=>{i.setValue(`${r}.${C}`,j,{shouldDirty:!0,shouldTouch:!0})},e[2]=i,e[3]=d):d=e[3];const u=d,f=sd();let m;if(e[4]!==f){m=new Map;for(const C of f)m.set(C.id,C);e[4]=f,e[5]=m}else m=e[5];const[_,p]=A.useState(null);let g;e[6]!==h?(g=()=>{h({key:"",kind:"literal",value:""})},e[6]=h,e[7]=g):g=e[7];const v=g;let x;e[8]!==h||e[9]!==i?(x=async()=>{let C;try{C=await navigator.clipboard.readText()}catch{he.error("Couldn't read clipboard");return}if(!C.trim()){he.error("Clipboard is empty");return}let j;try{j=Bu(C)}catch($){const W=$;he.error(W.message);return}const M=Object.entries(j);if(M.length===0){he.error("Nothing to add");return}const D=i.getValues(r)??[],F=new Set;for(const $ of D){const W=($.key??"").trim();W&&F.add(W)}let H=0,O=0;for(const[$,W]of M){if(F.has($)){O++;continue}h({key:$,kind:"literal",value:W}),F.add($),H++}H===0&&O>0?he.message(`All ${O} key${O===1?"":"s"} already exist`):he.success(O>0?`Added ${H} var${H===1?"":"s"} (${O} already existed)`:`Added ${H} var${H===1?"":"s"}`)},e[8]=h,e[9]=i,e[10]=x):x=e[10];const b=x;let S;if(e[11]!==s||e[12]!==l||e[13]!==i||e[14]!==c||e[15]!==m||e[16]!==f||e[17]!==u){let C;e[19]!==s||e[20]!==i||e[21]!==c||e[22]!==m||e[23]!==f||e[24]!==u?(C=(j,M)=>n.jsx("li",{className:"rounded-md border border-border bg-background",children:n.jsx(Uu,{index:M,control:s,form:i,onUpdateEntry:u,fieldPath:r,secrets:f,secretById:m,onSaveAsSecret:(D,F)=>p({kind:"save-literal",index:M,presetKey:D,presetValue:F}),onCreateNewSecret:D=>p({kind:"create-new",index:M,presetKey:D}),onRemove:()=>c(M)})},j.id),e[19]=s,e[20]=i,e[21]=c,e[22]=m,e[23]=f,e[24]=u,e[25]=C):C=e[25],S=l.map(C),e[11]=s,e[12]=l,e[13]=i,e[14]=c,e[15]=m,e[16]=f,e[17]=u,e[18]=S}else S=e[18];let w;e[26]!==S?(w=n.jsx("ul",{className:"space-y-2",children:S}),e[26]=S,e[27]=w):w=e[27];let k;e[28]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(es,{className:"size-3.5"}),e[28]=k):k=e[28];let E;e[29]!==v?(E=n.jsxs(se,{type:"button",variant:"outline",size:"sm",onClick:v,className:"flex-1",children:[k,"Add env var"]}),e[29]=v,e[30]=E):E=e[30];let P;e[31]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsx(nh,{className:"size-3.5"}),e[31]=P):P=e[31];let R;e[32]!==b?(R=n.jsx(ke,{asChild:!0,children:n.jsxs(se,{type:"button",variant:"outline",size:"sm",onClick:b,"aria-label":"Paste .env",children:[P,"Paste .env"]})}),e[32]=b,e[33]=R):R=e[33];let B;e[34]===Symbol.for("react.memo_cache_sentinel")?(B=n.jsx(Ne,{children:"Read a .env blob from the clipboard. Each pair is staged as a literal — save individual rows as secrets after."}),e[34]=B):B=e[34];let I;e[35]!==R?(I=n.jsxs(je,{children:[R,B]}),e[35]=R,e[36]=I):I=e[36];let T;e[37]!==I||e[38]!==E?(T=n.jsxs("div",{className:"flex items-center gap-2",children:[E,I]}),e[37]=I,e[38]=E,e[39]=T):T=e[39];let y;e[40]!==_||e[41]!==i||e[42]!==u?(y=_!==null?n.jsx(qu,{mode:_,onClose:()=>p(null),onSaved:C=>{const j=i.getValues(`${r}.${_.index}.key`)?.trim()??"";u(_.index,{key:j,kind:"secret",secretId:C}),p(null)}}):null,e[40]=_,e[41]=i,e[42]=u,e[43]=y):y=e[43];let N;return e[44]!==T||e[45]!==y||e[46]!==w?(N=n.jsxs("div",{className:"space-y-2",children:[w,T,y]}),e[44]=T,e[45]=y,e[46]=w,e[47]=N):N=e[47],N}function Uu(t){const e=z.c(55),{index:s,control:i,form:r,onUpdateEntry:o,fieldPath:a,secrets:l,secretById:h,onSaveAsSecret:c,onCreateNewSecret:d,onRemove:u}=t,f=`${a}.${s}.key`,m=`${a}.${s}.value`,_=`${a}.${s}.secretId`,p=`${a}.${s}.kind`;let g;e[0]!==i||e[1]!==p?(g={control:i,name:p},e[0]=i,e[1]=p,e[2]=g):g=e[2];const x=_a(g)==="secret"?"secret":"literal";let b;e[3]!==r||e[4]!==s||e[5]!==f||e[6]!==c||e[7]!==o||e[8]!==m?(b=H=>{const O=r.getValues(f)?.trim()??"";if(H==="literal"){o(s,{key:O,kind:"literal",value:""});return}const $=r.getValues(m)??"";if($.length>0){c(O,$);return}o(s,{key:O,kind:"secret",secretId:""})},e[3]=r,e[4]=s,e[5]=f,e[6]=c,e[7]=o,e[8]=m,e[9]=b):b=e[9];const S=b;let w;e[10]!==s?(w=H=>{const{field:O}=H;return n.jsx(ot,{...O,value:O.value??"",placeholder:"KEY",spellCheck:!1,autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",className:"font-mono","aria-label":`Env var ${s+1} key`,onBlur:$=>{const W=$.target.value.trim();O.onChange(W),O.onBlur()}})},e[10]=s,e[11]=w):w=e[11];let k;e[12]!==i||e[13]!==f||e[14]!==w?(k=n.jsx("div",{className:"flex-1 min-w-0",children:n.jsx(nt,{control:i,name:f,render:w})}),e[12]=i,e[13]=f,e[14]=w,e[15]=k):k=e[15];let E;e[16]!==S?(E=H=>S(H),e[16]=S,e[17]=E):E=e[17];let P;e[18]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsx(_t,{className:"h-9 w-[110px]",children:n.jsx(pt,{})}),e[18]=P):P=e[18];let R;e[19]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx(Ye,{value:"literal",children:n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx(Ya,{className:"size-3.5"}),"Literal"]})}),e[19]=R):R=e[19];let B;e[20]===Symbol.for("react.memo_cache_sentinel")?(B=n.jsxs(gt,{children:[R,n.jsx(Ye,{value:"secret",children:n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx(Qh,{className:"size-3.5"}),"Secret"]})})]}),e[20]=B):B=e[20];let I;e[21]!==x||e[22]!==E?(I=n.jsx("div",{className:"shrink-0",children:n.jsxs(mt,{value:x,onValueChange:E,children:[P,B]})}),e[21]=x,e[22]=E,e[23]=I):I=e[23];let T;e[24]!==i||e[25]!==r||e[26]!==s||e[27]!==f||e[28]!==x||e[29]!==d||e[30]!==h||e[31]!==_||e[32]!==l||e[33]!==m?(T=n.jsx("div",{className:"flex flex-[2] min-w-0 items-center gap-1",children:x==="literal"?n.jsx(nt,{control:i,name:m,render:H=>{const{field:O}=H;return n.jsx(ot,{...O,value:O.value??"",type:"password",placeholder:"value",spellCheck:!1,autoComplete:"off",className:"font-mono","aria-label":`Env var ${s+1} value`,onBlur:$=>{O.onChange($.target.value),O.onBlur()}})}}):n.jsxs(n.Fragment,{children:[n.jsx(nt,{control:i,name:_,render:H=>{const{field:O}=H;return n.jsxs(mt,{value:O.value||"",onValueChange:$=>O.onChange($),children:[n.jsx(_t,{className:te("h-9 w-full",!O.value&&"text-muted-foreground"),children:n.jsx(pt,{placeholder:"Pick a secret…",children:n.jsx(Ku,{field:O,secretById:h})})}),n.jsx(gt,{children:l.length===0?n.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:"No secrets yet. Use the “+” to create one."}):l.map(Vu)})]})}}),n.jsxs(je,{children:[n.jsx(ke,{asChild:!0,children:n.jsx(se,{type:"button",variant:"ghost",size:"icon","aria-label":"Create new secret",onClick:()=>{const H=r.getValues(f)?.trim()??"";d(H)},children:n.jsx(es,{className:"size-3.5"})})}),n.jsx(Ne,{children:"Create new secret"})]})]})}),e[24]=i,e[25]=r,e[26]=s,e[27]=f,e[28]=x,e[29]=d,e[30]=h,e[31]=_,e[32]=l,e[33]=m,e[34]=T):T=e[34];let y;e[35]!==r||e[36]!==f||e[37]!==x||e[38]!==c||e[39]!==m?(y=x==="literal"?n.jsxs(je,{children:[n.jsx(ke,{asChild:!0,children:n.jsx(se,{type:"button",variant:"ghost",size:"icon","aria-label":"Save value as secret",onClick:()=>{const H=r.getValues(f)?.trim()??"",O=r.getValues(m)??"";c(H,O)},children:n.jsx(oh,{className:"size-3.5"})})}),n.jsx(Ne,{children:"Save value as secret"})]}):null,e[35]=r,e[36]=f,e[37]=x,e[38]=c,e[39]=m,e[40]=y):y=e[40];let N;e[41]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx(Di,{className:"size-3.5"}),e[41]=N):N=e[41];let C;e[42]!==u?(C=n.jsx(ke,{asChild:!0,children:n.jsx(se,{type:"button",variant:"ghost",size:"icon","aria-label":"Remove env var",onClick:u,children:N})}),e[42]=u,e[43]=C):C=e[43];let j;e[44]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx(Ne,{children:"Remove"}),e[44]=j):j=e[44];let M;e[45]!==C?(M=n.jsxs(je,{children:[C,j]}),e[45]=C,e[46]=M):M=e[46];let D;e[47]!==y||e[48]!==M?(D=n.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[y,M]}),e[47]=y,e[48]=M,e[49]=D):D=e[49];let F;return e[50]!==T||e[51]!==D||e[52]!==k||e[53]!==I?(F=n.jsxs("div",{className:"flex flex-col gap-2 p-2 sm:flex-row sm:items-center",children:[k,I,T,D]}),e[50]=T,e[51]=D,e[52]=k,e[53]=I,e[54]=F):F=e[54],F}function Vu(t){return n.jsx(Ye,{value:t.id,children:n.jsxs("span",{className:"inline-flex items-center gap-2",children:[n.jsx(sl,{scope:t.scope}),n.jsx("span",{className:"font-mono",children:t.name})]})},t.id)}function Ku(t){const e=z.c(12),{field:s,secretById:i}=t,r=s.value||"";if(!r)return null;let o;e[0]!==r||e[1]!==i?(o=i.get(r),e[0]=r,e[1]=i,e[2]=o):o=e[2];const a=o;if(!a){let d;return e[3]!==r?(d=n.jsxs("span",{className:"text-destructive",children:["Missing secret (",r,")"]}),e[3]=r,e[4]=d):d=e[4],d}let l;e[5]!==a.scope?(l=n.jsx(sl,{scope:a.scope}),e[5]=a.scope,e[6]=l):l=e[6];let h;e[7]!==a.name?(h=n.jsx("span",{className:"truncate font-mono",children:a.name}),e[7]=a.name,e[8]=h):h=e[8];let c;return e[9]!==l||e[10]!==h?(c=n.jsxs("span",{className:"inline-flex items-center gap-1.5 truncate",children:[l,h]}),e[9]=l,e[10]=h,e[11]=c):c=e[11],c}function sl(t){const e=z.c(2),{scope:s}=t,i=s==="user"?ed:td;let r;return e[0]!==i?(r=n.jsx(i,{className:"size-3 text-muted-foreground"}),e[0]=i,e[1]=r):r=e[1],r}function qu({mode:t,onClose:e,onSaved:s}){const i=t.kind==="save-literal"?t.presetValue:"",r=t.presetKey,[o,a]=A.useState(()=>Gu(r)),[l,h]=A.useState("organization"),[c,d]=A.useState(i),[u,f]=A.useState(""),m=id(),_=o.trim(),p=c.length>0&&_.length>0&&Ou.test(_),g=async b=>{if(b.preventDefault(),!!p)try{const S=await m.mutateAsync({scope:l,name:_,value:c,description:u.trim()||void 0});he.success(`Saved secret "${S.name}"`),s(S.id)}catch(S){he.error(S instanceof Error?S.message:"Failed to save")}},v=t.kind==="save-literal"?"Save value as secret":"Create new secret",x=t.kind==="save-literal"?"Move this value into the encrypted vault. The env var will then reference the secret by id — its value never leaves the server.":"Stored encrypted in the credential vault. The env var will reference the new secret by id.";return n.jsx(Hi,{open:!0,onOpenChange:b=>{b||e()},children:n.jsxs(Fi,{className:"sm:max-w-md",children:[n.jsxs(wn,{children:[n.jsx(Cn,{children:v}),n.jsx(Oh,{children:x})]}),n.jsxs("form",{onSubmit:g,className:"space-y-4",children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Je,{htmlFor:"save-secret-scope",children:"Scope"}),n.jsxs(mt,{value:l,onValueChange:b=>h(b),children:[n.jsx(_t,{id:"save-secret-scope",children:n.jsx(pt,{})}),n.jsxs(gt,{children:[n.jsx(Ye,{value:"organization",children:"Organization — visible to all members"}),n.jsx(Ye,{value:"user",children:"Private — only visible to me"})]})]})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Je,{htmlFor:"save-secret-name",children:"Name"}),n.jsx(ot,{id:"save-secret-name",value:o,onChange:b=>a(b.target.value),placeholder:"STRIPE_API_KEY",autoComplete:"off",required:!0}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Letters, digits, underscore, dot, hyphen. Independent of the env var key."})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Je,{htmlFor:"save-secret-value",children:"Value"}),n.jsx(ot,{id:"save-secret-value",type:"password",value:c,onChange:b=>d(b.target.value),placeholder:"secret value",autoComplete:"new-password",required:!0})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Je,{htmlFor:"save-secret-description",children:"Description (optional)"}),n.jsx(Ws,{id:"save-secret-description",value:u,onChange:b=>f(b.target.value),rows:2,placeholder:"What is this secret used for?"})]}),n.jsxs(Va,{children:[n.jsx(se,{type:"button",variant:"outline",onClick:e,disabled:m.isPending,children:"Cancel"}),n.jsx(se,{type:"submit",disabled:!p||m.isPending,children:m.isPending?"Saving…":"Save secret"})]})]})]})})}function Gu(t){const e=t.trim();return e&&Lu.test(e)?e:""}function Yu(t){const e=z.c(12),{repo:s,className:i}=t;let r;e[0]!==i?(r=te("space-y-2",i),e[0]=i,e[1]=r):r=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(Je,{children:"Repository"}),e[2]=o):o=e[2];let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(Mh,{size:20,className:"shrink-0 text-foreground/60"}),e[3]=a):a=e[3];let l;e[4]!==s?(l=n.jsx(ke,{asChild:!0,children:n.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border bg-background px-4 py-3",tabIndex:0,children:[a,n.jsx("div",{className:"min-w-0 flex-1",children:s?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"truncate text-sm font-medium",children:[s.owner,"/",s.name]}),n.jsx("div",{className:"truncate text-xs text-muted-foreground",children:s.url})]}):n.jsx("div",{className:"text-sm text-muted-foreground",children:"No repository connected"})})]})}),e[4]=s,e[5]=l):l=e[5];let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Ne,{children:"The connected GitHub repository for this agent. Manage in Connections."}),e[6]=h):h=e[6];let c;e[7]!==l?(c=n.jsxs(je,{children:[l,h]}),e[7]=l,e[8]=c):c=e[8];let d;return e[9]!==r||e[10]!==c?(d=n.jsxs("div",{className:r,children:[o,c]}),e[9]=r,e[10]=c,e[11]=d):d=e[11],d}const Xu={npm:{install:"npm install",run:t=>`npm run ${t}`,runtime:"node"},pnpm:{install:"pnpm install",run:t=>`pnpm run ${t}`,runtime:"node"},yarn:{install:"yarn install",run:t=>`yarn run ${t}`,runtime:"node"},bun:{install:"bun install",run:t=>`bun run ${t}`,runtime:"bun"},deno:{install:"deno install",run:t=>`deno task ${t}`,runtime:"deno"}};function Ju(t){const e=t.trim();if(e==="")return{ok:!0,value:null};if(!/^\d+$/.test(e))return{ok:!1};const s=Number(e);return s<1||s>65535?{ok:!1}:{ok:!0,value:String(s)}}const Zu=Object.keys(Xu),rr="__none__";function Qu(t){const e=z.c(20),{control:s}=t,i=A.useRef(null);let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(Je,{htmlFor:"runtime-pm",children:"Package manager"}),e[0]=r):r=e[0];let o;e[1]!==s?(o=n.jsxs("div",{className:"space-y-2",children:[r,n.jsx(nt,{control:s,name:"metadata.runtime.selected",render:tf})]}),e[1]=s,e[2]=o):o=e[2];let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(Je,{htmlFor:"runtime-path",children:"Package path"}),e[3]=a):a=e[3];let l;e[4]!==s?(l=n.jsx(nt,{control:s,name:"metadata.runtime.path",render:ef}),e[4]=s,e[5]=l):l=e[5];let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx("p",{className:"text-xs text-muted-foreground",children:"Path (relative to repo root) to the directory containing package.json. Leave blank for the repo root."}),e[6]=h):h=e[6];let c;e[7]!==l?(c=n.jsxs("div",{className:"space-y-2",children:[a,l,h]}),e[7]=l,e[8]=c):c=e[8];let d;e[9]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Je,{htmlFor:"runtime-port",children:"Dev server port"}),e[9]=d):d=e[9];let u;e[10]===Symbol.for("react.memo_cache_sentinel")?(u=g=>{const{field:v}=g;return n.jsx(ot,{ref:i,id:"runtime-port",inputMode:"numeric",placeholder:"Auto",defaultValue:v.value??"",onBlur:x=>{const b=Ju(x.target.value);b.ok?v.onChange(b.value):i.current&&(i.current.value=v.value??"")}})},e[10]=u):u=e[10];let f;e[11]!==s?(f=n.jsx(nt,{control:s,name:"metadata.runtime.port",render:u}),e[11]=s,e[12]=f):f=e[12];let m;e[13]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx("p",{className:"text-xs text-muted-foreground",children:"Leave blank to let the runner pick."}),e[13]=m):m=e[13];let _;e[14]!==f?(_=n.jsxs("div",{className:"space-y-2",children:[d,f,m]}),e[14]=f,e[15]=_):_=e[15];let p;return e[16]!==_||e[17]!==o||e[18]!==c?(p=n.jsxs("div",{className:"space-y-5",children:[o,c,_]}),e[16]=_,e[17]=o,e[18]=c,e[19]=p):p=e[19],p}function ef(t){const{field:e}=t;return n.jsx(ot,{id:"runtime-path",placeholder:".",defaultValue:e.value??"",onBlur:s=>{const i=s.target.value.trim();e.onChange(i===""?null:i)}})}function tf(t){const{field:e}=t;return n.jsxs(mt,{value:e.value??rr,onValueChange:s=>e.onChange(s===rr?null:s),children:[n.jsx(_t,{id:"runtime-pm",children:n.jsx(pt,{placeholder:"Auto-detect"})}),n.jsxs(gt,{children:[n.jsx(Ye,{value:rr,children:"Auto-detect"}),Zu.map(sf)]})]})}function sf(t){return n.jsx(Ye,{value:t,children:t},t)}function rf(t,e){switch(e.type){case"SET_SHARE_DIALOG_OPEN":return{...t,shareDialogOpen:e.payload};case"SET_ADD_DIALOG_OPEN":return{...t,addDialogOpen:e.payload};case"OPEN_SETTINGS":return{...t,settingsDialogOpen:!0,settingsConnectionId:e.payload};case"CLOSE_SETTINGS":return{...t,settingsDialogOpen:!1,settingsConnectionId:null};default:return t}}function nf(t,e){switch(e.type){case"accumulate":{const s=t??{start:e.now,fields:new Set,saveCount:0,instructionsLength:null},i=new Set(s.fields);for(const r of e.fields)i.add(r);return{...s,fields:i,saveCount:s.saveCount+1,instructionsLength:e.instructionsLength??s.instructionsLength}}case"reset":return null}}function of(t){const e=t.metadata?.runtime?.env;if(!e||e.length===0)return t;const s=e.filter(i=>!i||typeof i!="object"||!(i.key??"").trim()?!1:i.kind==="literal"?!0:i.kind==="secret"?!!i.secretId:!1);return s.length===e.length?t:{...t,metadata:{...t.metadata,runtime:{...t.metadata?.runtime??{},env:s}}}}function af(t){const e=z.c(22),{connection_id:s,usedConnectionIds:i,onOpenSettings:r,onRemove:o,onAuthenticate:a,onSwitchInstance:l,onNewInstance:h}=t,c=yn(s),{org:d}=ge();if(!c)return null;let u;e[0]!==c?(u=Lh(c),e[0]=c,e[1]=u):u=e[1];const f=u;let m;e[2]!==s?(m=n.jsx(df,{connection_id:s}),e[2]=s,e[3]=m):m=e[3];let _;e[4]!==c.app_name||e[5]!==c.connection_type||e[6]!==c.description||e[7]!==c.icon||e[8]!==c.title||e[9]!==s||e[10]!==a||e[11]!==h||e[12]!==r||e[13]!==o||e[14]!==l||e[15]!==d.slug||e[16]!==f||e[17]!==i?(_=n.jsx(hf,{connection_id:s,connectionTitle:c.title,connectionDescription:c.description,connectionIcon:c.icon,connectionType:c.connection_type,slug:f,orgSlug:d.slug,appName:c.app_name,usedConnectionIds:i,onOpenSettings:r,onRemove:o,onAuthenticate:a,onSwitchInstance:l,onNewInstance:h}),e[4]=c.app_name,e[5]=c.connection_type,e[6]=c.description,e[7]=c.icon,e[8]=c.title,e[9]=s,e[10]=a,e[11]=h,e[12]=r,e[13]=o,e[14]=l,e[15]=d.slug,e[16]=f,e[17]=i,e[18]=_):_=e[18];let p;return e[19]!==m||e[20]!==_?(p=n.jsx(A.Suspense,{fallback:m,children:_}),e[19]=m,e[20]=_,e[21]=p):p=e[21],p}const oo="__new_instance__";async function lf(t,e){const s=t?.idToken??null;if(s){const r=ao(s);if(r)return r}const i=t?.userinfoEndpoint??null;if(i)try{const r=await fetch(i,{headers:{Authorization:`Bearer ${e}`}});if(r.ok){const o=await r.json(),a=typeof o.email=="string"?o.email:typeof o.upn=="string"?o.upn:typeof o.preferred_username=="string"?o.preferred_username:null;if(a)return a}}catch{}return ao(e)}function ao(t){try{const e=t.split(".");if(e.length===3&&e[1]){const s=JSON.parse(atob(e[1].replace(/-/g,"+").replace(/_/g,"/")));if(typeof s.email=="string")return s.email;if(typeof s.upn=="string")return s.upn;if(typeof s.preferred_username=="string")return s.preferred_username}}catch{}return null}function cf(t){const e=z.c(23),{appName:s,connectionId:i,usedConnectionIds:r,onSwitchInstance:o,onNewInstance:a}=t;let l;e[0]!==s?(l={filters:[{column:"app_name",value:s}]},e[0]=s,e[1]=l):l=e[1];const h=Ys(l);if(h.length<=1)return null;let c;e[2]!==i||e[3]!==a||e[4]!==o?(c=p=>{p===oo?a?.():o(i,p)},e[2]=i,e[3]=a,e[4]=o,e[5]=c):c=e[5];let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(_t,{size:"sm",className:"w-auto text-xs gap-1 px-2 shadow-none",children:n.jsx(pt,{})}),e[6]=d):d=e[6];let u;if(e[7]!==i||e[8]!==h||e[9]!==r){let p;e[11]!==i||e[12]!==r?(p=g=>n.jsx(Ye,{value:g.id,className:"text-xs",disabled:g.id!==i&&r.has(g.id),children:g.title},g.id),e[11]=i,e[12]=r,e[13]=p):p=e[13],u=h.map(p),e[7]=i,e[8]=h,e[9]=r,e[10]=u}else u=e[10];let f;e[14]!==a?(f=a&&n.jsx(Ye,{value:oo,className:"text-xs text-muted-foreground",children:"+ New instance"}),e[14]=a,e[15]=f):f=e[15];let m;e[16]!==u||e[17]!==f?(m=n.jsxs(gt,{children:[u,f]}),e[16]=u,e[17]=f,e[18]=m):m=e[18];let _;return e[19]!==i||e[20]!==c||e[21]!==m?(_=n.jsxs(mt,{value:i,onValueChange:c,children:[d,m]}),e[19]=i,e[20]=c,e[21]=m,e[22]=_):_=e[22],_}function hf(t){const e=z.c(55),{connection_id:s,connectionTitle:i,connectionDescription:r,connectionIcon:o,connectionType:a,slug:l,orgSlug:h,appName:c,usedConnectionIds:d,onOpenSettings:u,onRemove:f,onAuthenticate:m,onSwitchInstance:_,onNewInstance:p}=t;let g;e[0]!==s?(g={connectionId:s},e[0]=s,e[1]=g):g=e[1];const v=Aa(g),b=!(a==="VIRTUAL")&&v.supportsOAuth&&!v.isAuthenticated,S=b?"border-destructive/50 bg-destructive/5":"border-border";let w;e[2]!==S?(w=te("rounded-xl border overflow-hidden transition-colors",S),e[2]=S,e[3]=w):w=e[3];let k;e[4]!==h||e[5]!==l?(k={org:h,appSlug:l},e[4]=h,e[5]=l,e[6]=k):k=e[6];let E;e[7]!==o||e[8]!==i?(E=n.jsx(Ct,{icon:o,name:i,size:"sm",className:"shrink-0"}),e[7]=o,e[8]=i,e[9]=E):E=e[9];let P;e[10]!==i?(P=n.jsx("p",{className:"text-sm font-medium truncate",children:i}),e[10]=i,e[11]=P):P=e[11];let R;e[12]!==r||e[13]!==b?(R=b?n.jsx("span",{className:"text-xs text-destructive font-medium",children:"Needs authorization"}):r&&n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:r}),e[12]=r,e[13]=b,e[14]=R):R=e[14];let B;e[15]!==P||e[16]!==R?(B=n.jsxs("div",{className:"flex-1 min-w-0",children:[P,R]}),e[15]=P,e[16]=R,e[17]=B):B=e[17];let I;e[18]!==s||e[19]!==b||e[20]!==m?(I=b?n.jsx(se,{variant:"outline",size:"sm",className:"h-7 text-xs shrink-0",onClick:re=>{re.preventDefault(),re.stopPropagation(),m(s)},children:"Authorize"}):n.jsxs(je,{delayDuration:0,children:[n.jsx(ke,{asChild:!0,children:n.jsx("span",{className:"inline-flex items-center justify-center rounded-md h-7 w-7 hover:bg-accent text-muted-foreground shrink-0 transition-colors",children:n.jsx($h,{size:16})})}),n.jsx(Ne,{side:"bottom",children:"Connection settings"})]}),e[18]=s,e[19]=b,e[20]=m,e[21]=I):I=e[21];let T;e[22]!==k||e[23]!==E||e[24]!==B||e[25]!==I?(T=n.jsxs(yc,{to:"/$org/settings/connections/$appSlug",params:k,className:"flex items-center gap-3 px-4 py-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[E,B,I]}),e[22]=k,e[23]=E,e[24]=B,e[25]=I,e[26]=T):T=e[26];let y;e[27]!==c||e[28]!==s||e[29]!==p||e[30]!==_||e[31]!==d?(y=c&&n.jsx(cf,{appName:c,connectionId:s,usedConnectionIds:d,onSwitchInstance:_,onNewInstance:p}),e[27]=c,e[28]=s,e[29]=p,e[30]=_,e[31]=d,e[32]=y):y=e[32];let N;e[33]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx(lh,{size:13}),e[33]=N):N=e[33];let C;e[34]!==u?(C=n.jsx(ke,{asChild:!0,children:n.jsx(se,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:u,"aria-label":"Configure resources",children:N})}),e[34]=u,e[35]=C):C=e[35];let j;e[36]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx(Ne,{side:"bottom",children:"Configure resources"}),e[36]=j):j=e[36];let M;e[37]!==C?(M=n.jsxs(je,{delayDuration:0,children:[C,j]}),e[37]=C,e[38]=M):M=e[38];let D;e[39]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsx(fs,{size:13}),e[39]=D):D=e[39];let F;e[40]!==f?(F=n.jsx(ke,{asChild:!0,children:n.jsx(se,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:f,"aria-label":"Remove connection",children:D})}),e[40]=f,e[41]=F):F=e[41];let H;e[42]===Symbol.for("react.memo_cache_sentinel")?(H=n.jsx(Ne,{side:"bottom",children:"Remove"}),e[42]=H):H=e[42];let O;e[43]!==F?(O=n.jsxs(je,{delayDuration:0,children:[F,H]}),e[43]=F,e[44]=O):O=e[44];let $;e[45]!==M||e[46]!==O?($=n.jsxs("div",{className:"flex items-center gap-0.5 ml-auto",children:[M,O]}),e[45]=M,e[46]=O,e[47]=$):$=e[47];let W;e[48]!==y||e[49]!==$?(W=n.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 border-t border-border bg-muted/25",children:[y,$]}),e[48]=y,e[49]=$,e[50]=W):W=e[50];let K;return e[51]!==T||e[52]!==W||e[53]!==w?(K=n.jsxs("div",{className:w,children:[T,W]}),e[51]=T,e[52]=W,e[53]=w,e[54]=K):K=e[54],K}function df(t){const e=z.c(17),{connection_id:s}=t,i=yn(s);if(!i){let u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(il,{}),e[0]=u):u=e[0],u}let r;e[1]!==i.icon||e[2]!==i.title?(r=n.jsx(Ct,{icon:i.icon,name:i.title,size:"sm",className:"shrink-0"}),e[1]=i.icon,e[2]=i.title,e[3]=r):r=e[3];let o;e[4]!==i.title?(o=n.jsx("p",{className:"text-sm font-medium truncate",children:i.title}),e[4]=i.title,e[5]=o):o=e[5];let a;e[6]!==i.description?(a=i.description&&n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:i.description}),e[6]=i.description,e[7]=a):a=e[7];let l;e[8]!==o||e[9]!==a?(l=n.jsxs("div",{className:"flex-1 min-w-0",children:[o,a]}),e[8]=o,e[9]=a,e[10]=l):l=e[10];let h;e[11]!==r||e[12]!==l?(h=n.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[r,l]}),e[11]=r,e[12]=l,e[13]=h):h=e[13];let c;e[14]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:n.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})}),e[14]=c):c=e[14];let d;return e[15]!==h?(d=n.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[h,c]}),e[15]=h,e[16]=d):d=e[16],d}function il(){const t=z.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"size-8 rounded-md bg-muted animate-pulse shrink-0"}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e,n.jsxs("div",{className:"flex-1 space-y-1.5",children:[n.jsx("div",{className:"h-4 w-32 rounded bg-muted animate-pulse"}),n.jsx("div",{className:"h-3 w-48 rounded bg-muted animate-pulse"})]})]}),t[1]=s):s=t[1];let i;return t[2]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[s,n.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:n.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})})]}),t[2]=i):i=t[2],i}function uf({virtualMcpId:t,form:e,flushAndSave:s}){const{org:i}=ge(),r=Ue({connectionId:Ft,orgId:i.id,orgSlug:i.slug}),o=Pt(t),a=(o?.connections??[]).map(y=>y.connection_id).sort(),{data:l}=ga({queryKey:us.projectConnectionDetails(t,a),enabled:a.length>0,queryFn:async()=>await Promise.all(a.map(async N=>{try{const C=await r.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:N}}),{item:j}=Bh(C),M=(j?.tools??[]).filter(D=>!!Ih(D._meta)).map(D=>({name:D.name,description:D.description}));return{fetchOk:!0,id:N,title:j?.title??N,icon:j?.icon??null,uiTools:M}}catch{return{fetchOk:!1,id:N,title:N,icon:null,uiTools:[]}}}))}),h=(l??[]).filter(y=>y.uiTools.length>0),c=new Set(qc),d=e.watch("metadata.ui.pinnedViews")??[],u=e.watch("metadata.ui.layout")??null,f=u?.defaultMainView??null,m=u?.chatDefaultOpen??!1,_=!f||f.type==="chat"?"chat":f.type==="instructions"||f.type==="connections"||f.type==="layout"?"settings":c.has(f.type)?f.type:`${f.type}:${f.id??""}:${f.toolName??""}`,p=y=>{const[N,C,j]=y.split(":");return N?N==="chat"?{type:N}:c.has(N)?{type:N}:N==="ext-apps"&&C?{type:"ext-apps",id:C,toolName:j||void 0}:null:null},g=y=>{e.setValue("metadata.ui.pinnedViews",y,{shouldDirty:!0})},v=y=>{e.setValue("metadata.ui.layout",{...u,...y},{shouldDirty:!0})},x=A.useRef(!1);if(l&&l.length>0&&!x.current){x.current=!0;const y=new Set((l??[]).filter(j=>j.fetchOk).map(j=>j.id)),N=new Set(h.flatMap(j=>j.uiTools.map(M=>`${j.id}:${M.name}`))),C=d.filter(j=>!y.has(j.connectionId)||N.has(`${j.connectionId}:${j.toolName}`));C.length!==d.length&&(g(C),f?.type==="ext-apps"&&!C.some(j=>j.connectionId===f.id&&j.toolName===f.toolName)&&v({defaultMainView:{type:"chat"}}))}const b=(y,N)=>{if(d.some(j=>j.connectionId===y&&j.toolName===N)){const j=d.filter(D=>!(D.connectionId===y&&D.toolName===N));g(j);const M=`ext-apps:${y}:${N}`;_===M&&v({defaultMainView:{type:"chat"}})}else g([...d,{connectionId:y,toolName:N,label:Yn(N),icon:null}]);s()},S=(y,N,C)=>{g(d.map(j=>j.connectionId===y&&j.toolName===N?{...j,label:C}:j))},w=()=>{s()},k=(y,N,C)=>{g(d.map(j=>j.connectionId===y&&j.toolName===N?{...j,icon:C}:j)),s()},E=y=>{v({defaultMainView:p(y)}),s()},P=a.length===0,R=l&&h.length===0,B=!!Zt(o),I=[{value:"chat",label:"Chat"},{value:"settings",label:"Settings"},{value:"automations",label:"Automations"}];B&&I.push({value:"preview",label:"Preview"});for(const y of d)I.push({value:`ext-apps:${y.connectionId}:${y.toolName}`,label:y.label||y.toolName});const T=h.length>0||P||R;return n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("div",{className:"flex items-center justify-between gap-3",children:n.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Layout"})}),n.jsxs(Ka,{className:"p-6 gap-5",children:[n.jsxs(yr,{className:"p-0 space-y-5",children:[n.jsxs("div",{className:"flex items-center justify-between gap-4",children:[n.jsxs("div",{className:"space-y-0.5 min-w-0",children:[n.jsx(Je,{className:"font-normal text-foreground",children:"Main view"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"What users see when they first open this agent."})]}),n.jsxs(mt,{value:_,onValueChange:E,children:[n.jsx(_t,{className:"w-44 h-8 text-sm capitalize shrink-0",children:n.jsx(pt,{})}),n.jsx(gt,{children:I.map(y=>n.jsx(Ye,{value:y.value,className:"capitalize",children:y.label},y.value))})]})]}),n.jsxs("div",{className:"flex items-center justify-between gap-4",children:[n.jsxs("div",{className:"space-y-0.5 min-w-0",children:[n.jsx(Je,{className:"font-normal text-foreground",children:"Show chat"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Display the chat panel alongside the main view."})]}),n.jsxs(je,{delayDuration:0,children:[n.jsx(ke,{asChild:!0,children:n.jsx("span",{className:"shrink-0",children:n.jsx(wr,{checked:_==="chat"?!0:m,disabled:_==="chat",onCheckedChange:y=>{v({chatDefaultOpen:y}),s()}})})}),_==="chat"&&n.jsx(Ne,{side:"top",children:"Chat is always shown when it is the default view"})]})]})]}),T&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"border-t border-border -mx-6"}),n.jsxs(yr,{className:"p-0 space-y-3",children:[n.jsx("div",{className:"flex items-center justify-between gap-4",children:n.jsxs("div",{className:"space-y-0.5 min-w-0",children:[n.jsx(Je,{className:"font-normal text-foreground",children:"Pinned views"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Surface interactive tools as top-level tabs in the agent."})]})}),P&&n.jsx("p",{className:"text-xs text-muted-foreground",children:"Add a connection above to configure pinned views."}),R&&!P&&n.jsx("p",{className:"text-xs text-muted-foreground",children:"None of the connected servers expose interactive tools."}),h.length>0&&n.jsx("div",{className:"space-y-4 pt-1",children:h.map((y,N)=>n.jsxs("div",{children:[N>0&&n.jsx("div",{className:"border-t border-border -mx-6 mb-4"}),n.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[n.jsx(Ct,{icon:y.icon,name:y.title,size:"xs",className:"shrink-0"}),n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:y.title})]}),n.jsx("div",{className:"space-y-1.5",children:y.uiTools.map(C=>{const j=d.some(D=>D.connectionId===y.id&&D.toolName===C.name),M=d.find(D=>D.connectionId===y.id&&D.toolName===C.name);return n.jsxs("div",{className:te("flex items-center justify-between gap-3 px-3 py-2 rounded-lg border transition-colors",j?"bg-accent/40 border-border":"bg-transparent border-border"),children:[n.jsxs("div",{className:"min-w-0 flex-1 flex items-center gap-2",children:[n.jsx(du,{value:M?.icon??null,onChange:D=>k(y.id,C.name,D),disabled:!j}),n.jsx(ot,{value:j&&M?M.label:Yn(C.name),onChange:D=>S(y.id,C.name,D.target.value),onBlur:w,className:"h-7 text-sm w-40",disabled:!j,readOnly:!j})]}),n.jsx(wr,{checked:j,onCheckedChange:()=>b(y.id,C.name)})]},C.name)})})]},y.id))})]})]})]})]})}function ff({virtualMcp:t,hideOwnTitle:e}){const{org:s}=ge(),i=Bc(),r=Rh(),o=_s(),a=Ue({connectionId:Ft,orgId:s.id,orgSlug:s.slug}),l=pa({resolver:bc(Nu),defaultValues:t}),h=l.watch("connections"),c=!!Zt(t),d=Zt(t),u=d?{owner:d.owner,name:d.name,url:d.url}:null,[f,m]=A.useReducer(rf,{shareDialogOpen:!1,addDialogOpen:!1,settingsDialogOpen:!1,settingsConnectionId:null}),[_,p]=A.useState(!1),[g,v]=A.useState(!1),{createNewTask:x,setChatOpen:b}=Sn(),{sendMessage:S}=rs(),w=Ia(),k=async()=>{if(g)return;const L=l.getValues("metadata.instructions");if(L?.trim()){v(!0);try{T(),be("agent_instructions_improve_clicked",{agent_id:t.id,instructions_length:L.length}),await w(["studio-agent-manager"]),b(!0),await S({tiptapDoc:tl({managerAgentId:Sa.AGENT_MANAGER(s.id),managerName:"Agent Manager",kind:"agent",id:t.id,instructions:L})})}finally{v(!1)}}},E=()=>{T(),be("agent_test_clicked",{agent_id:t.id}),x()},[P,R]=A.useReducer(nf,null),B=()=>{P!==null&&(be("agent_updated",{agent_id:t.id,fields:Array.from(P.fields),instructions_length:P.instructionsLength,save_count:P.saveCount,edit_duration_ms:Date.now()-P.start}),R({type:"reset"}))},{schedule:I,flush:T}=$s({delayMs:3e4,save:async()=>B()}),y=async()=>{const L=Object.keys(l.control._formState.dirtyFields);if(L.length===0)return;const q=L.includes("metadata"),Q=l.getValues();l.reset(Q,{keepValues:!0});const Y=of(Q);await i.update.mutateAsync({id:t.id,data:Y}),R({type:"accumulate",now:Date.now(),fields:L,instructionsLength:q?Q.metadata?.instructions?.length??0:null}),I()},{schedule:N,flush:C}=$s({save:y});A.useEffect(()=>{const L=l.watch(()=>N());return()=>L.unsubscribe()},[]);const j=()=>{be("connections_dialog_opened",{source:"agent_settings",mode:"add"}),m({type:"SET_ADD_DIALOG_OPEN",payload:!0})},M=async L=>{const q=l.getValues("connections");if(q.some(ee=>ee.connection_id===L))return;l.setValue("connections",[...q,{connection_id:L,selected_tools:ir.tools,selected_resources:ir.resources,selected_prompts:ir.prompts}],{shouldDirty:!0}),m({type:"SET_ADD_DIALOG_OPEN",payload:!1});const Q=new URL(`/api/${s.slug}/mcp/${L}`,window.location.origin),Y=await Wn({url:Q.href,token:null,orgId:s.id});Y.supportsOAuth&&!Y.isAuthenticated&&await $(L)},D=L=>{const Q=l.getValues("connections").filter(Y=>Y.connection_id!==L);l.setValue("connections",Q,{shouldDirty:!0})},F=(L,q)=>{const Q=l.getValues("connections");if(Q.some(Y=>Y.connection_id===q)){he.error("This instance is already added to the agent");return}l.setValue("connections",Q.map(Y=>Y.connection_id===L?{...Y,connection_id:q}:Y),{shouldDirty:!0})},H=async L=>{if(l.getValues("connections").find(Q=>Q.connection_id===L))try{const Q=await a.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:L}}),{item:Y}=Q.structuredContent??{};if(!Y)return;const ee=Y.title.replace(/\s*\(.*?\)\s*$/,""),ae=Dh("conn"),_e=`${ee} (${Date.now().toString(36).slice(-4)})`;await r.create.mutateAsync({id:ae,title:_e,description:Y.description??null,connection_type:Y.connection_type,connection_url:Y.connection_url??null,connection_token:null,icon:Y.icon??null,app_name:Y.app_name??null,app_id:Y.app_id??null,connection_headers:Y.connection_headers??null});const ue=new URL(`/api/${s.slug}/mcp/${ae}`,window.location.origin),pe=await Wn({url:ue.href,token:null,orgId:s.id});if(pe.supportsOAuth&&!pe.isAuthenticated){const ve=await $(ae);if(!ve){await r.delete.mutateAsync(ae);return}await r.update.mutateAsync({id:ae,data:{title:`${ee} (${ve})`}})}F(L,ae),he.success("New instance created")}catch(Q){console.error("Failed to create instance:",Q),he.error("Failed to create instance")}},O=L=>{m({type:"OPEN_SETTINGS",payload:L})},$=async L=>{const{token:q,tokenInfo:Q,error:Y}=await Sc({connectionId:L,orgSlug:s.slug,scope:"offline_access"});if(Y||!q)return he.error(`Authentication failed: ${Y}`),null;if(Q)try{const ae=await fetch(`/api/${s.slug}/connections/${L}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:Q.accessToken,refreshToken:Q.refreshToken,expiresIn:Q.expiresIn,scope:Q.scope,clientId:Q.clientId,clientSecret:Q.clientSecret,tokenEndpoint:Q.tokenEndpoint})});if(!ae.ok)console.error("Failed to save OAuth token:",await ae.text()),await r.update.mutateAsync({id:L,data:{connection_token:q}});else try{await r.update.mutateAsync({id:L,data:{}})}catch(_e){console.warn("Failed to refresh connection tools after OAuth:",_e)}}catch(ae){console.error("Error saving OAuth token:",ae),await r.update.mutateAsync({id:L,data:{connection_token:q}})}else await r.update.mutateAsync({id:L,data:{connection_token:q}});const ee=new URL(`/api/${s.slug}/mcp/${L}`,window.location.origin);return await o.invalidateQueries({queryKey:us.isMCPAuthenticated(ee.href,null)}),he.success("Authentication successful"),lf(Q,q)},W=()=>{const L=l.getValues("metadata.instructions")??"",q=`<role>
|
|
5
5
|
Define who this agent is and what it specializes in.
|
|
6
6
|
Example: You are a support triage agent for B2B merchants.
|
|
7
7
|
</role>
|
|
@@ -28,7 +28,7 @@ Define step-by-step how the agent should handle requests.
|
|
|
28
28
|
4. Ask for confirmation before making any changes.
|
|
29
29
|
</workflows>`,Q=L.trim()?`${L}
|
|
30
30
|
|
|
31
|
-
${K}`:K;l.setValue("metadata.instructions",Q,{shouldDirty:!0})},V=new Set(h.map(L=>L.connection_id)),re=is(),[X,J]=A.useState(!1),Z=async()=>{R();try{await i.delete.mutateAsync(t.id),ve("agent_deleted",{agent_id:t.id,source:"agent_detail"}),he.success(`Deleted "${t.title}"`),re({to:"/$org",params:{org:s.slug}})}catch{}};return n.jsxs(dt,{children:[n.jsx(dt.Content,{children:n.jsx(dt.Body,{children:n.jsxs("div",{className:"flex flex-col gap-10",children:[!e&&n.jsx(dt.Title,{actions:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs(se,{variant:"outline",size:"sm",onClick:C,children:[n.jsx(Qt,{size:14,className:"!size-[14px]"}),"Test Agent"]}),n.jsx(se,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive",onClick:()=>J(!0),children:n.jsx(Ri,{size:14})})]}),children:"Settings"}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(rt,{name:"icon",control:l.control,render:({field:L})=>n.jsx(Gd,{value:L.value??null,onChange:K=>{L.onChange(K),N()},onColorChange:K=>{l.setValue("metadata.ui.themeColor",K,{shouldDirty:!0}),N()},name:l.watch("title")||"Agent",size:"md",className:"shrink-0",avatarClassName:"[&_svg]:w-1/2 [&_svg]:h-1/2",disabled:c})}),n.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[n.jsx(rt,{name:"title",control:l.control,render:({field:L})=>n.jsx("input",{...L,type:"text",value:L.value??"",onChange:K=>{L.onChange(K)},onBlur:()=>{L.onBlur(),N()},disabled:c,placeholder:"Agent name",className:"text-lg font-medium leading-tight text-foreground bg-transparent border-none outline-none px-1 -mx-1 rounded hover:bg-input/25 focus:bg-input/25 transition-colors w-full truncate disabled:hover:bg-transparent disabled:focus:bg-transparent disabled:opacity-50"})}),n.jsx(rt,{name:"description",control:l.control,render:({field:L})=>n.jsx("input",{...L,type:"text",value:L.value??"",onChange:K=>{L.onChange(K)},onBlur:()=>{L.onBlur(),N()},disabled:c,placeholder:"Add a description...",className:"text-sm text-muted-foreground bg-transparent border-none outline-none px-1 -mx-1 rounded hover:bg-input/25 focus:bg-input/25 transition-colors w-full truncate disabled:hover:bg-transparent disabled:focus:bg-transparent disabled:opacity-50"})})]}),n.jsxs(se,{variant:"outline",size:"sm",className:"shrink-0",onClick:()=>{ve("agent_connect_modal_opened",{agent_id:t.id}),m({type:"SET_SHARE_DIALOG_OPEN",payload:!0})},children:[n.jsxs("span",{className:"flex items-center -space-x-1.5 mr-0.5",children:[n.jsx("span",{className:"inline-flex items-center justify-center size-4 rounded-full bg-black ring-1 ring-white/20 shrink-0",children:n.jsx("img",{src:"/logos/cursor.svg",alt:"Cursor",className:"size-2.5 brightness-0 invert"})}),n.jsx("span",{className:"relative z-10 inline-flex items-center justify-center size-4 rounded-full ring-1 ring-background shrink-0",style:{backgroundColor:"#D97757"},children:n.jsx("img",{src:"/logos/Claude Code.svg",alt:"Claude",className:"size-2.5 brightness-0 invert"})})]}),"Connect"]})]}),n.jsxs("div",{className:"flex items-center gap-2 -mt-6 text-muted-foreground",children:[n.jsx(Ea,{id:t.created_by,size:"2xs",className:"text-sm text-muted-foreground"}),n.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),n.jsx("span",{className:"text-sm",children:new Date(t.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})})]}),n.jsxs("section",{className:"flex flex-col gap-3",children:[n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Connections"}),h.length>0&&n.jsxs(se,{variant:"outline",size:"sm",onClick:j,children:[n.jsx(es,{size:14}),"Add connection"]})]}),n.jsx("div",{className:"flex flex-col gap-2",children:h.length===0?n.jsxs("button",{type:"button",onClick:j,className:"flex items-center gap-3 px-3 py-2.5 rounded-lg border border-dashed border-border hover:bg-accent/50 transition-colors w-full text-left cursor-pointer",children:[n.jsx("div",{className:"flex items-center justify-center size-8 rounded-md text-muted-foreground/75 border border-dashed border-border shrink-0",children:n.jsx(es,{size:16})}),n.jsx("span",{className:"text-sm text-muted-foreground",children:"No connections yet. Add one to get started."})]}):h.map(L=>n.jsx(Rt,{fallback:()=>null,children:n.jsx(A.Suspense,{fallback:n.jsx(Ja,{}),children:n.jsx(Xu,{connection_id:L.connection_id,usedConnectionIds:V,onOpenSettings:()=>O(L.connection_id),onRemove:()=>P(L.connection_id),onAuthenticate:$,onSwitchInstance:F,onNewInstance:()=>W(L.connection_id)})})},L.connection_id))})]}),n.jsxs("section",{className:"flex flex-col gap-3",children:[n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Instructions"}),!c&&n.jsxs("div",{className:"flex items-center gap-2",children:[!l.watch("metadata.instructions")?.trim()&&n.jsx(se,{variant:"outline",size:"sm",onClick:H,children:"+ Prompt template"}),n.jsxs(se,{variant:"outline",size:"sm",disabled:g||!l.watch("metadata.instructions")?.trim(),onClick:k,children:[n.jsx(Cn,{size:13}),"Improve"]})]})]}),n.jsx(rt,{name:"metadata.instructions",control:l.control,render:({field:L})=>n.jsxs("div",{className:"relative rounded-xl card-shadow bg-card focus-within:ring-1 focus-within:ring-ring",children:[n.jsx(Fs,{...L,value:L.value??"",onChange:K=>{L.onChange(K)},onBlur:()=>{L.onBlur(),N()},disabled:c,placeholder:"Define how this agent should behave, what tone to use, any constraints or guidelines...",className:"min-h-[200px] max-h-[360px] overflow-auto resize-none text-base text-muted-foreground placeholder:text-muted-foreground/40 leading-relaxed border-0 shadow-none px-4 py-3 pr-11 focus-visible:ring-0 focus-visible:ring-offset-0 bg-transparent",style:{boxShadow:"none"}}),n.jsxs(Se,{delayDuration:0,children:[n.jsx(xe,{asChild:!0,children:n.jsx(se,{type:"button",variant:"ghost",size:"icon",className:"absolute top-2 right-2 h-7 w-7 text-muted-foreground",onClick:()=>p(!0),"aria-label":"Open fullscreen editor",children:n.jsx(Jc,{size:14})})}),n.jsx(be,{side:"left",children:"Fullscreen"})]})]})})]}),n.jsx(tf,{virtualMcpId:t.id,form:l,flushAndSave:N}),n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("div",{className:"flex items-center justify-between gap-3",children:n.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Sandbox"})}),n.jsx(za,{className:"p-6 gap-5",children:n.jsxs(Sr,{className:"p-0 space-y-5",children:[n.jsx($u,{repo:u}),n.jsx(Wu,{control:l.control}),n.jsx(Tu,{control:l.control,form:l,virtualMcpId:t.id,orgSlug:s.slug})]})})]}),n.jsxs("section",{className:"flex items-center justify-between border-t border-border pt-6",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium",children:"Delete agent"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Permanently delete this agent and all its data."})]}),n.jsxs(se,{variant:"outline",size:"sm",className:"text-destructive border-destructive/40 hover:bg-destructive/10 hover:text-destructive shrink-0",onClick:()=>J(!0),children:[n.jsx(Ri,{size:14}),"Delete agent"]})]})]})})}),n.jsx(Da,{open:X,onOpenChange:J,children:n.jsxs(Pa,{children:[n.jsxs(Ia,{children:[n.jsx(Ma,{children:"Delete Agent?"}),n.jsxs(Aa,{children:["This action cannot be undone. This will permanently delete"," ",n.jsx("span",{className:"font-medium text-foreground",children:t.title}),"."]})]}),n.jsxs(Ba,{children:[n.jsx(La,{children:"Cancel"}),n.jsx(Oa,{onClick:Z,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),n.jsx(vc,{open:f.addDialogOpen,onOpenChange:L=>m({type:"SET_ADD_DIALOG_OPEN",payload:L}),agentId:t.id,addedConnectionIds:V,onAdd:M}),n.jsx(_u,{open:f.settingsDialogOpen,onOpenChange:L=>{L||m({type:"CLOSE_SETTINGS"})},selectedId:f.settingsConnectionId,form:l,connections:h,onAuthenticate:$}),n.jsx(Cu,{open:f.shareDialogOpen,onOpenChange:L=>m({type:"SET_SHARE_DIALOG_OPEN",payload:L}),virtualMcp:t}),n.jsx(Fi,{open:_,onOpenChange:p,children:n.jsxs(zi,{className:"w-[90vw] sm:max-w-6xl h-[85vh] flex flex-col p-0 gap-0",children:[n.jsx(yn,{className:"px-6 pt-6 pb-3 border-b border-border shrink-0",children:n.jsx(wn,{children:"Instructions"})}),n.jsx("div",{className:"flex-1 min-h-0 p-6",children:n.jsx(rt,{name:"metadata.instructions",control:l.control,render:({field:L})=>n.jsx(Fs,{...L,value:L.value??"",onChange:K=>{L.onChange(K)},onBlur:()=>{L.onBlur(),N()},disabled:c,placeholder:"Define how this agent should behave, what tone to use, any constraints or guidelines...",className:"w-full h-full resize-none text-base text-muted-foreground placeholder:text-muted-foreground/40 leading-relaxed rounded-xl card-shadow px-4 py-3 focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0 bg-card border-0",style:{boxShadow:"none"}})})})]})})]})}function rf(t){const e=z.c(9),{virtualMcpId:s,hideOwnTitle:i}=t,r=is(),{org:o}=me(),a=Pt(s);if(!a){let c;return e[0]!==r||e[1]!==o.slug?(c=n.jsx("div",{className:"flex h-full w-full bg-background",children:n.jsx(Ti,{title:"Space not found",description:"This space may have been deleted or you may not have access.",actions:n.jsx(se,{variant:"outline",onClick:()=>r({to:"/$org",params:{org:o.slug}}),children:"Back to spaces"})})}),e[0]=r,e[1]=o.slug,e[2]=c):c=e[2],c}let l;e[3]!==a?(l=Zt(a)?.connectionId??"",e[3]=a,e[4]=l):l=e[4];let h;return e[5]!==i||e[6]!==l||e[7]!==a?(h=n.jsx(sf,{virtualMcp:a,hideOwnTitle:i},l),e[5]=i,e[6]=l,e[7]=a,e[8]=h):h=e[8],h}function to(t){const e=z.c(2),{virtualMcpId:s}=t;let i;return e[0]!==s?(i=n.jsx(rf,{virtualMcpId:s,hideOwnTitle:!0}),e[0]=s,e[1]=i):i=e[1],i}const nf={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" "};function Ws(t){return t?t.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g,(e,s)=>{if(s.startsWith("#x")||s.startsWith("#X")){const i=Number.parseInt(s.slice(2),16);return Number.isFinite(i)?String.fromCodePoint(i):e}if(s.startsWith("#")){const i=Number.parseInt(s.slice(1),10);return Number.isFinite(i)?String.fromCodePoint(i):e}return nf[s]??e}):""}function Qs(t){if(!t||typeof t!="object")return null;const e=t;if(e.structuredContent!==void 0)return e.structuredContent;const s=e.content?.find(i=>i.type==="text")?.text;if(!s)return null;try{return JSON.parse(s)}catch{return null}}const Hi=6e4,Wi=3e4;function Za(t){const e=z.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=Ue(s),r=t.branch?`${t.owner}:${t.branch}`:void 0;let o;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(o={owner:t.owner,repo:t.repo,state:"all",head:r,perPage:1},e[4]=t.owner,e[5]=t.repo,e[6]=r,e[7]=o):o=e[7];const a=!!t.branch;let l;return e[8]!==i||e[9]!==o||e[10]!==a?(l={client:i,toolName:"list_pull_requests",toolArguments:o,enabled:a,refetchInterval:Hi,refetchIntervalInBackground:!1,staleTime:Wi,select:of},e[8]=i,e[9]=o,e[10]=a,e[11]=l):l=e[11],Gs(l)}function of(t){const e=Qs(t);if(!e||!Array.isArray(e)||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 Qa(t){const e=z.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=Ue(s),r=t.prNumber??0;let o;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(o={method:"get_files",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:Hi,refetchIntervalInBackground:!1,staleTime:Wi,select:af},e[8]=i,e[9]=o,e[10]=a,e[11]=l):l=e[11],Gs(l)}function af(t){const e=Qs(t);return Array.isArray(e)?e.map(lf):[]}function lf(t){const e=Number(t.additions??0),s=Number(t.changes??e),i=Number(t.deletions??Math.max(0,s-e));return{filename:String(t.filename??""),status:t.status??"modified",additions:e,deletions:i,blobUrl:typeof t.blob_url=="string"?t.blob_url:null}}function el(t){const e=z.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=Ue(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:Hi,refetchIntervalInBackground:!1,staleTime:Wi,select:cf},e[8]=i,e[9]=o,e[10]=a,e[11]=l):l=e[11],Gs(l)}function cf(t){const e=Qs(t);return(Array.isArray(e)?e:e?.check_runs??[]).map(hf)}function hf(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 df(t){const e=z.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=Ue(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:Hi,refetchIntervalInBackground:!1,staleTime:Wi,select:uf},e[8]=i,e[9]=o,e[10]=a,e[11]=l):l=e[11],Gs(l)}function uf(t){const e=Qs(t);return Array.isArray(e)?e.map(ff):[]}function ff(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 mf(t){const e=z.c(28),{pr:s,connectionId:i,owner:r,repo:o}=t,{org:a}=me();let l;e[0]!==i||e[1]!==a.id||e[2]!==a.slug||e[3]!==r||e[4]!==s.number||e[5]!==o?(l={orgId:a.id,orgSlug:a.slug,connectionId:i,owner:r,repo:o,prNumber:s.number},e[0]=i,e[1]=a.id,e[2]=a.slug,e[3]=r,e[4]=s.number,e[5]=o,e[6]=l):l=e[6];const h=Qa(l);if(h.isLoading){let x;return e[7]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading files…"}),e[7]=x):x=e[7],x}if(h.isError){let x;return e[8]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx("div",{className:"text-sm text-destructive",children:"Couldn't load file list."}),e[8]=x):x=e[8],x}let c;e[9]!==h.data?(c=h.data??[],e[9]=h.data,e[10]=c):c=e[10];const d=c;if(d.length===0){let x;return e[11]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx("div",{className:"text-sm text-muted-foreground",children:"No files changed."}),e[11]=x):x=e[11],x}const u=d.length===1?"":"s",f=`${s.htmlUrl}/files`;let m;e[12]!==f?(m=n.jsx("a",{href:f,target:"_blank",rel:"noreferrer",className:"underline hover:text-foreground",children:"View diffs on GitHub"}),e[12]=f,e[13]=m):m=e[13];let _;e[14]!==d.length||e[15]!==u||e[16]!==m?(_=n.jsxs("div",{className:"pb-2 text-xs text-muted-foreground",children:[d.length," file",u," changed ·"," ",m]}),e[14]=d.length,e[15]=u,e[16]=m,e[17]=_):_=e[17];let p;if(e[18]!==d||e[19]!==s.htmlUrl){let x;e[21]!==s.htmlUrl?(x=b=>n.jsx("li",{children:n.jsxs("a",{href:b.blobUrl??`${s.htmlUrl}/files`,target:"_blank",rel:"noreferrer",className:"flex items-center justify-between rounded px-2 py-1 font-mono text-xs hover:bg-muted",children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(_f,{status:b.status}),n.jsx("span",{className:"truncate",children:b.filename})]}),n.jsxs("span",{className:"flex shrink-0 items-center gap-2 tabular-nums",children:[n.jsxs("span",{children:[n.jsxs("span",{className:"text-success",children:["+",b.additions]})," ",n.jsxs("span",{className:"text-destructive",children:["−",b.deletions]})]}),n.jsx(gs,{className:"h-3 w-3 text-muted-foreground"})]})]})},b.filename),e[21]=s.htmlUrl,e[22]=x):x=e[22],p=d.map(x),e[18]=d,e[19]=s.htmlUrl,e[20]=p}else p=e[20];let g;e[23]!==p?(g=n.jsx("ul",{className:"space-y-0.5",children:p}),e[23]=p,e[24]=g):g=e[24];let v;return e[25]!==_||e[26]!==g?(v=n.jsxs("div",{className:"flex flex-col gap-1",children:[_,g]}),e[25]=_,e[26]=g,e[27]=v):v=e[27],v}function _f(t){const e=z.c(2),{status:s}=t,i=s==="added"?"A":s==="removed"?"D":s==="renamed"?"R":s==="copied"?"C":"M";let r;return e[0]!==i?(r=n.jsx("span",{className:"inline-flex h-4 w-4 items-center justify-center rounded bg-muted text-[10px] font-bold text-muted-foreground",children:i}),e[0]=i,e[1]=r):r=e[1],r}const Nt="The user clicked this action deliberately — execute directly. Do not call user_ask unless you hit an actual problem outside the scope of this intent (missing auth, unresolvable conflict, a check with multiple plausible fixes).";function pf(t){return`Commit every pending change in the working tree with a concise conventional-commit message summarizing the diff, then push to \`origin/${t.branch}\`. If local commits are ahead of the remote, push those in the same invocation. ${Nt}`}function gf(t){return`Open a pull request for \`${t.branch}\` against its base. Write a clear title and a summary of the changes so far. ${Nt}`}function vf(t){return`Reopen PR #${t.prNumber}. ${Nt}`}function xf(t){return`Rebase \`${t.branch}\` on the latest base and force-push with --force-with-lease. ${Nt}`}function bf(t){return`Re-run the \`${t.checkName}\` check on PR #${t.prNumber}. If an empty commit is needed to retrigger CI, create and push one. ${Nt}`}function Sf(t){const e=(t.failingChecks??[]).map(s=>`\`${s}\``).join(", ");return`PR #${t.prNumber} has failing checks: ${e}. For each: read the logs, diagnose the root cause, apply the smallest fix that makes it pass, commit, and push. ${Nt}`}function yf(t){return`Mark PR #${t.prNumber} ready for review. ${Nt}`}function wf(t){return`Read the unresolved review threads on PR #${t.prNumber}. For each thread: understand the reviewer's ask, apply the needed changes, commit, push, reply explaining what changed, and resolve the thread. If a comment is a question that doesn't need a code change, reply with the answer and resolve. ${Nt}`}function Cf(t){return`Review PR #${t.prNumber}. Read the full diff, analyze every changed file for correctness, security, code quality, and alignment with the repo's patterns. Post specific line-level review comments on concerns, then submit an overall review (approve / request changes / comment) with a concise summary. Do not modify the code — this is a read-and-comment pass. ${Nt}`}function kf(t){return`Squash-merge PR #${t.prNumber} into its base. ${Nt}`}function Nf(t){const e=z.c(24),{pr:s,connectionId:i,owner:r,repo:o}=t,{org:a}=me(),l=rs();let h;e[0]!==i||e[1]!==a.id||e[2]!==a.slug||e[3]!==r||e[4]!==s.number||e[5]!==o?(h={orgId:a.id,orgSlug:a.slug,connectionId:i,owner:r,repo:o,prNumber:s.number},e[0]=i,e[1]=a.id,e[2]=a.slug,e[3]=r,e[4]=s.number,e[5]=o,e[6]=h):h=e[6];const c=el(h);let d;e[7]!==l||e[8]!==s.number?(d=g=>l.sendMessage({parts:[{type:"text",text:bf({prNumber:s.number,checkName:g})}]}),e[7]=l,e[8]=s.number,e[9]=d):d=e[9];const u=d;if(c.isLoading){let g;return e[10]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading checks…"}),e[10]=g):g=e[10],g}if(c.isError){let g;return e[11]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("div",{className:"text-sm text-destructive",children:"Couldn't load check runs."}),e[11]=g):g=e[11],g}let f;e[12]!==c.data?(f=c.data??[],e[12]=c.data,e[13]=f):f=e[13];const m=f;if(m.length===0){let g;return e[14]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("div",{className:"text-sm text-muted-foreground",children:"No check runs on the PR head commit."}),e[14]=g):g=e[14],g}let _;if(e[15]!==l||e[16]!==m||e[17]!==u){let g;e[19]!==l||e[20]!==u?(g=v=>n.jsxs("li",{className:"flex items-center justify-between gap-2 rounded px-2 py-1.5 text-sm hover:bg-muted",children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(jf,{check:v}),n.jsx("span",{className:"truncate",children:v.name}),v.durationMs!=null&&n.jsx("span",{className:"text-xs text-muted-foreground",children:Ef(v.durationMs)})]}),n.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[v.htmlUrl&&n.jsx("a",{href:v.htmlUrl,target:"_blank",rel:"noreferrer",className:"inline-flex h-7 items-center justify-center rounded px-2 text-xs text-muted-foreground hover:bg-background",title:"View run",children:n.jsx(gs,{className:"h-3.5 w-3.5"})}),v.conclusion==="failure"&&n.jsx(se,{size:"sm",variant:"ghost",disabled:l.isStreaming,onClick:()=>u(v.name),children:"Re-run"})]})]},v.id),e[19]=l,e[20]=u,e[21]=g):g=e[21],_=m.map(g),e[15]=l,e[16]=m,e[17]=u,e[18]=_}else _=e[18];let p;return e[22]!==_?(p=n.jsx("ul",{className:"flex flex-col gap-0.5",children:_}),e[22]=_,e[23]=p):p=e[23],p}function jf(t){const e=z.c(5),{check:s}=t;if(s.status!=="completed"){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("span",{className:"text-muted-foreground","aria-label":"In progress",children:"○"}),e[0]=o):o=e[0],o}if(s.conclusion==="success"){let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("span",{className:"text-success","aria-label":"Success",children:"✓"}),e[1]=o):o=e[1],o}if(s.conclusion==="failure"){let o;return e[2]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("span",{className:"text-destructive","aria-label":"Failure",children:"✗"}),e[2]=o):o=e[2],o}const i=s.conclusion??"—";let r;return e[3]!==i?(r=n.jsx("span",{className:"text-muted-foreground","aria-label":i,children:"—"}),e[3]=i,e[4]=r):r=e[4],r}function Ef(t){const e=Math.round(t/1e3);return e<60?`${e}s`:`${Math.round(e/60)}m`}function Tf(t){const e=z.c(10),{comments:s,isLoading:i,isError:r}=t;if(i||r||!s||s.length===0)return null;const o=s.length===1?"":"s";let a;e[0]!==s.length||e[1]!==o?(a=n.jsxs(mh,{className:"py-3 text-sm font-medium",children:[s.length," comment",o]}),e[0]=s.length,e[1]=o,e[2]=a):a=e[2];let l;e[3]!==s?(l=s.map(Rf),e[3]=s,e[4]=l):l=e[4];let h;e[5]!==l?(h=n.jsx(_h,{className:"space-y-3 pb-3",children:l}),e[5]=l,e[6]=h):h=e[6];let c;return e[7]!==a||e[8]!==h?(c=n.jsx(ph,{type:"single",collapsible:!0,className:"border-t border-border",children:n.jsxs(gh,{value:"comments",className:"border-b-0",children:[a,h]})}),e[7]=a,e[8]=h,e[9]=c):c=e[9],c}function Rf(t){return n.jsxs("div",{className:"rounded-md border border-border p-3",children:[n.jsxs("div",{className:"mb-1 text-xs text-muted-foreground",children:["@",t.author," · ",Df(t.createdAt)]}),n.jsx(fn,{id:`pr-comment-${t.id}`,text:Ws(t.body)})]},t.id)}function Df(t){if(!t)return"";const e=new Date(t).getTime();if(!Number.isFinite(e))return"";const s=Date.now()-e;if(s<0)return"just now";const i=Math.floor(s/864e5);if(i>0)return`${i}d ago`;const r=Math.floor(s/36e5);if(r>0)return`${r}h ago`;const o=Math.floor(s/6e4);return`${Math.max(1,o)}m ago`}function Pf(t){const e=z.c(19),{pr:s,connectionId:i,owner:r,repo:o}=t,{org:a}=me();let l;e[0]!==i||e[1]!==a.id||e[2]!==a.slug||e[3]!==r||e[4]!==s.number||e[5]!==o?(l={orgId:a.id,orgSlug:a.slug,connectionId:i,owner:r,repo:o,prNumber:s.number},e[0]=i,e[1]=a.id,e[2]=a.slug,e[3]=r,e[4]=s.number,e[5]=o,e[6]=l):l=e[6];const h=df(l);let c;e[7]!==s.body||e[8]!==s.number?(c=s.body&&n.jsx("div",{className:"text-sm",children:n.jsx(fn,{id:`pr-body-${s.number}`,text:Ws(s.body)})}),e[7]=s.body,e[8]=s.number,e[9]=c):c=e[9];let d;e[10]!==h.data?(d=h.data??[],e[10]=h.data,e[11]=d):d=e[11];let u;e[12]!==h.isError||e[13]!==h.isLoading||e[14]!==d?(u=n.jsx(Tf,{comments:d,isLoading:h.isLoading,isError:h.isError}),e[12]=h.isError,e[13]=h.isLoading,e[14]=d,e[15]=u):u=e[15];let f;return e[16]!==c||e[17]!==u?(f=n.jsxs("div",{className:"space-y-8",children:[c,u]}),e[16]=c,e[17]=u,e[18]=f):f=e[18],f}function If(t){const e=z.c(27),{pr:s,connectionId:i,owner:r,repo:o}=t,{org:a}=me();let l;e[0]!==i||e[1]!==a.id||e[2]!==a.slug||e[3]!==r||e[4]!==s.number||e[5]!==o?(l={orgId:a.id,orgSlug:a.slug,connectionId:i,owner:r,repo:o,prNumber:s.number},e[0]=i,e[1]=a.id,e[2]=a.slug,e[3]=r,e[4]=s.number,e[5]=o,e[6]=l):l=e[6];const c=Qa(l).data?.length,[d,u]=A.useState("description"),f=A.useRef({description:null,changes:null,checks:null}),[m,_]=A.useState(null),p=E=>T=>{if(f.current[E]=T,T&&E===d){const B=T.offsetLeft,I=T.offsetWidth;(m===null||B!==m.left||I!==m.width)&&_({left:B,width:I})}},g=E=>{const T=E;u(T);const B=f.current[T];B&&_({left:B.offsetLeft,width:B.offsetWidth})},v=Ji,x=p("checks");let b;e[7]!==v||e[8]!==x?(b=n.jsx(v,{ref:x,variant:"underline",value:"checks",className:"pb-3 data-[state=active]:border-transparent",children:"Checks"}),e[7]=v,e[8]=x,e[9]=b):b=e[9];let S;e[10]!==m?(S=m&&n.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute bottom-[-1px] h-0.5 bg-primary transition-[left,width] duration-200 ease-out",style:{left:m.left,width:m.width}}),e[10]=m,e[11]=S):S=e[11];let w;e[12]!==i||e[13]!==r||e[14]!==s||e[15]!==o?(w=n.jsx(Zi,{value:"description",className:"mt-6",children:n.jsx(Pf,{pr:s,connectionId:i,owner:r,repo:o})}),e[12]=i,e[13]=r,e[14]=s,e[15]=o,e[16]=w):w=e[16];let k;e[17]!==i||e[18]!==r||e[19]!==s||e[20]!==o?(k=n.jsx(Zi,{value:"changes",className:"mt-6",children:n.jsx(mf,{pr:s,connectionId:i,owner:r,repo:o})}),e[17]=i,e[18]=r,e[19]=s,e[20]=o,e[21]=k):k=e[21];let C;return e[22]!==i||e[23]!==r||e[24]!==s||e[25]!==o?(C=n.jsx(Zi,{value:"checks",className:"mt-6",children:n.jsx(Nf,{pr:s,connectionId:i,owner:r,repo:o})}),e[22]=i,e[23]=r,e[24]=s,e[25]=o,e[26]=C):C=e[26],n.jsxs(Lh,{value:d,onValueChange:g,variant:"underline",children:[n.jsxs(Oh,{variant:"underline",className:"relative h-auto p-0",children:[n.jsx(Ji,{ref:p("description"),variant:"underline",value:"description",className:"pb-3 data-[state=active]:border-transparent",children:"Description"}),n.jsxs(Ji,{ref:p("changes"),variant:"underline",value:"changes",className:"pb-3 data-[state=active]:border-transparent",children:["Changes",c!==void 0?` ${c}`:""]}),b,S]}),w,k,C]})}function Mf(t){const e=z.c(5),{pr:s}=t,i=`Open PR #${s.number} on GitHub`;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(gs,{className:"h-4 w-4 text-muted-foreground"}),e[0]=r):r=e[0];let o;return e[1]!==s.htmlUrl||e[2]!==s.number||e[3]!==i?(o=n.jsx("div",{className:"flex h-12 items-center border-b border-border px-4 shrink-0",children:n.jsxs("a",{href:s.htmlUrl,target:"_blank",rel:"noreferrer","aria-label":i,className:"inline-flex items-center gap-1.5 text-base font-medium text-foreground hover:underline",children:["PR #",s.number,r]})}),e[1]=s.htmlUrl,e[2]=s.number,e[3]=i,e[4]=o):o=e[4],o}function Af(t){const e=z.c(23),{pr:s}=t;let i;e[0]!==s.title?(i=Ws(s.title),e[0]=s.title,e[1]=i):i=e[1];let r;e[2]!==i?(r=n.jsx("h1",{className:"text-2xl font-semibold",children:i}),e[2]=i,e[3]=r):r=e[3];const o=`Open PR #${s.number} on GitHub`;let a;e[4]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(gs,{className:"h-3.5 w-3.5"}),e[4]=a):a=e[4];let l;e[5]!==s.htmlUrl||e[6]!==s.number||e[7]!==o?(l=n.jsxs("a",{href:s.htmlUrl,target:"_blank",rel:"noreferrer","aria-label":o,className:"inline-flex items-center gap-1 hover:text-foreground",children:["PR #",s.number,a]}),e[5]=s.htmlUrl,e[6]=s.number,e[7]=o,e[8]=l):l=e[8];let h;e[9]!==s.author?(h=s.author&&n.jsxs(n.Fragment,{children:["@",s.author," · "]}),e[9]=s.author,e[10]=h):h=e[10];let c;e[11]!==s.base?(c=n.jsx("span",{className:"font-mono text-xs",children:s.base}),e[11]=s.base,e[12]=c):c=e[12];let d;e[13]!==s.head?(d=n.jsx("span",{className:"font-mono text-xs",children:s.head}),e[13]=s.head,e[14]=d):d=e[14];let u;e[15]!==l||e[16]!==h||e[17]!==c||e[18]!==d?(u=n.jsxs("div",{className:"text-sm text-muted-foreground",children:[l," · ",h,c," ← ",d]}),e[15]=l,e[16]=h,e[17]=c,e[18]=d,e[19]=u):u=e[19];let f;return e[20]!==r||e[21]!==u?(f=n.jsxs("div",{className:"space-y-2",children:[r,u]}),e[20]=r,e[21]=u,e[22]=f):f=e[22],f}function Bf(t){const e=z.c(9),{virtualMcpId:s}=t,{org:i}=me(),r=Pt(s),{currentBranch:o}=Ht(),a=r?.metadata?.githubRepo??null;if(!a?.connectionId){let h;return e[0]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx("div",{className:"flex h-full items-center justify-center p-8 text-sm text-muted-foreground",children:"This virtualmcp is not linked to a GitHub repository."}),e[0]=h):h=e[0],h}if(!o){let h;return e[1]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-8 text-sm",children:[n.jsx(As,{className:"h-6 w-6 text-muted-foreground"}),n.jsx("div",{className:"text-muted-foreground",children:"No branch selected."}),n.jsx("div",{className:"text-xs text-muted-foreground",children:"Pick a branch from the dropdown in the header to see PR status."})]}),e[1]=h):h=e[1],h}let l;return e[2]!==o||e[3]!==a.connectionId||e[4]!==a.name||e[5]!==a.owner||e[6]!==i.id||e[7]!==i.slug?(l=n.jsx(Lf,{orgId:i.id,orgSlug:i.slug,connectionId:a.connectionId,owner:a.owner,repo:a.name,branch:o}),e[2]=o,e[3]=a.connectionId,e[4]=a.name,e[5]=a.owner,e[6]=i.id,e[7]=i.slug,e[8]=l):l=e[8],l}function Lf(t){const e=z.c(50),{orgId:s,orgSlug:i,connectionId:r,owner:o,repo:a,branch:l}=t;let h;e[0]!==l||e[1]!==r||e[2]!==s||e[3]!==i||e[4]!==o||e[5]!==a?(h={orgId:s,orgSlug:i,connectionId:r,owner:o,repo:a,branch:l},e[0]=l,e[1]=r,e[2]=s,e[3]=i,e[4]=o,e[5]=a,e[6]=h):h=e[6];const{data:c,isLoading:d,isError:u}=Za(h),f=Of;if(d){let x;return e[7]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading PR state…"}),e[7]=x):x=e[7],x}if(u){let x;return e[8]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx("div",{className:"p-4 text-sm text-destructive",children:"Couldn't load PR state. The GitHub connection may be broken."}),e[8]=x):x=e[8],x}const m=`https://github.com/${o}/${a}/tree/${l}`;if(c&&c.state==="closed"){let x;e[9]!==c?(x=n.jsx(Mf,{pr:c}),e[9]=c,e[10]=x):x=e[10];const b=c.merged?"✓ Merged":"✗ Closed";let S;e[11]!==c.mergedAt?(S=c.mergedAt&&n.jsxs(n.Fragment,{children:[" · ",new Date(c.mergedAt).toLocaleDateString()]}),e[11]=c.mergedAt,e[12]=S):S=e[12];let w;e[13]!==c.author?(w=c.author&&n.jsxs(n.Fragment,{children:[" · by @",c.author]}),e[13]=c.author,e[14]=w):w=e[14];let k;e[15]!==c.base||e[16]!==b||e[17]!==S||e[18]!==w?(k=n.jsxs("div",{className:"text-sm text-success",children:[b," into ",c.base,S,w]}),e[15]=c.base,e[16]=b,e[17]=S,e[18]=w,e[19]=k):k=e[19];let C;e[20]!==c.title?(C=Ws(c.title),e[20]=c.title,e[21]=C):C=e[21];let E;e[22]!==C?(E=n.jsx("h1",{className:"text-lg font-semibold",children:C}),e[22]=C,e[23]=E):E=e[23];let T;e[24]!==c.body||e[25]!==c.number?(T=c.body&&n.jsx("div",{className:"rounded-md border border-border bg-muted/30 p-3 text-sm",children:n.jsx(fn,{id:`pr-body-${c.number}`,text:Ws(c.body)})}),e[24]=c.body,e[25]=c.number,e[26]=T):T=e[26];let B;e[27]!==k||e[28]!==E||e[29]!==T?(B=n.jsxs("div",{className:"flex flex-col gap-4 p-4 overflow-auto",children:[k,E,T]}),e[27]=k,e[28]=E,e[29]=T,e[30]=B):B=e[30];let I;return e[31]!==x||e[32]!==B?(I=n.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[x,B]}),e[31]=x,e[32]=B,e[33]=I):I=e[33],I}if(c&&c.state==="open"){let x;e[34]!==c?(x=n.jsx(Af,{pr:c}),e[34]=c,e[35]=x):x=e[35];let b;e[36]!==r||e[37]!==o||e[38]!==c||e[39]!==a?(b=n.jsx("div",{className:"mt-8",children:n.jsx(If,{pr:c,connectionId:r,owner:o,repo:a})}),e[36]=r,e[37]=o,e[38]=c,e[39]=a,e[40]=b):b=e[40];let S;return e[41]!==x||e[42]!==b?(S=n.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:n.jsx("div",{className:"flex-1 overflow-auto",children:n.jsxs("div",{className:"mx-auto w-full max-w-[1200px] px-4 pt-8 pb-6 md:px-10 md:pt-12 md:pb-10",children:[x,b]})})}),e[41]=x,e[42]=b,e[43]=S):S=e[43],S}let _;e[44]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx("div",{className:"rounded-md border border-border bg-muted/30 p-4 text-sm",children:`This branch doesn't have an open pull request. Click "Submit for review" in the header to open one; the agent will draft the title and summary from the current state of the branch.`}),e[44]=_):_=e[44];let p;e[45]!==m?(p=()=>f(m),e[45]=m,e[46]=p):p=e[46];let g;e[47]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(gs,{className:"mr-1.5 h-4 w-4"}),e[47]=g):g=e[47];let v;return e[48]!==p?(v=n.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[_,n.jsx("div",{className:"flex items-center gap-2",children:n.jsxs(se,{size:"sm",variant:"outline",onClick:p,children:[g,"Open branch on GitHub"]})})]}),e[48]=p,e[49]=v):v=e[49],v}function Of(t){window.open(t,"_blank","noopener,noreferrer")}function $f(t){const e=z.c(8),s=t?`${t.orgSlug}/${t.virtualMcpId}/${t.branch}`:"";let i;e[0]!==s?(i=us.decofile(s),e[0]=s,e[1]=i):i=e[1];let r;e[2]!==t?(r=async()=>{const l=new URLSearchParams({path:"/.decofile"}),h=await fetch(`/api/${t.orgSlug}/vm/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/preview-fetch?${l.toString()}`);if(!h.ok)throw new Error(`Failed to fetch decofile: ${h.status}`);return await h.json()},e[2]=t,e[3]=r):r=e[3];const o=!!t;let a;return e[4]!==i||e[5]!==r||e[6]!==o?(a={queryKey:i,queryFn:r,enabled:o,staleTime:3e4},e[4]=i,e[5]=r,e[6]=o,e[7]=a):a=e[7],ha(a)}function zf(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 Ff=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function Hf(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"&&Ff.has(r.__resolveType)&&typeof r.path=="string"&&e.push({key:s,name:typeof r.name=="string"?r.name:zf(s),path:r.path})}return e}const Wf=Yi({tag:gt(),id:gt(),classes:gt(),text:gt(),html:gt(),manifestKey:gt().nullable(),componentName:gt().nullable(),parents:gt(),url:gt(),path:gt(),viewport:Yi({width:oi(),height:oi()}),position:Yi({x:oi(),y:oi()})}),Uf=`(function() {
|
|
31
|
+
${q}`:q;l.setValue("metadata.instructions",Q,{shouldDirty:!0})},K=new Set(h.map(L=>L.connection_id)),re=is(),[Z,J]=A.useState(!1),X=async()=>{T();try{await i.delete.mutateAsync(t.id),be("agent_deleted",{agent_id:t.id,source:"agent_detail"}),he.success(`Deleted "${t.title}"`),re({to:"/$org",params:{org:s.slug}})}catch{}};return n.jsxs(ft,{children:[n.jsx(ft.Content,{children:n.jsx(ft.Body,{children:n.jsxs("div",{className:"flex flex-col gap-10",children:[!e&&n.jsx(ft.Title,{actions:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs(se,{variant:"outline",size:"sm",onClick:E,children:[n.jsx(Qt,{size:14,className:"!size-[14px]"}),"Test Agent"]}),n.jsx(se,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive",onClick:()=>J(!0),children:n.jsx(Di,{size:14})})]}),children:"Settings"}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(nt,{name:"icon",control:l.control,render:({field:L})=>n.jsx(ru,{value:L.value??null,onChange:q=>{L.onChange(q),C()},onColorChange:q=>{l.setValue("metadata.ui.themeColor",q,{shouldDirty:!0}),C()},name:l.watch("title")||"Agent",size:"md",className:"shrink-0",avatarClassName:"[&_svg]:w-1/2 [&_svg]:h-1/2",disabled:c})}),n.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[n.jsx(nt,{name:"title",control:l.control,render:({field:L})=>n.jsx("input",{...L,type:"text",value:L.value??"",onChange:q=>{L.onChange(q)},onBlur:()=>{L.onBlur(),C()},disabled:c,placeholder:"Agent name",className:"text-lg font-medium leading-tight text-foreground bg-transparent border-none outline-none px-1 -mx-1 rounded hover:bg-input/25 focus:bg-input/25 transition-colors w-full truncate disabled:hover:bg-transparent disabled:focus:bg-transparent disabled:opacity-50"})}),n.jsx(nt,{name:"description",control:l.control,render:({field:L})=>n.jsx("input",{...L,type:"text",value:L.value??"",onChange:q=>{L.onChange(q)},onBlur:()=>{L.onBlur(),C()},disabled:c,placeholder:"Add a description...",className:"text-sm text-muted-foreground bg-transparent border-none outline-none px-1 -mx-1 rounded hover:bg-input/25 focus:bg-input/25 transition-colors w-full truncate disabled:hover:bg-transparent disabled:focus:bg-transparent disabled:opacity-50"})})]}),n.jsxs(se,{variant:"outline",size:"sm",className:"shrink-0",onClick:()=>{be("agent_connect_modal_opened",{agent_id:t.id}),m({type:"SET_SHARE_DIALOG_OPEN",payload:!0})},children:[n.jsxs("span",{className:"flex items-center -space-x-1.5 mr-0.5",children:[n.jsx("span",{className:"inline-flex items-center justify-center size-4 rounded-full bg-black ring-1 ring-white/20 shrink-0",children:n.jsx("img",{src:"/logos/cursor.svg",alt:"Cursor",className:"size-2.5 brightness-0 invert"})}),n.jsx("span",{className:"relative z-10 inline-flex items-center justify-center size-4 rounded-full ring-1 ring-background shrink-0",style:{backgroundColor:"#D97757"},children:n.jsx("img",{src:"/logos/Claude Code.svg",alt:"Claude",className:"size-2.5 brightness-0 invert"})})]}),"Connect"]})]}),n.jsxs("div",{className:"flex items-center gap-2 -mt-6 text-muted-foreground",children:[n.jsx(Ma,{id:t.created_by,size:"2xs",className:"text-sm text-muted-foreground"}),n.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),n.jsx("span",{className:"text-sm",children:new Date(t.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})})]}),n.jsxs("section",{className:"flex flex-col gap-3",children:[n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Connections"}),h.length>0&&n.jsxs(se,{variant:"outline",size:"sm",onClick:j,children:[n.jsx(es,{size:14}),"Add connection"]})]}),n.jsx("div",{className:"flex flex-col gap-2",children:h.length===0?n.jsxs("button",{type:"button",onClick:j,className:"flex items-center gap-3 px-3 py-2.5 rounded-lg border border-dashed border-border hover:bg-accent/50 transition-colors w-full text-left cursor-pointer",children:[n.jsx("div",{className:"flex items-center justify-center size-8 rounded-md text-muted-foreground/75 border border-dashed border-border shrink-0",children:n.jsx(es,{size:16})}),n.jsx("span",{className:"text-sm text-muted-foreground",children:"No connections yet. Add one to get started."})]}):h.map(L=>n.jsx(Rt,{fallback:()=>null,children:n.jsx(A.Suspense,{fallback:n.jsx(il,{}),children:n.jsx(af,{connection_id:L.connection_id,usedConnectionIds:K,onOpenSettings:()=>O(L.connection_id),onRemove:()=>D(L.connection_id),onAuthenticate:$,onSwitchInstance:F,onNewInstance:()=>H(L.connection_id)})})},L.connection_id))})]}),n.jsxs("section",{className:"flex flex-col gap-3",children:[n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Instructions"}),!c&&n.jsxs("div",{className:"flex items-center gap-2",children:[!l.watch("metadata.instructions")?.trim()&&n.jsx(se,{variant:"outline",size:"sm",onClick:W,children:"+ Prompt template"}),n.jsxs(se,{variant:"outline",size:"sm",disabled:g||!l.watch("metadata.instructions")?.trim(),onClick:k,children:[n.jsx(kn,{size:13}),"Improve"]})]})]}),n.jsx(nt,{name:"metadata.instructions",control:l.control,render:({field:L})=>n.jsxs("div",{className:"relative rounded-xl card-shadow bg-card focus-within:ring-1 focus-within:ring-ring",children:[n.jsx(Ws,{...L,value:L.value??"",onChange:q=>{L.onChange(q)},onBlur:()=>{L.onBlur(),C()},disabled:c,placeholder:"Define how this agent should behave, what tone to use, any constraints or guidelines...",className:"min-h-[200px] max-h-[360px] overflow-auto resize-none text-base text-muted-foreground placeholder:text-muted-foreground/40 leading-relaxed border-0 shadow-none px-4 py-3 pr-11 focus-visible:ring-0 focus-visible:ring-offset-0 bg-transparent",style:{boxShadow:"none"}}),n.jsxs(je,{delayDuration:0,children:[n.jsx(ke,{asChild:!0,children:n.jsx(se,{type:"button",variant:"ghost",size:"icon",className:"absolute top-2 right-2 h-7 w-7 text-muted-foreground",onClick:()=>p(!0),"aria-label":"Open fullscreen editor",children:n.jsx(ah,{size:14})})}),n.jsx(Ne,{side:"left",children:"Fullscreen"})]})]})})]}),n.jsx(uf,{virtualMcpId:t.id,form:l,flushAndSave:C}),n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("div",{className:"flex items-center justify-between gap-3",children:n.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Sandbox"})}),n.jsx(Ka,{className:"p-6 gap-5",children:n.jsxs(yr,{className:"p-0 space-y-5",children:[n.jsx(Yu,{repo:u}),n.jsx(Qu,{control:l.control}),n.jsx($u,{control:l.control,form:l,virtualMcpId:t.id,orgSlug:s.slug})]})})]}),n.jsxs("section",{className:"flex items-center justify-between border-t border-border pt-6",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium",children:"Delete agent"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Permanently delete this agent and all its data."})]}),n.jsxs(se,{variant:"outline",size:"sm",className:"text-destructive border-destructive/40 hover:bg-destructive/10 hover:text-destructive shrink-0",onClick:()=>J(!0),children:[n.jsx(Di,{size:14}),"Delete agent"]})]})]})})}),n.jsx(La,{open:Z,onOpenChange:J,children:n.jsxs(Oa,{children:[n.jsxs($a,{children:[n.jsx(za,{children:"Delete Agent?"}),n.jsxs(Fa,{children:["This action cannot be undone. This will permanently delete"," ",n.jsx("span",{className:"font-medium text-foreground",children:t.title}),"."]})]}),n.jsxs(Ha,{children:[n.jsx(Wa,{children:"Cancel"}),n.jsx(Ua,{onClick:X,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),n.jsx(Ec,{open:f.addDialogOpen,onOpenChange:L=>m({type:"SET_ADD_DIALOG_OPEN",payload:L}),agentId:t.id,addedConnectionIds:K,onAdd:M}),n.jsx(ku,{open:f.settingsDialogOpen,onOpenChange:L=>{L||m({type:"CLOSE_SETTINGS"})},selectedId:f.settingsConnectionId,form:l,connections:h,onAuthenticate:$}),n.jsx(Mu,{open:f.shareDialogOpen,onOpenChange:L=>m({type:"SET_SHARE_DIALOG_OPEN",payload:L}),virtualMcp:t}),n.jsx(Hi,{open:_,onOpenChange:p,children:n.jsxs(Fi,{className:"w-[90vw] sm:max-w-6xl h-[85vh] flex flex-col p-0 gap-0",children:[n.jsx(wn,{className:"px-6 pt-6 pb-3 border-b border-border shrink-0",children:n.jsx(Cn,{children:"Instructions"})}),n.jsx("div",{className:"flex-1 min-h-0 p-6",children:n.jsx(nt,{name:"metadata.instructions",control:l.control,render:({field:L})=>n.jsx(Ws,{...L,value:L.value??"",onChange:q=>{L.onChange(q)},onBlur:()=>{L.onBlur(),C()},disabled:c,placeholder:"Define how this agent should behave, what tone to use, any constraints or guidelines...",className:"w-full h-full resize-none text-base text-muted-foreground placeholder:text-muted-foreground/40 leading-relaxed rounded-xl card-shadow px-4 py-3 focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0 bg-card border-0",style:{boxShadow:"none"}})})})]})})]})}function mf(t){const e=z.c(9),{virtualMcpId:s,hideOwnTitle:i}=t,r=is(),{org:o}=ge(),a=Pt(s);if(!a){let c;return e[0]!==r||e[1]!==o.slug?(c=n.jsx("div",{className:"flex h-full w-full bg-background",children:n.jsx(Ri,{title:"Space not found",description:"This space may have been deleted or you may not have access.",actions:n.jsx(se,{variant:"outline",onClick:()=>r({to:"/$org",params:{org:o.slug}}),children:"Back to spaces"})})}),e[0]=r,e[1]=o.slug,e[2]=c):c=e[2],c}let l;e[3]!==a?(l=Zt(a)?.connectionId??"",e[3]=a,e[4]=l):l=e[4];let h;return e[5]!==i||e[6]!==l||e[7]!==a?(h=n.jsx(ff,{virtualMcp:a,hideOwnTitle:i},l),e[5]=i,e[6]=l,e[7]=a,e[8]=h):h=e[8],h}function lo(t){const e=z.c(2),{virtualMcpId:s}=t;let i;return e[0]!==s?(i=n.jsx(mf,{virtualMcpId:s,hideOwnTitle:!0}),e[0]=s,e[1]=i):i=e[1],i}const _f={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" "};function Vs(t){return t?t.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g,(e,s)=>{if(s.startsWith("#x")||s.startsWith("#X")){const i=Number.parseInt(s.slice(2),16);return Number.isFinite(i)?String.fromCodePoint(i):e}if(s.startsWith("#")){const i=Number.parseInt(s.slice(1),10);return Number.isFinite(i)?String.fromCodePoint(i):e}return _f[s]??e}):""}function ti(t){if(!t||typeof t!="object")return null;const e=t;if(e.structuredContent!==void 0)return e.structuredContent;const s=e.content?.find(i=>i.type==="text")?.text;if(!s)return null;try{return JSON.parse(s)}catch{return null}}const Wi=6e4,Ui=3e4;function rl(t){const e=z.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=Ue(s),r=t.branch?`${t.owner}:${t.branch}`:void 0;let o;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(o={owner:t.owner,repo:t.repo,state:"all",head:r,perPage:1},e[4]=t.owner,e[5]=t.repo,e[6]=r,e[7]=o):o=e[7];const a=!!t.branch;let l;return e[8]!==i||e[9]!==o||e[10]!==a?(l={client:i,toolName:"list_pull_requests",toolArguments:o,enabled:a,refetchInterval:Wi,refetchIntervalInBackground:!1,staleTime:Ui,select:pf},e[8]=i,e[9]=o,e[10]=a,e[11]=l):l=e[11],Xs(l)}function pf(t){const e=ti(t);if(!e||!Array.isArray(e)||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 nl(t){const e=z.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=Ue(s),r=t.prNumber??0;let o;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(o={method:"get_files",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:Wi,refetchIntervalInBackground:!1,staleTime:Ui,select:gf},e[8]=i,e[9]=o,e[10]=a,e[11]=l):l=e[11],Xs(l)}function gf(t){const e=ti(t);return Array.isArray(e)?e.map(vf):[]}function vf(t){const e=Number(t.additions??0),s=Number(t.changes??e),i=Number(t.deletions??Math.max(0,s-e));return{filename:String(t.filename??""),status:t.status??"modified",additions:e,deletions:i,blobUrl:typeof t.blob_url=="string"?t.blob_url:null}}function ol(t){const e=z.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=Ue(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:Wi,refetchIntervalInBackground:!1,staleTime:Ui,select:xf},e[8]=i,e[9]=o,e[10]=a,e[11]=l):l=e[11],Xs(l)}function xf(t){const e=ti(t);return(Array.isArray(e)?e:e?.check_runs??[]).map(bf)}function bf(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 Sf(t){const e=z.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=Ue(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:Wi,refetchIntervalInBackground:!1,staleTime:Ui,select:yf},e[8]=i,e[9]=o,e[10]=a,e[11]=l):l=e[11],Xs(l)}function yf(t){const e=ti(t);return Array.isArray(e)?e.map(wf):[]}function wf(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 Cf(t){const e=z.c(28),{pr:s,connectionId:i,owner:r,repo:o}=t,{org:a}=ge();let l;e[0]!==i||e[1]!==a.id||e[2]!==a.slug||e[3]!==r||e[4]!==s.number||e[5]!==o?(l={orgId:a.id,orgSlug:a.slug,connectionId:i,owner:r,repo:o,prNumber:s.number},e[0]=i,e[1]=a.id,e[2]=a.slug,e[3]=r,e[4]=s.number,e[5]=o,e[6]=l):l=e[6];const h=nl(l);if(h.isLoading){let x;return e[7]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading files…"}),e[7]=x):x=e[7],x}if(h.isError){let x;return e[8]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx("div",{className:"text-sm text-destructive",children:"Couldn't load file list."}),e[8]=x):x=e[8],x}let c;e[9]!==h.data?(c=h.data??[],e[9]=h.data,e[10]=c):c=e[10];const d=c;if(d.length===0){let x;return e[11]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx("div",{className:"text-sm text-muted-foreground",children:"No files changed."}),e[11]=x):x=e[11],x}const u=d.length===1?"":"s",f=`${s.htmlUrl}/files`;let m;e[12]!==f?(m=n.jsx("a",{href:f,target:"_blank",rel:"noreferrer",className:"underline hover:text-foreground",children:"View diffs on GitHub"}),e[12]=f,e[13]=m):m=e[13];let _;e[14]!==d.length||e[15]!==u||e[16]!==m?(_=n.jsxs("div",{className:"pb-2 text-xs text-muted-foreground",children:[d.length," file",u," changed ·"," ",m]}),e[14]=d.length,e[15]=u,e[16]=m,e[17]=_):_=e[17];let p;if(e[18]!==d||e[19]!==s.htmlUrl){let x;e[21]!==s.htmlUrl?(x=b=>n.jsx("li",{children:n.jsxs("a",{href:b.blobUrl??`${s.htmlUrl}/files`,target:"_blank",rel:"noreferrer",className:"flex items-center justify-between rounded px-2 py-1 font-mono text-xs hover:bg-muted",children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(kf,{status:b.status}),n.jsx("span",{className:"truncate",children:b.filename})]}),n.jsxs("span",{className:"flex shrink-0 items-center gap-2 tabular-nums",children:[n.jsxs("span",{children:[n.jsxs("span",{className:"text-success",children:["+",b.additions]})," ",n.jsxs("span",{className:"text-destructive",children:["−",b.deletions]})]}),n.jsx(gs,{className:"h-3 w-3 text-muted-foreground"})]})]})},b.filename),e[21]=s.htmlUrl,e[22]=x):x=e[22],p=d.map(x),e[18]=d,e[19]=s.htmlUrl,e[20]=p}else p=e[20];let g;e[23]!==p?(g=n.jsx("ul",{className:"space-y-0.5",children:p}),e[23]=p,e[24]=g):g=e[24];let v;return e[25]!==_||e[26]!==g?(v=n.jsxs("div",{className:"flex flex-col gap-1",children:[_,g]}),e[25]=_,e[26]=g,e[27]=v):v=e[27],v}function kf(t){const e=z.c(2),{status:s}=t,i=s==="added"?"A":s==="removed"?"D":s==="renamed"?"R":s==="copied"?"C":"M";let r;return e[0]!==i?(r=n.jsx("span",{className:"inline-flex h-4 w-4 items-center justify-center rounded bg-muted text-[10px] font-bold text-muted-foreground",children:i}),e[0]=i,e[1]=r):r=e[1],r}const Nt="The user clicked this action deliberately — execute directly. Do not call user_ask unless you hit an actual problem outside the scope of this intent (missing auth, unresolvable conflict, a check with multiple plausible fixes).";function Nf(t){return`Commit every pending change in the working tree with a concise conventional-commit message summarizing the diff, then push to \`origin/${t.branch}\`. If local commits are ahead of the remote, push those in the same invocation. ${Nt}`}function jf(t){return`Open a pull request for \`${t.branch}\` against its base. Write a clear title and a summary of the changes so far. ${Nt}`}function Ef(t){return`Reopen PR #${t.prNumber}. ${Nt}`}function Tf(t){return`Rebase \`${t.branch}\` on the latest base and force-push with --force-with-lease. ${Nt}`}function Rf(t){return`Re-run the \`${t.checkName}\` check on PR #${t.prNumber}. If an empty commit is needed to retrigger CI, create and push one. ${Nt}`}function Df(t){const e=(t.failingChecks??[]).map(s=>`\`${s}\``).join(", ");return`PR #${t.prNumber} has failing checks: ${e}. For each: read the logs, diagnose the root cause, apply the smallest fix that makes it pass, commit, and push. ${Nt}`}function Pf(t){return`Mark PR #${t.prNumber} ready for review. ${Nt}`}function If(t){return`Read the unresolved review threads on PR #${t.prNumber}. For each thread: understand the reviewer's ask, apply the needed changes, commit, push, reply explaining what changed, and resolve the thread. If a comment is a question that doesn't need a code change, reply with the answer and resolve. ${Nt}`}function Mf(t){return`Review PR #${t.prNumber}. Read the full diff, analyze every changed file for correctness, security, code quality, and alignment with the repo's patterns. Post specific line-level review comments on concerns, then submit an overall review (approve / request changes / comment) with a concise summary. Do not modify the code — this is a read-and-comment pass. ${Nt}`}function Af(t){return`Squash-merge PR #${t.prNumber} into its base. ${Nt}`}function Bf(t){const e=z.c(24),{pr:s,connectionId:i,owner:r,repo:o}=t,{org:a}=ge(),l=rs();let h;e[0]!==i||e[1]!==a.id||e[2]!==a.slug||e[3]!==r||e[4]!==s.number||e[5]!==o?(h={orgId:a.id,orgSlug:a.slug,connectionId:i,owner:r,repo:o,prNumber:s.number},e[0]=i,e[1]=a.id,e[2]=a.slug,e[3]=r,e[4]=s.number,e[5]=o,e[6]=h):h=e[6];const c=ol(h);let d;e[7]!==l||e[8]!==s.number?(d=g=>l.sendMessage({parts:[{type:"text",text:Rf({prNumber:s.number,checkName:g})}]}),e[7]=l,e[8]=s.number,e[9]=d):d=e[9];const u=d;if(c.isLoading){let g;return e[10]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading checks…"}),e[10]=g):g=e[10],g}if(c.isError){let g;return e[11]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("div",{className:"text-sm text-destructive",children:"Couldn't load check runs."}),e[11]=g):g=e[11],g}let f;e[12]!==c.data?(f=c.data??[],e[12]=c.data,e[13]=f):f=e[13];const m=f;if(m.length===0){let g;return e[14]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("div",{className:"text-sm text-muted-foreground",children:"No check runs on the PR head commit."}),e[14]=g):g=e[14],g}let _;if(e[15]!==l||e[16]!==m||e[17]!==u){let g;e[19]!==l||e[20]!==u?(g=v=>n.jsxs("li",{className:"flex items-center justify-between gap-2 rounded px-2 py-1.5 text-sm hover:bg-muted",children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(Lf,{check:v}),n.jsx("span",{className:"truncate",children:v.name}),v.durationMs!=null&&n.jsx("span",{className:"text-xs text-muted-foreground",children:Of(v.durationMs)})]}),n.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[v.htmlUrl&&n.jsx("a",{href:v.htmlUrl,target:"_blank",rel:"noreferrer",className:"inline-flex h-7 items-center justify-center rounded px-2 text-xs text-muted-foreground hover:bg-background",title:"View run",children:n.jsx(gs,{className:"h-3.5 w-3.5"})}),v.conclusion==="failure"&&n.jsx(se,{size:"sm",variant:"ghost",disabled:l.isStreaming,onClick:()=>u(v.name),children:"Re-run"})]})]},v.id),e[19]=l,e[20]=u,e[21]=g):g=e[21],_=m.map(g),e[15]=l,e[16]=m,e[17]=u,e[18]=_}else _=e[18];let p;return e[22]!==_?(p=n.jsx("ul",{className:"flex flex-col gap-0.5",children:_}),e[22]=_,e[23]=p):p=e[23],p}function Lf(t){const e=z.c(5),{check:s}=t;if(s.status!=="completed"){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("span",{className:"text-muted-foreground","aria-label":"In progress",children:"○"}),e[0]=o):o=e[0],o}if(s.conclusion==="success"){let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("span",{className:"text-success","aria-label":"Success",children:"✓"}),e[1]=o):o=e[1],o}if(s.conclusion==="failure"){let o;return e[2]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("span",{className:"text-destructive","aria-label":"Failure",children:"✗"}),e[2]=o):o=e[2],o}const i=s.conclusion??"—";let r;return e[3]!==i?(r=n.jsx("span",{className:"text-muted-foreground","aria-label":i,children:"—"}),e[3]=i,e[4]=r):r=e[4],r}function Of(t){const e=Math.round(t/1e3);return e<60?`${e}s`:`${Math.round(e/60)}m`}function $f(t){const e=z.c(10),{comments:s,isLoading:i,isError:r}=t;if(i||r||!s||s.length===0)return null;const o=s.length===1?"":"s";let a;e[0]!==s.length||e[1]!==o?(a=n.jsxs(Ch,{className:"py-3 text-sm font-medium",children:[s.length," comment",o]}),e[0]=s.length,e[1]=o,e[2]=a):a=e[2];let l;e[3]!==s?(l=s.map(zf),e[3]=s,e[4]=l):l=e[4];let h;e[5]!==l?(h=n.jsx(kh,{className:"space-y-3 pb-3",children:l}),e[5]=l,e[6]=h):h=e[6];let c;return e[7]!==a||e[8]!==h?(c=n.jsx(Nh,{type:"single",collapsible:!0,className:"border-t border-border",children:n.jsxs(jh,{value:"comments",className:"border-b-0",children:[a,h]})}),e[7]=a,e[8]=h,e[9]=c):c=e[9],c}function zf(t){return n.jsxs("div",{className:"rounded-md border border-border p-3",children:[n.jsxs("div",{className:"mb-1 text-xs text-muted-foreground",children:["@",t.author," · ",Ff(t.createdAt)]}),n.jsx(mn,{id:`pr-comment-${t.id}`,text:Vs(t.body)})]},t.id)}function Ff(t){if(!t)return"";const e=new Date(t).getTime();if(!Number.isFinite(e))return"";const s=Date.now()-e;if(s<0)return"just now";const i=Math.floor(s/864e5);if(i>0)return`${i}d ago`;const r=Math.floor(s/36e5);if(r>0)return`${r}h ago`;const o=Math.floor(s/6e4);return`${Math.max(1,o)}m ago`}function Hf(t){const e=z.c(19),{pr:s,connectionId:i,owner:r,repo:o}=t,{org:a}=ge();let l;e[0]!==i||e[1]!==a.id||e[2]!==a.slug||e[3]!==r||e[4]!==s.number||e[5]!==o?(l={orgId:a.id,orgSlug:a.slug,connectionId:i,owner:r,repo:o,prNumber:s.number},e[0]=i,e[1]=a.id,e[2]=a.slug,e[3]=r,e[4]=s.number,e[5]=o,e[6]=l):l=e[6];const h=Sf(l);let c;e[7]!==s.body||e[8]!==s.number?(c=s.body&&n.jsx("div",{className:"text-sm",children:n.jsx(mn,{id:`pr-body-${s.number}`,text:Vs(s.body)})}),e[7]=s.body,e[8]=s.number,e[9]=c):c=e[9];let d;e[10]!==h.data?(d=h.data??[],e[10]=h.data,e[11]=d):d=e[11];let u;e[12]!==h.isError||e[13]!==h.isLoading||e[14]!==d?(u=n.jsx($f,{comments:d,isLoading:h.isLoading,isError:h.isError}),e[12]=h.isError,e[13]=h.isLoading,e[14]=d,e[15]=u):u=e[15];let f;return e[16]!==c||e[17]!==u?(f=n.jsxs("div",{className:"space-y-8",children:[c,u]}),e[16]=c,e[17]=u,e[18]=f):f=e[18],f}function Wf(t){const e=z.c(27),{pr:s,connectionId:i,owner:r,repo:o}=t,{org:a}=ge();let l;e[0]!==i||e[1]!==a.id||e[2]!==a.slug||e[3]!==r||e[4]!==s.number||e[5]!==o?(l={orgId:a.id,orgSlug:a.slug,connectionId:i,owner:r,repo:o,prNumber:s.number},e[0]=i,e[1]=a.id,e[2]=a.slug,e[3]=r,e[4]=s.number,e[5]=o,e[6]=l):l=e[6];const c=nl(l).data?.length,[d,u]=A.useState("description"),f=A.useRef({description:null,changes:null,checks:null}),[m,_]=A.useState(null),p=P=>R=>{if(f.current[P]=R,R&&P===d){const B=R.offsetLeft,I=R.offsetWidth;(m===null||B!==m.left||I!==m.width)&&_({left:B,width:I})}},g=P=>{const R=P;u(R);const B=f.current[R];B&&_({left:B.offsetLeft,width:B.offsetWidth})},v=Zi,x=p("checks");let b;e[7]!==v||e[8]!==x?(b=n.jsx(v,{ref:x,variant:"underline",value:"checks",className:"pb-3 data-[state=active]:border-transparent",children:"Checks"}),e[7]=v,e[8]=x,e[9]=b):b=e[9];let S;e[10]!==m?(S=m&&n.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute bottom-[-1px] h-0.5 bg-primary transition-[left,width] duration-200 ease-out",style:{left:m.left,width:m.width}}),e[10]=m,e[11]=S):S=e[11];let w;e[12]!==i||e[13]!==r||e[14]!==s||e[15]!==o?(w=n.jsx(Qi,{value:"description",className:"mt-6",children:n.jsx(Hf,{pr:s,connectionId:i,owner:r,repo:o})}),e[12]=i,e[13]=r,e[14]=s,e[15]=o,e[16]=w):w=e[16];let k;e[17]!==i||e[18]!==r||e[19]!==s||e[20]!==o?(k=n.jsx(Qi,{value:"changes",className:"mt-6",children:n.jsx(Cf,{pr:s,connectionId:i,owner:r,repo:o})}),e[17]=i,e[18]=r,e[19]=s,e[20]=o,e[21]=k):k=e[21];let E;return e[22]!==i||e[23]!==r||e[24]!==s||e[25]!==o?(E=n.jsx(Qi,{value:"checks",className:"mt-6",children:n.jsx(Bf,{pr:s,connectionId:i,owner:r,repo:o})}),e[22]=i,e[23]=r,e[24]=s,e[25]=o,e[26]=E):E=e[26],n.jsxs(qh,{value:d,onValueChange:g,variant:"underline",children:[n.jsxs(Gh,{variant:"underline",className:"relative h-auto p-0",children:[n.jsx(Zi,{ref:p("description"),variant:"underline",value:"description",className:"pb-3 data-[state=active]:border-transparent",children:"Description"}),n.jsxs(Zi,{ref:p("changes"),variant:"underline",value:"changes",className:"pb-3 data-[state=active]:border-transparent",children:["Changes",c!==void 0?` ${c}`:""]}),b,S]}),w,k,E]})}function Uf(t){const e=z.c(5),{pr:s}=t,i=`Open PR #${s.number} on GitHub`;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(gs,{className:"h-4 w-4 text-muted-foreground"}),e[0]=r):r=e[0];let o;return e[1]!==s.htmlUrl||e[2]!==s.number||e[3]!==i?(o=n.jsx("div",{className:"flex h-12 items-center border-b border-border px-4 shrink-0",children:n.jsxs("a",{href:s.htmlUrl,target:"_blank",rel:"noreferrer","aria-label":i,className:"inline-flex items-center gap-1.5 text-base font-medium text-foreground hover:underline",children:["PR #",s.number,r]})}),e[1]=s.htmlUrl,e[2]=s.number,e[3]=i,e[4]=o):o=e[4],o}function Vf(t){const e=z.c(23),{pr:s}=t;let i;e[0]!==s.title?(i=Vs(s.title),e[0]=s.title,e[1]=i):i=e[1];let r;e[2]!==i?(r=n.jsx("h1",{className:"text-2xl font-semibold",children:i}),e[2]=i,e[3]=r):r=e[3];const o=`Open PR #${s.number} on GitHub`;let a;e[4]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(gs,{className:"h-3.5 w-3.5"}),e[4]=a):a=e[4];let l;e[5]!==s.htmlUrl||e[6]!==s.number||e[7]!==o?(l=n.jsxs("a",{href:s.htmlUrl,target:"_blank",rel:"noreferrer","aria-label":o,className:"inline-flex items-center gap-1 hover:text-foreground",children:["PR #",s.number,a]}),e[5]=s.htmlUrl,e[6]=s.number,e[7]=o,e[8]=l):l=e[8];let h;e[9]!==s.author?(h=s.author&&n.jsxs(n.Fragment,{children:["@",s.author," · "]}),e[9]=s.author,e[10]=h):h=e[10];let c;e[11]!==s.base?(c=n.jsx("span",{className:"font-mono text-xs",children:s.base}),e[11]=s.base,e[12]=c):c=e[12];let d;e[13]!==s.head?(d=n.jsx("span",{className:"font-mono text-xs",children:s.head}),e[13]=s.head,e[14]=d):d=e[14];let u;e[15]!==l||e[16]!==h||e[17]!==c||e[18]!==d?(u=n.jsxs("div",{className:"text-sm text-muted-foreground",children:[l," · ",h,c," ← ",d]}),e[15]=l,e[16]=h,e[17]=c,e[18]=d,e[19]=u):u=e[19];let f;return e[20]!==r||e[21]!==u?(f=n.jsxs("div",{className:"space-y-2",children:[r,u]}),e[20]=r,e[21]=u,e[22]=f):f=e[22],f}function Kf(t){const e=z.c(9),{virtualMcpId:s}=t,{org:i}=ge(),r=Pt(s),{currentBranch:o}=Ht(),a=r?.metadata?.githubRepo??null;if(!a?.connectionId){let h;return e[0]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx("div",{className:"flex h-full items-center justify-center p-8 text-sm text-muted-foreground",children:"This virtualmcp is not linked to a GitHub repository."}),e[0]=h):h=e[0],h}if(!o){let h;return e[1]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-8 text-sm",children:[n.jsx(Ls,{className:"h-6 w-6 text-muted-foreground"}),n.jsx("div",{className:"text-muted-foreground",children:"No branch selected."}),n.jsx("div",{className:"text-xs text-muted-foreground",children:"Pick a branch from the dropdown in the header to see PR status."})]}),e[1]=h):h=e[1],h}let l;return e[2]!==o||e[3]!==a.connectionId||e[4]!==a.name||e[5]!==a.owner||e[6]!==i.id||e[7]!==i.slug?(l=n.jsx(qf,{orgId:i.id,orgSlug:i.slug,connectionId:a.connectionId,owner:a.owner,repo:a.name,branch:o}),e[2]=o,e[3]=a.connectionId,e[4]=a.name,e[5]=a.owner,e[6]=i.id,e[7]=i.slug,e[8]=l):l=e[8],l}function qf(t){const e=z.c(50),{orgId:s,orgSlug:i,connectionId:r,owner:o,repo:a,branch:l}=t;let h;e[0]!==l||e[1]!==r||e[2]!==s||e[3]!==i||e[4]!==o||e[5]!==a?(h={orgId:s,orgSlug:i,connectionId:r,owner:o,repo:a,branch:l},e[0]=l,e[1]=r,e[2]=s,e[3]=i,e[4]=o,e[5]=a,e[6]=h):h=e[6];const{data:c,isLoading:d,isError:u}=rl(h),f=Gf;if(d){let x;return e[7]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading PR state…"}),e[7]=x):x=e[7],x}if(u){let x;return e[8]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx("div",{className:"p-4 text-sm text-destructive",children:"Couldn't load PR state. The GitHub connection may be broken."}),e[8]=x):x=e[8],x}const m=`https://github.com/${o}/${a}/tree/${l}`;if(c&&c.state==="closed"){let x;e[9]!==c?(x=n.jsx(Uf,{pr:c}),e[9]=c,e[10]=x):x=e[10];const b=c.merged?"✓ Merged":"✗ Closed";let S;e[11]!==c.mergedAt?(S=c.mergedAt&&n.jsxs(n.Fragment,{children:[" · ",new Date(c.mergedAt).toLocaleDateString()]}),e[11]=c.mergedAt,e[12]=S):S=e[12];let w;e[13]!==c.author?(w=c.author&&n.jsxs(n.Fragment,{children:[" · by @",c.author]}),e[13]=c.author,e[14]=w):w=e[14];let k;e[15]!==c.base||e[16]!==b||e[17]!==S||e[18]!==w?(k=n.jsxs("div",{className:"text-sm text-success",children:[b," into ",c.base,S,w]}),e[15]=c.base,e[16]=b,e[17]=S,e[18]=w,e[19]=k):k=e[19];let E;e[20]!==c.title?(E=Vs(c.title),e[20]=c.title,e[21]=E):E=e[21];let P;e[22]!==E?(P=n.jsx("h1",{className:"text-lg font-semibold",children:E}),e[22]=E,e[23]=P):P=e[23];let R;e[24]!==c.body||e[25]!==c.number?(R=c.body&&n.jsx("div",{className:"rounded-md border border-border bg-muted/30 p-3 text-sm",children:n.jsx(mn,{id:`pr-body-${c.number}`,text:Vs(c.body)})}),e[24]=c.body,e[25]=c.number,e[26]=R):R=e[26];let B;e[27]!==k||e[28]!==P||e[29]!==R?(B=n.jsxs("div",{className:"flex flex-col gap-4 p-4 overflow-auto",children:[k,P,R]}),e[27]=k,e[28]=P,e[29]=R,e[30]=B):B=e[30];let I;return e[31]!==x||e[32]!==B?(I=n.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[x,B]}),e[31]=x,e[32]=B,e[33]=I):I=e[33],I}if(c&&c.state==="open"){let x;e[34]!==c?(x=n.jsx(Vf,{pr:c}),e[34]=c,e[35]=x):x=e[35];let b;e[36]!==r||e[37]!==o||e[38]!==c||e[39]!==a?(b=n.jsx("div",{className:"mt-8",children:n.jsx(Wf,{pr:c,connectionId:r,owner:o,repo:a})}),e[36]=r,e[37]=o,e[38]=c,e[39]=a,e[40]=b):b=e[40];let S;return e[41]!==x||e[42]!==b?(S=n.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:n.jsx("div",{className:"flex-1 overflow-auto",children:n.jsxs("div",{className:"mx-auto w-full max-w-[1200px] px-4 pt-8 pb-6 md:px-10 md:pt-12 md:pb-10",children:[x,b]})})}),e[41]=x,e[42]=b,e[43]=S):S=e[43],S}let _;e[44]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx("div",{className:"rounded-md border border-border bg-muted/30 p-4 text-sm",children:`This branch doesn't have an open pull request. Click "Submit for review" in the header to open one; the agent will draft the title and summary from the current state of the branch.`}),e[44]=_):_=e[44];let p;e[45]!==m?(p=()=>f(m),e[45]=m,e[46]=p):p=e[46];let g;e[47]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(gs,{className:"mr-1.5 h-4 w-4"}),e[47]=g):g=e[47];let v;return e[48]!==p?(v=n.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[_,n.jsx("div",{className:"flex items-center gap-2",children:n.jsxs(se,{size:"sm",variant:"outline",onClick:p,children:[g,"Open branch on GitHub"]})})]}),e[48]=p,e[49]=v):v=e[49],v}function Gf(t){window.open(t,"_blank","noopener,noreferrer")}function Yf(t){const e=z.c(8),s=t?`${t.orgSlug}/${t.virtualMcpId}/${t.branch}`:"";let i;e[0]!==s?(i=us.decofile(s),e[0]=s,e[1]=i):i=e[1];let r;e[2]!==t?(r=async()=>{const l=new URLSearchParams({path:"/.decofile"}),h=await fetch(`/api/${t.orgSlug}/vm/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/preview-fetch?${l.toString()}`);if(!h.ok)throw new Error(`Failed to fetch decofile: ${h.status}`);return await h.json()},e[2]=t,e[3]=r):r=e[3];const o=!!t;let a;return e[4]!==i||e[5]!==r||e[6]!==o?(a={queryKey:i,queryFn:r,enabled:o,staleTime:3e4},e[4]=i,e[5]=r,e[6]=o,e[7]=a):a=e[7],ga(a)}function Xf(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 Jf=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function Zf(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"&&Jf.has(r.__resolveType)&&typeof r.path=="string"&&e.push({key:s,name:typeof r.name=="string"?r.name:Xf(s),path:r.path})}return e}const Qf=gi({tag:ut(),id:ut(),classes:ut(),text:ut(),html:ut(),manifestKey:ut().nullable(),componentName:ut().nullable(),parents:ut(),url:ut(),path:ut(),viewport:gi({width:Ds(),height:Ds()}),position:gi({x:Ds(),y:Ds()})}),em=`(function() {
|
|
32
32
|
if (window.__visualEditorActive) return;
|
|
33
33
|
window.__visualEditorActive = true;
|
|
34
34
|
|
|
@@ -150,9 +150,110 @@ ${K}`:K;l.setValue("metadata.instructions",Q,{shouldDirty:!0})},V=new Set(h.map(
|
|
|
150
150
|
window.__visualEditorActive = false;
|
|
151
151
|
}
|
|
152
152
|
});
|
|
153
|
-
})()
|
|
154
|
-
|
|
155
|
-
|
|
153
|
+
})();`,tm=gi({sectionIndex:Ds(),manifestKey:ut()}),sm=`(function() {
|
|
154
|
+
if (window.__cmsEditorActive) return;
|
|
155
|
+
window.__cmsEditorActive = true;
|
|
156
|
+
|
|
157
|
+
var highlight = document.createElement("div");
|
|
158
|
+
highlight.style.cssText = "position:fixed;pointer-events:none;outline:2px solid #06b6d4;background:rgba(6,182,212,0.06);border-radius:2px;z-index:2147483647;display:none;";
|
|
159
|
+
document.body.appendChild(highlight);
|
|
160
|
+
|
|
161
|
+
var badge = document.createElement("div");
|
|
162
|
+
badge.style.cssText = "position:fixed;pointer-events:none;background:#06b6d4;color:white;font:11px/1 monospace;padding:2px 6px;border-radius:2px;z-index:2147483647;display:none;white-space:nowrap;max-width:240px;overflow:hidden;text-overflow:ellipsis;";
|
|
163
|
+
document.body.appendChild(badge);
|
|
164
|
+
|
|
165
|
+
var findSection = function(el) {
|
|
166
|
+
var node = el;
|
|
167
|
+
while (node && node !== document.body) {
|
|
168
|
+
if (node.hasAttribute && node.hasAttribute("data-manifest-key")) return node;
|
|
169
|
+
node = node.parentElement;
|
|
170
|
+
}
|
|
171
|
+
return null;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
var getAllSections = function() {
|
|
175
|
+
return Array.from(document.querySelectorAll("[data-manifest-key]"));
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
var lastSection = null;
|
|
179
|
+
var rafPending = false;
|
|
180
|
+
|
|
181
|
+
var moveHandler = function(e) {
|
|
182
|
+
if (rafPending) return;
|
|
183
|
+
rafPending = true;
|
|
184
|
+
var target = e.target;
|
|
185
|
+
requestAnimationFrame(function() {
|
|
186
|
+
rafPending = false;
|
|
187
|
+
if (!target || target === highlight || target === badge) return;
|
|
188
|
+
var section = findSection(target);
|
|
189
|
+
if (section === lastSection) return;
|
|
190
|
+
lastSection = section;
|
|
191
|
+
if (!section) {
|
|
192
|
+
highlight.style.display = "none";
|
|
193
|
+
badge.style.display = "none";
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
var r = section.getBoundingClientRect();
|
|
197
|
+
highlight.style.display = "block";
|
|
198
|
+
highlight.style.top = r.top + "px";
|
|
199
|
+
highlight.style.left = r.left + "px";
|
|
200
|
+
highlight.style.width = r.width + "px";
|
|
201
|
+
highlight.style.height = r.height + "px";
|
|
202
|
+
badge.textContent = section.getAttribute("data-manifest-key") || "section";
|
|
203
|
+
badge.style.display = "block";
|
|
204
|
+
badge.style.top = Math.max(0, r.top - 20) + "px";
|
|
205
|
+
badge.style.left = r.left + "px";
|
|
206
|
+
});
|
|
207
|
+
};
|
|
208
|
+
document.addEventListener("mousemove", moveHandler, true);
|
|
209
|
+
|
|
210
|
+
var outHandler = function(e) {
|
|
211
|
+
if (!e.relatedTarget || e.relatedTarget === document.documentElement) {
|
|
212
|
+
highlight.style.display = "none";
|
|
213
|
+
badge.style.display = "none";
|
|
214
|
+
lastSection = null;
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
document.addEventListener("mouseout", outHandler, true);
|
|
218
|
+
|
|
219
|
+
var clickHandler = function(e) {
|
|
220
|
+
e.preventDefault();
|
|
221
|
+
e.stopImmediatePropagation();
|
|
222
|
+
var target = e.target;
|
|
223
|
+
if (!target || target === highlight || target === badge) return;
|
|
224
|
+
var section = findSection(target);
|
|
225
|
+
if (!section) return;
|
|
226
|
+
|
|
227
|
+
var sections = getAllSections();
|
|
228
|
+
var sectionIndex = sections.indexOf(section);
|
|
229
|
+
var manifestKey = section.getAttribute("data-manifest-key") || "";
|
|
230
|
+
|
|
231
|
+
highlight.style.outline = "2px solid #06b6d4";
|
|
232
|
+
highlight.style.background = "rgba(6,182,212,0.18)";
|
|
233
|
+
setTimeout(function() {
|
|
234
|
+
highlight.style.background = "rgba(6,182,212,0.06)";
|
|
235
|
+
}, 400);
|
|
236
|
+
|
|
237
|
+
window.parent.postMessage({
|
|
238
|
+
type: "cms-editor::section-clicked",
|
|
239
|
+
payload: { sectionIndex: sectionIndex, manifestKey: manifestKey }
|
|
240
|
+
}, "*");
|
|
241
|
+
};
|
|
242
|
+
document.addEventListener("click", clickHandler, true);
|
|
243
|
+
|
|
244
|
+
window.addEventListener("message", function(e) {
|
|
245
|
+
if (e.data && e.data.type === "cms-editor::deactivate") {
|
|
246
|
+
highlight.remove();
|
|
247
|
+
badge.remove();
|
|
248
|
+
document.removeEventListener("mousemove", moveHandler, true);
|
|
249
|
+
document.removeEventListener("mouseout", outHandler, true);
|
|
250
|
+
document.removeEventListener("click", clickHandler, true);
|
|
251
|
+
window.__cmsEditorActive = false;
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
})();`;function as(t){return t.replace(/[`*_]/g,"\\$&")}function im(t,e){const s=[`The user selected an element on the live preview and asked: **"${as(e.trim())}"**`,"","For text content changes, locate the correct source file and apply the change.","For code and CSS changes, understand which component the user is referring to and apply changes to the correct component.",""];t.manifestKey&&s.push(`**Section source file:** \`${as(t.manifestKey)}\``,"");const i=`<${t.tag}${t.classes?` class="${as(t.classes)}"`:""}>`;s.push(`**Clicked element:** \`${i}\``),t.parents&&s.push(`**DOM breadcrumb:** ${as(t.parents)} > ${t.tag}`),t.text&&s.push(`**Text content:** "${as(t.text)}"`),t.componentName&&s.push(`**Component name:** ${as(t.componentName)}`);const r=t.html.replace(/```/g,"`` `");return s.push("","**HTML snippet:**","```html",r,"```"),s.push("","Please read the source file, locate the element, and apply the requested change."),s.join(`
|
|
255
|
+
`)}function rm(t,e,s=320,i=44,r=12){const{x:o,y:a}=t,{width:l,height:h}=e,c=Math.max(r,Math.min(o-s/2,l-s-r)),u=a/h>.68?Math.max(r,a-i-18):Math.min(a+18,h-i-r);return{leftPct:c/l*100,topPct:u/h*100}}function nm(t){const e=z.c(32),{element:s,onDismiss:i}=t,[r,o]=A.useState(""),a=A.useRef(null),{sendMessage:l}=rs(),{setChatOpen:h}=Sn();let c;e[0]!==s||e[1]!==r||e[2]!==i||e[3]!==l||e[4]!==h?(c=()=>{if(!r.trim())return;const B=im(s,r);h(!0),l({parts:[{type:"text",text:B}]}),i()},e[0]=s,e[1]=r,e[2]=i,e[3]=l,e[4]=h,e[5]=c):c=e[5];const d=c;let u;e[6]!==s.position||e[7]!==s.viewport?(u=rm(s.position,s.viewport),e[6]=s.position,e[7]=s.viewport,e[8]=u):u=e[8];const f=u,m=`${f.leftPct}%`,_=`${f.topPct}%`;let p;e[9]!==m||e[10]!==_?(p={left:m,top:_,width:"320px"},e[9]=m,e[10]=_,e[11]=p):p=e[11];let g;e[12]!==d?(g=B=>{B.preventDefault(),d()},e[12]=d,e[13]=g):g=e[13];let v;e[14]===Symbol.for("react.memo_cache_sentinel")?(v=B=>o(B.target.value),e[14]=v):v=e[14];let x;e[15]!==i?(x=B=>{B.key==="Escape"&&i()},e[15]=i,e[16]=x):x=e[16];let b;e[17]!==r||e[18]!==x?(b=n.jsx("input",{ref:a,autoFocus:!0,type:"text",value:r,onChange:v,onKeyDown:x,placeholder:"Ask the AI...",className:"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"}),e[17]=r,e[18]=x,e[19]=b):b=e[19];let S;e[20]!==r?(S=r.trim(),e[20]=r,e[21]=S):S=e[21];const w=!S;let k;e[22]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none","aria-hidden":"true",children:[n.jsx("title",{children:"Send"}),n.jsx("path",{d:"M5 9V1M1 5l4-4 4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),e[22]=k):k=e[22];let E;e[23]!==w?(E=n.jsx("button",{type:"submit",disabled:w,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-foreground text-background transition-opacity disabled:opacity-30",title:"Send",children:k}),e[23]=w,e[24]=E):E=e[24];let P;e[25]!==E||e[26]!==g||e[27]!==b?(P=n.jsxs("form",{className:"pointer-events-auto flex w-full items-center gap-1.5 rounded-xl border border-border bg-background/95 px-3 py-1.5 shadow-lg backdrop-blur",onSubmit:g,children:[b,E]}),e[25]=E,e[26]=g,e[27]=b,e[28]=P):P=e[28];let R;return e[29]!==P||e[30]!==p?(R=n.jsx("div",{className:"absolute z-30 pointer-events-none",style:p,children:P}),e[29]=P,e[30]=p,e[31]=R):R=e[31],R}const om={phase:null,lifecycle:{phase:"idle"},status:{state:"running"},branch:{kind:"unknown"},suspended:!1,notFound:!1,scripts:[],activeProcesses:[],getBuffer:()=>"",hasData:()=>!1,subscribeChunks:()=>()=>{},subscribeReload:()=>()=>{}},al=A.createContext(om),co=16384;class am{data="";append(e){this.data+=e,this.data.length>co&&(this.data=this.data.slice(this.data.length-co))}get(){return this.data}clear(){this.data=""}}const lm=6e4,cm=1e3,hm=3e4,dm=["lifecycle","status","tasks","scripts","branch","reload"],um="log";function fm({virtualMcpId:t,branch:e,children:s}){const{org:i}=ge(),[r,o]=A.useState(null),[a,l]=A.useState({phase:"idle"}),[h,c]=A.useState({state:"running"}),[d,u]=A.useState({kind:"unknown"}),[f,m]=A.useState(!1),[_,p]=A.useState(!1),[g,v]=A.useState([]),[x,b]=A.useState([]),[,S]=A.useState(0),w=A.useRef(new Map),k=A.useRef(new Set),E=A.useRef(new Set),P=A.useRef(null),R=I=>{let T=w.current.get(I);return T||(T=new am,w.current.set(I,T)),T};A.useEffect(()=>{if(o(null),l({phase:"idle"}),c({state:"running"}),u({kind:"unknown"}),P.current=null,m(!1),p(!1),v([]),b([]),w.current.clear(),!t||!e)return;const I=`/api/${encodeURIComponent(i.slug)}/vm/${encodeURIComponent(t)}/${encodeURIComponent(e)}/events`;let T=!1,y=0,N=null,C=null,j=null,M=!1;const D=()=>{C||(C=setTimeout(()=>{m(!0)},lm))},F=()=>{C&&(clearTimeout(C),C=null)},H=Z=>{try{const J=JSON.parse(Z.data);o(J),J.kind!=="failed"&&p(!1),J.kind==="failed"&&(M=!0,j?.close())}catch(J){console.warn("[vm-events] bad phase payload",J)}},O=()=>{p(!0),o(null),l({phase:"idle"}),c({state:"running"}),u({kind:"unknown"}),v([]),b([]),w.current.clear()},$=Z=>{try{const J=JSON.parse(Z.data);if(typeof J.data!="string")return;const X=J.data.replace(/\r?\n/g,`\r
|
|
256
|
+
`);R(J.source).append(X);for(const L of k.current)try{L(J.source,X)}catch{}S(L=>L+1)}catch{}},W=Z=>{const J=Z.type;try{const X=JSON.parse(Z.data);switch(J){case"lifecycle":{const L=X;l(L.state);const q=L.state.phase==="running"?L.state.port:null,Q=P.current;if(P.current=q,Q!==null&&q!==null&&Q!==q)for(const Y of E.current)try{Y()}catch{}return}case"status":c(X);return;case"tasks":{const q=X.active.map(Q=>Q.logName??"").filter(Boolean);b(q);return}case"scripts":v(X.scripts);return;case"branch":u(X.meta);return;case"reload":for(const L of E.current)try{L()}catch{}return}}catch{}};function K(){if(!(T||M)){j=new EventSource(I),j.onopen=()=>{y=0,F(),m(!1)},j.onerror=()=>{j?.readyState===EventSource.CLOSED&&(M||(D(),re()))},j.addEventListener("phase",H),j.addEventListener("gone",O),j.addEventListener(um,$);for(const Z of dm)j.addEventListener(Z,W)}}function re(){if(T||N||M)return;const Z=Math.min(cm*2**y,hm);y++,N=setTimeout(()=>{N=null,!T&&(j?.close(),K())},Z)}return K(),()=>{T=!0,j?.close(),N&&clearTimeout(N),F()}},[t,e,i.slug]);const B={phase:r,lifecycle:a,status:h,branch:d,suspended:f,notFound:_,scripts:g,activeProcesses:x,getBuffer:I=>w.current.get(I)?.get()??"",hasData:I=>(w.current.get(I)?.get().length??0)>0,subscribeChunks:I=>(k.current.add(I),()=>{k.current.delete(I)}),subscribeReload:I=>(E.current.add(I),()=>{E.current.delete(I)})};return n.jsx(al,{value:B,children:s})}function xs(){return A.use(al)}function mm(t){const{subscribeChunks:e}=xs(),s=A.useRef(t);s.current=t,A.useEffect(()=>e((o,a)=>{s.current?.(o,a)}),[e])}function _m(t){const{subscribeReload:e}=xs(),s=A.useRef(t);s.current=t,A.useEffect(()=>e(()=>{s.current?.()}),[e])}function pm(t){return t.lastStartError?{kind:"errored",error:t.lastStartError}:t.suspended||t.appPaused?{kind:"suspended"}:t.userStopped?{kind:"never-started"}:t.notFound?{kind:"starting-now"}:!t.previewUrl&&t.vmStartPending?{kind:"starting-now"}:!t.previewUrl&&t.claimPhase&&t.claimPhase.kind!=="failed"?{kind:"starting-now"}:t.previewUrl?t.status==="online"||t.status==="offline"?t.htmlSupport?{kind:"iframe",previewUrl:t.previewUrl}:t.status==="offline"?{kind:"crashed",previewUrl:t.previewUrl}:{kind:"no-html",previewUrl:t.previewUrl}:{kind:"starting-now"}:{kind:"never-started"}}const ll={claiming:{long:"Reserving sandbox",short:"Reserving sandbox"},"waiting-for-capacity":{long:"Waiting for cluster capacity",short:"Waiting for capacity"},"pulling-image":{long:"Downloading sandbox image",short:"Downloading image"},"starting-container":{long:"Starting your sandbox",short:"Starting container"},"warming-daemon":{long:"Connecting to your sandbox",short:"Connecting to sandbox"}},Cr=["provision","cloning","install","dev"];function gm(t){switch(t.lifecycle.phase){case"cloning":case"checking-out":return{step:"cloning",status:"doing"};case"clone-failed":return{step:"cloning",status:"failed"};case"installing":return{step:"install",status:"doing"};case"install-failed":return{step:"install",status:"failed"};case"starting":return{step:"dev",status:"doing"};case"running":return{step:"dev",status:"done"};case"start-failed":return{step:"dev",status:"failed"};case"crashed":return{step:"dev",status:"failed"};case"idle":return t.claimPhase&&t.claimPhase.kind!=="ready"&&t.claimPhase.kind!=="failed"?{step:"provision",status:"doing"}:{step:"cloning",status:"doing"}}}function vm(t){switch(t){case"done":return"✓";case"failed":return"✗";case"doing":return"◐";case"pending":return"○"}}function xm(t){switch(t){case"never-started":return"Your sandbox is not running";case"starting-now":return"Starting your sandbox";case"errored":return"Sandbox failed to start";case"suspended":return"Sandbox is paused";case"crashed":return"Preview is unavailable"}}function li(t,e){const s=Cr.indexOf(t.step),i=Cr.indexOf(e);return i<s?"done":i>s?"pending":t.status}function bm(t){return Cr.indexOf(t.step)}const ho=48,cl=28,hl=3,Sm=(()=>{const t=[];let e=0;for(let s=0;s<ho;s++)s===cl?t.push(null):(t.push(e/(ho-1)*hl),e++);return t})(),ym={provision:"Reserving sandbox",cloning:"Cloning your repo",install:"Installing packages",dev:"Starting your preview"};function wm(t,e){return t.step==="provision"&&e!=null&&e.kind!=="ready"&&e.kind!=="failed"?ll[e.kind].long:ym[t.step]}const St="bg-foreground/[0.05]",ct="bg-foreground/[0.09]",Cm=Array.from({length:35},()=>Math.random()*1.8),km=Array.from({length:35},()=>Math.random()<.4);function Nm(t){const e=z.c(30),{progress:s,claimPhase:i}=t;let r;e[0]!==s?(r=bm(s),e[0]=s,e[1]=r):r=e[1];const o=r;let a;e[2]!==i||e[3]!==s?(a=wm(s,i),e[2]=i,e[3]=s,e[4]=a):a=e[4];const l=a;let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Gc,{}),e[5]=h):h=e[5];const c=`${s.step}-${l}`;let d;e[6]!==l||e[7]!==c?(d=n.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-foreground/10 bg-background px-3.5 py-1.5 shadow-[0_4px_20px_-4px_rgb(0_0_0_/_0.12)]",children:[h,n.jsxs("span",{className:"animate-in fade-in text-[13px] font-medium text-foreground/85 duration-500",children:[l,"…"]},c)]}),e[6]=l,e[7]=c,e[8]=d):d=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(jm,{}),e[9]=u):u=e[9];let f;e[10]!==o?(f=n.jsx(ci,{phase:0,current:o,children:u}),e[10]=o,e[11]=f):f=e[11];let m;e[12]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(Tm,{}),e[12]=m):m=e[12];let _;e[13]!==o?(_=n.jsx(ci,{phase:1,current:o,children:m}),e[13]=o,e[14]=_):_=e[14];let p;e[15]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(Rm,{}),e[15]=p):p=e[15];let g;e[16]!==o?(g=n.jsx(ci,{phase:2,current:o,children:p}),e[16]=o,e[17]=g):g=e[17];let v;e[18]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(Pm,{}),e[18]=v):v=e[18];let x;e[19]!==o?(x=n.jsx(ci,{phase:3,current:o,children:v}),e[19]=o,e[20]=x):x=e[20];let b;e[21]!==g||e[22]!==x||e[23]!==f||e[24]!==_?(b=n.jsxs("div",{className:"relative aspect-[4/3] w-[min(78%,560px)]",children:[f,_,g,x]}),e[21]=g,e[22]=x,e[23]=f,e[24]=_,e[25]=b):b=e[25];let S;e[26]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx("style",{children:`
|
|
156
257
|
@keyframes vm-pulse-soft {
|
|
157
258
|
0%, 100% { opacity: 0.25; }
|
|
158
259
|
50% { opacity: 1; }
|
|
@@ -166,21 +267,21 @@ ${K}`:K;l.setValue("metadata.instructions",Q,{shouldDirty:!0})},V=new Set(h.map(
|
|
|
166
267
|
8% { opacity: 1; }
|
|
167
268
|
22% { opacity: 0; }
|
|
168
269
|
}
|
|
169
|
-
`}),e[26]=S):S=e[26];let w;return e[27]!==b||e[28]!==d?(w=n.jsxs("div",{className:"relative flex w-full flex-col items-center justify-center gap-12 select-none [clip-path:inset(-24px_0_-200px_0)]",children:[d,b,S]}),e[27]=b,e[28]=d,e[29]=w):w=e[29],w}function ci(t){const e=z.c(10),{phase:s,current:i,children:r}=t,o=s-i,a=o<0,l=o===0,h=a?90:o*-22,c=a?.94:1-Math.max(o,0)*.04,d=a?0:l?1:o===1?.8:.55,u=a?10:30-o,f=!l;let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=te("absolute inset-0 overflow-hidden rounded-xl border border-foreground/10 bg-background shadow-[0_20px_60px_-20px_rgb(0_0_0_/_0.35)] transition-all ease-[cubic-bezier(0.22,1,0.36,1)]"),e[0]=m):m=e[0];const _=`translateY(${h}px) scale(${c})`,p=l?"auto":"none";let g;e[1]!==d||e[2]!==_||e[3]!==p||e[4]!==u?(g={transform:_,opacity:d,zIndex:u,transitionDuration:"1000ms",pointerEvents:p},e[1]=d,e[2]=_,e[3]=p,e[4]=u,e[5]=g):g=e[5];let v;return e[6]!==r||e[7]!==f||e[8]!==g?(v=n.jsx("div",{"aria-hidden":f,className:m,style:g,children:r}),e[6]=r,e[7]=f,e[8]=g,e[9]=v):v=e[9],v}function Ui(t){const e=z.c(7),{showUrl:s}=t,i=s===void 0?!1:s;let r,o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("div",{className:te("size-2.5 rounded-full",lt)}),o=n.jsx("div",{className:te("size-2.5 rounded-full",lt)}),a=n.jsx("div",{className:te("size-2.5 rounded-full",lt)}),e[0]=r,e[1]=o,e[2]=a):(r=e[0],o=e[1],a=e[2]);let l;e[3]!==i?(l=i&&n.jsx("div",{className:te("ml-3 h-3.5 max-w-[220px] flex-1 rounded-sm",St)}),e[3]=i,e[4]=l):l=e[4];let h;return e[5]!==l?(h=n.jsxs("div",{className:"flex h-7 shrink-0 items-center gap-1.5 px-3",children:[r,o,a,l]}),e[5]=l,e[6]=h):h=e[6],h}function _m(){const t=z.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(Ui,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsxs("div",{className:"flex h-full flex-col",children:[e,n.jsx("div",{className:"flex flex-1 px-8 py-5",children:n.jsx("div",{className:"grid h-full w-full grid-cols-8 grid-rows-6 gap-2",children:cm.map(pm)})})]}),t[1]=s):s=t[1],s}function pm(t,e){if(e===il)return n.jsx("div",{className:"rounded-md bg-chart-1/[0.55]",style:{animation:"vm-breathe 2.4s ease-in-out infinite"}},e);const s=t;return n.jsx("div",{className:te("relative rounded-md",lt),children:n.jsx("div",{className:"absolute inset-0 rounded-md bg-chart-1/40 opacity-0",style:{animation:`vm-rack-scan ${rl}s ease-in-out infinite`,animationDelay:`${s}s`}})},e)}function gm(){const t=z.c(5);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(Ui,{}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("div",{className:te("w-[18%] rounded-md",St),style:{animation:"vm-breathe 3s ease-in-out infinite"}}),t[1]=s):s=t[1];let i;t[2]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"h-[42%] shrink-0 rounded-md bg-chart-3/[0.12]",style:{animation:"vm-breathe 3s ease-in-out 0.4s infinite"}}),t[2]=i):i=t[2];let r;t[3]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("div",{className:"col-span-3 rounded-md bg-chart-3/[0.12]",style:{animation:"vm-breathe 3s ease-in-out 0.8s infinite"}}),t[3]=r):r=t[3];let o;return t[4]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsxs("div",{className:"flex h-full flex-col",children:[e,n.jsxs("div",{className:"flex min-h-0 flex-1 gap-1.5 p-3",children:[s,n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[i,n.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-5 gap-1.5",children:[r,n.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-1.5",children:[n.jsx("div",{className:te("rounded-md",St),style:{animation:"vm-breathe 3s ease-in-out 1.2s infinite"}}),n.jsx("div",{className:te("rounded-md",St),style:{animation:"vm-breathe 3s ease-in-out 1.6s infinite"}})]})]})]})]})]}),t[4]=o):o=t[4],o}function vm(){const t=z.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(Ui,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsxs("div",{className:"flex h-full flex-col",children:[e,n.jsx("div",{className:"relative flex flex-1 items-center justify-center px-8 py-5",children:n.jsx("div",{className:"grid w-full gap-2",style:{gridTemplateColumns:"repeat(7, minmax(0, 1fr))"},children:um.map(xm)})})]}),t[1]=s):s=t[1],s}function xm(t,e){return n.jsx("div",{className:te("aspect-square rounded-md",fm[e]?"bg-chart-2/70":lt),style:{animation:`vm-pulse-soft 2.2s ease-in-out ${t}s infinite`}},e)}function bm(){const t=z.c(11);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(Ui,{showUrl:!0}),t[0]=e):e=t[0];let s,i,r,o,a;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("div",{className:"mb-2 h-5 rounded-md bg-chart-1/[0.10]"}),i=n.jsx("div",{className:te("h-1.5 w-[70%] rounded-sm",lt)}),r=n.jsx("div",{className:te("h-1.5 w-[55%] rounded-sm",lt)}),o=n.jsx("div",{className:te("h-1.5 w-[80%] rounded-sm",lt)}),a=n.jsx("div",{className:te("h-1.5 w-[50%] rounded-sm",lt)}),t[1]=s,t[2]=i,t[3]=r,t[4]=o,t[5]=a):(s=t[1],i=t[2],r=t[3],o=t[4],a=t[5]);let l;t[6]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsxs("div",{className:"flex w-[18%] shrink-0 flex-col gap-1.5 bg-chart-1/[0.05] p-2.5",children:[s,i,r,o,a,n.jsx("div",{className:"mt-auto",children:n.jsx("div",{className:te("h-4 rounded-md",lt)})})]}),t[6]=l):l=t[6];let h;t[7]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx("div",{className:"relative h-[42%] shrink-0 overflow-hidden bg-chart-1/[0.10]",children:n.jsxs("div",{className:"absolute right-3 bottom-3 left-3 space-y-1.5",children:[n.jsx("div",{className:"h-3 w-[35%] rounded-sm bg-chart-1/[0.15]"}),n.jsx("div",{className:te("h-1.5 w-[55%] rounded-sm",St)})]})}),t[7]=h):h=t[7];let c;t[8]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsxs("div",{className:"flex shrink-0 gap-1.5",children:[n.jsx("div",{className:"h-4 w-12 rounded-full bg-chart-1/[0.12]"}),n.jsx("div",{className:te("h-4 w-10 rounded-full",St)}),n.jsx("div",{className:te("h-4 w-14 rounded-full",St)})]}),t[8]=c):c=t[8];let d;t[9]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsxs("div",{className:te("col-span-3 flex flex-col justify-end gap-1 rounded-md p-2",St),children:[n.jsx("div",{className:te("h-1.5 w-[50%] rounded-sm",lt)}),n.jsx("div",{className:te("h-1 w-[75%] rounded-sm",lt)})]}),t[9]=d):d=t[9];let u;return t[10]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsxs("div",{className:"flex h-full flex-col",children:[e,n.jsxs("div",{className:"flex min-h-0 flex-1",children:[l,n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[h,n.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2.5 p-3",children:[c,n.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-5 gap-2",children:[d,n.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-2",children:[n.jsx("div",{className:te("rounded-md",St)}),n.jsx("div",{className:te("rounded-md",St)})]})]})]})]})]})]}),t[10]=u):u=t[10],u}var nl=Object.defineProperty,Sm=Object.getOwnPropertyDescriptor,ym=(t,e)=>{for(var s in e)nl(t,s,{get:e[s],enumerable:!0})},Re=(t,e,s,i)=>{for(var r=i>1?void 0:i?Sm(e,s):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(i?a(e,s,r):a(r))||r);return i&&r&&nl(e,s,r),r},ie=(t,e)=>(s,i)=>e(s,i,t),ro="Terminal input",Cr={get:()=>ro,set:t=>ro=t},no="Too much output to announce, navigate to rows manually to read",kr={get:()=>no,set:t=>no=t};function wm(t){return t.replace(/\r?\n/g,"\r")}function Cm(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function km(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function Nm(t,e,s,i){if(t.stopPropagation(),t.clipboardData){let r=t.clipboardData.getData("text/plain");ol(r,e,s,i)}}function ol(t,e,s,i){t=wm(t),t=Cm(t,s.decPrivateModes.bracketedPasteMode&&i.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(t,!0),e.value=""}function al(t,e,s){let i=s.getBoundingClientRect(),r=t.clientX-i.left-10,o=t.clientY-i.top-10;e.style.width="20px",e.style.height="20px",e.style.left=`${r}px`,e.style.top=`${o}px`,e.style.zIndex="1000",e.focus()}function oo(t,e,s,i,r){al(t,e,s),r&&i.rightClickSelect(t),e.value=i.selectionText,e.select()}function Ot(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function Vi(t,e=0,s=t.length){let i="";for(let r=e;r<s;++r){let o=t[r];o>65535?(o-=65536,i+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):i+=String.fromCharCode(o)}return i}var jm=class{constructor(){this._interim=0}clear(){this._interim=0}decode(t,e){let s=t.length;if(!s)return 0;let i=0,r=0;if(this._interim){let o=t.charCodeAt(r++);56320<=o&&o<=57343?e[i++]=(this._interim-55296)*1024+o-56320+65536:(e[i++]=this._interim,e[i++]=o),this._interim=0}for(let o=r;o<s;++o){let a=t.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=s)return this._interim=a,i;let l=t.charCodeAt(o);56320<=l&&l<=57343?e[i++]=(a-55296)*1024+l-56320+65536:(e[i++]=a,e[i++]=l);continue}a!==65279&&(e[i++]=a)}return i}},Em=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(t,e){let s=t.length;if(!s)return 0;let i=0,r,o,a,l,h=0,c=0;if(this.interim[0]){let f=!1,m=this.interim[0];m&=(m&224)===192?31:(m&240)===224?15:7;let _=0,p;for(;(p=this.interim[++_]&63)&&_<4;)m<<=6,m|=p;let g=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,v=g-_;for(;c<v;){if(c>=s)return 0;if(p=t[c++],(p&192)!==128){c--,f=!0;break}else this.interim[_++]=p,m<<=6,m|=p&63}f||(g===2?m<128?c--:e[i++]=m:g===3?m<2048||m>=55296&&m<=57343||m===65279||(e[i++]=m):m<65536||m>1114111||(e[i++]=m)),this.interim.fill(0)}let d=s-4,u=c;for(;u<s;){for(;u<d&&!((r=t[u])&128)&&!((o=t[u+1])&128)&&!((a=t[u+2])&128)&&!((l=t[u+3])&128);)e[i++]=r,e[i++]=o,e[i++]=a,e[i++]=l,u+=4;if(r=t[u++],r<128)e[i++]=r;else if((r&224)===192){if(u>=s)return this.interim[0]=r,i;if(o=t[u++],(o&192)!==128){u--;continue}if(h=(r&31)<<6|o&63,h<128){u--;continue}e[i++]=h}else if((r&240)===224){if(u>=s)return this.interim[0]=r,i;if(o=t[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,i;if(a=t[u++],(a&192)!==128){u--;continue}if(h=(r&15)<<12|(o&63)<<6|a&63,h<2048||h>=55296&&h<=57343||h===65279)continue;e[i++]=h}else if((r&248)===240){if(u>=s)return this.interim[0]=r,i;if(o=t[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,i;if(a=t[u++],(a&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,this.interim[2]=a,i;if(l=t[u++],(l&192)!==128){u--;continue}if(h=(r&7)<<18|(o&63)<<12|(a&63)<<6|l&63,h<65536||h>1114111)continue;e[i++]=h}}return i}},ll="",$t=" ",ei=class cl{constructor(){this.fg=0,this.bg=0,this.extended=new Di}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let e=new cl;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Di=class hl{constructor(e=0,s=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=s}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new hl(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},ht=class dl extends ei{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Di,this.combinedData=""}static fromCharData(e){let s=new dl;return s.setFromCharData(e),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Ot(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let s=!1;if(e[1].length>2)s=!0;else if(e[1].length===2){let i=e[1].charCodeAt(0);if(55296<=i&&i<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(i-55296)*1024+r-56320+65536|e[2]<<22:s=!0}else s=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;s&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},ao="di$target",Nr="di$dependencies",rr=new Map;function Tm(t){return t[Nr]||[]}function Ve(t){if(rr.has(t))return rr.get(t);let e=function(s,i,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Rm(e,s,r)};return e._id=t,rr.set(t,e),e}function Rm(t,e,s){e[ao]===e?e[Nr].push({id:t,index:s}):(e[Nr]=[{id:t,index:s}],e[ao]=e)}var Ze=Ve("BufferService"),ul=Ve("CoreMouseService"),ns=Ve("CoreService"),Dm=Ve("CharsetService"),jn=Ve("InstantiationService"),fl=Ve("LogService"),Qe=Ve("OptionsService"),ml=Ve("OscLinkService"),Pm=Ve("UnicodeService"),ti=Ve("DecorationService"),jr=class{constructor(t,e,s){this._bufferService=t,this._optionsService=e,this._oscLinkService=s}provideLinks(t,e){let s=this._bufferService.buffer.lines.get(t-1);if(!s){e(void 0);return}let i=[],r=this._optionsService.rawOptions.linkHandler,o=new ht,a=s.getTrimmedLength(),l=-1,h=-1,c=!1;for(let d=0;d<a;d++)if(!(h===-1&&!s.hasContent(d))){if(s.loadCell(d,o),o.hasExtendedAttrs()&&o.extended.urlId)if(h===-1){h=d,l=o.extended.urlId;continue}else c=o.extended.urlId!==l;else h!==-1&&(c=!0);if(c||h!==-1&&d===a-1){let u=this._oscLinkService.getLinkData(l)?.uri;if(u){let f={start:{x:h+1,y:t},end:{x:d+(!c&&d===a-1?1:0),y:t}},m=!1;if(!r?.allowNonHttpProtocols)try{let _=new URL(u);["http:","https:"].includes(_.protocol)||(m=!0)}catch{m=!0}m||i.push({text:u,range:f,activate:(_,p)=>r?r.activate(_,p,f):Im(_,p),hover:(_,p)=>r?.hover?.(_,p,f),leave:(_,p)=>r?.leave?.(_,p,f)})}c=!1,o.hasExtendedAttrs()&&o.extended.urlId?(h=d,l=o.extended.urlId):(h=-1,l=-1)}}e(i)}};jr=Re([ie(0,Ze),ie(1,Qe),ie(2,ml)],jr);function Im(t,e){if(confirm(`Do you want to navigate to ${e}?
|
|
270
|
+
`}),e[26]=S):S=e[26];let w;return e[27]!==b||e[28]!==d?(w=n.jsxs("div",{className:"relative flex w-full flex-col items-center justify-center gap-12 select-none [clip-path:inset(-24px_0_-200px_0)]",children:[d,b,S]}),e[27]=b,e[28]=d,e[29]=w):w=e[29],w}function ci(t){const e=z.c(10),{phase:s,current:i,children:r}=t,o=s-i,a=o<0,l=o===0,h=a?90:o*-22,c=a?.94:1-Math.max(o,0)*.04,d=a?0:l?1:o===1?.8:.55,u=a?10:30-o,f=!l;let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=te("absolute inset-0 overflow-hidden rounded-xl border border-foreground/10 bg-background shadow-[0_20px_60px_-20px_rgb(0_0_0_/_0.35)] transition-all ease-[cubic-bezier(0.22,1,0.36,1)]"),e[0]=m):m=e[0];const _=`translateY(${h}px) scale(${c})`,p=l?"auto":"none";let g;e[1]!==d||e[2]!==_||e[3]!==p||e[4]!==u?(g={transform:_,opacity:d,zIndex:u,transitionDuration:"1000ms",pointerEvents:p},e[1]=d,e[2]=_,e[3]=p,e[4]=u,e[5]=g):g=e[5];let v;return e[6]!==r||e[7]!==f||e[8]!==g?(v=n.jsx("div",{"aria-hidden":f,className:m,style:g,children:r}),e[6]=r,e[7]=f,e[8]=g,e[9]=v):v=e[9],v}function Vi(t){const e=z.c(7),{showUrl:s}=t,i=s===void 0?!1:s;let r,o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("div",{className:te("size-2.5 rounded-full",ct)}),o=n.jsx("div",{className:te("size-2.5 rounded-full",ct)}),a=n.jsx("div",{className:te("size-2.5 rounded-full",ct)}),e[0]=r,e[1]=o,e[2]=a):(r=e[0],o=e[1],a=e[2]);let l;e[3]!==i?(l=i&&n.jsx("div",{className:te("ml-3 h-3.5 max-w-[220px] flex-1 rounded-sm",St)}),e[3]=i,e[4]=l):l=e[4];let h;return e[5]!==l?(h=n.jsxs("div",{className:"flex h-7 shrink-0 items-center gap-1.5 px-3",children:[r,o,a,l]}),e[5]=l,e[6]=h):h=e[6],h}function jm(){const t=z.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(Vi,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsxs("div",{className:"flex h-full flex-col",children:[e,n.jsx("div",{className:"flex flex-1 px-8 py-5",children:n.jsx("div",{className:"grid h-full w-full grid-cols-8 grid-rows-6 gap-2",children:Sm.map(Em)})})]}),t[1]=s):s=t[1],s}function Em(t,e){if(e===cl)return n.jsx("div",{className:"rounded-md bg-chart-1/[0.55]",style:{animation:"vm-breathe 2.4s ease-in-out infinite"}},e);const s=t;return n.jsx("div",{className:te("relative rounded-md",ct),children:n.jsx("div",{className:"absolute inset-0 rounded-md bg-chart-1/40 opacity-0",style:{animation:`vm-rack-scan ${hl}s ease-in-out infinite`,animationDelay:`${s}s`}})},e)}function Tm(){const t=z.c(5);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(Vi,{}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("div",{className:te("w-[18%] rounded-md",St),style:{animation:"vm-breathe 3s ease-in-out infinite"}}),t[1]=s):s=t[1];let i;t[2]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"h-[42%] shrink-0 rounded-md bg-chart-3/[0.12]",style:{animation:"vm-breathe 3s ease-in-out 0.4s infinite"}}),t[2]=i):i=t[2];let r;t[3]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("div",{className:"col-span-3 rounded-md bg-chart-3/[0.12]",style:{animation:"vm-breathe 3s ease-in-out 0.8s infinite"}}),t[3]=r):r=t[3];let o;return t[4]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsxs("div",{className:"flex h-full flex-col",children:[e,n.jsxs("div",{className:"flex min-h-0 flex-1 gap-1.5 p-3",children:[s,n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[i,n.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-5 gap-1.5",children:[r,n.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-1.5",children:[n.jsx("div",{className:te("rounded-md",St),style:{animation:"vm-breathe 3s ease-in-out 1.2s infinite"}}),n.jsx("div",{className:te("rounded-md",St),style:{animation:"vm-breathe 3s ease-in-out 1.6s infinite"}})]})]})]})]})]}),t[4]=o):o=t[4],o}function Rm(){const t=z.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(Vi,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsxs("div",{className:"flex h-full flex-col",children:[e,n.jsx("div",{className:"relative flex flex-1 items-center justify-center px-8 py-5",children:n.jsx("div",{className:"grid w-full gap-2",style:{gridTemplateColumns:"repeat(7, minmax(0, 1fr))"},children:Cm.map(Dm)})})]}),t[1]=s):s=t[1],s}function Dm(t,e){return n.jsx("div",{className:te("aspect-square rounded-md",km[e]?"bg-chart-2/70":ct),style:{animation:`vm-pulse-soft 2.2s ease-in-out ${t}s infinite`}},e)}function Pm(){const t=z.c(11);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(Vi,{showUrl:!0}),t[0]=e):e=t[0];let s,i,r,o,a;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("div",{className:"mb-2 h-5 rounded-md bg-chart-1/[0.10]"}),i=n.jsx("div",{className:te("h-1.5 w-[70%] rounded-sm",ct)}),r=n.jsx("div",{className:te("h-1.5 w-[55%] rounded-sm",ct)}),o=n.jsx("div",{className:te("h-1.5 w-[80%] rounded-sm",ct)}),a=n.jsx("div",{className:te("h-1.5 w-[50%] rounded-sm",ct)}),t[1]=s,t[2]=i,t[3]=r,t[4]=o,t[5]=a):(s=t[1],i=t[2],r=t[3],o=t[4],a=t[5]);let l;t[6]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsxs("div",{className:"flex w-[18%] shrink-0 flex-col gap-1.5 bg-chart-1/[0.05] p-2.5",children:[s,i,r,o,a,n.jsx("div",{className:"mt-auto",children:n.jsx("div",{className:te("h-4 rounded-md",ct)})})]}),t[6]=l):l=t[6];let h;t[7]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx("div",{className:"relative h-[42%] shrink-0 overflow-hidden bg-chart-1/[0.10]",children:n.jsxs("div",{className:"absolute right-3 bottom-3 left-3 space-y-1.5",children:[n.jsx("div",{className:"h-3 w-[35%] rounded-sm bg-chart-1/[0.15]"}),n.jsx("div",{className:te("h-1.5 w-[55%] rounded-sm",St)})]})}),t[7]=h):h=t[7];let c;t[8]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsxs("div",{className:"flex shrink-0 gap-1.5",children:[n.jsx("div",{className:"h-4 w-12 rounded-full bg-chart-1/[0.12]"}),n.jsx("div",{className:te("h-4 w-10 rounded-full",St)}),n.jsx("div",{className:te("h-4 w-14 rounded-full",St)})]}),t[8]=c):c=t[8];let d;t[9]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsxs("div",{className:te("col-span-3 flex flex-col justify-end gap-1 rounded-md p-2",St),children:[n.jsx("div",{className:te("h-1.5 w-[50%] rounded-sm",ct)}),n.jsx("div",{className:te("h-1 w-[75%] rounded-sm",ct)})]}),t[9]=d):d=t[9];let u;return t[10]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsxs("div",{className:"flex h-full flex-col",children:[e,n.jsxs("div",{className:"flex min-h-0 flex-1",children:[l,n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[h,n.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2.5 p-3",children:[c,n.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-5 gap-2",children:[d,n.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-2",children:[n.jsx("div",{className:te("rounded-md",St)}),n.jsx("div",{className:te("rounded-md",St)})]})]})]})]})]})]}),t[10]=u):u=t[10],u}var dl=Object.defineProperty,Im=Object.getOwnPropertyDescriptor,Mm=(t,e)=>{for(var s in e)dl(t,s,{get:e[s],enumerable:!0})},Te=(t,e,s,i)=>{for(var r=i>1?void 0:i?Im(e,s):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(i?a(e,s,r):a(r))||r);return i&&r&&dl(e,s,r),r},ie=(t,e)=>(s,i)=>e(s,i,t),uo="Terminal input",kr={get:()=>uo,set:t=>uo=t},fo="Too much output to announce, navigate to rows manually to read",Nr={get:()=>fo,set:t=>fo=t};function Am(t){return t.replace(/\r?\n/g,"\r")}function Bm(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function Lm(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function Om(t,e,s,i){if(t.stopPropagation(),t.clipboardData){let r=t.clipboardData.getData("text/plain");ul(r,e,s,i)}}function ul(t,e,s,i){t=Am(t),t=Bm(t,s.decPrivateModes.bracketedPasteMode&&i.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(t,!0),e.value=""}function fl(t,e,s){let i=s.getBoundingClientRect(),r=t.clientX-i.left-10,o=t.clientY-i.top-10;e.style.width="20px",e.style.height="20px",e.style.left=`${r}px`,e.style.top=`${o}px`,e.style.zIndex="1000",e.focus()}function mo(t,e,s,i,r){fl(t,e,s),r&&i.rightClickSelect(t),e.value=i.selectionText,e.select()}function Ot(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function Ki(t,e=0,s=t.length){let i="";for(let r=e;r<s;++r){let o=t[r];o>65535?(o-=65536,i+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):i+=String.fromCharCode(o)}return i}var $m=class{constructor(){this._interim=0}clear(){this._interim=0}decode(t,e){let s=t.length;if(!s)return 0;let i=0,r=0;if(this._interim){let o=t.charCodeAt(r++);56320<=o&&o<=57343?e[i++]=(this._interim-55296)*1024+o-56320+65536:(e[i++]=this._interim,e[i++]=o),this._interim=0}for(let o=r;o<s;++o){let a=t.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=s)return this._interim=a,i;let l=t.charCodeAt(o);56320<=l&&l<=57343?e[i++]=(a-55296)*1024+l-56320+65536:(e[i++]=a,e[i++]=l);continue}a!==65279&&(e[i++]=a)}return i}},zm=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(t,e){let s=t.length;if(!s)return 0;let i=0,r,o,a,l,h=0,c=0;if(this.interim[0]){let f=!1,m=this.interim[0];m&=(m&224)===192?31:(m&240)===224?15:7;let _=0,p;for(;(p=this.interim[++_]&63)&&_<4;)m<<=6,m|=p;let g=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,v=g-_;for(;c<v;){if(c>=s)return 0;if(p=t[c++],(p&192)!==128){c--,f=!0;break}else this.interim[_++]=p,m<<=6,m|=p&63}f||(g===2?m<128?c--:e[i++]=m:g===3?m<2048||m>=55296&&m<=57343||m===65279||(e[i++]=m):m<65536||m>1114111||(e[i++]=m)),this.interim.fill(0)}let d=s-4,u=c;for(;u<s;){for(;u<d&&!((r=t[u])&128)&&!((o=t[u+1])&128)&&!((a=t[u+2])&128)&&!((l=t[u+3])&128);)e[i++]=r,e[i++]=o,e[i++]=a,e[i++]=l,u+=4;if(r=t[u++],r<128)e[i++]=r;else if((r&224)===192){if(u>=s)return this.interim[0]=r,i;if(o=t[u++],(o&192)!==128){u--;continue}if(h=(r&31)<<6|o&63,h<128){u--;continue}e[i++]=h}else if((r&240)===224){if(u>=s)return this.interim[0]=r,i;if(o=t[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,i;if(a=t[u++],(a&192)!==128){u--;continue}if(h=(r&15)<<12|(o&63)<<6|a&63,h<2048||h>=55296&&h<=57343||h===65279)continue;e[i++]=h}else if((r&248)===240){if(u>=s)return this.interim[0]=r,i;if(o=t[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,i;if(a=t[u++],(a&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,this.interim[2]=a,i;if(l=t[u++],(l&192)!==128){u--;continue}if(h=(r&7)<<18|(o&63)<<12|(a&63)<<6|l&63,h<65536||h>1114111)continue;e[i++]=h}}return i}},ml="",$t=" ",si=class _l{constructor(){this.fg=0,this.bg=0,this.extended=new Pi}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let e=new _l;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Pi=class pl{constructor(e=0,s=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=s}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new pl(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},dt=class gl extends si{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Pi,this.combinedData=""}static fromCharData(e){let s=new gl;return s.setFromCharData(e),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Ot(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let s=!1;if(e[1].length>2)s=!0;else if(e[1].length===2){let i=e[1].charCodeAt(0);if(55296<=i&&i<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(i-55296)*1024+r-56320+65536|e[2]<<22:s=!0}else s=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;s&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},_o="di$target",jr="di$dependencies",nr=new Map;function Fm(t){return t[jr]||[]}function Ve(t){if(nr.has(t))return nr.get(t);let e=function(s,i,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Hm(e,s,r)};return e._id=t,nr.set(t,e),e}function Hm(t,e,s){e[_o]===e?e[jr].push({id:t,index:s}):(e[jr]=[{id:t,index:s}],e[_o]=e)}var Ze=Ve("BufferService"),vl=Ve("CoreMouseService"),ns=Ve("CoreService"),Wm=Ve("CharsetService"),En=Ve("InstantiationService"),xl=Ve("LogService"),Qe=Ve("OptionsService"),bl=Ve("OscLinkService"),Um=Ve("UnicodeService"),ii=Ve("DecorationService"),Er=class{constructor(t,e,s){this._bufferService=t,this._optionsService=e,this._oscLinkService=s}provideLinks(t,e){let s=this._bufferService.buffer.lines.get(t-1);if(!s){e(void 0);return}let i=[],r=this._optionsService.rawOptions.linkHandler,o=new dt,a=s.getTrimmedLength(),l=-1,h=-1,c=!1;for(let d=0;d<a;d++)if(!(h===-1&&!s.hasContent(d))){if(s.loadCell(d,o),o.hasExtendedAttrs()&&o.extended.urlId)if(h===-1){h=d,l=o.extended.urlId;continue}else c=o.extended.urlId!==l;else h!==-1&&(c=!0);if(c||h!==-1&&d===a-1){let u=this._oscLinkService.getLinkData(l)?.uri;if(u){let f={start:{x:h+1,y:t},end:{x:d+(!c&&d===a-1?1:0),y:t}},m=!1;if(!r?.allowNonHttpProtocols)try{let _=new URL(u);["http:","https:"].includes(_.protocol)||(m=!0)}catch{m=!0}m||i.push({text:u,range:f,activate:(_,p)=>r?r.activate(_,p,f):Vm(_,p),hover:(_,p)=>r?.hover?.(_,p,f),leave:(_,p)=>r?.leave?.(_,p,f)})}c=!1,o.hasExtendedAttrs()&&o.extended.urlId?(h=d,l=o.extended.urlId):(h=-1,l=-1)}}e(i)}};Er=Te([ie(0,Ze),ie(1,Qe),ie(2,bl)],Er);function Vm(t,e){if(confirm(`Do you want to navigate to ${e}?
|
|
170
271
|
|
|
171
|
-
WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=e}else console.warn("Opening link blocked as opener could not be cleared")}}var
|
|
272
|
+
WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=e}else console.warn("Opening link blocked as opener could not be cleared")}}var qi=Ve("CharSizeService"),It=Ve("CoreBrowserService"),Tn=Ve("MouseService"),Mt=Ve("RenderService"),Km=Ve("SelectionService"),Sl=Ve("CharacterJoinerService"),bs=Ve("ThemeService"),yl=Ve("LinkProviderService"),qm=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?po.isErrorNoTelemetry(t)?new po(t.message+`
|
|
172
273
|
|
|
173
274
|
`+t.stack):new Error(t.message+`
|
|
174
275
|
|
|
175
|
-
`+t.stack):t},0)}}addListener(t){return this.listeners.push(t),()=>{this._removeListener(t)}}emit(t){this.listeners.forEach(e=>{e(t)})}_removeListener(t){this.listeners.splice(this.listeners.indexOf(t),1)}setUnexpectedErrorHandler(t){this.unexpectedErrorHandler=t}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(t){this.unexpectedErrorHandler(t),this.emit(t)}onUnexpectedExternalError(t){this.unexpectedErrorHandler(t)}},Bm=new Am;function bi(t){Lm(t)||Bm.onUnexpectedError(t)}var Er="Canceled";function Lm(t){return t instanceof Om?!0:t instanceof Error&&t.name===Er&&t.message===Er}var Om=class extends Error{constructor(){super(Er),this.name=this.message}};function $m(t){return new Error(`Illegal argument: ${t}`)}var lo=class Tr extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof Tr)return e;let s=new Tr;return s.message=e.message,s.stack=e.stack,s}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}},Rr=class gl extends Error{constructor(e){super(e||"An unexpected bug occurred."),Object.setPrototypeOf(this,gl.prototype)}};function tt(t,e=0){return t[t.length-(1+e)]}var zm;(t=>{function e(o){return o<0}t.isLessThan=e;function s(o){return o<=0}t.isLessThanOrEqual=s;function i(o){return o>0}t.isGreaterThan=i;function r(o){return o===0}t.isNeitherLessOrGreaterThan=r,t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(zm||={});function Fm(t,e){let s=this,i=!1,r;return function(){return i||(i=!0,e||(r=t.apply(s,arguments))),r}}var vl;(t=>{function e(S){return S&&typeof S=="object"&&typeof S[Symbol.iterator]=="function"}t.is=e;let s=Object.freeze([]);function i(){return s}t.empty=i;function*r(S){yield S}t.single=r;function o(S){return e(S)?S:r(S)}t.wrap=o;function a(S){return S||s}t.from=a;function*l(S){for(let w=S.length-1;w>=0;w--)yield S[w]}t.reverse=l;function h(S){return!S||S[Symbol.iterator]().next().done===!0}t.isEmpty=h;function c(S){return S[Symbol.iterator]().next().value}t.first=c;function d(S,w){let k=0;for(let C of S)if(w(C,k++))return!0;return!1}t.some=d;function u(S,w){for(let k of S)if(w(k))return k}t.find=u;function*f(S,w){for(let k of S)w(k)&&(yield k)}t.filter=f;function*m(S,w){let k=0;for(let C of S)yield w(C,k++)}t.map=m;function*_(S,w){let k=0;for(let C of S)yield*w(C,k++)}t.flatMap=_;function*p(...S){for(let w of S)yield*w}t.concat=p;function g(S,w,k){let C=k;for(let E of S)C=w(C,E);return C}t.reduce=g;function*v(S,w,k=S.length){for(w<0&&(w+=S.length),k<0?k+=S.length:k>S.length&&(k=S.length);w<k;w++)yield S[w]}t.slice=v;function x(S,w=Number.POSITIVE_INFINITY){let k=[];if(w===0)return[k,S];let C=S[Symbol.iterator]();for(let E=0;E<w;E++){let T=C.next();if(T.done)return[k,t.empty()];k.push(T.value)}return[k,{[Symbol.iterator](){return C}}]}t.consume=x;async function b(S){let w=[];for await(let k of S)w.push(k);return Promise.resolve(w)}t.asyncToArray=b})(vl||={});function ts(t){if(vl.is(t)){let e=[];for(let s of t)if(s)try{s.dispose()}catch(i){e.push(i)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}else if(t)return t.dispose(),t}function Hm(...t){return ye(()=>ts(t))}function ye(t){return{dispose:Fm(()=>{t()})}}var xl=class bl{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{ts(this._toDispose)}finally{this._toDispose.clear()}}add(e){if(!e)return e;if(e===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?bl.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(e),e}delete(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),void 0)}};xl.DISABLE_DISPOSED_WARNING=!1;var zt=xl,de=class{constructor(){this._store=new zt,this._store}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};de.None=Object.freeze({dispose(){}});var ms=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(t){this._isDisposed||t===this._value||(this._value?.dispose(),this._value=t)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}clearAndLeak(){let t=this._value;return this._value=void 0,t}},Tt=typeof window=="object"?window:globalThis,Dr=class Pr{constructor(e){this.element=e,this.next=Pr.Undefined,this.prev=Pr.Undefined}};Dr.Undefined=new Dr(void 0);var Ce=Dr,co=class{constructor(){this._first=Ce.Undefined,this._last=Ce.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Ce.Undefined}clear(){let t=this._first;for(;t!==Ce.Undefined;){let e=t.next;t.prev=Ce.Undefined,t.next=Ce.Undefined,t=e}this._first=Ce.Undefined,this._last=Ce.Undefined,this._size=0}unshift(t){return this._insert(t,!1)}push(t){return this._insert(t,!0)}_insert(t,e){let s=new Ce(t);if(this._first===Ce.Undefined)this._first=s,this._last=s;else if(e){let r=this._last;this._last=s,s.prev=r,r.next=s}else{let r=this._first;this._first=s,s.next=r,r.prev=s}this._size+=1;let i=!1;return()=>{i||(i=!0,this._remove(s))}}shift(){if(this._first!==Ce.Undefined){let t=this._first.element;return this._remove(this._first),t}}pop(){if(this._last!==Ce.Undefined){let t=this._last.element;return this._remove(this._last),t}}_remove(t){if(t.prev!==Ce.Undefined&&t.next!==Ce.Undefined){let e=t.prev;e.next=t.next,t.next.prev=e}else t.prev===Ce.Undefined&&t.next===Ce.Undefined?(this._first=Ce.Undefined,this._last=Ce.Undefined):t.next===Ce.Undefined?(this._last=this._last.prev,this._last.next=Ce.Undefined):t.prev===Ce.Undefined&&(this._first=this._first.next,this._first.prev=Ce.Undefined);this._size-=1}*[Symbol.iterator](){let t=this._first;for(;t!==Ce.Undefined;)yield t.element,t=t.next}},Wm=globalThis.performance&&typeof globalThis.performance.now=="function",Um=class Sl{static create(e){return new Sl(e)}constructor(e){this._now=Wm&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Ke;(t=>{t.None=()=>de.None;function e(R,y){return u(R,()=>{},0,void 0,!0,void 0,y)}t.defer=e;function s(R){return(y,D=null,N)=>{let j=!1,M;return M=R(P=>{if(!j)return M?M.dispose():j=!0,y.call(D,P)},null,N),j&&M.dispose(),M}}t.once=s;function i(R,y,D){return c((N,j=null,M)=>R(P=>N.call(j,y(P)),null,M),D)}t.map=i;function r(R,y,D){return c((N,j=null,M)=>R(P=>{y(P),N.call(j,P)},null,M),D)}t.forEach=r;function o(R,y,D){return c((N,j=null,M)=>R(P=>y(P)&&N.call(j,P),null,M),D)}t.filter=o;function a(R){return R}t.signal=a;function l(...R){return(y,D=null,N)=>{let j=Hm(...R.map(M=>M(P=>y.call(D,P))));return d(j,N)}}t.any=l;function h(R,y,D,N){let j=D;return i(R,M=>(j=y(j,M),j),N)}t.reduce=h;function c(R,y){let D,N={onWillAddFirstListener(){D=R(j.fire,j)},onDidRemoveLastListener(){D?.dispose()}},j=new q(N);return y?.add(j),j.event}function d(R,y){return y instanceof Array?y.push(R):y&&y.add(R),R}function u(R,y,D=100,N=!1,j=!1,M,P){let F,W,O,$=0,H,V={leakWarningThreshold:M,onWillAddFirstListener(){F=R(X=>{$++,W=y(W,X),N&&!O&&(re.fire(W),W=void 0),H=()=>{let J=W;W=void 0,O=void 0,(!N||$>1)&&re.fire(J),$=0},typeof D=="number"?(clearTimeout(O),O=setTimeout(H,D)):O===void 0&&(O=0,queueMicrotask(H))})},onWillRemoveListener(){j&&$>0&&H?.()},onDidRemoveLastListener(){H=void 0,F.dispose()}},re=new q(V);return P?.add(re),re.event}t.debounce=u;function f(R,y=0,D){return t.debounce(R,(N,j)=>N?(N.push(j),N):[j],y,void 0,!0,void 0,D)}t.accumulate=f;function m(R,y=(N,j)=>N===j,D){let N=!0,j;return o(R,M=>{let P=N||!y(M,j);return N=!1,j=M,P},D)}t.latch=m;function _(R,y,D){return[t.filter(R,y,D),t.filter(R,N=>!y(N),D)]}t.split=_;function p(R,y=!1,D=[],N){let j=D.slice(),M=R(W=>{j?j.push(W):F.fire(W)});N&&N.add(M);let P=()=>{j?.forEach(W=>F.fire(W)),j=null},F=new q({onWillAddFirstListener(){M||(M=R(W=>F.fire(W)),N&&N.add(M))},onDidAddFirstListener(){j&&(y?setTimeout(P):P())},onDidRemoveLastListener(){M&&M.dispose(),M=null}});return N&&N.add(F),F.event}t.buffer=p;function g(R,y){return(D,N,j)=>{let M=y(new x);return R(function(P){let F=M.evaluate(P);F!==v&&D.call(N,F)},void 0,j)}}t.chain=g;let v=Symbol("HaltChainable");class x{constructor(){this.steps=[]}map(y){return this.steps.push(y),this}forEach(y){return this.steps.push(D=>(y(D),D)),this}filter(y){return this.steps.push(D=>y(D)?D:v),this}reduce(y,D){let N=D;return this.steps.push(j=>(N=y(N,j),N)),this}latch(y=(D,N)=>D===N){let D=!0,N;return this.steps.push(j=>{let M=D||!y(j,N);return D=!1,N=j,M?j:v}),this}evaluate(y){for(let D of this.steps)if(y=D(y),y===v)break;return y}}function b(R,y,D=N=>N){let N=(...F)=>P.fire(D(...F)),j=()=>R.on(y,N),M=()=>R.removeListener(y,N),P=new q({onWillAddFirstListener:j,onDidRemoveLastListener:M});return P.event}t.fromNodeEventEmitter=b;function S(R,y,D=N=>N){let N=(...F)=>P.fire(D(...F)),j=()=>R.addEventListener(y,N),M=()=>R.removeEventListener(y,N),P=new q({onWillAddFirstListener:j,onDidRemoveLastListener:M});return P.event}t.fromDOMEventEmitter=S;function w(R){return new Promise(y=>s(R)(y))}t.toPromise=w;function k(R){let y=new q;return R.then(D=>{y.fire(D)},()=>{y.fire(void 0)}).finally(()=>{y.dispose()}),y.event}t.fromPromise=k;function C(R,y){return R(D=>y.fire(D))}t.forward=C;function E(R,y,D){return y(D),R(N=>y(N))}t.runAndSubscribe=E;class T{constructor(y,D){this._observable=y,this._counter=0,this._hasChanged=!1;let N={onWillAddFirstListener:()=>{y.addObserver(this)},onDidRemoveLastListener:()=>{y.removeObserver(this)}};this.emitter=new q(N),D&&D.add(this.emitter)}beginUpdate(y){this._counter++}handlePossibleChange(y){}handleChange(y,D){this._hasChanged=!0}endUpdate(y){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function B(R,y){return new T(R,y).emitter.event}t.fromObservable=B;function I(R){return(y,D,N)=>{let j=0,M=!1,P={beginUpdate(){j++},endUpdate(){j--,j===0&&(R.reportChanges(),M&&(M=!1,y.call(D)))},handlePossibleChange(){},handleChange(){M=!0}};R.addObserver(P),R.reportChanges();let F={dispose(){R.removeObserver(P)}};return N instanceof zt?N.add(F):Array.isArray(N)&&N.push(F),F}}t.fromObservableLight=I})(Ke||={});var Ir=class Mr{constructor(e){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${e}_${Mr._idPool++}`,Mr.all.add(this)}start(e){this._stopWatch=new Um,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};Ir.all=new Set,Ir._idPool=0;var Vm=Ir,Km=-1,yl=class wl{constructor(e,s,i=(wl._idPool++).toString(16).padStart(3,"0")){this._errorHandler=e,this.threshold=s,this.name=i,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,s){let i=this.threshold;if(i<=0||s<i)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=i*.5;let[o,a]=this.getMostFrequentStack(),l=`[${this.name}] potential listener LEAK detected, having ${s} listeners already. MOST frequent listener (${a}):`;console.warn(l),console.warn(o);let h=new Ym(l,o);this._errorHandler(h)}return()=>{let o=this._stacks.get(e.value)||0;this._stacks.set(e.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,s=0;for(let[i,r]of this._stacks)(!e||s<r)&&(e=[i,r],s=r);return e}};yl._idPool=1;var qm=yl,Gm=class Cl{constructor(e){this.value=e}static create(){let e=new Error;return new Cl(e.stack??"")}print(){console.warn(this.value.split(`
|
|
276
|
+
`+t.stack):t},0)}}addListener(t){return this.listeners.push(t),()=>{this._removeListener(t)}}emit(t){this.listeners.forEach(e=>{e(t)})}_removeListener(t){this.listeners.splice(this.listeners.indexOf(t),1)}setUnexpectedErrorHandler(t){this.unexpectedErrorHandler=t}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(t){this.unexpectedErrorHandler(t),this.emit(t)}onUnexpectedExternalError(t){this.unexpectedErrorHandler(t)}},Gm=new qm;function Si(t){Ym(t)||Gm.onUnexpectedError(t)}var Tr="Canceled";function Ym(t){return t instanceof Xm?!0:t instanceof Error&&t.name===Tr&&t.message===Tr}var Xm=class extends Error{constructor(){super(Tr),this.name=this.message}};function Jm(t){return new Error(`Illegal argument: ${t}`)}var po=class Rr extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof Rr)return e;let s=new Rr;return s.message=e.message,s.stack=e.stack,s}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}},Dr=class wl extends Error{constructor(e){super(e||"An unexpected bug occurred."),Object.setPrototypeOf(this,wl.prototype)}};function st(t,e=0){return t[t.length-(1+e)]}var Zm;(t=>{function e(o){return o<0}t.isLessThan=e;function s(o){return o<=0}t.isLessThanOrEqual=s;function i(o){return o>0}t.isGreaterThan=i;function r(o){return o===0}t.isNeitherLessOrGreaterThan=r,t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(Zm||={});function Qm(t,e){let s=this,i=!1,r;return function(){return i||(i=!0,e||(r=t.apply(s,arguments))),r}}var Cl;(t=>{function e(S){return S&&typeof S=="object"&&typeof S[Symbol.iterator]=="function"}t.is=e;let s=Object.freeze([]);function i(){return s}t.empty=i;function*r(S){yield S}t.single=r;function o(S){return e(S)?S:r(S)}t.wrap=o;function a(S){return S||s}t.from=a;function*l(S){for(let w=S.length-1;w>=0;w--)yield S[w]}t.reverse=l;function h(S){return!S||S[Symbol.iterator]().next().done===!0}t.isEmpty=h;function c(S){return S[Symbol.iterator]().next().value}t.first=c;function d(S,w){let k=0;for(let E of S)if(w(E,k++))return!0;return!1}t.some=d;function u(S,w){for(let k of S)if(w(k))return k}t.find=u;function*f(S,w){for(let k of S)w(k)&&(yield k)}t.filter=f;function*m(S,w){let k=0;for(let E of S)yield w(E,k++)}t.map=m;function*_(S,w){let k=0;for(let E of S)yield*w(E,k++)}t.flatMap=_;function*p(...S){for(let w of S)yield*w}t.concat=p;function g(S,w,k){let E=k;for(let P of S)E=w(E,P);return E}t.reduce=g;function*v(S,w,k=S.length){for(w<0&&(w+=S.length),k<0?k+=S.length:k>S.length&&(k=S.length);w<k;w++)yield S[w]}t.slice=v;function x(S,w=Number.POSITIVE_INFINITY){let k=[];if(w===0)return[k,S];let E=S[Symbol.iterator]();for(let P=0;P<w;P++){let R=E.next();if(R.done)return[k,t.empty()];k.push(R.value)}return[k,{[Symbol.iterator](){return E}}]}t.consume=x;async function b(S){let w=[];for await(let k of S)w.push(k);return Promise.resolve(w)}t.asyncToArray=b})(Cl||={});function ts(t){if(Cl.is(t)){let e=[];for(let s of t)if(s)try{s.dispose()}catch(i){e.push(i)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}else if(t)return t.dispose(),t}function e_(...t){return Se(()=>ts(t))}function Se(t){return{dispose:Qm(()=>{t()})}}var kl=class Nl{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{ts(this._toDispose)}finally{this._toDispose.clear()}}add(e){if(!e)return e;if(e===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?Nl.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(e),e}delete(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),void 0)}};kl.DISABLE_DISPOSED_WARNING=!1;var zt=kl,de=class{constructor(){this._store=new zt,this._store}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};de.None=Object.freeze({dispose(){}});var ms=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(t){this._isDisposed||t===this._value||(this._value?.dispose(),this._value=t)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}clearAndLeak(){let t=this._value;return this._value=void 0,t}},Tt=typeof window=="object"?window:globalThis,Pr=class Ir{constructor(e){this.element=e,this.next=Ir.Undefined,this.prev=Ir.Undefined}};Pr.Undefined=new Pr(void 0);var ye=Pr,go=class{constructor(){this._first=ye.Undefined,this._last=ye.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===ye.Undefined}clear(){let t=this._first;for(;t!==ye.Undefined;){let e=t.next;t.prev=ye.Undefined,t.next=ye.Undefined,t=e}this._first=ye.Undefined,this._last=ye.Undefined,this._size=0}unshift(t){return this._insert(t,!1)}push(t){return this._insert(t,!0)}_insert(t,e){let s=new ye(t);if(this._first===ye.Undefined)this._first=s,this._last=s;else if(e){let r=this._last;this._last=s,s.prev=r,r.next=s}else{let r=this._first;this._first=s,s.next=r,r.prev=s}this._size+=1;let i=!1;return()=>{i||(i=!0,this._remove(s))}}shift(){if(this._first!==ye.Undefined){let t=this._first.element;return this._remove(this._first),t}}pop(){if(this._last!==ye.Undefined){let t=this._last.element;return this._remove(this._last),t}}_remove(t){if(t.prev!==ye.Undefined&&t.next!==ye.Undefined){let e=t.prev;e.next=t.next,t.next.prev=e}else t.prev===ye.Undefined&&t.next===ye.Undefined?(this._first=ye.Undefined,this._last=ye.Undefined):t.next===ye.Undefined?(this._last=this._last.prev,this._last.next=ye.Undefined):t.prev===ye.Undefined&&(this._first=this._first.next,this._first.prev=ye.Undefined);this._size-=1}*[Symbol.iterator](){let t=this._first;for(;t!==ye.Undefined;)yield t.element,t=t.next}},t_=globalThis.performance&&typeof globalThis.performance.now=="function",s_=class jl{static create(e){return new jl(e)}constructor(e){this._now=t_&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},qe;(t=>{t.None=()=>de.None;function e(T,y){return u(T,()=>{},0,void 0,!0,void 0,y)}t.defer=e;function s(T){return(y,N=null,C)=>{let j=!1,M;return M=T(D=>{if(!j)return M?M.dispose():j=!0,y.call(N,D)},null,C),j&&M.dispose(),M}}t.once=s;function i(T,y,N){return c((C,j=null,M)=>T(D=>C.call(j,y(D)),null,M),N)}t.map=i;function r(T,y,N){return c((C,j=null,M)=>T(D=>{y(D),C.call(j,D)},null,M),N)}t.forEach=r;function o(T,y,N){return c((C,j=null,M)=>T(D=>y(D)&&C.call(j,D),null,M),N)}t.filter=o;function a(T){return T}t.signal=a;function l(...T){return(y,N=null,C)=>{let j=e_(...T.map(M=>M(D=>y.call(N,D))));return d(j,C)}}t.any=l;function h(T,y,N,C){let j=N;return i(T,M=>(j=y(j,M),j),C)}t.reduce=h;function c(T,y){let N,C={onWillAddFirstListener(){N=T(j.fire,j)},onDidRemoveLastListener(){N?.dispose()}},j=new G(C);return y?.add(j),j.event}function d(T,y){return y instanceof Array?y.push(T):y&&y.add(T),T}function u(T,y,N=100,C=!1,j=!1,M,D){let F,H,O,$=0,W,K={leakWarningThreshold:M,onWillAddFirstListener(){F=T(Z=>{$++,H=y(H,Z),C&&!O&&(re.fire(H),H=void 0),W=()=>{let J=H;H=void 0,O=void 0,(!C||$>1)&&re.fire(J),$=0},typeof N=="number"?(clearTimeout(O),O=setTimeout(W,N)):O===void 0&&(O=0,queueMicrotask(W))})},onWillRemoveListener(){j&&$>0&&W?.()},onDidRemoveLastListener(){W=void 0,F.dispose()}},re=new G(K);return D?.add(re),re.event}t.debounce=u;function f(T,y=0,N){return t.debounce(T,(C,j)=>C?(C.push(j),C):[j],y,void 0,!0,void 0,N)}t.accumulate=f;function m(T,y=(C,j)=>C===j,N){let C=!0,j;return o(T,M=>{let D=C||!y(M,j);return C=!1,j=M,D},N)}t.latch=m;function _(T,y,N){return[t.filter(T,y,N),t.filter(T,C=>!y(C),N)]}t.split=_;function p(T,y=!1,N=[],C){let j=N.slice(),M=T(H=>{j?j.push(H):F.fire(H)});C&&C.add(M);let D=()=>{j?.forEach(H=>F.fire(H)),j=null},F=new G({onWillAddFirstListener(){M||(M=T(H=>F.fire(H)),C&&C.add(M))},onDidAddFirstListener(){j&&(y?setTimeout(D):D())},onDidRemoveLastListener(){M&&M.dispose(),M=null}});return C&&C.add(F),F.event}t.buffer=p;function g(T,y){return(N,C,j)=>{let M=y(new x);return T(function(D){let F=M.evaluate(D);F!==v&&N.call(C,F)},void 0,j)}}t.chain=g;let v=Symbol("HaltChainable");class x{constructor(){this.steps=[]}map(y){return this.steps.push(y),this}forEach(y){return this.steps.push(N=>(y(N),N)),this}filter(y){return this.steps.push(N=>y(N)?N:v),this}reduce(y,N){let C=N;return this.steps.push(j=>(C=y(C,j),C)),this}latch(y=(N,C)=>N===C){let N=!0,C;return this.steps.push(j=>{let M=N||!y(j,C);return N=!1,C=j,M?j:v}),this}evaluate(y){for(let N of this.steps)if(y=N(y),y===v)break;return y}}function b(T,y,N=C=>C){let C=(...F)=>D.fire(N(...F)),j=()=>T.on(y,C),M=()=>T.removeListener(y,C),D=new G({onWillAddFirstListener:j,onDidRemoveLastListener:M});return D.event}t.fromNodeEventEmitter=b;function S(T,y,N=C=>C){let C=(...F)=>D.fire(N(...F)),j=()=>T.addEventListener(y,C),M=()=>T.removeEventListener(y,C),D=new G({onWillAddFirstListener:j,onDidRemoveLastListener:M});return D.event}t.fromDOMEventEmitter=S;function w(T){return new Promise(y=>s(T)(y))}t.toPromise=w;function k(T){let y=new G;return T.then(N=>{y.fire(N)},()=>{y.fire(void 0)}).finally(()=>{y.dispose()}),y.event}t.fromPromise=k;function E(T,y){return T(N=>y.fire(N))}t.forward=E;function P(T,y,N){return y(N),T(C=>y(C))}t.runAndSubscribe=P;class R{constructor(y,N){this._observable=y,this._counter=0,this._hasChanged=!1;let C={onWillAddFirstListener:()=>{y.addObserver(this)},onDidRemoveLastListener:()=>{y.removeObserver(this)}};this.emitter=new G(C),N&&N.add(this.emitter)}beginUpdate(y){this._counter++}handlePossibleChange(y){}handleChange(y,N){this._hasChanged=!0}endUpdate(y){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function B(T,y){return new R(T,y).emitter.event}t.fromObservable=B;function I(T){return(y,N,C)=>{let j=0,M=!1,D={beginUpdate(){j++},endUpdate(){j--,j===0&&(T.reportChanges(),M&&(M=!1,y.call(N)))},handlePossibleChange(){},handleChange(){M=!0}};T.addObserver(D),T.reportChanges();let F={dispose(){T.removeObserver(D)}};return C instanceof zt?C.add(F):Array.isArray(C)&&C.push(F),F}}t.fromObservableLight=I})(qe||={});var Mr=class Ar{constructor(e){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${e}_${Ar._idPool++}`,Ar.all.add(this)}start(e){this._stopWatch=new s_,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};Mr.all=new Set,Mr._idPool=0;var i_=Mr,r_=-1,El=class Tl{constructor(e,s,i=(Tl._idPool++).toString(16).padStart(3,"0")){this._errorHandler=e,this.threshold=s,this.name=i,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,s){let i=this.threshold;if(i<=0||s<i)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=i*.5;let[o,a]=this.getMostFrequentStack(),l=`[${this.name}] potential listener LEAK detected, having ${s} listeners already. MOST frequent listener (${a}):`;console.warn(l),console.warn(o);let h=new a_(l,o);this._errorHandler(h)}return()=>{let o=this._stacks.get(e.value)||0;this._stacks.set(e.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,s=0;for(let[i,r]of this._stacks)(!e||s<r)&&(e=[i,r],s=r);return e}};El._idPool=1;var n_=El,o_=class Rl{constructor(e){this.value=e}static create(){let e=new Error;return new Rl(e.stack??"")}print(){console.warn(this.value.split(`
|
|
176
277
|
`).slice(2).join(`
|
|
177
|
-
`))}},Ym=class extends Error{constructor(t,e){super(t),this.name="ListenerLeakError",this.stack=e}},Xm=class extends Error{constructor(t,e){super(t),this.name="ListenerRefusalError",this.stack=e}},Jm=0,nr=class{constructor(t){this.value=t,this.id=Jm++}},Zm=2,Qm,q=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new qm(t?.onListenerError??bi,this._options?.leakWarningThreshold??Km):void 0,this._perfMon=this._options?._profName?new Vm(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(t,e,s)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let a=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(a);let l=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],h=new Xm(`${a}. HINT: Stack shows most frequent listener (${l[1]}-times)`,l[0]);return(this._options?.onListenerError||bi)(h),de.None}if(this._disposed)return de.None;e&&(t=t.bind(e));let i=new nr(t),r;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(i.stack=Gm.create(),r=this._leakageMon.check(i.stack,this._size+1)),this._listeners?this._listeners instanceof nr?(this._deliveryQueue??=new e_,this._listeners=[this._listeners,i]):this._listeners.push(i):(this._options?.onWillAddFirstListener?.(this),this._listeners=i,this._options?.onDidAddFirstListener?.(this)),this._size++;let o=ye(()=>{r?.(),this._removeListener(i)});return s instanceof zt?s.add(o):Array.isArray(s)&&s.push(o),o},this._event}_removeListener(t){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let e=this._listeners,s=e.indexOf(t);if(s===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,e[s]=void 0;let i=this._deliveryQueue.current===this;if(this._size*Zm<=e.length){let r=0;for(let o=0;o<e.length;o++)e[o]?e[r++]=e[o]:i&&(this._deliveryQueue.end--,r<this._deliveryQueue.i&&this._deliveryQueue.i--);e.length=r}}_deliver(t,e){if(!t)return;let s=this._options?.onListenerError||bi;if(!s){t.value(e);return}try{t.value(e)}catch(i){s(i)}}_deliverQueue(t){let e=t.current._listeners;for(;t.i<t.end;)this._deliver(e[t.i++],t.value);t.reset()}fire(t){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof nr)this._deliver(this._listeners,t);else{let e=this._deliveryQueue;e.enqueue(this,t,this._listeners.length),this._deliverQueue(e)}this._perfMon?.stop()}hasListeners(){return this._size>0}},e_=class{constructor(){this.i=-1,this.end=0}enqueue(t,e,s){this.i=0,this.end=s,this.current=t,this.value=e}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Ar=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new q,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new q,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,s){if(this.getZoomLevel(s)===e)return;let i=this.getWindowId(s);this.mapWindowIdToZoomLevel.set(i,e),this._onDidChangeZoomLevel.fire(i)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,s){this.mapWindowIdToZoomFactor.set(this.getWindowId(s),e)}setFullscreen(e,s){if(this.isFullscreen(s)===e)return;let i=this.getWindowId(s);this.mapWindowIdToFullScreen.set(i,e),this._onDidChangeFullscreen.fire(i)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};Ar.INSTANCE=new Ar;var Tn=Ar;function t_(t,e,s){typeof e=="string"&&(e=t.matchMedia(e)),e.addEventListener("change",s)}Tn.INSTANCE.onDidChangeZoomLevel;function s_(t){return Tn.INSTANCE.getZoomFactor(t)}Tn.INSTANCE.onDidChangeFullscreen;var Ss=typeof navigator=="object"?navigator.userAgent:"",Br=Ss.indexOf("Firefox")>=0,i_=Ss.indexOf("AppleWebKit")>=0,Rn=Ss.indexOf("Chrome")>=0,r_=!Rn&&Ss.indexOf("Safari")>=0;Ss.indexOf("Electron/")>=0;Ss.indexOf("Android")>=0;var or=!1;if(typeof Tt.matchMedia=="function"){let t=Tt.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),e=Tt.matchMedia("(display-mode: fullscreen)");or=t.matches,t_(Tt,t,({matches:s})=>{or&&e.matches||(or=s)})}var ds="en",Lr=!1,Or=!1,Si=!1,kl=!1,hi,yi=ds,ho=ds,n_,Et,Xt=globalThis,it;typeof Xt.vscode<"u"&&typeof Xt.vscode.process<"u"?it=Xt.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(it=process);var o_=typeof it?.versions?.electron=="string",a_=o_&&it?.type==="renderer";if(typeof it=="object"){Lr=it.platform==="win32",Or=it.platform==="darwin",Si=it.platform==="linux",Si&&it.env.SNAP&&it.env.SNAP_REVISION,it.env.CI||it.env.BUILD_ARTIFACTSTAGINGDIRECTORY,hi=ds,yi=ds;let t=it.env.VSCODE_NLS_CONFIG;if(t)try{let e=JSON.parse(t);hi=e.userLocale,ho=e.osLocale,yi=e.resolvedLanguage||ds,n_=e.languagePack?.translationsConfigFile}catch{}kl=!0}else typeof navigator=="object"&&!a_?(Et=navigator.userAgent,Lr=Et.indexOf("Windows")>=0,Or=Et.indexOf("Macintosh")>=0,(Et.indexOf("Macintosh")>=0||Et.indexOf("iPad")>=0||Et.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Si=Et.indexOf("Linux")>=0,Et?.indexOf("Mobi")>=0,yi=globalThis._VSCODE_NLS_LANGUAGE||ds,hi=navigator.language.toLowerCase(),ho=hi):console.error("Unable to resolve platform.");var Nl=Lr,wt=Or,l_=Si,uo=kl,kt=Et,At=yi,c_;(t=>{function e(){return At}t.value=e;function s(){return At.length===2?At==="en":At.length>=3?At[0]==="e"&&At[1]==="n"&&At[2]==="-":!1}t.isDefaultVariant=s;function i(){return At==="en"}t.isDefault=i})(c_||={});var h_=typeof Xt.postMessage=="function"&&!Xt.importScripts;(()=>{if(h_){let t=[];Xt.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let i=0,r=t.length;i<r;i++){let o=t[i];if(o.id===s.data.vscodeScheduleAsyncWork){t.splice(i,1),o.callback();return}}});let e=0;return s=>{let i=++e;t.push({id:i,callback:s}),Xt.postMessage({vscodeScheduleAsyncWork:i},"*")}}return t=>setTimeout(t)})();var d_=!!(kt&&kt.indexOf("Chrome")>=0);kt&&kt.indexOf("Firefox")>=0;!d_&&kt&&kt.indexOf("Safari")>=0;kt&&kt.indexOf("Edg/")>=0;kt&&kt.indexOf("Android")>=0;var ls=typeof navigator=="object"?navigator:{};uo||document.queryCommandSupported&&document.queryCommandSupported("copy")||ls&&ls.clipboard&&ls.clipboard.writeText,uo||ls&&ls.clipboard&&ls.clipboard.readText;var Dn=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(t,e){this._keyCodeToStr[t]=e,this._strToKeyCode[e.toLowerCase()]=t}keyCodeToStr(t){return this._keyCodeToStr[t]}strToKeyCode(t){return this._strToKeyCode[t.toLowerCase()]||0}},ar=new Dn,fo=new Dn,mo=new Dn,u_=new Array(230),jl;(t=>{function e(l){return ar.keyCodeToStr(l)}t.toString=e;function s(l){return ar.strToKeyCode(l)}t.fromString=s;function i(l){return fo.keyCodeToStr(l)}t.toUserSettingsUS=i;function r(l){return mo.keyCodeToStr(l)}t.toUserSettingsGeneral=r;function o(l){return fo.strToKeyCode(l)||mo.strToKeyCode(l)}t.fromUserSettings=o;function a(l){if(l>=98&&l<=113)return null;switch(l){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return ar.keyCodeToStr(l)}t.toElectronAccelerator=a})(jl||={});var f_=class El{constructor(e,s,i,r,o){this.ctrlKey=e,this.shiftKey=s,this.altKey=i,this.metaKey=r,this.keyCode=o}equals(e){return e instanceof El&&this.ctrlKey===e.ctrlKey&&this.shiftKey===e.shiftKey&&this.altKey===e.altKey&&this.metaKey===e.metaKey&&this.keyCode===e.keyCode}getHashCode(){let e=this.ctrlKey?"1":"0",s=this.shiftKey?"1":"0",i=this.altKey?"1":"0",r=this.metaKey?"1":"0";return`K${e}${s}${i}${r}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new m_([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},m_=class{constructor(t){if(t.length===0)throw $m("chords");this.chords=t}getHashCode(){let t="";for(let e=0,s=this.chords.length;e<s;e++)e!==0&&(t+=";"),t+=this.chords[e].getHashCode();return t}equals(t){if(t===null||this.chords.length!==t.chords.length)return!1;for(let e=0;e<this.chords.length;e++)if(!this.chords[e].equals(t.chords[e]))return!1;return!0}};function __(t){if(t.charCode){let s=String.fromCharCode(t.charCode).toUpperCase();return jl.fromString(s)}let e=t.keyCode;if(e===3)return 7;if(Br)switch(e){case 59:return 85;case 60:if(l_)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(wt)return 57;break}else if(i_&&(wt&&e===93||!wt&&e===92))return 57;return u_[e]||0}var p_=wt?256:2048,g_=512,v_=1024,x_=wt?2048:256,_o=class{constructor(t){this._standardKeyboardEventBrand=!0;let e=t;this.browserEvent=e,this.target=e.target,this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey,this.altGraphKey=e.getModifierState?.("AltGraph"),this.keyCode=__(e),this.code=e.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(t){return this._asKeybinding===t}_computeKeybinding(){let t=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(t=this.keyCode);let e=0;return this.ctrlKey&&(e|=p_),this.altKey&&(e|=g_),this.shiftKey&&(e|=v_),this.metaKey&&(e|=x_),e|=t,e}_computeKeyCodeChord(){let t=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(t=this.keyCode),new f_(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,t)}},po=new WeakMap;function b_(t){if(!t.parent||t.parent===t)return null;try{let e=t.location,s=t.parent.location;if(e.origin!=="null"&&s.origin!=="null"&&e.origin!==s.origin)return null}catch{return null}return t.parent}var S_=class{static getSameOriginWindowChain(t){let e=po.get(t);if(!e){e=[],po.set(t,e);let s=t,i;do i=b_(s),i?e.push({window:new WeakRef(s),iframeElement:s.frameElement||null}):e.push({window:new WeakRef(s),iframeElement:null}),s=i;while(s)}return e.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(t,e){if(!e||t===e)return{top:0,left:0};let s=0,i=0,r=this.getSameOriginWindowChain(t);for(let o of r){let a=o.window.deref();if(s+=a?.scrollY??0,i+=a?.scrollX??0,a===e||!o.iframeElement)break;let l=o.iframeElement.getBoundingClientRect();s+=l.top,i+=l.left}return{top:s,left:i}}},di=class{constructor(t,e){this.timestamp=Date.now(),this.browserEvent=e,this.leftButton=e.button===0,this.middleButton=e.button===1,this.rightButton=e.button===2,this.buttons=e.buttons,this.target=e.target,this.detail=e.detail||1,e.type==="dblclick"&&(this.detail=2),this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey,typeof e.pageX=="number"?(this.posx=e.pageX,this.posy=e.pageY):(this.posx=e.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=e.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let s=S_.getPositionOfChildWindowRelativeToAncestorWindow(t,e.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},go=class{constructor(t,e=0,s=0){this.browserEvent=t||null,this.target=t?t.target||t.targetNode||t.srcElement:null,this.deltaY=s,this.deltaX=e;let i=!1;if(Rn){let r=navigator.userAgent.match(/Chrome\/(\d+)/);i=(r?parseInt(r[1]):123)<=122}if(t){let r=t,o=t,a=t.view?.devicePixelRatio||1;if(typeof r.wheelDeltaY<"u")i?this.deltaY=r.wheelDeltaY/(120*a):this.deltaY=r.wheelDeltaY/120;else if(typeof o.VERTICAL_AXIS<"u"&&o.axis===o.VERTICAL_AXIS)this.deltaY=-o.detail/3;else if(t.type==="wheel"){let l=t;l.deltaMode===l.DOM_DELTA_LINE?Br&&!wt?this.deltaY=-t.deltaY/3:this.deltaY=-t.deltaY:this.deltaY=-t.deltaY/40}if(typeof r.wheelDeltaX<"u")r_&&Nl?this.deltaX=-(r.wheelDeltaX/120):i?this.deltaX=r.wheelDeltaX/(120*a):this.deltaX=r.wheelDeltaX/120;else if(typeof o.HORIZONTAL_AXIS<"u"&&o.axis===o.HORIZONTAL_AXIS)this.deltaX=-t.detail/3;else if(t.type==="wheel"){let l=t;l.deltaMode===l.DOM_DELTA_LINE?Br&&!wt?this.deltaX=-t.deltaX/3:this.deltaX=-t.deltaX:this.deltaX=-t.deltaX/40}this.deltaY===0&&this.deltaX===0&&t.wheelDelta&&(i?this.deltaY=t.wheelDelta/(120*a):this.deltaY=t.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},Tl=Object.freeze(function(t,e){let s=setTimeout(t.bind(e),0);return{dispose(){clearTimeout(s)}}}),y_;(t=>{function e(s){return s===t.None||s===t.Cancelled||s instanceof w_?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}t.isCancellationToken=e,t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Ke.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Tl})})(y_||={});var w_=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?Tl:(this._emitter||(this._emitter=new q),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Pn=class{constructor(t,e){this._isDisposed=!1,this._token=-1,typeof t=="function"&&typeof e=="number"&&this.setIfNotSet(t,e)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(t,e){if(this._isDisposed)throw new Rr("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,t()},e)}setIfNotSet(t,e){if(this._isDisposed)throw new Rr("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,t()},e))}},C_=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(t,e,s=globalThis){if(this.isDisposed)throw new Rr("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let i=s.setInterval(()=>{t()},e);this.disposable=ye(()=>{s.clearInterval(i),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},k_;(t=>{async function e(i){let r,o=await Promise.all(i.map(a=>a.then(l=>l,l=>{r||(r=l)})));if(typeof r<"u")throw r;return o}t.settled=e;function s(i){return new Promise(async(r,o)=>{try{await i(r,o)}catch(a){o(a)}})}t.withAsyncBody=s})(k_||={});var vo=class at{static fromArray(e){return new at(s=>{s.emitMany(e)})}static fromPromise(e){return new at(async s=>{s.emitMany(await e)})}static fromPromises(e){return new at(async s=>{await Promise.all(e.map(async i=>s.emitOne(await i)))})}static merge(e){return new at(async s=>{await Promise.all(e.map(async i=>{for await(let r of i)s.emitOne(r)}))})}constructor(e,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new q,queueMicrotask(async()=>{let i={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(e(i)),this.resolve()}catch(r){this.reject(r)}finally{i.emitOne=void 0,i.emitMany=void 0,i.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await Ke.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(e,s){return new at(async i=>{for await(let r of e)i.emitOne(s(r))})}map(e){return at.map(this,e)}static filter(e,s){return new at(async i=>{for await(let r of e)s(r)&&i.emitOne(r)})}filter(e){return at.filter(this,e)}static coalesce(e){return at.filter(e,s=>!!s)}coalesce(){return at.coalesce(this)}static async toPromise(e){let s=[];for await(let i of e)s.push(i);return s}toPromise(){return at.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};vo.EMPTY=vo.fromArray([]);var{getWindow:yt,getWindowId:N_,onDidRegisterWindow:j_}=(function(){let t=new Map,e={window:Tt,disposables:new zt};t.set(Tt.vscodeWindowId,e);let s=new q,i=new q,r=new q;function o(a,l){return(typeof a=="number"?t.get(a):void 0)??(l?e:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:i.event,registerWindow(a){if(t.has(a.vscodeWindowId))return de.None;let l=new zt,h={window:a,disposables:l.add(new zt)};return t.set(a.vscodeWindowId,h),l.add(ye(()=>{t.delete(a.vscodeWindowId),i.fire(a)})),l.add(ae(a,ze.BEFORE_UNLOAD,()=>{r.fire(a)})),s.fire(h),l},getWindows(){return t.values()},getWindowsCount(){return t.size},getWindowId(a){return a.vscodeWindowId},hasWindow(a){return t.has(a)},getWindowById:o,getWindow(a){let l=a;if(l?.ownerDocument?.defaultView)return l.ownerDocument.defaultView.window;let h=a;return h?.view?h.view.window:Tt},getDocument(a){return yt(a).document}}})(),E_=class{constructor(t,e,s,i){this._node=t,this._type=e,this._handler=s,this._options=i||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function ae(t,e,s,i){return new E_(t,e,s,i)}var xo=function(t,e,s,i){return ae(t,e,s,i)},In,T_=class extends C_{constructor(t){super(),this.defaultTarget=t&&yt(t)}cancelAndSet(t,e,s){return super.cancelAndSet(t,e,s??this.defaultTarget)}},bo=class{constructor(t,e=0){this._runner=t,this.priority=e,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(t){bi(t)}}static sort(t,e){return e.priority-t.priority}};(function(){let t=new Map,e=new Map,s=new Map,i=new Map,r=o=>{s.set(o,!1);let a=t.get(o)??[];for(e.set(o,a),t.set(o,[]),i.set(o,!0);a.length>0;)a.sort(bo.sort),a.shift().execute();i.set(o,!1)};In=(o,a,l=0)=>{let h=N_(o),c=new bo(a,l),d=t.get(h);return d||(d=[],t.set(h,d)),d.push(c),s.get(h)||(s.set(h,!0),o.requestAnimationFrame(()=>r(h))),c}})();function R_(t){let e=t.getBoundingClientRect(),s=yt(t);return{left:e.left+s.scrollX,top:e.top+s.scrollY,width:e.width,height:e.height}}var ze={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},D_=class{constructor(t){this.domNode=t,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(t){let e=et(t);this._maxWidth!==e&&(this._maxWidth=e,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let e=et(t);this._width!==e&&(this._width=e,this.domNode.style.width=this._width)}setHeight(t){let e=et(t);this._height!==e&&(this._height=e,this.domNode.style.height=this._height)}setTop(t){let e=et(t);this._top!==e&&(this._top=e,this.domNode.style.top=this._top)}setLeft(t){let e=et(t);this._left!==e&&(this._left=e,this.domNode.style.left=this._left)}setBottom(t){let e=et(t);this._bottom!==e&&(this._bottom=e,this.domNode.style.bottom=this._bottom)}setRight(t){let e=et(t);this._right!==e&&(this._right=e,this.domNode.style.right=this._right)}setPaddingTop(t){let e=et(t);this._paddingTop!==e&&(this._paddingTop=e,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let e=et(t);this._paddingLeft!==e&&(this._paddingLeft=e,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let e=et(t);this._paddingBottom!==e&&(this._paddingBottom=e,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let e=et(t);this._paddingRight!==e&&(this._paddingRight=e,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(t){let e=et(t);this._fontSize!==e&&(this._fontSize=e,this.domNode.style.fontSize=this._fontSize)}setFontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(t){this._fontFeatureSettings!==t&&(this._fontFeatureSettings=t,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(t){this._fontVariationSettings!==t&&(this._fontVariationSettings=t,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(t){this._textDecoration!==t&&(this._textDecoration=t,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(t){let e=et(t);this._lineHeight!==e&&(this._lineHeight=e,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let e=et(t);this._letterSpacing!==e&&(this._letterSpacing=e,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(t){this._className!==t&&(this._className=t,this.domNode.className=this._className)}toggleClassName(t,e){this.domNode.classList.toggle(t,e),this._className=this.domNode.className}setDisplay(t){this._display!==t&&(this._display=t,this.domNode.style.display=this._display)}setPosition(t){this._position!==t&&(this._position=t,this.domNode.style.position=this._position)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this.domNode.style.visibility=this._visibility)}setColor(t){this._color!==t&&(this._color=t,this.domNode.style.color=this._color)}setBackgroundColor(t){this._backgroundColor!==t&&(this._backgroundColor=t,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(t){this._layerHint!==t&&(this._layerHint=t,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(t){this._boxShadow!==t&&(this._boxShadow=t,this.domNode.style.boxShadow=t)}setContain(t){this._contain!==t&&(this._contain=t,this.domNode.style.contain=this._contain)}setAttribute(t,e){this.domNode.setAttribute(t,e)}removeAttribute(t){this.domNode.removeAttribute(t)}appendChild(t){this.domNode.appendChild(t.domNode)}removeChild(t){this.domNode.removeChild(t.domNode)}};function et(t){return typeof t=="number"?`${t}px`:t}function Os(t){return new D_(t)}var Rl=class{constructor(){this._hooks=new zt,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(t,e){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,t&&s&&s(e)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(t,e,s,i,r){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=i,this._onStopCallback=r;let o=t;try{t.setPointerCapture(e),this._hooks.add(ye(()=>{try{t.releasePointerCapture(e)}catch{}}))}catch{o=yt(t)}this._hooks.add(ae(o,ze.POINTER_MOVE,a=>{if(a.buttons!==s){this.stopMonitoring(!0);return}a.preventDefault(),this._pointerMoveCallback(a)})),this._hooks.add(ae(o,ze.POINTER_UP,a=>this.stopMonitoring(!0)))}};function P_(t,e,s){let i=null,r=null;if(typeof s.value=="function"?(i="value",r=s.value,r.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof s.get=="function"&&(i="get",r=s.get),!r)throw new Error("not supported");let o=`$memoize$${e}`;s[i]=function(...a){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,a)}),this[o]}}var bt;(t=>(t.Tap="-xterm-gesturetap",t.Change="-xterm-gesturechange",t.Start="-xterm-gesturestart",t.End="-xterm-gesturesend",t.Contextmenu="-xterm-gesturecontextmenu"))(bt||={});var Rs=class qe extends de{constructor(){super(),this.dispatched=!1,this.targets=new co,this.ignoreTargets=new co,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Ke.runAndSubscribe(j_,({window:e,disposables:s})=>{s.add(ae(e.document,"touchstart",i=>this.onTouchStart(i),{passive:!1})),s.add(ae(e.document,"touchend",i=>this.onTouchEnd(e,i))),s.add(ae(e.document,"touchmove",i=>this.onTouchMove(i),{passive:!1}))},{window:Tt,disposables:this._store}))}static addTarget(e){if(!qe.isTouchDevice())return de.None;qe.INSTANCE||(qe.INSTANCE=new qe);let s=qe.INSTANCE.targets.push(e);return ye(s)}static ignoreTarget(e){if(!qe.isTouchDevice())return de.None;qe.INSTANCE||(qe.INSTANCE=new qe);let s=qe.INSTANCE.ignoreTargets.push(e);return ye(s)}static isTouchDevice(){return"ontouchstart"in Tt||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(e){let s=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let i=0,r=e.targetTouches.length;i<r;i++){let o=e.targetTouches.item(i);this.activeTouches[o.identifier]={id:o.identifier,initialTarget:o.target,initialTimeStamp:s,initialPageX:o.pageX,initialPageY:o.pageY,rollingTimestamps:[s],rollingPageX:[o.pageX],rollingPageY:[o.pageY]};let a=this.newGestureEvent(bt.Start,o.target);a.pageX=o.pageX,a.pageY=o.pageY,this.dispatchEvent(a)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}onTouchEnd(e,s){let i=Date.now(),r=Object.keys(this.activeTouches).length;for(let o=0,a=s.changedTouches.length;o<a;o++){let l=s.changedTouches.item(o);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("move of an UNKNOWN touch",l);continue}let h=this.activeTouches[l.identifier],c=Date.now()-h.initialTimeStamp;if(c<qe.HOLD_DELAY&&Math.abs(h.initialPageX-tt(h.rollingPageX))<30&&Math.abs(h.initialPageY-tt(h.rollingPageY))<30){let d=this.newGestureEvent(bt.Tap,h.initialTarget);d.pageX=tt(h.rollingPageX),d.pageY=tt(h.rollingPageY),this.dispatchEvent(d)}else if(c>=qe.HOLD_DELAY&&Math.abs(h.initialPageX-tt(h.rollingPageX))<30&&Math.abs(h.initialPageY-tt(h.rollingPageY))<30){let d=this.newGestureEvent(bt.Contextmenu,h.initialTarget);d.pageX=tt(h.rollingPageX),d.pageY=tt(h.rollingPageY),this.dispatchEvent(d)}else if(r===1){let d=tt(h.rollingPageX),u=tt(h.rollingPageY),f=tt(h.rollingTimestamps)-h.rollingTimestamps[0],m=d-h.rollingPageX[0],_=u-h.rollingPageY[0],p=[...this.targets].filter(g=>h.initialTarget instanceof Node&&g.contains(h.initialTarget));this.inertia(e,p,i,Math.abs(m)/f,m>0?1:-1,d,Math.abs(_)/f,_>0?1:-1,u)}this.dispatchEvent(this.newGestureEvent(bt.End,h.initialTarget)),delete this.activeTouches[l.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(e,s){let i=document.createEvent("CustomEvent");return i.initEvent(e,!1,!0),i.initialTarget=s,i.tapCount=0,i}dispatchEvent(e){if(e.type===bt.Tap){let s=new Date().getTime(),i=0;s-this._lastSetTapCountTime>qe.CLEAR_TAP_COUNT_TIME?i=1:i=2,this._lastSetTapCountTime=s,e.tapCount=i}else(e.type===bt.Change||e.type===bt.Contextmenu)&&(this._lastSetTapCountTime=0);if(e.initialTarget instanceof Node){for(let i of this.ignoreTargets)if(i.contains(e.initialTarget))return;let s=[];for(let i of this.targets)if(i.contains(e.initialTarget)){let r=0,o=e.initialTarget;for(;o&&o!==i;)r++,o=o.parentElement;s.push([r,i])}s.sort((i,r)=>i[0]-r[0]);for(let[i,r]of s)r.dispatchEvent(e),this.dispatched=!0}}inertia(e,s,i,r,o,a,l,h,c){this.handle=In(e,()=>{let d=Date.now(),u=d-i,f=0,m=0,_=!0;r+=qe.SCROLL_FRICTION*u,l+=qe.SCROLL_FRICTION*u,r>0&&(_=!1,f=o*r*u),l>0&&(_=!1,m=h*l*u);let p=this.newGestureEvent(bt.Change);p.translationX=f,p.translationY=m,s.forEach(g=>g.dispatchEvent(p)),_||this.inertia(e,s,d,r,o,a+f,l,h,c+m)})}onTouchMove(e){let s=Date.now();for(let i=0,r=e.changedTouches.length;i<r;i++){let o=e.changedTouches.item(i);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn("end of an UNKNOWN touch",o);continue}let a=this.activeTouches[o.identifier],l=this.newGestureEvent(bt.Change,a.initialTarget);l.translationX=o.pageX-tt(a.rollingPageX),l.translationY=o.pageY-tt(a.rollingPageY),l.pageX=o.pageX,l.pageY=o.pageY,this.dispatchEvent(l),a.rollingPageX.length>3&&(a.rollingPageX.shift(),a.rollingPageY.shift(),a.rollingTimestamps.shift()),a.rollingPageX.push(o.pageX),a.rollingPageY.push(o.pageY),a.rollingTimestamps.push(s)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}};Rs.SCROLL_FRICTION=-.005,Rs.HOLD_DELAY=700,Rs.CLEAR_TAP_COUNT_TIME=400,Re([P_],Rs,"isTouchDevice",1);var I_=Rs,Mn=class extends de{onclick(t,e){this._register(ae(t,ze.CLICK,s=>e(new di(yt(t),s))))}onmousedown(t,e){this._register(ae(t,ze.MOUSE_DOWN,s=>e(new di(yt(t),s))))}onmouseover(t,e){this._register(ae(t,ze.MOUSE_OVER,s=>e(new di(yt(t),s))))}onmouseleave(t,e){this._register(ae(t,ze.MOUSE_LEAVE,s=>e(new di(yt(t),s))))}onkeydown(t,e){this._register(ae(t,ze.KEY_DOWN,s=>e(new _o(s))))}onkeyup(t,e){this._register(ae(t,ze.KEY_UP,s=>e(new _o(s))))}oninput(t,e){this._register(ae(t,ze.INPUT,e))}onblur(t,e){this._register(ae(t,ze.BLUR,e))}onfocus(t,e){this._register(ae(t,ze.FOCUS,e))}onchange(t,e){this._register(ae(t,ze.CHANGE,e))}ignoreGesture(t){return I_.ignoreTarget(t)}},So=11,M_=class extends Mn{constructor(t){super(),this._onActivate=t.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=t.bgWidth+"px",this.bgDomNode.style.height=t.bgHeight+"px",typeof t.top<"u"&&(this.bgDomNode.style.top="0px"),typeof t.left<"u"&&(this.bgDomNode.style.left="0px"),typeof t.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof t.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=t.className,this.domNode.style.position="absolute",this.domNode.style.width=So+"px",this.domNode.style.height=So+"px",typeof t.top<"u"&&(this.domNode.style.top=t.top+"px"),typeof t.left<"u"&&(this.domNode.style.left=t.left+"px"),typeof t.bottom<"u"&&(this.domNode.style.bottom=t.bottom+"px"),typeof t.right<"u"&&(this.domNode.style.right=t.right+"px"),this._pointerMoveMonitor=this._register(new Rl),this._register(xo(this.bgDomNode,ze.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(xo(this.domNode,ze.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new T_),this._pointerdownScheduleRepeatTimer=this._register(new Pn)}_arrowPointerDown(t){if(!t.target||!(t.target instanceof Element))return;let e=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,yt(t))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(e,200),this._pointerMoveMonitor.startMonitoring(t.target,t.pointerId,t.buttons,s=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),t.preventDefault()}},A_=class $r{constructor(e,s,i,r,o,a,l){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,i=i|0,r=r|0,o=o|0,a=a|0,l=l|0),this.rawScrollLeft=r,this.rawScrollTop=l,s<0&&(s=0),r+s>i&&(r=i-s),r<0&&(r=0),o<0&&(o=0),l+o>a&&(l=a-o),l<0&&(l=0),this.width=s,this.scrollWidth=i,this.scrollLeft=r,this.height=o,this.scrollHeight=a,this.scrollTop=l}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(e,s){return new $r(this._forceIntegerValues,typeof e.width<"u"?e.width:this.width,typeof e.scrollWidth<"u"?e.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof e.height<"u"?e.height:this.height,typeof e.scrollHeight<"u"?e.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(e){return new $r(this._forceIntegerValues,this.width,this.scrollWidth,typeof e.scrollLeft<"u"?e.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof e.scrollTop<"u"?e.scrollTop:this.rawScrollTop)}createScrollEvent(e,s){let i=this.width!==e.width,r=this.scrollWidth!==e.scrollWidth,o=this.scrollLeft!==e.scrollLeft,a=this.height!==e.height,l=this.scrollHeight!==e.scrollHeight,h=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:s,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:i,scrollWidthChanged:r,scrollLeftChanged:o,heightChanged:a,scrollHeightChanged:l,scrollTopChanged:h}}},B_=class extends de{constructor(t){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new q),this.onScroll=this._onScroll.event,this._smoothScrollDuration=t.smoothScrollDuration,this._scheduleAtNextAnimationFrame=t.scheduleAtNextAnimationFrame,this._state=new A_(t.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(t){this._smoothScrollDuration=t}validateScrollPosition(t){return this._state.withScrollPosition(t)}getScrollDimensions(){return this._state}setScrollDimensions(t,e){let s=this._state.withScrollDimensions(t,e);this._setState(s,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(t){let e=this._state.withScrollPosition(t);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(e,!1)}setScrollPositionSmooth(t,e){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(t);if(this._smoothScrolling){t={scrollLeft:typeof t.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:t.scrollLeft,scrollTop:typeof t.scrollTop>"u"?this._smoothScrolling.to.scrollTop:t.scrollTop};let s=this._state.withScrollPosition(t);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;let i;e?i=new wo(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):i=this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=i}else{let s=this._state.withScrollPosition(t);this._smoothScrolling=wo.start(this._state,s,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let t=this._smoothScrolling.tick(),e=this._state.withScrollPosition(t);if(this._setState(e,!0),!!this._smoothScrolling){if(t.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(t,e){let s=this._state;s.equals(t)||(this._state=t,this._onScroll.fire(this._state.createScrollEvent(s,e)))}},yo=class{constructor(t,e,s){this.scrollLeft=t,this.scrollTop=e,this.isDone=s}};function lr(t,e){let s=e-t;return function(i){return t+s*$_(i)}}function L_(t,e,s){return function(i){return i<s?t(i/s):e((i-s)/(1-s))}}var wo=class zr{constructor(e,s,i,r){this.from=e,this.to=s,this.duration=r,this.startTime=i,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(e,s,i){if(Math.abs(e-s)>2.5*i){let r,o;return e<s?(r=e+.75*i,o=s-.75*i):(r=e-.75*i,o=s+.75*i),L_(lr(e,r),lr(o,s),.33)}return lr(e,s)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let s=(e-this.startTime)/this.duration;if(s<1){let i=this.scrollLeft(s),r=this.scrollTop(s);return new yo(i,r,!1)}return new yo(this.to.scrollLeft,this.to.scrollTop,!0)}combine(e,s,i){return zr.start(e,s,i)}static start(e,s,i){i=i+10;let r=Date.now()-10;return new zr(e,s,r,i)}};function O_(t){return Math.pow(t,3)}function $_(t){return 1-O_(1-t)}var z_=class extends de{constructor(t,e,s){super(),this._visibility=t,this._visibleClassName=e,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Pn)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this._updateShouldBeVisible())}setShouldBeVisible(t){this._rawShouldBeVisible=t,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let t=this._applyVisibilitySetting();this._shouldBeVisible!==t&&(this._shouldBeVisible=t,this.ensureVisibility())}setIsNeeded(t){this._isNeeded!==t&&(this._isNeeded=t,this.ensureVisibility())}setDomNode(t){this._domNode=t,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(t){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(t?" fade":"")))}},F_=140,Dl=class extends Mn{constructor(t){super(),this._lazyRender=t.lazyRender,this._host=t.host,this._scrollable=t.scrollable,this._scrollByPage=t.scrollByPage,this._scrollbarState=t.scrollbarState,this._visibilityController=this._register(new z_(t.visibility,"visible scrollbar "+t.extraScrollbarClassName,"invisible scrollbar "+t.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Rl),this._shouldRender=!0,this.domNode=Os(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(ae(this.domNode.domNode,ze.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(t){let e=this._register(new M_(t));this.domNode.domNode.appendChild(e.bgDomNode),this.domNode.domNode.appendChild(e.domNode)}_createSlider(t,e,s,i){this.slider=Os(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(t),this.slider.setLeft(e),typeof s=="number"&&this.slider.setWidth(s),typeof i=="number"&&this.slider.setHeight(i),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(ae(this.slider.domNode,ze.POINTER_DOWN,r=>{r.button===0&&(r.preventDefault(),this._sliderPointerDown(r))})),this.onclick(this.slider.domNode,r=>{r.leftButton&&r.stopPropagation()})}_onElementSize(t){return this._scrollbarState.setVisibleSize(t)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(t){return this._scrollbarState.setScrollSize(t)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(t){return this._scrollbarState.setScrollPosition(t)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(t){t.target===this.domNode.domNode&&this._onPointerDown(t)}delegatePointerDown(t){let e=this.domNode.domNode.getClientRects()[0].top,s=e+this._scrollbarState.getSliderPosition(),i=e+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),r=this._sliderPointerPosition(t);s<=r&&r<=i?t.button===0&&(t.preventDefault(),this._sliderPointerDown(t)):this._onPointerDown(t)}_onPointerDown(t){let e,s;if(t.target===this.domNode.domNode&&typeof t.offsetX=="number"&&typeof t.offsetY=="number")e=t.offsetX,s=t.offsetY;else{let r=R_(this.domNode.domNode);e=t.pageX-r.left,s=t.pageY-r.top}let i=this._pointerDownRelativePosition(e,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(i):this._scrollbarState.getDesiredScrollPositionFromOffset(i)),t.button===0&&(t.preventDefault(),this._sliderPointerDown(t))}_sliderPointerDown(t){if(!t.target||!(t.target instanceof Element))return;let e=this._sliderPointerPosition(t),s=this._sliderOrthogonalPointerPosition(t),i=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(t.target,t.pointerId,t.buttons,r=>{let o=this._sliderOrthogonalPointerPosition(r),a=Math.abs(o-s);if(Nl&&a>F_){this._setDesiredScrollPositionNow(i.getScrollPosition());return}let l=this._sliderPointerPosition(r)-e;this._setDesiredScrollPositionNow(i.getDesiredScrollPositionFromDelta(l))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(t){let e={};this.writeScrollPosition(e,t),this._scrollable.setScrollPositionNow(e)}updateScrollbarSize(t){this._updateScrollbarSize(t),this._scrollbarState.setScrollbarSize(t),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},Pl=class Fr{constructor(e,s,i,r,o,a){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(i),this._arrowSize=Math.round(e),this._visibleSize=r,this._scrollSize=o,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Fr(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let s=Math.round(e);return this._visibleSize!==s?(this._visibleSize=s,this._refreshComputedValues(),!0):!1}setScrollSize(e){let s=Math.round(e);return this._scrollSize!==s?(this._scrollSize=s,this._refreshComputedValues(),!0):!1}setScrollPosition(e){let s=Math.round(e);return this._scrollPosition!==s?(this._scrollPosition=s,this._refreshComputedValues(),!0):!1}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,s,i,r,o){let a=Math.max(0,i-e),l=Math.max(0,a-2*s),h=r>0&&r>i;if(!h)return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(l),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(i*l/r))),d=(l-c)/(r-i),u=o*d;return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(c),computedSliderRatio:d,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let e=Fr._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=e.computedAvailableSize,this._computedIsNeeded=e.computedIsNeeded,this._computedSliderSize=e.computedSliderSize,this._computedSliderRatio=e.computedSliderRatio,this._computedSliderPosition=e.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){if(!this._computedIsNeeded)return 0;let s=e-this._arrowSize-this._computedSliderSize/2;return Math.round(s/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let s=e-this._arrowSize,i=this._scrollPosition;return s<this._computedSliderPosition?i-=this._visibleSize:i+=this._visibleSize,i}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let s=this._computedSliderPosition+e;return Math.round(s/this._computedSliderRatio)}},H_=class extends Dl{constructor(t,e,s){let i=t.getScrollDimensions(),r=t.getCurrentScrollPosition();if(super({lazyRender:e.lazyRender,host:s,scrollbarState:new Pl(e.horizontalHasArrows?e.arrowSize:0,e.horizontal===2?0:e.horizontalScrollbarSize,e.vertical===2?0:e.verticalScrollbarSize,i.width,i.scrollWidth,r.scrollLeft),visibility:e.horizontal,extraScrollbarClassName:"horizontal",scrollable:t,scrollByPage:e.scrollByPage}),e.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((e.horizontalScrollbarSize-e.horizontalSliderSize)/2),0,void 0,e.horizontalSliderSize)}_updateSlider(t,e){this.slider.setWidth(t),this.slider.setLeft(e)}_renderDomNode(t,e){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(t){return this._shouldRender=this._onElementScrollSize(t.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(t.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(t.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(t,e){return t}_sliderPointerPosition(t){return t.pageX}_sliderOrthogonalPointerPosition(t){return t.pageY}_updateScrollbarSize(t){this.slider.setHeight(t)}writeScrollPosition(t,e){t.scrollLeft=e}updateOptions(t){this.updateScrollbarSize(t.horizontal===2?0:t.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(t.vertical===2?0:t.verticalScrollbarSize),this._visibilityController.setVisibility(t.horizontal),this._scrollByPage=t.scrollByPage}},W_=class extends Dl{constructor(t,e,s){let i=t.getScrollDimensions(),r=t.getCurrentScrollPosition();if(super({lazyRender:e.lazyRender,host:s,scrollbarState:new Pl(e.verticalHasArrows?e.arrowSize:0,e.vertical===2?0:e.verticalScrollbarSize,0,i.height,i.scrollHeight,r.scrollTop),visibility:e.vertical,extraScrollbarClassName:"vertical",scrollable:t,scrollByPage:e.scrollByPage}),e.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((e.verticalScrollbarSize-e.verticalSliderSize)/2),e.verticalSliderSize,void 0)}_updateSlider(t,e){this.slider.setHeight(t),this.slider.setTop(e)}_renderDomNode(t,e){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(t){return this._shouldRender=this._onElementScrollSize(t.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(t.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(t.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(t,e){return e}_sliderPointerPosition(t){return t.pageY}_sliderOrthogonalPointerPosition(t){return t.pageX}_updateScrollbarSize(t){this.slider.setWidth(t)}writeScrollPosition(t,e){t.scrollTop=e}updateOptions(t){this.updateScrollbarSize(t.vertical===2?0:t.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(t.vertical),this._scrollByPage=t.scrollByPage}},U_=500,Co=50,V_=class{constructor(t,e,s){this.timestamp=t,this.deltaX=e,this.deltaY=s,this.score=0}},Hr=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let e=1,s=0,i=1,r=this._rear;do{let o=r===this._front?e:Math.pow(2,-i);if(e-=o,s+=this._memory[r].score*o,r===this._front)break;r=(this._capacity+r-1)%this._capacity,i++}while(!0);return s<=.5}acceptStandardWheelEvent(e){if(Rn){let s=yt(e.browserEvent),i=s_(s);this.accept(Date.now(),e.deltaX*i,e.deltaY*i)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,s,i){let r=null,o=new V_(e,s,i);this._front===-1&&this._rear===-1?(this._memory[0]=o,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=o),o.score=this._computeScore(o,r)}_computeScore(e,s){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let i=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(i+=.25),s){let r=Math.abs(e.deltaX),o=Math.abs(e.deltaY),a=Math.abs(s.deltaX),l=Math.abs(s.deltaY),h=Math.max(Math.min(r,a),1),c=Math.max(Math.min(o,l),1),d=Math.max(r,a),u=Math.max(o,l);d%h===0&&u%c===0&&(i-=.5)}return Math.min(Math.max(i,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};Hr.INSTANCE=new Hr;var K_=Hr,q_=class extends Mn{constructor(t,e,s){super(),this._onScroll=this._register(new q),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new q),this.onWillScroll=this._onWillScroll.event,this._options=Y_(e),this._scrollable=s,this._register(this._scrollable.onScroll(r=>{this._onWillScroll.fire(r),this._onDidScroll(r),this._onScroll.fire(r)}));let i={onMouseWheel:r=>this._onMouseWheel(r),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new W_(this._scrollable,this._options,i)),this._horizontalScrollbar=this._register(new H_(this._scrollable,this._options,i)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(t),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Os(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Os(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Os(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,r=>this._onMouseOver(r)),this.onmouseleave(this._listenOnDomNode,r=>this._onMouseLeave(r)),this._hideTimeout=this._register(new Pn),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=ts(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(t){this._verticalScrollbar.delegatePointerDown(t)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(t){this._scrollable.setScrollDimensions(t,!1)}updateClassName(t){this._options.className=t,wt&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(t){typeof t.handleMouseWheel<"u"&&(this._options.handleMouseWheel=t.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof t.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=t.mouseWheelScrollSensitivity),typeof t.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=t.fastScrollSensitivity),typeof t.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=t.scrollPredominantAxis),typeof t.horizontal<"u"&&(this._options.horizontal=t.horizontal),typeof t.vertical<"u"&&(this._options.vertical=t.vertical),typeof t.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=t.horizontalScrollbarSize),typeof t.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=t.verticalScrollbarSize),typeof t.scrollByPage<"u"&&(this._options.scrollByPage=t.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(t){this._revealOnScroll=t}delegateScrollFromMouseWheelEvent(t){this._onMouseWheel(new go(t))}_setListeningToMouseWheel(t){if(this._mouseWheelToDispose.length>0!==t&&(this._mouseWheelToDispose=ts(this._mouseWheelToDispose),t)){let e=s=>{this._onMouseWheel(new go(s))};this._mouseWheelToDispose.push(ae(this._listenOnDomNode,ze.MOUSE_WHEEL,e,{passive:!1}))}}_onMouseWheel(t){if(t.browserEvent?.defaultPrevented)return;let e=K_.INSTANCE;e.acceptStandardWheelEvent(t);let s=!1;if(t.deltaY||t.deltaX){let r=t.deltaY*this._options.mouseWheelScrollSensitivity,o=t.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&o+r===0?o=r=0:Math.abs(r)>=Math.abs(o)?o=0:r=0),this._options.flipAxes&&([r,o]=[o,r]);let a=!wt&&t.browserEvent&&t.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!o&&(o=r,r=0),t.browserEvent&&t.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,r=r*this._options.fastScrollSensitivity);let l=this._scrollable.getFutureScrollPosition(),h={};if(r){let c=Co*r,d=l.scrollTop-(c<0?Math.floor(c):Math.ceil(c));this._verticalScrollbar.writeScrollPosition(h,d)}if(o){let c=Co*o,d=l.scrollLeft-(c<0?Math.floor(c):Math.ceil(c));this._horizontalScrollbar.writeScrollPosition(h,d)}h=this._scrollable.validateScrollPosition(h),(l.scrollLeft!==h.scrollLeft||l.scrollTop!==h.scrollTop)&&(this._options.mouseWheelSmoothScroll&&e.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(h):this._scrollable.setScrollPositionNow(h),s=!0)}let i=s;!i&&this._options.alwaysConsumeMouseWheel&&(i=!0),!i&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(i=!0),i&&(t.preventDefault(),t.stopPropagation())}_onDidScroll(t){this._shouldRender=this._horizontalScrollbar.onDidScroll(t)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(t)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let t=this._scrollable.getCurrentScrollPosition(),e=t.scrollTop>0,s=t.scrollLeft>0,i=s?" left":"",r=e?" top":"",o=s||e?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${i}`),this._topShadowDomNode.setClassName(`shadow${r}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${r}${i}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(t){this._mouseIsOver=!1,this._hide()}_onMouseOver(t){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),U_)}},G_=class extends q_{constructor(t,e,s){super(t,e,s)}setScrollPosition(t){t.reuseAnimation?this._scrollable.setScrollPositionSmooth(t,t.reuseAnimation):this._scrollable.setScrollPositionNow(t)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function Y_(t){let e={lazyRender:typeof t.lazyRender<"u"?t.lazyRender:!1,className:typeof t.className<"u"?t.className:"",useShadows:typeof t.useShadows<"u"?t.useShadows:!0,handleMouseWheel:typeof t.handleMouseWheel<"u"?t.handleMouseWheel:!0,flipAxes:typeof t.flipAxes<"u"?t.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof t.consumeMouseWheelIfScrollbarIsNeeded<"u"?t.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof t.alwaysConsumeMouseWheel<"u"?t.alwaysConsumeMouseWheel:!1,scrollYToX:typeof t.scrollYToX<"u"?t.scrollYToX:!1,mouseWheelScrollSensitivity:typeof t.mouseWheelScrollSensitivity<"u"?t.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof t.fastScrollSensitivity<"u"?t.fastScrollSensitivity:5,scrollPredominantAxis:typeof t.scrollPredominantAxis<"u"?t.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof t.mouseWheelSmoothScroll<"u"?t.mouseWheelSmoothScroll:!0,arrowSize:typeof t.arrowSize<"u"?t.arrowSize:11,listenOnDomNode:typeof t.listenOnDomNode<"u"?t.listenOnDomNode:null,horizontal:typeof t.horizontal<"u"?t.horizontal:1,horizontalScrollbarSize:typeof t.horizontalScrollbarSize<"u"?t.horizontalScrollbarSize:10,horizontalSliderSize:typeof t.horizontalSliderSize<"u"?t.horizontalSliderSize:0,horizontalHasArrows:typeof t.horizontalHasArrows<"u"?t.horizontalHasArrows:!1,vertical:typeof t.vertical<"u"?t.vertical:1,verticalScrollbarSize:typeof t.verticalScrollbarSize<"u"?t.verticalScrollbarSize:10,verticalHasArrows:typeof t.verticalHasArrows<"u"?t.verticalHasArrows:!1,verticalSliderSize:typeof t.verticalSliderSize<"u"?t.verticalSliderSize:0,scrollByPage:typeof t.scrollByPage<"u"?t.scrollByPage:!1};return e.horizontalSliderSize=typeof t.horizontalSliderSize<"u"?t.horizontalSliderSize:e.horizontalScrollbarSize,e.verticalSliderSize=typeof t.verticalSliderSize<"u"?t.verticalSliderSize:e.verticalScrollbarSize,wt&&(e.className+=" mac"),e}var Wr=class extends de{constructor(t,e,s,i,r,o,a,l){super(),this._bufferService=s,this._optionsService=a,this._renderService=l,this._onRequestScrollLines=this._register(new q),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let h=this._register(new B_({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:c=>In(i.window,c)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new G_(e,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},h)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(r.onProtocolChange(c=>{this._scrollableElement.updateOptions({handleMouseWheel:!(c&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Ke.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),t.appendChild(this._scrollableElement.getDomNode()),this._register(ye(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=i.mainDocument.createElement("style"),e.appendChild(this._styleElement),this._register(ye(()=>this._styleElement.remove())),this._register(Ke.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
178
|
-
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(c=>this._handleScroll(c)))}scrollLines(t){let e=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:e.scrollTop+t*this._renderService.dimensions.css.cell.height})}scrollToLine(t,e){e&&(this._latestYDisp=t),this._scrollableElement.setScrollPosition({reuseAnimation:!e,scrollTop:t*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(t){t!==void 0&&(this._latestYDisp=t),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(t=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,t!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:t*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(t){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let e=Math.round(t.scrollTop/this._renderService.dimensions.css.cell.height),s=e-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=e,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};Wr=Re([ie(2,Ze),ie(3,It),ie(4,ul),ie(5,bs),ie(6,Qe),ie(7,Mt)],Wr);var Ur=class extends de{constructor(t,e,s,i,r){super(),this._screenElement=t,this._bufferService=e,this._coreBrowserService=s,this._decorationService=i,this._renderService=r,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(o=>this._removeDecoration(o))),this._register(ye(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let t of this._decorationService.decorations)this._renderDecoration(t);this._dimensionsChanged=!1}_renderDecoration(t){this._refreshStyle(t),this._dimensionsChanged&&this._refreshXPosition(t)}_createElement(t){let e=this._coreBrowserService.mainDocument.createElement("div");e.classList.add("xterm-decoration"),e.classList.toggle("xterm-decoration-top-layer",t?.options?.layer==="top"),e.style.width=`${Math.round((t.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,e.style.height=`${(t.options.height||1)*this._renderService.dimensions.css.cell.height}px`,e.style.top=`${(t.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,e.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let s=t.options.x??0;return s&&s>this._bufferService.cols&&(e.style.display="none"),this._refreshXPosition(t,e),e}_refreshStyle(t){let e=t.marker.line-this._bufferService.buffers.active.ydisp;if(e<0||e>=this._bufferService.rows)t.element&&(t.element.style.display="none",t.onRenderEmitter.fire(t.element));else{let s=this._decorationElements.get(t);s||(s=this._createElement(t),t.element=s,this._decorationElements.set(t,s),this._container.appendChild(s),t.onDispose(()=>{this._decorationElements.delete(t),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((t.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(t.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${e*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),t.onRenderEmitter.fire(s)}}_refreshXPosition(t,e=t.element){if(!e)return;let s=t.options.x??0;(t.options.anchor||"left")==="right"?e.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":e.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(t){this._decorationElements.get(t)?.remove(),this._decorationElements.delete(t),t.dispose()}};Ur=Re([ie(1,Ze),ie(2,It),ie(3,ti),ie(4,Mt)],Ur);var X_=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(t){if(t.options.overviewRulerOptions){for(let e of this._zones)if(e.color===t.options.overviewRulerOptions.color&&e.position===t.options.overviewRulerOptions.position){if(this._lineIntersectsZone(e,t.marker.line))return;if(this._lineAdjacentToZone(e,t.marker.line,t.options.overviewRulerOptions.position)){this._addLineToZone(e,t.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=t.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=t.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=t.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=t.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:t.options.overviewRulerOptions.color,position:t.options.overviewRulerOptions.position,startBufferLine:t.marker.line,endBufferLine:t.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(t){this._linePadding=t}_lineIntersectsZone(t,e){return e>=t.startBufferLine&&e<=t.endBufferLine}_lineAdjacentToZone(t,e,s){return e>=t.startBufferLine-this._linePadding[s||"full"]&&e<=t.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(t,e){t.startBufferLine=Math.min(t.startBufferLine,e),t.endBufferLine=Math.max(t.endBufferLine,e)}},vt={full:0,left:0,center:0,right:0},Bt={full:0,left:0,center:0,right:0},ws={full:0,left:0,center:0,right:0},Pi=class extends de{constructor(t,e,s,i,r,o,a,l){super(),this._viewportElement=t,this._screenElement=e,this._bufferService=s,this._decorationService=i,this._renderService=r,this._optionsService=o,this._themeService=a,this._coreBrowserService=l,this._colorZoneStore=new X_,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(ye(()=>this._canvas?.remove()));let h=this._canvas.getContext("2d");if(h)this._ctx=h;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let t=Math.floor((this._canvas.width-1)/3),e=Math.ceil((this._canvas.width-1)/3);Bt.full=this._canvas.width,Bt.left=t,Bt.center=e,Bt.right=t,this._refreshDrawHeightConstants(),ws.full=1,ws.left=1,ws.center=1+Bt.left,ws.right=1+Bt.left+Bt.center}_refreshDrawHeightConstants(){vt.full=Math.round(2*this._coreBrowserService.dpr);let t=this._canvas.height/this._bufferService.buffer.lines.length,e=Math.round(Math.max(Math.min(t,12),6)*this._coreBrowserService.dpr);vt.left=e,vt.center=e,vt.right=e}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*vt.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*vt.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*vt.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*vt.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let e of this._decorationService.decorations)this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1,this._renderRulerOutline();let t=this._colorZoneStore.zones;for(let e of t)e.position!=="full"&&this._renderColorZone(e);for(let e of t)e.position==="full"&&this._renderColorZone(e);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(t){this._ctx.fillStyle=t.color,this._ctx.fillRect(ws[t.position||"full"],Math.round((this._canvas.height-1)*(t.startBufferLine/this._bufferService.buffers.active.lines.length)-vt[t.position||"full"]/2),Bt[t.position||"full"],Math.round((this._canvas.height-1)*((t.endBufferLine-t.startBufferLine)/this._bufferService.buffers.active.lines.length)+vt[t.position||"full"]))}_queueRefresh(t,e){this._shouldUpdateDimensions=t||this._shouldUpdateDimensions,this._shouldUpdateAnchor=e||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};Pi=Re([ie(2,Ze),ie(3,ti),ie(4,Mt),ie(5,Qe),ie(6,bs),ie(7,It)],Pi);var U;(t=>(t.NUL="\0",t.SOH="",t.STX="",t.ETX="",t.EOT="",t.ENQ="",t.ACK="",t.BEL="\x07",t.BS="\b",t.HT=" ",t.LF=`
|
|
179
|
-
`,t.VT="\v",t.FF="\f",t.CR="\r",t.SO="",t.SI="",t.DLE="",t.DC1="",t.DC2="",t.DC3="",t.DC4="",t.NAK="",t.SYN="",t.ETB="",t.CAN="",t.EM="",t.SUB="",t.ESC="\x1B",t.FS="",t.GS="",t.RS="",t.US="",t.SP=" ",t.DEL=""))(U||={});var wi;(t=>(t.PAD="",t.HOP="",t.BPH="",t.NBH="",t.IND="",t.NEL="
",t.SSA="",t.ESA="",t.HTS="",t.HTJ="",t.VTS="",t.PLD="",t.PLU="",t.RI="",t.SS2="",t.SS3="",t.DCS="",t.PU1="",t.PU2="",t.STS="",t.CCH="",t.MW="",t.SPA="",t.EPA="",t.SOS="",t.SGCI="",t.SCI="",t.CSI="",t.ST="",t.OSC="",t.PM="",t.APC=""))(wi||={});var Il;(t=>t.ST=`${U.ESC}\\`)(Il||={});var Vr=class{constructor(t,e,s,i,r,o){this._textarea=t,this._compositionView=e,this._bufferService=s,this._optionsService=i,this._coreService=r,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(t){this._compositionView.textContent=t.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(t){if(this._isComposing||this._isSendingComposition){if(t.keyCode===20||t.keyCode===229||t.keyCode===16||t.keyCode===17||t.keyCode===18)return!1;this._finalizeComposition(!1)}return t.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(t){if(this._compositionView.classList.remove("active"),this._isComposing=!1,t){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let s;e.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(e.start,this._compositionPosition.start):s=this._textarea.value.substring(e.start),s.length>0&&this._coreService.triggerDataEvent(s,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let t=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let e=this._textarea.value,s=e.replace(t,"");this._dataAlreadySent=s,e.length>t.length?this._coreService.triggerDataEvent(s,!0):e.length<t.length?this._coreService.triggerDataEvent(`${U.DEL}`,!0):e.length===t.length&&e!==t&&this._coreService.triggerDataEvent(e,!0)}},0)}updateCompositionElements(t){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),s=this._renderService.dimensions.css.cell.height,i=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+"px",this._compositionView.style.top=i+"px",this._compositionView.style.height=s+"px",this._compositionView.style.lineHeight=s+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let o=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+"px",this._textarea.style.top=i+"px",this._textarea.style.width=Math.max(o.width,1)+"px",this._textarea.style.height=Math.max(o.height,1)+"px",this._textarea.style.lineHeight=o.height+"px"}t||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Vr=Re([ie(2,Ze),ie(3,Qe),ie(4,ns),ie(5,Mt)],Vr);var Fe=0,He=0,We=0,Te=0,ko={css:"#00000000",rgba:0},Me;(t=>{function e(r,o,a,l){return l!==void 0?`#${Kt(r)}${Kt(o)}${Kt(a)}${Kt(l)}`:`#${Kt(r)}${Kt(o)}${Kt(a)}`}t.toCss=e;function s(r,o,a,l=255){return(r<<24|o<<16|a<<8|l)>>>0}t.toRgba=s;function i(r,o,a,l){return{css:t.toCss(r,o,a,l),rgba:t.toRgba(r,o,a,l)}}t.toColor=i})(Me||={});var pe;(t=>{function e(h,c){if(Te=(c.rgba&255)/255,Te===1)return{css:c.css,rgba:c.rgba};let d=c.rgba>>24&255,u=c.rgba>>16&255,f=c.rgba>>8&255,m=h.rgba>>24&255,_=h.rgba>>16&255,p=h.rgba>>8&255;Fe=m+Math.round((d-m)*Te),He=_+Math.round((u-_)*Te),We=p+Math.round((f-p)*Te);let g=Me.toCss(Fe,He,We),v=Me.toRgba(Fe,He,We);return{css:g,rgba:v}}t.blend=e;function s(h){return(h.rgba&255)===255}t.isOpaque=s;function i(h,c,d){let u=Ci.ensureContrastRatio(h.rgba,c.rgba,d);if(u)return Me.toColor(u>>24&255,u>>16&255,u>>8&255)}t.ensureContrastRatio=i;function r(h){let c=(h.rgba|255)>>>0;return[Fe,He,We]=Ci.toChannels(c),{css:Me.toCss(Fe,He,We),rgba:c}}t.opaque=r;function o(h,c){return Te=Math.round(c*255),[Fe,He,We]=Ci.toChannels(h.rgba),{css:Me.toCss(Fe,He,We,Te),rgba:Me.toRgba(Fe,He,We,Te)}}t.opacity=o;function a(h,c){return Te=h.rgba&255,o(h,Te*c/255)}t.multiplyOpacity=a;function l(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}t.toColorRGB=l})(pe||={});var ke;(t=>{let e,s;try{let r=document.createElement("canvas");r.width=1,r.height=1;let o=r.getContext("2d",{willReadFrequently:!0});o&&(e=o,e.globalCompositeOperation="copy",s=e.createLinearGradient(0,0,1,1))}catch{}function i(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return Fe=parseInt(r.slice(1,2).repeat(2),16),He=parseInt(r.slice(2,3).repeat(2),16),We=parseInt(r.slice(3,4).repeat(2),16),Me.toColor(Fe,He,We);case 5:return Fe=parseInt(r.slice(1,2).repeat(2),16),He=parseInt(r.slice(2,3).repeat(2),16),We=parseInt(r.slice(3,4).repeat(2),16),Te=parseInt(r.slice(4,5).repeat(2),16),Me.toColor(Fe,He,We,Te);case 7:return{css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return{css:r,rgba:parseInt(r.slice(1),16)>>>0}}let o=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return Fe=parseInt(o[1]),He=parseInt(o[2]),We=parseInt(o[3]),Te=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),Me.toColor(Fe,He,We,Te);if(!e||!s)throw new Error("css.toColor: Unsupported css format");if(e.fillStyle=s,e.fillStyle=r,typeof e.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(e.fillRect(0,0,1,1),[Fe,He,We,Te]=e.getImageData(0,0,1,1).data,Te!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Me.toRgba(Fe,He,We,Te),css:r}}t.toColor=i})(ke||={});var Xe;(t=>{function e(i){return s(i>>16&255,i>>8&255,i&255)}t.relativeLuminance=e;function s(i,r,o){let a=i/255,l=r/255,h=o/255,c=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),d=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),u=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return c*.2126+d*.7152+u*.0722}t.relativeLuminance2=s})(Xe||={});var Ci;(t=>{function e(a,l){if(Te=(l&255)/255,Te===1)return l;let h=l>>24&255,c=l>>16&255,d=l>>8&255,u=a>>24&255,f=a>>16&255,m=a>>8&255;return Fe=u+Math.round((h-u)*Te),He=f+Math.round((c-f)*Te),We=m+Math.round((d-m)*Te),Me.toRgba(Fe,He,We)}t.blend=e;function s(a,l,h){let c=Xe.relativeLuminance(a>>8),d=Xe.relativeLuminance(l>>8);if(jt(c,d)<h){if(d<c){let m=i(a,l,h),_=jt(c,Xe.relativeLuminance(m>>8));if(_<h){let p=r(a,l,h),g=jt(c,Xe.relativeLuminance(p>>8));return _>g?m:p}return m}let u=r(a,l,h),f=jt(c,Xe.relativeLuminance(u>>8));if(f<h){let m=i(a,l,h),_=jt(c,Xe.relativeLuminance(m>>8));return f>_?u:m}return u}}t.ensureContrastRatio=s;function i(a,l,h){let c=a>>24&255,d=a>>16&255,u=a>>8&255,f=l>>24&255,m=l>>16&255,_=l>>8&255,p=jt(Xe.relativeLuminance2(f,m,_),Xe.relativeLuminance2(c,d,u));for(;p<h&&(f>0||m>0||_>0);)f-=Math.max(0,Math.ceil(f*.1)),m-=Math.max(0,Math.ceil(m*.1)),_-=Math.max(0,Math.ceil(_*.1)),p=jt(Xe.relativeLuminance2(f,m,_),Xe.relativeLuminance2(c,d,u));return(f<<24|m<<16|_<<8|255)>>>0}t.reduceLuminance=i;function r(a,l,h){let c=a>>24&255,d=a>>16&255,u=a>>8&255,f=l>>24&255,m=l>>16&255,_=l>>8&255,p=jt(Xe.relativeLuminance2(f,m,_),Xe.relativeLuminance2(c,d,u));for(;p<h&&(f<255||m<255||_<255);)f=Math.min(255,f+Math.ceil((255-f)*.1)),m=Math.min(255,m+Math.ceil((255-m)*.1)),_=Math.min(255,_+Math.ceil((255-_)*.1)),p=jt(Xe.relativeLuminance2(f,m,_),Xe.relativeLuminance2(c,d,u));return(f<<24|m<<16|_<<8|255)>>>0}t.increaseLuminance=r;function o(a){return[a>>24&255,a>>16&255,a>>8&255,a&255]}t.toChannels=o})(Ci||={});function Kt(t){let e=t.toString(16);return e.length<2?"0"+e:e}function jt(t,e){return t<e?(e+.05)/(t+.05):(t+.05)/(e+.05)}var J_=class extends ei{constructor(t,e,s){super(),this.content=0,this.combinedData="",this.fg=t.fg,this.bg=t.bg,this.combinedData=e,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(t){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Ii=class{constructor(t){this._bufferService=t,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new ht}register(t){let e={id:this._nextCharacterJoinerId++,handler:t};return this._characterJoiners.push(e),e.id}deregister(t){for(let e=0;e<this._characterJoiners.length;e++)if(this._characterJoiners[e].id===t)return this._characterJoiners.splice(e,1),!0;return!1}getJoinedCharacters(t){if(this._characterJoiners.length===0)return[];let e=this._bufferService.buffer.lines.get(t);if(!e||e.length===0)return[];let s=[],i=e.translateToString(!0),r=0,o=0,a=0,l=e.getFg(0),h=e.getBg(0);for(let c=0;c<e.getTrimmedLength();c++)if(e.loadCell(c,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==l||this._workCell.bg!==h){if(c-r>1){let d=this._getJoinedRanges(i,a,o,e,r);for(let u=0;u<d.length;u++)s.push(d[u])}r=c,a=o,l=this._workCell.fg,h=this._workCell.bg}o+=this._workCell.getChars().length||$t.length}if(this._bufferService.cols-r>1){let c=this._getJoinedRanges(i,a,o,e,r);for(let d=0;d<c.length;d++)s.push(c[d])}return s}_getJoinedRanges(t,e,s,i,r){let o=t.substring(e,s),a=[];try{a=this._characterJoiners[0].handler(o)}catch(l){console.error(l)}for(let l=1;l<this._characterJoiners.length;l++)try{let h=this._characterJoiners[l].handler(o);for(let c=0;c<h.length;c++)Ii._mergeRanges(a,h[c])}catch(h){console.error(h)}return this._stringRangesToCellRanges(a,i,r),a}_stringRangesToCellRanges(t,e,s){let i=0,r=!1,o=0,a=t[i];if(a){for(let l=s;l<this._bufferService.cols;l++){let h=e.getWidth(l),c=e.getString(l).length||$t.length;if(h!==0){if(!r&&a[0]<=o&&(a[0]=l,r=!0),a[1]<=o){if(a[1]=l,a=t[++i],!a)break;a[0]<=o?(a[0]=l,r=!0):r=!1}o+=c}}a&&(a[1]=this._bufferService.cols)}}static _mergeRanges(t,e){let s=!1;for(let i=0;i<t.length;i++){let r=t[i];if(s){if(e[1]<=r[0])return t[i-1][1]=e[1],t;if(e[1]<=r[1])return t[i-1][1]=Math.max(e[1],r[1]),t.splice(i,1),t;t.splice(i,1),i--}else{if(e[1]<=r[0])return t.splice(i,0,e),t;if(e[1]<=r[1])return r[0]=Math.min(e[0],r[0]),t;e[0]<r[1]&&(r[0]=Math.min(e[0],r[0]),s=!0);continue}}return s?t[t.length-1][1]=e[1]:t.push(e),t}};Ii=Re([ie(0,Ze)],Ii);function Z_(t){return 57508<=t&&t<=57558}function Q_(t){return 9472<=t&&t<=9631}function ep(t){return Z_(t)||Q_(t)}function tp(){return{css:{canvas:ui(),cell:ui()},device:{canvas:ui(),cell:ui(),char:{width:0,height:0,left:0,top:0}}}}function ui(){return{width:0,height:0}}var Kr=class{constructor(t,e,s,i,r,o,a){this._document=t,this._characterJoinerService=e,this._optionsService=s,this._coreBrowserService=i,this._coreService=r,this._decorationService=o,this._themeService=a,this._workCell=new ht,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(t,e,s){this._selectionStart=t,this._selectionEnd=e,this._columnSelectMode=s}createRow(t,e,s,i,r,o,a,l,h,c,d){let u=[],f=this._characterJoinerService.getJoinedCharacters(e),m=this._themeService.colors,_=t.getNoBgTrimmedLength();s&&_<o+1&&(_=o+1);let p,g=0,v="",x=0,b=0,S=0,w=0,k=!1,C=0,E=!1,T=0,B=0,I=[],R=c!==-1&&d!==-1;for(let y=0;y<_;y++){t.loadCell(y,this._workCell);let D=this._workCell.getWidth();if(D===0)continue;let N=!1,j=y>=B,M=y,P=this._workCell;if(f.length>0&&y===f[0][0]&&j){let ee=f.shift(),oe=this._isCellInSelection(ee[0],e);for(x=ee[0]+1;x<ee[1];x++)j&&=oe===this._isCellInSelection(x,e);j&&=!s||o<ee[0]||o>=ee[1],j?(N=!0,P=new J_(this._workCell,t.translateToString(!0,ee[0],ee[1]),ee[1]-ee[0]),M=ee[1]-1,D=P.getWidth()):B=ee[1]}let F=this._isCellInSelection(y,e),W=s&&y===o,O=R&&y>=c&&y<=d,$=!1;this._decorationService.forEachDecorationAtCell(y,e,void 0,ee=>{$=!0});let H=P.getChars()||$t;if(H===" "&&(P.isUnderline()||P.isOverline())&&(H=" "),T=D*l-h.get(H,P.isBold(),P.isItalic()),!p)p=this._document.createElement("span");else if(g&&(F&&E||!F&&!E&&P.bg===b)&&(F&&E&&m.selectionForeground||P.fg===S)&&P.extended.ext===w&&O===k&&T===C&&!W&&!N&&!$&&j){P.isInvisible()?v+=$t:v+=H,g++;continue}else g&&(p.textContent=v),p=this._document.createElement("span"),g=0,v="";if(b=P.bg,S=P.fg,w=P.extended.ext,k=O,C=T,E=F,N&&o>=y&&o<=M&&(o=y),!this._coreService.isCursorHidden&&W&&this._coreService.isCursorInitialized){if(I.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&I.push("xterm-cursor-blink"),I.push(i==="bar"?"xterm-cursor-bar":i==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){case"outline":I.push("xterm-cursor-outline");break;case"block":I.push("xterm-cursor-block");break;case"bar":I.push("xterm-cursor-bar");break;case"underline":I.push("xterm-cursor-underline");break}}if(P.isBold()&&I.push("xterm-bold"),P.isItalic()&&I.push("xterm-italic"),P.isDim()&&I.push("xterm-dim"),P.isInvisible()?v=$t:v=P.getChars()||$t,P.isUnderline()&&(I.push(`xterm-underline-${P.extended.underlineStyle}`),v===" "&&(v=" "),!P.isUnderlineColorDefault()))if(P.isUnderlineColorRGB())p.style.textDecorationColor=`rgb(${ei.toColorRGB(P.getUnderlineColor()).join(",")})`;else{let ee=P.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&P.isBold()&&ee<8&&(ee+=8),p.style.textDecorationColor=m.ansi[ee].css}P.isOverline()&&(I.push("xterm-overline"),v===" "&&(v=" ")),P.isStrikethrough()&&I.push("xterm-strikethrough"),O&&(p.style.textDecoration="underline");let V=P.getFgColor(),re=P.getFgColorMode(),X=P.getBgColor(),J=P.getBgColorMode(),Z=!!P.isInverse();if(Z){let ee=V;V=X,X=ee;let oe=re;re=J,J=oe}let L,K,Q=!1;this._decorationService.forEachDecorationAtCell(y,e,void 0,ee=>{ee.options.layer!=="top"&&Q||(ee.backgroundColorRGB&&(J=50331648,X=ee.backgroundColorRGB.rgba>>8&16777215,L=ee.backgroundColorRGB),ee.foregroundColorRGB&&(re=50331648,V=ee.foregroundColorRGB.rgba>>8&16777215,K=ee.foregroundColorRGB),Q=ee.options.layer==="top")}),!Q&&F&&(L=this._coreBrowserService.isFocused?m.selectionBackgroundOpaque:m.selectionInactiveBackgroundOpaque,X=L.rgba>>8&16777215,J=50331648,Q=!0,m.selectionForeground&&(re=50331648,V=m.selectionForeground.rgba>>8&16777215,K=m.selectionForeground)),Q&&I.push("xterm-decoration-top");let G;switch(J){case 16777216:case 33554432:G=m.ansi[X],I.push(`xterm-bg-${X}`);break;case 50331648:G=Me.toColor(X>>16,X>>8&255,X&255),this._addStyle(p,`background-color:#${No((X>>>0).toString(16),"0",6)}`);break;default:Z?(G=m.foreground,I.push("xterm-bg-257")):G=m.background}switch(L||P.isDim()&&(L=pe.multiplyOpacity(G,.5)),re){case 16777216:case 33554432:P.isBold()&&V<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(V+=8),this._applyMinimumContrast(p,G,m.ansi[V],P,L,void 0)||I.push(`xterm-fg-${V}`);break;case 50331648:let ee=Me.toColor(V>>16&255,V>>8&255,V&255);this._applyMinimumContrast(p,G,ee,P,L,K)||this._addStyle(p,`color:#${No(V.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(p,G,m.foreground,P,L,K)||Z&&I.push("xterm-fg-257")}I.length&&(p.className=I.join(" "),I.length=0),!W&&!N&&!$&&j?g++:p.textContent=v,T!==this.defaultSpacing&&(p.style.letterSpacing=`${T}px`),u.push(p),y=M}return p&&g&&(p.textContent=v),u}_applyMinimumContrast(t,e,s,i,r,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||ep(i.getCode()))return!1;let a=this._getContrastCache(i),l;if(!r&&!o&&(l=a.getColor(e.rgba,s.rgba)),l===void 0){let h=this._optionsService.rawOptions.minimumContrastRatio/(i.isDim()?2:1);l=pe.ensureContrastRatio(r||e,o||s,h),a.setColor((r||e).rgba,(o||s).rgba,l??null)}return l?(this._addStyle(t,`color:${l.css}`),!0):!1}_getContrastCache(t){return t.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(t,e){t.setAttribute("style",`${t.getAttribute("style")||""}${e};`)}_isCellInSelection(t,e){let s=this._selectionStart,i=this._selectionEnd;return!s||!i?!1:this._columnSelectMode?s[0]<=i[0]?t>=s[0]&&e>=s[1]&&t<i[0]&&e<=i[1]:t<s[0]&&e>=s[1]&&t>=i[0]&&e<=i[1]:e>s[1]&&e<i[1]||s[1]===i[1]&&e===s[1]&&t>=s[0]&&t<i[0]||s[1]<i[1]&&e===i[1]&&t<i[0]||s[1]<i[1]&&e===s[1]&&t>=s[0]}};Kr=Re([ie(1,_l),ie(2,Qe),ie(3,It),ie(4,ns),ie(5,ti),ie(6,bs)],Kr);function No(t,e,s){for(;t.length<s;)t=e+t;return t}var sp=class{constructor(t,e){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=t.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let s=t.createElement("span");s.classList.add("xterm-char-measure-element");let i=t.createElement("span");i.classList.add("xterm-char-measure-element"),i.style.fontWeight="bold";let r=t.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontStyle="italic";let o=t.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold",o.style.fontStyle="italic",this._measureElements=[s,i,r,o],this._container.appendChild(s),this._container.appendChild(i),this._container.appendChild(r),this._container.appendChild(o),e.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(t,e,s,i){t===this._font&&e===this._fontSize&&s===this._weight&&i===this._weightBold||(this._font=t,this._fontSize=e,this._weight=s,this._weightBold=i,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${i}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${i}`,this.clear())}get(t,e,s){let i=0;if(!e&&!s&&t.length===1&&(i=t.charCodeAt(0))<256){if(this._flat[i]!==-9999)return this._flat[i];let a=this._measure(t,0);return a>0&&(this._flat[i]=a),a}let r=t;e&&(r+="B"),s&&(r+="I");let o=this._holey.get(r);if(o===void 0){let a=0;e&&(a|=1),s&&(a|=2),o=this._measure(t,a),o>0&&this._holey.set(r,o)}return o}_measure(t,e){let s=this._measureElements[e];return s.textContent=t.repeat(32),s.offsetWidth/32}},ip=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(t,e,s,i=!1){if(this.selectionStart=e,this.selectionEnd=s,!e||!s||e[0]===s[0]&&e[1]===s[1]){this.clear();return}let r=t.buffers.active.ydisp,o=e[1]-r,a=s[1]-r,l=Math.max(o,0),h=Math.min(a,t.rows-1);if(l>=t.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=i,this.viewportStartRow=o,this.viewportEndRow=a,this.viewportCappedStartRow=l,this.viewportCappedEndRow=h,this.startCol=e[0],this.endCol=s[0]}isCellSelected(t,e,s){return this.hasSelection?(s-=t.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?e>=this.startCol&&s>=this.viewportCappedStartRow&&e<this.endCol&&s<=this.viewportCappedEndRow:e<this.startCol&&s>=this.viewportCappedStartRow&&e>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&e>=this.startCol&&e<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&e<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&e>=this.startCol):!1}};function rp(){return new ip}var cr="xterm-dom-renderer-owner-",ot="xterm-rows",fi="xterm-fg-",jo="xterm-bg-",Cs="xterm-focus",mi="xterm-selection",np=1,qr=class extends de{constructor(t,e,s,i,r,o,a,l,h,c,d,u,f,m){super(),this._terminal=t,this._document=e,this._element=s,this._screenElement=i,this._viewportElement=r,this._helperContainer=o,this._linkifier2=a,this._charSizeService=h,this._optionsService=c,this._bufferService=d,this._coreService=u,this._coreBrowserService=f,this._themeService=m,this._terminalClass=np++,this._rowElements=[],this._selectionRenderModel=rp(),this.onRequestRedraw=this._register(new q).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(ot),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(mi),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=tp(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(_=>this._injectCss(_))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(Kr,document),this._element.classList.add(cr+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(_=>this._handleLinkHover(_))),this._register(this._linkifier2.onHideLinkUnderline(_=>this._handleLinkLeave(_))),this._register(ye(()=>{this._element.classList.remove(cr+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new sp(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let t=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*t,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*t),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/t),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/t),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let e=`${this._terminalSelector} .${ot} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=e,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(t){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let e=`${this._terminalSelector} .${ot} { pointer-events: none; color: ${t.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;e+=`${this._terminalSelector} .${ot} .xterm-dim { color: ${pe.multiplyOpacity(t.foreground,.5).css};}`,e+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let s=`blink_underline_${this._terminalClass}`,i=`blink_bar_${this._terminalClass}`,r=`blink_block_${this._terminalClass}`;e+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,e+=`@keyframes ${i} { 50% { box-shadow: none; }}`,e+=`@keyframes ${r} { 0% { background-color: ${t.cursor.css}; color: ${t.cursorAccent.css}; } 50% { background-color: inherit; color: ${t.cursor.css}; }}`,e+=`${this._terminalSelector} .${ot}.${Cs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${ot}.${Cs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${ot}.${Cs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${ot} .xterm-cursor.xterm-cursor-block { background-color: ${t.cursor.css}; color: ${t.cursorAccent.css};}${this._terminalSelector} .${ot} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${t.cursor.css} !important; color: ${t.cursorAccent.css} !important;}${this._terminalSelector} .${ot} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${t.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${ot} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${t.cursor.css} inset;}${this._terminalSelector} .${ot} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${t.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,e+=`${this._terminalSelector} .${mi} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${mi} div { position: absolute; background-color: ${t.selectionBackgroundOpaque.css};}${this._terminalSelector} .${mi} div { position: absolute; background-color: ${t.selectionInactiveBackgroundOpaque.css};}`;for(let[o,a]of t.ansi.entries())e+=`${this._terminalSelector} .${fi}${o} { color: ${a.css}; }${this._terminalSelector} .${fi}${o}.xterm-dim { color: ${pe.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${jo}${o} { background-color: ${a.css}; }`;e+=`${this._terminalSelector} .${fi}257 { color: ${pe.opaque(t.background).css}; }${this._terminalSelector} .${fi}257.xterm-dim { color: ${pe.multiplyOpacity(pe.opaque(t.background),.5).css}; }${this._terminalSelector} .${jo}257 { background-color: ${t.foreground.css}; }`,this._themeStyleElement.textContent=e}_setDefaultSpacing(){let t=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${t}px`,this._rowFactory.defaultSpacing=t}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(t,e){for(let s=this._rowElements.length;s<=e;s++){let i=this._document.createElement("div");this._rowContainer.appendChild(i),this._rowElements.push(i)}for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(t,e){this._refreshRowElements(t,e),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Cs),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Cs),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(t,e,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(t,e,s),this.renderRows(0,this._bufferService.rows-1),!t||!e||(this._selectionRenderModel.update(this._terminal,t,e,s),!this._selectionRenderModel.hasSelection))return;let i=this._selectionRenderModel.viewportStartRow,r=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(s){let h=t[0]>e[0];l.appendChild(this._createSelectionElement(o,h?e[0]:t[0],h?t[0]:e[0],a-o+1))}else{let h=i===o?t[0]:0,c=o===r?e[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(o,h,c));let d=a-o-1;if(l.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,d)),o!==a){let u=r===a?e[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(a,0,u))}}this._selectionContainer.appendChild(l)}_createSelectionElement(t,e,s,i=1){let r=this._document.createElement("div"),o=e*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(s-e);return o+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-o),r.style.height=`${i*this.dimensions.css.cell.height}px`,r.style.top=`${t*this.dimensions.css.cell.height}px`,r.style.left=`${o}px`,r.style.width=`${a}px`,r}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let t of this._rowElements)t.replaceChildren()}renderRows(t,e){let s=this._bufferService.buffer,i=s.ybase+s.y,r=Math.min(s.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=t;h<=e;h++){let c=h+s.ydisp,d=this._rowElements[h],u=s.lines.get(c);if(!d||!u)break;d.replaceChildren(...this._rowFactory.createRow(u,c,c===i,a,l,r,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${cr}${this._terminalClass}`}_handleLinkHover(t){this._setCellUnderline(t.x1,t.x2,t.y1,t.y2,t.cols,!0)}_handleLinkLeave(t){this._setCellUnderline(t.x1,t.x2,t.y1,t.y2,t.cols,!1)}_setCellUnderline(t,e,s,i,r,o){s<0&&(t=0),i<0&&(e=0);let a=this._bufferService.rows-1;s=Math.max(Math.min(s,a),0),i=Math.max(Math.min(i,a),0),r=Math.min(r,this._bufferService.cols);let l=this._bufferService.buffer,h=l.ybase+l.y,c=Math.min(l.x,r-1),d=this._optionsService.rawOptions.cursorBlink,u=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let m=s;m<=i;++m){let _=m+l.ydisp,p=this._rowElements[m],g=l.lines.get(_);if(!p||!g)break;p.replaceChildren(...this._rowFactory.createRow(g,_,_===h,u,f,c,d,this.dimensions.css.cell.width,this._widthCache,o?m===s?t:0:-1,o?(m===i?e:r)-1:-1))}}};qr=Re([ie(7,jn),ie(8,Ki),ie(9,Qe),ie(10,Ze),ie(11,ns),ie(12,It),ie(13,bs)],qr);var Gr=class extends de{constructor(t,e,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new q),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new ap(this._optionsService))}catch{this._measureStrategy=this._register(new op(t,e,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let t=this._measureStrategy.measure();(t.width!==this.width||t.height!==this.height)&&(this.width=t.width,this.height=t.height,this._onCharSizeChange.fire())}};Gr=Re([ie(2,Qe)],Gr);var Ml=class extends de{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(t,e){t!==void 0&&t>0&&e!==void 0&&e>0&&(this._result.width=t,this._result.height=e)}},op=class extends Ml{constructor(t,e,s){super(),this._document=t,this._parentElement=e,this._optionsService=s,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},ap=class extends Ml{constructor(t){super(),this._optionsService=t,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let e=this._ctx.measureText("W");if(!("width"in e&&"fontBoundingBoxAscent"in e&&"fontBoundingBoxDescent"in e))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let t=this._ctx.measureText("W");return this._validateAndSet(t.width,t.fontBoundingBoxAscent+t.fontBoundingBoxDescent),this._result}},lp=class extends de{constructor(t,e,s){super(),this._textarea=t,this._window=e,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new cp(this._window)),this._onDprChange=this._register(new q),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new q),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(i=>this._screenDprMonitor.setWindow(i))),this._register(Ke.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(ae(this._textarea,"focus",()=>this._isFocused=!0)),this._register(ae(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(t){this._window!==t&&(this._window=t,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},cp=class extends de{constructor(t){super(),this._parentWindow=t,this._windowResizeListener=this._register(new ms),this._onDprChange=this._register(new q),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(ye(()=>this.clearListener()))}setWindow(t){this._parentWindow=t,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=ae(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},hp=class extends de{constructor(){super(),this.linkProviders=[],this._register(ye(()=>this.linkProviders.length=0))}registerLinkProvider(t){return this.linkProviders.push(t),{dispose:()=>{let e=this.linkProviders.indexOf(t);e!==-1&&this.linkProviders.splice(e,1)}}}};function An(t,e,s){let i=s.getBoundingClientRect(),r=t.getComputedStyle(s),o=parseInt(r.getPropertyValue("padding-left")),a=parseInt(r.getPropertyValue("padding-top"));return[e.clientX-i.left-o,e.clientY-i.top-a]}function dp(t,e,s,i,r,o,a,l,h){if(!o)return;let c=An(t,e,s);if(c)return c[0]=Math.ceil((c[0]+(h?a/2:0))/a),c[1]=Math.ceil(c[1]/l),c[0]=Math.min(Math.max(c[0],1),i+(h?1:0)),c[1]=Math.min(Math.max(c[1],1),r),c}var Yr=class{constructor(t,e){this._renderService=t,this._charSizeService=e}getCoords(t,e,s,i,r){return dp(window,t,e,s,i,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,r)}getMouseReportCoords(t,e){let s=An(window,t,e);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};Yr=Re([ie(0,Mt),ie(1,Ki)],Yr);var up=class{constructor(t,e){this._renderCallback=t,this._coreBrowserService=e,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(t){return this._refreshCallbacks.push(t),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}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,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();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),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let t of this._refreshCallbacks)t(0);this._refreshCallbacks=[]}},Al={};ym(Al,{getSafariVersion:()=>mp,isChromeOS:()=>$l,isFirefox:()=>Bl,isIpad:()=>_p,isIphone:()=>pp,isLegacyEdge:()=>fp,isLinux:()=>Bn,isMac:()=>Mi,isNode:()=>qi,isSafari:()=>Ll,isWindows:()=>Ol});var qi=typeof process<"u"&&"title"in process,si=qi?"node":navigator.userAgent,ii=qi?"node":navigator.platform,Bl=si.includes("Firefox"),fp=si.includes("Edge"),Ll=/^((?!chrome|android).)*safari/i.test(si);function mp(){if(!Ll)return 0;let t=si.match(/Version\/(\d+)/);return t===null||t.length<2?0:parseInt(t[1])}var Mi=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(ii),_p=ii==="iPad",pp=ii==="iPhone",Ol=["Windows","Win16","Win32","WinCE"].includes(ii),Bn=ii.indexOf("Linux")>=0,$l=/\bCrOS\b/.test(si),zl=class{constructor(){this._tasks=[],this._i=0}enqueue(t){this._tasks.push(t),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(t){this._idleCallback=void 0;let e=0,s=0,i=t.timeRemaining(),r=0;for(;this._i<this._tasks.length;){if(e=performance.now(),this._tasks[this._i]()||this._i++,e=Math.max(1,performance.now()-e),s=Math.max(e,s),r=t.timeRemaining(),s*1.5>r){i-e<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-e))}ms`),this._start();return}i=r}this.clear()}},gp=class extends zl{_requestCallback(t){return setTimeout(()=>t(this._createDeadline(16)))}_cancelCallback(t){clearTimeout(t)}_createDeadline(t){let e=performance.now()+t;return{timeRemaining:()=>Math.max(0,e-performance.now())}}},vp=class extends zl{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},Ai=!qi&&"requestIdleCallback"in window?vp:gp,xp=class{constructor(){this._queue=new Ai}set(t){this._queue.clear(),this._queue.enqueue(t)}flush(){this._queue.flush()}},Xr=class extends de{constructor(t,e,s,i,r,o,a,l,h){super(),this._rowCount=t,this._optionsService=s,this._charSizeService=i,this._coreService=r,this._coreBrowserService=l,this._renderer=this._register(new ms),this._pausedResizeTask=new xp,this._observerDisposable=this._register(new ms),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new q),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new q),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new q),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new q),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new up((c,d)=>this._renderRows(c,d),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new bp(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(ye(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(a.onResize(()=>this._fullRefresh())),this._register(a.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(a.cols,a.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(a.buffer.y,a.buffer.y,!0))),this._register(h.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,e),this._register(this._coreBrowserService.onWindowChange(c=>this._registerIntersectionObserver(c,e)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(t,e){if("IntersectionObserver"in t){let s=new t.IntersectionObserver(i=>this._handleIntersectionChange(i[i.length-1]),{threshold:0});s.observe(e),this._observerDisposable.value=ye(()=>s.disconnect())}}_handleIntersectionChange(t){this._isPaused=t.isIntersecting===void 0?t.intersectionRatio===0:!t.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(t,e,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(t,e);return}let i=this._syncOutputHandler.flush();i&&(t=Math.min(t,i.start),e=Math.max(e,i.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(t,e,this._rowCount)}_renderRows(t,e){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(t,e);return}t=Math.min(t,this._rowCount-1),e=Math.min(e,this._rowCount-1),this._renderer.value.renderRows(t,e),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:t,end:e}),this._onRender.fire({start:t,end:e}),this._isNextRenderRedrawOnly=!0}}resize(t,e){this._rowCount=e,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(t){this._renderer.value=t,this._renderer.value&&(this._renderer.value.onRequestRedraw(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(t){return this._renderDebouncer.addRefreshCallback(t)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(t,e){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(t,e)):this._renderer.value.handleResize(t,e),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(t,e,s){this._selectionState.start=t,this._selectionState.end=e,this._selectionState.columnSelectMode=s,this._renderer.value?.handleSelectionChanged(t,e,s)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};Xr=Re([ie(2,Qe),ie(3,Ki),ie(4,ns),ie(5,ti),ie(6,Ze),ie(7,It),ie(8,bs)],Xr);var bp=class{constructor(t,e,s){this._coreBrowserService=t,this._coreService=e,this._onTimeout=s,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(t,e){this._isBuffering?(this._start=Math.min(this._start,t),this._end=Math.max(this._end,e)):(this._start=t,this._end=e,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let t={start:this._start,end:this._end};return this._isBuffering=!1,t}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function Sp(t,e,s,i){let r=s.buffer.x,o=s.buffer.y;if(!s.buffer.hasScrollback)return Cp(r,o,t,e,s,i)+Gi(o,e,s,i)+kp(r,o,t,e,s,i);let a;if(o===e)return a=r>t?"D":"C",Vs(Math.abs(r-t),Us(a,i));a=o>e?"D":"C";let l=Math.abs(o-e),h=wp(o>e?t:r,s)+(l-1)*s.cols+1+yp(o>e?r:t);return Vs(h,Us(a,i))}function yp(t,e){return t-1}function wp(t,e){return e.cols-t}function Cp(t,e,s,i,r,o){return Gi(e,i,r,o).length===0?"":Vs(Hl(t,e,t,e-ss(e,r),!1,r).length,Us("D",o))}function Gi(t,e,s,i){let r=t-ss(t,s),o=e-ss(e,s),a=Math.abs(r-o)-Np(t,e,s);return Vs(a,Us(Fl(t,e),i))}function kp(t,e,s,i,r,o){let a;Gi(e,i,r,o).length>0?a=i-ss(i,r):a=e;let l=i,h=jp(t,e,s,i,r,o);return Vs(Hl(t,a,s,l,h==="C",r).length,Us(h,o))}function Np(t,e,s){let i=0,r=t-ss(t,s),o=e-ss(e,s);for(let a=0;a<Math.abs(r-o);a++){let l=Fl(t,e)==="A"?-1:1;s.buffer.lines.get(r+l*a)?.isWrapped&&i++}return i}function ss(t,e){let s=0,i=e.buffer.lines.get(t),r=i?.isWrapped;for(;r&&t>=0&&t<e.rows;)s++,i=e.buffer.lines.get(--t),r=i?.isWrapped;return s}function jp(t,e,s,i,r,o){let a;return Gi(s,i,r,o).length>0?a=i-ss(i,r):a=e,t<s&&a<=i||t>=s&&a<i?"C":"D"}function Fl(t,e){return t>e?"A":"B"}function Hl(t,e,s,i,r,o){let a=t,l=e,h="";for(;(a!==s||l!==i)&&l>=0&&l<o.buffer.lines.length;)a+=r?1:-1,r&&a>o.cols-1?(h+=o.buffer.translateBufferLineToString(l,!1,t,a),a=0,t=0,l++):!r&&a<0&&(h+=o.buffer.translateBufferLineToString(l,!1,0,t+1),a=o.cols-1,t=a,l--);return h+o.buffer.translateBufferLineToString(l,!1,t,a)}function Us(t,e){let s=e?"O":"[";return U.ESC+s+t}function Vs(t,e){t=Math.floor(t);let s="";for(let i=0;i<t;i++)s+=e;return s}var Ep=class{constructor(t){this._bufferService=t,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let t=this.selectionStart[0]+this.selectionStartLength;return t>this._bufferService.cols?t%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)-1]:[t%this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)]:[t,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let t=this.selectionStart[0]+this.selectionStartLength;return t>this._bufferService.cols?[t%this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)]:[Math.max(t,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let t=this.selectionStart,e=this.selectionEnd;return!t||!e?!1:t[1]>e[1]||t[1]===e[1]&&t[0]>e[0]}handleTrim(t){return this.selectionStart&&(this.selectionStart[1]-=t),this.selectionEnd&&(this.selectionEnd[1]-=t),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function Eo(t,e){if(t.start.y>t.end.y)throw new Error(`Buffer range end (${t.end.x}, ${t.end.y}) cannot be before start (${t.start.x}, ${t.start.y})`);return e*(t.end.y-t.start.y)+(t.end.x-t.start.x+1)}var hr=50,Tp=15,Rp=50,Dp=500,Pp=" ",Ip=new RegExp(Pp,"g"),Jr=class extends de{constructor(t,e,s,i,r,o,a,l,h){super(),this._element=t,this._screenElement=e,this._linkifier=s,this._bufferService=i,this._coreService=r,this._mouseService=o,this._optionsService=a,this._renderService=l,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new ht,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new q),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new q),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new q),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new q),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=c=>this._handleMouseMove(c),this._mouseUpListener=c=>this._handleMouseUp(c),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(c=>this._handleTrim(c)),this._register(this._bufferService.buffers.onBufferActivate(c=>this._handleBufferActivate(c))),this.enable(),this._model=new Ep(this._bufferService),this._activeSelectionMode=0,this._register(ye(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(c=>{c.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let t=this._model.finalSelectionStart,e=this._model.finalSelectionEnd;return!t||!e?!1:t[0]!==e[0]||t[1]!==e[1]}get selectionText(){let t=this._model.finalSelectionStart,e=this._model.finalSelectionEnd;if(!t||!e)return"";let s=this._bufferService.buffer,i=[];if(this._activeSelectionMode===3){if(t[0]===e[0])return"";let r=t[0]<e[0]?t[0]:e[0],o=t[0]<e[0]?e[0]:t[0];for(let a=t[1];a<=e[1];a++){let l=s.translateBufferLineToString(a,!0,r,o);i.push(l)}}else{let r=t[1]===e[1]?e[0]:void 0;i.push(s.translateBufferLineToString(t[1],!0,t[0],r));for(let o=t[1]+1;o<=e[1]-1;o++){let a=s.lines.get(o),l=s.translateBufferLineToString(o,!0);a?.isWrapped?i[i.length-1]+=l:i.push(l)}if(t[1]!==e[1]){let o=s.lines.get(e[1]),a=s.translateBufferLineToString(e[1],!0,0,e[0]);o&&o.isWrapped?i[i.length-1]+=a:i.push(a)}}return i.map(r=>r.replace(Ip," ")).join(Ol?`\r
|
|
278
|
+
`))}},a_=class extends Error{constructor(t,e){super(t),this.name="ListenerLeakError",this.stack=e}},l_=class extends Error{constructor(t,e){super(t),this.name="ListenerRefusalError",this.stack=e}},c_=0,or=class{constructor(t){this.value=t,this.id=c_++}},h_=2,d_,G=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new n_(t?.onListenerError??Si,this._options?.leakWarningThreshold??r_):void 0,this._perfMon=this._options?._profName?new i_(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(t,e,s)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let a=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(a);let l=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],h=new l_(`${a}. HINT: Stack shows most frequent listener (${l[1]}-times)`,l[0]);return(this._options?.onListenerError||Si)(h),de.None}if(this._disposed)return de.None;e&&(t=t.bind(e));let i=new or(t),r;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(i.stack=o_.create(),r=this._leakageMon.check(i.stack,this._size+1)),this._listeners?this._listeners instanceof or?(this._deliveryQueue??=new u_,this._listeners=[this._listeners,i]):this._listeners.push(i):(this._options?.onWillAddFirstListener?.(this),this._listeners=i,this._options?.onDidAddFirstListener?.(this)),this._size++;let o=Se(()=>{r?.(),this._removeListener(i)});return s instanceof zt?s.add(o):Array.isArray(s)&&s.push(o),o},this._event}_removeListener(t){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let e=this._listeners,s=e.indexOf(t);if(s===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,e[s]=void 0;let i=this._deliveryQueue.current===this;if(this._size*h_<=e.length){let r=0;for(let o=0;o<e.length;o++)e[o]?e[r++]=e[o]:i&&(this._deliveryQueue.end--,r<this._deliveryQueue.i&&this._deliveryQueue.i--);e.length=r}}_deliver(t,e){if(!t)return;let s=this._options?.onListenerError||Si;if(!s){t.value(e);return}try{t.value(e)}catch(i){s(i)}}_deliverQueue(t){let e=t.current._listeners;for(;t.i<t.end;)this._deliver(e[t.i++],t.value);t.reset()}fire(t){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof or)this._deliver(this._listeners,t);else{let e=this._deliveryQueue;e.enqueue(this,t,this._listeners.length),this._deliverQueue(e)}this._perfMon?.stop()}hasListeners(){return this._size>0}},u_=class{constructor(){this.i=-1,this.end=0}enqueue(t,e,s){this.i=0,this.end=s,this.current=t,this.value=e}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Br=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new G,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new G,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,s){if(this.getZoomLevel(s)===e)return;let i=this.getWindowId(s);this.mapWindowIdToZoomLevel.set(i,e),this._onDidChangeZoomLevel.fire(i)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,s){this.mapWindowIdToZoomFactor.set(this.getWindowId(s),e)}setFullscreen(e,s){if(this.isFullscreen(s)===e)return;let i=this.getWindowId(s);this.mapWindowIdToFullScreen.set(i,e),this._onDidChangeFullscreen.fire(i)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};Br.INSTANCE=new Br;var Rn=Br;function f_(t,e,s){typeof e=="string"&&(e=t.matchMedia(e)),e.addEventListener("change",s)}Rn.INSTANCE.onDidChangeZoomLevel;function m_(t){return Rn.INSTANCE.getZoomFactor(t)}Rn.INSTANCE.onDidChangeFullscreen;var Ss=typeof navigator=="object"?navigator.userAgent:"",Lr=Ss.indexOf("Firefox")>=0,__=Ss.indexOf("AppleWebKit")>=0,Dn=Ss.indexOf("Chrome")>=0,p_=!Dn&&Ss.indexOf("Safari")>=0;Ss.indexOf("Electron/")>=0;Ss.indexOf("Android")>=0;var ar=!1;if(typeof Tt.matchMedia=="function"){let t=Tt.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),e=Tt.matchMedia("(display-mode: fullscreen)");ar=t.matches,f_(Tt,t,({matches:s})=>{ar&&e.matches||(ar=s)})}var ds="en",Or=!1,$r=!1,yi=!1,Dl=!1,hi,wi=ds,vo=ds,g_,Et,Xt=globalThis,rt;typeof Xt.vscode<"u"&&typeof Xt.vscode.process<"u"?rt=Xt.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(rt=process);var v_=typeof rt?.versions?.electron=="string",x_=v_&&rt?.type==="renderer";if(typeof rt=="object"){Or=rt.platform==="win32",$r=rt.platform==="darwin",yi=rt.platform==="linux",yi&&rt.env.SNAP&&rt.env.SNAP_REVISION,rt.env.CI||rt.env.BUILD_ARTIFACTSTAGINGDIRECTORY,hi=ds,wi=ds;let t=rt.env.VSCODE_NLS_CONFIG;if(t)try{let e=JSON.parse(t);hi=e.userLocale,vo=e.osLocale,wi=e.resolvedLanguage||ds,g_=e.languagePack?.translationsConfigFile}catch{}Dl=!0}else typeof navigator=="object"&&!x_?(Et=navigator.userAgent,Or=Et.indexOf("Windows")>=0,$r=Et.indexOf("Macintosh")>=0,(Et.indexOf("Macintosh")>=0||Et.indexOf("iPad")>=0||Et.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,yi=Et.indexOf("Linux")>=0,Et?.indexOf("Mobi")>=0,wi=globalThis._VSCODE_NLS_LANGUAGE||ds,hi=navigator.language.toLowerCase(),vo=hi):console.error("Unable to resolve platform.");var Pl=Or,wt=$r,b_=yi,xo=Dl,kt=Et,At=wi,S_;(t=>{function e(){return At}t.value=e;function s(){return At.length===2?At==="en":At.length>=3?At[0]==="e"&&At[1]==="n"&&At[2]==="-":!1}t.isDefaultVariant=s;function i(){return At==="en"}t.isDefault=i})(S_||={});var y_=typeof Xt.postMessage=="function"&&!Xt.importScripts;(()=>{if(y_){let t=[];Xt.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let i=0,r=t.length;i<r;i++){let o=t[i];if(o.id===s.data.vscodeScheduleAsyncWork){t.splice(i,1),o.callback();return}}});let e=0;return s=>{let i=++e;t.push({id:i,callback:s}),Xt.postMessage({vscodeScheduleAsyncWork:i},"*")}}return t=>setTimeout(t)})();var w_=!!(kt&&kt.indexOf("Chrome")>=0);kt&&kt.indexOf("Firefox")>=0;!w_&&kt&&kt.indexOf("Safari")>=0;kt&&kt.indexOf("Edg/")>=0;kt&&kt.indexOf("Android")>=0;var ls=typeof navigator=="object"?navigator:{};xo||document.queryCommandSupported&&document.queryCommandSupported("copy")||ls&&ls.clipboard&&ls.clipboard.writeText,xo||ls&&ls.clipboard&&ls.clipboard.readText;var Pn=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(t,e){this._keyCodeToStr[t]=e,this._strToKeyCode[e.toLowerCase()]=t}keyCodeToStr(t){return this._keyCodeToStr[t]}strToKeyCode(t){return this._strToKeyCode[t.toLowerCase()]||0}},lr=new Pn,bo=new Pn,So=new Pn,C_=new Array(230),Il;(t=>{function e(l){return lr.keyCodeToStr(l)}t.toString=e;function s(l){return lr.strToKeyCode(l)}t.fromString=s;function i(l){return bo.keyCodeToStr(l)}t.toUserSettingsUS=i;function r(l){return So.keyCodeToStr(l)}t.toUserSettingsGeneral=r;function o(l){return bo.strToKeyCode(l)||So.strToKeyCode(l)}t.fromUserSettings=o;function a(l){if(l>=98&&l<=113)return null;switch(l){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return lr.keyCodeToStr(l)}t.toElectronAccelerator=a})(Il||={});var k_=class Ml{constructor(e,s,i,r,o){this.ctrlKey=e,this.shiftKey=s,this.altKey=i,this.metaKey=r,this.keyCode=o}equals(e){return e instanceof Ml&&this.ctrlKey===e.ctrlKey&&this.shiftKey===e.shiftKey&&this.altKey===e.altKey&&this.metaKey===e.metaKey&&this.keyCode===e.keyCode}getHashCode(){let e=this.ctrlKey?"1":"0",s=this.shiftKey?"1":"0",i=this.altKey?"1":"0",r=this.metaKey?"1":"0";return`K${e}${s}${i}${r}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new N_([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},N_=class{constructor(t){if(t.length===0)throw Jm("chords");this.chords=t}getHashCode(){let t="";for(let e=0,s=this.chords.length;e<s;e++)e!==0&&(t+=";"),t+=this.chords[e].getHashCode();return t}equals(t){if(t===null||this.chords.length!==t.chords.length)return!1;for(let e=0;e<this.chords.length;e++)if(!this.chords[e].equals(t.chords[e]))return!1;return!0}};function j_(t){if(t.charCode){let s=String.fromCharCode(t.charCode).toUpperCase();return Il.fromString(s)}let e=t.keyCode;if(e===3)return 7;if(Lr)switch(e){case 59:return 85;case 60:if(b_)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(wt)return 57;break}else if(__&&(wt&&e===93||!wt&&e===92))return 57;return C_[e]||0}var E_=wt?256:2048,T_=512,R_=1024,D_=wt?2048:256,yo=class{constructor(t){this._standardKeyboardEventBrand=!0;let e=t;this.browserEvent=e,this.target=e.target,this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey,this.altGraphKey=e.getModifierState?.("AltGraph"),this.keyCode=j_(e),this.code=e.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(t){return this._asKeybinding===t}_computeKeybinding(){let t=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(t=this.keyCode);let e=0;return this.ctrlKey&&(e|=E_),this.altKey&&(e|=T_),this.shiftKey&&(e|=R_),this.metaKey&&(e|=D_),e|=t,e}_computeKeyCodeChord(){let t=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(t=this.keyCode),new k_(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,t)}},wo=new WeakMap;function P_(t){if(!t.parent||t.parent===t)return null;try{let e=t.location,s=t.parent.location;if(e.origin!=="null"&&s.origin!=="null"&&e.origin!==s.origin)return null}catch{return null}return t.parent}var I_=class{static getSameOriginWindowChain(t){let e=wo.get(t);if(!e){e=[],wo.set(t,e);let s=t,i;do i=P_(s),i?e.push({window:new WeakRef(s),iframeElement:s.frameElement||null}):e.push({window:new WeakRef(s),iframeElement:null}),s=i;while(s)}return e.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(t,e){if(!e||t===e)return{top:0,left:0};let s=0,i=0,r=this.getSameOriginWindowChain(t);for(let o of r){let a=o.window.deref();if(s+=a?.scrollY??0,i+=a?.scrollX??0,a===e||!o.iframeElement)break;let l=o.iframeElement.getBoundingClientRect();s+=l.top,i+=l.left}return{top:s,left:i}}},di=class{constructor(t,e){this.timestamp=Date.now(),this.browserEvent=e,this.leftButton=e.button===0,this.middleButton=e.button===1,this.rightButton=e.button===2,this.buttons=e.buttons,this.target=e.target,this.detail=e.detail||1,e.type==="dblclick"&&(this.detail=2),this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey,typeof e.pageX=="number"?(this.posx=e.pageX,this.posy=e.pageY):(this.posx=e.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=e.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let s=I_.getPositionOfChildWindowRelativeToAncestorWindow(t,e.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Co=class{constructor(t,e=0,s=0){this.browserEvent=t||null,this.target=t?t.target||t.targetNode||t.srcElement:null,this.deltaY=s,this.deltaX=e;let i=!1;if(Dn){let r=navigator.userAgent.match(/Chrome\/(\d+)/);i=(r?parseInt(r[1]):123)<=122}if(t){let r=t,o=t,a=t.view?.devicePixelRatio||1;if(typeof r.wheelDeltaY<"u")i?this.deltaY=r.wheelDeltaY/(120*a):this.deltaY=r.wheelDeltaY/120;else if(typeof o.VERTICAL_AXIS<"u"&&o.axis===o.VERTICAL_AXIS)this.deltaY=-o.detail/3;else if(t.type==="wheel"){let l=t;l.deltaMode===l.DOM_DELTA_LINE?Lr&&!wt?this.deltaY=-t.deltaY/3:this.deltaY=-t.deltaY:this.deltaY=-t.deltaY/40}if(typeof r.wheelDeltaX<"u")p_&&Pl?this.deltaX=-(r.wheelDeltaX/120):i?this.deltaX=r.wheelDeltaX/(120*a):this.deltaX=r.wheelDeltaX/120;else if(typeof o.HORIZONTAL_AXIS<"u"&&o.axis===o.HORIZONTAL_AXIS)this.deltaX=-t.detail/3;else if(t.type==="wheel"){let l=t;l.deltaMode===l.DOM_DELTA_LINE?Lr&&!wt?this.deltaX=-t.deltaX/3:this.deltaX=-t.deltaX:this.deltaX=-t.deltaX/40}this.deltaY===0&&this.deltaX===0&&t.wheelDelta&&(i?this.deltaY=t.wheelDelta/(120*a):this.deltaY=t.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},Al=Object.freeze(function(t,e){let s=setTimeout(t.bind(e),0);return{dispose(){clearTimeout(s)}}}),M_;(t=>{function e(s){return s===t.None||s===t.Cancelled||s instanceof A_?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}t.isCancellationToken=e,t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:qe.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Al})})(M_||={});var A_=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?Al:(this._emitter||(this._emitter=new G),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},In=class{constructor(t,e){this._isDisposed=!1,this._token=-1,typeof t=="function"&&typeof e=="number"&&this.setIfNotSet(t,e)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(t,e){if(this._isDisposed)throw new Dr("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,t()},e)}setIfNotSet(t,e){if(this._isDisposed)throw new Dr("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,t()},e))}},B_=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(t,e,s=globalThis){if(this.isDisposed)throw new Dr("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let i=s.setInterval(()=>{t()},e);this.disposable=Se(()=>{s.clearInterval(i),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},L_;(t=>{async function e(i){let r,o=await Promise.all(i.map(a=>a.then(l=>l,l=>{r||(r=l)})));if(typeof r<"u")throw r;return o}t.settled=e;function s(i){return new Promise(async(r,o)=>{try{await i(r,o)}catch(a){o(a)}})}t.withAsyncBody=s})(L_||={});var ko=class lt{static fromArray(e){return new lt(s=>{s.emitMany(e)})}static fromPromise(e){return new lt(async s=>{s.emitMany(await e)})}static fromPromises(e){return new lt(async s=>{await Promise.all(e.map(async i=>s.emitOne(await i)))})}static merge(e){return new lt(async s=>{await Promise.all(e.map(async i=>{for await(let r of i)s.emitOne(r)}))})}constructor(e,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new G,queueMicrotask(async()=>{let i={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(e(i)),this.resolve()}catch(r){this.reject(r)}finally{i.emitOne=void 0,i.emitMany=void 0,i.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await qe.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(e,s){return new lt(async i=>{for await(let r of e)i.emitOne(s(r))})}map(e){return lt.map(this,e)}static filter(e,s){return new lt(async i=>{for await(let r of e)s(r)&&i.emitOne(r)})}filter(e){return lt.filter(this,e)}static coalesce(e){return lt.filter(e,s=>!!s)}coalesce(){return lt.coalesce(this)}static async toPromise(e){let s=[];for await(let i of e)s.push(i);return s}toPromise(){return lt.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};ko.EMPTY=ko.fromArray([]);var{getWindow:yt,getWindowId:O_,onDidRegisterWindow:$_}=(function(){let t=new Map,e={window:Tt,disposables:new zt};t.set(Tt.vscodeWindowId,e);let s=new G,i=new G,r=new G;function o(a,l){return(typeof a=="number"?t.get(a):void 0)??(l?e:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:i.event,registerWindow(a){if(t.has(a.vscodeWindowId))return de.None;let l=new zt,h={window:a,disposables:l.add(new zt)};return t.set(a.vscodeWindowId,h),l.add(Se(()=>{t.delete(a.vscodeWindowId),i.fire(a)})),l.add(oe(a,ze.BEFORE_UNLOAD,()=>{r.fire(a)})),s.fire(h),l},getWindows(){return t.values()},getWindowsCount(){return t.size},getWindowId(a){return a.vscodeWindowId},hasWindow(a){return t.has(a)},getWindowById:o,getWindow(a){let l=a;if(l?.ownerDocument?.defaultView)return l.ownerDocument.defaultView.window;let h=a;return h?.view?h.view.window:Tt},getDocument(a){return yt(a).document}}})(),z_=class{constructor(t,e,s,i){this._node=t,this._type=e,this._handler=s,this._options=i||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function oe(t,e,s,i){return new z_(t,e,s,i)}var No=function(t,e,s,i){return oe(t,e,s,i)},Mn,F_=class extends B_{constructor(t){super(),this.defaultTarget=t&&yt(t)}cancelAndSet(t,e,s){return super.cancelAndSet(t,e,s??this.defaultTarget)}},jo=class{constructor(t,e=0){this._runner=t,this.priority=e,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(t){Si(t)}}static sort(t,e){return e.priority-t.priority}};(function(){let t=new Map,e=new Map,s=new Map,i=new Map,r=o=>{s.set(o,!1);let a=t.get(o)??[];for(e.set(o,a),t.set(o,[]),i.set(o,!0);a.length>0;)a.sort(jo.sort),a.shift().execute();i.set(o,!1)};Mn=(o,a,l=0)=>{let h=O_(o),c=new jo(a,l),d=t.get(h);return d||(d=[],t.set(h,d)),d.push(c),s.get(h)||(s.set(h,!0),o.requestAnimationFrame(()=>r(h))),c}})();function H_(t){let e=t.getBoundingClientRect(),s=yt(t);return{left:e.left+s.scrollX,top:e.top+s.scrollY,width:e.width,height:e.height}}var ze={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},W_=class{constructor(t){this.domNode=t,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(t){let e=et(t);this._maxWidth!==e&&(this._maxWidth=e,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let e=et(t);this._width!==e&&(this._width=e,this.domNode.style.width=this._width)}setHeight(t){let e=et(t);this._height!==e&&(this._height=e,this.domNode.style.height=this._height)}setTop(t){let e=et(t);this._top!==e&&(this._top=e,this.domNode.style.top=this._top)}setLeft(t){let e=et(t);this._left!==e&&(this._left=e,this.domNode.style.left=this._left)}setBottom(t){let e=et(t);this._bottom!==e&&(this._bottom=e,this.domNode.style.bottom=this._bottom)}setRight(t){let e=et(t);this._right!==e&&(this._right=e,this.domNode.style.right=this._right)}setPaddingTop(t){let e=et(t);this._paddingTop!==e&&(this._paddingTop=e,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let e=et(t);this._paddingLeft!==e&&(this._paddingLeft=e,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let e=et(t);this._paddingBottom!==e&&(this._paddingBottom=e,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let e=et(t);this._paddingRight!==e&&(this._paddingRight=e,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(t){let e=et(t);this._fontSize!==e&&(this._fontSize=e,this.domNode.style.fontSize=this._fontSize)}setFontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(t){this._fontFeatureSettings!==t&&(this._fontFeatureSettings=t,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(t){this._fontVariationSettings!==t&&(this._fontVariationSettings=t,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(t){this._textDecoration!==t&&(this._textDecoration=t,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(t){let e=et(t);this._lineHeight!==e&&(this._lineHeight=e,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let e=et(t);this._letterSpacing!==e&&(this._letterSpacing=e,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(t){this._className!==t&&(this._className=t,this.domNode.className=this._className)}toggleClassName(t,e){this.domNode.classList.toggle(t,e),this._className=this.domNode.className}setDisplay(t){this._display!==t&&(this._display=t,this.domNode.style.display=this._display)}setPosition(t){this._position!==t&&(this._position=t,this.domNode.style.position=this._position)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this.domNode.style.visibility=this._visibility)}setColor(t){this._color!==t&&(this._color=t,this.domNode.style.color=this._color)}setBackgroundColor(t){this._backgroundColor!==t&&(this._backgroundColor=t,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(t){this._layerHint!==t&&(this._layerHint=t,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(t){this._boxShadow!==t&&(this._boxShadow=t,this.domNode.style.boxShadow=t)}setContain(t){this._contain!==t&&(this._contain=t,this.domNode.style.contain=this._contain)}setAttribute(t,e){this.domNode.setAttribute(t,e)}removeAttribute(t){this.domNode.removeAttribute(t)}appendChild(t){this.domNode.appendChild(t.domNode)}removeChild(t){this.domNode.removeChild(t.domNode)}};function et(t){return typeof t=="number"?`${t}px`:t}function zs(t){return new W_(t)}var Bl=class{constructor(){this._hooks=new zt,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(t,e){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,t&&s&&s(e)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(t,e,s,i,r){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=i,this._onStopCallback=r;let o=t;try{t.setPointerCapture(e),this._hooks.add(Se(()=>{try{t.releasePointerCapture(e)}catch{}}))}catch{o=yt(t)}this._hooks.add(oe(o,ze.POINTER_MOVE,a=>{if(a.buttons!==s){this.stopMonitoring(!0);return}a.preventDefault(),this._pointerMoveCallback(a)})),this._hooks.add(oe(o,ze.POINTER_UP,a=>this.stopMonitoring(!0)))}};function U_(t,e,s){let i=null,r=null;if(typeof s.value=="function"?(i="value",r=s.value,r.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof s.get=="function"&&(i="get",r=s.get),!r)throw new Error("not supported");let o=`$memoize$${e}`;s[i]=function(...a){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,a)}),this[o]}}var bt;(t=>(t.Tap="-xterm-gesturetap",t.Change="-xterm-gesturechange",t.Start="-xterm-gesturestart",t.End="-xterm-gesturesend",t.Contextmenu="-xterm-gesturecontextmenu"))(bt||={});var Ps=class Ge extends de{constructor(){super(),this.dispatched=!1,this.targets=new go,this.ignoreTargets=new go,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(qe.runAndSubscribe($_,({window:e,disposables:s})=>{s.add(oe(e.document,"touchstart",i=>this.onTouchStart(i),{passive:!1})),s.add(oe(e.document,"touchend",i=>this.onTouchEnd(e,i))),s.add(oe(e.document,"touchmove",i=>this.onTouchMove(i),{passive:!1}))},{window:Tt,disposables:this._store}))}static addTarget(e){if(!Ge.isTouchDevice())return de.None;Ge.INSTANCE||(Ge.INSTANCE=new Ge);let s=Ge.INSTANCE.targets.push(e);return Se(s)}static ignoreTarget(e){if(!Ge.isTouchDevice())return de.None;Ge.INSTANCE||(Ge.INSTANCE=new Ge);let s=Ge.INSTANCE.ignoreTargets.push(e);return Se(s)}static isTouchDevice(){return"ontouchstart"in Tt||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(e){let s=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let i=0,r=e.targetTouches.length;i<r;i++){let o=e.targetTouches.item(i);this.activeTouches[o.identifier]={id:o.identifier,initialTarget:o.target,initialTimeStamp:s,initialPageX:o.pageX,initialPageY:o.pageY,rollingTimestamps:[s],rollingPageX:[o.pageX],rollingPageY:[o.pageY]};let a=this.newGestureEvent(bt.Start,o.target);a.pageX=o.pageX,a.pageY=o.pageY,this.dispatchEvent(a)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}onTouchEnd(e,s){let i=Date.now(),r=Object.keys(this.activeTouches).length;for(let o=0,a=s.changedTouches.length;o<a;o++){let l=s.changedTouches.item(o);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("move of an UNKNOWN touch",l);continue}let h=this.activeTouches[l.identifier],c=Date.now()-h.initialTimeStamp;if(c<Ge.HOLD_DELAY&&Math.abs(h.initialPageX-st(h.rollingPageX))<30&&Math.abs(h.initialPageY-st(h.rollingPageY))<30){let d=this.newGestureEvent(bt.Tap,h.initialTarget);d.pageX=st(h.rollingPageX),d.pageY=st(h.rollingPageY),this.dispatchEvent(d)}else if(c>=Ge.HOLD_DELAY&&Math.abs(h.initialPageX-st(h.rollingPageX))<30&&Math.abs(h.initialPageY-st(h.rollingPageY))<30){let d=this.newGestureEvent(bt.Contextmenu,h.initialTarget);d.pageX=st(h.rollingPageX),d.pageY=st(h.rollingPageY),this.dispatchEvent(d)}else if(r===1){let d=st(h.rollingPageX),u=st(h.rollingPageY),f=st(h.rollingTimestamps)-h.rollingTimestamps[0],m=d-h.rollingPageX[0],_=u-h.rollingPageY[0],p=[...this.targets].filter(g=>h.initialTarget instanceof Node&&g.contains(h.initialTarget));this.inertia(e,p,i,Math.abs(m)/f,m>0?1:-1,d,Math.abs(_)/f,_>0?1:-1,u)}this.dispatchEvent(this.newGestureEvent(bt.End,h.initialTarget)),delete this.activeTouches[l.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(e,s){let i=document.createEvent("CustomEvent");return i.initEvent(e,!1,!0),i.initialTarget=s,i.tapCount=0,i}dispatchEvent(e){if(e.type===bt.Tap){let s=new Date().getTime(),i=0;s-this._lastSetTapCountTime>Ge.CLEAR_TAP_COUNT_TIME?i=1:i=2,this._lastSetTapCountTime=s,e.tapCount=i}else(e.type===bt.Change||e.type===bt.Contextmenu)&&(this._lastSetTapCountTime=0);if(e.initialTarget instanceof Node){for(let i of this.ignoreTargets)if(i.contains(e.initialTarget))return;let s=[];for(let i of this.targets)if(i.contains(e.initialTarget)){let r=0,o=e.initialTarget;for(;o&&o!==i;)r++,o=o.parentElement;s.push([r,i])}s.sort((i,r)=>i[0]-r[0]);for(let[i,r]of s)r.dispatchEvent(e),this.dispatched=!0}}inertia(e,s,i,r,o,a,l,h,c){this.handle=Mn(e,()=>{let d=Date.now(),u=d-i,f=0,m=0,_=!0;r+=Ge.SCROLL_FRICTION*u,l+=Ge.SCROLL_FRICTION*u,r>0&&(_=!1,f=o*r*u),l>0&&(_=!1,m=h*l*u);let p=this.newGestureEvent(bt.Change);p.translationX=f,p.translationY=m,s.forEach(g=>g.dispatchEvent(p)),_||this.inertia(e,s,d,r,o,a+f,l,h,c+m)})}onTouchMove(e){let s=Date.now();for(let i=0,r=e.changedTouches.length;i<r;i++){let o=e.changedTouches.item(i);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn("end of an UNKNOWN touch",o);continue}let a=this.activeTouches[o.identifier],l=this.newGestureEvent(bt.Change,a.initialTarget);l.translationX=o.pageX-st(a.rollingPageX),l.translationY=o.pageY-st(a.rollingPageY),l.pageX=o.pageX,l.pageY=o.pageY,this.dispatchEvent(l),a.rollingPageX.length>3&&(a.rollingPageX.shift(),a.rollingPageY.shift(),a.rollingTimestamps.shift()),a.rollingPageX.push(o.pageX),a.rollingPageY.push(o.pageY),a.rollingTimestamps.push(s)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}};Ps.SCROLL_FRICTION=-.005,Ps.HOLD_DELAY=700,Ps.CLEAR_TAP_COUNT_TIME=400,Te([U_],Ps,"isTouchDevice",1);var V_=Ps,An=class extends de{onclick(t,e){this._register(oe(t,ze.CLICK,s=>e(new di(yt(t),s))))}onmousedown(t,e){this._register(oe(t,ze.MOUSE_DOWN,s=>e(new di(yt(t),s))))}onmouseover(t,e){this._register(oe(t,ze.MOUSE_OVER,s=>e(new di(yt(t),s))))}onmouseleave(t,e){this._register(oe(t,ze.MOUSE_LEAVE,s=>e(new di(yt(t),s))))}onkeydown(t,e){this._register(oe(t,ze.KEY_DOWN,s=>e(new yo(s))))}onkeyup(t,e){this._register(oe(t,ze.KEY_UP,s=>e(new yo(s))))}oninput(t,e){this._register(oe(t,ze.INPUT,e))}onblur(t,e){this._register(oe(t,ze.BLUR,e))}onfocus(t,e){this._register(oe(t,ze.FOCUS,e))}onchange(t,e){this._register(oe(t,ze.CHANGE,e))}ignoreGesture(t){return V_.ignoreTarget(t)}},Eo=11,K_=class extends An{constructor(t){super(),this._onActivate=t.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=t.bgWidth+"px",this.bgDomNode.style.height=t.bgHeight+"px",typeof t.top<"u"&&(this.bgDomNode.style.top="0px"),typeof t.left<"u"&&(this.bgDomNode.style.left="0px"),typeof t.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof t.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=t.className,this.domNode.style.position="absolute",this.domNode.style.width=Eo+"px",this.domNode.style.height=Eo+"px",typeof t.top<"u"&&(this.domNode.style.top=t.top+"px"),typeof t.left<"u"&&(this.domNode.style.left=t.left+"px"),typeof t.bottom<"u"&&(this.domNode.style.bottom=t.bottom+"px"),typeof t.right<"u"&&(this.domNode.style.right=t.right+"px"),this._pointerMoveMonitor=this._register(new Bl),this._register(No(this.bgDomNode,ze.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(No(this.domNode,ze.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new F_),this._pointerdownScheduleRepeatTimer=this._register(new In)}_arrowPointerDown(t){if(!t.target||!(t.target instanceof Element))return;let e=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,yt(t))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(e,200),this._pointerMoveMonitor.startMonitoring(t.target,t.pointerId,t.buttons,s=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),t.preventDefault()}},q_=class zr{constructor(e,s,i,r,o,a,l){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,i=i|0,r=r|0,o=o|0,a=a|0,l=l|0),this.rawScrollLeft=r,this.rawScrollTop=l,s<0&&(s=0),r+s>i&&(r=i-s),r<0&&(r=0),o<0&&(o=0),l+o>a&&(l=a-o),l<0&&(l=0),this.width=s,this.scrollWidth=i,this.scrollLeft=r,this.height=o,this.scrollHeight=a,this.scrollTop=l}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(e,s){return new zr(this._forceIntegerValues,typeof e.width<"u"?e.width:this.width,typeof e.scrollWidth<"u"?e.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof e.height<"u"?e.height:this.height,typeof e.scrollHeight<"u"?e.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(e){return new zr(this._forceIntegerValues,this.width,this.scrollWidth,typeof e.scrollLeft<"u"?e.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof e.scrollTop<"u"?e.scrollTop:this.rawScrollTop)}createScrollEvent(e,s){let i=this.width!==e.width,r=this.scrollWidth!==e.scrollWidth,o=this.scrollLeft!==e.scrollLeft,a=this.height!==e.height,l=this.scrollHeight!==e.scrollHeight,h=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:s,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:i,scrollWidthChanged:r,scrollLeftChanged:o,heightChanged:a,scrollHeightChanged:l,scrollTopChanged:h}}},G_=class extends de{constructor(t){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new G),this.onScroll=this._onScroll.event,this._smoothScrollDuration=t.smoothScrollDuration,this._scheduleAtNextAnimationFrame=t.scheduleAtNextAnimationFrame,this._state=new q_(t.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(t){this._smoothScrollDuration=t}validateScrollPosition(t){return this._state.withScrollPosition(t)}getScrollDimensions(){return this._state}setScrollDimensions(t,e){let s=this._state.withScrollDimensions(t,e);this._setState(s,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(t){let e=this._state.withScrollPosition(t);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(e,!1)}setScrollPositionSmooth(t,e){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(t);if(this._smoothScrolling){t={scrollLeft:typeof t.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:t.scrollLeft,scrollTop:typeof t.scrollTop>"u"?this._smoothScrolling.to.scrollTop:t.scrollTop};let s=this._state.withScrollPosition(t);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;let i;e?i=new Ro(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):i=this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=i}else{let s=this._state.withScrollPosition(t);this._smoothScrolling=Ro.start(this._state,s,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let t=this._smoothScrolling.tick(),e=this._state.withScrollPosition(t);if(this._setState(e,!0),!!this._smoothScrolling){if(t.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(t,e){let s=this._state;s.equals(t)||(this._state=t,this._onScroll.fire(this._state.createScrollEvent(s,e)))}},To=class{constructor(t,e,s){this.scrollLeft=t,this.scrollTop=e,this.isDone=s}};function cr(t,e){let s=e-t;return function(i){return t+s*J_(i)}}function Y_(t,e,s){return function(i){return i<s?t(i/s):e((i-s)/(1-s))}}var Ro=class Fr{constructor(e,s,i,r){this.from=e,this.to=s,this.duration=r,this.startTime=i,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(e,s,i){if(Math.abs(e-s)>2.5*i){let r,o;return e<s?(r=e+.75*i,o=s-.75*i):(r=e-.75*i,o=s+.75*i),Y_(cr(e,r),cr(o,s),.33)}return cr(e,s)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let s=(e-this.startTime)/this.duration;if(s<1){let i=this.scrollLeft(s),r=this.scrollTop(s);return new To(i,r,!1)}return new To(this.to.scrollLeft,this.to.scrollTop,!0)}combine(e,s,i){return Fr.start(e,s,i)}static start(e,s,i){i=i+10;let r=Date.now()-10;return new Fr(e,s,r,i)}};function X_(t){return Math.pow(t,3)}function J_(t){return 1-X_(1-t)}var Z_=class extends de{constructor(t,e,s){super(),this._visibility=t,this._visibleClassName=e,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new In)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this._updateShouldBeVisible())}setShouldBeVisible(t){this._rawShouldBeVisible=t,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let t=this._applyVisibilitySetting();this._shouldBeVisible!==t&&(this._shouldBeVisible=t,this.ensureVisibility())}setIsNeeded(t){this._isNeeded!==t&&(this._isNeeded=t,this.ensureVisibility())}setDomNode(t){this._domNode=t,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(t){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(t?" fade":"")))}},Q_=140,Ll=class extends An{constructor(t){super(),this._lazyRender=t.lazyRender,this._host=t.host,this._scrollable=t.scrollable,this._scrollByPage=t.scrollByPage,this._scrollbarState=t.scrollbarState,this._visibilityController=this._register(new Z_(t.visibility,"visible scrollbar "+t.extraScrollbarClassName,"invisible scrollbar "+t.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Bl),this._shouldRender=!0,this.domNode=zs(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(oe(this.domNode.domNode,ze.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(t){let e=this._register(new K_(t));this.domNode.domNode.appendChild(e.bgDomNode),this.domNode.domNode.appendChild(e.domNode)}_createSlider(t,e,s,i){this.slider=zs(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(t),this.slider.setLeft(e),typeof s=="number"&&this.slider.setWidth(s),typeof i=="number"&&this.slider.setHeight(i),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(oe(this.slider.domNode,ze.POINTER_DOWN,r=>{r.button===0&&(r.preventDefault(),this._sliderPointerDown(r))})),this.onclick(this.slider.domNode,r=>{r.leftButton&&r.stopPropagation()})}_onElementSize(t){return this._scrollbarState.setVisibleSize(t)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(t){return this._scrollbarState.setScrollSize(t)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(t){return this._scrollbarState.setScrollPosition(t)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(t){t.target===this.domNode.domNode&&this._onPointerDown(t)}delegatePointerDown(t){let e=this.domNode.domNode.getClientRects()[0].top,s=e+this._scrollbarState.getSliderPosition(),i=e+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),r=this._sliderPointerPosition(t);s<=r&&r<=i?t.button===0&&(t.preventDefault(),this._sliderPointerDown(t)):this._onPointerDown(t)}_onPointerDown(t){let e,s;if(t.target===this.domNode.domNode&&typeof t.offsetX=="number"&&typeof t.offsetY=="number")e=t.offsetX,s=t.offsetY;else{let r=H_(this.domNode.domNode);e=t.pageX-r.left,s=t.pageY-r.top}let i=this._pointerDownRelativePosition(e,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(i):this._scrollbarState.getDesiredScrollPositionFromOffset(i)),t.button===0&&(t.preventDefault(),this._sliderPointerDown(t))}_sliderPointerDown(t){if(!t.target||!(t.target instanceof Element))return;let e=this._sliderPointerPosition(t),s=this._sliderOrthogonalPointerPosition(t),i=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(t.target,t.pointerId,t.buttons,r=>{let o=this._sliderOrthogonalPointerPosition(r),a=Math.abs(o-s);if(Pl&&a>Q_){this._setDesiredScrollPositionNow(i.getScrollPosition());return}let l=this._sliderPointerPosition(r)-e;this._setDesiredScrollPositionNow(i.getDesiredScrollPositionFromDelta(l))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(t){let e={};this.writeScrollPosition(e,t),this._scrollable.setScrollPositionNow(e)}updateScrollbarSize(t){this._updateScrollbarSize(t),this._scrollbarState.setScrollbarSize(t),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},Ol=class Hr{constructor(e,s,i,r,o,a){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(i),this._arrowSize=Math.round(e),this._visibleSize=r,this._scrollSize=o,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Hr(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let s=Math.round(e);return this._visibleSize!==s?(this._visibleSize=s,this._refreshComputedValues(),!0):!1}setScrollSize(e){let s=Math.round(e);return this._scrollSize!==s?(this._scrollSize=s,this._refreshComputedValues(),!0):!1}setScrollPosition(e){let s=Math.round(e);return this._scrollPosition!==s?(this._scrollPosition=s,this._refreshComputedValues(),!0):!1}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,s,i,r,o){let a=Math.max(0,i-e),l=Math.max(0,a-2*s),h=r>0&&r>i;if(!h)return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(l),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(i*l/r))),d=(l-c)/(r-i),u=o*d;return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(c),computedSliderRatio:d,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let e=Hr._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=e.computedAvailableSize,this._computedIsNeeded=e.computedIsNeeded,this._computedSliderSize=e.computedSliderSize,this._computedSliderRatio=e.computedSliderRatio,this._computedSliderPosition=e.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){if(!this._computedIsNeeded)return 0;let s=e-this._arrowSize-this._computedSliderSize/2;return Math.round(s/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let s=e-this._arrowSize,i=this._scrollPosition;return s<this._computedSliderPosition?i-=this._visibleSize:i+=this._visibleSize,i}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let s=this._computedSliderPosition+e;return Math.round(s/this._computedSliderRatio)}},ep=class extends Ll{constructor(t,e,s){let i=t.getScrollDimensions(),r=t.getCurrentScrollPosition();if(super({lazyRender:e.lazyRender,host:s,scrollbarState:new Ol(e.horizontalHasArrows?e.arrowSize:0,e.horizontal===2?0:e.horizontalScrollbarSize,e.vertical===2?0:e.verticalScrollbarSize,i.width,i.scrollWidth,r.scrollLeft),visibility:e.horizontal,extraScrollbarClassName:"horizontal",scrollable:t,scrollByPage:e.scrollByPage}),e.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((e.horizontalScrollbarSize-e.horizontalSliderSize)/2),0,void 0,e.horizontalSliderSize)}_updateSlider(t,e){this.slider.setWidth(t),this.slider.setLeft(e)}_renderDomNode(t,e){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(t){return this._shouldRender=this._onElementScrollSize(t.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(t.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(t.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(t,e){return t}_sliderPointerPosition(t){return t.pageX}_sliderOrthogonalPointerPosition(t){return t.pageY}_updateScrollbarSize(t){this.slider.setHeight(t)}writeScrollPosition(t,e){t.scrollLeft=e}updateOptions(t){this.updateScrollbarSize(t.horizontal===2?0:t.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(t.vertical===2?0:t.verticalScrollbarSize),this._visibilityController.setVisibility(t.horizontal),this._scrollByPage=t.scrollByPage}},tp=class extends Ll{constructor(t,e,s){let i=t.getScrollDimensions(),r=t.getCurrentScrollPosition();if(super({lazyRender:e.lazyRender,host:s,scrollbarState:new Ol(e.verticalHasArrows?e.arrowSize:0,e.vertical===2?0:e.verticalScrollbarSize,0,i.height,i.scrollHeight,r.scrollTop),visibility:e.vertical,extraScrollbarClassName:"vertical",scrollable:t,scrollByPage:e.scrollByPage}),e.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((e.verticalScrollbarSize-e.verticalSliderSize)/2),e.verticalSliderSize,void 0)}_updateSlider(t,e){this.slider.setHeight(t),this.slider.setTop(e)}_renderDomNode(t,e){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(t){return this._shouldRender=this._onElementScrollSize(t.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(t.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(t.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(t,e){return e}_sliderPointerPosition(t){return t.pageY}_sliderOrthogonalPointerPosition(t){return t.pageX}_updateScrollbarSize(t){this.slider.setWidth(t)}writeScrollPosition(t,e){t.scrollTop=e}updateOptions(t){this.updateScrollbarSize(t.vertical===2?0:t.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(t.vertical),this._scrollByPage=t.scrollByPage}},sp=500,Do=50,ip=class{constructor(t,e,s){this.timestamp=t,this.deltaX=e,this.deltaY=s,this.score=0}},Wr=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let e=1,s=0,i=1,r=this._rear;do{let o=r===this._front?e:Math.pow(2,-i);if(e-=o,s+=this._memory[r].score*o,r===this._front)break;r=(this._capacity+r-1)%this._capacity,i++}while(!0);return s<=.5}acceptStandardWheelEvent(e){if(Dn){let s=yt(e.browserEvent),i=m_(s);this.accept(Date.now(),e.deltaX*i,e.deltaY*i)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,s,i){let r=null,o=new ip(e,s,i);this._front===-1&&this._rear===-1?(this._memory[0]=o,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=o),o.score=this._computeScore(o,r)}_computeScore(e,s){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let i=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(i+=.25),s){let r=Math.abs(e.deltaX),o=Math.abs(e.deltaY),a=Math.abs(s.deltaX),l=Math.abs(s.deltaY),h=Math.max(Math.min(r,a),1),c=Math.max(Math.min(o,l),1),d=Math.max(r,a),u=Math.max(o,l);d%h===0&&u%c===0&&(i-=.5)}return Math.min(Math.max(i,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};Wr.INSTANCE=new Wr;var rp=Wr,np=class extends An{constructor(t,e,s){super(),this._onScroll=this._register(new G),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new G),this.onWillScroll=this._onWillScroll.event,this._options=ap(e),this._scrollable=s,this._register(this._scrollable.onScroll(r=>{this._onWillScroll.fire(r),this._onDidScroll(r),this._onScroll.fire(r)}));let i={onMouseWheel:r=>this._onMouseWheel(r),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new tp(this._scrollable,this._options,i)),this._horizontalScrollbar=this._register(new ep(this._scrollable,this._options,i)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(t),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=zs(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=zs(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=zs(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,r=>this._onMouseOver(r)),this.onmouseleave(this._listenOnDomNode,r=>this._onMouseLeave(r)),this._hideTimeout=this._register(new In),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=ts(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(t){this._verticalScrollbar.delegatePointerDown(t)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(t){this._scrollable.setScrollDimensions(t,!1)}updateClassName(t){this._options.className=t,wt&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(t){typeof t.handleMouseWheel<"u"&&(this._options.handleMouseWheel=t.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof t.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=t.mouseWheelScrollSensitivity),typeof t.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=t.fastScrollSensitivity),typeof t.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=t.scrollPredominantAxis),typeof t.horizontal<"u"&&(this._options.horizontal=t.horizontal),typeof t.vertical<"u"&&(this._options.vertical=t.vertical),typeof t.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=t.horizontalScrollbarSize),typeof t.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=t.verticalScrollbarSize),typeof t.scrollByPage<"u"&&(this._options.scrollByPage=t.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(t){this._revealOnScroll=t}delegateScrollFromMouseWheelEvent(t){this._onMouseWheel(new Co(t))}_setListeningToMouseWheel(t){if(this._mouseWheelToDispose.length>0!==t&&(this._mouseWheelToDispose=ts(this._mouseWheelToDispose),t)){let e=s=>{this._onMouseWheel(new Co(s))};this._mouseWheelToDispose.push(oe(this._listenOnDomNode,ze.MOUSE_WHEEL,e,{passive:!1}))}}_onMouseWheel(t){if(t.browserEvent?.defaultPrevented)return;let e=rp.INSTANCE;e.acceptStandardWheelEvent(t);let s=!1;if(t.deltaY||t.deltaX){let r=t.deltaY*this._options.mouseWheelScrollSensitivity,o=t.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&o+r===0?o=r=0:Math.abs(r)>=Math.abs(o)?o=0:r=0),this._options.flipAxes&&([r,o]=[o,r]);let a=!wt&&t.browserEvent&&t.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!o&&(o=r,r=0),t.browserEvent&&t.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,r=r*this._options.fastScrollSensitivity);let l=this._scrollable.getFutureScrollPosition(),h={};if(r){let c=Do*r,d=l.scrollTop-(c<0?Math.floor(c):Math.ceil(c));this._verticalScrollbar.writeScrollPosition(h,d)}if(o){let c=Do*o,d=l.scrollLeft-(c<0?Math.floor(c):Math.ceil(c));this._horizontalScrollbar.writeScrollPosition(h,d)}h=this._scrollable.validateScrollPosition(h),(l.scrollLeft!==h.scrollLeft||l.scrollTop!==h.scrollTop)&&(this._options.mouseWheelSmoothScroll&&e.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(h):this._scrollable.setScrollPositionNow(h),s=!0)}let i=s;!i&&this._options.alwaysConsumeMouseWheel&&(i=!0),!i&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(i=!0),i&&(t.preventDefault(),t.stopPropagation())}_onDidScroll(t){this._shouldRender=this._horizontalScrollbar.onDidScroll(t)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(t)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let t=this._scrollable.getCurrentScrollPosition(),e=t.scrollTop>0,s=t.scrollLeft>0,i=s?" left":"",r=e?" top":"",o=s||e?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${i}`),this._topShadowDomNode.setClassName(`shadow${r}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${r}${i}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(t){this._mouseIsOver=!1,this._hide()}_onMouseOver(t){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),sp)}},op=class extends np{constructor(t,e,s){super(t,e,s)}setScrollPosition(t){t.reuseAnimation?this._scrollable.setScrollPositionSmooth(t,t.reuseAnimation):this._scrollable.setScrollPositionNow(t)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function ap(t){let e={lazyRender:typeof t.lazyRender<"u"?t.lazyRender:!1,className:typeof t.className<"u"?t.className:"",useShadows:typeof t.useShadows<"u"?t.useShadows:!0,handleMouseWheel:typeof t.handleMouseWheel<"u"?t.handleMouseWheel:!0,flipAxes:typeof t.flipAxes<"u"?t.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof t.consumeMouseWheelIfScrollbarIsNeeded<"u"?t.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof t.alwaysConsumeMouseWheel<"u"?t.alwaysConsumeMouseWheel:!1,scrollYToX:typeof t.scrollYToX<"u"?t.scrollYToX:!1,mouseWheelScrollSensitivity:typeof t.mouseWheelScrollSensitivity<"u"?t.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof t.fastScrollSensitivity<"u"?t.fastScrollSensitivity:5,scrollPredominantAxis:typeof t.scrollPredominantAxis<"u"?t.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof t.mouseWheelSmoothScroll<"u"?t.mouseWheelSmoothScroll:!0,arrowSize:typeof t.arrowSize<"u"?t.arrowSize:11,listenOnDomNode:typeof t.listenOnDomNode<"u"?t.listenOnDomNode:null,horizontal:typeof t.horizontal<"u"?t.horizontal:1,horizontalScrollbarSize:typeof t.horizontalScrollbarSize<"u"?t.horizontalScrollbarSize:10,horizontalSliderSize:typeof t.horizontalSliderSize<"u"?t.horizontalSliderSize:0,horizontalHasArrows:typeof t.horizontalHasArrows<"u"?t.horizontalHasArrows:!1,vertical:typeof t.vertical<"u"?t.vertical:1,verticalScrollbarSize:typeof t.verticalScrollbarSize<"u"?t.verticalScrollbarSize:10,verticalHasArrows:typeof t.verticalHasArrows<"u"?t.verticalHasArrows:!1,verticalSliderSize:typeof t.verticalSliderSize<"u"?t.verticalSliderSize:0,scrollByPage:typeof t.scrollByPage<"u"?t.scrollByPage:!1};return e.horizontalSliderSize=typeof t.horizontalSliderSize<"u"?t.horizontalSliderSize:e.horizontalScrollbarSize,e.verticalSliderSize=typeof t.verticalSliderSize<"u"?t.verticalSliderSize:e.verticalScrollbarSize,wt&&(e.className+=" mac"),e}var Ur=class extends de{constructor(t,e,s,i,r,o,a,l){super(),this._bufferService=s,this._optionsService=a,this._renderService=l,this._onRequestScrollLines=this._register(new G),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let h=this._register(new G_({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:c=>Mn(i.window,c)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new op(e,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},h)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(r.onProtocolChange(c=>{this._scrollableElement.updateOptions({handleMouseWheel:!(c&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(qe.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),t.appendChild(this._scrollableElement.getDomNode()),this._register(Se(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=i.mainDocument.createElement("style"),e.appendChild(this._styleElement),this._register(Se(()=>this._styleElement.remove())),this._register(qe.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
279
|
+
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(c=>this._handleScroll(c)))}scrollLines(t){let e=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:e.scrollTop+t*this._renderService.dimensions.css.cell.height})}scrollToLine(t,e){e&&(this._latestYDisp=t),this._scrollableElement.setScrollPosition({reuseAnimation:!e,scrollTop:t*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(t){t!==void 0&&(this._latestYDisp=t),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(t=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,t!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:t*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(t){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let e=Math.round(t.scrollTop/this._renderService.dimensions.css.cell.height),s=e-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=e,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};Ur=Te([ie(2,Ze),ie(3,It),ie(4,vl),ie(5,bs),ie(6,Qe),ie(7,Mt)],Ur);var Vr=class extends de{constructor(t,e,s,i,r){super(),this._screenElement=t,this._bufferService=e,this._coreBrowserService=s,this._decorationService=i,this._renderService=r,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(o=>this._removeDecoration(o))),this._register(Se(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let t of this._decorationService.decorations)this._renderDecoration(t);this._dimensionsChanged=!1}_renderDecoration(t){this._refreshStyle(t),this._dimensionsChanged&&this._refreshXPosition(t)}_createElement(t){let e=this._coreBrowserService.mainDocument.createElement("div");e.classList.add("xterm-decoration"),e.classList.toggle("xterm-decoration-top-layer",t?.options?.layer==="top"),e.style.width=`${Math.round((t.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,e.style.height=`${(t.options.height||1)*this._renderService.dimensions.css.cell.height}px`,e.style.top=`${(t.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,e.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let s=t.options.x??0;return s&&s>this._bufferService.cols&&(e.style.display="none"),this._refreshXPosition(t,e),e}_refreshStyle(t){let e=t.marker.line-this._bufferService.buffers.active.ydisp;if(e<0||e>=this._bufferService.rows)t.element&&(t.element.style.display="none",t.onRenderEmitter.fire(t.element));else{let s=this._decorationElements.get(t);s||(s=this._createElement(t),t.element=s,this._decorationElements.set(t,s),this._container.appendChild(s),t.onDispose(()=>{this._decorationElements.delete(t),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((t.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(t.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${e*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),t.onRenderEmitter.fire(s)}}_refreshXPosition(t,e=t.element){if(!e)return;let s=t.options.x??0;(t.options.anchor||"left")==="right"?e.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":e.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(t){this._decorationElements.get(t)?.remove(),this._decorationElements.delete(t),t.dispose()}};Vr=Te([ie(1,Ze),ie(2,It),ie(3,ii),ie(4,Mt)],Vr);var lp=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(t){if(t.options.overviewRulerOptions){for(let e of this._zones)if(e.color===t.options.overviewRulerOptions.color&&e.position===t.options.overviewRulerOptions.position){if(this._lineIntersectsZone(e,t.marker.line))return;if(this._lineAdjacentToZone(e,t.marker.line,t.options.overviewRulerOptions.position)){this._addLineToZone(e,t.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=t.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=t.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=t.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=t.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:t.options.overviewRulerOptions.color,position:t.options.overviewRulerOptions.position,startBufferLine:t.marker.line,endBufferLine:t.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(t){this._linePadding=t}_lineIntersectsZone(t,e){return e>=t.startBufferLine&&e<=t.endBufferLine}_lineAdjacentToZone(t,e,s){return e>=t.startBufferLine-this._linePadding[s||"full"]&&e<=t.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(t,e){t.startBufferLine=Math.min(t.startBufferLine,e),t.endBufferLine=Math.max(t.endBufferLine,e)}},vt={full:0,left:0,center:0,right:0},Bt={full:0,left:0,center:0,right:0},Cs={full:0,left:0,center:0,right:0},Ii=class extends de{constructor(t,e,s,i,r,o,a,l){super(),this._viewportElement=t,this._screenElement=e,this._bufferService=s,this._decorationService=i,this._renderService=r,this._optionsService=o,this._themeService=a,this._coreBrowserService=l,this._colorZoneStore=new lp,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(Se(()=>this._canvas?.remove()));let h=this._canvas.getContext("2d");if(h)this._ctx=h;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let t=Math.floor((this._canvas.width-1)/3),e=Math.ceil((this._canvas.width-1)/3);Bt.full=this._canvas.width,Bt.left=t,Bt.center=e,Bt.right=t,this._refreshDrawHeightConstants(),Cs.full=1,Cs.left=1,Cs.center=1+Bt.left,Cs.right=1+Bt.left+Bt.center}_refreshDrawHeightConstants(){vt.full=Math.round(2*this._coreBrowserService.dpr);let t=this._canvas.height/this._bufferService.buffer.lines.length,e=Math.round(Math.max(Math.min(t,12),6)*this._coreBrowserService.dpr);vt.left=e,vt.center=e,vt.right=e}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*vt.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*vt.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*vt.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*vt.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let e of this._decorationService.decorations)this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1,this._renderRulerOutline();let t=this._colorZoneStore.zones;for(let e of t)e.position!=="full"&&this._renderColorZone(e);for(let e of t)e.position==="full"&&this._renderColorZone(e);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(t){this._ctx.fillStyle=t.color,this._ctx.fillRect(Cs[t.position||"full"],Math.round((this._canvas.height-1)*(t.startBufferLine/this._bufferService.buffers.active.lines.length)-vt[t.position||"full"]/2),Bt[t.position||"full"],Math.round((this._canvas.height-1)*((t.endBufferLine-t.startBufferLine)/this._bufferService.buffers.active.lines.length)+vt[t.position||"full"]))}_queueRefresh(t,e){this._shouldUpdateDimensions=t||this._shouldUpdateDimensions,this._shouldUpdateAnchor=e||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};Ii=Te([ie(2,Ze),ie(3,ii),ie(4,Mt),ie(5,Qe),ie(6,bs),ie(7,It)],Ii);var U;(t=>(t.NUL="\0",t.SOH="",t.STX="",t.ETX="",t.EOT="",t.ENQ="",t.ACK="",t.BEL="\x07",t.BS="\b",t.HT=" ",t.LF=`
|
|
280
|
+
`,t.VT="\v",t.FF="\f",t.CR="\r",t.SO="",t.SI="",t.DLE="",t.DC1="",t.DC2="",t.DC3="",t.DC4="",t.NAK="",t.SYN="",t.ETB="",t.CAN="",t.EM="",t.SUB="",t.ESC="\x1B",t.FS="",t.GS="",t.RS="",t.US="",t.SP=" ",t.DEL=""))(U||={});var Ci;(t=>(t.PAD="",t.HOP="",t.BPH="",t.NBH="",t.IND="",t.NEL="
",t.SSA="",t.ESA="",t.HTS="",t.HTJ="",t.VTS="",t.PLD="",t.PLU="",t.RI="",t.SS2="",t.SS3="",t.DCS="",t.PU1="",t.PU2="",t.STS="",t.CCH="",t.MW="",t.SPA="",t.EPA="",t.SOS="",t.SGCI="",t.SCI="",t.CSI="",t.ST="",t.OSC="",t.PM="",t.APC=""))(Ci||={});var $l;(t=>t.ST=`${U.ESC}\\`)($l||={});var Kr=class{constructor(t,e,s,i,r,o){this._textarea=t,this._compositionView=e,this._bufferService=s,this._optionsService=i,this._coreService=r,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(t){this._compositionView.textContent=t.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(t){if(this._isComposing||this._isSendingComposition){if(t.keyCode===20||t.keyCode===229||t.keyCode===16||t.keyCode===17||t.keyCode===18)return!1;this._finalizeComposition(!1)}return t.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(t){if(this._compositionView.classList.remove("active"),this._isComposing=!1,t){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let s;e.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(e.start,this._compositionPosition.start):s=this._textarea.value.substring(e.start),s.length>0&&this._coreService.triggerDataEvent(s,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let t=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let e=this._textarea.value,s=e.replace(t,"");this._dataAlreadySent=s,e.length>t.length?this._coreService.triggerDataEvent(s,!0):e.length<t.length?this._coreService.triggerDataEvent(`${U.DEL}`,!0):e.length===t.length&&e!==t&&this._coreService.triggerDataEvent(e,!0)}},0)}updateCompositionElements(t){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),s=this._renderService.dimensions.css.cell.height,i=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+"px",this._compositionView.style.top=i+"px",this._compositionView.style.height=s+"px",this._compositionView.style.lineHeight=s+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let o=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+"px",this._textarea.style.top=i+"px",this._textarea.style.width=Math.max(o.width,1)+"px",this._textarea.style.height=Math.max(o.height,1)+"px",this._textarea.style.lineHeight=o.height+"px"}t||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Kr=Te([ie(2,Ze),ie(3,Qe),ie(4,ns),ie(5,Mt)],Kr);var Fe=0,He=0,We=0,Ee=0,Po={css:"#00000000",rgba:0},Ae;(t=>{function e(r,o,a,l){return l!==void 0?`#${Kt(r)}${Kt(o)}${Kt(a)}${Kt(l)}`:`#${Kt(r)}${Kt(o)}${Kt(a)}`}t.toCss=e;function s(r,o,a,l=255){return(r<<24|o<<16|a<<8|l)>>>0}t.toRgba=s;function i(r,o,a,l){return{css:t.toCss(r,o,a,l),rgba:t.toRgba(r,o,a,l)}}t.toColor=i})(Ae||={});var xe;(t=>{function e(h,c){if(Ee=(c.rgba&255)/255,Ee===1)return{css:c.css,rgba:c.rgba};let d=c.rgba>>24&255,u=c.rgba>>16&255,f=c.rgba>>8&255,m=h.rgba>>24&255,_=h.rgba>>16&255,p=h.rgba>>8&255;Fe=m+Math.round((d-m)*Ee),He=_+Math.round((u-_)*Ee),We=p+Math.round((f-p)*Ee);let g=Ae.toCss(Fe,He,We),v=Ae.toRgba(Fe,He,We);return{css:g,rgba:v}}t.blend=e;function s(h){return(h.rgba&255)===255}t.isOpaque=s;function i(h,c,d){let u=ki.ensureContrastRatio(h.rgba,c.rgba,d);if(u)return Ae.toColor(u>>24&255,u>>16&255,u>>8&255)}t.ensureContrastRatio=i;function r(h){let c=(h.rgba|255)>>>0;return[Fe,He,We]=ki.toChannels(c),{css:Ae.toCss(Fe,He,We),rgba:c}}t.opaque=r;function o(h,c){return Ee=Math.round(c*255),[Fe,He,We]=ki.toChannels(h.rgba),{css:Ae.toCss(Fe,He,We,Ee),rgba:Ae.toRgba(Fe,He,We,Ee)}}t.opacity=o;function a(h,c){return Ee=h.rgba&255,o(h,Ee*c/255)}t.multiplyOpacity=a;function l(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}t.toColorRGB=l})(xe||={});var we;(t=>{let e,s;try{let r=document.createElement("canvas");r.width=1,r.height=1;let o=r.getContext("2d",{willReadFrequently:!0});o&&(e=o,e.globalCompositeOperation="copy",s=e.createLinearGradient(0,0,1,1))}catch{}function i(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return Fe=parseInt(r.slice(1,2).repeat(2),16),He=parseInt(r.slice(2,3).repeat(2),16),We=parseInt(r.slice(3,4).repeat(2),16),Ae.toColor(Fe,He,We);case 5:return Fe=parseInt(r.slice(1,2).repeat(2),16),He=parseInt(r.slice(2,3).repeat(2),16),We=parseInt(r.slice(3,4).repeat(2),16),Ee=parseInt(r.slice(4,5).repeat(2),16),Ae.toColor(Fe,He,We,Ee);case 7:return{css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return{css:r,rgba:parseInt(r.slice(1),16)>>>0}}let o=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return Fe=parseInt(o[1]),He=parseInt(o[2]),We=parseInt(o[3]),Ee=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),Ae.toColor(Fe,He,We,Ee);if(!e||!s)throw new Error("css.toColor: Unsupported css format");if(e.fillStyle=s,e.fillStyle=r,typeof e.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(e.fillRect(0,0,1,1),[Fe,He,We,Ee]=e.getImageData(0,0,1,1).data,Ee!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Ae.toRgba(Fe,He,We,Ee),css:r}}t.toColor=i})(we||={});var Xe;(t=>{function e(i){return s(i>>16&255,i>>8&255,i&255)}t.relativeLuminance=e;function s(i,r,o){let a=i/255,l=r/255,h=o/255,c=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),d=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),u=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return c*.2126+d*.7152+u*.0722}t.relativeLuminance2=s})(Xe||={});var ki;(t=>{function e(a,l){if(Ee=(l&255)/255,Ee===1)return l;let h=l>>24&255,c=l>>16&255,d=l>>8&255,u=a>>24&255,f=a>>16&255,m=a>>8&255;return Fe=u+Math.round((h-u)*Ee),He=f+Math.round((c-f)*Ee),We=m+Math.round((d-m)*Ee),Ae.toRgba(Fe,He,We)}t.blend=e;function s(a,l,h){let c=Xe.relativeLuminance(a>>8),d=Xe.relativeLuminance(l>>8);if(jt(c,d)<h){if(d<c){let m=i(a,l,h),_=jt(c,Xe.relativeLuminance(m>>8));if(_<h){let p=r(a,l,h),g=jt(c,Xe.relativeLuminance(p>>8));return _>g?m:p}return m}let u=r(a,l,h),f=jt(c,Xe.relativeLuminance(u>>8));if(f<h){let m=i(a,l,h),_=jt(c,Xe.relativeLuminance(m>>8));return f>_?u:m}return u}}t.ensureContrastRatio=s;function i(a,l,h){let c=a>>24&255,d=a>>16&255,u=a>>8&255,f=l>>24&255,m=l>>16&255,_=l>>8&255,p=jt(Xe.relativeLuminance2(f,m,_),Xe.relativeLuminance2(c,d,u));for(;p<h&&(f>0||m>0||_>0);)f-=Math.max(0,Math.ceil(f*.1)),m-=Math.max(0,Math.ceil(m*.1)),_-=Math.max(0,Math.ceil(_*.1)),p=jt(Xe.relativeLuminance2(f,m,_),Xe.relativeLuminance2(c,d,u));return(f<<24|m<<16|_<<8|255)>>>0}t.reduceLuminance=i;function r(a,l,h){let c=a>>24&255,d=a>>16&255,u=a>>8&255,f=l>>24&255,m=l>>16&255,_=l>>8&255,p=jt(Xe.relativeLuminance2(f,m,_),Xe.relativeLuminance2(c,d,u));for(;p<h&&(f<255||m<255||_<255);)f=Math.min(255,f+Math.ceil((255-f)*.1)),m=Math.min(255,m+Math.ceil((255-m)*.1)),_=Math.min(255,_+Math.ceil((255-_)*.1)),p=jt(Xe.relativeLuminance2(f,m,_),Xe.relativeLuminance2(c,d,u));return(f<<24|m<<16|_<<8|255)>>>0}t.increaseLuminance=r;function o(a){return[a>>24&255,a>>16&255,a>>8&255,a&255]}t.toChannels=o})(ki||={});function Kt(t){let e=t.toString(16);return e.length<2?"0"+e:e}function jt(t,e){return t<e?(e+.05)/(t+.05):(t+.05)/(e+.05)}var cp=class extends si{constructor(t,e,s){super(),this.content=0,this.combinedData="",this.fg=t.fg,this.bg=t.bg,this.combinedData=e,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(t){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Mi=class{constructor(t){this._bufferService=t,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new dt}register(t){let e={id:this._nextCharacterJoinerId++,handler:t};return this._characterJoiners.push(e),e.id}deregister(t){for(let e=0;e<this._characterJoiners.length;e++)if(this._characterJoiners[e].id===t)return this._characterJoiners.splice(e,1),!0;return!1}getJoinedCharacters(t){if(this._characterJoiners.length===0)return[];let e=this._bufferService.buffer.lines.get(t);if(!e||e.length===0)return[];let s=[],i=e.translateToString(!0),r=0,o=0,a=0,l=e.getFg(0),h=e.getBg(0);for(let c=0;c<e.getTrimmedLength();c++)if(e.loadCell(c,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==l||this._workCell.bg!==h){if(c-r>1){let d=this._getJoinedRanges(i,a,o,e,r);for(let u=0;u<d.length;u++)s.push(d[u])}r=c,a=o,l=this._workCell.fg,h=this._workCell.bg}o+=this._workCell.getChars().length||$t.length}if(this._bufferService.cols-r>1){let c=this._getJoinedRanges(i,a,o,e,r);for(let d=0;d<c.length;d++)s.push(c[d])}return s}_getJoinedRanges(t,e,s,i,r){let o=t.substring(e,s),a=[];try{a=this._characterJoiners[0].handler(o)}catch(l){console.error(l)}for(let l=1;l<this._characterJoiners.length;l++)try{let h=this._characterJoiners[l].handler(o);for(let c=0;c<h.length;c++)Mi._mergeRanges(a,h[c])}catch(h){console.error(h)}return this._stringRangesToCellRanges(a,i,r),a}_stringRangesToCellRanges(t,e,s){let i=0,r=!1,o=0,a=t[i];if(a){for(let l=s;l<this._bufferService.cols;l++){let h=e.getWidth(l),c=e.getString(l).length||$t.length;if(h!==0){if(!r&&a[0]<=o&&(a[0]=l,r=!0),a[1]<=o){if(a[1]=l,a=t[++i],!a)break;a[0]<=o?(a[0]=l,r=!0):r=!1}o+=c}}a&&(a[1]=this._bufferService.cols)}}static _mergeRanges(t,e){let s=!1;for(let i=0;i<t.length;i++){let r=t[i];if(s){if(e[1]<=r[0])return t[i-1][1]=e[1],t;if(e[1]<=r[1])return t[i-1][1]=Math.max(e[1],r[1]),t.splice(i,1),t;t.splice(i,1),i--}else{if(e[1]<=r[0])return t.splice(i,0,e),t;if(e[1]<=r[1])return r[0]=Math.min(e[0],r[0]),t;e[0]<r[1]&&(r[0]=Math.min(e[0],r[0]),s=!0);continue}}return s?t[t.length-1][1]=e[1]:t.push(e),t}};Mi=Te([ie(0,Ze)],Mi);function hp(t){return 57508<=t&&t<=57558}function dp(t){return 9472<=t&&t<=9631}function up(t){return hp(t)||dp(t)}function fp(){return{css:{canvas:ui(),cell:ui()},device:{canvas:ui(),cell:ui(),char:{width:0,height:0,left:0,top:0}}}}function ui(){return{width:0,height:0}}var qr=class{constructor(t,e,s,i,r,o,a){this._document=t,this._characterJoinerService=e,this._optionsService=s,this._coreBrowserService=i,this._coreService=r,this._decorationService=o,this._themeService=a,this._workCell=new dt,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(t,e,s){this._selectionStart=t,this._selectionEnd=e,this._columnSelectMode=s}createRow(t,e,s,i,r,o,a,l,h,c,d){let u=[],f=this._characterJoinerService.getJoinedCharacters(e),m=this._themeService.colors,_=t.getNoBgTrimmedLength();s&&_<o+1&&(_=o+1);let p,g=0,v="",x=0,b=0,S=0,w=0,k=!1,E=0,P=!1,R=0,B=0,I=[],T=c!==-1&&d!==-1;for(let y=0;y<_;y++){t.loadCell(y,this._workCell);let N=this._workCell.getWidth();if(N===0)continue;let C=!1,j=y>=B,M=y,D=this._workCell;if(f.length>0&&y===f[0][0]&&j){let ee=f.shift(),ae=this._isCellInSelection(ee[0],e);for(x=ee[0]+1;x<ee[1];x++)j&&=ae===this._isCellInSelection(x,e);j&&=!s||o<ee[0]||o>=ee[1],j?(C=!0,D=new cp(this._workCell,t.translateToString(!0,ee[0],ee[1]),ee[1]-ee[0]),M=ee[1]-1,N=D.getWidth()):B=ee[1]}let F=this._isCellInSelection(y,e),H=s&&y===o,O=T&&y>=c&&y<=d,$=!1;this._decorationService.forEachDecorationAtCell(y,e,void 0,ee=>{$=!0});let W=D.getChars()||$t;if(W===" "&&(D.isUnderline()||D.isOverline())&&(W=" "),R=N*l-h.get(W,D.isBold(),D.isItalic()),!p)p=this._document.createElement("span");else if(g&&(F&&P||!F&&!P&&D.bg===b)&&(F&&P&&m.selectionForeground||D.fg===S)&&D.extended.ext===w&&O===k&&R===E&&!H&&!C&&!$&&j){D.isInvisible()?v+=$t:v+=W,g++;continue}else g&&(p.textContent=v),p=this._document.createElement("span"),g=0,v="";if(b=D.bg,S=D.fg,w=D.extended.ext,k=O,E=R,P=F,C&&o>=y&&o<=M&&(o=y),!this._coreService.isCursorHidden&&H&&this._coreService.isCursorInitialized){if(I.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&I.push("xterm-cursor-blink"),I.push(i==="bar"?"xterm-cursor-bar":i==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){case"outline":I.push("xterm-cursor-outline");break;case"block":I.push("xterm-cursor-block");break;case"bar":I.push("xterm-cursor-bar");break;case"underline":I.push("xterm-cursor-underline");break}}if(D.isBold()&&I.push("xterm-bold"),D.isItalic()&&I.push("xterm-italic"),D.isDim()&&I.push("xterm-dim"),D.isInvisible()?v=$t:v=D.getChars()||$t,D.isUnderline()&&(I.push(`xterm-underline-${D.extended.underlineStyle}`),v===" "&&(v=" "),!D.isUnderlineColorDefault()))if(D.isUnderlineColorRGB())p.style.textDecorationColor=`rgb(${si.toColorRGB(D.getUnderlineColor()).join(",")})`;else{let ee=D.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&D.isBold()&&ee<8&&(ee+=8),p.style.textDecorationColor=m.ansi[ee].css}D.isOverline()&&(I.push("xterm-overline"),v===" "&&(v=" ")),D.isStrikethrough()&&I.push("xterm-strikethrough"),O&&(p.style.textDecoration="underline");let K=D.getFgColor(),re=D.getFgColorMode(),Z=D.getBgColor(),J=D.getBgColorMode(),X=!!D.isInverse();if(X){let ee=K;K=Z,Z=ee;let ae=re;re=J,J=ae}let L,q,Q=!1;this._decorationService.forEachDecorationAtCell(y,e,void 0,ee=>{ee.options.layer!=="top"&&Q||(ee.backgroundColorRGB&&(J=50331648,Z=ee.backgroundColorRGB.rgba>>8&16777215,L=ee.backgroundColorRGB),ee.foregroundColorRGB&&(re=50331648,K=ee.foregroundColorRGB.rgba>>8&16777215,q=ee.foregroundColorRGB),Q=ee.options.layer==="top")}),!Q&&F&&(L=this._coreBrowserService.isFocused?m.selectionBackgroundOpaque:m.selectionInactiveBackgroundOpaque,Z=L.rgba>>8&16777215,J=50331648,Q=!0,m.selectionForeground&&(re=50331648,K=m.selectionForeground.rgba>>8&16777215,q=m.selectionForeground)),Q&&I.push("xterm-decoration-top");let Y;switch(J){case 16777216:case 33554432:Y=m.ansi[Z],I.push(`xterm-bg-${Z}`);break;case 50331648:Y=Ae.toColor(Z>>16,Z>>8&255,Z&255),this._addStyle(p,`background-color:#${Io((Z>>>0).toString(16),"0",6)}`);break;default:X?(Y=m.foreground,I.push("xterm-bg-257")):Y=m.background}switch(L||D.isDim()&&(L=xe.multiplyOpacity(Y,.5)),re){case 16777216:case 33554432:D.isBold()&&K<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(K+=8),this._applyMinimumContrast(p,Y,m.ansi[K],D,L,void 0)||I.push(`xterm-fg-${K}`);break;case 50331648:let ee=Ae.toColor(K>>16&255,K>>8&255,K&255);this._applyMinimumContrast(p,Y,ee,D,L,q)||this._addStyle(p,`color:#${Io(K.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(p,Y,m.foreground,D,L,q)||X&&I.push("xterm-fg-257")}I.length&&(p.className=I.join(" "),I.length=0),!H&&!C&&!$&&j?g++:p.textContent=v,R!==this.defaultSpacing&&(p.style.letterSpacing=`${R}px`),u.push(p),y=M}return p&&g&&(p.textContent=v),u}_applyMinimumContrast(t,e,s,i,r,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||up(i.getCode()))return!1;let a=this._getContrastCache(i),l;if(!r&&!o&&(l=a.getColor(e.rgba,s.rgba)),l===void 0){let h=this._optionsService.rawOptions.minimumContrastRatio/(i.isDim()?2:1);l=xe.ensureContrastRatio(r||e,o||s,h),a.setColor((r||e).rgba,(o||s).rgba,l??null)}return l?(this._addStyle(t,`color:${l.css}`),!0):!1}_getContrastCache(t){return t.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(t,e){t.setAttribute("style",`${t.getAttribute("style")||""}${e};`)}_isCellInSelection(t,e){let s=this._selectionStart,i=this._selectionEnd;return!s||!i?!1:this._columnSelectMode?s[0]<=i[0]?t>=s[0]&&e>=s[1]&&t<i[0]&&e<=i[1]:t<s[0]&&e>=s[1]&&t>=i[0]&&e<=i[1]:e>s[1]&&e<i[1]||s[1]===i[1]&&e===s[1]&&t>=s[0]&&t<i[0]||s[1]<i[1]&&e===i[1]&&t<i[0]||s[1]<i[1]&&e===s[1]&&t>=s[0]}};qr=Te([ie(1,Sl),ie(2,Qe),ie(3,It),ie(4,ns),ie(5,ii),ie(6,bs)],qr);function Io(t,e,s){for(;t.length<s;)t=e+t;return t}var mp=class{constructor(t,e){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=t.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let s=t.createElement("span");s.classList.add("xterm-char-measure-element");let i=t.createElement("span");i.classList.add("xterm-char-measure-element"),i.style.fontWeight="bold";let r=t.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontStyle="italic";let o=t.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold",o.style.fontStyle="italic",this._measureElements=[s,i,r,o],this._container.appendChild(s),this._container.appendChild(i),this._container.appendChild(r),this._container.appendChild(o),e.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(t,e,s,i){t===this._font&&e===this._fontSize&&s===this._weight&&i===this._weightBold||(this._font=t,this._fontSize=e,this._weight=s,this._weightBold=i,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${i}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${i}`,this.clear())}get(t,e,s){let i=0;if(!e&&!s&&t.length===1&&(i=t.charCodeAt(0))<256){if(this._flat[i]!==-9999)return this._flat[i];let a=this._measure(t,0);return a>0&&(this._flat[i]=a),a}let r=t;e&&(r+="B"),s&&(r+="I");let o=this._holey.get(r);if(o===void 0){let a=0;e&&(a|=1),s&&(a|=2),o=this._measure(t,a),o>0&&this._holey.set(r,o)}return o}_measure(t,e){let s=this._measureElements[e];return s.textContent=t.repeat(32),s.offsetWidth/32}},_p=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(t,e,s,i=!1){if(this.selectionStart=e,this.selectionEnd=s,!e||!s||e[0]===s[0]&&e[1]===s[1]){this.clear();return}let r=t.buffers.active.ydisp,o=e[1]-r,a=s[1]-r,l=Math.max(o,0),h=Math.min(a,t.rows-1);if(l>=t.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=i,this.viewportStartRow=o,this.viewportEndRow=a,this.viewportCappedStartRow=l,this.viewportCappedEndRow=h,this.startCol=e[0],this.endCol=s[0]}isCellSelected(t,e,s){return this.hasSelection?(s-=t.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?e>=this.startCol&&s>=this.viewportCappedStartRow&&e<this.endCol&&s<=this.viewportCappedEndRow:e<this.startCol&&s>=this.viewportCappedStartRow&&e>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&e>=this.startCol&&e<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&e<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&e>=this.startCol):!1}};function pp(){return new _p}var hr="xterm-dom-renderer-owner-",at="xterm-rows",fi="xterm-fg-",Mo="xterm-bg-",ks="xterm-focus",mi="xterm-selection",gp=1,Gr=class extends de{constructor(t,e,s,i,r,o,a,l,h,c,d,u,f,m){super(),this._terminal=t,this._document=e,this._element=s,this._screenElement=i,this._viewportElement=r,this._helperContainer=o,this._linkifier2=a,this._charSizeService=h,this._optionsService=c,this._bufferService=d,this._coreService=u,this._coreBrowserService=f,this._themeService=m,this._terminalClass=gp++,this._rowElements=[],this._selectionRenderModel=pp(),this.onRequestRedraw=this._register(new G).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(at),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(mi),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=fp(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(_=>this._injectCss(_))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(qr,document),this._element.classList.add(hr+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(_=>this._handleLinkHover(_))),this._register(this._linkifier2.onHideLinkUnderline(_=>this._handleLinkLeave(_))),this._register(Se(()=>{this._element.classList.remove(hr+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new mp(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let t=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*t,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*t),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/t),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/t),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let e=`${this._terminalSelector} .${at} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=e,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(t){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let e=`${this._terminalSelector} .${at} { pointer-events: none; color: ${t.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;e+=`${this._terminalSelector} .${at} .xterm-dim { color: ${xe.multiplyOpacity(t.foreground,.5).css};}`,e+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let s=`blink_underline_${this._terminalClass}`,i=`blink_bar_${this._terminalClass}`,r=`blink_block_${this._terminalClass}`;e+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,e+=`@keyframes ${i} { 50% { box-shadow: none; }}`,e+=`@keyframes ${r} { 0% { background-color: ${t.cursor.css}; color: ${t.cursorAccent.css}; } 50% { background-color: inherit; color: ${t.cursor.css}; }}`,e+=`${this._terminalSelector} .${at}.${ks} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${at}.${ks} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${at}.${ks} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${at} .xterm-cursor.xterm-cursor-block { background-color: ${t.cursor.css}; color: ${t.cursorAccent.css};}${this._terminalSelector} .${at} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${t.cursor.css} !important; color: ${t.cursorAccent.css} !important;}${this._terminalSelector} .${at} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${t.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${at} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${t.cursor.css} inset;}${this._terminalSelector} .${at} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${t.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,e+=`${this._terminalSelector} .${mi} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${mi} div { position: absolute; background-color: ${t.selectionBackgroundOpaque.css};}${this._terminalSelector} .${mi} div { position: absolute; background-color: ${t.selectionInactiveBackgroundOpaque.css};}`;for(let[o,a]of t.ansi.entries())e+=`${this._terminalSelector} .${fi}${o} { color: ${a.css}; }${this._terminalSelector} .${fi}${o}.xterm-dim { color: ${xe.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${Mo}${o} { background-color: ${a.css}; }`;e+=`${this._terminalSelector} .${fi}257 { color: ${xe.opaque(t.background).css}; }${this._terminalSelector} .${fi}257.xterm-dim { color: ${xe.multiplyOpacity(xe.opaque(t.background),.5).css}; }${this._terminalSelector} .${Mo}257 { background-color: ${t.foreground.css}; }`,this._themeStyleElement.textContent=e}_setDefaultSpacing(){let t=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${t}px`,this._rowFactory.defaultSpacing=t}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(t,e){for(let s=this._rowElements.length;s<=e;s++){let i=this._document.createElement("div");this._rowContainer.appendChild(i),this._rowElements.push(i)}for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(t,e){this._refreshRowElements(t,e),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(ks),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(ks),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(t,e,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(t,e,s),this.renderRows(0,this._bufferService.rows-1),!t||!e||(this._selectionRenderModel.update(this._terminal,t,e,s),!this._selectionRenderModel.hasSelection))return;let i=this._selectionRenderModel.viewportStartRow,r=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(s){let h=t[0]>e[0];l.appendChild(this._createSelectionElement(o,h?e[0]:t[0],h?t[0]:e[0],a-o+1))}else{let h=i===o?t[0]:0,c=o===r?e[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(o,h,c));let d=a-o-1;if(l.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,d)),o!==a){let u=r===a?e[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(a,0,u))}}this._selectionContainer.appendChild(l)}_createSelectionElement(t,e,s,i=1){let r=this._document.createElement("div"),o=e*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(s-e);return o+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-o),r.style.height=`${i*this.dimensions.css.cell.height}px`,r.style.top=`${t*this.dimensions.css.cell.height}px`,r.style.left=`${o}px`,r.style.width=`${a}px`,r}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let t of this._rowElements)t.replaceChildren()}renderRows(t,e){let s=this._bufferService.buffer,i=s.ybase+s.y,r=Math.min(s.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=t;h<=e;h++){let c=h+s.ydisp,d=this._rowElements[h],u=s.lines.get(c);if(!d||!u)break;d.replaceChildren(...this._rowFactory.createRow(u,c,c===i,a,l,r,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${hr}${this._terminalClass}`}_handleLinkHover(t){this._setCellUnderline(t.x1,t.x2,t.y1,t.y2,t.cols,!0)}_handleLinkLeave(t){this._setCellUnderline(t.x1,t.x2,t.y1,t.y2,t.cols,!1)}_setCellUnderline(t,e,s,i,r,o){s<0&&(t=0),i<0&&(e=0);let a=this._bufferService.rows-1;s=Math.max(Math.min(s,a),0),i=Math.max(Math.min(i,a),0),r=Math.min(r,this._bufferService.cols);let l=this._bufferService.buffer,h=l.ybase+l.y,c=Math.min(l.x,r-1),d=this._optionsService.rawOptions.cursorBlink,u=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let m=s;m<=i;++m){let _=m+l.ydisp,p=this._rowElements[m],g=l.lines.get(_);if(!p||!g)break;p.replaceChildren(...this._rowFactory.createRow(g,_,_===h,u,f,c,d,this.dimensions.css.cell.width,this._widthCache,o?m===s?t:0:-1,o?(m===i?e:r)-1:-1))}}};Gr=Te([ie(7,En),ie(8,qi),ie(9,Qe),ie(10,Ze),ie(11,ns),ie(12,It),ie(13,bs)],Gr);var Yr=class extends de{constructor(t,e,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new G),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new xp(this._optionsService))}catch{this._measureStrategy=this._register(new vp(t,e,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let t=this._measureStrategy.measure();(t.width!==this.width||t.height!==this.height)&&(this.width=t.width,this.height=t.height,this._onCharSizeChange.fire())}};Yr=Te([ie(2,Qe)],Yr);var zl=class extends de{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(t,e){t!==void 0&&t>0&&e!==void 0&&e>0&&(this._result.width=t,this._result.height=e)}},vp=class extends zl{constructor(t,e,s){super(),this._document=t,this._parentElement=e,this._optionsService=s,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},xp=class extends zl{constructor(t){super(),this._optionsService=t,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let e=this._ctx.measureText("W");if(!("width"in e&&"fontBoundingBoxAscent"in e&&"fontBoundingBoxDescent"in e))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let t=this._ctx.measureText("W");return this._validateAndSet(t.width,t.fontBoundingBoxAscent+t.fontBoundingBoxDescent),this._result}},bp=class extends de{constructor(t,e,s){super(),this._textarea=t,this._window=e,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new Sp(this._window)),this._onDprChange=this._register(new G),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new G),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(i=>this._screenDprMonitor.setWindow(i))),this._register(qe.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(oe(this._textarea,"focus",()=>this._isFocused=!0)),this._register(oe(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(t){this._window!==t&&(this._window=t,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},Sp=class extends de{constructor(t){super(),this._parentWindow=t,this._windowResizeListener=this._register(new ms),this._onDprChange=this._register(new G),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Se(()=>this.clearListener()))}setWindow(t){this._parentWindow=t,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=oe(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},yp=class extends de{constructor(){super(),this.linkProviders=[],this._register(Se(()=>this.linkProviders.length=0))}registerLinkProvider(t){return this.linkProviders.push(t),{dispose:()=>{let e=this.linkProviders.indexOf(t);e!==-1&&this.linkProviders.splice(e,1)}}}};function Bn(t,e,s){let i=s.getBoundingClientRect(),r=t.getComputedStyle(s),o=parseInt(r.getPropertyValue("padding-left")),a=parseInt(r.getPropertyValue("padding-top"));return[e.clientX-i.left-o,e.clientY-i.top-a]}function wp(t,e,s,i,r,o,a,l,h){if(!o)return;let c=Bn(t,e,s);if(c)return c[0]=Math.ceil((c[0]+(h?a/2:0))/a),c[1]=Math.ceil(c[1]/l),c[0]=Math.min(Math.max(c[0],1),i+(h?1:0)),c[1]=Math.min(Math.max(c[1],1),r),c}var Xr=class{constructor(t,e){this._renderService=t,this._charSizeService=e}getCoords(t,e,s,i,r){return wp(window,t,e,s,i,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,r)}getMouseReportCoords(t,e){let s=Bn(window,t,e);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};Xr=Te([ie(0,Mt),ie(1,qi)],Xr);var Cp=class{constructor(t,e){this._renderCallback=t,this._coreBrowserService=e,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(t){return this._refreshCallbacks.push(t),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}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,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();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),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let t of this._refreshCallbacks)t(0);this._refreshCallbacks=[]}},Fl={};Mm(Fl,{getSafariVersion:()=>Np,isChromeOS:()=>Vl,isFirefox:()=>Hl,isIpad:()=>jp,isIphone:()=>Ep,isLegacyEdge:()=>kp,isLinux:()=>Ln,isMac:()=>Ai,isNode:()=>Gi,isSafari:()=>Wl,isWindows:()=>Ul});var Gi=typeof process<"u"&&"title"in process,ri=Gi?"node":navigator.userAgent,ni=Gi?"node":navigator.platform,Hl=ri.includes("Firefox"),kp=ri.includes("Edge"),Wl=/^((?!chrome|android).)*safari/i.test(ri);function Np(){if(!Wl)return 0;let t=ri.match(/Version\/(\d+)/);return t===null||t.length<2?0:parseInt(t[1])}var Ai=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(ni),jp=ni==="iPad",Ep=ni==="iPhone",Ul=["Windows","Win16","Win32","WinCE"].includes(ni),Ln=ni.indexOf("Linux")>=0,Vl=/\bCrOS\b/.test(ri),Kl=class{constructor(){this._tasks=[],this._i=0}enqueue(t){this._tasks.push(t),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(t){this._idleCallback=void 0;let e=0,s=0,i=t.timeRemaining(),r=0;for(;this._i<this._tasks.length;){if(e=performance.now(),this._tasks[this._i]()||this._i++,e=Math.max(1,performance.now()-e),s=Math.max(e,s),r=t.timeRemaining(),s*1.5>r){i-e<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-e))}ms`),this._start();return}i=r}this.clear()}},Tp=class extends Kl{_requestCallback(t){return setTimeout(()=>t(this._createDeadline(16)))}_cancelCallback(t){clearTimeout(t)}_createDeadline(t){let e=performance.now()+t;return{timeRemaining:()=>Math.max(0,e-performance.now())}}},Rp=class extends Kl{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},Bi=!Gi&&"requestIdleCallback"in window?Rp:Tp,Dp=class{constructor(){this._queue=new Bi}set(t){this._queue.clear(),this._queue.enqueue(t)}flush(){this._queue.flush()}},Jr=class extends de{constructor(t,e,s,i,r,o,a,l,h){super(),this._rowCount=t,this._optionsService=s,this._charSizeService=i,this._coreService=r,this._coreBrowserService=l,this._renderer=this._register(new ms),this._pausedResizeTask=new Dp,this._observerDisposable=this._register(new ms),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new G),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new G),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new G),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new G),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Cp((c,d)=>this._renderRows(c,d),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new Pp(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Se(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(a.onResize(()=>this._fullRefresh())),this._register(a.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(a.cols,a.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(a.buffer.y,a.buffer.y,!0))),this._register(h.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,e),this._register(this._coreBrowserService.onWindowChange(c=>this._registerIntersectionObserver(c,e)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(t,e){if("IntersectionObserver"in t){let s=new t.IntersectionObserver(i=>this._handleIntersectionChange(i[i.length-1]),{threshold:0});s.observe(e),this._observerDisposable.value=Se(()=>s.disconnect())}}_handleIntersectionChange(t){this._isPaused=t.isIntersecting===void 0?t.intersectionRatio===0:!t.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(t,e,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(t,e);return}let i=this._syncOutputHandler.flush();i&&(t=Math.min(t,i.start),e=Math.max(e,i.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(t,e,this._rowCount)}_renderRows(t,e){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(t,e);return}t=Math.min(t,this._rowCount-1),e=Math.min(e,this._rowCount-1),this._renderer.value.renderRows(t,e),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:t,end:e}),this._onRender.fire({start:t,end:e}),this._isNextRenderRedrawOnly=!0}}resize(t,e){this._rowCount=e,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(t){this._renderer.value=t,this._renderer.value&&(this._renderer.value.onRequestRedraw(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(t){return this._renderDebouncer.addRefreshCallback(t)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(t,e){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(t,e)):this._renderer.value.handleResize(t,e),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(t,e,s){this._selectionState.start=t,this._selectionState.end=e,this._selectionState.columnSelectMode=s,this._renderer.value?.handleSelectionChanged(t,e,s)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};Jr=Te([ie(2,Qe),ie(3,qi),ie(4,ns),ie(5,ii),ie(6,Ze),ie(7,It),ie(8,bs)],Jr);var Pp=class{constructor(t,e,s){this._coreBrowserService=t,this._coreService=e,this._onTimeout=s,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(t,e){this._isBuffering?(this._start=Math.min(this._start,t),this._end=Math.max(this._end,e)):(this._start=t,this._end=e,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let t={start:this._start,end:this._end};return this._isBuffering=!1,t}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function Ip(t,e,s,i){let r=s.buffer.x,o=s.buffer.y;if(!s.buffer.hasScrollback)return Bp(r,o,t,e,s,i)+Yi(o,e,s,i)+Lp(r,o,t,e,s,i);let a;if(o===e)return a=r>t?"D":"C",qs(Math.abs(r-t),Ks(a,i));a=o>e?"D":"C";let l=Math.abs(o-e),h=Ap(o>e?t:r,s)+(l-1)*s.cols+1+Mp(o>e?r:t);return qs(h,Ks(a,i))}function Mp(t,e){return t-1}function Ap(t,e){return e.cols-t}function Bp(t,e,s,i,r,o){return Yi(e,i,r,o).length===0?"":qs(Gl(t,e,t,e-ss(e,r),!1,r).length,Ks("D",o))}function Yi(t,e,s,i){let r=t-ss(t,s),o=e-ss(e,s),a=Math.abs(r-o)-Op(t,e,s);return qs(a,Ks(ql(t,e),i))}function Lp(t,e,s,i,r,o){let a;Yi(e,i,r,o).length>0?a=i-ss(i,r):a=e;let l=i,h=$p(t,e,s,i,r,o);return qs(Gl(t,a,s,l,h==="C",r).length,Ks(h,o))}function Op(t,e,s){let i=0,r=t-ss(t,s),o=e-ss(e,s);for(let a=0;a<Math.abs(r-o);a++){let l=ql(t,e)==="A"?-1:1;s.buffer.lines.get(r+l*a)?.isWrapped&&i++}return i}function ss(t,e){let s=0,i=e.buffer.lines.get(t),r=i?.isWrapped;for(;r&&t>=0&&t<e.rows;)s++,i=e.buffer.lines.get(--t),r=i?.isWrapped;return s}function $p(t,e,s,i,r,o){let a;return Yi(s,i,r,o).length>0?a=i-ss(i,r):a=e,t<s&&a<=i||t>=s&&a<i?"C":"D"}function ql(t,e){return t>e?"A":"B"}function Gl(t,e,s,i,r,o){let a=t,l=e,h="";for(;(a!==s||l!==i)&&l>=0&&l<o.buffer.lines.length;)a+=r?1:-1,r&&a>o.cols-1?(h+=o.buffer.translateBufferLineToString(l,!1,t,a),a=0,t=0,l++):!r&&a<0&&(h+=o.buffer.translateBufferLineToString(l,!1,0,t+1),a=o.cols-1,t=a,l--);return h+o.buffer.translateBufferLineToString(l,!1,t,a)}function Ks(t,e){let s=e?"O":"[";return U.ESC+s+t}function qs(t,e){t=Math.floor(t);let s="";for(let i=0;i<t;i++)s+=e;return s}var zp=class{constructor(t){this._bufferService=t,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let t=this.selectionStart[0]+this.selectionStartLength;return t>this._bufferService.cols?t%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)-1]:[t%this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)]:[t,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let t=this.selectionStart[0]+this.selectionStartLength;return t>this._bufferService.cols?[t%this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)]:[Math.max(t,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let t=this.selectionStart,e=this.selectionEnd;return!t||!e?!1:t[1]>e[1]||t[1]===e[1]&&t[0]>e[0]}handleTrim(t){return this.selectionStart&&(this.selectionStart[1]-=t),this.selectionEnd&&(this.selectionEnd[1]-=t),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function Ao(t,e){if(t.start.y>t.end.y)throw new Error(`Buffer range end (${t.end.x}, ${t.end.y}) cannot be before start (${t.start.x}, ${t.start.y})`);return e*(t.end.y-t.start.y)+(t.end.x-t.start.x+1)}var dr=50,Fp=15,Hp=50,Wp=500,Up=" ",Vp=new RegExp(Up,"g"),Zr=class extends de{constructor(t,e,s,i,r,o,a,l,h){super(),this._element=t,this._screenElement=e,this._linkifier=s,this._bufferService=i,this._coreService=r,this._mouseService=o,this._optionsService=a,this._renderService=l,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new dt,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new G),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new G),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new G),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new G),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=c=>this._handleMouseMove(c),this._mouseUpListener=c=>this._handleMouseUp(c),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(c=>this._handleTrim(c)),this._register(this._bufferService.buffers.onBufferActivate(c=>this._handleBufferActivate(c))),this.enable(),this._model=new zp(this._bufferService),this._activeSelectionMode=0,this._register(Se(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(c=>{c.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let t=this._model.finalSelectionStart,e=this._model.finalSelectionEnd;return!t||!e?!1:t[0]!==e[0]||t[1]!==e[1]}get selectionText(){let t=this._model.finalSelectionStart,e=this._model.finalSelectionEnd;if(!t||!e)return"";let s=this._bufferService.buffer,i=[];if(this._activeSelectionMode===3){if(t[0]===e[0])return"";let r=t[0]<e[0]?t[0]:e[0],o=t[0]<e[0]?e[0]:t[0];for(let a=t[1];a<=e[1];a++){let l=s.translateBufferLineToString(a,!0,r,o);i.push(l)}}else{let r=t[1]===e[1]?e[0]:void 0;i.push(s.translateBufferLineToString(t[1],!0,t[0],r));for(let o=t[1]+1;o<=e[1]-1;o++){let a=s.lines.get(o),l=s.translateBufferLineToString(o,!0);a?.isWrapped?i[i.length-1]+=l:i.push(l)}if(t[1]!==e[1]){let o=s.lines.get(e[1]),a=s.translateBufferLineToString(e[1],!0,0,e[0]);o&&o.isWrapped?i[i.length-1]+=a:i.push(a)}}return i.map(r=>r.replace(Vp," ")).join(Ul?`\r
|
|
180
281
|
`:`
|
|
181
|
-
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(t){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Bn&&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=Eo(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=An(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,-hr),hr),e/=hr,e/Math.abs(e)+Math.round(e*(Tp-1)))}shouldForceSelection(t){return Mi?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(),Rp)}_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&&!(Mi&&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<Dp&&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=Sp(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,m=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],v=t[0];o.getWidth(g)===0&&(d++,g--),o.getWidth(v)===2&&(u++,v++);let x=o.getString(v).length;for(x>1&&(m+=x-1,h+=x-1);g>0&&l>0&&!this._isCharWordSeparator(o.loadCell(g-1,this._workCell));){o.loadCell(g-1,this._workCell);let b=this._workCell.getChars().length;this._workCell.getWidth()===0?(d++,g--):b>1&&(f+=b-1,l-=b-1),l--,g--}for(;v<o.length&&h+1<a.length&&!this._isCharWordSeparator(o.loadCell(v+1,this._workCell));){o.loadCell(v+1,this._workCell);let b=this._workCell.getChars().length;this._workCell.getWidth()===2?(u++,v++):b>1&&(m+=b-1,h+=b-1),h++,v++}}h++;let _=l+c-d+f,p=Math.min(this._bufferService.cols,h-l+d+u-f-m);if(!(!e&&a.slice(l,h).trim()==="")){if(s&&_===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 v=this._getWordAt([this._bufferService.cols-1,t[1]-1],!1,!0,!1);if(v){let x=this._bufferService.cols-v.start;_-=x,p+=x}}}if(i&&_+p===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 v=this._getWordAt([0,t[1]+1],!1,!1,!0);v&&(p+=v.length)}}return{start:_,length:p}}}_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=Eo(s,this._bufferService.cols)}};Jr=Re([ie(3,Ze),ie(4,ns),ie(5,En),ie(6,Qe),ie(7,Mt),ie(8,It)],Jr);var To=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={}}},Ro=class{constructor(){this._color=new To,this._css=new To}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()}},Be=Object.freeze((()=>{let t=[ke.toColor("#2e3436"),ke.toColor("#cc0000"),ke.toColor("#4e9a06"),ke.toColor("#c4a000"),ke.toColor("#3465a4"),ke.toColor("#75507b"),ke.toColor("#06989a"),ke.toColor("#d3d7cf"),ke.toColor("#555753"),ke.toColor("#ef2929"),ke.toColor("#8ae234"),ke.toColor("#fce94f"),ke.toColor("#729fcf"),ke.toColor("#ad7fa8"),ke.toColor("#34e2e2"),ke.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:Me.toCss(i,r,o),rgba:Me.toRgba(i,r,o)})}for(let s=0;s<24;s++){let i=8+s*10;t.push({css:Me.toCss(i,i,i),rgba:Me.toRgba(i,i,i)})}return t})()),qt=ke.toColor("#ffffff"),Ds=ke.toColor("#000000"),Do=ke.toColor("#ffffff"),Po=Ds,ks={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Mp=qt,Zr=class extends de{constructor(t){super(),this._optionsService=t,this._contrastCache=new Ro,this._halfContrastCache=new Ro,this._onChangeColors=this._register(new q),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:qt,background:Ds,cursor:Do,cursorAccent:Po,selectionForeground:void 0,selectionBackgroundTransparent:ks,selectionBackgroundOpaque:pe.blend(Ds,ks),selectionInactiveBackgroundTransparent:ks,selectionInactiveBackgroundOpaque:pe.blend(Ds,ks),scrollbarSliderBackground:pe.opacity(qt,.2),scrollbarSliderHoverBackground:pe.opacity(qt,.4),scrollbarSliderActiveBackground:pe.opacity(qt,.5),overviewRulerBorder:qt,ansi:Be.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=fe(t.foreground,qt),e.background=fe(t.background,Ds),e.cursor=pe.blend(e.background,fe(t.cursor,Do)),e.cursorAccent=pe.blend(e.background,fe(t.cursorAccent,Po)),e.selectionBackgroundTransparent=fe(t.selectionBackground,ks),e.selectionBackgroundOpaque=pe.blend(e.background,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundTransparent=fe(t.selectionInactiveBackground,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundOpaque=pe.blend(e.background,e.selectionInactiveBackgroundTransparent),e.selectionForeground=t.selectionForeground?fe(t.selectionForeground,ko):void 0,e.selectionForeground===ko&&(e.selectionForeground=void 0),pe.isOpaque(e.selectionBackgroundTransparent)&&(e.selectionBackgroundTransparent=pe.opacity(e.selectionBackgroundTransparent,.3)),pe.isOpaque(e.selectionInactiveBackgroundTransparent)&&(e.selectionInactiveBackgroundTransparent=pe.opacity(e.selectionInactiveBackgroundTransparent,.3)),e.scrollbarSliderBackground=fe(t.scrollbarSliderBackground,pe.opacity(e.foreground,.2)),e.scrollbarSliderHoverBackground=fe(t.scrollbarSliderHoverBackground,pe.opacity(e.foreground,.4)),e.scrollbarSliderActiveBackground=fe(t.scrollbarSliderActiveBackground,pe.opacity(e.foreground,.5)),e.overviewRulerBorder=fe(t.overviewRulerBorder,Mp),e.ansi=Be.slice(),e.ansi[0]=fe(t.black,Be[0]),e.ansi[1]=fe(t.red,Be[1]),e.ansi[2]=fe(t.green,Be[2]),e.ansi[3]=fe(t.yellow,Be[3]),e.ansi[4]=fe(t.blue,Be[4]),e.ansi[5]=fe(t.magenta,Be[5]),e.ansi[6]=fe(t.cyan,Be[6]),e.ansi[7]=fe(t.white,Be[7]),e.ansi[8]=fe(t.brightBlack,Be[8]),e.ansi[9]=fe(t.brightRed,Be[9]),e.ansi[10]=fe(t.brightGreen,Be[10]),e.ansi[11]=fe(t.brightYellow,Be[11]),e.ansi[12]=fe(t.brightBlue,Be[12]),e.ansi[13]=fe(t.brightMagenta,Be[13]),e.ansi[14]=fe(t.brightCyan,Be[14]),e.ansi[15]=fe(t.brightWhite,Be[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]=fe(t.extendedAnsi[i],Be[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()}}};Zr=Re([ie(0,Qe)],Zr);function fe(t,e){if(t!==void 0)try{return ke.toColor(t)}catch{}return e}var Ap=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)}},Bp=class{constructor(){this._services=new Ap,this._services.set(jn,this)}setService(t,e){this._services.set(t,e)}getService(t){return this._services.get(t)}createInstance(t,...e){let s=Tm(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)}},Lp={trace:0,debug:1,info:2,warn:3,error:4,off:5},Op="xterm.js: ",Qr=class extends de{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=Lp[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?"":Op)+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)}};Qr=Re([ie(0,Qe)],Qr);var Io=class extends de{constructor(t){super(),this._maxLength=t,this.onDeleteEmitter=this._register(new q),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new q),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new q),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}},ce=3,Ie=Object.freeze(new ei),_i=0,dr=2,Ps=class Wl{constructor(e,s,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*ce);let r=s||ht.fromCharData([0,ll,1,0]);for(let o=0;o<e;++o)this.setCell(o,r);this.length=e}get(e){let s=this._data[e*ce+0],i=s&2097151;return[this._data[e*ce+1],s&2097152?this._combined[e]:i?Ot(i):"",s>>22,s&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):i]}set(e,s){this._data[e*ce+1]=s[0],s[1].length>1?(this._combined[e]=s[1],this._data[e*ce+0]=e|2097152|s[2]<<22):this._data[e*ce+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(e){return this._data[e*ce+0]>>22}hasWidth(e){return this._data[e*ce+0]&12582912}getFg(e){return this._data[e*ce+1]}getBg(e){return this._data[e*ce+2]}hasContent(e){return this._data[e*ce+0]&4194303}getCodePoint(e){let s=this._data[e*ce+0];return s&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):s&2097151}isCombined(e){return this._data[e*ce+0]&2097152}getString(e){let s=this._data[e*ce+0];return s&2097152?this._combined[e]:s&2097151?Ot(s&2097151):""}isProtected(e){return this._data[e*ce+2]&536870912}loadCell(e,s){return _i=e*ce,s.content=this._data[_i+0],s.fg=this._data[_i+1],s.bg=this._data[_i+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*ce+0]=s.content,this._data[e*ce+1]=s.fg,this._data[e*ce+2]=s.bg}setCellFromCodepoint(e,s,i,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*ce+0]=s|i<<22,this._data[e*ce+1]=r.fg,this._data[e*ce+2]=r.bg}addCodepointToCell(e,s,i){let r=this._data[e*ce+0];r&2097152?this._combined[e]+=Ot(s):r&2097151?(this._combined[e]=Ot(r&2097151)+Ot(s),r&=-2097152,r|=2097152):r=s|1<<22,i&&(r&=-12582913,r|=i<<22),this._data[e*ce+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 ht;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 ht;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*dr<this._data.buffer.byteLength;let i=e*ce;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*dr<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*dr<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 Wl(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*ce+0]&4194303)return e+(this._data[e*ce+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*ce+0]&4194303||this._data[e*ce+2]&50331648)return e+(this._data[e*ce+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<ce;c++)this._data[(i+h)*ce+c]=a[(s+h)*ce+c];a[(s+h)*ce+2]&268435456&&(this._extendedAttrs[i+h]=e._extendedAttrs[s+h])}else for(let h=0;h<r;h++){for(let c=0;c<ce;c++)this._data[(i+h)*ce+c]=a[(s+h)*ce+c];a[(s+h)*ce+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*ce+0],l=a&2097151,h=a&2097152?this._combined[s]:l?Ot(l):$t;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 $p(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=Ks(d,u,e),m=1,_=0;for(;m<d.length;){let g=Ks(d,m,e),v=g-_,x=s-f,b=Math.min(v,x);d[u].copyCellsFrom(d[m],_,f,b,!1),f+=b,f===s&&(u++,f=0),_+=b,_===g&&(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 p=0;for(let g=d.length-1;g>0&&(g>u||d[g].getTrimmedLength()===0);g--)p++;p>0&&(a.push(l+d.length-p),a.push(p)),l+=d.length-1}return a}function zp(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 Fp(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 Hp(t,e,s){let i=[],r=t.map((h,c)=>Ks(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=Ks(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 Ks(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 Ul=class Vl{constructor(e){this.line=e,this.isDisposed=!1,this._disposables=[],this._id=Vl._nextId++,this._onDispose=this.register(new q),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),ts(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};Ul._nextId=1;var Wp=Ul,Oe={},Gt=Oe.B;Oe[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Oe.A={"#":"£"};Oe.B=void 0;Oe[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Oe.C=Oe[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Oe.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Oe.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Oe.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Oe.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Oe.E=Oe[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Oe.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Oe.H=Oe[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Oe["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Mo=4294967295,Ao=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=Ie.clone(),this.savedCharset=Gt,this.markers=[],this._nullCell=ht.fromCharData([0,ll,1,0]),this._whitespaceCell=ht.fromCharData([0,$t,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Ai,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Io(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 Di),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 Di),this._whitespaceCell}getBlankLine(t,e){return new Ps(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>Mo?Mo:e}fillViewportRows(t){if(this.lines.length===0){t===void 0&&(t=Ie);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 Io(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(t,e){let s=this.getNullCell(Ie),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 Ps(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 Ps(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=$p(this.lines,this._cols,t,this.ybase+this.y,this.getNullCell(Ie),s);if(i.length>0){let r=zp(this.lines,i);Fp(this.lines,r.layout),this._reflowLargerAdjustViewport(t,e,r.countRemoved)}}_reflowLargerAdjustViewport(t,e,s){let i=this.getNullCell(Ie),r=s;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<e&&this.lines.push(new Ps(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(Ie),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 b=this.ybase+this.y;if(b>=a&&b<a+h.length)continue}let c=h[h.length-1].getTrimmedLength(),d=Hp(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 m=[];for(let b=0;b<u;b++){let S=this.getBlankLine(Ie,!0);m.push(S)}m.length>0&&(r.push({start:a+h.length+o,newLines:m}),o+=m.length),h.push(...m);let _=d.length-1,p=d[_];p===0&&(_--,p=d[_]);let g=h.length-u-1,v=c;for(;g>=0;){let b=Math.min(v,p);if(h[_]===void 0)break;if(h[_].copyCellsFrom(h[g],v-b,p-b,b,!0),p-=b,p===0&&(_--,p=d[_]),v-=b,v===0){g--;let S=Math.max(g,0);v=Ks(h,S,this._cols)}}for(let b=0;b<h.length;b++)d[b]<t&&h[b].setCell(d[b],i);let x=u-f;for(;x-- >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 p=0;p<this.lines.length;p++)l.push(this.lines.get(p));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 p=Math.min(this.lines.maxLength-1,h+o-1);p>=0;p--)if(u&&u.start>c+f){for(let g=u.newLines.length-1;g>=0;g--)this.lines.set(p--,u.newLines[g]);p++,a.push({index:c+1,amount:u.newLines.length}),f+=u.newLines.length,u=r[++d]}else this.lines.set(p,l[c--]);let m=0;for(let p=a.length-1;p>=0;p--)a[p].index+=m,this.lines.onInsertEmitter.fire(a[p]),m+=a[p].amount;let _=Math.max(0,h+o-this.lines.maxLength);_>0&&this.lines.onTrimEmitter.fire(_)}}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 Wp(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)}},Up=class extends de{constructor(t,e){super(),this._optionsService=t,this._bufferService=e,this._onBufferActivate=this._register(new q),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 Ao(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Ao(!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)}},Kl=2,ql=1,en=class extends de{constructor(t){super(),this.isUserScrolling=!1,this._onResize=this._register(new q),this.onResize=this._onResize.event,this._onScroll=this._register(new q),this.onScroll=this._onScroll.event,this.cols=Math.max(t.rawOptions.cols||0,Kl),this.rows=Math.max(t.rawOptions.rows||0,ql),this.buffers=this._register(new Up(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))}};en=Re([ie(0,Qe)],en);var cs={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:Mi,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},Vp=["normal","bold","100","200","300","400","500","600","700","800","900"],Kp=class extends de{constructor(t){super(),this._onOptionChange=this._register(new q),this.onOptionChange=this._onOptionChange.event;let e={...cs};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(ye(()=>{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 cs))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},e=(s,i)=>{if(!(s in cs))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=cs[t]),!qp(e))throw new Error(`"${e}" is not a valid value for ${t}`);break;case"wordSeparator":e||(e=cs[t]);break;case"fontWeight":case"fontWeightBold":if(typeof e=="number"&&1<=e&&e<=1e3)break;e=Vp.includes(e)?e:cs[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 qp(t){return t==="block"||t==="underline"||t==="bar"}function Is(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]&&Is(t[i],e-1);return s}var Bo=Object.freeze({insertMode:!1}),Lo=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),tn=class extends de{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 q),this.onData=this._onData.event,this._onUserInput=this._register(new q),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new q),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new q),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Is(Bo),this.decPrivateModes=Is(Lo)}reset(){this.modes=Is(Bo),this.decPrivateModes=Is(Lo)}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))}};tn=Re([ie(0,Ze),ie(1,fl),ie(2,Qe)],tn);var Oo={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 ur(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 fr=String.fromCharCode,$o={DEFAULT:t=>{let e=[ur(t,!1)+32,t.col+32,t.row+32];return e[0]>255||e[1]>255||e[2]>255?"":`\x1B[M${fr(e[0])}${fr(e[1])}${fr(e[2])}`},SGR:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${ur(t,!0)};${t.col};${t.row}${e}`},SGR_PIXELS:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${ur(t,!0)};${t.x};${t.y}${e}`}},sn=class extends de{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 q),this.onProtocolChange=this._onProtocolChange.event;for(let i of Object.keys(Oo))this.addProtocol(i,Oo[i]);for(let i of Object.keys($o))this.addEncoding(i,$o[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)}};sn=Re([ie(0,Ze),ie(1,ns),ie(2,Qe)],sn);var mr=[[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]],Gp=[[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]],Le;function Yp(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 Xp=class{constructor(){if(this.version="6",!Le){Le=new Uint8Array(65536),Le.fill(1),Le[0]=0,Le.fill(0,1,32),Le.fill(0,127,160),Le.fill(2,4352,4448),Le[9001]=2,Le[9002]=2,Le.fill(2,11904,42192),Le[12351]=1,Le.fill(2,44032,55204),Le.fill(2,63744,64256),Le.fill(2,65040,65050),Le.fill(2,65072,65136),Le.fill(2,65280,65377),Le.fill(2,65504,65511);for(let t=0;t<mr.length;++t)Le.fill(0,mr[t][0],mr[t][1]+1)}}wcwidth(t){return t<32?0:t<127?1:t<65536?Le[t]:Yp(t,Gp)?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=Yt.extractWidth(e);r===0?i=!1:r>s&&(s=r)}return Yt.createPropertyValue(0,s,i)}},Yt=class ki{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new q,this.onChange=this._onChange.event;let e=new Xp;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=ki.extractWidth(l);ki.extractShouldJoin(l)&&(h-=ki.extractWidth(i)),s+=h,i=l}return s}charProperties(e,s){return this._activeProvider.charProperties(e,s)}},Jp=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 zo(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 Ns=2147483647,Zp=256,Gl=class rn{constructor(e=32,s=32){if(this.maxLength=e,this.maxSubParamsLength=s,s>Zp)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 rn;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 rn(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>Ns?Ns: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>Ns?Ns: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,Ns):e}},js=[],Qp=class{constructor(){this._state=0,this._active=js,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=js}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=js,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||js,!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",Vi(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=js,this._id=-1,this._state=0}}},st=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+=Vi(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}},Es=[],eg=class{constructor(){this._handlers=Object.create(null),this._active=Es,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Es}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=Es,this._ident=0}hook(t,e){if(this.reset(),this._ident=t,this._active=this._handlers[t]||Es,!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",Vi(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=Es,this._ident=0}},Ms=new Gl;Ms.addParam(0);var Fo=class{constructor(t){this._handler=t,this._data="",this._params=Ms,this._hitLimit=!1}hook(t){this._params=t.length>1||t.params[0]?t.clone():Ms,this._data="",this._hitLimit=!1}put(t,e,s){this._hitLimit||(this._data+=Vi(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=Ms,this._data="",this._hitLimit=!1,s));return this._params=Ms,this._data="",this._hitLimit=!1,e}},tg=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}},ct=160,sg=(function(){let t=new tg(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(ct,0,2,0),t.add(ct,8,5,8),t.add(ct,6,0,6),t.add(ct,11,0,11),t.add(ct,13,13,13),t})(),ig=class extends de{constructor(t=sg){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 Gl,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(ye(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new Qp),this._dcsParser=this._register(new eg),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:ct)],r>>4){case 2:for(let f=l+1;;++f){if(f>=e||(i=t[f])<32||i>126&&i<ct){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(i=t[f])<32||i>126&&i<ct){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(i=t[f])<32||i>126&&i<ct){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(i=t[f])<32||i>126&&i<ct){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<ct){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<ct){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}}},rg=/^([\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})$/,ng=/^[\da-f]+$/;function Ho(t){if(!t)return;let e=t.toLowerCase();if(e.indexOf("rgb:")===0){e=e.slice(4);let s=rg.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),ng.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 _r(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 og(t,e=16){let[s,i,r]=t;return`rgb:${_r(s,e)}/${_r(i,e)}/${_r(r,e)}`}var ag={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Lt=131072,Wo=10;function Uo(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 Vo=5e3,Ko=0,lg=class extends de{constructor(t,e,s,i,r,o,a,l,h=new ig){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 jm,this._utf8Decoder=new Em,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Ie.clone(),this._eraseAttrDataInternal=Ie.clone(),this._onRequestBell=this._register(new q),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new q),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new q),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new q),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new q),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new q),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new q),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new q),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new q),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new q),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new q),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new q),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new q),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 nn(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(U.BEL,()=>this.bell()),this._parser.setExecuteHandler(U.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(U.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(U.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(U.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(U.BS,()=>this.backspace()),this._parser.setExecuteHandler(U.HT,()=>this.tab()),this._parser.setExecuteHandler(U.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(U.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(wi.IND,()=>this.index()),this._parser.setExecuteHandler(wi.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(wi.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new st(c=>(this.setTitle(c),this.setIconName(c),!0))),this._parser.registerOscHandler(1,new st(c=>this.setIconName(c))),this._parser.registerOscHandler(2,new st(c=>this.setTitle(c))),this._parser.registerOscHandler(4,new st(c=>this.setOrReportIndexedColor(c))),this._parser.registerOscHandler(8,new st(c=>this.setHyperlink(c))),this._parser.registerOscHandler(10,new st(c=>this.setOrReportFgColor(c))),this._parser.registerOscHandler(11,new st(c=>this.setOrReportBgColor(c))),this._parser.registerOscHandler(12,new st(c=>this.setOrReportCursorColor(c))),this._parser.registerOscHandler(104,new st(c=>this.restoreIndexedColor(c))),this._parser.registerOscHandler(110,new st(c=>this.restoreFgColor(c))),this._parser.registerOscHandler(111,new st(c=>this.restoreBgColor(c))),this._parser.registerOscHandler(112,new st(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 Oe)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 Fo((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"),Vo))]).catch(e=>{if(e!=="#SLOW_TIMEOUT")throw e;console.warn(`async parser handler taking longer than ${Vo} 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>Lt&&(o=this._parseStack.position+Lt)}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<Lt&&(this._parseBuffer=new Uint32Array(Math.min(t.length,Lt))),a||this._dirtyRowTracker.clearRange(),t.length>Lt)for(let c=o;c<t.length;c+=Lt){let d=c+Lt<t.length?c+Lt: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 m=e;m<s;++m){if(i=t[m],i<127&&o){let v=o[String.fromCharCode(i)];v&&(i=v.charCodeAt(0))}let _=this._unicodeService.charProperties(i,f);r=Yt.extractWidth(_);let p=Yt.extractShouldJoin(_),g=p?Yt.extractWidth(f):0;if(f=_,a&&this._onA11yChar.fire(Ot(i)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-g>l){if(h){let v=u,x=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 Ps&&u.copyCellsFrom(v,x,0,g,!1);x<l;)v.setCellFromCodepoint(x++,0,1,d)}else if(this._activeBuffer.x=l-1,r===2)continue}if(p&&this._activeBuffer.x){let v=u.getWidth(this._activeBuffer.x-1)?1:2;u.addCodepointToCell(this._activeBuffer.x-v,i,r);for(let x=r-g;--x>=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=>Uo(s.params[0],this._optionsService.rawOptions.windowOptions)?e(s):!0):this._parser.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._parser.registerDcsHandler(t,new Fo(e))}registerEscHandler(t,e){return this._parser.registerEscHandler(t,e)}registerOscHandler(t,e){return this._parser.registerOscHandler(t,new st(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(Ie));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=Yt.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(U.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(U.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(t){return t.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(U.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(U.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(t.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(U.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,Gt),this._charsetService.setgCharset(1,Gt),this._charsetService.setgCharset(2,Gt),this._charsetService.setgCharset(3,Gt);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;(p=>(p[p.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",p[p.SET=1]="SET",p[p.RESET=2]="RESET",p[p.PERMANENTLY_SET=3]="PERMANENTLY_SET",p[p.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=(p,g)=>(a.triggerDataEvent(`${U.ESC}[${e?"":"?"}${p};${g}$y`),!0),m=p=>p?1:2,_=t.params[0];return e?_===2?f(_,4):_===4?f(_,m(a.modes.insertMode)):_===12?f(_,3):_===20?f(_,m(u.convertEol)):f(_,0):_===1?f(_,m(i.applicationCursorKeys)):_===3?f(_,u.windowOptions.setWinLines?h===80?2:h===132?1:0:0):_===6?f(_,m(i.origin)):_===7?f(_,m(i.wraparound)):_===8?f(_,3):_===9?f(_,m(r==="X10")):_===12?f(_,m(u.cursorBlink)):_===25?f(_,m(!a.isCursorHidden)):_===45?f(_,m(i.reverseWraparound)):_===66?f(_,m(i.applicationKeypad)):_===67?f(_,4):_===1e3?f(_,m(r==="VT200")):_===1002?f(_,m(r==="DRAG")):_===1003?f(_,m(r==="ANY")):_===1004?f(_,m(i.sendFocus)):_===1005?f(_,4):_===1006?f(_,m(o==="SGR")):_===1015?f(_,4):_===1016?f(_,m(o==="SGR_PIXELS")):_===1048?f(_,1):_===47||_===1047||_===1049?f(_,m(c===d)):_===2004?f(_,m(i.bracketedPasteMode)):_===2026?f(_,m(i.synchronizedOutput)):f(_,0)}_updateAttrColor(t,e,s,i,r){return e===2?(t|=50331648,t&=-16777216,t|=ei.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=Ie.fg,t.bg=Ie.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|=Ie.fg&16777215):s===49?(i.bg&=-67108864,i.bg|=Ie.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|=Ie.fg&16777215,i.bg&=-67108864,i.bg|=Ie.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(t){switch(t.params[0]){case 5:this._coreService.triggerDataEvent(`${U.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${U.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(`${U.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=Ie.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(!Uo(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(`${U.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(e===0||e===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Wo&&this._windowTitleStack.shift()),(e===0||e===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Wo&&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(qo(o))if(r==="?")e.push({type:0,index:o});else{let a=Ho(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=Ho(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]);qo(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,Gt),!0}selectCharset(t){return t.length!==2?(this.selectDefaultCharset(),!0):(t[0]==="/"||this._charsetService.setgCharset(ag[t[0]],Oe[t[1]]||Gt),!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=Ie.clone(),this._eraseAttrDataInternal=Ie.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 ht;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(`${U.ESC}${a}${U.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)}},nn=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&&(Ko=t,t=e,e=Ko),t<this.start&&(this.start=t),e>this.end&&(this.end=e)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};nn=Re([ie(0,Ze)],nn);function qo(t){return 0<=t&&t<256}var cg=5e7,Go=12,hg=50,dg=class extends de{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 q),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>cg)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>=Go?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>=Go)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>hg&&(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()}},on=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)))}};on=Re([ie(0,Ze)],on);var Yo=!1,ug=class extends de{constructor(t){super(),this._windowsWrappingHeuristics=this._register(new ms),this._onBinary=this._register(new q),this.onBinary=this._onBinary.event,this._onData=this._register(new q),this.onData=this._onData.event,this._onLineFeed=this._register(new q),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new q),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new q),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new q),this._instantiationService=new Bp,this.optionsService=this._register(new Kp(t)),this._instantiationService.setService(Qe,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(en)),this._instantiationService.setService(Ze,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Qr)),this._instantiationService.setService(fl,this._logService),this.coreService=this._register(this._instantiationService.createInstance(tn)),this._instantiationService.setService(ns,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(sn)),this._instantiationService.setService(ul,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Yt)),this._instantiationService.setService(Pm,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Jp),this._instantiationService.setService(Dm,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(on),this._instantiationService.setService(ml,this._oscLinkService),this._inputHandler=this._register(new lg(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Ke.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Ke.forward(this._bufferService.onResize,this._onResize)),this._register(Ke.forward(this.coreService.onData,this._onData)),this._register(Ke.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 dg((e,s)=>this._inputHandler.parse(e,s))),this._register(Ke.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new q),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&&!Yo&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Yo=!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,Kl),e=Math.max(e,ql),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(zo.bind(null,this._bufferService))),t.push(this.registerCsiHandler({final:"H"},()=>(zo(this._bufferService),!1))),this._windowsWrappingHeuristics.value=ye(()=>{for(let e of t)e.dispose()})}}},fg={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 mg(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=U.ESC+"OA":r.key=U.ESC+"[A":t.key==="UIKeyInputLeftArrow"?e?r.key=U.ESC+"OD":r.key=U.ESC+"[D":t.key==="UIKeyInputRightArrow"?e?r.key=U.ESC+"OC":r.key=U.ESC+"[C":t.key==="UIKeyInputDownArrow"&&(e?r.key=U.ESC+"OB":r.key=U.ESC+"[B");break;case 8:r.key=t.ctrlKey?"\b":U.DEL,t.altKey&&(r.key=U.ESC+r.key);break;case 9:if(t.shiftKey){r.key=U.ESC+"[Z";break}r.key=U.HT,r.cancel=!0;break;case 13:r.key=t.altKey?U.ESC+U.CR:U.CR,r.cancel=!0;break;case 27:r.key=U.ESC,t.altKey&&(r.key=U.ESC+U.ESC),r.cancel=!0;break;case 37:if(t.metaKey)break;o?r.key=U.ESC+"[1;"+(o+1)+"D":e?r.key=U.ESC+"OD":r.key=U.ESC+"[D";break;case 39:if(t.metaKey)break;o?r.key=U.ESC+"[1;"+(o+1)+"C":e?r.key=U.ESC+"OC":r.key=U.ESC+"[C";break;case 38:if(t.metaKey)break;o?r.key=U.ESC+"[1;"+(o+1)+"A":e?r.key=U.ESC+"OA":r.key=U.ESC+"[A";break;case 40:if(t.metaKey)break;o?r.key=U.ESC+"[1;"+(o+1)+"B":e?r.key=U.ESC+"OB":r.key=U.ESC+"[B";break;case 45:!t.shiftKey&&!t.ctrlKey&&(r.key=U.ESC+"[2~");break;case 46:o?r.key=U.ESC+"[3;"+(o+1)+"~":r.key=U.ESC+"[3~";break;case 36:o?r.key=U.ESC+"[1;"+(o+1)+"H":e?r.key=U.ESC+"OH":r.key=U.ESC+"[H";break;case 35:o?r.key=U.ESC+"[1;"+(o+1)+"F":e?r.key=U.ESC+"OF":r.key=U.ESC+"[F";break;case 33:t.shiftKey?r.type=2:t.ctrlKey?r.key=U.ESC+"[5;"+(o+1)+"~":r.key=U.ESC+"[5~";break;case 34:t.shiftKey?r.type=3:t.ctrlKey?r.key=U.ESC+"[6;"+(o+1)+"~":r.key=U.ESC+"[6~";break;case 112:o?r.key=U.ESC+"[1;"+(o+1)+"P":r.key=U.ESC+"OP";break;case 113:o?r.key=U.ESC+"[1;"+(o+1)+"Q":r.key=U.ESC+"OQ";break;case 114:o?r.key=U.ESC+"[1;"+(o+1)+"R":r.key=U.ESC+"OR";break;case 115:o?r.key=U.ESC+"[1;"+(o+1)+"S":r.key=U.ESC+"OS";break;case 116:o?r.key=U.ESC+"[15;"+(o+1)+"~":r.key=U.ESC+"[15~";break;case 117:o?r.key=U.ESC+"[17;"+(o+1)+"~":r.key=U.ESC+"[17~";break;case 118:o?r.key=U.ESC+"[18;"+(o+1)+"~":r.key=U.ESC+"[18~";break;case 119:o?r.key=U.ESC+"[19;"+(o+1)+"~":r.key=U.ESC+"[19~";break;case 120:o?r.key=U.ESC+"[20;"+(o+1)+"~":r.key=U.ESC+"[20~";break;case 121:o?r.key=U.ESC+"[21;"+(o+1)+"~":r.key=U.ESC+"[21~";break;case 122:o?r.key=U.ESC+"[23;"+(o+1)+"~":r.key=U.ESC+"[23~";break;case 123:o?r.key=U.ESC+"[24;"+(o+1)+"~":r.key=U.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=U.NUL:t.keyCode>=51&&t.keyCode<=55?r.key=String.fromCharCode(t.keyCode-51+27):t.keyCode===56?r.key=U.DEL:t.keyCode===219?r.key=U.ESC:t.keyCode===220?r.key=U.FS:t.keyCode===221&&(r.key=U.GS);else if((!s||i)&&t.altKey&&!t.metaKey){let a=fg[t.keyCode]?.[t.shiftKey?1:0];if(a)r.key=U.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=U.ESC+h}else if(t.keyCode===32)r.key=U.ESC+(t.ctrlKey?U.NUL:" ");else if(t.key==="Dead"&&t.code.startsWith("Key")){let l=t.code.slice(3,4);t.shiftKey||(l=l.toLowerCase()),r.key=U.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=U.US),t.key==="@"&&(r.key=U.NUL));break}return r}var Pe=0,_g=class{constructor(t){this._getKey=t,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Ai,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Ai,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||(Pe=this._search(e),Pe===-1)||this._getKey(this._array[Pe])!==e)return!1;do if(this._array[Pe]===t)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Pe),!0;while(++Pe<this._array.length&&this._getKey(this._array[Pe])===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&&(Pe=this._search(t),!(Pe<0||Pe>=this._array.length)&&this._getKey(this._array[Pe])===t))do yield this._array[Pe];while(++Pe<this._array.length&&this._getKey(this._array[Pe])===t)}forEachByKey(t,e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Pe=this._search(t),!(Pe<0||Pe>=this._array.length)&&this._getKey(this._array[Pe])===t))do e(this._array[Pe]);while(++Pe<this._array.length&&this._getKey(this._array[Pe])===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}},pr=0,Xo=0,pg=class extends de{constructor(){super(),this._decorations=new _g(t=>t?.marker.line),this._onDecorationRegistered=this._register(new q),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new q),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(ye(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(t){if(t.marker.isDisposed)return;let e=new gg(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=>{pr=r.options.x??0,Xo=pr+(r.options.width??1),t>=pr&&t<Xo&&(!s||(r.options.layer??"bottom")===s)&&i(r)})}},gg=class extends zt{constructor(t){super(),this.options=t,this.onRenderEmitter=this.add(new q),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new q),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=ke.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=ke.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},vg=1e3,xg=class{constructor(t,e=vg){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)}},Jo=20,Bi=class extends de{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 xg(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(`
|
|
182
|
-
`))),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(
|
|
183
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Jo+1&&(this._liveRegion.textContent+=kr.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})`}};Bi=Re([ie(1,jn),ie(2,It),ie(3,Mt)],Bi);var an=class extends de{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 q),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new q),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(ye(()=>{ts(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(ae(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(ae(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(ae(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(ae(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&&bg(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,ts(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}}};an=Re([ie(1,En),ie(2,Mt),ie(3,Ze),ie(4,pl)],an);function bg(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 Sg=class extends ug{constructor(t={}){super(t),this._linkifier=this._register(new ms),this.browser=Al,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new ms),this._onCursorMove=this._register(new q),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new q),this.onKey=this._onKey.event,this._onRender=this._register(new q),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new q),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new q),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new q),this.onBell=this._onBell.event,this._onFocus=this._register(new q),this._onBlur=this._register(new q),this._onA11yCharEmitter=this._register(new q),this._onA11yTabEmitter=this._register(new q),this._onWillOpen=this._register(new q),this._setup(),this._decorationService=this._instantiationService.createInstance(pg),this._instantiationService.setService(ti,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(hp),this._instantiationService.setService(pl,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(jr)),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(Ke.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Ke.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Ke.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Ke.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(ye(()=>{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=pe.toColorRGB(s==="ansi"?this._themeService.colors.ansi[e.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${U.ESC}]${i};${og(r)}${Il.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(o=>o.ansi[e.index]=Me.toColor(...e.color));else{let o=s;this._themeService.modifyColors(a=>a[o]=Me.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(Bi,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(t){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(U.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(U.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(ae(this.element,"copy",e=>{this.hasSelection()&&km(e,this._selectionService)}));let t=e=>Nm(e,this.textarea,this.coreService,this.optionsService);this._register(ae(this.textarea,"paste",t)),this._register(ae(this.element,"paste",t)),Bl?this._register(ae(this.element,"mousedown",e=>{e.button===2&&oo(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(ae(this.element,"contextmenu",e=>{oo(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Bn&&this._register(ae(this.element,"auxclick",e=>{e.button===1&&al(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(ae(this.textarea,"keyup",t=>this._keyUp(t),!0)),this._register(ae(this.textarea,"keydown",t=>this._keyDown(t),!0)),this._register(ae(this.textarea,"keypress",t=>this._keyPress(t),!0)),this._register(ae(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(ae(this.textarea,"compositionupdate",t=>this._compositionHelper.compositionupdate(t))),this._register(ae(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(ae(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(ae(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",Cr.get()),$l||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(lp,this.textarea,t.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(It,this._coreBrowserService),this._register(ae(this.textarea,"focus",r=>this._handleTextAreaFocus(r))),this._register(ae(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Gr,this._document,this._helperContainer),this._instantiationService.setService(Ki,this._charSizeService),this._themeService=this._instantiationService.createInstance(Zr),this._instantiationService.setService(bs,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Ii),this._instantiationService.setService(_l,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Xr,this.rows,this.screenElement)),this._instantiationService.setService(Mt,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(Vr,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Yr),this._instantiationService.setService(En,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(an,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(Wr,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(Jr,this.element,this.screenElement,i)),this._instantiationService.setService(Mm,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(Ke.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(Ur,this.screenElement)),this._register(ae(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(Bi,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",r=>this._handleScreenReaderModeOptionChange(r))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Pi,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",r=>{!this._overviewRulerRenderer&&r&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Pi,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(qr,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(ae(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(ae(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=U.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){ol(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=mg(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===U.ETX||s.key===U.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)&&(yg(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(Ie));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(U.ESC+"[I"):this.coreService.triggerDataEvent(U.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(`${U.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(`${U.ESC}[6;${r};${i}t`);break}}cancel(t,e){if(!(!this.options.cancelEvents&&!e))return t.preventDefault(),t.stopPropagation(),!1}};function yg(t){return t.keyCode===16||t.keyCode===17||t.keyCode===18}var wg=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)}},Cg=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 ht)}translateToString(t,e,s){return this._line.translateToString(t,e,s)}},Zo=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 Cg(e)}getNullCell(){return new ht}},kg=class extends de{constructor(t){super(),this._core=t,this._onBufferChange=this._register(new q),this.onBufferChange=this._onBufferChange.event,this._normal=new Zo(this._core.buffers.normal,"normal"),this._alternate=new Zo(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)}},Ng=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)}},jg=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}},Eg=["cols","rows"],xt=0,Tg=class extends de{constructor(t){super(),this._core=this._register(new Sg(t)),this._addonManager=this._register(new wg),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(Eg.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 Ng(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new jg(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 kg(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
|
|
184
|
-
`,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 Cr.get()},set promptLabel(t){Cr.set(t)},get tooMuchOutput(){return kr.get()},set tooMuchOutput(t){kr.set(t)}}}_verifyIntegers(...t){for(xt of t)if(xt===1/0||isNaN(xt)||xt%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(xt of t)if(xt&&(xt===1/0||isNaN(xt)||xt%1!==0||xt<0))throw new Error("This API only accepts positive integers")}};var Rg=2,Dg=1,Pg=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(Rg,Math.floor(d/t.css.cell.width)),rows:Math.max(Dg,Math.floor(c/t.css.cell.height))}}};function Yl({source:t,onReady:e,onSelectionChange:s,className:i}){const r=A.useRef(null),o=A.useRef(null),a=A.useRef(s);a.current=s;const l=xs(),h=A.useRef(t);return h.current=t,sm((c,d)=>{c===h.current&&o.current?.write(d)}),A.useEffect(()=>{const c=r.current;if(!c)return;const d=getComputedStyle(document.documentElement),u=v=>d.getPropertyValue(v).trim()||void 0,f=new Tg({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")}}),m=new Pg;f.loadAddon(m),f.open(c),m.fit();const _=l.getBuffer(t);_&&f.write(_),o.current=f,e?.(f);const p=f.onSelectionChange(()=>{const v=!!f.getSelection();a.current?.(v,()=>f.getSelection())}),g=new ResizeObserver(()=>{m.fit()});return g.observe(c),()=>{p.dispose(),g.disconnect(),o.current=null,f.dispose()}},[]),n.jsx("div",{className:te("h-full bg-sidebar p-3",i),children:n.jsx("div",{ref:r,className:"h-full"})})}function Ts(t){const e=z.c(24);if(t.kind==="starting-now"){let c;return e[0]!==t.claimPhase||e[1]!==t.progress?(c=n.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:n.jsx(mm,{progress:t.progress,claimPhase:t.claimPhase})}),e[0]=t.claimPhase,e[1]=t.progress,e[2]=c):c=e[2],c}let s,i;e[3]!==t.kind?(s=n.jsx(Ig,{kind:t.kind}),i=n.jsx(Mg,{kind:t.kind}),e[3]=t.kind,e[4]=s,e[5]=i):(s=e[4],i=e[5]);let r;e[6]!==t?(r=n.jsx(Ag,{...t}),e[6]=t,e[7]=r):r=e[7];let o;e[8]!==t.kind||e[9]!==t.progress?(o=t.kind==="errored"&&n.jsx(Bg,{progress:t.progress}),e[8]=t.kind,e[9]=t.progress,e[10]=o):o=e[10];let a;e[11]!==t.drawerOpen||e[12]!==t.kind||e[13]!==t.logSource?(a=t.kind==="errored"&&!t.drawerOpen&&n.jsx(Lg,{source:t.logSource}),e[11]=t.drawerOpen,e[12]=t.kind,e[13]=t.logSource,e[14]=a):a=e[14];let l;e[15]!==t?(l=n.jsx(Og,{...t}),e[15]=t,e[16]=l):l=e[16];let h;return e[17]!==s||e[18]!==i||e[19]!==r||e[20]!==o||e[21]!==a||e[22]!==l?(h=n.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:n.jsxs("div",{className:"flex w-full max-w-md flex-col items-center gap-4 text-center",children:[s,i,r,o,a,l]})}),e[17]=s,e[18]=i,e[19]=r,e[20]=o,e[21]=a,e[22]=l,e[23]=h):h=e[23],h}function Ig(t){const e=z.c(4),{kind:s}=t;switch(s){case"never-started":{let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(ga,{className:te("size-12","text-muted-foreground/60")}),e[0]=i):i=e[0],i}case"errored":{let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Ni,{className:te("size-12","text-destructive")}),e[1]=i):i=e[1],i}case"suspended":{let i;return e[2]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Qc,{className:te("size-12","text-blue-500")}),e[2]=i):i=e[2],i}case"crashed":{let i;return e[3]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Ni,{className:te("size-12","text-amber-500")}),e[3]=i):i=e[3],i}}}function Mg(t){const e=z.c(4),{kind:s}=t;let i;e[0]!==s?(i=am(s),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=n.jsx("h3",{className:"text-lg font-medium",children:i}),e[2]=i,e[3]=r):r=e[3],r}function Ag(t){const e=z.c(5);switch(t.kind){case"never-started":{let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:"Start the sandbox to launch your dev environment."}),e[0]=s):s=e[0],s}case"errored":{let s;return e[1]!==t.errorLine?(s=n.jsx("p",{role:"alert",className:"max-w-sm break-words text-sm text-destructive/80",children:t.errorLine}),e[1]=t.errorLine,e[2]=s):s=e[2],s}case"suspended":{let s;return e[3]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:"Suspended after 30 min idle to conserve resources. Resume to continue where you left off."}),e[3]=s):s=e[3],s}case"crashed":{let s;return e[4]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:"The dev server stopped responding. Open the terminal to inspect the logs and restart it."}),e[4]=s):s=e[4],s}}}function Bg(t){const e=z.c(21),{progress:s}=t;let i;e[0]!==s?(i=li(s,"provision"),e[0]=s,e[1]=i):i=e[1];let r;e[2]!==i?(r=n.jsx(pi,{label:"provision",status:i}),e[2]=i,e[3]=r):r=e[3];let o;e[4]!==s?(o=li(s,"cloning"),e[4]=s,e[5]=o):o=e[5];let a;e[6]!==o?(a=n.jsx(pi,{label:"cloning",status:o}),e[6]=o,e[7]=a):a=e[7];let l;e[8]!==s?(l=li(s,"install"),e[8]=s,e[9]=l):l=e[9];let h;e[10]!==l?(h=n.jsx(pi,{label:"install",status:l}),e[10]=l,e[11]=h):h=e[11];let c;e[12]!==s?(c=li(s,"dev"),e[12]=s,e[13]=c):c=e[13];let d;e[14]!==c?(d=n.jsx(pi,{label:"dev",status:c}),e[14]=c,e[15]=d):d=e[15];let u;return e[16]!==r||e[17]!==a||e[18]!==h||e[19]!==d?(u=n.jsx("div",{className:"flex w-full flex-col gap-1 rounded-lg border border-border bg-muted/30 px-4 py-3 text-left",children:n.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs font-medium",children:[r,a,h,d]})}),e[16]=r,e[17]=a,e[18]=h,e[19]=d,e[20]=u):u=e[20],u}function pi(t){const e=z.c(12),{label:s,status:i}=t;let r;e[0]!==i?(r=om(i),e[0]=i,e[1]=r):r=e[1];const o=r,a=i==="done"?"text-emerald-600":i==="failed"?"text-destructive":i==="doing"?"text-amber-500":"text-muted-foreground/60";let l;e[2]!==a?(l=te("flex items-center gap-1.5",a),e[2]=a,e[3]=l):l=e[3];let h;e[4]!==o?(h=n.jsx("span",{"aria-hidden":!0,children:o}),e[4]=o,e[5]=h):h=e[5];let c;e[6]!==s?(c=n.jsx("span",{children:s}),e[6]=s,e[7]=c):c=e[7];let d;return e[8]!==l||e[9]!==h||e[10]!==c?(d=n.jsxs("span",{className:l,children:[h,c]}),e[8]=l,e[9]=h,e[10]=c,e[11]=d):d=e[11],d}function Lg(t){const e=z.c(2),{source:s}=t;let i;return e[0]!==s?(i=n.jsx("div",{className:"flex w-[min(78%,560px)] flex-col items-stretch gap-1.5",children:n.jsx("div",{className:"h-32 overflow-hidden rounded-md [&_.xterm-viewport::-webkit-scrollbar]:hidden [&_.xterm-viewport]:!overflow-hidden",children:n.jsx(Yl,{source:s,className:"h-full"})})}),e[0]=s,e[1]=i):i=e[1],i}function Og(t){const e=z.c(12);switch(t.kind){case"never-started":{let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(Qt,{className:"size-4"}),e[0]=s):s=e[0];let i;return e[1]!==t.onStart?(i=n.jsxs(se,{onClick:t.onStart,className:"mt-2",children:[s," Start sandbox"]}),e[1]=t.onStart,e[2]=i):i=e[2],i}case"errored":{let s;e[3]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(zs,{className:"size-4"}),e[3]=s):s=e[3];let i;return e[4]!==t.onRetry?(i=n.jsxs(se,{size:"sm",onClick:t.onRetry,className:"mt-2",children:[s," Retry"]}),e[4]=t.onRetry,e[5]=i):i=e[5],i}case"suspended":{let s;e[6]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(Qt,{className:"size-4"}),e[6]=s):s=e[6];let i;return e[7]!==t.onResume?(i=n.jsxs(se,{onClick:t.onResume,className:"mt-2",children:[s," Resume"]}),e[7]=t.onResume,e[8]=i):i=e[8],i}case"crashed":{let s;e[9]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(va,{className:"size-4"}),e[9]=s):s=e[9];let i;return e[10]!==t.onOpenTerminal?(i=n.jsxs(se,{onClick:t.onOpenTerminal,className:"mt-2",children:[s," Open terminal"]}),e[10]=t.onOpenTerminal,e[11]=i):i=e[11],i}}}const Jt="setup";function $g(t){const e=z.c(35);let s;if(e[0]!==t.scriptTabs||e[1]!==t.scripts){let m;e[3]!==t.scriptTabs?(m=_=>!t.scriptTabs.includes(_),e[3]=t.scriptTabs,e[4]=m):m=e[4],s=t.scripts.filter(m),e[0]=t.scriptTabs,e[1]=t.scripts,e[2]=s}else s=e[2];const i=s;let r;e[5]!==t?(r=()=>{t.active===Jt?t.onToggle():t.onSelectTab(Jt)},e[5]=t,e[6]=r):r=e[6];const o=r,a=t.active===Jt;let l;e[7]!==o||e[8]!==t.open||e[9]!==a?(l=n.jsx(zg,{active:a,open:t.open,onClick:o}),e[7]=o,e[8]=t.open,e[9]=a,e[10]=l):l=e[10];let h;e[11]!==t?(h=t.scriptTabs.map(m=>n.jsx(Hg,{active:t.active===m,onClick:()=>t.onSelectTab(m),onClose:()=>t.onCloseScript(m),children:m},m)),e[11]=t,e[12]=h):h=e[12];let c;e[13]!==i||e[14]!==t.onAddScript?(c=n.jsx(Wg,{scripts:i,onRun:t.onAddScript}),e[13]=i,e[14]=t.onAddScript,e[15]=c):c=e[15];let d;e[16]!==l||e[17]!==h||e[18]!==c?(d=n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:[l,h,c]}),e[16]=l,e[17]=h,e[18]=c,e[19]=d):d=e[19];let u;e[20]!==t.onRestart||e[21]!==t.onResume||e[22]!==t.onRetry||e[23]!==t.onRunActiveScript||e[24]!==t.onStart||e[25]!==t.onStop||e[26]!==t.onStopActiveScript||e[27]!==t.scriptIsKilling||e[28]!==t.scriptIsRunning||e[29]!==t.showScriptControls||e[30]!==t.status?(u=t.showScriptControls?n.jsx(Ug,{isRunning:t.scriptIsRunning,isKilling:t.scriptIsKilling,onRun:t.onRunActiveScript,onStop:t.onStopActiveScript}):n.jsx(Fg,{status:t.status,onStart:t.onStart,onStop:t.onStop,onRestart:t.onRestart,onResume:t.onResume,onRetry:t.onRetry}),e[20]=t.onRestart,e[21]=t.onResume,e[22]=t.onRetry,e[23]=t.onRunActiveScript,e[24]=t.onStart,e[25]=t.onStop,e[26]=t.onStopActiveScript,e[27]=t.scriptIsKilling,e[28]=t.scriptIsRunning,e[29]=t.showScriptControls,e[30]=t.status,e[31]=u):u=e[31];let f;return e[32]!==d||e[33]!==u?(f=n.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 border-t border-b border-border bg-muted/60 px-3",children:[d,u]}),e[32]=d,e[33]=u,e[34]=f):f=e[34],f}function zg(t){const e=z.c(8),{active:s,open:i,onClick:r}=t,o=s&&i,a=s&&i,l=s?"border-border bg-background font-medium text-foreground shadow-sm":"border-transparent text-muted-foreground hover:bg-background/50 hover:text-foreground";let h;e[0]!==l?(h=te("flex h-7 items-center gap-1.5 rounded-md border px-2.5 text-xs",l),e[0]=l,e[1]=h):h=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(va,{className:"size-3.5"}),e[2]=c):c=e[2];let d;return e[3]!==r||e[4]!==o||e[5]!==a||e[6]!==h?(d=n.jsxs("button",{type:"button","aria-pressed":o,"aria-expanded":a,onClick:r,className:h,children:[c,"sandbox"]}),e[3]=r,e[4]=o,e[5]=a,e[6]=h,e[7]=d):d=e[7],d}function Fg(t){const e=z.c(24),{status:s,onStart:i,onStop:r,onRestart:o,onResume:a,onRetry:l}=t;if(s==="idle"&&i){let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Qt,{className:"size-3.5"}),e[0]=h):h=e[0];let c;return e[1]!==i?(c=n.jsxs(se,{variant:"outline",size:"sm",onClick:i,children:[h," Start"]}),e[1]=i,e[2]=c):c=e[2],c}if(s==="suspended"&&a){let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Qt,{className:"size-3.5"}),e[3]=h):h=e[3];let c;return e[4]!==a?(c=n.jsxs(se,{variant:"outline",size:"sm",onClick:a,children:[h," Resume"]}),e[4]=a,e[5]=c):c=e[5],c}if(s==="errored"&&l){let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(zs,{className:"size-3.5"}),e[6]=h):h=e[6];let c;return e[7]!==l?(c=n.jsxs(se,{variant:"outline",size:"sm",onClick:l,children:[h," Retry"]}),e[7]=l,e[8]=c):c=e[8],c}if(s==="starting"||s==="running"){const h=s==="running"&&!!o,c=h?"rounded-r-none border-r-0":void 0;let d;e[9]!==c?(d=te(c),e[9]=c,e[10]=d):d=e[10];let u;e[11]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(xa,{className:"size-3.5"}),e[11]=u):u=e[11];let f;e[12]!==r||e[13]!==d?(f=n.jsx(xe,{asChild:!0,children:n.jsxs(se,{variant:"outline",size:"sm",onClick:r,className:d,children:[u," Stop"]})}),e[12]=r,e[13]=d,e[14]=f):f=e[14];let m;e[15]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(be,{children:"Stop sandbox"}),e[15]=m):m=e[15];let _;e[16]!==f?(_=n.jsxs(Se,{children:[f,m]}),e[16]=f,e[17]=_):_=e[17];let p;e[18]!==o||e[19]!==h?(p=h&&n.jsxs(Ys,{children:[n.jsx(Xs,{asChild:!0,children:n.jsx(se,{variant:"outline",size:"sm",className:"rounded-l-none px-1",children:n.jsx(vs,{className:"size-3"})})}),n.jsx(Js,{align:"end",children:n.jsxs(Dt,{onClick:o,children:[n.jsx(zs,{className:"size-3.5"})," Restart"]})})]}),e[18]=o,e[19]=h,e[20]=p):p=e[20];let g;return e[21]!==_||e[22]!==p?(g=n.jsxs("div",{className:"flex items-center",children:[_,p]}),e[21]=_,e[22]=p,e[23]=g):g=e[23],g}return null}function Hg(t){const e=z.c(16),{active:s,onClick:i,onClose:r,children:o}=t,a=s?"border-border bg-background shadow-sm":"border-transparent hover:bg-background/50";let l;e[0]!==a?(l=te("flex h-7 items-center rounded-md border text-xs",a),e[0]=a,e[1]=l):l=e[1];const h=r?"pl-2.5 pr-1":"px-2.5",c=s?"font-medium text-foreground":"text-muted-foreground hover:text-foreground";let d;e[2]!==h||e[3]!==c?(d=te("flex h-full items-center",h,c),e[2]=h,e[3]=c,e[4]=d):d=e[4];let u;e[5]!==o||e[6]!==i||e[7]!==d?(u=n.jsx("button",{type:"button",onClick:i,className:d,children:o}),e[5]=o,e[6]=i,e[7]=d,e[8]=u):u=e[8];let f;e[9]!==o||e[10]!==r?(f=r&&n.jsx("button",{type:"button","aria-label":`Close ${o}`,onClick:r,className:"pr-1.5 text-muted-foreground hover:text-foreground",children:n.jsx(Qh,{className:"size-3"})}),e[9]=o,e[10]=r,e[11]=f):f=e[11];let m;return e[12]!==l||e[13]!==u||e[14]!==f?(m=n.jsxs("div",{className:l,children:[u,f]}),e[12]=l,e[13]=u,e[14]=f,e[15]=m):m=e[15],m}function Wg(t){const e=z.c(10),{scripts:s,onRun:i}=t,[r,o]=A.useState(!1);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsxs(Se,{children:[n.jsx(xe,{asChild:!0,children:n.jsx(Wt,{asChild:!0,children:n.jsx(se,{variant:"ghost",size:"sm","aria-label":"Run script",children:n.jsx(es,{className:"size-3.5"})})})}),n.jsx(be,{children:"Run script"})]}),e[0]=a):a=e[0];let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wide text-muted-foreground",children:"run a script"}),e[1]=l):l=e[1];let h;e[2]!==i||e[3]!==s?(h=s.length===0?n.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:"No scripts found"}):s.map(u=>n.jsxs("button",{type:"button",onClick:()=>{o(!1),i(u)},className:"w-full rounded-md px-2 py-1.5 text-left text-xs hover:bg-accent",children:["▸ ",u]},u)),e[2]=i,e[3]=s,e[4]=h):h=e[4];let c;e[5]!==h?(c=n.jsxs(Ut,{align:"start",className:"p-1 w-56",children:[l,h]}),e[5]=h,e[6]=c):c=e[6];let d;return e[7]!==r||e[8]!==c?(d=n.jsxs(Vt,{open:r,onOpenChange:o,children:[a,c]}),e[7]=r,e[8]=c,e[9]=d):d=e[9],d}function Ug(t){const e=z.c(13),{isRunning:s,isKilling:i,onRun:r,onStop:o}=t;if(i){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsxs(se,{variant:"outline",size:"sm",disabled:!0,children:[n.jsx(Ae,{className:"size-3.5 animate-spin"})," Stopping…"]}),e[0]=d):d=e[0],d}if(!s){let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Qt,{className:"size-3.5"}),e[1]=d):d=e[1];let u;e[2]!==r?(u=n.jsx(xe,{asChild:!0,children:n.jsxs(se,{variant:"outline",size:"sm",onClick:r,children:[d," Run"]})}),e[2]=r,e[3]=u):u=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(be,{children:"Start process"}),e[4]=f):f=e[4];let m;return e[5]!==u?(m=n.jsxs(Se,{children:[u,f]}),e[5]=u,e[6]=m):m=e[6],m}let a;e[7]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(xa,{className:"size-3.5"}),e[7]=a):a=e[7];let l;e[8]!==o?(l=n.jsx(xe,{asChild:!0,children:n.jsxs(se,{variant:"outline",size:"sm",onClick:o,children:[a," Stop"]})}),e[8]=o,e[9]=l):l=e[9];let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(be,{children:"Stop process"}),e[10]=h):h=e[10];let c;return e[11]!==l?(c=n.jsxs(Se,{children:[l,h]}),e[11]=l,e[12]=c):c=e[12],c}const Vg=["dev","start"];function Kg(t){const e=xs(),[s,i]=A.useState(Jt),[r,o]=A.useState([]),[a,l]=A.useState(new Set),h=A.useRef(!1);if(!h.current&&e.scripts.length>0){const S=Vg.find(w=>e.scripts.includes(w));S&&(h.current=!0,o(w=>w.includes(S)?w:[...w,S]),i(S))}if(a.size>0){let S=!1;const w=new Set(a);for(const k of a)e.activeProcesses.includes(k)||(w.delete(k),S=!0);S&&l(w)}const c=()=>t.onOpenChange(!t.open),d=S=>{i(S),t.open||t.onOpenChange(!0)},u=S=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(`/api/${encodeURIComponent(t.orgSlug)}/vm/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/exec/${encodeURIComponent(S)}`,{method:"POST"}),f=S=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(`/api/${encodeURIComponent(t.orgSlug)}/vm/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/exec/${encodeURIComponent(S)}/kill`,{method:"POST"}),m=async S=>{o(w=>w.includes(S)?w:[...w,S]),i(S),t.onOpenChange(!0);try{const w=await u(S);if(w===null)return;if(!w.ok)throw new Error(`Exec failed: ${w.statusText}`)}catch{he.error("Failed to run "+S)}},_=async S=>{await f(S),o(w=>w.filter(k=>k!==S)),s===S&&i(Jt)},p=async()=>{const S=e.activeProcesses.includes(s);try{const w=await u(s);if(w===null)return;if(!w.ok)throw new Error(`Exec failed: ${w.statusText}`)}catch{he.error((S?"Failed to restart ":"Failed to run ")+s)}},g=async()=>{if(!a.has(s)){l(S=>new Set(S).add(s));try{const S=await f(s);if(S===null){l(w=>{const k=new Set(w);return k.delete(s),k});return}if(!S.ok)throw new Error(`Kill failed: ${S.statusText}`)}catch{l(S=>{const w=new Set(S);return w.delete(s),w}),he.error("Failed to stop "+s)}}},v=s!==Jt&&r.includes(s),x=v&&e.activeProcesses.includes(s),b=v&&a.has(s);return n.jsxs("div",{className:"flex shrink-0 flex-col",style:{height:t.open?"50%":"auto"},children:[n.jsx($g,{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:m,onCloseScript:_,showScriptControls:v,scriptIsRunning:x,scriptIsKilling:b,onRunActiveScript:p,onStopActiveScript:g}),t.open&&n.jsx("div",{className:"flex-1 overflow-hidden",children:n.jsx(qg,{vmId:t.vmId,active:s,hasData:e.hasData(s),onRunActive:p})})]})}function qg(t){const e=z.c(10),{vmId:s,active:i,hasData:r,onRunActive:o}=t;if(!s)return null;if(i===Jt||r){let d;return e[0]!==i?(d=n.jsx(Yl,{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(Qt,{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 Xl=t=>`preview-drawer:${t}`;function Gg(t){try{const e=localStorage.getItem(Xl(t));return e?!!JSON.parse(e).open:!1}catch{return!1}}function Yg(t,e){try{localStorage.setItem(Xl(t),JSON.stringify({open:e}))}catch{}}const Xg=A.lazy(()=>ln(()=>import("./sections-editor-Cf97i73N.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])).then(t=>({default:t.SectionsEditor}))),Jg=A.lazy(()=>ln(()=>import("./file-explorer-ENlS4PGn.js"),__vite__mapDeps([124,1,2,125,8,21,10,11,12,13,14,3,15,16,17,18,19,20,7,9,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,4,5,6,65,66,53,67,68,56,52,69,70,71,49,72,73,74])).then(t=>({default:t.FileExplorer}))),Zg=500;function Qg(t,e){return t.kind==="errored"?"errored":t.kind==="suspended"?"suspended":t.kind==="starting-now"||e?"starting":t.kind==="iframe"||t.kind==="no-html"||t.kind==="crashed"?"running":"idle"}const ev=[{value:"preview",icon:n.jsx(ga,{size:14}),tooltip:"Interactive"},{value:"visual",icon:n.jsx(Sa,{size:14}),tooltip:"Visual Editor"},{value:"code",icon:n.jsx(th,{size:14}),tooltip:"Code Editor"}];function tv(){const t=Ql(),{data:e}=Li.useSession(),{taskId:s,currentBranch:i,setCurrentTaskBranch:r}=Ht(),[o,a]=A.useState("preview"),[l,h]=A.useState(null),c=A.useRef(null),[d,u]=A.useState(!1),f=A.useRef(null),[m,_]=A.useState(!1),[p,g]=A.useState(""),v=A.useRef(null),[x,b]=A.useState("/"),S=e?.user?.id,w=t?.entity?.metadata,k=S&&i?w?.vmMap?.[S]?.[i]:void 0,C=k?.previewUrl??null,E=t?.entity?.id??null,{org:T}=me(),B=E&&i?{orgSlug:T.slug,virtualMcpId:E,branch:i}:null,{data:I}=$f(B),R=I?Hf(I).sort((Y,ue)=>Y.name.localeCompare(ue.name)):[],y=xs();im(()=>{const Y=c.current;Y&&(Y.src=Y.src)});const D=y.lifecycle.phase,N=A.useRef({url:"",value:!1});C&&N.current.url!==C&&(N.current={url:C,value:!1}),y.lifecycle.phase==="running"&&(N.current.value=y.lifecycle.htmlSupport);const j=N.current.value,M=D==="running"?"online":D==="crashed"?"offline":"booting",P=y.suspended,F=y.status.state==="paused",W=Ue({connectionId:Ft,orgId:t?.entity?.organization_id??"",orgSlug:T.slug}),O=qa(W),$=O.error?.message??null,H=Ud(E??void 0,i??void 0),V=A.useRef(null),re=A.useRef(null),X=y.phase,J=nm({claimPhase:X,lifecycle:y.lifecycle}),Z=!!E&&!!i&&vi.isStopped(E,i),L=rm({previewUrl:C,status:M,htmlSupport:j,suspended:P,appPaused:F,vmStartPending:H,lastStartError:$,claimPhase:X,notFound:y.notFound,userStopped:Z}),K=Y=>{if(!E)return;const ue={virtualMcpId:E};i&&(ue.branch=i),O.mutate(ue,{onSuccess:Ye=>{Ye?.branch&&!i&&r(Ye.branch)},onError:Ye=>{console.error(`[preview] ${Y} VM_START failed`,Ye)}})},Q=A.useRef(K);Q.current=K,s&&k&&V.current!==s&&(V.current=s);const G=!!s&&!!E&&!!S&&!!i&&!k&&!$&&!Z&&!O.isPending&&V.current!==s;A.useEffect(()=>{!G||!s||(V.current=s,Q.current("auto-start"))},[G,s,Z]);const ee=y.notFound?k?.vmId??null:null;A.useEffect(()=>{!ee||!E||$||O.isPending||re.current!==ee&&(i&&vi.isStopped(E,i)||(re.current=ee,Q.current("self-heal")))},[ee,E,$,O.isPending,i]);const oe=()=>{V.current=null,re.current=null,O.reset(),Q.current("auto-start")},_e=_s(),ge=E??"__no-vmcp__",[we,je]=A.useState(null),De=A.useRef(null);De.current!==ge&&(De.current=ge,je(Gg(ge)));const ne=L.kind==="never-started"?!1:we??!1,le=Y=>{je(Y),Yg(ge,Y)},Ee=()=>le(!0),$e=async()=>{if(!E)return;const Y=i;if(Y){vi.mark(E,Y);try{await W.callTool({name:"VM_DELETE",arguments:{virtualMcpId:E,branch:Y}})}catch{}oa(_e)}},os=async()=>{await $e(),Q.current("auto-start")};A.useEffect(()=>{if(!C)return;let Y;try{Y=new URL(C,window.location.href).origin}catch{return}const ue=Ye=>{if(Ye.origin!==Y||Ye.data?.type!=="visual-editor::element-clicked")return;const pt=Wf.safeParse(Ye.data.payload);pt.success&&h(pt.data)};return window.addEventListener("message",ue),()=>window.removeEventListener("message",ue)},[C]),A.useEffect(()=>{if(!m)return;const Y=ue=>{v.current?.contains(ue.target)||(_(!1),g(""))};return document.addEventListener("pointerdown",Y),()=>document.removeEventListener("pointerdown",Y)},[m]),A.useEffect(()=>{if(!d)return;const Y=Ye=>{const pt=Ye.target;pt&&pt!==c.current&&(f.current=pt)},ue=()=>{requestAnimationFrame(()=>{const Ye=document.activeElement;(Ye===document.body||Ye===c.current)&&f.current&&f.current.focus()})};return document.addEventListener("focusin",Y),document.addEventListener("blur",ue,!0),()=>{document.removeEventListener("focusin",Y),document.removeEventListener("blur",ue,!0)}},[d]);const ri=()=>{const Y=c.current?.contentWindow;Y&&Y.postMessage({type:"visual-editor::activate",script:Uf},"*")},ni=()=>{const Y=c.current?.contentWindow;Y&&Y.postMessage({type:"visual-editor::deactivate"},"*")},ec=Y=>{a(Y),h(null),Y==="visual"?ri():ni()},tc=()=>{if(!c.current)return;const Y=c.current;Y.src=Y.src},sc=()=>{if(!c.current||!C)return;const Y=C.includes("?")?"&":"?";c.current.src=`${C}${Y}_r=${Date.now()}`},ic=()=>{const Y=c.current?.contentWindow?.location?.href??C;Y&&navigator.clipboard.writeText(Y)},rc=(()=>{if(!C)return"No server running";try{const Y=new URL(C),ue=x==="/"?"":x;return`${Y.host}${ue}`}catch{return C}})();return n.jsxs("div",{className:"flex flex-col w-full h-full",children:[L.kind==="iframe"&&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.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[j&&n.jsx(Zh,{value:o,onValueChange:ec,options:ev,size:"sm",className:"shrink-0 bg-foreground/4.5"}),R.length>0&&n.jsxs(Se,{children:[n.jsx(xe,{asChild:!0,children:n.jsx(se,{variant:d?"secondary":"ghost",size:"icon",onClick:()=>u(Y=>!Y),children:n.jsx(eh,{size:14})})}),n.jsx(be,{side:"bottom",children:"Sections Editor"})]})]}),n.jsxs("div",{className:te("flex min-w-0 flex-1 items-center gap-0.5",o==="code"&&"hidden"),children:[n.jsxs(Se,{children:[n.jsx(xe,{asChild:!0,children:n.jsx(se,{variant:"ghost",size:"icon",onClick:()=>c.current?.contentWindow?.history.back(),children:n.jsx(Ua,{size:14})})}),n.jsx(be,{side:"bottom",children:"Back"})]}),n.jsxs(Se,{children:[n.jsx(xe,{asChild:!0,children:n.jsx(se,{variant:"ghost",size:"icon",onClick:()=>c.current?.contentWindow?.history.forward(),children:n.jsx(Ic,{size:14})})}),n.jsx(be,{side:"bottom",children:"Forward"})]}),n.jsxs(Se,{children:[n.jsx(xe,{asChild:!0,children:n.jsx(se,{variant:"ghost",size:"icon",onClick:tc,children:n.jsx(zs,{size:14})})}),n.jsx(be,{side:"bottom",children:"Refresh"})]}),n.jsxs("div",{ref:v,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:()=>_(Y=>!Y),children:[n.jsx("span",{className:"min-w-0 flex-1 truncate text-left text-[12px] text-foreground/88",children:rc}),R.length>0&&n.jsx(vs,{size:12,className:te("shrink-0 text-muted-foreground transition-transform",m&&"rotate-180")})]}),m&&R.length>0&&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.jsx("div",{className:"px-2 pt-2 pb-1",children:n.jsx("input",{type:"text",value:p,onChange:Y=>g(Y.target.value),placeholder:"Search pages...",className:"w-full rounded-md border border-input bg-transparent px-2.5 py-1.5 text-xs outline-none placeholder:text-muted-foreground focus:ring-1 focus:ring-ring",autoFocus:!0})}),n.jsx(kn,{className:"max-h-[60vh]",children:n.jsxs("div",{className:"p-1.5",children:[R.filter(Y=>{if(!p)return!0;const ue=p.toLowerCase();return Y.name.toLowerCase().includes(ue)||Y.path.toLowerCase().includes(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",onClick:()=>{_(!1),g(""),b(Y.path);const ue=c.current;ue&&C&&(ue.src=new URL(Y.path,C).href)},children:[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)),p&&R.every(Y=>{const ue=p.toLowerCase();return!Y.name.toLowerCase().includes(ue)&&!Y.path.toLowerCase().includes(ue)})&&n.jsxs("div",{className:"px-3 py-4 text-center text-xs text-muted-foreground",children:['No pages match "',p,'"']})]})})]})]})]}),n.jsxs("div",{className:te("flex shrink-0 items-center gap-0.5",o==="code"&&"hidden"),children:[n.jsxs(Se,{children:[n.jsx(xe,{asChild:!0,children:n.jsx(se,{variant:"ghost",size:"icon",onClick:()=>{let Y=L.previewUrl;if(Y&&x&&x!=="/")try{const ue=new URL(Y);ue.pathname=x,Y=ue.href}catch{}window.open(Y,"_blank","noopener")},children:n.jsx(gs,{size:14})})}),n.jsx(be,{side:"bottom",children:"Open in new tab"})]}),n.jsxs(Ys,{children:[n.jsx(Xs,{asChild:!0,children:n.jsx(se,{variant:"ghost",size:"icon",children:n.jsx(ba,{size:14})})}),n.jsxs(Js,{align:"end",children:[n.jsx(Dt,{onClick:sc,children:"Hard Reload"}),n.jsx(Dt,{onClick:ic,children:"Copy Current URL"})]})]})]})]}),n.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[d&&C&&i&&E&&n.jsx("div",{className:"w-96 shrink-0 border-r overflow-hidden",children:n.jsx(A.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(Ae,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(Xg,{orgSlug:T.slug,virtualMcpId:E,branch:i,currentPath:x,onSaved:()=>{setTimeout(()=>{const Y=c.current;if(!Y)return;const ue=document.activeElement,Ye=Y.tabIndex;Y.tabIndex=-1,Y.style.pointerEvents="none",Y.blur();try{Y.contentWindow?.location.reload()}catch{Y.src=Y.src}const pt=()=>{Y.tabIndex=Ye,Y.style.pointerEvents="",ue?.focus(),Y.removeEventListener("load",pt)};Y.addEventListener("load",pt),setTimeout(pt,3e3)},Zg)}})})}),n.jsxs("div",{className:"flex-1 relative overflow-hidden",children:[L.kind==="never-started"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(Ts,{kind:"never-started",onStart:()=>{le(!1),K("auto-start")}})}),L.kind==="starting-now"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(Ts,{kind:"starting-now",progress:J,claimPhase:X})}),L.kind==="errored"&&n.jsx("div",{className:"absolute inset-0 z-40",children:n.jsx(Ts,{kind:"errored",progress:J,logSource:"setup",errorLine:L.error.split(`
|
|
185
|
-
`)[0]??"Failed to start",onRetry:oe,drawerOpen:ne})}),L.kind==="suspended"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(Ts,{kind:"suspended",onResume:oe})}),L.kind==="crashed"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(Ts,{kind:"crashed",onOpenTerminal:Ee})}),L.kind==="no-html"&&n.jsxs("div",{className:"absolute inset-0 z-30 flex flex-col items-center justify-center gap-4 bg-background",children:[n.jsx(Kn,{size:48,className:"text-muted-foreground/40"}),n.jsx("h3",{className:"text-lg font-medium",children:"No web page at this URL"}),n.jsx("p",{className:"text-sm text-muted-foreground text-center max-w-sm",children:"The server is running, but doesn't serve a web page at /. This preview only renders web pages."}),n.jsxs(se,{onClick:Ee,children:[n.jsx(Kn,{size:14}),"View Logs"]})]}),o==="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(Sa,{size:12}),"Click any element to ask the AI"]}),o==="visual"&&l&&n.jsx(qf,{element:l,onDismiss:()=>h(null)}),o==="code"&&L.kind==="iframe"&&E&&i&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(A.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(Ae,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(Jg,{orgSlug:T.slug,virtualMcpId:E,branch:i})})}),L.kind==="iframe"&&n.jsx("iframe",{ref:c,src:L.previewUrl,className:te("w-full h-full border-0",o==="code"&&"invisible"),title:"Dev Server Preview",tabIndex:d?-1:void 0,onLoad:()=>{ve("vm_preview_loaded",{view_mode:o,vm_id:k?.vmId??null});try{const Y=c.current?.contentWindow?.location?.pathname;Y&&b(Y)}catch{}o==="visual"&&ri()}},L.previewUrl)]})]}),n.jsx(Kg,{vmId:k?.vmId??null,orgSlug:T.slug,virtualMcpId:E,branch:i,status:Qg(L,H),scripts:y.scripts,open:ne,onOpenChange:le,onStart:()=>K("auto-start"),onStop:$e,onRestart:os,onResume:oe,onRetry:oe},k?.vmId??"no-vm")]})}function sv(t){const e=z.c(2),{virtualMcpId:s}=t,i=Pt(s);if(!(i?Zt(i):null)){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(hn,{size:24,className:"text-muted-foreground/60"}),n.jsx("div",{children:"No repository connected."}),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(tv,{}),e[1]=o):o=e[1],o}function iv({inputSchema:t,value:e,onChange:s}){const i=t?.properties,r=t?.required??[],o=!!i&&Object.keys(i).length>0;if(!t||!o&&Object.keys(t).length===0)return n.jsx("div",{className:"text-sm text-muted-foreground italic",children:"No arguments defined in schema."});if(!o)return n.jsx(av,{value:e,onChange:s});const a=(l,h)=>{if(h===void 0){const{[l]:c,...d}=e;s(d);return}s({...e,[l]:h})};return n.jsxs("div",{className:"space-y-4",children:[r.length>0&&n.jsxs("div",{className:"text-xs text-muted-foreground",children:[n.jsx("span",{className:"text-red-500",children:"*"})," Required"]}),Object.entries(i).map(([l,h])=>{const c=r.includes(l),d=Array.isArray(h.type)?h.type[0]:h.type;return n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("label",{htmlFor:`tool-param-${l}`,className:"text-sm font-medium leading-none flex items-center gap-1.5",children:[l,c&&n.jsx("span",{className:"text-red-500 text-xs",children:"*"})]}),d&&n.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:d})]}),h.description&&n.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:h.description}),n.jsx(rv,{id:`tool-param-${l}`,propKey:l,prop:h,type:d,value:e[l],onChange:u=>a(l,u)})]},l)})]})}function rv(t){const e=z.c(52),{id:s,propKey:i,prop:r,type:o,value:a,onChange:l}=t;if(r.enum&&r.enum.length>0){let f;e[0]!==r.enum?(f=new Map(r.enum.map(ov)),e[0]=r.enum,e[1]=f):f=e[1];const m=f,_=a!==void 0?String(a):"";let p;e[2]!==m||e[3]!==l?(p=k=>l(m.get(k)??k),e[2]=m,e[3]=l,e[4]=p):p=e[4];const g=`Select ${i}…`;let v;e[5]!==g?(v=n.jsx(mt,{placeholder:g}),e[5]=g,e[6]=v):v=e[6];let x;e[7]!==s||e[8]!==v?(x=n.jsx(ft,{id:s,children:v}),e[7]=s,e[8]=v,e[9]=x):x=e[9];let b;e[10]!==r.enum?(b=r.enum.map(nv),e[10]=r.enum,e[11]=b):b=e[11];let S;e[12]!==b?(S=n.jsx(_t,{children:b}),e[12]=b,e[13]=S):S=e[13];let w;return e[14]!==_||e[15]!==p||e[16]!==x||e[17]!==S?(w=n.jsxs(ut,{value:_,onValueChange:p,children:[x,S]}),e[14]=_,e[15]=p,e[16]=x,e[17]=S,e[18]=w):w=e[18],w}if(o==="boolean"){const f=a===void 0?"":String(a);let m;e[19]!==l?(m=x=>l(x==="true"),e[19]=l,e[20]=m):m=e[20];let _;e[21]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx(mt,{placeholder:"Select true or false…"}),e[21]=_):_=e[21];let p;e[22]!==s?(p=n.jsx(ft,{id:s,children:_}),e[22]=s,e[23]=p):p=e[23];let g;e[24]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsxs(_t,{children:[n.jsx(Ge,{value:"true",children:"true"}),n.jsx(Ge,{value:"false",children:"false"})]}),e[24]=g):g=e[24];let v;return e[25]!==f||e[26]!==m||e[27]!==p?(v=n.jsxs(ut,{value:f,onValueChange:m,children:[p,g]}),e[25]=f,e[26]=m,e[27]=p,e[28]=v):v=e[28],v}if(o==="number"||o==="integer"){const f=a===void 0?"":a;let m;e[29]!==l?(m=g=>{const v=g.currentTarget.value;if(v==="")return l(void 0);const x=Number(v);l(Number.isFinite(x)?x:v)},e[29]=l,e[30]=m):m=e[30];const _=`Enter ${i}…`;let p;return e[31]!==s||e[32]!==f||e[33]!==m||e[34]!==_?(p=n.jsx(nt,{id:s,type:"number",value:f,onChange:m,placeholder:_}),e[31]=s,e[32]=f,e[33]=m,e[34]=_,e[35]=p):p=e[35],p}if(o==="object"||o==="array"){let f;e[36]!==a?(f=typeof a=="string"?a:a===void 0?"":JSON.stringify(a,null,2),e[36]=a,e[37]=f):f=e[37];const m=f;let _;e[38]!==l?(_=v=>{const x=v.currentTarget.value;if(x.trim()==="")return l(void 0);try{l(JSON.parse(x))}catch{l(x)}},e[38]=l,e[39]=_):_=e[39];const p=`Enter ${i} as JSON…`;let g;return e[40]!==s||e[41]!==_||e[42]!==p||e[43]!==m?(g=n.jsx(Fs,{id:s,className:"font-mono text-xs",value:m,rows:4,spellCheck:!1,onChange:_,placeholder:p}),e[40]=s,e[41]=_,e[42]=p,e[43]=m,e[44]=g):g=e[44],g}const h=a===void 0?"":a;let c;e[45]!==l?(c=f=>{const m=f.currentTarget.value;l(m===""?void 0:m)},e[45]=l,e[46]=c):c=e[46];const d=`Enter ${i}…`;let u;return e[47]!==s||e[48]!==h||e[49]!==c||e[50]!==d?(u=n.jsx(nt,{id:s,value:h,onChange:c,placeholder:d}),e[47]=s,e[48]=h,e[49]=c,e[50]=d,e[51]=u):u=e[51],u}function nv(t){const e=String(t);return n.jsx(Ge,{value:e,children:e},e)}function ov(t){return[String(t),t]}function av({value:t,onChange:e}){const[s,i]=A.useState(()=>Object.keys(t).length===0?"{}":JSON.stringify(t,null,2));return n.jsxs("div",{className:"space-y-2",children:[n.jsx("label",{htmlFor:"tool-raw-json",className:"text-sm font-medium leading-none",children:"Raw JSON Input"}),n.jsx(Fs,{id:"tool-raw-json",className:"font-mono text-xs min-h-[120px]",value:s,spellCheck:!1,onChange:r=>{const o=r.currentTarget.value;i(o);const a=o.trim();if(a===""){e({});return}try{const l=JSON.parse(a);l&&typeof l=="object"&&!Array.isArray(l)&&e(l)}catch{}},placeholder:'e.g. { "foo": "bar" }'})]})}function lv(t){const e=z.c(22),{value:s,onChange:i}=t,r=qs();let o,a;e[0]!==r||e[1]!==s.connectionId?(a=r.filter(cv),o=a.find(p=>p.id===s.connectionId)??null,e[0]=r,e[1]=s.connectionId,e[2]=o,e[3]=a):(o=e[2],a=e[3]);const l=o;let h;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Je,{children:"Connection"}),e[4]=h):h=e[4];let c;e[5]!==i||e[6]!==s?(c=p=>{p.id!==s.connectionId&&i({...s,connectionId:p.id,toolName:"",input:{}})},e[5]=i,e[6]=s,e[7]=c):c=e[7];let d;e[8]!==l||e[9]!==c||e[10]!==a?(d=n.jsxs("div",{className:"flex flex-col gap-1.5",children:[h,n.jsx(hv,{connections:a,selected:l,onSelect:c})]}),e[8]=l,e[9]=c,e[10]=a,e[11]=d):d=e[11];let u;e[12]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(Je,{children:"Tool"}),e[12]=u):u=e[12];let f,m;e[13]!==i||e[14]!==l||e[15]!==s?(f=n.jsxs("div",{className:"flex flex-col gap-1.5",children:[u,l?n.jsx(dv,{connection:l,selectedToolName:s.toolName,onSelect:p=>{p.name!==s.toolName&&i({...s,toolName:p.name,input:{}})}}):n.jsxs(se,{variant:"outline",size:"sm",disabled:!0,className:"h-9 justify-start gap-2 px-3 text-sm font-normal text-muted-foreground",children:[n.jsx(un,{className:"size-4"}),"Pick a connection first"]})]}),m=l&&s.toolName?n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsx(Je,{children:"Input"}),n.jsx("div",{className:"rounded-md border border-border p-3",children:n.jsx(uv,{connection:l,toolName:s.toolName,input:s.input,onChange:p=>i({...s,input:p})},`${l.id}:${s.toolName}`)})]}):null,e[13]=i,e[14]=l,e[15]=s,e[16]=f,e[17]=m):(f=e[16],m=e[17]);let _;return e[18]!==d||e[19]!==f||e[20]!==m?(_=n.jsxs("div",{className:"flex flex-col gap-4",children:[d,f,m]}),e[18]=d,e[19]=f,e[20]=m,e[21]=_):_=e[21],_}function cv(t){return t.id!==Ft}function hv(t){const e=z.c(20),{connections:s,selected:i,onSelect:r}=t,[o,a]=A.useState(!1);let l;e[0]!==i?(l=n.jsx("span",{className:"flex min-w-0 items-center gap-2",children:i?n.jsxs(n.Fragment,{children:[n.jsx(Ct,{icon:i.icon,name:i.title,size:"2xs"}),n.jsx("span",{className:"truncate",children:i.title})]}):n.jsx("span",{className:"text-muted-foreground",children:"Pick a connection"})}),e[0]=i,e[1]=l):l=e[1];let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(vs,{className:"size-4 shrink-0 opacity-50"}),e[2]=h):h=e[2];let c;e[3]!==l?(c=n.jsx(Wt,{asChild:!0,children:n.jsxs(se,{variant:"outline",size:"sm",className:"h-9 justify-between gap-2 px-3 text-sm font-normal",children:[l,h]})}),e[3]=l,e[4]=c):c=e[4];let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(mn,{placeholder:"Search connections…"}),e[5]=d):d=e[5];let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(_n,{children:"No connections found."}),e[6]=u):u=e[6];let f;if(e[7]!==s||e[8]!==r||e[9]!==i?.id){let p;e[11]!==r||e[12]!==i?.id?(p=g=>n.jsxs(Ei,{value:`${g.title} ${g.description??""} ${g.id}`,onSelect:()=>{r(g),a(!1)},className:"flex items-start gap-2.5",children:[n.jsx(Ct,{icon:g.icon,name:g.title,size:"xs"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("div",{className:"text-sm truncate",children:g.title}),g.description&&n.jsx("div",{className:"text-xs text-muted-foreground line-clamp-2",children:g.description})]}),n.jsx(ps,{className:te("size-4 shrink-0 mt-0.5",i?.id===g.id?"opacity-100":"opacity-0")})]},g.id),e[11]=r,e[12]=i?.id,e[13]=p):p=e[13],f=s.map(p),e[7]=s,e[8]=r,e[9]=i?.id,e[10]=f}else f=e[10];let m;e[14]!==f?(m=n.jsx(Ut,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:n.jsxs(gn,{children:[d,n.jsxs(pn,{children:[u,n.jsx(ji,{children:f})]})]})}),e[14]=f,e[15]=m):m=e[15];let _;return e[16]!==o||e[17]!==c||e[18]!==m?(_=n.jsxs(Vt,{open:o,onOpenChange:a,children:[c,m]}),e[16]=o,e[17]=c,e[18]=m,e[19]=_):_=e[19],_}function dv(t){const e=z.c(41),{connection:s,selectedToolName:i,onSelect:r}=t,{org:o}=me();let a;e[0]!==s.id||e[1]!==o.id||e[2]!==o.slug?(a={connectionId:s.id,orgId:o.id,orgSlug:o.slug},e[0]=s.id,e[1]=o.id,e[2]=o.slug,e[3]=a):a=e[3];const l=Ue(a);let h;e[4]!==l?(h={client:l},e[4]=l,e[5]=h):h=e[5];const{data:c,isLoading:d,error:u}=Ha(h);let f;e[6]!==c?.tools?(f=c?.tools??[],e[6]=c?.tools,e[7]=f):f=e[7];const m=f;let _;e[8]!==i||e[9]!==m?(_=m.find(M=>M.name===i)??null,e[8]=i,e[9]=m,e[10]=_):_=e[10];const p=_,[g,v]=A.useState(!1);let x;e:{if(p){x=p.name;break e}if(u){x=`Failed to load tools: ${u.message}`;break e}if(d){x="Loading tools…";break e}if(m.length===0){x="No tools available";break e}x="Pick a tool"}const b=x,S=d||!!u||m.length===0;let w;e[11]!==s.icon||e[12]!==s.title?(w=n.jsx(Ct,{icon:s.icon,name:s.title,size:"2xs"}),e[11]=s.icon,e[12]=s.title,e[13]=w):w=e[13];const k=!p&&"text-muted-foreground font-sans";let C;e[14]!==k?(C=te("truncate font-mono text-xs",k),e[14]=k,e[15]=C):C=e[15];let E;e[16]!==C||e[17]!==b?(E=n.jsx("span",{className:C,children:b}),e[16]=C,e[17]=b,e[18]=E):E=e[18];let T;e[19]!==w||e[20]!==E?(T=n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[w,E]}),e[19]=w,e[20]=E,e[21]=T):T=e[21];let B;e[22]===Symbol.for("react.memo_cache_sentinel")?(B=n.jsx(vs,{className:"size-4 shrink-0 opacity-50"}),e[22]=B):B=e[22];let I;e[23]!==S||e[24]!==T?(I=n.jsx(Wt,{asChild:!0,children:n.jsxs(se,{variant:"outline",size:"sm",disabled:S,className:"h-9 justify-between gap-2 px-3 text-sm font-normal",children:[T,B]})}),e[23]=S,e[24]=T,e[25]=I):I=e[25];let R;e[26]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx(mn,{placeholder:"Search tools…"}),e[26]=R):R=e[26];let y;e[27]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(_n,{children:"No tools found."}),e[27]=y):y=e[27];let D;if(e[28]!==r||e[29]!==i||e[30]!==m){let M;e[32]!==r||e[33]!==i?(M=P=>n.jsxs(Ei,{value:`${P.name} ${P.description??""}`,onSelect:()=>{r(P),v(!1)},className:"flex items-start gap-2.5",children:[n.jsx(un,{className:"size-4 mt-0.5 text-muted-foreground shrink-0"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("div",{className:"text-sm font-mono truncate",children:P.name}),P.description&&n.jsx("div",{className:"text-xs text-muted-foreground line-clamp-2",children:P.description})]}),n.jsx(ps,{className:te("size-4 shrink-0 mt-0.5",i===P.name?"opacity-100":"opacity-0")})]},P.name),e[32]=r,e[33]=i,e[34]=M):M=e[34],D=m.map(M),e[28]=r,e[29]=i,e[30]=m,e[31]=D}else D=e[31];let N;e[35]!==D?(N=n.jsx(Ut,{className:"w-[min(480px,calc(100vw-2rem))] p-0",align:"start",children:n.jsxs(gn,{children:[R,n.jsxs(pn,{children:[y,n.jsx(ji,{children:D})]})]})}),e[35]=D,e[36]=N):N=e[36];let j;return e[37]!==g||e[38]!==I||e[39]!==N?(j=n.jsxs(Vt,{open:g,onOpenChange:v,children:[I,N]}),e[37]=g,e[38]=I,e[39]=N,e[40]=j):j=e[40],j}function uv(t){const e=z.c(18),{connection:s,toolName:i,input:r,onChange:o}=t,{org:a}=me();let l;e[0]!==s.id||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s.id,orgId:a.id,orgSlug:a.slug},e[0]=s.id,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const h=Ue(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:d,isLoading:u,error:f}=Ha(c);let m;e[6]!==d?.tools||e[7]!==i?(m=d?.tools?.find(g=>g.name===i)??null,e[6]=d?.tools,e[7]=i,e[8]=m):m=e[8];const _=m;if(u){let g;return e[9]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("div",{className:"text-sm text-muted-foreground italic",children:"Loading tool schema…"}),e[9]=g):g=e[9],g}if(f){let g;return e[10]!==f.message?(g=n.jsxs("div",{className:"text-sm text-destructive",children:["Failed to load tool schema: ",f.message]}),e[10]=f.message,e[11]=g):g=e[11],g}if(!_){let g;return e[12]!==i?(g=n.jsxs("div",{className:"text-sm text-muted-foreground italic",children:["Tool ",i," not found on this connection."]}),e[12]=i,e[13]=g):g=e[13],g}let p;return e[14]!==r||e[15]!==o||e[16]!==_.inputSchema?(p=n.jsx(iv,{inputSchema:_.inputSchema,value:r,onChange:o}),e[14]=r,e[15]=o,e[16]=_.inputSchema,e[17]=p):p=e[17],p}function $s(t){const e=t.trim().split(/\s+/);return e.length!==5?!1:e.every(s=>/^[\d*/,-]+$/.test(s))}function fv(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 mv(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 _v(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 pv(t,e){return e===1?{minutes:"minute",hours:"hour",days:"day",weeks:"week"}[t]??t:t}const gv=[{label:"5 minutes",cron:"*/5 * * * *"},{label:"Hour",cron:"0 * * * *"},{label:"Day",cron:"0 0 * * *"},{label:"Week",cron:"0 0 * * 1"}];function vv(t){const e=z.c(33),{automationId:s,open:i,onOpenChange:r,onCustomSelect:o,onEventSelect:a}=t,{triggerAdd:l}=Zs(),[h,c]=A.useState(!1),d=i??h;let u;e[0]!==r?(u=I=>{r?r(I):c(I)},e[0]=r,e[1]=u):u=e[1];const f=u;let m;e[2]!==l||e[3]!==s||e[4]!==f?(m=async I=>{try{await l.mutateAsync({automation_id:s,type:"cron",cron_expression:I}),he.success("Starter added"),f(!1)}catch(R){const y=R,D=y instanceof Error?y.message:"Failed to add starter";he.error(D)}},e[2]=l,e[3]=s,e[4]=f,e[5]=m):m=e[5];const _=m;let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(Xs,{asChild:!0,children:n.jsxs(se,{variant:"outline",size:"sm",children:[n.jsx(es,{size:14}),"Add Starter"]})}),e[6]=p):p=e[6];let g;e[7]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsxs(Yh,{className:"gap-2.5",children:[n.jsx(Bs,{size:14,className:"text-muted-foreground shrink-0"}),"Every..."]}),e[7]=g):g=e[7];let v;e[8]!==l||e[9]!==_?(v=gv.map(I=>n.jsxs(Dt,{className:"gap-2.5",onSelect:()=>_(I.cron),disabled:l.isPending,children:[n.jsx(Bs,{size:14,className:"text-muted-foreground shrink-0"}),"Every ",I.label]},I.cron)),e[8]=l,e[9]=_,e[10]=v):v=e[10];let x;e[11]!==v?(x=n.jsxs(Xh,{children:[g,n.jsx(Jh,{className:"w-[160px]",children:v})]}),e[11]=v,e[12]=x):x=e[12];let b;e[13]!==f||e[14]!==o?(b=()=>{f(!1),o?.()},e[13]=f,e[14]=o,e[15]=b):b=e[15];let S;e[16]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(Bs,{size:14,className:"text-muted-foreground shrink-0"}),e[16]=S):S=e[16];let w;e[17]!==b?(w=n.jsxs(Dt,{className:"gap-2.5",onSelect:b,children:[S,"Custom (cron)"]}),e[17]=b,e[18]=w):w=e[18];let k;e[19]!==f||e[20]!==a?(k=()=>{f(!1),a?.()},e[19]=f,e[20]=a,e[21]=k):k=e[21];let C;e[22]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx(Hs,{size:14,className:"text-muted-foreground shrink-0"}),e[22]=C):C=e[22];let E;e[23]!==k?(E=n.jsxs(Dt,{className:"gap-2.5",onSelect:k,children:[C,"Event"]}),e[23]=k,e[24]=E):E=e[24];let T;e[25]!==E||e[26]!==x||e[27]!==w?(T=n.jsxs(Js,{align:"end",className:"w-[200px]",children:[x,w,E]}),e[25]=E,e[26]=x,e[27]=w,e[28]=T):T=e[28];let B;return e[29]!==f||e[30]!==d||e[31]!==T?(B=n.jsxs(Ys,{open:d,onOpenChange:f,children:[p,T]}),e[29]=f,e[30]=d,e[31]=T,e[32]=B):B=e[32],B}function xv(t){const e=z.c(60),{trigger:s,automationId:i,connectionName:r}=t,{triggerAdd:o,triggerRemove:a}=Zs(),[l,h]=A.useState(!1);let c;e[0]!==s.cron_expression?(c=s.cron_expression?_v(s.cron_expression):null,e[0]=s.cron_expression,e[1]=c):c=e[1];const d=c,[u,f]=A.useState(d?.count??1),[m,_]=A.useState(!1),[p,g]=A.useState(s.cron_expression??""),v=a.isPending||o.isPending,x=s.type==="cron";let b;e[2]!==i||e[3]!==a||e[4]!==s.id?(b=async()=>{try{await a.mutateAsync({trigger_id:s.id,automation_id:i}),he.success("Starter removed")}catch{he.error("Failed to remove starter")}h(!1)},e[2]=i,e[3]=a,e[4]=s.id,e[5]=b):b=e[5];const S=b;let w;e[6]!==o||e[7]!==i||e[8]!==p||e[9]!==a||e[10]!==s.cron_expression||e[11]!==s.id?(w=async()=>{const O=p.trim();if(!O||!$s(O)||O===s.cron_expression){_(!1),g(s.cron_expression??"");return}try{await o.mutateAsync({automation_id:i,type:"cron",cron_expression:O}),await a.mutateAsync({trigger_id:s.id,automation_id:i}),_(!1)}catch{he.error("Failed to update starter"),g(s.cron_expression??""),_(!1)}},e[6]=o,e[7]=i,e[8]=p,e[9]=a,e[10]=s.cron_expression,e[11]=s.id,e[12]=w):w=e[12];const k=w;let C;e[13]!==o||e[14]!==i||e[15]!==d||e[16]!==a||e[17]!==s.cron_expression||e[18]!==s.id?(C=async O=>{if(!d)return;const $=d.unit==="minutes"?5:1,H=Math.max($,O);H!==O&&f(H);const V=mv(H,d.unit);if(V!==s.cron_expression)try{await o.mutateAsync({automation_id:i,type:"cron",cron_expression:V}),await a.mutateAsync({trigger_id:s.id,automation_id:i})}catch{he.error("Failed to update starter"),f(d.count)}},e[13]=o,e[14]=i,e[15]=d,e[16]=a,e[17]=s.cron_expression,e[18]=s.id,e[19]=C):C=e[19];const E=C;let T;e[20]!==x?(T=x?n.jsx(Bs,{size:14,className:"text-muted-foreground shrink-0"}):n.jsx(Hs,{size:14,className:"text-muted-foreground shrink-0"}),e[20]=x,e[21]=T):T=e[21];let B;e[22]!==r||e[23]!==u||e[24]!==p||e[25]!==E||e[26]!==k||e[27]!==d||e[28]!==x||e[29]!==m||e[30]!==v||e[31]!==s.cron_expression||e[32]!==s.event_type||e[33]!==s.params?(B=d&&x?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-sm text-muted-foreground",children:"Every"}),n.jsx("input",{type:"number",min:d.unit==="minutes"?5:1,value:u,onChange:O=>f(parseInt(O.target.value)||1),onBlur:()=>E(u),onKeyDown:O=>{O.key==="Enter"&&O.target.blur(),O.key==="Escape"&&f(d.count)},disabled:v,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:pv(d.unit,u)})]}):x&&m?n.jsxs(n.Fragment,{children:[n.jsx("input",{type:"text",value:p,onChange:O=>g(O.target.value),onBlur:k,onKeyDown:O=>{O.key==="Enter"&&O.target.blur(),O.key==="Escape"&&(_(!1),g(s.cron_expression??""))},className:"flex-1 text-sm font-mono bg-transparent outline-none",autoFocus:!0}),p&&!$s(p)&&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:x?fv(s.cron_expression??""):`${s.event_type}${r?` · ${r}`:""}`}),!x&&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(bv).join(", ")})]}),e[22]=r,e[23]=u,e[24]=p,e[25]=E,e[26]=k,e[27]=d,e[28]=x,e[29]=m,e[30]=v,e[31]=s.cron_expression,e[32]=s.event_type,e[33]=s.params,e[34]=B):B=e[34];let I;e[35]!==v?(I=v&&n.jsx(Ae,{size:13,className:"animate-spin text-muted-foreground"}),e[35]=v,e[36]=I):I=e[36];let R;e[37]!==d||e[38]!==x||e[39]!==m||e[40]!==s.cron_expression?(R=x&&!d&&!m&&n.jsx(se,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{g(s.cron_expression??""),_(!0)},children:n.jsx(Rh,{size:13,className:"text-muted-foreground"})}),e[37]=d,e[38]=x,e[39]=m,e[40]=s.cron_expression,e[41]=R):R=e[41];let y;e[42]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(se,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>h(!0),children:n.jsx(fs,{size:13,className:"text-muted-foreground"})}),e[42]=y):y=e[42];let D;e[43]!==I||e[44]!==R?(D=n.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[I,R,y]}),e[43]=I,e[44]=R,e[45]=D):D=e[45];let N;e[46]!==D||e[47]!==T||e[48]!==B?(N=n.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[T,B,D]}),e[46]=D,e[47]=T,e[48]=B,e[49]=N):N=e[49];let j;e[50]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsxs(Ia,{children:[n.jsx(Ma,{children:"Remove Starter"}),n.jsx(Aa,{children:"Are you sure you want to remove this starter?"})]}),e[50]=j):j=e[50];let M;e[51]===Symbol.for("react.memo_cache_sentinel")?(M=n.jsx(La,{children:"Cancel"}),e[51]=M):M=e[51];let P;e[52]!==S?(P=n.jsxs(Pa,{children:[j,n.jsxs(Ba,{children:[M,n.jsx(Oa,{onClick:S,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]}),e[52]=S,e[53]=P):P=e[53];let F;e[54]!==l||e[55]!==P?(F=n.jsx(Da,{open:l,onOpenChange:h,children:P}),e[54]=l,e[55]=P,e[56]=F):F=e[56];let W;return e[57]!==N||e[58]!==F?(W=n.jsxs(n.Fragment,{children:[N,F]}),e[57]=N,e[58]=F,e[59]=W):W=e[59],W}function bv(t){const[e,s]=t;return`${e}: ${s}`}function Sv(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 yv(t){const e=z.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=qs(r),[a,l]=A.useState(),[h,c]=A.useState();let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d={},e[1]=d):d=e[1];const[u,f]=A.useState(d),{triggerAdd:m}=Zs(),{data:_,isLoading:p}=ed(a);let g,v,x,b,S,w;if(e[2]!==m||e[3]!==s||e[4]!==a||e[5]!==h||e[6]!==p||e[7]!==i||e[8]!==u||e[9]!==o||e[10]!==_){const E=_?.find(P=>P.type===h);let T;e[17]!==m||e[18]!==s||e[19]!==a||e[20]!==h||e[21]!==i||e[22]!==u?(T=async()=>{if(!(!a||!h))try{await m.mutateAsync({automation_id:s,type:"event",event_type:h,connection_id:a,params:u}),ve("automation_trigger_added",{automation_id:s,trigger_type:"event",connection_id:a,event_type:h}),he.success("Event trigger added"),i()}catch{he.error("Failed to add event trigger")}},e[17]=m,e[18]=s,e[19]=a,e[20]=h,e[21]=i,e[22]=u,e[23]=T):T=e[23],g=T,v="flex flex-col gap-3 px-3 py-3 rounded-lg border border-border bg-background";let B,I;e[24]===Symbol.for("react.memo_cache_sentinel")?(I=n.jsx(Hs,{size:14,className:"text-muted-foreground shrink-0"}),B=n.jsx("span",{className:"text-sm font-medium",children:"Event trigger"}),e[24]=B,e[25]=I):(B=e[24],I=e[25]);let R;e[26]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx(fs,{size:13}),e[26]=R):R=e[26],e[27]!==i?(x=n.jsxs("div",{className:"flex items-center gap-2",children:[I,B,n.jsx("button",{type:"button",className:"ml-auto shrink-0 p-0.5 rounded text-muted-foreground hover:text-foreground",onClick:i,children:R})]}),e[27]=i,e[28]=x):x=e[28];const y=a??"";let D;e[29]===Symbol.for("react.memo_cache_sentinel")?(D=P=>{l(P),c(void 0),f({})},e[29]=D):D=e[29];let N;e[30]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx(ft,{className:"w-full",children:n.jsx(mt,{placeholder:"Select connection..."})}),e[30]=N):N=e[30];let j;e[31]!==o?(j=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(kv),e[31]=o,e[32]=j):j=e[32];let M;e[33]!==j?(M=n.jsx(_t,{children:j}),e[33]=j,e[34]=M):M=e[34],e[35]!==y||e[36]!==M?(b=n.jsxs(ut,{value:y,onValueChange:D,children:[N,M]}),e[35]=y,e[36]=M,e[37]=b):b=e[37],e[38]!==a||e[39]!==h||e[40]!==p||e[41]!==_?(S=a&&n.jsxs(ut,{value:h??"",onValueChange:P=>{c(P),f({})},children:[n.jsx(ft,{className:"w-full",children:p?n.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[n.jsx(Ae,{size:13,className:"animate-spin"}),"Loading events..."]}):n.jsx(mt,{placeholder:"Select event type...",children:h??"Select event type..."})}),n.jsx(_t,{children:_?.map(Cv)})]}),e[38]=a,e[39]=h,e[40]=p,e[41]=_,e[42]=S):S=e[42],w=E?.paramsSchema&&Object.keys(E.paramsSchema).length>0&&n.jsx("div",{className:"flex flex-col gap-2",children:Object.entries(E.paramsSchema).map(P=>{const[F,W]=P;return n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsxs("label",{className:"text-xs text-muted-foreground",children:[F,W.description&&n.jsxs("span",{className:"text-muted-foreground/60",children:[" ","— ",W.description]})]}),W.enum?n.jsxs(ut,{value:u[F]??"",onValueChange:O=>f($=>({...$,[F]:O})),children:[n.jsx(ft,{className:"w-full",children:n.jsx(mt,{placeholder:`Select ${F}...`})}),n.jsx(_t,{children:W.enum.map(wv)})]}):n.jsx("input",{type:"text",value:u[F]??"",onChange:O=>f($=>({...$,[F]:O.target.value})),placeholder:W.description??F,className:"text-sm border border-border rounded-md bg-background px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-ring"})]},F)})}),e[2]=m,e[3]=s,e[4]=a,e[5]=h,e[6]=p,e[7]=i,e[8]=u,e[9]=o,e[10]=_,e[11]=g,e[12]=v,e[13]=x,e[14]=b,e[15]=S,e[16]=w}else g=e[11],v=e[12],x=e[13],b=e[14],S=e[15],w=e[16];let k;e[43]!==m||e[44]!==a||e[45]!==h||e[46]!==g?(k=a&&h&&n.jsx(se,{size:"sm",onClick:g,disabled:m.isPending,children:m.isPending?n.jsx(Ae,{size:13,className:"animate-spin"}):"Add trigger"}),e[43]=m,e[44]=a,e[45]=h,e[46]=g,e[47]=k):k=e[47];let C;return e[48]!==v||e[49]!==x||e[50]!==b||e[51]!==S||e[52]!==w||e[53]!==k?(C=n.jsxs("div",{className:v,children:[x,b,S,w,k]}),e[48]=v,e[49]=x,e[50]=b,e[51]=S,e[52]=w,e[53]=k,e[54]=C):C=e[54],C}function wv(t){return n.jsx(Ge,{value:t,children:t},t)}function Cv(t){return n.jsx(Ge,{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 kv(t){return n.jsx(Ge,{value:t.id,children:t.title},t.id)}function Nv({automationId:t,automation:e,onBack:s,onDelete:i}){const r=e.virtual_mcp_id,{org:o}=me(),{update:a,triggerAdd:l,run:h}=Zs(),c=qs(),d=new Map(c.map(ne=>[ne.id,ne.title])),{createTaskWithMessage:u}=Ht(),{setSimpleModeTier:f}=cn(),{setChatOpen:m}=bn(),{sendMessage:_}=rs(),p=ja(),[g,v]=fc(),x=e.messages?.[0]?.metadata?.tiptapDoc??void 0,[b,S]=A.useState(x),[w,k]=A.useState(!1),[C,E]=A.useState(!1),[T,B]=A.useState(""),[I,R]=A.useState(!1),[y,D]=A.useState(!1),[N,j]=A.useState(!1),[M,P]=A.useState(!1),[F,W]=A.useState(()=>({connectionId:e.connection_id??"",toolName:e.tool_name??"",input:e.tool_input??{}})),O=async()=>{if(y)return;const le=$n(b).filter(Ee=>Ee.type==="text").map(Ee=>Ee.text).join(`
|
|
186
|
-
`);if(le.trim()){D(!0);try{we(),ve("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:le.length}),await p(["studio-automation-manager"]),m(!0),await _({tiptapDoc:Ya({managerAgentId:ma.AUTOMATION_MANAGER(o.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:le})})}finally{D(!1)}}},$=e.models?.tier??"smart",H=ca({defaultValues:{name:e.name,active:e.active,tier:$}}),V=H.watch("active"),[re,X]=A.useReducer(Sv,null),J=()=>{re!==null&&(ve("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(re.fields),save_count:re.saveCount,edit_duration_ms:Date.now()-re.start}),X({type:"reset"}))},Z=async()=>{const ne=H.control._formState.dirtyFields,le=Object.keys(ne);if(le.length===0&&!M)return!0;const Ee=H.getValues(),$e=H.control._defaultValues;H.reset(Ee,{keepValues:!0});const os=M;P(!1);const ri={id:t,name:Ee.name,active:Ee.active,models:{tier:Ee.tier},messages:Ec(b),temperature:0};try{await a.mutateAsync(ri)}catch{return H.reset($e,{keepValues:!0}),os&&P(!0),!1}const ni=[...le];return os&&ni.push("messages"),X({type:"accumulate",now:Date.now(),fields:ni}),ge(),!0},{schedule:L,flush:K}=Ls({save:Z}),Q=Ue({connectionId:Ft,orgId:o.id,orgSlug:o.slug}),G=_s(),ee=async ne=>{if(e.kind!=="tool_call")return!0;try{const le=await Q.callTool({name:"AUTOMATION_UPDATE",arguments:{id:t,connection_id:ne.connectionId,tool_name:ne.toolName,tool_input:ne.input}});return le.isError?(he.error(le.content?.[0]?.text??"Failed to save tool-call config"),!1):(G.invalidateQueries({queryKey:us.automationsAll(o.id)}),G.invalidateQueries({queryKey:us.automation(o.id,t)}),!0)}catch(le){return he.error(le instanceof Error?le.message:"Failed to save tool-call config"),!1}},{schedule:oe,flush:_e}=Ls({save:()=>ee(F)}),{schedule:ge,flush:we}=Ls({delayMs:3e4,save:async()=>J()});A.useEffect(()=>{const ne=H.watch(()=>L());return()=>ne.unsubscribe()},[]);const je=ne=>{if(S(ne),!N){j(!0);return}P(!0),L()},De=async()=>{if(ve("automation_test_clicked",{automation_id:t,agent_id:r,kind:e.kind}),e.kind==="tool_call"){if(!await _e())return;try{await h.mutateAsync(t)}catch{}return}const ne=await K();if(we(),!ne)return;if(!b){he.error("No instructions configured for this automation");return}f(H.getValues("tier")),m(!0),v({...g,toolApprovalLevel:"auto"});const le=$n(b);u({message:{tiptapDoc:b,parts:le},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(se,{variant:"ghost",size:"sm",onClick:s,children:[n.jsx(Ua,{size:14}),e.kind==="tool_call"?"Back to all automations":"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(rt,{control:H.control,name:"name",render:({field:ne})=>n.jsx(nt,{...ne,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(se,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:i,children:n.jsx(Ri,{size:14})})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(rt,{control:H.control,name:"active",render:({field:ne})=>n.jsx(yr,{checked:ne.value,onCheckedChange:le=>{ne.onChange(le),K()},className:"cursor-pointer"})}),n.jsx("span",{className:"text-sm text-muted-foreground",children:V?"Active":"Inactive"}),n.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),n.jsx(Ea,{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(vv,{automationId:t,open:w,onOpenChange:k,onCustomSelect:()=>{E(!0),R(!1),B("")},onEventSelect:()=>{R(!0),E(!1)}})]}),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:()=>k(!0),children:"Add a starter"})," ","to get going."]})}):n.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(ne=>n.jsx(xv,{trigger:ne,automationId:t,connectionName:ne.connection_id?d.get(ne.connection_id):void 0},ne.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(Bs,{size:14,className:"text-muted-foreground shrink-0"}),n.jsx("input",{type:"text",value:T,onChange:ne=>B(ne.target.value),onBlur:async()=>{const ne=T.trim();if(!(!ne||!$s(ne)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:ne}),ve("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),he.success("Starter added"),E(!1),B("")}catch{he.error("Failed to add starter")}},onKeyDown:async ne=>{const le=T.trim();ne.key==="Enter"&&le&&$s(le)&&ne.target.blur(),ne.key==="Escape"&&(E(!1),B(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),T&&!$s(T)&&n.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&n.jsx(Ae,{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:()=>{E(!1),B("")},children:n.jsx(fs,{size:13})})]}),I&&n.jsx(A.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(Ae,{size:13,className:"animate-spin text-muted-foreground"}),n.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:n.jsx(yv,{automationId:t,onDone:()=>R(!1)})})]}),e.kind==="tool_call"?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:"Tool call"}),n.jsxs(se,{type:"button",variant:"default",size:"sm",className:"h-7 gap-1.5 px-3 text-xs",onClick:De,disabled:h.isPending||!F.connectionId||!F.toolName,children:[n.jsx(Fn,{size:14}),"Test"]})]}),n.jsx("div",{className:"rounded-xl border border-border p-3",children:n.jsx(lv,{value:F,onChange:ne=>{W(ne),oe()}})})]}):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(se,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:y||!b,onClick:O,children:[n.jsx(Cn,{size:13}),"Improve"]})]}),n.jsx(xc,{tiptapDoc:b,setTiptapDoc:je,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(bc,{virtualMcpId:r||null,className:"max-h-[45vh]"}),n.jsxs("div",{className:"flex items-center justify-end gap-1.5 p-2.5",children:[n.jsx(Sc,{tier:H.watch("tier"),onSelect:ne=>H.setValue("tier",ne,{shouldDirty:!0})}),n.jsxs(Se,{children:[n.jsx(xe,{asChild:!0,children:n.jsxs(se,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:De,disabled:!r,children:[n.jsx(Fn,{size:16}),"Test"]})}),n.jsx(be,{children:"Test Automation"})]})]})]})})]})]})]})}function jv(t){const e=z.c(5),{tabId:s}=t;let i;e[0]!==s?(i=_a(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(Ae,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=o):o=e[2];let a;return e[3]!==r.id?(a=n.jsx(dt,{children:n.jsx(dt.Content,{children:n.jsx(dt.Body,{children:n.jsx(A.Suspense,{fallback:o,children:n.jsx(Ev,{id:r.id})})})})}),e[3]=r.id,e[4]=a):a=e[4],a}function Ev(t){const e=z.c(10),{id:s}=t,i=is(),{org:r}=me(),{data:o,isLoading:a}=td(s),l=o?.kind==="tool_call";let h;e[0]!==l||e[1]!==i||e[2]!==r?(h=()=>{if(l){i({to:"/$org/settings/automations",params:{org:r.slug}});return}i({to:".",search:Tv,replace:!0})},e[0]=l,e[1]=i,e[2]=r,e[3]=h):h=e[3];const c=h;if(a){let u;return e[4]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(Ae,{size:20,className:"animate-spin text-muted-foreground"})}),e[4]=u):u=e[4],u}if(!o){let u;return e[5]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[5]=u):u=e[5],u}let d;return e[6]!==o||e[7]!==s||e[8]!==c?(d=n.jsx(Nv,{automationId:s,automation:o,onBack:c}),e[6]=o,e[7]=s,e[8]=c,e[9]=d):d=e[9],d}function Tv(t){return{...t,main:"automations"}}function Rv(t){const e=z.c(42),{virtualMcpId:s}=t,i=is(),{data:r}=sd(s),o=r===void 0?[]:r,{create:a}=Zs(),[l,h]=A.useState(""),c=l.toLowerCase(),d=o.filter(H=>H.name.toLowerCase().includes(c));let u;e[0]!==i?(u=H=>i({to:".",search:V=>({...V,main:"automation:"+H}),replace:!0}),e[0]=i,e[1]=u):u=e[1];const f=u,m=async()=>{if(a.isPending)return;ve("automation_new_clicked",{virtual_mcp_id:s,existing_count:o.length});const H=await a.mutateAsync(rd(s));f(H.id)},_=async()=>{if(a.isPending)return;ve("automation_new_tool_call_clicked",{source_virtual_mcp_id:s,existing_count:o.length});const H=await a.mutateAsync(nd());f(H.id)};let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(es,{size:14}),e[2]=p):p=e[2];let g;e[3]!==a.isPending||e[4]!==m?(g=n.jsxs(se,{size:"sm",onClick:m,disabled:a.isPending,className:"rounded-r-none",children:[p,"New automation"]}),e[3]=a.isPending,e[4]=m,e[5]=g):g=e[5];let v;e[6]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(vs,{size:14}),e[6]=v):v=e[6];let x;e[7]!==a.isPending?(x=n.jsx(Xs,{asChild:!0,children:n.jsx(se,{size:"sm",disabled:a.isPending,className:"rounded-l-none border-l border-primary-foreground/20 px-2","aria-label":"Pick automation kind",children:v})}),e[7]=a.isPending,e[8]=x):x=e[8];let b;e[9]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(Cn,{size:14}),e[9]=b):b=e[9];let S;e[10]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsxs("div",{className:"flex flex-col",children:[n.jsx("span",{children:"Agent automation"}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"Runs this agent on a schedule or event"})]}),e[10]=S):S=e[10];let w;e[11]!==a.isPending||e[12]!==m?(w=n.jsxs(Dt,{onClick:m,disabled:a.isPending,children:[b,S]}),e[11]=a.isPending,e[12]=m,e[13]=w):w=e[13];let k;e[14]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(un,{size:14}),e[14]=k):k=e[14];let C;e[15]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsxs("div",{className:"flex flex-col",children:[n.jsx("span",{children:"Tool-call automation"}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"Invokes a fixed MCP tool — no agent, no LLM"})]}),e[15]=C):C=e[15];let E;e[16]!==a.isPending||e[17]!==_?(E=n.jsxs(Dt,{onClick:_,disabled:a.isPending,children:[k,C]}),e[16]=a.isPending,e[17]=_,e[18]=E):E=e[18];let T;e[19]!==E||e[20]!==w?(T=n.jsxs(Js,{align:"end",className:"w-72",children:[w,E]}),e[19]=E,e[20]=w,e[21]=T):T=e[21];let B;e[22]!==T||e[23]!==x?(B=n.jsxs(Ys,{children:[x,T]}),e[22]=T,e[23]=x,e[24]=B):B=e[24];let I;e[25]!==B||e[26]!==g?(I=n.jsxs("div",{className:"flex items-stretch",children:[g,B]}),e[25]=B,e[26]=g,e[27]=I):I=e[27];const R=I,y=dt,D=dt,N=dt;let j;e[28]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx(dt.Title,{children:"Automations"}),e[28]=j):j=e[28];const M=o.length>0&&n.jsx(od,{value:l,onChange:h,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let P;e[29]!==R||e[30]!==M?(P=n.jsxs("div",{className:"flex flex-col gap-6",children:[j,n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[M,R]})]}),e[29]=R,e[30]=M,e[31]=P):P=e[31];const F=o.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(Ti,{image:n.jsx(Hs,{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:R})}):d.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(Ti,{image:n.jsx(Hs,{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(H=>n.jsx(id,{automation:H,onClick:()=>f(H.id)},H.id))});let W;e[32]!==N.Body||e[33]!==P||e[34]!==F?(W=n.jsxs(N.Body,{children:[P,F]}),e[32]=N.Body,e[33]=P,e[34]=F,e[35]=W):W=e[35];let O;e[36]!==D.Content||e[37]!==W?(O=n.jsx(D.Content,{children:W}),e[36]=D.Content,e[37]=W,e[38]=O):O=e[38];let $;return e[39]!==y||e[40]!==O?($=n.jsx(y,{children:O}),e[39]=y,e[40]=O,e[41]=$):$=e[41],$}function Dv(t){const e=z.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(Ae,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsx(A.Suspense,{fallback:i,children:n.jsx(Rv,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}const Qo=A.lazy(()=>ln(()=>import("./project-app-view-C1aTqtaY.js"),__vite__mapDeps([126,1,2,75,10,11,12,13,14,3,15,16,17,18,19,20,7,8,21,9,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,76,77,6,78,49,79,80,53,65,66,67,68,56,52,69,70,71,72,73,74,63,64])).then(t=>({default:t.AppViewContent})));function Jl(t){const e=z.c(41),{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}=Ga(r);if($c(o)){let _;return e[3]!==i?(_=n.jsx(to,{virtualMcpId:i}),e[3]=i,e[4]=_):_=e[4],_}if(o==="git"){let _;return e[5]!==i?(_=n.jsx(Bf,{virtualMcpId:i}),e[5]=i,e[6]=_):_=e[6],_}if(o==="automations"){let _;return e[7]!==i?(_=n.jsx(Dv,{virtualMcpId:i}),e[7]=i,e[8]=_):_=e[8],_}if(o==="preview"){let _;return e[9]!==i?(_=n.jsx(sv,{virtualMcpId:i}),e[9]=i,e[10]=_):_=e[10],_}if(h){let _;return e[11]!==o?(_=n.jsx(jv,{tabId:o}),e[11]=o,e[12]=_):_=e[12],_}let c;e[13]!==o?(c=zc(o),e[13]=o,e[14]=c):c=e[14];const d=c;if(d){let _;if(e[15]!==l||e[16]!==d.connectionId||e[17]!==d.toolName){let b;e[19]!==d.connectionId||e[20]!==d.toolName?(b=S=>S.appId===d.connectionId&&S.toolName===d.toolName,e[19]=d.connectionId,e[20]=d.toolName,e[21]=b):b=e[21],_=l.find(b),e[15]=l,e[16]=d.connectionId,e[17]=d.toolName,e[18]=_}else _=e[18];const p=_;let g;e[22]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(Ae,{size:20,className:"animate-spin text-muted-foreground"})}),e[22]=g):g=e[22];const v=p?.args;let x;return e[23]!==o||e[24]!==d.connectionId||e[25]!==d.toolName||e[26]!==v?(x=n.jsx(A.Suspense,{fallback:g,children:n.jsx(Qo,{connectionId:d.connectionId,toolName:d.toolName,args:v},o)}),e[23]=o,e[24]=d.connectionId,e[25]=d.toolName,e[26]=v,e[27]=x):x=e[27],x}let u;if(e[28]!==o||e[29]!==a){let _;e[31]!==o?(_=p=>p.id===o,e[31]=o,e[32]=_):_=e[32],u=a.find(_),e[28]=o,e[29]=a,e[30]=u}else u=e[30];const f=u;if(f){let _;e[33]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(Ae,{size:20,className:"animate-spin text-muted-foreground"})}),e[33]=_):_=e[33];let p;return e[34]!==o||e[35]!==f.id||e[36]!==f.view.appId||e[37]!==f.view.args?(p=n.jsx(A.Suspense,{fallback:_,children:n.jsx(Qo,{connectionId:f.view.appId,toolName:f.id,args:f.view.args},o)}),e[34]=o,e[35]=f.id,e[36]=f.view.appId,e[37]=f.view.args,e[38]=p):p=e[38],p}let m;return e[39]!==i?(m=n.jsx(to,{virtualMcpId:i}),e[39]=i,e[40]=m):m=e[40],m}function Pv(t){const e=z.c(10),{children:s,defaultSize:i,chatOpen:r}=t,[,o]=A.useTransition();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=ua.decoChatPanelWidth(),e[0]=a):a=e[0];const[l,h]=da(a,45),c=i>0&&i<100?l:i;let d;e[1]!==h?(d=p=>o(()=>{p>0&&p<100&&h(p)}),e[1]=h,e[2]=d):d=e[2];const u=d,f=r?"min-w-[348px]":"min-w-0";let m;e[3]!==f?(m=te("overflow-hidden bg-sidebar",f),e[3]=f,e[4]=m):m=e[4];let _;return e[5]!==s||e[6]!==c||e[7]!==u||e[8]!==m?(_=n.jsx(ka,{defaultSize:c,minSize:20,collapsible:!0,collapsedSize:0,className:m,onResize:u,order:1,children:s}),e[5]=s,e[6]=c,e[7]=u,e[8]=m,e[9]=_):_=e[9],_}function Iv(t){const e=z.c(31),{virtualMcpId:s,taskId:i,chatOpen:r,mainOpen:o,chatContent:a}=t;let l;e[0]!==r||e[1]!==o?(l=On(r,o),e[0]=r,e[1]=o,e[2]=l):l=e[2];const h=l;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=ua.decoChatPanelWidth(),e[3]=c):c=e[3];const[d]=da(c,45),u=A.useRef(null);let f,m;e[4]!==r||e[5]!==o||e[6]!==d?(f=()=>{const B=u.current;if(!B)return;const I=On(r,o),R=I.chat>0&&I.chat<100?d:I.chat,y=I.chat>0&&I.chat<100?100-d:I.main;B.setLayout([R,y])},m=[r,o,d],e[4]=r,e[5]=o,e[6]=d,e[7]=f,e[8]=m):(f=e[7],m=e[8]),A.useEffect(f,m);const _=`${s}-${i}`;let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p={overflow:"visible"},e[9]=p):p=e[9];let g;e[10]!==a?(g=a??n.jsx(Va,{}),e[10]=a,e[11]=g):g=e[11];let v;e[12]!==g?(v=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[12]=g,e[13]=v):v=e[13];let x;e[14]!==r||e[15]!==h.chat||e[16]!==v?(x=n.jsx(Pv,{defaultSize:h.chat,chatOpen:r,children:v}),e[14]=r,e[15]=h.chat,e[16]=v,e[17]=x):x=e[17];let b;e[18]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(vh,{className:"bg-sidebar"}),e[18]=b):b=e[18];const S=h.main;let w;e[19]===Symbol.for("react.memo_cache_sentinel")?(w={overflow:"visible"},e[19]=w):w=e[19];let k;e[20]===Symbol.for("react.memo_cache_sentinel")?(k=te("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[20]=k):k=e[20];let C;e[21]!==i||e[22]!==s?(C=n.jsx("div",{className:"h-full p-0.5 pt-0.25",children:n.jsx("div",{className:k,children:n.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.jsx(Rt,{children:n.jsx(Jl,{taskId:i,virtualMcpId:s})})})})}),e[21]=i,e[22]=s,e[23]=C):C=e[23];let E;e[24]!==h.main||e[25]!==C?(E=n.jsx(ka,{className:"min-w-0 flex flex-col",order:2,defaultSize:S,style:w,collapsible:!0,collapsedSize:0,minSize:20,children:C}),e[24]=h.main,e[25]=C,e[26]=E):E=e[26];let T;return e[27]!==E||e[28]!==_||e[29]!==x?(T=n.jsxs(xh,{ref:u,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:p,children:[x,b,E]},_),e[27]=E,e[28]=_,e[29]=x,e[30]=T):T=e[30],T}const gr="flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",ea="bg-sidebar-accent text-sidebar-foreground",vr="text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";function Mv(t){const e=z.c(47),{chatOpen:s,toggleChat:i,onNewTask:r}=t,{tasksOpen:o,toggleTasks:a}=yc(),l=!!r;let h;e[0]!==o||e[1]!==a?(h=()=>{ve("agent_toolbar_toggled",{button:"tasks",next_state:o?"closed":"open"}),a()},e[0]=o,e[1]=a,e[2]=h):h=e[2];const c=o?ea:vr;let d;e[3]!==c?(d=te(gr,c),e[3]=c,e[4]=d):d=e[4];let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(sh,{size:16}),e[5]=u):u=e[5];let f;e[6]!==h||e[7]!==d||e[8]!==o?(f=n.jsx(xe,{asChild:!0,children:n.jsx("button",{type:"button",onClick:h,"aria-pressed":o,className:d,children:u})}),e[6]=h,e[7]=d,e[8]=o,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(be,{side:"bottom",children:"Tasks"}),e[10]=m):m=e[10];let _;e[11]!==f?(_=n.jsxs(Se,{delayDuration:300,children:[f,m]}),e[11]=f,e[12]=_):_=e[12];let p;e[13]!==s||e[14]!==i?(p=()=>{ve("agent_toolbar_toggled",{button:"chat",next_state:s?"closed":"open"}),i()},e[13]=s,e[14]=i,e[15]=p):p=e[15];const g=s?ea:vr;let v;e[16]!==g?(v=te(gr,g),e[16]=g,e[17]=v):v=e[17];let x;e[18]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(ya,{size:16}),e[18]=x):x=e[18];let b;e[19]!==s||e[20]!==v||e[21]!==p?(b=n.jsx(xe,{asChild:!0,children:n.jsx("button",{type:"button",onClick:p,"aria-pressed":s,className:v,children:x})}),e[19]=s,e[20]=v,e[21]=p,e[22]=b):b=e[22];let S;e[23]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(be,{side:"bottom",children:"Chat"}),e[23]=S):S=e[23];let w;e[24]!==b?(w=n.jsxs(Se,{delayDuration:300,children:[b,S]}),e[24]=b,e[25]=w):w=e[25];const k=l?"grid-cols-[1fr]":"grid-cols-[0fr]";let C;e[26]!==k?(C=te("grid transition-[grid-template-columns] duration-200 ease-[var(--ease-out-quart)]",k),e[26]=k,e[27]=C):C=e[27];const E=!l,T=l?0:-1,B=!l,I=l?"translate-x-0 opacity-100":"-translate-x-2 opacity-0";let R;e[28]!==I?(R=te(gr,vr,"transition-[transform,opacity] duration-200 ease-[var(--ease-out-quart)] will-change-transform",I),e[28]=I,e[29]=R):R=e[29];let y;e[30]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(xn,{size:16}),e[30]=y):y=e[30];let D;e[31]!==r||e[32]!==E||e[33]!==T||e[34]!==B||e[35]!==R?(D=n.jsx(xe,{asChild:!0,children:n.jsx("button",{type:"button",onClick:r,disabled:E,tabIndex:T,"aria-hidden":B,className:R,children:y})}),e[31]=r,e[32]=E,e[33]=T,e[34]=B,e[35]=R,e[36]=D):D=e[36];let N;e[37]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx(be,{side:"bottom",children:"New task"}),e[37]=N):N=e[37];let j;e[38]!==D?(j=n.jsx("div",{className:"overflow-hidden",children:n.jsxs(Se,{delayDuration:300,children:[D,N]})}),e[38]=D,e[39]=j):j=e[39];let M;e[40]!==C||e[41]!==j?(M=n.jsx("div",{className:C,children:j}),e[40]=C,e[41]=j,e[42]=M):M=e[42];let P;return e[43]!==w||e[44]!==M||e[45]!==_?(P=n.jsxs(n.Fragment,{children:[_,w,M]}),e[43]=w,e[44]=M,e[45]=_,e[46]=P):P=e[46],P}function Av(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 Bv(t){const e=z.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=te("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(Lv,{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 Lv(t){const e=z.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(wa,{className:"size-4"}),e[4]=i):i=e[4],i}function Ov(t){const e=z.c(13),{overflow:s,onSelect:i}=t,[r,o]=A.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(Wt,{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(ba,{className:"size-4"})})}),e[2]=h):h=e[2];let c;if(e[3]!==l||e[4]!==s){let f;e[6]!==l?(f=m=>n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>l(m.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($v,{icon:m.icon})}),n.jsx("span",{className:"truncate",children:m.title})]})},m.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(Ut,{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(Vt,{open:r,onOpenChange:o,children:[h,d]}),e[10]=r,e[11]=d,e[12]=u):u=e[12],u}function $v(t){const e=z.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(wa,{className:"size-4"}),e[4]=i):i=e[4],i}const zv=6;function Zl(t){const e=z.c(20),{virtualMcpId:s,taskId:i}=t,r=is();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}=Ga(o);let d,u,f,m;if(e[3]!==l||e[4]!==h||e[5]!==r||e[6]!==c||e[7]!==a||e[8]!==s){const g=Fc({activeTab:l,mainOpen:h}),v=k=>k.id==="automations"?g:h&&k.id===l,b=a.find(k=>v(k))?.id??null,{visible:S,overflow:w}=Av(a,b,zv);u=w,d=k=>{const C=a.find(T=>T.id===k),E=b===k&&h;if(ve("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:k,tab_kind:C?.kind??null,was_active:E}),k==="automations"){const T=Hc({activeTab:l,mainOpen:h});r({to:".",search:B=>({...B,main:T}),replace:!0});return}c(k)},f="flex items-center min-w-0 gap-0.5",m=S.map(k=>n.jsx(Bv,{title:k.title,icon:k.icon,active:v(k),onClick:()=>d(k.id)},k.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]=m}else d=e[9],u=e[10],f=e[11],m=e[12];let _;e[13]!==d||e[14]!==u?(_=u.length>0&&n.jsx(Ov,{overflow:u,onSelect:d}),e[13]=d,e[14]=u,e[15]=_):_=e[15];let p;return e[16]!==f||e[17]!==m||e[18]!==_?(p=n.jsxs("div",{className:f,children:[m,_]}),e[16]=f,e[17]=m,e[18]=_,e[19]=p):p=e[19],p}function Fv(t){const e=z.c(12);let s,i,r,o;e[0]!==t?({className:s,orientation:r,decorative:o,...i}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r,e[4]=o):(s=e[1],i=e[2],r=e[3],o=e[4]);const a=r===void 0?"horizontal":r,l=o===void 0?!0:o;let h;e[5]!==s?(h=te("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",s),e[5]=s,e[6]=h):h=e[6];let c;return e[7]!==l||e[8]!==a||e[9]!==i||e[10]!==h?(c=n.jsx(mc,{"data-slot":"separator-root",decorative:l,orientation:a,className:h,...i}),e[7]=l,e[8]=a,e[9]=i,e[10]=h,e[11]=c):c=e[11],c}function Hv(t){const e=z.c(20),{prNumber:s,disabled:i,send:r}=t;let o;e[0]!==s||e[1]!==r?(o=()=>r(kf({prNumber:s})),e[0]=s,e[1]=r,e[2]=o):o=e[2];const a=o;let l;e[3]!==s||e[4]!==r?(l=()=>r(Cf({prNumber:s})),e[3]=s,e[4]=r,e[5]=l):l=e[5];const h=l;let c;e[6]!==i||e[7]!==a?(c=n.jsx(se,{size:"sm",variant:"success",className:"rounded-r-none border-r border-success-foreground/20",disabled:i,onClick:a,children:"Publish"}),e[6]=i,e[7]=a,e[8]=c):c=e[8];let d;e[9]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(vs,{className:"h-3.5 w-3.5"}),e[9]=d):d=e[9];let u;e[10]!==i?(u=n.jsx(Xs,{asChild:!0,children:n.jsx(se,{size:"sm",variant:"success",className:"rounded-l-none px-2",disabled:i,"aria-label":"More actions",children:d})}),e[10]=i,e[11]=u):u=e[11];let f;e[12]!==h?(f=n.jsx(Js,{align:"end",children:n.jsx(Dt,{onClick:h,children:"Review"})}),e[12]=h,e[13]=f):f=e[13];let m;e[14]!==u||e[15]!==f?(m=n.jsxs(Ys,{children:[u,f]}),e[14]=u,e[15]=f,e[16]=m):m=e[16];let _;return e[17]!==c||e[18]!==m?(_=n.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[c,m]}),e[17]=c,e[18]=m,e[19]=_):_=e[19],_}function Wv(t){if(!(t==="claiming"||t==="ready"||t==="failed"))return sl[t].short}const Uv=new Set(["failure","timed_out","cancelled","action_required"]);function Vv(t){return t.status==="completed"&&Uv.has(t.conclusion)}function Kv(t){return t.status==="queued"||t.status==="in_progress"}function qv(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&&Wv(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(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(Vv).map(m=>m.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(Kv);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:"Publish",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}`}}const Gv=6e4,Yv=3e4;function Xv(t){const e=z.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=Ue(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:Gv,refetchIntervalInBackground:!1,staleTime:Yv,select:Jv},e[8]=i,e[9]=o,e[10]=a,e[11]=l):l=e[11],Gs(l)}function Jv(t){const e=Qs(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}}function Zv(t){const e=z.c(44),{virtualMcpId:s}=t,{org:i}=me(),r=Pt(s),{currentBranch:o}=Ht(),a=rs(),l=r?.metadata?.githubRepo??null,{lifecycle:h,branch:c,phase:d}=xs(),u=l?.connectionId??"",f=l?.owner??"",m=l?.name??"",_=o??null;let p;e[0]!==i.id||e[1]!==i.slug||e[2]!==u||e[3]!==f||e[4]!==m||e[5]!==_?(p={orgId:i.id,orgSlug:i.slug,connectionId:u,owner:f,repo:m,branch:_},e[0]=i.id,e[1]=i.slug,e[2]=u,e[3]=f,e[4]=m,e[5]=_,e[6]=p):p=e[6];const g=Za(p),v=g.data??null,x=l?.connectionId??"",b=l?.owner??"",S=l?.name??"",w=v&&v.state==="open"?v.number:null;let k;e[7]!==i.id||e[8]!==i.slug||e[9]!==x||e[10]!==b||e[11]!==S||e[12]!==w?(k={orgId:i.id,orgSlug:i.slug,connectionId:x,owner:b,repo:S,prNumber:w},e[7]=i.id,e[8]=i.slug,e[9]=x,e[10]=b,e[11]=S,e[12]=w,e[13]=k):k=e[13];const C=el(k),E=l?.connectionId??"",T=l?.owner??"",B=l?.name??"",I=v&&v.state==="open"?v.number:null;let R;e[14]!==i.id||e[15]!==i.slug||e[16]!==E||e[17]!==T||e[18]!==B||e[19]!==I?(R={orgId:i.id,orgSlug:i.slug,connectionId:E,owner:T,repo:B,prNumber:I},e[14]=i.id,e[15]=i.slug,e[16]=E,e[17]=T,e[18]=B,e[19]=I,e[20]=R):R=e[20];const y=Xv(R);if(!l?.connectionId||!o)return null;let D;e[21]!==c||e[22]!==C.data||e[23]!==d||e[24]!==h||e[25]!==v||e[26]!==g.isPending||e[27]!==y.data?(D=qv({lifecycle:h,branch:c,claimPhase:d,pr:v,checks:C.data??[],reviews:y.data??null,loading:g.isPending}),e[21]=c,e[22]=C.data,e[23]=d,e[24]=h,e[25]=v,e[26]=g.isPending,e[27]=y.data,e[28]=D):D=e[28];const N=D;let j;e[29]!==a?(j=V=>a.sendMessage({parts:[{type:"text",text:V}]}),e[29]=a,e[30]=j):j=e[30];const M=j,P=a.isStreaming;let F;e[31]!==o||e[32]!==N||e[33]!==P||e[34]!==v||e[35]!==M?(F=V=>{if(!P)switch(V){case"commit-and-push":{M(pf({branch:o}));return}case"create-pr":{M(gf({branch:o}));return}case"reopen":{v&&M(vf({prNumber:v.number}));return}case"rebase":{M(xf({branch:o}));return}case"fix-checks":{v&&M(Sf({prNumber:v.number,failingChecks:N.meta?.failingChecks??[]}));return}case"mark-ready":{v&&M(yf({prNumber:v.number}));return}case"resolve-comments":{v&&M(wf({prNumber:v.number}));return}case"merge-split":return}},e[31]=o,e[32]=N,e[33]=P,e[34]=v,e[35]=M,e[36]=F):F=e[36];const W=F;let O;e[37]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(Fv,{orientation:"vertical",className:"mx-2 data-[orientation=vertical]:h-5"}),e[37]=O):O=e[37];const $=v?.number;let H;return e[38]!==N||e[39]!==P||e[40]!==W||e[41]!==M||e[42]!==$?(H=n.jsxs(n.Fragment,{children:[O,n.jsx(Qv,{button:N,isStreaming:P,onActivate:W,prNumber:$,send:M})]}),e[38]=N,e[39]=P,e[40]=W,e[41]=M,e[42]=$,e[43]=H):H=e[43],H}function Qv(t){const e=z.c(21),{button:s,isStreaming:i}=t,r=!!s.disabled||i,o=i?"Chat is running":s.tooltip??null;if(s.action==="merge-split"&&t.prNumber!=null){let d;e[0]!==r||e[1]!==t.prNumber||e[2]!==t.send?(d=n.jsx(Hv,{prNumber:t.prNumber,disabled:r,send:t.send}),e[0]=r,e[1]=t.prNumber,e[2]=t.send,e[3]=d):d=e[3];let u;return e[4]!==d||e[5]!==o?(u=n.jsx(ta,{label:o,children:d}),e[4]=d,e[5]=o,e[6]=u):u=e[6],u}let a;e[7]!==s.action||e[8]!==t?(a=()=>t.onActivate(s.action),e[7]=s.action,e[8]=t,e[9]=a):a=e[9];let l;e[10]!==s.loading?(l=s.loading?n.jsx(Gh,{size:"xs",variant:"default"}):null,e[10]=s.loading,e[11]=l):l=e[11];let h;e[12]!==s.label||e[13]!==s.variant||e[14]!==r||e[15]!==a||e[16]!==l?(h=n.jsxs(se,{size:"sm",variant:s.variant,disabled:r,onClick:a,children:[l,s.label]}),e[12]=s.label,e[13]=s.variant,e[14]=r,e[15]=a,e[16]=l,e[17]=h):h=e[17];let c;return e[18]!==h||e[19]!==o?(c=n.jsx(ta,{label:o,children:h}),e[18]=h,e[19]=o,e[20]=c):c=e[20],c}function ta(t){const e=z.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(xe,{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(be,{children:s}),e[4]=s,e[5]=o):o=e[5];let a;return e[6]!==r||e[7]!==o?(a=n.jsx(uh,{children:n.jsxs(Se,{children:[r,o]})}),e[6]=r,e[7]=o,e[8]=a):a=e[8],a}function e1(t){const e=z.c(2),{virtualMcp:s}=t;if(!!!(s.metadata?.githubRepo??null)?.connectionId)return null;let o;return e[0]!==s.id?(o=n.jsx(xr.Right,{children:n.jsx(Zv,{virtualMcpId:s.id})}),e[0]=s.id,e[1]=o):o=e[1],o}function t1(t,e){const s=z.c(34),i=Na(),r=A.useSyncExternalStore(i.threads.subscribe,i.threads.get),o=A.useSyncExternalStore(i.threadsStatus.subscribe,i.threadsStatus.get);let a;s[0]!==t||s[1]!==r?(a=t?r.find(b=>b.id===t)??null:null,s[0]=t,s[1]=r,s[2]=a):a=s[2];const l=a,[h,c]=A.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],A.useEffect(d,u);let f,m;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(b=>{c(b)})))},m=[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]=m):(f=s[11],m=s[12]),A.useEffect(f,m);let _;s[13]!==i||s[14]!==e?(_={mutationFn:async b=>i.create({id:b,virtual_mcp_id:e})},s[13]=i,s[14]=e,s[15]=_):_=s[15];const p=na(_);let g,v;if(s[16]!==p||s[17]!==h||s[18]!==t||s[19]!==l||s[20]!==o.kind?(g=()=>{t&&(l||h===null&&o.kind!=="loading"&&(p.isPending||p.variables!==t&&p.mutate(t)))},v=[t,l,h,o.kind,p],s[16]=p,s[17]=h,s[18]=t,s[19]=l,s[20]=o.kind,s[21]=g,s[22]=v):(g=s[21],v=s[22]),A.useEffect(g,v),!t){let b;return s[23]===Symbol.for("react.memo_cache_sentinel")?(b={status:"ready",task:null},s[23]=b):b=s[23],b}if(l){let b;return s[24]!==l?(b={status:"ready",task:l},s[24]=l,s[25]=b):b=s[25],b}if(h&&typeof h=="object"){let b;return s[26]!==h?(b={status:"ready",task:h},s[26]=h,s[27]=b):b=s[27],b}if(p.data){let b;return s[28]!==p.data?(b={status:"ready",task:p.data},s[28]=p.data,s[29]=b):b=s[29],b}if(p.isError){let b;return s[30]!==p.error?(b={status:"error",error:p.error},s[30]=p.error,s[31]=b):b=s[31],b}if(p.isPending||o.kind!=="loading"){let b;return s[32]===Symbol.for("react.memo_cache_sentinel")?(b={status:"creating"},s[32]=b):b=s[32],b}let x;return s[33]===Symbol.for("react.memo_cache_sentinel")?(x={status:"loading"},s[33]=x):x=s[33],x}const hs=A.createContext(null);function Ql(){return A.use(hs)}function sa(t){const e=z.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(Ne.Skeleton,{}),e[1]=r):r=e[1];let o;e[2]!==s?(o=s??n.jsx(Va,{}),e[2]=s,e[3]=o):o=e[3];let a;return e[4]!==o?(a=n.jsx(Rt,{fallback:i,children:n.jsx(A.Suspense,{fallback:r,children:o})}),e[4]=o,e[5]=a):a=e[5],a}function ia(t){const e=z.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],A.useLayoutEffect(r),null}function s1(t){const e=z.c(23),{onOpenSidebar:s,virtualMcpId:i,taskId:r,mainOpen:o,onToggleMain:a,onNewTask:l}=t;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Rc,{size:20}),e[0]=h):h=e[0];let c;e[1]!==s?(c=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:h}),e[1]=s,e[2]=c):c=e[2];let d;e[3]!==r||e[4]!==i?(d=n.jsx("div",{className:"flex-1 min-w-0 overflow-x-auto [scrollbar-width:none]",children:n.jsx(Zl,{virtualMcpId:i,taskId:r})}),e[3]=r,e[4]=i,e[5]=d):d=e[5];const u=!o,f=o?"text-foreground/60 hover:bg-accent hover:text-foreground":"bg-accent text-foreground";let m;e[6]!==f?(m=te("flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",f),e[6]=f,e[7]=m):m=e[7];let _;e[8]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx(ya,{size:16}),e[8]=_):_=e[8];let p;e[9]!==a||e[10]!==u||e[11]!==m?(p=n.jsx("button",{type:"button",onClick:a,"aria-pressed":u,className:m,title:"Chat",children:_}),e[9]=a,e[10]=u,e[11]=m,e[12]=p):p=e[12];let g;e[13]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(xn,{size:16}),e[13]=g):g=e[13];let v;e[14]!==l?(v=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:g}),e[14]=l,e[15]=v):v=e[15];let x;e[16]!==v||e[17]!==p?(x=n.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[p,v]}),e[16]=v,e[17]=p,e[18]=x):x=e[18];let b;return e[19]!==x||e[20]!==c||e[21]!==d?(b=n.jsxs("div",{className:"shrink-0 flex items-center gap-1 px-2 h-12 bg-background border-b border-border",children:[c,d,x]}),e[19]=x,e[20]=c,e[21]=d,e[22]=b):b=e[22],b}function ra(t){const e=z.c(16),{virtualMcpId:s,hasActiveGithubRepo:i,vmMap:r,children:o}=t,{org:a}=me(),{currentBranch:l}=Ht(),{data:h}=Li.useSession(),c=h?.user?.id;let d;e[0]!==a.id||e[1]!==a.slug?(d={connectionId:Ft,orgId:a.id,orgSlug:a.slug},e[0]=a.id,e[1]=a.slug,e[2]=d):d=e[2];const u=Ue(d),{mutate:f}=qa(u);let m;e[3]===Symbol.for("react.memo_cache_sentinel")?(m=new Set,e[3]=m):m=e[3];const _=A.useRef(m);let p,g;e[4]!==l||e[5]!==i||e[6]!==f||e[7]!==c||e[8]!==s||e[9]!==r?(p=()=>{if(i&&c&&l){if(r?.[c]?.[l]){_.current.add(l);return}_.current.has(l)||(_.current.add(l),f({virtualMcpId:s,branch:l},{onError:i1}))}},g=[i,c,l,r,s,f],e[4]=l,e[5]=i,e[6]=f,e[7]=c,e[8]=s,e[9]=r,e[10]=p,e[11]=g):(p=e[10],g=e[11]),A.useEffect(p,g);const v=l??null;let x;return e[12]!==o||e[13]!==v||e[14]!==s?(x=n.jsx(tm,{virtualMcpId:s,branch:v,children:o}),e[12]=o,e[13]=v,e[14]=s,e[15]=x):x=e[15],x}function i1(t){console.error("[auto-start-vm] failed:",t)}function r1(){const t=z.c(115),e=Ca(),s=is(),{org:i}=me(),r=wc()?.tasksOpen??!1;fh(i.slug);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o={strict:!1},t[0]=o):o=t[0];const a=_c(o),l=a.org??"";let h;t[1]===Symbol.for("react.memo_cache_sentinel")?(h={strict:!1},t[1]=h):h=t[1];const c=aa(h);let d;t[2]!==i.id||t[3]!==c.virtualmcpid?(d=c.virtualmcpid??fa(i.id).id,t[2]=i.id,t[3]=c.virtualmcpid,t[4]=d):d=t[4];const u=d,f=t1(a.taskId??"",u),m=Pt(u),_=m?.metadata?.ui?.layout??null;let p;t[5]!==_?(p=_?{defaultMainView:_.defaultMainView??null,chatDefaultOpen:_.chatDefaultOpen??null}:null,t[5]=_,t[6]=p):p=t[6];const g=p;let v;t[7]!==m?(v=m&&Zt(m),t[7]=m,t[8]=v):v=t[8];const x=!!v;let b;t[9]!==l||t[10]!==u?(b={virtualMcpId:u,orgSlug:l,isAgentRoute:!0},t[9]=l,t[10]=u,t[11]=b):b=t[11];const S=Cc(g,b),{setOpenMobile:w,openMobile:k}=lh(),C=w,E=A.useRef(null);let T,B;t[12]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{const J=Z=>{ah(Z)&&Z.shiftKey&&Z.code==="KeyS"&&!Z.repeat&&(Z.preventDefault(),E.current?.())};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)},B=[],t[12]=T,t[13]=B):(T=t[12],B=t[13]),A.useEffect(T,B);const I=u;let R;t[14]!==m||t[15]!==u?(R={virtualMcpId:u,entity:m},t[14]=m,t[15]=u,t[16]=R):R=t[16];const y=R;if(f.status==="creating"||f.status==="loading"){let J;t[17]===Symbol.for("react.memo_cache_sentinel")?(J=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(Ae,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[17]=J):J=t[17];let Z;return t[18]!==y?(Z=n.jsx(hs,{value:y,children:J}),t[18]=y,t[19]=Z):Z=t[19],Z}if(f.status==="error"){let J;t[20]===Symbol.for("react.memo_cache_sentinel")?(J=n.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[20]=J):J=t[20];let Z;t[21]!==f.error.message?(Z=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:[J,n.jsx("div",{className:"text-muted-foreground",children:f.error.message})]})}),t[21]=f.error.message,t[22]=Z):Z=t[22];let L;return t[23]!==y||t[24]!==Z?(L=n.jsx(hs,{value:y,children:Z}),t[23]=y,t[24]=Z,t[25]=L):L=t[25],L}if(!m){let J;t[26]===Symbol.for("react.memo_cache_sentinel")?(J=n.jsx(hn,{size:48,className:"text-muted-foreground"}),t[26]=J):J=t[26];const Z=`The agent "${u}" does not exist in this organization.`;let L;t[27]!==s||t[28]!==l?(L=n.jsx(se,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:l}}),children:"Go to organization home"}),t[27]=s,t[28]=l,t[29]=L):L=t[29];let K;t[30]!==Z||t[31]!==L?(K=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(Ti,{image:J,title:"Agent not found",description:Z,actions:L})})}),t[30]=Z,t[31]=L,t[32]=K):K=t[32];let Q;return t[33]!==y||t[34]!==K?(Q=n.jsx(hs,{value:y,children:K}),t[33]=y,t[34]=K,t[35]=Q):Q=t[35],Q}if(e){let J;t[36]===Symbol.for("react.memo_cache_sentinel")?(J=n.jsx(ch,{className:"sr-only",children:"Navigation"}),t[36]=J):J=t[36];let Z;t[37]!==C?(Z=n.jsx("div",{className:"w-14 shrink-0 bg-sidebar flex flex-col items-center border-r border-border overflow-y-auto group/sidebar","data-state":"collapsed",children:n.jsx(nh,{onClose:()=>C(!1)})}),t[37]=C,t[38]=Z):Z=t[38];let L;t[39]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:n.jsx(oh,{})}),t[39]=L):L=t[39];let K;t[40]!==Z?(K=n.jsxs(hh,{side:"left",hideCloseButton:!0,className:"w-[calc(100vw-3rem)] sm:max-w-md! p-0",children:[J,n.jsxs("div",{className:"flex h-full",children:[Z,L]})]}),t[40]=Z,t[41]=K):K=t[41];let Q;t[42]!==k||t[43]!==C||t[44]!==K?(Q=n.jsx(dh,{open:k,onOpenChange:C,children:K}),t[42]=k,t[43]=C,t[44]=K,t[45]=Q):Q=t[45];const G=Q,ee=m?.metadata?.vmMap;let oe;t[46]!==S.createNewTask?(oe=n.jsx(ia,{onNewTaskRef:E,createNewTask:S.createNewTask}),t[46]=S.createNewTask,t[47]=oe):oe=t[47];let _e;t[48]!==C?(_e=()=>C(!0),t[48]=C,t[49]=_e):_e=t[49];let ge;t[50]!==I||t[51]!==S.createNewTask||t[52]!==S.mainOpen||t[53]!==S.taskId||t[54]!==S.toggleMain||t[55]!==_e?(ge=n.jsx(s1,{onOpenSidebar:_e,virtualMcpId:I,taskId:S.taskId,mainOpen:S.mainOpen,onToggleMain:S.toggleMain,onNewTask:S.createNewTask}),t[50]=I,t[51]=S.createNewTask,t[52]=S.mainOpen,t[53]=S.taskId,t[54]=S.toggleMain,t[55]=_e,t[56]=ge):ge=t[56];let we;t[57]===Symbol.for("react.memo_cache_sentinel")?(we=n.jsx(Ne.Skeleton,{}),t[57]=we):we=t[57];let je;t[58]!==I||t[59]!==S.mainOpen||t[60]!==S.taskId?(je=n.jsx(A.Suspense,{fallback:we,children:n.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:S.mainOpen?n.jsx(Rt,{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(A.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(Ae,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(Jl,{taskId:S.taskId,virtualMcpId:I})})}):n.jsx(sa,{})})}),t[58]=I,t[59]=S.mainOpen,t[60]=S.taskId,t[61]=je):je=t[61];let De;t[62]!==S.taskId||t[63]!==je?(De=n.jsx(Ne.ActiveTaskProvider,{taskId:S.taskId,children:je},S.taskId),t[62]=S.taskId,t[63]=je,t[64]=De):De=t[64];let ne;t[65]!==x||t[66]!==G||t[67]!==ee||t[68]!==oe||t[69]!==ge||t[70]!==De||t[71]!==u?(ne=n.jsxs(ra,{virtualMcpId:u,hasActiveGithubRepo:x,vmMap:ee,children:[oe,ge,De,G]}),t[65]=x,t[66]=G,t[67]=ee,t[68]=oe,t[69]=ge,t[70]=De,t[71]=u,t[72]=ne):ne=t[72];let le;t[73]!==I||t[74]!==ne?(le=n.jsx("div",{className:"flex flex-col flex-1 bg-background min-h-0",children:n.jsx(Ne.Provider,{virtualMcpId:I,children:ne},I)}),t[73]=I,t[74]=ne,t[75]=le):le=t[75];let Ee;return t[76]!==y||t[77]!==le?(Ee=n.jsx(hs,{value:y,children:le}),t[76]=y,t[77]=le,t[78]=Ee):Ee=t[78],Ee}const D=r?void 0:S.createNewTask;let N;t[79]!==S.chatOpen||t[80]!==S.toggleChat||t[81]!==D?(N=n.jsx(xr.Toggles,{children:n.jsx(Mv,{chatOpen:S.chatOpen,toggleChat:S.toggleChat,onNewTask:D})}),t[79]=S.chatOpen,t[80]=S.toggleChat,t[81]=D,t[82]=N):N=t[82];let j;t[83]!==S.taskId||t[84]!==u?(j=n.jsx(xr.Tabs,{children:n.jsx(Zl,{virtualMcpId:u,taskId:S.taskId})}),t[83]=S.taskId,t[84]=u,t[85]=j):j=t[85];const M=m?.metadata?.vmMap;let P;t[86]!==S.createNewTask?(P=n.jsx(ia,{onNewTaskRef:E,createNewTask:S.createNewTask}),t[86]=S.createNewTask,t[87]=P):P=t[87];let F;t[88]!==m?(F=n.jsx(e1,{virtualMcp:m}),t[88]=m,t[89]=F):F=t[89];let W;t[90]===Symbol.for("react.memo_cache_sentinel")?(W=n.jsx(Ne.Skeleton,{}),t[90]=W):W=t[90];let O;t[91]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(sa,{}),t[91]=O):O=t[91];let $;t[92]!==S.chatOpen||t[93]!==S.mainOpen||t[94]!==S.taskId||t[95]!==u?($=n.jsx(A.Suspense,{fallback:W,children:n.jsx(Iv,{virtualMcpId:u,taskId:S.taskId,chatOpen:S.chatOpen,mainOpen:S.mainOpen,chatContent:O})}),t[92]=S.chatOpen,t[93]=S.mainOpen,t[94]=S.taskId,t[95]=u,t[96]=$):$=t[96];let H;t[97]!==S.taskId||t[98]!==F||t[99]!==$?(H=n.jsxs(Ne.ActiveTaskProvider,{taskId:S.taskId,children:[F,$]},S.taskId),t[97]=S.taskId,t[98]=F,t[99]=$,t[100]=H):H=t[100];let V;t[101]!==x||t[102]!==M||t[103]!==P||t[104]!==H||t[105]!==u?(V=n.jsxs(ra,{virtualMcpId:u,hasActiveGithubRepo:x,vmMap:M,children:[P,H]}),t[101]=x,t[102]=M,t[103]=P,t[104]=H,t[105]=u,t[106]=V):V=t[106];let re;t[107]!==I||t[108]!==j||t[109]!==V?(re=n.jsxs(Ne.Provider,{virtualMcpId:I,children:[j,V]},I),t[107]=I,t[108]=j,t[109]=V,t[110]=re):re=t[110];let X;return t[111]!==y||t[112]!==N||t[113]!==re?(X=n.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:n.jsxs(hs,{value:y,children:[N,re]})}),t[111]=y,t[112]=N,t[113]=re,t[114]=X):X=t[114],X}function n1(){const t=z.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(A.Suspense,{fallback:n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(Ae,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(r1,{})}),t[0]=e):e=t[0],e}const Tx=Object.freeze(Object.defineProperty({__proto__:null,default:n1,useInsetContext:Ql},Symbol.toStringTag,{value:"Module"}));export{Hf as e,Tx as i,$f as u};
|
|
282
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(t){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Ln&&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=Ao(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=Bn(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,-dr),dr),e/=dr,e/Math.abs(e)+Math.round(e*(Fp-1)))}shouldForceSelection(t){return Ai?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(),Hp)}_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&&!(Ai&&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<Wp&&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=Ip(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,m=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],v=t[0];o.getWidth(g)===0&&(d++,g--),o.getWidth(v)===2&&(u++,v++);let x=o.getString(v).length;for(x>1&&(m+=x-1,h+=x-1);g>0&&l>0&&!this._isCharWordSeparator(o.loadCell(g-1,this._workCell));){o.loadCell(g-1,this._workCell);let b=this._workCell.getChars().length;this._workCell.getWidth()===0?(d++,g--):b>1&&(f+=b-1,l-=b-1),l--,g--}for(;v<o.length&&h+1<a.length&&!this._isCharWordSeparator(o.loadCell(v+1,this._workCell));){o.loadCell(v+1,this._workCell);let b=this._workCell.getChars().length;this._workCell.getWidth()===2?(u++,v++):b>1&&(m+=b-1,h+=b-1),h++,v++}}h++;let _=l+c-d+f,p=Math.min(this._bufferService.cols,h-l+d+u-f-m);if(!(!e&&a.slice(l,h).trim()==="")){if(s&&_===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 v=this._getWordAt([this._bufferService.cols-1,t[1]-1],!1,!0,!1);if(v){let x=this._bufferService.cols-v.start;_-=x,p+=x}}}if(i&&_+p===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 v=this._getWordAt([0,t[1]+1],!1,!1,!0);v&&(p+=v.length)}}return{start:_,length:p}}}_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=Ao(s,this._bufferService.cols)}};Zr=Te([ie(3,Ze),ie(4,ns),ie(5,Tn),ie(6,Qe),ie(7,Mt),ie(8,It)],Zr);var Bo=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={}}},Lo=class{constructor(){this._color=new Bo,this._css=new Bo}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()}},Le=Object.freeze((()=>{let t=[we.toColor("#2e3436"),we.toColor("#cc0000"),we.toColor("#4e9a06"),we.toColor("#c4a000"),we.toColor("#3465a4"),we.toColor("#75507b"),we.toColor("#06989a"),we.toColor("#d3d7cf"),we.toColor("#555753"),we.toColor("#ef2929"),we.toColor("#8ae234"),we.toColor("#fce94f"),we.toColor("#729fcf"),we.toColor("#ad7fa8"),we.toColor("#34e2e2"),we.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:Ae.toCss(i,r,o),rgba:Ae.toRgba(i,r,o)})}for(let s=0;s<24;s++){let i=8+s*10;t.push({css:Ae.toCss(i,i,i),rgba:Ae.toRgba(i,i,i)})}return t})()),qt=we.toColor("#ffffff"),Is=we.toColor("#000000"),Oo=we.toColor("#ffffff"),$o=Is,Ns={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Kp=qt,Qr=class extends de{constructor(t){super(),this._optionsService=t,this._contrastCache=new Lo,this._halfContrastCache=new Lo,this._onChangeColors=this._register(new G),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:qt,background:Is,cursor:Oo,cursorAccent:$o,selectionForeground:void 0,selectionBackgroundTransparent:Ns,selectionBackgroundOpaque:xe.blend(Is,Ns),selectionInactiveBackgroundTransparent:Ns,selectionInactiveBackgroundOpaque:xe.blend(Is,Ns),scrollbarSliderBackground:xe.opacity(qt,.2),scrollbarSliderHoverBackground:xe.opacity(qt,.4),scrollbarSliderActiveBackground:xe.opacity(qt,.5),overviewRulerBorder:qt,ansi:Le.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=me(t.foreground,qt),e.background=me(t.background,Is),e.cursor=xe.blend(e.background,me(t.cursor,Oo)),e.cursorAccent=xe.blend(e.background,me(t.cursorAccent,$o)),e.selectionBackgroundTransparent=me(t.selectionBackground,Ns),e.selectionBackgroundOpaque=xe.blend(e.background,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundTransparent=me(t.selectionInactiveBackground,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundOpaque=xe.blend(e.background,e.selectionInactiveBackgroundTransparent),e.selectionForeground=t.selectionForeground?me(t.selectionForeground,Po):void 0,e.selectionForeground===Po&&(e.selectionForeground=void 0),xe.isOpaque(e.selectionBackgroundTransparent)&&(e.selectionBackgroundTransparent=xe.opacity(e.selectionBackgroundTransparent,.3)),xe.isOpaque(e.selectionInactiveBackgroundTransparent)&&(e.selectionInactiveBackgroundTransparent=xe.opacity(e.selectionInactiveBackgroundTransparent,.3)),e.scrollbarSliderBackground=me(t.scrollbarSliderBackground,xe.opacity(e.foreground,.2)),e.scrollbarSliderHoverBackground=me(t.scrollbarSliderHoverBackground,xe.opacity(e.foreground,.4)),e.scrollbarSliderActiveBackground=me(t.scrollbarSliderActiveBackground,xe.opacity(e.foreground,.5)),e.overviewRulerBorder=me(t.overviewRulerBorder,Kp),e.ansi=Le.slice(),e.ansi[0]=me(t.black,Le[0]),e.ansi[1]=me(t.red,Le[1]),e.ansi[2]=me(t.green,Le[2]),e.ansi[3]=me(t.yellow,Le[3]),e.ansi[4]=me(t.blue,Le[4]),e.ansi[5]=me(t.magenta,Le[5]),e.ansi[6]=me(t.cyan,Le[6]),e.ansi[7]=me(t.white,Le[7]),e.ansi[8]=me(t.brightBlack,Le[8]),e.ansi[9]=me(t.brightRed,Le[9]),e.ansi[10]=me(t.brightGreen,Le[10]),e.ansi[11]=me(t.brightYellow,Le[11]),e.ansi[12]=me(t.brightBlue,Le[12]),e.ansi[13]=me(t.brightMagenta,Le[13]),e.ansi[14]=me(t.brightCyan,Le[14]),e.ansi[15]=me(t.brightWhite,Le[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]=me(t.extendedAnsi[i],Le[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()}}};Qr=Te([ie(0,Qe)],Qr);function me(t,e){if(t!==void 0)try{return we.toColor(t)}catch{}return e}var qp=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)}},Gp=class{constructor(){this._services=new qp,this._services.set(En,this)}setService(t,e){this._services.set(t,e)}getService(t){return this._services.get(t)}createInstance(t,...e){let s=Fm(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)}},Yp={trace:0,debug:1,info:2,warn:3,error:4,off:5},Xp="xterm.js: ",en=class extends de{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=Yp[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?"":Xp)+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)}};en=Te([ie(0,Qe)],en);var zo=class extends de{constructor(t){super(),this._maxLength=t,this.onDeleteEmitter=this._register(new G),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new G),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new G),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}},ce=3,Me=Object.freeze(new si),_i=0,ur=2,Ms=class Yl{constructor(e,s,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*ce);let r=s||dt.fromCharData([0,ml,1,0]);for(let o=0;o<e;++o)this.setCell(o,r);this.length=e}get(e){let s=this._data[e*ce+0],i=s&2097151;return[this._data[e*ce+1],s&2097152?this._combined[e]:i?Ot(i):"",s>>22,s&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):i]}set(e,s){this._data[e*ce+1]=s[0],s[1].length>1?(this._combined[e]=s[1],this._data[e*ce+0]=e|2097152|s[2]<<22):this._data[e*ce+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(e){return this._data[e*ce+0]>>22}hasWidth(e){return this._data[e*ce+0]&12582912}getFg(e){return this._data[e*ce+1]}getBg(e){return this._data[e*ce+2]}hasContent(e){return this._data[e*ce+0]&4194303}getCodePoint(e){let s=this._data[e*ce+0];return s&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):s&2097151}isCombined(e){return this._data[e*ce+0]&2097152}getString(e){let s=this._data[e*ce+0];return s&2097152?this._combined[e]:s&2097151?Ot(s&2097151):""}isProtected(e){return this._data[e*ce+2]&536870912}loadCell(e,s){return _i=e*ce,s.content=this._data[_i+0],s.fg=this._data[_i+1],s.bg=this._data[_i+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*ce+0]=s.content,this._data[e*ce+1]=s.fg,this._data[e*ce+2]=s.bg}setCellFromCodepoint(e,s,i,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*ce+0]=s|i<<22,this._data[e*ce+1]=r.fg,this._data[e*ce+2]=r.bg}addCodepointToCell(e,s,i){let r=this._data[e*ce+0];r&2097152?this._combined[e]+=Ot(s):r&2097151?(this._combined[e]=Ot(r&2097151)+Ot(s),r&=-2097152,r|=2097152):r=s|1<<22,i&&(r&=-12582913,r|=i<<22),this._data[e*ce+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 dt;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 dt;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*ur<this._data.buffer.byteLength;let i=e*ce;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*ur<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*ur<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 Yl(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*ce+0]&4194303)return e+(this._data[e*ce+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*ce+0]&4194303||this._data[e*ce+2]&50331648)return e+(this._data[e*ce+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<ce;c++)this._data[(i+h)*ce+c]=a[(s+h)*ce+c];a[(s+h)*ce+2]&268435456&&(this._extendedAttrs[i+h]=e._extendedAttrs[s+h])}else for(let h=0;h<r;h++){for(let c=0;c<ce;c++)this._data[(i+h)*ce+c]=a[(s+h)*ce+c];a[(s+h)*ce+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*ce+0],l=a&2097151,h=a&2097152?this._combined[s]:l?Ot(l):$t;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 Jp(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=Gs(d,u,e),m=1,_=0;for(;m<d.length;){let g=Gs(d,m,e),v=g-_,x=s-f,b=Math.min(v,x);d[u].copyCellsFrom(d[m],_,f,b,!1),f+=b,f===s&&(u++,f=0),_+=b,_===g&&(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 p=0;for(let g=d.length-1;g>0&&(g>u||d[g].getTrimmedLength()===0);g--)p++;p>0&&(a.push(l+d.length-p),a.push(p)),l+=d.length-1}return a}function Zp(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 Qp(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 eg(t,e,s){let i=[],r=t.map((h,c)=>Gs(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=Gs(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 Gs(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 Xl=class Jl{constructor(e){this.line=e,this.isDisposed=!1,this._disposables=[],this._id=Jl._nextId++,this._onDispose=this.register(new G),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),ts(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};Xl._nextId=1;var tg=Xl,$e={},Gt=$e.B;$e[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:"≥","{":"π","|":"≠","}":"£","~":"·"};$e.A={"#":"£"};$e.B=void 0;$e[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};$e.C=$e[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};$e.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};$e.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};$e.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};$e.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};$e.E=$e[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};$e.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};$e.H=$e[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};$e["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Fo=4294967295,Ho=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=Me.clone(),this.savedCharset=Gt,this.markers=[],this._nullCell=dt.fromCharData([0,ml,1,0]),this._whitespaceCell=dt.fromCharData([0,$t,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Bi,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new zo(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 Pi),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 Pi),this._whitespaceCell}getBlankLine(t,e){return new Ms(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>Fo?Fo:e}fillViewportRows(t){if(this.lines.length===0){t===void 0&&(t=Me);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 zo(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(t,e){let s=this.getNullCell(Me),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 Ms(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 Ms(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=Jp(this.lines,this._cols,t,this.ybase+this.y,this.getNullCell(Me),s);if(i.length>0){let r=Zp(this.lines,i);Qp(this.lines,r.layout),this._reflowLargerAdjustViewport(t,e,r.countRemoved)}}_reflowLargerAdjustViewport(t,e,s){let i=this.getNullCell(Me),r=s;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<e&&this.lines.push(new Ms(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(Me),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 b=this.ybase+this.y;if(b>=a&&b<a+h.length)continue}let c=h[h.length-1].getTrimmedLength(),d=eg(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 m=[];for(let b=0;b<u;b++){let S=this.getBlankLine(Me,!0);m.push(S)}m.length>0&&(r.push({start:a+h.length+o,newLines:m}),o+=m.length),h.push(...m);let _=d.length-1,p=d[_];p===0&&(_--,p=d[_]);let g=h.length-u-1,v=c;for(;g>=0;){let b=Math.min(v,p);if(h[_]===void 0)break;if(h[_].copyCellsFrom(h[g],v-b,p-b,b,!0),p-=b,p===0&&(_--,p=d[_]),v-=b,v===0){g--;let S=Math.max(g,0);v=Gs(h,S,this._cols)}}for(let b=0;b<h.length;b++)d[b]<t&&h[b].setCell(d[b],i);let x=u-f;for(;x-- >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 p=0;p<this.lines.length;p++)l.push(this.lines.get(p));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 p=Math.min(this.lines.maxLength-1,h+o-1);p>=0;p--)if(u&&u.start>c+f){for(let g=u.newLines.length-1;g>=0;g--)this.lines.set(p--,u.newLines[g]);p++,a.push({index:c+1,amount:u.newLines.length}),f+=u.newLines.length,u=r[++d]}else this.lines.set(p,l[c--]);let m=0;for(let p=a.length-1;p>=0;p--)a[p].index+=m,this.lines.onInsertEmitter.fire(a[p]),m+=a[p].amount;let _=Math.max(0,h+o-this.lines.maxLength);_>0&&this.lines.onTrimEmitter.fire(_)}}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 tg(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)}},sg=class extends de{constructor(t,e){super(),this._optionsService=t,this._bufferService=e,this._onBufferActivate=this._register(new G),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 Ho(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Ho(!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)}},Zl=2,Ql=1,tn=class extends de{constructor(t){super(),this.isUserScrolling=!1,this._onResize=this._register(new G),this.onResize=this._onResize.event,this._onScroll=this._register(new G),this.onScroll=this._onScroll.event,this.cols=Math.max(t.rawOptions.cols||0,Zl),this.rows=Math.max(t.rawOptions.rows||0,Ql),this.buffers=this._register(new sg(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))}};tn=Te([ie(0,Qe)],tn);var cs={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:Ai,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},ig=["normal","bold","100","200","300","400","500","600","700","800","900"],rg=class extends de{constructor(t){super(),this._onOptionChange=this._register(new G),this.onOptionChange=this._onOptionChange.event;let e={...cs};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(Se(()=>{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 cs))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},e=(s,i)=>{if(!(s in cs))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=cs[t]),!ng(e))throw new Error(`"${e}" is not a valid value for ${t}`);break;case"wordSeparator":e||(e=cs[t]);break;case"fontWeight":case"fontWeightBold":if(typeof e=="number"&&1<=e&&e<=1e3)break;e=ig.includes(e)?e:cs[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 ng(t){return t==="block"||t==="underline"||t==="bar"}function As(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]&&As(t[i],e-1);return s}var Wo=Object.freeze({insertMode:!1}),Uo=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),sn=class extends de{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 G),this.onData=this._onData.event,this._onUserInput=this._register(new G),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new G),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new G),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=As(Wo),this.decPrivateModes=As(Uo)}reset(){this.modes=As(Wo),this.decPrivateModes=As(Uo)}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))}};sn=Te([ie(0,Ze),ie(1,xl),ie(2,Qe)],sn);var Vo={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 fr(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 mr=String.fromCharCode,Ko={DEFAULT:t=>{let e=[fr(t,!1)+32,t.col+32,t.row+32];return e[0]>255||e[1]>255||e[2]>255?"":`\x1B[M${mr(e[0])}${mr(e[1])}${mr(e[2])}`},SGR:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${fr(t,!0)};${t.col};${t.row}${e}`},SGR_PIXELS:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${fr(t,!0)};${t.x};${t.y}${e}`}},rn=class extends de{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 G),this.onProtocolChange=this._onProtocolChange.event;for(let i of Object.keys(Vo))this.addProtocol(i,Vo[i]);for(let i of Object.keys(Ko))this.addEncoding(i,Ko[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)}};rn=Te([ie(0,Ze),ie(1,ns),ie(2,Qe)],rn);var _r=[[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]],og=[[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]],Oe;function ag(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 lg=class{constructor(){if(this.version="6",!Oe){Oe=new Uint8Array(65536),Oe.fill(1),Oe[0]=0,Oe.fill(0,1,32),Oe.fill(0,127,160),Oe.fill(2,4352,4448),Oe[9001]=2,Oe[9002]=2,Oe.fill(2,11904,42192),Oe[12351]=1,Oe.fill(2,44032,55204),Oe.fill(2,63744,64256),Oe.fill(2,65040,65050),Oe.fill(2,65072,65136),Oe.fill(2,65280,65377),Oe.fill(2,65504,65511);for(let t=0;t<_r.length;++t)Oe.fill(0,_r[t][0],_r[t][1]+1)}}wcwidth(t){return t<32?0:t<127?1:t<65536?Oe[t]:ag(t,og)?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=Yt.extractWidth(e);r===0?i=!1:r>s&&(s=r)}return Yt.createPropertyValue(0,s,i)}},Yt=class Ni{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new G,this.onChange=this._onChange.event;let e=new lg;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=Ni.extractWidth(l);Ni.extractShouldJoin(l)&&(h-=Ni.extractWidth(i)),s+=h,i=l}return s}charProperties(e,s){return this._activeProvider.charProperties(e,s)}},cg=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 qo(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 js=2147483647,hg=256,ec=class nn{constructor(e=32,s=32){if(this.maxLength=e,this.maxSubParamsLength=s,s>hg)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 nn;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 nn(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>js?js: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>js?js: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,js):e}},Es=[],dg=class{constructor(){this._state=0,this._active=Es,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=Es}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=Es,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Es,!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",Ki(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=Es,this._id=-1,this._state=0}}},it=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+=Ki(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}},Ts=[],ug=class{constructor(){this._handlers=Object.create(null),this._active=Ts,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Ts}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=Ts,this._ident=0}hook(t,e){if(this.reset(),this._ident=t,this._active=this._handlers[t]||Ts,!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",Ki(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=Ts,this._ident=0}},Bs=new ec;Bs.addParam(0);var Go=class{constructor(t){this._handler=t,this._data="",this._params=Bs,this._hitLimit=!1}hook(t){this._params=t.length>1||t.params[0]?t.clone():Bs,this._data="",this._hitLimit=!1}put(t,e,s){this._hitLimit||(this._data+=Ki(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=Bs,this._data="",this._hitLimit=!1,s));return this._params=Bs,this._data="",this._hitLimit=!1,e}},fg=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}},ht=160,mg=(function(){let t=new fg(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(ht,0,2,0),t.add(ht,8,5,8),t.add(ht,6,0,6),t.add(ht,11,0,11),t.add(ht,13,13,13),t})(),_g=class extends de{constructor(t=mg){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 ec,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(Se(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new dg),this._dcsParser=this._register(new ug),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:ht)],r>>4){case 2:for(let f=l+1;;++f){if(f>=e||(i=t[f])<32||i>126&&i<ht){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(i=t[f])<32||i>126&&i<ht){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(i=t[f])<32||i>126&&i<ht){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(i=t[f])<32||i>126&&i<ht){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<ht){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<ht){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}}},pg=/^([\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})$/,gg=/^[\da-f]+$/;function Yo(t){if(!t)return;let e=t.toLowerCase();if(e.indexOf("rgb:")===0){e=e.slice(4);let s=pg.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),gg.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 pr(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 vg(t,e=16){let[s,i,r]=t;return`rgb:${pr(s,e)}/${pr(i,e)}/${pr(r,e)}`}var xg={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Lt=131072,Xo=10;function Jo(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 Zo=5e3,Qo=0,bg=class extends de{constructor(t,e,s,i,r,o,a,l,h=new _g){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 $m,this._utf8Decoder=new zm,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Me.clone(),this._eraseAttrDataInternal=Me.clone(),this._onRequestBell=this._register(new G),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new G),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new G),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new G),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new G),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new G),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new G),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new G),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new G),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new G),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new G),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new G),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new G),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 on(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(U.BEL,()=>this.bell()),this._parser.setExecuteHandler(U.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(U.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(U.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(U.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(U.BS,()=>this.backspace()),this._parser.setExecuteHandler(U.HT,()=>this.tab()),this._parser.setExecuteHandler(U.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(U.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Ci.IND,()=>this.index()),this._parser.setExecuteHandler(Ci.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Ci.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new it(c=>(this.setTitle(c),this.setIconName(c),!0))),this._parser.registerOscHandler(1,new it(c=>this.setIconName(c))),this._parser.registerOscHandler(2,new it(c=>this.setTitle(c))),this._parser.registerOscHandler(4,new it(c=>this.setOrReportIndexedColor(c))),this._parser.registerOscHandler(8,new it(c=>this.setHyperlink(c))),this._parser.registerOscHandler(10,new it(c=>this.setOrReportFgColor(c))),this._parser.registerOscHandler(11,new it(c=>this.setOrReportBgColor(c))),this._parser.registerOscHandler(12,new it(c=>this.setOrReportCursorColor(c))),this._parser.registerOscHandler(104,new it(c=>this.restoreIndexedColor(c))),this._parser.registerOscHandler(110,new it(c=>this.restoreFgColor(c))),this._parser.registerOscHandler(111,new it(c=>this.restoreBgColor(c))),this._parser.registerOscHandler(112,new it(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 $e)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 Go((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"),Zo))]).catch(e=>{if(e!=="#SLOW_TIMEOUT")throw e;console.warn(`async parser handler taking longer than ${Zo} 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>Lt&&(o=this._parseStack.position+Lt)}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<Lt&&(this._parseBuffer=new Uint32Array(Math.min(t.length,Lt))),a||this._dirtyRowTracker.clearRange(),t.length>Lt)for(let c=o;c<t.length;c+=Lt){let d=c+Lt<t.length?c+Lt: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 m=e;m<s;++m){if(i=t[m],i<127&&o){let v=o[String.fromCharCode(i)];v&&(i=v.charCodeAt(0))}let _=this._unicodeService.charProperties(i,f);r=Yt.extractWidth(_);let p=Yt.extractShouldJoin(_),g=p?Yt.extractWidth(f):0;if(f=_,a&&this._onA11yChar.fire(Ot(i)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-g>l){if(h){let v=u,x=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 Ms&&u.copyCellsFrom(v,x,0,g,!1);x<l;)v.setCellFromCodepoint(x++,0,1,d)}else if(this._activeBuffer.x=l-1,r===2)continue}if(p&&this._activeBuffer.x){let v=u.getWidth(this._activeBuffer.x-1)?1:2;u.addCodepointToCell(this._activeBuffer.x-v,i,r);for(let x=r-g;--x>=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=>Jo(s.params[0],this._optionsService.rawOptions.windowOptions)?e(s):!0):this._parser.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._parser.registerDcsHandler(t,new Go(e))}registerEscHandler(t,e){return this._parser.registerEscHandler(t,e)}registerOscHandler(t,e){return this._parser.registerOscHandler(t,new it(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(Me));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=Yt.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(U.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(U.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(t){return t.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(U.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(U.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(t.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(U.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,Gt),this._charsetService.setgCharset(1,Gt),this._charsetService.setgCharset(2,Gt),this._charsetService.setgCharset(3,Gt);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;(p=>(p[p.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",p[p.SET=1]="SET",p[p.RESET=2]="RESET",p[p.PERMANENTLY_SET=3]="PERMANENTLY_SET",p[p.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=(p,g)=>(a.triggerDataEvent(`${U.ESC}[${e?"":"?"}${p};${g}$y`),!0),m=p=>p?1:2,_=t.params[0];return e?_===2?f(_,4):_===4?f(_,m(a.modes.insertMode)):_===12?f(_,3):_===20?f(_,m(u.convertEol)):f(_,0):_===1?f(_,m(i.applicationCursorKeys)):_===3?f(_,u.windowOptions.setWinLines?h===80?2:h===132?1:0:0):_===6?f(_,m(i.origin)):_===7?f(_,m(i.wraparound)):_===8?f(_,3):_===9?f(_,m(r==="X10")):_===12?f(_,m(u.cursorBlink)):_===25?f(_,m(!a.isCursorHidden)):_===45?f(_,m(i.reverseWraparound)):_===66?f(_,m(i.applicationKeypad)):_===67?f(_,4):_===1e3?f(_,m(r==="VT200")):_===1002?f(_,m(r==="DRAG")):_===1003?f(_,m(r==="ANY")):_===1004?f(_,m(i.sendFocus)):_===1005?f(_,4):_===1006?f(_,m(o==="SGR")):_===1015?f(_,4):_===1016?f(_,m(o==="SGR_PIXELS")):_===1048?f(_,1):_===47||_===1047||_===1049?f(_,m(c===d)):_===2004?f(_,m(i.bracketedPasteMode)):_===2026?f(_,m(i.synchronizedOutput)):f(_,0)}_updateAttrColor(t,e,s,i,r){return e===2?(t|=50331648,t&=-16777216,t|=si.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=Me.fg,t.bg=Me.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|=Me.fg&16777215):s===49?(i.bg&=-67108864,i.bg|=Me.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|=Me.fg&16777215,i.bg&=-67108864,i.bg|=Me.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(t){switch(t.params[0]){case 5:this._coreService.triggerDataEvent(`${U.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${U.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(`${U.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=Me.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(!Jo(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(`${U.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(e===0||e===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Xo&&this._windowTitleStack.shift()),(e===0||e===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Xo&&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(ea(o))if(r==="?")e.push({type:0,index:o});else{let a=Yo(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=Yo(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]);ea(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,Gt),!0}selectCharset(t){return t.length!==2?(this.selectDefaultCharset(),!0):(t[0]==="/"||this._charsetService.setgCharset(xg[t[0]],$e[t[1]]||Gt),!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=Me.clone(),this._eraseAttrDataInternal=Me.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 dt;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(`${U.ESC}${a}${U.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)}},on=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&&(Qo=t,t=e,e=Qo),t<this.start&&(this.start=t),e>this.end&&(this.end=e)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};on=Te([ie(0,Ze)],on);function ea(t){return 0<=t&&t<256}var Sg=5e7,ta=12,yg=50,wg=class extends de{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 G),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>Sg)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>=ta?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>=ta)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>yg&&(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()}},an=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)))}};an=Te([ie(0,Ze)],an);var sa=!1,Cg=class extends de{constructor(t){super(),this._windowsWrappingHeuristics=this._register(new ms),this._onBinary=this._register(new G),this.onBinary=this._onBinary.event,this._onData=this._register(new G),this.onData=this._onData.event,this._onLineFeed=this._register(new G),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new G),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new G),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new G),this._instantiationService=new Gp,this.optionsService=this._register(new rg(t)),this._instantiationService.setService(Qe,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(tn)),this._instantiationService.setService(Ze,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(en)),this._instantiationService.setService(xl,this._logService),this.coreService=this._register(this._instantiationService.createInstance(sn)),this._instantiationService.setService(ns,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(rn)),this._instantiationService.setService(vl,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Yt)),this._instantiationService.setService(Um,this.unicodeService),this._charsetService=this._instantiationService.createInstance(cg),this._instantiationService.setService(Wm,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(an),this._instantiationService.setService(bl,this._oscLinkService),this._inputHandler=this._register(new bg(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(qe.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(qe.forward(this._bufferService.onResize,this._onResize)),this._register(qe.forward(this.coreService.onData,this._onData)),this._register(qe.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 wg((e,s)=>this._inputHandler.parse(e,s))),this._register(qe.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new G),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&&!sa&&(this._logService.warn("writeSync is unreliable and will be removed soon."),sa=!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,Zl),e=Math.max(e,Ql),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(qo.bind(null,this._bufferService))),t.push(this.registerCsiHandler({final:"H"},()=>(qo(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Se(()=>{for(let e of t)e.dispose()})}}},kg={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 Ng(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=U.ESC+"OA":r.key=U.ESC+"[A":t.key==="UIKeyInputLeftArrow"?e?r.key=U.ESC+"OD":r.key=U.ESC+"[D":t.key==="UIKeyInputRightArrow"?e?r.key=U.ESC+"OC":r.key=U.ESC+"[C":t.key==="UIKeyInputDownArrow"&&(e?r.key=U.ESC+"OB":r.key=U.ESC+"[B");break;case 8:r.key=t.ctrlKey?"\b":U.DEL,t.altKey&&(r.key=U.ESC+r.key);break;case 9:if(t.shiftKey){r.key=U.ESC+"[Z";break}r.key=U.HT,r.cancel=!0;break;case 13:r.key=t.altKey?U.ESC+U.CR:U.CR,r.cancel=!0;break;case 27:r.key=U.ESC,t.altKey&&(r.key=U.ESC+U.ESC),r.cancel=!0;break;case 37:if(t.metaKey)break;o?r.key=U.ESC+"[1;"+(o+1)+"D":e?r.key=U.ESC+"OD":r.key=U.ESC+"[D";break;case 39:if(t.metaKey)break;o?r.key=U.ESC+"[1;"+(o+1)+"C":e?r.key=U.ESC+"OC":r.key=U.ESC+"[C";break;case 38:if(t.metaKey)break;o?r.key=U.ESC+"[1;"+(o+1)+"A":e?r.key=U.ESC+"OA":r.key=U.ESC+"[A";break;case 40:if(t.metaKey)break;o?r.key=U.ESC+"[1;"+(o+1)+"B":e?r.key=U.ESC+"OB":r.key=U.ESC+"[B";break;case 45:!t.shiftKey&&!t.ctrlKey&&(r.key=U.ESC+"[2~");break;case 46:o?r.key=U.ESC+"[3;"+(o+1)+"~":r.key=U.ESC+"[3~";break;case 36:o?r.key=U.ESC+"[1;"+(o+1)+"H":e?r.key=U.ESC+"OH":r.key=U.ESC+"[H";break;case 35:o?r.key=U.ESC+"[1;"+(o+1)+"F":e?r.key=U.ESC+"OF":r.key=U.ESC+"[F";break;case 33:t.shiftKey?r.type=2:t.ctrlKey?r.key=U.ESC+"[5;"+(o+1)+"~":r.key=U.ESC+"[5~";break;case 34:t.shiftKey?r.type=3:t.ctrlKey?r.key=U.ESC+"[6;"+(o+1)+"~":r.key=U.ESC+"[6~";break;case 112:o?r.key=U.ESC+"[1;"+(o+1)+"P":r.key=U.ESC+"OP";break;case 113:o?r.key=U.ESC+"[1;"+(o+1)+"Q":r.key=U.ESC+"OQ";break;case 114:o?r.key=U.ESC+"[1;"+(o+1)+"R":r.key=U.ESC+"OR";break;case 115:o?r.key=U.ESC+"[1;"+(o+1)+"S":r.key=U.ESC+"OS";break;case 116:o?r.key=U.ESC+"[15;"+(o+1)+"~":r.key=U.ESC+"[15~";break;case 117:o?r.key=U.ESC+"[17;"+(o+1)+"~":r.key=U.ESC+"[17~";break;case 118:o?r.key=U.ESC+"[18;"+(o+1)+"~":r.key=U.ESC+"[18~";break;case 119:o?r.key=U.ESC+"[19;"+(o+1)+"~":r.key=U.ESC+"[19~";break;case 120:o?r.key=U.ESC+"[20;"+(o+1)+"~":r.key=U.ESC+"[20~";break;case 121:o?r.key=U.ESC+"[21;"+(o+1)+"~":r.key=U.ESC+"[21~";break;case 122:o?r.key=U.ESC+"[23;"+(o+1)+"~":r.key=U.ESC+"[23~";break;case 123:o?r.key=U.ESC+"[24;"+(o+1)+"~":r.key=U.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=U.NUL:t.keyCode>=51&&t.keyCode<=55?r.key=String.fromCharCode(t.keyCode-51+27):t.keyCode===56?r.key=U.DEL:t.keyCode===219?r.key=U.ESC:t.keyCode===220?r.key=U.FS:t.keyCode===221&&(r.key=U.GS);else if((!s||i)&&t.altKey&&!t.metaKey){let a=kg[t.keyCode]?.[t.shiftKey?1:0];if(a)r.key=U.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=U.ESC+h}else if(t.keyCode===32)r.key=U.ESC+(t.ctrlKey?U.NUL:" ");else if(t.key==="Dead"&&t.code.startsWith("Key")){let l=t.code.slice(3,4);t.shiftKey||(l=l.toLowerCase()),r.key=U.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=U.US),t.key==="@"&&(r.key=U.NUL));break}return r}var Pe=0,jg=class{constructor(t){this._getKey=t,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Bi,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Bi,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||(Pe=this._search(e),Pe===-1)||this._getKey(this._array[Pe])!==e)return!1;do if(this._array[Pe]===t)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Pe),!0;while(++Pe<this._array.length&&this._getKey(this._array[Pe])===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&&(Pe=this._search(t),!(Pe<0||Pe>=this._array.length)&&this._getKey(this._array[Pe])===t))do yield this._array[Pe];while(++Pe<this._array.length&&this._getKey(this._array[Pe])===t)}forEachByKey(t,e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Pe=this._search(t),!(Pe<0||Pe>=this._array.length)&&this._getKey(this._array[Pe])===t))do e(this._array[Pe]);while(++Pe<this._array.length&&this._getKey(this._array[Pe])===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}},gr=0,ia=0,Eg=class extends de{constructor(){super(),this._decorations=new jg(t=>t?.marker.line),this._onDecorationRegistered=this._register(new G),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new G),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Se(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(t){if(t.marker.isDisposed)return;let e=new Tg(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=>{gr=r.options.x??0,ia=gr+(r.options.width??1),t>=gr&&t<ia&&(!s||(r.options.layer??"bottom")===s)&&i(r)})}},Tg=class extends zt{constructor(t){super(),this.options=t,this.onRenderEmitter=this.add(new G),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new G),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=we.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=we.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},Rg=1e3,Dg=class{constructor(t,e=Rg){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)}},ra=20,Li=class extends de{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 Dg(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(`
|
|
283
|
+
`))),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(oe(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Se(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(t){for(let e=0;e<t;e++)this._handleChar(" ")}_handleChar(t){this._liveRegionLineCount<ra+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==t&&(this._charsToAnnounce+=t):this._charsToAnnounce+=t,t===`
|
|
284
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===ra+1&&(this._liveRegion.textContent+=Nr.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})`}};Li=Te([ie(1,En),ie(2,It),ie(3,Mt)],Li);var ln=class extends de{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 G),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new G),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Se(()=>{ts(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(oe(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(oe(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(oe(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(oe(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&&Pg(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,ts(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}}};ln=Te([ie(1,Tn),ie(2,Mt),ie(3,Ze),ie(4,yl)],ln);function Pg(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 Ig=class extends Cg{constructor(t={}){super(t),this._linkifier=this._register(new ms),this.browser=Fl,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new ms),this._onCursorMove=this._register(new G),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new G),this.onKey=this._onKey.event,this._onRender=this._register(new G),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new G),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new G),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new G),this.onBell=this._onBell.event,this._onFocus=this._register(new G),this._onBlur=this._register(new G),this._onA11yCharEmitter=this._register(new G),this._onA11yTabEmitter=this._register(new G),this._onWillOpen=this._register(new G),this._setup(),this._decorationService=this._instantiationService.createInstance(Eg),this._instantiationService.setService(ii,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(yp),this._instantiationService.setService(yl,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Er)),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(qe.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(qe.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(qe.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(qe.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(Se(()=>{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=xe.toColorRGB(s==="ansi"?this._themeService.colors.ansi[e.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${U.ESC}]${i};${vg(r)}${$l.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(o=>o.ansi[e.index]=Ae.toColor(...e.color));else{let o=s;this._themeService.modifyColors(a=>a[o]=Ae.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(Li,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(t){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(U.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(U.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(oe(this.element,"copy",e=>{this.hasSelection()&&Lm(e,this._selectionService)}));let t=e=>Om(e,this.textarea,this.coreService,this.optionsService);this._register(oe(this.textarea,"paste",t)),this._register(oe(this.element,"paste",t)),Hl?this._register(oe(this.element,"mousedown",e=>{e.button===2&&mo(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(oe(this.element,"contextmenu",e=>{mo(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Ln&&this._register(oe(this.element,"auxclick",e=>{e.button===1&&fl(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(oe(this.textarea,"keyup",t=>this._keyUp(t),!0)),this._register(oe(this.textarea,"keydown",t=>this._keyDown(t),!0)),this._register(oe(this.textarea,"keypress",t=>this._keyPress(t),!0)),this._register(oe(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(oe(this.textarea,"compositionupdate",t=>this._compositionHelper.compositionupdate(t))),this._register(oe(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(oe(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(oe(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",kr.get()),Vl||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(bp,this.textarea,t.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(It,this._coreBrowserService),this._register(oe(this.textarea,"focus",r=>this._handleTextAreaFocus(r))),this._register(oe(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Yr,this._document,this._helperContainer),this._instantiationService.setService(qi,this._charSizeService),this._themeService=this._instantiationService.createInstance(Qr),this._instantiationService.setService(bs,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Mi),this._instantiationService.setService(Sl,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Jr,this.rows,this.screenElement)),this._instantiationService.setService(Mt,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(Kr,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Xr),this._instantiationService.setService(Tn,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(ln,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(Ur,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(Zr,this.element,this.screenElement,i)),this._instantiationService.setService(Km,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(qe.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(Vr,this.screenElement)),this._register(oe(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(Li,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",r=>this._handleScreenReaderModeOptionChange(r))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Ii,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",r=>{!this._overviewRulerRenderer&&r&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Ii,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Gr,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(oe(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(oe(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=U.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){ul(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=Ng(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===U.ETX||s.key===U.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)&&(Mg(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(Me));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(U.ESC+"[I"):this.coreService.triggerDataEvent(U.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(`${U.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(`${U.ESC}[6;${r};${i}t`);break}}cancel(t,e){if(!(!this.options.cancelEvents&&!e))return t.preventDefault(),t.stopPropagation(),!1}};function Mg(t){return t.keyCode===16||t.keyCode===17||t.keyCode===18}var Ag=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)}},Bg=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 dt)}translateToString(t,e,s){return this._line.translateToString(t,e,s)}},na=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 Bg(e)}getNullCell(){return new dt}},Lg=class extends de{constructor(t){super(),this._core=t,this._onBufferChange=this._register(new G),this.onBufferChange=this._onBufferChange.event,this._normal=new na(this._core.buffers.normal,"normal"),this._alternate=new na(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)}},Og=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)}},$g=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}},zg=["cols","rows"],xt=0,Fg=class extends de{constructor(t){super(),this._core=this._register(new Ig(t)),this._addonManager=this._register(new Ag),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(zg.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 Og(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new $g(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 Lg(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
|
|
285
|
+
`,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 kr.get()},set promptLabel(t){kr.set(t)},get tooMuchOutput(){return Nr.get()},set tooMuchOutput(t){Nr.set(t)}}}_verifyIntegers(...t){for(xt of t)if(xt===1/0||isNaN(xt)||xt%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(xt of t)if(xt&&(xt===1/0||isNaN(xt)||xt%1!==0||xt<0))throw new Error("This API only accepts positive integers")}};var Hg=2,Wg=1,Ug=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(Hg,Math.floor(d/t.css.cell.width)),rows:Math.max(Wg,Math.floor(c/t.css.cell.height))}}};function tc({source:t,onReady:e,onSelectionChange:s,className:i}){const r=A.useRef(null),o=A.useRef(null),a=A.useRef(s);a.current=s;const l=xs(),h=A.useRef(t);return h.current=t,mm((c,d)=>{c===h.current&&o.current?.write(d)}),A.useEffect(()=>{const c=r.current;if(!c)return;const d=getComputedStyle(document.documentElement),u=v=>d.getPropertyValue(v).trim()||void 0,f=new Fg({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")}}),m=new Ug;f.loadAddon(m),f.open(c),m.fit();const _=l.getBuffer(t);_&&f.write(_),o.current=f,e?.(f);const p=f.onSelectionChange(()=>{const v=!!f.getSelection();a.current?.(v,()=>f.getSelection())}),g=new ResizeObserver(()=>{m.fit()});return g.observe(c),()=>{p.dispose(),g.disconnect(),o.current=null,f.dispose()}},[]),n.jsx("div",{className:te("h-full bg-sidebar p-3",i),children:n.jsx("div",{ref:r,className:"h-full"})})}function Rs(t){const e=z.c(24);if(t.kind==="starting-now"){let c;return e[0]!==t.claimPhase||e[1]!==t.progress?(c=n.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:n.jsx(Nm,{progress:t.progress,claimPhase:t.claimPhase})}),e[0]=t.claimPhase,e[1]=t.progress,e[2]=c):c=e[2],c}let s,i;e[3]!==t.kind?(s=n.jsx(Vg,{kind:t.kind}),i=n.jsx(Kg,{kind:t.kind}),e[3]=t.kind,e[4]=s,e[5]=i):(s=e[4],i=e[5]);let r;e[6]!==t?(r=n.jsx(qg,{...t}),e[6]=t,e[7]=r):r=e[7];let o;e[8]!==t.kind||e[9]!==t.progress?(o=t.kind==="errored"&&n.jsx(Gg,{progress:t.progress}),e[8]=t.kind,e[9]=t.progress,e[10]=o):o=e[10];let a;e[11]!==t.drawerOpen||e[12]!==t.kind||e[13]!==t.logSource?(a=t.kind==="errored"&&!t.drawerOpen&&n.jsx(Yg,{source:t.logSource}),e[11]=t.drawerOpen,e[12]=t.kind,e[13]=t.logSource,e[14]=a):a=e[14];let l;e[15]!==t?(l=n.jsx(Xg,{...t}),e[15]=t,e[16]=l):l=e[16];let h;return e[17]!==s||e[18]!==i||e[19]!==r||e[20]!==o||e[21]!==a||e[22]!==l?(h=n.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:n.jsxs("div",{className:"flex w-full max-w-md flex-col items-center gap-4 text-center",children:[s,i,r,o,a,l]})}),e[17]=s,e[18]=i,e[19]=r,e[20]=o,e[21]=a,e[22]=l,e[23]=h):h=e[23],h}function Vg(t){const e=z.c(4),{kind:s}=t;switch(s){case"never-started":{let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Ca,{className:te("size-12","text-muted-foreground/60")}),e[0]=i):i=e[0],i}case"errored":{let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(ji,{className:te("size-12","text-destructive")}),e[1]=i):i=e[1],i}case"suspended":{let i;return e[2]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(ch,{className:te("size-12","text-blue-500")}),e[2]=i):i=e[2],i}case"crashed":{let i;return e[3]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(ji,{className:te("size-12","text-amber-500")}),e[3]=i):i=e[3],i}}}function Kg(t){const e=z.c(4),{kind:s}=t;let i;e[0]!==s?(i=xm(s),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=n.jsx("h3",{className:"text-lg font-medium",children:i}),e[2]=i,e[3]=r):r=e[3],r}function qg(t){const e=z.c(5);switch(t.kind){case"never-started":{let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:"Start the sandbox to launch your dev environment."}),e[0]=s):s=e[0],s}case"errored":{let s;return e[1]!==t.errorLine?(s=n.jsx("p",{role:"alert",className:"max-w-sm break-words text-sm text-destructive/80",children:t.errorLine}),e[1]=t.errorLine,e[2]=s):s=e[2],s}case"suspended":{let s;return e[3]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:"Suspended after 30 min idle to conserve resources. Resume to continue where you left off."}),e[3]=s):s=e[3],s}case"crashed":{let s;return e[4]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:"The dev server stopped responding. Open the terminal to inspect the logs and restart it."}),e[4]=s):s=e[4],s}}}function Gg(t){const e=z.c(21),{progress:s}=t;let i;e[0]!==s?(i=li(s,"provision"),e[0]=s,e[1]=i):i=e[1];let r;e[2]!==i?(r=n.jsx(pi,{label:"provision",status:i}),e[2]=i,e[3]=r):r=e[3];let o;e[4]!==s?(o=li(s,"cloning"),e[4]=s,e[5]=o):o=e[5];let a;e[6]!==o?(a=n.jsx(pi,{label:"cloning",status:o}),e[6]=o,e[7]=a):a=e[7];let l;e[8]!==s?(l=li(s,"install"),e[8]=s,e[9]=l):l=e[9];let h;e[10]!==l?(h=n.jsx(pi,{label:"install",status:l}),e[10]=l,e[11]=h):h=e[11];let c;e[12]!==s?(c=li(s,"dev"),e[12]=s,e[13]=c):c=e[13];let d;e[14]!==c?(d=n.jsx(pi,{label:"dev",status:c}),e[14]=c,e[15]=d):d=e[15];let u;return e[16]!==r||e[17]!==a||e[18]!==h||e[19]!==d?(u=n.jsx("div",{className:"flex w-full flex-col gap-1 rounded-lg border border-border bg-muted/30 px-4 py-3 text-left",children:n.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs font-medium",children:[r,a,h,d]})}),e[16]=r,e[17]=a,e[18]=h,e[19]=d,e[20]=u):u=e[20],u}function pi(t){const e=z.c(12),{label:s,status:i}=t;let r;e[0]!==i?(r=vm(i),e[0]=i,e[1]=r):r=e[1];const o=r,a=i==="done"?"text-emerald-600":i==="failed"?"text-destructive":i==="doing"?"text-amber-500":"text-muted-foreground/60";let l;e[2]!==a?(l=te("flex items-center gap-1.5",a),e[2]=a,e[3]=l):l=e[3];let h;e[4]!==o?(h=n.jsx("span",{"aria-hidden":!0,children:o}),e[4]=o,e[5]=h):h=e[5];let c;e[6]!==s?(c=n.jsx("span",{children:s}),e[6]=s,e[7]=c):c=e[7];let d;return e[8]!==l||e[9]!==h||e[10]!==c?(d=n.jsxs("span",{className:l,children:[h,c]}),e[8]=l,e[9]=h,e[10]=c,e[11]=d):d=e[11],d}function Yg(t){const e=z.c(2),{source:s}=t;let i;return e[0]!==s?(i=n.jsx("div",{className:"flex w-[min(78%,560px)] flex-col items-stretch gap-1.5",children:n.jsx("div",{className:"h-32 overflow-hidden rounded-md [&_.xterm-viewport::-webkit-scrollbar]:hidden [&_.xterm-viewport]:!overflow-hidden",children:n.jsx(tc,{source:s,className:"h-full"})})}),e[0]=s,e[1]=i):i=e[1],i}function Xg(t){const e=z.c(12);switch(t.kind){case"never-started":{let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(Qt,{className:"size-4"}),e[0]=s):s=e[0];let i;return e[1]!==t.onStart?(i=n.jsxs(se,{onClick:t.onStart,className:"mt-2",children:[s," Start sandbox"]}),e[1]=t.onStart,e[2]=i):i=e[2],i}case"errored":{let s;e[3]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(Hs,{className:"size-4"}),e[3]=s):s=e[3];let i;return e[4]!==t.onRetry?(i=n.jsxs(se,{size:"sm",onClick:t.onRetry,className:"mt-2",children:[s," Retry"]}),e[4]=t.onRetry,e[5]=i):i=e[5],i}case"suspended":{let s;e[6]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(Qt,{className:"size-4"}),e[6]=s):s=e[6];let i;return e[7]!==t.onResume?(i=n.jsxs(se,{onClick:t.onResume,className:"mt-2",children:[s," Resume"]}),e[7]=t.onResume,e[8]=i):i=e[8],i}case"crashed":{let s;e[9]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(ka,{className:"size-4"}),e[9]=s):s=e[9];let i;return e[10]!==t.onOpenTerminal?(i=n.jsxs(se,{onClick:t.onOpenTerminal,className:"mt-2",children:[s," Open terminal"]}),e[10]=t.onOpenTerminal,e[11]=i):i=e[11],i}}}const Jt="setup";function Jg(t){const e=z.c(35);let s;if(e[0]!==t.scriptTabs||e[1]!==t.scripts){let m;e[3]!==t.scriptTabs?(m=_=>!t.scriptTabs.includes(_),e[3]=t.scriptTabs,e[4]=m):m=e[4],s=t.scripts.filter(m),e[0]=t.scriptTabs,e[1]=t.scripts,e[2]=s}else s=e[2];const i=s;let r;e[5]!==t?(r=()=>{t.active===Jt?t.onToggle():t.onSelectTab(Jt)},e[5]=t,e[6]=r):r=e[6];const o=r,a=t.active===Jt;let l;e[7]!==o||e[8]!==t.open||e[9]!==a?(l=n.jsx(Zg,{active:a,open:t.open,onClick:o}),e[7]=o,e[8]=t.open,e[9]=a,e[10]=l):l=e[10];let h;e[11]!==t?(h=t.scriptTabs.map(m=>n.jsx(ev,{active:t.active===m,onClick:()=>t.onSelectTab(m),onClose:()=>t.onCloseScript(m),children:m},m)),e[11]=t,e[12]=h):h=e[12];let c;e[13]!==i||e[14]!==t.onAddScript?(c=n.jsx(tv,{scripts:i,onRun:t.onAddScript}),e[13]=i,e[14]=t.onAddScript,e[15]=c):c=e[15];let d;e[16]!==l||e[17]!==h||e[18]!==c?(d=n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:[l,h,c]}),e[16]=l,e[17]=h,e[18]=c,e[19]=d):d=e[19];let u;e[20]!==t.onRestart||e[21]!==t.onResume||e[22]!==t.onRetry||e[23]!==t.onRunActiveScript||e[24]!==t.onStart||e[25]!==t.onStop||e[26]!==t.onStopActiveScript||e[27]!==t.scriptIsKilling||e[28]!==t.scriptIsRunning||e[29]!==t.showScriptControls||e[30]!==t.status?(u=t.showScriptControls?n.jsx(sv,{isRunning:t.scriptIsRunning,isKilling:t.scriptIsKilling,onRun:t.onRunActiveScript,onStop:t.onStopActiveScript}):n.jsx(Qg,{status:t.status,onStart:t.onStart,onStop:t.onStop,onRestart:t.onRestart,onResume:t.onResume,onRetry:t.onRetry}),e[20]=t.onRestart,e[21]=t.onResume,e[22]=t.onRetry,e[23]=t.onRunActiveScript,e[24]=t.onStart,e[25]=t.onStop,e[26]=t.onStopActiveScript,e[27]=t.scriptIsKilling,e[28]=t.scriptIsRunning,e[29]=t.showScriptControls,e[30]=t.status,e[31]=u):u=e[31];let f;return e[32]!==d||e[33]!==u?(f=n.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 border-t border-b border-border bg-muted/60 px-3",children:[d,u]}),e[32]=d,e[33]=u,e[34]=f):f=e[34],f}function Zg(t){const e=z.c(8),{active:s,open:i,onClick:r}=t,o=s&&i,a=s&&i,l=s?"border-border bg-background font-medium text-foreground shadow-sm":"border-transparent text-muted-foreground hover:bg-background/50 hover:text-foreground";let h;e[0]!==l?(h=te("flex h-7 items-center gap-1.5 rounded-md border px-2.5 text-xs",l),e[0]=l,e[1]=h):h=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(ka,{className:"size-3.5"}),e[2]=c):c=e[2];let d;return e[3]!==r||e[4]!==o||e[5]!==a||e[6]!==h?(d=n.jsxs("button",{type:"button","aria-pressed":o,"aria-expanded":a,onClick:r,className:h,children:[c,"sandbox"]}),e[3]=r,e[4]=o,e[5]=a,e[6]=h,e[7]=d):d=e[7],d}function Qg(t){const e=z.c(24),{status:s,onStart:i,onStop:r,onRestart:o,onResume:a,onRetry:l}=t;if(s==="idle"&&i){let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Qt,{className:"size-3.5"}),e[0]=h):h=e[0];let c;return e[1]!==i?(c=n.jsxs(se,{variant:"outline",size:"sm",onClick:i,children:[h," Start"]}),e[1]=i,e[2]=c):c=e[2],c}if(s==="suspended"&&a){let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Qt,{className:"size-3.5"}),e[3]=h):h=e[3];let c;return e[4]!==a?(c=n.jsxs(se,{variant:"outline",size:"sm",onClick:a,children:[h," Resume"]}),e[4]=a,e[5]=c):c=e[5],c}if(s==="errored"&&l){let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Hs,{className:"size-3.5"}),e[6]=h):h=e[6];let c;return e[7]!==l?(c=n.jsxs(se,{variant:"outline",size:"sm",onClick:l,children:[h," Retry"]}),e[7]=l,e[8]=c):c=e[8],c}if(s==="starting"||s==="running"){const h=s==="running"&&!!o,c=h?"rounded-r-none border-r-0":void 0;let d;e[9]!==c?(d=te(c),e[9]=c,e[10]=d):d=e[10];let u;e[11]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(Na,{className:"size-3.5"}),e[11]=u):u=e[11];let f;e[12]!==r||e[13]!==d?(f=n.jsx(ke,{asChild:!0,children:n.jsxs(se,{variant:"outline",size:"sm",onClick:r,className:d,children:[u," Stop"]})}),e[12]=r,e[13]=d,e[14]=f):f=e[14];let m;e[15]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(Ne,{children:"Stop sandbox"}),e[15]=m):m=e[15];let _;e[16]!==f?(_=n.jsxs(je,{children:[f,m]}),e[16]=f,e[17]=_):_=e[17];let p;e[18]!==o||e[19]!==h?(p=h&&n.jsxs(Js,{children:[n.jsx(Zs,{asChild:!0,children:n.jsx(se,{variant:"outline",size:"sm",className:"rounded-l-none px-1",children:n.jsx(vs,{className:"size-3"})})}),n.jsx(Qs,{align:"end",children:n.jsxs(Dt,{onClick:o,children:[n.jsx(Hs,{className:"size-3.5"})," Restart"]})})]}),e[18]=o,e[19]=h,e[20]=p):p=e[20];let g;return e[21]!==_||e[22]!==p?(g=n.jsxs("div",{className:"flex items-center",children:[_,p]}),e[21]=_,e[22]=p,e[23]=g):g=e[23],g}return null}function ev(t){const e=z.c(16),{active:s,onClick:i,onClose:r,children:o}=t,a=s?"border-border bg-background shadow-sm":"border-transparent hover:bg-background/50";let l;e[0]!==a?(l=te("flex h-7 items-center rounded-md border text-xs",a),e[0]=a,e[1]=l):l=e[1];const h=r?"pl-2.5 pr-1":"px-2.5",c=s?"font-medium text-foreground":"text-muted-foreground hover:text-foreground";let d;e[2]!==h||e[3]!==c?(d=te("flex h-full items-center",h,c),e[2]=h,e[3]=c,e[4]=d):d=e[4];let u;e[5]!==o||e[6]!==i||e[7]!==d?(u=n.jsx("button",{type:"button",onClick:i,className:d,children:o}),e[5]=o,e[6]=i,e[7]=d,e[8]=u):u=e[8];let f;e[9]!==o||e[10]!==r?(f=r&&n.jsx("button",{type:"button","aria-label":`Close ${o}`,onClick:r,className:"pr-1.5 text-muted-foreground hover:text-foreground",children:n.jsx(cd,{className:"size-3"})}),e[9]=o,e[10]=r,e[11]=f):f=e[11];let m;return e[12]!==l||e[13]!==u||e[14]!==f?(m=n.jsxs("div",{className:l,children:[u,f]}),e[12]=l,e[13]=u,e[14]=f,e[15]=m):m=e[15],m}function tv(t){const e=z.c(10),{scripts:s,onRun:i}=t,[r,o]=A.useState(!1);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsxs(je,{children:[n.jsx(ke,{asChild:!0,children:n.jsx(Wt,{asChild:!0,children:n.jsx(se,{variant:"ghost",size:"sm","aria-label":"Run script",children:n.jsx(es,{className:"size-3.5"})})})}),n.jsx(Ne,{children:"Run script"})]}),e[0]=a):a=e[0];let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wide text-muted-foreground",children:"run a script"}),e[1]=l):l=e[1];let h;e[2]!==i||e[3]!==s?(h=s.length===0?n.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:"No scripts found"}):s.map(u=>n.jsxs("button",{type:"button",onClick:()=>{o(!1),i(u)},className:"w-full rounded-md px-2 py-1.5 text-left text-xs hover:bg-accent",children:["▸ ",u]},u)),e[2]=i,e[3]=s,e[4]=h):h=e[4];let c;e[5]!==h?(c=n.jsxs(Ut,{align:"start",className:"p-1 w-56",children:[l,h]}),e[5]=h,e[6]=c):c=e[6];let d;return e[7]!==r||e[8]!==c?(d=n.jsxs(Vt,{open:r,onOpenChange:o,children:[a,c]}),e[7]=r,e[8]=c,e[9]=d):d=e[9],d}function sv(t){const e=z.c(13),{isRunning:s,isKilling:i,onRun:r,onStop:o}=t;if(i){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsxs(se,{variant:"outline",size:"sm",disabled:!0,children:[n.jsx(Be,{className:"size-3.5 animate-spin"})," Stopping…"]}),e[0]=d):d=e[0],d}if(!s){let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Qt,{className:"size-3.5"}),e[1]=d):d=e[1];let u;e[2]!==r?(u=n.jsx(ke,{asChild:!0,children:n.jsxs(se,{variant:"outline",size:"sm",onClick:r,children:[d," Run"]})}),e[2]=r,e[3]=u):u=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(Ne,{children:"Start process"}),e[4]=f):f=e[4];let m;return e[5]!==u?(m=n.jsxs(je,{children:[u,f]}),e[5]=u,e[6]=m):m=e[6],m}let a;e[7]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(Na,{className:"size-3.5"}),e[7]=a):a=e[7];let l;e[8]!==o?(l=n.jsx(ke,{asChild:!0,children:n.jsxs(se,{variant:"outline",size:"sm",onClick:o,children:[a," Stop"]})}),e[8]=o,e[9]=l):l=e[9];let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Ne,{children:"Stop process"}),e[10]=h):h=e[10];let c;return e[11]!==l?(c=n.jsxs(je,{children:[l,h]}),e[11]=l,e[12]=c):c=e[12],c}const iv=["dev","start"];function rv(t){const e=xs(),[s,i]=A.useState(Jt),[r,o]=A.useState([]),[a,l]=A.useState(new Set),h=A.useRef(!1);if(!h.current&&e.scripts.length>0){const S=iv.find(w=>e.scripts.includes(w));S&&(h.current=!0,o(w=>w.includes(S)?w:[...w,S]),i(S))}if(a.size>0){let S=!1;const w=new Set(a);for(const k of a)e.activeProcesses.includes(k)||(w.delete(k),S=!0);S&&l(w)}const c=()=>t.onOpenChange(!t.open),d=S=>{i(S),t.open||t.onOpenChange(!0)},u=S=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(`/api/${encodeURIComponent(t.orgSlug)}/vm/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/exec/${encodeURIComponent(S)}`,{method:"POST"}),f=S=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(`/api/${encodeURIComponent(t.orgSlug)}/vm/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/exec/${encodeURIComponent(S)}/kill`,{method:"POST"}),m=async S=>{o(w=>w.includes(S)?w:[...w,S]),i(S),t.onOpenChange(!0);try{const w=await u(S);if(w===null)return;if(!w.ok)throw new Error(`Exec failed: ${w.statusText}`)}catch{he.error("Failed to run "+S)}},_=async S=>{await f(S),o(w=>w.filter(k=>k!==S)),s===S&&i(Jt)},p=async()=>{const S=e.activeProcesses.includes(s);try{const w=await u(s);if(w===null)return;if(!w.ok)throw new Error(`Exec failed: ${w.statusText}`)}catch{he.error((S?"Failed to restart ":"Failed to run ")+s)}},g=async()=>{if(!a.has(s)){l(S=>new Set(S).add(s));try{const S=await f(s);if(S===null){l(w=>{const k=new Set(w);return k.delete(s),k});return}if(!S.ok)throw new Error(`Kill failed: ${S.statusText}`)}catch{l(S=>{const w=new Set(S);return w.delete(s),w}),he.error("Failed to stop "+s)}}},v=s!==Jt&&r.includes(s),x=v&&e.activeProcesses.includes(s),b=v&&a.has(s);return n.jsxs("div",{className:"flex shrink-0 flex-col",style:{height:t.open?"50%":"auto"},children:[n.jsx(Jg,{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:m,onCloseScript:_,showScriptControls:v,scriptIsRunning:x,scriptIsKilling:b,onRunActiveScript:p,onStopActiveScript:g}),t.open&&n.jsx("div",{className:"flex-1 overflow-hidden",children:n.jsx(nv,{vmId:t.vmId,active:s,hasData:e.hasData(s),onRunActive:p})})]})}function nv(t){const e=z.c(10),{vmId:s,active:i,hasData:r,onRunActive:o}=t;if(!s)return null;if(i===Jt||r){let d;return e[0]!==i?(d=n.jsx(tc,{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(Qt,{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 sc=t=>`preview-drawer:${t}`;function ov(t){try{const e=localStorage.getItem(sc(t));return e?!!JSON.parse(e).open:!1}catch{return!1}}function av(t,e){try{localStorage.setItem(sc(t),JSON.stringify({open:e}))}catch{}}const lv=A.lazy(()=>cn(()=>import("./sections-editor-mCI01e08.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])).then(t=>({default:t.SectionsEditor}))),cv=A.lazy(()=>cn(()=>import("./file-explorer-D4u2-UUk.js"),__vite__mapDeps([124,1,2,125,8,3,10,11,12,13,14,15,16,17,18,19,20,21,7,9,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,4,5,6,66,67,54,68,69,57,53,70,71,72,50,73,74,75])).then(t=>({default:t.FileExplorer}))),hv=500;function dv(t,e){return t.kind==="errored"?"errored":t.kind==="suspended"?"suspended":t.kind==="starting-now"||e?"starting":t.kind==="iframe"||t.kind==="no-html"||t.kind==="crashed"?"running":"idle"}function uv(){const t=nc(),{data:e}=Oi.useSession(),{taskId:s,currentBranch:i,setCurrentTaskBranch:r}=Ht(),[o,a]=A.useState("preview"),[l,h]=A.useState(null),c=A.useRef(null),d=o==="cms",[u,f]=A.useState(null),[m,_]=A.useState(384),p=A.useRef(!1),g=A.useRef(0),v=A.useRef(0),x=A.useRef(null),[b,S]=A.useState(!1),[w,k]=A.useState(""),E=A.useRef(null),[P,R]=A.useState("/"),B=e?.user?.id,I=t?.entity?.metadata,T=B&&i?I?.vmMap?.[B]?.[i]:void 0,y=T?.previewUrl??null,N=t?.entity?.id??null,{org:C}=ge(),j=N&&i?{orgSlug:C.slug,virtualMcpId:N,branch:i}:null,{data:M}=Yf(j),D=M?Zf(M).sort((V,fe)=>V.name.localeCompare(fe.name)):[],F=D.find(V=>V.path===P)?.name,H=xs();_m(()=>{const V=c.current;V&&(V.src=V.src)});const O=H.lifecycle.phase,$=A.useRef({url:"",value:!1});y&&$.current.url!==y&&($.current={url:y,value:!1}),H.lifecycle.phase==="running"&&($.current.value=H.lifecycle.htmlSupport);const W=$.current.value,K=O==="running"?"online":O==="crashed"?"offline":"booting",re=H.suspended,Z=H.status.state==="paused",J=Ue({connectionId:Ft,orgId:t?.entity?.organization_id??"",orgSlug:C.slug}),X=Qa(J),L=X.error?.message??null,q=eu(N??void 0,i??void 0),Q=A.useRef(null),Y=A.useRef(null),ee=H.phase,ae=gm({claimPhase:ee,lifecycle:H.lifecycle}),_e=!!N&&!!i&&xi.isStopped(N,i),ue=pm({previewUrl:y,status:K,htmlSupport:W,suspended:re,appPaused:Z,vmStartPending:q,lastStartError:L,claimPhase:ee,notFound:H.notFound,userStopped:_e}),pe=V=>{if(!N)return;const fe={virtualMcpId:N};i&&(fe.branch=i),X.mutate(fe,{onSuccess:Ke=>{Ke?.branch&&!i&&r(Ke.branch)},onError:Ke=>{console.error(`[preview] ${V} VM_START failed`,Ke)}})},ve=A.useRef(pe);ve.current=pe,s&&T&&Q.current!==s&&(Q.current=s);const Re=!!s&&!!N&&!!B&&!!i&&!T&&!L&&!_e&&!X.isPending&&Q.current!==s;A.useEffect(()=>{!Re||!s||(Q.current=s,ve.current("auto-start"))},[Re,s,_e]);const ne=H.notFound?T?.vmId??null:null;A.useEffect(()=>{!ne||!N||L||X.isPending||Y.current!==ne&&(i&&xi.isStopped(N,i)||(Y.current=ne,ve.current("self-heal")))},[ne,N,L,X.isPending,i]);const le=()=>{Q.current=null,Y.current=null,X.reset(),ve.current("auto-start")},De=_s(),Ie=N??"__no-vmcp__",[os,oi]=A.useState(null),ys=A.useRef(null);ys.current!==Ie&&(ys.current=Ie,oi(ov(Ie)));const On=ue.kind==="never-started"?!1:os??!1,Xi=V=>{oi(V),av(Ie,V)},$n=()=>Xi(!0),zn=async()=>{if(!N)return;const V=i;if(V){xi.mark(N,V);try{await J.callTool({name:"VM_DELETE",arguments:{virtualMcpId:N,branch:V}})}catch{}fa(De)}},oc=async()=>{await zn(),ve.current("auto-start")};A.useEffect(()=>{if(!y)return;let V;try{V=new URL(y,window.location.href).origin}catch{return}const fe=Ke=>{if(Ke.origin===V){if(Ke.data?.type==="visual-editor::element-clicked"){const tt=Qf.safeParse(Ke.data.payload);tt.success&&h(tt.data)}else if(Ke.data?.type==="cms-editor::section-clicked"){const tt=tm.safeParse(Ke.data.payload);tt.success&&f(tt.data.sectionIndex)}}};return window.addEventListener("message",fe),()=>window.removeEventListener("message",fe)},[y]),A.useEffect(()=>{if(!b)return;const V=fe=>{E.current?.contains(fe.target)||(S(!1),k(""))};return document.addEventListener("pointerdown",V),()=>document.removeEventListener("pointerdown",V)},[b]),A.useEffect(()=>{if(!d)return;const V=Ke=>{const tt=Ke.target;tt&&tt!==c.current&&(x.current=tt)},fe=()=>{requestAnimationFrame(()=>{const Ke=document.activeElement;(Ke===document.body||Ke===c.current)&&x.current&&x.current.focus()})};return document.addEventListener("focusin",V),document.addEventListener("blur",fe,!0),()=>{document.removeEventListener("focusin",V),document.removeEventListener("blur",fe,!0)}},[d]);const Fn=()=>{const V=c.current?.contentWindow;V&&V.postMessage({type:"visual-editor::activate",script:em},"*")},ac=()=>{const V=c.current?.contentWindow;V&&V.postMessage({type:"visual-editor::deactivate"},"*")},Hn=()=>{const V=c.current?.contentWindow;V&&V.postMessage({type:"visual-editor::activate",script:sm},"*")},lc=()=>{const V=c.current?.contentWindow;V&&V.postMessage({type:"cms-editor::deactivate"},"*")},cc=V=>{const fe=o;a(V),h(null),V!=="cms"&&f(null),fe==="visual"&&ac(),fe==="cms"&&lc(),V==="visual"&&Fn(),V==="cms"&&Hn()},hc=()=>{if(!c.current)return;const V=c.current;V.src=V.src},dc=()=>{if(!c.current||!y)return;const V=y.includes("?")?"&":"?";c.current.src=`${y}${V}_r=${Date.now()}`},uc=()=>{const V=c.current?.contentWindow?.location?.href??y;V&&navigator.clipboard.writeText(V)},fc=(()=>{if(!y)return"No server running";try{const V=new URL(y),fe=P==="/"?"":P;return`${V.host}${fe}`}catch{return y}})(),mc=[{value:"preview",icon:n.jsx(Ca,{size:14}),tooltip:"Interactive"},{value:"visual",icon:n.jsx(Qn,{size:14}),tooltip:"Visual editor"},...D.length>0?[{value:"cms",icon:n.jsx(hh,{size:14}),tooltip:"Sections editor"}]:[],{value:"code",icon:n.jsx(dh,{size:14}),tooltip:"Code editor"}];return n.jsxs("div",{className:"flex flex-col w-full h-full",children:[ue.kind==="iframe"&&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:W&&n.jsx(ld,{value:o,onValueChange:cc,options:mc,size:"sm",className:"shrink-0 bg-foreground/4.5"})}),n.jsxs("div",{className:te("flex min-w-0 flex-1 items-center gap-0.5",o==="code"&&"hidden"),children:[n.jsxs(je,{children:[n.jsx(ke,{asChild:!0,children:n.jsx(se,{variant:"ghost",size:"icon",onClick:()=>c.current?.contentWindow?.history.back(),children:n.jsx(Xa,{size:14})})}),n.jsx(Ne,{side:"bottom",children:"Back"})]}),n.jsxs(je,{children:[n.jsx(ke,{asChild:!0,children:n.jsx(se,{variant:"ghost",size:"icon",onClick:()=>c.current?.contentWindow?.history.forward(),children:n.jsx(Wc,{size:14})})}),n.jsx(Ne,{side:"bottom",children:"Forward"})]}),n.jsxs(je,{children:[n.jsx(ke,{asChild:!0,children:n.jsx(se,{variant:"ghost",size:"icon",onClick:hc,children:n.jsx(Hs,{size:14})})}),n.jsx(Ne,{side:"bottom",children:"Refresh"})]}),n.jsxs("div",{ref:E,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:()=>S(V=>!V),children:[n.jsx("span",{className:"min-w-0 flex-1 truncate text-left text-[12px] text-foreground/88",children:fc}),F&&n.jsx("span",{className:"shrink-0 text-[12px] text-muted-foreground",children:F}),D.length>0&&n.jsx(vs,{size:12,className:te("shrink-0 text-muted-foreground transition-transform",b&&"rotate-180")})]}),b&&D.length>0&&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.jsx("div",{className:"px-2 pt-2 pb-1",children:n.jsx("input",{type:"text",value:w,onChange:V=>k(V.target.value),placeholder:"Search pages...",className:"w-full rounded-md border border-input bg-transparent px-2.5 py-1.5 text-xs outline-none placeholder:text-muted-foreground focus:ring-1 focus:ring-ring",autoFocus:!0})}),n.jsx(Nn,{className:"max-h-[60vh]",children:n.jsxs("div",{className:"p-1.5",children:[D.filter(V=>{if(!w)return!0;const fe=w.toLowerCase();return V.name.toLowerCase().includes(fe)||V.path.toLowerCase().includes(fe)}).map(V=>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",onClick:()=>{S(!1),k(""),R(V.path);const fe=c.current;fe&&y&&(fe.src=new URL(V.path,y).href)},children:[n.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:V.name}),n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:V.path})]},V.key)),w&&D.every(V=>{const fe=w.toLowerCase();return!V.name.toLowerCase().includes(fe)&&!V.path.toLowerCase().includes(fe)})&&n.jsxs("div",{className:"px-3 py-4 text-center text-xs text-muted-foreground",children:['No pages match "',w,'"']})]})})]})]})]}),n.jsxs("div",{className:te("flex shrink-0 items-center gap-0.5",o==="code"&&"hidden"),children:[n.jsxs(je,{children:[n.jsx(ke,{asChild:!0,children:n.jsx(se,{variant:"ghost",size:"icon",onClick:()=>{let V=ue.previewUrl;if(V&&P&&P!=="/")try{const fe=new URL(V);fe.pathname=P,V=fe.href}catch{}window.open(V,"_blank","noopener")},children:n.jsx(gs,{size:14})})}),n.jsx(Ne,{side:"bottom",children:"Open in new tab"})]}),n.jsxs(Js,{children:[n.jsx(Zs,{asChild:!0,children:n.jsx(se,{variant:"ghost",size:"icon",children:n.jsx(ja,{size:14})})}),n.jsxs(Qs,{align:"end",children:[n.jsx(Dt,{onClick:dc,children:"Hard Reload"}),n.jsx(Dt,{onClick:uc,children:"Copy Current URL"})]})]})]})]}),n.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[d&&y&&i&&N&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"shrink-0 border-r overflow-hidden",style:{width:m},children:n.jsx(A.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(Be,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(lv,{orgSlug:C.slug,virtualMcpId:N,branch:i,currentPath:P,externalSelectedIndex:u,onSaved:()=>{setTimeout(()=>{const V=c.current;if(!V)return;const fe=document.activeElement,Ke=V.tabIndex;V.tabIndex=-1,V.style.pointerEvents="none",V.blur();try{V.contentWindow?.location.reload()}catch{V.src=V.src}const tt=()=>{V.tabIndex=Ke,V.style.pointerEvents="",fe?.focus(),V.removeEventListener("load",tt)};V.addEventListener("load",tt),setTimeout(tt,3e3)},hv)}})})}),n.jsx("div",{className:"w-1 shrink-0 cursor-col-resize bg-transparent hover:bg-border transition-colors",onPointerDown:V=>{p.current=!0,g.current=V.clientX,v.current=m,V.currentTarget.setPointerCapture(V.pointerId)},onPointerMove:V=>{if(!p.current)return;const fe=V.clientX-g.current;_(Math.max(240,Math.min(640,v.current+fe)))},onPointerUp:()=>{p.current=!1}})]}),n.jsxs("div",{className:"flex-1 relative overflow-hidden",children:[ue.kind==="never-started"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(Rs,{kind:"never-started",onStart:()=>{Xi(!1),pe("auto-start")}})}),ue.kind==="starting-now"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(Rs,{kind:"starting-now",progress:ae,claimPhase:ee})}),ue.kind==="errored"&&n.jsx("div",{className:"absolute inset-0 z-40",children:n.jsx(Rs,{kind:"errored",progress:ae,logSource:"setup",errorLine:ue.error.split(`
|
|
286
|
+
`)[0]??"Failed to start",onRetry:le,drawerOpen:On})}),ue.kind==="suspended"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(Rs,{kind:"suspended",onResume:le})}),ue.kind==="crashed"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(Rs,{kind:"crashed",onOpenTerminal:$n})}),ue.kind==="no-html"&&n.jsxs("div",{className:"absolute inset-0 z-30 flex flex-col items-center justify-center gap-4 bg-background",children:[n.jsx(Zn,{size:48,className:"text-muted-foreground/40"}),n.jsx("h3",{className:"text-lg font-medium",children:"No web page at this URL"}),n.jsx("p",{className:"text-sm text-muted-foreground text-center max-w-sm",children:"The server is running, but doesn't serve a web page at /. This preview only renders web pages."}),n.jsxs(se,{onClick:$n,children:[n.jsx(Zn,{size:14}),"View Logs"]})]}),o==="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(Qn,{size:12}),"Click any element to ask the AI"]}),o==="visual"&&l&&n.jsx(nm,{element:l,onDismiss:()=>h(null)}),o==="code"&&ue.kind==="iframe"&&N&&i&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(A.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(Be,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(cv,{orgSlug:C.slug,virtualMcpId:N,branch:i})})}),ue.kind==="iframe"&&n.jsx("iframe",{ref:c,src:ue.previewUrl,className:te("w-full h-full border-0",o==="code"&&"invisible"),title:"Dev Server Preview",tabIndex:d?-1:void 0,onLoad:()=>{be("vm_preview_loaded",{view_mode:o,vm_id:T?.vmId??null});try{const V=c.current?.contentWindow?.location?.pathname;V&&R(V)}catch{}o==="visual"&&Fn(),o==="cms"&&Hn()}},ue.previewUrl)]})]}),n.jsx(rv,{vmId:T?.vmId??null,orgSlug:C.slug,virtualMcpId:N,branch:i,status:dv(ue,q),scripts:H.scripts,open:On,onOpenChange:Xi,onStart:()=>pe("auto-start"),onStop:zn,onRestart:oc,onResume:le,onRetry:le},T?.vmId??"no-vm")]})}function fv(t){const e=z.c(2),{virtualMcpId:s}=t,i=Pt(s);if(!(i?Zt(i):null)){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(dn,{size:24,className:"text-muted-foreground/60"}),n.jsx("div",{children:"No repository connected."}),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(uv,{}),e[1]=o):o=e[1],o}function mv({inputSchema:t,value:e,onChange:s}){const i=t?.properties,r=t?.required??[],o=!!i&&Object.keys(i).length>0;if(!t||!o&&Object.keys(t).length===0)return n.jsx("div",{className:"text-sm text-muted-foreground italic",children:"No arguments defined in schema."});if(!o)return n.jsx(vv,{value:e,onChange:s});const a=(l,h)=>{if(h===void 0){const{[l]:c,...d}=e;s(d);return}s({...e,[l]:h})};return n.jsxs("div",{className:"space-y-4",children:[r.length>0&&n.jsxs("div",{className:"text-xs text-muted-foreground",children:[n.jsx("span",{className:"text-red-500",children:"*"})," Required"]}),Object.entries(i).map(([l,h])=>{const c=r.includes(l),d=Array.isArray(h.type)?h.type[0]:h.type;return n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("label",{htmlFor:`tool-param-${l}`,className:"text-sm font-medium leading-none flex items-center gap-1.5",children:[l,c&&n.jsx("span",{className:"text-red-500 text-xs",children:"*"})]}),d&&n.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:d})]}),h.description&&n.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:h.description}),n.jsx(_v,{id:`tool-param-${l}`,propKey:l,prop:h,type:d,value:e[l],onChange:u=>a(l,u)})]},l)})]})}function _v(t){const e=z.c(52),{id:s,propKey:i,prop:r,type:o,value:a,onChange:l}=t;if(r.enum&&r.enum.length>0){let f;e[0]!==r.enum?(f=new Map(r.enum.map(gv)),e[0]=r.enum,e[1]=f):f=e[1];const m=f,_=a!==void 0?String(a):"";let p;e[2]!==m||e[3]!==l?(p=k=>l(m.get(k)??k),e[2]=m,e[3]=l,e[4]=p):p=e[4];const g=`Select ${i}…`;let v;e[5]!==g?(v=n.jsx(pt,{placeholder:g}),e[5]=g,e[6]=v):v=e[6];let x;e[7]!==s||e[8]!==v?(x=n.jsx(_t,{id:s,children:v}),e[7]=s,e[8]=v,e[9]=x):x=e[9];let b;e[10]!==r.enum?(b=r.enum.map(pv),e[10]=r.enum,e[11]=b):b=e[11];let S;e[12]!==b?(S=n.jsx(gt,{children:b}),e[12]=b,e[13]=S):S=e[13];let w;return e[14]!==_||e[15]!==p||e[16]!==x||e[17]!==S?(w=n.jsxs(mt,{value:_,onValueChange:p,children:[x,S]}),e[14]=_,e[15]=p,e[16]=x,e[17]=S,e[18]=w):w=e[18],w}if(o==="boolean"){const f=a===void 0?"":String(a);let m;e[19]!==l?(m=x=>l(x==="true"),e[19]=l,e[20]=m):m=e[20];let _;e[21]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx(pt,{placeholder:"Select true or false…"}),e[21]=_):_=e[21];let p;e[22]!==s?(p=n.jsx(_t,{id:s,children:_}),e[22]=s,e[23]=p):p=e[23];let g;e[24]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsxs(gt,{children:[n.jsx(Ye,{value:"true",children:"true"}),n.jsx(Ye,{value:"false",children:"false"})]}),e[24]=g):g=e[24];let v;return e[25]!==f||e[26]!==m||e[27]!==p?(v=n.jsxs(mt,{value:f,onValueChange:m,children:[p,g]}),e[25]=f,e[26]=m,e[27]=p,e[28]=v):v=e[28],v}if(o==="number"||o==="integer"){const f=a===void 0?"":a;let m;e[29]!==l?(m=g=>{const v=g.currentTarget.value;if(v==="")return l(void 0);const x=Number(v);l(Number.isFinite(x)?x:v)},e[29]=l,e[30]=m):m=e[30];const _=`Enter ${i}…`;let p;return e[31]!==s||e[32]!==f||e[33]!==m||e[34]!==_?(p=n.jsx(ot,{id:s,type:"number",value:f,onChange:m,placeholder:_}),e[31]=s,e[32]=f,e[33]=m,e[34]=_,e[35]=p):p=e[35],p}if(o==="object"||o==="array"){let f;e[36]!==a?(f=typeof a=="string"?a:a===void 0?"":JSON.stringify(a,null,2),e[36]=a,e[37]=f):f=e[37];const m=f;let _;e[38]!==l?(_=v=>{const x=v.currentTarget.value;if(x.trim()==="")return l(void 0);try{l(JSON.parse(x))}catch{l(x)}},e[38]=l,e[39]=_):_=e[39];const p=`Enter ${i} as JSON…`;let g;return e[40]!==s||e[41]!==_||e[42]!==p||e[43]!==m?(g=n.jsx(Ws,{id:s,className:"font-mono text-xs",value:m,rows:4,spellCheck:!1,onChange:_,placeholder:p}),e[40]=s,e[41]=_,e[42]=p,e[43]=m,e[44]=g):g=e[44],g}const h=a===void 0?"":a;let c;e[45]!==l?(c=f=>{const m=f.currentTarget.value;l(m===""?void 0:m)},e[45]=l,e[46]=c):c=e[46];const d=`Enter ${i}…`;let u;return e[47]!==s||e[48]!==h||e[49]!==c||e[50]!==d?(u=n.jsx(ot,{id:s,value:h,onChange:c,placeholder:d}),e[47]=s,e[48]=h,e[49]=c,e[50]=d,e[51]=u):u=e[51],u}function pv(t){const e=String(t);return n.jsx(Ye,{value:e,children:e},e)}function gv(t){return[String(t),t]}function vv({value:t,onChange:e}){const[s,i]=A.useState(()=>Object.keys(t).length===0?"{}":JSON.stringify(t,null,2));return n.jsxs("div",{className:"space-y-2",children:[n.jsx("label",{htmlFor:"tool-raw-json",className:"text-sm font-medium leading-none",children:"Raw JSON Input"}),n.jsx(Ws,{id:"tool-raw-json",className:"font-mono text-xs min-h-[120px]",value:s,spellCheck:!1,onChange:r=>{const o=r.currentTarget.value;i(o);const a=o.trim();if(a===""){e({});return}try{const l=JSON.parse(a);l&&typeof l=="object"&&!Array.isArray(l)&&e(l)}catch{}},placeholder:'e.g. { "foo": "bar" }'})]})}function xv(t){const e=z.c(22),{value:s,onChange:i}=t,r=Ys();let o,a;e[0]!==r||e[1]!==s.connectionId?(a=r.filter(bv),o=a.find(p=>p.id===s.connectionId)??null,e[0]=r,e[1]=s.connectionId,e[2]=o,e[3]=a):(o=e[2],a=e[3]);const l=o;let h;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Je,{children:"Connection"}),e[4]=h):h=e[4];let c;e[5]!==i||e[6]!==s?(c=p=>{p.id!==s.connectionId&&i({...s,connectionId:p.id,toolName:"",input:{}})},e[5]=i,e[6]=s,e[7]=c):c=e[7];let d;e[8]!==l||e[9]!==c||e[10]!==a?(d=n.jsxs("div",{className:"flex flex-col gap-1.5",children:[h,n.jsx(Sv,{connections:a,selected:l,onSelect:c})]}),e[8]=l,e[9]=c,e[10]=a,e[11]=d):d=e[11];let u;e[12]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(Je,{children:"Tool"}),e[12]=u):u=e[12];let f,m;e[13]!==i||e[14]!==l||e[15]!==s?(f=n.jsxs("div",{className:"flex flex-col gap-1.5",children:[u,l?n.jsx(yv,{connection:l,selectedToolName:s.toolName,onSelect:p=>{p.name!==s.toolName&&i({...s,toolName:p.name,input:{}})}}):n.jsxs(se,{variant:"outline",size:"sm",disabled:!0,className:"h-9 justify-start gap-2 px-3 text-sm font-normal text-muted-foreground",children:[n.jsx(fn,{className:"size-4"}),"Pick a connection first"]})]}),m=l&&s.toolName?n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsx(Je,{children:"Input"}),n.jsx("div",{className:"rounded-md border border-border p-3",children:n.jsx(wv,{connection:l,toolName:s.toolName,input:s.input,onChange:p=>i({...s,input:p})},`${l.id}:${s.toolName}`)})]}):null,e[13]=i,e[14]=l,e[15]=s,e[16]=f,e[17]=m):(f=e[16],m=e[17]);let _;return e[18]!==d||e[19]!==f||e[20]!==m?(_=n.jsxs("div",{className:"flex flex-col gap-4",children:[d,f,m]}),e[18]=d,e[19]=f,e[20]=m,e[21]=_):_=e[21],_}function bv(t){return t.id!==Ft}function Sv(t){const e=z.c(20),{connections:s,selected:i,onSelect:r}=t,[o,a]=A.useState(!1);let l;e[0]!==i?(l=n.jsx("span",{className:"flex min-w-0 items-center gap-2",children:i?n.jsxs(n.Fragment,{children:[n.jsx(Ct,{icon:i.icon,name:i.title,size:"2xs"}),n.jsx("span",{className:"truncate",children:i.title})]}):n.jsx("span",{className:"text-muted-foreground",children:"Pick a connection"})}),e[0]=i,e[1]=l):l=e[1];let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(vs,{className:"size-4 shrink-0 opacity-50"}),e[2]=h):h=e[2];let c;e[3]!==l?(c=n.jsx(Wt,{asChild:!0,children:n.jsxs(se,{variant:"outline",size:"sm",className:"h-9 justify-between gap-2 px-3 text-sm font-normal",children:[l,h]})}),e[3]=l,e[4]=c):c=e[4];let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(_n,{placeholder:"Search connections…"}),e[5]=d):d=e[5];let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(pn,{children:"No connections found."}),e[6]=u):u=e[6];let f;if(e[7]!==s||e[8]!==r||e[9]!==i?.id){let p;e[11]!==r||e[12]!==i?.id?(p=g=>n.jsxs(Ti,{value:`${g.title} ${g.description??""} ${g.id}`,onSelect:()=>{r(g),a(!1)},className:"flex items-start gap-2.5",children:[n.jsx(Ct,{icon:g.icon,name:g.title,size:"xs"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("div",{className:"text-sm truncate",children:g.title}),g.description&&n.jsx("div",{className:"text-xs text-muted-foreground line-clamp-2",children:g.description})]}),n.jsx(ps,{className:te("size-4 shrink-0 mt-0.5",i?.id===g.id?"opacity-100":"opacity-0")})]},g.id),e[11]=r,e[12]=i?.id,e[13]=p):p=e[13],f=s.map(p),e[7]=s,e[8]=r,e[9]=i?.id,e[10]=f}else f=e[10];let m;e[14]!==f?(m=n.jsx(Ut,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:n.jsxs(vn,{children:[d,n.jsxs(gn,{children:[u,n.jsx(Ei,{children:f})]})]})}),e[14]=f,e[15]=m):m=e[15];let _;return e[16]!==o||e[17]!==c||e[18]!==m?(_=n.jsxs(Vt,{open:o,onOpenChange:a,children:[c,m]}),e[16]=o,e[17]=c,e[18]=m,e[19]=_):_=e[19],_}function yv(t){const e=z.c(41),{connection:s,selectedToolName:i,onSelect:r}=t,{org:o}=ge();let a;e[0]!==s.id||e[1]!==o.id||e[2]!==o.slug?(a={connectionId:s.id,orgId:o.id,orgSlug:o.slug},e[0]=s.id,e[1]=o.id,e[2]=o.slug,e[3]=a):a=e[3];const l=Ue(a);let h;e[4]!==l?(h={client:l},e[4]=l,e[5]=h):h=e[5];const{data:c,isLoading:d,error:u}=Ga(h);let f;e[6]!==c?.tools?(f=c?.tools??[],e[6]=c?.tools,e[7]=f):f=e[7];const m=f;let _;e[8]!==i||e[9]!==m?(_=m.find(M=>M.name===i)??null,e[8]=i,e[9]=m,e[10]=_):_=e[10];const p=_,[g,v]=A.useState(!1);let x;e:{if(p){x=p.name;break e}if(u){x=`Failed to load tools: ${u.message}`;break e}if(d){x="Loading tools…";break e}if(m.length===0){x="No tools available";break e}x="Pick a tool"}const b=x,S=d||!!u||m.length===0;let w;e[11]!==s.icon||e[12]!==s.title?(w=n.jsx(Ct,{icon:s.icon,name:s.title,size:"2xs"}),e[11]=s.icon,e[12]=s.title,e[13]=w):w=e[13];const k=!p&&"text-muted-foreground font-sans";let E;e[14]!==k?(E=te("truncate font-mono text-xs",k),e[14]=k,e[15]=E):E=e[15];let P;e[16]!==E||e[17]!==b?(P=n.jsx("span",{className:E,children:b}),e[16]=E,e[17]=b,e[18]=P):P=e[18];let R;e[19]!==w||e[20]!==P?(R=n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[w,P]}),e[19]=w,e[20]=P,e[21]=R):R=e[21];let B;e[22]===Symbol.for("react.memo_cache_sentinel")?(B=n.jsx(vs,{className:"size-4 shrink-0 opacity-50"}),e[22]=B):B=e[22];let I;e[23]!==S||e[24]!==R?(I=n.jsx(Wt,{asChild:!0,children:n.jsxs(se,{variant:"outline",size:"sm",disabled:S,className:"h-9 justify-between gap-2 px-3 text-sm font-normal",children:[R,B]})}),e[23]=S,e[24]=R,e[25]=I):I=e[25];let T;e[26]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsx(_n,{placeholder:"Search tools…"}),e[26]=T):T=e[26];let y;e[27]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(pn,{children:"No tools found."}),e[27]=y):y=e[27];let N;if(e[28]!==r||e[29]!==i||e[30]!==m){let M;e[32]!==r||e[33]!==i?(M=D=>n.jsxs(Ti,{value:`${D.name} ${D.description??""}`,onSelect:()=>{r(D),v(!1)},className:"flex items-start gap-2.5",children:[n.jsx(fn,{className:"size-4 mt-0.5 text-muted-foreground shrink-0"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("div",{className:"text-sm font-mono truncate",children:D.name}),D.description&&n.jsx("div",{className:"text-xs text-muted-foreground line-clamp-2",children:D.description})]}),n.jsx(ps,{className:te("size-4 shrink-0 mt-0.5",i===D.name?"opacity-100":"opacity-0")})]},D.name),e[32]=r,e[33]=i,e[34]=M):M=e[34],N=m.map(M),e[28]=r,e[29]=i,e[30]=m,e[31]=N}else N=e[31];let C;e[35]!==N?(C=n.jsx(Ut,{className:"w-[min(480px,calc(100vw-2rem))] p-0",align:"start",children:n.jsxs(vn,{children:[T,n.jsxs(gn,{children:[y,n.jsx(Ei,{children:N})]})]})}),e[35]=N,e[36]=C):C=e[36];let j;return e[37]!==g||e[38]!==I||e[39]!==C?(j=n.jsxs(Vt,{open:g,onOpenChange:v,children:[I,C]}),e[37]=g,e[38]=I,e[39]=C,e[40]=j):j=e[40],j}function wv(t){const e=z.c(18),{connection:s,toolName:i,input:r,onChange:o}=t,{org:a}=ge();let l;e[0]!==s.id||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s.id,orgId:a.id,orgSlug:a.slug},e[0]=s.id,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const h=Ue(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:d,isLoading:u,error:f}=Ga(c);let m;e[6]!==d?.tools||e[7]!==i?(m=d?.tools?.find(g=>g.name===i)??null,e[6]=d?.tools,e[7]=i,e[8]=m):m=e[8];const _=m;if(u){let g;return e[9]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("div",{className:"text-sm text-muted-foreground italic",children:"Loading tool schema…"}),e[9]=g):g=e[9],g}if(f){let g;return e[10]!==f.message?(g=n.jsxs("div",{className:"text-sm text-destructive",children:["Failed to load tool schema: ",f.message]}),e[10]=f.message,e[11]=g):g=e[11],g}if(!_){let g;return e[12]!==i?(g=n.jsxs("div",{className:"text-sm text-muted-foreground italic",children:["Tool ",i," not found on this connection."]}),e[12]=i,e[13]=g):g=e[13],g}let p;return e[14]!==r||e[15]!==o||e[16]!==_.inputSchema?(p=n.jsx(mv,{inputSchema:_.inputSchema,value:r,onChange:o}),e[14]=r,e[15]=o,e[16]=_.inputSchema,e[17]=p):p=e[17],p}function Fs(t){const e=t.trim().split(/\s+/);return e.length!==5?!1:e.every(s=>/^[\d*/,-]+$/.test(s))}function Cv(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 kv(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 Nv(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 jv(t,e){return e===1?{minutes:"minute",hours:"hour",days:"day",weeks:"week"}[t]??t:t}const Ev=[{label:"5 minutes",cron:"*/5 * * * *"},{label:"Hour",cron:"0 * * * *"},{label:"Day",cron:"0 0 * * *"},{label:"Week",cron:"0 0 * * 1"}];function Tv(t){const e=z.c(33),{automationId:s,open:i,onOpenChange:r,onCustomSelect:o,onEventSelect:a}=t,{triggerAdd:l}=ei(),[h,c]=A.useState(!1),d=i??h;let u;e[0]!==r?(u=I=>{r?r(I):c(I)},e[0]=r,e[1]=u):u=e[1];const f=u;let m;e[2]!==l||e[3]!==s||e[4]!==f?(m=async I=>{try{await l.mutateAsync({automation_id:s,type:"cron",cron_expression:I}),he.success("Starter added"),f(!1)}catch(T){const y=T,N=y instanceof Error?y.message:"Failed to add starter";he.error(N)}},e[2]=l,e[3]=s,e[4]=f,e[5]=m):m=e[5];const _=m;let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(Zs,{asChild:!0,children:n.jsxs(se,{variant:"outline",size:"sm",children:[n.jsx(es,{size:14}),"Add Starter"]})}),e[6]=p):p=e[6];let g;e[7]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsxs(nd,{className:"gap-2.5",children:[n.jsx(Os,{size:14,className:"text-muted-foreground shrink-0"}),"Every..."]}),e[7]=g):g=e[7];let v;e[8]!==l||e[9]!==_?(v=Ev.map(I=>n.jsxs(Dt,{className:"gap-2.5",onSelect:()=>_(I.cron),disabled:l.isPending,children:[n.jsx(Os,{size:14,className:"text-muted-foreground shrink-0"}),"Every ",I.label]},I.cron)),e[8]=l,e[9]=_,e[10]=v):v=e[10];let x;e[11]!==v?(x=n.jsxs(od,{children:[g,n.jsx(ad,{className:"w-[160px]",children:v})]}),e[11]=v,e[12]=x):x=e[12];let b;e[13]!==f||e[14]!==o?(b=()=>{f(!1),o?.()},e[13]=f,e[14]=o,e[15]=b):b=e[15];let S;e[16]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(Os,{size:14,className:"text-muted-foreground shrink-0"}),e[16]=S):S=e[16];let w;e[17]!==b?(w=n.jsxs(Dt,{className:"gap-2.5",onSelect:b,children:[S,"Custom (cron)"]}),e[17]=b,e[18]=w):w=e[18];let k;e[19]!==f||e[20]!==a?(k=()=>{f(!1),a?.()},e[19]=f,e[20]=a,e[21]=k):k=e[21];let E;e[22]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx(Us,{size:14,className:"text-muted-foreground shrink-0"}),e[22]=E):E=e[22];let P;e[23]!==k?(P=n.jsxs(Dt,{className:"gap-2.5",onSelect:k,children:[E,"Event"]}),e[23]=k,e[24]=P):P=e[24];let R;e[25]!==P||e[26]!==x||e[27]!==w?(R=n.jsxs(Qs,{align:"end",className:"w-[200px]",children:[x,w,P]}),e[25]=P,e[26]=x,e[27]=w,e[28]=R):R=e[28];let B;return e[29]!==f||e[30]!==d||e[31]!==R?(B=n.jsxs(Js,{open:d,onOpenChange:f,children:[p,R]}),e[29]=f,e[30]=d,e[31]=R,e[32]=B):B=e[32],B}function Rv(t){const e=z.c(60),{trigger:s,automationId:i,connectionName:r}=t,{triggerAdd:o,triggerRemove:a}=ei(),[l,h]=A.useState(!1);let c;e[0]!==s.cron_expression?(c=s.cron_expression?Nv(s.cron_expression):null,e[0]=s.cron_expression,e[1]=c):c=e[1];const d=c,[u,f]=A.useState(d?.count??1),[m,_]=A.useState(!1),[p,g]=A.useState(s.cron_expression??""),v=a.isPending||o.isPending,x=s.type==="cron";let b;e[2]!==i||e[3]!==a||e[4]!==s.id?(b=async()=>{try{await a.mutateAsync({trigger_id:s.id,automation_id:i}),he.success("Starter removed")}catch{he.error("Failed to remove starter")}h(!1)},e[2]=i,e[3]=a,e[4]=s.id,e[5]=b):b=e[5];const S=b;let w;e[6]!==o||e[7]!==i||e[8]!==p||e[9]!==a||e[10]!==s.cron_expression||e[11]!==s.id?(w=async()=>{const O=p.trim();if(!O||!Fs(O)||O===s.cron_expression){_(!1),g(s.cron_expression??"");return}try{await o.mutateAsync({automation_id:i,type:"cron",cron_expression:O}),await a.mutateAsync({trigger_id:s.id,automation_id:i}),_(!1)}catch{he.error("Failed to update starter"),g(s.cron_expression??""),_(!1)}},e[6]=o,e[7]=i,e[8]=p,e[9]=a,e[10]=s.cron_expression,e[11]=s.id,e[12]=w):w=e[12];const k=w;let E;e[13]!==o||e[14]!==i||e[15]!==d||e[16]!==a||e[17]!==s.cron_expression||e[18]!==s.id?(E=async O=>{if(!d)return;const $=d.unit==="minutes"?5:1,W=Math.max($,O);W!==O&&f(W);const K=kv(W,d.unit);if(K!==s.cron_expression)try{await o.mutateAsync({automation_id:i,type:"cron",cron_expression:K}),await a.mutateAsync({trigger_id:s.id,automation_id:i})}catch{he.error("Failed to update starter"),f(d.count)}},e[13]=o,e[14]=i,e[15]=d,e[16]=a,e[17]=s.cron_expression,e[18]=s.id,e[19]=E):E=e[19];const P=E;let R;e[20]!==x?(R=x?n.jsx(Os,{size:14,className:"text-muted-foreground shrink-0"}):n.jsx(Us,{size:14,className:"text-muted-foreground shrink-0"}),e[20]=x,e[21]=R):R=e[21];let B;e[22]!==r||e[23]!==u||e[24]!==p||e[25]!==P||e[26]!==k||e[27]!==d||e[28]!==x||e[29]!==m||e[30]!==v||e[31]!==s.cron_expression||e[32]!==s.event_type||e[33]!==s.params?(B=d&&x?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-sm text-muted-foreground",children:"Every"}),n.jsx("input",{type:"number",min:d.unit==="minutes"?5:1,value:u,onChange:O=>f(parseInt(O.target.value)||1),onBlur:()=>P(u),onKeyDown:O=>{O.key==="Enter"&&O.target.blur(),O.key==="Escape"&&f(d.count)},disabled:v,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:jv(d.unit,u)})]}):x&&m?n.jsxs(n.Fragment,{children:[n.jsx("input",{type:"text",value:p,onChange:O=>g(O.target.value),onBlur:k,onKeyDown:O=>{O.key==="Enter"&&O.target.blur(),O.key==="Escape"&&(_(!1),g(s.cron_expression??""))},className:"flex-1 text-sm font-mono bg-transparent outline-none",autoFocus:!0}),p&&!Fs(p)&&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:x?Cv(s.cron_expression??""):`${s.event_type}${r?` · ${r}`:""}`}),!x&&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(Dv).join(", ")})]}),e[22]=r,e[23]=u,e[24]=p,e[25]=P,e[26]=k,e[27]=d,e[28]=x,e[29]=m,e[30]=v,e[31]=s.cron_expression,e[32]=s.event_type,e[33]=s.params,e[34]=B):B=e[34];let I;e[35]!==v?(I=v&&n.jsx(Be,{size:13,className:"animate-spin text-muted-foreground"}),e[35]=v,e[36]=I):I=e[36];let T;e[37]!==d||e[38]!==x||e[39]!==m||e[40]!==s.cron_expression?(T=x&&!d&&!m&&n.jsx(se,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{g(s.cron_expression??""),_(!0)},children:n.jsx(zh,{size:13,className:"text-muted-foreground"})}),e[37]=d,e[38]=x,e[39]=m,e[40]=s.cron_expression,e[41]=T):T=e[41];let y;e[42]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(se,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>h(!0),children:n.jsx(fs,{size:13,className:"text-muted-foreground"})}),e[42]=y):y=e[42];let N;e[43]!==I||e[44]!==T?(N=n.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[I,T,y]}),e[43]=I,e[44]=T,e[45]=N):N=e[45];let C;e[46]!==N||e[47]!==R||e[48]!==B?(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:[R,B,N]}),e[46]=N,e[47]=R,e[48]=B,e[49]=C):C=e[49];let j;e[50]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsxs($a,{children:[n.jsx(za,{children:"Remove Starter"}),n.jsx(Fa,{children:"Are you sure you want to remove this starter?"})]}),e[50]=j):j=e[50];let M;e[51]===Symbol.for("react.memo_cache_sentinel")?(M=n.jsx(Wa,{children:"Cancel"}),e[51]=M):M=e[51];let D;e[52]!==S?(D=n.jsxs(Oa,{children:[j,n.jsxs(Ha,{children:[M,n.jsx(Ua,{onClick:S,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]}),e[52]=S,e[53]=D):D=e[53];let F;e[54]!==l||e[55]!==D?(F=n.jsx(La,{open:l,onOpenChange:h,children:D}),e[54]=l,e[55]=D,e[56]=F):F=e[56];let H;return e[57]!==C||e[58]!==F?(H=n.jsxs(n.Fragment,{children:[C,F]}),e[57]=C,e[58]=F,e[59]=H):H=e[59],H}function Dv(t){const[e,s]=t;return`${e}: ${s}`}function Pv(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 Iv(t){const e=z.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=Ys(r),[a,l]=A.useState(),[h,c]=A.useState();let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d={},e[1]=d):d=e[1];const[u,f]=A.useState(d),{triggerAdd:m}=ei(),{data:_,isLoading:p}=hd(a);let g,v,x,b,S,w;if(e[2]!==m||e[3]!==s||e[4]!==a||e[5]!==h||e[6]!==p||e[7]!==i||e[8]!==u||e[9]!==o||e[10]!==_){const P=_?.find(D=>D.type===h);let R;e[17]!==m||e[18]!==s||e[19]!==a||e[20]!==h||e[21]!==i||e[22]!==u?(R=async()=>{if(!(!a||!h))try{await m.mutateAsync({automation_id:s,type:"event",event_type:h,connection_id:a,params:u}),be("automation_trigger_added",{automation_id:s,trigger_type:"event",connection_id:a,event_type:h}),he.success("Event trigger added"),i()}catch{he.error("Failed to add event trigger")}},e[17]=m,e[18]=s,e[19]=a,e[20]=h,e[21]=i,e[22]=u,e[23]=R):R=e[23],g=R,v="flex flex-col gap-3 px-3 py-3 rounded-lg border border-border bg-background";let B,I;e[24]===Symbol.for("react.memo_cache_sentinel")?(I=n.jsx(Us,{size:14,className:"text-muted-foreground shrink-0"}),B=n.jsx("span",{className:"text-sm font-medium",children:"Event trigger"}),e[24]=B,e[25]=I):(B=e[24],I=e[25]);let T;e[26]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsx(fs,{size:13}),e[26]=T):T=e[26],e[27]!==i?(x=n.jsxs("div",{className:"flex items-center gap-2",children:[I,B,n.jsx("button",{type:"button",className:"ml-auto shrink-0 p-0.5 rounded text-muted-foreground hover:text-foreground",onClick:i,children:T})]}),e[27]=i,e[28]=x):x=e[28];const y=a??"";let N;e[29]===Symbol.for("react.memo_cache_sentinel")?(N=D=>{l(D),c(void 0),f({})},e[29]=N):N=e[29];let C;e[30]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx(_t,{className:"w-full",children:n.jsx(pt,{placeholder:"Select connection..."})}),e[30]=C):C=e[30];let j;e[31]!==o?(j=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(Bv),e[31]=o,e[32]=j):j=e[32];let M;e[33]!==j?(M=n.jsx(gt,{children:j}),e[33]=j,e[34]=M):M=e[34],e[35]!==y||e[36]!==M?(b=n.jsxs(mt,{value:y,onValueChange:N,children:[C,M]}),e[35]=y,e[36]=M,e[37]=b):b=e[37],e[38]!==a||e[39]!==h||e[40]!==p||e[41]!==_?(S=a&&n.jsxs(mt,{value:h??"",onValueChange:D=>{c(D),f({})},children:[n.jsx(_t,{className:"w-full",children:p?n.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[n.jsx(Be,{size:13,className:"animate-spin"}),"Loading events..."]}):n.jsx(pt,{placeholder:"Select event type...",children:h??"Select event type..."})}),n.jsx(gt,{children:_?.map(Av)})]}),e[38]=a,e[39]=h,e[40]=p,e[41]=_,e[42]=S):S=e[42],w=P?.paramsSchema&&Object.keys(P.paramsSchema).length>0&&n.jsx("div",{className:"flex flex-col gap-2",children:Object.entries(P.paramsSchema).map(D=>{const[F,H]=D;return n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsxs("label",{className:"text-xs text-muted-foreground",children:[F,H.description&&n.jsxs("span",{className:"text-muted-foreground/60",children:[" ","— ",H.description]})]}),H.enum?n.jsxs(mt,{value:u[F]??"",onValueChange:O=>f($=>({...$,[F]:O})),children:[n.jsx(_t,{className:"w-full",children:n.jsx(pt,{placeholder:`Select ${F}...`})}),n.jsx(gt,{children:H.enum.map(Mv)})]}):n.jsx("input",{type:"text",value:u[F]??"",onChange:O=>f($=>({...$,[F]:O.target.value})),placeholder:H.description??F,className:"text-sm border border-border rounded-md bg-background px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-ring"})]},F)})}),e[2]=m,e[3]=s,e[4]=a,e[5]=h,e[6]=p,e[7]=i,e[8]=u,e[9]=o,e[10]=_,e[11]=g,e[12]=v,e[13]=x,e[14]=b,e[15]=S,e[16]=w}else g=e[11],v=e[12],x=e[13],b=e[14],S=e[15],w=e[16];let k;e[43]!==m||e[44]!==a||e[45]!==h||e[46]!==g?(k=a&&h&&n.jsx(se,{size:"sm",onClick:g,disabled:m.isPending,children:m.isPending?n.jsx(Be,{size:13,className:"animate-spin"}):"Add trigger"}),e[43]=m,e[44]=a,e[45]=h,e[46]=g,e[47]=k):k=e[47];let E;return e[48]!==v||e[49]!==x||e[50]!==b||e[51]!==S||e[52]!==w||e[53]!==k?(E=n.jsxs("div",{className:v,children:[x,b,S,w,k]}),e[48]=v,e[49]=x,e[50]=b,e[51]=S,e[52]=w,e[53]=k,e[54]=E):E=e[54],E}function Mv(t){return n.jsx(Ye,{value:t,children:t},t)}function Av(t){return n.jsx(Ye,{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 Bv(t){return n.jsx(Ye,{value:t.id,children:t.title},t.id)}function Lv({automationId:t,automation:e,onBack:s,onDelete:i}){const r=e.virtual_mcp_id,{org:o}=ge(),{update:a,triggerAdd:l,run:h}=ei(),c=Ys(),d=new Map(c.map(ne=>[ne.id,ne.title])),{createTaskWithMessage:u}=Ht(),{setSimpleModeTier:f}=hn(),{setChatOpen:m}=Sn(),{sendMessage:_}=rs(),p=Ia(),[g,v]=wc(),x=e.messages?.[0]?.metadata?.tiptapDoc??void 0,[b,S]=A.useState(x),[w,k]=A.useState(!1),[E,P]=A.useState(!1),[R,B]=A.useState(""),[I,T]=A.useState(!1),[y,N]=A.useState(!1),[C,j]=A.useState(!1),[M,D]=A.useState(!1),[F,H]=A.useState(()=>({connectionId:e.connection_id??"",toolName:e.tool_name??"",input:e.tool_input??{}})),O=async()=>{if(y)return;const le=Vn(b).filter(De=>De.type==="text").map(De=>De.text).join(`
|
|
287
|
+
`);if(le.trim()){N(!0);try{pe(),be("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:le.length}),await p(["studio-automation-manager"]),m(!0),await _({tiptapDoc:tl({managerAgentId:Sa.AUTOMATION_MANAGER(o.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:le})})}finally{N(!1)}}},$=e.models?.tier??"smart",W=pa({defaultValues:{name:e.name,active:e.active,tier:$}}),K=W.watch("active"),[re,Z]=A.useReducer(Pv,null),J=()=>{re!==null&&(be("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(re.fields),save_count:re.saveCount,edit_duration_ms:Date.now()-re.start}),Z({type:"reset"}))},X=async()=>{const ne=W.control._formState.dirtyFields,le=Object.keys(ne);if(le.length===0&&!M)return!0;const De=W.getValues(),Ie=W.control._defaultValues;W.reset(De,{keepValues:!0});const os=M;D(!1);const oi={id:t,name:De.name,active:De.active,models:{tier:De.tier},messages:Oc(b),temperature:0};try{await a.mutateAsync(oi)}catch{return W.reset(Ie,{keepValues:!0}),os&&D(!0),!1}const ys=[...le];return os&&ys.push("messages"),Z({type:"accumulate",now:Date.now(),fields:ys}),ue(),!0},{schedule:L,flush:q}=$s({save:X}),Q=Ue({connectionId:Ft,orgId:o.id,orgSlug:o.slug}),Y=_s(),ee=async ne=>{if(e.kind!=="tool_call")return!0;try{const le=await Q.callTool({name:"AUTOMATION_UPDATE",arguments:{id:t,connection_id:ne.connectionId,tool_name:ne.toolName,tool_input:ne.input}});return le.isError?(he.error(le.content?.[0]?.text??"Failed to save tool-call config"),!1):(Y.invalidateQueries({queryKey:us.automationsAll(o.id)}),Y.invalidateQueries({queryKey:us.automation(o.id,t)}),!0)}catch(le){return he.error(le instanceof Error?le.message:"Failed to save tool-call config"),!1}},{schedule:ae,flush:_e}=$s({save:()=>ee(F)}),{schedule:ue,flush:pe}=$s({delayMs:3e4,save:async()=>J()});A.useEffect(()=>{const ne=W.watch(()=>L());return()=>ne.unsubscribe()},[]);const ve=ne=>{if(S(ne),!C){j(!0);return}D(!0),L()},Re=async()=>{if(be("automation_test_clicked",{automation_id:t,agent_id:r,kind:e.kind}),e.kind==="tool_call"){if(!await _e())return;try{await h.mutateAsync(t)}catch{}return}const ne=await q();if(pe(),!ne)return;if(!b){he.error("No instructions configured for this automation");return}f(W.getValues("tier")),m(!0),v({...g,toolApprovalLevel:"auto"});const le=Vn(b);u({message:{tiptapDoc:b,parts:le},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(se,{variant:"ghost",size:"sm",onClick:s,children:[n.jsx(Xa,{size:14}),e.kind==="tool_call"?"Back to all automations":"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(nt,{control:W.control,name:"name",render:({field:ne})=>n.jsx(ot,{...ne,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(se,{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(nt,{control:W.control,name:"active",render:({field:ne})=>n.jsx(wr,{checked:ne.value,onCheckedChange:le=>{ne.onChange(le),q()},className:"cursor-pointer"})}),n.jsx("span",{className:"text-sm text-muted-foreground",children:K?"Active":"Inactive"}),n.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),n.jsx(Ma,{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(Tv,{automationId:t,open:w,onOpenChange:k,onCustomSelect:()=>{P(!0),T(!1),B("")},onEventSelect:()=>{T(!0),P(!1)}})]}),e.triggers.length===0&&!E?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:()=>k(!0),children:"Add a starter"})," ","to get going."]})}):n.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(ne=>n.jsx(Rv,{trigger:ne,automationId:t,connectionName:ne.connection_id?d.get(ne.connection_id):void 0},ne.id))}),E&&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(Os,{size:14,className:"text-muted-foreground shrink-0"}),n.jsx("input",{type:"text",value:R,onChange:ne=>B(ne.target.value),onBlur:async()=>{const ne=R.trim();if(!(!ne||!Fs(ne)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:ne}),be("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),he.success("Starter added"),P(!1),B("")}catch{he.error("Failed to add starter")}},onKeyDown:async ne=>{const le=R.trim();ne.key==="Enter"&&le&&Fs(le)&&ne.target.blur(),ne.key==="Escape"&&(P(!1),B(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),R&&!Fs(R)&&n.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&n.jsx(Be,{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:()=>{P(!1),B("")},children:n.jsx(fs,{size:13})})]}),I&&n.jsx(A.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(Be,{size:13,className:"animate-spin text-muted-foreground"}),n.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:n.jsx(Iv,{automationId:t,onDone:()=>T(!1)})})]}),e.kind==="tool_call"?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:"Tool call"}),n.jsxs(se,{type:"button",variant:"default",size:"sm",className:"h-7 gap-1.5 px-3 text-xs",onClick:Re,disabled:h.isPending||!F.connectionId||!F.toolName,children:[n.jsx(qn,{size:14}),"Test"]})]}),n.jsx("div",{className:"rounded-xl border border-border p-3",children:n.jsx(xv,{value:F,onChange:ne=>{H(ne),ae()}})})]}):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(se,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:y||!b,onClick:O,children:[n.jsx(kn,{size:13}),"Improve"]})]}),n.jsx(Tc,{tiptapDoc:b,setTiptapDoc:ve,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(Rc,{virtualMcpId:r||null,className:"max-h-[45vh]"}),n.jsxs("div",{className:"flex items-center justify-end gap-1.5 p-2.5",children:[n.jsx(Dc,{tier:W.watch("tier"),onSelect:ne=>W.setValue("tier",ne,{shouldDirty:!0})}),n.jsxs(je,{children:[n.jsx(ke,{asChild:!0,children:n.jsxs(se,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:Re,disabled:!r,children:[n.jsx(qn,{size:16}),"Test"]})}),n.jsx(Ne,{children:"Test Automation"})]})]})]})})]})]})]})}function Ov(t){const e=z.c(5),{tabId:s}=t;let i;e[0]!==s?(i=ya(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(Be,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=o):o=e[2];let a;return e[3]!==r.id?(a=n.jsx(ft,{children:n.jsx(ft.Content,{children:n.jsx(ft.Body,{children:n.jsx(A.Suspense,{fallback:o,children:n.jsx($v,{id:r.id})})})})}),e[3]=r.id,e[4]=a):a=e[4],a}function $v(t){const e=z.c(10),{id:s}=t,i=is(),{org:r}=ge(),{data:o,isLoading:a}=dd(s),l=o?.kind==="tool_call";let h;e[0]!==l||e[1]!==i||e[2]!==r?(h=()=>{if(l){i({to:"/$org/settings/automations",params:{org:r.slug}});return}i({to:".",search:zv,replace:!0})},e[0]=l,e[1]=i,e[2]=r,e[3]=h):h=e[3];const c=h;if(a){let u;return e[4]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(Be,{size:20,className:"animate-spin text-muted-foreground"})}),e[4]=u):u=e[4],u}if(!o){let u;return e[5]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[5]=u):u=e[5],u}let d;return e[6]!==o||e[7]!==s||e[8]!==c?(d=n.jsx(Lv,{automationId:s,automation:o,onBack:c}),e[6]=o,e[7]=s,e[8]=c,e[9]=d):d=e[9],d}function zv(t){return{...t,main:"automations"}}function Fv(t){const e=z.c(42),{virtualMcpId:s}=t,i=is(),{data:r}=ud(s),o=r===void 0?[]:r,{create:a}=ei(),[l,h]=A.useState(""),c=l.toLowerCase(),d=o.filter(W=>W.name.toLowerCase().includes(c));let u;e[0]!==i?(u=W=>i({to:".",search:K=>({...K,main:"automation:"+W}),replace:!0}),e[0]=i,e[1]=u):u=e[1];const f=u,m=async()=>{if(a.isPending)return;be("automation_new_clicked",{virtual_mcp_id:s,existing_count:o.length});const W=await a.mutateAsync(md(s));f(W.id)},_=async()=>{if(a.isPending)return;be("automation_new_tool_call_clicked",{source_virtual_mcp_id:s,existing_count:o.length});const W=await a.mutateAsync(_d());f(W.id)};let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(es,{size:14}),e[2]=p):p=e[2];let g;e[3]!==a.isPending||e[4]!==m?(g=n.jsxs(se,{size:"sm",onClick:m,disabled:a.isPending,className:"rounded-r-none",children:[p,"New automation"]}),e[3]=a.isPending,e[4]=m,e[5]=g):g=e[5];let v;e[6]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(vs,{size:14}),e[6]=v):v=e[6];let x;e[7]!==a.isPending?(x=n.jsx(Zs,{asChild:!0,children:n.jsx(se,{size:"sm",disabled:a.isPending,className:"rounded-l-none border-l border-primary-foreground/20 px-2","aria-label":"Pick automation kind",children:v})}),e[7]=a.isPending,e[8]=x):x=e[8];let b;e[9]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(kn,{size:14}),e[9]=b):b=e[9];let S;e[10]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsxs("div",{className:"flex flex-col",children:[n.jsx("span",{children:"Agent automation"}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"Runs this agent on a schedule or event"})]}),e[10]=S):S=e[10];let w;e[11]!==a.isPending||e[12]!==m?(w=n.jsxs(Dt,{onClick:m,disabled:a.isPending,children:[b,S]}),e[11]=a.isPending,e[12]=m,e[13]=w):w=e[13];let k;e[14]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(fn,{size:14}),e[14]=k):k=e[14];let E;e[15]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsxs("div",{className:"flex flex-col",children:[n.jsx("span",{children:"Tool-call automation"}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"Invokes a fixed MCP tool — no agent, no LLM"})]}),e[15]=E):E=e[15];let P;e[16]!==a.isPending||e[17]!==_?(P=n.jsxs(Dt,{onClick:_,disabled:a.isPending,children:[k,E]}),e[16]=a.isPending,e[17]=_,e[18]=P):P=e[18];let R;e[19]!==P||e[20]!==w?(R=n.jsxs(Qs,{align:"end",className:"w-72",children:[w,P]}),e[19]=P,e[20]=w,e[21]=R):R=e[21];let B;e[22]!==R||e[23]!==x?(B=n.jsxs(Js,{children:[x,R]}),e[22]=R,e[23]=x,e[24]=B):B=e[24];let I;e[25]!==B||e[26]!==g?(I=n.jsxs("div",{className:"flex items-stretch",children:[g,B]}),e[25]=B,e[26]=g,e[27]=I):I=e[27];const T=I,y=ft,N=ft,C=ft;let j;e[28]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx(ft.Title,{children:"Automations"}),e[28]=j):j=e[28];const M=o.length>0&&n.jsx(pd,{value:l,onChange:h,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let D;e[29]!==T||e[30]!==M?(D=n.jsxs("div",{className:"flex flex-col gap-6",children:[j,n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[M,T]})]}),e[29]=T,e[30]=M,e[31]=D):D=e[31];const F=o.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(Ri,{image:n.jsx(Us,{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:T})}):d.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(Ri,{image:n.jsx(Us,{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(W=>n.jsx(fd,{automation:W,onClick:()=>f(W.id)},W.id))});let H;e[32]!==C.Body||e[33]!==D||e[34]!==F?(H=n.jsxs(C.Body,{children:[D,F]}),e[32]=C.Body,e[33]=D,e[34]=F,e[35]=H):H=e[35];let O;e[36]!==N.Content||e[37]!==H?(O=n.jsx(N.Content,{children:H}),e[36]=N.Content,e[37]=H,e[38]=O):O=e[38];let $;return e[39]!==y||e[40]!==O?($=n.jsx(y,{children:O}),e[39]=y,e[40]=O,e[41]=$):$=e[41],$}function Hv(t){const e=z.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(Be,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsx(A.Suspense,{fallback:i,children:n.jsx(Fv,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}const oa=A.lazy(()=>cn(()=>import("./project-app-view-0puAiHFx.js"),__vite__mapDeps([126,1,2,76,10,11,12,13,14,15,16,17,18,19,20,21,7,8,3,9,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,77,78,6,79,50,80,81,54,66,67,68,69,57,53,70,71,72,73,74,75,64,65])).then(t=>({default:t.AppViewContent})));function ic(t){const e=z.c(41),{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}=el(r);if(Yc(o)){let _;return e[3]!==i?(_=n.jsx(lo,{virtualMcpId:i}),e[3]=i,e[4]=_):_=e[4],_}if(o==="git"){let _;return e[5]!==i?(_=n.jsx(Kf,{virtualMcpId:i}),e[5]=i,e[6]=_):_=e[6],_}if(o==="automations"){let _;return e[7]!==i?(_=n.jsx(Hv,{virtualMcpId:i}),e[7]=i,e[8]=_):_=e[8],_}if(o==="preview"){let _;return e[9]!==i?(_=n.jsx(fv,{virtualMcpId:i}),e[9]=i,e[10]=_):_=e[10],_}if(h){let _;return e[11]!==o?(_=n.jsx(Ov,{tabId:o}),e[11]=o,e[12]=_):_=e[12],_}let c;e[13]!==o?(c=Xc(o),e[13]=o,e[14]=c):c=e[14];const d=c;if(d){let _;if(e[15]!==l||e[16]!==d.connectionId||e[17]!==d.toolName){let b;e[19]!==d.connectionId||e[20]!==d.toolName?(b=S=>S.appId===d.connectionId&&S.toolName===d.toolName,e[19]=d.connectionId,e[20]=d.toolName,e[21]=b):b=e[21],_=l.find(b),e[15]=l,e[16]=d.connectionId,e[17]=d.toolName,e[18]=_}else _=e[18];const p=_;let g;e[22]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(Be,{size:20,className:"animate-spin text-muted-foreground"})}),e[22]=g):g=e[22];const v=p?.args;let x;return e[23]!==o||e[24]!==d.connectionId||e[25]!==d.toolName||e[26]!==v?(x=n.jsx(A.Suspense,{fallback:g,children:n.jsx(oa,{connectionId:d.connectionId,toolName:d.toolName,args:v},o)}),e[23]=o,e[24]=d.connectionId,e[25]=d.toolName,e[26]=v,e[27]=x):x=e[27],x}let u;if(e[28]!==o||e[29]!==a){let _;e[31]!==o?(_=p=>p.id===o,e[31]=o,e[32]=_):_=e[32],u=a.find(_),e[28]=o,e[29]=a,e[30]=u}else u=e[30];const f=u;if(f){let _;e[33]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(Be,{size:20,className:"animate-spin text-muted-foreground"})}),e[33]=_):_=e[33];let p;return e[34]!==o||e[35]!==f.id||e[36]!==f.view.appId||e[37]!==f.view.args?(p=n.jsx(A.Suspense,{fallback:_,children:n.jsx(oa,{connectionId:f.view.appId,toolName:f.id,args:f.view.args},o)}),e[34]=o,e[35]=f.id,e[36]=f.view.appId,e[37]=f.view.args,e[38]=p):p=e[38],p}let m;return e[39]!==i?(m=n.jsx(lo,{virtualMcpId:i}),e[39]=i,e[40]=m):m=e[40],m}function Wv(t){const e=z.c(10),{children:s,defaultSize:i,chatOpen:r}=t,[,o]=A.useTransition();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=xa.decoChatPanelWidth(),e[0]=a):a=e[0];const[l,h]=va(a,45),c=i>0&&i<100?l:i;let d;e[1]!==h?(d=p=>o(()=>{p>0&&p<100&&h(p)}),e[1]=h,e[2]=d):d=e[2];const u=d,f=r?"min-w-[348px]":"min-w-0";let m;e[3]!==f?(m=te("overflow-hidden bg-sidebar",f),e[3]=f,e[4]=m):m=e[4];let _;return e[5]!==s||e[6]!==c||e[7]!==u||e[8]!==m?(_=n.jsx(Da,{defaultSize:c,minSize:20,collapsible:!0,collapsedSize:0,className:m,onResize:u,order:1,children:s}),e[5]=s,e[6]=c,e[7]=u,e[8]=m,e[9]=_):_=e[9],_}function Uv(t){const e=z.c(31),{virtualMcpId:s,taskId:i,chatOpen:r,mainOpen:o,chatContent:a}=t;let l;e[0]!==r||e[1]!==o?(l=Un(r,o),e[0]=r,e[1]=o,e[2]=l):l=e[2];const h=l;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=xa.decoChatPanelWidth(),e[3]=c):c=e[3];const[d]=va(c,45),u=A.useRef(null);let f,m;e[4]!==r||e[5]!==o||e[6]!==d?(f=()=>{const B=u.current;if(!B)return;const I=Un(r,o),T=I.chat>0&&I.chat<100?d:I.chat,y=I.chat>0&&I.chat<100?100-d:I.main;B.setLayout([T,y])},m=[r,o,d],e[4]=r,e[5]=o,e[6]=d,e[7]=f,e[8]=m):(f=e[7],m=e[8]),A.useEffect(f,m);const _=`${s}-${i}`;let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p={overflow:"visible"},e[9]=p):p=e[9];let g;e[10]!==a?(g=a??n.jsx(Ja,{}),e[10]=a,e[11]=g):g=e[11];let v;e[12]!==g?(v=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[12]=g,e[13]=v):v=e[13];let x;e[14]!==r||e[15]!==h.chat||e[16]!==v?(x=n.jsx(Wv,{defaultSize:h.chat,chatOpen:r,children:v}),e[14]=r,e[15]=h.chat,e[16]=v,e[17]=x):x=e[17];let b;e[18]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(Eh,{className:"bg-sidebar"}),e[18]=b):b=e[18];const S=h.main;let w;e[19]===Symbol.for("react.memo_cache_sentinel")?(w={overflow:"visible"},e[19]=w):w=e[19];let k;e[20]===Symbol.for("react.memo_cache_sentinel")?(k=te("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[20]=k):k=e[20];let E;e[21]!==i||e[22]!==s?(E=n.jsx("div",{className:"h-full p-0.5 pt-0.25",children:n.jsx("div",{className:k,children:n.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.jsx(Rt,{children:n.jsx(ic,{taskId:i,virtualMcpId:s})})})})}),e[21]=i,e[22]=s,e[23]=E):E=e[23];let P;e[24]!==h.main||e[25]!==E?(P=n.jsx(Da,{className:"min-w-0 flex flex-col",order:2,defaultSize:S,style:w,collapsible:!0,collapsedSize:0,minSize:20,children:E}),e[24]=h.main,e[25]=E,e[26]=P):P=e[26];let R;return e[27]!==P||e[28]!==_||e[29]!==x?(R=n.jsxs(Th,{ref:u,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:p,children:[x,b,P]},_),e[27]=P,e[28]=_,e[29]=x,e[30]=R):R=e[30],R}const vr="flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",aa="bg-sidebar-accent text-sidebar-foreground",xr="text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";function Vv(t){const e=z.c(47),{chatOpen:s,toggleChat:i,onNewTask:r}=t,{tasksOpen:o,toggleTasks:a}=Pc(),l=!!r;let h;e[0]!==o||e[1]!==a?(h=()=>{be("agent_toolbar_toggled",{button:"tasks",next_state:o?"closed":"open"}),a()},e[0]=o,e[1]=a,e[2]=h):h=e[2];const c=o?aa:xr;let d;e[3]!==c?(d=te(vr,c),e[3]=c,e[4]=d):d=e[4];let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(uh,{size:16}),e[5]=u):u=e[5];let f;e[6]!==h||e[7]!==d||e[8]!==o?(f=n.jsx(ke,{asChild:!0,children:n.jsx("button",{type:"button",onClick:h,"aria-pressed":o,className:d,children:u})}),e[6]=h,e[7]=d,e[8]=o,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(Ne,{side:"bottom",children:"Tasks"}),e[10]=m):m=e[10];let _;e[11]!==f?(_=n.jsxs(je,{delayDuration:300,children:[f,m]}),e[11]=f,e[12]=_):_=e[12];let p;e[13]!==s||e[14]!==i?(p=()=>{be("agent_toolbar_toggled",{button:"chat",next_state:s?"closed":"open"}),i()},e[13]=s,e[14]=i,e[15]=p):p=e[15];const g=s?aa:xr;let v;e[16]!==g?(v=te(vr,g),e[16]=g,e[17]=v):v=e[17];let x;e[18]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(Ea,{size:16}),e[18]=x):x=e[18];let b;e[19]!==s||e[20]!==v||e[21]!==p?(b=n.jsx(ke,{asChild:!0,children:n.jsx("button",{type:"button",onClick:p,"aria-pressed":s,className:v,children:x})}),e[19]=s,e[20]=v,e[21]=p,e[22]=b):b=e[22];let S;e[23]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(Ne,{side:"bottom",children:"Chat"}),e[23]=S):S=e[23];let w;e[24]!==b?(w=n.jsxs(je,{delayDuration:300,children:[b,S]}),e[24]=b,e[25]=w):w=e[25];const k=l?"grid-cols-[1fr]":"grid-cols-[0fr]";let E;e[26]!==k?(E=te("grid transition-[grid-template-columns] duration-200 ease-[var(--ease-out-quart)]",k),e[26]=k,e[27]=E):E=e[27];const P=!l,R=l?0:-1,B=!l,I=l?"translate-x-0 opacity-100":"-translate-x-2 opacity-0";let T;e[28]!==I?(T=te(vr,xr,"transition-[transform,opacity] duration-200 ease-[var(--ease-out-quart)] will-change-transform",I),e[28]=I,e[29]=T):T=e[29];let y;e[30]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(bn,{size:16}),e[30]=y):y=e[30];let N;e[31]!==r||e[32]!==P||e[33]!==R||e[34]!==B||e[35]!==T?(N=n.jsx(ke,{asChild:!0,children:n.jsx("button",{type:"button",onClick:r,disabled:P,tabIndex:R,"aria-hidden":B,className:T,children:y})}),e[31]=r,e[32]=P,e[33]=R,e[34]=B,e[35]=T,e[36]=N):N=e[36];let C;e[37]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx(Ne,{side:"bottom",children:"New task"}),e[37]=C):C=e[37];let j;e[38]!==N?(j=n.jsx("div",{className:"overflow-hidden",children:n.jsxs(je,{delayDuration:300,children:[N,C]})}),e[38]=N,e[39]=j):j=e[39];let M;e[40]!==E||e[41]!==j?(M=n.jsx("div",{className:E,children:j}),e[40]=E,e[41]=j,e[42]=M):M=e[42];let D;return e[43]!==w||e[44]!==M||e[45]!==_?(D=n.jsxs(n.Fragment,{children:[_,w,M]}),e[43]=w,e[44]=M,e[45]=_,e[46]=D):D=e[46],D}function Kv(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 qv(t){const e=z.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=te("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(Gv,{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 Gv(t){const e=z.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(Ta,{className:"size-4"}),e[4]=i):i=e[4],i}function Yv(t){const e=z.c(13),{overflow:s,onSelect:i}=t,[r,o]=A.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(Wt,{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(ja,{className:"size-4"})})}),e[2]=h):h=e[2];let c;if(e[3]!==l||e[4]!==s){let f;e[6]!==l?(f=m=>n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>l(m.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(Xv,{icon:m.icon})}),n.jsx("span",{className:"truncate",children:m.title})]})},m.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(Ut,{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(Vt,{open:r,onOpenChange:o,children:[h,d]}),e[10]=r,e[11]=d,e[12]=u):u=e[12],u}function Xv(t){const e=z.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(Ta,{className:"size-4"}),e[4]=i):i=e[4],i}const Jv=6;function rc(t){const e=z.c(20),{virtualMcpId:s,taskId:i}=t,r=is();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}=el(o);let d,u,f,m;if(e[3]!==l||e[4]!==h||e[5]!==r||e[6]!==c||e[7]!==a||e[8]!==s){const g=Jc({activeTab:l,mainOpen:h}),v=k=>k.id==="automations"?g:h&&k.id===l,b=a.find(k=>v(k))?.id??null,{visible:S,overflow:w}=Kv(a,b,Jv);u=w,d=k=>{const E=a.find(R=>R.id===k),P=b===k&&h;if(be("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:k,tab_kind:E?.kind??null,was_active:P}),k==="automations"){const R=Zc({activeTab:l,mainOpen:h});r({to:".",search:B=>({...B,main:R}),replace:!0});return}c(k)},f="flex items-center min-w-0 gap-0.5",m=S.map(k=>n.jsx(qv,{title:k.title,icon:k.icon,active:v(k),onClick:()=>d(k.id)},k.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]=m}else d=e[9],u=e[10],f=e[11],m=e[12];let _;e[13]!==d||e[14]!==u?(_=u.length>0&&n.jsx(Yv,{overflow:u,onSelect:d}),e[13]=d,e[14]=u,e[15]=_):_=e[15];let p;return e[16]!==f||e[17]!==m||e[18]!==_?(p=n.jsxs("div",{className:f,children:[m,_]}),e[16]=f,e[17]=m,e[18]=_,e[19]=p):p=e[19],p}function Zv(t){const e=z.c(12);let s,i,r,o;e[0]!==t?({className:s,orientation:r,decorative:o,...i}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r,e[4]=o):(s=e[1],i=e[2],r=e[3],o=e[4]);const a=r===void 0?"horizontal":r,l=o===void 0?!0:o;let h;e[5]!==s?(h=te("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",s),e[5]=s,e[6]=h):h=e[6];let c;return e[7]!==l||e[8]!==a||e[9]!==i||e[10]!==h?(c=n.jsx(Cc,{"data-slot":"separator-root",decorative:l,orientation:a,className:h,...i}),e[7]=l,e[8]=a,e[9]=i,e[10]=h,e[11]=c):c=e[11],c}function Qv(t){const e=z.c(20),{prNumber:s,disabled:i,send:r}=t;let o;e[0]!==s||e[1]!==r?(o=()=>r(Af({prNumber:s})),e[0]=s,e[1]=r,e[2]=o):o=e[2];const a=o;let l;e[3]!==s||e[4]!==r?(l=()=>r(Mf({prNumber:s})),e[3]=s,e[4]=r,e[5]=l):l=e[5];const h=l;let c;e[6]!==i||e[7]!==a?(c=n.jsx(se,{size:"sm",variant:"success",className:"rounded-r-none border-r border-success-foreground/20",disabled:i,onClick:a,children:"Publish"}),e[6]=i,e[7]=a,e[8]=c):c=e[8];let d;e[9]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(vs,{className:"h-3.5 w-3.5"}),e[9]=d):d=e[9];let u;e[10]!==i?(u=n.jsx(Zs,{asChild:!0,children:n.jsx(se,{size:"sm",variant:"success",className:"rounded-l-none px-2",disabled:i,"aria-label":"More actions",children:d})}),e[10]=i,e[11]=u):u=e[11];let f;e[12]!==h?(f=n.jsx(Qs,{align:"end",children:n.jsx(Dt,{onClick:h,children:"Review"})}),e[12]=h,e[13]=f):f=e[13];let m;e[14]!==u||e[15]!==f?(m=n.jsxs(Js,{children:[u,f]}),e[14]=u,e[15]=f,e[16]=m):m=e[16];let _;return e[17]!==c||e[18]!==m?(_=n.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[c,m]}),e[17]=c,e[18]=m,e[19]=_):_=e[19],_}function e1(t){if(!(t==="claiming"||t==="ready"||t==="failed"))return ll[t].short}const t1=new Set(["failure","timed_out","cancelled","action_required"]);function s1(t){return t.status==="completed"&&t1.has(t.conclusion)}function i1(t){return t.status==="queued"||t.status==="in_progress"}function r1(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&&e1(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(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(s1).map(m=>m.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(i1);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:"Publish",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}`}}const n1=6e4,o1=3e4;function a1(t){const e=z.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=Ue(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:n1,refetchIntervalInBackground:!1,staleTime:o1,select:l1},e[8]=i,e[9]=o,e[10]=a,e[11]=l):l=e[11],Xs(l)}function l1(t){const e=ti(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}}function c1(t){const e=z.c(44),{virtualMcpId:s}=t,{org:i}=ge(),r=Pt(s),{currentBranch:o}=Ht(),a=rs(),l=r?.metadata?.githubRepo??null,{lifecycle:h,branch:c,phase:d}=xs(),u=l?.connectionId??"",f=l?.owner??"",m=l?.name??"",_=o??null;let p;e[0]!==i.id||e[1]!==i.slug||e[2]!==u||e[3]!==f||e[4]!==m||e[5]!==_?(p={orgId:i.id,orgSlug:i.slug,connectionId:u,owner:f,repo:m,branch:_},e[0]=i.id,e[1]=i.slug,e[2]=u,e[3]=f,e[4]=m,e[5]=_,e[6]=p):p=e[6];const g=rl(p),v=g.data??null,x=l?.connectionId??"",b=l?.owner??"",S=l?.name??"",w=v&&v.state==="open"?v.number:null;let k;e[7]!==i.id||e[8]!==i.slug||e[9]!==x||e[10]!==b||e[11]!==S||e[12]!==w?(k={orgId:i.id,orgSlug:i.slug,connectionId:x,owner:b,repo:S,prNumber:w},e[7]=i.id,e[8]=i.slug,e[9]=x,e[10]=b,e[11]=S,e[12]=w,e[13]=k):k=e[13];const E=ol(k),P=l?.connectionId??"",R=l?.owner??"",B=l?.name??"",I=v&&v.state==="open"?v.number:null;let T;e[14]!==i.id||e[15]!==i.slug||e[16]!==P||e[17]!==R||e[18]!==B||e[19]!==I?(T={orgId:i.id,orgSlug:i.slug,connectionId:P,owner:R,repo:B,prNumber:I},e[14]=i.id,e[15]=i.slug,e[16]=P,e[17]=R,e[18]=B,e[19]=I,e[20]=T):T=e[20];const y=a1(T);if(!l?.connectionId||!o)return null;let N;e[21]!==c||e[22]!==E.data||e[23]!==d||e[24]!==h||e[25]!==v||e[26]!==g.isPending||e[27]!==y.data?(N=r1({lifecycle:h,branch:c,claimPhase:d,pr:v,checks:E.data??[],reviews:y.data??null,loading:g.isPending}),e[21]=c,e[22]=E.data,e[23]=d,e[24]=h,e[25]=v,e[26]=g.isPending,e[27]=y.data,e[28]=N):N=e[28];const C=N;let j;e[29]!==a?(j=K=>a.sendMessage({parts:[{type:"text",text:K}]}),e[29]=a,e[30]=j):j=e[30];const M=j,D=a.isStreaming;let F;e[31]!==o||e[32]!==C||e[33]!==D||e[34]!==v||e[35]!==M?(F=K=>{if(!D)switch(K){case"commit-and-push":{M(Nf({branch:o}));return}case"create-pr":{M(jf({branch:o}));return}case"reopen":{v&&M(Ef({prNumber:v.number}));return}case"rebase":{M(Tf({branch:o}));return}case"fix-checks":{v&&M(Df({prNumber:v.number,failingChecks:C.meta?.failingChecks??[]}));return}case"mark-ready":{v&&M(Pf({prNumber:v.number}));return}case"resolve-comments":{v&&M(If({prNumber:v.number}));return}case"merge-split":return}},e[31]=o,e[32]=C,e[33]=D,e[34]=v,e[35]=M,e[36]=F):F=e[36];const H=F;let O;e[37]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(Zv,{orientation:"vertical",className:"mx-2 data-[orientation=vertical]:h-5"}),e[37]=O):O=e[37];const $=v?.number;let W;return e[38]!==C||e[39]!==D||e[40]!==H||e[41]!==M||e[42]!==$?(W=n.jsxs(n.Fragment,{children:[O,n.jsx(h1,{button:C,isStreaming:D,onActivate:H,prNumber:$,send:M})]}),e[38]=C,e[39]=D,e[40]=H,e[41]=M,e[42]=$,e[43]=W):W=e[43],W}function h1(t){const e=z.c(21),{button:s,isStreaming:i}=t,r=!!s.disabled||i,o=i?"Chat is running":s.tooltip??null;if(s.action==="merge-split"&&t.prNumber!=null){let d;e[0]!==r||e[1]!==t.prNumber||e[2]!==t.send?(d=n.jsx(Qv,{prNumber:t.prNumber,disabled:r,send:t.send}),e[0]=r,e[1]=t.prNumber,e[2]=t.send,e[3]=d):d=e[3];let u;return e[4]!==d||e[5]!==o?(u=n.jsx(la,{label:o,children:d}),e[4]=d,e[5]=o,e[6]=u):u=e[6],u}let a;e[7]!==s.action||e[8]!==t?(a=()=>t.onActivate(s.action),e[7]=s.action,e[8]=t,e[9]=a):a=e[9];let l;e[10]!==s.loading?(l=s.loading?n.jsx(rd,{size:"xs",variant:"default"}):null,e[10]=s.loading,e[11]=l):l=e[11];let h;e[12]!==s.label||e[13]!==s.variant||e[14]!==r||e[15]!==a||e[16]!==l?(h=n.jsxs(se,{size:"sm",variant:s.variant,disabled:r,onClick:a,children:[l,s.label]}),e[12]=s.label,e[13]=s.variant,e[14]=r,e[15]=a,e[16]=l,e[17]=h):h=e[17];let c;return e[18]!==h||e[19]!==o?(c=n.jsx(la,{label:o,children:h}),e[18]=h,e[19]=o,e[20]=c):c=e[20],c}function la(t){const e=z.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(ke,{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(Ne,{children:s}),e[4]=s,e[5]=o):o=e[5];let a;return e[6]!==r||e[7]!==o?(a=n.jsx(yh,{children:n.jsxs(je,{children:[r,o]})}),e[6]=r,e[7]=o,e[8]=a):a=e[8],a}function d1(t){const e=z.c(2),{virtualMcp:s}=t;if(!!!(s.metadata?.githubRepo??null)?.connectionId)return null;let o;return e[0]!==s.id?(o=n.jsx(br.Right,{children:n.jsx(c1,{virtualMcpId:s.id})}),e[0]=s.id,e[1]=o):o=e[1],o}function u1(t,e){const s=z.c(34),i=Pa(),r=A.useSyncExternalStore(i.threads.subscribe,i.threads.get),o=A.useSyncExternalStore(i.threadsStatus.subscribe,i.threadsStatus.get);let a;s[0]!==t||s[1]!==r?(a=t?r.find(b=>b.id===t)??null:null,s[0]=t,s[1]=r,s[2]=a):a=s[2];const l=a,[h,c]=A.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],A.useEffect(d,u);let f,m;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(b=>{c(b)})))},m=[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]=m):(f=s[11],m=s[12]),A.useEffect(f,m);let _;s[13]!==i||s[14]!==e?(_={mutationFn:async b=>i.create({id:b,virtual_mcp_id:e})},s[13]=i,s[14]=e,s[15]=_):_=s[15];const p=ua(_);let g,v;if(s[16]!==p||s[17]!==h||s[18]!==t||s[19]!==l||s[20]!==o.kind?(g=()=>{t&&(l||h===null&&o.kind!=="loading"&&(p.isPending||p.variables!==t&&p.mutate(t)))},v=[t,l,h,o.kind,p],s[16]=p,s[17]=h,s[18]=t,s[19]=l,s[20]=o.kind,s[21]=g,s[22]=v):(g=s[21],v=s[22]),A.useEffect(g,v),!t){let b;return s[23]===Symbol.for("react.memo_cache_sentinel")?(b={status:"ready",task:null},s[23]=b):b=s[23],b}if(l){let b;return s[24]!==l?(b={status:"ready",task:l},s[24]=l,s[25]=b):b=s[25],b}if(h&&typeof h=="object"){let b;return s[26]!==h?(b={status:"ready",task:h},s[26]=h,s[27]=b):b=s[27],b}if(p.data){let b;return s[28]!==p.data?(b={status:"ready",task:p.data},s[28]=p.data,s[29]=b):b=s[29],b}if(p.isError){let b;return s[30]!==p.error?(b={status:"error",error:p.error},s[30]=p.error,s[31]=b):b=s[31],b}if(p.isPending||o.kind!=="loading"){let b;return s[32]===Symbol.for("react.memo_cache_sentinel")?(b={status:"creating"},s[32]=b):b=s[32],b}let x;return s[33]===Symbol.for("react.memo_cache_sentinel")?(x={status:"loading"},s[33]=x):x=s[33],x}const hs=A.createContext(null);function nc(){return A.use(hs)}function ca(t){const e=z.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(Ce.Skeleton,{}),e[1]=r):r=e[1];let o;e[2]!==s?(o=s??n.jsx(Ja,{}),e[2]=s,e[3]=o):o=e[3];let a;return e[4]!==o?(a=n.jsx(Rt,{fallback:i,children:n.jsx(A.Suspense,{fallback:r,children:o})}),e[4]=o,e[5]=a):a=e[5],a}function ha(t){const e=z.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],A.useLayoutEffect(r),null}function f1(t){const e=z.c(23),{onOpenSidebar:s,virtualMcpId:i,taskId:r,mainOpen:o,onToggleMain:a,onNewTask:l}=t;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(zc,{size:20}),e[0]=h):h=e[0];let c;e[1]!==s?(c=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:h}),e[1]=s,e[2]=c):c=e[2];let d;e[3]!==r||e[4]!==i?(d=n.jsx("div",{className:"flex-1 min-w-0 overflow-x-auto [scrollbar-width:none]",children:n.jsx(rc,{virtualMcpId:i,taskId:r})}),e[3]=r,e[4]=i,e[5]=d):d=e[5];const u=!o,f=o?"text-foreground/60 hover:bg-accent hover:text-foreground":"bg-accent text-foreground";let m;e[6]!==f?(m=te("flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",f),e[6]=f,e[7]=m):m=e[7];let _;e[8]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx(Ea,{size:16}),e[8]=_):_=e[8];let p;e[9]!==a||e[10]!==u||e[11]!==m?(p=n.jsx("button",{type:"button",onClick:a,"aria-pressed":u,className:m,title:"Chat",children:_}),e[9]=a,e[10]=u,e[11]=m,e[12]=p):p=e[12];let g;e[13]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(bn,{size:16}),e[13]=g):g=e[13];let v;e[14]!==l?(v=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:g}),e[14]=l,e[15]=v):v=e[15];let x;e[16]!==v||e[17]!==p?(x=n.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[p,v]}),e[16]=v,e[17]=p,e[18]=x):x=e[18];let b;return e[19]!==x||e[20]!==c||e[21]!==d?(b=n.jsxs("div",{className:"shrink-0 flex items-center gap-1 px-2 h-12 bg-background border-b border-border",children:[c,d,x]}),e[19]=x,e[20]=c,e[21]=d,e[22]=b):b=e[22],b}function da(t){const e=z.c(16),{virtualMcpId:s,hasActiveGithubRepo:i,vmMap:r,children:o}=t,{org:a}=ge(),{currentBranch:l}=Ht(),{data:h}=Oi.useSession(),c=h?.user?.id;let d;e[0]!==a.id||e[1]!==a.slug?(d={connectionId:Ft,orgId:a.id,orgSlug:a.slug},e[0]=a.id,e[1]=a.slug,e[2]=d):d=e[2];const u=Ue(d),{mutate:f}=Qa(u);let m;e[3]===Symbol.for("react.memo_cache_sentinel")?(m=new Set,e[3]=m):m=e[3];const _=A.useRef(m);let p,g;e[4]!==l||e[5]!==i||e[6]!==f||e[7]!==c||e[8]!==s||e[9]!==r?(p=()=>{if(i&&c&&l){if(r?.[c]?.[l]){_.current.add(l);return}_.current.has(l)||(_.current.add(l),f({virtualMcpId:s,branch:l},{onError:m1}))}},g=[i,c,l,r,s,f],e[4]=l,e[5]=i,e[6]=f,e[7]=c,e[8]=s,e[9]=r,e[10]=p,e[11]=g):(p=e[10],g=e[11]),A.useEffect(p,g);const v=l??null;let x;return e[12]!==o||e[13]!==v||e[14]!==s?(x=n.jsx(fm,{virtualMcpId:s,branch:v,children:o}),e[12]=o,e[13]=v,e[14]=s,e[15]=x):x=e[15],x}function m1(t){console.error("[auto-start-vm] failed:",t)}function _1(){const t=z.c(115),e=Ra(),s=is(),{org:i}=ge(),r=Ic()?.tasksOpen??!1;wh(i.slug);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o={strict:!1},t[0]=o):o=t[0];const a=kc(o),l=a.org??"";let h;t[1]===Symbol.for("react.memo_cache_sentinel")?(h={strict:!1},t[1]=h):h=t[1];const c=ma(h);let d;t[2]!==i.id||t[3]!==c.virtualmcpid?(d=c.virtualmcpid??ba(i.id).id,t[2]=i.id,t[3]=c.virtualmcpid,t[4]=d):d=t[4];const u=d,f=u1(a.taskId??"",u),m=Pt(u),_=m?.metadata?.ui?.layout??null;let p;t[5]!==_?(p=_?{defaultMainView:_.defaultMainView??null,chatDefaultOpen:_.chatDefaultOpen??null}:null,t[5]=_,t[6]=p):p=t[6];const g=p;let v;t[7]!==m?(v=m&&Zt(m),t[7]=m,t[8]=v):v=t[8];const x=!!v;let b;t[9]!==l||t[10]!==u?(b={virtualMcpId:u,orgSlug:l,isAgentRoute:!0},t[9]=l,t[10]=u,t[11]=b):b=t[11];const S=Mc(g,b),{setOpenMobile:w,openMobile:k}=vh(),E=w,P=A.useRef(null);let R,B;t[12]===Symbol.for("react.memo_cache_sentinel")?(R=()=>{const J=X=>{gh(X)&&X.shiftKey&&X.code==="KeyS"&&!X.repeat&&(X.preventDefault(),P.current?.())};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)},B=[],t[12]=R,t[13]=B):(R=t[12],B=t[13]),A.useEffect(R,B);const I=u;let T;t[14]!==m||t[15]!==u?(T={virtualMcpId:u,entity:m},t[14]=m,t[15]=u,t[16]=T):T=t[16];const y=T;if(f.status==="creating"||f.status==="loading"){let J;t[17]===Symbol.for("react.memo_cache_sentinel")?(J=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(Be,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[17]=J):J=t[17];let X;return t[18]!==y?(X=n.jsx(hs,{value:y,children:J}),t[18]=y,t[19]=X):X=t[19],X}if(f.status==="error"){let J;t[20]===Symbol.for("react.memo_cache_sentinel")?(J=n.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[20]=J):J=t[20];let X;t[21]!==f.error.message?(X=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:[J,n.jsx("div",{className:"text-muted-foreground",children:f.error.message})]})}),t[21]=f.error.message,t[22]=X):X=t[22];let L;return t[23]!==y||t[24]!==X?(L=n.jsx(hs,{value:y,children:X}),t[23]=y,t[24]=X,t[25]=L):L=t[25],L}if(!m){let J;t[26]===Symbol.for("react.memo_cache_sentinel")?(J=n.jsx(dn,{size:48,className:"text-muted-foreground"}),t[26]=J):J=t[26];const X=`The agent "${u}" does not exist in this organization.`;let L;t[27]!==s||t[28]!==l?(L=n.jsx(se,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:l}}),children:"Go to organization home"}),t[27]=s,t[28]=l,t[29]=L):L=t[29];let q;t[30]!==X||t[31]!==L?(q=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(Ri,{image:J,title:"Agent not found",description:X,actions:L})})}),t[30]=X,t[31]=L,t[32]=q):q=t[32];let Q;return t[33]!==y||t[34]!==q?(Q=n.jsx(hs,{value:y,children:q}),t[33]=y,t[34]=q,t[35]=Q):Q=t[35],Q}if(e){let J;t[36]===Symbol.for("react.memo_cache_sentinel")?(J=n.jsx(xh,{className:"sr-only",children:"Navigation"}),t[36]=J):J=t[36];let X;t[37]!==E?(X=n.jsx("div",{className:"w-14 shrink-0 bg-sidebar flex flex-col items-center border-r border-border overflow-y-auto group/sidebar","data-state":"collapsed",children:n.jsx(_h,{onClose:()=>E(!1)})}),t[37]=E,t[38]=X):X=t[38];let L;t[39]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:n.jsx(ph,{})}),t[39]=L):L=t[39];let q;t[40]!==X?(q=n.jsxs(bh,{side:"left",hideCloseButton:!0,className:"w-[calc(100vw-3rem)] sm:max-w-md! p-0",children:[J,n.jsxs("div",{className:"flex h-full",children:[X,L]})]}),t[40]=X,t[41]=q):q=t[41];let Q;t[42]!==k||t[43]!==E||t[44]!==q?(Q=n.jsx(Sh,{open:k,onOpenChange:E,children:q}),t[42]=k,t[43]=E,t[44]=q,t[45]=Q):Q=t[45];const Y=Q,ee=m?.metadata?.vmMap;let ae;t[46]!==S.createNewTask?(ae=n.jsx(ha,{onNewTaskRef:P,createNewTask:S.createNewTask}),t[46]=S.createNewTask,t[47]=ae):ae=t[47];let _e;t[48]!==E?(_e=()=>E(!0),t[48]=E,t[49]=_e):_e=t[49];let ue;t[50]!==I||t[51]!==S.createNewTask||t[52]!==S.mainOpen||t[53]!==S.taskId||t[54]!==S.toggleMain||t[55]!==_e?(ue=n.jsx(f1,{onOpenSidebar:_e,virtualMcpId:I,taskId:S.taskId,mainOpen:S.mainOpen,onToggleMain:S.toggleMain,onNewTask:S.createNewTask}),t[50]=I,t[51]=S.createNewTask,t[52]=S.mainOpen,t[53]=S.taskId,t[54]=S.toggleMain,t[55]=_e,t[56]=ue):ue=t[56];let pe;t[57]===Symbol.for("react.memo_cache_sentinel")?(pe=n.jsx(Ce.Skeleton,{}),t[57]=pe):pe=t[57];let ve;t[58]!==I||t[59]!==S.mainOpen||t[60]!==S.taskId?(ve=n.jsx(A.Suspense,{fallback:pe,children:n.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:S.mainOpen?n.jsx(Rt,{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(A.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(Be,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(ic,{taskId:S.taskId,virtualMcpId:I})})}):n.jsx(ca,{})})}),t[58]=I,t[59]=S.mainOpen,t[60]=S.taskId,t[61]=ve):ve=t[61];let Re;t[62]!==S.taskId||t[63]!==ve?(Re=n.jsx(Ce.ActiveTaskProvider,{taskId:S.taskId,children:ve},S.taskId),t[62]=S.taskId,t[63]=ve,t[64]=Re):Re=t[64];let ne;t[65]!==x||t[66]!==Y||t[67]!==ee||t[68]!==ae||t[69]!==ue||t[70]!==Re||t[71]!==u?(ne=n.jsxs(da,{virtualMcpId:u,hasActiveGithubRepo:x,vmMap:ee,children:[ae,ue,Re,Y]}),t[65]=x,t[66]=Y,t[67]=ee,t[68]=ae,t[69]=ue,t[70]=Re,t[71]=u,t[72]=ne):ne=t[72];let le;t[73]!==I||t[74]!==ne?(le=n.jsx("div",{className:"flex flex-col flex-1 bg-background min-h-0",children:n.jsx(Ce.Provider,{virtualMcpId:I,children:ne},I)}),t[73]=I,t[74]=ne,t[75]=le):le=t[75];let De;return t[76]!==y||t[77]!==le?(De=n.jsx(hs,{value:y,children:le}),t[76]=y,t[77]=le,t[78]=De):De=t[78],De}const N=r?void 0:S.createNewTask;let C;t[79]!==S.chatOpen||t[80]!==S.toggleChat||t[81]!==N?(C=n.jsx(br.Toggles,{children:n.jsx(Vv,{chatOpen:S.chatOpen,toggleChat:S.toggleChat,onNewTask:N})}),t[79]=S.chatOpen,t[80]=S.toggleChat,t[81]=N,t[82]=C):C=t[82];let j;t[83]!==S.taskId||t[84]!==u?(j=n.jsx(br.Tabs,{children:n.jsx(rc,{virtualMcpId:u,taskId:S.taskId})}),t[83]=S.taskId,t[84]=u,t[85]=j):j=t[85];const M=m?.metadata?.vmMap;let D;t[86]!==S.createNewTask?(D=n.jsx(ha,{onNewTaskRef:P,createNewTask:S.createNewTask}),t[86]=S.createNewTask,t[87]=D):D=t[87];let F;t[88]!==m?(F=n.jsx(d1,{virtualMcp:m}),t[88]=m,t[89]=F):F=t[89];let H;t[90]===Symbol.for("react.memo_cache_sentinel")?(H=n.jsx(Ce.Skeleton,{}),t[90]=H):H=t[90];let O;t[91]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(ca,{}),t[91]=O):O=t[91];let $;t[92]!==S.chatOpen||t[93]!==S.mainOpen||t[94]!==S.taskId||t[95]!==u?($=n.jsx(A.Suspense,{fallback:H,children:n.jsx(Uv,{virtualMcpId:u,taskId:S.taskId,chatOpen:S.chatOpen,mainOpen:S.mainOpen,chatContent:O})}),t[92]=S.chatOpen,t[93]=S.mainOpen,t[94]=S.taskId,t[95]=u,t[96]=$):$=t[96];let W;t[97]!==S.taskId||t[98]!==F||t[99]!==$?(W=n.jsxs(Ce.ActiveTaskProvider,{taskId:S.taskId,children:[F,$]},S.taskId),t[97]=S.taskId,t[98]=F,t[99]=$,t[100]=W):W=t[100];let K;t[101]!==x||t[102]!==M||t[103]!==D||t[104]!==W||t[105]!==u?(K=n.jsxs(da,{virtualMcpId:u,hasActiveGithubRepo:x,vmMap:M,children:[D,W]}),t[101]=x,t[102]=M,t[103]=D,t[104]=W,t[105]=u,t[106]=K):K=t[106];let re;t[107]!==I||t[108]!==j||t[109]!==K?(re=n.jsxs(Ce.Provider,{virtualMcpId:I,children:[j,K]},I),t[107]=I,t[108]=j,t[109]=K,t[110]=re):re=t[110];let Z;return t[111]!==y||t[112]!==C||t[113]!==re?(Z=n.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:n.jsxs(hs,{value:y,children:[C,re]})}),t[111]=y,t[112]=C,t[113]=re,t[114]=Z):Z=t[114],Z}function p1(){const t=z.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(A.Suspense,{fallback:n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(Be,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(_1,{})}),t[0]=e):e=t[0],e}const zx=Object.freeze(Object.defineProperty({__proto__:null,default:p1,useInsetContext:nc},Symbol.toStringTag,{value:"Module"}));export{Zf as e,zx as i,Yf as u};
|