decocms 2.336.3 → 2.336.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/{AlertCircle-CzC7ZSK_.js → AlertCircle-CjrkFJHK.js} +1 -1
- package/dist/client/assets/{Archive-Dm6jw2g7.js → Archive-BarCxwpE.js} +1 -1
- package/dist/client/assets/{ArrowNarrowLeft-_lTR-4c4.js → ArrowNarrowLeft-DRE-cw-S.js} +1 -1
- package/dist/client/assets/{ArrowUpRight-DDhTZtsb.js → ArrowUpRight-BKdj1VbG.js} +1 -1
- package/dist/client/assets/{Check-OeHnl9E3.js → Check-DdYluJck.js} +1 -1
- package/dist/client/assets/{CheckCircle-Cp9l-YHW.js → CheckCircle-kHO0pa51.js} +1 -1
- package/dist/client/assets/{ChevronDown-CuYGosfw.js → ChevronDown-BAKjIgXh.js} +1 -1
- package/dist/client/assets/{ChevronRight-BauQJC5s.js → ChevronRight-B-8LusXJ.js} +1 -1
- package/dist/client/assets/{ChevronUp-DnmsZgEN.js → ChevronUp-D7QboKdc.js} +1 -1
- package/dist/client/assets/{Container-AaJdoi4_.js → Container-CmUnLpsX.js} +1 -1
- package/dist/client/assets/{DotsVertical-CfckZVJs.js → DotsVertical-CnVO0OpB.js} +1 -1
- package/dist/client/assets/{LayoutLeft-DxHYCN7c.js → LayoutLeft-BMmAvwCD.js} +1 -1
- package/dist/client/assets/{LinkExternal01-CncWBPZd.js → LinkExternal01-BayTxy65.js} +1 -1
- package/dist/client/assets/{Lock01-CsYhltZK.js → Lock01-8E0Wr0eA.js} +1 -1
- package/dist/client/assets/{Palette-DvNphITe.js → Palette-CpuIFkYy.js} +1 -1
- package/dist/client/assets/{Play-DeGLKrCL.js → Play-CP3hVsFr.js} +1 -1
- package/dist/client/assets/{Plus-D1Yu1xQA.js → Plus-zEhHcjjP.js} +1 -1
- package/dist/client/assets/{RefreshCcw01-DXaEg2ju.js → RefreshCcw01-D552aO61.js} +1 -1
- package/dist/client/assets/{SearchMd-D0CnJpXx.js → SearchMd-s2Jbqw4w.js} +1 -1
- package/dist/client/assets/{Settings02-8TyufenA.js → Settings02-DRw28liT.js} +1 -1
- package/dist/client/assets/{Shield01-lXoz1ncn.js → Shield01-BLttmvSx.js} +1 -1
- package/dist/client/assets/{Star01-DoDKN-GV.js → Star01-BwqTqEjx.js} +1 -1
- package/dist/client/assets/{Sun-Cws8aSyT.js → Sun-Bb3jVOT-.js} +1 -1
- package/dist/client/assets/{Tool01-DhWBzmcZ.js → Tool01-M5BKIVAY.js} +1 -1
- package/dist/client/assets/{Trash01-D-FCHDZZ.js → Trash01-C_wjOvHD.js} +1 -1
- package/dist/client/assets/{Upload01-CFFVHgIn.js → Upload01-CVb_j1Ea.js} +1 -1
- package/dist/client/assets/{User01-DcUuDiue.js → User01-D_P5Q--v.js} +1 -1
- package/dist/client/assets/{Users03-CTLpvWLs.js → Users03-COIo8UWy.js} +1 -1
- package/dist/client/assets/{X-BrHvxfOo.js → X-C1hFR-Mq.js} +1 -1
- package/dist/client/assets/{XCircle-B0MpXTmN.js → XCircle-iHkGWHIc.js} +1 -1
- package/dist/client/assets/{XClose-Cby3mvjS.js → XClose-Dqw-sYW9.js} +1 -1
- package/dist/client/assets/{Zap-DSHZfZ84.js → Zap-bl5P48Ty.js} +1 -1
- package/dist/client/assets/{ZapSquare-DB0hRfEs.js → ZapSquare-CeugHzDH.js} +1 -1
- package/dist/client/assets/{accordion-C441xtb3.js → accordion-Bi61pH6t.js} +1 -1
- package/dist/client/assets/{agent-icon-BUo6_aM4.js → agent-icon-CcklalU6.js} +1 -1
- package/dist/client/assets/{agents-list-CXRrtqkU.js → agents-list-CTsDO1f7.js} +1 -1
- package/dist/client/assets/{ai-providers-aNSRnQht.js → ai-providers-CqaYTO7i.js} +1 -1
- package/dist/client/assets/{alert-dialog-_F7MPtLk.js → alert-dialog-Do1lje0R.js} +1 -1
- package/dist/client/assets/{auth-catchall-CcOBMWou.js → auth-catchall-CGaIO6fM.js} +1 -1
- package/dist/client/assets/{auth-split-layout-CoYJ_GjO.js → auth-split-layout-vN2NXzyk.js} +1 -1
- package/dist/client/assets/{automation-list-row-DkFGPJJb.js → automation-list-row-DSHa8CuV.js} +1 -1
- package/dist/client/assets/{automations-B0h_Mwwk.js → automations-D49ooe_-.js} +1 -1
- package/dist/client/assets/{avatar-C-hYuHcC.js → avatar-C9Zh4tyR.js} +1 -1
- package/dist/client/assets/{badge-dQO5_0CH.js → badge-Bs7dB7fk.js} +1 -1
- package/dist/client/assets/{brand-context-CvV7b3Zr.js → brand-context-_IpnrVa7.js} +1 -1
- package/dist/client/assets/{card-TrAnkZgD.js → card-Duk-DFoS.js} +1 -1
- package/dist/client/assets/{chat-context-Bf2X2OWp.js → chat-context-Dz-0OkSQ.js} +1 -1
- package/dist/client/assets/{checkbox-DzboXJ7g.js → checkbox-DGjeb88W.js} +1 -1
- package/dist/client/assets/{collection-detail-Dol0mwob.js → collection-detail-DvEjvg7q.js} +1 -1
- package/dist/client/assets/{collection-display-button-BFOYENmm.js → collection-display-button-rz1gGhRc.js} +1 -1
- package/dist/client/assets/{collection-search-jfVf7Xuh.js → collection-search-DRDeCr6M.js} +1 -1
- package/dist/client/assets/{collection-search-Bgm1c9Fn.js → collection-search-DcGEPWSE.js} +1 -1
- package/dist/client/assets/{collection-table-wrapper-BW3wOn0e.js → collection-table-wrapper-oOcL0Ck_.js} +1 -1
- package/dist/client/assets/{collection-tabs-D0p8RAMM.js → collection-tabs-C8Rt6HzN.js} +1 -1
- package/dist/client/assets/{collections-BzixHdgJ.js → collections-uiCZSwA4.js} +1 -1
- package/dist/client/assets/{command-DHok21xN.js → command-CDQ1nFDC.js} +1 -1
- package/dist/client/assets/{connection-card-C9DmY_Pl.js → connection-card-BgHIL4-h.js} +1 -1
- package/dist/client/assets/{connection-detail-0UZB9Chu.js → connection-detail-BwAB6eLZ.js} +1 -1
- package/dist/client/assets/{connection-form-helpers-5K_orpeG.js → connection-form-helpers-du3f3VU8.js} +1 -1
- package/dist/client/assets/{connections-DsPSJj9w.js → connections-CJyovduB.js} +1 -1
- package/dist/client/assets/{constants-DVY8UCVe.js → constants-DqGGBYTE.js} +1 -1
- package/dist/client/assets/{constants-ftFug3sX.js → constants-xo9FMQpo.js} +1 -1
- package/dist/client/assets/{dialog-46s22Acb.js → dialog-St5aPWdZ.js} +1 -1
- package/dist/client/assets/{domain-settings-BX8r4WSh.js → domain-settings-BBEfI0Vh.js} +1 -1
- package/dist/client/assets/{drawer-BB8cZ1q7.js → drawer-BCgFeHFj.js} +1 -1
- package/dist/client/assets/{dropdown-menu-BxQ3NUc_.js → dropdown-menu-CDqAiPwR.js} +1 -1
- package/dist/client/assets/{dynamic-plugin-layout-x2_-DLpn.js → dynamic-plugin-layout-Cgsa8r2y.js} +1 -1
- package/dist/client/assets/{empty-state-CGWwjg61.js → empty-state-BHYPz363.js} +1 -1
- package/dist/client/assets/{empty-state-TeLafGjX.js → empty-state-CGAvOv4f.js} +1 -1
- package/dist/client/assets/{extract-connection-data-BiRYgbQi.js → extract-connection-data-BgCPhMgs.js} +1 -1
- package/dist/client/assets/{features-CuAZqchj.js → features-yF_ju6Ln.js} +1 -1
- package/dist/client/assets/{form-DXfV6J45.js → form-Cv07qrVj.js} +1 -1
- package/dist/client/assets/{general-D_fnTODB.js → general-DZT7jNjg.js} +1 -1
- package/dist/client/assets/{index-DMA82FB3.js → index-BRRcywl9.js} +1 -1
- package/dist/client/assets/{index-DddjpQKO.js → index-BbPDaL6X.js} +1 -1
- package/dist/client/assets/{index-Baqf2Om4.js → index-BtkNe4lY.js} +4 -4
- package/dist/client/assets/{index-3iXKo145.js → index-BxLXnZgh.js} +1 -1
- package/dist/client/assets/{index-D5TAB6xe.js → index-CEAbp8FO.js} +1 -1
- package/dist/client/assets/{index-CjfJ06E2.js → index-CejOYsEK.js} +1 -1
- package/dist/client/assets/{index-CEhipwjl.js → index-DVwDV_MY.js} +1 -1
- package/dist/client/assets/{index-BotHcl5q.js → index-Dqlv6mJf.js} +1 -1
- package/dist/client/assets/{index-DY1iUQhc.js → index-DvxxDj72.js} +1 -1
- package/dist/client/assets/{index-BuUlIKPQ.js → index-QzOB-31G.js} +1 -1
- package/dist/client/assets/{index-C4DeTdLr.js → index-RCQgT-6h.js} +1 -1
- package/dist/client/assets/{index-Cdzy04L7.js → index-RLSWM5YA.js} +1 -1
- package/dist/client/assets/{index-B7eI0KJG.js → index-bKmeYupE.js} +1 -1
- package/dist/client/assets/{index--iYBXjoV.js → index-caHAHcCO.js} +1 -1
- package/dist/client/assets/{index-FoCGERXy.js → index-p5lQwl0X.js} +2 -2
- package/dist/client/assets/{index-CtJAFqgR.js → index-vzH_WuWs.js} +1 -1
- package/dist/client/assets/{infiniteQueryObserver-Behzbev4.js → infiniteQueryObserver-DQBPaPTZ.js} +1 -1
- package/dist/client/assets/{input-CrrEpoEp.js → input-BETjeJzT.js} +1 -1
- package/dist/client/assets/{integration-icon-CmZ6WWq3.js → integration-icon-ZFFOKUiG.js} +1 -1
- package/dist/client/assets/{label-TV-nrPhr.js → label-Zof__E9D.js} +1 -1
- package/dist/client/assets/{layout-Cuyy2-HU.js → layout-JRIkAJfX.js} +1 -1
- package/dist/client/assets/{lean-canvas-recruit-modal-DUGKrUYC.js → lean-canvas-recruit-modal-Dfphbztu.js} +1 -1
- package/dist/client/assets/{login-DLZVBoxI.js → login-DdkOCob0.js} +1 -1
- package/dist/client/assets/{members-DQvftob-.js → members-3kFDw1fg.js} +1 -1
- package/dist/client/assets/{monaco-editor-MgD8oOHb.js → monaco-editor-YOb0zHH-.js} +1 -1
- package/dist/client/assets/{monitoring-stats-row-gKichnvy.js → monitoring-stats-row-DAFWWitp.js} +1 -1
- package/dist/client/assets/{oauth-callback-DTkQAIop.js → oauth-callback-B2qQrcYg.js} +1 -1
- package/dist/client/assets/{oauth-callback-ai-provider-EbUe8ye-.js → oauth-callback-ai-provider-CcYXF7OS.js} +1 -1
- package/dist/client/assets/{onboarding-CYkuplNq.js → onboarding-B5EMIAOE.js} +1 -1
- package/dist/client/assets/{org-layout-CgjOWhmI.js → org-layout-B9hxDFp3.js} +1 -1
- package/dist/client/assets/{org-plugin-layout-DXcMY-Pq.js → org-plugin-layout-rfzmvcF1.js} +1 -1
- package/dist/client/assets/{pair-Dna8m7R6.js → pair-Jb7zWXq9.js} +1 -1
- package/dist/client/assets/{plugin-empty-state-BmTIZA6g.js → plugin-empty-state-Dp9C6PON.js} +1 -1
- package/dist/client/assets/{plugin-header-DsFKKKau.js → plugin-header-Cb65k0-c.js} +1 -1
- package/dist/client/assets/{plugin-layout-BCwKWave.js → plugin-layout--tTlDKXK.js} +1 -1
- package/dist/client/assets/{popover-BtksO74_.js → popover-BslyxYEb.js} +1 -1
- package/dist/client/assets/{profile-CUHLGlg3.js → profile-zeVuWClo.js} +1 -1
- package/dist/client/assets/{project-app-view-BWOVxJN2.js → project-app-view-CsMPFfW3.js} +1 -1
- package/dist/client/assets/registry-BNG88dZe.js +2 -0
- package/dist/client/assets/{registry-layout--lCA4XAs.js → registry-layout-C2reYjPW.js} +1 -1
- package/dist/client/assets/{required-auth-layout-BMnvWTk_.js → required-auth-layout-C3c1U3dT.js} +1 -1
- package/dist/client/assets/{reset-password-fUfHgOil.js → reset-password-Dzswot6h.js} +1 -1
- package/dist/client/assets/{roles-BeMf1FFe.js → roles-BAHRjdHB.js} +1 -1
- package/dist/client/assets/{scroll-area-D3D4HjQS.js → scroll-area-COOkrs3n.js} +1 -1
- package/dist/client/assets/{search-input-D7EWawQW.js → search-input-v0O-M_8S.js} +1 -1
- package/dist/client/assets/{sections-editor-CtUZTN7D.js → sections-editor-BikVGLU0.js} +1 -1
- package/dist/client/assets/{select-ir24AxQp.js → select-C3glAc_e.js} +1 -1
- package/dist/client/assets/{select-model-CBfzhE3A.js → select-model-Dtm0JmWL.js} +1 -1
- package/dist/client/assets/{settings-layout-CKcrXczS.js → settings-layout-BPB2eIrJ.js} +1 -1
- package/dist/client/assets/{settings-section-DV-cVfy0.js → settings-section-k4FViU80.js} +1 -1
- package/dist/client/assets/{shell-layout-BJKgEgV7.js → shell-layout-DS-5RUnm.js} +1 -1
- package/dist/client/assets/{sidebar-BotVRwI9.js → sidebar-BjZcW3Qm.js} +1 -1
- package/dist/client/assets/{skeleton-BHgefywY.js → skeleton-BBSMvSv5.js} +1 -1
- package/dist/client/assets/{spinner-D315AV7Y.js → spinner-C6RVycM7.js} +1 -1
- package/dist/client/assets/{sso-D-5l3NVf.js → sso-BjH7KtFs.js} +1 -1
- package/dist/client/assets/{store-BWyqjvUf.js → store-CnGenqMn.js} +1 -1
- package/dist/client/assets/store-registry-KA76pMnR.js +2 -0
- package/dist/client/assets/{switch-jtsj2wdW.js → switch-owpJeyq4.js} +1 -1
- package/dist/client/assets/{table-CJ9eUMdG.js → table-DwQBc3Dq.js} +1 -1
- package/dist/client/assets/{tabs-CiyAXKZE.js → tabs-hU89DoA1.js} +1 -1
- package/dist/client/assets/{task-status-Bqz7roZE.js → task-status-CS9JzVC1.js} +1 -1
- package/dist/client/assets/{textarea-CmaQk80Y.js → textarea-DLh_1ULt.js} +1 -1
- package/dist/client/assets/{thread-actions-CSvId1Rl.js → thread-actions-DTSL-BSS.js} +1 -1
- package/dist/client/assets/{toggle-group-CJP54sxI.js → toggle-group-D_BQlgOr.js} +1 -1
- package/dist/client/assets/{tools-list-BC1r9vrS.js → tools-list-DGOABzmh.js} +1 -1
- package/dist/client/assets/{tooltip-BGUfs8eQ.js → tooltip-B_71WVRV.js} +1 -1
- package/dist/client/assets/{types-CkZDdnl4.js → types-B-rR5vzy.js} +1 -1
- package/dist/client/assets/{use-ai-providers-BeFAHT7o.js → use-ai-providers-cWjUNZ9V.js} +1 -1
- package/dist/client/assets/{use-collections-B6jBEagC.js → use-collections-DsZF9hhL.js} +1 -1
- package/dist/client/assets/{use-connection-CBIh_u5I.js → use-connection-CJS5rEpQ.js} +1 -1
- package/dist/client/assets/{use-copy-B2bX2XHK.js → use-copy-9NpnXT3D.js} +1 -1
- package/dist/client/assets/{use-create-virtual-mcp-Baxvcs40.js → use-create-virtual-mcp-C0jf4Eq5.js} +1 -1
- package/dist/client/assets/{use-debounced-autosave-Ca-FI4MH.js → use-debounced-autosave-692EDLpe.js} +1 -1
- package/dist/client/assets/{use-decopilot-events-CbU-7L1f.js → use-decopilot-events-CP9EmOJV.js} +1 -1
- package/dist/client/assets/{use-delete-connection-fPl38ASM.js → use-delete-connection-eZhFrPPD.js} +1 -1
- package/dist/client/assets/{use-infinite-scroll-5wqBXRIl.js → use-infinite-scroll-Blg-LfdS.js} +1 -1
- package/dist/client/assets/{use-list-state-DwplKDOM.js → use-list-state-BkwSi7VI.js} +1 -1
- package/dist/client/assets/{use-mcp-tools-Ccl7f7pg.js → use-mcp-tools-D9aWBmgr.js} +1 -1
- package/dist/client/assets/{use-members-Tu1ahDBc.js → use-members-D1c4zRia.js} +1 -1
- package/dist/client/assets/{use-navigate-to-agent-amzqWRHl.js → use-navigate-to-agent-DVB8wqjx.js} +1 -1
- package/dist/client/assets/{use-org-auth-client-M7mzFZVt.js → use-org-auth-client-BuT92bYP.js} +1 -1
- package/dist/client/assets/{use-org-sso-fTSI4QpJ.js → use-org-sso-DWBoHAbr.js} +1 -1
- package/dist/client/assets/{use-organization-roles-ZK2ePHU_.js → use-organization-roles-1lEzc5zO.js} +1 -1
- package/dist/client/assets/{use-organization-settings-CrVYRtNy.js → use-organization-settings--xeUNSBg.js} +1 -1
- package/dist/client/assets/{use-registry-connections-DXoIwXsU.js → use-registry-connections-pNJLal6m.js} +1 -1
- package/dist/client/assets/{use-status-sounds-jOhmINqN.js → use-status-sounds-DqqGv1Uq.js} +1 -1
- package/dist/client/assets/{use-view-mode-BINwPckK.js → use-view-mode-DzI-oB5o.js} +1 -1
- package/dist/client/assets/{use-virtual-mcp-CnxTU9Pu.js → use-virtual-mcp-U3tI_7Qc.js} +1 -1
- package/dist/client/assets/useInfiniteQuery-CJm0m8_T.js +1 -0
- package/dist/client/assets/{useRouterState-Dpdpe-dA.js → useRouterState-BDSagFd7.js} +1 -1
- package/dist/client/assets/{user-CMZUKFYl.js → user-_zRnyYsB.js} +1 -1
- package/dist/client/assets/{view-mode-toggle-u8UibRw0.js → view-mode-toggle-BN8C_nyX.js} +1 -1
- package/dist/client/assets/{workflow-C22wf-_w.js → workflow-DfUJc3xU.js} +1 -1
- package/dist/client/assets/workflow-detail-BcJVuFms.js +1 -0
- package/dist/client/index.html +1 -1
- package/dist/server/cli.js +335 -335
- package/dist/server/node_modules/@opentelemetry/otlp-transformer/build/esm/generated/root.js +6 -36
- 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 +0 -15
- 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 +6 -36
- 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 +0 -15
- 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 +6 -36
- 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 +0 -15
- 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 +14 -12
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/InstrumentDescriptor.js +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/InstrumentDescriptor.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/Instruments.d.ts +3 -3
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/Instruments.js +6 -6
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/Instruments.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/Meter.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/Meter.js +2 -2
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/Meter.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/ObservableResult.d.ts +3 -3
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/ObservableResult.js +5 -5
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/ObservableResult.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/aggregator/ExponentialHistogram.d.ts +3 -3
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/aggregator/ExponentialHistogram.js +17 -17
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/aggregator/ExponentialHistogram.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/aggregator/Histogram.d.ts +3 -3
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/aggregator/Histogram.js +8 -8
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/aggregator/Histogram.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/aggregator/LastValue.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/aggregator/LastValue.js +2 -2
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/aggregator/LastValue.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/aggregator/Sum.d.ts +2 -2
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/aggregator/Sum.js +3 -3
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/aggregator/Sum.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/aggregator/exponential-histogram/Buckets.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/aggregator/exponential-histogram/Buckets.js +2 -2
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/aggregator/exponential-histogram/Buckets.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/export/ConsoleMetricExporter.js +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/export/ConsoleMetricExporter.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/export/MetricReader.js +3 -3
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/export/MetricReader.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/export/PeriodicExportingMetricReader.js +14 -21
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/export/PeriodicExportingMetricReader.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/state/AsyncMetricStorage.d.ts +2 -2
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/state/AsyncMetricStorage.js +4 -4
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/state/AsyncMetricStorage.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/state/DeltaMetricProcessor.d.ts +2 -2
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/state/DeltaMetricProcessor.js +3 -3
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/state/DeltaMetricProcessor.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/state/HashMap.d.ts +2 -2
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/state/HashMap.js +3 -3
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/state/HashMap.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/state/MeterProviderSharedState.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/state/MeterProviderSharedState.js +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/state/MeterProviderSharedState.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/state/MeterSharedState.d.ts +3 -3
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/state/MeterSharedState.js +11 -12
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/state/MeterSharedState.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/state/MetricCollector.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/state/MetricCollector.js +3 -3
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/state/MetricCollector.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/state/MetricStorage.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/state/MetricStorage.js +2 -2
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/state/MetricStorage.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/state/MultiWritableMetricStorage.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/state/MultiWritableMetricStorage.js +2 -2
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/state/MultiWritableMetricStorage.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/state/ObservableRegistry.js +4 -4
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/state/ObservableRegistry.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/state/SyncMetricStorage.d.ts +2 -2
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/state/SyncMetricStorage.js +4 -4
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/state/SyncMetricStorage.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/state/TemporalMetricProcessor.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/state/TemporalMetricProcessor.js +2 -2
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/state/TemporalMetricProcessor.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/utils.d.ts +19 -0
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/utils.js +36 -0
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/utils.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/version.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/version.js +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/version.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/view/Aggregation.d.ts +3 -3
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/view/Aggregation.js +6 -6
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/view/Aggregation.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/view/AttributesProcessor.js +12 -16
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esm/view/AttributesProcessor.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/InstrumentDescriptor.js +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/InstrumentDescriptor.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/Instruments.d.ts +3 -3
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/Instruments.js +6 -6
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/Instruments.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/Meter.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/Meter.js +2 -2
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/Meter.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/ObservableResult.d.ts +3 -3
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/ObservableResult.js +5 -5
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/ObservableResult.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/aggregator/ExponentialHistogram.d.ts +3 -3
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/aggregator/ExponentialHistogram.js +17 -17
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/aggregator/ExponentialHistogram.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/aggregator/Histogram.d.ts +3 -3
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/aggregator/Histogram.js +8 -8
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/aggregator/Histogram.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/aggregator/LastValue.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/aggregator/LastValue.js +2 -2
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/aggregator/LastValue.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/aggregator/Sum.d.ts +2 -2
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/aggregator/Sum.js +3 -3
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/aggregator/Sum.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/aggregator/exponential-histogram/Buckets.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/aggregator/exponential-histogram/Buckets.js +2 -2
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/aggregator/exponential-histogram/Buckets.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/export/ConsoleMetricExporter.js +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/export/ConsoleMetricExporter.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/export/MetricReader.js +3 -3
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/export/MetricReader.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/export/PeriodicExportingMetricReader.js +14 -21
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/export/PeriodicExportingMetricReader.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/state/AsyncMetricStorage.d.ts +2 -2
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/state/AsyncMetricStorage.js +4 -4
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/state/AsyncMetricStorage.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/state/DeltaMetricProcessor.d.ts +2 -2
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/state/DeltaMetricProcessor.js +3 -3
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/state/DeltaMetricProcessor.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/state/HashMap.d.ts +2 -2
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/state/HashMap.js +3 -3
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/state/HashMap.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/state/MeterProviderSharedState.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/state/MeterProviderSharedState.js +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/state/MeterProviderSharedState.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/state/MeterSharedState.d.ts +3 -3
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/state/MeterSharedState.js +11 -12
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/state/MeterSharedState.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/state/MetricCollector.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/state/MetricCollector.js +3 -3
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/state/MetricCollector.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/state/MetricStorage.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/state/MetricStorage.js +2 -2
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/state/MetricStorage.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/state/MultiWritableMetricStorage.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/state/MultiWritableMetricStorage.js +2 -2
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/state/MultiWritableMetricStorage.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/state/ObservableRegistry.js +4 -4
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/state/ObservableRegistry.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/state/SyncMetricStorage.d.ts +2 -2
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/state/SyncMetricStorage.js +4 -4
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/state/SyncMetricStorage.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/state/TemporalMetricProcessor.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/state/TemporalMetricProcessor.js +2 -2
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/state/TemporalMetricProcessor.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/utils.d.ts +19 -0
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/utils.js +36 -0
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/utils.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/version.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/version.js +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/version.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/view/Aggregation.d.ts +3 -3
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/view/Aggregation.js +6 -6
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/view/Aggregation.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/view/AttributesProcessor.js +12 -16
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/esnext/view/AttributesProcessor.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/InstrumentDescriptor.js +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/InstrumentDescriptor.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/Instruments.d.ts +3 -3
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/Instruments.js +6 -6
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/Instruments.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/Meter.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/Meter.js +2 -2
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/Meter.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/ObservableResult.d.ts +3 -3
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/ObservableResult.js +5 -5
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/ObservableResult.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/aggregator/ExponentialHistogram.d.ts +3 -3
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/aggregator/ExponentialHistogram.js +17 -17
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/aggregator/ExponentialHistogram.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/aggregator/Histogram.d.ts +3 -3
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/aggregator/Histogram.js +8 -8
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/aggregator/Histogram.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/aggregator/LastValue.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/aggregator/LastValue.js +2 -2
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/aggregator/LastValue.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/aggregator/Sum.d.ts +2 -2
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/aggregator/Sum.js +3 -3
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/aggregator/Sum.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/aggregator/exponential-histogram/Buckets.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/aggregator/exponential-histogram/Buckets.js +2 -2
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/aggregator/exponential-histogram/Buckets.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/export/ConsoleMetricExporter.js +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/export/ConsoleMetricExporter.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/export/MetricReader.js +2 -2
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/export/MetricReader.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/export/PeriodicExportingMetricReader.js +14 -21
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/export/PeriodicExportingMetricReader.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/state/AsyncMetricStorage.d.ts +2 -2
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/state/AsyncMetricStorage.js +4 -4
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/state/AsyncMetricStorage.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/state/DeltaMetricProcessor.d.ts +2 -2
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/state/DeltaMetricProcessor.js +3 -3
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/state/DeltaMetricProcessor.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/state/HashMap.d.ts +2 -2
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/state/HashMap.js +3 -3
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/state/HashMap.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/state/MeterProviderSharedState.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/state/MeterProviderSharedState.js +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/state/MeterProviderSharedState.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/state/MeterSharedState.d.ts +3 -3
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/state/MeterSharedState.js +11 -12
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/state/MeterSharedState.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/state/MetricCollector.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/state/MetricCollector.js +3 -3
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/state/MetricCollector.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/state/MetricStorage.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/state/MetricStorage.js +2 -2
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/state/MetricStorage.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/state/MultiWritableMetricStorage.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/state/MultiWritableMetricStorage.js +2 -2
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/state/MultiWritableMetricStorage.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/state/ObservableRegistry.js +3 -3
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/state/ObservableRegistry.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/state/SyncMetricStorage.d.ts +2 -2
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/state/SyncMetricStorage.js +4 -4
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/state/SyncMetricStorage.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/state/TemporalMetricProcessor.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/state/TemporalMetricProcessor.js +2 -2
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/state/TemporalMetricProcessor.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/utils.d.ts +19 -0
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/utils.js +41 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/utils.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/version.d.ts +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/version.js +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/version.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/view/Aggregation.d.ts +3 -3
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/view/Aggregation.js +6 -6
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/view/Aggregation.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/view/AttributesProcessor.js +12 -16
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/build/src/view/AttributesProcessor.js.map +1 -1
- package/dist/server/node_modules/@opentelemetry/sdk-metrics/package.json +6 -6
- package/dist/server/node_modules/ansi-styles/index.d.ts +236 -0
- package/dist/server/node_modules/ansi-styles/index.js +223 -0
- package/dist/server/node_modules/{ansi-regex → ansi-styles}/package.json +13 -20
- package/dist/server/node_modules/ansi-styles/readme.md +173 -0
- package/dist/server/node_modules/pg/README.md +89 -0
- package/dist/server/node_modules/pg/lib/client.js +631 -0
- package/dist/server/node_modules/pg/lib/connection-parameters.js +167 -0
- package/dist/server/node_modules/pg/lib/connection.js +223 -0
- package/dist/server/node_modules/pg/lib/crypto/sasl.js +186 -0
- package/dist/server/node_modules/pg/lib/crypto/utils-legacy.js +37 -0
- package/dist/server/node_modules/pg/lib/crypto/utils-webcrypto.js +83 -0
- package/dist/server/node_modules/pg/lib/crypto/utils.js +9 -0
- package/dist/server/node_modules/pg/lib/defaults.js +84 -0
- package/dist/server/node_modules/pg/lib/index.js +58 -0
- package/dist/server/node_modules/pg/lib/native/client.js +307 -0
- package/dist/server/node_modules/pg/lib/native/index.js +2 -0
- package/dist/server/node_modules/pg/lib/native/query.js +165 -0
- package/dist/server/node_modules/pg/lib/query.js +241 -0
- package/dist/server/node_modules/pg/lib/result.js +107 -0
- package/dist/server/node_modules/pg/lib/stream.js +28 -0
- package/dist/server/node_modules/pg/lib/type-overrides.js +35 -0
- package/dist/server/node_modules/pg/lib/utils.js +204 -0
- package/dist/server/node_modules/pg/package.json +64 -0
- package/package.json +1 -1
- package/dist/client/assets/registry-BCqaEJ8H.js +0 -2
- package/dist/client/assets/store-registry-DQjxL3Jx.js +0 -2
- package/dist/client/assets/useInfiniteQuery-TyulAqFt.js +0 -1
- package/dist/client/assets/workflow-detail-ZnX2RbsG.js +0 -1
- package/dist/server/node_modules/ansi-regex/index.d.ts +0 -33
- package/dist/server/node_modules/ansi-regex/index.js +0 -14
- package/dist/server/node_modules/ansi-regex/readme.md +0 -66
- package/dist/server/node_modules/emoji-regex/LICENSE-MIT.txt +0 -20
- package/dist/server/node_modules/emoji-regex/README.md +0 -107
- package/dist/server/node_modules/emoji-regex/index.d.ts +0 -3
- package/dist/server/node_modules/emoji-regex/index.js +0 -4
- package/dist/server/node_modules/emoji-regex/index.mjs +0 -4
- package/dist/server/node_modules/emoji-regex/package.json +0 -45
- package/dist/server/node_modules/pg-cloudflare/README.md +0 -112
- package/dist/server/node_modules/pg-cloudflare/dist/empty.d.ts +0 -2
- package/dist/server/node_modules/pg-cloudflare/dist/empty.js +0 -6
- package/dist/server/node_modules/pg-cloudflare/dist/empty.js.map +0 -1
- package/dist/server/node_modules/pg-cloudflare/dist/index.d.ts +0 -31
- package/dist/server/node_modules/pg-cloudflare/dist/index.js +0 -152
- package/dist/server/node_modules/pg-cloudflare/dist/index.js.map +0 -1
- package/dist/server/node_modules/pg-cloudflare/esm/index.mjs +0 -3
- package/dist/server/node_modules/pg-cloudflare/package.json +0 -39
- package/dist/server/node_modules/pg-cloudflare/src/empty.ts +0 -3
- package/dist/server/node_modules/pg-cloudflare/src/index.ts +0 -166
- package/dist/server/node_modules/pg-cloudflare/src/types.d.ts +0 -25
- package/dist/server/node_modules/pg-int8/LICENSE +0 -13
- package/dist/server/node_modules/pg-int8/README.md +0 -16
- package/dist/server/node_modules/pg-int8/index.js +0 -100
- package/dist/server/node_modules/pg-int8/package.json +0 -24
- package/dist/server/node_modules/postgres-array/index.d.ts +0 -4
- package/dist/server/node_modules/postgres-array/index.js +0 -97
- package/dist/server/node_modules/postgres-array/license +0 -21
- package/dist/server/node_modules/postgres-array/package.json +0 -35
- package/dist/server/node_modules/postgres-array/readme.md +0 -43
- package/dist/server/node_modules/postgres-bytea/index.js +0 -33
- package/dist/server/node_modules/postgres-bytea/license +0 -21
- package/dist/server/node_modules/postgres-bytea/package.json +0 -34
- package/dist/server/node_modules/postgres-bytea/readme.md +0 -34
- package/dist/server/node_modules/postgres-date/index.js +0 -116
- package/dist/server/node_modules/postgres-date/license +0 -21
- package/dist/server/node_modules/postgres-date/package.json +0 -33
- package/dist/server/node_modules/postgres-date/readme.md +0 -49
- package/dist/server/node_modules/postgres-interval/index.d.ts +0 -20
- package/dist/server/node_modules/postgres-interval/index.js +0 -125
- package/dist/server/node_modules/postgres-interval/license +0 -21
- package/dist/server/node_modules/postgres-interval/package.json +0 -36
- package/dist/server/node_modules/postgres-interval/readme.md +0 -48
- package/dist/server/node_modules/protobufjs/LICENSE +0 -39
- package/dist/server/node_modules/protobufjs/README.md +0 -727
- package/dist/server/node_modules/protobufjs/dist/light/protobuf.js +0 -7839
- package/dist/server/node_modules/protobufjs/dist/light/protobuf.js.map +0 -1
- package/dist/server/node_modules/protobufjs/dist/light/protobuf.min.js +0 -8
- package/dist/server/node_modules/protobufjs/dist/light/protobuf.min.js.map +0 -1
- package/dist/server/node_modules/protobufjs/dist/minimal/protobuf.js +0 -2736
- package/dist/server/node_modules/protobufjs/dist/minimal/protobuf.js.map +0 -1
- package/dist/server/node_modules/protobufjs/dist/minimal/protobuf.min.js +0 -8
- package/dist/server/node_modules/protobufjs/dist/minimal/protobuf.min.js.map +0 -1
- package/dist/server/node_modules/protobufjs/dist/protobuf.js +0 -9643
- package/dist/server/node_modules/protobufjs/dist/protobuf.js.map +0 -1
- package/dist/server/node_modules/protobufjs/dist/protobuf.min.js +0 -8
- package/dist/server/node_modules/protobufjs/dist/protobuf.min.js.map +0 -1
- package/dist/server/node_modules/protobufjs/ext/debug/README.md +0 -4
- package/dist/server/node_modules/protobufjs/ext/debug/index.js +0 -71
- package/dist/server/node_modules/protobufjs/ext/descriptor/README.md +0 -72
- package/dist/server/node_modules/protobufjs/ext/descriptor/index.d.ts +0 -191
- package/dist/server/node_modules/protobufjs/ext/descriptor/index.js +0 -1162
- package/dist/server/node_modules/protobufjs/ext/descriptor/test.js +0 -54
- package/dist/server/node_modules/protobufjs/google/LICENSE +0 -27
- package/dist/server/node_modules/protobufjs/google/README.md +0 -1
- package/dist/server/node_modules/protobufjs/google/api/annotations.json +0 -83
- package/dist/server/node_modules/protobufjs/google/api/annotations.proto +0 -11
- package/dist/server/node_modules/protobufjs/google/api/http.json +0 -86
- package/dist/server/node_modules/protobufjs/google/api/http.proto +0 -31
- package/dist/server/node_modules/protobufjs/google/protobuf/api.json +0 -118
- package/dist/server/node_modules/protobufjs/google/protobuf/api.proto +0 -34
- package/dist/server/node_modules/protobufjs/google/protobuf/descriptor.json +0 -1382
- package/dist/server/node_modules/protobufjs/google/protobuf/descriptor.proto +0 -535
- package/dist/server/node_modules/protobufjs/google/protobuf/source_context.json +0 -20
- package/dist/server/node_modules/protobufjs/google/protobuf/source_context.proto +0 -7
- package/dist/server/node_modules/protobufjs/google/protobuf/type.json +0 -202
- package/dist/server/node_modules/protobufjs/google/protobuf/type.proto +0 -89
- package/dist/server/node_modules/protobufjs/index.d.ts +0 -2799
- package/dist/server/node_modules/protobufjs/index.js +0 -4
- package/dist/server/node_modules/protobufjs/light.d.ts +0 -2
- package/dist/server/node_modules/protobufjs/light.js +0 -4
- package/dist/server/node_modules/protobufjs/minimal.d.ts +0 -2
- package/dist/server/node_modules/protobufjs/minimal.js +0 -4
- package/dist/server/node_modules/protobufjs/package.json +0 -114
- package/dist/server/node_modules/protobufjs/scripts/postinstall.js +0 -32
- package/dist/server/node_modules/protobufjs/src/common.js +0 -399
- package/dist/server/node_modules/protobufjs/src/converter.js +0 -301
- package/dist/server/node_modules/protobufjs/src/decoder.js +0 -127
- package/dist/server/node_modules/protobufjs/src/encoder.js +0 -100
- package/dist/server/node_modules/protobufjs/src/enum.js +0 -223
- package/dist/server/node_modules/protobufjs/src/field.js +0 -453
- package/dist/server/node_modules/protobufjs/src/index-light.js +0 -104
- package/dist/server/node_modules/protobufjs/src/index-minimal.js +0 -36
- package/dist/server/node_modules/protobufjs/src/index.js +0 -12
- package/dist/server/node_modules/protobufjs/src/mapfield.js +0 -126
- package/dist/server/node_modules/protobufjs/src/message.js +0 -143
- package/dist/server/node_modules/protobufjs/src/method.js +0 -160
- package/dist/server/node_modules/protobufjs/src/namespace.js +0 -546
- package/dist/server/node_modules/protobufjs/src/object.js +0 -378
- package/dist/server/node_modules/protobufjs/src/oneof.js +0 -222
- package/dist/server/node_modules/protobufjs/src/parse.js +0 -969
- package/dist/server/node_modules/protobufjs/src/reader.js +0 -416
- package/dist/server/node_modules/protobufjs/src/reader_buffer.js +0 -51
- package/dist/server/node_modules/protobufjs/src/root.js +0 -404
- package/dist/server/node_modules/protobufjs/src/roots.js +0 -18
- package/dist/server/node_modules/protobufjs/src/rpc/service.js +0 -142
- package/dist/server/node_modules/protobufjs/src/rpc.js +0 -36
- package/dist/server/node_modules/protobufjs/src/service.js +0 -189
- package/dist/server/node_modules/protobufjs/src/tokenize.js +0 -416
- package/dist/server/node_modules/protobufjs/src/type.js +0 -615
- package/dist/server/node_modules/protobufjs/src/types.js +0 -196
- package/dist/server/node_modules/protobufjs/src/typescript.jsdoc +0 -15
- package/dist/server/node_modules/protobufjs/src/util/longbits.js +0 -200
- package/dist/server/node_modules/protobufjs/src/util/minimal.js +0 -438
- package/dist/server/node_modules/protobufjs/src/util.js +0 -215
- package/dist/server/node_modules/protobufjs/src/verifier.js +0 -177
- package/dist/server/node_modules/protobufjs/src/wrappers.js +0 -102
- package/dist/server/node_modules/protobufjs/src/writer.js +0 -465
- package/dist/server/node_modules/protobufjs/src/writer_buffer.js +0 -85
- package/dist/server/node_modules/protobufjs/tsconfig.json +0 -8
- package/dist/server/node_modules/split2/LICENSE +0 -13
- package/dist/server/node_modules/split2/README.md +0 -85
- package/dist/server/node_modules/split2/bench.js +0 -27
- package/dist/server/node_modules/split2/index.js +0 -141
- package/dist/server/node_modules/split2/package.json +0 -39
- package/dist/server/node_modules/split2/test.js +0 -409
- package/dist/server/node_modules/xtend/.jshintrc +0 -30
- package/dist/server/node_modules/xtend/LICENSE +0 -20
- package/dist/server/node_modules/xtend/README.md +0 -32
- package/dist/server/node_modules/xtend/immutable.js +0 -19
- package/dist/server/node_modules/xtend/mutable.js +0 -17
- package/dist/server/node_modules/xtend/package.json +0 -55
- package/dist/server/node_modules/xtend/test.js +0 -103
- /package/dist/server/node_modules/{ansi-regex → ansi-styles}/license +0 -0
- /package/dist/server/node_modules/{pg-cloudflare → pg}/LICENSE +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/sections-editor-
|
|
2
|
-
import{p as hs,r as B,q as ql,s as Gl,e as $,c as ie,j as o,l as He,B as re,E as Rt,v as ve,b as Zr,a as Yo,w as Xo,f as Vt,d as Jo,x as Yl,K as Fs,o as me,y as lr,V as Xl,t as ye,C as mt,z as Zo,D as Jl,F as Zl,G as kn,n as Qr,L as Ql,H as Oi,I as Ys,J as ct,M as _i,_ as Qo,P as ec,Q as ea,R as ta,T as tc,g as sc}from"./index-FoCGERXy.js";import{C as Se,b as ic,w as rc,A as nc,c as oc,d as ac,S as lc,e as Nn,u as cc,a as cr,f as hc,g as dc}from"./index-C4DeTdLr.js";import{I as qt}from"./integration-icon-CmZ6WWq3.js";import{u as Ve,K as uc,g as sa,S as Gt,a as ia}from"./constants-DVY8UCVe.js";import{u as yt,a as fc}from"./use-virtual-mcp-CnxTU9Pu.js";import{a as mc}from"./Users03-CTLpvWLs.js";import{u as Yt,a as Pt,b as en,t as _c,d as jn}from"./chat-context-Bf2X2OWp.js";import{i as tn}from"./AlertCircle-CzC7ZSK_.js";import{i as pc}from"./CheckCircle-Cp9l-YHW.js";import{a as En,n as gc}from"./ZapSquare-DB0hRfEs.js";import{i as vc,a as xc,b as sn,c as bc}from"./XCircle-B0MpXTmN.js";import{s as as,i as Sc}from"./XClose-Cby3mvjS.js";import{c as yc,r as wc,p as ra,f as Tn,a as Cc,F as kc,t as Rn,M as rn,G as Nc,i as jc,b as Ec,d as Tc,e as Rc}from"./pair-Dna8m7R6.js";import{C as Dn,a as Mn,b as Dc,c as Mc,d as Pc,e as Ic,f as Ac}from"./command-DHok21xN.js";import{P as ds,a as us,b as fs}from"./popover-BtksO74_.js";import{i as Ms,a as Bc,b as Lc,p as Ci,g as ki,c as nn,d as na,h as hr,e as $i,f as Pn,A as In,j as on,k as Oc,l as $c,n as zc,t as Fc,m as Hc,s as Wc,o as oa,q as aa,r as la,u as Uc,v as ca,w as An,x as ha,y as Ps,z as Kc,B as da,C as ua}from"./agent-icon-BUo6_aM4.js";import{u as Vc}from"./useInfiniteQuery-TyulAqFt.js";import{u as qc}from"./use-ai-providers-BeFAHT7o.js";import{g as Ht,a as Gc,T as Yc}from"./index-CEhipwjl.js";import{u as an,i as Xc}from"./shell-layout-BJKgEgV7.js";import{u as Jc,c as Zc,d as Qc,e as eh}from"./sidebar-BotVRwI9.js";import{u as fa,T as Re,a as De,b as Me,c as th}from"./tooltip-BGUfs8eQ.js";import{u as sh}from"./use-status-sounds-jOhmINqN.js";import{E as pi}from"./empty-state-CGWwjg61.js";import{A as ih,a as rh,b as nh,c as oh,R as ma,d as ah,e as lh}from"./accordion-C441xtb3.js";import{u as Ni,a as ln,b as ch}from"./use-connection-CBIh_u5I.js";import{g as hh}from"./constants-ftFug3sX.js";import{u as dh,g as uh}from"./types-CkZDdnl4.js";import{G as fh,u as _a}from"./lean-canvas-recruit-modal-DUGKrUYC.js";import{U as pa}from"./user-CMZUKFYl.js";import{T as mh,u as ga}from"./tools-list-BC1r9vrS.js";import{u as _h}from"./unwrap-tool-result-BYXdCQMg.js";import{s as va,g as ph}from"./connection-slug-eyAPH6o3.js";import{A as xa,a as ba,b as Sa,c as ya,d as wa,e as Ca,f as ka,g as Na}from"./alert-dialog-_F7MPtLk.js";import{D as gh,a as cn,b as hn,c as ja,d as Ea}from"./dialog-46s22Acb.js";import{C as Ta,a as dr}from"./card-TrAnkZgD.js";import{I as Xt}from"./input-CrrEpoEp.js";import{L as Ot}from"./label-TV-nrPhr.js";import{S as is,a as rs,b as ns,c as os,d as Mt}from"./select-ir24AxQp.js";import{S as ur}from"./switch-jtsj2wdW.js";import{T as Bn}from"./textarea-CmaQk80Y.js";import{i as Wt}from"./Play-DeGLKrCL.js";import{s as ls}from"./Plus-D1Yu1xQA.js";import{a as vh}from"./Settings02-8TyufenA.js";import{t as Ra,i as xh}from"./Tool01-DhWBzmcZ.js";import{s as fr}from"./Trash01-D-FCHDZZ.js";import{u as gi}from"./use-debounced-autosave-Ca-FI4MH.js";import{S as dn}from"./scroll-area-D3D4HjQS.js";import{i as Da,a as bh}from"./SearchMd-D0CnJpXx.js";import{i as Sh}from"./Upload01-CFFVHgIn.js";import{i as yh}from"./LayoutLeft-DxHYCN7c.js";import{P as at}from"./index-DMA82FB3.js";import{C as wh}from"./collection-tabs-D0p8RAMM.js";import{C as Ch}from"./checkbox-DzboXJ7g.js";import{u as kh,a as Hs}from"./use-mcp-tools-Ccl7f7pg.js";import{u as Nh,T as zi,a as jh,b as Eh,c as Fi}from"./tabs-CiyAXKZE.js";import{D as Th,a as Rh,b as Dh}from"./drawer-BB8cZ1q7.js";import{i as ji}from"./Check-OeHnl9E3.js";import{n as ms}from"./LinkExternal01-CncWBPZd.js";import{S as Mh}from"./spinner-D315AV7Y.js";import{D as Ei,a as Ti,b as Ri,c as $t,d as Ph,e as Ih,f as Ah}from"./dropdown-menu-BxQ3NUc_.js";import{t as un}from"./ChevronDown-CuYGosfw.js";import{p as Bh}from"./thread-actions-CSvId1Rl.js";import{i as Ma}from"./RefreshCcw01-DXaEg2ju.js";import{V as Lh}from"./view-mode-toggle-u8UibRw0.js";import{i as Oh}from"./X-BrHvxfOo.js";import{u as Ws,a as $h,b as zh,c as Fh,A as Hh,d as Wh}from"./automation-list-row-DkFGPJJb.js";import{i as Bs}from"./Zap-DSHZfZ84.js";import{S as Uh}from"./search-input-D7EWawQW.js";function Kh(t,e){const s=hs(e);return Vh({filters:{...t,status:"pending"}},s).length}function Ln(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function Vh(t={},e){const s=hs(e).getMutationCache(),i=B.useRef(t),r=B.useRef(null);return r.current===null&&(r.current=Ln(s,t)),B.useEffect(()=>{i.current=t}),B.useSyncExternalStore(B.useCallback(n=>s.subscribe(()=>{const a=ql(r.current,Ln(s,i.current));r.current!==a&&(r.current=a,Gl.schedule(n))}),[s]),()=>r.current,()=>r.current)}function xs(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function On(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 qh(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function Gh(t){const e=$.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(Yh),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=o.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 Yh(t){return o.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[o.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),o.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function Xh(t){const e=$.c(30),{userTokens:s,assistantTokens:i,otherTokens:r}=t,n=s+i+r,a=n>0?s/n*100:0,l=n>0?i/n*100:0,h=n>0?r/n*100:0;let c;e[0]!==a?(c=a>0&&o.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&&o.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&&o.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=o.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=o.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=o.jsxs("div",{className:"flex items-center gap-1.5",children:[m,o.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",_,"%"]})]}),e[13]=_,e[14]=p):p=e[14];let v;e[15]===Symbol.for("react.memo_cache_sentinel")?(v=o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=v):v=e[15];let x;e[16]!==l?(x=l.toFixed(1),e[16]=l,e[17]=x):x=e[17];let b;e[18]!==x?(b=o.jsxs("div",{className:"flex items-center gap-1.5",children:[v,o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",x,"%"]})]}),e[18]=x,e[19]=b):b=e[19];let S;e[20]!==h||e[21]!==r?(S=r>0&&o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",h.toFixed(1),"%"]})]}),e[20]=h,e[21]=r,e[22]=S):S=e[22];let g;e[23]!==b||e[24]!==S||e[25]!==p?(g=o.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[p,b,S]}),e[23]=b,e[24]=S,e[25]=p,e[26]=g):g=e[26];let w;return e[27]!==g||e[28]!==f?(w=o.jsxs("div",{className:"flex flex-col gap-2",children:[f,g]}),e[27]=g,e[28]=f,e[29]=w):w=e[29],w}function Jh(t){const e=$.c(11),{agentId:s,isError:i}=t,r=yt(s),n=r?.title??"Subtask",a=r?.icon??null;let l;e[0]!==a||e[1]!==n?(l=o.jsx(qt,{icon:a,name:n,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=n,e[2]=l):l=e[2];const h=i?"text-destructive":"text-foreground";let c;e[3]!==h?(c=ie("shrink-0 font-medium",h),e[3]=h,e[4]=c):c=e[4];let d;e[5]!==n||e[6]!==c?(d=o.jsx("span",{className:c,children:n}),e[5]=n,e[6]=c,e[7]=d):d=e[7];let u;return e[8]!==l||e[9]!==d?(u=o.jsxs(o.Fragment,{children:[l,d]}),e[8]=l,e[9]=d,e[10]=u):u=e[10],u}function Zh(t){const e=$.c(5),{isError:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(qt,{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 n;e[1]!==r?(n=ie("shrink-0 font-medium",r),e[1]=r,e[2]=n):n=e[2];let a;return e[3]!==n?(a=o.jsxs(o.Fragment,{children:[i,o.jsx("span",{className:n,children:"Subtask"})]}),e[3]=n,e[4]=a):a=e[4],a}function Qh(t){const e=$.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,n=s.state==="output-error",a=s.state==="approval-requested";let l;e[0]!==n?(l=o.jsx(Zh,{isError:n}),e[0]=n,e[1]=l):l=e[1];let h;e[2]!==i||e[3]!==n?(h=o.jsx(Jh,{agentId:i,isError:n}),e[2]=i,e[3]=n,e[4]=h):h=e[4];let c;e[5]!==l||e[6]!==h?(c=o.jsx(B.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&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-muted-foreground/50",children:"·"}),o.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]!==n||e[12]!==r?(u=o.jsx("span",{className:"ml-auto shrink-0",children:r?o.jsx(He,{size:12,className:"animate-spin text-muted-foreground"}):n?o.jsx(vc,{size:12,className:"text-destructive"}):a?o.jsx(tn,{size:12,className:"text-warning"}):o.jsx(pc,{size:12,className:"text-emerald-500"})}),e[10]=a,e[11]=n,e[12]=r,e[13]=u):u=e[13];let f;return e[14]!==c||e[15]!==d||e[16]!==u?(f=o.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 ed(t){const e=$.c(58),{onClose:s,back:i,className:r}=t,[n,a]=B.useState(null),{messages:l}=Yt(),{tasks:h,taskId:c}=Pt(),{selectedModel:d,selectedVirtualMcp:u}=en();let f,m,_,p,v,x,b,S;if(e[0]!==i||e[1]!==r||e[2]!==l||e[3]!==s||e[4]!==n?.id||e[5]!==d||e[6]!==u?.title||e[7]!==c||e[8]!==h){S=Symbol.for("react.early_return_sentinel");e:{let k;e[17]!==c?(k=V=>V.id===c,e[17]=c,e[18]=k):k=e[18];const C=h.find(k),N=yc(l),T=[...l].reverse().find(dd),L=T?.metadata?.usage,M=T?.metadata?.modelLimits?.contextWindow??d?.limits?.contextWindow??null,D=L?.contextTokens??L?.totalTokens??0,y=M&&M>0?(D/M*100).toFixed(1):null,R=l;let E;e[19]!==R?(E=R.filter(hd).reduce(cd,0),e[19]=R,e[20]=E):E=e[20];const j=E,I=l;let P;e[21]!==I?(P=I.filter(ld).reduce(ad,0),e[21]=I,e[22]=P):P=e[22];const z=P,U=Math.max(0,N.totalTokens-j-z),W=l[0],H=l.at(-1),G=W?.metadata?.created_at??C?.created_at,K=H?.metadata?.created_at??C?.updated_at,se=l.filter(od),Y=l.flatMap(rd),J=d?.modelId?qh(d.modelId):"—",ee=u?.title??"Decopilot",A=[{label:"Session",value:C?.title??"New chat"},{label:"Messages",value:se.length},{label:"Agent",value:ee},{label:"Model",value:J},{label:"Context Limit",value:M?xs(M):"—"},{label:"Session Tokens (billed)",value:N.totalTokens>0?xs(N.totalTokens):"0"},{label:"Usage",value:y!==null?`${y}%`:"—"},{label:"Input Tokens",value:N.inputTokens>0?xs(N.inputTokens):"0"},{label:"Output Tokens",value:N.outputTokens>0?xs(N.outputTokens):"0"},{label:"Reasoning Tokens",value:N.reasoningTokens>0?xs(N.reasoningTokens):"0"},{label:"Cost",value:N.cost>0?`$${N.cost<.001?N.cost.toFixed(6):N.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:On(G)},{label:"Last Activity",value:On(K)}];if(!C&&se.length===0){let V;e[23]!==r?(V=ie("flex flex-col h-full w-full border-l border-border bg-background",r),e[23]=r,e[24]=V):V=e[24];let ne;e[25]===Symbol.for("react.memo_cache_sentinel")?(ne=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[25]=ne):ne=e[25];let he;e[26]!==i?(he=i?o.jsx(En,{size:14,className:"text-muted-foreground"}):o.jsx(as,{size:14,className:"text-muted-foreground"}),e[26]=i,e[27]=he):he=e[27];let ce;e[28]!==s||e[29]!==he?(ce=o.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[ne,o.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:he})]}),e[28]=s,e[29]=he,e[30]=ce):ce=e[30];let de;e[31]===Symbol.for("react.memo_cache_sentinel")?(de=o.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:o.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a conversation to see context"})}),e[31]=de):de=e[31];let fe;e[32]!==V||e[33]!==ce?(fe=o.jsxs("div",{className:V,children:[ce,de]}),e[32]=V,e[33]=ce,e[34]=fe):fe=e[34],S=fe;break e}e[35]!==r?(x=ie("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",r),e[35]=r,e[36]=x):x=e[36];let X;e[37]===Symbol.for("react.memo_cache_sentinel")?(X=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[37]=X):X=e[37];let Q;e[38]!==i?(Q=i?o.jsx(En,{size:14}):o.jsx(as,{size:14}),e[38]=i,e[39]=Q):Q=e[39],e[40]!==s||e[41]!==Q?(b=o.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[X,o.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:Q})]}),e[40]=s,e[41]=Q,e[42]=b):b=e[42],f="flex flex-col gap-8 p-6",m=Y.length>0&&o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"Subtasks"}),o.jsx("div",{className:"flex flex-col gap-1",children:Y.map(id)})]}),_=o.jsx(Gh,{items:A});let F;e[43]===Symbol.for("react.memo_cache_sentinel")?(F=o.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[43]=F):F=e[43],e[44]!==z||e[45]!==U||e[46]!==j?(p=o.jsxs("div",{className:"flex flex-col gap-3",children:[F,o.jsx(Xh,{userTokens:j,assistantTokens:z,otherTokens:U})]}),e[44]=z,e[45]=U,e[46]=j,e[47]=p):p=e[47],v=se.length>0&&o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"Raw messages"}),o.jsx("div",{className:"flex flex-col gap-1",children:se.map(V=>{const ne=V.metadata?.created_at,he=n?.id===V.id;return o.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[o.jsxs("button",{type:"button",onClick:()=>a(he?null:V),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:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx("span",{className:ie("shrink-0 font-medium",V.role==="user"?"text-chart-1":"text-chart-2"),children:V.role}),o.jsx("span",{className:"text-muted-foreground",children:"•"}),o.jsx("span",{className:"truncate text-muted-foreground font-mono",children:V.id})]}),ne&&o.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(ne).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),he&&o.jsxs(o.Fragment,{children:[V.role==="assistant"&&(()=>{const ce=V.metadata?._request;if(!ce)return null;const de=ce.systemSections??[],fe=Math.max(1,...de.map(sd)),Be=de.reduce(td,0);return o.jsxs("div",{className:"border-t border-border/50 px-3 py-2.5 text-xs space-y-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"font-medium text-foreground",children:"Request"}),o.jsxs("span",{className:"text-muted-foreground tabular-nums",children:[ce.activeTools??0," / ",ce.tools??0," ","tools active"]})]}),de.length>0&&o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("div",{className:"text-muted-foreground",children:["System prompt"," ",o.jsxs("span",{className:"tabular-nums",children:["~",Math.round(Be/4).toLocaleString()," ","tok"]})]}),de.map((Ne,je)=>{const Je=Ne.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${je}`,Le=Ne.chars/fe*100,vs=Math.round(Ne.chars/4);return o.jsxs("div",{className:"space-y-0.5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx("span",{className:"font-mono text-foreground truncate",children:Je}),o.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:["~",vs.toLocaleString()," tok"]})]}),o.jsx("div",{className:"h-1 w-full rounded-full bg-muted overflow-hidden",children:o.jsx("div",{className:"h-full rounded-full bg-chart-3",style:{width:`${Le}%`}})})]},je)})]})]})})(),o.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(V,null,2)})]})]},V.id)})})]})}e[0]=i,e[1]=r,e[2]=l,e[3]=s,e[4]=n?.id,e[5]=d,e[6]=u?.title,e[7]=c,e[8]=h,e[9]=f,e[10]=m,e[11]=_,e[12]=p,e[13]=v,e[14]=x,e[15]=b,e[16]=S}else f=e[9],m=e[10],_=e[11],p=e[12],v=e[13],x=e[14],b=e[15],S=e[16];if(S!==Symbol.for("react.early_return_sentinel"))return S;let g;e[48]!==f||e[49]!==m||e[50]!==_||e[51]!==p||e[52]!==v?(g=o.jsxs("div",{className:f,children:[m,_,p,v]}),e[48]=f,e[49]=m,e[50]=_,e[51]=p,e[52]=v,e[53]=g):g=e[53];let w;return e[54]!==x||e[55]!==b||e[56]!==g?(w=o.jsxs("div",{className:x,children:[b,g]}),e[54]=x,e[55]=b,e[56]=g,e[57]=w):w=e[57],w}function td(t,e){return t+e.chars}function sd(t){return t.chars}function id(t,e){return o.jsx(Qh,{part:t},e)}function rd(t){return(t.parts??[]).filter(nd)}function nd(t){return t.type==="tool-subtask"}function od(t){return t.role!=="system"}function ad(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function ld(t){return t.role==="assistant"}function cd(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function hd(t){return t.role==="user"}function dd(t){return t.role==="assistant"&&t.metadata?.usage}const $n=["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"],zn=["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 ud(){const t=$n[Math.floor(Math.random()*$n.length)],e=zn[Math.floor(Math.random()*zn.length)];return`deco/${t}-${e}`}const oi=100;function fd(t,e,s){const i=e.trim().toLowerCase();return i?(t??[]).some(r=>r.branches.some(n=>typeof n.name=="string"&&!s.has(n.name)&&n.name.toLowerCase().includes(i))):!0}function md(t,e){const s=e.trim().toLowerCase();return s?[...t].some(i=>i.toLowerCase().includes(s)):!0}function _d(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=$.c(48),{orgId:s,orgSlug:i,userId:r,connectionId:n,vmMap:a,owner:l,repo:h,enabled:c}=t,d=c===void 0?!0:c,u=n??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=Ve(f);let _;e[4]!==n||e[5]!==s||e[6]!==i||e[7]!==l||e[8]!==h?(_=uc.githubBranches(s,i,n,l,h),e[4]=n,e[5]=s,e[6]=i,e[7]=l,e[8]=h,e[9]=_):_=e[9];const p=d&&!!n&&!!l&&!!h;let v;e[10]!==m||e[11]!==l||e[12]!==h?(v=async W=>{const{pageParam:H,signal:G}=W,K=Number(H),se=await m.callTool({name:"list_branches",arguments:{owner:l,repo:h,page:K,perPage:oi}},void 0,{signal:G}),Y=_d(se);return{branches:Array.isArray(Y)?Y:Y.branches??[],default_branch:Array.isArray(Y)?null:Y.default_branch??null,page:K}},e[10]=m,e[11]=l,e[12]=h,e[13]=v):v=e[13];let x;e[14]!==_||e[15]!==p||e[16]!==v?(x={queryKey:_,enabled:p,staleTime:3e4,retry:!1,initialPageParam:1,queryFn:v,getNextPageParam:yd},e[14]=_,e[15]=p,e[16]=v,e[17]=x):x=e[17];const{data:b,isLoading:S,isError:g,hasNextPage:w,isFetchingNextPage:k,fetchNextPage:C}=Vc(x);let N,T;e[18]!==r||e[19]!==a?(T=new Set(Object.keys(a?.[r]??{})),N=[...T].sort().map(Sd),e[18]=r,e[19]=a,e[20]=N,e[21]=T):(N=e[20],T=e[21]);const L=N;let M;if(e[22]!==b?.pages){const W=new Map;for(const G of b?.pages??[])for(const K of G.branches)typeof K.name=="string"&&W.set(K.name,K);M=[...W.values()].filter(bd),e[22]=b?.pages,e[23]=M}else M=e[23];let D;e[24]!==M||e[25]!==T?(D=M.filter(W=>!T.has(W.name)).map(xd),e[24]=M,e[25]=T,e[26]=D):D=e[26];const y=D;let R;e[27]!==b?.pages?(R=b?.pages.find(vd)?.default_branch??null,e[27]=b?.pages,e[28]=R):R=e[28];const E=R;let j;e[29]!==b?.pages||e[30]!==C||e[31]!==k||e[32]!==T?(j=async(W,H)=>{const G=H===void 0?gd:H;if(!G()||md(T,W)||k)return;let K=b?.pages??[];for(;G()&&!fd(K,W,T)&&(K.at(-1)?.branches.length??oi)>=oi;){const se=await C();if(!G())break;const Y=se.data?.pages??K;if(Y.length===K.length)break;K=Y}},e[29]=b?.pages,e[30]=C,e[31]=k,e[32]=T,e[33]=j):j=e[33];const I=j,P=w??!1;let z;e[34]!==C||e[35]!==w||e[36]!==k?(z=()=>{w&&!k&&C()},e[34]=C,e[35]=w,e[36]=k,e[37]=z):z=e[37];let U;return e[38]!==E||e[39]!==I||e[40]!==g||e[41]!==k||e[42]!==S||e[43]!==y||e[44]!==P||e[45]!==z||e[46]!==L?(U={yours:L,others:y,defaultBase:E,isLoading:S,isError:g,hasMore:P,isFetchingMore:k,fetchMore:z,fetchUntilMatch:I},e[38]=E,e[39]=I,e[40]=g,e[41]=k,e[42]=S,e[43]=y,e[44]=P,e[45]=z,e[46]=L,e[47]=U):U=e[47],U}function gd(){return!0}function vd(t){return t.default_branch}function xd(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 Sd(t){return{name:t,source:"yours"}}function yd(t){if(!(t.branches.length<oi))return t.page+1}function wd(t){const e=$.c(61),{orgId:s,orgSlug:i,userId:r,connectionId:n,owner:a,repo:l,vmMap:h,value:c,onChange:d}=t,[u,f]=B.useState(!1),[m,_]=B.useState(""),[p,v]=B.useState(!1),x=B.useRef(0);let b;e[0]!==n||e[1]!==u||e[2]!==s||e[3]!==i||e[4]!==a||e[5]!==l||e[6]!==r||e[7]!==h?(b={orgId:s,orgSlug:i,userId:r,connectionId:n,vmMap:h,owner:a,repo:l,enabled:u},e[0]=n,e[1]=u,e[2]=s,e[3]=i,e[4]=a,e[5]=l,e[6]=r,e[7]=h,e[8]=b):b=e[8];const{yours:S,others:g,isLoading:w,isError:k,hasMore:C,isFetchingMore:N,fetchMore:T,fetchUntilMatch:L}=pd(b);let M;e[9]!==d?(M=F=>{d(F),f(!1)},e[9]=d,e[10]=M):M=e[10];const D=M,y=c??"Select branch…";let R;e[11]!==L?(R=F=>{_(F),x.current=x.current+1;const V=x.current,ne=F.trim();if(!ne){v(!1);return}v(!0),L(ne,()=>V===x.current).finally(()=>{V===x.current&&v(!1)})},e[11]=L,e[12]=R):R=e[12];const E=R;let j;e[13]!==T?(j=F=>{const V=F.currentTarget;V.scrollHeight-V.scrollTop-V.clientHeight<48&&T()},e[13]=T,e[14]=j):j=e[14];const I=j;let P;e[15]===Symbol.for("react.memo_cache_sentinel")?(P=o.jsx(Ms,{className:"h-3.5 w-3.5"}),e[15]=P):P=e[15];let z;e[16]!==y?(z=o.jsx(ds,{asChild:!0,children:o.jsxs(re,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 font-mono text-xs",children:[P,o.jsx("span",{className:"max-w-[200px] truncate",children:y})]})}),e[16]=y,e[17]=z):z=e[17];let U;e[18]!==E||e[19]!==m?(U=o.jsx(Mc,{placeholder:"Search loaded branches…",value:m,onValueChange:E}),e[18]=E,e[19]=m,e[20]=U):U=e[20];let W;e[21]!==D?(W=o.jsx(re,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>D(ud()),children:"New"}),e[21]=D,e[22]=W):W=e[22];let H;e[23]!==U||e[24]!==W?(H=o.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:[U,W]}),e[23]=U,e[24]=W,e[25]=H):H=e[25];let G;e[26]!==k?(G=k&&o.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]=G):G=e[27];let K;e[28]!==C||e[29]!==k||e[30]!==w?(K=!k&&!w&&o.jsx(Pc,{children:C?"Looking through more branches...":"No branches found."}),e[28]=C,e[29]=k,e[30]=w,e[31]=K):K=e[31];let se;e[32]!==D||e[33]!==S?(se=S.length>0&&o.jsx(Dn,{heading:"Your branches",children:S.map(F=>o.jsxs(Mn,{value:F.name,onSelect:()=>D(F.name),children:[o.jsx(Ms,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:F.name})]},F.name))}),e[32]=D,e[33]=S,e[34]=se):se=e[34];let Y;e[35]!==g||e[36]!==D?(Y=g.length>0&&o.jsxs(o.Fragment,{children:[o.jsx(Dc,{}),o.jsx(Dn,{heading:"Other branches in repo",children:g.map(F=>o.jsxs(Mn,{value:F.name,onSelect:()=>D(F.name),children:[o.jsx(Ms,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:F.name}),F.author&&o.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",F.author]})]},F.name))})]}),e[35]=g,e[36]=D,e[37]=Y):Y=e[37];let J;e[38]!==T||e[39]!==C||e[40]!==N||e[41]!==p?(J=C&&o.jsx("div",{className:"border-t p-2",children:o.jsx(re,{variant:"ghost",size:"sm",className:"h-7 w-full text-xs",disabled:N,onClick:T,children:N||p?"Loading more…":"Load more branches"})}),e[38]=T,e[39]=C,e[40]=N,e[41]=p,e[42]=J):J=e[42];let ee;e[43]!==C||e[44]!==g.length?(ee=!C&&g.length>0&&o.jsx("div",{className:"border-t p-2 text-center text-xs text-muted-foreground",children:"All loaded"}),e[43]=C,e[44]=g.length,e[45]=ee):ee=e[45];let A;e[46]!==I||e[47]!==G||e[48]!==K||e[49]!==se||e[50]!==Y||e[51]!==J||e[52]!==ee?(A=o.jsxs(Ic,{onScroll:I,children:[G,K,se,Y,J,ee]}),e[46]=I,e[47]=G,e[48]=K,e[49]=se,e[50]=Y,e[51]=J,e[52]=ee,e[53]=A):A=e[53];let X;e[54]!==A||e[55]!==H?(X=o.jsx(us,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:o.jsxs(Ac,{children:[H,A]})}),e[54]=A,e[55]=H,e[56]=X):X=e[56];let Q;return e[57]!==u||e[58]!==X||e[59]!==z?(Q=o.jsxs(fs,{open:u,onOpenChange:f,children:[z,X]}),e[57]=u,e[58]=X,e[59]=z,e[60]=Q):Q=e[60],Q}function Cd(){const t=$.c(27),{org:e}=ve(),{selectedVirtualMcp:s}=en(),{data:i}=Zr.useSession(),{currentBranch:r,setCurrentTaskBranch:n}=Pt();let a;t[0]!==e.id?(a=sa(e.id),t[0]=e.id,t[1]=a):a=t[1];const h=s??a,c=yt(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=o.jsx(mc,{size:32}),t[2]=m):m=t[2];let _;t[3]!==h.icon||t[4]!==h.title?(_=o.jsx(qt,{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=o.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 v=h.description??"Ask anything about configuring model providers or using MCP Mesh.";let x;t[8]!==v?(x=o.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:v}),t[8]=v,t[9]=x):x=t[9];let b;t[10]!==r||t[11]!==c?.metadata?.vmMap||t[12]!==u||t[13]!==e.id||t[14]!==e.slug||t[15]!==n||t[16]!==f||t[17]!==d?(b=f&&o.jsx("div",{className:"mt-2",children:o.jsx(wd,{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:n})}),t[10]=r,t[11]=c?.metadata?.vmMap,t[12]=u,t[13]=e.id,t[14]=e.slug,t[15]=n,t[16]=f,t[17]=d,t[18]=b):b=t[18];let S;t[19]!==_||t[20]!==p||t[21]!==x||t[22]!==b?(S=o.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[_,p,x,b]}),t[19]=_,t[20]=p,t[21]=x,t[22]=b,t[23]=S):S=t[23];let g;t[24]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("div",{className:"w-full max-w-3xl mx-auto",children:o.jsx(Se.IceBreakers,{})}),t[24]=g):g=t[24];let w;return t[25]!==S?(w=o.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center gap-6 px-4",children:[S,g]}),t[25]=S,t[26]=w):w=t[26],w}function kd(){const t=$.c(26),{org:e}=ve(),s=qc(),{isChatEmpty:i}=Yt(),[r,n]=B.useState("chat"),a=ic();if(s.length===0){let S;return t[0]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(Se,{className:"animate-in fade-in-0 duration-200",children:o.jsx(Se.Main,{className:"flex flex-col items-center",children:o.jsx(Se.EmptyState,{children:o.jsx(Se.NoAiProviderEmptyState,{})})})}),t[0]=S):S=t[0],S}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&&!rc(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&&o.jsx(Se.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=ie("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?o.jsxs(o.Fragment,{children:[o.jsx(Se.Main,{children:o.jsx(Cd,{})}),o.jsx(Se.Footer,{children:o.jsx(Se.Input,{onOpenContextPanel:()=>n("context")})})]}):o.jsxs(o.Fragment,{children:[o.jsx(Se.Main,{children:o.jsx(Se.Messages,{})}),o.jsx(Se.Footer,{children:o.jsx(Se.Input,{onOpenContextPanel:()=>n("context")})})]}),t[12]=i,t[13]=f):f=t[13];let m;t[14]!==u||t[15]!==f?(m=o.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=ie("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",_),t[17]=_,t[18]=p):p=t[18];let v;t[19]===Symbol.for("react.memo_cache_sentinel")?(v=o.jsx(ed,{back:!0,onClose:()=>n("chat")}),t[19]=v):v=t[19];let x;t[20]!==p?(x=o.jsx("div",{className:p,children:v}),t[20]=p,t[21]=x):x=t[21];let b;return t[22]!==c||t[23]!==m||t[24]!==x?(b=o.jsxs(Se,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[c,m,x]}),t[22]=c,t[23]=m,t[24]=x,t[25]=b):b=t[25],b}function Pa(){const t=$.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(Se.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsx(Rt,{fallback:e,children:o.jsx(B.Suspense,{fallback:o.jsx(Se.Skeleton,{}),children:o.jsx(kd,{})})}),t[1]=s):s=t[1],s}async function Nd(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 Ia=["VM_START"],Xs=new Map,jd=t=>`${t.virtualMcpId}::${t.branch??""}`,Hi=new Set,ai={mark:(t,e)=>Hi.add(`${t}::${e}`),clear:(t,e)=>Hi.delete(`${t}::${e}`),isStopped:(t,e)=>Hi.has(`${t}::${e}`)};function Aa(t){const e=hs();return Yo({mutationKey:Ia,mutationFn:async s=>{s.branch&&ai.clear(s.virtualMcpId,s.branch);const i=jd(s),r=Xs.get(i);if(r)return r;const n=(async()=>(await Nd(t,"VM_START",s)).structuredContent)();Xs.set(i,n);try{return await n}finally{Xs.get(i)===n&&Xs.delete(i)}},onSuccess:()=>{Xo(e)}})}function Ed(t,e){const s=$.c(3);let i;return s[0]!==e||s[1]!==t?(i={mutationKey:Ia,predicate:n=>{if(!t)return!1;const a=n.state.variables;return!a||a.virtualMcpId!==t?!1:(a.branch??"")===(e??"")}},s[0]=e,s[1]=t,s[2]=i):i=s[2],Kh(i)>0}const Td={settings:Lc,automations:Bc,preview:xc,git:Ms};function Fn(t){const e=Ci(t);if(e.type==="icon"){const s=ki(e.name);return s?{kind:"component",Component:s}:null}return e.type==="url"?{kind:"url",src:e.url}:null}function Wi(t){if(t.kind==="system")return{kind:"component",Component:Td[t.tabId]};const e=Fn(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=Fn(s.icon);return i||{kind:"fallback"}}function Rd(t){const{org:e}=ve(),s=Ve({connectionId:Gt,orgId:e.id,orgSlug:e.slug}),{data:i}=Yl({queryKey:Fs.ensureTask(e.id,t),queryFn:async()=>{if(!s||!t)return null;try{const r=await s.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}});return(r.structuredContent??r).item??null}catch{return null}},select:r=>r?.metadata??null,staleTime:3e4});return i}function Ba(t){const e=$.c(8),s=Vt();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},e[0]=i):i=e[0];const r=Jo(i),n=yt(t.virtualMcpId),a=Rd(t.taskId),{currentBranch:l}=Pt(),h=n?.metadata?.ui??null,c=h?.layout??null,d=c?.tabs??[],u=h?.pinnedViews??[],f=a?.expanded_tools??[],m=!!(n&&Ht(n));let _;e[1]===Symbol.for("react.memo_cache_sentinel")?(_={includeVirtual:!0},e[1]=_):_=e[1];const p=Ni(_),{activeTab:v,mainOpen:x}=wc({mainParam:r.main,metadata:c?{defaultMainView:c.defaultMainView??null,tabs:d.map(Dd)}:null}),b=ra(v),S=[];m&&(S.push({id:"preview",title:"Preview"}),S.push({id:"git",title:l??"git"})),S.push({id:"settings",title:"Settings"}),S.push({id:"automations",title:"Automations"});const g=new Map;for(const T of f){const L=Tn(T.appId,T.toolName);g.set(L,{id:L,title:T.toolName,appId:T.appId,iconKey:T.toolName})}for(const T of u){const L=Tn(T.connectionId,T.toolName);g.set(L,{id:L,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:Wi({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(g.values()).map(T=>({id:T.id,title:T.title,kind:"expanded",icon:Wi({tabId:T.iconKey,kind:"expanded",appId:T.appId,iconUrl:T.iconUrl,connections:p})})),...S.map(T=>({id:T.id,title:T.title,kind:"system",icon:Wi({tabId:T.id,kind:"system",connections:p})}))];let C;return e[4]!==v||e[5]!==x||e[6]!==s?(C=T=>{const L=Cc({clickedId:T,activeTab:v,mainOpen:x});s({to:".",search:M=>({...M,main:L}),replace:!0})},e[4]=v,e[5]=x,e[6]=s,e[7]=C):C=e[7],{activeTab:v,mainOpen:x,setActiveTab:C,systemTabs:S,layoutTabs:d,expandedTools:f,automationTabParsed:b,tabs:k}}function Dd(t){return{id:t.id}}function La(t){const{managerAgentId:e,managerName:s,kind:i,id:r,instructions:n}=t,a=` to improve the instructions of ${i} "${r}". Here are its current instructions.
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/sections-editor-BikVGLU0.js","assets/index-p5lQwl0X.js","assets/index-BQruevEl.css","assets/RefreshCcw01-D552aO61.js","assets/scroll-area-COOkrs3n.js","assets/select-C3glAc_e.js","assets/tooltip-B_71WVRV.js","assets/Check-DdYluJck.js","assets/ChevronDown-BAKjIgXh.js","assets/ChevronUp-D7QboKdc.js","assets/agent-icon-CcklalU6.js","assets/AlertCircle-CjrkFJHK.js","assets/Tool01-M5BKIVAY.js","assets/Archive-BarCxwpE.js","assets/XClose-Dqw-sYW9.js","assets/ArrowNarrowLeft-DRE-cw-S.js","assets/XCircle-iHkGWHIc.js","assets/ArrowUpRight-BKdj1VbG.js","assets/ZapSquare-CeugHzDH.js","assets/Users03-COIo8UWy.js","assets/CheckCircle-kHO0pa51.js","assets/ChevronRight-B-8LusXJ.js","assets/DotsVertical-CnVO0OpB.js","assets/Container-CmUnLpsX.js","assets/Star01-BwqTqEjx.js","assets/Palette-CpuIFkYy.js","assets/SearchMd-s2Jbqw4w.js","assets/LayoutLeft-BMmAvwCD.js","assets/LinkExternal01-BayTxy65.js","assets/Lock01-8E0Wr0eA.js","assets/Sun-Bb3jVOT-.js","assets/Play-CP3hVsFr.js","assets/Plus-zEhHcjjP.js","assets/Settings02-DRw28liT.js","assets/Shield01-BLttmvSx.js","assets/Trash01-C_wjOvHD.js","assets/Upload01-CVb_j1Ea.js","assets/User01-D_P5Q--v.js","assets/X-C1hFR-Mq.js","assets/Zap-bl5P48Ty.js","assets/collection-search-DRDeCr6M.js","assets/input-BETjeJzT.js","assets/textarea-DLh_1ULt.js","assets/label-Zof__E9D.js","assets/switch-owpJeyq4.js","assets/command-CDQ1nFDC.js","assets/index-BbPDaL6X.js","assets/dialog-St5aPWdZ.js","assets/index-RCQgT-6h.js","assets/use-connection-CJS5rEpQ.js","assets/use-collections-DsZF9hhL.js","assets/constants-DqGGBYTE.js","assets/lean-canvas-recruit-modal-Dfphbztu.js","assets/use-navigate-to-agent-DVB8wqjx.js","assets/use-virtual-mcp-U3tI_7Qc.js","assets/collection-search-DcGEPWSE.js","assets/checkbox-DGjeb88W.js","assets/extract-connection-data-BgCPhMgs.js","assets/constants-xo9FMQpo.js","assets/collections-uiCZSwA4.js","assets/drawer-BCgFeHFj.js","assets/integration-icon-ZFFOKUiG.js","assets/use-mcp-tools-D9aWBmgr.js","assets/chat-context-Dz-0OkSQ.js","assets/thread-actions-DTSL-BSS.js","assets/use-decopilot-events-CP9EmOJV.js","assets/create-sse-subscription-CxkOgzKf.js","assets/use-ai-providers-cWjUNZ9V.js","assets/infiniteQueryObserver-DQBPaPTZ.js","assets/use-organization-settings--xeUNSBg.js","assets/shell-layout-DS-5RUnm.js","assets/required-auth-layout-C3c1U3dT.js","assets/useRouterState-BDSagFd7.js","assets/use-org-sso-DWBoHAbr.js","assets/pair-Jb7zWXq9.js","assets/index-QzOB-31G.js","assets/use-copy-9NpnXT3D.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/content-blocks-o63cs2vh.js","assets/types-B-rR5vzy.js","assets/spinner-C6RVycM7.js","assets/tabs-hU89DoA1.js","assets/form-Cv07qrVj.js","assets/toggle-group-D_BQlgOr.js","assets/select-model-Dtm0JmWL.js","assets/skeleton-BBSMvSv5.js","assets/ai-providers-logos-DD3qZ33J.js","assets/avatar-C9Zh4tyR.js","assets/settings-section-k4FViU80.js","assets/card-Duk-DFoS.js","assets/unwrap-tool-result-BYXdCQMg.js","assets/dropdown-menu-CDqAiPwR.js","assets/index-RLSWM5YA.js","assets/question-004-sINsf4GQ.js","assets/connection-slug-eyAPH6o3.js","assets/connection-card-BgHIL4-h.js","assets/use-registry-connections-pNJLal6m.js","assets/useInfiniteQuery-CJm0m8_T.js","assets/collection-tabs-C8Rt6HzN.js","assets/badge-Bs7dB7fk.js","assets/connection-form-helpers-du3f3VU8.js","assets/use-infinite-scroll-Blg-LfdS.js","assets/popover-BslyxYEb.js","assets/index-DVwDV_MY.js","assets/sidebar-BjZcW3Qm.js","assets/alert-dialog-Do1lje0R.js","assets/index-bKmeYupE.js","assets/use-create-virtual-mcp-C0jf4Eq5.js","assets/empty-state-BHYPz363.js","assets/task-status-CS9JzVC1.js","assets/use-status-sounds-DqqGv1Uq.js","assets/accordion-Bi61pH6t.js","assets/user-_zRnyYsB.js","assets/tools-list-DGOABzmh.js","assets/use-debounced-autosave-692EDLpe.js","assets/index-BRRcywl9.js","assets/view-mode-toggle-BN8C_nyX.js","assets/automation-list-row-DSHa8CuV.js","assets/search-input-v0O-M_8S.js","assets/project-app-view-CsMPFfW3.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{p as hs,r as B,q as ql,s as Gl,e as $,c as ie,j as o,l as He,B as re,E as Rt,v as ve,b as Zr,a as Yo,w as Xo,f as Vt,d as Jo,x as Yl,K as Fs,o as me,y as lr,V as Xl,t as ye,C as mt,z as Zo,D as Jl,F as Zl,G as kn,n as Qr,L as Ql,H as Oi,I as Ys,J as ct,M as _i,_ as Qo,P as ec,Q as ea,R as ta,T as tc,g as sc}from"./index-p5lQwl0X.js";import{C as Se,b as ic,w as rc,A as nc,c as oc,d as ac,S as lc,e as Nn,u as cc,a as cr,f as hc,g as dc}from"./index-RCQgT-6h.js";import{I as qt}from"./integration-icon-ZFFOKUiG.js";import{u as Ve,K as uc,g as sa,S as Gt,a as ia}from"./constants-DqGGBYTE.js";import{u as yt,a as fc}from"./use-virtual-mcp-U3tI_7Qc.js";import{a as mc}from"./Users03-COIo8UWy.js";import{u as Yt,a as Pt,b as en,t as _c,d as jn}from"./chat-context-Dz-0OkSQ.js";import{i as tn}from"./AlertCircle-CjrkFJHK.js";import{i as pc}from"./CheckCircle-kHO0pa51.js";import{a as En,n as gc}from"./ZapSquare-CeugHzDH.js";import{i as vc,a as xc,b as sn,c as bc}from"./XCircle-iHkGWHIc.js";import{s as as,i as Sc}from"./XClose-Dqw-sYW9.js";import{c as yc,r as wc,p as ra,f as Tn,a as Cc,F as kc,t as Rn,M as rn,G as Nc,i as jc,b as Ec,d as Tc,e as Rc}from"./pair-Jb7zWXq9.js";import{C as Dn,a as Mn,b as Dc,c as Mc,d as Pc,e as Ic,f as Ac}from"./command-CDQ1nFDC.js";import{P as ds,a as us,b as fs}from"./popover-BslyxYEb.js";import{i as Ms,a as Bc,b as Lc,p as Ci,g as ki,c as nn,d as na,h as hr,e as $i,f as Pn,A as In,j as on,k as Oc,l as $c,n as zc,t as Fc,m as Hc,s as Wc,o as oa,q as aa,r as la,u as Uc,v as ca,w as An,x as ha,y as Ps,z as Kc,B as da,C as ua}from"./agent-icon-CcklalU6.js";import{u as Vc}from"./useInfiniteQuery-CJm0m8_T.js";import{u as qc}from"./use-ai-providers-cWjUNZ9V.js";import{g as Ht,a as Gc,T as Yc}from"./index-DVwDV_MY.js";import{u as an,i as Xc}from"./shell-layout-DS-5RUnm.js";import{u as Jc,c as Zc,d as Qc,e as eh}from"./sidebar-BjZcW3Qm.js";import{u as fa,T as Re,a as De,b as Me,c as th}from"./tooltip-B_71WVRV.js";import{u as sh}from"./use-status-sounds-DqqGv1Uq.js";import{E as pi}from"./empty-state-BHYPz363.js";import{A as ih,a as rh,b as nh,c as oh,R as ma,d as ah,e as lh}from"./accordion-Bi61pH6t.js";import{u as Ni,a as ln,b as ch}from"./use-connection-CJS5rEpQ.js";import{g as hh}from"./constants-xo9FMQpo.js";import{u as dh,g as uh}from"./types-B-rR5vzy.js";import{G as fh,u as _a}from"./lean-canvas-recruit-modal-Dfphbztu.js";import{U as pa}from"./user-_zRnyYsB.js";import{T as mh,u as ga}from"./tools-list-DGOABzmh.js";import{u as _h}from"./unwrap-tool-result-BYXdCQMg.js";import{s as va,g as ph}from"./connection-slug-eyAPH6o3.js";import{A as xa,a as ba,b as Sa,c as ya,d as wa,e as Ca,f as ka,g as Na}from"./alert-dialog-Do1lje0R.js";import{D as gh,a as cn,b as hn,c as ja,d as Ea}from"./dialog-St5aPWdZ.js";import{C as Ta,a as dr}from"./card-Duk-DFoS.js";import{I as Xt}from"./input-BETjeJzT.js";import{L as Ot}from"./label-Zof__E9D.js";import{S as is,a as rs,b as ns,c as os,d as Mt}from"./select-C3glAc_e.js";import{S as ur}from"./switch-owpJeyq4.js";import{T as Bn}from"./textarea-DLh_1ULt.js";import{i as Wt}from"./Play-CP3hVsFr.js";import{s as ls}from"./Plus-zEhHcjjP.js";import{a as vh}from"./Settings02-DRw28liT.js";import{t as Ra,i as xh}from"./Tool01-M5BKIVAY.js";import{s as fr}from"./Trash01-C_wjOvHD.js";import{u as gi}from"./use-debounced-autosave-692EDLpe.js";import{S as dn}from"./scroll-area-COOkrs3n.js";import{i as Da,a as bh}from"./SearchMd-s2Jbqw4w.js";import{i as Sh}from"./Upload01-CVb_j1Ea.js";import{i as yh}from"./LayoutLeft-BMmAvwCD.js";import{P as at}from"./index-BRRcywl9.js";import{C as wh}from"./collection-tabs-C8Rt6HzN.js";import{C as Ch}from"./checkbox-DGjeb88W.js";import{u as kh,a as Hs}from"./use-mcp-tools-D9aWBmgr.js";import{u as Nh,T as zi,a as jh,b as Eh,c as Fi}from"./tabs-hU89DoA1.js";import{D as Th,a as Rh,b as Dh}from"./drawer-BCgFeHFj.js";import{i as ji}from"./Check-DdYluJck.js";import{n as ms}from"./LinkExternal01-BayTxy65.js";import{S as Mh}from"./spinner-C6RVycM7.js";import{D as Ei,a as Ti,b as Ri,c as $t,d as Ph,e as Ih,f as Ah}from"./dropdown-menu-CDqAiPwR.js";import{t as un}from"./ChevronDown-BAKjIgXh.js";import{p as Bh}from"./thread-actions-DTSL-BSS.js";import{i as Ma}from"./RefreshCcw01-D552aO61.js";import{V as Lh}from"./view-mode-toggle-BN8C_nyX.js";import{i as Oh}from"./X-C1hFR-Mq.js";import{u as Ws,a as $h,b as zh,c as Fh,A as Hh,d as Wh}from"./automation-list-row-DSHa8CuV.js";import{i as Bs}from"./Zap-bl5P48Ty.js";import{S as Uh}from"./search-input-v0O-M_8S.js";function Kh(t,e){const s=hs(e);return Vh({filters:{...t,status:"pending"}},s).length}function Ln(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function Vh(t={},e){const s=hs(e).getMutationCache(),i=B.useRef(t),r=B.useRef(null);return r.current===null&&(r.current=Ln(s,t)),B.useEffect(()=>{i.current=t}),B.useSyncExternalStore(B.useCallback(n=>s.subscribe(()=>{const a=ql(r.current,Ln(s,i.current));r.current!==a&&(r.current=a,Gl.schedule(n))}),[s]),()=>r.current,()=>r.current)}function xs(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function On(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 qh(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function Gh(t){const e=$.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(Yh),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=o.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 Yh(t){return o.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[o.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),o.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function Xh(t){const e=$.c(30),{userTokens:s,assistantTokens:i,otherTokens:r}=t,n=s+i+r,a=n>0?s/n*100:0,l=n>0?i/n*100:0,h=n>0?r/n*100:0;let c;e[0]!==a?(c=a>0&&o.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&&o.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&&o.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=o.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=o.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=o.jsxs("div",{className:"flex items-center gap-1.5",children:[m,o.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",_,"%"]})]}),e[13]=_,e[14]=p):p=e[14];let v;e[15]===Symbol.for("react.memo_cache_sentinel")?(v=o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=v):v=e[15];let x;e[16]!==l?(x=l.toFixed(1),e[16]=l,e[17]=x):x=e[17];let b;e[18]!==x?(b=o.jsxs("div",{className:"flex items-center gap-1.5",children:[v,o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",x,"%"]})]}),e[18]=x,e[19]=b):b=e[19];let S;e[20]!==h||e[21]!==r?(S=r>0&&o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",h.toFixed(1),"%"]})]}),e[20]=h,e[21]=r,e[22]=S):S=e[22];let g;e[23]!==b||e[24]!==S||e[25]!==p?(g=o.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[p,b,S]}),e[23]=b,e[24]=S,e[25]=p,e[26]=g):g=e[26];let w;return e[27]!==g||e[28]!==f?(w=o.jsxs("div",{className:"flex flex-col gap-2",children:[f,g]}),e[27]=g,e[28]=f,e[29]=w):w=e[29],w}function Jh(t){const e=$.c(11),{agentId:s,isError:i}=t,r=yt(s),n=r?.title??"Subtask",a=r?.icon??null;let l;e[0]!==a||e[1]!==n?(l=o.jsx(qt,{icon:a,name:n,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=n,e[2]=l):l=e[2];const h=i?"text-destructive":"text-foreground";let c;e[3]!==h?(c=ie("shrink-0 font-medium",h),e[3]=h,e[4]=c):c=e[4];let d;e[5]!==n||e[6]!==c?(d=o.jsx("span",{className:c,children:n}),e[5]=n,e[6]=c,e[7]=d):d=e[7];let u;return e[8]!==l||e[9]!==d?(u=o.jsxs(o.Fragment,{children:[l,d]}),e[8]=l,e[9]=d,e[10]=u):u=e[10],u}function Zh(t){const e=$.c(5),{isError:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(qt,{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 n;e[1]!==r?(n=ie("shrink-0 font-medium",r),e[1]=r,e[2]=n):n=e[2];let a;return e[3]!==n?(a=o.jsxs(o.Fragment,{children:[i,o.jsx("span",{className:n,children:"Subtask"})]}),e[3]=n,e[4]=a):a=e[4],a}function Qh(t){const e=$.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,n=s.state==="output-error",a=s.state==="approval-requested";let l;e[0]!==n?(l=o.jsx(Zh,{isError:n}),e[0]=n,e[1]=l):l=e[1];let h;e[2]!==i||e[3]!==n?(h=o.jsx(Jh,{agentId:i,isError:n}),e[2]=i,e[3]=n,e[4]=h):h=e[4];let c;e[5]!==l||e[6]!==h?(c=o.jsx(B.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&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-muted-foreground/50",children:"·"}),o.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]!==n||e[12]!==r?(u=o.jsx("span",{className:"ml-auto shrink-0",children:r?o.jsx(He,{size:12,className:"animate-spin text-muted-foreground"}):n?o.jsx(vc,{size:12,className:"text-destructive"}):a?o.jsx(tn,{size:12,className:"text-warning"}):o.jsx(pc,{size:12,className:"text-emerald-500"})}),e[10]=a,e[11]=n,e[12]=r,e[13]=u):u=e[13];let f;return e[14]!==c||e[15]!==d||e[16]!==u?(f=o.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 ed(t){const e=$.c(58),{onClose:s,back:i,className:r}=t,[n,a]=B.useState(null),{messages:l}=Yt(),{tasks:h,taskId:c}=Pt(),{selectedModel:d,selectedVirtualMcp:u}=en();let f,m,_,p,v,x,b,S;if(e[0]!==i||e[1]!==r||e[2]!==l||e[3]!==s||e[4]!==n?.id||e[5]!==d||e[6]!==u?.title||e[7]!==c||e[8]!==h){S=Symbol.for("react.early_return_sentinel");e:{let k;e[17]!==c?(k=V=>V.id===c,e[17]=c,e[18]=k):k=e[18];const C=h.find(k),N=yc(l),T=[...l].reverse().find(dd),L=T?.metadata?.usage,M=T?.metadata?.modelLimits?.contextWindow??d?.limits?.contextWindow??null,D=L?.contextTokens??L?.totalTokens??0,y=M&&M>0?(D/M*100).toFixed(1):null,R=l;let E;e[19]!==R?(E=R.filter(hd).reduce(cd,0),e[19]=R,e[20]=E):E=e[20];const j=E,I=l;let P;e[21]!==I?(P=I.filter(ld).reduce(ad,0),e[21]=I,e[22]=P):P=e[22];const z=P,U=Math.max(0,N.totalTokens-j-z),W=l[0],H=l.at(-1),G=W?.metadata?.created_at??C?.created_at,K=H?.metadata?.created_at??C?.updated_at,se=l.filter(od),Y=l.flatMap(rd),J=d?.modelId?qh(d.modelId):"—",ee=u?.title??"Decopilot",A=[{label:"Session",value:C?.title??"New chat"},{label:"Messages",value:se.length},{label:"Agent",value:ee},{label:"Model",value:J},{label:"Context Limit",value:M?xs(M):"—"},{label:"Session Tokens (billed)",value:N.totalTokens>0?xs(N.totalTokens):"0"},{label:"Usage",value:y!==null?`${y}%`:"—"},{label:"Input Tokens",value:N.inputTokens>0?xs(N.inputTokens):"0"},{label:"Output Tokens",value:N.outputTokens>0?xs(N.outputTokens):"0"},{label:"Reasoning Tokens",value:N.reasoningTokens>0?xs(N.reasoningTokens):"0"},{label:"Cost",value:N.cost>0?`$${N.cost<.001?N.cost.toFixed(6):N.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:On(G)},{label:"Last Activity",value:On(K)}];if(!C&&se.length===0){let V;e[23]!==r?(V=ie("flex flex-col h-full w-full border-l border-border bg-background",r),e[23]=r,e[24]=V):V=e[24];let ne;e[25]===Symbol.for("react.memo_cache_sentinel")?(ne=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[25]=ne):ne=e[25];let he;e[26]!==i?(he=i?o.jsx(En,{size:14,className:"text-muted-foreground"}):o.jsx(as,{size:14,className:"text-muted-foreground"}),e[26]=i,e[27]=he):he=e[27];let ce;e[28]!==s||e[29]!==he?(ce=o.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[ne,o.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:he})]}),e[28]=s,e[29]=he,e[30]=ce):ce=e[30];let de;e[31]===Symbol.for("react.memo_cache_sentinel")?(de=o.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:o.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a conversation to see context"})}),e[31]=de):de=e[31];let fe;e[32]!==V||e[33]!==ce?(fe=o.jsxs("div",{className:V,children:[ce,de]}),e[32]=V,e[33]=ce,e[34]=fe):fe=e[34],S=fe;break e}e[35]!==r?(x=ie("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",r),e[35]=r,e[36]=x):x=e[36];let X;e[37]===Symbol.for("react.memo_cache_sentinel")?(X=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[37]=X):X=e[37];let Q;e[38]!==i?(Q=i?o.jsx(En,{size:14}):o.jsx(as,{size:14}),e[38]=i,e[39]=Q):Q=e[39],e[40]!==s||e[41]!==Q?(b=o.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[X,o.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:Q})]}),e[40]=s,e[41]=Q,e[42]=b):b=e[42],f="flex flex-col gap-8 p-6",m=Y.length>0&&o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"Subtasks"}),o.jsx("div",{className:"flex flex-col gap-1",children:Y.map(id)})]}),_=o.jsx(Gh,{items:A});let F;e[43]===Symbol.for("react.memo_cache_sentinel")?(F=o.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[43]=F):F=e[43],e[44]!==z||e[45]!==U||e[46]!==j?(p=o.jsxs("div",{className:"flex flex-col gap-3",children:[F,o.jsx(Xh,{userTokens:j,assistantTokens:z,otherTokens:U})]}),e[44]=z,e[45]=U,e[46]=j,e[47]=p):p=e[47],v=se.length>0&&o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"Raw messages"}),o.jsx("div",{className:"flex flex-col gap-1",children:se.map(V=>{const ne=V.metadata?.created_at,he=n?.id===V.id;return o.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[o.jsxs("button",{type:"button",onClick:()=>a(he?null:V),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:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx("span",{className:ie("shrink-0 font-medium",V.role==="user"?"text-chart-1":"text-chart-2"),children:V.role}),o.jsx("span",{className:"text-muted-foreground",children:"•"}),o.jsx("span",{className:"truncate text-muted-foreground font-mono",children:V.id})]}),ne&&o.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(ne).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),he&&o.jsxs(o.Fragment,{children:[V.role==="assistant"&&(()=>{const ce=V.metadata?._request;if(!ce)return null;const de=ce.systemSections??[],fe=Math.max(1,...de.map(sd)),Be=de.reduce(td,0);return o.jsxs("div",{className:"border-t border-border/50 px-3 py-2.5 text-xs space-y-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"font-medium text-foreground",children:"Request"}),o.jsxs("span",{className:"text-muted-foreground tabular-nums",children:[ce.activeTools??0," / ",ce.tools??0," ","tools active"]})]}),de.length>0&&o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("div",{className:"text-muted-foreground",children:["System prompt"," ",o.jsxs("span",{className:"tabular-nums",children:["~",Math.round(Be/4).toLocaleString()," ","tok"]})]}),de.map((Ne,je)=>{const Je=Ne.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${je}`,Le=Ne.chars/fe*100,vs=Math.round(Ne.chars/4);return o.jsxs("div",{className:"space-y-0.5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx("span",{className:"font-mono text-foreground truncate",children:Je}),o.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:["~",vs.toLocaleString()," tok"]})]}),o.jsx("div",{className:"h-1 w-full rounded-full bg-muted overflow-hidden",children:o.jsx("div",{className:"h-full rounded-full bg-chart-3",style:{width:`${Le}%`}})})]},je)})]})]})})(),o.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(V,null,2)})]})]},V.id)})})]})}e[0]=i,e[1]=r,e[2]=l,e[3]=s,e[4]=n?.id,e[5]=d,e[6]=u?.title,e[7]=c,e[8]=h,e[9]=f,e[10]=m,e[11]=_,e[12]=p,e[13]=v,e[14]=x,e[15]=b,e[16]=S}else f=e[9],m=e[10],_=e[11],p=e[12],v=e[13],x=e[14],b=e[15],S=e[16];if(S!==Symbol.for("react.early_return_sentinel"))return S;let g;e[48]!==f||e[49]!==m||e[50]!==_||e[51]!==p||e[52]!==v?(g=o.jsxs("div",{className:f,children:[m,_,p,v]}),e[48]=f,e[49]=m,e[50]=_,e[51]=p,e[52]=v,e[53]=g):g=e[53];let w;return e[54]!==x||e[55]!==b||e[56]!==g?(w=o.jsxs("div",{className:x,children:[b,g]}),e[54]=x,e[55]=b,e[56]=g,e[57]=w):w=e[57],w}function td(t,e){return t+e.chars}function sd(t){return t.chars}function id(t,e){return o.jsx(Qh,{part:t},e)}function rd(t){return(t.parts??[]).filter(nd)}function nd(t){return t.type==="tool-subtask"}function od(t){return t.role!=="system"}function ad(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function ld(t){return t.role==="assistant"}function cd(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function hd(t){return t.role==="user"}function dd(t){return t.role==="assistant"&&t.metadata?.usage}const $n=["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"],zn=["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 ud(){const t=$n[Math.floor(Math.random()*$n.length)],e=zn[Math.floor(Math.random()*zn.length)];return`deco/${t}-${e}`}const oi=100;function fd(t,e,s){const i=e.trim().toLowerCase();return i?(t??[]).some(r=>r.branches.some(n=>typeof n.name=="string"&&!s.has(n.name)&&n.name.toLowerCase().includes(i))):!0}function md(t,e){const s=e.trim().toLowerCase();return s?[...t].some(i=>i.toLowerCase().includes(s)):!0}function _d(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=$.c(48),{orgId:s,orgSlug:i,userId:r,connectionId:n,vmMap:a,owner:l,repo:h,enabled:c}=t,d=c===void 0?!0:c,u=n??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=Ve(f);let _;e[4]!==n||e[5]!==s||e[6]!==i||e[7]!==l||e[8]!==h?(_=uc.githubBranches(s,i,n,l,h),e[4]=n,e[5]=s,e[6]=i,e[7]=l,e[8]=h,e[9]=_):_=e[9];const p=d&&!!n&&!!l&&!!h;let v;e[10]!==m||e[11]!==l||e[12]!==h?(v=async W=>{const{pageParam:H,signal:G}=W,K=Number(H),se=await m.callTool({name:"list_branches",arguments:{owner:l,repo:h,page:K,perPage:oi}},void 0,{signal:G}),Y=_d(se);return{branches:Array.isArray(Y)?Y:Y.branches??[],default_branch:Array.isArray(Y)?null:Y.default_branch??null,page:K}},e[10]=m,e[11]=l,e[12]=h,e[13]=v):v=e[13];let x;e[14]!==_||e[15]!==p||e[16]!==v?(x={queryKey:_,enabled:p,staleTime:3e4,retry:!1,initialPageParam:1,queryFn:v,getNextPageParam:yd},e[14]=_,e[15]=p,e[16]=v,e[17]=x):x=e[17];const{data:b,isLoading:S,isError:g,hasNextPage:w,isFetchingNextPage:k,fetchNextPage:C}=Vc(x);let N,T;e[18]!==r||e[19]!==a?(T=new Set(Object.keys(a?.[r]??{})),N=[...T].sort().map(Sd),e[18]=r,e[19]=a,e[20]=N,e[21]=T):(N=e[20],T=e[21]);const L=N;let M;if(e[22]!==b?.pages){const W=new Map;for(const G of b?.pages??[])for(const K of G.branches)typeof K.name=="string"&&W.set(K.name,K);M=[...W.values()].filter(bd),e[22]=b?.pages,e[23]=M}else M=e[23];let D;e[24]!==M||e[25]!==T?(D=M.filter(W=>!T.has(W.name)).map(xd),e[24]=M,e[25]=T,e[26]=D):D=e[26];const y=D;let R;e[27]!==b?.pages?(R=b?.pages.find(vd)?.default_branch??null,e[27]=b?.pages,e[28]=R):R=e[28];const E=R;let j;e[29]!==b?.pages||e[30]!==C||e[31]!==k||e[32]!==T?(j=async(W,H)=>{const G=H===void 0?gd:H;if(!G()||md(T,W)||k)return;let K=b?.pages??[];for(;G()&&!fd(K,W,T)&&(K.at(-1)?.branches.length??oi)>=oi;){const se=await C();if(!G())break;const Y=se.data?.pages??K;if(Y.length===K.length)break;K=Y}},e[29]=b?.pages,e[30]=C,e[31]=k,e[32]=T,e[33]=j):j=e[33];const I=j,P=w??!1;let z;e[34]!==C||e[35]!==w||e[36]!==k?(z=()=>{w&&!k&&C()},e[34]=C,e[35]=w,e[36]=k,e[37]=z):z=e[37];let U;return e[38]!==E||e[39]!==I||e[40]!==g||e[41]!==k||e[42]!==S||e[43]!==y||e[44]!==P||e[45]!==z||e[46]!==L?(U={yours:L,others:y,defaultBase:E,isLoading:S,isError:g,hasMore:P,isFetchingMore:k,fetchMore:z,fetchUntilMatch:I},e[38]=E,e[39]=I,e[40]=g,e[41]=k,e[42]=S,e[43]=y,e[44]=P,e[45]=z,e[46]=L,e[47]=U):U=e[47],U}function gd(){return!0}function vd(t){return t.default_branch}function xd(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 Sd(t){return{name:t,source:"yours"}}function yd(t){if(!(t.branches.length<oi))return t.page+1}function wd(t){const e=$.c(61),{orgId:s,orgSlug:i,userId:r,connectionId:n,owner:a,repo:l,vmMap:h,value:c,onChange:d}=t,[u,f]=B.useState(!1),[m,_]=B.useState(""),[p,v]=B.useState(!1),x=B.useRef(0);let b;e[0]!==n||e[1]!==u||e[2]!==s||e[3]!==i||e[4]!==a||e[5]!==l||e[6]!==r||e[7]!==h?(b={orgId:s,orgSlug:i,userId:r,connectionId:n,vmMap:h,owner:a,repo:l,enabled:u},e[0]=n,e[1]=u,e[2]=s,e[3]=i,e[4]=a,e[5]=l,e[6]=r,e[7]=h,e[8]=b):b=e[8];const{yours:S,others:g,isLoading:w,isError:k,hasMore:C,isFetchingMore:N,fetchMore:T,fetchUntilMatch:L}=pd(b);let M;e[9]!==d?(M=F=>{d(F),f(!1)},e[9]=d,e[10]=M):M=e[10];const D=M,y=c??"Select branch…";let R;e[11]!==L?(R=F=>{_(F),x.current=x.current+1;const V=x.current,ne=F.trim();if(!ne){v(!1);return}v(!0),L(ne,()=>V===x.current).finally(()=>{V===x.current&&v(!1)})},e[11]=L,e[12]=R):R=e[12];const E=R;let j;e[13]!==T?(j=F=>{const V=F.currentTarget;V.scrollHeight-V.scrollTop-V.clientHeight<48&&T()},e[13]=T,e[14]=j):j=e[14];const I=j;let P;e[15]===Symbol.for("react.memo_cache_sentinel")?(P=o.jsx(Ms,{className:"h-3.5 w-3.5"}),e[15]=P):P=e[15];let z;e[16]!==y?(z=o.jsx(ds,{asChild:!0,children:o.jsxs(re,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 font-mono text-xs",children:[P,o.jsx("span",{className:"max-w-[200px] truncate",children:y})]})}),e[16]=y,e[17]=z):z=e[17];let U;e[18]!==E||e[19]!==m?(U=o.jsx(Mc,{placeholder:"Search loaded branches…",value:m,onValueChange:E}),e[18]=E,e[19]=m,e[20]=U):U=e[20];let W;e[21]!==D?(W=o.jsx(re,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>D(ud()),children:"New"}),e[21]=D,e[22]=W):W=e[22];let H;e[23]!==U||e[24]!==W?(H=o.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:[U,W]}),e[23]=U,e[24]=W,e[25]=H):H=e[25];let G;e[26]!==k?(G=k&&o.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]=G):G=e[27];let K;e[28]!==C||e[29]!==k||e[30]!==w?(K=!k&&!w&&o.jsx(Pc,{children:C?"Looking through more branches...":"No branches found."}),e[28]=C,e[29]=k,e[30]=w,e[31]=K):K=e[31];let se;e[32]!==D||e[33]!==S?(se=S.length>0&&o.jsx(Dn,{heading:"Your branches",children:S.map(F=>o.jsxs(Mn,{value:F.name,onSelect:()=>D(F.name),children:[o.jsx(Ms,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:F.name})]},F.name))}),e[32]=D,e[33]=S,e[34]=se):se=e[34];let Y;e[35]!==g||e[36]!==D?(Y=g.length>0&&o.jsxs(o.Fragment,{children:[o.jsx(Dc,{}),o.jsx(Dn,{heading:"Other branches in repo",children:g.map(F=>o.jsxs(Mn,{value:F.name,onSelect:()=>D(F.name),children:[o.jsx(Ms,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:F.name}),F.author&&o.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",F.author]})]},F.name))})]}),e[35]=g,e[36]=D,e[37]=Y):Y=e[37];let J;e[38]!==T||e[39]!==C||e[40]!==N||e[41]!==p?(J=C&&o.jsx("div",{className:"border-t p-2",children:o.jsx(re,{variant:"ghost",size:"sm",className:"h-7 w-full text-xs",disabled:N,onClick:T,children:N||p?"Loading more…":"Load more branches"})}),e[38]=T,e[39]=C,e[40]=N,e[41]=p,e[42]=J):J=e[42];let ee;e[43]!==C||e[44]!==g.length?(ee=!C&&g.length>0&&o.jsx("div",{className:"border-t p-2 text-center text-xs text-muted-foreground",children:"All loaded"}),e[43]=C,e[44]=g.length,e[45]=ee):ee=e[45];let A;e[46]!==I||e[47]!==G||e[48]!==K||e[49]!==se||e[50]!==Y||e[51]!==J||e[52]!==ee?(A=o.jsxs(Ic,{onScroll:I,children:[G,K,se,Y,J,ee]}),e[46]=I,e[47]=G,e[48]=K,e[49]=se,e[50]=Y,e[51]=J,e[52]=ee,e[53]=A):A=e[53];let X;e[54]!==A||e[55]!==H?(X=o.jsx(us,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:o.jsxs(Ac,{children:[H,A]})}),e[54]=A,e[55]=H,e[56]=X):X=e[56];let Q;return e[57]!==u||e[58]!==X||e[59]!==z?(Q=o.jsxs(fs,{open:u,onOpenChange:f,children:[z,X]}),e[57]=u,e[58]=X,e[59]=z,e[60]=Q):Q=e[60],Q}function Cd(){const t=$.c(27),{org:e}=ve(),{selectedVirtualMcp:s}=en(),{data:i}=Zr.useSession(),{currentBranch:r,setCurrentTaskBranch:n}=Pt();let a;t[0]!==e.id?(a=sa(e.id),t[0]=e.id,t[1]=a):a=t[1];const h=s??a,c=yt(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=o.jsx(mc,{size:32}),t[2]=m):m=t[2];let _;t[3]!==h.icon||t[4]!==h.title?(_=o.jsx(qt,{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=o.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 v=h.description??"Ask anything about configuring model providers or using MCP Mesh.";let x;t[8]!==v?(x=o.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:v}),t[8]=v,t[9]=x):x=t[9];let b;t[10]!==r||t[11]!==c?.metadata?.vmMap||t[12]!==u||t[13]!==e.id||t[14]!==e.slug||t[15]!==n||t[16]!==f||t[17]!==d?(b=f&&o.jsx("div",{className:"mt-2",children:o.jsx(wd,{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:n})}),t[10]=r,t[11]=c?.metadata?.vmMap,t[12]=u,t[13]=e.id,t[14]=e.slug,t[15]=n,t[16]=f,t[17]=d,t[18]=b):b=t[18];let S;t[19]!==_||t[20]!==p||t[21]!==x||t[22]!==b?(S=o.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[_,p,x,b]}),t[19]=_,t[20]=p,t[21]=x,t[22]=b,t[23]=S):S=t[23];let g;t[24]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("div",{className:"w-full max-w-3xl mx-auto",children:o.jsx(Se.IceBreakers,{})}),t[24]=g):g=t[24];let w;return t[25]!==S?(w=o.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center gap-6 px-4",children:[S,g]}),t[25]=S,t[26]=w):w=t[26],w}function kd(){const t=$.c(26),{org:e}=ve(),s=qc(),{isChatEmpty:i}=Yt(),[r,n]=B.useState("chat"),a=ic();if(s.length===0){let S;return t[0]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(Se,{className:"animate-in fade-in-0 duration-200",children:o.jsx(Se.Main,{className:"flex flex-col items-center",children:o.jsx(Se.EmptyState,{children:o.jsx(Se.NoAiProviderEmptyState,{})})})}),t[0]=S):S=t[0],S}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&&!rc(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&&o.jsx(Se.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=ie("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?o.jsxs(o.Fragment,{children:[o.jsx(Se.Main,{children:o.jsx(Cd,{})}),o.jsx(Se.Footer,{children:o.jsx(Se.Input,{onOpenContextPanel:()=>n("context")})})]}):o.jsxs(o.Fragment,{children:[o.jsx(Se.Main,{children:o.jsx(Se.Messages,{})}),o.jsx(Se.Footer,{children:o.jsx(Se.Input,{onOpenContextPanel:()=>n("context")})})]}),t[12]=i,t[13]=f):f=t[13];let m;t[14]!==u||t[15]!==f?(m=o.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=ie("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",_),t[17]=_,t[18]=p):p=t[18];let v;t[19]===Symbol.for("react.memo_cache_sentinel")?(v=o.jsx(ed,{back:!0,onClose:()=>n("chat")}),t[19]=v):v=t[19];let x;t[20]!==p?(x=o.jsx("div",{className:p,children:v}),t[20]=p,t[21]=x):x=t[21];let b;return t[22]!==c||t[23]!==m||t[24]!==x?(b=o.jsxs(Se,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[c,m,x]}),t[22]=c,t[23]=m,t[24]=x,t[25]=b):b=t[25],b}function Pa(){const t=$.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(Se.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsx(Rt,{fallback:e,children:o.jsx(B.Suspense,{fallback:o.jsx(Se.Skeleton,{}),children:o.jsx(kd,{})})}),t[1]=s):s=t[1],s}async function Nd(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 Ia=["VM_START"],Xs=new Map,jd=t=>`${t.virtualMcpId}::${t.branch??""}`,Hi=new Set,ai={mark:(t,e)=>Hi.add(`${t}::${e}`),clear:(t,e)=>Hi.delete(`${t}::${e}`),isStopped:(t,e)=>Hi.has(`${t}::${e}`)};function Aa(t){const e=hs();return Yo({mutationKey:Ia,mutationFn:async s=>{s.branch&&ai.clear(s.virtualMcpId,s.branch);const i=jd(s),r=Xs.get(i);if(r)return r;const n=(async()=>(await Nd(t,"VM_START",s)).structuredContent)();Xs.set(i,n);try{return await n}finally{Xs.get(i)===n&&Xs.delete(i)}},onSuccess:()=>{Xo(e)}})}function Ed(t,e){const s=$.c(3);let i;return s[0]!==e||s[1]!==t?(i={mutationKey:Ia,predicate:n=>{if(!t)return!1;const a=n.state.variables;return!a||a.virtualMcpId!==t?!1:(a.branch??"")===(e??"")}},s[0]=e,s[1]=t,s[2]=i):i=s[2],Kh(i)>0}const Td={settings:Lc,automations:Bc,preview:xc,git:Ms};function Fn(t){const e=Ci(t);if(e.type==="icon"){const s=ki(e.name);return s?{kind:"component",Component:s}:null}return e.type==="url"?{kind:"url",src:e.url}:null}function Wi(t){if(t.kind==="system")return{kind:"component",Component:Td[t.tabId]};const e=Fn(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=Fn(s.icon);return i||{kind:"fallback"}}function Rd(t){const{org:e}=ve(),s=Ve({connectionId:Gt,orgId:e.id,orgSlug:e.slug}),{data:i}=Yl({queryKey:Fs.ensureTask(e.id,t),queryFn:async()=>{if(!s||!t)return null;try{const r=await s.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}});return(r.structuredContent??r).item??null}catch{return null}},select:r=>r?.metadata??null,staleTime:3e4});return i}function Ba(t){const e=$.c(8),s=Vt();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},e[0]=i):i=e[0];const r=Jo(i),n=yt(t.virtualMcpId),a=Rd(t.taskId),{currentBranch:l}=Pt(),h=n?.metadata?.ui??null,c=h?.layout??null,d=c?.tabs??[],u=h?.pinnedViews??[],f=a?.expanded_tools??[],m=!!(n&&Ht(n));let _;e[1]===Symbol.for("react.memo_cache_sentinel")?(_={includeVirtual:!0},e[1]=_):_=e[1];const p=Ni(_),{activeTab:v,mainOpen:x}=wc({mainParam:r.main,metadata:c?{defaultMainView:c.defaultMainView??null,tabs:d.map(Dd)}:null}),b=ra(v),S=[];m&&(S.push({id:"preview",title:"Preview"}),S.push({id:"git",title:l??"git"})),S.push({id:"settings",title:"Settings"}),S.push({id:"automations",title:"Automations"});const g=new Map;for(const T of f){const L=Tn(T.appId,T.toolName);g.set(L,{id:L,title:T.toolName,appId:T.appId,iconKey:T.toolName})}for(const T of u){const L=Tn(T.connectionId,T.toolName);g.set(L,{id:L,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:Wi({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(g.values()).map(T=>({id:T.id,title:T.title,kind:"expanded",icon:Wi({tabId:T.iconKey,kind:"expanded",appId:T.appId,iconUrl:T.iconUrl,connections:p})})),...S.map(T=>({id:T.id,title:T.title,kind:"system",icon:Wi({tabId:T.id,kind:"system",connections:p})}))];let C;return e[4]!==v||e[5]!==x||e[6]!==s?(C=T=>{const L=Cc({clickedId:T,activeTab:v,mainOpen:x});s({to:".",search:M=>({...M,main:L}),replace:!0})},e[4]=v,e[5]=x,e[6]=s,e[7]=C):C=e[7],{activeTab:v,mainOpen:x,setActiveTab:C,systemTabs:S,layoutTabs:d,expandedTools:f,automationTabParsed:b,tabs:k}}function Dd(t){return{id:t.id}}function La(t){const{managerAgentId:e,managerName:s,kind:i,id:r,instructions:n}=t,a=` to improve the instructions of ${i} "${r}". Here are its current instructions.
|
|
3
3
|
<current_instructions>${n}</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 Md(t){const e=$.c(84),{value:s,onChange:i,onColorChange:r,name:n,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]=B.useState(!1),[v,x]=B.useState("icons"),[b,S]=B.useState(""),[g,w]=B.useState("blue");let k;e[0]!==s?(k=Ci(s),e[0]=s,e[1]=k):k=e[1];const C=k,N=C.type==="icon"||C.type==="url"&&C.color?C.color:g;let T;e[2]!==i||e[3]!==N?(T=Le=>{i($i(Le,N))},e[2]=i,e[3]=N,e[4]=T):T=e[4];const L=T;let M;e[5]!==i||e[6]!==r||e[7]!==C.name||e[8]!==C.type||e[9]!==C.url?(M=Le=>{w(Le),r?.(Le),C.type==="icon"?i($i(C.name,Le)):C.type==="url"&&i(Pn(C.url,Le))},e[5]=i,e[6]=r,e[7]=C.name,e[8]=C.type,e[9]=C.url,e[10]=M):M=e[10];const D=M;let y;e[11]!==i||e[12]!==N?(y=Le=>{i(Pn(Le,N)),p(!1)},e[11]=i,e[12]=N,e[13]=y):y=e[13];const R=y;let E;e[14]!==i||e[15]!==N?(E=()=>{const Le=nn(),vs=Le[Math.floor(Math.random()*Le.length)];i($i(vs,N))},e[14]=i,e[15]=N,e[16]=E):E=e[16];const j=E;let I,P,z,U,W,H,G,K;if(e[17]!==l||e[18]!==m||e[19]!==_||e[20]!==u){const Le={xs:"rounded-md",sm:"rounded-lg","sm+":"rounded-xl",md:"rounded-xl",lg:"rounded-2xl",xl:"rounded-2xl"};P=fs,H=m?!1:_,G=p,I=ds,W=!0,K="button",z=m,U=ie("relative group overflow-hidden",m?"cursor-default opacity-50":"cursor-pointer",Le[u],l),e[17]=l,e[18]=m,e[19]=_,e[20]=u,e[21]=I,e[22]=P,e[23]=z,e[24]=U,e[25]=W,e[26]=H,e[27]=G,e[28]=K}else I=e[21],P=e[22],z=e[23],U=e[24],W=e[25],H=e[26],G=e[27],K=e[28];let se;e[29]!==h||e[30]!==n||e[31]!==u||e[32]!==s?(se=o.jsx(In,{icon:s,name:n,size:u,className:h}),e[29]=h,e[30]=n,e[31]=u,e[32]=s,e[33]=se):se=e[33];let Y;e[34]!==m||e[35]!==f?(Y=f&&!m&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity",children:o.jsx(on,{size:16,className:"text-white"})}),e[34]=m,e[35]=f,e[36]=Y):Y=e[36];let J;e[37]!==z||e[38]!==U||e[39]!==se||e[40]!==Y||e[41]!==K?(J=o.jsxs("button",{type:K,disabled:z,className:U,children:[se,Y]}),e[37]=z,e[38]=U,e[39]=se,e[40]=Y,e[41]=K,e[42]=J):J=e[42];let ee;e[43]!==I||e[44]!==W||e[45]!==J?(ee=o.jsx(I,{asChild:W,children:J}),e[43]=I,e[44]=W,e[45]=J,e[46]=ee):ee=e[46];let A;e[47]!==n||e[48]!==s?(A=o.jsx("div",{className:"flex items-center justify-center py-4",children:o.jsx(In,{icon:s,name:n,size:"xl"})}),e[47]=n,e[48]=s,e[49]=A):A=e[49];let X;e[50]===Symbol.for("react.memo_cache_sentinel")?(X=()=>x("icons"),e[50]=X):X=e[50];const Q=v==="icons"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let F;e[51]!==Q?(F=ie("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",Q),e[51]=Q,e[52]=F):F=e[52];let V;e[53]!==F?(V=o.jsx("button",{type:"button",onClick:X,className:F,children:"Icons"}),e[53]=F,e[54]=V):V=e[54];let ne;e[55]===Symbol.for("react.memo_cache_sentinel")?(ne=()=>x("upload"),e[55]=ne):ne=e[55];const he=v==="upload"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let ce;e[56]!==he?(ce=ie("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",he),e[56]=he,e[57]=ce):ce=e[57];let de;e[58]!==ce?(de=o.jsx("button",{type:"button",onClick:ne,className:ce,children:"Upload"}),e[58]=ce,e[59]=de):de=e[59];let fe;e[60]===Symbol.for("react.memo_cache_sentinel")?(fe=o.jsx("div",{className:"flex-1"}),e[60]=fe):fe=e[60];let Be;e[61]!==V||e[62]!==de?(Be=o.jsxs("div",{className:"flex items-center border-b border-border px-3",children:[V,de,fe]}),e[61]=V,e[62]=de,e[63]=Be):Be=e[63];let Ne;e[64]!==D||e[65]!==j||e[66]!==L||e[67]!==R||e[68]!==C.name||e[69]!==C.type||e[70]!==b||e[71]!==N||e[72]!==v?(Ne=v==="icons"?o.jsx(Bd,{search:b,onSearchChange:S,selectedColor:N,onColorChange:D,onSelectIcon:L,onRandom:j,currentIconName:C.type==="icon"?C.name:null}):o.jsx(Ld,{onUpload:R}),e[64]=D,e[65]=j,e[66]=L,e[67]=R,e[68]=C.name,e[69]=C.type,e[70]=b,e[71]=N,e[72]=v,e[73]=Ne):Ne=e[73];let je;e[74]!==A||e[75]!==Be||e[76]!==Ne?(je=o.jsx(us,{align:"start",className:"w-80 p-0",onOpenAutoFocus:Pd,children:o.jsxs("div",{className:"flex flex-col",children:[A,Be,Ne]})}),e[74]=A,e[75]=Be,e[76]=Ne,e[77]=je):je=e[77];let Je;return e[78]!==P||e[79]!==H||e[80]!==G||e[81]!==ee||e[82]!==je?(Je=o.jsxs(P,{open:H,onOpenChange:G,children:[ee,je]}),e[78]=P,e[79]=H,e[80]=G,e[81]=ee,e[82]=je,e[83]=Je):Je=e[83],Je}function Pd(t){return t.preventDefault()}function Id(t){const e=$.c(27),{selectedColor:s,onColorChange:i}=t,[r,n]=B.useState(!1);let a,l,h,c,d,u,f;if(e[0]!==r||e[1]!==s){const b=na(s);l=fs,u=r,f=n,a=ds,d=!0,h="button",c=ie("h-6 w-6 rounded-full shrink-0 ring-2 ring-offset-2 ring-offset-background transition-all cursor-pointer hover:scale-110",b.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=o.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?(_=o.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=$c.map(b=>o.jsx("button",{type:"button",onClick:()=>{i(b.name),n(!1)},className:ie("h-5 w-5 rounded-full transition-all shrink-0 cursor-pointer",b.dot,s===b.name?"ring-2 ring-offset-1 ring-offset-background ring-foreground/30 scale-110":"hover:scale-110"),title:b.name},b.name)),e[16]=i,e[17]=s,e[18]=p):p=e[18];let v;e[19]!==p?(v=o.jsx(us,{align:"start",side:"right",sideOffset:8,className:"w-auto p-2",onOpenAutoFocus:Ad,children:o.jsx("div",{className:"grid grid-cols-4 gap-1",children:p})}),e[19]=p,e[20]=v):v=e[20];let x;return e[21]!==l||e[22]!==u||e[23]!==f||e[24]!==_||e[25]!==v?(x=o.jsxs(l,{open:u,onOpenChange:f,children:[_,v]}),e[21]=l,e[22]=u,e[23]=f,e[24]=_,e[25]=v,e[26]=x):x=e[26],x}function Ad(t){return t.preventDefault()}function Bd(t){const e=$.c(44),{search:s,onSearchChange:i,selectedColor:r,onColorChange:n,onSelectIcon:a,onRandom:l,currentIconName:h}=t;let c,d,u,f,m,_,p;if(e[0]!==h||e[1]!==n||e[2]!==l||e[3]!==i||e[4]!==a||e[5]!==s||e[6]!==r){const g=nn(),w=na(r);d=s.trim()?g.filter(D=>{const y=hr(D),R=s.toLowerCase();return y.includes(R)||D.toLowerCase().includes(R)}):g,_="flex flex-col";let k;e[14]===Symbol.for("react.memo_cache_sentinel")?(k=o.jsx(Da,{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=D=>i(D.target.value),e[15]=i,e[16]=C):C=e[16];let N;e[17]!==s||e[18]!==C?(N=o.jsxs("div",{className:"relative flex-1",children:[k,o.jsx(Xt,{value:s,onChange:C,placeholder:"Filter...",className:"h-8 text-xs pl-7"})]}),e[17]=s,e[18]=C,e[19]=N):N=e[19];let T;e[20]===Symbol.for("react.memo_cache_sentinel")?(T=o.jsx(Oc,{size:14,className:"text-muted-foreground"}),e[20]=T):T=e[20];let L;e[21]!==l?(L=o.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]=L):L=e[22];let M;e[23]!==n||e[24]!==r?(M=o.jsx(Id,{selectedColor:r,onColorChange:n}),e[23]=n,e[24]=r,e[25]=M):M=e[25],e[26]!==L||e[27]!==M||e[28]!==N?(p=o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[N,L,M]}),e[26]=L,e[27]=M,e[28]=N,e[29]=p):p=e[29],c=dn,m="h-56",u="grid grid-cols-9 gap-0.5 px-2 pb-2",f=d.map(D=>{const y=ki(D);return y?o.jsx("button",{type:"button",onClick:()=>a(D),className:ie("h-8 w-8 flex items-center justify-center rounded-md transition-colors cursor-pointer",h===D?ie(w.bg,w.text):ie(w.text,"hover:bg-accent")),title:D,children:o.jsx(y,{size:18})},D):null}),e[0]=h,e[1]=n,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 v;e[30]!==u||e[31]!==f?(v=o.jsx("div",{className:u,children:f}),e[30]=u,e[31]=f,e[32]=v):v=e[32];let x;e[33]!==d.length?(x=d.length===0&&o.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"No icons found"}),e[33]=d.length,e[34]=x):x=e[34];let b;e[35]!==c||e[36]!==m||e[37]!==v||e[38]!==x?(b=o.jsxs(c,{className:m,children:[v,x]}),e[35]=c,e[36]=m,e[37]=v,e[38]=x,e[39]=b):b=e[39];let S;return e[40]!==_||e[41]!==p||e[42]!==b?(S=o.jsxs("div",{className:_,children:[p,b]}),e[40]=_,e[41]=p,e[42]=b,e[43]=S):S=e[43],S}function Ld(t){const e=$.c(27),{onUpload:s}=t,i=B.useRef(null);let r;e[0]!==s?(r=k=>{const C=k.target.files?.[0];if(!C)return;if(C.size>2097152){me.error("Image must be smaller than 2MB"),k.target.value="";return}const N=new FileReader;N.onerror=()=>{me.error("Failed to read image file"),i.current&&(i.current.value="")},N.onloadend=()=>{N.readyState===FileReader.DONE&&N.result&&s(N.result),i.current&&(i.current.value="")},N.readAsDataURL(C)},e[0]=s,e[1]=r):r=e[1];const n=r,[a,l]=B.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]!==n?(d=o.jsx("input",{type:"file",ref:i,className:"hidden",accept:"image/*",onChange:n}),e[5]=n,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=o.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:[o.jsx(Sh,{size:20}),o.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=o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"or"}),o.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 v;e[13]!==a||e[14]!==p?(v=o.jsx(Xt,{value:a,onChange:_,placeholder:"Paste image URL...",className:"h-8 text-xs flex-1",onKeyDown:p}),e[13]=a,e[14]=p,e[15]=v):v=e[15];let x;e[16]!==a?(x=a.trim(),e[16]=a,e[17]=x):x=e[17];const b=!x;let S;e[18]!==c||e[19]!==b?(S=o.jsx(re,{variant:"outline",size:"sm",className:"h-8 px-3 text-xs shrink-0",onClick:c,disabled:b,children:"Apply"}),e[18]=c,e[19]=b,e[20]=S):S=e[20];let g;e[21]!==S||e[22]!==v?(g=o.jsxs("div",{className:"flex items-center gap-1.5",children:[v,S]}),e[21]=S,e[22]=v,e[23]=g):g=e[23];let w;return e[24]!==g||e[25]!==d?(w=o.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[d,f,m,g]}),e[24]=g,e[25]=d,e[26]=w):w=e[26],w}function Od(t){const e=$.c(5),{value:s}=t;let i;if(e[0]!==s){i=Symbol.for("react.early_return_sentinel");e:{const n=Ci(s);if(n.type==="icon"){const a=ki(n.name);if(a){let l;e[2]!==a?(l=o.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=o.jsx(yh,{size:16,className:"text-muted-foreground"}),e[4]=r):r=e[4],r}function $d(t){const e=$.c(66),{value:s,onChange:i,className:r,disabled:n}=t,[a,l]=B.useState(!1),[h,c]=B.useState("");let d;e[0]!==s?(d=Ci(s),e[0]=s,e[1]=d):d=e[1];const u=d,f=u.type==="icon"?u.name:null;let m,_,p,v,x,b,S,g,w,k,C,N,T,L,M;if(e[2]!==r||e[3]!==f||e[4]!==n||e[5]!==i||e[6]!==a||e[7]!==h||e[8]!==s){const P=nn();v=h.trim()?P.filter(se=>{const Y=h.toLowerCase();return hr(se).includes(Y)||se.toLowerCase().includes(Y)}):P,p=fs,x=n?!1:a,b=l;const z=n?"cursor-default opacity-50":"cursor-pointer hover:bg-accent";let U;e[24]!==r||e[25]!==z?(U=ie("size-7 shrink-0 rounded-md transition-colors flex items-center justify-center",z,r),e[24]=r,e[25]=z,e[26]=U):U=e[26];let W;e[27]!==s?(W=o.jsx(Od,{value:s}),e[27]=s,e[28]=W):W=e[28],e[29]!==n||e[30]!==U||e[31]!==W?(S=o.jsx(ds,{asChild:!0,children:o.jsx("button",{type:"button",disabled:n,className:U,children:W})}),e[29]=n,e[30]=U,e[31]=W,e[32]=S):S=e[32],_=us,T="start",L="w-64 p-0",M=zd,C="flex flex-col";let H;e[33]===Symbol.for("react.memo_cache_sentinel")?(H=o.jsx(Da,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[33]=H):H=e[33];let G;e[34]===Symbol.for("react.memo_cache_sentinel")?(G=se=>c(se.target.value),e[34]=G):G=e[34],e[35]!==h?(N=o.jsx("div",{className:"px-2 py-2",children:o.jsxs("div",{className:"relative",children:[H,o.jsx(Xt,{value:h,onChange:G,placeholder:"Filter...",className:"h-7 text-xs pl-7"})]})}),e[35]=h,e[36]=N):N=e[36],m=dn,k="h-48",g="grid grid-cols-8 gap-0.5 px-2 pb-2";let K;e[37]!==f||e[38]!==i?(K=se=>{const Y=ki(se);return Y?o.jsx("button",{type:"button",onClick:()=>{i(`icon://${se}`),l(!1)},className:ie("h-7 w-7 flex items-center justify-center rounded-md transition-colors cursor-pointer",f===se?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),title:hr(se),children:o.jsx(Y,{size:16})},se):null},e[37]=f,e[38]=i,e[39]=K):K=e[39],w=v.map(K),e[2]=r,e[3]=f,e[4]=n,e[5]=i,e[6]=a,e[7]=h,e[8]=s,e[9]=m,e[10]=_,e[11]=p,e[12]=v,e[13]=x,e[14]=b,e[15]=S,e[16]=g,e[17]=w,e[18]=k,e[19]=C,e[20]=N,e[21]=T,e[22]=L,e[23]=M}else m=e[9],_=e[10],p=e[11],v=e[12],x=e[13],b=e[14],S=e[15],g=e[16],w=e[17],k=e[18],C=e[19],N=e[20],T=e[21],L=e[22],M=e[23];let D;e[40]!==g||e[41]!==w?(D=o.jsx("div",{className:g,children:w}),e[40]=g,e[41]=w,e[42]=D):D=e[42];let y;e[43]!==v.length?(y=v.length===0&&o.jsx("div",{className:"flex items-center justify-center py-6 text-xs text-muted-foreground",children:"No icons found"}),e[43]=v.length,e[44]=y):y=e[44];let R;e[45]!==m||e[46]!==D||e[47]!==y||e[48]!==k?(R=o.jsxs(m,{className:k,children:[D,y]}),e[45]=m,e[46]=D,e[47]=y,e[48]=k,e[49]=R):R=e[49];let E;e[50]!==R||e[51]!==C||e[52]!==N?(E=o.jsxs("div",{className:C,children:[N,R]}),e[50]=R,e[51]=C,e[52]=N,e[53]=E):E=e[53];let j;e[54]!==_||e[55]!==E||e[56]!==T||e[57]!==L||e[58]!==M?(j=o.jsx(_,{align:T,className:L,onOpenAutoFocus:M,children:E}),e[54]=_,e[55]=E,e[56]=T,e[57]=L,e[58]=M,e[59]=j):j=e[59];let I;return e[60]!==p||e[61]!==x||e[62]!==b||e[63]!==S||e[64]!==j?(I=o.jsxs(p,{open:x,onOpenChange:b,children:[S,j]}),e[60]=p,e[61]=x,e[62]=b,e[63]=S,e[64]=j,e[65]=I):I=e[65],I}function zd(t){return t.preventDefault()}function li(){const t=$.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx("div",{className:"flex items-center justify-center h-32",children:o.jsx(He,{className:"animate-spin text-muted-foreground",size:24})}),t[0]=e):e=t[0],e}function Ui(t){return({error:e})=>e?.message?.includes("Method not found")||e?.code===-32601?o.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:o.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:t})}):o.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center h-full p-6 text-center space-y-4",children:[o.jsx("div",{className:"bg-destructive/10 p-3 rounded-full",children:o.jsx(lr,{className:"h-6 w-6 text-destructive"})}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("h3",{className:"text-lg font-medium",children:"Something went wrong"}),o.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 Fd(t){const e=$.c(23),{item:s,isSelected:i,onToggle:r,disabled:n}=t,a=n?"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=ie("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=o.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&&o.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=o.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&&o.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=o.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]!==n||e[16]!==i||e[17]!==r?(_=o.jsx(Ch,{checked:i,onCheckedChange:r,disabled:n,className:"mt-0.5"}),e[15]=n,e[16]=i,e[17]=r,e[18]=_):_=e[18];let p;return e[19]!==h||e[20]!==m||e[21]!==_?(p=o.jsxs("label",{className:h,children:[m,_]}),e[19]=h,e[20]=m,e[21]=_,e[22]=p):p=e[22],p}function fn(t){const e=$.c(13),{items:s,selections:i,onToggle:r,emptyMessage:n,disabled:a}=t;let l,h,c;if(e[0]!==a||e[1]!==n||e[2]!==s||e[3]!==r||e[4]!==i){c=Symbol.for("react.early_return_sentinel");e:{const u=s.map(Hd);if(s.length===0){let f;e[8]!==n?(f=o.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:o.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:n})}),e[8]=n,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=>o.jsx(Fd,{item:f,isSelected:i===null||i?.includes(f.id),onToggle:()=>r(f.id,u),disabled:a},f.id))}e[0]=a,e[1]=n,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=o.jsx("div",{className:l,children:h}),e[10]=l,e[11]=h,e[12]=d):d=e[12],d}function Hd(t){return t.id}function Wd(t){const e=$.c(13),{connectionId:s,selections:i,onToggle:r,disabled:n}=t,{org:a}=ve();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=Ve(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.tools?(u=d.tools.map(Ud),e[6]=d.tools,e[7]=u):u=e[7];const f=u;let m;return e[8]!==n||e[9]!==f||e[10]!==r||e[11]!==i?(m=o.jsx(fn,{items:f,selections:i,onToggle:r,emptyMessage:"No tools available",disabled:n}),e[8]=n,e[9]=f,e[10]=r,e[11]=i,e[12]=m):m=e[12],m}function Ud(t){return{id:t.name,name:t.name,description:t.description,tags:o.jsx(mh,{annotations:t.annotations,_meta:t._meta})}}function Kd(t){const e=$.c(13),{connectionId:s,selections:i,onToggle:r,disabled:n}=t,{org:a}=ve();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=Ve(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:d}=dh(c);let u;e[6]!==d.resources?(u=d.resources.map(Vd),e[6]=d.resources,e[7]=u):u=e[7];const f=u;let m;return e[8]!==n||e[9]!==f||e[10]!==r||e[11]!==i?(m=o.jsx(fn,{items:f,selections:i,onToggle:r,emptyMessage:"No resources available",disabled:n}),e[8]=n,e[9]=f,e[10]=r,e[11]=i,e[12]=m):m=e[12],m}function Vd(t){return{id:t.name||t.uri,name:t.name||t.uri,description:t.description}}function qd(t){const e=$.c(13),{connectionId:s,selections:i,onToggle:r,disabled:n}=t,{org:a}=ve();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=Ve(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:d}=Nh(c);let u;e[6]!==d.prompts?(u=d.prompts.map(Gd),e[6]=d.prompts,e[7]=u):u=e[7];const f=u;let m;return e[8]!==n||e[9]!==f||e[10]!==r||e[11]!==i?(m=o.jsx(fn,{items:f,selections:i,onToggle:r,emptyMessage:"No prompts available",disabled:n}),e[8]=n,e[9]=f,e[10]=r,e[11]=i,e[12]=m):m=e[12],m}function Gd(t){return{id:t.name,name:t.name,description:t.description}}function Yd(t){const e=$.c(54),{currentConnection:s,activeTab:i,selectedId:r,formData:n,toggleTool:a,toggleResource:l,togglePrompt:h,toggleAllTools:c,toggleAllResources:d,toggleAllPrompts:u,onTabChange:f}=t,m=n[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 v=p;let x;e[6]!==s.icon||e[7]!==s.title?(x=o.jsx(qt,{icon:s.icon,name:s.title,size:"sm",className:"shrink-0"}),e[6]=s.icon,e[7]=s.title,e[8]=x):x=e[8];let b;e[9]!==s.title?(b=o.jsx("h2",{className:"text-base font-semibold truncate",children:s.title}),e[9]=s.title,e[10]=b):b=e[10];let S;e[11]!==s.description?(S=s.description&&o.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.description}),e[11]=s.description,e[12]=S):S=e[12];let g;e[13]!==b||e[14]!==S?(g=o.jsxs("div",{className:"flex-1 min-w-0",children:[b,S]}),e[13]=b,e[14]=S,e[15]=g):g=e[15];let w;e[16]!==x||e[17]!==g?(w=o.jsx("div",{className:"px-6 pt-5 pb-4 shrink-0",children:o.jsxs("div",{className:"flex items-center gap-3",children:[x,g]})}),e[16]=x,e[17]=g,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=I=>f(I),e[20]=f,e[21]=C):C=e[21];let N;e[22]!==i||e[23]!==C?(N=o.jsx(wh,{tabs:k,activeTab:i,onTabChange:C}),e[22]=i,e[23]=C,e[24]=N):N=e[24];const T=_?"Deselect all":"Select all";let L;e[25]!==v||e[26]!==T?(L=o.jsx("button",{type:"button",onClick:v,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:T}),e[25]=v,e[26]=T,e[27]=L):L=e[27];let M;e[28]!==L||e[29]!==N?(M=o.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-t border-border shrink-0",children:[N,L]}),e[28]=L,e[29]=N,e[30]=M):M=e[30];let D;e[31]!==i||e[32]!==n||e[33]!==r||e[34]!==a?(D=i==="tools"&&o.jsx(Rt,{fallback:Ui("Tools not supported by this server"),children:o.jsx(B.Suspense,{fallback:o.jsx(li,{}),children:o.jsx(Wd,{connectionId:r,selections:n[r]?n[r].tools:[],onToggle:(I,P)=>a(r,I,P)})})}),e[31]=i,e[32]=n,e[33]=r,e[34]=a,e[35]=D):D=e[35];let y;e[36]!==i||e[37]!==n||e[38]!==r||e[39]!==l?(y=i==="resources"&&o.jsx(Rt,{fallback:Ui("Resources not supported by this server"),children:o.jsx(B.Suspense,{fallback:o.jsx(li,{}),children:o.jsx(Kd,{connectionId:r,selections:n[r]?n[r].resources:[],onToggle:(I,P)=>l(r,I,P)})})}),e[36]=i,e[37]=n,e[38]=r,e[39]=l,e[40]=y):y=e[40];let R;e[41]!==i||e[42]!==n||e[43]!==r||e[44]!==h?(R=i==="prompts"&&o.jsx(Rt,{fallback:Ui("Prompts not supported by this server"),children:o.jsx(B.Suspense,{fallback:o.jsx(li,{}),children:o.jsx(qd,{connectionId:r,selections:n[r]?n[r].prompts:[],onToggle:(I,P)=>h(r,I,P)})})}),e[41]=i,e[42]=n,e[43]=r,e[44]=h,e[45]=R):R=e[45];let E;e[46]!==D||e[47]!==y||e[48]!==R?(E=o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[D,y,R]}),e[46]=D,e[47]=y,e[48]=R,e[49]=E):E=e[49];let j;return e[50]!==M||e[51]!==E||e[52]!==w?(j=o.jsxs(o.Fragment,{children:[w,M,E]}),e[50]=M,e[51]=E,e[52]=w,e[53]=j):j=e[53],j}function Xd(t){const e=$.c(11),{connectionId:s,onAuthenticate:i,children:r}=t;let n;e[0]!==s?(n={connectionId:s},e[0]=s,e[1]=n):n=e[1];const a=ga(n);if(a.supportsOAuth&&!a.isAuthenticated){let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex items-center justify-center size-12 rounded-full bg-muted",children:o.jsx(zc,{size:22,className:"text-muted-foreground"})}),e[2]=c):c=e[2];let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsxs("div",{className:"space-y-1",children:[o.jsx("p",{className:"text-sm font-medium",children:"Authorization required"}),o.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&&o.jsx(re,{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=o.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=o.jsx(o.Fragment,{children:r}),e[9]=r,e[10]=h):h=e[10],h}function Jd(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 Hn(t){return Object.entries(t).map(([e,s])=>({connection_id:e,selected_tools:s.tools,selected_resources:s.resources,selected_prompts:s.prompts}))}function Zd(t,e){return e.type==="SET_ACTIVE_TAB"?{...t,activeTab:e.payload}:t}function Qd(t){const e=$.c(49),{open:s,onOpenChange:i,selectedId:r,form:n,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]=B.useReducer(Zd,h),u=ln(r??"");let f;e[1]!==a?(f=a??[],e[1]=a,e[2]=f):f=e[2];let m;e[3]!==f?(m=Jd(f),e[3]=f,e[4]=m):m=e[4];const _=m;let p;e[5]!==n||e[6]!==_?(p=(H,G,K,se)=>{const Y=_[H]?.[G];let J;Y===null?J=se.filter(A=>A!==K):Y?.includes(K)?J=Y.filter(A=>A!==K):(J=[...Y??[],K],J.length===se.length&&(J=null));const ee={..._};ee[H]?ee[H]={...ee[H]}:ee[H]={tools:null,resources:null,prompts:null},ee[H][G]=J,n.setValue("connections",Hn(ee),{shouldDirty:!0,shouldTouch:!0})},e[5]=n,e[6]=_,e[7]=p):p=e[7];const v=p;let x;e[8]!==n||e[9]!==_?(x=(H,G)=>{const se=_[H]?.[G]===null?[]:null,Y={..._};Y[H]?Y[H]={...Y[H]}:Y[H]={tools:null,resources:null,prompts:null},Y[H][G]=se,n.setValue("connections",Hn(Y),{shouldDirty:!0,shouldTouch:!0})},e[8]=n,e[9]=_,e[10]=x):x=e[10];const b=x;let S;e[11]!==v?(S=(H,G,K)=>v(H,"tools",G,K),e[11]=v,e[12]=S):S=e[12];const g=S;let w;e[13]!==v?(w=(H,G,K)=>v(H,"resources",G,K),e[13]=v,e[14]=w):w=e[14];const k=w;let C;e[15]!==v?(C=(H,G,K)=>v(H,"prompts",G,K),e[15]=v,e[16]=C):C=e[16];const N=C;let T;e[17]!==b?(T=H=>b(H,"tools"),e[17]=b,e[18]=T):T=e[18];const L=T;let M;e[19]!==b?(M=H=>b(H,"resources"),e[19]=b,e[20]=M):M=e[20];const D=M;let y;e[21]!==b?(y=H=>b(H,"prompts"),e[21]=b,e[22]=y):y=e[22];const R=y;if(!r||!u)return null;let E;e[23]===Symbol.for("react.memo_cache_sentinel")?(E=o.jsx(li,{}),e[23]=E):E=e[23];let j;e[24]===Symbol.for("react.memo_cache_sentinel")?(j=H=>d({type:"SET_ACTIVE_TAB",payload:H}),e[24]=j):j=e[24];let I;e[25]!==u||e[26]!==c.activeTab||e[27]!==_||e[28]!==r||e[29]!==R||e[30]!==D||e[31]!==L||e[32]!==N||e[33]!==k||e[34]!==g?(I=o.jsx(Yd,{currentConnection:u,activeTab:c.activeTab,selectedId:r,formData:_,toggleTool:g,toggleResource:k,togglePrompt:N,toggleAllTools:L,toggleAllResources:D,toggleAllPrompts:R,onTabChange:j},r),e[25]=u,e[26]=c.activeTab,e[27]=_,e[28]=r,e[29]=R,e[30]=D,e[31]=L,e[32]=N,e[33]=k,e[34]=g,e[35]=I):I=e[35];let P;e[36]!==l||e[37]!==r||e[38]!==I?(P=o.jsx(B.Suspense,{fallback:E,children:o.jsx(Xd,{connectionId:r,onAuthenticate:l,children:I})}),e[36]=l,e[37]=r,e[38]=I,e[39]=P):P=e[39];let z;e[40]!==i?(z=o.jsx(gh,{className:"px-6 py-4 border-t border-border shrink-0",children:o.jsx(re,{variant:"outline",onClick:()=>i(!1),children:"Done"})}),e[40]=i,e[41]=z):z=e[41];let U;e[42]!==P||e[43]!==z?(U=o.jsxs(cn,{className:"sm:max-w-2xl h-[75vh] max-h-[75vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[P,z]}),e[42]=P,e[43]=z,e[44]=U):U=e[44];let W;return e[45]!==i||e[46]!==s||e[47]!==U?(W=o.jsx(hn,{open:s,onOpenChange:i,children:U}),e[45]=i,e[46]=s,e[47]=U,e[48]=W):W=e[48],W}const Ki={tools:null,resources:null,prompts:null},eu=Xl.pick({status:!0,title:!0,description:!0,icon:!0,metadata:!0,connections:!0});function tu(t){const s=new TextEncoder().encode(t),i=Array.from(s,r=>String.fromCharCode(r)).join("");return btoa(i)}function su(t){const e=$.c(11),{url:s,agentId:i}=t,[r,n]=B.useState(!1);let a;e[0]!==i||e[1]!==s?(a=async()=>{ye("agent_connect_action",{agent_id:i,action:"copy_url"}),await navigator.clipboard.writeText(s),n(!0),me.success("Agent URL copied to clipboard"),setTimeout(()=>n(!1),2e3)},e[0]=i,e[1]=s,e[2]=a):a=e[2];const l=a;let h;e[3]!==r?(h=r?o.jsx(ji,{size:20,className:"text-green-600"}):o.jsx(sn,{size:20}),e[3]=r,e[4]=h):h=e[4];const c=r?"Copied!":"Copy URL";let d;e[5]!==c?(d=o.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=o.jsxs(re,{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 iu(t){const e=$.c(8),{url:s,serverName:i,agentId:r}=t;let n;e[0]!==r||e[1]!==i||e[2]!==s?(n=()=>{ye("agent_connect_action",{agent_id:r,action:"install_cursor"});const d=va(i),f=tu(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"),me.success("Opening Cursor...")},e[0]=r,e[1]=i,e[2]=s,e[3]=n):n=e[3];const a=n;let l,h;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=o.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=o.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=o.jsxs(re,{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=$.c(12),{url:s,serverName:i,agentId:r}=t,[n,a]=B.useState(!1);let l;e[0]!==r||e[1]!==i||e[2]!==s?(l=async()=>{ye("agent_connect_action",{agent_id:r,action:"install_claude_code"});const m=va(i),p=JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Claude Code"}},null,2),v=`claude mcp add-json "${m}" '${p.replace(/'/g,"'\\''")}' --scope user`;await navigator.clipboard.writeText(v),a(!0),me.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]!==n?(c=n?o.jsx(ji,{size:20,className:"text-green-600"}):o.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]=n,e[5]=c):c=e[5];const d=n?"Copied!":"Install on Claude Code";let u;e[6]!==d?(u=o.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=o.jsxs(re,{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 nu({virtualMcp:t}){const{org:e}=ve(),s=Ve({connectionId:Gt,orgId:e.id,orgSlug:e.slug}),[i,r]=B.useState(null),[n,a]=B.useState(!1),[l,h]=B.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),ye("agent_typegen_key_generated",{agent_id:c})}catch{ye("agent_typegen_key_failed",{agent_id:c}),me.error("Failed to generate API key")}finally{a(!1)}},m=async()=>{ye("agent_connect_action",{agent_id:c,action:"typegen_copy_command",has_api_key:!!i}),await navigator.clipboard.writeText(u),h(!0),me.success("Command copied to clipboard"),setTimeout(()=>h(!1),2e3)};return o.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[o.jsxs("div",{className:"flex items-start justify-between gap-3",children:[o.jsxs("div",{className:"flex flex-col gap-0.5",children:[o.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Generate typed client"}),o.jsxs("p",{className:"text-xs text-muted-foreground",children:["Introspects this agent and writes a typed"," ",o.jsx("code",{className:"font-mono",children:"client.ts"})," you can import directly."]})]}),!i&&o.jsxs(re,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:f,disabled:n,children:[n?o.jsx(He,{size:14,className:"animate-spin"}):o.jsx(bh,{size:14}),o.jsx("span",{children:n?"Generating…":"Generate API key"})]})]}),i&&o.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."}),o.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Generate client"}),o.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx("code",{className:"min-w-0 flex-1 break-all font-mono text-xs text-muted-foreground",children:u}),o.jsx(re,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:m,children:l?o.jsx(ji,{size:12,className:"text-green-600"}):o.jsx(sn,{size:12})})]})}),o.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Runtime variables"}),o.jsx(ou,{apiKey:i,agentId:c})]})}function ou(t){const e=$.c(21),{apiKey:s,agentId:i}=t,[r,n]=B.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
4
|
${h}`;let d;e[0]!==i||e[1]!==s||e[2]!==c?(d=async()=>{ye("agent_connect_action",{agent_id:i,action:"typegen_copy_env",has_api_key:!!s}),await navigator.clipboard.writeText(c),n(!0),setTimeout(()=>n(!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=ie({"opacity-50":f}),e[4]=f,e[5]=m):m=e[5];let _;e[6]!==l||e[7]!==m?(_=o.jsx("span",{className:m,children:l}),e[6]=l,e[7]=m,e[8]=_):_=e[8];let p,v;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=o.jsx("br",{}),v=o.jsx("span",{children:h}),e[9]=p,e[10]=v):(p=e[9],v=e[10]);let x;e[11]!==_?(x=o.jsxs("code",{className:"min-w-0 flex-1 font-mono text-xs text-muted-foreground",children:[_,p,v]}),e[11]=_,e[12]=x):x=e[12];let b;e[13]!==r?(b=r?o.jsx(ji,{size:12,className:"text-green-600"}):o.jsx(sn,{size:12}),e[13]=r,e[14]=b):b=e[14];let S;e[15]!==u||e[16]!==b?(S=o.jsx(re,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:u,children:b}),e[15]=u,e[16]=b,e[17]=S):S=e[17];let g;return e[18]!==x||e[19]!==S?(g=o.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:o.jsxs("div",{className:"flex items-start gap-2",children:[x,S]})}),e[18]=x,e[19]=S,e[20]=g):g=e[20],g}function au(t){const e=$.c(3),{virtualMcp:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx("div",{className:"h-20 animate-pulse rounded-md bg-muted"}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx(B.Suspense,{fallback:i,children:o.jsx(nu,{virtualMcp:s})}),e[1]=s,e[2]=r):r=e[2],r}function lu(t){const e=$.c(37),{open:s,onOpenChange:i,virtualMcp:r}=t,{org:n}=ve(),a=`/api/${n.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=fa();let f;e[5]!==r.id||e[6]!==h.href?(f=o.jsx(su,{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=o.jsx(iu,{url:h.href,serverName:d,agentId:r.id}),_=o.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=o.jsx("div",{className:"flex flex-col gap-3 pt-2",children:o.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 v;e[17]===Symbol.for("react.memo_cache_sentinel")?(v=o.jsx("div",{className:"border-t border-border"}),e[17]=v):v=e[17];let x;e[18]!==r?(x=o.jsx(au,{virtualMcp:r}),e[18]=r,e[19]=x):x=e[19];let b;e[20]!==p||e[21]!==x?(b=o.jsxs("div",{className:"flex flex-col gap-6",children:[p,v,x]}),e[20]=p,e[21]=x,e[22]=b):b=e[22];const S=b;if(u){let C;e[23]===Symbol.for("react.memo_cache_sentinel")?(C=o.jsx(Th,{className:"mt-4 mb-4 text-base font-semibold",children:"Connect"}),e[23]=C):C=e[23];let N;e[24]!==S?(N=o.jsx(Rh,{children:o.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-6 [touch-action:pan-y]",children:[C,S]})}),e[24]=S,e[25]=N):N=e[25];let T;return e[26]!==i||e[27]!==s||e[28]!==N?(T=o.jsx(Dh,{open:s,onOpenChange:i,children:N}),e[26]=i,e[27]=s,e[28]=N,e[29]=T):T=e[29],T}let g;e[30]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx(ja,{children:o.jsx(Ea,{children:"Connect"})}),e[30]=g):g=e[30];let w;e[31]!==S?(w=o.jsxs(cn,{className:"max-h-[80vh] overflow-y-auto sm:max-w-2xl",children:[g,S]}),e[31]=S,e[32]=w):w=e[32];let k;return e[33]!==i||e[34]!==s||e[35]!==w?(k=o.jsx(hn,{open:s,onOpenChange:i,children:w}),e[33]=i,e[34]=s,e[35]=w,e[36]=k):k=e[36],k}function cu(t){const e=$.c(12),{repo:s,className:i}=t;let r;e[0]!==i?(r=ie("space-y-2",i),e[0]=i,e[1]=r):r=e[1];let n;e[2]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx(Ot,{children:"Repository"}),e[2]=n):n=e[2];let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=o.jsx(fh,{size:20,className:"shrink-0 text-foreground/60"}),e[3]=a):a=e[3];let l;e[4]!==s?(l=o.jsx(Re,{asChild:!0,children:o.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border bg-background px-4 py-3",tabIndex:0,children:[a,o.jsx("div",{className:"min-w-0 flex-1",children:s?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"truncate text-sm font-medium",children:[s.owner,"/",s.name]}),o.jsx("div",{className:"truncate text-xs text-muted-foreground",children:s.url})]}):o.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=o.jsx(De,{children:"The connected GitHub repository for this agent. Manage in Connections."}),e[6]=h):h=e[6];let c;e[7]!==l?(c=o.jsxs(Me,{children:[l,h]}),e[7]=l,e[8]=c):c=e[8];let d;return e[9]!==r||e[10]!==c?(d=o.jsxs("div",{className:r,children:[n,c]}),e[9]=r,e[10]=c,e[11]=d):d=e[11],d}const hu={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 du(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 uu=Object.keys(hu),Vi="__none__";function fu(t){const e=$.c(20),{control:s}=t,i=B.useRef(null);let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=o.jsx(Ot,{htmlFor:"runtime-pm",children:"Package manager"}),e[0]=r):r=e[0];let n;e[1]!==s?(n=o.jsxs("div",{className:"space-y-2",children:[r,o.jsx(mt,{control:s,name:"metadata.runtime.selected",render:_u})]}),e[1]=s,e[2]=n):n=e[2];let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=o.jsx(Ot,{htmlFor:"runtime-path",children:"Package path"}),e[3]=a):a=e[3];let l;e[4]!==s?(l=o.jsx(mt,{control:s,name:"metadata.runtime.path",render:mu}),e[4]=s,e[5]=l):l=e[5];let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=o.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=o.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=o.jsx(Ot,{htmlFor:"runtime-port",children:"Dev server port"}),e[9]=d):d=e[9];let u;e[10]===Symbol.for("react.memo_cache_sentinel")?(u=v=>{const{field:x}=v;return o.jsx(Xt,{ref:i,id:"runtime-port",inputMode:"numeric",placeholder:"Auto",defaultValue:x.value??"",onBlur:b=>{const S=du(b.target.value);S.ok?x.onChange(S.value):i.current&&(i.current.value=x.value??"")}})},e[10]=u):u=e[10];let f;e[11]!==s?(f=o.jsx(mt,{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=o.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?(_=o.jsxs("div",{className:"space-y-2",children:[d,f,m]}),e[14]=f,e[15]=_):_=e[15];let p;return e[16]!==_||e[17]!==n||e[18]!==c?(p=o.jsxs("div",{className:"space-y-5",children:[n,c,_]}),e[16]=_,e[17]=n,e[18]=c,e[19]=p):p=e[19],p}function mu(t){const{field:e}=t;return o.jsx(Xt,{id:"runtime-path",placeholder:".",defaultValue:e.value??"",onBlur:s=>{const i=s.target.value.trim();e.onChange(i===""?null:i)}})}function _u(t){const{field:e}=t;return o.jsxs(is,{value:e.value??Vi,onValueChange:s=>e.onChange(s===Vi?null:s),children:[o.jsx(rs,{id:"runtime-pm",children:o.jsx(ns,{placeholder:"Auto-detect"})}),o.jsxs(os,{children:[o.jsx(Mt,{value:Vi,children:"Auto-detect"}),uu.map(pu)]})]})}function pu(t){return o.jsx(Mt,{value:t,children:t},t)}function gu(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 vu(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 xu(t){const e=$.c(22),{connection_id:s,usedConnectionIds:i,onOpenSettings:r,onRemove:n,onAuthenticate:a,onSwitchInstance:l,onNewInstance:h}=t,c=ln(s),{org:d}=ve();if(!c)return null;let u;e[0]!==c?(u=ph(c),e[0]=c,e[1]=u):u=e[1];const f=u;let m;e[2]!==s?(m=o.jsx(wu,{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]!==n||e[14]!==l||e[15]!==d.slug||e[16]!==f||e[17]!==i?(_=o.jsx(yu,{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:n,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]=n,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=o.jsx(B.Suspense,{fallback:m,children:_}),e[19]=m,e[20]=_,e[21]=p):p=e[21],p}const Wn="__new_instance__";async function bu(t,e){const s=t?.idToken??null;if(s){const r=Un(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 n=await r.json(),a=typeof n.email=="string"?n.email:typeof n.upn=="string"?n.upn:typeof n.preferred_username=="string"?n.preferred_username:null;if(a)return a}}catch{}return Un(e)}function Un(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 Su(t){const e=$.c(23),{appName:s,connectionId:i,usedConnectionIds:r,onSwitchInstance:n,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=Ni(l);if(h.length<=1)return null;let c;e[2]!==i||e[3]!==a||e[4]!==n?(c=p=>{p===Wn?a?.():n(i,p)},e[2]=i,e[3]=a,e[4]=n,e[5]=c):c=e[5];let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx(rs,{size:"sm",className:"w-auto text-xs gap-1 px-2 shadow-none",children:o.jsx(ns,{})}),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=v=>o.jsx(Mt,{value:v.id,className:"text-xs",disabled:v.id!==i&&r.has(v.id),children:v.title},v.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&&o.jsx(Mt,{value:Wn,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=o.jsxs(os,{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?(_=o.jsxs(is,{value:i,onValueChange:c,children:[d,m]}),e[19]=i,e[20]=c,e[21]=m,e[22]=_):_=e[22],_}function yu(t){const e=$.c(55),{connection_id:s,connectionTitle:i,connectionDescription:r,connectionIcon:n,connectionType:a,slug:l,orgSlug:h,appName:c,usedConnectionIds:d,onOpenSettings:u,onRemove:f,onAuthenticate:m,onSwitchInstance:_,onNewInstance:p}=t;let v;e[0]!==s?(v={connectionId:s},e[0]=s,e[1]=v):v=e[1];const x=ga(v),S=!(a==="VIRTUAL")&&x.supportsOAuth&&!x.isAuthenticated,g=S?"border-destructive/50 bg-destructive/5":"border-border";let w;e[2]!==g?(w=ie("rounded-xl border overflow-hidden transition-colors",g),e[2]=g,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]!==n||e[8]!==i?(C=o.jsx(qt,{icon:n,name:i,size:"sm",className:"shrink-0"}),e[7]=n,e[8]=i,e[9]=C):C=e[9];let N;e[10]!==i?(N=o.jsx("p",{className:"text-sm font-medium truncate",children:i}),e[10]=i,e[11]=N):N=e[11];let T;e[12]!==r||e[13]!==S?(T=S?o.jsx("span",{className:"text-xs text-destructive font-medium",children:"Needs authorization"}):r&&o.jsx("p",{className:"text-xs text-muted-foreground truncate",children:r}),e[12]=r,e[13]=S,e[14]=T):T=e[14];let L;e[15]!==N||e[16]!==T?(L=o.jsxs("div",{className:"flex-1 min-w-0",children:[N,T]}),e[15]=N,e[16]=T,e[17]=L):L=e[17];let M;e[18]!==s||e[19]!==S||e[20]!==m?(M=S?o.jsx(re,{variant:"outline",size:"sm",className:"h-7 text-xs shrink-0",onClick:se=>{se.preventDefault(),se.stopPropagation(),m(s)},children:"Authorize"}):o.jsxs(Me,{delayDuration:0,children:[o.jsx(Re,{asChild:!0,children:o.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:o.jsx(vh,{size:16})})}),o.jsx(De,{side:"bottom",children:"Connection settings"})]}),e[18]=s,e[19]=S,e[20]=m,e[21]=M):M=e[21];let D;e[22]!==k||e[23]!==C||e[24]!==L||e[25]!==M?(D=o.jsxs(Ql,{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,L,M]}),e[22]=k,e[23]=C,e[24]=L,e[25]=M,e[26]=D):D=e[26];let y;e[27]!==c||e[28]!==s||e[29]!==p||e[30]!==_||e[31]!==d?(y=c&&o.jsx(Su,{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 R;e[33]===Symbol.for("react.memo_cache_sentinel")?(R=o.jsx(Hc,{size:13}),e[33]=R):R=e[33];let E;e[34]!==u?(E=o.jsx(Re,{asChild:!0,children:o.jsx(re,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:u,"aria-label":"Configure resources",children:R})}),e[34]=u,e[35]=E):E=e[35];let j;e[36]===Symbol.for("react.memo_cache_sentinel")?(j=o.jsx(De,{side:"bottom",children:"Configure resources"}),e[36]=j):j=e[36];let I;e[37]!==E?(I=o.jsxs(Me,{delayDuration:0,children:[E,j]}),e[37]=E,e[38]=I):I=e[38];let P;e[39]===Symbol.for("react.memo_cache_sentinel")?(P=o.jsx(as,{size:13}),e[39]=P):P=e[39];let z;e[40]!==f?(z=o.jsx(Re,{asChild:!0,children:o.jsx(re,{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]=z):z=e[41];let U;e[42]===Symbol.for("react.memo_cache_sentinel")?(U=o.jsx(De,{side:"bottom",children:"Remove"}),e[42]=U):U=e[42];let W;e[43]!==z?(W=o.jsxs(Me,{delayDuration:0,children:[z,U]}),e[43]=z,e[44]=W):W=e[44];let H;e[45]!==I||e[46]!==W?(H=o.jsxs("div",{className:"flex items-center gap-0.5 ml-auto",children:[I,W]}),e[45]=I,e[46]=W,e[47]=H):H=e[47];let G;e[48]!==y||e[49]!==H?(G=o.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 border-t border-border bg-muted/25",children:[y,H]}),e[48]=y,e[49]=H,e[50]=G):G=e[50];let K;return e[51]!==D||e[52]!==G||e[53]!==w?(K=o.jsxs("div",{className:w,children:[D,G]}),e[51]=D,e[52]=G,e[53]=w,e[54]=K):K=e[54],K}function wu(t){const e=$.c(17),{connection_id:s}=t,i=ln(s);if(!i){let u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsx(Oa,{}),e[0]=u):u=e[0],u}let r;e[1]!==i.icon||e[2]!==i.title?(r=o.jsx(qt,{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 n;e[4]!==i.title?(n=o.jsx("p",{className:"text-sm font-medium truncate",children:i.title}),e[4]=i.title,e[5]=n):n=e[5];let a;e[6]!==i.description?(a=i.description&&o.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]!==n||e[9]!==a?(l=o.jsxs("div",{className:"flex-1 min-w-0",children:[n,a]}),e[8]=n,e[9]=a,e[10]=l):l=e[10];let h;e[11]!==r||e[12]!==l?(h=o.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=o.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:o.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=o.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[h,c]}),e[15]=h,e[16]=d):d=e[16],d}function Oa(){const t=$.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.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=o.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e,o.jsxs("div",{className:"flex-1 space-y-1.5",children:[o.jsx("div",{className:"h-4 w-32 rounded bg-muted animate-pulse"}),o.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=o.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[s,o.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:o.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})})]}),t[2]=i):i=t[2],i}function Cu({virtualMcpId:t,form:e,flushAndSave:s}){const{org:i}=ve(),r=Ve({connectionId:Gt,orgId:i.id,orgSlug:i.slug}),n=yt(t),a=(n?.connections??[]).map(y=>y.connection_id).sort(),{data:l}=Qr({queryKey:Fs.projectConnectionDetails(t,a),enabled:a.length>0,queryFn:async()=>await Promise.all(a.map(async R=>{try{const E=await r.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:R}}),{item:j}=_h(E),I=(j?.tools??[]).filter(P=>!!uh(P._meta)).map(P=>({name:P.name,description:P.description}));return{fetchOk:!0,id:R,title:j?.title??R,icon:j?.icon??null,uiTools:I}}catch{return{fetchOk:!1,id:R,title:R,icon:null,uiTools:[]}}}))}),h=(l??[]).filter(y=>y.uiTools.length>0),c=new Set(kc),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[R,E,j]=y.split(":");return R?R==="chat"?{type:R}:c.has(R)?{type:R}:R==="ext-apps"&&E?{type:"ext-apps",id:E,toolName:j||void 0}:null:null},v=y=>{e.setValue("metadata.ui.pinnedViews",y,{shouldDirty:!0})},x=y=>{e.setValue("metadata.ui.layout",{...u,...y},{shouldDirty:!0})},b=B.useRef(!1);if(l&&l.length>0&&!b.current){b.current=!0;const y=new Set((l??[]).filter(j=>j.fetchOk).map(j=>j.id)),R=new Set(h.flatMap(j=>j.uiTools.map(I=>`${j.id}:${I.name}`))),E=d.filter(j=>!y.has(j.connectionId)||R.has(`${j.connectionId}:${j.toolName}`));E.length!==d.length&&(v(E),f?.type==="ext-apps"&&!E.some(j=>j.connectionId===f.id&&j.toolName===f.toolName)&&x({defaultMainView:{type:"chat"}}))}const S=(y,R)=>{if(d.some(j=>j.connectionId===y&&j.toolName===R)){const j=d.filter(P=>!(P.connectionId===y&&P.toolName===R));v(j);const I=`ext-apps:${y}:${R}`;_===I&&x({defaultMainView:{type:"chat"}})}else v([...d,{connectionId:y,toolName:R,label:Rn(R),icon:null}]);s()},g=(y,R,E)=>{v(d.map(j=>j.connectionId===y&&j.toolName===R?{...j,label:E}:j))},w=()=>{s()},k=(y,R,E)=>{v(d.map(j=>j.connectionId===y&&j.toolName===R?{...j,icon:E}:j)),s()},C=y=>{x({defaultMainView:p(y)}),s()},N=a.length===0,T=l&&h.length===0,L=!!Ht(n),M=[{value:"chat",label:"Chat"},{value:"settings",label:"Settings"},{value:"automations",label:"Automations"}];L&&M.push({value:"preview",label:"Preview"});for(const y of d)M.push({value:`ext-apps:${y.connectionId}:${y.toolName}`,label:y.label||y.toolName});const D=h.length>0||N||T;return o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("div",{className:"flex items-center justify-between gap-3",children:o.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Layout"})}),o.jsxs(Ta,{className:"p-6 gap-5",children:[o.jsxs(dr,{className:"p-0 space-y-5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsxs("div",{className:"space-y-0.5 min-w-0",children:[o.jsx(Ot,{className:"font-normal text-foreground",children:"Main view"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"What users see when they first open this agent."})]}),o.jsxs(is,{value:_,onValueChange:C,children:[o.jsx(rs,{className:"w-44 h-8 text-sm capitalize shrink-0",children:o.jsx(ns,{})}),o.jsx(os,{children:M.map(y=>o.jsx(Mt,{value:y.value,className:"capitalize",children:y.label},y.value))})]})]}),o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsxs("div",{className:"space-y-0.5 min-w-0",children:[o.jsx(Ot,{className:"font-normal text-foreground",children:"Show chat"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Display the chat panel alongside the main view."})]}),o.jsxs(Me,{delayDuration:0,children:[o.jsx(Re,{asChild:!0,children:o.jsx("span",{className:"shrink-0",children:o.jsx(ur,{checked:_==="chat"?!0:m,disabled:_==="chat",onCheckedChange:y=>{x({chatDefaultOpen:y}),s()}})})}),_==="chat"&&o.jsx(De,{side:"top",children:"Chat is always shown when it is the default view"})]})]})]}),D&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"border-t border-border -mx-6"}),o.jsxs(dr,{className:"p-0 space-y-3",children:[o.jsx("div",{className:"flex items-center justify-between gap-4",children:o.jsxs("div",{className:"space-y-0.5 min-w-0",children:[o.jsx(Ot,{className:"font-normal text-foreground",children:"Pinned views"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Surface interactive tools as top-level tabs in the agent."})]})}),N&&o.jsx("p",{className:"text-xs text-muted-foreground",children:"Add a connection above to configure pinned views."}),T&&!N&&o.jsx("p",{className:"text-xs text-muted-foreground",children:"None of the connected servers expose interactive tools."}),h.length>0&&o.jsx("div",{className:"space-y-4 pt-1",children:h.map((y,R)=>o.jsxs("div",{children:[R>0&&o.jsx("div",{className:"border-t border-border -mx-6 mb-4"}),o.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[o.jsx(qt,{icon:y.icon,name:y.title,size:"xs",className:"shrink-0"}),o.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:y.title})]}),o.jsx("div",{className:"space-y-1.5",children:y.uiTools.map(E=>{const j=d.some(P=>P.connectionId===y.id&&P.toolName===E.name),I=d.find(P=>P.connectionId===y.id&&P.toolName===E.name);return o.jsxs("div",{className:ie("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:[o.jsxs("div",{className:"min-w-0 flex-1 flex items-center gap-2",children:[o.jsx($d,{value:I?.icon??null,onChange:P=>k(y.id,E.name,P),disabled:!j}),o.jsx(Xt,{value:j&&I?I.label:Rn(E.name),onChange:P=>g(y.id,E.name,P.target.value),onBlur:w,className:"h-7 text-sm w-40",disabled:!j,readOnly:!j})]}),o.jsx(ur,{checked:j,onCheckedChange:()=>S(y.id,E.name)})]},E.name)})})]},y.id))})]})]})]})]})}function ku({virtualMcp:t,hideOwnTitle:e}){const{org:s}=ve(),i=fc(),r=ch(),n=hs(),a=Ve({connectionId:Gt,orgId:s.id,orgSlug:s.slug}),l=Zo({resolver:Jl(eu),defaultValues:t}),h=l.watch("connections"),c=!!Ht(t),d=Ht(t),u=d?{owner:d.owner,name:d.name,url:d.url}:null,[f,m]=B.useReducer(gu,{shareDialogOpen:!1,addDialogOpen:!1,settingsDialogOpen:!1,settingsConnectionId:null}),[_,p]=B.useState(!1),[v,x]=B.useState(!1),{createNewTask:b,setChatOpen:S}=an(),{sendMessage:g}=Yt(),w=_a(),k=async()=>{if(v)return;const A=l.getValues("metadata.instructions");if(A?.trim()){x(!0);try{D(),ye("agent_instructions_improve_clicked",{agent_id:t.id,instructions_length:A.length}),await w(["studio-agent-manager"]),S(!0),await g({tiptapDoc:La({managerAgentId:ia.AGENT_MANAGER(s.id),managerName:"Agent Manager",kind:"agent",id:t.id,instructions:A})})}finally{x(!1)}}},C=()=>{D(),ye("agent_test_clicked",{agent_id:t.id}),b()},[N,T]=B.useReducer(vu,null),L=()=>{N!==null&&(ye("agent_updated",{agent_id:t.id,fields:Array.from(N.fields),instructions_length:N.instructionsLength,save_count:N.saveCount,edit_duration_ms:Date.now()-N.start}),T({type:"reset"}))},{schedule:M,flush:D}=gi({delayMs:3e4,save:async()=>L()}),y=async()=>{const A=Object.keys(l.control._formState.dirtyFields);if(A.length===0)return;const X=A.includes("metadata"),Q=l.getValues();l.reset(Q,{keepValues:!0}),await i.update.mutateAsync({id:t.id,data:Q}),T({type:"accumulate",now:Date.now(),fields:A,instructionsLength:X?Q.metadata?.instructions?.length??0:null}),M()},{schedule:R,flush:E}=gi({save:y});B.useEffect(()=>{const A=l.watch(()=>R());return()=>A.unsubscribe()},[]);const j=()=>{ye("connections_dialog_opened",{source:"agent_settings",mode:"add"}),m({type:"SET_ADD_DIALOG_OPEN",payload:!0})},I=async A=>{const X=l.getValues("connections");if(X.some(V=>V.connection_id===A))return;l.setValue("connections",[...X,{connection_id:A,selected_tools:Ki.tools,selected_resources:Ki.resources,selected_prompts:Ki.prompts}],{shouldDirty:!0}),m({type:"SET_ADD_DIALOG_OPEN",payload:!1});const Q=new URL(`/api/${s.slug}/mcp/${A}`,window.location.origin),F=await kn({url:Q.href,token:null,orgId:s.id});F.supportsOAuth&&!F.isAuthenticated&&await H(A)},P=A=>{const Q=l.getValues("connections").filter(F=>F.connection_id!==A);l.setValue("connections",Q,{shouldDirty:!0})},z=(A,X)=>{const Q=l.getValues("connections");if(Q.some(F=>F.connection_id===X)){me.error("This instance is already added to the agent");return}l.setValue("connections",Q.map(F=>F.connection_id===A?{...F,connection_id:X}:F),{shouldDirty:!0})},U=async A=>{if(l.getValues("connections").find(Q=>Q.connection_id===A))try{const Q=await a.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:A}}),{item:F}=Q.structuredContent??{};if(!F)return;const V=F.title.replace(/\s*\(.*?\)\s*$/,""),ne=hh("conn"),he=`${V} (${Date.now().toString(36).slice(-4)})`;await r.create.mutateAsync({id:ne,title:he,description:F.description??null,connection_type:F.connection_type,connection_url:F.connection_url??null,connection_token:null,icon:F.icon??null,app_name:F.app_name??null,app_id:F.app_id??null,connection_headers:F.connection_headers??null});const ce=new URL(`/api/${s.slug}/mcp/${ne}`,window.location.origin),de=await kn({url:ce.href,token:null,orgId:s.id});if(de.supportsOAuth&&!de.isAuthenticated){const fe=await H(ne);if(!fe){await r.delete.mutateAsync(ne);return}await r.update.mutateAsync({id:ne,data:{title:`${V} (${fe})`}})}z(A,ne),me.success("New instance created")}catch(Q){console.error("Failed to create instance:",Q),me.error("Failed to create instance")}},W=A=>{m({type:"OPEN_SETTINGS",payload:A})},H=async A=>{const{token:X,tokenInfo:Q,error:F}=await Zl({connectionId:A,orgSlug:s.slug,scope:"offline_access"});if(F||!X)return me.error(`Authentication failed: ${F}`),null;if(Q)try{const ne=await fetch(`/api/${s.slug}/connections/${A}/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(!ne.ok)console.error("Failed to save OAuth token:",await ne.text()),await r.update.mutateAsync({id:A,data:{connection_token:X}});else try{await r.update.mutateAsync({id:A,data:{}})}catch(he){console.warn("Failed to refresh connection tools after OAuth:",he)}}catch(ne){console.error("Error saving OAuth token:",ne),await r.update.mutateAsync({id:A,data:{connection_token:X}})}else await r.update.mutateAsync({id:A,data:{connection_token:X}});const V=new URL(`/api/${s.slug}/mcp/${A}`,window.location.origin);return await n.invalidateQueries({queryKey:Fs.isMCPAuthenticated(V.href,null)}),me.success("Authentication successful"),bu(Q,X)},G=()=>{const A=l.getValues("metadata.instructions")??"",X=`<role>
|
|
5
5
|
Define who this agent is and what it specializes in.
|
|
@@ -181,6 +181,6 @@ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){t
|
|
|
181
181
|
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(t){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),wn&&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=vo(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=yn(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,-Qi),Qi),e/=Qi,e/Math.abs(e)+Math.round(e*(Z_-1)))}shouldForceSelection(t){return Si?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(),Q_)}_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&&!(Si&&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<ep&&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=U_(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,n=r.lines.get(t[1]);if(!n)return;let a=r.translateBufferLineToString(t[1],!1),l=this._convertViewportColToCharacterIndex(n,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 v=t[0],x=t[0];n.getWidth(v)===0&&(d++,v--),n.getWidth(x)===2&&(u++,x++);let b=n.getString(x).length;for(b>1&&(m+=b-1,h+=b-1);v>0&&l>0&&!this._isCharWordSeparator(n.loadCell(v-1,this._workCell));){n.loadCell(v-1,this._workCell);let S=this._workCell.getChars().length;this._workCell.getWidth()===0?(d++,v--):S>1&&(f+=S-1,l-=S-1),l--,v--}for(;x<n.length&&h+1<a.length&&!this._isCharWordSeparator(n.loadCell(x+1,this._workCell));){n.loadCell(x+1,this._workCell);let S=this._workCell.getChars().length;this._workCell.getWidth()===2?(u++,x++):S>1&&(m+=S-1,h+=S-1),h++,x++}}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&&n.getCodePoint(0)!==32){let v=r.lines.get(t[1]-1);if(v&&n.isWrapped&&v.getCodePoint(this._bufferService.cols-1)!==32){let x=this._getWordAt([this._bufferService.cols-1,t[1]-1],!1,!0,!1);if(x){let b=this._bufferService.cols-x.start;_-=b,p+=b}}}if(i&&_+p===this._bufferService.cols&&n.getCodePoint(this._bufferService.cols-1)!==32){let v=r.lines.get(t[1]+1);if(v?.isWrapped&&v.getCodePoint(0)!==32){let x=this._getWordAt([0,t[1]+1],!1,!1,!0);x&&(p+=x.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=vo(s,this._bufferService.cols)}};Hr=Ce([te(3,Ye),te(4,Jt),te(5,_n),te(6,Xe),te(7,Ct),te(8,wt)],Hr);var xo=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={}}},bo=class{constructor(){this._color=new xo,this._css=new xo}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()}},Pe=Object.freeze((()=>{let t=[be.toColor("#2e3436"),be.toColor("#cc0000"),be.toColor("#4e9a06"),be.toColor("#c4a000"),be.toColor("#3465a4"),be.toColor("#75507b"),be.toColor("#06989a"),be.toColor("#d3d7cf"),be.toColor("#555753"),be.toColor("#ef2929"),be.toColor("#8ae234"),be.toColor("#fce94f"),be.toColor("#729fcf"),be.toColor("#ad7fa8"),be.toColor("#34e2e2"),be.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],n=e[s%6];t.push({css:Te.toCss(i,r,n),rgba:Te.toRgba(i,r,n)})}for(let s=0;s<24;s++){let i=8+s*10;t.push({css:Te.toCss(i,i,i),rgba:Te.toRgba(i,i,i)})}return t})()),At=be.toColor("#ffffff"),Es=be.toColor("#000000"),So=be.toColor("#ffffff"),yo=Es,ys={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},ip=At,Wr=class extends le{constructor(t){super(),this._optionsService=t,this._contrastCache=new bo,this._halfContrastCache=new bo,this._onChangeColors=this._register(new q),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:At,background:Es,cursor:So,cursorAccent:yo,selectionForeground:void 0,selectionBackgroundTransparent:ys,selectionBackgroundOpaque:pe.blend(Es,ys),selectionInactiveBackgroundTransparent:ys,selectionInactiveBackgroundOpaque:pe.blend(Es,ys),scrollbarSliderBackground:pe.opacity(At,.2),scrollbarSliderHoverBackground:pe.opacity(At,.4),scrollbarSliderActiveBackground:pe.opacity(At,.5),overviewRulerBorder:At,ansi:Pe.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=ue(t.foreground,At),e.background=ue(t.background,Es),e.cursor=pe.blend(e.background,ue(t.cursor,So)),e.cursorAccent=pe.blend(e.background,ue(t.cursorAccent,yo)),e.selectionBackgroundTransparent=ue(t.selectionBackground,ys),e.selectionBackgroundOpaque=pe.blend(e.background,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundTransparent=ue(t.selectionInactiveBackground,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundOpaque=pe.blend(e.background,e.selectionInactiveBackgroundTransparent),e.selectionForeground=t.selectionForeground?ue(t.selectionForeground,_o):void 0,e.selectionForeground===_o&&(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=ue(t.scrollbarSliderBackground,pe.opacity(e.foreground,.2)),e.scrollbarSliderHoverBackground=ue(t.scrollbarSliderHoverBackground,pe.opacity(e.foreground,.4)),e.scrollbarSliderActiveBackground=ue(t.scrollbarSliderActiveBackground,pe.opacity(e.foreground,.5)),e.overviewRulerBorder=ue(t.overviewRulerBorder,ip),e.ansi=Pe.slice(),e.ansi[0]=ue(t.black,Pe[0]),e.ansi[1]=ue(t.red,Pe[1]),e.ansi[2]=ue(t.green,Pe[2]),e.ansi[3]=ue(t.yellow,Pe[3]),e.ansi[4]=ue(t.blue,Pe[4]),e.ansi[5]=ue(t.magenta,Pe[5]),e.ansi[6]=ue(t.cyan,Pe[6]),e.ansi[7]=ue(t.white,Pe[7]),e.ansi[8]=ue(t.brightBlack,Pe[8]),e.ansi[9]=ue(t.brightRed,Pe[9]),e.ansi[10]=ue(t.brightGreen,Pe[10]),e.ansi[11]=ue(t.brightYellow,Pe[11]),e.ansi[12]=ue(t.brightBlue,Pe[12]),e.ansi[13]=ue(t.brightMagenta,Pe[13]),e.ansi[14]=ue(t.brightCyan,Pe[14]),e.ansi[15]=ue(t.brightWhite,Pe[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]=ue(t.extendedAnsi[i],Pe[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()}}};Wr=Ce([te(0,Xe)],Wr);function ue(t,e){if(t!==void 0)try{return be.toColor(t)}catch{}return e}var rp=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)}},np=class{constructor(){this._services=new rp,this._services.set(mn,this)}setService(t,e){this._services.set(t,e)}getService(t){return this._services.get(t)}createInstance(t,...e){let s=Zf(t).sort((n,a)=>n.index-a.index),i=[];for(let n of s){let a=this._services.get(n.id);if(!a)throw new Error(`[createInstance] ${t.name} depends on UNKNOWN service ${n.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)}},op={trace:0,debug:1,info:2,warn:3,error:4,off:5},ap="xterm.js: ",Ur=class extends le{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=op[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?"":ap)+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)}};Ur=Ce([te(0,Xe)],Ur);var wo=class extends le{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}},ae=3,Ee=Object.freeze(new Ks),ri=0,er=2,Ts=class Rl{constructor(e,s,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*ae);let r=s||ot.fromCharData([0,Ya,1,0]);for(let n=0;n<e;++n)this.setCell(n,r);this.length=e}get(e){let s=this._data[e*ae+0],i=s&2097151;return[this._data[e*ae+1],s&2097152?this._combined[e]:i?Et(i):"",s>>22,s&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):i]}set(e,s){this._data[e*ae+1]=s[0],s[1].length>1?(this._combined[e]=s[1],this._data[e*ae+0]=e|2097152|s[2]<<22):this._data[e*ae+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(e){return this._data[e*ae+0]>>22}hasWidth(e){return this._data[e*ae+0]&12582912}getFg(e){return this._data[e*ae+1]}getBg(e){return this._data[e*ae+2]}hasContent(e){return this._data[e*ae+0]&4194303}getCodePoint(e){let s=this._data[e*ae+0];return s&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):s&2097151}isCombined(e){return this._data[e*ae+0]&2097152}getString(e){let s=this._data[e*ae+0];return s&2097152?this._combined[e]:s&2097151?Et(s&2097151):""}isProtected(e){return this._data[e*ae+2]&536870912}loadCell(e,s){return ri=e*ae,s.content=this._data[ri+0],s.fg=this._data[ri+1],s.bg=this._data[ri+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*ae+0]=s.content,this._data[e*ae+1]=s.fg,this._data[e*ae+2]=s.bg}setCellFromCodepoint(e,s,i,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*ae+0]=s|i<<22,this._data[e*ae+1]=r.fg,this._data[e*ae+2]=r.bg}addCodepointToCell(e,s,i){let r=this._data[e*ae+0];r&2097152?this._combined[e]+=Et(s):r&2097151?(this._combined[e]=Et(r&2097151)+Et(s),r&=-2097152,r|=2097152):r=s|1<<22,i&&(r&=-12582913,r|=i<<22),this._data[e*ae+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 ot;for(let n=this.length-e-s-1;n>=0;--n)this.setCell(e+s+n,this.loadCell(e+n,r));for(let n=0;n<s;++n)this.setCell(e+n,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 ot;for(let n=0;n<this.length-e-s;++n)this.setCell(e+n,this.loadCell(e+s+n,r));for(let n=this.length-s;n<this.length;++n)this.setCell(n,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*er<this._data.buffer.byteLength;let i=e*ae;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 n=Object.keys(this._extendedAttrs);for(let a=0;a<n.length;a++){let l=parseInt(n[a],10);l>=e&&delete this._extendedAttrs[l]}}return this.length=e,i*4*er<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*er<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 Rl(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*ae+0]&4194303)return e+(this._data[e*ae+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*ae+0]&4194303||this._data[e*ae+2]&50331648)return e+(this._data[e*ae+0]>>22);return 0}copyCellsFrom(e,s,i,r,n){let a=e._data;if(n)for(let h=r-1;h>=0;h--){for(let c=0;c<ae;c++)this._data[(i+h)*ae+c]=a[(s+h)*ae+c];a[(s+h)*ae+2]&268435456&&(this._extendedAttrs[i+h]=e._extendedAttrs[s+h])}else for(let h=0;h<r;h++){for(let c=0;c<ae;c++)this._data[(i+h)*ae+c]=a[(s+h)*ae+c];a[(s+h)*ae+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 n="";for(;s<i;){let a=this._data[s*ae+0],l=a&2097151,h=a&2097152?this._combined[s]:l?Et(l):Tt;if(n+=h,r)for(let c=0;c<h.length;++c)r.push(s);s+=a>>22||1}return r&&r.push(s),n}};function lp(t,e,s,i,r,n){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(!n&&i>=l&&i<h){l+=d.length-1;continue}let u=0,f=zs(d,u,e),m=1,_=0;for(;m<d.length;){let v=zs(d,m,e),x=v-_,b=s-f,S=Math.min(x,b);d[u].copyCellsFrom(d[m],_,f,S,!1),f+=S,f===s&&(u++,f=0),_+=S,_===v&&(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 v=d.length-1;v>0&&(v>u||d[v].getTrimmedLength()===0);v--)p++;p>0&&(a.push(l+d.length-p),a.push(p)),l+=d.length-1}return a}function cp(t,e){let s=[],i=0,r=e[i],n=0;for(let a=0;a<t.length;a++)if(r===a){let l=e[++i];t.onDeleteEmitter.fire({index:a-n,amount:l}),a+=l-1,n+=l,r=e[++i]}else s.push(a);return{layout:s,countRemoved:n}}function hp(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 dp(t,e,s){let i=[],r=t.map((h,c)=>zs(t,c,e)).reduce((h,c)=>h+c),n=0,a=0,l=0;for(;l<r;){if(r-l<s){i.push(r-l);break}n+=s;let h=zs(t,a,e);n>h&&(n-=h,a++);let c=t[a].getWidth(n-1)===2;c&&n--;let d=c?s-1:s;i.push(d),l+=d}return i}function zs(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 Dl=class Ml{constructor(e){this.line=e,this.isDisposed=!1,this._disposables=[],this._id=Ml._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(),Ut(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};Dl._nextId=1;var up=Dl,Ae={},Bt=Ae.B;Ae[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Ae.A={"#":"£"};Ae.B=void 0;Ae[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Ae.C=Ae[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ae.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Ae.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Ae.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Ae.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Ae.E=Ae[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Ae.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Ae.H=Ae[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ae["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Co=4294967295,ko=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=Ee.clone(),this.savedCharset=Bt,this.markers=[],this._nullCell=ot.fromCharData([0,Ya,1,0]),this._whitespaceCell=ot.fromCharData([0,Tt,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new yi,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new wo(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 vi),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 vi),this._whitespaceCell}getBlankLine(t,e){return new Ts(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>Co?Co:e}fillViewportRows(t){if(this.lines.length===0){t===void 0&&(t=Ee);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 wo(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(t,e){let s=this.getNullCell(Ee),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 n=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 Ts(t,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+n+1?(this.ybase--,n++,this.ydisp>0&&this.ydisp--):this.lines.push(new Ts(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),n&&(this.y+=n),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 n=0;n<this.lines.length;n++)i+=+this.lines.get(n).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=lp(this.lines,this._cols,t,this.ybase+this.y,this.getNullCell(Ee),s);if(i.length>0){let r=cp(this.lines,i);hp(this.lines,r.layout),this._reflowLargerAdjustViewport(t,e,r.countRemoved)}}_reflowLargerAdjustViewport(t,e,s){let i=this.getNullCell(Ee),r=s;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<e&&this.lines.push(new Ts(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(Ee),r=[],n=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 S=this.ybase+this.y;if(S>=a&&S<a+h.length)continue}let c=h[h.length-1].getTrimmedLength(),d=dp(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 S=0;S<u;S++){let g=this.getBlankLine(Ee,!0);m.push(g)}m.length>0&&(r.push({start:a+h.length+n,newLines:m}),n+=m.length),h.push(...m);let _=d.length-1,p=d[_];p===0&&(_--,p=d[_]);let v=h.length-u-1,x=c;for(;v>=0;){let S=Math.min(x,p);if(h[_]===void 0)break;if(h[_].copyCellsFrom(h[v],x-S,p-S,S,!0),p-=S,p===0&&(_--,p=d[_]),x-=S,x===0){v--;let g=Math.max(v,0);x=zs(h,g,this._cols)}}for(let S=0;S<h.length;S++)d[S]<t&&h[S].setCell(d[S],i);let b=u-f;for(;b-- >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+n)-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+n);let f=0;for(let p=Math.min(this.lines.maxLength-1,h+n-1);p>=0;p--)if(u&&u.start>c+f){for(let v=u.newLines.length-1;v>=0;v--)this.lines.set(p--,u.newLines[v]);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+n-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 up(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)}},fp=class extends le{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 ko(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new ko(!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)}},Pl=2,Il=1,Kr=class extends le{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,Pl),this.rows=Math.max(t.rawOptions.rows||0,Il),this.buffers=this._register(new fp(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,n=s.ybase+s.scrollBottom;if(s.scrollTop===0){let a=s.lines.isFull;n===s.lines.length-1?a?s.lines.recycle().copyFrom(i):s.lines.push(i.clone()):s.lines.splice(n+1,0,i.clone()),a?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let a=n-r+1;s.lines.shiftElements(r+1,a-1,-1),s.lines.set(n,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))}};Kr=Ce([te(0,Xe)],Kr);var es={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:Si,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},mp=["normal","bold","100","200","300","400","500","600","700","800","900"],_p=class extends le{constructor(t){super(),this._onOptionChange=this._register(new q),this.onOptionChange=this._onOptionChange.event;let e={...es};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(ge(()=>{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 es))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},e=(s,i)=>{if(!(s in es))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=es[t]),!pp(e))throw new Error(`"${e}" is not a valid value for ${t}`);break;case"wordSeparator":e||(e=es[t]);break;case"fontWeight":case"fontWeightBold":if(typeof e=="number"&&1<=e&&e<=1e3)break;e=mp.includes(e)?e:es[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 pp(t){return t==="block"||t==="underline"||t==="bar"}function Rs(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]&&Rs(t[i],e-1);return s}var No=Object.freeze({insertMode:!1}),jo=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Vr=class extends le{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=Rs(No),this.decPrivateModes=Rs(jo)}reset(){this.modes=Rs(No),this.decPrivateModes=Rs(jo)}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))}};Vr=Ce([te(0,Ye),te(1,el),te(2,Xe)],Vr);var Eo={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 tr(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 sr=String.fromCharCode,To={DEFAULT:t=>{let e=[tr(t,!1)+32,t.col+32,t.row+32];return e[0]>255||e[1]>255||e[2]>255?"":`\x1B[M${sr(e[0])}${sr(e[1])}${sr(e[2])}`},SGR:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${tr(t,!0)};${t.col};${t.row}${e}`},SGR_PIXELS:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${tr(t,!0)};${t.x};${t.y}${e}`}},qr=class extends le{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(Eo))this.addProtocol(i,Eo[i]);for(let i of Object.keys(To))this.addEncoding(i,To[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)}};qr=Ce([te(0,Ye),te(1,Jt),te(2,Xe)],qr);var ir=[[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]],Ie;function vp(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",!Ie){Ie=new Uint8Array(65536),Ie.fill(1),Ie[0]=0,Ie.fill(0,1,32),Ie.fill(0,127,160),Ie.fill(2,4352,4448),Ie[9001]=2,Ie[9002]=2,Ie.fill(2,11904,42192),Ie[12351]=1,Ie.fill(2,44032,55204),Ie.fill(2,63744,64256),Ie.fill(2,65040,65050),Ie.fill(2,65072,65136),Ie.fill(2,65280,65377),Ie.fill(2,65504,65511);for(let t=0;t<ir.length;++t)Ie.fill(0,ir[t][0],ir[t][1]+1)}}wcwidth(t){return t<32?0:t<127?1:t<65536?Ie[t]:vp(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=Lt.extractWidth(e);r===0?i=!1:r>s&&(s=r)}return Lt.createPropertyValue(0,s,i)}},Lt=class mi{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 n=0;n<r;++n){let a=e.charCodeAt(n);if(55296<=a&&a<=56319){if(++n>=r)return s+this.wcwidth(a);let c=e.charCodeAt(n);56320<=c&&c<=57343?a=(a-55296)*1024+c-56320+65536:s+=this.wcwidth(c)}let l=this.charProperties(a,i),h=mi.extractWidth(l);mi.extractShouldJoin(l)&&(h-=mi.extractWidth(i)),s+=h,i=l}return s}charProperties(e,s){return this._activeProvider.charProperties(e,s)}},bp=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 Ro(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 ws=2147483647,Sp=256,Al=class Gr{constructor(e=32,s=32){if(this.maxLength=e,this.maxSubParamsLength=s,s>Sp)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 Gr;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 n=0;n<r.length;++n)s.addSubParam(r[n]);else s.addParam(r)}return s}clone(){let e=new Gr(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>ws?ws: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>ws?ws: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,ws):e}},Cs=[],yp=class{constructor(){this._state=0,this._active=Cs,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=Cs}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=Cs,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Cs,!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",Ii(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=Cs,this._id=-1,this._state=0}}},et=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+=Ii(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}},ks=[],wp=class{constructor(){this._handlers=Object.create(null),this._active=ks,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=ks}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=ks,this._ident=0}hook(t,e){if(this.reset(),this._ident=t,this._active=this._handlers[t]||ks,!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",Ii(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=ks,this._ident=0}},Ds=new Al;Ds.addParam(0);var Do=class{constructor(t){this._handler=t,this._data="",this._params=Ds,this._hitLimit=!1}hook(t){this._params=t.length>1||t.params[0]?t.clone():Ds,this._data="",this._hitLimit=!1}put(t,e,s){this._hitLimit||(this._data+=Ii(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=Ds,this._data="",this._hitLimit=!1,s));return this._params=Ds,this._data="",this._hitLimit=!1,e}},Cp=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}},nt=160,kp=(function(){let t=new Cp(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 n=s(0,14),a;t.setDefault(1,0),t.addMany(i,0,2,0);for(a in n)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(nt,0,2,0),t.add(nt,8,5,8),t.add(nt,6,0,6),t.add(nt,11,0,11),t.add(nt,13,13,13),t})(),Np=class extends le{constructor(t=kp){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 Al,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(ge(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new yp),this._dcsParser=this._register(new wp),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 n=t.intermediates.charCodeAt(r);if(32>n||n>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=n}}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,n=0,a;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,n=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,n=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let l=n;l<e;++l){switch(i=t[l],r=this._transitions.table[this.currentState<<8|(i<160?i:nt)],r>>4){case 2:for(let f=l+1;;++f){if(f>=e||(i=t[f])<32||i>126&&i<nt){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(i=t[f])<32||i>126&&i<nt){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(i=t[f])<32||i>126&&i<nt){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(i=t[f])<32||i>126&&i<nt){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<nt){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<nt){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}}},jp=/^([\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})$/,Ep=/^[\da-f]+$/;function Mo(t){if(!t)return;let e=t.toLowerCase();if(e.indexOf("rgb:")===0){e=e.slice(4);let s=jp.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),Ep.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 n=parseInt(e.slice(s*r,s*r+s),16);i[r]=s===1?n<<4:s===2?n:s===3?n>>4:n>>8}return i}}function rr(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 Tp(t,e=16){let[s,i,r]=t;return`rgb:${rr(s,e)}/${rr(i,e)}/${rr(r,e)}`}var Rp={"(":0,")":1,"*":2,"+":3,"-":1,".":2},jt=131072,Po=10;function Io(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 Ao=5e3,Bo=0,Dp=class extends le{constructor(t,e,s,i,r,n,a,l,h=new Np){super(),this._bufferService=t,this._charsetService=e,this._coreService=s,this._logService=i,this._optionsService=r,this._oscLinkService=n,this._coreMouseService=a,this._unicodeService=l,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Xf,this._utf8Decoder=new Jf,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Ee.clone(),this._eraseAttrDataInternal=Ee.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 Yr(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(O.BEL,()=>this.bell()),this._parser.setExecuteHandler(O.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(O.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(O.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(O.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(O.BS,()=>this.backspace()),this._parser.setExecuteHandler(O.HT,()=>this.tab()),this._parser.setExecuteHandler(O.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(O.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(ui.IND,()=>this.index()),this._parser.setExecuteHandler(ui.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(ui.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new et(c=>(this.setTitle(c),this.setIconName(c),!0))),this._parser.registerOscHandler(1,new et(c=>this.setIconName(c))),this._parser.registerOscHandler(2,new et(c=>this.setTitle(c))),this._parser.registerOscHandler(4,new et(c=>this.setOrReportIndexedColor(c))),this._parser.registerOscHandler(8,new et(c=>this.setHyperlink(c))),this._parser.registerOscHandler(10,new et(c=>this.setOrReportFgColor(c))),this._parser.registerOscHandler(11,new et(c=>this.setOrReportBgColor(c))),this._parser.registerOscHandler(12,new et(c=>this.setOrReportCursorColor(c))),this._parser.registerOscHandler(104,new et(c=>this.restoreIndexedColor(c))),this._parser.registerOscHandler(110,new et(c=>this.restoreFgColor(c))),this._parser.registerOscHandler(111,new et(c=>this.restoreBgColor(c))),this._parser.registerOscHandler(112,new et(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 Ae)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 Do((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"),Ao))]).catch(e=>{if(e!=="#SLOW_TIMEOUT")throw e;console.warn(`async parser handler taking longer than ${Ao} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(t,e){let s,i=this._activeBuffer.x,r=this._activeBuffer.y,n=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>jt&&(n=this._parseStack.position+jt)}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<jt&&(this._parseBuffer=new Uint32Array(Math.min(t.length,jt))),a||this._dirtyRowTracker.clearRange(),t.length>jt)for(let c=n;c<t.length;c+=jt){let d=c+jt<t.length?c+jt: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,n=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&&n){let x=n[String.fromCharCode(i)];x&&(i=x.charCodeAt(0))}let _=this._unicodeService.charProperties(i,f);r=Lt.extractWidth(_);let p=Lt.extractShouldJoin(_),v=p?Lt.extractWidth(f):0;if(f=_,a&&this._onA11yChar.fire(Et(i)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-v>l){if(h){let x=u,b=this._activeBuffer.x-v;for(this._activeBuffer.x=v,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),v>0&&u instanceof Ts&&u.copyCellsFrom(x,b,0,v,!1);b<l;)x.setCellFromCodepoint(b++,0,1,d)}else if(this._activeBuffer.x=l-1,r===2)continue}if(p&&this._activeBuffer.x){let x=u.getWidth(this._activeBuffer.x-1)?1:2;u.addCodepointToCell(this._activeBuffer.x-x,i,r);for(let b=r-v;--b>=0;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,d);continue}if(c&&(u.insertCells(this._activeBuffer.x,r-v,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=>Io(s.params[0],this._optionsService.rawOptions.windowOptions)?e(s):!0):this._parser.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._parser.registerDcsHandler(t,new Do(e))}registerEscHandler(t,e){return this._parser.registerEscHandler(t,e)}registerOscHandler(t,e){return this._parser.registerOscHandler(t,new et(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 n=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);n.replaceCells(e,s,this._activeBuffer.getNullCell(this._eraseAttrData()),r),i&&(n.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(Ee));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=Lt.extractWidth(e),r=this._activeBuffer.x-i,n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),a=new Uint32Array(n.length*s),l=0;for(let c=0;c<n.length;){let d=n.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(O.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(O.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(t){return t.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(O.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(O.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(t.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(O.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,Bt),this._charsetService.setgCharset(1,Bt),this._charsetService.setgCharset(2,Bt),this._charsetService.setgCharset(3,Bt);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:n}=this._coreMouseService,a=this._coreService,{buffers:l,cols:h}=this._bufferService,{active:c,alt:d}=l,u=this._optionsService.rawOptions,f=(p,v)=>(a.triggerDataEvent(`${O.ESC}[${e?"":"?"}${p};${v}$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(n==="SGR")):_===1015?f(_,4):_===1016?f(_,m(n==="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|=Ks.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,n=0;do{if(i[n+r]=t.params[e+n],t.hasSubParams(e+n)){let a=t.getSubParams(e+n),l=0;do i[1]===5&&(r=1),i[n+l+1+r]=a[l];while(++l<a.length&&l+n+1+r<i.length);break}if(i[1]===5&&n+r>=2||i[1]===2&&n+r>=5)break;i[1]&&(r=1)}while(++n+e<t.length&&n+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 n}_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=Ee.fg,t.bg=Ee.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|=Ee.fg&16777215):s===49?(i.bg&=-67108864,i.bg|=Ee.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|=Ee.fg&16777215,i.bg&=-67108864,i.bg|=Ee.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(t){switch(t.params[0]){case 5:this._coreService.triggerDataEvent(`${O.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${O.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(`${O.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=Ee.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(!Io(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(`${O.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(e===0||e===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Po&&this._windowTitleStack.shift()),(e===0||e===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Po&&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 n=parseInt(i);if(Lo(n))if(r==="?")e.push({type:0,index:n});else{let a=Mo(r);a&&e.push({type:1,index:n,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(n=>n.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=Mo(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]);Lo(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,Bt),!0}selectCharset(t){return t.length!==2?(this.selectDefaultCharset(),!0):(t[0]==="/"||this._charsetService.setgCharset(Rp[t[0]],Ae[t[1]]||Bt),!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=Ee.clone(),this._eraseAttrDataInternal=Ee.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 ot;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(`${O.ESC}${a}${O.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)}},Yr=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&&(Bo=t,t=e,e=Bo),t<this.start&&(this.start=t),e>this.end&&(this.end=e)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Yr=Ce([te(0,Ye)],Yr);function Lo(t){return 0<=t&&t<256}var Mp=5e7,Oo=12,Pp=50,Ip=class extends le{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>Mp)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>=Oo?setTimeout(()=>this._innerWrite(0,l)):this._innerWrite(s,l);r.catch(l=>(queueMicrotask(()=>{throw l}),Promise.resolve(!1))).then(a);return}let n=this._callbacks[this._bufferOffset];if(n&&n(),this._bufferOffset++,this._pendingData-=i.length,performance.now()-s>=Oo)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>Pp&&(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()}},Xr=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 n=e.addMarker(e.ybase+e.y),a={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(a,n)),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)))}};Xr=Ce([te(0,Ye)],Xr);var $o=!1,Ap=class extends le{constructor(t){super(),this._windowsWrappingHeuristics=this._register(new cs),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 np,this.optionsService=this._register(new _p(t)),this._instantiationService.setService(Xe,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Kr)),this._instantiationService.setService(Ye,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Ur)),this._instantiationService.setService(el,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Vr)),this._instantiationService.setService(Jt,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(qr)),this._instantiationService.setService(Qa,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Lt)),this._instantiationService.setService(tm,this.unicodeService),this._charsetService=this._instantiationService.createInstance(bp),this._instantiationService.setService(em,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Xr),this._instantiationService.setService(tl,this._oscLinkService),this._inputHandler=this._register(new Dp(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Ue.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Ue.forward(this._bufferService.onResize,this._onResize)),this._register(Ue.forward(this.coreService.onData,this._onData)),this._register(Ue.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 Ip((e,s)=>this._inputHandler.parse(e,s))),this._register(Ue.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&&!$o&&(this._logService.warn("writeSync is unreliable and will be removed soon."),$o=!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,Pl),e=Math.max(e,Il),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(Ro.bind(null,this._bufferService))),t.push(this.registerCsiHandler({final:"H"},()=>(Ro(this._bufferService),!1))),this._windowsWrappingHeuristics.value=ge(()=>{for(let e of t)e.dispose()})}}},Bp={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 Lp(t,e,s,i){let r={type:0,cancel:!1,key:void 0},n=(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=O.ESC+"OA":r.key=O.ESC+"[A":t.key==="UIKeyInputLeftArrow"?e?r.key=O.ESC+"OD":r.key=O.ESC+"[D":t.key==="UIKeyInputRightArrow"?e?r.key=O.ESC+"OC":r.key=O.ESC+"[C":t.key==="UIKeyInputDownArrow"&&(e?r.key=O.ESC+"OB":r.key=O.ESC+"[B");break;case 8:r.key=t.ctrlKey?"\b":O.DEL,t.altKey&&(r.key=O.ESC+r.key);break;case 9:if(t.shiftKey){r.key=O.ESC+"[Z";break}r.key=O.HT,r.cancel=!0;break;case 13:r.key=t.altKey?O.ESC+O.CR:O.CR,r.cancel=!0;break;case 27:r.key=O.ESC,t.altKey&&(r.key=O.ESC+O.ESC),r.cancel=!0;break;case 37:if(t.metaKey)break;n?r.key=O.ESC+"[1;"+(n+1)+"D":e?r.key=O.ESC+"OD":r.key=O.ESC+"[D";break;case 39:if(t.metaKey)break;n?r.key=O.ESC+"[1;"+(n+1)+"C":e?r.key=O.ESC+"OC":r.key=O.ESC+"[C";break;case 38:if(t.metaKey)break;n?r.key=O.ESC+"[1;"+(n+1)+"A":e?r.key=O.ESC+"OA":r.key=O.ESC+"[A";break;case 40:if(t.metaKey)break;n?r.key=O.ESC+"[1;"+(n+1)+"B":e?r.key=O.ESC+"OB":r.key=O.ESC+"[B";break;case 45:!t.shiftKey&&!t.ctrlKey&&(r.key=O.ESC+"[2~");break;case 46:n?r.key=O.ESC+"[3;"+(n+1)+"~":r.key=O.ESC+"[3~";break;case 36:n?r.key=O.ESC+"[1;"+(n+1)+"H":e?r.key=O.ESC+"OH":r.key=O.ESC+"[H";break;case 35:n?r.key=O.ESC+"[1;"+(n+1)+"F":e?r.key=O.ESC+"OF":r.key=O.ESC+"[F";break;case 33:t.shiftKey?r.type=2:t.ctrlKey?r.key=O.ESC+"[5;"+(n+1)+"~":r.key=O.ESC+"[5~";break;case 34:t.shiftKey?r.type=3:t.ctrlKey?r.key=O.ESC+"[6;"+(n+1)+"~":r.key=O.ESC+"[6~";break;case 112:n?r.key=O.ESC+"[1;"+(n+1)+"P":r.key=O.ESC+"OP";break;case 113:n?r.key=O.ESC+"[1;"+(n+1)+"Q":r.key=O.ESC+"OQ";break;case 114:n?r.key=O.ESC+"[1;"+(n+1)+"R":r.key=O.ESC+"OR";break;case 115:n?r.key=O.ESC+"[1;"+(n+1)+"S":r.key=O.ESC+"OS";break;case 116:n?r.key=O.ESC+"[15;"+(n+1)+"~":r.key=O.ESC+"[15~";break;case 117:n?r.key=O.ESC+"[17;"+(n+1)+"~":r.key=O.ESC+"[17~";break;case 118:n?r.key=O.ESC+"[18;"+(n+1)+"~":r.key=O.ESC+"[18~";break;case 119:n?r.key=O.ESC+"[19;"+(n+1)+"~":r.key=O.ESC+"[19~";break;case 120:n?r.key=O.ESC+"[20;"+(n+1)+"~":r.key=O.ESC+"[20~";break;case 121:n?r.key=O.ESC+"[21;"+(n+1)+"~":r.key=O.ESC+"[21~";break;case 122:n?r.key=O.ESC+"[23;"+(n+1)+"~":r.key=O.ESC+"[23~";break;case 123:n?r.key=O.ESC+"[24;"+(n+1)+"~":r.key=O.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=O.NUL:t.keyCode>=51&&t.keyCode<=55?r.key=String.fromCharCode(t.keyCode-51+27):t.keyCode===56?r.key=O.DEL:t.keyCode===219?r.key=O.ESC:t.keyCode===220?r.key=O.FS:t.keyCode===221&&(r.key=O.GS);else if((!s||i)&&t.altKey&&!t.metaKey){let a=Bp[t.keyCode]?.[t.shiftKey?1:0];if(a)r.key=O.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=O.ESC+h}else if(t.keyCode===32)r.key=O.ESC+(t.ctrlKey?O.NUL:" ");else if(t.key==="Dead"&&t.code.startsWith("Key")){let l=t.code.slice(3,4);t.shiftKey||(l=l.toLowerCase()),r.key=O.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=O.US),t.key==="@"&&(r.key=O.NUL));break}return r}var ke=0,Op=class{constructor(t){this._getKey=t,this._array=[],this._insertedValues=[],this._flushInsertedTask=new yi,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new yi,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,n)=>this._getKey(r)-this._getKey(n)),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||(ke=this._search(e),ke===-1)||this._getKey(this._array[ke])!==e)return!1;do if(this._array[ke]===t)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(ke),!0;while(++ke<this._array.length&&this._getKey(this._array[ke])===e);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let t=this._deletedIndices.sort((r,n)=>r-n),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&&(ke=this._search(t),!(ke<0||ke>=this._array.length)&&this._getKey(this._array[ke])===t))do yield this._array[ke];while(++ke<this._array.length&&this._getKey(this._array[ke])===t)}forEachByKey(t,e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ke=this._search(t),!(ke<0||ke>=this._array.length)&&this._getKey(this._array[ke])===t))do e(this._array[ke]);while(++ke<this._array.length&&this._getKey(this._array[ke])===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}},nr=0,zo=0,$p=class extends le{constructor(){super(),this._decorations=new Op(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(ge(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(t){if(t.marker.isDisposed)return;let e=new zp(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 n of this._decorations.getKeyIterator(e))i=n.options.x??0,r=i+(n.options.width??1),t>=i&&t<r&&(!s||(n.options.layer??"bottom")===s)&&(yield n)}forEachDecorationAtCell(t,e,s,i){this._decorations.forEachByKey(e,r=>{nr=r.options.x??0,zo=nr+(r.options.width??1),t>=nr&&t<zo&&(!s||(r.options.layer??"bottom")===s)&&i(r)})}},zp=class extends Dt{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=be.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=be.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},Fp=1e3,Hp=class{constructor(t,e=Fp){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,n=this._debounceThresholdMS-r;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},n)}}_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)}},Fo=20,wi=class extends le{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 n=0;n<this._terminal.rows;n++)this._rowElements[n]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[n]);if(this._topBoundaryFocusListener=n=>this._handleBoundaryFocus(n,0),this._bottomBoundaryFocusListener=n=>this._handleBoundaryFocus(n,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 Hp(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(n=>this._handleResize(n.rows))),this._register(this._terminal.onRender(n=>this._refreshRows(n.start,n.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(n=>this._handleChar(n))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
182
182
|
`))),this._register(this._terminal.onA11yTab(n=>this._handleTab(n))),this._register(this._terminal.onKey(n=>this._handleKey(n.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(ge(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(t){for(let e=0;e<t;e++)this._handleChar(" ")}_handleChar(t){this._liveRegionLineCount<Fo+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==t&&(this._charsToAnnounce+=t):this._charsToAnnounce+=t,t===`
|
|
183
183
|
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Fo+1&&(this._liveRegion.textContent+=pr.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 n=s.lines.get(s.ydisp+r),a=[],l=n?.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"),n=e===0?"1":`${this._terminal.buffer.lines.length}`;if(r===n||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}},n=r(e),a=r(s);if(!(!n||!a)){if(n.row>a.row||n.row===a.row&&n.column>=a.column)throw new Error("invalid range");this._terminal.select(n.column,n.row,(a.row-n.row)*this._terminal.cols-n.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})`}};wi=Ce([te(1,mn),te(2,wt),te(3,Ct)],wi);var Jr=class extends le{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(ge(()=>{Ut(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,n=>{if(this._isMouseOut)return;let a=n?.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 n=0;n<r.length;n++){let a=r[n],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(n--,1);break}s.add(c)}}}}_checkLinkProviderResult(t,e,s){if(!this._activeProviderReplies)return s;let i=this._activeProviderReplies.get(t),r=!1;for(let n=0;n<t;n++)(!this._activeProviderReplies.has(n)||this._activeProviderReplies.get(n))&&(r=!0);if(!r&&i){let n=i.find(a=>this._linkAtPosition(a.link,e));n&&(s=!0,this._handleNewLink(n))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let n=0;n<this._activeProviderReplies.size;n++){let a=this._activeProviderReplies.get(n)?.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&&Wp(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,Ut(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 n=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);n&&this._askForLink(n,!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}}};Jr=Ce([te(1,_n),te(2,Ct),te(3,Ye),te(4,il)],Jr);function Wp(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 Up=class extends Ap{constructor(t={}){super(t),this._linkifier=this._register(new cs),this.browser=yl,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new cs),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($p),this._instantiationService.setService(Vs,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(P_),this._instantiationService.setService(il,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(vr)),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(Ue.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Ue.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Ue.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Ue.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(ge(()=>{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(`${O.ESC}]${i};${Tp(r)}${bl.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(n=>n.ansi[e.index]=Te.toColor(...e.color));else{let n=s;this._themeService.modifyColors(a=>a[n]=Te.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(wi,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(t){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(O.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(O.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),n=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=n+"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()&&Gf(e,this._selectionService)}));let t=e=>Yf(e,this.textarea,this.coreService,this.optionsService);this._register(oe(this.textarea,"paste",t)),this._register(oe(this.element,"paste",t)),wl?this._register(oe(this.element,"mousedown",e=>{e.button===2&&Xn(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(oe(this.element,"contextmenu",e=>{Xn(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),wn&&this._register(oe(this.element,"auxclick",e=>{e.button===1&&Ga(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",_r.get()),Nl||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(D_,this.textarea,t.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(wt,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($r,this._document,this._helperContainer),this._instantiationService.setService(Ai,this._charSizeService),this._themeService=this._instantiationService.createInstance(Wr),this._instantiationService.setService(ps,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(bi),this._instantiationService.setService(sl,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Fr,this.rows,this.screenElement)),this._instantiationService.setService(Ct,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(Br,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(zr),this._instantiationService.setService(_n,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(Jr,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(Ir,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(Hr,this.element,this.screenElement,i)),this._instantiationService.setService(im,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(Ue.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(Ar,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(wi,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",r=>this._handleScreenReaderModeOptionChange(r))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(xi,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",r=>{!this._overviewRulerRenderer&&r&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(xi,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Or,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let t=this,e=this.element;function s(n){let a=t._mouseService.getMouseReportCoords(n,t.screenElement);if(!a)return!1;let l,h;switch(n.overrideType||n.type){case"mousemove":h=32,n.buttons===void 0?(l=3,n.button!==void 0&&(l=n.button<3?n.button:3)):l=n.buttons&1?0:n.buttons&4?1:n.buttons&2?2:3;break;case"mouseup":h=0,l=n.button<3?n.button:3;break;case"mousedown":h=1,l=n.button<3?n.button:3;break;case"wheel":if(t._customWheelEventHandler&&t._customWheelEventHandler(n)===!1)return!1;let c=n.deltaY;if(c===0||t.coreMouseService.consumeWheelEvent(n,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:n.ctrlKey,alt:n.altKey,shift:n.shiftKey})}let i={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:n=>(s(n),n.buttons||(this._document.removeEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.removeEventListener("mousemove",i.mousedrag)),this.cancel(n)),wheel:n=>(s(n),this.cancel(n,!0)),mousedrag:n=>{n.buttons&&s(n)},mousemove:n=>{n.buttons||s(n)}};this._register(this.coreMouseService.onProtocolChange(n=>{n?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(n)),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()),n&8?i.mousemove||(e.addEventListener("mousemove",r.mousemove),i.mousemove=r.mousemove):(e.removeEventListener("mousemove",i.mousemove),i.mousemove=null),n&16?i.wheel||(e.addEventListener("wheel",r.wheel,{passive:!1}),i.wheel=r.wheel):(e.removeEventListener("wheel",i.wheel),i.wheel=null),n&2?i.mouseup||(i.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",i.mouseup),i.mouseup=null),n&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",n=>{if(n.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(n)))return s(n),i.mouseup&&this._document.addEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.addEventListener("mousemove",i.mousedrag),this.cancel(n)})),this._register(oe(e,"wheel",n=>{if(!i.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(n)===!1)return!1;if(!this.buffer.hasScrollback){if(n.deltaY===0)return!1;if(t.coreMouseService.consumeWheelEvent(n,t._renderService?.dimensions?.device?.cell?.height,t._coreBrowserService?.dpr)===0)return this.cancel(n,!0);let a=O.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(n.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(a,!0),this.cancel(n,!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){qa(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=Lp(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===O.ETX||s.key===O.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)&&(Kp(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(Ee));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(O.ESC+"[I"):this.coreService.triggerDataEvent(O.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(`${O.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(`${O.ESC}[6;${r};${i}t`);break}}cancel(t,e){if(!(!this.options.cancelEvents&&!e))return t.preventDefault(),t.stopPropagation(),!1}};function Kp(t){return t.keyCode===16||t.keyCode===17||t.keyCode===18}var Vp=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)}},qp=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 ot)}translateToString(t,e,s){return this._line.translateToString(t,e,s)}},Ho=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 qp(e)}getNullCell(){return new ot}},Gp=class extends le{constructor(t){super(),this._core=t,this._onBufferChange=this._register(new q),this.onBufferChange=this._onBufferChange.event,this._normal=new Ho(this._core.buffers.normal,"normal"),this._alternate=new Ho(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)}},Yp=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)}},Xp=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}},Jp=["cols","rows"],dt=0,Zp=class extends le{constructor(t){super(),this._core=this._register(new Up(t)),this._addonManager=this._register(new Vp),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(Jp.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 Yp(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new Xp(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 Gp(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 _r.get()},set promptLabel(t){_r.set(t)},get tooMuchOutput(){return pr.get()},set tooMuchOutput(t){pr.set(t)}}}_verifyIntegers(...t){for(dt of t)if(dt===1/0||isNaN(dt)||dt%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(dt of t)if(dt&&(dt===1/0||isNaN(dt)||dt%1!==0||dt<0))throw new Error("This API only accepts positive integers")}};var Qp=2,eg=1,tg=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"))),n=window.getComputedStyle(this._terminal.element),a={top:parseInt(n.getPropertyValue("padding-top")),bottom:parseInt(n.getPropertyValue("padding-bottom")),right:parseInt(n.getPropertyValue("padding-right")),left:parseInt(n.getPropertyValue("padding-left"))},l=a.top+a.bottom,h=a.right+a.left,c=i-l,d=r-h-e;return{cols:Math.max(Qp,Math.floor(d/t.css.cell.width)),rows:Math.max(eg,Math.floor(c/t.css.cell.height))}}};function Bl({source:t,onReady:e,onSelectionChange:s,className:i}){const r=B.useRef(null),n=B.useRef(null),a=B.useRef(s);a.current=s;const l=_s(),h=B.useRef(t);return h.current=t,kf((c,d)=>{c===h.current&&n.current?.write(d)}),B.useEffect(()=>{const c=r.current;if(!c)return;const d=getComputedStyle(document.documentElement),u=x=>d.getPropertyValue(x).trim()||void 0,f=new Zp({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 tg;f.loadAddon(m),f.open(c),m.fit();const _=l.getBuffer(t);_&&f.write(_),n.current=f,e?.(f);const p=f.onSelectionChange(()=>{const x=!!f.getSelection();a.current?.(x,()=>f.getSelection())}),v=new ResizeObserver(()=>{m.fit()});return v.observe(c),()=>{p.dispose(),v.disconnect(),n.current=null,f.dispose()}},[]),o.jsx("div",{className:ie("h-full bg-sidebar p-3",i),children:o.jsx("div",{ref:r,className:"h-full"})})}function Ns(t){const e=$.c(24);if(t.kind==="starting-now"){let c;return e[0]!==t.claimPhase||e[1]!==t.progress?(c=o.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:o.jsx(Lf,{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=o.jsx(sg,{kind:t.kind}),i=o.jsx(ig,{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=o.jsx(rg,{...t}),e[6]=t,e[7]=r):r=e[7];let n;e[8]!==t.kind||e[9]!==t.progress?(n=t.kind==="errored"&&o.jsx(ng,{progress:t.progress}),e[8]=t.kind,e[9]=t.progress,e[10]=n):n=e[10];let a;e[11]!==t.drawerOpen||e[12]!==t.kind||e[13]!==t.logSource?(a=t.kind==="errored"&&!t.drawerOpen&&o.jsx(og,{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=o.jsx(ag,{...t}),e[15]=t,e[16]=l):l=e[16];let h;return e[17]!==s||e[18]!==i||e[19]!==r||e[20]!==n||e[21]!==a||e[22]!==l?(h=o.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:o.jsxs("div",{className:"flex w-full max-w-md flex-col items-center gap-4 text-center",children:[s,i,r,n,a,l]})}),e[17]=s,e[18]=i,e[19]=r,e[20]=n,e[21]=a,e[22]=l,e[23]=h):h=e[23],h}function sg(t){const e=$.c(4),{kind:s}=t;switch(s){case"never-started":{let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(oa,{className:ie("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=o.jsx(lr,{className:ie("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=o.jsx(Wc,{className:ie("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=o.jsx(lr,{className:ie("size-12","text-amber-500")}),e[3]=i):i=e[3],i}}}function ig(t){const e=$.c(4),{kind:s}=t;let i;e[0]!==s?(i=Rf(s),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=o.jsx("h3",{className:"text-lg font-medium",children:i}),e[2]=i,e[3]=r):r=e[3],r}function rg(t){const e=$.c(5);switch(t.kind){case"never-started":{let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=o.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=o.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=o.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=o.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 ng(t){const e=$.c(21),{progress:s}=t;let i;e[0]!==s?(i=Js(s,"provision"),e[0]=s,e[1]=i):i=e[1];let r;e[2]!==i?(r=o.jsx(ni,{label:"provision",status:i}),e[2]=i,e[3]=r):r=e[3];let n;e[4]!==s?(n=Js(s,"cloning"),e[4]=s,e[5]=n):n=e[5];let a;e[6]!==n?(a=o.jsx(ni,{label:"cloning",status:n}),e[6]=n,e[7]=a):a=e[7];let l;e[8]!==s?(l=Js(s,"install"),e[8]=s,e[9]=l):l=e[9];let h;e[10]!==l?(h=o.jsx(ni,{label:"install",status:l}),e[10]=l,e[11]=h):h=e[11];let c;e[12]!==s?(c=Js(s,"dev"),e[12]=s,e[13]=c):c=e[13];let d;e[14]!==c?(d=o.jsx(ni,{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=o.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:o.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 ni(t){const e=$.c(12),{label:s,status:i}=t;let r;e[0]!==i?(r=Tf(i),e[0]=i,e[1]=r):r=e[1];const n=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=ie("flex items-center gap-1.5",a),e[2]=a,e[3]=l):l=e[3];let h;e[4]!==n?(h=o.jsx("span",{"aria-hidden":!0,children:n}),e[4]=n,e[5]=h):h=e[5];let c;e[6]!==s?(c=o.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=o.jsxs("span",{className:l,children:[h,c]}),e[8]=l,e[9]=h,e[10]=c,e[11]=d):d=e[11],d}function og(t){const e=$.c(2),{source:s}=t;let i;return e[0]!==s?(i=o.jsx("div",{className:"flex w-[min(78%,560px)] flex-col items-stretch gap-1.5",children:o.jsx("div",{className:"h-32 overflow-hidden rounded-md [&_.xterm-viewport::-webkit-scrollbar]:hidden [&_.xterm-viewport]:!overflow-hidden",children:o.jsx(Bl,{source:s,className:"h-full"})})}),e[0]=s,e[1]=i):i=e[1],i}function ag(t){const e=$.c(12);switch(t.kind){case"never-started":{let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsx(Wt,{className:"size-4"}),e[0]=s):s=e[0];let i;return e[1]!==t.onStart?(i=o.jsxs(re,{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=o.jsx(_i,{className:"size-4"}),e[3]=s):s=e[3];let i;return e[4]!==t.onRetry?(i=o.jsxs(re,{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=o.jsx(Wt,{className:"size-4"}),e[6]=s):s=e[6];let i;return e[7]!==t.onResume?(i=o.jsxs(re,{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=o.jsx(aa,{className:"size-4"}),e[9]=s):s=e[9];let i;return e[10]!==t.onOpenTerminal?(i=o.jsxs(re,{onClick:t.onOpenTerminal,className:"mt-2",children:[s," Open terminal"]}),e[10]=t.onOpenTerminal,e[11]=i):i=e[11],i}}}const Ft="setup";function lg(t){const e=$.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===Ft?t.onToggle():t.onSelectTab(Ft)},e[5]=t,e[6]=r):r=e[6];const n=r,a=t.active===Ft;let l;e[7]!==n||e[8]!==t.open||e[9]!==a?(l=o.jsx(cg,{active:a,open:t.open,onClick:n}),e[7]=n,e[8]=t.open,e[9]=a,e[10]=l):l=e[10];let h;e[11]!==t?(h=t.scriptTabs.map(m=>o.jsx(dg,{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=o.jsx(ug,{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=o.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?o.jsx(fg,{isRunning:t.scriptIsRunning,isKilling:t.scriptIsKilling,onRun:t.onRunActiveScript,onStop:t.onStopActiveScript}):o.jsx(hg,{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=o.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 cg(t){const e=$.c(8),{active:s,open:i,onClick:r}=t,n=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=ie("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=o.jsx(aa,{className:"size-3.5"}),e[2]=c):c=e[2];let d;return e[3]!==r||e[4]!==n||e[5]!==a||e[6]!==h?(d=o.jsxs("button",{type:"button","aria-pressed":n,"aria-expanded":a,onClick:r,className:h,children:[c,"sandbox"]}),e[3]=r,e[4]=n,e[5]=a,e[6]=h,e[7]=d):d=e[7],d}function hg(t){const e=$.c(24),{status:s,onStart:i,onStop:r,onRestart:n,onResume:a,onRetry:l}=t;if(s==="idle"&&i){let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=o.jsx(Wt,{className:"size-3.5"}),e[0]=h):h=e[0];let c;return e[1]!==i?(c=o.jsxs(re,{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=o.jsx(Wt,{className:"size-3.5"}),e[3]=h):h=e[3];let c;return e[4]!==a?(c=o.jsxs(re,{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=o.jsx(_i,{className:"size-3.5"}),e[6]=h):h=e[6];let c;return e[7]!==l?(c=o.jsxs(re,{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"&&!!n,c=h?"rounded-r-none border-r-0":void 0;let d;e[9]!==c?(d=ie(c),e[9]=c,e[10]=d):d=e[10];let u;e[11]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsx(la,{className:"size-3.5"}),e[11]=u):u=e[11];let f;e[12]!==r||e[13]!==d?(f=o.jsx(Re,{asChild:!0,children:o.jsxs(re,{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=o.jsx(De,{children:"Stop sandbox"}),e[15]=m):m=e[15];let _;e[16]!==f?(_=o.jsxs(Me,{children:[f,m]}),e[16]=f,e[17]=_):_=e[17];let p;e[18]!==n||e[19]!==h?(p=h&&o.jsxs(Ei,{children:[o.jsx(Ti,{asChild:!0,children:o.jsx(re,{variant:"outline",size:"sm",className:"rounded-l-none px-1",children:o.jsx(un,{className:"size-3"})})}),o.jsx(Ri,{align:"end",children:o.jsxs($t,{onClick:n,children:[o.jsx(_i,{className:"size-3.5"})," Restart"]})})]}),e[18]=n,e[19]=h,e[20]=p):p=e[20];let v;return e[21]!==_||e[22]!==p?(v=o.jsxs("div",{className:"flex items-center",children:[_,p]}),e[21]=_,e[22]=p,e[23]=v):v=e[23],v}return null}function dg(t){const e=$.c(16),{active:s,onClick:i,onClose:r,children:n}=t,a=s?"border-border bg-background shadow-sm":"border-transparent hover:bg-background/50";let l;e[0]!==a?(l=ie("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=ie("flex h-full items-center",h,c),e[2]=h,e[3]=c,e[4]=d):d=e[4];let u;e[5]!==n||e[6]!==i||e[7]!==d?(u=o.jsx("button",{type:"button",onClick:i,className:d,children:n}),e[5]=n,e[6]=i,e[7]=d,e[8]=u):u=e[8];let f;e[9]!==n||e[10]!==r?(f=r&&o.jsx("button",{type:"button","aria-label":`Close ${n}`,onClick:r,className:"pr-1.5 text-muted-foreground hover:text-foreground",children:o.jsx(Oh,{className:"size-3"})}),e[9]=n,e[10]=r,e[11]=f):f=e[11];let m;return e[12]!==l||e[13]!==u||e[14]!==f?(m=o.jsxs("div",{className:l,children:[u,f]}),e[12]=l,e[13]=u,e[14]=f,e[15]=m):m=e[15],m}function ug(t){const e=$.c(10),{scripts:s,onRun:i}=t,[r,n]=B.useState(!1);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=o.jsxs(Me,{children:[o.jsx(Re,{asChild:!0,children:o.jsx(ds,{asChild:!0,children:o.jsx(re,{variant:"ghost",size:"sm","aria-label":"Run script",children:o.jsx(ls,{className:"size-3.5"})})})}),o.jsx(De,{children:"Run script"})]}),e[0]=a):a=e[0];let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=o.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?o.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:"No scripts found"}):s.map(u=>o.jsxs("button",{type:"button",onClick:()=>{n(!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=o.jsxs(us,{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=o.jsxs(fs,{open:r,onOpenChange:n,children:[a,c]}),e[7]=r,e[8]=c,e[9]=d):d=e[9],d}function fg(t){const e=$.c(13),{isRunning:s,isKilling:i,onRun:r,onStop:n}=t;if(i){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsxs(re,{variant:"outline",size:"sm",disabled:!0,children:[o.jsx(He,{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=o.jsx(Wt,{className:"size-3.5"}),e[1]=d):d=e[1];let u;e[2]!==r?(u=o.jsx(Re,{asChild:!0,children:o.jsxs(re,{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=o.jsx(De,{children:"Start process"}),e[4]=f):f=e[4];let m;return e[5]!==u?(m=o.jsxs(Me,{children:[u,f]}),e[5]=u,e[6]=m):m=e[6],m}let a;e[7]===Symbol.for("react.memo_cache_sentinel")?(a=o.jsx(la,{className:"size-3.5"}),e[7]=a):a=e[7];let l;e[8]!==n?(l=o.jsx(Re,{asChild:!0,children:o.jsxs(re,{variant:"outline",size:"sm",onClick:n,children:[a," Stop"]})}),e[8]=n,e[9]=l):l=e[9];let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=o.jsx(De,{children:"Stop process"}),e[10]=h):h=e[10];let c;return e[11]!==l?(c=o.jsxs(Me,{children:[l,h]}),e[11]=l,e[12]=c):c=e[12],c}const mg=["dev","start"];function _g(t){const e=_s(),[s,i]=B.useState(Ft),[r,n]=B.useState([]),[a,l]=B.useState(new Set),h=B.useRef(!1);if(!h.current&&e.scripts.length>0){const g=mg.find(w=>e.scripts.includes(w));g&&(h.current=!0,n(w=>w.includes(g)?w:[...w,g]),i(g))}if(a.size>0){let g=!1;const w=new Set(a);for(const k of a)e.activeProcesses.includes(k)||(w.delete(k),g=!0);g&&l(w)}const c=()=>t.onOpenChange(!t.open),d=g=>{i(g),t.open||t.onOpenChange(!0)},u=g=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(`/api/${encodeURIComponent(t.orgSlug)}/vm/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/exec/${encodeURIComponent(g)}`,{method:"POST"}),f=g=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(`/api/${encodeURIComponent(t.orgSlug)}/vm/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/exec/${encodeURIComponent(g)}/kill`,{method:"POST"}),m=async g=>{n(w=>w.includes(g)?w:[...w,g]),i(g),t.onOpenChange(!0);try{const w=await u(g);if(w===null)return;if(!w.ok)throw new Error(`Exec failed: ${w.statusText}`)}catch{me.error("Failed to run "+g)}},_=async g=>{await f(g),n(w=>w.filter(k=>k!==g)),s===g&&i(Ft)},p=async()=>{const g=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{me.error((g?"Failed to restart ":"Failed to run ")+s)}},v=async()=>{if(!a.has(s)){l(g=>new Set(g).add(s));try{const g=await f(s);if(g===null){l(w=>{const k=new Set(w);return k.delete(s),k});return}if(!g.ok)throw new Error(`Kill failed: ${g.statusText}`)}catch{l(g=>{const w=new Set(g);return w.delete(s),w}),me.error("Failed to stop "+s)}}},x=s!==Ft&&r.includes(s),b=x&&e.activeProcesses.includes(s),S=x&&a.has(s);return o.jsxs("div",{className:"flex shrink-0 flex-col",style:{height:t.open?"50%":"auto"},children:[o.jsx(lg,{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:x,scriptIsRunning:b,scriptIsKilling:S,onRunActiveScript:p,onStopActiveScript:v}),t.open&&o.jsx("div",{className:"flex-1 overflow-hidden",children:o.jsx(pg,{vmId:t.vmId,active:s,hasData:e.hasData(s),onRunActive:p})})]})}function pg(t){const e=$.c(10),{vmId:s,active:i,hasData:r,onRunActive:n}=t;if(!s)return null;if(i===Ft||r){let d;return e[0]!==i?(d=o.jsx(Bl,{source:i,className:"h-full"},i),e[0]=i,e[1]=d):d=e[1],d}let a;e[2]!==i?(a=o.jsxs("p",{children:['Script "',o.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=o.jsx(Wt,{className:"size-3.5"}),e[4]=l):l=e[4];let h;e[5]!==n?(h=o.jsxs("button",{type:"button",onClick:n,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]=n,e[6]=h):h=e[6];let c;return e[7]!==a||e[8]!==h?(c=o.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 Ll=t=>`preview-drawer:${t}`;function gg(t){try{const e=localStorage.getItem(Ll(t));return e?!!JSON.parse(e).open:!1}catch{return!1}}function vg(t,e){try{localStorage.setItem(Ll(t),JSON.stringify({open:e}))}catch{}}const xg=B.lazy(()=>Qo(()=>import("./sections-editor-CtUZTN7D.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])).then(t=>({default:t.SectionsEditor}))),bg=500;function Sg(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 yg=[{value:"preview",icon:o.jsx(oa,{size:14}),tooltip:"Interactive"},{value:"visual",icon:o.jsx(ha,{size:14}),tooltip:"Visual Editor"}];function wg(){const t=zl(),{data:e}=Zr.useSession(),{taskId:s,currentBranch:i,setCurrentTaskBranch:r}=Pt(),[n,a]=B.useState("preview"),[l,h]=B.useState(null),c=B.useRef(null),[d,u]=B.useState(!1),f=B.useRef(null),[m,_]=B.useState(!1),[p,v]=B.useState(""),x=B.useRef(null),[b,S]=B.useState("/"),g=e?.user?.id,w=t?.entity?.metadata,k=g&&i?w?.vmMap?.[g]?.[i]:void 0,C=k?.previewUrl??null,N=t?.entity?.id??null,{org:T}=ve(),L=N&&i?{orgSlug:T.slug,virtualMcpId:N,branch:i}:null,{data:M}=lf(L),D=M?df(M).sort((Z,_e)=>Z.name.localeCompare(_e.name)):[],y=_s();Nf(()=>{const Z=c.current;Z&&(Z.src=Z.src)});const R=y.lifecycle.phase,E=B.useRef({url:"",value:!1});C&&E.current.url!==C&&(E.current={url:C,value:!1}),y.lifecycle.phase==="running"&&(E.current.value=y.lifecycle.htmlSupport);const j=E.current.value,I=R==="running"?"online":R==="crashed"?"offline":"booting",P=y.suspended,z=y.status.state==="paused",U=Ve({connectionId:Gt,orgId:t?.entity?.organization_id??"",orgSlug:T.slug}),W=Aa(U),H=W.error?.message??null,G=Ed(N??void 0,i??void 0),K=B.useRef(null),se=B.useRef(null),Y=y.phase,J=Ef({claimPhase:Y,lifecycle:y.lifecycle}),ee=!!N&&!!i&&ai.isStopped(N,i),A=jf({previewUrl:C,status:I,htmlSupport:j,suspended:P,appPaused:z,vmStartPending:G,lastStartError:H,claimPhase:Y,notFound:y.notFound,userStopped:ee}),X=Z=>{if(!N)return;const _e={virtualMcpId:N};i&&(_e.branch=i),W.mutate(_e,{onSuccess:qe=>{qe?.branch&&!i&&r(qe.branch)},onError:qe=>{console.error(`[preview] ${Z} VM_START failed`,qe)}})},Q=B.useRef(X);Q.current=X,s&&k&&K.current!==s&&(K.current=s);const F=!!s&&!!N&&!!g&&!!i&&!k&&!H&&!ee&&!W.isPending&&K.current!==s;B.useEffect(()=>{!F||!s||(K.current=s,Q.current("auto-start"))},[F,s,ee]);const V=y.notFound?k?.vmId??null:null;B.useEffect(()=>{!V||!N||H||W.isPending||se.current!==V&&(i&&ai.isStopped(N,i)||(se.current=V,Q.current("self-heal")))},[V,N,H,W.isPending,i]);const ne=()=>{K.current=null,se.current=null,W.reset(),Q.current("auto-start")},he=hs(),ce=N??"__no-vmcp__",[de,fe]=B.useState(null),Be=B.useRef(null);Be.current!==ce&&(Be.current=ce,fe(gg(ce)));const Ne=A.kind==="never-started"?!1:de??!1,je=Z=>{fe(Z),vg(ce,Z)},Je=()=>je(!0),Le=async()=>{if(!N)return;const Z=i;if(Z){ai.mark(N,Z);try{await U.callTool({name:"VM_DELETE",arguments:{virtualMcpId:N,branch:Z}})}catch{}Xo(he)}},vs=async()=>{await Le(),Q.current("auto-start")};B.useEffect(()=>{if(!C)return;let Z;try{Z=new URL(C,window.location.href).origin}catch{return}const _e=qe=>{if(qe.origin!==Z||qe.data?.type!=="visual-editor::element-clicked")return;const lt=uf.safeParse(qe.data.payload);lt.success&&h(lt.data)};return window.addEventListener("message",_e),()=>window.removeEventListener("message",_e)},[C]),B.useEffect(()=>{if(!m)return;const Z=_e=>{x.current?.contains(_e.target)||(_(!1),v(""))};return document.addEventListener("pointerdown",Z),()=>document.removeEventListener("pointerdown",Z)},[m]),B.useEffect(()=>{if(!d)return;const Z=qe=>{const lt=qe.target;lt&<!==c.current&&(f.current=lt)},_e=()=>{requestAnimationFrame(()=>{const qe=document.activeElement;(qe===document.body||qe===c.current)&&f.current&&f.current.focus()})};return document.addEventListener("focusin",Z),document.addEventListener("blur",_e,!0),()=>{document.removeEventListener("focusin",Z),document.removeEventListener("blur",_e,!0)}},[d]);const Cn=()=>{const Z=c.current?.contentWindow;Z&&Z.postMessage({type:"visual-editor::activate",script:ff},"*")},Fl=()=>{const Z=c.current?.contentWindow;Z&&Z.postMessage({type:"visual-editor::deactivate"},"*")},Hl=Z=>{a(Z),h(null),Z==="visual"?Cn():Fl()},Wl=()=>{if(!c.current)return;const Z=c.current;Z.src=Z.src},Ul=()=>{if(!c.current||!C)return;const Z=C.includes("?")?"&":"?";c.current.src=`${C}${Z}_r=${Date.now()}`},Kl=()=>{const Z=c.current?.contentWindow?.location?.href??C;Z&&navigator.clipboard.writeText(Z)},Vl=(()=>{if(!C)return"No server running";try{const Z=new URL(C),_e=b==="/"?"":b;return`${Z.host}${_e}`}catch{return C}})();return o.jsxs("div",{className:"flex flex-col w-full h-full",children:[A.kind==="iframe"&&o.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-4 border-b border-border/60 px-3 md:px-4",children:[o.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[j&&o.jsx(Lh,{value:n,onValueChange:Hl,options:yg,size:"sm",className:"shrink-0 bg-foreground/4.5"}),D.length>0&&o.jsxs(Me,{children:[o.jsx(Re,{asChild:!0,children:o.jsx(re,{variant:d?"secondary":"ghost",size:"icon",onClick:()=>u(Z=>!Z),children:o.jsx(Uc,{size:14})})}),o.jsx(De,{side:"bottom",children:"Sections Editor"})]})]}),o.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-0.5",children:[o.jsxs(Me,{children:[o.jsx(Re,{asChild:!0,children:o.jsx(re,{variant:"ghost",size:"icon",onClick:()=>c.current?.contentWindow?.history.back(),children:o.jsx(Ma,{size:14})})}),o.jsx(De,{side:"bottom",children:"Back"})]}),o.jsxs(Me,{children:[o.jsx(Re,{asChild:!0,children:o.jsx(re,{variant:"ghost",size:"icon",onClick:()=>c.current?.contentWindow?.history.forward(),children:o.jsx(bc,{size:14})})}),o.jsx(De,{side:"bottom",children:"Forward"})]}),o.jsxs(Me,{children:[o.jsx(Re,{asChild:!0,children:o.jsx(re,{variant:"ghost",size:"icon",onClick:Wl,children:o.jsx(_i,{size:14})})}),o.jsx(De,{side:"bottom",children:"Refresh"})]}),o.jsxs("div",{ref:x,className:"relative min-w-0 flex-1",children:[o.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:()=>_(Z=>!Z),children:[o.jsx("span",{className:"min-w-0 flex-1 truncate text-left text-[12px] text-foreground/88",children:Vl}),D.length>0&&o.jsx(un,{size:12,className:ie("shrink-0 text-muted-foreground transition-transform",m&&"rotate-180")})]}),m&&D.length>0&&o.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:[o.jsx("div",{className:"px-2 pt-2 pb-1",children:o.jsx("input",{type:"text",value:p,onChange:Z=>v(Z.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})}),o.jsx(dn,{className:"max-h-[60vh]",children:o.jsxs("div",{className:"p-1.5",children:[D.filter(Z=>{if(!p)return!0;const _e=p.toLowerCase();return Z.name.toLowerCase().includes(_e)||Z.path.toLowerCase().includes(_e)}).map(Z=>o.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),v(""),S(Z.path);const _e=c.current;_e&&C&&(_e.src=new URL(Z.path,C).href)},children:[o.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:Z.name}),o.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:Z.path})]},Z.key)),p&&D.every(Z=>{const _e=p.toLowerCase();return!Z.name.toLowerCase().includes(_e)&&!Z.path.toLowerCase().includes(_e)})&&o.jsxs("div",{className:"px-3 py-4 text-center text-xs text-muted-foreground",children:['No pages match "',p,'"']})]})})]})]})]}),o.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[o.jsxs(Me,{children:[o.jsx(Re,{asChild:!0,children:o.jsx(re,{variant:"ghost",size:"icon",onClick:()=>window.open(A.previewUrl,"_blank","noopener"),children:o.jsx(ms,{size:14})})}),o.jsx(De,{side:"bottom",children:"Open in new tab"})]}),o.jsxs(Ei,{children:[o.jsx(Ti,{asChild:!0,children:o.jsx(re,{variant:"ghost",size:"icon",children:o.jsx(ca,{size:14})})}),o.jsxs(Ri,{align:"end",children:[o.jsx($t,{onClick:Ul,children:"Hard Reload"}),o.jsx($t,{onClick:Kl,children:"Copy Current URL"})]})]})]})]}),o.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[d&&C&&i&&N&&o.jsx("div",{className:"w-96 shrink-0 border-r overflow-hidden",children:o.jsx(B.Suspense,{fallback:o.jsx("div",{className:"h-full flex items-center justify-center",children:o.jsx(He,{size:20,className:"animate-spin text-muted-foreground"})}),children:o.jsx(xg,{orgSlug:T.slug,virtualMcpId:N,branch:i,currentPath:b,onSaved:()=>{setTimeout(()=>{const Z=c.current;if(!Z)return;const _e=document.activeElement,qe=Z.tabIndex;Z.tabIndex=-1,Z.style.pointerEvents="none",Z.blur();try{Z.contentWindow?.location.reload()}catch{Z.src=Z.src}const lt=()=>{Z.tabIndex=qe,Z.style.pointerEvents="",_e?.focus(),Z.removeEventListener("load",lt)};Z.addEventListener("load",lt),setTimeout(lt,3e3)},bg)}})})}),o.jsxs("div",{className:"flex-1 relative overflow-hidden",children:[A.kind==="never-started"&&o.jsx("div",{className:"absolute inset-0 z-30",children:o.jsx(Ns,{kind:"never-started",onStart:()=>{je(!1),X("auto-start")}})}),A.kind==="starting-now"&&o.jsx("div",{className:"absolute inset-0 z-30",children:o.jsx(Ns,{kind:"starting-now",progress:J,claimPhase:Y})}),A.kind==="errored"&&o.jsx("div",{className:"absolute inset-0 z-40",children:o.jsx(Ns,{kind:"errored",progress:J,logSource:"setup",errorLine:A.error.split(`
|
|
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 _r.get()},set promptLabel(t){_r.set(t)},get tooMuchOutput(){return pr.get()},set tooMuchOutput(t){pr.set(t)}}}_verifyIntegers(...t){for(dt of t)if(dt===1/0||isNaN(dt)||dt%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(dt of t)if(dt&&(dt===1/0||isNaN(dt)||dt%1!==0||dt<0))throw new Error("This API only accepts positive integers")}};var Qp=2,eg=1,tg=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"))),n=window.getComputedStyle(this._terminal.element),a={top:parseInt(n.getPropertyValue("padding-top")),bottom:parseInt(n.getPropertyValue("padding-bottom")),right:parseInt(n.getPropertyValue("padding-right")),left:parseInt(n.getPropertyValue("padding-left"))},l=a.top+a.bottom,h=a.right+a.left,c=i-l,d=r-h-e;return{cols:Math.max(Qp,Math.floor(d/t.css.cell.width)),rows:Math.max(eg,Math.floor(c/t.css.cell.height))}}};function Bl({source:t,onReady:e,onSelectionChange:s,className:i}){const r=B.useRef(null),n=B.useRef(null),a=B.useRef(s);a.current=s;const l=_s(),h=B.useRef(t);return h.current=t,kf((c,d)=>{c===h.current&&n.current?.write(d)}),B.useEffect(()=>{const c=r.current;if(!c)return;const d=getComputedStyle(document.documentElement),u=x=>d.getPropertyValue(x).trim()||void 0,f=new Zp({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 tg;f.loadAddon(m),f.open(c),m.fit();const _=l.getBuffer(t);_&&f.write(_),n.current=f,e?.(f);const p=f.onSelectionChange(()=>{const x=!!f.getSelection();a.current?.(x,()=>f.getSelection())}),v=new ResizeObserver(()=>{m.fit()});return v.observe(c),()=>{p.dispose(),v.disconnect(),n.current=null,f.dispose()}},[]),o.jsx("div",{className:ie("h-full bg-sidebar p-3",i),children:o.jsx("div",{ref:r,className:"h-full"})})}function Ns(t){const e=$.c(24);if(t.kind==="starting-now"){let c;return e[0]!==t.claimPhase||e[1]!==t.progress?(c=o.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:o.jsx(Lf,{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=o.jsx(sg,{kind:t.kind}),i=o.jsx(ig,{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=o.jsx(rg,{...t}),e[6]=t,e[7]=r):r=e[7];let n;e[8]!==t.kind||e[9]!==t.progress?(n=t.kind==="errored"&&o.jsx(ng,{progress:t.progress}),e[8]=t.kind,e[9]=t.progress,e[10]=n):n=e[10];let a;e[11]!==t.drawerOpen||e[12]!==t.kind||e[13]!==t.logSource?(a=t.kind==="errored"&&!t.drawerOpen&&o.jsx(og,{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=o.jsx(ag,{...t}),e[15]=t,e[16]=l):l=e[16];let h;return e[17]!==s||e[18]!==i||e[19]!==r||e[20]!==n||e[21]!==a||e[22]!==l?(h=o.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:o.jsxs("div",{className:"flex w-full max-w-md flex-col items-center gap-4 text-center",children:[s,i,r,n,a,l]})}),e[17]=s,e[18]=i,e[19]=r,e[20]=n,e[21]=a,e[22]=l,e[23]=h):h=e[23],h}function sg(t){const e=$.c(4),{kind:s}=t;switch(s){case"never-started":{let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(oa,{className:ie("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=o.jsx(lr,{className:ie("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=o.jsx(Wc,{className:ie("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=o.jsx(lr,{className:ie("size-12","text-amber-500")}),e[3]=i):i=e[3],i}}}function ig(t){const e=$.c(4),{kind:s}=t;let i;e[0]!==s?(i=Rf(s),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=o.jsx("h3",{className:"text-lg font-medium",children:i}),e[2]=i,e[3]=r):r=e[3],r}function rg(t){const e=$.c(5);switch(t.kind){case"never-started":{let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=o.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=o.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=o.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=o.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 ng(t){const e=$.c(21),{progress:s}=t;let i;e[0]!==s?(i=Js(s,"provision"),e[0]=s,e[1]=i):i=e[1];let r;e[2]!==i?(r=o.jsx(ni,{label:"provision",status:i}),e[2]=i,e[3]=r):r=e[3];let n;e[4]!==s?(n=Js(s,"cloning"),e[4]=s,e[5]=n):n=e[5];let a;e[6]!==n?(a=o.jsx(ni,{label:"cloning",status:n}),e[6]=n,e[7]=a):a=e[7];let l;e[8]!==s?(l=Js(s,"install"),e[8]=s,e[9]=l):l=e[9];let h;e[10]!==l?(h=o.jsx(ni,{label:"install",status:l}),e[10]=l,e[11]=h):h=e[11];let c;e[12]!==s?(c=Js(s,"dev"),e[12]=s,e[13]=c):c=e[13];let d;e[14]!==c?(d=o.jsx(ni,{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=o.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:o.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 ni(t){const e=$.c(12),{label:s,status:i}=t;let r;e[0]!==i?(r=Tf(i),e[0]=i,e[1]=r):r=e[1];const n=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=ie("flex items-center gap-1.5",a),e[2]=a,e[3]=l):l=e[3];let h;e[4]!==n?(h=o.jsx("span",{"aria-hidden":!0,children:n}),e[4]=n,e[5]=h):h=e[5];let c;e[6]!==s?(c=o.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=o.jsxs("span",{className:l,children:[h,c]}),e[8]=l,e[9]=h,e[10]=c,e[11]=d):d=e[11],d}function og(t){const e=$.c(2),{source:s}=t;let i;return e[0]!==s?(i=o.jsx("div",{className:"flex w-[min(78%,560px)] flex-col items-stretch gap-1.5",children:o.jsx("div",{className:"h-32 overflow-hidden rounded-md [&_.xterm-viewport::-webkit-scrollbar]:hidden [&_.xterm-viewport]:!overflow-hidden",children:o.jsx(Bl,{source:s,className:"h-full"})})}),e[0]=s,e[1]=i):i=e[1],i}function ag(t){const e=$.c(12);switch(t.kind){case"never-started":{let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsx(Wt,{className:"size-4"}),e[0]=s):s=e[0];let i;return e[1]!==t.onStart?(i=o.jsxs(re,{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=o.jsx(_i,{className:"size-4"}),e[3]=s):s=e[3];let i;return e[4]!==t.onRetry?(i=o.jsxs(re,{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=o.jsx(Wt,{className:"size-4"}),e[6]=s):s=e[6];let i;return e[7]!==t.onResume?(i=o.jsxs(re,{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=o.jsx(aa,{className:"size-4"}),e[9]=s):s=e[9];let i;return e[10]!==t.onOpenTerminal?(i=o.jsxs(re,{onClick:t.onOpenTerminal,className:"mt-2",children:[s," Open terminal"]}),e[10]=t.onOpenTerminal,e[11]=i):i=e[11],i}}}const Ft="setup";function lg(t){const e=$.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===Ft?t.onToggle():t.onSelectTab(Ft)},e[5]=t,e[6]=r):r=e[6];const n=r,a=t.active===Ft;let l;e[7]!==n||e[8]!==t.open||e[9]!==a?(l=o.jsx(cg,{active:a,open:t.open,onClick:n}),e[7]=n,e[8]=t.open,e[9]=a,e[10]=l):l=e[10];let h;e[11]!==t?(h=t.scriptTabs.map(m=>o.jsx(dg,{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=o.jsx(ug,{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=o.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?o.jsx(fg,{isRunning:t.scriptIsRunning,isKilling:t.scriptIsKilling,onRun:t.onRunActiveScript,onStop:t.onStopActiveScript}):o.jsx(hg,{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=o.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 cg(t){const e=$.c(8),{active:s,open:i,onClick:r}=t,n=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=ie("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=o.jsx(aa,{className:"size-3.5"}),e[2]=c):c=e[2];let d;return e[3]!==r||e[4]!==n||e[5]!==a||e[6]!==h?(d=o.jsxs("button",{type:"button","aria-pressed":n,"aria-expanded":a,onClick:r,className:h,children:[c,"sandbox"]}),e[3]=r,e[4]=n,e[5]=a,e[6]=h,e[7]=d):d=e[7],d}function hg(t){const e=$.c(24),{status:s,onStart:i,onStop:r,onRestart:n,onResume:a,onRetry:l}=t;if(s==="idle"&&i){let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=o.jsx(Wt,{className:"size-3.5"}),e[0]=h):h=e[0];let c;return e[1]!==i?(c=o.jsxs(re,{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=o.jsx(Wt,{className:"size-3.5"}),e[3]=h):h=e[3];let c;return e[4]!==a?(c=o.jsxs(re,{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=o.jsx(_i,{className:"size-3.5"}),e[6]=h):h=e[6];let c;return e[7]!==l?(c=o.jsxs(re,{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"&&!!n,c=h?"rounded-r-none border-r-0":void 0;let d;e[9]!==c?(d=ie(c),e[9]=c,e[10]=d):d=e[10];let u;e[11]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsx(la,{className:"size-3.5"}),e[11]=u):u=e[11];let f;e[12]!==r||e[13]!==d?(f=o.jsx(Re,{asChild:!0,children:o.jsxs(re,{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=o.jsx(De,{children:"Stop sandbox"}),e[15]=m):m=e[15];let _;e[16]!==f?(_=o.jsxs(Me,{children:[f,m]}),e[16]=f,e[17]=_):_=e[17];let p;e[18]!==n||e[19]!==h?(p=h&&o.jsxs(Ei,{children:[o.jsx(Ti,{asChild:!0,children:o.jsx(re,{variant:"outline",size:"sm",className:"rounded-l-none px-1",children:o.jsx(un,{className:"size-3"})})}),o.jsx(Ri,{align:"end",children:o.jsxs($t,{onClick:n,children:[o.jsx(_i,{className:"size-3.5"})," Restart"]})})]}),e[18]=n,e[19]=h,e[20]=p):p=e[20];let v;return e[21]!==_||e[22]!==p?(v=o.jsxs("div",{className:"flex items-center",children:[_,p]}),e[21]=_,e[22]=p,e[23]=v):v=e[23],v}return null}function dg(t){const e=$.c(16),{active:s,onClick:i,onClose:r,children:n}=t,a=s?"border-border bg-background shadow-sm":"border-transparent hover:bg-background/50";let l;e[0]!==a?(l=ie("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=ie("flex h-full items-center",h,c),e[2]=h,e[3]=c,e[4]=d):d=e[4];let u;e[5]!==n||e[6]!==i||e[7]!==d?(u=o.jsx("button",{type:"button",onClick:i,className:d,children:n}),e[5]=n,e[6]=i,e[7]=d,e[8]=u):u=e[8];let f;e[9]!==n||e[10]!==r?(f=r&&o.jsx("button",{type:"button","aria-label":`Close ${n}`,onClick:r,className:"pr-1.5 text-muted-foreground hover:text-foreground",children:o.jsx(Oh,{className:"size-3"})}),e[9]=n,e[10]=r,e[11]=f):f=e[11];let m;return e[12]!==l||e[13]!==u||e[14]!==f?(m=o.jsxs("div",{className:l,children:[u,f]}),e[12]=l,e[13]=u,e[14]=f,e[15]=m):m=e[15],m}function ug(t){const e=$.c(10),{scripts:s,onRun:i}=t,[r,n]=B.useState(!1);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=o.jsxs(Me,{children:[o.jsx(Re,{asChild:!0,children:o.jsx(ds,{asChild:!0,children:o.jsx(re,{variant:"ghost",size:"sm","aria-label":"Run script",children:o.jsx(ls,{className:"size-3.5"})})})}),o.jsx(De,{children:"Run script"})]}),e[0]=a):a=e[0];let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=o.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?o.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:"No scripts found"}):s.map(u=>o.jsxs("button",{type:"button",onClick:()=>{n(!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=o.jsxs(us,{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=o.jsxs(fs,{open:r,onOpenChange:n,children:[a,c]}),e[7]=r,e[8]=c,e[9]=d):d=e[9],d}function fg(t){const e=$.c(13),{isRunning:s,isKilling:i,onRun:r,onStop:n}=t;if(i){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsxs(re,{variant:"outline",size:"sm",disabled:!0,children:[o.jsx(He,{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=o.jsx(Wt,{className:"size-3.5"}),e[1]=d):d=e[1];let u;e[2]!==r?(u=o.jsx(Re,{asChild:!0,children:o.jsxs(re,{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=o.jsx(De,{children:"Start process"}),e[4]=f):f=e[4];let m;return e[5]!==u?(m=o.jsxs(Me,{children:[u,f]}),e[5]=u,e[6]=m):m=e[6],m}let a;e[7]===Symbol.for("react.memo_cache_sentinel")?(a=o.jsx(la,{className:"size-3.5"}),e[7]=a):a=e[7];let l;e[8]!==n?(l=o.jsx(Re,{asChild:!0,children:o.jsxs(re,{variant:"outline",size:"sm",onClick:n,children:[a," Stop"]})}),e[8]=n,e[9]=l):l=e[9];let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=o.jsx(De,{children:"Stop process"}),e[10]=h):h=e[10];let c;return e[11]!==l?(c=o.jsxs(Me,{children:[l,h]}),e[11]=l,e[12]=c):c=e[12],c}const mg=["dev","start"];function _g(t){const e=_s(),[s,i]=B.useState(Ft),[r,n]=B.useState([]),[a,l]=B.useState(new Set),h=B.useRef(!1);if(!h.current&&e.scripts.length>0){const g=mg.find(w=>e.scripts.includes(w));g&&(h.current=!0,n(w=>w.includes(g)?w:[...w,g]),i(g))}if(a.size>0){let g=!1;const w=new Set(a);for(const k of a)e.activeProcesses.includes(k)||(w.delete(k),g=!0);g&&l(w)}const c=()=>t.onOpenChange(!t.open),d=g=>{i(g),t.open||t.onOpenChange(!0)},u=g=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(`/api/${encodeURIComponent(t.orgSlug)}/vm/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/exec/${encodeURIComponent(g)}`,{method:"POST"}),f=g=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(`/api/${encodeURIComponent(t.orgSlug)}/vm/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/exec/${encodeURIComponent(g)}/kill`,{method:"POST"}),m=async g=>{n(w=>w.includes(g)?w:[...w,g]),i(g),t.onOpenChange(!0);try{const w=await u(g);if(w===null)return;if(!w.ok)throw new Error(`Exec failed: ${w.statusText}`)}catch{me.error("Failed to run "+g)}},_=async g=>{await f(g),n(w=>w.filter(k=>k!==g)),s===g&&i(Ft)},p=async()=>{const g=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{me.error((g?"Failed to restart ":"Failed to run ")+s)}},v=async()=>{if(!a.has(s)){l(g=>new Set(g).add(s));try{const g=await f(s);if(g===null){l(w=>{const k=new Set(w);return k.delete(s),k});return}if(!g.ok)throw new Error(`Kill failed: ${g.statusText}`)}catch{l(g=>{const w=new Set(g);return w.delete(s),w}),me.error("Failed to stop "+s)}}},x=s!==Ft&&r.includes(s),b=x&&e.activeProcesses.includes(s),S=x&&a.has(s);return o.jsxs("div",{className:"flex shrink-0 flex-col",style:{height:t.open?"50%":"auto"},children:[o.jsx(lg,{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:x,scriptIsRunning:b,scriptIsKilling:S,onRunActiveScript:p,onStopActiveScript:v}),t.open&&o.jsx("div",{className:"flex-1 overflow-hidden",children:o.jsx(pg,{vmId:t.vmId,active:s,hasData:e.hasData(s),onRunActive:p})})]})}function pg(t){const e=$.c(10),{vmId:s,active:i,hasData:r,onRunActive:n}=t;if(!s)return null;if(i===Ft||r){let d;return e[0]!==i?(d=o.jsx(Bl,{source:i,className:"h-full"},i),e[0]=i,e[1]=d):d=e[1],d}let a;e[2]!==i?(a=o.jsxs("p",{children:['Script "',o.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=o.jsx(Wt,{className:"size-3.5"}),e[4]=l):l=e[4];let h;e[5]!==n?(h=o.jsxs("button",{type:"button",onClick:n,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]=n,e[6]=h):h=e[6];let c;return e[7]!==a||e[8]!==h?(c=o.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 Ll=t=>`preview-drawer:${t}`;function gg(t){try{const e=localStorage.getItem(Ll(t));return e?!!JSON.parse(e).open:!1}catch{return!1}}function vg(t,e){try{localStorage.setItem(Ll(t),JSON.stringify({open:e}))}catch{}}const xg=B.lazy(()=>Qo(()=>import("./sections-editor-BikVGLU0.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])).then(t=>({default:t.SectionsEditor}))),bg=500;function Sg(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 yg=[{value:"preview",icon:o.jsx(oa,{size:14}),tooltip:"Interactive"},{value:"visual",icon:o.jsx(ha,{size:14}),tooltip:"Visual Editor"}];function wg(){const t=zl(),{data:e}=Zr.useSession(),{taskId:s,currentBranch:i,setCurrentTaskBranch:r}=Pt(),[n,a]=B.useState("preview"),[l,h]=B.useState(null),c=B.useRef(null),[d,u]=B.useState(!1),f=B.useRef(null),[m,_]=B.useState(!1),[p,v]=B.useState(""),x=B.useRef(null),[b,S]=B.useState("/"),g=e?.user?.id,w=t?.entity?.metadata,k=g&&i?w?.vmMap?.[g]?.[i]:void 0,C=k?.previewUrl??null,N=t?.entity?.id??null,{org:T}=ve(),L=N&&i?{orgSlug:T.slug,virtualMcpId:N,branch:i}:null,{data:M}=lf(L),D=M?df(M).sort((Z,_e)=>Z.name.localeCompare(_e.name)):[],y=_s();Nf(()=>{const Z=c.current;Z&&(Z.src=Z.src)});const R=y.lifecycle.phase,E=B.useRef({url:"",value:!1});C&&E.current.url!==C&&(E.current={url:C,value:!1}),y.lifecycle.phase==="running"&&(E.current.value=y.lifecycle.htmlSupport);const j=E.current.value,I=R==="running"?"online":R==="crashed"?"offline":"booting",P=y.suspended,z=y.status.state==="paused",U=Ve({connectionId:Gt,orgId:t?.entity?.organization_id??"",orgSlug:T.slug}),W=Aa(U),H=W.error?.message??null,G=Ed(N??void 0,i??void 0),K=B.useRef(null),se=B.useRef(null),Y=y.phase,J=Ef({claimPhase:Y,lifecycle:y.lifecycle}),ee=!!N&&!!i&&ai.isStopped(N,i),A=jf({previewUrl:C,status:I,htmlSupport:j,suspended:P,appPaused:z,vmStartPending:G,lastStartError:H,claimPhase:Y,notFound:y.notFound,userStopped:ee}),X=Z=>{if(!N)return;const _e={virtualMcpId:N};i&&(_e.branch=i),W.mutate(_e,{onSuccess:qe=>{qe?.branch&&!i&&r(qe.branch)},onError:qe=>{console.error(`[preview] ${Z} VM_START failed`,qe)}})},Q=B.useRef(X);Q.current=X,s&&k&&K.current!==s&&(K.current=s);const F=!!s&&!!N&&!!g&&!!i&&!k&&!H&&!ee&&!W.isPending&&K.current!==s;B.useEffect(()=>{!F||!s||(K.current=s,Q.current("auto-start"))},[F,s,ee]);const V=y.notFound?k?.vmId??null:null;B.useEffect(()=>{!V||!N||H||W.isPending||se.current!==V&&(i&&ai.isStopped(N,i)||(se.current=V,Q.current("self-heal")))},[V,N,H,W.isPending,i]);const ne=()=>{K.current=null,se.current=null,W.reset(),Q.current("auto-start")},he=hs(),ce=N??"__no-vmcp__",[de,fe]=B.useState(null),Be=B.useRef(null);Be.current!==ce&&(Be.current=ce,fe(gg(ce)));const Ne=A.kind==="never-started"?!1:de??!1,je=Z=>{fe(Z),vg(ce,Z)},Je=()=>je(!0),Le=async()=>{if(!N)return;const Z=i;if(Z){ai.mark(N,Z);try{await U.callTool({name:"VM_DELETE",arguments:{virtualMcpId:N,branch:Z}})}catch{}Xo(he)}},vs=async()=>{await Le(),Q.current("auto-start")};B.useEffect(()=>{if(!C)return;let Z;try{Z=new URL(C,window.location.href).origin}catch{return}const _e=qe=>{if(qe.origin!==Z||qe.data?.type!=="visual-editor::element-clicked")return;const lt=uf.safeParse(qe.data.payload);lt.success&&h(lt.data)};return window.addEventListener("message",_e),()=>window.removeEventListener("message",_e)},[C]),B.useEffect(()=>{if(!m)return;const Z=_e=>{x.current?.contains(_e.target)||(_(!1),v(""))};return document.addEventListener("pointerdown",Z),()=>document.removeEventListener("pointerdown",Z)},[m]),B.useEffect(()=>{if(!d)return;const Z=qe=>{const lt=qe.target;lt&<!==c.current&&(f.current=lt)},_e=()=>{requestAnimationFrame(()=>{const qe=document.activeElement;(qe===document.body||qe===c.current)&&f.current&&f.current.focus()})};return document.addEventListener("focusin",Z),document.addEventListener("blur",_e,!0),()=>{document.removeEventListener("focusin",Z),document.removeEventListener("blur",_e,!0)}},[d]);const Cn=()=>{const Z=c.current?.contentWindow;Z&&Z.postMessage({type:"visual-editor::activate",script:ff},"*")},Fl=()=>{const Z=c.current?.contentWindow;Z&&Z.postMessage({type:"visual-editor::deactivate"},"*")},Hl=Z=>{a(Z),h(null),Z==="visual"?Cn():Fl()},Wl=()=>{if(!c.current)return;const Z=c.current;Z.src=Z.src},Ul=()=>{if(!c.current||!C)return;const Z=C.includes("?")?"&":"?";c.current.src=`${C}${Z}_r=${Date.now()}`},Kl=()=>{const Z=c.current?.contentWindow?.location?.href??C;Z&&navigator.clipboard.writeText(Z)},Vl=(()=>{if(!C)return"No server running";try{const Z=new URL(C),_e=b==="/"?"":b;return`${Z.host}${_e}`}catch{return C}})();return o.jsxs("div",{className:"flex flex-col w-full h-full",children:[A.kind==="iframe"&&o.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-4 border-b border-border/60 px-3 md:px-4",children:[o.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[j&&o.jsx(Lh,{value:n,onValueChange:Hl,options:yg,size:"sm",className:"shrink-0 bg-foreground/4.5"}),D.length>0&&o.jsxs(Me,{children:[o.jsx(Re,{asChild:!0,children:o.jsx(re,{variant:d?"secondary":"ghost",size:"icon",onClick:()=>u(Z=>!Z),children:o.jsx(Uc,{size:14})})}),o.jsx(De,{side:"bottom",children:"Sections Editor"})]})]}),o.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-0.5",children:[o.jsxs(Me,{children:[o.jsx(Re,{asChild:!0,children:o.jsx(re,{variant:"ghost",size:"icon",onClick:()=>c.current?.contentWindow?.history.back(),children:o.jsx(Ma,{size:14})})}),o.jsx(De,{side:"bottom",children:"Back"})]}),o.jsxs(Me,{children:[o.jsx(Re,{asChild:!0,children:o.jsx(re,{variant:"ghost",size:"icon",onClick:()=>c.current?.contentWindow?.history.forward(),children:o.jsx(bc,{size:14})})}),o.jsx(De,{side:"bottom",children:"Forward"})]}),o.jsxs(Me,{children:[o.jsx(Re,{asChild:!0,children:o.jsx(re,{variant:"ghost",size:"icon",onClick:Wl,children:o.jsx(_i,{size:14})})}),o.jsx(De,{side:"bottom",children:"Refresh"})]}),o.jsxs("div",{ref:x,className:"relative min-w-0 flex-1",children:[o.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:()=>_(Z=>!Z),children:[o.jsx("span",{className:"min-w-0 flex-1 truncate text-left text-[12px] text-foreground/88",children:Vl}),D.length>0&&o.jsx(un,{size:12,className:ie("shrink-0 text-muted-foreground transition-transform",m&&"rotate-180")})]}),m&&D.length>0&&o.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:[o.jsx("div",{className:"px-2 pt-2 pb-1",children:o.jsx("input",{type:"text",value:p,onChange:Z=>v(Z.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})}),o.jsx(dn,{className:"max-h-[60vh]",children:o.jsxs("div",{className:"p-1.5",children:[D.filter(Z=>{if(!p)return!0;const _e=p.toLowerCase();return Z.name.toLowerCase().includes(_e)||Z.path.toLowerCase().includes(_e)}).map(Z=>o.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),v(""),S(Z.path);const _e=c.current;_e&&C&&(_e.src=new URL(Z.path,C).href)},children:[o.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:Z.name}),o.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:Z.path})]},Z.key)),p&&D.every(Z=>{const _e=p.toLowerCase();return!Z.name.toLowerCase().includes(_e)&&!Z.path.toLowerCase().includes(_e)})&&o.jsxs("div",{className:"px-3 py-4 text-center text-xs text-muted-foreground",children:['No pages match "',p,'"']})]})})]})]})]}),o.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[o.jsxs(Me,{children:[o.jsx(Re,{asChild:!0,children:o.jsx(re,{variant:"ghost",size:"icon",onClick:()=>window.open(A.previewUrl,"_blank","noopener"),children:o.jsx(ms,{size:14})})}),o.jsx(De,{side:"bottom",children:"Open in new tab"})]}),o.jsxs(Ei,{children:[o.jsx(Ti,{asChild:!0,children:o.jsx(re,{variant:"ghost",size:"icon",children:o.jsx(ca,{size:14})})}),o.jsxs(Ri,{align:"end",children:[o.jsx($t,{onClick:Ul,children:"Hard Reload"}),o.jsx($t,{onClick:Kl,children:"Copy Current URL"})]})]})]})]}),o.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[d&&C&&i&&N&&o.jsx("div",{className:"w-96 shrink-0 border-r overflow-hidden",children:o.jsx(B.Suspense,{fallback:o.jsx("div",{className:"h-full flex items-center justify-center",children:o.jsx(He,{size:20,className:"animate-spin text-muted-foreground"})}),children:o.jsx(xg,{orgSlug:T.slug,virtualMcpId:N,branch:i,currentPath:b,onSaved:()=>{setTimeout(()=>{const Z=c.current;if(!Z)return;const _e=document.activeElement,qe=Z.tabIndex;Z.tabIndex=-1,Z.style.pointerEvents="none",Z.blur();try{Z.contentWindow?.location.reload()}catch{Z.src=Z.src}const lt=()=>{Z.tabIndex=qe,Z.style.pointerEvents="",_e?.focus(),Z.removeEventListener("load",lt)};Z.addEventListener("load",lt),setTimeout(lt,3e3)},bg)}})})}),o.jsxs("div",{className:"flex-1 relative overflow-hidden",children:[A.kind==="never-started"&&o.jsx("div",{className:"absolute inset-0 z-30",children:o.jsx(Ns,{kind:"never-started",onStart:()=>{je(!1),X("auto-start")}})}),A.kind==="starting-now"&&o.jsx("div",{className:"absolute inset-0 z-30",children:o.jsx(Ns,{kind:"starting-now",progress:J,claimPhase:Y})}),A.kind==="errored"&&o.jsx("div",{className:"absolute inset-0 z-40",children:o.jsx(Ns,{kind:"errored",progress:J,logSource:"setup",errorLine:A.error.split(`
|
|
185
185
|
`)[0]??"Failed to start",onRetry:ne,drawerOpen:Ne})}),A.kind==="suspended"&&o.jsx("div",{className:"absolute inset-0 z-30",children:o.jsx(Ns,{kind:"suspended",onResume:ne})}),A.kind==="crashed"&&o.jsx("div",{className:"absolute inset-0 z-30",children:o.jsx(Ns,{kind:"crashed",onOpenTerminal:Je})}),A.kind==="no-html"&&o.jsxs("div",{className:"absolute inset-0 z-30 flex flex-col items-center justify-center gap-4 bg-background",children:[o.jsx(An,{size:48,className:"text-muted-foreground/40"}),o.jsx("h3",{className:"text-lg font-medium",children:"No web page at this URL"}),o.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."}),o.jsxs(re,{onClick:Je,children:[o.jsx(An,{size:14}),"View Logs"]})]}),n==="visual"&&!l&&o.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:[o.jsx(ha,{size:12}),"Click any element to ask the AI"]}),n==="visual"&&l&&o.jsx(pf,{element:l,onDismiss:()=>h(null)}),A.kind==="iframe"&&o.jsx("iframe",{ref:c,src:A.previewUrl,className:"w-full h-full border-0",title:"Dev Server Preview",tabIndex:d?-1:void 0,onLoad:()=>{ye("vm_preview_loaded",{view_mode:n,vm_id:k?.vmId??null});try{const Z=c.current?.contentWindow?.location?.pathname;Z&&S(Z)}catch{}n==="visual"&&Cn()}},A.previewUrl)]})]}),o.jsx(_g,{vmId:k?.vmId??null,orgSlug:T.slug,virtualMcpId:N,branch:i,status:Sg(A,G),scripts:y.scripts,open:Ne,onOpenChange:je,onStart:()=>X("auto-start"),onStop:Le,onRestart:vs,onResume:ne,onRetry:ne},k?.vmId??"no-vm")]})}function Cg(t){const e=$.c(2),{virtualMcpId:s}=t,i=yt(s);if(!(i?Ht(i):null)){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=o.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground p-6",children:[o.jsx(tn,{size:24,className:"text-muted-foreground/60"}),o.jsx("div",{children:"No repository connected."}),o.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 n;return e[1]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx(wg,{}),e[1]=n):n=e[1],n}function As(t){const e=t.trim().split(/\s+/);return e.length!==5?!1:e.every(s=>/^[\d*/,-]+$/.test(s))}function kg(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 n=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+\*$/);if(n){const l=(n[2]??"0").padStart(2,"0"),h=(n[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 Ng(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 jg(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 n=parseInt(r[1]);return n%7===0?{count:n/7,unit:"weeks"}:{count:n,unit:"days"}}return null}function Eg(t,e){return e===1?{minutes:"minute",hours:"hour",days:"day",weeks:"week"}[t]??t:t}const Tg=[{label:"5 minutes",cron:"*/5 * * * *"},{label:"Hour",cron:"0 * * * *"},{label:"Day",cron:"0 0 * * *"},{label:"Week",cron:"0 0 * * 1"}];function Rg(t){const e=$.c(33),{automationId:s,open:i,onOpenChange:r,onCustomSelect:n,onEventSelect:a}=t,{triggerAdd:l}=Ws(),[h,c]=B.useState(!1),d=i??h;let u;e[0]!==r?(u=M=>{r?r(M):c(M)},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 M=>{try{await l.mutateAsync({automation_id:s,type:"cron",cron_expression:M}),me.success("Starter added"),f(!1)}catch(D){const y=D,R=y instanceof Error?y.message:"Failed to add starter";me.error(R)}},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=o.jsx(Ti,{asChild:!0,children:o.jsxs(re,{variant:"outline",size:"sm",children:[o.jsx(ls,{size:14}),"Add Starter"]})}),e[6]=p):p=e[6];let v;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=o.jsxs(Ph,{className:"gap-2.5",children:[o.jsx(Ps,{size:14,className:"text-muted-foreground shrink-0"}),"Every..."]}),e[7]=v):v=e[7];let x;e[8]!==l||e[9]!==_?(x=Tg.map(M=>o.jsxs($t,{className:"gap-2.5",onSelect:()=>_(M.cron),disabled:l.isPending,children:[o.jsx(Ps,{size:14,className:"text-muted-foreground shrink-0"}),"Every ",M.label]},M.cron)),e[8]=l,e[9]=_,e[10]=x):x=e[10];let b;e[11]!==x?(b=o.jsxs(Ih,{children:[v,o.jsx(Ah,{className:"w-[160px]",children:x})]}),e[11]=x,e[12]=b):b=e[12];let S;e[13]!==f||e[14]!==n?(S=()=>{f(!1),n?.()},e[13]=f,e[14]=n,e[15]=S):S=e[15];let g;e[16]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx(Ps,{size:14,className:"text-muted-foreground shrink-0"}),e[16]=g):g=e[16];let w;e[17]!==S?(w=o.jsxs($t,{className:"gap-2.5",onSelect:S,children:[g,"Custom (cron)"]}),e[17]=S,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=o.jsx(Bs,{size:14,className:"text-muted-foreground shrink-0"}),e[22]=C):C=e[22];let N;e[23]!==k?(N=o.jsxs($t,{className:"gap-2.5",onSelect:k,children:[C,"Event"]}),e[23]=k,e[24]=N):N=e[24];let T;e[25]!==N||e[26]!==b||e[27]!==w?(T=o.jsxs(Ri,{align:"end",className:"w-[200px]",children:[b,w,N]}),e[25]=N,e[26]=b,e[27]=w,e[28]=T):T=e[28];let L;return e[29]!==f||e[30]!==d||e[31]!==T?(L=o.jsxs(Ei,{open:d,onOpenChange:f,children:[p,T]}),e[29]=f,e[30]=d,e[31]=T,e[32]=L):L=e[32],L}function Dg(t){const e=$.c(60),{trigger:s,automationId:i,connectionName:r}=t,{triggerAdd:n,triggerRemove:a}=Ws(),[l,h]=B.useState(!1);let c;e[0]!==s.cron_expression?(c=s.cron_expression?jg(s.cron_expression):null,e[0]=s.cron_expression,e[1]=c):c=e[1];const d=c,[u,f]=B.useState(d?.count??1),[m,_]=B.useState(!1),[p,v]=B.useState(s.cron_expression??""),x=a.isPending||n.isPending,b=s.type==="cron";let S;e[2]!==i||e[3]!==a||e[4]!==s.id?(S=async()=>{try{await a.mutateAsync({trigger_id:s.id,automation_id:i}),me.success("Starter removed")}catch{me.error("Failed to remove starter")}h(!1)},e[2]=i,e[3]=a,e[4]=s.id,e[5]=S):S=e[5];const g=S;let w;e[6]!==n||e[7]!==i||e[8]!==p||e[9]!==a||e[10]!==s.cron_expression||e[11]!==s.id?(w=async()=>{const W=p.trim();if(!W||!As(W)||W===s.cron_expression){_(!1),v(s.cron_expression??"");return}try{await n.mutateAsync({automation_id:i,type:"cron",cron_expression:W}),await a.mutateAsync({trigger_id:s.id,automation_id:i}),_(!1)}catch{me.error("Failed to update starter"),v(s.cron_expression??""),_(!1)}},e[6]=n,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]!==n||e[14]!==i||e[15]!==d||e[16]!==a||e[17]!==s.cron_expression||e[18]!==s.id?(C=async W=>{if(!d)return;const H=d.unit==="minutes"?5:1,G=Math.max(H,W);G!==W&&f(G);const K=Ng(G,d.unit);if(K!==s.cron_expression)try{await n.mutateAsync({automation_id:i,type:"cron",cron_expression:K}),await a.mutateAsync({trigger_id:s.id,automation_id:i})}catch{me.error("Failed to update starter"),f(d.count)}},e[13]=n,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 N=C;let T;e[20]!==b?(T=b?o.jsx(Ps,{size:14,className:"text-muted-foreground shrink-0"}):o.jsx(Bs,{size:14,className:"text-muted-foreground shrink-0"}),e[20]=b,e[21]=T):T=e[21];let L;e[22]!==r||e[23]!==u||e[24]!==p||e[25]!==N||e[26]!==k||e[27]!==d||e[28]!==b||e[29]!==m||e[30]!==x||e[31]!==s.cron_expression||e[32]!==s.event_type||e[33]!==s.params?(L=d&&b?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-sm text-muted-foreground",children:"Every"}),o.jsx("input",{type:"number",min:d.unit==="minutes"?5:1,value:u,onChange:W=>f(parseInt(W.target.value)||1),onBlur:()=>N(u),onKeyDown:W=>{W.key==="Enter"&&W.target.blur(),W.key==="Escape"&&f(d.count)},disabled:x,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"}),o.jsx("span",{className:"text-sm",children:Eg(d.unit,u)})]}):b&&m?o.jsxs(o.Fragment,{children:[o.jsx("input",{type:"text",value:p,onChange:W=>v(W.target.value),onBlur:k,onKeyDown:W=>{W.key==="Enter"&&W.target.blur(),W.key==="Escape"&&(_(!1),v(s.cron_expression??""))},className:"flex-1 text-sm font-mono bg-transparent outline-none",autoFocus:!0}),p&&!As(p)&&o.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"})]}):o.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[o.jsx("span",{className:"text-sm font-mono text-xs text-muted-foreground truncate",children:b?kg(s.cron_expression??""):`${s.event_type}${r?` · ${r}`:""}`}),!b&&s.params&&Object.keys(s.params).length>0&&o.jsx("span",{className:"text-xs text-muted-foreground/60 truncate",children:Object.entries(s.params).map(Mg).join(", ")})]}),e[22]=r,e[23]=u,e[24]=p,e[25]=N,e[26]=k,e[27]=d,e[28]=b,e[29]=m,e[30]=x,e[31]=s.cron_expression,e[32]=s.event_type,e[33]=s.params,e[34]=L):L=e[34];let M;e[35]!==x?(M=x&&o.jsx(He,{size:13,className:"animate-spin text-muted-foreground"}),e[35]=x,e[36]=M):M=e[36];let D;e[37]!==d||e[38]!==b||e[39]!==m||e[40]!==s.cron_expression?(D=b&&!d&&!m&&o.jsx(re,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{v(s.cron_expression??""),_(!0)},children:o.jsx(xh,{size:13,className:"text-muted-foreground"})}),e[37]=d,e[38]=b,e[39]=m,e[40]=s.cron_expression,e[41]=D):D=e[41];let y;e[42]===Symbol.for("react.memo_cache_sentinel")?(y=o.jsx(re,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>h(!0),children:o.jsx(as,{size:13,className:"text-muted-foreground"})}),e[42]=y):y=e[42];let R;e[43]!==M||e[44]!==D?(R=o.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[M,D,y]}),e[43]=M,e[44]=D,e[45]=R):R=e[45];let E;e[46]!==R||e[47]!==T||e[48]!==L?(E=o.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[T,L,R]}),e[46]=R,e[47]=T,e[48]=L,e[49]=E):E=e[49];let j;e[50]===Symbol.for("react.memo_cache_sentinel")?(j=o.jsxs(Sa,{children:[o.jsx(ya,{children:"Remove Starter"}),o.jsx(wa,{children:"Are you sure you want to remove this starter?"})]}),e[50]=j):j=e[50];let I;e[51]===Symbol.for("react.memo_cache_sentinel")?(I=o.jsx(ka,{children:"Cancel"}),e[51]=I):I=e[51];let P;e[52]!==g?(P=o.jsxs(ba,{children:[j,o.jsxs(Ca,{children:[I,o.jsx(Na,{onClick:g,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]}),e[52]=g,e[53]=P):P=e[53];let z;e[54]!==l||e[55]!==P?(z=o.jsx(xa,{open:l,onOpenChange:h,children:P}),e[54]=l,e[55]=P,e[56]=z):z=e[56];let U;return e[57]!==E||e[58]!==z?(U=o.jsxs(o.Fragment,{children:[E,z]}),e[57]=E,e[58]=z,e[59]=U):U=e[59],U}function Mg(t){const[e,s]=t;return`${e}: ${s}`}function Pg(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 Ig(t){const e=$.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 n=Ni(r),[a,l]=B.useState(),[h,c]=B.useState();let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d={},e[1]=d):d=e[1];const[u,f]=B.useState(d),{triggerAdd:m}=Ws(),{data:_,isLoading:p}=$h(a);let v,x,b,S,g,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]!==n||e[10]!==_){const N=_?.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}),ye("automation_trigger_added",{automation_id:s,trigger_type:"event",connection_id:a,event_type:h}),me.success("Event trigger added"),i()}catch{me.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],v=T,x="flex flex-col gap-3 px-3 py-3 rounded-lg border border-border bg-background";let L,M;e[24]===Symbol.for("react.memo_cache_sentinel")?(M=o.jsx(Bs,{size:14,className:"text-muted-foreground shrink-0"}),L=o.jsx("span",{className:"text-sm font-medium",children:"Event trigger"}),e[24]=L,e[25]=M):(L=e[24],M=e[25]);let D;e[26]===Symbol.for("react.memo_cache_sentinel")?(D=o.jsx(as,{size:13}),e[26]=D):D=e[26],e[27]!==i?(b=o.jsxs("div",{className:"flex items-center gap-2",children:[M,L,o.jsx("button",{type:"button",className:"ml-auto shrink-0 p-0.5 rounded text-muted-foreground hover:text-foreground",onClick:i,children:D})]}),e[27]=i,e[28]=b):b=e[28];const y=a??"";let R;e[29]===Symbol.for("react.memo_cache_sentinel")?(R=P=>{l(P),c(void 0),f({})},e[29]=R):R=e[29];let E;e[30]===Symbol.for("react.memo_cache_sentinel")?(E=o.jsx(rs,{className:"w-full",children:o.jsx(ns,{placeholder:"Select connection..."})}),e[30]=E):E=e[30];let j;e[31]!==n?(j=n.length===0?o.jsx("div",{className:"px-2 py-3 text-center text-xs text-muted-foreground",children:"No connections with trigger support"}):n.map(Lg),e[31]=n,e[32]=j):j=e[32];let I;e[33]!==j?(I=o.jsx(os,{children:j}),e[33]=j,e[34]=I):I=e[34],e[35]!==y||e[36]!==I?(S=o.jsxs(is,{value:y,onValueChange:R,children:[E,I]}),e[35]=y,e[36]=I,e[37]=S):S=e[37],e[38]!==a||e[39]!==h||e[40]!==p||e[41]!==_?(g=a&&o.jsxs(is,{value:h??"",onValueChange:P=>{c(P),f({})},children:[o.jsx(rs,{className:"w-full",children:p?o.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[o.jsx(He,{size:13,className:"animate-spin"}),"Loading events..."]}):o.jsx(ns,{placeholder:"Select event type...",children:h??"Select event type..."})}),o.jsx(os,{children:_?.map(Bg)})]}),e[38]=a,e[39]=h,e[40]=p,e[41]=_,e[42]=g):g=e[42],w=N?.paramsSchema&&Object.keys(N.paramsSchema).length>0&&o.jsx("div",{className:"flex flex-col gap-2",children:Object.entries(N.paramsSchema).map(P=>{const[z,U]=P;return o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsxs("label",{className:"text-xs text-muted-foreground",children:[z,U.description&&o.jsxs("span",{className:"text-muted-foreground/60",children:[" ","— ",U.description]})]}),U.enum?o.jsxs(is,{value:u[z]??"",onValueChange:W=>f(H=>({...H,[z]:W})),children:[o.jsx(rs,{className:"w-full",children:o.jsx(ns,{placeholder:`Select ${z}...`})}),o.jsx(os,{children:U.enum.map(Ag)})]}):o.jsx("input",{type:"text",value:u[z]??"",onChange:W=>f(H=>({...H,[z]:W.target.value})),placeholder:U.description??z,className:"text-sm border border-border rounded-md bg-background px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-ring"})]},z)})}),e[2]=m,e[3]=s,e[4]=a,e[5]=h,e[6]=p,e[7]=i,e[8]=u,e[9]=n,e[10]=_,e[11]=v,e[12]=x,e[13]=b,e[14]=S,e[15]=g,e[16]=w}else v=e[11],x=e[12],b=e[13],S=e[14],g=e[15],w=e[16];let k;e[43]!==m||e[44]!==a||e[45]!==h||e[46]!==v?(k=a&&h&&o.jsx(re,{size:"sm",onClick:v,disabled:m.isPending,children:m.isPending?o.jsx(He,{size:13,className:"animate-spin"}):"Add trigger"}),e[43]=m,e[44]=a,e[45]=h,e[46]=v,e[47]=k):k=e[47];let C;return e[48]!==x||e[49]!==b||e[50]!==S||e[51]!==g||e[52]!==w||e[53]!==k?(C=o.jsxs("div",{className:x,children:[b,S,g,w,k]}),e[48]=x,e[49]=b,e[50]=S,e[51]=g,e[52]=w,e[53]=k,e[54]=C):C=e[54],C}function Ag(t){return o.jsx(Mt,{value:t,children:t},t)}function Bg(t){return o.jsx(Mt,{value:t.type,children:o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{children:t.type}),o.jsx("span",{className:"text-xs text-muted-foreground",children:t.description})]})},t.type)}function Lg(t){return o.jsx(Mt,{value:t.id,children:t.title},t.id)}function Og({automationId:t,automation:e,onBack:s,onDelete:i}){const r=e.virtual_mcp_id,{org:n}=ve(),{update:a,triggerAdd:l}=Ws(),h=Ni(),c=new Map(h.map(F=>[F.id,F.title])),{createTaskWithMessage:d}=Pt(),{setSimpleModeTier:u}=en(),{setChatOpen:f}=an(),{sendMessage:m}=Yt(),_=_a(),[p,v]=ec(),x=e.messages?.[0]?.metadata?.tiptapDoc??void 0,[b,S]=B.useState(x),[g,w]=B.useState(!1),[k,C]=B.useState(!1),[N,T]=B.useState(""),[L,M]=B.useState(!1),[D,y]=B.useState(!1),[R,E]=B.useState(!1),[j,I]=B.useState(!1),P=async()=>{if(D)return;const V=jn(b).filter(ne=>ne.type==="text").map(ne=>ne.text).join(`
|
|
186
|
-
`);if(V.trim()){y(!0);try{A(),ye("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:V.length}),await _(["studio-automation-manager"]),f(!0),await m({tiptapDoc:La({managerAgentId:ia.AUTOMATION_MANAGER(n.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:V})})}finally{y(!1)}}},z=e.models?.tier??"smart",U=Zo({defaultValues:{name:e.name,active:e.active,tier:z}}),W=U.watch("active"),[H,G]=B.useReducer(Pg,null),K=()=>{H!==null&&(ye("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(H.fields),save_count:H.saveCount,edit_duration_ms:Date.now()-H.start}),G({type:"reset"}))},se=async()=>{const F=U.control._formState.dirtyFields,V=Object.keys(F);if(V.length===0&&!j)return!0;const ne=U.getValues(),he=U.control._defaultValues;U.reset(ne,{keepValues:!0});const ce=j;I(!1);const de={id:t,name:ne.name,active:ne.active,models:{tier:ne.tier},messages:_c(b),temperature:0};try{await a.mutateAsync(de)}catch{return U.reset(he,{keepValues:!0}),ce&&I(!0),!1}const fe=[...V];return ce&&fe.push("messages"),G({type:"accumulate",now:Date.now(),fields:fe}),ee(),!0},{schedule:Y,flush:J}=gi({save:se}),{schedule:ee,flush:A}=gi({delayMs:3e4,save:async()=>K()});B.useEffect(()=>{const F=U.watch(()=>Y());return()=>F.unsubscribe()},[]);const X=F=>{if(S(F),!R){E(!0);return}I(!0),Y()},Q=async()=>{ye("automation_test_clicked",{automation_id:t,agent_id:r});const F=await J();if(A(),!F)return;if(!b){me.error("No instructions configured for this automation");return}u(U.getValues("tier")),f(!0),v({...p,toolApprovalLevel:"auto"});const V=jn(b);d({message:{tiptapDoc:b,parts:V},virtualMcpId:r||void 0})};return o.jsxs(o.Fragment,{children:[s&&o.jsx("div",{className:"flex items-center pb-4 shrink-0",children:o.jsxs(re,{variant:"ghost",size:"sm",onClick:s,children:[o.jsx(Ma,{size:14}),"Back to list"]})}),o.jsxs("div",{className:"flex flex-col gap-8",children:[o.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsx(mt,{control:U.control,name:"name",render:({field:F})=>o.jsx(Xt,{...F,placeholder:"Automation name",className:"border border-transparent shadow-none px-0 text-lg font-medium h-auto focus-visible:ring-0 focus-visible:border-border bg-transparent flex-1",style:{boxShadow:"none"}})}),i&&o.jsx(re,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:i,children:o.jsx(fr,{size:14})})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(mt,{control:U.control,name:"active",render:({field:F})=>o.jsx(ur,{checked:F.value,onCheckedChange:V=>{F.onChange(V),J()},className:"cursor-pointer"})}),o.jsx("span",{className:"text-sm text-muted-foreground",children:W?"Active":"Inactive"}),o.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),o.jsx(pa,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),o.jsxs("div",{className:"flex flex-col gap-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),o.jsx(Rg,{automationId:t,open:g,onOpenChange:w,onCustomSelect:()=>{C(!0),M(!1),T("")},onEventSelect:()=>{M(!0),C(!1)}})]}),e.triggers.length===0&&!k?o.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:o.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",o.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>w(!0),children:"Add a starter"})," ","to get going."]})}):o.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(F=>o.jsx(Dg,{trigger:F,automationId:t,connectionName:F.connection_id?c.get(F.connection_id):void 0},F.id))}),k&&o.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[o.jsx(Ps,{size:14,className:"text-muted-foreground shrink-0"}),o.jsx("input",{type:"text",value:N,onChange:F=>T(F.target.value),onBlur:async()=>{const F=N.trim();if(!(!F||!As(F)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:F}),ye("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),me.success("Starter added"),C(!1),T("")}catch{me.error("Failed to add starter")}},onKeyDown:async F=>{const V=N.trim();F.key==="Enter"&&V&&As(V)&&F.target.blur(),F.key==="Escape"&&(C(!1),T(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),N&&!As(N)&&o.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&o.jsx(He,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),o.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:()=>{C(!1),T("")},children:o.jsx(as,{size:13})})]}),L&&o.jsx(B.Suspense,{fallback:o.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[o.jsx(He,{size:13,className:"animate-spin text-muted-foreground"}),o.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:o.jsx(Ig,{automationId:t,onDone:()=>M(!1)})})]}),o.jsxs("div",{className:"flex flex-col gap-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),o.jsxs(re,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:D||!b,onClick:P,children:[o.jsx(Ra,{size:13}),"Improve"]})]}),o.jsx(oc,{tiptapDoc:b,setTiptapDoc:X,placeholder:"What should this automation do?",children:o.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[o.jsx(ac,{virtualMcpId:r||null,className:"max-h-[45vh]"}),o.jsxs("div",{className:"flex items-center justify-end gap-1.5 p-2.5",children:[o.jsx(lc,{tier:U.watch("tier"),onSelect:F=>U.setValue("tier",F,{shouldDirty:!0})}),o.jsxs(Me,{children:[o.jsx(Re,{asChild:!0,children:o.jsxs(re,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:Q,disabled:!r,children:[o.jsx(Sc,{size:16}),"Test"]})}),o.jsx(De,{children:"Test Automation"})]})]})]})})]})]})]})}function $g(t){const e=$.c(5),{tabId:s}=t;let i;e[0]!==s?(i=ra(s),e[0]=s,e[1]=i):i=e[1];const r=i;if(!r)return null;let n;e[2]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(He,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=n):n=e[2];let a;return e[3]!==r.id?(a=o.jsx(at,{children:o.jsx(at.Content,{children:o.jsx(at.Body,{children:o.jsx(B.Suspense,{fallback:n,children:o.jsx(zg,{id:r.id})})})})}),e[3]=r.id,e[4]=a):a=e[4],a}function zg(t){const e=$.c(8),{id:s}=t,i=Vt(),{data:r,isLoading:n}=zh(s);let a;e[0]!==i?(a=()=>i({to:".",search:Fg,replace:!0}),e[0]=i,e[1]=a):a=e[1];const l=a;if(n){let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(He,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=c):c=e[2],c}if(!r){let c;return e[3]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=c):c=e[3],c}let h;return e[4]!==r||e[5]!==s||e[6]!==l?(h=o.jsx(Og,{automationId:s,automation:r,onBack:l}),e[4]=r,e[5]=s,e[6]=l,e[7]=h):h=e[7],h}function Fg(t){return{...t,main:"automations"}}function Hg(t){const e=$.c(20),{virtualMcpId:s}=t,i=Vt(),{data:r}=Fh(s),n=r===void 0?[]:r,{create:a}=Ws(),[l,h]=B.useState(""),c=l.toLowerCase(),d=n.filter(L=>L.name.toLowerCase().includes(c));let u;e[0]!==i?(u=L=>i({to:".",search:M=>({...M,main:"automation:"+L}),replace:!0}),e[0]=i,e[1]=u):u=e[1];const f=u,m=async()=>{if(a.isPending)return;ye("automation_new_clicked",{virtual_mcp_id:s,existing_count:n.length});const L=await a.mutateAsync(Wh(s));f(L.id)},_=at,p=at,v=at;let x;e[2]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx(at.Title,{children:"Automations"}),e[2]=x):x=e[2];const b=n.length>0&&o.jsx(Uh,{value:l,onChange:h,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let S;e[3]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(ls,{size:14}),e[3]=S):S=e[3];let g;e[4]!==a.isPending||e[5]!==m?(g=o.jsxs(re,{size:"sm",onClick:m,disabled:a.isPending,children:[S,"New automation"]}),e[4]=a.isPending,e[5]=m,e[6]=g):g=e[6];let w;e[7]!==b||e[8]!==g?(w=o.jsxs("div",{className:"flex flex-col gap-6",children:[x,o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[b,g]})]}),e[7]=b,e[8]=g,e[9]=w):w=e[9];const k=n.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(pi,{image:o.jsx(Bs,{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:o.jsxs(re,{size:"sm",onClick:m,disabled:a.isPending,children:[o.jsx(ls,{size:14}),"New automation"]})})}):d.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(pi,{image:o.jsx(Bs,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${l}"`})}):o.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:d.map(L=>o.jsx(Hh,{automation:L,onClick:()=>f(L.id)},L.id))});let C;e[10]!==k||e[11]!==v.Body||e[12]!==w?(C=o.jsxs(v.Body,{children:[w,k]}),e[10]=k,e[11]=v.Body,e[12]=w,e[13]=C):C=e[13];let N;e[14]!==C||e[15]!==p.Content?(N=o.jsx(p.Content,{children:C}),e[14]=C,e[15]=p.Content,e[16]=N):N=e[16];let T;return e[17]!==_||e[18]!==N?(T=o.jsx(_,{children:N}),e[17]=_,e[18]=N,e[19]=T):T=e[19],T}function Wg(t){const e=$.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(He,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx(B.Suspense,{fallback:i,children:o.jsx(Hg,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}const Wo=B.lazy(()=>Qo(()=>import("./project-app-view-BWOVxJN2.js"),__vite__mapDeps([119,1,2,74,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,75,76,6,77,47,78,79,51,63,64,50,65,66,54,67,68,69,70,71,72,73,61,62])).then(t=>({default:t.AppViewContent})));function Ol(t){const e=$.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:n,layoutTabs:a,expandedTools:l,automationTabParsed:h}=Ba(r);if(jc(n)){let _;return e[3]!==i?(_=o.jsx(Kn,{virtualMcpId:i}),e[3]=i,e[4]=_):_=e[4],_}if(n==="git"){let _;return e[5]!==i?(_=o.jsx(nf,{virtualMcpId:i}),e[5]=i,e[6]=_):_=e[6],_}if(n==="automations"){let _;return e[7]!==i?(_=o.jsx(Wg,{virtualMcpId:i}),e[7]=i,e[8]=_):_=e[8],_}if(n==="preview"){let _;return e[9]!==i?(_=o.jsx(Cg,{virtualMcpId:i}),e[9]=i,e[10]=_):_=e[10],_}if(h){let _;return e[11]!==n?(_=o.jsx($g,{tabId:n}),e[11]=n,e[12]=_):_=e[12],_}let c;e[13]!==n?(c=Ec(n),e[13]=n,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 S;e[19]!==d.connectionId||e[20]!==d.toolName?(S=g=>g.appId===d.connectionId&&g.toolName===d.toolName,e[19]=d.connectionId,e[20]=d.toolName,e[21]=S):S=e[21],_=l.find(S),e[15]=l,e[16]=d.connectionId,e[17]=d.toolName,e[18]=_}else _=e[18];const p=_;let v;e[22]===Symbol.for("react.memo_cache_sentinel")?(v=o.jsx("div",{className:"h-full w-full flex items-center justify-center",children:o.jsx(He,{size:20,className:"animate-spin text-muted-foreground"})}),e[22]=v):v=e[22];const x=p?.args;let b;return e[23]!==n||e[24]!==d.connectionId||e[25]!==d.toolName||e[26]!==x?(b=o.jsx(B.Suspense,{fallback:v,children:o.jsx(Wo,{connectionId:d.connectionId,toolName:d.toolName,args:x},n)}),e[23]=n,e[24]=d.connectionId,e[25]=d.toolName,e[26]=x,e[27]=b):b=e[27],b}let u;if(e[28]!==n||e[29]!==a){let _;e[31]!==n?(_=p=>p.id===n,e[31]=n,e[32]=_):_=e[32],u=a.find(_),e[28]=n,e[29]=a,e[30]=u}else u=e[30];const f=u;if(f){let _;e[33]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx("div",{className:"h-full w-full flex items-center justify-center",children:o.jsx(He,{size:20,className:"animate-spin text-muted-foreground"})}),e[33]=_):_=e[33];let p;return e[34]!==n||e[35]!==f.id||e[36]!==f.view.appId||e[37]!==f.view.args?(p=o.jsx(B.Suspense,{fallback:_,children:o.jsx(Wo,{connectionId:f.view.appId,toolName:f.id,args:f.view.args},n)}),e[34]=n,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=o.jsx(Kn,{virtualMcpId:i}),e[39]=i,e[40]=m):m=e[40],m}function Ug(t){const e=$.c(10),{children:s,defaultSize:i,chatOpen:r}=t,[,n]=B.useTransition();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=ta.decoChatPanelWidth(),e[0]=a):a=e[0];const[l,h]=ea(a,45),c=i>0&&i<100?l:i;let d;e[1]!==h?(d=p=>n(()=>{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=ie("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?(_=o.jsx(ma,{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 Kg(t){const e=$.c(31),{virtualMcpId:s,taskId:i,chatOpen:r,mainOpen:n,chatContent:a}=t;let l;e[0]!==r||e[1]!==n?(l=Nn(r,n),e[0]=r,e[1]=n,e[2]=l):l=e[2];const h=l;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=ta.decoChatPanelWidth(),e[3]=c):c=e[3];const[d]=ea(c,45),u=B.useRef(null);let f,m;e[4]!==r||e[5]!==n||e[6]!==d?(f=()=>{const L=u.current;if(!L)return;const M=Nn(r,n),D=M.chat>0&&M.chat<100?d:M.chat,y=M.chat>0&&M.chat<100?100-d:M.main;L.setLayout([D,y])},m=[r,n,d],e[4]=r,e[5]=n,e[6]=d,e[7]=f,e[8]=m):(f=e[7],m=e[8]),B.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 v;e[10]!==a?(v=a??o.jsx(Pa,{}),e[10]=a,e[11]=v):v=e[11];let x;e[12]!==v?(x=o.jsx("div",{className:"h-full p-0.5 pt-0.25",children:o.jsx("div",{className:"h-full bg-background rounded-[0.75rem] overflow-hidden card-shadow",children:v})}),e[12]=v,e[13]=x):x=e[13];let b;e[14]!==r||e[15]!==h.chat||e[16]!==x?(b=o.jsx(Ug,{defaultSize:h.chat,chatOpen:r,children:x}),e[14]=r,e[15]=h.chat,e[16]=x,e[17]=b):b=e[17];let S;e[18]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(ah,{className:"bg-sidebar"}),e[18]=S):S=e[18];const g=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=ie("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=o.jsx("div",{className:"h-full p-0.5 pt-0.25",children:o.jsx("div",{className:k,children:o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:o.jsx(Rt,{children:o.jsx(Ol,{taskId:i,virtualMcpId:s})})})})}),e[21]=i,e[22]=s,e[23]=C):C=e[23];let N;e[24]!==h.main||e[25]!==C?(N=o.jsx(ma,{className:"min-w-0 flex flex-col",order:2,defaultSize:g,style:w,collapsible:!0,collapsedSize:0,minSize:20,children:C}),e[24]=h.main,e[25]=C,e[26]=N):N=e[26];let T;return e[27]!==N||e[28]!==_||e[29]!==b?(T=o.jsxs(lh,{ref:u,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:p,children:[b,S,N]},_),e[27]=N,e[28]=_,e[29]=b,e[30]=T):T=e[30],T}const or="flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",Uo="bg-sidebar-accent text-sidebar-foreground",ar="text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";function Vg(t){const e=$.c(47),{chatOpen:s,toggleChat:i,onNewTask:r}=t,{tasksOpen:n,toggleTasks:a}=cc(),l=!!r;let h;e[0]!==n||e[1]!==a?(h=()=>{ye("agent_toolbar_toggled",{button:"tasks",next_state:n?"closed":"open"}),a()},e[0]=n,e[1]=a,e[2]=h):h=e[2];const c=n?Uo:ar;let d;e[3]!==c?(d=ie(or,c),e[3]=c,e[4]=d):d=e[4];let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsx(Kc,{size:16}),e[5]=u):u=e[5];let f;e[6]!==h||e[7]!==d||e[8]!==n?(f=o.jsx(Re,{asChild:!0,children:o.jsx("button",{type:"button",onClick:h,"aria-pressed":n,className:d,children:u})}),e[6]=h,e[7]=d,e[8]=n,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=o.jsx(De,{side:"bottom",children:"Tasks"}),e[10]=m):m=e[10];let _;e[11]!==f?(_=o.jsxs(Me,{delayDuration:300,children:[f,m]}),e[11]=f,e[12]=_):_=e[12];let p;e[13]!==s||e[14]!==i?(p=()=>{ye("agent_toolbar_toggled",{button:"chat",next_state:s?"closed":"open"}),i()},e[13]=s,e[14]=i,e[15]=p):p=e[15];const v=s?Uo:ar;let x;e[16]!==v?(x=ie(or,v),e[16]=v,e[17]=x):x=e[17];let b;e[18]===Symbol.for("react.memo_cache_sentinel")?(b=o.jsx(da,{size:16}),e[18]=b):b=e[18];let S;e[19]!==s||e[20]!==x||e[21]!==p?(S=o.jsx(Re,{asChild:!0,children:o.jsx("button",{type:"button",onClick:p,"aria-pressed":s,className:x,children:b})}),e[19]=s,e[20]=x,e[21]=p,e[22]=S):S=e[22];let g;e[23]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx(De,{side:"bottom",children:"Chat"}),e[23]=g):g=e[23];let w;e[24]!==S?(w=o.jsxs(Me,{delayDuration:300,children:[S,g]}),e[24]=S,e[25]=w):w=e[25];const k=l?"grid-cols-[1fr]":"grid-cols-[0fr]";let C;e[26]!==k?(C=ie("grid transition-[grid-template-columns] duration-200 ease-[var(--ease-out-quart)]",k),e[26]=k,e[27]=C):C=e[27];const N=!l,T=l?0:-1,L=!l,M=l?"translate-x-0 opacity-100":"-translate-x-2 opacity-0";let D;e[28]!==M?(D=ie(or,ar,"transition-[transform,opacity] duration-200 ease-[var(--ease-out-quart)] will-change-transform",M),e[28]=M,e[29]=D):D=e[29];let y;e[30]===Symbol.for("react.memo_cache_sentinel")?(y=o.jsx(on,{size:16}),e[30]=y):y=e[30];let R;e[31]!==r||e[32]!==N||e[33]!==T||e[34]!==L||e[35]!==D?(R=o.jsx(Re,{asChild:!0,children:o.jsx("button",{type:"button",onClick:r,disabled:N,tabIndex:T,"aria-hidden":L,className:D,children:y})}),e[31]=r,e[32]=N,e[33]=T,e[34]=L,e[35]=D,e[36]=R):R=e[36];let E;e[37]===Symbol.for("react.memo_cache_sentinel")?(E=o.jsx(De,{side:"bottom",children:"New task"}),e[37]=E):E=e[37];let j;e[38]!==R?(j=o.jsx("div",{className:"overflow-hidden",children:o.jsxs(Me,{delayDuration:300,children:[R,E]})}),e[38]=R,e[39]=j):j=e[39];let I;e[40]!==C||e[41]!==j?(I=o.jsx("div",{className:C,children:j}),e[40]=C,e[41]=j,e[42]=I):I=e[42];let P;return e[43]!==w||e[44]!==I||e[45]!==_?(P=o.jsxs(o.Fragment,{children:[_,w,I]}),e[43]=w,e[44]=I,e[45]=_,e[46]=P):P=e[46],P}function qg(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 Gg(t){const e=$.c(13),{title:s,icon:i,active:r,onClick:n}=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=ie("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=o.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:o.jsx(Yg,{icon:i})}),e[2]=i,e[3]=h):h=e[3];let c;e[4]!==s?(c=o.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]!==n||e[8]!==l||e[9]!==h||e[10]!==c||e[11]!==s?(d=o.jsxs("button",{type:"button",onClick:n,"aria-pressed":r,"aria-label":s,className:l,children:[h,c]}),e[6]=r,e[7]=n,e[8]=l,e[9]=h,e[10]=c,e[11]=s,e[12]=d):d=e[12],d}function Yg(t){const e=$.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let n;return e[0]!==r?(n=o.jsx(r,{className:"size-4"}),e[0]=r,e[1]=n):n=e[1],n}if(s.kind==="url"){let r;return e[2]!==s.src?(r=o.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=o.jsx(ua,{className:"size-4"}),e[4]=i):i=e[4],i}function Xg(t){const e=$.c(13),{overflow:s,onSelect:i}=t,[r,n]=B.useState(!1);let a;e[0]!==i?(a=f=>{n(!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=o.jsx(ds,{asChild:!0,children:o.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:o.jsx(ca,{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=>o.jsx("li",{children:o.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:[o.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:o.jsx(Jg,{icon:m.icon})}),o.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=o.jsx(us,{align:"end",className:"w-56 p-1",children:o.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=o.jsxs(fs,{open:r,onOpenChange:n,children:[h,d]}),e[10]=r,e[11]=d,e[12]=u):u=e[12],u}function Jg(t){const e=$.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let n;return e[0]!==r?(n=o.jsx(r,{className:"size-4"}),e[0]=r,e[1]=n):n=e[1],n}if(s.kind==="url"){let r;return e[2]!==s.src?(r=o.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=o.jsx(ua,{className:"size-4"}),e[4]=i):i=e[4],i}const Zg=6;function $l(t){const e=$.c(20),{virtualMcpId:s,taskId:i}=t,r=Vt();let n;e[0]!==i||e[1]!==s?(n={virtualMcpId:s,taskId:i},e[0]=i,e[1]=s,e[2]=n):n=e[2];const{tabs:a,activeTab:l,mainOpen:h,setActiveTab:c}=Ba(n);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 v=Tc({activeTab:l,mainOpen:h}),x=k=>k.id==="automations"?v:h&&k.id===l,S=a.find(k=>x(k))?.id??null,{visible:g,overflow:w}=qg(a,S,Zg);u=w,d=k=>{const C=a.find(T=>T.id===k),N=S===k&&h;if(ye("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:k,tab_kind:C?.kind??null,was_active:N}),k==="automations"){const T=Rc({activeTab:l,mainOpen:h});r({to:".",search:L=>({...L,main:T}),replace:!0});return}c(k)},f="flex items-center min-w-0 gap-0.5",m=g.map(k=>o.jsx(Gg,{title:k.title,icon:k.icon,active:x(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&&o.jsx(Xg,{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=o.jsxs("div",{className:f,children:[m,_]}),e[16]=f,e[17]=m,e[18]=_,e[19]=p):p=e[19],p}function Qg(t){const e=$.c(12);let s,i,r,n;e[0]!==t?({className:s,orientation:r,decorative:n,...i}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r,e[4]=n):(s=e[1],i=e[2],r=e[3],n=e[4]);const a=r===void 0?"horizontal":r,l=n===void 0?!0:n;let h;e[5]!==s?(h=ie("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=o.jsx(tc,{"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 ev(t){const e=$.c(20),{prNumber:s,disabled:i,send:r}=t;let n;e[0]!==s||e[1]!==r?(n=()=>r(qu({prNumber:s})),e[0]=s,e[1]=r,e[2]=n):n=e[2];const a=n;let l;e[3]!==s||e[4]!==r?(l=()=>r(Vu({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=o.jsx(re,{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=o.jsx(un,{className:"h-3.5 w-3.5"}),e[9]=d):d=e[9];let u;e[10]!==i?(u=o.jsx(Ti,{asChild:!0,children:o.jsx(re,{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=o.jsx(Ri,{align:"end",children:o.jsx($t,{onClick:h,children:"Review"})}),e[12]=h,e[13]=f):f=e[13];let m;e[14]!==u||e[15]!==f?(m=o.jsxs(Ei,{children:[u,f]}),e[14]=u,e[15]=f,e[16]=m):m=e[16];let _;return e[17]!==c||e[18]!==m?(_=o.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[c,m]}),e[17]=c,e[18]=m,e[19]=_):_=e[19],_}function tv(t){if(!(t==="claiming"||t==="ready"||t==="failed"))return Wa[t].short}const sv=new Set(["failure","timed_out","cancelled","action_required"]);function iv(t){return t.status==="completed"&&sv.has(t.conclusion)}function rv(t){return t.status==="queued"||t.status==="in_progress"}function nv(t){const{lifecycle:e,branch:s,pr:i,checks:r,reviews:n,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&&tv(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((n?.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(iv).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(rv);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(n?.draft)return{label:"Mark ready",action:"mark-ready",variant:"default",tooltip:"Mark draft PR ready for review"};const f=n?.unresolvedConversations??0;return f>0?{label:"Address feedback",action:"resolve-comments",variant:"default",tooltip:`${f} unresolved conversation${f===1?"":"s"}`}:n?.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 ov=6e4,av=3e4;function lv(t){const e=$.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=Ve(s),r=t.prNumber??0;let n;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(n={method:"get",owner:t.owner,repo:t.repo,pullNumber:r},e[4]=t.owner,e[5]=t.repo,e[6]=r,e[7]=n):n=e[7];const a=!!t.prNumber;let l;return e[8]!==i||e[9]!==n||e[10]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:n,enabled:a,refetchInterval:ov,refetchIntervalInBackground:!1,staleTime:av,select:cv},e[8]=i,e[9]=n,e[10]=a,e[11]=l):l=e[11],Hs(l)}function cv(t){const e=Us(t);if(!e)return null;const s=e.mergeable_state??"unknown",i=!!(e.draft??!1),r=Number(e.review_comments??0),n=s==="blocked"&&r>0?r:0;return{draft:i,mergeableState:s,unresolvedConversations:n,missingRequiredApprovals:s==="blocked"&&n===0}}function hv(t){const e=$.c(44),{virtualMcpId:s}=t,{org:i}=ve(),r=yt(s),{currentBranch:n}=Pt(),a=Yt(),l=r?.metadata?.githubRepo??null,{lifecycle:h,branch:c,phase:d}=_s(),u=l?.connectionId??"",f=l?.owner??"",m=l?.name??"",_=n??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 v=$a(p),x=v.data??null,b=l?.connectionId??"",S=l?.owner??"",g=l?.name??"",w=x&&x.state==="open"?x.number:null;let k;e[7]!==i.id||e[8]!==i.slug||e[9]!==b||e[10]!==S||e[11]!==g||e[12]!==w?(k={orgId:i.id,orgSlug:i.slug,connectionId:b,owner:S,repo:g,prNumber:w},e[7]=i.id,e[8]=i.slug,e[9]=b,e[10]=S,e[11]=g,e[12]=w,e[13]=k):k=e[13];const C=Fa(k),N=l?.connectionId??"",T=l?.owner??"",L=l?.name??"",M=x&&x.state==="open"?x.number:null;let D;e[14]!==i.id||e[15]!==i.slug||e[16]!==N||e[17]!==T||e[18]!==L||e[19]!==M?(D={orgId:i.id,orgSlug:i.slug,connectionId:N,owner:T,repo:L,prNumber:M},e[14]=i.id,e[15]=i.slug,e[16]=N,e[17]=T,e[18]=L,e[19]=M,e[20]=D):D=e[20];const y=lv(D);if(!l?.connectionId||!n)return null;let R;e[21]!==c||e[22]!==C.data||e[23]!==d||e[24]!==h||e[25]!==x||e[26]!==v.isPending||e[27]!==y.data?(R=nv({lifecycle:h,branch:c,claimPhase:d,pr:x,checks:C.data??[],reviews:y.data??null,loading:v.isPending}),e[21]=c,e[22]=C.data,e[23]=d,e[24]=h,e[25]=x,e[26]=v.isPending,e[27]=y.data,e[28]=R):R=e[28];const E=R;let j;e[29]!==a?(j=K=>a.sendMessage({parts:[{type:"text",text:K}]}),e[29]=a,e[30]=j):j=e[30];const I=j,P=a.isStreaming;let z;e[31]!==n||e[32]!==E||e[33]!==P||e[34]!==x||e[35]!==I?(z=K=>{if(!P)switch(K){case"commit-and-push":{I(Ou({branch:n}));return}case"create-pr":{I($u({branch:n}));return}case"reopen":{x&&I(zu({prNumber:x.number}));return}case"rebase":{I(Fu({branch:n}));return}case"fix-checks":{x&&I(Wu({prNumber:x.number,failingChecks:E.meta?.failingChecks??[]}));return}case"mark-ready":{x&&I(Uu({prNumber:x.number}));return}case"resolve-comments":{x&&I(Ku({prNumber:x.number}));return}case"merge-split":return}},e[31]=n,e[32]=E,e[33]=P,e[34]=x,e[35]=I,e[36]=z):z=e[36];const U=z;let W;e[37]===Symbol.for("react.memo_cache_sentinel")?(W=o.jsx(Qg,{orientation:"vertical",className:"mx-2 data-[orientation=vertical]:h-5"}),e[37]=W):W=e[37];const H=x?.number;let G;return e[38]!==E||e[39]!==P||e[40]!==U||e[41]!==I||e[42]!==H?(G=o.jsxs(o.Fragment,{children:[W,o.jsx(dv,{button:E,isStreaming:P,onActivate:U,prNumber:H,send:I})]}),e[38]=E,e[39]=P,e[40]=U,e[41]=I,e[42]=H,e[43]=G):G=e[43],G}function dv(t){const e=$.c(21),{button:s,isStreaming:i}=t,r=!!s.disabled||i,n=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=o.jsx(ev,{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]!==n?(u=o.jsx(Ko,{label:n,children:d}),e[4]=d,e[5]=n,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?o.jsx(Mh,{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=o.jsxs(re,{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]!==n?(c=o.jsx(Ko,{label:n,children:h}),e[18]=h,e[19]=n,e[20]=c):c=e[20],c}function Ko(t){const e=$.c(9),{label:s,children:i}=t;if(!s){let l;return e[0]!==i?(l=o.jsx(o.Fragment,{children:i}),e[0]=i,e[1]=l):l=e[1],l}let r;e[2]!==i?(r=o.jsx(Re,{asChild:!0,children:o.jsx("span",{children:i})}),e[2]=i,e[3]=r):r=e[3];let n;e[4]!==s?(n=o.jsx(De,{children:s}),e[4]=s,e[5]=n):n=e[5];let a;return e[6]!==r||e[7]!==n?(a=o.jsx(th,{children:o.jsxs(Me,{children:[r,n]})}),e[6]=r,e[7]=n,e[8]=a):a=e[8],a}function uv(t){const e=$.c(2),{virtualMcp:s}=t;if(!!!(s.metadata?.githubRepo??null)?.connectionId)return null;let n;return e[0]!==s.id?(n=o.jsx(cr.Right,{children:o.jsx(hv,{virtualMcpId:s.id})}),e[0]=s.id,e[1]=n):n=e[1],n}function fv(t,e){const s=$.c(40),{org:i,locator:r}=ve();let n;s[0]!==i.id||s[1]!==i.slug?(n={connectionId:Gt,orgId:i.id,orgSlug:i.slug},s[0]=i.id,s[1]=i.slug,s[2]=n):n=s[2];const a=Ve(n),l=hs();let h;s[3]!==t||s[4]!==i.id?(h=Fs.ensureTask(i.id,t),s[3]=t,s[4]=i.id,s[5]=h):h=s[5];let c;s[6]!==a||s[7]!==t?(c=async()=>(await a.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}})).structuredContent?.item??null,s[6]=a,s[7]=t,s[8]=c):c=s[8];const d=t.length>0;let u;s[9]!==h||s[10]!==c||s[11]!==d?(u={queryKey:h,queryFn:c,enabled:d,retry:!1,refetchOnWindowFocus:!1},s[9]=h,s[10]=c,s[11]=d,s[12]=u):u=s[12];const f=Qr(u);let m;s[13]!==a||s[14]!==e?(m=async g=>{const w=await a.callTool({name:"COLLECTION_THREADS_CREATE",arguments:{data:{id:g,virtual_mcp_id:e}}});if(w.isError){const C=w.content,N=Array.isArray(C)&&C[0]&&typeof C[0]=="object"?C[0].text??"Create failed":"Create failed";throw new Error(N)}return w.structuredContent.item},s[13]=a,s[14]=e,s[15]=m):m=s[15];let _;s[16]!==r||s[17]!==i.id||s[18]!==f||s[19]!==l?(_=g=>{l.invalidateQueries({predicate:w=>w.queryKey[1]===i.id&&w.queryKey[3]==="collection"&&w.queryKey[4]==="THREADS"}),Bh(l,r,g),f.refetch()},s[16]=r,s[17]=i.id,s[18]=f,s[19]=l,s[20]=_):_=s[20];let p;s[21]!==m||s[22]!==_?(p={mutationFn:m,onSuccess:_},s[21]=m,s[22]=_,s[23]=p):p=s[23];const v=Yo(p);let x,b;if(s[24]!==v||s[25]!==t||s[26]!==f.data||s[27]!==f.isSuccess?(x=()=>{t&&(!f.isSuccess||f.data||v.isPending||v.variables!==t&&v.mutate(t))},b=[t,f.isSuccess,f.data,v],s[24]=v,s[25]=t,s[26]=f.data,s[27]=f.isSuccess,s[28]=x,s[29]=b):(x=s[28],b=s[29]),B.useEffect(x,b),!t){let g;return s[30]===Symbol.for("react.memo_cache_sentinel")?(g={status:"ready",task:null},s[30]=g):g=s[30],g}if(f.isLoading){let g;return s[31]===Symbol.for("react.memo_cache_sentinel")?(g={status:"loading"},s[31]=g):g=s[31],g}if(f.isError){const g=f.error;let w;return s[32]!==g?(w={status:"error",error:g},s[32]=g,s[33]=w):w=s[33],w}if(f.isSuccess&&f.data){let g;return s[34]!==f.data?(g={status:"ready",task:f.data},s[34]=f.data,s[35]=g):g=s[35],g}if(v.isPending||f.isSuccess&&!f.data){let g;return s[36]===Symbol.for("react.memo_cache_sentinel")?(g={status:"creating"},s[36]=g):g=s[36],g}if(v.isError){let g;return s[37]!==v.error?(g={status:"error",error:v.error},s[37]=v.error,s[38]=g):g=s[38],g}let S;return s[39]===Symbol.for("react.memo_cache_sentinel")?(S={status:"loading"},s[39]=S):S=s[39],S}const ts=B.createContext(null);function zl(){return B.use(ts)}function Vo(t){const e=$.c(6),{children:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.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=o.jsx(Se.Skeleton,{}),e[1]=r):r=e[1];let n;e[2]!==s?(n=s??o.jsx(Pa,{}),e[2]=s,e[3]=n):n=e[3];let a;return e[4]!==n?(a=o.jsx(Rt,{fallback:i,children:o.jsx(B.Suspense,{fallback:r,children:n})}),e[4]=n,e[5]=a):a=e[5],a}function qo(t){const e=$.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],B.useLayoutEffect(r),null}function mv(t){const e=$.c(23),{onOpenSidebar:s,virtualMcpId:i,taskId:r,mainOpen:n,onToggleMain:a,onNewTask:l}=t;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=o.jsx(gc,{size:20}),e[0]=h):h=e[0];let c;e[1]!==s?(c=o.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=o.jsx("div",{className:"flex-1 min-w-0 overflow-x-auto [scrollbar-width:none]",children:o.jsx($l,{virtualMcpId:i,taskId:r})}),e[3]=r,e[4]=i,e[5]=d):d=e[5];const u=!n,f=n?"text-foreground/60 hover:bg-accent hover:text-foreground":"bg-accent text-foreground";let m;e[6]!==f?(m=ie("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")?(_=o.jsx(da,{size:16}),e[8]=_):_=e[8];let p;e[9]!==a||e[10]!==u||e[11]!==m?(p=o.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 v;e[13]===Symbol.for("react.memo_cache_sentinel")?(v=o.jsx(on,{size:16}),e[13]=v):v=e[13];let x;e[14]!==l?(x=o.jsx("button",{type:"button",onClick:l,className:"flex size-7 shrink-0 items-center justify-center rounded-md text-foreground/60 hover:bg-accent hover:text-foreground transition-colors",title:"New task",children:v}),e[14]=l,e[15]=x):x=e[15];let b;e[16]!==x||e[17]!==p?(b=o.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[p,x]}),e[16]=x,e[17]=p,e[18]=b):b=e[18];let S;return e[19]!==b||e[20]!==c||e[21]!==d?(S=o.jsxs("div",{className:"shrink-0 flex items-center gap-1 px-2 h-12 bg-background border-b border-border",children:[c,d,b]}),e[19]=b,e[20]=c,e[21]=d,e[22]=S):S=e[22],S}function Go(t){const e=$.c(16),{virtualMcpId:s,hasActiveGithubRepo:i,vmMap:r,children:n}=t,{org:a}=ve(),{currentBranch:l}=Pt(),{data:h}=Zr.useSession(),c=h?.user?.id;let d;e[0]!==a.id||e[1]!==a.slug?(d={connectionId:Gt,orgId:a.id,orgSlug:a.slug},e[0]=a.id,e[1]=a.slug,e[2]=d):d=e[2];const u=Ve(d),{mutate:f}=Aa(u);let m;e[3]===Symbol.for("react.memo_cache_sentinel")?(m=new Set,e[3]=m):m=e[3];const _=B.useRef(m);let p,v;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:_v}))}},v=[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]=v):(p=e[10],v=e[11]),B.useEffect(p,v);const x=l??null;let b;return e[12]!==n||e[13]!==x||e[14]!==s?(b=o.jsx(Cf,{virtualMcpId:s,branch:x,children:n}),e[12]=n,e[13]=x,e[14]=s,e[15]=b):b=e[15],b}function _v(t){console.error("[auto-start-vm] failed:",t)}function pv(){const t=$.c(115),e=fa(),s=Vt(),{org:i}=ve(),r=hc()?.tasksOpen??!1;sh(i.slug);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={strict:!1},t[0]=n):n=t[0];const a=sc(n),l=a.org??"";let h;t[1]===Symbol.for("react.memo_cache_sentinel")?(h={strict:!1},t[1]=h):h=t[1];const c=Jo(h);let d;t[2]!==i.id||t[3]!==c.virtualmcpid?(d=c.virtualmcpid??sa(i.id).id,t[2]=i.id,t[3]=c.virtualmcpid,t[4]=d):d=t[4];const u=d,f=fv(a.taskId??"",u),m=yt(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 v=p;let x;t[7]!==m?(x=m&&Ht(m),t[7]=m,t[8]=x):x=t[8];const b=!!x;let S;t[9]!==l||t[10]!==u?(S={virtualMcpId:u,orgSlug:l,isAgentRoute:!0},t[9]=l,t[10]=u,t[11]=S):S=t[11];const g=dc(v,S),{setOpenMobile:w,openMobile:k}=Jc(),C=w,N=B.useRef(null);let T,L;t[12]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{const J=ee=>{Xc(ee)&&ee.shiftKey&&ee.code==="KeyS"&&!ee.repeat&&(ee.preventDefault(),N.current?.())};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)},L=[],t[12]=T,t[13]=L):(T=t[12],L=t[13]),B.useEffect(T,L);const M=u;let D;t[14]!==m||t[15]!==u?(D={virtualMcpId:u,entity:m},t[14]=m,t[15]=u,t[16]=D):D=t[16];const y=D;if(f.status==="creating"||f.status==="loading"){let J;t[17]===Symbol.for("react.memo_cache_sentinel")?(J=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsxs("div",{className:"flex h-full items-center justify-center bg-background card-shadow rounded-[0.75rem] text-sm text-muted-foreground",children:[o.jsx(He,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[17]=J):J=t[17];let ee;return t[18]!==y?(ee=o.jsx(ts,{value:y,children:J}),t[18]=y,t[19]=ee):ee=t[19],ee}if(f.status==="error"){let J;t[20]===Symbol.for("react.memo_cache_sentinel")?(J=o.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[20]=J):J=t[20];let ee;t[21]!==f.error.message?(ee=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.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,o.jsx("div",{className:"text-muted-foreground",children:f.error.message})]})}),t[21]=f.error.message,t[22]=ee):ee=t[22];let A;return t[23]!==y||t[24]!==ee?(A=o.jsx(ts,{value:y,children:ee}),t[23]=y,t[24]=ee,t[25]=A):A=t[25],A}if(!m){let J;t[26]===Symbol.for("react.memo_cache_sentinel")?(J=o.jsx(tn,{size:48,className:"text-muted-foreground"}),t[26]=J):J=t[26];const ee=`The agent "${u}" does not exist in this organization.`;let A;t[27]!==s||t[28]!==l?(A=o.jsx(re,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:l}}),children:"Go to organization home"}),t[27]=s,t[28]=l,t[29]=A):A=t[29];let X;t[30]!==ee||t[31]!==A?(X=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsx("div",{className:"flex flex-col h-full bg-background overflow-hidden card-shadow rounded-[0.75rem]",children:o.jsx(pi,{image:J,title:"Agent not found",description:ee,actions:A})})}),t[30]=ee,t[31]=A,t[32]=X):X=t[32];let Q;return t[33]!==y||t[34]!==X?(Q=o.jsx(ts,{value:y,children:X}),t[33]=y,t[34]=X,t[35]=Q):Q=t[35],Q}if(e){let J;t[36]===Symbol.for("react.memo_cache_sentinel")?(J=o.jsx(Zc,{className:"sr-only",children:"Navigation"}),t[36]=J):J=t[36];let ee;t[37]!==C?(ee=o.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:o.jsx(Gc,{onClose:()=>C(!1)})}),t[37]=C,t[38]=ee):ee=t[38];let A;t[39]===Symbol.for("react.memo_cache_sentinel")?(A=o.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:o.jsx(Yc,{})}),t[39]=A):A=t[39];let X;t[40]!==ee?(X=o.jsxs(Qc,{side:"left",hideCloseButton:!0,className:"w-[calc(100vw-3rem)] sm:max-w-md! p-0",children:[J,o.jsxs("div",{className:"flex h-full",children:[ee,A]})]}),t[40]=ee,t[41]=X):X=t[41];let Q;t[42]!==k||t[43]!==C||t[44]!==X?(Q=o.jsx(eh,{open:k,onOpenChange:C,children:X}),t[42]=k,t[43]=C,t[44]=X,t[45]=Q):Q=t[45];const F=Q,V=m?.metadata?.vmMap;let ne;t[46]!==g.createNewTask?(ne=o.jsx(qo,{onNewTaskRef:N,createNewTask:g.createNewTask}),t[46]=g.createNewTask,t[47]=ne):ne=t[47];let he;t[48]!==C?(he=()=>C(!0),t[48]=C,t[49]=he):he=t[49];let ce;t[50]!==M||t[51]!==g.createNewTask||t[52]!==g.mainOpen||t[53]!==g.taskId||t[54]!==g.toggleMain||t[55]!==he?(ce=o.jsx(mv,{onOpenSidebar:he,virtualMcpId:M,taskId:g.taskId,mainOpen:g.mainOpen,onToggleMain:g.toggleMain,onNewTask:g.createNewTask}),t[50]=M,t[51]=g.createNewTask,t[52]=g.mainOpen,t[53]=g.taskId,t[54]=g.toggleMain,t[55]=he,t[56]=ce):ce=t[56];let de;t[57]===Symbol.for("react.memo_cache_sentinel")?(de=o.jsx(Se.Skeleton,{}),t[57]=de):de=t[57];let fe;t[58]!==M||t[59]!==g.mainOpen||t[60]!==g.taskId?(fe=o.jsx(B.Suspense,{fallback:de,children:o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:g.mainOpen?o.jsx(Rt,{fallback:o.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Something went wrong. Try refreshing."}),children:o.jsx(B.Suspense,{fallback:o.jsx("div",{className:"h-full flex items-center justify-center",children:o.jsx(He,{size:20,className:"animate-spin text-muted-foreground"})}),children:o.jsx(Ol,{taskId:g.taskId,virtualMcpId:M})})}):o.jsx(Vo,{})})}),t[58]=M,t[59]=g.mainOpen,t[60]=g.taskId,t[61]=fe):fe=t[61];let Be;t[62]!==g.taskId||t[63]!==fe?(Be=o.jsx(Se.ActiveTaskProvider,{taskId:g.taskId,children:fe},g.taskId),t[62]=g.taskId,t[63]=fe,t[64]=Be):Be=t[64];let Ne;t[65]!==b||t[66]!==F||t[67]!==V||t[68]!==ne||t[69]!==ce||t[70]!==Be||t[71]!==u?(Ne=o.jsxs(Go,{virtualMcpId:u,hasActiveGithubRepo:b,vmMap:V,children:[ne,ce,Be,F]}),t[65]=b,t[66]=F,t[67]=V,t[68]=ne,t[69]=ce,t[70]=Be,t[71]=u,t[72]=Ne):Ne=t[72];let je;t[73]!==M||t[74]!==Ne?(je=o.jsx("div",{className:"flex flex-col flex-1 bg-background min-h-0",children:o.jsx(Se.Provider,{virtualMcpId:M,children:Ne},M)}),t[73]=M,t[74]=Ne,t[75]=je):je=t[75];let Je;return t[76]!==y||t[77]!==je?(Je=o.jsx(ts,{value:y,children:je}),t[76]=y,t[77]=je,t[78]=Je):Je=t[78],Je}const R=r?void 0:g.createNewTask;let E;t[79]!==g.chatOpen||t[80]!==g.toggleChat||t[81]!==R?(E=o.jsx(cr.Toggles,{children:o.jsx(Vg,{chatOpen:g.chatOpen,toggleChat:g.toggleChat,onNewTask:R})}),t[79]=g.chatOpen,t[80]=g.toggleChat,t[81]=R,t[82]=E):E=t[82];let j;t[83]!==g.taskId||t[84]!==u?(j=o.jsx(cr.Tabs,{children:o.jsx($l,{virtualMcpId:u,taskId:g.taskId})}),t[83]=g.taskId,t[84]=u,t[85]=j):j=t[85];const I=m?.metadata?.vmMap;let P;t[86]!==g.createNewTask?(P=o.jsx(qo,{onNewTaskRef:N,createNewTask:g.createNewTask}),t[86]=g.createNewTask,t[87]=P):P=t[87];let z;t[88]!==m?(z=o.jsx(uv,{virtualMcp:m}),t[88]=m,t[89]=z):z=t[89];let U;t[90]===Symbol.for("react.memo_cache_sentinel")?(U=o.jsx(Se.Skeleton,{}),t[90]=U):U=t[90];let W;t[91]===Symbol.for("react.memo_cache_sentinel")?(W=o.jsx(Vo,{}),t[91]=W):W=t[91];let H;t[92]!==g.chatOpen||t[93]!==g.mainOpen||t[94]!==g.taskId||t[95]!==u?(H=o.jsx(B.Suspense,{fallback:U,children:o.jsx(Kg,{virtualMcpId:u,taskId:g.taskId,chatOpen:g.chatOpen,mainOpen:g.mainOpen,chatContent:W})}),t[92]=g.chatOpen,t[93]=g.mainOpen,t[94]=g.taskId,t[95]=u,t[96]=H):H=t[96];let G;t[97]!==g.taskId||t[98]!==z||t[99]!==H?(G=o.jsxs(Se.ActiveTaskProvider,{taskId:g.taskId,children:[z,H]},g.taskId),t[97]=g.taskId,t[98]=z,t[99]=H,t[100]=G):G=t[100];let K;t[101]!==b||t[102]!==I||t[103]!==P||t[104]!==G||t[105]!==u?(K=o.jsxs(Go,{virtualMcpId:u,hasActiveGithubRepo:b,vmMap:I,children:[P,G]}),t[101]=b,t[102]=I,t[103]=P,t[104]=G,t[105]=u,t[106]=K):K=t[106];let se;t[107]!==M||t[108]!==j||t[109]!==K?(se=o.jsxs(Se.Provider,{virtualMcpId:M,children:[j,K]},M),t[107]=M,t[108]=j,t[109]=K,t[110]=se):se=t[110];let Y;return t[111]!==y||t[112]!==E||t[113]!==se?(Y=o.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:o.jsxs(ts,{value:y,children:[E,se]})}),t[111]=y,t[112]=E,t[113]=se,t[114]=Y):Y=t[114],Y}function gv(){const t=$.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(B.Suspense,{fallback:o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(He,{size:20,className:"animate-spin text-muted-foreground"})}),children:o.jsx(pv,{})}),t[0]=e):e=t[0],e}const A1=Object.freeze(Object.defineProperty({__proto__:null,default:gv,useInsetContext:zl},Symbol.toStringTag,{value:"Module"}));export{df as e,A1 as i,lf as u};
|
|
186
|
+
`);if(V.trim()){y(!0);try{A(),ye("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:V.length}),await _(["studio-automation-manager"]),f(!0),await m({tiptapDoc:La({managerAgentId:ia.AUTOMATION_MANAGER(n.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:V})})}finally{y(!1)}}},z=e.models?.tier??"smart",U=Zo({defaultValues:{name:e.name,active:e.active,tier:z}}),W=U.watch("active"),[H,G]=B.useReducer(Pg,null),K=()=>{H!==null&&(ye("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(H.fields),save_count:H.saveCount,edit_duration_ms:Date.now()-H.start}),G({type:"reset"}))},se=async()=>{const F=U.control._formState.dirtyFields,V=Object.keys(F);if(V.length===0&&!j)return!0;const ne=U.getValues(),he=U.control._defaultValues;U.reset(ne,{keepValues:!0});const ce=j;I(!1);const de={id:t,name:ne.name,active:ne.active,models:{tier:ne.tier},messages:_c(b),temperature:0};try{await a.mutateAsync(de)}catch{return U.reset(he,{keepValues:!0}),ce&&I(!0),!1}const fe=[...V];return ce&&fe.push("messages"),G({type:"accumulate",now:Date.now(),fields:fe}),ee(),!0},{schedule:Y,flush:J}=gi({save:se}),{schedule:ee,flush:A}=gi({delayMs:3e4,save:async()=>K()});B.useEffect(()=>{const F=U.watch(()=>Y());return()=>F.unsubscribe()},[]);const X=F=>{if(S(F),!R){E(!0);return}I(!0),Y()},Q=async()=>{ye("automation_test_clicked",{automation_id:t,agent_id:r});const F=await J();if(A(),!F)return;if(!b){me.error("No instructions configured for this automation");return}u(U.getValues("tier")),f(!0),v({...p,toolApprovalLevel:"auto"});const V=jn(b);d({message:{tiptapDoc:b,parts:V},virtualMcpId:r||void 0})};return o.jsxs(o.Fragment,{children:[s&&o.jsx("div",{className:"flex items-center pb-4 shrink-0",children:o.jsxs(re,{variant:"ghost",size:"sm",onClick:s,children:[o.jsx(Ma,{size:14}),"Back to list"]})}),o.jsxs("div",{className:"flex flex-col gap-8",children:[o.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsx(mt,{control:U.control,name:"name",render:({field:F})=>o.jsx(Xt,{...F,placeholder:"Automation name",className:"border border-transparent shadow-none px-0 text-lg font-medium h-auto focus-visible:ring-0 focus-visible:border-border bg-transparent flex-1",style:{boxShadow:"none"}})}),i&&o.jsx(re,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:i,children:o.jsx(fr,{size:14})})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(mt,{control:U.control,name:"active",render:({field:F})=>o.jsx(ur,{checked:F.value,onCheckedChange:V=>{F.onChange(V),J()},className:"cursor-pointer"})}),o.jsx("span",{className:"text-sm text-muted-foreground",children:W?"Active":"Inactive"}),o.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),o.jsx(pa,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),o.jsxs("div",{className:"flex flex-col gap-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),o.jsx(Rg,{automationId:t,open:g,onOpenChange:w,onCustomSelect:()=>{C(!0),M(!1),T("")},onEventSelect:()=>{M(!0),C(!1)}})]}),e.triggers.length===0&&!k?o.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:o.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",o.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>w(!0),children:"Add a starter"})," ","to get going."]})}):o.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(F=>o.jsx(Dg,{trigger:F,automationId:t,connectionName:F.connection_id?c.get(F.connection_id):void 0},F.id))}),k&&o.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[o.jsx(Ps,{size:14,className:"text-muted-foreground shrink-0"}),o.jsx("input",{type:"text",value:N,onChange:F=>T(F.target.value),onBlur:async()=>{const F=N.trim();if(!(!F||!As(F)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:F}),ye("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),me.success("Starter added"),C(!1),T("")}catch{me.error("Failed to add starter")}},onKeyDown:async F=>{const V=N.trim();F.key==="Enter"&&V&&As(V)&&F.target.blur(),F.key==="Escape"&&(C(!1),T(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),N&&!As(N)&&o.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&o.jsx(He,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),o.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:()=>{C(!1),T("")},children:o.jsx(as,{size:13})})]}),L&&o.jsx(B.Suspense,{fallback:o.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[o.jsx(He,{size:13,className:"animate-spin text-muted-foreground"}),o.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:o.jsx(Ig,{automationId:t,onDone:()=>M(!1)})})]}),o.jsxs("div",{className:"flex flex-col gap-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),o.jsxs(re,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:D||!b,onClick:P,children:[o.jsx(Ra,{size:13}),"Improve"]})]}),o.jsx(oc,{tiptapDoc:b,setTiptapDoc:X,placeholder:"What should this automation do?",children:o.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[o.jsx(ac,{virtualMcpId:r||null,className:"max-h-[45vh]"}),o.jsxs("div",{className:"flex items-center justify-end gap-1.5 p-2.5",children:[o.jsx(lc,{tier:U.watch("tier"),onSelect:F=>U.setValue("tier",F,{shouldDirty:!0})}),o.jsxs(Me,{children:[o.jsx(Re,{asChild:!0,children:o.jsxs(re,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:Q,disabled:!r,children:[o.jsx(Sc,{size:16}),"Test"]})}),o.jsx(De,{children:"Test Automation"})]})]})]})})]})]})]})}function $g(t){const e=$.c(5),{tabId:s}=t;let i;e[0]!==s?(i=ra(s),e[0]=s,e[1]=i):i=e[1];const r=i;if(!r)return null;let n;e[2]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(He,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=n):n=e[2];let a;return e[3]!==r.id?(a=o.jsx(at,{children:o.jsx(at.Content,{children:o.jsx(at.Body,{children:o.jsx(B.Suspense,{fallback:n,children:o.jsx(zg,{id:r.id})})})})}),e[3]=r.id,e[4]=a):a=e[4],a}function zg(t){const e=$.c(8),{id:s}=t,i=Vt(),{data:r,isLoading:n}=zh(s);let a;e[0]!==i?(a=()=>i({to:".",search:Fg,replace:!0}),e[0]=i,e[1]=a):a=e[1];const l=a;if(n){let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(He,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=c):c=e[2],c}if(!r){let c;return e[3]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=c):c=e[3],c}let h;return e[4]!==r||e[5]!==s||e[6]!==l?(h=o.jsx(Og,{automationId:s,automation:r,onBack:l}),e[4]=r,e[5]=s,e[6]=l,e[7]=h):h=e[7],h}function Fg(t){return{...t,main:"automations"}}function Hg(t){const e=$.c(20),{virtualMcpId:s}=t,i=Vt(),{data:r}=Fh(s),n=r===void 0?[]:r,{create:a}=Ws(),[l,h]=B.useState(""),c=l.toLowerCase(),d=n.filter(L=>L.name.toLowerCase().includes(c));let u;e[0]!==i?(u=L=>i({to:".",search:M=>({...M,main:"automation:"+L}),replace:!0}),e[0]=i,e[1]=u):u=e[1];const f=u,m=async()=>{if(a.isPending)return;ye("automation_new_clicked",{virtual_mcp_id:s,existing_count:n.length});const L=await a.mutateAsync(Wh(s));f(L.id)},_=at,p=at,v=at;let x;e[2]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx(at.Title,{children:"Automations"}),e[2]=x):x=e[2];const b=n.length>0&&o.jsx(Uh,{value:l,onChange:h,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let S;e[3]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(ls,{size:14}),e[3]=S):S=e[3];let g;e[4]!==a.isPending||e[5]!==m?(g=o.jsxs(re,{size:"sm",onClick:m,disabled:a.isPending,children:[S,"New automation"]}),e[4]=a.isPending,e[5]=m,e[6]=g):g=e[6];let w;e[7]!==b||e[8]!==g?(w=o.jsxs("div",{className:"flex flex-col gap-6",children:[x,o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[b,g]})]}),e[7]=b,e[8]=g,e[9]=w):w=e[9];const k=n.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(pi,{image:o.jsx(Bs,{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:o.jsxs(re,{size:"sm",onClick:m,disabled:a.isPending,children:[o.jsx(ls,{size:14}),"New automation"]})})}):d.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(pi,{image:o.jsx(Bs,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${l}"`})}):o.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:d.map(L=>o.jsx(Hh,{automation:L,onClick:()=>f(L.id)},L.id))});let C;e[10]!==k||e[11]!==v.Body||e[12]!==w?(C=o.jsxs(v.Body,{children:[w,k]}),e[10]=k,e[11]=v.Body,e[12]=w,e[13]=C):C=e[13];let N;e[14]!==C||e[15]!==p.Content?(N=o.jsx(p.Content,{children:C}),e[14]=C,e[15]=p.Content,e[16]=N):N=e[16];let T;return e[17]!==_||e[18]!==N?(T=o.jsx(_,{children:N}),e[17]=_,e[18]=N,e[19]=T):T=e[19],T}function Wg(t){const e=$.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(He,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx(B.Suspense,{fallback:i,children:o.jsx(Hg,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}const Wo=B.lazy(()=>Qo(()=>import("./project-app-view-CsMPFfW3.js"),__vite__mapDeps([119,1,2,74,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,75,76,6,77,47,78,79,51,63,64,50,65,66,54,67,68,69,70,71,72,73,61,62])).then(t=>({default:t.AppViewContent})));function Ol(t){const e=$.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:n,layoutTabs:a,expandedTools:l,automationTabParsed:h}=Ba(r);if(jc(n)){let _;return e[3]!==i?(_=o.jsx(Kn,{virtualMcpId:i}),e[3]=i,e[4]=_):_=e[4],_}if(n==="git"){let _;return e[5]!==i?(_=o.jsx(nf,{virtualMcpId:i}),e[5]=i,e[6]=_):_=e[6],_}if(n==="automations"){let _;return e[7]!==i?(_=o.jsx(Wg,{virtualMcpId:i}),e[7]=i,e[8]=_):_=e[8],_}if(n==="preview"){let _;return e[9]!==i?(_=o.jsx(Cg,{virtualMcpId:i}),e[9]=i,e[10]=_):_=e[10],_}if(h){let _;return e[11]!==n?(_=o.jsx($g,{tabId:n}),e[11]=n,e[12]=_):_=e[12],_}let c;e[13]!==n?(c=Ec(n),e[13]=n,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 S;e[19]!==d.connectionId||e[20]!==d.toolName?(S=g=>g.appId===d.connectionId&&g.toolName===d.toolName,e[19]=d.connectionId,e[20]=d.toolName,e[21]=S):S=e[21],_=l.find(S),e[15]=l,e[16]=d.connectionId,e[17]=d.toolName,e[18]=_}else _=e[18];const p=_;let v;e[22]===Symbol.for("react.memo_cache_sentinel")?(v=o.jsx("div",{className:"h-full w-full flex items-center justify-center",children:o.jsx(He,{size:20,className:"animate-spin text-muted-foreground"})}),e[22]=v):v=e[22];const x=p?.args;let b;return e[23]!==n||e[24]!==d.connectionId||e[25]!==d.toolName||e[26]!==x?(b=o.jsx(B.Suspense,{fallback:v,children:o.jsx(Wo,{connectionId:d.connectionId,toolName:d.toolName,args:x},n)}),e[23]=n,e[24]=d.connectionId,e[25]=d.toolName,e[26]=x,e[27]=b):b=e[27],b}let u;if(e[28]!==n||e[29]!==a){let _;e[31]!==n?(_=p=>p.id===n,e[31]=n,e[32]=_):_=e[32],u=a.find(_),e[28]=n,e[29]=a,e[30]=u}else u=e[30];const f=u;if(f){let _;e[33]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx("div",{className:"h-full w-full flex items-center justify-center",children:o.jsx(He,{size:20,className:"animate-spin text-muted-foreground"})}),e[33]=_):_=e[33];let p;return e[34]!==n||e[35]!==f.id||e[36]!==f.view.appId||e[37]!==f.view.args?(p=o.jsx(B.Suspense,{fallback:_,children:o.jsx(Wo,{connectionId:f.view.appId,toolName:f.id,args:f.view.args},n)}),e[34]=n,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=o.jsx(Kn,{virtualMcpId:i}),e[39]=i,e[40]=m):m=e[40],m}function Ug(t){const e=$.c(10),{children:s,defaultSize:i,chatOpen:r}=t,[,n]=B.useTransition();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=ta.decoChatPanelWidth(),e[0]=a):a=e[0];const[l,h]=ea(a,45),c=i>0&&i<100?l:i;let d;e[1]!==h?(d=p=>n(()=>{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=ie("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?(_=o.jsx(ma,{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 Kg(t){const e=$.c(31),{virtualMcpId:s,taskId:i,chatOpen:r,mainOpen:n,chatContent:a}=t;let l;e[0]!==r||e[1]!==n?(l=Nn(r,n),e[0]=r,e[1]=n,e[2]=l):l=e[2];const h=l;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=ta.decoChatPanelWidth(),e[3]=c):c=e[3];const[d]=ea(c,45),u=B.useRef(null);let f,m;e[4]!==r||e[5]!==n||e[6]!==d?(f=()=>{const L=u.current;if(!L)return;const M=Nn(r,n),D=M.chat>0&&M.chat<100?d:M.chat,y=M.chat>0&&M.chat<100?100-d:M.main;L.setLayout([D,y])},m=[r,n,d],e[4]=r,e[5]=n,e[6]=d,e[7]=f,e[8]=m):(f=e[7],m=e[8]),B.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 v;e[10]!==a?(v=a??o.jsx(Pa,{}),e[10]=a,e[11]=v):v=e[11];let x;e[12]!==v?(x=o.jsx("div",{className:"h-full p-0.5 pt-0.25",children:o.jsx("div",{className:"h-full bg-background rounded-[0.75rem] overflow-hidden card-shadow",children:v})}),e[12]=v,e[13]=x):x=e[13];let b;e[14]!==r||e[15]!==h.chat||e[16]!==x?(b=o.jsx(Ug,{defaultSize:h.chat,chatOpen:r,children:x}),e[14]=r,e[15]=h.chat,e[16]=x,e[17]=b):b=e[17];let S;e[18]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(ah,{className:"bg-sidebar"}),e[18]=S):S=e[18];const g=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=ie("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=o.jsx("div",{className:"h-full p-0.5 pt-0.25",children:o.jsx("div",{className:k,children:o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:o.jsx(Rt,{children:o.jsx(Ol,{taskId:i,virtualMcpId:s})})})})}),e[21]=i,e[22]=s,e[23]=C):C=e[23];let N;e[24]!==h.main||e[25]!==C?(N=o.jsx(ma,{className:"min-w-0 flex flex-col",order:2,defaultSize:g,style:w,collapsible:!0,collapsedSize:0,minSize:20,children:C}),e[24]=h.main,e[25]=C,e[26]=N):N=e[26];let T;return e[27]!==N||e[28]!==_||e[29]!==b?(T=o.jsxs(lh,{ref:u,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:p,children:[b,S,N]},_),e[27]=N,e[28]=_,e[29]=b,e[30]=T):T=e[30],T}const or="flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",Uo="bg-sidebar-accent text-sidebar-foreground",ar="text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";function Vg(t){const e=$.c(47),{chatOpen:s,toggleChat:i,onNewTask:r}=t,{tasksOpen:n,toggleTasks:a}=cc(),l=!!r;let h;e[0]!==n||e[1]!==a?(h=()=>{ye("agent_toolbar_toggled",{button:"tasks",next_state:n?"closed":"open"}),a()},e[0]=n,e[1]=a,e[2]=h):h=e[2];const c=n?Uo:ar;let d;e[3]!==c?(d=ie(or,c),e[3]=c,e[4]=d):d=e[4];let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsx(Kc,{size:16}),e[5]=u):u=e[5];let f;e[6]!==h||e[7]!==d||e[8]!==n?(f=o.jsx(Re,{asChild:!0,children:o.jsx("button",{type:"button",onClick:h,"aria-pressed":n,className:d,children:u})}),e[6]=h,e[7]=d,e[8]=n,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=o.jsx(De,{side:"bottom",children:"Tasks"}),e[10]=m):m=e[10];let _;e[11]!==f?(_=o.jsxs(Me,{delayDuration:300,children:[f,m]}),e[11]=f,e[12]=_):_=e[12];let p;e[13]!==s||e[14]!==i?(p=()=>{ye("agent_toolbar_toggled",{button:"chat",next_state:s?"closed":"open"}),i()},e[13]=s,e[14]=i,e[15]=p):p=e[15];const v=s?Uo:ar;let x;e[16]!==v?(x=ie(or,v),e[16]=v,e[17]=x):x=e[17];let b;e[18]===Symbol.for("react.memo_cache_sentinel")?(b=o.jsx(da,{size:16}),e[18]=b):b=e[18];let S;e[19]!==s||e[20]!==x||e[21]!==p?(S=o.jsx(Re,{asChild:!0,children:o.jsx("button",{type:"button",onClick:p,"aria-pressed":s,className:x,children:b})}),e[19]=s,e[20]=x,e[21]=p,e[22]=S):S=e[22];let g;e[23]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx(De,{side:"bottom",children:"Chat"}),e[23]=g):g=e[23];let w;e[24]!==S?(w=o.jsxs(Me,{delayDuration:300,children:[S,g]}),e[24]=S,e[25]=w):w=e[25];const k=l?"grid-cols-[1fr]":"grid-cols-[0fr]";let C;e[26]!==k?(C=ie("grid transition-[grid-template-columns] duration-200 ease-[var(--ease-out-quart)]",k),e[26]=k,e[27]=C):C=e[27];const N=!l,T=l?0:-1,L=!l,M=l?"translate-x-0 opacity-100":"-translate-x-2 opacity-0";let D;e[28]!==M?(D=ie(or,ar,"transition-[transform,opacity] duration-200 ease-[var(--ease-out-quart)] will-change-transform",M),e[28]=M,e[29]=D):D=e[29];let y;e[30]===Symbol.for("react.memo_cache_sentinel")?(y=o.jsx(on,{size:16}),e[30]=y):y=e[30];let R;e[31]!==r||e[32]!==N||e[33]!==T||e[34]!==L||e[35]!==D?(R=o.jsx(Re,{asChild:!0,children:o.jsx("button",{type:"button",onClick:r,disabled:N,tabIndex:T,"aria-hidden":L,className:D,children:y})}),e[31]=r,e[32]=N,e[33]=T,e[34]=L,e[35]=D,e[36]=R):R=e[36];let E;e[37]===Symbol.for("react.memo_cache_sentinel")?(E=o.jsx(De,{side:"bottom",children:"New task"}),e[37]=E):E=e[37];let j;e[38]!==R?(j=o.jsx("div",{className:"overflow-hidden",children:o.jsxs(Me,{delayDuration:300,children:[R,E]})}),e[38]=R,e[39]=j):j=e[39];let I;e[40]!==C||e[41]!==j?(I=o.jsx("div",{className:C,children:j}),e[40]=C,e[41]=j,e[42]=I):I=e[42];let P;return e[43]!==w||e[44]!==I||e[45]!==_?(P=o.jsxs(o.Fragment,{children:[_,w,I]}),e[43]=w,e[44]=I,e[45]=_,e[46]=P):P=e[46],P}function qg(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 Gg(t){const e=$.c(13),{title:s,icon:i,active:r,onClick:n}=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=ie("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=o.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:o.jsx(Yg,{icon:i})}),e[2]=i,e[3]=h):h=e[3];let c;e[4]!==s?(c=o.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]!==n||e[8]!==l||e[9]!==h||e[10]!==c||e[11]!==s?(d=o.jsxs("button",{type:"button",onClick:n,"aria-pressed":r,"aria-label":s,className:l,children:[h,c]}),e[6]=r,e[7]=n,e[8]=l,e[9]=h,e[10]=c,e[11]=s,e[12]=d):d=e[12],d}function Yg(t){const e=$.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let n;return e[0]!==r?(n=o.jsx(r,{className:"size-4"}),e[0]=r,e[1]=n):n=e[1],n}if(s.kind==="url"){let r;return e[2]!==s.src?(r=o.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=o.jsx(ua,{className:"size-4"}),e[4]=i):i=e[4],i}function Xg(t){const e=$.c(13),{overflow:s,onSelect:i}=t,[r,n]=B.useState(!1);let a;e[0]!==i?(a=f=>{n(!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=o.jsx(ds,{asChild:!0,children:o.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:o.jsx(ca,{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=>o.jsx("li",{children:o.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:[o.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:o.jsx(Jg,{icon:m.icon})}),o.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=o.jsx(us,{align:"end",className:"w-56 p-1",children:o.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=o.jsxs(fs,{open:r,onOpenChange:n,children:[h,d]}),e[10]=r,e[11]=d,e[12]=u):u=e[12],u}function Jg(t){const e=$.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let n;return e[0]!==r?(n=o.jsx(r,{className:"size-4"}),e[0]=r,e[1]=n):n=e[1],n}if(s.kind==="url"){let r;return e[2]!==s.src?(r=o.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=o.jsx(ua,{className:"size-4"}),e[4]=i):i=e[4],i}const Zg=6;function $l(t){const e=$.c(20),{virtualMcpId:s,taskId:i}=t,r=Vt();let n;e[0]!==i||e[1]!==s?(n={virtualMcpId:s,taskId:i},e[0]=i,e[1]=s,e[2]=n):n=e[2];const{tabs:a,activeTab:l,mainOpen:h,setActiveTab:c}=Ba(n);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 v=Tc({activeTab:l,mainOpen:h}),x=k=>k.id==="automations"?v:h&&k.id===l,S=a.find(k=>x(k))?.id??null,{visible:g,overflow:w}=qg(a,S,Zg);u=w,d=k=>{const C=a.find(T=>T.id===k),N=S===k&&h;if(ye("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:k,tab_kind:C?.kind??null,was_active:N}),k==="automations"){const T=Rc({activeTab:l,mainOpen:h});r({to:".",search:L=>({...L,main:T}),replace:!0});return}c(k)},f="flex items-center min-w-0 gap-0.5",m=g.map(k=>o.jsx(Gg,{title:k.title,icon:k.icon,active:x(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&&o.jsx(Xg,{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=o.jsxs("div",{className:f,children:[m,_]}),e[16]=f,e[17]=m,e[18]=_,e[19]=p):p=e[19],p}function Qg(t){const e=$.c(12);let s,i,r,n;e[0]!==t?({className:s,orientation:r,decorative:n,...i}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r,e[4]=n):(s=e[1],i=e[2],r=e[3],n=e[4]);const a=r===void 0?"horizontal":r,l=n===void 0?!0:n;let h;e[5]!==s?(h=ie("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=o.jsx(tc,{"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 ev(t){const e=$.c(20),{prNumber:s,disabled:i,send:r}=t;let n;e[0]!==s||e[1]!==r?(n=()=>r(qu({prNumber:s})),e[0]=s,e[1]=r,e[2]=n):n=e[2];const a=n;let l;e[3]!==s||e[4]!==r?(l=()=>r(Vu({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=o.jsx(re,{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=o.jsx(un,{className:"h-3.5 w-3.5"}),e[9]=d):d=e[9];let u;e[10]!==i?(u=o.jsx(Ti,{asChild:!0,children:o.jsx(re,{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=o.jsx(Ri,{align:"end",children:o.jsx($t,{onClick:h,children:"Review"})}),e[12]=h,e[13]=f):f=e[13];let m;e[14]!==u||e[15]!==f?(m=o.jsxs(Ei,{children:[u,f]}),e[14]=u,e[15]=f,e[16]=m):m=e[16];let _;return e[17]!==c||e[18]!==m?(_=o.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[c,m]}),e[17]=c,e[18]=m,e[19]=_):_=e[19],_}function tv(t){if(!(t==="claiming"||t==="ready"||t==="failed"))return Wa[t].short}const sv=new Set(["failure","timed_out","cancelled","action_required"]);function iv(t){return t.status==="completed"&&sv.has(t.conclusion)}function rv(t){return t.status==="queued"||t.status==="in_progress"}function nv(t){const{lifecycle:e,branch:s,pr:i,checks:r,reviews:n,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&&tv(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((n?.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(iv).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(rv);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(n?.draft)return{label:"Mark ready",action:"mark-ready",variant:"default",tooltip:"Mark draft PR ready for review"};const f=n?.unresolvedConversations??0;return f>0?{label:"Address feedback",action:"resolve-comments",variant:"default",tooltip:`${f} unresolved conversation${f===1?"":"s"}`}:n?.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 ov=6e4,av=3e4;function lv(t){const e=$.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=Ve(s),r=t.prNumber??0;let n;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(n={method:"get",owner:t.owner,repo:t.repo,pullNumber:r},e[4]=t.owner,e[5]=t.repo,e[6]=r,e[7]=n):n=e[7];const a=!!t.prNumber;let l;return e[8]!==i||e[9]!==n||e[10]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:n,enabled:a,refetchInterval:ov,refetchIntervalInBackground:!1,staleTime:av,select:cv},e[8]=i,e[9]=n,e[10]=a,e[11]=l):l=e[11],Hs(l)}function cv(t){const e=Us(t);if(!e)return null;const s=e.mergeable_state??"unknown",i=!!(e.draft??!1),r=Number(e.review_comments??0),n=s==="blocked"&&r>0?r:0;return{draft:i,mergeableState:s,unresolvedConversations:n,missingRequiredApprovals:s==="blocked"&&n===0}}function hv(t){const e=$.c(44),{virtualMcpId:s}=t,{org:i}=ve(),r=yt(s),{currentBranch:n}=Pt(),a=Yt(),l=r?.metadata?.githubRepo??null,{lifecycle:h,branch:c,phase:d}=_s(),u=l?.connectionId??"",f=l?.owner??"",m=l?.name??"",_=n??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 v=$a(p),x=v.data??null,b=l?.connectionId??"",S=l?.owner??"",g=l?.name??"",w=x&&x.state==="open"?x.number:null;let k;e[7]!==i.id||e[8]!==i.slug||e[9]!==b||e[10]!==S||e[11]!==g||e[12]!==w?(k={orgId:i.id,orgSlug:i.slug,connectionId:b,owner:S,repo:g,prNumber:w},e[7]=i.id,e[8]=i.slug,e[9]=b,e[10]=S,e[11]=g,e[12]=w,e[13]=k):k=e[13];const C=Fa(k),N=l?.connectionId??"",T=l?.owner??"",L=l?.name??"",M=x&&x.state==="open"?x.number:null;let D;e[14]!==i.id||e[15]!==i.slug||e[16]!==N||e[17]!==T||e[18]!==L||e[19]!==M?(D={orgId:i.id,orgSlug:i.slug,connectionId:N,owner:T,repo:L,prNumber:M},e[14]=i.id,e[15]=i.slug,e[16]=N,e[17]=T,e[18]=L,e[19]=M,e[20]=D):D=e[20];const y=lv(D);if(!l?.connectionId||!n)return null;let R;e[21]!==c||e[22]!==C.data||e[23]!==d||e[24]!==h||e[25]!==x||e[26]!==v.isPending||e[27]!==y.data?(R=nv({lifecycle:h,branch:c,claimPhase:d,pr:x,checks:C.data??[],reviews:y.data??null,loading:v.isPending}),e[21]=c,e[22]=C.data,e[23]=d,e[24]=h,e[25]=x,e[26]=v.isPending,e[27]=y.data,e[28]=R):R=e[28];const E=R;let j;e[29]!==a?(j=K=>a.sendMessage({parts:[{type:"text",text:K}]}),e[29]=a,e[30]=j):j=e[30];const I=j,P=a.isStreaming;let z;e[31]!==n||e[32]!==E||e[33]!==P||e[34]!==x||e[35]!==I?(z=K=>{if(!P)switch(K){case"commit-and-push":{I(Ou({branch:n}));return}case"create-pr":{I($u({branch:n}));return}case"reopen":{x&&I(zu({prNumber:x.number}));return}case"rebase":{I(Fu({branch:n}));return}case"fix-checks":{x&&I(Wu({prNumber:x.number,failingChecks:E.meta?.failingChecks??[]}));return}case"mark-ready":{x&&I(Uu({prNumber:x.number}));return}case"resolve-comments":{x&&I(Ku({prNumber:x.number}));return}case"merge-split":return}},e[31]=n,e[32]=E,e[33]=P,e[34]=x,e[35]=I,e[36]=z):z=e[36];const U=z;let W;e[37]===Symbol.for("react.memo_cache_sentinel")?(W=o.jsx(Qg,{orientation:"vertical",className:"mx-2 data-[orientation=vertical]:h-5"}),e[37]=W):W=e[37];const H=x?.number;let G;return e[38]!==E||e[39]!==P||e[40]!==U||e[41]!==I||e[42]!==H?(G=o.jsxs(o.Fragment,{children:[W,o.jsx(dv,{button:E,isStreaming:P,onActivate:U,prNumber:H,send:I})]}),e[38]=E,e[39]=P,e[40]=U,e[41]=I,e[42]=H,e[43]=G):G=e[43],G}function dv(t){const e=$.c(21),{button:s,isStreaming:i}=t,r=!!s.disabled||i,n=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=o.jsx(ev,{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]!==n?(u=o.jsx(Ko,{label:n,children:d}),e[4]=d,e[5]=n,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?o.jsx(Mh,{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=o.jsxs(re,{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]!==n?(c=o.jsx(Ko,{label:n,children:h}),e[18]=h,e[19]=n,e[20]=c):c=e[20],c}function Ko(t){const e=$.c(9),{label:s,children:i}=t;if(!s){let l;return e[0]!==i?(l=o.jsx(o.Fragment,{children:i}),e[0]=i,e[1]=l):l=e[1],l}let r;e[2]!==i?(r=o.jsx(Re,{asChild:!0,children:o.jsx("span",{children:i})}),e[2]=i,e[3]=r):r=e[3];let n;e[4]!==s?(n=o.jsx(De,{children:s}),e[4]=s,e[5]=n):n=e[5];let a;return e[6]!==r||e[7]!==n?(a=o.jsx(th,{children:o.jsxs(Me,{children:[r,n]})}),e[6]=r,e[7]=n,e[8]=a):a=e[8],a}function uv(t){const e=$.c(2),{virtualMcp:s}=t;if(!!!(s.metadata?.githubRepo??null)?.connectionId)return null;let n;return e[0]!==s.id?(n=o.jsx(cr.Right,{children:o.jsx(hv,{virtualMcpId:s.id})}),e[0]=s.id,e[1]=n):n=e[1],n}function fv(t,e){const s=$.c(40),{org:i,locator:r}=ve();let n;s[0]!==i.id||s[1]!==i.slug?(n={connectionId:Gt,orgId:i.id,orgSlug:i.slug},s[0]=i.id,s[1]=i.slug,s[2]=n):n=s[2];const a=Ve(n),l=hs();let h;s[3]!==t||s[4]!==i.id?(h=Fs.ensureTask(i.id,t),s[3]=t,s[4]=i.id,s[5]=h):h=s[5];let c;s[6]!==a||s[7]!==t?(c=async()=>(await a.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}})).structuredContent?.item??null,s[6]=a,s[7]=t,s[8]=c):c=s[8];const d=t.length>0;let u;s[9]!==h||s[10]!==c||s[11]!==d?(u={queryKey:h,queryFn:c,enabled:d,retry:!1,refetchOnWindowFocus:!1},s[9]=h,s[10]=c,s[11]=d,s[12]=u):u=s[12];const f=Qr(u);let m;s[13]!==a||s[14]!==e?(m=async g=>{const w=await a.callTool({name:"COLLECTION_THREADS_CREATE",arguments:{data:{id:g,virtual_mcp_id:e}}});if(w.isError){const C=w.content,N=Array.isArray(C)&&C[0]&&typeof C[0]=="object"?C[0].text??"Create failed":"Create failed";throw new Error(N)}return w.structuredContent.item},s[13]=a,s[14]=e,s[15]=m):m=s[15];let _;s[16]!==r||s[17]!==i.id||s[18]!==f||s[19]!==l?(_=g=>{l.invalidateQueries({predicate:w=>w.queryKey[1]===i.id&&w.queryKey[3]==="collection"&&w.queryKey[4]==="THREADS"}),Bh(l,r,g),f.refetch()},s[16]=r,s[17]=i.id,s[18]=f,s[19]=l,s[20]=_):_=s[20];let p;s[21]!==m||s[22]!==_?(p={mutationFn:m,onSuccess:_},s[21]=m,s[22]=_,s[23]=p):p=s[23];const v=Yo(p);let x,b;if(s[24]!==v||s[25]!==t||s[26]!==f.data||s[27]!==f.isSuccess?(x=()=>{t&&(!f.isSuccess||f.data||v.isPending||v.variables!==t&&v.mutate(t))},b=[t,f.isSuccess,f.data,v],s[24]=v,s[25]=t,s[26]=f.data,s[27]=f.isSuccess,s[28]=x,s[29]=b):(x=s[28],b=s[29]),B.useEffect(x,b),!t){let g;return s[30]===Symbol.for("react.memo_cache_sentinel")?(g={status:"ready",task:null},s[30]=g):g=s[30],g}if(f.isLoading){let g;return s[31]===Symbol.for("react.memo_cache_sentinel")?(g={status:"loading"},s[31]=g):g=s[31],g}if(f.isError){const g=f.error;let w;return s[32]!==g?(w={status:"error",error:g},s[32]=g,s[33]=w):w=s[33],w}if(f.isSuccess&&f.data){let g;return s[34]!==f.data?(g={status:"ready",task:f.data},s[34]=f.data,s[35]=g):g=s[35],g}if(v.isPending||f.isSuccess&&!f.data){let g;return s[36]===Symbol.for("react.memo_cache_sentinel")?(g={status:"creating"},s[36]=g):g=s[36],g}if(v.isError){let g;return s[37]!==v.error?(g={status:"error",error:v.error},s[37]=v.error,s[38]=g):g=s[38],g}let S;return s[39]===Symbol.for("react.memo_cache_sentinel")?(S={status:"loading"},s[39]=S):S=s[39],S}const ts=B.createContext(null);function zl(){return B.use(ts)}function Vo(t){const e=$.c(6),{children:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.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=o.jsx(Se.Skeleton,{}),e[1]=r):r=e[1];let n;e[2]!==s?(n=s??o.jsx(Pa,{}),e[2]=s,e[3]=n):n=e[3];let a;return e[4]!==n?(a=o.jsx(Rt,{fallback:i,children:o.jsx(B.Suspense,{fallback:r,children:n})}),e[4]=n,e[5]=a):a=e[5],a}function qo(t){const e=$.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],B.useLayoutEffect(r),null}function mv(t){const e=$.c(23),{onOpenSidebar:s,virtualMcpId:i,taskId:r,mainOpen:n,onToggleMain:a,onNewTask:l}=t;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=o.jsx(gc,{size:20}),e[0]=h):h=e[0];let c;e[1]!==s?(c=o.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=o.jsx("div",{className:"flex-1 min-w-0 overflow-x-auto [scrollbar-width:none]",children:o.jsx($l,{virtualMcpId:i,taskId:r})}),e[3]=r,e[4]=i,e[5]=d):d=e[5];const u=!n,f=n?"text-foreground/60 hover:bg-accent hover:text-foreground":"bg-accent text-foreground";let m;e[6]!==f?(m=ie("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")?(_=o.jsx(da,{size:16}),e[8]=_):_=e[8];let p;e[9]!==a||e[10]!==u||e[11]!==m?(p=o.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 v;e[13]===Symbol.for("react.memo_cache_sentinel")?(v=o.jsx(on,{size:16}),e[13]=v):v=e[13];let x;e[14]!==l?(x=o.jsx("button",{type:"button",onClick:l,className:"flex size-7 shrink-0 items-center justify-center rounded-md text-foreground/60 hover:bg-accent hover:text-foreground transition-colors",title:"New task",children:v}),e[14]=l,e[15]=x):x=e[15];let b;e[16]!==x||e[17]!==p?(b=o.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[p,x]}),e[16]=x,e[17]=p,e[18]=b):b=e[18];let S;return e[19]!==b||e[20]!==c||e[21]!==d?(S=o.jsxs("div",{className:"shrink-0 flex items-center gap-1 px-2 h-12 bg-background border-b border-border",children:[c,d,b]}),e[19]=b,e[20]=c,e[21]=d,e[22]=S):S=e[22],S}function Go(t){const e=$.c(16),{virtualMcpId:s,hasActiveGithubRepo:i,vmMap:r,children:n}=t,{org:a}=ve(),{currentBranch:l}=Pt(),{data:h}=Zr.useSession(),c=h?.user?.id;let d;e[0]!==a.id||e[1]!==a.slug?(d={connectionId:Gt,orgId:a.id,orgSlug:a.slug},e[0]=a.id,e[1]=a.slug,e[2]=d):d=e[2];const u=Ve(d),{mutate:f}=Aa(u);let m;e[3]===Symbol.for("react.memo_cache_sentinel")?(m=new Set,e[3]=m):m=e[3];const _=B.useRef(m);let p,v;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:_v}))}},v=[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]=v):(p=e[10],v=e[11]),B.useEffect(p,v);const x=l??null;let b;return e[12]!==n||e[13]!==x||e[14]!==s?(b=o.jsx(Cf,{virtualMcpId:s,branch:x,children:n}),e[12]=n,e[13]=x,e[14]=s,e[15]=b):b=e[15],b}function _v(t){console.error("[auto-start-vm] failed:",t)}function pv(){const t=$.c(115),e=fa(),s=Vt(),{org:i}=ve(),r=hc()?.tasksOpen??!1;sh(i.slug);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={strict:!1},t[0]=n):n=t[0];const a=sc(n),l=a.org??"";let h;t[1]===Symbol.for("react.memo_cache_sentinel")?(h={strict:!1},t[1]=h):h=t[1];const c=Jo(h);let d;t[2]!==i.id||t[3]!==c.virtualmcpid?(d=c.virtualmcpid??sa(i.id).id,t[2]=i.id,t[3]=c.virtualmcpid,t[4]=d):d=t[4];const u=d,f=fv(a.taskId??"",u),m=yt(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 v=p;let x;t[7]!==m?(x=m&&Ht(m),t[7]=m,t[8]=x):x=t[8];const b=!!x;let S;t[9]!==l||t[10]!==u?(S={virtualMcpId:u,orgSlug:l,isAgentRoute:!0},t[9]=l,t[10]=u,t[11]=S):S=t[11];const g=dc(v,S),{setOpenMobile:w,openMobile:k}=Jc(),C=w,N=B.useRef(null);let T,L;t[12]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{const J=ee=>{Xc(ee)&&ee.shiftKey&&ee.code==="KeyS"&&!ee.repeat&&(ee.preventDefault(),N.current?.())};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)},L=[],t[12]=T,t[13]=L):(T=t[12],L=t[13]),B.useEffect(T,L);const M=u;let D;t[14]!==m||t[15]!==u?(D={virtualMcpId:u,entity:m},t[14]=m,t[15]=u,t[16]=D):D=t[16];const y=D;if(f.status==="creating"||f.status==="loading"){let J;t[17]===Symbol.for("react.memo_cache_sentinel")?(J=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsxs("div",{className:"flex h-full items-center justify-center bg-background card-shadow rounded-[0.75rem] text-sm text-muted-foreground",children:[o.jsx(He,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[17]=J):J=t[17];let ee;return t[18]!==y?(ee=o.jsx(ts,{value:y,children:J}),t[18]=y,t[19]=ee):ee=t[19],ee}if(f.status==="error"){let J;t[20]===Symbol.for("react.memo_cache_sentinel")?(J=o.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[20]=J):J=t[20];let ee;t[21]!==f.error.message?(ee=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.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,o.jsx("div",{className:"text-muted-foreground",children:f.error.message})]})}),t[21]=f.error.message,t[22]=ee):ee=t[22];let A;return t[23]!==y||t[24]!==ee?(A=o.jsx(ts,{value:y,children:ee}),t[23]=y,t[24]=ee,t[25]=A):A=t[25],A}if(!m){let J;t[26]===Symbol.for("react.memo_cache_sentinel")?(J=o.jsx(tn,{size:48,className:"text-muted-foreground"}),t[26]=J):J=t[26];const ee=`The agent "${u}" does not exist in this organization.`;let A;t[27]!==s||t[28]!==l?(A=o.jsx(re,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:l}}),children:"Go to organization home"}),t[27]=s,t[28]=l,t[29]=A):A=t[29];let X;t[30]!==ee||t[31]!==A?(X=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsx("div",{className:"flex flex-col h-full bg-background overflow-hidden card-shadow rounded-[0.75rem]",children:o.jsx(pi,{image:J,title:"Agent not found",description:ee,actions:A})})}),t[30]=ee,t[31]=A,t[32]=X):X=t[32];let Q;return t[33]!==y||t[34]!==X?(Q=o.jsx(ts,{value:y,children:X}),t[33]=y,t[34]=X,t[35]=Q):Q=t[35],Q}if(e){let J;t[36]===Symbol.for("react.memo_cache_sentinel")?(J=o.jsx(Zc,{className:"sr-only",children:"Navigation"}),t[36]=J):J=t[36];let ee;t[37]!==C?(ee=o.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:o.jsx(Gc,{onClose:()=>C(!1)})}),t[37]=C,t[38]=ee):ee=t[38];let A;t[39]===Symbol.for("react.memo_cache_sentinel")?(A=o.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:o.jsx(Yc,{})}),t[39]=A):A=t[39];let X;t[40]!==ee?(X=o.jsxs(Qc,{side:"left",hideCloseButton:!0,className:"w-[calc(100vw-3rem)] sm:max-w-md! p-0",children:[J,o.jsxs("div",{className:"flex h-full",children:[ee,A]})]}),t[40]=ee,t[41]=X):X=t[41];let Q;t[42]!==k||t[43]!==C||t[44]!==X?(Q=o.jsx(eh,{open:k,onOpenChange:C,children:X}),t[42]=k,t[43]=C,t[44]=X,t[45]=Q):Q=t[45];const F=Q,V=m?.metadata?.vmMap;let ne;t[46]!==g.createNewTask?(ne=o.jsx(qo,{onNewTaskRef:N,createNewTask:g.createNewTask}),t[46]=g.createNewTask,t[47]=ne):ne=t[47];let he;t[48]!==C?(he=()=>C(!0),t[48]=C,t[49]=he):he=t[49];let ce;t[50]!==M||t[51]!==g.createNewTask||t[52]!==g.mainOpen||t[53]!==g.taskId||t[54]!==g.toggleMain||t[55]!==he?(ce=o.jsx(mv,{onOpenSidebar:he,virtualMcpId:M,taskId:g.taskId,mainOpen:g.mainOpen,onToggleMain:g.toggleMain,onNewTask:g.createNewTask}),t[50]=M,t[51]=g.createNewTask,t[52]=g.mainOpen,t[53]=g.taskId,t[54]=g.toggleMain,t[55]=he,t[56]=ce):ce=t[56];let de;t[57]===Symbol.for("react.memo_cache_sentinel")?(de=o.jsx(Se.Skeleton,{}),t[57]=de):de=t[57];let fe;t[58]!==M||t[59]!==g.mainOpen||t[60]!==g.taskId?(fe=o.jsx(B.Suspense,{fallback:de,children:o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:g.mainOpen?o.jsx(Rt,{fallback:o.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Something went wrong. Try refreshing."}),children:o.jsx(B.Suspense,{fallback:o.jsx("div",{className:"h-full flex items-center justify-center",children:o.jsx(He,{size:20,className:"animate-spin text-muted-foreground"})}),children:o.jsx(Ol,{taskId:g.taskId,virtualMcpId:M})})}):o.jsx(Vo,{})})}),t[58]=M,t[59]=g.mainOpen,t[60]=g.taskId,t[61]=fe):fe=t[61];let Be;t[62]!==g.taskId||t[63]!==fe?(Be=o.jsx(Se.ActiveTaskProvider,{taskId:g.taskId,children:fe},g.taskId),t[62]=g.taskId,t[63]=fe,t[64]=Be):Be=t[64];let Ne;t[65]!==b||t[66]!==F||t[67]!==V||t[68]!==ne||t[69]!==ce||t[70]!==Be||t[71]!==u?(Ne=o.jsxs(Go,{virtualMcpId:u,hasActiveGithubRepo:b,vmMap:V,children:[ne,ce,Be,F]}),t[65]=b,t[66]=F,t[67]=V,t[68]=ne,t[69]=ce,t[70]=Be,t[71]=u,t[72]=Ne):Ne=t[72];let je;t[73]!==M||t[74]!==Ne?(je=o.jsx("div",{className:"flex flex-col flex-1 bg-background min-h-0",children:o.jsx(Se.Provider,{virtualMcpId:M,children:Ne},M)}),t[73]=M,t[74]=Ne,t[75]=je):je=t[75];let Je;return t[76]!==y||t[77]!==je?(Je=o.jsx(ts,{value:y,children:je}),t[76]=y,t[77]=je,t[78]=Je):Je=t[78],Je}const R=r?void 0:g.createNewTask;let E;t[79]!==g.chatOpen||t[80]!==g.toggleChat||t[81]!==R?(E=o.jsx(cr.Toggles,{children:o.jsx(Vg,{chatOpen:g.chatOpen,toggleChat:g.toggleChat,onNewTask:R})}),t[79]=g.chatOpen,t[80]=g.toggleChat,t[81]=R,t[82]=E):E=t[82];let j;t[83]!==g.taskId||t[84]!==u?(j=o.jsx(cr.Tabs,{children:o.jsx($l,{virtualMcpId:u,taskId:g.taskId})}),t[83]=g.taskId,t[84]=u,t[85]=j):j=t[85];const I=m?.metadata?.vmMap;let P;t[86]!==g.createNewTask?(P=o.jsx(qo,{onNewTaskRef:N,createNewTask:g.createNewTask}),t[86]=g.createNewTask,t[87]=P):P=t[87];let z;t[88]!==m?(z=o.jsx(uv,{virtualMcp:m}),t[88]=m,t[89]=z):z=t[89];let U;t[90]===Symbol.for("react.memo_cache_sentinel")?(U=o.jsx(Se.Skeleton,{}),t[90]=U):U=t[90];let W;t[91]===Symbol.for("react.memo_cache_sentinel")?(W=o.jsx(Vo,{}),t[91]=W):W=t[91];let H;t[92]!==g.chatOpen||t[93]!==g.mainOpen||t[94]!==g.taskId||t[95]!==u?(H=o.jsx(B.Suspense,{fallback:U,children:o.jsx(Kg,{virtualMcpId:u,taskId:g.taskId,chatOpen:g.chatOpen,mainOpen:g.mainOpen,chatContent:W})}),t[92]=g.chatOpen,t[93]=g.mainOpen,t[94]=g.taskId,t[95]=u,t[96]=H):H=t[96];let G;t[97]!==g.taskId||t[98]!==z||t[99]!==H?(G=o.jsxs(Se.ActiveTaskProvider,{taskId:g.taskId,children:[z,H]},g.taskId),t[97]=g.taskId,t[98]=z,t[99]=H,t[100]=G):G=t[100];let K;t[101]!==b||t[102]!==I||t[103]!==P||t[104]!==G||t[105]!==u?(K=o.jsxs(Go,{virtualMcpId:u,hasActiveGithubRepo:b,vmMap:I,children:[P,G]}),t[101]=b,t[102]=I,t[103]=P,t[104]=G,t[105]=u,t[106]=K):K=t[106];let se;t[107]!==M||t[108]!==j||t[109]!==K?(se=o.jsxs(Se.Provider,{virtualMcpId:M,children:[j,K]},M),t[107]=M,t[108]=j,t[109]=K,t[110]=se):se=t[110];let Y;return t[111]!==y||t[112]!==E||t[113]!==se?(Y=o.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:o.jsxs(ts,{value:y,children:[E,se]})}),t[111]=y,t[112]=E,t[113]=se,t[114]=Y):Y=t[114],Y}function gv(){const t=$.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(B.Suspense,{fallback:o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(He,{size:20,className:"animate-spin text-muted-foreground"})}),children:o.jsx(pv,{})}),t[0]=e):e=t[0],e}const A1=Object.freeze(Object.defineProperty({__proto__:null,default:gv,useInsetContext:zl},Symbol.toStringTag,{value:"Module"}));export{df as e,A1 as i,lf as u};
|