agent-tower 0.7.4 → 0.7.5-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +6 -1
- package/dist/app.js.map +1 -1
- package/dist/core/container.d.ts +2 -0
- package/dist/core/container.d.ts.map +1 -1
- package/dist/core/container.js +25 -0
- package/dist/core/container.js.map +1 -1
- package/dist/executors/__tests__/base.executor.test.js +19 -0
- package/dist/executors/__tests__/base.executor.test.js.map +1 -1
- package/dist/executors/__tests__/claude-code-mcp.test.d.ts +2 -0
- package/dist/executors/__tests__/claude-code-mcp.test.d.ts.map +1 -0
- package/dist/executors/__tests__/claude-code-mcp.test.js +211 -0
- package/dist/executors/__tests__/claude-code-mcp.test.js.map +1 -0
- package/dist/executors/__tests__/codex-mcp-windows.test.d.ts +2 -0
- package/dist/executors/__tests__/codex-mcp-windows.test.d.ts.map +1 -0
- package/dist/executors/__tests__/codex-mcp-windows.test.js +128 -0
- package/dist/executors/__tests__/codex-mcp-windows.test.js.map +1 -0
- package/dist/executors/__tests__/codex.executor.test.js +394 -1
- package/dist/executors/__tests__/codex.executor.test.js.map +1 -1
- package/dist/executors/base.executor.d.ts.map +1 -1
- package/dist/executors/base.executor.js +13 -0
- package/dist/executors/base.executor.js.map +1 -1
- package/dist/executors/claude-code.executor.d.ts +1 -0
- package/dist/executors/claude-code.executor.d.ts.map +1 -1
- package/dist/executors/claude-code.executor.js +52 -3
- package/dist/executors/claude-code.executor.js.map +1 -1
- package/dist/executors/codex.executor.d.ts +6 -6
- package/dist/executors/codex.executor.d.ts.map +1 -1
- package/dist/executors/codex.executor.js +118 -32
- package/dist/executors/codex.executor.js.map +1 -1
- package/dist/git/worktree.manager.d.ts.map +1 -1
- package/dist/git/worktree.manager.js +5 -2
- package/dist/git/worktree.manager.js.map +1 -1
- package/dist/mcp/http-client.d.ts +8 -1
- package/dist/mcp/http-client.d.ts.map +1 -1
- package/dist/mcp/http-client.js +6 -0
- package/dist/mcp/http-client.js.map +1 -1
- package/dist/mcp/tools/__tests__/workspace-services.test.js +34 -1
- package/dist/mcp/tools/__tests__/workspace-services.test.js.map +1 -1
- package/dist/mcp/tools/tasks.js +1 -1
- package/dist/mcp/tools/tasks.js.map +1 -1
- package/dist/mcp/tools/workspace-services.d.ts.map +1 -1
- package/dist/mcp/tools/workspace-services.js +39 -2
- package/dist/mcp/tools/workspace-services.js.map +1 -1
- package/dist/mcp/types.d.ts +20 -0
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/mcp/types.js +12 -0
- package/dist/mcp/types.js.map +1 -1
- package/dist/middleware/__tests__/preview-fallback.test.d.ts +2 -0
- package/dist/middleware/__tests__/preview-fallback.test.d.ts.map +1 -0
- package/dist/middleware/__tests__/preview-fallback.test.js +93 -0
- package/dist/middleware/__tests__/preview-fallback.test.js.map +1 -0
- package/dist/middleware/preview-fallback.d.ts +5 -0
- package/dist/middleware/preview-fallback.d.ts.map +1 -0
- package/dist/middleware/preview-fallback.js +91 -0
- package/dist/middleware/preview-fallback.js.map +1 -0
- package/dist/output/__tests__/claude-code-parser-continuation.test.d.ts +2 -0
- package/dist/output/__tests__/claude-code-parser-continuation.test.d.ts.map +1 -0
- package/dist/output/__tests__/claude-code-parser-continuation.test.js +89 -0
- package/dist/output/__tests__/claude-code-parser-continuation.test.js.map +1 -0
- package/dist/output/__tests__/claude-code-parser-lifecycle.test.js +4 -1
- package/dist/output/__tests__/claude-code-parser-lifecycle.test.js.map +1 -1
- package/dist/output/claude-code-parser.d.ts +36 -1
- package/dist/output/claude-code-parser.d.ts.map +1 -1
- package/dist/output/claude-code-parser.js +149 -18
- package/dist/output/claude-code-parser.js.map +1 -1
- package/dist/output/types.d.ts +2 -0
- package/dist/output/types.d.ts.map +1 -1
- package/dist/output/types.js.map +1 -1
- package/dist/prompts/workspace-background-service-policy.d.ts +6 -2
- package/dist/prompts/workspace-background-service-policy.d.ts.map +1 -1
- package/dist/prompts/workspace-background-service-policy.js +12 -3
- package/dist/prompts/workspace-background-service-policy.js.map +1 -1
- package/dist/prompts/workspace-background-service-policy.test.js +11 -0
- package/dist/prompts/workspace-background-service-policy.test.js.map +1 -1
- package/dist/routes/__tests__/previews.integration.test.js +117 -6
- package/dist/routes/__tests__/previews.integration.test.js.map +1 -1
- package/dist/routes/__tests__/previews.test.js +223 -194
- package/dist/routes/__tests__/previews.test.js.map +1 -1
- package/dist/routes/__tests__/task-handoff.test.js +25 -16
- package/dist/routes/__tests__/task-handoff.test.js.map +1 -1
- package/dist/routes/index.d.ts.map +1 -1
- package/dist/routes/index.js +3 -0
- package/dist/routes/index.js.map +1 -1
- package/dist/routes/previews.d.ts +11 -9
- package/dist/routes/previews.d.ts.map +1 -1
- package/dist/routes/previews.js +137 -516
- package/dist/routes/previews.js.map +1 -1
- package/dist/routes/session-wakeups.d.ts +7 -0
- package/dist/routes/session-wakeups.d.ts.map +1 -0
- package/dist/routes/session-wakeups.js +86 -0
- package/dist/routes/session-wakeups.js.map +1 -0
- package/dist/routes/tasks.d.ts.map +1 -1
- package/dist/routes/tasks.js +3 -1
- package/dist/routes/tasks.js.map +1 -1
- package/dist/runtime/__tests__/acp-process-manager.test.js +65 -0
- package/dist/runtime/__tests__/acp-process-manager.test.js.map +1 -1
- package/dist/runtime/__tests__/claude-cli-driver.test.js +96 -2
- package/dist/runtime/__tests__/claude-cli-driver.test.js.map +1 -1
- package/dist/runtime/__tests__/claude-run-lifecycle.test.d.ts +2 -0
- package/dist/runtime/__tests__/claude-run-lifecycle.test.d.ts.map +1 -0
- package/dist/runtime/__tests__/claude-run-lifecycle.test.js +88 -0
- package/dist/runtime/__tests__/claude-run-lifecycle.test.js.map +1 -0
- package/dist/runtime/__tests__/cli-driver-lifecycle.test.js +14 -7
- package/dist/runtime/__tests__/cli-driver-lifecycle.test.js.map +1 -1
- package/dist/runtime/acp/agents/pi-coding-agent.d.ts.map +1 -1
- package/dist/runtime/acp/agents/pi-coding-agent.js +3 -0
- package/dist/runtime/acp/agents/pi-coding-agent.js.map +1 -1
- package/dist/runtime/claude-run-lifecycle.d.ts +77 -0
- package/dist/runtime/claude-run-lifecycle.d.ts.map +1 -0
- package/dist/runtime/claude-run-lifecycle.js +147 -0
- package/dist/runtime/claude-run-lifecycle.js.map +1 -0
- package/dist/runtime/cli-driver.d.ts.map +1 -1
- package/dist/runtime/cli-driver.js +89 -3
- package/dist/runtime/cli-driver.js.map +1 -1
- package/dist/runtime/contracts.d.ts +6 -1
- package/dist/runtime/contracts.d.ts.map +1 -1
- package/dist/runtime/process-scope/__tests__/process-scope.test.d.ts +2 -0
- package/dist/runtime/process-scope/__tests__/process-scope.test.d.ts.map +1 -0
- package/dist/runtime/process-scope/__tests__/process-scope.test.js +156 -0
- package/dist/runtime/process-scope/__tests__/process-scope.test.js.map +1 -0
- package/dist/runtime/process-scope/process-scope.d.ts +46 -0
- package/dist/runtime/process-scope/process-scope.d.ts.map +1 -0
- package/dist/runtime/process-scope/process-scope.js +68 -0
- package/dist/runtime/process-scope/process-scope.js.map +1 -0
- package/dist/runtime/process-scope/scope-helper.d.ts +28 -0
- package/dist/runtime/process-scope/scope-helper.d.ts.map +1 -0
- package/dist/runtime/process-scope/scope-helper.js +78 -0
- package/dist/runtime/process-scope/scope-helper.js.map +1 -0
- package/dist/runtime/runtime-coordinator.d.ts.map +1 -1
- package/dist/runtime/runtime-coordinator.js +6 -0
- package/dist/runtime/runtime-coordinator.js.map +1 -1
- package/dist/services/__tests__/preview-runtime-manager.test.js +13 -112
- package/dist/services/__tests__/preview-runtime-manager.test.js.map +1 -1
- package/dist/services/__tests__/preview.service.test.js +13 -14
- package/dist/services/__tests__/preview.service.test.js.map +1 -1
- package/dist/services/__tests__/session-manager.lifecycle.test.js +147 -1
- package/dist/services/__tests__/session-manager.lifecycle.test.js.map +1 -1
- package/dist/services/__tests__/session-wakeup.service.test.d.ts +2 -0
- package/dist/services/__tests__/session-wakeup.service.test.d.ts.map +1 -0
- package/dist/services/__tests__/session-wakeup.service.test.js +173 -0
- package/dist/services/__tests__/session-wakeup.service.test.js.map +1 -0
- package/dist/services/__tests__/terminal-manager.test.js +129 -51
- package/dist/services/__tests__/terminal-manager.test.js.map +1 -1
- package/dist/services/__tests__/workspace.service.test.js +31 -0
- package/dist/services/__tests__/workspace.service.test.js.map +1 -1
- package/dist/services/message-delivery.service.d.ts +3 -2
- package/dist/services/message-delivery.service.d.ts.map +1 -1
- package/dist/services/message-delivery.service.js +11 -7
- package/dist/services/message-delivery.service.js.map +1 -1
- package/dist/services/preview-bridge.d.ts +50 -0
- package/dist/services/preview-bridge.d.ts.map +1 -0
- package/dist/services/preview-bridge.js +537 -0
- package/dist/services/preview-bridge.js.map +1 -0
- package/dist/services/preview-cookies.d.ts +28 -0
- package/dist/services/preview-cookies.d.ts.map +1 -0
- package/dist/services/preview-cookies.js +133 -0
- package/dist/services/preview-cookies.js.map +1 -0
- package/dist/services/preview-proxy.d.ts +71 -0
- package/dist/services/preview-proxy.d.ts.map +1 -0
- package/dist/services/preview-proxy.js +462 -0
- package/dist/services/preview-proxy.js.map +1 -0
- package/dist/services/preview-runtime-manager.d.ts +11 -25
- package/dist/services/preview-runtime-manager.d.ts.map +1 -1
- package/dist/services/preview-runtime-manager.js +46 -363
- package/dist/services/preview-runtime-manager.js.map +1 -1
- package/dist/services/preview.service.d.ts.map +1 -1
- package/dist/services/preview.service.js +11 -9
- package/dist/services/preview.service.js.map +1 -1
- package/dist/services/project.service.d.ts +13 -13
- package/dist/services/session-manager.d.ts +2 -0
- package/dist/services/session-manager.d.ts.map +1 -1
- package/dist/services/session-manager.js +4 -2
- package/dist/services/session-manager.js.map +1 -1
- package/dist/services/session-wakeup.service.d.ts +105 -0
- package/dist/services/session-wakeup.service.d.ts.map +1 -0
- package/dist/services/session-wakeup.service.js +319 -0
- package/dist/services/session-wakeup.service.js.map +1 -0
- package/dist/services/task-handoff.service.d.ts +3 -2
- package/dist/services/task-handoff.service.d.ts.map +1 -1
- package/dist/services/task-handoff.service.js +7 -6
- package/dist/services/task-handoff.service.js.map +1 -1
- package/dist/services/team-room-delivery.d.ts +4 -4
- package/dist/services/terminal-manager.d.ts +16 -0
- package/dist/services/terminal-manager.d.ts.map +1 -1
- package/dist/services/terminal-manager.js +64 -7
- package/dist/services/terminal-manager.js.map +1 -1
- package/dist/services/workspace-background-service.service.d.ts +15 -1
- package/dist/services/workspace-background-service.service.d.ts.map +1 -1
- package/dist/services/workspace-background-service.service.js +41 -2
- package/dist/services/workspace-background-service.service.js.map +1 -1
- package/dist/services/workspace.service.d.ts.map +1 -1
- package/dist/services/workspace.service.js +2 -1
- package/dist/services/workspace.service.js.map +1 -1
- package/dist/utils/database-schema.d.ts.map +1 -1
- package/dist/utils/database-schema.js +9 -4
- package/dist/utils/database-schema.js.map +1 -1
- package/dist/utils/database-schema.test.js +21 -0
- package/dist/utils/database-schema.test.js.map +1 -1
- package/dist/utils/owned-child-process.d.ts +32 -3
- package/dist/utils/owned-child-process.d.ts.map +1 -1
- package/dist/utils/owned-child-process.js +138 -1
- package/dist/utils/owned-child-process.js.map +1 -1
- package/dist/web/assets/{AgentDemoPage-D9bIiALx.js → AgentDemoPage-D6clLNZx.js} +1 -1
- package/dist/web/assets/{AgentEnvironmentSettingsPage-BE0RC6fR.js → AgentEnvironmentSettingsPage-O1hlpsgp.js} +1 -1
- package/dist/web/assets/AttachmentPreview-hD3g_T_y.js +2 -0
- package/dist/web/assets/{BranchSelect-Kv3M1YhZ.js → BranchSelect-BkuXnEG2.js} +1 -1
- package/dist/web/assets/{BrandLogo-fR2lCwEo.js → BrandLogo-BSwQa2SF.js} +1 -1
- package/dist/web/assets/{ConversationPage-BZiMHI9T.js → ConversationPage-DvWjqFF2.js} +1 -1
- package/dist/web/assets/CreateTaskInput-Bric0GeW.js +1 -0
- package/dist/web/assets/{DemoPage-DwpThe16.js → DemoPage-Cwy3EmOm.js} +1 -1
- package/dist/web/assets/{DesignSystemPage-DH9_cygJ.js → DesignSystemPage-C1HrGwpV.js} +1 -1
- package/dist/web/assets/{ExecutionPermissionSelector-C-akTOVg.js → ExecutionPermissionSelector-BgrxbvBB.js} +1 -1
- package/dist/web/assets/{GeneralSettingsPage-v2w1eofz.js → GeneralSettingsPage-qdeAdBkW.js} +1 -1
- package/dist/web/assets/{LoadingPreviewPage-pgk3PWM9.js → LoadingPreviewPage-qeZ8nuiQ.js} +1 -1
- package/dist/web/assets/{McpSettingsPage-w1DOlY5V.js → McpSettingsPage-Bo-auo0X.js} +1 -1
- package/dist/web/assets/{MemberAvatar-CJtylxwu.js → MemberAvatar-DBab_9EO.js} +1 -1
- package/dist/web/assets/{MobileTaskDetail-D5Czlr2O.js → MobileTaskDetail-Dm64ie99.js} +2 -2
- package/dist/web/assets/{NotificationSettingsPage-CkLg4WvT.js → NotificationSettingsPage-BVJpo76k.js} +1 -1
- package/dist/web/assets/{ProfileSettingsPage-B3yzbY1V.js → ProfileSettingsPage-CbSRYGcp.js} +1 -1
- package/dist/web/assets/{ProjectKanbanPage-CuGSLvrU.js → ProjectKanbanPage-Cp3rdFik.js} +6 -6
- package/dist/web/assets/{ProjectSettingsPage-DoklOfna.js → ProjectSettingsPage-DLs5-Gk3.js} +1 -1
- package/dist/web/assets/{ProviderSettingsPage-Cm0hbX5n.js → ProviderSettingsPage-BnBcgAMQ.js} +1 -1
- package/dist/web/assets/{SettingsMasterDetail-CGCUalkW.js → SettingsMasterDetail-fu-_yejj.js} +1 -1
- package/dist/web/assets/{TaskDetail-BiZbuXcE.js → TaskDetail-C2_Fg59e.js} +1 -1
- package/dist/web/assets/TaskHandoffPanel-3Y0gcjyN.js +70 -0
- package/dist/web/assets/{TeamSettingsPage-CyppRTaY.js → TeamSettingsPage-CAjitaBe.js} +1 -1
- package/dist/web/assets/{TranslationSettingsPage-BoQXEZmn.js → TranslationSettingsPage-DKD6Uw2F.js} +1 -1
- package/dist/web/assets/{arc-5NPBSbiL.js → arc-BiuUFTzU.js} +1 -1
- package/dist/web/assets/{architectureDiagram-3BPJPVTR-CqPT-IsX.js → architectureDiagram-3BPJPVTR-Dcwk905A.js} +1 -1
- package/dist/web/assets/{at-sign-Cf39WHCg.js → at-sign-CZAKOH3i.js} +1 -1
- package/dist/web/assets/{blockDiagram-GPEHLZMM-BN-1z9KN.js → blockDiagram-GPEHLZMM-Cfc5JDN-.js} +1 -1
- package/dist/web/assets/{c4Diagram-AAUBKEIU-CkeLbmQp.js → c4Diagram-AAUBKEIU-B4v5PUdt.js} +1 -1
- package/dist/web/assets/channel-DThSYkmR.js +1 -0
- package/dist/web/assets/check-C3vuSPKz.js +1 -0
- package/dist/web/assets/{chevron-down-Ct7FZbKm.js → chevron-down-CtAk9uZw.js} +1 -1
- package/dist/web/assets/{chevron-up-ARFlXMyO.js → chevron-up-DAc3NX1J.js} +1 -1
- package/dist/web/assets/{chip-BV_1-tIb.js → chip-CDUNxQW2.js} +1 -1
- package/dist/web/assets/{chunk-2J33WTMH-CWR7tRuT.js → chunk-2J33WTMH-BYRdUeyt.js} +1 -1
- package/dist/web/assets/{chunk-4BX2VUAB-CAulp4D5.js → chunk-4BX2VUAB-3si_kPmV.js} +1 -1
- package/dist/web/assets/{chunk-55IACEB6-DqkKXsbD.js → chunk-55IACEB6-JiMm9u33.js} +1 -1
- package/dist/web/assets/{chunk-727SXJPM-B19m45Sq.js → chunk-727SXJPM-CMCFIUyF.js} +1 -1
- package/dist/web/assets/{chunk-AQP2D5EJ-CuODwkza.js → chunk-AQP2D5EJ-CzvnZjH5.js} +1 -1
- package/dist/web/assets/{chunk-FMBD7UC4-CbUAjtCT.js → chunk-FMBD7UC4-hsabZkPl.js} +1 -1
- package/dist/web/assets/{chunk-ND2GUHAM-C54VxArl.js → chunk-ND2GUHAM-D2o-Reeo.js} +1 -1
- package/dist/web/assets/{chunk-QZHKN3VN-D54Uw5fD.js → chunk-QZHKN3VN-ASJk-E7d.js} +1 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-CjJqgIpK.js +1 -0
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-CjJqgIpK.js +1 -0
- package/dist/web/assets/{code-block-OCS4YCEC-CtAySD1h.js → code-block-OCS4YCEC-5bkFBowa.js} +1 -1
- package/dist/web/assets/{confirm-dialog-CCjHVFTv.js → confirm-dialog-Bs80kXB9.js} +1 -1
- package/dist/web/assets/{content-DZozZbBD.js → content-DAccroCT.js} +1 -1
- package/dist/web/assets/{copy-C-jvx2et.js → copy-D1XK3OqK.js} +1 -1
- package/dist/web/assets/{cose-bilkent-S5V4N54A-BaB2EVcU.js → cose-bilkent-S5V4N54A-C52UKnOd.js} +1 -1
- package/dist/web/assets/{cssMode-wd7JR1S4.js → cssMode-BFq_c5xU.js} +1 -1
- package/dist/web/assets/{dagre-BM42HDAG-C2j1Y8pO.js → dagre-BM42HDAG-CeEute93.js} +1 -1
- package/dist/web/assets/{diagram-2AECGRRQ-CF-EvpV9.js → diagram-2AECGRRQ-CEcq4W4S.js} +1 -1
- package/dist/web/assets/{diagram-5GNKFQAL-rBNso835.js → diagram-5GNKFQAL-DqQe7Rr7.js} +1 -1
- package/dist/web/assets/{diagram-KO2AKTUF-6NW-oos1.js → diagram-KO2AKTUF-C1KVZphS.js} +1 -1
- package/dist/web/assets/{diagram-LMA3HP47-DTfRxRLT.js → diagram-LMA3HP47-D1BL7GQh.js} +1 -1
- package/dist/web/assets/{diagram-OG6HWLK6-CS4Ae-hD.js → diagram-OG6HWLK6-ngyXooqC.js} +1 -1
- package/dist/web/assets/{dialog-DV4wfpNU.js → dialog-XkZ8wMQa.js} +1 -1
- package/dist/web/assets/{erDiagram-TEJ5UH35-Dw9QQctN.js → erDiagram-TEJ5UH35-D1zIFVqE.js} +1 -1
- package/dist/web/assets/{file-Btui_I8Z.js → file-CXCll7Pm.js} +1 -1
- package/dist/web/assets/{flowDiagram-I6XJVG4X-BGZ9q86S.js → flowDiagram-I6XJVG4X-BZu49qcj.js} +1 -1
- package/dist/web/assets/{folder-picker-DiR-8Qdl.js → folder-picker-CVkaEJEL.js} +1 -1
- package/dist/web/assets/{freemarker2-yVWXzD3l.js → freemarker2-CmhadAeB.js} +1 -1
- package/dist/web/assets/{ganttDiagram-6RSMTGT7-CkGun0no.js → ganttDiagram-6RSMTGT7-eJ8yBxfS.js} +1 -1
- package/dist/web/assets/{gitGraphDiagram-PVQCEYII-Bz3oiYvi.js → gitGraphDiagram-PVQCEYII-DpeUUyH_.js} +1 -1
- package/dist/web/assets/{globe-DAFqpAcW.js → globe-WnxN1JzY.js} +1 -1
- package/dist/web/assets/{handlebars-BPf0z6eN.js → handlebars-DtjmH1qR.js} +1 -1
- package/dist/web/assets/{html-HCTCjfUg.js → html-DOYAlzlD.js} +1 -1
- package/dist/web/assets/{htmlMode-BDkbsknt.js → htmlMode-ORxd7KRN.js} +1 -1
- package/dist/web/assets/{index-BMcLxIvZ.js → index-6mINSZng.js} +1 -1
- package/dist/web/assets/{index-BPqjxXmH.js → index-BrjvxKaf.js} +1 -1
- package/dist/web/assets/{index-B8xoIIa6.js → index-CqIyOiVN.js} +4 -4
- package/dist/web/assets/{index-DgUtx9rV.js → index-D9w1zMaz.js} +1 -1
- package/dist/web/assets/{index-DkSPjZm4.js → index-DHDgbH3t.js} +1 -1
- package/dist/web/assets/{index-BszkzNS4.js → index-Dz9SKopM.js} +13 -13
- package/dist/web/assets/{index-GuczxPxb.js → index-eIXz5Hbk.js} +1 -1
- package/dist/web/assets/{index-DuM6iAxG.js → index-iOIxdF6J.js} +1 -1
- package/dist/web/assets/{index-lZLy5rkr.js → index-wbMiSmsY.js} +1 -1
- package/dist/web/assets/{infoDiagram-5YYISTIA-DYFufUYC.js → infoDiagram-5YYISTIA-BiVrC__7.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-IOkrKRwu.js → ishikawaDiagram-YF4QCWOH-B1kPjO1J.js} +1 -1
- package/dist/web/assets/javascript-CHlWHrtz.js +1 -0
- package/dist/web/assets/{journeyDiagram-JHISSGLW-Btl3yxne.js → journeyDiagram-JHISSGLW-DoTAPPAQ.js} +1 -1
- package/dist/web/assets/{jsonMode-DJPdvFcw.js → jsonMode-BkeQ_C6g.js} +1 -1
- package/dist/web/assets/{kanban-definition-UN3LZRKU-CDryhPbA.js → kanban-definition-UN3LZRKU-CBRmLcce.js} +1 -1
- package/dist/web/assets/{kbd-8RRRm9jd.js → kbd-CTfS0G5-.js} +1 -1
- package/dist/web/assets/{key-round-wojrCrDP.js → key-round-B7gTfpDR.js} +1 -1
- package/dist/web/assets/{layers-BH_LL4b8.js → layers-DE0xXedq.js} +1 -1
- package/dist/web/assets/{linear-BLuwKHze.js → linear-VLiA8Vcw.js} +1 -1
- package/dist/web/assets/{link-jWQOSQOQ.js → link-BSE_nRDT.js} +1 -1
- package/dist/web/assets/{liquid-1y-xg637.js → liquid-BZeg6p1K.js} +1 -1
- package/dist/web/assets/{lspLanguageFeatures-cYkILdCn.js → lspLanguageFeatures-CuFQ2_f9.js} +1 -1
- package/dist/web/assets/{mdx-CRg4Q6aP.js → mdx-C7xLyFFX.js} +1 -1
- package/dist/web/assets/{menu-CMqbaDni.js → menu-Dp4RDxvP.js} +1 -1
- package/dist/web/assets/{mermaid-NOHMQCX5-CYeAhOl-.js → mermaid-NOHMQCX5-C2enCJxR.js} +62 -62
- package/dist/web/assets/{message-square-DykJ2lWP.js → message-square-4lyHjyHe.js} +1 -1
- package/dist/web/assets/{mindmap-definition-RKZ34NQL-B5wtw1Rv.js → mindmap-definition-RKZ34NQL-C1OOtqma.js} +1 -1
- package/dist/web/assets/{modal-BwOwTzij.js → modal-BGglpgrR.js} +1 -1
- package/dist/web/assets/{monaco-CcHqpOKe.js → monaco-B-6VmJO0.js} +3 -3
- package/dist/web/assets/{nav-row-BmtdNLxR.js → nav-row-DaR8yP7p.js} +1 -1
- package/dist/web/assets/{paperclip-C4t49vX2.js → paperclip-DORF2rEM.js} +1 -1
- package/dist/web/assets/{pencil-BQ5_raiB.js → pencil-BG033B74.js} +1 -1
- package/dist/web/assets/{people-Dr0v8HK0.js → people-1qyKeYq6.js} +1 -1
- package/dist/web/assets/{pieDiagram-4H26LBE5-BZ3VoaNI.js → pieDiagram-4H26LBE5-BYYFVqOS.js} +1 -1
- package/dist/web/assets/{popover-CTqvKqTR.js → popover-CvjMbMb4.js} +1 -1
- package/dist/web/assets/{python-Huq_acyd.js → python-TTfnYnjF.js} +1 -1
- package/dist/web/assets/{quadrantDiagram-W4KKPZXB-C6ArHmnG.js → quadrantDiagram-W4KKPZXB-DTllM2j9.js} +1 -1
- package/dist/web/assets/{razor-Clc87Ivb.js → razor-BFVXAHVd.js} +1 -1
- package/dist/web/assets/{requirementDiagram-4Y6WPE33-DiLzBRQP.js → requirementDiagram-4Y6WPE33-DeJDRYUP.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-5OEKKPKP-QlYYd7IZ.js → sankeyDiagram-5OEKKPKP-DzTvEKv8.js} +1 -1
- package/dist/web/assets/{search-CMIAPUEt.js → search-DDRcBORc.js} +1 -1
- package/dist/web/assets/{select-DqB7YF38.js → select-CXC17bJx.js} +1 -1
- package/dist/web/assets/{select-Bg7NI8i0.js → select-CzXL3ZbG.js} +1 -1
- package/dist/web/assets/{sequenceDiagram-3UESZ5HK-COKEtqc0.js → sequenceDiagram-3UESZ5HK-CIYrA1ww.js} +1 -1
- package/dist/web/assets/{server-D7knl8H9.js → server-KqeWHfgr.js} +1 -1
- package/dist/web/assets/{stateDiagram-AJRCARHV-1RZZZdOe.js → stateDiagram-AJRCARHV-Dg_UXkEq.js} +1 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-Lc4r0bC3.js +1 -0
- package/dist/web/assets/{textarea-BCY2J2ca.js → textarea-Cmbv5l35.js} +1 -1
- package/dist/web/assets/{timeline-definition-PNZ67QCA-IJl1LY6J.js → timeline-definition-PNZ67QCA-CfSPMqxF.js} +1 -1
- package/dist/web/assets/{toggles-C4LmZwyo.js → toggles-t5v4QKn6.js} +1 -1
- package/dist/web/assets/{tooltip-Cirpotu3.js → tooltip-Cp8tovqH.js} +1 -1
- package/dist/web/assets/{track-Cv7h6oaE.js → track-C1rUV49K.js} +1 -1
- package/dist/web/assets/{trash-2-BEOQ1ICJ.js → trash-2-Ca2ken6q.js} +1 -1
- package/dist/web/assets/{tsMode-CHIbCBQc.js → tsMode-DBbiXlyu.js} +1 -1
- package/dist/web/assets/{typescript-CScj0bbb.js → typescript-jv_3P9x_.js} +1 -1
- package/dist/web/assets/{upload-tLVD0xMT.js → upload-CgGjN1FH.js} +1 -1
- package/dist/web/assets/{use-profiles-TkoP4Yw9.js → use-profiles-BdL-U8GZ.js} +1 -1
- package/dist/web/assets/{use-providers-Bz6YNiYj.js → use-providers-B6Mj5qeG.js} +1 -1
- package/dist/web/assets/{use-translation-settings-CCpQNS30.js → use-translation-settings-FIP674t9.js} +1 -1
- package/dist/web/assets/{useNormalizedLogs-Bstb98cF.js → useNormalizedLogs-FpVMUHeq.js} +1 -1
- package/dist/web/assets/useTokenUsage-Ay3Yy0_V.js +1 -0
- package/dist/web/assets/{vennDiagram-CIIHVFJN-DzVayy4U.js → vennDiagram-CIIHVFJN-DKREAIRT.js} +1 -1
- package/dist/web/assets/{wardley-L42UT6IY-CULSKh55.js → wardley-L42UT6IY-BMpDotAz.js} +1 -1
- package/dist/web/assets/{wardleyDiagram-YWT4CUSO-C5_h3lAA.js → wardleyDiagram-YWT4CUSO-DAPccQsF.js} +1 -1
- package/dist/web/assets/{xml-XuycSwh6.js → xml-DnxIQwRS.js} +1 -1
- package/dist/web/assets/{xychartDiagram-2RQKCTM6-F65naXcR.js → xychartDiagram-2RQKCTM6-o06g8vo8.js} +1 -1
- package/dist/web/assets/{yaml-BWm159lw.js → yaml-BV5yQTRd.js} +1 -1
- package/dist/web/index.html +1 -1
- package/node_modules/@agent-tower/shared/dist/log-adapter.d.ts +4 -0
- package/node_modules/@agent-tower/shared/dist/log-adapter.d.ts.map +1 -1
- package/node_modules/@agent-tower/shared/dist/log-adapter.js +1 -0
- package/node_modules/@agent-tower/shared/dist/log-adapter.js.map +1 -1
- package/node_modules/@agent-tower/shared/dist/translation.d.ts +4 -1
- package/node_modules/@agent-tower/shared/dist/translation.d.ts.map +1 -1
- package/node_modules/@agent-tower/shared/dist/translation.js +4 -1
- package/node_modules/@agent-tower/shared/dist/translation.js.map +1 -1
- package/node_modules/@agent-tower/shared/dist/types.d.ts +38 -2
- package/node_modules/@agent-tower/shared/dist/types.d.ts.map +1 -1
- package/node_modules/@agent-tower/shared/dist/types.js.map +1 -1
- package/package.json +2 -1
- package/prisma/migrations/20261106000000_add_session_wakeups/migration.sql +28 -0
- package/prisma/schema.prisma +28 -0
- package/scripts/postinstall.js +23 -0
- package/dist/web/assets/AttachmentPreview-TPd4gdfb.js +0 -2
- package/dist/web/assets/CreateTaskInput-TcZpjBe-.js +0 -1
- package/dist/web/assets/TaskHandoffPanel-CJahUKNo.js +0 -70
- package/dist/web/assets/channel-CDkuQ_7m.js +0 -1
- package/dist/web/assets/check-yNWhPvMH.js +0 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-eHY73FGu.js +0 -1
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-eHY73FGu.js +0 -1
- package/dist/web/assets/javascript-DKmxrNeR.js +0 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-CCLmVs34.js +0 -1
- package/dist/web/assets/useTokenUsage-D7SEwXb0.js +0 -1
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/monaco-B-6VmJO0.js","assets/index-Dz9SKopM.js","assets/index-408ws6FY.css","assets/monaco-Dvl_Svmm.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as Pe,r as A,cp as Mn,cq as Pn,c as pe,u as re,bw as Dn,bp as Bn,au as as,j as t,a5 as ce,aA as On,l as Q,aC as Hs,n as Ct,p as ne,ai as In,cr as sr,q as ie,m as Ee,cs as ot,af as be,ag as Le,ah as mt,J as Ze,ax as qt,B as ge,ct as Vr,cu as Fn,bb as Gr,cv as Hn,aw as zn,X as tt,a3 as zs,ay as Wn,cn as Ws,a2 as Je,cw as Qr,cx as Zr,aE as vt,a0 as $s,cy as $n,_ as Gt,cz as Jr,ao as We,as as He,O as Un,cA as qn,cB as Kn,cC as Xn,ae as Nt,t as ke,aW as ei,ab as _e,aB as xe,aU as _t,ac as yt,bB as Yn,aj as Oe,aq as Qt,cD as kt,bF as Vn,b9 as ti,s as Es,bl as si,bH as Gn,aD as Ye,a6 as Wt,bf as Qn,am as Zn,ba as ri,cE as ii,cF as ni,cG as rr,cH as oi,cI as ir,ar as nr,a9 as Jn,b2 as ai,bz as eo}from"./index-Dz9SKopM.js";import{L as li,m as to,t as so}from"./ProjectKanbanPage-Cp3rdFik.js";import{P as pt,T as ro}from"./trash-2-Ca2ken6q.js";import{e as js,M as io,f as ci,h as no,i as oo,j as ao,k as lo,l as di,m as co,p as ho,o as uo,q as fo,Q as hi,t as mo,v as Pt,w as po,x as go,y as vo,T as _o,s as bo}from"./mermaid-NOHMQCX5-C2enCJxR.js";import{e as xo,c as So,A as yo,i as wo,b as Co,a as ko,p as ui,j as Eo,k as jo}from"./AttachmentPreview-hD3g_T_y.js";import{u as fi}from"./use-translation-settings-FIP674t9.js";import{u as Us}from"./use-providers-B6Mj5qeG.js";import{M as Ue}from"./MemberAvatar-DBab_9EO.js";import{C as Ke}from"./chevron-down-CtAk9uZw.js";import{C as mi}from"./chevron-up-DAc3NX1J.js";import{A as or}from"./at-sign-CZAKOH3i.js";import{P as To}from"./paperclip-DORF2rEM.js";import{C as Et}from"./check-C3vuSPKz.js";import{F as No}from"./tooltip-Cp8tovqH.js";import{u as Ao,T as Ro}from"./useTokenUsage-Ay3Yy0_V.js";import{a as Lo,I as $e}from"./BrandLogo-BSwQa2SF.js";import{C as Mo}from"./confirm-dialog-Bs80kXB9.js";import{M as At}from"./modal-BGglpgrR.js";import{S as Xe}from"./select-CXC17bJx.js";import{i as pi}from"./provider-selection-DSu7SCI7.js";import{L as Ts}from"./layers-DE0xXedq.js";import{M as Po}from"./message-square-4lyHjyHe.js";import{T as Do}from"./textarea-Cmbv5l35.js";import{r as Bo,P as Oo,a as gi,h as Io,f as vi,k as _i,H as Kt,F as bi,l as Fo,C as xi,d as Ho}from"./content-DAccroCT.js";import{M as Si,a as yi,b as wi,p as zo,d as Wo,e as $o}from"./menu-Dp4RDxvP.js";import{Z as Uo,g as ar,e as qo}from"./CreateTaskInput-Bric0GeW.js";import{S as Ns}from"./server-KqeWHfgr.js";import{F as qs,S as Ko,I as Xo}from"./popover-CvjMbMb4.js";import{m as Ci,f as Yo,n as Vo,B as Go,b as Qo,o as ki,p as Ei,u as ji,q as Zo,r as Jo,d as ea,l as ta,c as sa}from"./BranchSelect-BkuXnEG2.js";import{U as Ks}from"./upload-CgGjN1FH.js";import{G as Ti}from"./globe-WnxN1JzY.js";import{a as ht,l as ra}from"./ExecutionPermissionSelector-BgrxbvBB.js";import{S as ia}from"./select-CzXL3ZbG.js";import{P as na}from"./pencil-BG033B74.js";function Ni(e,i){const s=Pe(i);return oa({filters:{...e,status:"pending"}},s).length}function lr(e,i){return e.findAll(i.filters).map(s=>i.select?i.select(s):s.state)}function oa(e={},i){const s=Pe(i).getMutationCache(),a=A.useRef(e),p=A.useRef(null);return p.current===null&&(p.current=lr(s,e)),A.useEffect(()=>{a.current=e}),A.useSyncExternalStore(A.useCallback(v=>s.subscribe(()=>{const w=Mn(p.current,lr(s,a.current));p.current!==w&&(p.current=w,Pn.schedule(v))}),[s]),()=>p.current,()=>p.current)}const aa=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Ai=pe("arrow-right",aa);const la=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ri=pe("ban",la);const ca=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],da=pe("chevron-left",ca);const ha=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],ua=pe("circle",ha);const fa=[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]],ma=pe("clipboard-paste",fa);const pa=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ve=pe("clock-3",pa);const ga=[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],cr=pe("copy-plus",ga);const va=[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],_a=pe("earth",va);const ba=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],Xf=pe("ellipsis-vertical",ba);const xa=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],As=pe("file-code-corner",xa);const Sa=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],ya=pe("file-exclamation-point",Sa);const wa=[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v6",key:"158jrl"}],["circle",{cx:"5",cy:"18",r:"3",key:"104gr9"}],["path",{d:"M12 3v18",key:"108xh3"}],["circle",{cx:"19",cy:"6",r:"3",key:"108a5v"}],["path",{d:"M16 15.7A9 9 0 0 0 19 9",key:"1e3vqb"}]],Xs=pe("git-graph",wa);const Ca=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],ka=pe("maximize",Ca);const Ea=[["path",{d:"M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4",key:"re6nr2"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"pqwjuv"}]],ja=pe("notebook-pen",Ea);const Ta=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],Na=pe("panel-left-close",Ta);const Aa=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],Ra=pe("panel-left-open",Aa);const La=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],Ma=pe("panel-right-close",La);const Pa=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],Rs=pe("panel-right-open",Pa);const Da=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],Ba=pe("pen-line",Da);const Oa=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],Li=pe("settings-2",Oa);const Ia=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],Dt=pe("user-plus",Ia);const Fa=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Ha=pe("zoom-in",Fa);const za=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Wa=pe("zoom-out",za),$a=32768;function Yf({task:e,onSelectTask:i,onCreateSubtask:s}){const{t:a}=re(),p=Dn(e.parentTaskId??""),v=Bn(e.id,as(e)),w=v.data?.pages[0]?.total??e.subtaskCount??0;return t.jsxs("section",{className:"flex h-full min-h-0 flex-col","aria-label":a("Subtasks"),children:[e.parentTaskId&&t.jsx("div",{className:"shrink-0 border-b border-border/60 px-3 py-2",children:t.jsxs(ce,{variant:"link",size:"sm",className:"max-w-full",onClick:()=>i?.(e.parentTaskId),children:[t.jsx(li,{size:14,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:a("Parent task: {title}",{title:p.data?.titlePreview??p.data?.title??a("Loading...")})})]})}),t.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3 py-2",children:[t.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:a("{count} subtasks",{count:w})}),s&&as(e)&&!e.projectArchivedAt&&t.jsxs(ce,{variant:"ghost",size:"sm",onClick:()=>s(e.id),children:[t.jsx(pt,{size:14}),a("Create subtask")]})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-2 py-2",children:[!as(e)&&t.jsx("p",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:a("Tasks support at most three levels")}),v.isLoading&&t.jsx("p",{className:"px-2 py-1 text-xs text-muted-foreground",children:a("Loading...")}),v.isError&&t.jsx(ce,{variant:"ghost",size:"sm",onClick:()=>v.refetch(),children:a("Could not load subtasks. Retry")}),v.data?.pages.flatMap(r=>r.data).map(r=>{const o=On[to(r.displayStatus??r.status)];return t.jsxs(ce,{variant:"ghost",size:"sm",className:"w-full justify-start",title:r.title,onClick:()=>i?.(r.id),children:[t.jsx(o.icon,{className:Q("size-3.5 shrink-0",o.accentClass)}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:r.title}),t.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:a(o.label)})]},r.id)}),v.data&&w===0&&t.jsx("p",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:a("No subtasks yet")}),v.hasNextPage&&t.jsx(ce,{variant:"ghost",size:"sm",disabled:v.isFetchingNextPage,onClick:()=>v.fetchNextPage(),children:a("Load more")})]})]})}function Mi({taskId:e,teamRunId:i,enabled:s=!0,showDeliveries:a=!0}){const{t:p}=re(),v=Pe(),w=fi(),r=js(s?`task:${e}`:"","pending","TEAM_TASK"),o=Hs({queryKey:["team-task-inputs",i],initialPageParam:void 0,queryFn:({pageParam:l})=>ne.get(`/team-runs/${i}/task-inputs${l?`?cursor=${encodeURIComponent(l)}`:""}`),getNextPageParam:l=>l.nextCursor??void 0,enabled:s&&!!i,refetchInterval:2e3}),u=Ct({mutationFn:({input:l,action:g})=>xo(`task-input:${l.id}`,{action:g,expectedRevision:l.revision},m=>{const{clientSubmissionId:y,...b}=m;return ne.post(`/team-runs/${i}/task-inputs/${l.id}/actions`,{...b,actionId:y})}),onSettled:()=>{v.invalidateQueries({queryKey:["team-task-inputs",i]}),v.invalidateQueries({queryKey:["message-deliveries",`task:${e}`]})}}),f=Ct({mutationFn:l=>ne.get(`/team-runs/${i}/task-inputs/${l}`)});return s?t.jsxs("div",{className:"space-y-2 text-xs","aria-live":"polite",children:[a&&r.data?.pages.flatMap(l=>l.items).filter(l=>!["SENT","CANCELLED"].includes(l.state)).map(l=>t.jsx("div",{className:"flex justify-end","data-operation-id":l.id,children:t.jsxs("div",{className:"flex max-w-[85%] min-w-0 flex-col items-end",children:[l.origin==="TEAM_INITIAL"&&t.jsx("p",{className:"mb-1 px-0.5 text-xs text-muted-foreground",children:p("Team creation pending")}),t.jsxs("div",{className:"max-w-full rounded-2xl rounded-tr-sm bg-foreground/[0.08] px-5 py-3.5 text-sm",children:[t.jsx("p",{className:"whitespace-pre-wrap break-words",children:l.originalText}),t.jsx(io,{delivery:l})]}),t.jsx("div",{className:"mt-1 max-w-full px-0.5","data-message-feedback":!0,children:t.jsx(ci,{delivery:l})})]})},l.id)),o.data?.pages.flatMap(l=>l.items).filter(l=>l.state==="PENDING"&&l.consumerCount>0).map(l=>t.jsxs("div",{className:"ml-auto max-w-[85%] space-y-1 px-0.5 text-muted-foreground",children:[t.jsxs("p",{children:[p("Task input"),": ",l.translationState??"PENDING"," ",l.errorCode??""]}),t.jsxs("div",{className:"flex flex-wrap gap-3",children:[t.jsx("button",{type:"button",className:"underline",disabled:f.isPending,onClick:()=>f.mutate(l.id),children:p("查看原文")}),t.jsx("button",{type:"button",className:"underline",disabled:u.isPending,onClick:()=>u.mutate({input:l,action:"send_original"}),children:p("Send original")}),w.data?.enabled===!0&&["FAILED","CANCELLED","QUEUE_FULL","PAUSED_DISABLED","INTERRUPTED"].includes(l.translationState??"")&&t.jsx("button",{type:"button",className:"underline",disabled:u.isPending,onClick:()=>u.mutate({input:l,action:"retry_translation"}),children:p("Retry translation")})]}),f.data?.id===l.id&&t.jsx("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap",children:f.data.originalText})]},l.id)),o.hasNextPage&&t.jsx("button",{type:"button",className:"underline",onClick:()=>{o.fetchNextPage()},children:p("Load more task inputs")}),r.hasNextPage&&t.jsx("button",{type:"button",className:"underline",onClick:()=>{r.fetchNextPage()},children:p("Load more")}),(u.error||f.error)&&t.jsx("p",{role:"alert",children:p("Delivery action failed. Refresh and try again.")}),(r.error||o.error)&&t.jsx("p",{role:"alert",children:p("Failed to restore pending messages")})]}):null}function Vf({taskId:e}){const{t:i}=re(),s=Pe(),a=In(),[p,v]=A.useState(null);let w=!1,r=null;try{w=!!sr(e)}catch(f){r=f.message}const o=r??p,u=async()=>{try{const f=sr(e);f&&await a.mutateAsync({taskId:e,...f}),v(null),s.invalidateQueries({queryKey:["message-deliveries",`task:${e}`]})}catch(f){v(f.message)}};return t.jsxs("div",{className:"space-y-2 py-2","data-team-creation-status":!0,children:[w&&t.jsxs("div",{className:"rounded border p-2 text-xs",children:[t.jsx("p",{children:i("Team creation result unknown. Check the original request.")}),t.jsx("button",{type:"button",className:"underline",disabled:a.isPending,onClick:()=>{u()},children:i("Check team creation")})]}),o&&t.jsx("p",{role:"alert",className:"text-xs text-destructive",children:o}),t.jsx(Mi,{taskId:e,teamRunId:""})]})}function Ua(e){return`${e.mimeType.startsWith("image/")?"!":""}[${e.originalName}](${e.storagePath})`}function $t(e,i){if(i.length===0)return e;const s=new Set(i.map(Ua));return e.split(`
|
|
3
|
+
`).map(a=>{const p=a.match(/^\s*/)?.[0]??"",v=a.trimStart();for(const w of s){if(v===w)return null;if(v.startsWith(`${w} `)||v.startsWith(`${w} `))return`${p}${v.slice(w.length).trimStart()}`}return a}).filter(a=>a!=null).join(`
|
|
4
|
+
`).replace(/\n{3,}/g,`
|
|
5
|
+
|
|
6
|
+
`).trim()}function qa({draft:e,attachmentMarkdown:i,attachmentIds:s,mentions:a}){const v=[e.trim(),i].filter(Boolean).join(`
|
|
7
|
+
|
|
8
|
+
`);return v?{content:v,mentions:a,senderType:"user",...s.length>0?{attachmentIds:s}:{}}:null}function Ka({items:e,renderItem:i,scrollElementRef:s,compact:a}){const[p,v]=A.useState(null),[w,r]=A.useState(0),[o,u]=A.useState(!1),f=A.useCallback(m=>{if(!m)return;const y=s.current??m.closest("[data-room-scroll]");v(y),r(y?.clientHeight??0),u(!0)},[s]);A.useEffect(()=>{if(!p)return;const m=()=>r(p.clientHeight);if(m(),typeof ResizeObserver>"u")return;const y=new ResizeObserver(m);return y.observe(p),()=>y.disconnect()},[p]);const l=a?12:16,g=no({count:e.length,getScrollElement:()=>p,getItemKey:A.useCallback(m=>e[m].key,[e]),estimateSize:()=>160,overscan:6,scrollMargin:l,measureElement:m=>m.getBoundingClientRect().height});return g.shouldAdjustScrollPositionOnItemSizeChange=oo,o?t.jsx("div",{ref:f,children:w>0?t.jsx("div",{style:{position:"relative",height:g.getTotalSize(),width:"100%"},children:g.getVirtualItems().map(m=>t.jsx("div",{"data-index":m.index,"data-room-row":m.key,ref:g.measureElement,style:{position:"absolute",top:m.start-l,left:0,width:"100%",paddingBottom:a?10:12},children:i(e[m.index])},m.key))},"virtual"):t.jsx("div",{className:a?"space-y-2.5":"space-y-3",children:e.slice(-20).map(m=>t.jsx("div",{"data-room-row":m.key,children:i(m)},m.key))},"unmeasured")}):t.jsx("div",{ref:f})}const ze=new WeakMap,lt=()=>new DOMException("Aborted","AbortError"),ls=e=>e instanceof Ze&&[401,403,404].includes(e.status);function Xa(e,i,s){let a=ze.get(e);a||(a=new Map,ze.set(e,a));let p=a.get(i);if(p)p.owners.add(s),s.permission(p.denied);else{const v=new Set;let w=0,r=!1;const o=()=>{p.epoch++,!r&&(r=!0,queueMicrotask(()=>{if(r=!1,a.get(i)===p)for(const g of v)g.refresh()}))},u=()=>{const g=++w;e.emit(mt.SUBSCRIBE,{topic:"team-run",id:i},m=>{if(!(g!==w||a.get(i)!==p)){p.denied=!m.success;for(const y of v)y.permission(!m.success);o()}}),o()},f=g=>{g.teamRunId===i&&o()},l=g=>{if(g==="io server disconnect"){w++,p.denied=!0,p.epoch++;for(const m of v)m.permission(!0)}};p={owners:v,epoch:0,itemGenerations:new Map,denied:!1,dispose:()=>{w++,e.off("connect",u),e.off("disconnect",l),e.off(Le.TRANSLATION_INVALIDATED,f),e.emit(mt.UNSUBSCRIBE,{topic:"team-run",id:i})}},a.set(i,p),e.on("connect",u),e.on("disconnect",l),e.on(Le.TRANSLATION_INVALIDATED,f),v.add(s),e.connected&&u()}return()=>{p.owners.delete(s),p.owners.size||(p.dispose(),a.delete(i))}}function Bt(e,i){return ze.get(e)?.get(i)?.epoch??0}function ut(e,i,s){return ze.get(e)?.get(i)?.itemGenerations.get(s)??0}function Ya(e,i){const s=new Map(e?.map(a=>[a.sourceId,a]));return i.map(a=>{const p=s.get(a.sourceId);return p&&(p.sourceRevision>a.sourceRevision||p.sourceRevision===a.sourceRevision&&p.overlayRevision>a.overlayRevision)?p:a})}async function Va(e,i,s){const a=[];for(let p=0;p<i.length;p+=100){if(s.aborted)throw lt();const v=await ne.get(`/team-runs/${encodeURIComponent(e)}/translations`,{signal:s,params:{messageIds:i.slice(p,p+100).join(",")}});a.push(...v.items)}return a}function Ga(e,i){const s=Pe(),a=Ni({mutationKey:ie.accessAuth.identityChange})>0,p=ot(),[v,w]=A.useState(!1),[,r]=A.useState(0),o=A.useMemo(()=>i.filter(C=>C.teamRunId===e&&C.senderType==="agent"&&C.visibility==="PUBLIC"&&!C.id.startsWith("pending-")),[i,e]),u=A.useMemo(()=>[...new Set(o.map(C=>C.id))].sort(),[o]),f=A.useMemo(()=>o.map(C=>[C.id,C.content,C.contentPreview,C.isTruncated,C.senderId,C.senderInvocationId]),[o]),l=A.useMemo(()=>({teamRunId:e,accessGeneration:p,active:!0,allowed:!1,generation:0,summaries:new Map}),[e,p]),g=A.useRef(new Set(u)),m=A.useRef(new Set(u));g.current=new Set(u);const y=()=>{s.cancelQueries({queryKey:ie.roomTranslations.scope(e)}),s.removeQueries({queryKey:ie.roomTranslations.scope(e)})},b=()=>{if(p!==ot())return;const C=ze.get(be.getSocket())?.get(e);if(C){C.denied=!0;for(const N of C.owners)N.permission(!0)}else l.allowed=!1,l.generation++,w(!0);y()},n=Ee({queryKey:[...ie.roomTranslations.summaries(e),p,u,f],enabled:u.length>0&&!v&&!a,queryFn:async({signal:C})=>{const N=be.getSocket();try{for(let L=0;L<3;L++){const R=Bt(N,e),P=Object.fromEntries(u.map(B=>[B,ut(N,e,B)])),F=await Va(e,u,C);if(C.aborted||ze.get(N)?.get(e)?.denied||p!==ot())throw lt();if(R===Bt(N,e)&&u.every(B=>P[B]===ut(N,e,B)))return{items:F.filter(B=>B.teamRunId===e&&u.includes(B.messageId)),generations:P}}throw new Error("Translation snapshot changed while reading")}catch(L){throw ls(L)&&b(),L}},structuralSharing:(C,N)=>{const L=C,R=N;return{...R,items:Ya(L?.items.filter(P=>L.generations[P.messageId]===R.generations[P.messageId]),R.items)}},refetchOnMount:"always",refetchOnWindowFocus:!0,refetchInterval:5e3,retry:!1,gcTime:0});l.allowed=!v&&!a&&!n.isError&&n.isFetchedAfterMount&&p===ot();const d=n.data?.generations,c=A.useMemo(()=>l.allowed?n.data?.items??[]:[],[l.allowed,n.data]);l.summaries=new Map(c.filter(C=>g.current.has(C.messageId)&&d?.[C.messageId]===ut(be.getSocket(),e,C.messageId)).map(C=>[C.messageId,C])),A.useEffect(()=>{l.active=!0;const C=be.connect(),N=Xa(C,e,{client:s,candidates:()=>g.current,withdraw:L=>{l.summaries.delete(L),r(R=>R+1)},refresh:()=>{s.invalidateQueries({queryKey:ie.roomTranslations.scope(e)},{cancelRefetch:!1})},permission:L=>{L&&(l.allowed=!1,l.generation++,l.summaries.clear(),y()),w(L)}});return()=>{l.active=!1,l.allowed=!1,l.generation++,N(),ze.get(C)?.has(e)||y()}},[s,e,l]),A.useLayoutEffect(()=>{const C=ze.get(be.getSocket())?.get(e),N=[...m.current].filter(L=>!g.current.has(L)&&![...C?.owners??[]].some(R=>R.candidates().has(L)));m.current=new Set(u);for(const L of N){const R=[...ie.roomTranslations.details(e),L];s.cancelQueries({queryKey:R}),s.removeQueries({queryKey:R})}},[s,e,u]),A.useEffect(()=>{if(!n.isSuccess||!n.isFetchedAfterMount)return;const C=new Set(c.map(L=>L.messageId)),N=s.getQueryCache().findAll({queryKey:ie.roomTranslations.details(e)}).filter(L=>u.includes(L.queryKey[3])&&!C.has(L.queryKey[3]));for(const L of N)s.cancelQueries({queryKey:L.queryKey,exact:!0}),s.removeQueries({queryKey:L.queryKey,exact:!0})},[s,e,c,u,n.isSuccess,n.isFetchedAfterMount]);const h=C=>{const N=l.summaries.get(C.messageId);return l.active&&l.allowed&&p===ot()&&g.current.has(C.messageId)&&d?.[C.messageId]===ut(be.getSocket(),e,C.messageId)&&N?.sourceId===C.sourceId&&N.sourceRevision===C.sourceRevision&&N.overlayRevision===C.overlayRevision},_=async C=>{if(!h(C))throw lt();const N=l.generation,L=ut(be.getSocket(),e,C.messageId),R=await s.fetchQuery({queryKey:ie.roomTranslations.full(e,C.messageId,C.sourceId,C.sourceRevision,C.overlayRevision),staleTime:0,gcTime:0,retry:!1,queryFn:async({signal:P})=>{try{for(let F=0;F<3;F++){const B=Bt(be.getSocket(),e),H=await ne.get(`/team-runs/${encodeURIComponent(e)}/messages/${encodeURIComponent(C.messageId)}/translation`,{signal:P}),U=ze.get(be.getSocket())?.get(e);if(P.aborted||p!==ot()||!U||U.denied||L!==ut(be.getSocket(),e,C.messageId)||![...U.owners].some(T=>T.candidates().has(C.messageId))||H.teamRunId!==e||H.messageId!==C.messageId||H.sourceId!==C.sourceId||H.sourceRevision!==C.sourceRevision)throw lt();if(H.overlayRevision>=C.overlayRevision&&B===Bt(be.getSocket(),e))return H}throw new Error("Translation detail changed while reading")}catch(F){throw F instanceof Ze&&F.status===404?S(C):ls(F)&&b(),F}}});if(N!==l.generation||!h(C))throw lt();return R},S=C=>{if(p!==ot())return;const N=ze.get(be.getSocket())?.get(e);if(N){N.itemGenerations.set(C.messageId,(N.itemGenerations.get(C.messageId)??0)+1);for(const L of N.owners)L.withdraw(C.messageId);for(const L of new Set([s,...[...N.owners].map(R=>R.client)])){const R=[...ie.roomTranslations.details(e),C.messageId];L.cancelQueries({queryKey:R}),L.removeQueries({queryKey:R});const P=ie.roomTranslations.summaries(e);L.cancelQueries({queryKey:P}),L.setQueriesData({queryKey:P},F=>F&&{...F,items:F.items.filter(B=>B.messageId!==C.messageId)}),L.invalidateQueries({queryKey:P},{cancelRefetch:!1})}}},k=async C=>{if(!h(C))throw lt();try{await ne.post(`/team-runs/${encodeURIComponent(e)}/translations/${encodeURIComponent(C.sourceId)}/retry`,{expectedRevision:C.sourceRevision})}catch(N){throw N instanceof Ze&&N.status===404?S(C):ls(N)&&b(),N}finally{s.invalidateQueries({queryKey:ie.roomTranslations.summaries(e)},{cancelRefetch:!1})}},E=[...l.summaries.values()],x=ao(`${e}:${p}`,o.map(C=>({id:C.id,revision:0})),E.map(C=>({id:C.messageId,version:`${C.sourceId}:${C.sourceRevision}`,state:C.state})),i.length>0);return{overlays:E,loadFull:_,isCurrent:h,retry:k,claimReveal:x}}const Qa=10,Za=24,Pi=Qa*Za,Ja=8;function el(e,i=Pi){return e>i+Ja}function tl(e,i){return e.includes(i)?e:[...e,i]}function sl(e,i){return e.filter(s=>s!==i)}function rl(e,i){const s=new Map(i.map(a=>[a.id,a]));return e.map(a=>s.get(a)).filter(a=>!!a).map(a=>({memberId:a.id,label:a.name}))}const Zt=new Set(["RUNNING","WAITING_ROOM_REPLY","QUEUED","SESSION_ENDED"]);function dr(e){if(!e)return 0;const i=Date.parse(e);return Number.isNaN(i)?0:i}function il(e,i=[],s=[]){const a=new Set(s.filter(v=>Zt.has(v.status)).map(v=>v.workRequestId));return[...e.map(v=>({kind:"message",key:`message:${v.id}`,sortTime:v.createdAt,order:0,message:v})),...i.filter(v=>v.status==="PENDING_APPROVAL").filter(v=>!a.has(v.id)).map(v=>({kind:"pendingApproval",key:`pending-approval:${v.id}`,sortTime:v.updatedAt??v.createdAt,order:1,request:v}))].sort((v,w)=>{const r=dr(v.sortTime)-dr(w.sortTime);return r!==0?r:v.order!==w.order?v.order-w.order:v.key.localeCompare(w.key)})}function nl(e){switch(e){case"RUNNING":return"Working";case"QUEUED":return"Queued...";case"WAITING_ROOM_REPLY":return"Waiting reply...";case"SESSION_ENDED":return"Session ended";default:return e}}function ol(e){switch(e){case"FAILED":return"text-destructive-ink";case"RUNNING":case"WAITING_ROOM_REPLY":case"QUEUED":case"SESSION_ENDED":return"text-muted-foreground";default:return"text-muted-foreground"}}function al(e,i){const s=e.reduce((p,v)=>(p[v.status]=(p[v.status]??0)+1,p),{});return[["RUNNING","running"],["QUEUED","queued"],["WAITING_ROOM_REPLY","waiting"],["SESSION_ENDED","ended"]].map(([p,v])=>{const w=s[p];return w?`${w} ${i(v)}`:null}).filter(p=>!!p).join(" · ")}function ll(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(min-width: 768px)").matches}function cl({status:e}){const{t:i}=re();return e==="RUNNING"?t.jsxs(t.Fragment,{children:[i("Working"),t.jsxs("span",{className:"active-work-dots","aria-hidden":"true",children:[t.jsx("span",{children:"."}),t.jsx("span",{className:"active-work-dots__second",children:"."}),t.jsx("span",{className:"active-work-dots__third",children:"."})]})]}):t.jsx(t.Fragment,{children:i(nl(e))})}function dl({invocations:e,memberById:i,workRequestById:s,onViewInvocationSession:a,onStopMember:p,isStopPending:v,stoppingMemberId:w,stopPromptInvocationId:r,onToggleStopConfirm:o}){const{t:u}=re(),[f,l]=A.useState(ll),g=A.useMemo(()=>e.filter(y=>Zt.has(y.status)).sort((y,b)=>Date.parse(b.updatedAt??b.createdAt??"")-Date.parse(y.updatedAt??y.createdAt??"")),[e]);if(g.length===0)return null;const m=al(g,u);return t.jsxs("div",{className:"border-t border-border bg-muted/40",children:[t.jsxs("button",{type:"button",onClick:()=>l(y=>!y),"aria-expanded":f,className:"flex h-8 w-full items-center justify-between gap-3 px-3 text-left text-xs text-foreground/70 transition-colors hover:bg-accent",children:[t.jsxs("span",{className:"min-w-0 truncate",children:[t.jsx("span",{className:"font-medium text-foreground",children:u("Active work")}),t.jsx("span",{className:"mx-1.5 text-muted-foreground",children:"·"}),t.jsx("span",{children:m})]}),f?t.jsx(Ke,{size:15,className:"shrink-0 text-muted-foreground/70"}):t.jsx(mi,{size:15,className:"shrink-0 text-muted-foreground/70"})]}),f&&t.jsx("div",{className:"max-h-32 overflow-y-auto border-t border-border",children:g.map(y=>{const b=i.get(y.memberId),n=s.get(y.workRequestId),d=!!(y.sessionId&&a),c=!!b,h=r===y.id,_=v&&w===y.memberId,S=n?.instruction??y.workRequestId;return t.jsxs("div",{className:"border-t border-border/60 first:border-t-0",children:[t.jsxs("div",{title:S,className:Q("group flex h-8 items-center gap-2 px-3 text-xs text-foreground/80",d?"cursor-pointer hover:bg-background":"cursor-default"),role:d?"button":void 0,tabIndex:d?0:void 0,onClick:()=>y.sessionId&&a?.(y.sessionId),onKeyDown:k=>{!d||!y.sessionId||(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),a?.(y.sessionId))},children:[t.jsx(Ue,{name:b?.name??u("Agent"),avatar:b?.avatar??null,size:"xs",className:"size-4"}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[t.jsx("span",{className:"truncate font-medium text-foreground",children:b?.name??u("Agent")}),t.jsx("span",{className:Q("shrink-0",ol(y.status)),children:t.jsx(cl,{status:y.status})})]}),d&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),y.sessionId&&a?.(y.sessionId)},onKeyDown:k=>k.stopPropagation(),className:"hidden shrink-0 rounded-md p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground/80 group-hover:inline-flex",title:u("View log"),"aria-label":`${u("View log")} ${b?.name??u("Agent")}`,children:t.jsx(Rs,{size:13})}),c&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),o(y.id)},onKeyDown:k=>k.stopPropagation(),disabled:_,className:"shrink-0 rounded-md p-1 text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive-ink disabled:cursor-not-allowed disabled:opacity-50",title:u("Stop"),"aria-label":`${u("Stop")} ${b?.name??u("Agent")}`,children:t.jsx(qt,{size:12})})]}),c&&h&&b&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 border-t border-border/60 bg-background px-3 py-2",children:[t.jsx("span",{className:"mr-1 text-xs text-foreground/70",children:u("Stop running work?")}),t.jsxs(ge,{type:"button",size:"xs",variant:"outline",disabled:_,onClick:()=>p(b.id,!1),children:[t.jsx(qt,{size:11}),t.jsx("span",{children:u(_?"Stopping":"Stop only")})]}),t.jsxs(ge,{type:"button",size:"xs",variant:"outline",disabled:_,className:"border-destructive/25 bg-destructive/10 text-destructive-ink hover:bg-destructive/15 hover:text-destructive-ink",onClick:()=>p(b.id,!0),children:[t.jsx(Ri,{size:11}),t.jsx("span",{children:u(_?"Stopping":"Stop + clear queue")})]})]})]},y.id)})})]})}const Ls=$s(),hl=240;function cs(e,i){return{id:i.clientSubmissionId??Gr(),submissionInput:i,teamRunId:e,senderType:i.senderType??"user",senderId:i.senderId??null,senderInvocationId:i.senderInvocationId??null,kind:i.kind??((i.mentions?.length??0)>0?"work_request":"chat"),visibility:"PUBLIC",content:i.content,mentions:i.mentions??[],workRequestIds:[],artifactRefs:i.artifactRefs??[],attachmentIds:i.attachmentIds??[],createdAt:new Date().toISOString(),pendingStatus:"sending"}}function Xt(e){return"pendingStatus"in e}function ul(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function fl(e){if(!e)return"";const i=new Date(e);return Number.isNaN(i.getTime())?"":i.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Ys(e,i){return e instanceof Error?e.message:i}function ml(e,i=hl){const s=(e??"").replace(/\s+/g," ").trim();return s.length<=i?s:`${s.slice(0,i-3).trimEnd()}...`}function pl(e,i){const a=e.slice(0,i).match(/(^|\s)@([^\s@]*)$/);return!a||a.index==null?null:{start:a.index+a[1].length,end:i,query:a[2]??""}}function gl(e,i){const s=i.trim().toLowerCase();return s?[e.name,e.providerId,...e.aliases??[]].some(p=>p.toLowerCase().includes(s)):!0}function hr(e){return e.membershipStatus!=="REMOVED"}function vl(e,i){return e.label??i.get(e.memberId)?.name??e.memberId}function _l(e,i){return(e.recipientMemberIds??[]).map(s=>i.get(s)?.name??s)}function bl(e,i){const s=e.mentions??[],a=e.contentPreview??e.content;if(s.length===0)return a;const p=s.map(w=>vl(w,i)).filter(w=>w&&!a.includes(`@${w}`));if(p.length===0)return a;const v=p.map(w=>`@${w}`).join(" ");return a.trimEnd()?`${a.trimEnd()} ${v}`:v}function xl(e,i,s){if(e.senderType!=="agent")return null;if(e.senderId&&i.has(e.senderId))return i.get(e.senderId)??null;if(e.senderInvocationId){const a=s.get(e.senderInvocationId);if(a?.memberId&&i.has(a.memberId))return i.get(a.memberId)??null}return null}function Di({content:e,workingDir:i,onOpenWorkspaceFile:s,onOpenPreviewUrl:a,onOpenVisualization:p,downloadSessionId:v}){const w=A.useMemo(()=>p||v?ho(e):e,[e,v,p]),r=uo(w),o=A.useMemo(()=>fo({workingDir:i,onOpenWorkspaceFile:s,onOpenPreviewUrl:a,onOpenVisualization:p,downloadSessionId:v}),[v,a,p,s,i]);return t.jsx("div",{className:Q("team-room-message-markdown prose prose-sm max-w-none break-words [overflow-wrap:anywhere]","prose-p:my-2 prose-p:first:mt-0 prose-p:last:mb-0 prose-p:leading-6","prose-ul:my-2 prose-ol:my-2 prose-li:my-1 prose-li:pl-0 prose-li:leading-6 prose-li:marker:text-muted-foreground","prose-blockquote:my-2 prose-blockquote:border-l-2 prose-blockquote:border-border prose-blockquote:pl-3 prose-blockquote:text-foreground/70","prose-pre:my-3 prose-pre:max-w-full prose-pre:overflow-x-auto prose-pre:rounded-md prose-pre:border prose-pre:border-border/60 prose-pre:bg-foreground/[0.025] prose-pre:p-3 prose-pre:text-xs prose-pre:leading-relaxed","prose-code:break-words prose-code:rounded prose-code:bg-muted prose-code:px-1 prose-code:py-0.5 prose-code:text-[0.9em] prose-code:font-medium prose-code:text-foreground","prose-pre:prose-code:bg-transparent prose-pre:prose-code:p-0 prose-pre:prose-code:text-foreground","prose-headings:mb-2 prose-headings:mt-3 prose-headings:font-semibold prose-headings:leading-snug","prose-hr:my-3 prose-hr:border-border","text-foreground prose-strong:text-foreground"),children:t.jsx(hi,{components:o,plugins:r,controls:r?mo:void 0,children:w})})}function Sl({hasAttachmentIds:e,attachments:i,isLoading:s,onOpenImage:a}){if(!e)return null;if(s&&i.length===0)return t.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"Loading attachments..."});if(i.length===0)return null;const p=i.filter(w=>w.mimeType.startsWith("image/")),v=new Map(p.map((w,r)=>[w.id,r]));return t.jsx("div",{className:"mt-3 flex flex-wrap gap-2 text-foreground/80",children:i.map(w=>{const r=`${Ls}${w.url}`;if(w.mimeType.startsWith("image/")){const u=v.get(w.id)??0;return t.jsxs("button",{type:"button",onClick:()=>a(p,u),className:"group relative h-24 w-24 overflow-hidden rounded-lg border border-border bg-muted/50 shadow-raised transition-opacity hover:opacity-90",title:w.originalName,children:[t.jsx("img",{src:r,alt:w.originalName,className:"h-full w-full object-cover",loading:"lazy"}),t.jsx("span",{className:"absolute inset-x-0 bottom-0 truncate bg-inverse/60 px-1.5 py-1 text-left text-[11px] text-inverse-foreground",children:w.originalName})]},w.id)}return t.jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"flex max-w-[220px] items-center gap-2 rounded-lg border border-border bg-background px-3 py-2 text-xs text-foreground/80 shadow-raised hover:bg-accent",title:w.originalName,children:[t.jsx(No,{size:16,className:"shrink-0 text-muted-foreground/70","aria-hidden":!0}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate font-medium",children:w.originalName}),t.jsx("span",{className:"text-muted-foreground",children:ul(w.sizeBytes)})]}),t.jsx(Ws,{size:13,className:"shrink-0 text-muted-foreground/70","aria-hidden":!0})]},w.id)})})}function Bi({message:e,content:i,attachmentIds:s,isUser:a,tone:p,onOpenImage:v,workingDir:w,onOpenWorkspaceFile:r,onOpenPreviewUrl:o,onOpenVisualization:u,downloadSessionId:f,textVersion:l}){const g=A.useMemo(()=>Array.from(new Set(s??[])),[s]),{data:m=[],isLoading:y}=wo(g),b=m.length>0?$t(i,m):i;return t.jsxs(t.Fragment,{children:[b.trim()&&t.jsx(wl,{message:e,content:b,attachments:m,isUser:a,tone:p,workingDir:w,onOpenWorkspaceFile:r,onOpenPreviewUrl:o,onOpenVisualization:u,downloadSessionId:f,textVersion:l}),t.jsx(Sl,{hasAttachmentIds:g.length>0,attachments:m,isLoading:y,onOpenImage:v})]})}function yl({images:e,index:i,onClose:s,onSelect:a}){const p=e[i];if(!p)return null;const v=i>0,w=i<e.length-1;return t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-inverse/90 p-4",role:"dialog","aria-modal":"true",children:[t.jsx("button",{type:"button",onClick:s,className:"absolute right-4 top-4 rounded-full bg-inverse-foreground/10 p-2 text-inverse-foreground transition-colors hover:bg-inverse-foreground/20","aria-label":"Close image preview",children:t.jsx(tt,{size:20})}),v&&t.jsx("button",{type:"button",onClick:()=>a(i-1),className:"absolute left-4 top-1/2 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-inverse-foreground/10 text-inverse-foreground transition-colors hover:bg-inverse-foreground/20","aria-label":"Previous image",children:t.jsx(da,{size:24,"aria-hidden":!0})}),t.jsxs("div",{className:"flex max-h-full max-w-full flex-col items-center gap-3",children:[t.jsx("img",{src:`${Ls}${p.url}`,alt:p.originalName,className:"max-h-[82vh] max-w-[92vw] rounded-lg object-contain"}),t.jsxs("div",{className:"flex items-center gap-3 text-sm text-inverse-foreground",children:[t.jsx("span",{className:"max-w-[70vw] truncate",children:p.originalName}),t.jsxs("a",{href:`${Ls}${p.url}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-md bg-inverse-foreground/10 px-2 py-1 text-xs hover:bg-inverse-foreground/20",children:[t.jsx(Ws,{size:13,"aria-hidden":!0}),"Open"]})]})]}),w&&t.jsx("button",{type:"button",onClick:()=>a(i+1),className:"absolute right-4 top-1/2 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-inverse-foreground/10 text-inverse-foreground transition-colors hover:bg-inverse-foreground/20","aria-label":"Next image",children:t.jsx(Je,{size:24,"aria-hidden":!0})})]})}const Oi=A.createContext(null);function wl({message:e,content:i,attachments:s,isUser:a,tone:p=a?"user":"agent",workingDir:v,onOpenWorkspaceFile:w,onOpenPreviewUrl:r,onOpenVisualization:o,downloadSessionId:u,textVersion:f}){const{t:l}=re(),g=A.useId(),m=A.useRef(null),y=A.useContext(Oi),[b,n]=A.useState(()=>y?.get(e.id)??null),d=A.useCallback(T=>{T.expanded?y?.set(e.id,T):y?.delete(e.id),n(T)},[y,e.id]),[c,h]=A.useState(!1),[_,S]=A.useState(null),k=Jr(e.teamRunId,e.id,!1),E=f?f.full:k.data?.content,x=E?$t(E,s):void 0,N=!!(x&&x!==i)?x:i,L=!!((f?f.truncated:e.isTruncated)&&!Xt(e)),R=b?.messageId===e.id&&b.content===N&&b.expanded,P=A.useCallback(()=>{const T=m.current;T&&h(el(T.scrollHeight))},[]);A.useLayoutEffect(()=>{P();const T=m.current;if(!T)return;const D=window.requestAnimationFrame(P),M=typeof ResizeObserver>"u"?null:new ResizeObserver(P);return M?.observe(T),window.addEventListener("resize",P),()=>{window.cancelAnimationFrame(D),M?.disconnect(),window.removeEventListener("resize",P)}},[N,P]);const F=A.useCallback(async()=>{if(S(null),R){d({messageId:e.id,content:N,expanded:!1});return}if(L&&!E){if(f){try{const M=await f.load();d({messageId:e.id,content:$t(M,s),expanded:!0})}catch{S(l("Failed to load full message"))}return}const T=await k.refetch();if(T.error){S(Ys(T.error,l("Failed to load full message")));return}const D=T.data?.content?$t(T.data.content,s):N;d({messageId:e.id,content:D,expanded:!0});return}d({messageId:e.id,content:N,expanded:!0})},[s,L,E,k,R,e.id,N,d,l,f]),B=(c||L)&&!R,H=c||L,U=f?f.loading:k.isFetching;return t.jsxs("div",{className:"relative",children:[t.jsxs("div",{id:g,ref:m,onLoadCapture:P,className:Q("relative transition-[max-height] duration-200 ease-out",B?"overflow-hidden":""),style:B?{maxHeight:Pi}:void 0,children:[t.jsx(Di,{content:N,isUser:a,workingDir:v,onOpenWorkspaceFile:w,onOpenPreviewUrl:r,onOpenVisualization:o,downloadSessionId:u}),B&&t.jsx("div",{className:Q("pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-gradient-to-b from-transparent",p==="system"?"to-[color-mix(in_oklab,var(--color-warning)_8%,var(--color-background))]":p==="user"?"to-[color-mix(in_oklab,var(--color-foreground)_8%,var(--color-background))]":"to-background")})]}),H&&t.jsxs("button",{type:"button","aria-expanded":R,"aria-controls":g,"aria-label":l(R?"Collapse message":"Expand full message"),disabled:U,onClick:()=>{F()},className:Q("mt-2 inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",p==="system"?"bg-warning/10 text-warning-ink hover:bg-warning/20":p==="user"?"bg-background/70 text-foreground/70 hover:bg-background hover:text-foreground":"bg-muted text-foreground/70 hover:bg-foreground/10 hover:text-foreground",U?"cursor-wait opacity-70":""),children:[R?t.jsx(mi,{size:13}):t.jsx(Ke,{size:13}),t.jsx("span",{children:l(U?"Loading":R?"Collapse message":"Expand full message")})]}),_&&t.jsx("div",{className:Q("mt-1 text-xs","text-destructive-ink"),children:_})]})}function Ii({senderName:e,avatar:i,createdAt:s,isUser:a,isSystem:p,children:v,headerAddon:w,footer:r,bubbleClassName:o,isPending:u}){return p?t.jsx("div",{className:"flex justify-center",children:t.jsx("div",{className:"max-w-[min(100%,42rem)] rounded-lg border border-warning/25 bg-warning/10 px-3 py-2 text-xs text-warning-ink shadow-raised",children:v})}):t.jsxs("div",{className:Q("group flex items-start gap-3",a?"justify-end pl-8 sm:pl-14":"justify-start pr-8 sm:pr-14"),children:[!a&&t.jsx(Ue,{name:e,avatar:i??null,className:"mt-0.5 h-8 w-8 text-[11px]"}),t.jsxs("div",{className:Q("flex min-w-0 max-w-[min(86%,46rem)] flex-col",a?"items-end":"items-start"),children:[t.jsxs("div",{className:Q("mb-1.5 flex max-w-full items-center gap-1.5 px-0.5 text-xs text-muted-foreground",a?"justify-end":"justify-start"),children:[t.jsx("span",{className:"truncate font-semibold text-foreground/80",children:e}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-foreground/15","aria-hidden":!0}),t.jsx(Ve,{size:11,className:"text-muted-foreground/70"}),t.jsx("span",{className:"shrink-0",children:fl(s)}),w]}),t.jsx("div",{className:Q("max-w-full rounded-lg px-3.5 py-3 text-sm leading-6 transition-colors",a?"rounded-tr-[4px] bg-foreground/[0.08] text-foreground":"rounded-tl-[4px] border border-border/70 bg-background text-foreground",o,u?"opacity-70":""),children:v}),r&&t.jsx("div",{className:"mt-1 max-w-full px-0.5","data-message-feedback":!0,children:r})]}),a&&t.jsx(Ue,{name:e,avatar:null,className:"mt-0.5 h-8 w-8 text-[11px]"})]})}function Cl({provider:e}){return t.jsxs("span",{className:"ml-0.5 inline-flex max-w-[10rem] shrink items-center gap-1 rounded-full bg-foreground/5 px-1.5 py-0.5 text-xs font-medium leading-none text-muted-foreground",children:[t.jsx(Gt,{agentType:e.agentType,className:"size-2.5"}),t.jsx("span",{className:"truncate",children:e.name})]})}function kl({overlay:e,translations:i,enabled:s,body:a}){const{t:p}=re(),[v,w]=A.useState(null),[r,o]=A.useState(!1),[u,f]=A.useState(null),l=A.useRef(null),g=A.useRef(!0);A.useEffect(()=>(g.current=!0,()=>{g.current=!1}),[]);const m=()=>g.current&&i.isCurrent(e),y=async()=>{if(!m())throw new DOMException("Aborted","AbortError");return v||(l.current||(o(!0),f(null),l.current=i.loadFull(e).then(_=>{if(!m())throw new DOMException("Aborted","AbortError");if(!a.message.isTruncated&&a.message.contentMode==="full"&&a.message.content!==_.originalText)throw new Error("Message changed");return w(_),_}).catch(_=>{throw m()&&f(p("Failed to load full message")),_}).finally(()=>{l.current=null,g.current&&o(!1)})),l.current)},b=e.state==="SUCCESS"&&e.translatedTextPreview!==null,n=v?.originalText??e.originalTextPreview,d=v?.translatedText??e.translatedTextPreview??"",c=async()=>e.originalTextTruncated?(await y()).originalText:n,h=async()=>b?e.translatedTextTruncated?(await y()).translatedText??"":d:c();return t.jsxs("div",{className:`relative ${e.state==="NOT_REQUIRED"?"":"pr-8"}`,children:[t.jsx(Bi,{...a,content:b?d:a.content,textVersion:b?{kind:"translated",truncated:e.translatedTextTruncated,full:v?.translatedText??void 0,loading:r,load:h}:void 0}),e.state!=="NOT_REQUIRED"&&t.jsx("div",{className:"absolute bottom-0 right-0",children:t.jsxs(di,{original:n,getOriginal:c,canCopy:m,onOpen:()=>{e.originalTextTruncated&&y().catch(()=>{})},loading:r,error:u,children:[t.jsx(Di,{content:n,workingDir:a.workingDir,onOpenWorkspaceFile:a.onOpenWorkspaceFile,onOpenPreviewUrl:a.onOpenPreviewUrl,onOpenVisualization:a.onOpenVisualization,downloadSessionId:a.downloadSessionId}),t.jsx(co,{state:e.state,errorCode:e.errorCode,enabled:s,onRetry:()=>i.retry(e)})]})})]})}function El({message:e,senderName:i,senderMember:s,senderProvider:a,memberById:p,displayContent:v,onOpenImage:w,workingDir:r,onOpenWorkspaceFile:o,onOpenPreviewUrl:u,onOpenVisualization:f,previewWorkspaceId:l,previewSessionId:g,overlay:m,translations:y,translationEnabled:b,delivery:n,onRetrySubmission:d}){const{t:c}=re(),h=e.senderType==="user",_=e.senderType==="system",S=!n&&Xt(e)?e.pendingStatus:null,k=e.mentions??[],E=e.workRequestIds?.length??0,x=e.visibility==="PRIVATE",C=A.useCallback(F=>{u?.(F,l)},[u,l]),N=A.useCallback(F=>{g&&f?.(g,F,l)},[f,g,l]),L=x?_l(e,p):[],R={message:e,content:v,attachmentIds:e.attachmentIds,isUser:h&&S!=="failed",tone:_?"system":void 0,onOpenImage:w,workingDir:r,onOpenWorkspaceFile:o,onOpenPreviewUrl:u?C:void 0,onOpenVisualization:f&&g?N:void 0,downloadSessionId:g},P=t.jsxs(t.Fragment,{children:[!h&&!_&&a&&t.jsx(Cl,{provider:a}),x&&t.jsxs("span",{className:"ml-0.5 inline-flex max-w-[18rem] shrink items-center gap-1 rounded-full bg-foreground/[0.06] px-1.5 py-0.5 text-xs font-medium leading-none text-foreground/70",title:L.join(", "),children:[t.jsx($n,{size:10}),t.jsxs("span",{className:"truncate",children:[c("Private"),L.length>0?`: ${L.join(", ")}`:""]})]}),!_&&E>0&&k.length===0&&t.jsxs("span",{className:"ml-0.5 shrink-0 rounded-full bg-foreground/[0.08] px-1.5 py-0.5 text-xs font-medium leading-none text-foreground/70",children:[c("Work requests"),": ",E]}),S==="failed"&&t.jsx("span",{className:"ml-0.5 shrink-0 rounded-full bg-destructive/10 px-1.5 py-0.5 text-xs font-medium leading-none text-destructive-ink",children:c("Acceptance unknown")})]});return t.jsx(Ii,{senderName:i,avatar:s?.avatar??null,createdAt:e.createdAt,isUser:h,isSystem:_,headerAddon:P,bubbleClassName:h&&S==="failed"?"border border-destructive/25 bg-destructive/10 text-destructive-ink":void 0,isPending:S==="sending",footer:n||e.userDelivery||S==="failed"?t.jsxs(t.Fragment,{children:[n&&t.jsx(ci,{delivery:n}),e.userDelivery&&!n&&t.jsx(jl,{message:e}),S==="failed"&&!n&&t.jsxs("div",{className:"text-xs",children:[t.jsx("p",{children:c("Acceptance unknown; check or retry the same submission.")}),Xt(e)&&e.error&&t.jsx("p",{children:e.error}),t.jsx("button",{type:"button",className:"underline",onClick:d,children:c("Retry original submission")})]})]}):void 0,children:t.jsx(lo,{claim:b?y.claimReveal:void 0,version:m?.state==="SUCCESS"?`${m.sourceId}:${m.sourceRevision}`:null,blocks:".team-room-message-markdown > div",children:m?t.jsx(kl,{overlay:m,translations:y,enabled:b,body:R},`${m.sourceId}:${m.sourceRevision}:${m.overlayRevision}`):t.jsx(Bi,{...R})})})}function jl({message:e}){const i=Jr(e.teamRunId,e.id,!1),s=e.userDelivery;if(s.sentMode!=="TRANSLATED")return null;const a=i.data?.userDelivery?.actualSentText??s.actualSentText??"",p=async()=>{if(!s.isTruncated)return a;const v=await i.refetch();if(v.error||!v.data?.userDelivery)throw new Error("Failed to load sent text");return v.data.userDelivery.actualSentText??""};return t.jsx(di,{label:"Actual sent text",original:a,getOriginal:p,onOpen:()=>{s.isTruncated&&i.refetch()},loading:i.isFetching,error:i.error?.message,children:t.jsx("pre",{className:"whitespace-pre-wrap",children:a})})}function Tl({request:e,member:i,onApprove:s,onReject:a,isActionPending:p,isApprovePending:v,isRejectPending:w}){const{t:r}=re();return t.jsx(Ii,{senderName:i?.name??r("Agent"),avatar:i?.avatar??null,createdAt:e.createdAt,bubbleClassName:"border border-warning/25 bg-warning/8",children:t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-warning/25 bg-warning/10 px-2 py-0.5 text-xs font-medium text-warning-ink",children:[t.jsx(Ve,{size:11}),r("Pending approval")]}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:[r("Requester"),": ",r(e.requesterType==="user"?"User":e.requesterType==="system"?"System":"Agent")]})]}),t.jsx("div",{className:"text-sm leading-6 text-foreground [overflow-wrap:anywhere]",children:e.instructionPreview??ml(e.instruction)}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs(ge,{type:"button",size:"xs",variant:"outline",disabled:p,className:"border-success/25 bg-success/10 text-success-ink hover:bg-success/15 hover:text-success-ink",onClick:s,children:[t.jsx(Et,{size:12}),t.jsx("span",{children:r(v?"Approving":"Approve")})]}),t.jsxs(ge,{type:"button",size:"xs",variant:"outline",disabled:p,onClick:a,children:[t.jsx(tt,{size:12}),t.jsx("span",{children:r(w?"Rejecting":"Reject")})]})]})]})})}const Nl=A.memo(function({teamRun:i,messages:s,timelineItems:a,recovered:p,scrollElementRef:v,compact:w,onRetrySubmission:r,onOpenImage:o,workingDir:u,onOpenWorkspaceFile:f,onOpenPreviewUrl:l,onOpenVisualization:g}){const{t:m}=re(),y=Qr(i.id),b=Ga(i.id,s),{data:n}=fi(),d=new Map(b.overlays.map(L=>[L.messageId,L])),c=Zr(i.id),{data:h}=Us(),_=A.useMemo(()=>{const L=new Map;for(const R of h??[])L.set(R.provider.id,R.provider);return L},[h]),S=A.useMemo(()=>new Map((i.members??[]).map(L=>[L.id,L])),[i.members]),k=A.useMemo(()=>new Map((i.invocations??[]).map(L=>[L.id,L])),[i.invocations]),E=y.isError?y.error:c.isError?c.error:null,x=y.isPending||c.isPending,[C]=A.useState(()=>new Map);A.useEffect(()=>{const L=new Set(s.map(R=>R.id));for(const R of C.keys())L.has(R)||C.delete(R)},[C,s]);const N=L=>{if(L.kind==="pendingApproval"){const M=L.request,O=S.get(M.targetMemberId),q=y.isPending&&y.variables===M.id,V=c.isPending&&c.variables===M.id;return t.jsx(Tl,{request:M,member:O,onApprove:()=>y.mutate(M.id),onReject:()=>c.mutate(M.id),isActionPending:x,isApprovePending:q,isRejectPending:V},L.key)}const R=L.message,P=xl(R,S,k),F=R.senderType==="user"?m("你"):R.senderType==="system"?m("System"):P?.name??m("Agent"),B=bl(R,S),H=P?.providerId?_.get(P.providerId)??null:null,U=R.senderInvocationId?k.get(R.senderInvocationId):void 0,T=U?.workspaceId??void 0,D=U?.sessionId??void 0;return t.jsx(El,{message:R,senderName:F,senderMember:P,senderProvider:H,memberById:S,displayContent:B,overlay:d.get(R.id),translations:b,translationEnabled:n?.enabled===!0,delivery:p.get(R.userDelivery?.clientSubmissionId??R.id),onRetrySubmission:Xt(R)?()=>r(R):void 0,onOpenImage:o,workingDir:u,onOpenWorkspaceFile:f,onOpenPreviewUrl:l,onOpenVisualization:g,previewWorkspaceId:T,previewSessionId:D},L.key)};return t.jsxs(Oi.Provider,{value:C,children:[a.length===0?t.jsxs("div",{className:"flex min-h-[180px] flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-border bg-background text-muted-foreground",children:[t.jsx(vt,{size:24,className:"text-muted-foreground/70"}),t.jsx("span",{className:"text-sm",children:m("No room messages yet")})]}):t.jsx(Ka,{items:a,renderItem:N,scrollElementRef:v,compact:w}),E&&t.jsx("div",{className:"rounded-md border border-destructive/25 bg-destructive/10 px-3 py-2 text-xs text-destructive-ink",children:Ys(E,m("Failed to update work request"))})]})});function Gf({teamRun:e,messages:i,readOnly:s,readOnlyMessage:a,onSendMessage:p,onViewInvocationSession:v,changeSummaryBar:w,compactComposer:r,centered:o,workingDir:u,onOpenWorkspaceFile:f,onOpenPreviewUrl:l,onOpenVisualization:g}){const{t:m}=re(),y=Vr(e.id),[b,n]=A.useState(""),[d,c]=A.useState(!1),[h,_]=A.useState(null),[S,k]=A.useState(0),[E,x]=A.useState([]),[C,N]=A.useState(!1),L=js(s?"":`task:${e.taskId}`,"pending","TEAM_TASK"),R=js(s?"":`task:${e.taskId}`,"sent","TEAM_TASK"),P=A.useMemo(()=>new Map([...L.data?.pages.flatMap(Y=>Y.items)??[],...R.data?.pages.flatMap(Y=>Y.items)??[]].filter(Y=>Y.destination.kind==="TEAM_ROOM"&&Y.destination.teamRunId===e.id).sort((Y,ee)=>Y.revision-ee.revision).map(Y=>[Y.clientSubmissionId,Y])),[L.data,R.data,e.id]),[F,B]=A.useState([]),[H,U]=A.useState(null),T=A.useRef(null),D=A.useRef(null),{files:M,addFiles:O,removeFile:q,clear:V,buildMarkdownLinks:$,getDoneAttachments:z,isUploading:W}=So(),j=M.some(Y=>Y.status==="done"&&Y.attachment),[I,K]=A.useState(null),{scrollRef:X,contentRef:J,isAtBottom:G,scrollToBottom:Z}=Ao({resize:"instant",initial:"instant"}),ae=A.useRef(!1),he=A.useRef(null),je=A.useRef(e.id),se=A.useCallback(()=>(ae.current=!1,Z({animation:"instant",ignoreEscapes:!0})),[Z]);A.useEffect(()=>{if(je.current===e.id)return;je.current=e.id;const Y=requestAnimationFrame(()=>{se()});return()=>cancelAnimationFrame(Y)},[se,e.id]),A.useEffect(()=>{const Y=X.current;if(!Y)return;const ee=oe=>{if(oe.deltaY<0){ae.current=!0;return}oe.deltaY>0&&Y.scrollHeight-Y.scrollTop-Y.clientHeight<=70&&(ae.current=!1)};return Y.addEventListener("wheel",ee,{passive:!0}),()=>Y.removeEventListener("wheel",ee)},[X]);const Ae=A.useMemo(()=>new Map((e.members??[]).map(Y=>[Y.id,Y])),[e.members]),te=A.useMemo(()=>(e.members??[]).filter(hr),[e.members]),me=A.useMemo(()=>new Set([...i.flatMap(Y=>Y.userDelivery?[Y.userDelivery.clientSubmissionId]:[]),...L.data?.pages.flatMap(Y=>Y.items.map(ee=>ee.clientSubmissionId))??[]]),[i,L.data]);A.useEffect(()=>{for(const Y of me)Fn(e.id,Y);B(Y=>Y.some(ee=>me.has(ee.id))?Y.filter(ee=>!me.has(ee.id)):Y)},[me,e.id]);const De=A.useMemo(()=>{const Y=new Set(i.map(le=>le.id)),ee=new Set(i.flatMap(le=>le.userDelivery?[le.userDelivery.clientSubmissionId]:[])),oe=[...P.values()].filter(le=>le.state!=="CANCELLED"&&!ee.has(le.clientSubmissionId)).map(le=>({...cs(e.id,{content:le.originalText,clientSubmissionId:le.clientSubmissionId,attachmentIds:le.attachmentIds}),pendingStatus:"sending",createdAt:le.createdAt})),ye=F.filter(le=>!Y.has(le.id)&&!ee.has(le.id)&&!P.has(le.id));return[...i,...oe,...ye].sort((le,we)=>Date.parse(le.createdAt??"")-Date.parse(we.createdAt??""))},[i,F,P,e.id]),qe=A.useMemo(()=>new Map((e.workRequests??[]).map(Y=>[Y.id,Y])),[e.workRequests]),ve=A.useMemo(()=>il(De,e.workRequests??[],e.invocations??[]),[De,e.invocations,e.workRequests]);A.useEffect(()=>{const Y=ve.at(-1)?.key??null,ee=he.current;if(he.current=Y,ee==null||Y==null||Y===ee||ae.current)return;const oe=requestAnimationFrame(()=>{Z({animation:"instant",preserveScrollPosition:!0})});return()=>cancelAnimationFrame(oe)},[Z,ve]);const Re=A.useMemo(()=>(e.invocations??[]).filter(Y=>Zt.has(Y.status)),[e.invocations]),Se=A.useMemo(()=>E.map(Y=>Ae.get(Y)).filter(Y=>!!Y).filter(hr),[Ae,E]),Ce=A.useMemo(()=>{const Y=h?.query??"";return te.filter(ee=>gl(ee,Y)).sort((ee,oe)=>{const ye=E.includes(ee.id),le=E.includes(oe.id);return ye!==le?ye?1:-1:ee.name.localeCompare(oe.name)})},[te,h?.query,E]),rt=!s&&(d||!!h)&&Ce.length>0,Te=A.useCallback((Y,ee)=>{if(ee==null){_(null);return}_(pl(Y,ee)),k(0)},[]),it=A.useCallback(Y=>{x(we=>tl(we,Y.id));const ee=`@${Y.name} `;if(h){const we=`${b.slice(0,h.start)}${ee}${b.slice(h.end)}`,dt=h.start+ee.length;n(we),_(null),c(!1),requestAnimationFrame(()=>{T.current?.focus(),T.current?.setSelectionRange(dt,dt)});return}const oe=b.length===0||/\s$/.test(b)?"":" ",ye=`${b}${oe}${ee}`,le=ye.length;n(ye),c(!1),requestAnimationFrame(()=>{T.current?.focus(),T.current?.setSelectionRange(le,le)})},[b,h]),Ie=A.useCallback(Y=>{x(ee=>sl(ee,Y))},[]),nt=A.useCallback(Y=>{const ee=Y.target.value;n(ee);const oe=Y.target;oe.style.height="auto",oe.style.height=`${Math.max(r?40:72,Math.min(oe.scrollHeight,r?140:240))}px`,c(!1),Te(ee,oe.selectionStart)},[r,Te]),ue=A.useCallback(Y=>{const ee=Y.target.files;ee&&ee.length>0&&O(Array.from(ee)),Y.target.value=""},[O]),rs=A.useCallback(Y=>{const ee=[];for(const oe of Y.clipboardData.items)if(oe.kind==="file"){const ye=oe.getAsFile();ye&&ee.push(ye)}ee.length>0&&(Y.preventDefault(),O(ee))},[O]),is=A.useCallback(async()=>{if(s||C||W)return;const Y=$(),ee=z().map(we=>we.id),oe=rl(E,te),ye=qa({draft:b,attachmentMarkdown:Y,attachmentIds:ee,mentions:oe});if(!ye||!b.trim()&&!j)return;ye.clientSubmissionId=Gr();const le=cs(e.id,ye);B(we=>[...we,le]),n(""),x([]),c(!1),_(null),V(),T.current&&(T.current.style.height=r?"40px":"72px"),requestAnimationFrame(()=>se()),N(!0);try{const we=await p(ye);B(dt=>dt.filter(ns=>ns.id!==le.id)),we&&typeof we=="object"&&"id"in we&&requestAnimationFrame(()=>se())}catch(we){const dt=we instanceof Error?we.message:"Failed to send room message";B(ns=>ns.map(os=>os.id===le.id?{...os,pendingStatus:"failed",error:dt}:os)),requestAnimationFrame(()=>se())}finally{N(!1)}},[te,$,V,r,b,z,j,C,W,se,p,s,E,e.id]),Nn=A.useCallback(Y=>{const ee=Y.nativeEvent.isComposing||Y.nativeEvent.keyCode===229;if(rt){if(Y.key==="ArrowDown"){Y.preventDefault(),k(oe=>(oe+1)%Ce.length);return}if(Y.key==="ArrowUp"){Y.preventDefault(),k(oe=>(oe-1+Ce.length)%Ce.length);return}if(Y.key==="Enter"&&!ee||Y.key==="Tab"){Y.preventDefault();const oe=Ce[S]??Ce[0];oe&&it(oe);return}if(Y.key==="Escape"){Y.preventDefault(),_(null),c(!1);return}}Y.key==="Enter"&&!Y.shiftKey&&!Y.repeat&&!ee&&(Y.preventDefault(),is())},[it,is,S,Ce,rt]);A.useEffect(()=>{n(""),x([]),c(!1),_(null),B(Hn(e.id).map(Y=>({...cs(e.id,Y),pendingStatus:"failed",error:"Acceptance unknown; check or retry the same submission."}))),V(),ae.current=!1,he.current=null,U(null),T.current&&(T.current.style.height=r?"40px":"72px")},[V,r,e.id]);const An=A.useCallback((Y,ee)=>{K({images:Y,index:ee})},[]),Rn=A.useCallback(Y=>{C||(N(!0),p(Y.submissionInput).then(()=>B(ee=>ee.filter(oe=>oe.id!==Y.id))).finally(()=>N(!1)).catch(()=>{}))},[C,p]),Ln=A.useCallback((Y,ee)=>{y.mutate({memberId:Y,cancelQueued:ee},{onSuccess:()=>U(null)})},[y]);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background",children:[I&&t.jsx(yl,{images:I.images,index:I.index,onClose:()=>K(null),onSelect:Y=>K(ee=>ee&&{...ee,index:Y})}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:X,"data-room-scroll":!0,className:Q("h-full overflow-y-auto scrollbar-app-thin bg-background",r?"px-3 py-3":"px-4 py-4"),children:t.jsxs("div",{ref:J,className:Q(r?"space-y-2.5":"space-y-3",o&&"max-w-4xl mx-auto"),children:[t.jsx(Nl,{teamRun:e,messages:i,timelineItems:ve,recovered:P,scrollElementRef:X,compact:r,onRetrySubmission:Rn,onOpenImage:An,workingDir:u,onOpenWorkspaceFile:f,onOpenPreviewUrl:l,onOpenVisualization:g},e.id),t.jsx(Mi,{taskId:e.taskId,teamRunId:e.id,enabled:!s,showDeliveries:!1}),y.isError&&t.jsx("div",{className:"rounded-md border border-destructive/25 bg-destructive/10 px-3 py-2 text-xs text-destructive-ink",children:Ys(y.error,m("Failed to stop member work"))})]})}),!G&&t.jsxs("button",{type:"button",onClick:()=>se(),className:"absolute bottom-3 left-1/2 z-10 flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-border bg-background/90 px-3 py-1.5 text-xs text-foreground/70 shadow-raised backdrop-blur-sm hover:bg-background hover:text-foreground transition-colors",children:[t.jsx(zn,{size:14}),t.jsx("span",{children:m("Back to bottom")})]})]}),t.jsx("div",{className:Q("shrink-0 border-t border-transparent bg-background",r?"px-3 pb-2 pt-1.5":"px-6 pb-6 pt-2"),children:t.jsxs("div",{className:Q(o&&"max-w-4xl mx-auto"),children:[t.jsx(dl,{invocations:Re,memberById:Ae,workRequestById:qe,onViewInvocationSession:v,onStopMember:Ln,isStopPending:y.isPending,stoppingMemberId:y.variables?.memberId??null,stopPromptInvocationId:H,onToggleStopConfirm:Y=>U(ee=>ee===Y?null:Y)}),!s&&w,s?t.jsx("div",{className:"rounded-xl border border-border bg-muted/50 px-4 py-3 text-sm text-muted-foreground",children:a??m("This project is read-only")}):t.jsxs("div",{className:"relative rounded-xl border border-border bg-background shadow-raised transition-all duration-200 hover:shadow-raised focus-within:border-ring focus-within:shadow-raised",children:[rt&&t.jsxs("div",{className:"absolute bottom-full left-3 z-20 mb-2 w-[min(24rem,calc(100vw-3rem))] overflow-hidden rounded-xl border border-border bg-background shadow-popover",children:[t.jsx("div",{className:"border-b border-border/60 px-3 py-2 text-xs font-medium text-muted-foreground",children:m(h?"Mention members":"Team members")}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:Ce.map((Y,ee)=>{const oe=E.includes(Y.id),ye=ee===S;return t.jsxs("button",{type:"button",onMouseEnter:()=>k(ee),onMouseDown:le=>{le.preventDefault(),it(Y)},className:Q("flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors",ye?"bg-muted":"hover:bg-accent"),children:[t.jsx(Ue,{name:Y.name,avatar:Y.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:Y.name}),oe&&t.jsx("span",{className:"rounded-full bg-primary px-1.5 py-0.5 text-xs font-medium text-primary-foreground",children:m("selected")})]}),t.jsx("div",{className:"truncate text-xs text-muted-foreground",children:[Y.providerId,Y.id.slice(0,8)].filter(Boolean).join(" · ")})]}),t.jsx(or,{size:15,className:"text-muted-foreground/70"})]},Y.id)})})]}),Se.length>0&&t.jsx("div",{className:"flex flex-wrap items-center gap-1.5 border-b border-border/60 px-3 py-2",children:Se.map(Y=>t.jsxs("span",{className:"inline-flex max-w-full items-center gap-1.5 rounded-full border border-border bg-muted/50 px-2 py-1 text-xs text-foreground/80",children:[t.jsxs("span",{className:"truncate font-medium",children:["@",Y.name]}),t.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:Y.id.slice(0,8)}),t.jsx("button",{type:"button",onClick:()=>Ie(Y.id),className:"shrink-0 rounded-full p-0.5 text-muted-foreground transition-colors hover:bg-foreground/10 hover:text-foreground/80",title:m("Remove mention"),"aria-label":`${m("Remove mention")} ${Y.name}`,children:t.jsx(tt,{size:12})})]},Y.id))}),t.jsx(yo,{files:M,onRemove:q}),t.jsx("textarea",{ref:T,value:b,rows:r?1:void 0,onChange:nt,onKeyDown:Nn,onPaste:rs,onClick:Y=>Te(b,Y.currentTarget.selectionStart),onSelect:Y=>Te(b,Y.currentTarget.selectionStart),placeholder:m("Message the team room..."),className:Q("w-full resize-none border-none bg-transparent text-foreground placeholder:text-muted-foreground/70 focus:outline-none",r?"px-3 pb-1 pt-2.5 text-[15px] leading-5":"px-4 pb-2 pt-4 text-sm leading-relaxed"),style:r?{minHeight:40,maxHeight:140}:{minHeight:60,maxHeight:220}}),t.jsxs("div",{className:Q("flex items-center justify-between",r?"px-2 pb-1.5 pt-0.5":"px-2 pb-2 pt-1"),children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{ref:D,type:"file",multiple:!0,className:"hidden",onChange:ue}),t.jsx("button",{type:"button",onClick:()=>D.current?.click(),title:m("Upload file"),"aria-label":m("Upload file"),className:"rounded-lg p-2 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground/70",children:t.jsx(To,{size:18})}),t.jsx("button",{type:"button",onClick:()=>{c(Y=>!Y),_(null),requestAnimationFrame(()=>T.current?.focus())},disabled:Se.length===0&&te.length===0,title:m("Mention members"),"aria-label":m("Mention members"),className:Q("rounded-lg transition-colors",r?"p-1.5":"p-2",d?"bg-muted text-foreground/80":"text-muted-foreground hover:bg-accent hover:text-foreground/70",Se.length===0&&te.length===0?"cursor-not-allowed opacity-50":""),children:t.jsx(or,{size:r?15:18})}),Se.length>0&&t.jsxs("span",{className:"text-xs text-muted-foreground",children:[Se.length," ",m("selected")]})]}),t.jsx("button",{type:"button",onClick:()=>{is()},disabled:s||C||W||!b.trim()&&!j,"aria-busy":C,title:m(W?"Uploading...":C?"发送中...":"发送"),"aria-label":m(W?"Uploading...":C?"发送中...":"发送"),className:Q("rounded-lg transition-all duration-200",r?"p-1.5":"p-2",(b.trim()||j)&&!s&&!C&&!W?"bg-primary text-primary-foreground shadow-raised hover:bg-primary":"cursor-not-allowed bg-transparent text-muted-foreground",C||W?"opacity-70":""),children:C?t.jsx(zs,{size:r?15:18,className:"animate-spin"}):t.jsx(Wn,{size:r?15:18})})]})]})]})})]})}function Al(e){return e?e.slice(0,8):""}function ur(e){const i=e?Date.parse(e):0;return Number.isNaN(i)?0:i}function Vs(e){return e?.workspaceKind===He.MAIN_DIRECTORY}function jt(e){return e?Vs(e)?"Project directory":e.branchName:"—"}function Qf(e){return e?.workingDir||e?.worktreePath||void 0}function Gs(e,i){if(!e?.length)return[];const s=new Map((i?.members??[]).map(v=>[v.id,v])),a=new Map(e.map(v=>[v.id,v])),p=i?.mainWorkspaceId??null;return e.map(v=>{const w=v.parentWorkspaceId?a.get(v.parentWorkspaceId):void 0,r=v.ownerMemberId?s.get(v.ownerMemberId):void 0,o=!!(p&&v.id===p),u=o?"main":v.parentWorkspaceId?"child":"root",f=r?.name??(v.ownerMemberId?`Member ${Al(v.ownerMemberId)}`:void 0),l=Vs(v)?"Project directory":o?"Main workspace":u==="child"?f?`${f} workspace`:"Child workspace":i?"Root workspace":"Workspace";return{workspace:v,kind:u,roleLabel:o?"Main":u==="child"?"Child":"Root",displayName:l,ownerName:f,parentBranchName:w?jt(w):void 0,isMain:o}}).sort((v,w)=>{const r=u=>u.kind==="main"?0:u.kind==="child"?1:2,o=r(v)-r(w);return o!==0?o:ur(v.workspace.createdAt)-ur(w.workspace.createdAt)})}function Zf(e,i,s){if(e?.length)return s&&e.some(a=>a.id===s)?s:i?.mainWorkspaceId&&e.some(a=>a.id===i.mainWorkspaceId)?i.mainWorkspaceId:e.find(a=>a.status===We.ACTIVE)?.id??e[0]?.id}function Jf(e,i){return!e||e.status!==We.ACTIVE||Vs(e)?!1:!i||e.parentWorkspaceId?!0:!!(i.mainWorkspaceId&&e.id===i.mainWorkspaceId)}function em(e,i,s){return e?.parentWorkspaceId?i?.find(p=>p.id===e.parentWorkspaceId)?.branchName??e.baseBranch??s:e?.baseBranch||s}const Qs={readRoom:!1,postRoomMessage:!1,mentionMembers:!1,stopMemberWork:!1,markReadyForReview:!1,readFiles:!1,writeFiles:!1,runCommands:!1,readDiff:!1,mergeWorkspace:!1},Rl=[{key:"readRoom",label:"读房间"},{key:"postRoomMessage",label:"发房间消息"},{key:"mentionMembers",label:"提及成员"},{key:"stopMemberWork",label:"停止成员工作"},{key:"markReadyForReview",label:"标记可审查"},{key:"readFiles",label:"读文件"},{key:"writeFiles",label:"写文件"},{key:"runCommands",label:"运行命令"},{key:"readDiff",label:"读 diff"},{key:"mergeWorkspace",label:"合并工作区"}],Fi=[{value:"none",label:"无"},{value:"shared",label:"共享"},{value:"dedicated",label:"独占"}],Ll=[{value:"MENTION_ONLY",label:"仅提及"},{value:"USER_MESSAGES",label:"所有用户消息"}],Hi=[{value:"new_per_request",label:"每次新会话"},{value:"resume_last",label:"复用上次会话"}],Ml=[{value:"own_only",label:"仅自己队列"},{value:"team_pending",label:"全队列待处理"}];function bt(){return{name:"",aliasesText:"",providerId:"",rolePrompt:"",capabilities:{...Qs},workspacePolicy:"none",triggerPolicy:"MENTION_ONLY",sessionPolicy:"new_per_request",queueManagementPolicy:"own_only",avatar:""}}function ft(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...Qs,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function ds(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...Qs,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function Pl(e){return Array.from(new Set(e.split(/[\n,]/).map(i=>i.trim()).filter(Boolean)))}function Dl(e){return{name:e.name.trim(),aliases:Pl(e.aliasesText),providerId:e.providerId.trim(),rolePrompt:e.rolePrompt.trim(),capabilities:{...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar.trim()||null}}function fr(e,i){return e instanceof Error?e.message:i}function mr(e){return e.membershipStatus!=="REMOVED"}function Ms(e){return e.status==="RUNNING"||e.status==="WAITING_ROOM_REPLY"||e.status==="SESSION_ENDED"||e.status==="QUEUED"}function pr(e){return Ms(e)?"bg-success":e.status==="FAILED"?"bg-destructive":"bg-foreground/15"}function gr(e){return Fi.find(i=>i.value===e)?.label??e}function Bl(e){return Hi.find(i=>i.value===e)?.label??e}function Fe({children:e}){return t.jsx("span",{className:"text-xs font-medium text-foreground/70",children:e})}function vr({icon:e,title:i,description:s,action:a}){return t.jsxs("div",{className:"flex min-h-[18rem] flex-col items-center justify-center rounded-lg border border-dashed border-border bg-background px-6 py-8 text-center",children:[t.jsx("div",{className:"mb-3 flex h-10 w-10 items-center justify-center rounded-full bg-muted text-muted-foreground",children:e}),t.jsx("div",{className:"text-sm font-medium text-foreground",children:i}),s?t.jsx("div",{className:"mt-1 max-w-sm text-xs leading-relaxed text-muted-foreground",children:s}):null,a?t.jsx("div",{className:"mt-4",children:a}):null]})}function Ol({isOpen:e,onClose:i,teamRun:s}){const{t:a}=re(),{data:p=[]}=Un(),{data:v=[]}=Us(),w=qn(s.id),r=Kn(s.id),o=Xn(s.id),u=A.useRef(!1),[f,l]=A.useState("edit"),[g,m]=A.useState(null),[y,b]=A.useState(""),[n,d]=A.useState(bt()),[c,h]=A.useState(null),[_,S]=A.useState(null),k=s.members??[],E=A.useMemo(()=>k.filter(mr),[k]),x=A.useMemo(()=>_&&mr(_)&&!E.some(W=>W.id===_.id)?[...E,_]:E,[_,E]),C=g?E.find(W=>W.id===g)??null:null,N=_?.id===g?_:C,L=y?p.find(W=>W.id===y)??null:null,R=w.isPending||r.isPending||o.isPending,P=x.filter(Ms).length,F=A.useMemo(()=>{const W=v.filter(pi).map(({provider:j,availability:I})=>({value:j.id,label:j.name+(I.type==="NOT_FOUND"?a(" (不可用)"):""),icon:t.jsx(Gt,{agentType:j.agentType,className:"size-4"}),disabled:I.type==="NOT_FOUND"}));return n.providerId&&!v.some(j=>j.provider.id===n.providerId)&&!W.some(j=>j.value===n.providerId)&&W.unshift({value:n.providerId,label:`${n.providerId}${a(" (不可用)")}`,disabled:!0}),W},[n.providerId,v,a]);A.useEffect(()=>{if(!e){u.current=!1,S(null);return}if(u.current)return;u.current=!0;const W=x[0]??null;l(W?"edit":"add-preset"),m(W?.id??null),b(""),d(W?ft(W):bt()),h(null)},[x,e]),A.useEffect(()=>{_&&E.some(W=>W.id===_.id)&&S(null)},[_,E]),A.useEffect(()=>{f==="add-preset"&&L&&d(ds(L))},[f,L]);const B=(W,j)=>{d(I=>({...I,[W]:j}))},H=(W,j)=>{d(I=>({...I,capabilities:{...I.capabilities,[W]:j}}))},U=W=>{l("edit"),m(W.id),b(""),d(ft(W))},T=()=>{l("add-preset"),m(null);const W=L??p[0]??null;b(W?.id??""),d(W?ds(W):bt())},D=()=>{l("add-custom"),m(null),b(""),d(bt())},M=!!(n.name.trim()&&n.providerId.trim()&&n.rolePrompt.trim()),O=f==="add-preset"?!!y:f==="edit"?!!(N&&M):M,q=async()=>{try{if(f==="add-preset"){if(!y)return;const j=await w.mutateAsync({memberPresetId:y});ke.success(a("Member added")),S(j),l("edit"),m(j.id),b(""),d(ft(j));return}const W=Dl(n);if(!W.name||!W.providerId||!W.rolePrompt){ke.error(a("Name, provider, and role prompt are required"));return}if(f==="add-custom"){const j=await w.mutateAsync({member:W});ke.success(a("Member added")),S(j),l("edit"),m(j.id),d(ft(j));return}if(N){const j=await r.mutateAsync({memberId:N.id,data:W});ke.success(a("Member updated")),S(I=>I?.id===j.id?j:I),m(j.id),d(ft(j))}}catch(W){ke.error(fr(W,a("Failed to save member")))}},V=async()=>{if(c)try{if(await o.mutateAsync({memberId:c.id,stopActive:!0,cancelQueued:!0}),g===c.id){const W=x.find(j=>j.id!==c.id)??null;m(W?.id??null),l(W?"edit":"add-preset"),d(W?ft(W):bt())}S(W=>W?.id===c.id?null:W),h(null),ke.success(a("Member removed"))}catch(W){ke.error(fr(W,a("Failed to remove member")))}},$=()=>t.jsxs("div",{className:"flex min-h-0 flex-col lg:flex-1",children:[t.jsx("div",{className:"border-b border-border/60 px-5 py-4",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-foreground",children:[t.jsx(Dt,{size:15,className:"text-muted-foreground"}),t.jsx("span",{children:a("Add member from preset")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:a("Choose a saved preset to add a ready-to-run member snapshot.")})]}),t.jsxs(ge,{type:"button",variant:"outline",size:"sm",onClick:D,disabled:R,children:[t.jsx(cr,{size:13}),a("Custom member")]})]})}),t.jsx("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:p.length===0?t.jsx(vr,{icon:t.jsx(Dt,{size:18}),title:a("No member presets"),description:a("Create a custom member for this TeamRun, or add presets from Team Collaboration Settings."),action:t.jsxs(ge,{type:"button",variant:"outline",size:"sm",onClick:D,disabled:R,children:[t.jsx(pt,{size:13}),a("Custom member")]})}):t.jsx("div",{className:"grid grid-cols-1 gap-2 xl:grid-cols-2",children:p.map(W=>{const j=y===W.id;return t.jsxs("button",{type:"button",onClick:()=>{b(W.id),d(ds(W))},className:Q("flex min-h-[4.25rem] items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors",j?"border-foreground bg-muted/50 shadow-raised":"border-border bg-background hover:border-foreground/20 hover:bg-accent"),children:[t.jsx(Ue,{name:W.name,avatar:W.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-medium text-foreground",children:W.name}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-muted-foreground",children:W.providerId}),t.jsxs("span",{className:"mt-1 block truncate text-xs text-muted-foreground",children:[a(gr(W.workspacePolicy))," · ",a(Bl(W.sessionPolicy))]})]}),j?t.jsx(Et,{size:16,className:"shrink-0 text-foreground"}):null]},W.id)})})})]}),z=()=>{const W=f==="edit";return W&&!N?t.jsx("div",{className:"p-5",children:t.jsx(vr,{icon:t.jsx(vt,{size:18}),title:a("Select a member"),description:a("Choose a member on the left to edit its future TeamRun configuration."),action:t.jsxs(ge,{type:"button",variant:"outline",size:"sm",onClick:T,disabled:R,children:[t.jsx(pt,{size:13}),a("Add member")]})})}):t.jsxs("div",{className:"flex min-h-0 flex-col lg:flex-1",children:[t.jsx("div",{className:"border-b border-border/60 px-5 py-4",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-foreground",children:[W?t.jsx(Li,{size:15,className:"text-muted-foreground"}):t.jsx(pt,{size:15,className:"text-muted-foreground"}),t.jsx("span",{children:a(W?"Edit member":"Custom member")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:a(W?"Provider, role, workspace, and session changes apply to future work only.":"Create a one-off member snapshot for this TeamRun.")})]}),W&&N?t.jsxs(ge,{type:"button",variant:"outline",size:"sm",onClick:()=>h(N),disabled:R,className:"border-destructive/25 text-destructive-ink hover:bg-destructive/10 hover:text-destructive-ink",children:[t.jsx(ro,{size:13}),a("Remove")]}):t.jsxs(ge,{type:"button",variant:"outline",size:"sm",onClick:T,disabled:R,children:[t.jsx(Dt,{size:13}),a("Use preset")]})]})}),t.jsxs("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:[W&&N?t.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg border border-border bg-muted/50 px-3 py-2.5",children:[t.jsx(Ue,{name:N.name,avatar:N.avatar,className:"h-9 w-9 text-xs"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:Q("h-2 w-2 shrink-0 rounded-full",pr(N))}),t.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:N.name})]}),t.jsxs("div",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:[N.providerId," · ",a(gr(N.workspacePolicy))]})]})]}):null,t.jsxs("div",{className:"space-y-5",children:[t.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Fe,{children:a("Name")}),t.jsx("input",{value:n.name,onChange:j=>B("name",j.target.value),className:"h-9 w-full rounded-lg border border-border px-3 text-sm outline-none transition-colors focus:border-ring"})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Fe,{children:a("Aliases")}),t.jsx("input",{value:n.aliasesText,onChange:j=>B("aliasesText",j.target.value),placeholder:a("Comma separated"),className:"h-9 w-full rounded-lg border border-border px-3 text-sm outline-none transition-colors focus:border-ring"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Fe,{children:a("Provider")}),t.jsx(Xe,{value:n.providerId,onChange:j=>B("providerId",j),options:F,placeholder:v.find(j=>j.provider.id===n.providerId)?.provider.name})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Fe,{children:a("Avatar")}),t.jsx("input",{value:n.avatar,onChange:j=>B("avatar",j.target.value),className:"h-9 w-full rounded-lg border border-border px-3 text-sm outline-none transition-colors focus:border-ring"})]})]}),t.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Fe,{children:a("Workspace policy")}),t.jsx(Xe,{value:n.workspacePolicy,onChange:j=>B("workspacePolicy",j),options:Fi.map(j=>({value:j.value,label:a(j.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Fe,{children:a("Trigger policy")}),t.jsx(Xe,{value:n.triggerPolicy,onChange:j=>B("triggerPolicy",j),options:Ll.map(j=>({value:j.value,label:a(j.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Fe,{children:a("Session policy")}),t.jsx(Xe,{value:n.sessionPolicy,onChange:j=>B("sessionPolicy",j),options:Hi.map(j=>({value:j.value,label:a(j.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Fe,{children:a("Queue policy")}),t.jsx(Xe,{value:n.queueManagementPolicy,onChange:j=>B("queueManagementPolicy",j),options:Ml.map(j=>({value:j.value,label:a(j.label)}))})]})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Fe,{children:a("Role prompt")}),t.jsx("textarea",{value:n.rolePrompt,onChange:j=>B("rolePrompt",j.target.value),rows:7,className:"w-full resize-y rounded-lg border border-border px-3 py-2 text-sm leading-relaxed outline-none transition-colors focus:border-ring"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Fe,{children:a("Capabilities")}),t.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-3",children:Rl.map(j=>t.jsxs("label",{className:"flex min-h-9 items-center gap-2 rounded-md border border-border bg-background px-2.5 py-2 text-xs text-foreground/80",children:[t.jsx("input",{type:"checkbox",checked:!!n.capabilities[j.key],onChange:I=>H(j.key,I.target.checked)}),t.jsx("span",{className:"min-w-0 truncate",children:a(j.label)})]},j.key))})]})]})]})]})};return t.jsxs(t.Fragment,{children:[t.jsx(At,{isOpen:e,onClose:R?()=>{}:i,title:a("Manage Team Members"),className:"max-w-6xl",action:t.jsxs(t.Fragment,{children:[t.jsx(ge,{type:"button",variant:"outline",onClick:i,disabled:R,children:a("Close")}),t.jsx(ge,{type:"button",onClick:q,disabled:R||!O,children:a(R?"Processing...":f==="edit"?"Save member":"Add member")})]}),children:t.jsxs("div",{className:"grid min-h-0 grid-cols-1 overflow-visible rounded-lg border border-border bg-background lg:h-[min(42rem,calc(100vh-13rem))] lg:min-h-[34rem] lg:grid-cols-[20rem_minmax(0,1fr)] lg:overflow-hidden",children:[t.jsxs("aside",{className:"flex min-h-0 flex-col border-b border-border bg-muted/35 lg:border-b-0 lg:border-r",children:[t.jsx("div",{className:"border-b border-border px-4 py-4",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-foreground",children:[t.jsx(vt,{size:15,className:"text-muted-foreground"}),t.jsx("span",{children:a("Members")})]}),t.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[x.length," ",a("active")," · ",P," ",a("working")]})]}),t.jsx(ge,{type:"button",size:"icon-sm",variant:"outline",onClick:T,disabled:R,title:a("Add member"),children:t.jsx(pt,{size:14})})]})}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-2 lg:min-h-0 lg:max-h-none lg:flex-1",children:x.length===0?t.jsx("div",{className:"rounded-lg border border-dashed border-border bg-background px-3 py-5 text-center text-xs text-muted-foreground",children:a("No active members")}):t.jsx("div",{className:"space-y-1",children:x.map(W=>{const j=f==="edit"&&g===W.id;return t.jsxs("button",{type:"button",onClick:()=>U(W),className:Q("group flex w-full items-center gap-2 rounded-lg border px-2.5 py-2 text-left transition-colors",j?"border-border bg-background shadow-raised":"border-transparent hover:border-border hover:bg-background"),children:[t.jsx(Ue,{name:W.name,avatar:W.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:Q("h-1.5 w-1.5 shrink-0 rounded-full",pr(W))}),t.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:W.name})]}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-muted-foreground",children:W.providerId})]}),t.jsx(Ba,{size:13,className:Q("shrink-0 text-muted-foreground transition-opacity",j?"opacity-100":"opacity-0 group-hover:opacity-100")})]},W.id)})})}),t.jsx("div",{className:"border-t border-border p-2",children:t.jsx(Lo,{block:!0,"aria-label":a("Add member"),value:f,onValueChange:W=>W==="add-preset"?T():D(),options:[{value:"add-preset",label:a("Preset"),icon:t.jsx(Dt,{}),disabled:R},{value:"add-custom",label:a("Custom"),icon:t.jsx(cr,{}),disabled:R}]})})]}),t.jsx("section",{className:"flex min-h-0 min-w-0 flex-col",children:f==="add-preset"?$():z()})]})}),t.jsx(Mo,{isOpen:!!c,onClose:()=>h(null),onConfirm:V,title:a("Remove member"),variant:"danger",isLoading:o.isPending,confirmText:a("Remove"),description:t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{children:c?a("Remove this member from future TeamRun work?"):""}),c&&Ms(c)?t.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-destructive/25 bg-destructive/10 px-3 py-2 text-left text-destructive-ink",children:[t.jsx(Nt,{size:15,className:"mt-0.5 shrink-0"}),t.jsx("span",{className:"text-sm font-medium",children:a("确认后会停止当前工作并取消队列")})]}):null]})})]})}const Il=[],Fl=[],Hl=[],zl=240;function Wl(e){switch(e){case"RUNNING":return"running";case"WAITING":case"WAITING_ROOM_REPLY":return"waiting room reply";case"QUEUED":return"queued";case"SESSION_ENDED":return"session ended";case"PENDING_APPROVAL":return"pending approval";case"REMOVED":return"removed";default:return"idle"}}const _r={running:0,"waiting room reply":1,queued:2,"session ended":3,"pending approval":4,idle:5,removed:6};function hs(e){if(!e)return"";const i=new Date(e);return Number.isNaN(i.getTime())?"":i.toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function br(e,i){return e instanceof Error?e.message:i}function $l(e,i=zl){const s=(e??"").replace(/\s+/g," ").trim();return s.length<=i?s:`${s.slice(0,i-3).trimEnd()}...`}function Ot(e){return e?e.instructionPreview??$l(e.instruction):""}function Ul(e){switch(e){case"running":return"Running";case"waiting room reply":return"Waiting room reply";case"queued":return"Queued";case"session ended":return"Session ended";case"pending approval":return"Pending approval";case"removed":return"Removed";case"idle":return"Idle"}}function ql(e){switch(e){case"running":return"border-success/25 bg-success/10 text-success-ink";case"waiting room reply":return"border-warning/25 bg-warning/10 text-warning-ink";case"queued":case"session ended":return"border-info/25 bg-info/10 text-info-ink";case"pending approval":return"border-border bg-muted/50 text-foreground/70";case"removed":return"border-border bg-muted/50 text-muted-foreground";case"idle":return"border-border bg-background text-muted-foreground"}}function Kl(e){switch(e){case"running":return"bg-success";case"waiting room reply":return"bg-warning";case"queued":case"session ended":return"bg-info";case"pending approval":return"bg-muted-foreground/60";case"removed":return"bg-foreground/15";case"idle":return"bg-foreground/15"}}function Xl(e){switch(e){case"user":return"User";case"agent":return"Agent";case"system":return"System"}}function Yl(e){switch(e){case"RUNNING":return"border-success/25 bg-success/10 text-success-ink";case"WAITING_ROOM_REPLY":return"border-warning/25 bg-warning/10 text-warning-ink";case"QUEUED":case"SESSION_ENDED":return"border-info/25 bg-info/10 text-info-ink";case"COMPLETED":return"border-border bg-muted/50 text-foreground/80";case"FAILED":return"border-destructive/25 bg-destructive/10 text-destructive-ink";case"CANCELLED":return"border-border bg-background text-muted-foreground"}}function Vl(e){switch(e){case We.ACTIVE:return"border-success/25 bg-success/10 text-success-ink";case We.MERGED:return"border-info/25 bg-info/10 text-info-ink";case We.HIBERNATED:return"border-warning/25 bg-warning/10 text-warning-ink";case We.ABANDONED:return"border-border bg-muted/50 text-muted-foreground"}}function Gl(e){switch(e){case"Main":return"border-border bg-muted/50 text-foreground/80";case"Child":return"border-border bg-muted/50 text-foreground/80";default:return"border-border bg-muted/50 text-foreground/70"}}function Ql(e){return[...e].sort((i,s)=>Date.parse(s.updatedAt??s.createdAt??"")-Date.parse(i.updatedAt??i.createdAt??""))}function Zl(e,i){return i.find(s=>s.memberId===e.id&&Zt.has(s.status))}function tm({teamRun:e,workspaces:i,selectedWorkspaceId:s,onSelectWorkspace:a,onViewInvocationSession:p}){const{t:v}=re(),w=Qr(e.id),r=Zr(e.id),o=Vr(e.id),[u,f]=A.useState(null),[l,g]=A.useState(null),[m,y]=A.useState(!1),[b,n]=A.useState(!1),d=e.members??Il,c=A.useMemo(()=>d.filter(B=>B.membershipStatus!=="REMOVED"),[d]),h=e.workRequests??Fl,_=e.invocations??Hl,S=A.useMemo(()=>Gs(i,e),[e,i]),k=A.useMemo(()=>new Map(h.map(B=>[B.id,B])),[h]),E=A.useMemo(()=>[...h].filter(B=>B.status==="PENDING_APPROVAL").sort((B,H)=>Date.parse(H.updatedAt??H.createdAt??"")-Date.parse(B.updatedAt??B.createdAt??"")),[h]),x=A.useMemo(()=>[...h].filter(B=>B.status==="QUEUED").sort((B,H)=>Date.parse(H.updatedAt??H.createdAt??"")-Date.parse(B.updatedAt??B.createdAt??"")),[h]),C=A.useMemo(()=>[...d].map(B=>({member:B,status:Wl(B.status)})).sort((B,H)=>_r[B.status]-_r[H.status]),[d]),N=w.isError?w.error:r.isError?r.error:null,L=w.isPending||r.isPending,R=S.find(B=>B.workspace.id===s),P=e.messages??[],F=C.filter(({status:B})=>B==="running"||B==="waiting room reply").length;return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background",children:[t.jsx(Ol,{isOpen:b,onClose:()=>n(!1),teamRun:e}),t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border px-4 py-3 shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(Ts,{size:14,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:v("Team Status")})]}),t.jsxs("div",{className:"flex items-center gap-1.5 rounded-full border border-border bg-muted/50 px-2 py-0.5 text-xs font-medium text-muted-foreground",children:[t.jsx("span",{children:v("Team mode")}),t.jsx("span",{className:"text-foreground/80",children:e.mode})]})]}),t.jsxs("div",{className:"flex items-center gap-3 border-b border-border/60 px-4 py-1.5 shrink-0 text-xs text-muted-foreground",children:[t.jsxs("span",{className:"inline-flex items-center gap-1",title:v("Messages"),children:[t.jsx(Po,{size:11,className:"text-muted-foreground/70"}),t.jsx("span",{className:"tabular-nums",children:P.length})]}),t.jsxs("span",{className:"inline-flex items-center gap-1",title:v("Members"),children:[t.jsx(vt,{size:11,className:"text-muted-foreground/70"}),t.jsx("span",{className:"tabular-nums",children:F>0?`${F}/${c.length}`:c.length}),F>0&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-success"})]}),x.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1",title:v("Queue"),children:[t.jsx(Ve,{size:11,className:"text-muted-foreground/70"}),t.jsx("span",{className:"tabular-nums",children:x.length})]}),E.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-warning-ink",title:v("Pending approval"),children:[t.jsx(Ve,{size:11}),t.jsx("span",{className:"tabular-nums",children:E.length})]})]}),t.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-app-thin px-4 py-3 space-y-3",children:[E.length>0&&t.jsxs("section",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-warning-ink",children:[t.jsx(Ve,{size:13}),t.jsx("span",{children:v("Pending approval")}),t.jsx("span",{className:"ml-auto rounded-full bg-warning/10 px-1.5 py-0.5 text-[11px] font-semibold text-warning-ink",children:E.length})]}),t.jsx("div",{className:"space-y-1.5",children:E.map(B=>{const H=d.find(D=>D.id===B.targetMemberId),U=w.isPending&&w.variables===B.id,T=r.isPending&&r.variables===B.id;return t.jsxs("div",{className:"rounded-md border border-warning/25 bg-warning/5 px-3 py-2",children:[t.jsx("div",{className:"flex items-start justify-between gap-2",children:t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(Ue,{name:H?.name??"Agent",avatar:H?.avatar??null,size:"xs",className:"size-4"}),t.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:H?.name??B.targetMemberId})]}),t.jsx("div",{className:"mt-1 text-xs leading-relaxed text-foreground/70 line-clamp-2",children:Ot(B)})]})}),t.jsxs("div",{className:"mt-1.5 flex items-center gap-x-2 text-xs text-muted-foreground",children:[t.jsx("span",{children:v(Xl(B.requesterType))}),t.jsx("span",{children:hs(B.createdAt)})]}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>w.mutate(B.id),disabled:L,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-success/25 bg-success/10 px-2 text-xs font-medium text-success-ink transition-colors hover:bg-success/15 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Et,{size:11}),t.jsx("span",{className:"truncate",children:v(U?"Approving":"Approve")})]}),t.jsxs("button",{type:"button",onClick:()=>r.mutate(B.id),disabled:L,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-border bg-muted/50 px-2 text-xs font-medium text-foreground/80 transition-colors hover:bg-accent disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(tt,{size:11}),t.jsx("span",{className:"truncate",children:v(T?"Rejecting":"Reject")})]})]})]},B.id)})}),N&&t.jsx("div",{className:"rounded-md border border-destructive/25 bg-destructive/10 px-3 py-2 text-xs text-destructive-ink",children:br(N,v("Failed to update work request"))})]}),t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground",children:[t.jsx(vt,{size:13}),t.jsx("span",{children:v("Members")}),t.jsx("span",{className:"ml-auto text-[11px] font-normal text-muted-foreground",children:c.length}),t.jsx("button",{type:"button",onClick:()=>n(!0),className:"rounded-md p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground/80",title:v("Manage Team Members"),"aria-label":v("Manage Team Members"),children:t.jsx(Li,{size:13})})]}),d.length===0?t.jsx("div",{className:"py-3 text-center text-xs text-muted-foreground",children:v("No members")}):t.jsx("div",{className:"space-y-px rounded-md border border-border overflow-hidden",children:C.map(({member:B,status:H})=>{const U=Zl(B,_),T=Ql(_.filter(z=>z.memberId===B.id)),D=U?k.get(U.workRequestId):void 0,M=l===B.id,O=H==="running"||H==="waiting room reply",q=O&&!!U,V=u===B.id,$=o.isPending&&o.variables?.memberId===B.id;return t.jsxs("div",{className:Q("bg-background",M&&"bg-muted/25"),children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[t.jsx(Ue,{name:B.name,avatar:B.avatar,className:"h-6 w-6 text-[10px] shrink-0"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:Q("h-1.5 w-1.5 shrink-0 rounded-full",Kl(H))}),t.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:B.name}),t.jsx("span",{className:Q("shrink-0 rounded-full border px-1.5 py-px text-xs font-medium leading-tight",ql(H)),children:v(Ul(H))})]}),O&&D?.instruction&&t.jsx("div",{className:"mt-0.5 truncate pl-3 text-xs text-muted-foreground",children:Ot(D)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[q&&t.jsx("button",{type:"button",onClick:()=>f(V?null:B.id),disabled:o.isPending,className:"rounded-md p-1 text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive-ink disabled:cursor-not-allowed disabled:opacity-50",title:v("Stop"),"aria-label":v("Stop"),children:t.jsx(qt,{size:12})}),U?.sessionId&&p&&t.jsx("button",{type:"button",onClick:()=>p(U.sessionId),className:"rounded-md p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground/80",title:v("View log"),"aria-label":v("View log"),children:t.jsx(Rs,{size:12})}),t.jsx("button",{type:"button",onClick:()=>g(M?null:B.id),className:"rounded-md p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground/70",title:v("Details"),"aria-label":v("Details"),"aria-expanded":M,children:M?t.jsx(Ke,{size:13}):t.jsx(Je,{size:13})})]})]}),q&&V&&t.jsxs("div",{className:"mx-3 mb-2 rounded-md border border-border bg-muted/50 p-2",children:[t.jsx("div",{className:"mb-1.5 text-xs text-foreground/70",children:v("Stop running work?")}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{o.mutate({memberId:B.id,cancelQueued:!1},{onSuccess:()=>f(null)})},disabled:o.isPending,className:"inline-flex h-6 items-center gap-1 rounded-md border border-border bg-background px-2 text-xs font-medium text-foreground/80 transition-colors hover:bg-accent disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(qt,{size:10}),t.jsx("span",{children:$&&o.variables?.cancelQueued===!1?v("Stopping"):v("Stop only")})]}),t.jsxs("button",{type:"button",onClick:()=>{o.mutate({memberId:B.id,cancelQueued:!0},{onSuccess:()=>f(null)})},disabled:o.isPending,className:"inline-flex h-6 items-center gap-1 rounded-md border border-destructive/25 bg-destructive/10 px-2 text-xs font-medium text-destructive-ink transition-colors hover:bg-destructive/15 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Ri,{size:10}),t.jsx("span",{children:$&&o.variables?.cancelQueued===!0?v("Stopping"):v("Stop + clear queue")})]})]})]}),M&&t.jsxs("div",{className:"border-t border-border/60 px-3 py-2",children:[t.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[t.jsx("span",{children:B.providerId}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-foreground/15"}),t.jsx("span",{children:B.workspacePolicy}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-foreground/15"}),t.jsx("span",{children:B.sessionPolicy==="resume_last"?v("Resume last session"):v("New session per request")})]}),t.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:v("Invocation history")}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:T.length})]}),T.length===0?t.jsx("div",{className:"py-2 text-center text-xs text-muted-foreground",children:v("No invocations yet")}):t.jsx("div",{className:"space-y-1",children:T.map(z=>{const W=k.get(z.workRequestId),j=!!(z.sessionId&&p);return t.jsx("div",{className:"rounded-md border border-border/60 bg-background px-2.5 py-1.5",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:Q("rounded-full border px-1.5 py-px text-[10px] font-medium leading-tight",Yl(z.status)),children:z.status}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:hs(z.updatedAt??z.createdAt)})]}),t.jsx("div",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:Ot(W)||z.workRequestId})]}),j&&t.jsxs("button",{type:"button",onClick:()=>z.sessionId&&p?.(z.sessionId),className:"inline-flex h-5 shrink-0 items-center gap-1 rounded border border-border bg-background px-1.5 text-xs font-medium text-foreground/70 transition-colors hover:bg-accent",title:v("View log"),"aria-label":v("View log"),children:[t.jsx(Rs,{size:10}),t.jsx("span",{children:v("Log")})]})]})},z.id)})})]}),C[C.length-1]?.member.id!==B.id&&!M&&t.jsx("div",{className:"mx-3 border-b border-border/60"})]},B.id)})}),o.isError&&t.jsx("div",{className:"rounded-md border border-destructive/25 bg-destructive/10 px-3 py-2 text-xs text-destructive-ink",children:br(o.error,v("Failed to stop member work"))})]}),x.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground",children:[t.jsx(Ve,{size:13}),t.jsx("span",{children:v("Queue")}),t.jsx("span",{className:"ml-auto rounded-full bg-muted px-1.5 py-0.5 text-[11px] font-semibold text-foreground/70",children:x.length})]}),t.jsx("div",{className:"space-y-1",children:x.map(B=>{const H=d.find(U=>U.id===B.targetMemberId);return t.jsx("div",{className:"rounded-md border border-border bg-background px-3 py-2",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(Ue,{name:H?.name??"Agent",avatar:H?.avatar??null,size:"xs",className:"size-4"}),t.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:H?.name??B.targetMemberId})]}),t.jsx("div",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:Ot(B)})]}),t.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:hs(B.createdAt)})]})},B.id)})})]}),S.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>y(B=>!B),className:"flex w-full items-center gap-2 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground/80","aria-expanded":m,"aria-label":v("Workspaces"),children:[t.jsx(Ts,{size:13}),t.jsx("span",{children:v("Workspaces")}),t.jsxs("span",{className:"ml-auto flex items-center gap-1.5",children:[R&&t.jsx("span",{className:"max-w-[120px] truncate font-mono text-[11px] font-normal text-muted-foreground",children:jt(R.workspace)}),t.jsx("span",{className:"rounded-full bg-muted px-1.5 py-0.5 text-[11px] font-semibold text-foreground/70",children:S.length}),m?t.jsx(Ke,{size:13,className:"text-muted-foreground/70"}):t.jsx(Je,{size:13,className:"text-muted-foreground/70"})]})]}),m&&t.jsx("div",{className:"space-y-1.5",children:S.map(B=>{const H=s===B.workspace.id;return t.jsx("div",{className:Q("rounded-md border bg-background px-3 py-2",H?"border-foreground/25 shadow-raised":"border-border"),children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:v(B.displayName)}),t.jsx("span",{className:Q("shrink-0 rounded-full border px-1.5 py-px text-[11px] font-medium leading-tight",Gl(B.roleLabel)),children:v(B.roleLabel)}),t.jsx("span",{className:Q("shrink-0 rounded-full border px-1.5 py-px text-[11px] font-medium leading-tight",Vl(B.workspace.status)),children:B.workspace.status})]}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-[11px] text-muted-foreground",children:jt(B.workspace)}),t.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground",children:[B.ownerName&&t.jsxs("span",{children:[v("Owner"),": ",B.ownerName]}),B.parentBranchName&&t.jsxs("span",{children:[v("Parent"),": ",B.parentBranchName]})]})]}),t.jsxs("button",{type:"button",onClick:()=>a?.(B.workspace.id),disabled:!a||H,className:"inline-flex h-6 shrink-0 items-center gap-1 rounded-md border border-border bg-muted/50 px-2 text-xs font-medium text-foreground/80 transition-colors hover:bg-accent disabled:cursor-not-allowed disabled:opacity-50",title:v("View workspace"),children:[H?t.jsx(Et,{size:11}):t.jsx(ei,{size:11}),t.jsx("span",{children:v(H?"Selected":"Select")})]})]})},B.workspace.id)})})]}),E.length===0&&x.length===0&&C.every(({status:B})=>B==="idle")&&t.jsx("div",{className:"py-2 text-center text-xs text-muted-foreground",children:v("All members idle")})]})]})}var us={exports:{}},xr;function Jl(){return xr||(xr=1,(function(e,i){(function(s,a){e.exports=a()})(self,(()=>(()=>{var s={4567:function(w,r,o){var u=this&&this.__decorate||function(h,_,S,k){var E,x=arguments.length,C=x<3?_:k===null?k=Object.getOwnPropertyDescriptor(_,S):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(h,_,S,k);else for(var N=h.length-1;N>=0;N--)(E=h[N])&&(C=(x<3?E(C):x>3?E(_,S,C):E(_,S))||C);return x>3&&C&&Object.defineProperty(_,S,C),C},f=this&&this.__param||function(h,_){return function(S,k){_(S,k,h)}};Object.defineProperty(r,"__esModule",{value:!0}),r.AccessibilityManager=void 0;const l=o(9042),g=o(6114),m=o(9924),y=o(844),b=o(5596),n=o(4725),d=o(3656);let c=r.AccessibilityManager=class extends y.Disposable{constructor(h,_){super(),this._terminal=h,this._renderService=_,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=document.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=document.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let S=0;S<this._terminal.rows;S++)this._rowElements[S]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[S]);if(this._topBoundaryFocusListener=S=>this._handleBoundaryFocus(S,0),this._bottomBoundaryFocusListener=S=>this._handleBoundaryFocus(S,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=document.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new m.TimeBasedDebouncer(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((S=>this._handleResize(S.rows)))),this.register(this._terminal.onRender((S=>this._refreshRows(S.start,S.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((S=>this._handleChar(S)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
|
|
9
|
+
`)))),this.register(this._terminal.onA11yTab((S=>this._handleTab(S)))),this.register(this._terminal.onKey((S=>this._handleKey(S.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this._screenDprMonitor=new b.ScreenDprMonitor(window),this.register(this._screenDprMonitor),this._screenDprMonitor.setListener((()=>this._refreshRowsDimensions())),this.register((0,d.addDisposableDomListener)(window,"resize",(()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,y.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(h){for(let _=0;_<h;_++)this._handleChar(" ")}_handleChar(h){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==h&&(this._charsToAnnounce+=h):this._charsToAnnounce+=h,h===`
|
|
10
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=l.tooMuchOutput)),g.isMac&&this._liveRegion.textContent&&this._liveRegion.textContent.length>0&&!this._liveRegion.parentNode&&setTimeout((()=>{this._accessibilityContainer.appendChild(this._liveRegion)}),0))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0,g.isMac&&this._liveRegion.remove()}_handleKey(h){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(h)||this._charsToConsume.push(h)}_refreshRows(h,_){this._liveRegionDebouncer.refresh(h,_,this._terminal.rows)}_renderRows(h,_){const S=this._terminal.buffer,k=S.lines.length.toString();for(let E=h;E<=_;E++){const x=S.translateBufferLineToString(S.ydisp+E,!0),C=(S.ydisp+E+1).toString(),N=this._rowElements[E];N&&(x.length===0?N.innerText=" ":N.textContent=x,N.setAttribute("aria-posinset",C),N.setAttribute("aria-setsize",k))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(h,_){const S=h.target,k=this._rowElements[_===0?1:this._rowElements.length-2];if(S.getAttribute("aria-posinset")===(_===0?"1":`${this._terminal.buffer.lines.length}`)||h.relatedTarget!==k)return;let E,x;if(_===0?(E=S,x=this._rowElements.pop(),this._rowContainer.removeChild(x)):(E=this._rowElements.shift(),x=S,this._rowContainer.removeChild(E)),E.removeEventListener("focus",this._topBoundaryFocusListener),x.removeEventListener("focus",this._bottomBoundaryFocusListener),_===0){const C=this._createAccessibilityTreeNode();this._rowElements.unshift(C),this._rowContainer.insertAdjacentElement("afterbegin",C)}else{const C=this._createAccessibilityTreeNode();this._rowElements.push(C),this._rowContainer.appendChild(C)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(_===0?-1:1),this._rowElements[_===0?1:this._rowElements.length-2].focus(),h.preventDefault(),h.stopImmediatePropagation()}_handleResize(h){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let _=this._rowContainer.children.length;_<this._terminal.rows;_++)this._rowElements[_]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[_]);for(;this._rowElements.length>h;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const h=document.createElement("div");return h.setAttribute("role","listitem"),h.tabIndex=-1,this._refreshRowDimensions(h),h}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let h=0;h<this._terminal.rows;h++)this._refreshRowDimensions(this._rowElements[h])}}_refreshRowDimensions(h){h.style.height=`${this._renderService.dimensions.css.cell.height}px`}};r.AccessibilityManager=c=u([f(1,n.IRenderService)],c)},3614:(w,r)=>{function o(g){return g.replace(/\r?\n/g,"\r")}function u(g,m){return m?"\x1B[200~"+g+"\x1B[201~":g}function f(g,m,y,b){g=u(g=o(g),y.decPrivateModes.bracketedPasteMode&&b.rawOptions.ignoreBracketedPasteMode!==!0),y.triggerDataEvent(g,!0),m.value=""}function l(g,m,y){const b=y.getBoundingClientRect(),n=g.clientX-b.left-10,d=g.clientY-b.top-10;m.style.width="20px",m.style.height="20px",m.style.left=`${n}px`,m.style.top=`${d}px`,m.style.zIndex="1000",m.focus()}Object.defineProperty(r,"__esModule",{value:!0}),r.rightClickHandler=r.moveTextAreaUnderMouseCursor=r.paste=r.handlePasteEvent=r.copyHandler=r.bracketTextForPaste=r.prepareTextForTerminal=void 0,r.prepareTextForTerminal=o,r.bracketTextForPaste=u,r.copyHandler=function(g,m){g.clipboardData&&g.clipboardData.setData("text/plain",m.selectionText),g.preventDefault()},r.handlePasteEvent=function(g,m,y,b){g.stopPropagation(),g.clipboardData&&f(g.clipboardData.getData("text/plain"),m,y,b)},r.paste=f,r.moveTextAreaUnderMouseCursor=l,r.rightClickHandler=function(g,m,y,b,n){l(g,m,y),n&&b.rightClickSelect(g),m.value=b.selectionText,m.select()}},7239:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ColorContrastCache=void 0;const u=o(1505);r.ColorContrastCache=class{constructor(){this._color=new u.TwoKeyMap,this._css=new u.TwoKeyMap}setCss(f,l,g){this._css.set(f,l,g)}getCss(f,l){return this._css.get(f,l)}setColor(f,l,g){this._color.set(f,l,g)}getColor(f,l){return this._color.get(f,l)}clear(){this._color.clear(),this._css.clear()}}},3656:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.addDisposableDomListener=void 0,r.addDisposableDomListener=function(o,u,f,l){o.addEventListener(u,f,l);let g=!1;return{dispose:()=>{g||(g=!0,o.removeEventListener(u,f,l))}}}},6465:function(w,r,o){var u=this&&this.__decorate||function(n,d,c,h){var _,S=arguments.length,k=S<3?d:h===null?h=Object.getOwnPropertyDescriptor(d,c):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(n,d,c,h);else for(var E=n.length-1;E>=0;E--)(_=n[E])&&(k=(S<3?_(k):S>3?_(d,c,k):_(d,c))||k);return S>3&&k&&Object.defineProperty(d,c,k),k},f=this&&this.__param||function(n,d){return function(c,h){d(c,h,n)}};Object.defineProperty(r,"__esModule",{value:!0}),r.Linkifier2=void 0;const l=o(3656),g=o(8460),m=o(844),y=o(2585);let b=r.Linkifier2=class extends m.Disposable{get currentLink(){return this._currentLink}constructor(n){super(),this._bufferService=n,this._linkProviders=[],this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new g.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new g.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,m.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,m.toDisposable)((()=>{this._lastMouseEvent=void 0}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0})))}registerLinkProvider(n){return this._linkProviders.push(n),{dispose:()=>{const d=this._linkProviders.indexOf(n);d!==-1&&this._linkProviders.splice(d,1)}}}attachToDom(n,d,c){this._element=n,this._mouseService=d,this._renderService=c,this.register((0,l.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,l.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,l.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,l.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(n){if(this._lastMouseEvent=n,!this._element||!this._mouseService)return;const d=this._positionFromMouseEvent(n,this._element,this._mouseService);if(!d)return;this._isMouseOut=!1;const c=n.composedPath();for(let h=0;h<c.length;h++){const _=c[h];if(_.classList.contains("xterm"))break;if(_.classList.contains("xterm-hover"))return}this._lastBufferCell&&d.x===this._lastBufferCell.x&&d.y===this._lastBufferCell.y||(this._handleHover(d),this._lastBufferCell=d)}_handleHover(n){if(this._activeLine!==n.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(n,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,n)||(this._clearCurrentLink(),this._askForLink(n,!0))}_askForLink(n,d){var c,h;this._activeProviderReplies&&d||((c=this._activeProviderReplies)===null||c===void 0||c.forEach((S=>{S?.forEach((k=>{k.link.dispose&&k.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=n.y);let _=!1;for(const[S,k]of this._linkProviders.entries())d?!((h=this._activeProviderReplies)===null||h===void 0)&&h.get(S)&&(_=this._checkLinkProviderResult(S,n,_)):k.provideLinks(n.y,(E=>{var x,C;if(this._isMouseOut)return;const N=E?.map((L=>({link:L})));(x=this._activeProviderReplies)===null||x===void 0||x.set(S,N),_=this._checkLinkProviderResult(S,n,_),((C=this._activeProviderReplies)===null||C===void 0?void 0:C.size)===this._linkProviders.length&&this._removeIntersectingLinks(n.y,this._activeProviderReplies)}))}_removeIntersectingLinks(n,d){const c=new Set;for(let h=0;h<d.size;h++){const _=d.get(h);if(_)for(let S=0;S<_.length;S++){const k=_[S],E=k.link.range.start.y<n?0:k.link.range.start.x,x=k.link.range.end.y>n?this._bufferService.cols:k.link.range.end.x;for(let C=E;C<=x;C++){if(c.has(C)){_.splice(S--,1);break}c.add(C)}}}}_checkLinkProviderResult(n,d,c){var h;if(!this._activeProviderReplies)return c;const _=this._activeProviderReplies.get(n);let S=!1;for(let k=0;k<n;k++)this._activeProviderReplies.has(k)&&!this._activeProviderReplies.get(k)||(S=!0);if(!S&&_){const k=_.find((E=>this._linkAtPosition(E.link,d)));k&&(c=!0,this._handleNewLink(k))}if(this._activeProviderReplies.size===this._linkProviders.length&&!c)for(let k=0;k<this._activeProviderReplies.size;k++){const E=(h=this._activeProviderReplies.get(k))===null||h===void 0?void 0:h.find((x=>this._linkAtPosition(x.link,d)));if(E){c=!0,this._handleNewLink(E);break}}return c}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(n){if(!this._element||!this._mouseService||!this._currentLink)return;const d=this._positionFromMouseEvent(n,this._element,this._mouseService);d&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,d)&&this._currentLink.link.activate(n,this._currentLink.link.text)}_clearCurrentLink(n,d){this._element&&this._currentLink&&this._lastMouseEvent&&(!n||!d||this._currentLink.link.range.start.y>=n&&this._currentLink.link.range.end.y<=d)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,m.disposeArray)(this._linkCacheDisposables))}_handleNewLink(n){if(!this._element||!this._lastMouseEvent||!this._mouseService)return;const d=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);d&&this._linkAtPosition(n.link,d)&&(this._currentLink=n,this._currentLink.state={decorations:{underline:n.link.decorations===void 0||n.link.decorations.underline,pointerCursor:n.link.decorations===void 0||n.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,n.link,this._lastMouseEvent),n.link.decorations={},Object.defineProperties(n.link.decorations,{pointerCursor:{get:()=>{var c,h;return(h=(c=this._currentLink)===null||c===void 0?void 0:c.state)===null||h===void 0?void 0:h.decorations.pointerCursor},set:c=>{var h,_;!((h=this._currentLink)===null||h===void 0)&&h.state&&this._currentLink.state.decorations.pointerCursor!==c&&(this._currentLink.state.decorations.pointerCursor=c,this._currentLink.state.isHovered&&((_=this._element)===null||_===void 0||_.classList.toggle("xterm-cursor-pointer",c)))}},underline:{get:()=>{var c,h;return(h=(c=this._currentLink)===null||c===void 0?void 0:c.state)===null||h===void 0?void 0:h.decorations.underline},set:c=>{var h,_,S;!((h=this._currentLink)===null||h===void 0)&&h.state&&((S=(_=this._currentLink)===null||_===void 0?void 0:_.state)===null||S===void 0?void 0:S.decorations.underline)!==c&&(this._currentLink.state.decorations.underline=c,this._currentLink.state.isHovered&&this._fireUnderlineEvent(n.link,c))}}}),this._renderService&&this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((c=>{if(!this._currentLink)return;const h=c.start===0?0:c.start+1+this._bufferService.buffer.ydisp,_=this._bufferService.buffer.ydisp+1+c.end;if(this._currentLink.link.range.start.y>=h&&this._currentLink.link.range.end.y<=_&&(this._clearCurrentLink(h,_),this._lastMouseEvent&&this._element)){const S=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);S&&this._askForLink(S,!1)}}))))}_linkHover(n,d,c){var h;!((h=this._currentLink)===null||h===void 0)&&h.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(d,!0),this._currentLink.state.decorations.pointerCursor&&n.classList.add("xterm-cursor-pointer")),d.hover&&d.hover(c,d.text)}_fireUnderlineEvent(n,d){const c=n.range,h=this._bufferService.buffer.ydisp,_=this._createLinkUnderlineEvent(c.start.x-1,c.start.y-h-1,c.end.x,c.end.y-h-1,void 0);(d?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(_)}_linkLeave(n,d,c){var h;!((h=this._currentLink)===null||h===void 0)&&h.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(d,!1),this._currentLink.state.decorations.pointerCursor&&n.classList.remove("xterm-cursor-pointer")),d.leave&&d.leave(c,d.text)}_linkAtPosition(n,d){const c=n.range.start.y*this._bufferService.cols+n.range.start.x,h=n.range.end.y*this._bufferService.cols+n.range.end.x,_=d.y*this._bufferService.cols+d.x;return c<=_&&_<=h}_positionFromMouseEvent(n,d,c){const h=c.getCoords(n,d,this._bufferService.cols,this._bufferService.rows);if(h)return{x:h[0],y:h[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(n,d,c,h,_){return{x1:n,y1:d,x2:c,y2:h,cols:this._bufferService.cols,fg:_}}};r.Linkifier2=b=u([f(0,y.IBufferService)],b)},9042:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.tooMuchOutput=r.promptLabel=void 0,r.promptLabel="Terminal input",r.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(w,r,o){var u=this&&this.__decorate||function(b,n,d,c){var h,_=arguments.length,S=_<3?n:c===null?c=Object.getOwnPropertyDescriptor(n,d):c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(b,n,d,c);else for(var k=b.length-1;k>=0;k--)(h=b[k])&&(S=(_<3?h(S):_>3?h(n,d,S):h(n,d))||S);return _>3&&S&&Object.defineProperty(n,d,S),S},f=this&&this.__param||function(b,n){return function(d,c){n(d,c,b)}};Object.defineProperty(r,"__esModule",{value:!0}),r.OscLinkProvider=void 0;const l=o(511),g=o(2585);let m=r.OscLinkProvider=class{constructor(b,n,d){this._bufferService=b,this._optionsService=n,this._oscLinkService=d}provideLinks(b,n){var d;const c=this._bufferService.buffer.lines.get(b-1);if(!c)return void n(void 0);const h=[],_=this._optionsService.rawOptions.linkHandler,S=new l.CellData,k=c.getTrimmedLength();let E=-1,x=-1,C=!1;for(let N=0;N<k;N++)if(x!==-1||c.hasContent(N)){if(c.loadCell(N,S),S.hasExtendedAttrs()&&S.extended.urlId){if(x===-1){x=N,E=S.extended.urlId;continue}C=S.extended.urlId!==E}else x!==-1&&(C=!0);if(C||x!==-1&&N===k-1){const L=(d=this._oscLinkService.getLinkData(E))===null||d===void 0?void 0:d.uri;if(L){const R={start:{x:x+1,y:b},end:{x:N+(C||N!==k-1?0:1),y:b}};let P=!1;if(!_?.allowNonHttpProtocols)try{const F=new URL(L);["http:","https:"].includes(F.protocol)||(P=!0)}catch{P=!0}P||h.push({text:L,range:R,activate:(F,B)=>_?_.activate(F,B,R):y(0,B),hover:(F,B)=>{var H;return(H=_?.hover)===null||H===void 0?void 0:H.call(_,F,B,R)},leave:(F,B)=>{var H;return(H=_?.leave)===null||H===void 0?void 0:H.call(_,F,B,R)}})}C=!1,S.hasExtendedAttrs()&&S.extended.urlId?(x=N,E=S.extended.urlId):(x=-1,E=-1)}}n(h)}};function y(b,n){if(confirm(`Do you want to navigate to ${n}?
|
|
11
|
+
|
|
12
|
+
WARNING: This link could potentially be dangerous`)){const d=window.open();if(d){try{d.opener=null}catch{}d.location.href=n}else console.warn("Opening link blocked as opener could not be cleared")}}r.OscLinkProvider=m=u([f(0,g.IBufferService),f(1,g.IOptionsService),f(2,g.IOscLinkService)],m)},6193:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.RenderDebouncer=void 0,r.RenderDebouncer=class{constructor(o,u){this._parentWindow=o,this._renderCallback=u,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._parentWindow.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(o){return this._refreshCallbacks.push(o),this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(o,u,f){this._rowCount=f,o=o!==void 0?o:0,u=u!==void 0?u:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,o):o,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,u):u,this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return void this._runRefreshCallbacks();const o=Math.max(this._rowStart,0),u=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(o,u),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const o of this._refreshCallbacks)o(0);this._refreshCallbacks=[]}}},5596:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ScreenDprMonitor=void 0;const u=o(844);class f extends u.Disposable{constructor(g){super(),this._parentWindow=g,this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this.register((0,u.toDisposable)((()=>{this.clearListener()})))}setListener(g){this._listener&&this.clearListener(),this._listener=g,this._outerListener=()=>{this._listener&&(this._listener(this._parentWindow.devicePixelRatio,this._currentDevicePixelRatio),this._updateDpr())},this._updateDpr()}_updateDpr(){var g;this._outerListener&&((g=this._resolutionMediaMatchList)===null||g===void 0||g.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._listener&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._listener=void 0,this._outerListener=void 0)}}r.ScreenDprMonitor=f},3236:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Terminal=void 0;const u=o(3614),f=o(3656),l=o(6465),g=o(9042),m=o(3730),y=o(1680),b=o(3107),n=o(5744),d=o(2950),c=o(1296),h=o(428),_=o(4269),S=o(5114),k=o(8934),E=o(3230),x=o(9312),C=o(4725),N=o(6731),L=o(8055),R=o(8969),P=o(8460),F=o(844),B=o(6114),H=o(8437),U=o(2584),T=o(7399),D=o(5941),M=o(9074),O=o(2585),q=o(5435),V=o(4567),$=typeof window<"u"?window.document:null;class z extends R.CoreTerminal{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}constructor(j={}){super(j),this.browser=B,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new F.MutableDisposable),this._onCursorMove=this.register(new P.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new P.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new P.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new P.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new P.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new P.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new P.EventEmitter),this._onBlur=this.register(new P.EventEmitter),this._onA11yCharEmitter=this.register(new P.EventEmitter),this._onA11yTabEmitter=this.register(new P.EventEmitter),this._onWillOpen=this.register(new P.EventEmitter),this._setup(),this.linkifier2=this.register(this._instantiationService.createInstance(l.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(m.OscLinkProvider)),this._decorationService=this._instantiationService.createInstance(M.DecorationService),this._instantiationService.setService(O.IDecorationService,this._decorationService),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((I,K)=>this.refresh(I,K)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((I=>this._reportWindowsOptions(I)))),this.register(this._inputHandler.onColor((I=>this._handleColorEvent(I)))),this.register((0,P.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,P.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,P.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,P.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((I=>this._afterResize(I.cols,I.rows)))),this.register((0,F.toDisposable)((()=>{var I,K;this._customKeyEventHandler=void 0,(K=(I=this.element)===null||I===void 0?void 0:I.parentNode)===null||K===void 0||K.removeChild(this.element)})))}_handleColorEvent(j){if(this._themeService)for(const I of j){let K,X="";switch(I.index){case 256:K="foreground",X="10";break;case 257:K="background",X="11";break;case 258:K="cursor",X="12";break;default:K="ansi",X="4;"+I.index}switch(I.type){case 0:const J=L.color.toColorRGB(K==="ansi"?this._themeService.colors.ansi[I.index]:this._themeService.colors[K]);this.coreService.triggerDataEvent(`${U.C0.ESC}]${X};${(0,D.toRgbString)(J)}${U.C1_ESCAPED.ST}`);break;case 1:if(K==="ansi")this._themeService.modifyColors((G=>G.ansi[I.index]=L.rgba.toColor(...I.color)));else{const G=K;this._themeService.modifyColors((Z=>Z[G]=L.rgba.toColor(...I.color)))}break;case 2:this._themeService.restoreColor(I.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(j){j?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(V.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(j){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(U.C0.ESC+"[I"),this.updateCursorStyle(j),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var j;return(j=this.textarea)===null||j===void 0?void 0:j.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(U.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;const j=this.buffer.ybase+this.buffer.y,I=this.buffer.lines.get(j);if(!I)return;const K=Math.min(this.buffer.x,this.cols-1),X=this._renderService.dimensions.css.cell.height,J=I.getWidth(K),G=this._renderService.dimensions.css.cell.width*J,Z=this.buffer.y*this._renderService.dimensions.css.cell.height,ae=K*this._renderService.dimensions.css.cell.width;this.textarea.style.left=ae+"px",this.textarea.style.top=Z+"px",this.textarea.style.width=G+"px",this.textarea.style.height=X+"px",this.textarea.style.lineHeight=X+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,f.addDisposableDomListener)(this.element,"copy",(I=>{this.hasSelection()&&(0,u.copyHandler)(I,this._selectionService)})));const j=I=>(0,u.handlePasteEvent)(I,this.textarea,this.coreService,this.optionsService);this.register((0,f.addDisposableDomListener)(this.textarea,"paste",j)),this.register((0,f.addDisposableDomListener)(this.element,"paste",j)),B.isFirefox?this.register((0,f.addDisposableDomListener)(this.element,"mousedown",(I=>{I.button===2&&(0,u.rightClickHandler)(I,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,f.addDisposableDomListener)(this.element,"contextmenu",(I=>{(0,u.rightClickHandler)(I,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),B.isLinux&&this.register((0,f.addDisposableDomListener)(this.element,"auxclick",(I=>{I.button===1&&(0,u.moveTextAreaUnderMouseCursor)(I,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,f.addDisposableDomListener)(this.textarea,"keyup",(j=>this._keyUp(j)),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"keydown",(j=>this._keyDown(j)),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"keypress",(j=>this._keyPress(j)),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionupdate",(j=>this._compositionHelper.compositionupdate(j)))),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,f.addDisposableDomListener)(this.textarea,"input",(j=>this._inputEvent(j)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(j){var I;if(!j)throw new Error("Terminal requires a parent element.");j.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this._document=j.ownerDocument,this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),j.appendChild(this.element);const K=$.createDocumentFragment();this._viewportElement=$.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),K.appendChild(this._viewportElement),this._viewportScrollArea=$.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=$.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=$.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),K.appendChild(this.screenElement),this.textarea=$.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",g.promptLabel),B.isChromeOS||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._coreBrowserService=this._instantiationService.createInstance(S.CoreBrowserService,this.textarea,(I=this._document.defaultView)!==null&&I!==void 0?I:window),this._instantiationService.setService(C.ICoreBrowserService,this._coreBrowserService),this.register((0,f.addDisposableDomListener)(this.textarea,"focus",(X=>this._handleTextAreaFocus(X)))),this.register((0,f.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(h.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(C.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(N.ThemeService),this._instantiationService.setService(C.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(_.CharacterJoinerService),this._instantiationService.setService(C.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(E.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(C.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((X=>this._onRender.fire(X)))),this.onResize((X=>this._renderService.resize(X.cols,X.rows))),this._compositionView=$.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(d.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this.element.appendChild(K);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._mouseService=this._instantiationService.createInstance(k.MouseService),this._instantiationService.setService(C.IMouseService,this._mouseService),this.viewport=this._instantiationService.createInstance(y.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((X=>this.scrollLines(X.amount,X.suppressScrollEvent,1))),this.register(this._inputHandler.onRequestSyncScrollBar((()=>this.viewport.syncScrollArea()))),this.register(this.viewport),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.register(this._renderService.onDimensionsChange((()=>this.viewport.syncScrollArea()))),this._selectionService=this.register(this._instantiationService.createInstance(x.SelectionService,this.element,this.screenElement,this.linkifier2)),this._instantiationService.setService(C.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((X=>this.scrollLines(X.amount,X.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((X=>this._renderService.handleSelectionChanged(X.start,X.end,X.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((X=>{this.textarea.value=X,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((X=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,f.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.linkifier2.attachToDom(this.screenElement,this._mouseService,this._renderService),this.register(this._instantiationService.createInstance(b.BufferDecorationRenderer,this.screenElement)),this.register((0,f.addDisposableDomListener)(this.element,"mousedown",(X=>this._selectionService.handleMouseDown(X)))),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(V.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(X=>this._handleScreenReaderModeOptionChange(X)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(n.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(X=>{!this._overviewRulerRenderer&&X&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(n.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(c.DomRenderer,this.element,this.screenElement,this._viewportElement,this.linkifier2)}bindMouse(){const j=this,I=this.element;function K(G){const Z=j._mouseService.getMouseReportCoords(G,j.screenElement);if(!Z)return!1;let ae,he;switch(G.overrideType||G.type){case"mousemove":he=32,G.buttons===void 0?(ae=3,G.button!==void 0&&(ae=G.button<3?G.button:3)):ae=1&G.buttons?0:4&G.buttons?1:2&G.buttons?2:3;break;case"mouseup":he=0,ae=G.button<3?G.button:3;break;case"mousedown":he=1,ae=G.button<3?G.button:3;break;case"wheel":if(j.viewport.getLinesScrolled(G)===0)return!1;he=G.deltaY<0?0:1,ae=4;break;default:return!1}return!(he===void 0||ae===void 0||ae>4)&&j.coreMouseService.triggerMouseEvent({col:Z.col,row:Z.row,x:Z.x,y:Z.y,button:ae,action:he,ctrl:G.ctrlKey,alt:G.altKey,shift:G.shiftKey})}const X={mouseup:null,wheel:null,mousedrag:null,mousemove:null},J={mouseup:G=>(K(G),G.buttons||(this._document.removeEventListener("mouseup",X.mouseup),X.mousedrag&&this._document.removeEventListener("mousemove",X.mousedrag)),this.cancel(G)),wheel:G=>(K(G),this.cancel(G,!0)),mousedrag:G=>{G.buttons&&K(G)},mousemove:G=>{G.buttons||K(G)}};this.register(this.coreMouseService.onProtocolChange((G=>{G?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(G)),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()),8&G?X.mousemove||(I.addEventListener("mousemove",J.mousemove),X.mousemove=J.mousemove):(I.removeEventListener("mousemove",X.mousemove),X.mousemove=null),16&G?X.wheel||(I.addEventListener("wheel",J.wheel,{passive:!1}),X.wheel=J.wheel):(I.removeEventListener("wheel",X.wheel),X.wheel=null),2&G?X.mouseup||(I.addEventListener("mouseup",J.mouseup),X.mouseup=J.mouseup):(this._document.removeEventListener("mouseup",X.mouseup),I.removeEventListener("mouseup",X.mouseup),X.mouseup=null),4&G?X.mousedrag||(X.mousedrag=J.mousedrag):(this._document.removeEventListener("mousemove",X.mousedrag),X.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,f.addDisposableDomListener)(I,"mousedown",(G=>{if(G.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(G))return K(G),X.mouseup&&this._document.addEventListener("mouseup",X.mouseup),X.mousedrag&&this._document.addEventListener("mousemove",X.mousedrag),this.cancel(G)}))),this.register((0,f.addDisposableDomListener)(I,"wheel",(G=>{if(!X.wheel){if(!this.buffer.hasScrollback){const Z=this.viewport.getLinesScrolled(G);if(Z===0)return;const ae=U.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(G.deltaY<0?"A":"B");let he="";for(let je=0;je<Math.abs(Z);je++)he+=ae;return this.coreService.triggerDataEvent(he,!0),this.cancel(G,!0)}return this.viewport.handleWheel(G)?this.cancel(G):void 0}}),{passive:!1})),this.register((0,f.addDisposableDomListener)(I,"touchstart",(G=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(G),this.cancel(G)}),{passive:!0})),this.register((0,f.addDisposableDomListener)(I,"touchmove",(G=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(G)?void 0:this.cancel(G)}),{passive:!1}))}refresh(j,I){var K;(K=this._renderService)===null||K===void 0||K.refreshRows(j,I)}updateCursorStyle(j){var I;!((I=this._selectionService)===null||I===void 0)&&I.shouldColumnSelect(j)?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(j,I,K=0){var X;K===1?(super.scrollLines(j,I,K),this.refresh(0,this.rows-1)):(X=this.viewport)===null||X===void 0||X.scrollLines(j)}paste(j){(0,u.paste)(j,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(j){this._customKeyEventHandler=j}registerLinkProvider(j){return this.linkifier2.registerLinkProvider(j)}registerCharacterJoiner(j){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const I=this._characterJoinerService.register(j);return this.refresh(0,this.rows-1),I}deregisterCharacterJoiner(j){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(j)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(j){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+j)}registerDecoration(j){return this._decorationService.registerDecoration(j)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(j,I,K){this._selectionService.setSelection(j,I,K)}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(){var j;(j=this._selectionService)===null||j===void 0||j.clearSelection()}selectAll(){var j;(j=this._selectionService)===null||j===void 0||j.selectAll()}selectLines(j,I){var K;(K=this._selectionService)===null||K===void 0||K.selectLines(j,I)}_keyDown(j){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(j)===!1)return!1;const I=this.browser.isMac&&this.options.macOptionIsMeta&&j.altKey;if(!I&&!this._compositionHelper.keydown(j))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;I||j.key!=="Dead"&&j.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const K=(0,T.evaluateKeyboardEvent)(j,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(j),K.type===3||K.type===2){const X=this.rows-1;return this.scrollLines(K.type===2?-X:X),this.cancel(j,!0)}return K.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,j)||(K.cancel&&this.cancel(j,!0),!K.key||!!(j.key&&!j.ctrlKey&&!j.altKey&&!j.metaKey&&j.key.length===1&&j.key.charCodeAt(0)>=65&&j.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(K.key!==U.C0.ETX&&K.key!==U.C0.CR||(this.textarea.value=""),this._onKey.fire({key:K.key,domEvent:j}),this._showCursor(),this.coreService.triggerDataEvent(K.key,!0),!this.optionsService.rawOptions.screenReaderMode||j.altKey||j.ctrlKey?this.cancel(j,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(j,I){const K=j.isMac&&!this.options.macOptionIsMeta&&I.altKey&&!I.ctrlKey&&!I.metaKey||j.isWindows&&I.altKey&&I.ctrlKey&&!I.metaKey||j.isWindows&&I.getModifierState("AltGraph");return I.type==="keypress"?K:K&&(!I.keyCode||I.keyCode>47)}_keyUp(j){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(j)===!1||((function(I){return I.keyCode===16||I.keyCode===17||I.keyCode===18})(j)||this.focus(),this.updateCursorStyle(j),this._keyPressHandled=!1)}_keyPress(j){let I;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(j)===!1)return!1;if(this.cancel(j),j.charCode)I=j.charCode;else if(j.which===null||j.which===void 0)I=j.keyCode;else{if(j.which===0||j.charCode===0)return!1;I=j.which}return!(!I||(j.altKey||j.ctrlKey||j.metaKey)&&!this._isThirdLevelShift(this.browser,j)||(I=String.fromCharCode(I),this._onKey.fire({key:I,domEvent:j}),this._showCursor(),this.coreService.triggerDataEvent(I,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(j){if(j.data&&j.inputType==="insertText"&&(!j.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const I=j.data;return this.coreService.triggerDataEvent(I,!0),this.cancel(j),!0}return!1}resize(j,I){j!==this.cols||I!==this.rows?super.resize(j,I):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(j,I){var K,X;(K=this._charSizeService)===null||K===void 0||K.measure(),(X=this.viewport)===null||X===void 0||X.syncScrollArea(!0)}clear(){var j;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 I=1;I<this.rows;I++)this.buffer.lines.push(this.buffer.getBlankLine(H.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(j=this.viewport)===null||j===void 0||j.reset(),this.refresh(0,this.rows-1)}}reset(){var j,I;this.options.rows=this.rows,this.options.cols=this.cols;const K=this._customKeyEventHandler;this._setup(),super.reset(),(j=this._selectionService)===null||j===void 0||j.reset(),this._decorationService.reset(),(I=this.viewport)===null||I===void 0||I.reset(),this._customKeyEventHandler=K,this.refresh(0,this.rows-1)}clearTextureAtlas(){var j;(j=this._renderService)===null||j===void 0||j.clearTextureAtlas()}_reportFocus(){var j;!((j=this.element)===null||j===void 0)&&j.classList.contains("focus")?this.coreService.triggerDataEvent(U.C0.ESC+"[I"):this.coreService.triggerDataEvent(U.C0.ESC+"[O")}_reportWindowsOptions(j){if(this._renderService)switch(j){case q.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const I=this._renderService.dimensions.css.canvas.width.toFixed(0),K=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${U.C0.ESC}[4;${K};${I}t`);break;case q.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const X=this._renderService.dimensions.css.cell.width.toFixed(0),J=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${U.C0.ESC}[6;${J};${X}t`)}}cancel(j,I){if(this.options.cancelEvents||I)return j.preventDefault(),j.stopPropagation(),!1}}r.Terminal=z},9924:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.TimeBasedDebouncer=void 0,r.TimeBasedDebouncer=class{constructor(o,u=1e3){this._renderCallback=o,this._debounceThresholdMS=u,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(o,u,f){this._rowCount=f,o=o!==void 0?o:0,u=u!==void 0?u:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,o):o,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,u):u;const l=Date.now();if(l-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=l,this._innerRefresh();else if(!this._additionalRefreshRequested){const g=l-this._lastRefreshMs,m=this._debounceThresholdMS-g;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),m)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const o=Math.max(this._rowStart,0),u=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(o,u)}}},1680:function(w,r,o){var u=this&&this.__decorate||function(d,c,h,_){var S,k=arguments.length,E=k<3?c:_===null?_=Object.getOwnPropertyDescriptor(c,h):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(d,c,h,_);else for(var x=d.length-1;x>=0;x--)(S=d[x])&&(E=(k<3?S(E):k>3?S(c,h,E):S(c,h))||E);return k>3&&E&&Object.defineProperty(c,h,E),E},f=this&&this.__param||function(d,c){return function(h,_){c(h,_,d)}};Object.defineProperty(r,"__esModule",{value:!0}),r.Viewport=void 0;const l=o(3656),g=o(4725),m=o(8460),y=o(844),b=o(2585);let n=r.Viewport=class extends y.Disposable{constructor(d,c,h,_,S,k,E,x){super(),this._viewportElement=d,this._scrollArea=c,this._bufferService=h,this._optionsService=_,this._charSizeService=S,this._renderService=k,this._coreBrowserService=E,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new m.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,l.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((C=>this._activeBuffer=C.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((C=>this._renderDimensions=C))),this._handleThemeChange(x.colors),this.register(x.onChangeColors((C=>this._handleThemeChange(C)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(d){this._viewportElement.style.backgroundColor=d.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame((()=>this.syncScrollArea()))}_refresh(d){if(d)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderService.dimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderService.dimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;const c=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderService.dimensions.css.canvas.height);this._lastRecordedBufferHeight!==c&&(this._lastRecordedBufferHeight=c,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const d=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==d&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=d),this._refreshAnimationFrame=null}syncScrollArea(d=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(d);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(d)}_handleScroll(d){if(this._lastScrollTop=this._viewportElement.scrollTop,!this._viewportElement.offsetParent)return;if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._onRequestScrollLines.fire({amount:0,suppressScrollEvent:!0});const c=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:c,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const d=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(d*(this._smoothScrollState.target-this._smoothScrollState.origin)),d<1?this._coreBrowserService.window.requestAnimationFrame((()=>this._smoothScroll())):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(d,c){const h=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(c<0&&this._viewportElement.scrollTop!==0||c>0&&h<this._lastRecordedBufferHeight)||(d.cancelable&&d.preventDefault(),!1)}handleWheel(d){const c=this._getPixelsScrolled(d);return c!==0&&(this._optionsService.rawOptions.smoothScrollDuration?(this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target===-1?this._smoothScrollState.target=this._viewportElement.scrollTop+c:this._smoothScrollState.target+=c,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=c,this._bubbleScroll(d,c))}scrollLines(d){if(d!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const c=d*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+c,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:d,suppressScrollEvent:!1})}_getPixelsScrolled(d){if(d.deltaY===0||d.shiftKey)return 0;let c=this._applyScrollModifier(d.deltaY,d);return d.deltaMode===WheelEvent.DOM_DELTA_LINE?c*=this._currentRowHeight:d.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(c*=this._currentRowHeight*this._bufferService.rows),c}getBufferElements(d,c){var h;let _,S="";const k=[],E=c??this._bufferService.buffer.lines.length,x=this._bufferService.buffer.lines;for(let C=d;C<E;C++){const N=x.get(C);if(!N)continue;const L=(h=x.get(C+1))===null||h===void 0?void 0:h.isWrapped;if(S+=N.translateToString(!L),!L||C===x.length-1){const R=document.createElement("div");R.textContent=S,k.push(R),S.length>0&&(_=R),S=""}}return{bufferElements:k,cursorElement:_}}getLinesScrolled(d){if(d.deltaY===0||d.shiftKey)return 0;let c=this._applyScrollModifier(d.deltaY,d);return d.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(c/=this._currentRowHeight+0,this._wheelPartialScroll+=c,c=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):d.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(c*=this._bufferService.rows),c}_applyScrollModifier(d,c){const h=this._optionsService.rawOptions.fastScrollModifier;return h==="alt"&&c.altKey||h==="ctrl"&&c.ctrlKey||h==="shift"&&c.shiftKey?d*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:d*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(d){this._lastTouchY=d.touches[0].pageY}handleTouchMove(d){const c=this._lastTouchY-d.touches[0].pageY;return this._lastTouchY=d.touches[0].pageY,c!==0&&(this._viewportElement.scrollTop+=c,this._bubbleScroll(d,c))}};r.Viewport=n=u([f(2,b.IBufferService),f(3,b.IOptionsService),f(4,g.ICharSizeService),f(5,g.IRenderService),f(6,g.ICoreBrowserService),f(7,g.IThemeService)],n)},3107:function(w,r,o){var u=this&&this.__decorate||function(n,d,c,h){var _,S=arguments.length,k=S<3?d:h===null?h=Object.getOwnPropertyDescriptor(d,c):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(n,d,c,h);else for(var E=n.length-1;E>=0;E--)(_=n[E])&&(k=(S<3?_(k):S>3?_(d,c,k):_(d,c))||k);return S>3&&k&&Object.defineProperty(d,c,k),k},f=this&&this.__param||function(n,d){return function(c,h){d(c,h,n)}};Object.defineProperty(r,"__esModule",{value:!0}),r.BufferDecorationRenderer=void 0;const l=o(3656),g=o(4725),m=o(844),y=o(2585);let b=r.BufferDecorationRenderer=class extends m.Disposable{constructor(n,d,c,h){super(),this._screenElement=n,this._bufferService=d,this._decorationService=c,this._renderService=h,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this.register(this._renderService.onRenderedViewportChange((()=>this._doRefreshDecorations()))),this.register(this._renderService.onDimensionsChange((()=>{this._dimensionsChanged=!0,this._queueRefresh()}))),this.register((0,l.addDisposableDomListener)(window,"resize",(()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt}))),this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh()))),this.register(this._decorationService.onDecorationRemoved((_=>this._removeDecoration(_)))),this.register((0,m.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(const n of this._decorationService.decorations)this._renderDecoration(n);this._dimensionsChanged=!1}_renderDecoration(n){this._refreshStyle(n),this._dimensionsChanged&&this._refreshXPosition(n)}_createElement(n){var d,c;const h=document.createElement("div");h.classList.add("xterm-decoration"),h.classList.toggle("xterm-decoration-top-layer",((d=n?.options)===null||d===void 0?void 0:d.layer)==="top"),h.style.width=`${Math.round((n.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,h.style.height=(n.options.height||1)*this._renderService.dimensions.css.cell.height+"px",h.style.top=(n.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",h.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const _=(c=n.options.x)!==null&&c!==void 0?c:0;return _&&_>this._bufferService.cols&&(h.style.display="none"),this._refreshXPosition(n,h),h}_refreshStyle(n){const d=n.marker.line-this._bufferService.buffers.active.ydisp;if(d<0||d>=this._bufferService.rows)n.element&&(n.element.style.display="none",n.onRenderEmitter.fire(n.element));else{let c=this._decorationElements.get(n);c||(c=this._createElement(n),n.element=c,this._decorationElements.set(n,c),this._container.appendChild(c),n.onDispose((()=>{this._decorationElements.delete(n),c.remove()}))),c.style.top=d*this._renderService.dimensions.css.cell.height+"px",c.style.display=this._altBufferIsActive?"none":"block",n.onRenderEmitter.fire(c)}}_refreshXPosition(n,d=n.element){var c;if(!d)return;const h=(c=n.options.x)!==null&&c!==void 0?c:0;(n.options.anchor||"left")==="right"?d.style.right=h?h*this._renderService.dimensions.css.cell.width+"px":"":d.style.left=h?h*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(n){var d;(d=this._decorationElements.get(n))===null||d===void 0||d.remove(),this._decorationElements.delete(n),n.dispose()}};r.BufferDecorationRenderer=b=u([f(1,y.IBufferService),f(2,y.IDecorationService),f(3,g.IRenderService)],b)},5871:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ColorZoneStore=void 0,r.ColorZoneStore=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(o){if(o.options.overviewRulerOptions){for(const u of this._zones)if(u.color===o.options.overviewRulerOptions.color&&u.position===o.options.overviewRulerOptions.position){if(this._lineIntersectsZone(u,o.marker.line))return;if(this._lineAdjacentToZone(u,o.marker.line,o.options.overviewRulerOptions.position))return void this._addLineToZone(u,o.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=o.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=o.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=o.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=o.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:o.options.overviewRulerOptions.color,position:o.options.overviewRulerOptions.position,startBufferLine:o.marker.line,endBufferLine:o.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(o){this._linePadding=o}_lineIntersectsZone(o,u){return u>=o.startBufferLine&&u<=o.endBufferLine}_lineAdjacentToZone(o,u,f){return u>=o.startBufferLine-this._linePadding[f||"full"]&&u<=o.endBufferLine+this._linePadding[f||"full"]}_addLineToZone(o,u){o.startBufferLine=Math.min(o.startBufferLine,u),o.endBufferLine=Math.max(o.endBufferLine,u)}}},5744:function(w,r,o){var u=this&&this.__decorate||function(_,S,k,E){var x,C=arguments.length,N=C<3?S:E===null?E=Object.getOwnPropertyDescriptor(S,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(_,S,k,E);else for(var L=_.length-1;L>=0;L--)(x=_[L])&&(N=(C<3?x(N):C>3?x(S,k,N):x(S,k))||N);return C>3&&N&&Object.defineProperty(S,k,N),N},f=this&&this.__param||function(_,S){return function(k,E){S(k,E,_)}};Object.defineProperty(r,"__esModule",{value:!0}),r.OverviewRulerRenderer=void 0;const l=o(5871),g=o(3656),m=o(4725),y=o(844),b=o(2585),n={full:0,left:0,center:0,right:0},d={full:0,left:0,center:0,right:0},c={full:0,left:0,center:0,right:0};let h=r.OverviewRulerRenderer=class extends y.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(_,S,k,E,x,C,N){var L;super(),this._viewportElement=_,this._screenElement=S,this._bufferService=k,this._decorationService=E,this._renderService=x,this._optionsService=C,this._coreBrowseService=N,this._colorZoneStore=new l.ColorZoneStore,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=document.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(L=this._viewportElement.parentElement)===null||L===void 0||L.insertBefore(this._canvas,this._viewportElement);const R=this._canvas.getContext("2d");if(!R)throw new Error("Ctx cannot be null");this._ctx=R,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,y.toDisposable)((()=>{var P;(P=this._canvas)===null||P===void 0||P.remove()})))}_registerDecorationListeners(){this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh(void 0,!0)))),this.register(this._decorationService.onDecorationRemoved((()=>this._queueRefresh(void 0,!0))))}_registerBufferChangeListeners(){this.register(this._renderService.onRenderedViewportChange((()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"}))),this.register(this._bufferService.onScroll((()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})))}_registerDimensionChangeListeners(){this.register(this._renderService.onRender((()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)}))),this.register(this._optionsService.onSpecificOptionChange("overviewRulerWidth",(()=>this._queueRefresh(!0)))),this.register((0,g.addDisposableDomListener)(this._coreBrowseService.window,"resize",(()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){const _=Math.floor(this._canvas.width/3),S=Math.ceil(this._canvas.width/3);d.full=this._canvas.width,d.left=_,d.center=S,d.right=_,this._refreshDrawHeightConstants(),c.full=0,c.left=0,c.center=d.left,c.right=d.left+d.center}_refreshDrawHeightConstants(){n.full=Math.round(2*this._coreBrowseService.dpr);const _=this._canvas.height/this._bufferService.buffer.lines.length,S=Math.round(Math.max(Math.min(_,12),6)*this._coreBrowseService.dpr);n.left=S,n.center=S,n.right=S}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*n.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*n.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*n.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*n.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowseService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowseService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(const S of this._decorationService.decorations)this._colorZoneStore.addDecoration(S);this._ctx.lineWidth=1;const _=this._colorZoneStore.zones;for(const S of _)S.position!=="full"&&this._renderColorZone(S);for(const S of _)S.position==="full"&&this._renderColorZone(S);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(_){this._ctx.fillStyle=_.color,this._ctx.fillRect(c[_.position||"full"],Math.round((this._canvas.height-1)*(_.startBufferLine/this._bufferService.buffers.active.lines.length)-n[_.position||"full"]/2),d[_.position||"full"],Math.round((this._canvas.height-1)*((_.endBufferLine-_.startBufferLine)/this._bufferService.buffers.active.lines.length)+n[_.position||"full"]))}_queueRefresh(_,S){this._shouldUpdateDimensions=_||this._shouldUpdateDimensions,this._shouldUpdateAnchor=S||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowseService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};r.OverviewRulerRenderer=h=u([f(2,b.IBufferService),f(3,b.IDecorationService),f(4,m.IRenderService),f(5,b.IOptionsService),f(6,m.ICoreBrowserService)],h)},2950:function(w,r,o){var u=this&&this.__decorate||function(b,n,d,c){var h,_=arguments.length,S=_<3?n:c===null?c=Object.getOwnPropertyDescriptor(n,d):c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(b,n,d,c);else for(var k=b.length-1;k>=0;k--)(h=b[k])&&(S=(_<3?h(S):_>3?h(n,d,S):h(n,d))||S);return _>3&&S&&Object.defineProperty(n,d,S),S},f=this&&this.__param||function(b,n){return function(d,c){n(d,c,b)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CompositionHelper=void 0;const l=o(4725),g=o(2585),m=o(2584);let y=r.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(b,n,d,c,h,_){this._textarea=b,this._compositionView=n,this._bufferService=d,this._optionsService=c,this._coreService=h,this._renderService=_,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(b){this._compositionView.textContent=b.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(b){if(this._isComposing||this._isSendingComposition){if(b.keyCode===229||b.keyCode===16||b.keyCode===17||b.keyCode===18)return!1;this._finalizeComposition(!1)}return b.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(b){if(this._compositionView.classList.remove("active"),this._isComposing=!1,b){const n={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let d;this._isSendingComposition=!1,n.start+=this._dataAlreadySent.length,d=this._isComposing?this._textarea.value.substring(n.start,n.end):this._textarea.value.substring(n.start),d.length>0&&this._coreService.triggerDataEvent(d,!0)}}),0)}else{this._isSendingComposition=!1;const n=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(n,!0)}}_handleAnyTextareaChanges(){const b=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const n=this._textarea.value,d=n.replace(b,"");this._dataAlreadySent=d,n.length>b.length?this._coreService.triggerDataEvent(d,!0):n.length<b.length?this._coreService.triggerDataEvent(`${m.C0.DEL}`,!0):n.length===b.length&&n!==b&&this._coreService.triggerDataEvent(n,!0)}}),0)}updateCompositionElements(b){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const n=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),d=this._renderService.dimensions.css.cell.height,c=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,h=n*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=h+"px",this._compositionView.style.top=c+"px",this._compositionView.style.height=d+"px",this._compositionView.style.lineHeight=d+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const _=this._compositionView.getBoundingClientRect();this._textarea.style.left=h+"px",this._textarea.style.top=c+"px",this._textarea.style.width=Math.max(_.width,1)+"px",this._textarea.style.height=Math.max(_.height,1)+"px",this._textarea.style.lineHeight=_.height+"px"}b||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};r.CompositionHelper=y=u([f(2,g.IBufferService),f(3,g.IOptionsService),f(4,g.ICoreService),f(5,l.IRenderService)],y)},9806:(w,r)=>{function o(u,f,l){const g=l.getBoundingClientRect(),m=u.getComputedStyle(l),y=parseInt(m.getPropertyValue("padding-left")),b=parseInt(m.getPropertyValue("padding-top"));return[f.clientX-g.left-y,f.clientY-g.top-b]}Object.defineProperty(r,"__esModule",{value:!0}),r.getCoords=r.getCoordsRelativeToElement=void 0,r.getCoordsRelativeToElement=o,r.getCoords=function(u,f,l,g,m,y,b,n,d){if(!y)return;const c=o(u,f,l);return c?(c[0]=Math.ceil((c[0]+(d?b/2:0))/b),c[1]=Math.ceil(c[1]/n),c[0]=Math.min(Math.max(c[0],1),g+(d?1:0)),c[1]=Math.min(Math.max(c[1],1),m),c):void 0}},9504:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.moveToCellSequence=void 0;const u=o(2584);function f(n,d,c,h){const _=n-l(n,c),S=d-l(d,c),k=Math.abs(_-S)-(function(E,x,C){let N=0;const L=E-l(E,C),R=x-l(x,C);for(let P=0;P<Math.abs(L-R);P++){const F=g(E,x)==="A"?-1:1,B=C.buffer.lines.get(L+F*P);B?.isWrapped&&N++}return N})(n,d,c);return b(k,y(g(n,d),h))}function l(n,d){let c=0,h=d.buffer.lines.get(n),_=h?.isWrapped;for(;_&&n>=0&&n<d.rows;)c++,h=d.buffer.lines.get(--n),_=h?.isWrapped;return c}function g(n,d){return n>d?"A":"B"}function m(n,d,c,h,_,S){let k=n,E=d,x="";for(;k!==c||E!==h;)k+=_?1:-1,_&&k>S.cols-1?(x+=S.buffer.translateBufferLineToString(E,!1,n,k),k=0,n=0,E++):!_&&k<0&&(x+=S.buffer.translateBufferLineToString(E,!1,0,n+1),k=S.cols-1,n=k,E--);return x+S.buffer.translateBufferLineToString(E,!1,n,k)}function y(n,d){const c=d?"O":"[";return u.C0.ESC+c+n}function b(n,d){n=Math.floor(n);let c="";for(let h=0;h<n;h++)c+=d;return c}r.moveToCellSequence=function(n,d,c,h){const _=c.buffer.x,S=c.buffer.y;if(!c.buffer.hasScrollback)return(function(x,C,N,L,R,P){return f(C,L,R,P).length===0?"":b(m(x,C,x,C-l(C,R),!1,R).length,y("D",P))})(_,S,0,d,c,h)+f(S,d,c,h)+(function(x,C,N,L,R,P){let F;F=f(C,L,R,P).length>0?L-l(L,R):C;const B=L,H=(function(U,T,D,M,O,q){let V;return V=f(D,M,O,q).length>0?M-l(M,O):T,U<D&&V<=M||U>=D&&V<M?"C":"D"})(x,C,N,L,R,P);return b(m(x,F,N,B,H==="C",R).length,y(H,P))})(_,S,n,d,c,h);let k;if(S===d)return k=_>n?"D":"C",b(Math.abs(_-n),y(k,h));k=S>d?"D":"C";const E=Math.abs(S-d);return b((function(x,C){return C.cols-x})(S>d?n:_,c)+(E-1)*c.cols+1+((S>d?_:n)-1),y(k,h))}},1296:function(w,r,o){var u=this&&this.__decorate||function(R,P,F,B){var H,U=arguments.length,T=U<3?P:B===null?B=Object.getOwnPropertyDescriptor(P,F):B;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(R,P,F,B);else for(var D=R.length-1;D>=0;D--)(H=R[D])&&(T=(U<3?H(T):U>3?H(P,F,T):H(P,F))||T);return U>3&&T&&Object.defineProperty(P,F,T),T},f=this&&this.__param||function(R,P){return function(F,B){P(F,B,R)}};Object.defineProperty(r,"__esModule",{value:!0}),r.DomRenderer=void 0;const l=o(3787),g=o(2550),m=o(2223),y=o(6171),b=o(4725),n=o(8055),d=o(8460),c=o(844),h=o(2585),_="xterm-dom-renderer-owner-",S="xterm-rows",k="xterm-fg-",E="xterm-bg-",x="xterm-focus",C="xterm-selection";let N=1,L=r.DomRenderer=class extends c.Disposable{constructor(R,P,F,B,H,U,T,D,M,O){super(),this._element=R,this._screenElement=P,this._viewportElement=F,this._linkifier2=B,this._charSizeService=U,this._optionsService=T,this._bufferService=D,this._coreBrowserService=M,this._themeService=O,this._terminalClass=N++,this._rowElements=[],this.onRequestRedraw=this.register(new d.EventEmitter).event,this._rowContainer=document.createElement("div"),this._rowContainer.classList.add(S),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=document.createElement("div"),this._selectionContainer.classList.add(C),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,y.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((q=>this._injectCss(q)))),this._injectCss(this._themeService.colors),this._rowFactory=H.createInstance(l.DomRendererRowFactory,document),this._element.classList.add(_+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((q=>this._handleLinkHover(q)))),this.register(this._linkifier2.onHideLinkUnderline((q=>this._handleLinkLeave(q)))),this.register((0,c.toDisposable)((()=>{this._element.classList.remove(_+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new g.WidthCache(document),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){const R=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*R,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*R),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/R),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/R),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(const F of this._rowElements)F.style.width=`${this.dimensions.css.canvas.width}px`,F.style.height=`${this.dimensions.css.cell.height}px`,F.style.lineHeight=`${this.dimensions.css.cell.height}px`,F.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const P=`${this._terminalSelector} .${S} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=P,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(R){this._themeStyleElement||(this._themeStyleElement=document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let P=`${this._terminalSelector} .${S} { color: ${R.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;P+=`${this._terminalSelector} .${S} .xterm-dim { color: ${n.color.multiplyOpacity(R.foreground,.5).css};}`,P+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`,P+="@keyframes blink_box_shadow_"+this._terminalClass+" { 50% { border-bottom-style: hidden; }}",P+="@keyframes blink_block_"+this._terminalClass+` { 0% { background-color: ${R.cursor.css}; color: ${R.cursorAccent.css}; } 50% { background-color: inherit; color: ${R.cursor.css}; }}`,P+=`${this._terminalSelector} .${S}.${x} .xterm-cursor.xterm-cursor-blink:not(.xterm-cursor-block) { animation: blink_box_shadow_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${S}.${x} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: blink_block_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-block { background-color: ${R.cursor.css}; color: ${R.cursorAccent.css};}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${R.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${R.cursor.css} inset;}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${R.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,P+=`${this._terminalSelector} .${C} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${C} div { position: absolute; background-color: ${R.selectionBackgroundOpaque.css};}${this._terminalSelector} .${C} div { position: absolute; background-color: ${R.selectionInactiveBackgroundOpaque.css};}`;for(const[F,B]of R.ansi.entries())P+=`${this._terminalSelector} .${k}${F} { color: ${B.css}; }${this._terminalSelector} .${k}${F}.xterm-dim { color: ${n.color.multiplyOpacity(B,.5).css}; }${this._terminalSelector} .${E}${F} { background-color: ${B.css}; }`;P+=`${this._terminalSelector} .${k}${m.INVERTED_DEFAULT_COLOR} { color: ${n.color.opaque(R.background).css}; }${this._terminalSelector} .${k}${m.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${n.color.multiplyOpacity(n.color.opaque(R.background),.5).css}; }${this._terminalSelector} .${E}${m.INVERTED_DEFAULT_COLOR} { background-color: ${R.foreground.css}; }`,this._themeStyleElement.textContent=P}_setDefaultSpacing(){const R=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${R}px`,this._rowFactory.defaultSpacing=R}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(R,P){for(let F=this._rowElements.length;F<=P;F++){const B=document.createElement("div");this._rowContainer.appendChild(B),this._rowElements.push(B)}for(;this._rowElements.length>P;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(R,P){this._refreshRowElements(R,P),this._updateDimensions()}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(x)}handleFocus(){this._rowContainer.classList.add(x),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(R,P,F){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(R,P,F),this.renderRows(0,this._bufferService.rows-1),!R||!P)return;const B=R[1]-this._bufferService.buffer.ydisp,H=P[1]-this._bufferService.buffer.ydisp,U=Math.max(B,0),T=Math.min(H,this._bufferService.rows-1);if(U>=this._bufferService.rows||T<0)return;const D=document.createDocumentFragment();if(F){const M=R[0]>P[0];D.appendChild(this._createSelectionElement(U,M?P[0]:R[0],M?R[0]:P[0],T-U+1))}else{const M=B===U?R[0]:0,O=U===H?P[0]:this._bufferService.cols;D.appendChild(this._createSelectionElement(U,M,O));const q=T-U-1;if(D.appendChild(this._createSelectionElement(U+1,0,this._bufferService.cols,q)),U!==T){const V=H===T?P[0]:this._bufferService.cols;D.appendChild(this._createSelectionElement(T,0,V))}}this._selectionContainer.appendChild(D)}_createSelectionElement(R,P,F,B=1){const H=document.createElement("div");return H.style.height=B*this.dimensions.css.cell.height+"px",H.style.top=R*this.dimensions.css.cell.height+"px",H.style.left=P*this.dimensions.css.cell.width+"px",H.style.width=this.dimensions.css.cell.width*(F-P)+"px",H}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(const R of this._rowElements)R.replaceChildren()}renderRows(R,P){const F=this._bufferService.buffer,B=F.ybase+F.y,H=Math.min(F.x,this._bufferService.cols-1),U=this._optionsService.rawOptions.cursorBlink,T=this._optionsService.rawOptions.cursorStyle,D=this._optionsService.rawOptions.cursorInactiveStyle;for(let M=R;M<=P;M++){const O=M+F.ydisp,q=this._rowElements[M],V=F.lines.get(O);if(!q||!V)break;q.replaceChildren(...this._rowFactory.createRow(V,O,O===B,T,D,H,U,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${_}${this._terminalClass}`}_handleLinkHover(R){this._setCellUnderline(R.x1,R.x2,R.y1,R.y2,R.cols,!0)}_handleLinkLeave(R){this._setCellUnderline(R.x1,R.x2,R.y1,R.y2,R.cols,!1)}_setCellUnderline(R,P,F,B,H,U){F<0&&(R=0),B<0&&(P=0);const T=this._bufferService.rows-1;F=Math.max(Math.min(F,T),0),B=Math.max(Math.min(B,T),0),H=Math.min(H,this._bufferService.cols);const D=this._bufferService.buffer,M=D.ybase+D.y,O=Math.min(D.x,H-1),q=this._optionsService.rawOptions.cursorBlink,V=this._optionsService.rawOptions.cursorStyle,$=this._optionsService.rawOptions.cursorInactiveStyle;for(let z=F;z<=B;++z){const W=z+D.ydisp,j=this._rowElements[z],I=D.lines.get(W);if(!j||!I)break;j.replaceChildren(...this._rowFactory.createRow(I,W,W===M,V,$,O,q,this.dimensions.css.cell.width,this._widthCache,U?z===F?R:0:-1,U?(z===B?P:H)-1:-1))}}};r.DomRenderer=L=u([f(4,h.IInstantiationService),f(5,b.ICharSizeService),f(6,h.IOptionsService),f(7,h.IBufferService),f(8,b.ICoreBrowserService),f(9,b.IThemeService)],L)},3787:function(w,r,o){var u=this&&this.__decorate||function(k,E,x,C){var N,L=arguments.length,R=L<3?E:C===null?C=Object.getOwnPropertyDescriptor(E,x):C;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(k,E,x,C);else for(var P=k.length-1;P>=0;P--)(N=k[P])&&(R=(L<3?N(R):L>3?N(E,x,R):N(E,x))||R);return L>3&&R&&Object.defineProperty(E,x,R),R},f=this&&this.__param||function(k,E){return function(x,C){E(x,C,k)}};Object.defineProperty(r,"__esModule",{value:!0}),r.DomRendererRowFactory=void 0;const l=o(2223),g=o(643),m=o(511),y=o(2585),b=o(8055),n=o(4725),d=o(4269),c=o(6171),h=o(3734);let _=r.DomRendererRowFactory=class{constructor(k,E,x,C,N,L,R){this._document=k,this._characterJoinerService=E,this._optionsService=x,this._coreBrowserService=C,this._coreService=N,this._decorationService=L,this._themeService=R,this._workCell=new m.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(k,E,x){this._selectionStart=k,this._selectionEnd=E,this._columnSelectMode=x}createRow(k,E,x,C,N,L,R,P,F,B,H){const U=[],T=this._characterJoinerService.getJoinedCharacters(E),D=this._themeService.colors;let M,O=k.getNoBgTrimmedLength();x&&O<L+1&&(O=L+1);let q=0,V="",$=0,z=0,W=0,j=!1,I=0,K=!1,X=0;const J=[],G=B!==-1&&H!==-1;for(let Z=0;Z<O;Z++){k.loadCell(Z,this._workCell);let ae=this._workCell.getWidth();if(ae===0)continue;let he=!1,je=Z,se=this._workCell;if(T.length>0&&Z===T[0][0]){he=!0;const ue=T.shift();se=new d.JoinedCellData(this._workCell,k.translateToString(!0,ue[0],ue[1]),ue[1]-ue[0]),je=ue[1]-1,ae=se.getWidth()}const Ae=this._isCellInSelection(Z,E),te=x&&Z===L,me=G&&Z>=B&&Z<=H;let De=!1;this._decorationService.forEachDecorationAtCell(Z,E,void 0,(ue=>{De=!0}));let qe=se.getChars()||g.WHITESPACE_CELL_CHAR;if(qe===" "&&(se.isUnderline()||se.isOverline())&&(qe=" "),X=ae*P-F.get(qe,se.isBold(),se.isItalic()),M){if(q&&(Ae&&K||!Ae&&!K&&se.bg===$)&&(Ae&&K&&D.selectionForeground||se.fg===z)&&se.extended.ext===W&&me===j&&X===I&&!te&&!he&&!De){V+=qe,q++;continue}q&&(M.textContent=V),M=this._document.createElement("span"),q=0,V=""}else M=this._document.createElement("span");if($=se.bg,z=se.fg,W=se.extended.ext,j=me,I=X,K=Ae,he&&L>=Z&&L<=je&&(L=Z),!this._coreService.isCursorHidden&&te){if(J.push("xterm-cursor"),this._coreBrowserService.isFocused)R&&J.push("xterm-cursor-blink"),J.push(C==="bar"?"xterm-cursor-bar":C==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(N)switch(N){case"outline":J.push("xterm-cursor-outline");break;case"block":J.push("xterm-cursor-block");break;case"bar":J.push("xterm-cursor-bar");break;case"underline":J.push("xterm-cursor-underline")}}if(se.isBold()&&J.push("xterm-bold"),se.isItalic()&&J.push("xterm-italic"),se.isDim()&&J.push("xterm-dim"),V=se.isInvisible()?g.WHITESPACE_CELL_CHAR:se.getChars()||g.WHITESPACE_CELL_CHAR,se.isUnderline()&&(J.push(`xterm-underline-${se.extended.underlineStyle}`),V===" "&&(V=" "),!se.isUnderlineColorDefault()))if(se.isUnderlineColorRGB())M.style.textDecorationColor=`rgb(${h.AttributeData.toColorRGB(se.getUnderlineColor()).join(",")})`;else{let ue=se.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&se.isBold()&&ue<8&&(ue+=8),M.style.textDecorationColor=D.ansi[ue].css}se.isOverline()&&(J.push("xterm-overline"),V===" "&&(V=" ")),se.isStrikethrough()&&J.push("xterm-strikethrough"),me&&(M.style.textDecoration="underline");let ve=se.getFgColor(),Re=se.getFgColorMode(),Se=se.getBgColor(),Ce=se.getBgColorMode();const rt=!!se.isInverse();if(rt){const ue=ve;ve=Se,Se=ue;const rs=Re;Re=Ce,Ce=rs}let Te,it,Ie,nt=!1;switch(this._decorationService.forEachDecorationAtCell(Z,E,void 0,(ue=>{ue.options.layer!=="top"&&nt||(ue.backgroundColorRGB&&(Ce=50331648,Se=ue.backgroundColorRGB.rgba>>8&16777215,Te=ue.backgroundColorRGB),ue.foregroundColorRGB&&(Re=50331648,ve=ue.foregroundColorRGB.rgba>>8&16777215,it=ue.foregroundColorRGB),nt=ue.options.layer==="top")})),!nt&&Ae&&(Te=this._coreBrowserService.isFocused?D.selectionBackgroundOpaque:D.selectionInactiveBackgroundOpaque,Se=Te.rgba>>8&16777215,Ce=50331648,nt=!0,D.selectionForeground&&(Re=50331648,ve=D.selectionForeground.rgba>>8&16777215,it=D.selectionForeground)),nt&&J.push("xterm-decoration-top"),Ce){case 16777216:case 33554432:Ie=D.ansi[Se],J.push(`xterm-bg-${Se}`);break;case 50331648:Ie=b.rgba.toColor(Se>>16,Se>>8&255,255&Se),this._addStyle(M,`background-color:#${S((Se>>>0).toString(16),"0",6)}`);break;default:rt?(Ie=D.foreground,J.push(`xterm-bg-${l.INVERTED_DEFAULT_COLOR}`)):Ie=D.background}switch(Te||se.isDim()&&(Te=b.color.multiplyOpacity(Ie,.5)),Re){case 16777216:case 33554432:se.isBold()&&ve<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ve+=8),this._applyMinimumContrast(M,Ie,D.ansi[ve],se,Te,void 0)||J.push(`xterm-fg-${ve}`);break;case 50331648:const ue=b.rgba.toColor(ve>>16&255,ve>>8&255,255&ve);this._applyMinimumContrast(M,Ie,ue,se,Te,it)||this._addStyle(M,`color:#${S(ve.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(M,Ie,D.foreground,se,Te,void 0)||rt&&J.push(`xterm-fg-${l.INVERTED_DEFAULT_COLOR}`)}J.length&&(M.className=J.join(" "),J.length=0),te||he||De?M.textContent=V:q++,X!==this.defaultSpacing&&(M.style.letterSpacing=`${X}px`),U.push(M),Z=je}return M&&q&&(M.textContent=V),U}_applyMinimumContrast(k,E,x,C,N,L){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,c.excludeFromContrastRatioDemands)(C.getCode()))return!1;const R=this._getContrastCache(C);let P;if(N||L||(P=R.getColor(E.rgba,x.rgba)),P===void 0){const F=this._optionsService.rawOptions.minimumContrastRatio/(C.isDim()?2:1);P=b.color.ensureContrastRatio(N||E,L||x,F),R.setColor((N||E).rgba,(L||x).rgba,P??null)}return!!P&&(this._addStyle(k,`color:${P.css}`),!0)}_getContrastCache(k){return k.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(k,E){k.setAttribute("style",`${k.getAttribute("style")||""}${E};`)}_isCellInSelection(k,E){const x=this._selectionStart,C=this._selectionEnd;return!(!x||!C)&&(this._columnSelectMode?x[0]<=C[0]?k>=x[0]&&E>=x[1]&&k<C[0]&&E<=C[1]:k<x[0]&&E>=x[1]&&k>=C[0]&&E<=C[1]:E>x[1]&&E<C[1]||x[1]===C[1]&&E===x[1]&&k>=x[0]&&k<C[0]||x[1]<C[1]&&E===C[1]&&k<C[0]||x[1]<C[1]&&E===x[1]&&k>=x[0])}};function S(k,E,x){for(;k.length<x;)k=E+k;return k}r.DomRendererRowFactory=_=u([f(1,n.ICharacterJoinerService),f(2,y.IOptionsService),f(3,n.ICoreBrowserService),f(4,y.ICoreService),f(5,y.IDecorationService),f(6,n.IThemeService)],_)},2550:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.WidthCache=void 0,r.WidthCache=class{constructor(o){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=o.createElement("div"),this._container.style.position="absolute",this._container.style.top="-50000px",this._container.style.width="50000px",this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";const u=o.createElement("span"),f=o.createElement("span");f.style.fontWeight="bold";const l=o.createElement("span");l.style.fontStyle="italic";const g=o.createElement("span");g.style.fontWeight="bold",g.style.fontStyle="italic",this._measureElements=[u,f,l,g],this._container.appendChild(u),this._container.appendChild(f),this._container.appendChild(l),this._container.appendChild(g),o.body.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(o,u,f,l){o===this._font&&u===this._fontSize&&f===this._weight&&l===this._weightBold||(this._font=o,this._fontSize=u,this._weight=f,this._weightBold=l,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${f}`,this._measureElements[1].style.fontWeight=`${l}`,this._measureElements[2].style.fontWeight=`${f}`,this._measureElements[3].style.fontWeight=`${l}`,this.clear())}get(o,u,f){let l=0;if(!u&&!f&&o.length===1&&(l=o.charCodeAt(0))<256)return this._flat[l]!==-9999?this._flat[l]:this._flat[l]=this._measure(o,0);let g=o;u&&(g+="B"),f&&(g+="I");let m=this._holey.get(g);if(m===void 0){let y=0;u&&(y|=1),f&&(y|=2),m=this._measure(o,y),this._holey.set(g,m)}return m}_measure(o,u){const f=this._measureElements[u];return f.textContent=o.repeat(32),f.offsetWidth/32}}},2223:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.TEXT_BASELINE=r.DIM_OPACITY=r.INVERTED_DEFAULT_COLOR=void 0;const u=o(6114);r.INVERTED_DEFAULT_COLOR=257,r.DIM_OPACITY=.5,r.TEXT_BASELINE=u.isFirefox||u.isLegacyEdge?"bottom":"ideographic"},6171:(w,r)=>{function o(u){return 57508<=u&&u<=57558}Object.defineProperty(r,"__esModule",{value:!0}),r.createRenderDimensions=r.excludeFromContrastRatioDemands=r.isRestrictedPowerlineGlyph=r.isPowerlineGlyph=r.throwIfFalsy=void 0,r.throwIfFalsy=function(u){if(!u)throw new Error("value must not be falsy");return u},r.isPowerlineGlyph=o,r.isRestrictedPowerlineGlyph=function(u){return 57520<=u&&u<=57527},r.excludeFromContrastRatioDemands=function(u){return o(u)||(function(f){return 9472<=f&&f<=9631})(u)},r.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}}},456:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.SelectionModel=void 0,r.SelectionModel=class{constructor(o){this._bufferService=o,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){const o=this.selectionStart[0]+this.selectionStartLength;return o>this._bufferService.cols?o%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(o/this._bufferService.cols)-1]:[o%this._bufferService.cols,this.selectionStart[1]+Math.floor(o/this._bufferService.cols)]:[o,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const o=this.selectionStart[0]+this.selectionStartLength;return o>this._bufferService.cols?[o%this._bufferService.cols,this.selectionStart[1]+Math.floor(o/this._bufferService.cols)]:[Math.max(o,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const o=this.selectionStart,u=this.selectionEnd;return!(!o||!u)&&(o[1]>u[1]||o[1]===u[1]&&o[0]>u[0])}handleTrim(o){return this.selectionStart&&(this.selectionStart[1]-=o),this.selectionEnd&&(this.selectionEnd[1]-=o),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(w,r,o){var u=this&&this.__decorate||function(n,d,c,h){var _,S=arguments.length,k=S<3?d:h===null?h=Object.getOwnPropertyDescriptor(d,c):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(n,d,c,h);else for(var E=n.length-1;E>=0;E--)(_=n[E])&&(k=(S<3?_(k):S>3?_(d,c,k):_(d,c))||k);return S>3&&k&&Object.defineProperty(d,c,k),k},f=this&&this.__param||function(n,d){return function(c,h){d(c,h,n)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CharSizeService=void 0;const l=o(2585),g=o(8460),m=o(844);let y=r.CharSizeService=class extends m.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(n,d,c){super(),this._optionsService=c,this.width=0,this.height=0,this._onCharSizeChange=this.register(new g.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event,this._measureStrategy=new b(n,d,this._optionsService),this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const n=this._measureStrategy.measure();n.width===this.width&&n.height===this.height||(this.width=n.width,this.height=n.height,this._onCharSizeChange.fire())}};r.CharSizeService=y=u([f(2,l.IOptionsService)],y);class b{constructor(d,c,h){this._document=d,this._parentElement=c,this._optionsService=h,this._result={width:0,height:0},this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`;const d={height:Number(this._measureElement.offsetHeight),width:Number(this._measureElement.offsetWidth)};return d.width!==0&&d.height!==0&&(this._result.width=d.width/32,this._result.height=Math.ceil(d.height)),this._result}}},4269:function(w,r,o){var u=this&&this.__decorate||function(d,c,h,_){var S,k=arguments.length,E=k<3?c:_===null?_=Object.getOwnPropertyDescriptor(c,h):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(d,c,h,_);else for(var x=d.length-1;x>=0;x--)(S=d[x])&&(E=(k<3?S(E):k>3?S(c,h,E):S(c,h))||E);return k>3&&E&&Object.defineProperty(c,h,E),E},f=this&&this.__param||function(d,c){return function(h,_){c(h,_,d)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CharacterJoinerService=r.JoinedCellData=void 0;const l=o(3734),g=o(643),m=o(511),y=o(2585);class b extends l.AttributeData{constructor(c,h,_){super(),this.content=0,this.combinedData="",this.fg=c.fg,this.bg=c.bg,this.combinedData=h,this._width=_}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(c){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}r.JoinedCellData=b;let n=r.CharacterJoinerService=class zi{constructor(c){this._bufferService=c,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new m.CellData}register(c){const h={id:this._nextCharacterJoinerId++,handler:c};return this._characterJoiners.push(h),h.id}deregister(c){for(let h=0;h<this._characterJoiners.length;h++)if(this._characterJoiners[h].id===c)return this._characterJoiners.splice(h,1),!0;return!1}getJoinedCharacters(c){if(this._characterJoiners.length===0)return[];const h=this._bufferService.buffer.lines.get(c);if(!h||h.length===0)return[];const _=[],S=h.translateToString(!0);let k=0,E=0,x=0,C=h.getFg(0),N=h.getBg(0);for(let L=0;L<h.getTrimmedLength();L++)if(h.loadCell(L,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==C||this._workCell.bg!==N){if(L-k>1){const R=this._getJoinedRanges(S,x,E,h,k);for(let P=0;P<R.length;P++)_.push(R[P])}k=L,x=E,C=this._workCell.fg,N=this._workCell.bg}E+=this._workCell.getChars().length||g.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-k>1){const L=this._getJoinedRanges(S,x,E,h,k);for(let R=0;R<L.length;R++)_.push(L[R])}return _}_getJoinedRanges(c,h,_,S,k){const E=c.substring(h,_);let x=[];try{x=this._characterJoiners[0].handler(E)}catch(C){console.error(C)}for(let C=1;C<this._characterJoiners.length;C++)try{const N=this._characterJoiners[C].handler(E);for(let L=0;L<N.length;L++)zi._mergeRanges(x,N[L])}catch(N){console.error(N)}return this._stringRangesToCellRanges(x,S,k),x}_stringRangesToCellRanges(c,h,_){let S=0,k=!1,E=0,x=c[S];if(x){for(let C=_;C<this._bufferService.cols;C++){const N=h.getWidth(C),L=h.getString(C).length||g.WHITESPACE_CELL_CHAR.length;if(N!==0){if(!k&&x[0]<=E&&(x[0]=C,k=!0),x[1]<=E){if(x[1]=C,x=c[++S],!x)break;x[0]<=E?(x[0]=C,k=!0):k=!1}E+=L}}x&&(x[1]=this._bufferService.cols)}}static _mergeRanges(c,h){let _=!1;for(let S=0;S<c.length;S++){const k=c[S];if(_){if(h[1]<=k[0])return c[S-1][1]=h[1],c;if(h[1]<=k[1])return c[S-1][1]=Math.max(h[1],k[1]),c.splice(S,1),c;c.splice(S,1),S--}else{if(h[1]<=k[0])return c.splice(S,0,h),c;if(h[1]<=k[1])return k[0]=Math.min(h[0],k[0]),c;h[0]<k[1]&&(k[0]=Math.min(h[0],k[0]),_=!0)}}return _?c[c.length-1][1]=h[1]:c.push(h),c}};r.CharacterJoinerService=n=u([f(0,y.IBufferService)],n)},5114:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CoreBrowserService=void 0,r.CoreBrowserService=class{constructor(o,u){this._textarea=o,this.window=u,this._isFocused=!1,this._cachedIsFocused=void 0,this._textarea.addEventListener("focus",(()=>this._isFocused=!0)),this._textarea.addEventListener("blur",(()=>this._isFocused=!1))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask((()=>this._cachedIsFocused=void 0))),this._cachedIsFocused}}},8934:function(w,r,o){var u=this&&this.__decorate||function(y,b,n,d){var c,h=arguments.length,_=h<3?b:d===null?d=Object.getOwnPropertyDescriptor(b,n):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")_=Reflect.decorate(y,b,n,d);else for(var S=y.length-1;S>=0;S--)(c=y[S])&&(_=(h<3?c(_):h>3?c(b,n,_):c(b,n))||_);return h>3&&_&&Object.defineProperty(b,n,_),_},f=this&&this.__param||function(y,b){return function(n,d){b(n,d,y)}};Object.defineProperty(r,"__esModule",{value:!0}),r.MouseService=void 0;const l=o(4725),g=o(9806);let m=r.MouseService=class{constructor(y,b){this._renderService=y,this._charSizeService=b}getCoords(y,b,n,d,c){return(0,g.getCoords)(window,y,b,n,d,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,c)}getMouseReportCoords(y,b){const n=(0,g.getCoordsRelativeToElement)(window,y,b);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};r.MouseService=m=u([f(0,l.IRenderService),f(1,l.ICharSizeService)],m)},3230:function(w,r,o){var u=this&&this.__decorate||function(_,S,k,E){var x,C=arguments.length,N=C<3?S:E===null?E=Object.getOwnPropertyDescriptor(S,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(_,S,k,E);else for(var L=_.length-1;L>=0;L--)(x=_[L])&&(N=(C<3?x(N):C>3?x(S,k,N):x(S,k))||N);return C>3&&N&&Object.defineProperty(S,k,N),N},f=this&&this.__param||function(_,S){return function(k,E){S(k,E,_)}};Object.defineProperty(r,"__esModule",{value:!0}),r.RenderService=void 0;const l=o(3656),g=o(6193),m=o(5596),y=o(4725),b=o(8460),n=o(844),d=o(7226),c=o(2585);let h=r.RenderService=class extends n.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(_,S,k,E,x,C,N,L){if(super(),this._rowCount=_,this._charSizeService=E,this._renderer=this.register(new n.MutableDisposable),this._pausedResizeTask=new d.DebouncedIdleTask,this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this.register(new b.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new b.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new b.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new b.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new g.RenderDebouncer(N.window,((R,P)=>this._renderRows(R,P))),this.register(this._renderDebouncer),this._screenDprMonitor=new m.ScreenDprMonitor(N.window),this._screenDprMonitor.setListener((()=>this.handleDevicePixelRatioChange())),this.register(this._screenDprMonitor),this.register(C.onResize((()=>this._fullRefresh()))),this.register(C.buffers.onBufferActivate((()=>{var R;return(R=this._renderer.value)===null||R===void 0?void 0:R.clear()}))),this.register(k.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(x.onDecorationRegistered((()=>this._fullRefresh()))),this.register(x.onDecorationRemoved((()=>this._fullRefresh()))),this.register(k.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio"],(()=>{this.clear(),this.handleResize(C.cols,C.rows),this._fullRefresh()}))),this.register(k.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(C.buffer.y,C.buffer.y,!0)))),this.register((0,l.addDisposableDomListener)(N.window,"resize",(()=>this.handleDevicePixelRatioChange()))),this.register(L.onChangeColors((()=>this._fullRefresh()))),"IntersectionObserver"in N.window){const R=new N.window.IntersectionObserver((P=>this._handleIntersectionChange(P[P.length-1])),{threshold:0});R.observe(S),this.register({dispose:()=>R.disconnect()})}}_handleIntersectionChange(_){this._isPaused=_.isIntersecting===void 0?_.intersectionRatio===0:!_.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(_,S,k=!1){this._isPaused?this._needsFullRefresh=!0:(k||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(_,S,this._rowCount))}_renderRows(_,S){this._renderer.value&&(_=Math.min(_,this._rowCount-1),S=Math.min(S,this._rowCount-1),this._renderer.value.renderRows(_,S),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:_,end:S}),this._onRender.fire({start:_,end:S}),this._isNextRenderRedrawOnly=!0)}resize(_,S){this._rowCount=S,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(_){this._renderer.value=_,this._renderer.value.onRequestRedraw((S=>this.refreshRows(S.start,S.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh()}addRefreshCallback(_){return this._renderDebouncer.addRefreshCallback(_)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var _,S;this._renderer.value&&((S=(_=this._renderer.value).clearTextureAtlas)===null||S===void 0||S.call(_),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(_,S){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value.handleResize(_,S))):this._renderer.value.handleResize(_,S),this._fullRefresh())}handleCharSizeChanged(){var _;(_=this._renderer.value)===null||_===void 0||_.handleCharSizeChanged()}handleBlur(){var _;(_=this._renderer.value)===null||_===void 0||_.handleBlur()}handleFocus(){var _;(_=this._renderer.value)===null||_===void 0||_.handleFocus()}handleSelectionChanged(_,S,k){var E;this._selectionState.start=_,this._selectionState.end=S,this._selectionState.columnSelectMode=k,(E=this._renderer.value)===null||E===void 0||E.handleSelectionChanged(_,S,k)}handleCursorMove(){var _;(_=this._renderer.value)===null||_===void 0||_.handleCursorMove()}clear(){var _;(_=this._renderer.value)===null||_===void 0||_.clear()}};r.RenderService=h=u([f(2,c.IOptionsService),f(3,y.ICharSizeService),f(4,c.IDecorationService),f(5,c.IBufferService),f(6,y.ICoreBrowserService),f(7,y.IThemeService)],h)},9312:function(w,r,o){var u=this&&this.__decorate||function(x,C,N,L){var R,P=arguments.length,F=P<3?C:L===null?L=Object.getOwnPropertyDescriptor(C,N):L;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")F=Reflect.decorate(x,C,N,L);else for(var B=x.length-1;B>=0;B--)(R=x[B])&&(F=(P<3?R(F):P>3?R(C,N,F):R(C,N))||F);return P>3&&F&&Object.defineProperty(C,N,F),F},f=this&&this.__param||function(x,C){return function(N,L){C(N,L,x)}};Object.defineProperty(r,"__esModule",{value:!0}),r.SelectionService=void 0;const l=o(9806),g=o(9504),m=o(456),y=o(4725),b=o(8460),n=o(844),d=o(6114),c=o(4841),h=o(511),_=o(2585),S=" ",k=new RegExp(S,"g");let E=r.SelectionService=class extends n.Disposable{constructor(x,C,N,L,R,P,F,B,H){super(),this._element=x,this._screenElement=C,this._linkifier=N,this._bufferService=L,this._coreService=R,this._mouseService=P,this._optionsService=F,this._renderService=B,this._coreBrowserService=H,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new h.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new b.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new b.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new b.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new b.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=U=>this._handleMouseMove(U),this._mouseUpListener=U=>this._handleMouseUp(U),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((U=>this._handleTrim(U))),this.register(this._bufferService.buffers.onBufferActivate((U=>this._handleBufferActivate(U)))),this.enable(),this._model=new m.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,n.toDisposable)((()=>{this._removeMouseDownListeners()})))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){const x=this._model.finalSelectionStart,C=this._model.finalSelectionEnd;return!(!x||!C||x[0]===C[0]&&x[1]===C[1])}get selectionText(){const x=this._model.finalSelectionStart,C=this._model.finalSelectionEnd;if(!x||!C)return"";const N=this._bufferService.buffer,L=[];if(this._activeSelectionMode===3){if(x[0]===C[0])return"";const R=x[0]<C[0]?x[0]:C[0],P=x[0]<C[0]?C[0]:x[0];for(let F=x[1];F<=C[1];F++){const B=N.translateBufferLineToString(F,!0,R,P);L.push(B)}}else{const R=x[1]===C[1]?C[0]:void 0;L.push(N.translateBufferLineToString(x[1],!0,x[0],R));for(let P=x[1]+1;P<=C[1]-1;P++){const F=N.lines.get(P),B=N.translateBufferLineToString(P,!0);F?.isWrapped?L[L.length-1]+=B:L.push(B)}if(x[1]!==C[1]){const P=N.lines.get(C[1]),F=N.translateBufferLineToString(C[1],!0,0,C[0]);P&&P.isWrapped?L[L.length-1]+=F:L.push(F)}}return L.map((R=>R.replace(k," "))).join(d.isWindows?`\r
|
|
13
|
+
`:`
|
|
14
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(x){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),d.isLinux&&x&&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(x){const C=this._getMouseBufferCoords(x),N=this._model.finalSelectionStart,L=this._model.finalSelectionEnd;return!!(N&&L&&C)&&this._areCoordsInSelection(C,N,L)}isCellInSelection(x,C){const N=this._model.finalSelectionStart,L=this._model.finalSelectionEnd;return!(!N||!L)&&this._areCoordsInSelection([x,C],N,L)}_areCoordsInSelection(x,C,N){return x[1]>C[1]&&x[1]<N[1]||C[1]===N[1]&&x[1]===C[1]&&x[0]>=C[0]&&x[0]<N[0]||C[1]<N[1]&&x[1]===N[1]&&x[0]<N[0]||C[1]<N[1]&&x[1]===C[1]&&x[0]>=C[0]}_selectWordAtCursor(x,C){var N,L;const R=(L=(N=this._linkifier.currentLink)===null||N===void 0?void 0:N.link)===null||L===void 0?void 0:L.range;if(R)return this._model.selectionStart=[R.start.x-1,R.start.y-1],this._model.selectionStartLength=(0,c.getRangeLength)(R,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const P=this._getMouseBufferCoords(x);return!!P&&(this._selectWordAt(P,C),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(x,C){this._model.clearSelection(),x=Math.max(x,0),C=Math.min(C,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,x],this._model.selectionEnd=[this._bufferService.cols,C],this.refresh(),this._onSelectionChange.fire()}_handleTrim(x){this._model.handleTrim(x)&&this.refresh()}_getMouseBufferCoords(x){const C=this._mouseService.getCoords(x,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(C)return C[0]--,C[1]--,C[1]+=this._bufferService.buffer.ydisp,C}_getMouseEventScrollAmount(x){let C=(0,l.getCoordsRelativeToElement)(this._coreBrowserService.window,x,this._screenElement)[1];const N=this._renderService.dimensions.css.canvas.height;return C>=0&&C<=N?0:(C>N&&(C-=N),C=Math.min(Math.max(C,-50),50),C/=50,C/Math.abs(C)+Math.round(14*C))}shouldForceSelection(x){return d.isMac?x.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:x.shiftKey}handleMouseDown(x){if(this._mouseDownTimeStamp=x.timeStamp,(x.button!==2||!this.hasSelection)&&x.button===0){if(!this._enabled){if(!this.shouldForceSelection(x))return;x.stopPropagation()}x.preventDefault(),this._dragScrollAmount=0,this._enabled&&x.shiftKey?this._handleIncrementalClick(x):x.detail===1?this._handleSingleClick(x):x.detail===2?this._handleDoubleClick(x):x.detail===3&&this._handleTripleClick(x),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()),50)}_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(x){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(x))}_handleSingleClick(x){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(x)?3:0,this._model.selectionStart=this._getMouseBufferCoords(x),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const C=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);C&&C.length!==this._model.selectionStart[0]&&C.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(x){this._selectWordAtCursor(x,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(x){const C=this._getMouseBufferCoords(x);C&&(this._activeSelectionMode=2,this._selectLineAt(C[1]))}shouldColumnSelect(x){return x.altKey&&!(d.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(x){if(x.stopImmediatePropagation(),!this._model.selectionStart)return;const C=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(x),!this._model.selectionEnd)return void this.refresh(!0);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(x),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const N=this._bufferService.buffer;if(this._model.selectionEnd[1]<N.lines.length){const L=N.lines.get(this._model.selectionEnd[1]);L&&L.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]++}C&&C[0]===this._model.selectionEnd[0]&&C[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});const x=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(x.ydisp+this._bufferService.rows,x.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=x.ydisp),this.refresh()}}_handleMouseUp(x){const C=x.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&C<500&&x.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const N=this._mouseService.getCoords(x,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(N&&N[0]!==void 0&&N[1]!==void 0){const L=(0,g.moveToCellSequence)(N[0]-1,N[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(L,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const x=this._model.finalSelectionStart,C=this._model.finalSelectionEnd,N=!(!x||!C||x[0]===C[0]&&x[1]===C[1]);N?x&&C&&(this._oldSelectionStart&&this._oldSelectionEnd&&x[0]===this._oldSelectionStart[0]&&x[1]===this._oldSelectionStart[1]&&C[0]===this._oldSelectionEnd[0]&&C[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(x,C,N)):this._oldHasSelection&&this._fireOnSelectionChange(x,C,N)}_fireOnSelectionChange(x,C,N){this._oldSelectionStart=x,this._oldSelectionEnd=C,this._oldHasSelection=N,this._onSelectionChange.fire()}_handleBufferActivate(x){this.clearSelection(),this._trimListener.dispose(),this._trimListener=x.activeBuffer.lines.onTrim((C=>this._handleTrim(C)))}_convertViewportColToCharacterIndex(x,C){let N=C;for(let L=0;C>=L;L++){const R=x.loadCell(L,this._workCell).getChars().length;this._workCell.getWidth()===0?N--:R>1&&C!==L&&(N+=R-1)}return N}setSelection(x,C,N){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[x,C],this._model.selectionStartLength=N,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(x){this._isClickInSelection(x)||(this._selectWordAtCursor(x,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(x,C,N=!0,L=!0){if(x[0]>=this._bufferService.cols)return;const R=this._bufferService.buffer,P=R.lines.get(x[1]);if(!P)return;const F=R.translateBufferLineToString(x[1],!1);let B=this._convertViewportColToCharacterIndex(P,x[0]),H=B;const U=x[0]-B;let T=0,D=0,M=0,O=0;if(F.charAt(B)===" "){for(;B>0&&F.charAt(B-1)===" ";)B--;for(;H<F.length&&F.charAt(H+1)===" ";)H++}else{let $=x[0],z=x[0];P.getWidth($)===0&&(T++,$--),P.getWidth(z)===2&&(D++,z++);const W=P.getString(z).length;for(W>1&&(O+=W-1,H+=W-1);$>0&&B>0&&!this._isCharWordSeparator(P.loadCell($-1,this._workCell));){P.loadCell($-1,this._workCell);const j=this._workCell.getChars().length;this._workCell.getWidth()===0?(T++,$--):j>1&&(M+=j-1,B-=j-1),B--,$--}for(;z<P.length&&H+1<F.length&&!this._isCharWordSeparator(P.loadCell(z+1,this._workCell));){P.loadCell(z+1,this._workCell);const j=this._workCell.getChars().length;this._workCell.getWidth()===2?(D++,z++):j>1&&(O+=j-1,H+=j-1),H++,z++}}H++;let q=B+U-T+M,V=Math.min(this._bufferService.cols,H-B+T+D-M-O);if(C||F.slice(B,H).trim()!==""){if(N&&q===0&&P.getCodePoint(0)!==32){const $=R.lines.get(x[1]-1);if($&&P.isWrapped&&$.getCodePoint(this._bufferService.cols-1)!==32){const z=this._getWordAt([this._bufferService.cols-1,x[1]-1],!1,!0,!1);if(z){const W=this._bufferService.cols-z.start;q-=W,V+=W}}}if(L&&q+V===this._bufferService.cols&&P.getCodePoint(this._bufferService.cols-1)!==32){const $=R.lines.get(x[1]+1);if($?.isWrapped&&$.getCodePoint(0)!==32){const z=this._getWordAt([0,x[1]+1],!1,!1,!0);z&&(V+=z.length)}}return{start:q,length:V}}}_selectWordAt(x,C){const N=this._getWordAt(x,C);if(N){for(;N.start<0;)N.start+=this._bufferService.cols,x[1]--;this._model.selectionStart=[N.start,x[1]],this._model.selectionStartLength=N.length}}_selectToWordAt(x){const C=this._getWordAt(x,!0);if(C){let N=x[1];for(;C.start<0;)C.start+=this._bufferService.cols,N--;if(!this._model.areSelectionValuesReversed())for(;C.start+C.length>this._bufferService.cols;)C.length-=this._bufferService.cols,N++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?C.start:C.start+C.length,N]}}_isCharWordSeparator(x){return x.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(x.getChars())>=0}_selectLineAt(x){const C=this._bufferService.buffer.getWrappedRangeForLine(x),N={start:{x:0,y:C.first},end:{x:this._bufferService.cols-1,y:C.last}};this._model.selectionStart=[0,C.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,c.getRangeLength)(N,this._bufferService.cols)}};r.SelectionService=E=u([f(3,_.IBufferService),f(4,_.ICoreService),f(5,y.IMouseService),f(6,_.IOptionsService),f(7,y.IRenderService),f(8,y.ICoreBrowserService)],E)},4725:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.IThemeService=r.ICharacterJoinerService=r.ISelectionService=r.IRenderService=r.IMouseService=r.ICoreBrowserService=r.ICharSizeService=void 0;const u=o(8343);r.ICharSizeService=(0,u.createDecorator)("CharSizeService"),r.ICoreBrowserService=(0,u.createDecorator)("CoreBrowserService"),r.IMouseService=(0,u.createDecorator)("MouseService"),r.IRenderService=(0,u.createDecorator)("RenderService"),r.ISelectionService=(0,u.createDecorator)("SelectionService"),r.ICharacterJoinerService=(0,u.createDecorator)("CharacterJoinerService"),r.IThemeService=(0,u.createDecorator)("ThemeService")},6731:function(w,r,o){var u=this&&this.__decorate||function(E,x,C,N){var L,R=arguments.length,P=R<3?x:N===null?N=Object.getOwnPropertyDescriptor(x,C):N;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")P=Reflect.decorate(E,x,C,N);else for(var F=E.length-1;F>=0;F--)(L=E[F])&&(P=(R<3?L(P):R>3?L(x,C,P):L(x,C))||P);return R>3&&P&&Object.defineProperty(x,C,P),P},f=this&&this.__param||function(E,x){return function(C,N){x(C,N,E)}};Object.defineProperty(r,"__esModule",{value:!0}),r.ThemeService=r.DEFAULT_ANSI_COLORS=void 0;const l=o(7239),g=o(8055),m=o(8460),y=o(844),b=o(2585),n=g.css.toColor("#ffffff"),d=g.css.toColor("#000000"),c=g.css.toColor("#ffffff"),h=g.css.toColor("#000000"),_={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};r.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const E=[g.css.toColor("#2e3436"),g.css.toColor("#cc0000"),g.css.toColor("#4e9a06"),g.css.toColor("#c4a000"),g.css.toColor("#3465a4"),g.css.toColor("#75507b"),g.css.toColor("#06989a"),g.css.toColor("#d3d7cf"),g.css.toColor("#555753"),g.css.toColor("#ef2929"),g.css.toColor("#8ae234"),g.css.toColor("#fce94f"),g.css.toColor("#729fcf"),g.css.toColor("#ad7fa8"),g.css.toColor("#34e2e2"),g.css.toColor("#eeeeec")],x=[0,95,135,175,215,255];for(let C=0;C<216;C++){const N=x[C/36%6|0],L=x[C/6%6|0],R=x[C%6];E.push({css:g.channels.toCss(N,L,R),rgba:g.channels.toRgba(N,L,R)})}for(let C=0;C<24;C++){const N=8+10*C;E.push({css:g.channels.toCss(N,N,N),rgba:g.channels.toRgba(N,N,N)})}return E})());let S=r.ThemeService=class extends y.Disposable{get colors(){return this._colors}constructor(E){super(),this._optionsService=E,this._contrastCache=new l.ColorContrastCache,this._halfContrastCache=new l.ColorContrastCache,this._onChangeColors=this.register(new m.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:n,background:d,cursor:c,cursorAccent:h,selectionForeground:void 0,selectionBackgroundTransparent:_,selectionBackgroundOpaque:g.color.blend(d,_),selectionInactiveBackgroundTransparent:_,selectionInactiveBackgroundOpaque:g.color.blend(d,_),ansi:r.DEFAULT_ANSI_COLORS.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))))}_setTheme(E={}){const x=this._colors;if(x.foreground=k(E.foreground,n),x.background=k(E.background,d),x.cursor=k(E.cursor,c),x.cursorAccent=k(E.cursorAccent,h),x.selectionBackgroundTransparent=k(E.selectionBackground,_),x.selectionBackgroundOpaque=g.color.blend(x.background,x.selectionBackgroundTransparent),x.selectionInactiveBackgroundTransparent=k(E.selectionInactiveBackground,x.selectionBackgroundTransparent),x.selectionInactiveBackgroundOpaque=g.color.blend(x.background,x.selectionInactiveBackgroundTransparent),x.selectionForeground=E.selectionForeground?k(E.selectionForeground,g.NULL_COLOR):void 0,x.selectionForeground===g.NULL_COLOR&&(x.selectionForeground=void 0),g.color.isOpaque(x.selectionBackgroundTransparent)&&(x.selectionBackgroundTransparent=g.color.opacity(x.selectionBackgroundTransparent,.3)),g.color.isOpaque(x.selectionInactiveBackgroundTransparent)&&(x.selectionInactiveBackgroundTransparent=g.color.opacity(x.selectionInactiveBackgroundTransparent,.3)),x.ansi=r.DEFAULT_ANSI_COLORS.slice(),x.ansi[0]=k(E.black,r.DEFAULT_ANSI_COLORS[0]),x.ansi[1]=k(E.red,r.DEFAULT_ANSI_COLORS[1]),x.ansi[2]=k(E.green,r.DEFAULT_ANSI_COLORS[2]),x.ansi[3]=k(E.yellow,r.DEFAULT_ANSI_COLORS[3]),x.ansi[4]=k(E.blue,r.DEFAULT_ANSI_COLORS[4]),x.ansi[5]=k(E.magenta,r.DEFAULT_ANSI_COLORS[5]),x.ansi[6]=k(E.cyan,r.DEFAULT_ANSI_COLORS[6]),x.ansi[7]=k(E.white,r.DEFAULT_ANSI_COLORS[7]),x.ansi[8]=k(E.brightBlack,r.DEFAULT_ANSI_COLORS[8]),x.ansi[9]=k(E.brightRed,r.DEFAULT_ANSI_COLORS[9]),x.ansi[10]=k(E.brightGreen,r.DEFAULT_ANSI_COLORS[10]),x.ansi[11]=k(E.brightYellow,r.DEFAULT_ANSI_COLORS[11]),x.ansi[12]=k(E.brightBlue,r.DEFAULT_ANSI_COLORS[12]),x.ansi[13]=k(E.brightMagenta,r.DEFAULT_ANSI_COLORS[13]),x.ansi[14]=k(E.brightCyan,r.DEFAULT_ANSI_COLORS[14]),x.ansi[15]=k(E.brightWhite,r.DEFAULT_ANSI_COLORS[15]),E.extendedAnsi){const C=Math.min(x.ansi.length-16,E.extendedAnsi.length);for(let N=0;N<C;N++)x.ansi[N+16]=k(E.extendedAnsi[N],r.DEFAULT_ANSI_COLORS[N+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(E){this._restoreColor(E),this._onChangeColors.fire(this.colors)}_restoreColor(E){if(E!==void 0)switch(E){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[E]=this._restoreColors.ansi[E]}else for(let x=0;x<this._restoreColors.ansi.length;++x)this._colors.ansi[x]=this._restoreColors.ansi[x]}modifyColors(E){E(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()}}};function k(E,x){if(E!==void 0)try{return g.css.toColor(E)}catch{}return x}r.ThemeService=S=u([f(0,b.IOptionsService)],S)},6349:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CircularList=void 0;const u=o(8460),f=o(844);class l extends f.Disposable{constructor(m){super(),this._maxLength=m,this.onDeleteEmitter=this.register(new u.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new u.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new u.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(m){if(this._maxLength===m)return;const y=new Array(m);for(let b=0;b<Math.min(m,this.length);b++)y[b]=this._array[this._getCyclicIndex(b)];this._array=y,this._maxLength=m,this._startIndex=0}get length(){return this._length}set length(m){if(m>this._length)for(let y=this._length;y<m;y++)this._array[y]=void 0;this._length=m}get(m){return this._array[this._getCyclicIndex(m)]}set(m,y){this._array[this._getCyclicIndex(m)]=y}push(m){this._array[this._getCyclicIndex(this._length)]=m,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(m,y,...b){if(y){for(let n=m;n<this._length-y;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+y)];this._length-=y,this.onDeleteEmitter.fire({index:m,amount:y})}for(let n=this._length-1;n>=m;n--)this._array[this._getCyclicIndex(n+b.length)]=this._array[this._getCyclicIndex(n)];for(let n=0;n<b.length;n++)this._array[this._getCyclicIndex(m+n)]=b[n];if(b.length&&this.onInsertEmitter.fire({index:m,amount:b.length}),this._length+b.length>this._maxLength){const n=this._length+b.length-this._maxLength;this._startIndex+=n,this._length=this._maxLength,this.onTrimEmitter.fire(n)}else this._length+=b.length}trimStart(m){m>this._length&&(m=this._length),this._startIndex+=m,this._length-=m,this.onTrimEmitter.fire(m)}shiftElements(m,y,b){if(!(y<=0)){if(m<0||m>=this._length)throw new Error("start argument out of range");if(m+b<0)throw new Error("Cannot shift elements in list beyond index 0");if(b>0){for(let d=y-1;d>=0;d--)this.set(m+d+b,this.get(m+d));const n=m+y+b-this._length;if(n>0)for(this._length+=n;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let n=0;n<y;n++)this.set(m+n+b,this.get(m+n))}}_getCyclicIndex(m){return(this._startIndex+m)%this._maxLength}}r.CircularList=l},1439:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.clone=void 0,r.clone=function o(u,f=5){if(typeof u!="object")return u;const l=Array.isArray(u)?[]:{};for(const g in u)l[g]=f<=1?u[g]:u[g]&&o(u[g],f-1);return l}},8055:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.contrastRatio=r.toPaddedHex=r.rgba=r.rgb=r.css=r.color=r.channels=r.NULL_COLOR=void 0;const u=o(6114);let f=0,l=0,g=0,m=0;var y,b,n,d,c;function h(S){const k=S.toString(16);return k.length<2?"0"+k:k}function _(S,k){return S<k?(k+.05)/(S+.05):(S+.05)/(k+.05)}r.NULL_COLOR={css:"#00000000",rgba:0},(function(S){S.toCss=function(k,E,x,C){return C!==void 0?`#${h(k)}${h(E)}${h(x)}${h(C)}`:`#${h(k)}${h(E)}${h(x)}`},S.toRgba=function(k,E,x,C=255){return(k<<24|E<<16|x<<8|C)>>>0}})(y||(r.channels=y={})),(function(S){function k(E,x){return m=Math.round(255*x),[f,l,g]=c.toChannels(E.rgba),{css:y.toCss(f,l,g,m),rgba:y.toRgba(f,l,g,m)}}S.blend=function(E,x){if(m=(255&x.rgba)/255,m===1)return{css:x.css,rgba:x.rgba};const C=x.rgba>>24&255,N=x.rgba>>16&255,L=x.rgba>>8&255,R=E.rgba>>24&255,P=E.rgba>>16&255,F=E.rgba>>8&255;return f=R+Math.round((C-R)*m),l=P+Math.round((N-P)*m),g=F+Math.round((L-F)*m),{css:y.toCss(f,l,g),rgba:y.toRgba(f,l,g)}},S.isOpaque=function(E){return(255&E.rgba)==255},S.ensureContrastRatio=function(E,x,C){const N=c.ensureContrastRatio(E.rgba,x.rgba,C);if(N)return c.toColor(N>>24&255,N>>16&255,N>>8&255)},S.opaque=function(E){const x=(255|E.rgba)>>>0;return[f,l,g]=c.toChannels(x),{css:y.toCss(f,l,g),rgba:x}},S.opacity=k,S.multiplyOpacity=function(E,x){return m=255&E.rgba,k(E,m*x/255)},S.toColorRGB=function(E){return[E.rgba>>24&255,E.rgba>>16&255,E.rgba>>8&255]}})(b||(r.color=b={})),(function(S){let k,E;if(!u.isNode){const x=document.createElement("canvas");x.width=1,x.height=1;const C=x.getContext("2d",{willReadFrequently:!0});C&&(k=C,k.globalCompositeOperation="copy",E=k.createLinearGradient(0,0,1,1))}S.toColor=function(x){if(x.match(/#[\da-f]{3,8}/i))switch(x.length){case 4:return f=parseInt(x.slice(1,2).repeat(2),16),l=parseInt(x.slice(2,3).repeat(2),16),g=parseInt(x.slice(3,4).repeat(2),16),c.toColor(f,l,g);case 5:return f=parseInt(x.slice(1,2).repeat(2),16),l=parseInt(x.slice(2,3).repeat(2),16),g=parseInt(x.slice(3,4).repeat(2),16),m=parseInt(x.slice(4,5).repeat(2),16),c.toColor(f,l,g,m);case 7:return{css:x,rgba:(parseInt(x.slice(1),16)<<8|255)>>>0};case 9:return{css:x,rgba:parseInt(x.slice(1),16)>>>0}}const C=x.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(C)return f=parseInt(C[1]),l=parseInt(C[2]),g=parseInt(C[3]),m=Math.round(255*(C[5]===void 0?1:parseFloat(C[5]))),c.toColor(f,l,g,m);if(!k||!E)throw new Error("css.toColor: Unsupported css format");if(k.fillStyle=E,k.fillStyle=x,typeof k.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(k.fillRect(0,0,1,1),[f,l,g,m]=k.getImageData(0,0,1,1).data,m!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:y.toRgba(f,l,g,m),css:x}}})(n||(r.css=n={})),(function(S){function k(E,x,C){const N=E/255,L=x/255,R=C/255;return .2126*(N<=.03928?N/12.92:Math.pow((N+.055)/1.055,2.4))+.7152*(L<=.03928?L/12.92:Math.pow((L+.055)/1.055,2.4))+.0722*(R<=.03928?R/12.92:Math.pow((R+.055)/1.055,2.4))}S.relativeLuminance=function(E){return k(E>>16&255,E>>8&255,255&E)},S.relativeLuminance2=k})(d||(r.rgb=d={})),(function(S){function k(x,C,N){const L=x>>24&255,R=x>>16&255,P=x>>8&255;let F=C>>24&255,B=C>>16&255,H=C>>8&255,U=_(d.relativeLuminance2(F,B,H),d.relativeLuminance2(L,R,P));for(;U<N&&(F>0||B>0||H>0);)F-=Math.max(0,Math.ceil(.1*F)),B-=Math.max(0,Math.ceil(.1*B)),H-=Math.max(0,Math.ceil(.1*H)),U=_(d.relativeLuminance2(F,B,H),d.relativeLuminance2(L,R,P));return(F<<24|B<<16|H<<8|255)>>>0}function E(x,C,N){const L=x>>24&255,R=x>>16&255,P=x>>8&255;let F=C>>24&255,B=C>>16&255,H=C>>8&255,U=_(d.relativeLuminance2(F,B,H),d.relativeLuminance2(L,R,P));for(;U<N&&(F<255||B<255||H<255);)F=Math.min(255,F+Math.ceil(.1*(255-F))),B=Math.min(255,B+Math.ceil(.1*(255-B))),H=Math.min(255,H+Math.ceil(.1*(255-H))),U=_(d.relativeLuminance2(F,B,H),d.relativeLuminance2(L,R,P));return(F<<24|B<<16|H<<8|255)>>>0}S.ensureContrastRatio=function(x,C,N){const L=d.relativeLuminance(x>>8),R=d.relativeLuminance(C>>8);if(_(L,R)<N){if(R<L){const B=k(x,C,N),H=_(L,d.relativeLuminance(B>>8));if(H<N){const U=E(x,C,N);return H>_(L,d.relativeLuminance(U>>8))?B:U}return B}const P=E(x,C,N),F=_(L,d.relativeLuminance(P>>8));if(F<N){const B=k(x,C,N);return F>_(L,d.relativeLuminance(B>>8))?P:B}return P}},S.reduceLuminance=k,S.increaseLuminance=E,S.toChannels=function(x){return[x>>24&255,x>>16&255,x>>8&255,255&x]},S.toColor=function(x,C,N,L){return{css:y.toCss(x,C,N,L),rgba:y.toRgba(x,C,N,L)}}})(c||(r.rgba=c={})),r.toPaddedHex=h,r.contrastRatio=_},8969:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CoreTerminal=void 0;const u=o(844),f=o(2585),l=o(4348),g=o(7866),m=o(744),y=o(7302),b=o(6975),n=o(8460),d=o(1753),c=o(1480),h=o(7994),_=o(9282),S=o(5435),k=o(5981),E=o(2660);let x=!1;class C extends u.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new n.EventEmitter),this._onScroll.event((L=>{var R;(R=this._onScrollApi)===null||R===void 0||R.fire(L.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(L){for(const R in L)this.optionsService.options[R]=L[R]}constructor(L){super(),this._windowsWrappingHeuristics=this.register(new u.MutableDisposable),this._onBinary=this.register(new n.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new n.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new n.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new n.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new n.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new n.EventEmitter),this._instantiationService=new l.InstantiationService,this.optionsService=this.register(new y.OptionsService(L)),this._instantiationService.setService(f.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(m.BufferService)),this._instantiationService.setService(f.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(g.LogService)),this._instantiationService.setService(f.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(b.CoreService)),this._instantiationService.setService(f.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(d.CoreMouseService)),this._instantiationService.setService(f.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(c.UnicodeService)),this._instantiationService.setService(f.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(h.CharsetService),this._instantiationService.setService(f.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(E.OscLinkService),this._instantiationService.setService(f.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new S.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,n.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,n.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,n.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,n.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom((()=>this.scrollToBottom()))),this.register(this.coreService.onUserInput((()=>this._writeBuffer.handleUserInput()))),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],(()=>this._handleWindowsPtyOptionChange()))),this.register(this._bufferService.onScroll((R=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this.register(this._inputHandler.onScroll((R=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new k.WriteBuffer(((R,P)=>this._inputHandler.parse(R,P)))),this.register((0,n.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(L,R){this._writeBuffer.write(L,R)}writeSync(L,R){this._logService.logLevel<=f.LogLevelEnum.WARN&&!x&&(this._logService.warn("writeSync is unreliable and will be removed soon."),x=!0),this._writeBuffer.writeSync(L,R)}resize(L,R){isNaN(L)||isNaN(R)||(L=Math.max(L,m.MINIMUM_COLS),R=Math.max(R,m.MINIMUM_ROWS),this._bufferService.resize(L,R))}scroll(L,R=!1){this._bufferService.scroll(L,R)}scrollLines(L,R,P){this._bufferService.scrollLines(L,R,P)}scrollPages(L){this.scrollLines(L*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(L){const R=L-this._bufferService.buffer.ydisp;R!==0&&this.scrollLines(R)}registerEscHandler(L,R){return this._inputHandler.registerEscHandler(L,R)}registerDcsHandler(L,R){return this._inputHandler.registerDcsHandler(L,R)}registerCsiHandler(L,R){return this._inputHandler.registerCsiHandler(L,R)}registerOscHandler(L,R){return this._inputHandler.registerOscHandler(L,R)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let L=!1;const R=this.optionsService.rawOptions.windowsPty;R&&R.buildNumber!==void 0&&R.buildNumber!==void 0?L=R.backend==="conpty"&&R.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(L=!0),L?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const L=[];L.push(this.onLineFeed(_.updateWindowsModeWrappedState.bind(null,this._bufferService))),L.push(this.registerCsiHandler({final:"H"},(()=>((0,_.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,u.toDisposable)((()=>{for(const R of L)R.dispose()}))}}}r.CoreTerminal=C},8460:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.forwardEvent=r.EventEmitter=void 0,r.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=o=>(this._listeners.push(o),{dispose:()=>{if(!this._disposed){for(let u=0;u<this._listeners.length;u++)if(this._listeners[u]===o)return void this._listeners.splice(u,1)}}})),this._event}fire(o,u){const f=[];for(let l=0;l<this._listeners.length;l++)f.push(this._listeners[l]);for(let l=0;l<f.length;l++)f[l].call(void 0,o,u)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},r.forwardEvent=function(o,u){return o((f=>u.fire(f)))}},5435:function(w,r,o){var u=this&&this.__decorate||function(U,T,D,M){var O,q=arguments.length,V=q<3?T:M===null?M=Object.getOwnPropertyDescriptor(T,D):M;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")V=Reflect.decorate(U,T,D,M);else for(var $=U.length-1;$>=0;$--)(O=U[$])&&(V=(q<3?O(V):q>3?O(T,D,V):O(T,D))||V);return q>3&&V&&Object.defineProperty(T,D,V),V},f=this&&this.__param||function(U,T){return function(D,M){T(D,M,U)}};Object.defineProperty(r,"__esModule",{value:!0}),r.InputHandler=r.WindowsOptionsReportType=void 0;const l=o(2584),g=o(7116),m=o(2015),y=o(844),b=o(482),n=o(8437),d=o(8460),c=o(643),h=o(511),_=o(3734),S=o(2585),k=o(6242),E=o(6351),x=o(5941),C={"(":0,")":1,"*":2,"+":3,"-":1,".":2},N=131072;function L(U,T){if(U>24)return T.setWinLines||!1;switch(U){case 1:return!!T.restoreWin;case 2:return!!T.minimizeWin;case 3:return!!T.setWinPosition;case 4:return!!T.setWinSizePixels;case 5:return!!T.raiseWin;case 6:return!!T.lowerWin;case 7:return!!T.refreshWin;case 8:return!!T.setWinSizeChars;case 9:return!!T.maximizeWin;case 10:return!!T.fullscreenWin;case 11:return!!T.getWinState;case 13:return!!T.getWinPosition;case 14:return!!T.getWinSizePixels;case 15:return!!T.getScreenSizePixels;case 16:return!!T.getCellSizePixels;case 18:return!!T.getWinSizeChars;case 19:return!!T.getScreenSizeChars;case 20:return!!T.getIconTitle;case 21:return!!T.getWinTitle;case 22:return!!T.pushTitle;case 23:return!!T.popTitle;case 24:return!!T.setWinLines}return!1}var R;(function(U){U[U.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",U[U.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(R||(r.WindowsOptionsReportType=R={}));let P=0;class F extends y.Disposable{getAttrData(){return this._curAttrData}constructor(T,D,M,O,q,V,$,z,W=new m.EscapeSequenceParser){super(),this._bufferService=T,this._charsetService=D,this._coreService=M,this._logService=O,this._optionsService=q,this._oscLinkService=V,this._coreMouseService=$,this._unicodeService=z,this._parser=W,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new b.StringToUtf32,this._utf8Decoder=new b.Utf8ToUtf32,this._workCell=new h.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=n.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=n.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new d.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new d.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new d.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new d.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new d.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new d.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new d.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new d.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new d.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new d.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new d.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new d.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new d.EventEmitter),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 B(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((j=>this._activeBuffer=j.activeBuffer))),this._parser.setCsiHandlerFallback(((j,I)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(j),params:I.toArray()})})),this._parser.setEscHandlerFallback((j=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(j)})})),this._parser.setExecuteHandlerFallback((j=>{this._logService.debug("Unknown EXECUTE code: ",{code:j})})),this._parser.setOscHandlerFallback(((j,I,K)=>{this._logService.debug("Unknown OSC code: ",{identifier:j,action:I,data:K})})),this._parser.setDcsHandlerFallback(((j,I,K)=>{I==="HOOK"&&(K=K.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(j),action:I,payload:K})})),this._parser.setPrintHandler(((j,I,K)=>this.print(j,I,K))),this._parser.registerCsiHandler({final:"@"},(j=>this.insertChars(j))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(j=>this.scrollLeft(j))),this._parser.registerCsiHandler({final:"A"},(j=>this.cursorUp(j))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(j=>this.scrollRight(j))),this._parser.registerCsiHandler({final:"B"},(j=>this.cursorDown(j))),this._parser.registerCsiHandler({final:"C"},(j=>this.cursorForward(j))),this._parser.registerCsiHandler({final:"D"},(j=>this.cursorBackward(j))),this._parser.registerCsiHandler({final:"E"},(j=>this.cursorNextLine(j))),this._parser.registerCsiHandler({final:"F"},(j=>this.cursorPrecedingLine(j))),this._parser.registerCsiHandler({final:"G"},(j=>this.cursorCharAbsolute(j))),this._parser.registerCsiHandler({final:"H"},(j=>this.cursorPosition(j))),this._parser.registerCsiHandler({final:"I"},(j=>this.cursorForwardTab(j))),this._parser.registerCsiHandler({final:"J"},(j=>this.eraseInDisplay(j,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(j=>this.eraseInDisplay(j,!0))),this._parser.registerCsiHandler({final:"K"},(j=>this.eraseInLine(j,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(j=>this.eraseInLine(j,!0))),this._parser.registerCsiHandler({final:"L"},(j=>this.insertLines(j))),this._parser.registerCsiHandler({final:"M"},(j=>this.deleteLines(j))),this._parser.registerCsiHandler({final:"P"},(j=>this.deleteChars(j))),this._parser.registerCsiHandler({final:"S"},(j=>this.scrollUp(j))),this._parser.registerCsiHandler({final:"T"},(j=>this.scrollDown(j))),this._parser.registerCsiHandler({final:"X"},(j=>this.eraseChars(j))),this._parser.registerCsiHandler({final:"Z"},(j=>this.cursorBackwardTab(j))),this._parser.registerCsiHandler({final:"`"},(j=>this.charPosAbsolute(j))),this._parser.registerCsiHandler({final:"a"},(j=>this.hPositionRelative(j))),this._parser.registerCsiHandler({final:"b"},(j=>this.repeatPrecedingCharacter(j))),this._parser.registerCsiHandler({final:"c"},(j=>this.sendDeviceAttributesPrimary(j))),this._parser.registerCsiHandler({prefix:">",final:"c"},(j=>this.sendDeviceAttributesSecondary(j))),this._parser.registerCsiHandler({final:"d"},(j=>this.linePosAbsolute(j))),this._parser.registerCsiHandler({final:"e"},(j=>this.vPositionRelative(j))),this._parser.registerCsiHandler({final:"f"},(j=>this.hVPosition(j))),this._parser.registerCsiHandler({final:"g"},(j=>this.tabClear(j))),this._parser.registerCsiHandler({final:"h"},(j=>this.setMode(j))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(j=>this.setModePrivate(j))),this._parser.registerCsiHandler({final:"l"},(j=>this.resetMode(j))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(j=>this.resetModePrivate(j))),this._parser.registerCsiHandler({final:"m"},(j=>this.charAttributes(j))),this._parser.registerCsiHandler({final:"n"},(j=>this.deviceStatus(j))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(j=>this.deviceStatusPrivate(j))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(j=>this.softReset(j))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(j=>this.setCursorStyle(j))),this._parser.registerCsiHandler({final:"r"},(j=>this.setScrollRegion(j))),this._parser.registerCsiHandler({final:"s"},(j=>this.saveCursor(j))),this._parser.registerCsiHandler({final:"t"},(j=>this.windowOptions(j))),this._parser.registerCsiHandler({final:"u"},(j=>this.restoreCursor(j))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(j=>this.insertColumns(j))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(j=>this.deleteColumns(j))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(j=>this.selectProtected(j))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(j=>this.requestMode(j,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(j=>this.requestMode(j,!1))),this._parser.setExecuteHandler(l.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(l.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(l.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(l.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(l.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(l.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(l.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(l.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(l.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(l.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(l.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(l.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new k.OscHandler((j=>(this.setTitle(j),this.setIconName(j),!0)))),this._parser.registerOscHandler(1,new k.OscHandler((j=>this.setIconName(j)))),this._parser.registerOscHandler(2,new k.OscHandler((j=>this.setTitle(j)))),this._parser.registerOscHandler(4,new k.OscHandler((j=>this.setOrReportIndexedColor(j)))),this._parser.registerOscHandler(8,new k.OscHandler((j=>this.setHyperlink(j)))),this._parser.registerOscHandler(10,new k.OscHandler((j=>this.setOrReportFgColor(j)))),this._parser.registerOscHandler(11,new k.OscHandler((j=>this.setOrReportBgColor(j)))),this._parser.registerOscHandler(12,new k.OscHandler((j=>this.setOrReportCursorColor(j)))),this._parser.registerOscHandler(104,new k.OscHandler((j=>this.restoreIndexedColor(j)))),this._parser.registerOscHandler(110,new k.OscHandler((j=>this.restoreFgColor(j)))),this._parser.registerOscHandler(111,new k.OscHandler((j=>this.restoreBgColor(j)))),this._parser.registerOscHandler(112,new k.OscHandler((j=>this.restoreCursorColor(j)))),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(const j in g.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:j},(()=>this.selectCharset("("+j))),this._parser.registerEscHandler({intermediates:")",final:j},(()=>this.selectCharset(")"+j))),this._parser.registerEscHandler({intermediates:"*",final:j},(()=>this.selectCharset("*"+j))),this._parser.registerEscHandler({intermediates:"+",final:j},(()=>this.selectCharset("+"+j))),this._parser.registerEscHandler({intermediates:"-",final:j},(()=>this.selectCharset("-"+j))),this._parser.registerEscHandler({intermediates:".",final:j},(()=>this.selectCharset("."+j))),this._parser.registerEscHandler({intermediates:"/",final:j},(()=>this.selectCharset("/"+j)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((j=>(this._logService.error("Parsing error: ",j),j))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new E.DcsHandler(((j,I)=>this.requestStatusString(j,I))))}_preserveStack(T,D,M,O){this._parseStack.paused=!0,this._parseStack.cursorStartX=T,this._parseStack.cursorStartY=D,this._parseStack.decodedLength=M,this._parseStack.position=O}_logSlowResolvingAsync(T){this._logService.logLevel<=S.LogLevelEnum.WARN&&Promise.race([T,new Promise(((D,M)=>setTimeout((()=>M("#SLOW_TIMEOUT")),5e3)))]).catch((D=>{if(D!=="#SLOW_TIMEOUT")throw D;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(T,D){let M,O=this._activeBuffer.x,q=this._activeBuffer.y,V=0;const $=this._parseStack.paused;if($){if(M=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,D))return this._logSlowResolvingAsync(M),M;O=this._parseStack.cursorStartX,q=this._parseStack.cursorStartY,this._parseStack.paused=!1,T.length>N&&(V=this._parseStack.position+N)}if(this._logService.logLevel<=S.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof T=="string"?` "${T}"`:` "${Array.prototype.map.call(T,(z=>String.fromCharCode(z))).join("")}"`),typeof T=="string"?T.split("").map((z=>z.charCodeAt(0))):T),this._parseBuffer.length<T.length&&this._parseBuffer.length<N&&(this._parseBuffer=new Uint32Array(Math.min(T.length,N))),$||this._dirtyRowTracker.clearRange(),T.length>N)for(let z=V;z<T.length;z+=N){const W=z+N<T.length?z+N:T.length,j=typeof T=="string"?this._stringDecoder.decode(T.substring(z,W),this._parseBuffer):this._utf8Decoder.decode(T.subarray(z,W),this._parseBuffer);if(M=this._parser.parse(this._parseBuffer,j))return this._preserveStack(O,q,j,z),this._logSlowResolvingAsync(M),M}else if(!$){const z=typeof T=="string"?this._stringDecoder.decode(T,this._parseBuffer):this._utf8Decoder.decode(T,this._parseBuffer);if(M=this._parser.parse(this._parseBuffer,z))return this._preserveStack(O,q,z,0),this._logSlowResolvingAsync(M),M}this._activeBuffer.x===O&&this._activeBuffer.y===q||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowTracker.start,this._dirtyRowTracker.end)}print(T,D,M){let O,q;const V=this._charsetService.charset,$=this._optionsService.rawOptions.screenReaderMode,z=this._bufferService.cols,W=this._coreService.decPrivateModes.wraparound,j=this._coreService.modes.insertMode,I=this._curAttrData;let K=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&M-D>0&&K.getWidth(this._activeBuffer.x-1)===2&&K.setCellFromCodePoint(this._activeBuffer.x-1,0,1,I.fg,I.bg,I.extended);for(let X=D;X<M;++X){if(O=T[X],q=this._unicodeService.wcwidth(O),O<127&&V){const J=V[String.fromCharCode(O)];J&&(O=J.charCodeAt(0))}if($&&this._onA11yChar.fire((0,b.stringFromCodePoint)(O)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),q||!this._activeBuffer.x){if(this._activeBuffer.x+q-1>=z){if(W){for(;this._activeBuffer.x<z;)K.setCellFromCodePoint(this._activeBuffer.x++,0,1,I.fg,I.bg,I.extended);this._activeBuffer.x=0,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),K=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)}else if(this._activeBuffer.x=z-1,q===2)continue}if(j&&(K.insertCells(this._activeBuffer.x,q,this._activeBuffer.getNullCell(I),I),K.getWidth(z-1)===2&&K.setCellFromCodePoint(z-1,c.NULL_CELL_CODE,c.NULL_CELL_WIDTH,I.fg,I.bg,I.extended)),K.setCellFromCodePoint(this._activeBuffer.x++,O,q,I.fg,I.bg,I.extended),q>0)for(;--q;)K.setCellFromCodePoint(this._activeBuffer.x++,0,0,I.fg,I.bg,I.extended)}else K.getWidth(this._activeBuffer.x-1)?K.addCodepointToCell(this._activeBuffer.x-1,O):K.addCodepointToCell(this._activeBuffer.x-2,O)}M-D>0&&(K.loadCell(this._activeBuffer.x-1,this._workCell),this._workCell.getWidth()===2||this._workCell.getCode()>65535?this._parser.precedingCodepoint=0:this._workCell.isCombined()?this._parser.precedingCodepoint=this._workCell.getChars().charCodeAt(0):this._parser.precedingCodepoint=this._workCell.content),this._activeBuffer.x<z&&M-D>0&&K.getWidth(this._activeBuffer.x)===0&&!K.hasContent(this._activeBuffer.x)&&K.setCellFromCodePoint(this._activeBuffer.x,0,1,I.fg,I.bg,I.extended),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(T,D){return T.final!=="t"||T.prefix||T.intermediates?this._parser.registerCsiHandler(T,D):this._parser.registerCsiHandler(T,(M=>!L(M.params[0],this._optionsService.rawOptions.windowOptions)||D(M)))}registerDcsHandler(T,D){return this._parser.registerDcsHandler(T,new E.DcsHandler(D))}registerEscHandler(T,D){return this._parser.registerEscHandler(T,D)}registerOscHandler(T,D){return this._parser.registerOscHandler(T,new k.OscHandler(D))}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(){var T;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&&(!((T=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))===null||T===void 0)&&T.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const D=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);D.hasWidth(this._activeBuffer.x)&&!D.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const 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,D){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=T,this._activeBuffer.y=this._activeBuffer.scrollTop+D):(this._activeBuffer.x=T,this._activeBuffer.y=D),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(T,D){this._restrictCursor(),this._setCursor(this._activeBuffer.x+T,this._activeBuffer.y+D)}cursorUp(T){const D=this._activeBuffer.y-this._activeBuffer.scrollTop;return D>=0?this._moveCursor(0,-Math.min(D,T.params[0]||1)):this._moveCursor(0,-(T.params[0]||1)),!0}cursorDown(T){const D=this._activeBuffer.scrollBottom-this._activeBuffer.y;return D>=0?this._moveCursor(0,Math.min(D,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){const D=T.params[0];return D===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:D===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(T){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let D=T.params[0]||1;for(;D--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(T){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let D=T.params[0]||1;for(;D--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(T){const D=T.params[0];return D===1&&(this._curAttrData.bg|=536870912),D!==2&&D!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(T,D,M,O=!1,q=!1){const V=this._activeBuffer.lines.get(this._activeBuffer.ybase+T);V.replaceCells(D,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),q),O&&(V.isWrapped=!1)}_resetBufferLine(T,D=!1){const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+T);M&&(M.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),D),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+T),M.isWrapped=!1)}eraseInDisplay(T,D=!1){let M;switch(this._restrictCursor(this._bufferService.cols),T.params[0]){case 0:for(M=this._activeBuffer.y,this._dirtyRowTracker.markDirty(M),this._eraseInBufferLine(M++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,D);M<this._bufferService.rows;M++)this._resetBufferLine(M,D);this._dirtyRowTracker.markDirty(M);break;case 1:for(M=this._activeBuffer.y,this._dirtyRowTracker.markDirty(M),this._eraseInBufferLine(M,0,this._activeBuffer.x+1,!0,D),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(M+1).isWrapped=!1);M--;)this._resetBufferLine(M,D);this._dirtyRowTracker.markDirty(0);break;case 2:for(M=this._bufferService.rows,this._dirtyRowTracker.markDirty(M-1);M--;)this._resetBufferLine(M,D);this._dirtyRowTracker.markDirty(0);break;case 3:const O=this._activeBuffer.lines.length-this._bufferService.rows;O>0&&(this._activeBuffer.lines.trimStart(O),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-O,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-O,0),this._onScroll.fire(0))}return!0}eraseInLine(T,D=!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,D);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,D);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,D)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(T){this._restrictCursor();let D=T.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=this._activeBuffer.ybase+this._activeBuffer.y,O=this._bufferService.rows-1-this._activeBuffer.scrollBottom,q=this._bufferService.rows-1+this._activeBuffer.ybase-O+1;for(;D--;)this._activeBuffer.lines.splice(q-1,1),this._activeBuffer.lines.splice(M,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 D=T.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=this._activeBuffer.ybase+this._activeBuffer.y;let O;for(O=this._bufferService.rows-1-this._activeBuffer.scrollBottom,O=this._bufferService.rows-1+this._activeBuffer.ybase-O;D--;)this._activeBuffer.lines.splice(M,1),this._activeBuffer.lines.splice(O,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();const D=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return D&&(D.insertCells(this._activeBuffer.x,T.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(T){this._restrictCursor();const D=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return D&&(D.deleteCells(this._activeBuffer.x,T.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(T){let D=T.params[0]||1;for(;D--;)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 D=T.params[0]||1;for(;D--;)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(n.DEFAULT_ATTR_DATA));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;const D=T.params[0]||1;for(let M=this._activeBuffer.scrollTop;M<=this._activeBuffer.scrollBottom;++M){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+M);O.deleteCells(0,D,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.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;const D=T.params[0]||1;for(let M=this._activeBuffer.scrollTop;M<=this._activeBuffer.scrollBottom;++M){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+M);O.insertCells(0,D,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.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;const D=T.params[0]||1;for(let M=this._activeBuffer.scrollTop;M<=this._activeBuffer.scrollBottom;++M){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+M);O.insertCells(this._activeBuffer.x,D,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.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;const D=T.params[0]||1;for(let M=this._activeBuffer.scrollTop;M<=this._activeBuffer.scrollBottom;++M){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+M);O.deleteCells(this._activeBuffer.x,D,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(T){this._restrictCursor();const D=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return D&&(D.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(T.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(T){if(!this._parser.precedingCodepoint)return!0;const D=T.params[0]||1,M=new Uint32Array(D);for(let O=0;O<D;++O)M[O]=this._parser.precedingCodepoint;return this.print(M,0,M.length),!0}sendDeviceAttributesPrimary(T){return T.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(l.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(l.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(T){return T.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(l.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(l.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(T.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(l.C0.ESC+"[>83;40003;0c")),!0}_is(T){return(this._optionsService.rawOptions.termName+"").indexOf(T)===0}setMode(T){for(let D=0;D<T.length;D++)switch(T.params[D]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(T){for(let D=0;D<T.length;D++)switch(T.params[D]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,g.DEFAULT_CHARSET),this._charsetService.setgCharset(1,g.DEFAULT_CHARSET),this._charsetService.setgCharset(2,g.DEFAULT_CHARSET),this._charsetService.setgCharset(3,g.DEFAULT_CHARSET);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(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(T){for(let D=0;D<T.length;D++)switch(T.params[D]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(T){for(let D=0;D<T.length;D++)switch(T.params[D]){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:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");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[D]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(T,D){const M=this._coreService.decPrivateModes,{activeProtocol:O,activeEncoding:q}=this._coreMouseService,V=this._coreService,{buffers:$,cols:z}=this._bufferService,{active:W,alt:j}=$,I=this._optionsService.rawOptions,K=Z=>Z?1:2,X=T.params[0];return J=X,G=D?X===2?4:X===4?K(V.modes.insertMode):X===12?3:X===20?K(I.convertEol):0:X===1?K(M.applicationCursorKeys):X===3?I.windowOptions.setWinLines?z===80?2:z===132?1:0:0:X===6?K(M.origin):X===7?K(M.wraparound):X===8?3:X===9?K(O==="X10"):X===12?K(I.cursorBlink):X===25?K(!V.isCursorHidden):X===45?K(M.reverseWraparound):X===66?K(M.applicationKeypad):X===67?4:X===1e3?K(O==="VT200"):X===1002?K(O==="DRAG"):X===1003?K(O==="ANY"):X===1004?K(M.sendFocus):X===1005?4:X===1006?K(q==="SGR"):X===1015?4:X===1016?K(q==="SGR_PIXELS"):X===1048?1:X===47||X===1047||X===1049?K(W===j):X===2004?K(M.bracketedPasteMode):0,V.triggerDataEvent(`${l.C0.ESC}[${D?"":"?"}${J};${G}$y`),!0;var J,G}_updateAttrColor(T,D,M,O,q){return D===2?(T|=50331648,T&=-16777216,T|=_.AttributeData.fromColorRGB([M,O,q])):D===5&&(T&=-50331904,T|=33554432|255&M),T}_extractColor(T,D,M){const O=[0,0,-1,0,0,0];let q=0,V=0;do{if(O[V+q]=T.params[D+V],T.hasSubParams(D+V)){const $=T.getSubParams(D+V);let z=0;do O[1]===5&&(q=1),O[V+z+1+q]=$[z];while(++z<$.length&&z+V+1+q<O.length);break}if(O[1]===5&&V+q>=2||O[1]===2&&V+q>=5)break;O[1]&&(q=1)}while(++V+D<T.length&&V+q<O.length);for(let $=2;$<O.length;++$)O[$]===-1&&(O[$]=0);switch(O[0]){case 38:M.fg=this._updateAttrColor(M.fg,O[1],O[3],O[4],O[5]);break;case 48:M.bg=this._updateAttrColor(M.bg,O[1],O[3],O[4],O[5]);break;case 58:M.extended=M.extended.clone(),M.extended.underlineColor=this._updateAttrColor(M.extended.underlineColor,O[1],O[3],O[4],O[5])}return V}_processUnderline(T,D){D.extended=D.extended.clone(),(!~T||T>5)&&(T=1),D.extended.underlineStyle=T,D.fg|=268435456,T===0&&(D.fg&=-268435457),D.updateExtended()}_processSGR0(T){T.fg=n.DEFAULT_ATTR_DATA.fg,T.bg=n.DEFAULT_ATTR_DATA.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;const D=T.length;let M;const O=this._curAttrData;for(let q=0;q<D;q++)M=T.params[q],M>=30&&M<=37?(O.fg&=-50331904,O.fg|=16777216|M-30):M>=40&&M<=47?(O.bg&=-50331904,O.bg|=16777216|M-40):M>=90&&M<=97?(O.fg&=-50331904,O.fg|=16777224|M-90):M>=100&&M<=107?(O.bg&=-50331904,O.bg|=16777224|M-100):M===0?this._processSGR0(O):M===1?O.fg|=134217728:M===3?O.bg|=67108864:M===4?(O.fg|=268435456,this._processUnderline(T.hasSubParams(q)?T.getSubParams(q)[0]:1,O)):M===5?O.fg|=536870912:M===7?O.fg|=67108864:M===8?O.fg|=1073741824:M===9?O.fg|=2147483648:M===2?O.bg|=134217728:M===21?this._processUnderline(2,O):M===22?(O.fg&=-134217729,O.bg&=-134217729):M===23?O.bg&=-67108865:M===24?(O.fg&=-268435457,this._processUnderline(0,O)):M===25?O.fg&=-536870913:M===27?O.fg&=-67108865:M===28?O.fg&=-1073741825:M===29?O.fg&=2147483647:M===39?(O.fg&=-67108864,O.fg|=16777215&n.DEFAULT_ATTR_DATA.fg):M===49?(O.bg&=-67108864,O.bg|=16777215&n.DEFAULT_ATTR_DATA.bg):M===38||M===48||M===58?q+=this._extractColor(T,q,O):M===53?O.bg|=1073741824:M===55?O.bg&=-1073741825:M===59?(O.extended=O.extended.clone(),O.extended.underlineColor=-1,O.updateExtended()):M===100?(O.fg&=-67108864,O.fg|=16777215&n.DEFAULT_ATTR_DATA.fg,O.bg&=-67108864,O.bg|=16777215&n.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",M);return!0}deviceStatus(T){switch(T.params[0]){case 5:this._coreService.triggerDataEvent(`${l.C0.ESC}[0n`);break;case 6:const D=this._activeBuffer.y+1,M=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${l.C0.ESC}[${D};${M}R`)}return!0}deviceStatusPrivate(T){if(T.params[0]===6){const D=this._activeBuffer.y+1,M=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${l.C0.ESC}[?${D};${M}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=n.DEFAULT_ATTR_DATA.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){const D=T.params[0]||1;switch(D){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}const M=D%2==1;return this._optionsService.options.cursorBlink=M,!0}setScrollRegion(T){const D=T.params[0]||1;let M;return(T.length<2||(M=T.params[1])>this._bufferService.rows||M===0)&&(M=this._bufferService.rows),M>D&&(this._activeBuffer.scrollTop=D-1,this._activeBuffer.scrollBottom=M-1,this._setCursor(0,0)),!0}windowOptions(T){if(!L(T.params[0],this._optionsService.rawOptions.windowOptions))return!0;const D=T.length>1?T.params[1]:0;switch(T.params[0]){case 14:D!==2&&this._onRequestWindowsOptionsReport.fire(R.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(R.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${l.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:D!==0&&D!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),D!==0&&D!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:D!==0&&D!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),D!==0&&D!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}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){const D=[],M=T.split(";");for(;M.length>1;){const O=M.shift(),q=M.shift();if(/^\d+$/.exec(O)){const V=parseInt(O);if(H(V))if(q==="?")D.push({type:0,index:V});else{const $=(0,x.parseColor)(q);$&&D.push({type:1,index:V,color:$})}}}return D.length&&this._onColor.fire(D),!0}setHyperlink(T){const D=T.split(";");return!(D.length<2)&&(D[1]?this._createHyperlink(D[0],D[1]):!D[0]&&this._finishHyperlink())}_createHyperlink(T,D){this._getCurrentLinkId()&&this._finishHyperlink();const M=T.split(":");let O;const q=M.findIndex((V=>V.startsWith("id=")));return q!==-1&&(O=M[q].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:O,uri:D}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(T,D){const M=T.split(";");for(let O=0;O<M.length&&!(D>=this._specialColors.length);++O,++D)if(M[O]==="?")this._onColor.fire([{type:0,index:this._specialColors[D]}]);else{const q=(0,x.parseColor)(M[O]);q&&this._onColor.fire([{type:1,index:this._specialColors[D],color:q}])}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;const D=[],M=T.split(";");for(let O=0;O<M.length;++O)if(/^\d+$/.exec(M[O])){const q=parseInt(M[O]);H(q)&&D.push({type:2,index:q})}return D.length&&this._onColor.fire(D),!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,g.DEFAULT_CHARSET),!0}selectCharset(T){return T.length!==2?(this.selectDefaultCharset(),!0):(T[0]==="/"||this._charsetService.setgCharset(C[T[0]],g.CHARSETS[T[1]]||g.DEFAULT_CHARSET),!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){const 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=n.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=n.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(T){return this._charsetService.setgLevel(T),!0}screenAlignmentPattern(){const T=new h.CellData;T.content=4194373,T.fg=this._curAttrData.fg,T.bg=this._curAttrData.bg,this._setCursor(0,0);for(let D=0;D<this._bufferService.rows;++D){const M=this._activeBuffer.ybase+this._activeBuffer.y+D,O=this._activeBuffer.lines.get(M);O&&(O.fill(T),O.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(T,D){const M=this._bufferService.buffer,O=this._optionsService.rawOptions;return(q=>(this._coreService.triggerDataEvent(`${l.C0.ESC}${q}${l.C0.ESC}\\`),!0))(T==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:T==='"p'?'P1$r61;1"p':T==="r"?`P1$r${M.scrollTop+1};${M.scrollBottom+1}r`:T==="m"?"P1$r0m":T===" q"?`P1$r${{block:2,underline:4,bar:6}[O.cursorStyle]-(O.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(T,D){this._dirtyRowTracker.markRangeDirty(T,D)}}r.InputHandler=F;let B=class{constructor(U){this._bufferService=U,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(U){U<this.start?this.start=U:U>this.end&&(this.end=U)}markRangeDirty(U,T){U>T&&(P=U,U=T,T=P),U<this.start&&(this.start=U),T>this.end&&(this.end=T)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function H(U){return 0<=U&&U<256}B=u([f(0,S.IBufferService)],B)},844:(w,r)=>{function o(u){for(const f of u)f.dispose();u.length=0}Object.defineProperty(r,"__esModule",{value:!0}),r.getDisposeArrayDisposable=r.disposeArray=r.toDisposable=r.MutableDisposable=r.Disposable=void 0,r.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const u of this._disposables)u.dispose();this._disposables.length=0}register(u){return this._disposables.push(u),u}unregister(u){const f=this._disposables.indexOf(u);f!==-1&&this._disposables.splice(f,1)}},r.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(u){var f;this._isDisposed||u===this._value||((f=this._value)===null||f===void 0||f.dispose(),this._value=u)}clear(){this.value=void 0}dispose(){var u;this._isDisposed=!0,(u=this._value)===null||u===void 0||u.dispose(),this._value=void 0}},r.toDisposable=function(u){return{dispose:u}},r.disposeArray=o,r.getDisposeArrayDisposable=function(u){return{dispose:()=>o(u)}}},1505:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.FourKeyMap=r.TwoKeyMap=void 0;class o{constructor(){this._data={}}set(f,l,g){this._data[f]||(this._data[f]={}),this._data[f][l]=g}get(f,l){return this._data[f]?this._data[f][l]:void 0}clear(){this._data={}}}r.TwoKeyMap=o,r.FourKeyMap=class{constructor(){this._data=new o}set(u,f,l,g,m){this._data.get(u,f)||this._data.set(u,f,new o),this._data.get(u,f).set(l,g,m)}get(u,f,l,g){var m;return(m=this._data.get(u,f))===null||m===void 0?void 0:m.get(l,g)}clear(){this._data.clear()}}},6114:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.isChromeOS=r.isLinux=r.isWindows=r.isIphone=r.isIpad=r.isMac=r.getSafariVersion=r.isSafari=r.isLegacyEdge=r.isFirefox=r.isNode=void 0,r.isNode=typeof navigator>"u";const o=r.isNode?"node":navigator.userAgent,u=r.isNode?"node":navigator.platform;r.isFirefox=o.includes("Firefox"),r.isLegacyEdge=o.includes("Edge"),r.isSafari=/^((?!chrome|android).)*safari/i.test(o),r.getSafariVersion=function(){if(!r.isSafari)return 0;const f=o.match(/Version\/(\d+)/);return f===null||f.length<2?0:parseInt(f[1])},r.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(u),r.isIpad=u==="iPad",r.isIphone=u==="iPhone",r.isWindows=["Windows","Win16","Win32","WinCE"].includes(u),r.isLinux=u.indexOf("Linux")>=0,r.isChromeOS=/\bCrOS\b/.test(o)},6106:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.SortedList=void 0;let o=0;r.SortedList=class{constructor(u){this._getKey=u,this._array=[]}clear(){this._array.length=0}insert(u){this._array.length!==0?(o=this._search(this._getKey(u)),this._array.splice(o,0,u)):this._array.push(u)}delete(u){if(this._array.length===0)return!1;const f=this._getKey(u);if(f===void 0||(o=this._search(f),o===-1)||this._getKey(this._array[o])!==f)return!1;do if(this._array[o]===u)return this._array.splice(o,1),!0;while(++o<this._array.length&&this._getKey(this._array[o])===f);return!1}*getKeyIterator(u){if(this._array.length!==0&&(o=this._search(u),!(o<0||o>=this._array.length)&&this._getKey(this._array[o])===u))do yield this._array[o];while(++o<this._array.length&&this._getKey(this._array[o])===u)}forEachByKey(u,f){if(this._array.length!==0&&(o=this._search(u),!(o<0||o>=this._array.length)&&this._getKey(this._array[o])===u))do f(this._array[o]);while(++o<this._array.length&&this._getKey(this._array[o])===u)}values(){return[...this._array].values()}_search(u){let f=0,l=this._array.length-1;for(;l>=f;){let g=f+l>>1;const m=this._getKey(this._array[g]);if(m>u)l=g-1;else{if(!(m<u)){for(;g>0&&this._getKey(this._array[g-1])===u;)g--;return g}f=g+1}}return f}}},7226:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.DebouncedIdleTask=r.IdleTaskQueue=r.PriorityTaskQueue=void 0;const u=o(6114);class f{constructor(){this._tasks=[],this._i=0}enqueue(m){this._tasks.push(m),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(m){this._idleCallback=void 0;let y=0,b=0,n=m.timeRemaining(),d=0;for(;this._i<this._tasks.length;){if(y=Date.now(),this._tasks[this._i]()||this._i++,y=Math.max(1,Date.now()-y),b=Math.max(y,b),d=m.timeRemaining(),1.5*b>d)return n-y<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(n-y))}ms`),void this._start();n=d}this.clear()}}class l extends f{_requestCallback(m){return setTimeout((()=>m(this._createDeadline(16))))}_cancelCallback(m){clearTimeout(m)}_createDeadline(m){const y=Date.now()+m;return{timeRemaining:()=>Math.max(0,y-Date.now())}}}r.PriorityTaskQueue=l,r.IdleTaskQueue=!u.isNode&&"requestIdleCallback"in window?class extends f{_requestCallback(g){return requestIdleCallback(g)}_cancelCallback(g){cancelIdleCallback(g)}}:l,r.DebouncedIdleTask=class{constructor(){this._queue=new r.IdleTaskQueue}set(g){this._queue.clear(),this._queue.enqueue(g)}flush(){this._queue.flush()}}},9282:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.updateWindowsModeWrappedState=void 0;const u=o(643);r.updateWindowsModeWrappedState=function(f){const l=f.buffer.lines.get(f.buffer.ybase+f.buffer.y-1),g=l?.get(f.cols-1),m=f.buffer.lines.get(f.buffer.ybase+f.buffer.y);m&&g&&(m.isWrapped=g[u.CHAR_DATA_CODE_INDEX]!==u.NULL_CELL_CODE&&g[u.CHAR_DATA_CODE_INDEX]!==u.WHITESPACE_CELL_CODE)}},3734:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ExtendedAttrs=r.AttributeData=void 0;class o{constructor(){this.fg=0,this.bg=0,this.extended=new u}static toColorRGB(l){return[l>>>16&255,l>>>8&255,255&l]}static fromColorRGB(l){return(255&l[0])<<16|(255&l[1])<<8|255&l[2]}clone(){const l=new o;return l.fg=this.fg,l.bg=this.bg,l.extended=this.extended.clone(),l}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}}r.AttributeData=o;class u{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(l){this._ext=l}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(l){this._ext&=-469762049,this._ext|=l<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(l){this._ext&=-67108864,this._ext|=67108863&l}get urlId(){return this._urlId}set urlId(l){this._urlId=l}constructor(l=0,g=0){this._ext=0,this._urlId=0,this._ext=l,this._urlId=g}clone(){return new u(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}r.ExtendedAttrs=u},9092:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Buffer=r.MAX_BUFFER_SIZE=void 0;const u=o(6349),f=o(7226),l=o(3734),g=o(8437),m=o(4634),y=o(511),b=o(643),n=o(4863),d=o(7116);r.MAX_BUFFER_SIZE=4294967295,r.Buffer=class{constructor(c,h,_){this._hasScrollback=c,this._optionsService=h,this._bufferService=_,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=g.DEFAULT_ATTR_DATA.clone(),this.savedCharset=d.DEFAULT_CHARSET,this.markers=[],this._nullCell=y.CellData.fromCharData([0,b.NULL_CELL_CHAR,b.NULL_CELL_WIDTH,b.NULL_CELL_CODE]),this._whitespaceCell=y.CellData.fromCharData([0,b.WHITESPACE_CELL_CHAR,b.WHITESPACE_CELL_WIDTH,b.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new f.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new u.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(c){return c?(this._nullCell.fg=c.fg,this._nullCell.bg=c.bg,this._nullCell.extended=c.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new l.ExtendedAttrs),this._nullCell}getWhitespaceCell(c){return c?(this._whitespaceCell.fg=c.fg,this._whitespaceCell.bg=c.bg,this._whitespaceCell.extended=c.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new l.ExtendedAttrs),this._whitespaceCell}getBlankLine(c,h){return new g.BufferLine(this._bufferService.cols,this.getNullCell(c),h)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const c=this.ybase+this.y-this.ydisp;return c>=0&&c<this._rows}_getCorrectBufferLength(c){if(!this._hasScrollback)return c;const h=c+this._optionsService.rawOptions.scrollback;return h>r.MAX_BUFFER_SIZE?r.MAX_BUFFER_SIZE:h}fillViewportRows(c){if(this.lines.length===0){c===void 0&&(c=g.DEFAULT_ATTR_DATA);let h=this._rows;for(;h--;)this.lines.push(this.getBlankLine(c))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new u.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(c,h){const _=this.getNullCell(g.DEFAULT_ATTR_DATA);let S=0;const k=this._getCorrectBufferLength(h);if(k>this.lines.maxLength&&(this.lines.maxLength=k),this.lines.length>0){if(this._cols<c)for(let x=0;x<this.lines.length;x++)S+=+this.lines.get(x).resize(c,_);let E=0;if(this._rows<h)for(let x=this._rows;x<h;x++)this.lines.length<h+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new g.BufferLine(c,_)):this.ybase>0&&this.lines.length<=this.ybase+this.y+E+1?(this.ybase--,E++,this.ydisp>0&&this.ydisp--):this.lines.push(new g.BufferLine(c,_)));else for(let x=this._rows;x>h;x--)this.lines.length>h+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(k<this.lines.maxLength){const x=this.lines.length-k;x>0&&(this.lines.trimStart(x),this.ybase=Math.max(this.ybase-x,0),this.ydisp=Math.max(this.ydisp-x,0),this.savedY=Math.max(this.savedY-x,0)),this.lines.maxLength=k}this.x=Math.min(this.x,c-1),this.y=Math.min(this.y,h-1),E&&(this.y+=E),this.savedX=Math.min(this.savedX,c-1),this.scrollTop=0}if(this.scrollBottom=h-1,this._isReflowEnabled&&(this._reflow(c,h),this._cols>c))for(let E=0;E<this.lines.length;E++)S+=+this.lines.get(E).resize(c,_);this._cols=c,this._rows=h,this._memoryCleanupQueue.clear(),S>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let c=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,c=!1);let h=0;for(;this._memoryCleanupPosition<this.lines.length;)if(h+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),h>100)return!0;return c}get _isReflowEnabled(){const c=this._optionsService.rawOptions.windowsPty;return c&&c.buildNumber?this._hasScrollback&&c.backend==="conpty"&&c.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(c,h){this._cols!==c&&(c>this._cols?this._reflowLarger(c,h):this._reflowSmaller(c,h))}_reflowLarger(c,h){const _=(0,m.reflowLargerGetLinesToRemove)(this.lines,this._cols,c,this.ybase+this.y,this.getNullCell(g.DEFAULT_ATTR_DATA));if(_.length>0){const S=(0,m.reflowLargerCreateNewLayout)(this.lines,_);(0,m.reflowLargerApplyNewLayout)(this.lines,S.layout),this._reflowLargerAdjustViewport(c,h,S.countRemoved)}}_reflowLargerAdjustViewport(c,h,_){const S=this.getNullCell(g.DEFAULT_ATTR_DATA);let k=_;for(;k-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<h&&this.lines.push(new g.BufferLine(c,S))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-_,0)}_reflowSmaller(c,h){const _=this.getNullCell(g.DEFAULT_ATTR_DATA),S=[];let k=0;for(let E=this.lines.length-1;E>=0;E--){let x=this.lines.get(E);if(!x||!x.isWrapped&&x.getTrimmedLength()<=c)continue;const C=[x];for(;x.isWrapped&&E>0;)x=this.lines.get(--E),C.unshift(x);const N=this.ybase+this.y;if(N>=E&&N<E+C.length)continue;const L=C[C.length-1].getTrimmedLength(),R=(0,m.reflowSmallerGetNewLineLengths)(C,this._cols,c),P=R.length-C.length;let F;F=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+P):Math.max(0,this.lines.length-this.lines.maxLength+P);const B=[];for(let O=0;O<P;O++){const q=this.getBlankLine(g.DEFAULT_ATTR_DATA,!0);B.push(q)}B.length>0&&(S.push({start:E+C.length+k,newLines:B}),k+=B.length),C.push(...B);let H=R.length-1,U=R[H];U===0&&(H--,U=R[H]);let T=C.length-P-1,D=L;for(;T>=0;){const O=Math.min(D,U);if(C[H]===void 0)break;if(C[H].copyCellsFrom(C[T],D-O,U-O,O,!0),U-=O,U===0&&(H--,U=R[H]),D-=O,D===0){T--;const q=Math.max(T,0);D=(0,m.getWrappedLineTrimmedLength)(C,q,this._cols)}}for(let O=0;O<C.length;O++)R[O]<c&&C[O].setCell(R[O],_);let M=P-F;for(;M-- >0;)this.ybase===0?this.y<h-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+k)-h&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+P,this.ybase+h-1)}if(S.length>0){const E=[],x=[];for(let H=0;H<this.lines.length;H++)x.push(this.lines.get(H));const C=this.lines.length;let N=C-1,L=0,R=S[L];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+k);let P=0;for(let H=Math.min(this.lines.maxLength-1,C+k-1);H>=0;H--)if(R&&R.start>N+P){for(let U=R.newLines.length-1;U>=0;U--)this.lines.set(H--,R.newLines[U]);H++,E.push({index:N+1,amount:R.newLines.length}),P+=R.newLines.length,R=S[++L]}else this.lines.set(H,x[N--]);let F=0;for(let H=E.length-1;H>=0;H--)E[H].index+=F,this.lines.onInsertEmitter.fire(E[H]),F+=E[H].amount;const B=Math.max(0,C+k-this.lines.maxLength);B>0&&this.lines.onTrimEmitter.fire(B)}}translateBufferLineToString(c,h,_=0,S){const k=this.lines.get(c);return k?k.translateToString(h,_,S):""}getWrappedRangeForLine(c){let h=c,_=c;for(;h>0&&this.lines.get(h).isWrapped;)h--;for(;_+1<this.lines.length&&this.lines.get(_+1).isWrapped;)_++;return{first:h,last:_}}setupTabStops(c){for(c!=null?this.tabs[c]||(c=this.prevStop(c)):(this.tabs={},c=0);c<this._cols;c+=this._optionsService.rawOptions.tabStopWidth)this.tabs[c]=!0}prevStop(c){for(c==null&&(c=this.x);!this.tabs[--c]&&c>0;);return c>=this._cols?this._cols-1:c<0?0:c}nextStop(c){for(c==null&&(c=this.x);!this.tabs[++c]&&c<this._cols;);return c>=this._cols?this._cols-1:c<0?0:c}clearMarkers(c){this._isClearing=!0;for(let h=0;h<this.markers.length;h++)this.markers[h].line===c&&(this.markers[h].dispose(),this.markers.splice(h--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let c=0;c<this.markers.length;c++)this.markers[c].dispose(),this.markers.splice(c--,1);this._isClearing=!1}addMarker(c){const h=new n.Marker(c);return this.markers.push(h),h.register(this.lines.onTrim((_=>{h.line-=_,h.line<0&&h.dispose()}))),h.register(this.lines.onInsert((_=>{h.line>=_.index&&(h.line+=_.amount)}))),h.register(this.lines.onDelete((_=>{h.line>=_.index&&h.line<_.index+_.amount&&h.dispose(),h.line>_.index&&(h.line-=_.amount)}))),h.register(h.onDispose((()=>this._removeMarker(h)))),h}_removeMarker(c){this._isClearing||this.markers.splice(this.markers.indexOf(c),1)}}},8437:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferLine=r.DEFAULT_ATTR_DATA=void 0;const u=o(3734),f=o(511),l=o(643),g=o(482);r.DEFAULT_ATTR_DATA=Object.freeze(new u.AttributeData);let m=0;class y{constructor(n,d,c=!1){this.isWrapped=c,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*n);const h=d||f.CellData.fromCharData([0,l.NULL_CELL_CHAR,l.NULL_CELL_WIDTH,l.NULL_CELL_CODE]);for(let _=0;_<n;++_)this.setCell(_,h);this.length=n}get(n){const d=this._data[3*n+0],c=2097151&d;return[this._data[3*n+1],2097152&d?this._combined[n]:c?(0,g.stringFromCodePoint)(c):"",d>>22,2097152&d?this._combined[n].charCodeAt(this._combined[n].length-1):c]}set(n,d){this._data[3*n+1]=d[l.CHAR_DATA_ATTR_INDEX],d[l.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[n]=d[1],this._data[3*n+0]=2097152|n|d[l.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*n+0]=d[l.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|d[l.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(n){return this._data[3*n+0]>>22}hasWidth(n){return 12582912&this._data[3*n+0]}getFg(n){return this._data[3*n+1]}getBg(n){return this._data[3*n+2]}hasContent(n){return 4194303&this._data[3*n+0]}getCodePoint(n){const d=this._data[3*n+0];return 2097152&d?this._combined[n].charCodeAt(this._combined[n].length-1):2097151&d}isCombined(n){return 2097152&this._data[3*n+0]}getString(n){const d=this._data[3*n+0];return 2097152&d?this._combined[n]:2097151&d?(0,g.stringFromCodePoint)(2097151&d):""}isProtected(n){return 536870912&this._data[3*n+2]}loadCell(n,d){return m=3*n,d.content=this._data[m+0],d.fg=this._data[m+1],d.bg=this._data[m+2],2097152&d.content&&(d.combinedData=this._combined[n]),268435456&d.bg&&(d.extended=this._extendedAttrs[n]),d}setCell(n,d){2097152&d.content&&(this._combined[n]=d.combinedData),268435456&d.bg&&(this._extendedAttrs[n]=d.extended),this._data[3*n+0]=d.content,this._data[3*n+1]=d.fg,this._data[3*n+2]=d.bg}setCellFromCodePoint(n,d,c,h,_,S){268435456&_&&(this._extendedAttrs[n]=S),this._data[3*n+0]=d|c<<22,this._data[3*n+1]=h,this._data[3*n+2]=_}addCodepointToCell(n,d){let c=this._data[3*n+0];2097152&c?this._combined[n]+=(0,g.stringFromCodePoint)(d):(2097151&c?(this._combined[n]=(0,g.stringFromCodePoint)(2097151&c)+(0,g.stringFromCodePoint)(d),c&=-2097152,c|=2097152):c=d|4194304,this._data[3*n+0]=c)}insertCells(n,d,c,h){if((n%=this.length)&&this.getWidth(n-1)===2&&this.setCellFromCodePoint(n-1,0,1,h?.fg||0,h?.bg||0,h?.extended||new u.ExtendedAttrs),d<this.length-n){const _=new f.CellData;for(let S=this.length-n-d-1;S>=0;--S)this.setCell(n+d+S,this.loadCell(n+S,_));for(let S=0;S<d;++S)this.setCell(n+S,c)}else for(let _=n;_<this.length;++_)this.setCell(_,c);this.getWidth(this.length-1)===2&&this.setCellFromCodePoint(this.length-1,0,1,h?.fg||0,h?.bg||0,h?.extended||new u.ExtendedAttrs)}deleteCells(n,d,c,h){if(n%=this.length,d<this.length-n){const _=new f.CellData;for(let S=0;S<this.length-n-d;++S)this.setCell(n+S,this.loadCell(n+d+S,_));for(let S=this.length-d;S<this.length;++S)this.setCell(S,c)}else for(let _=n;_<this.length;++_)this.setCell(_,c);n&&this.getWidth(n-1)===2&&this.setCellFromCodePoint(n-1,0,1,h?.fg||0,h?.bg||0,h?.extended||new u.ExtendedAttrs),this.getWidth(n)!==0||this.hasContent(n)||this.setCellFromCodePoint(n,0,1,h?.fg||0,h?.bg||0,h?.extended||new u.ExtendedAttrs)}replaceCells(n,d,c,h,_=!1){if(_)for(n&&this.getWidth(n-1)===2&&!this.isProtected(n-1)&&this.setCellFromCodePoint(n-1,0,1,h?.fg||0,h?.bg||0,h?.extended||new u.ExtendedAttrs),d<this.length&&this.getWidth(d-1)===2&&!this.isProtected(d)&&this.setCellFromCodePoint(d,0,1,h?.fg||0,h?.bg||0,h?.extended||new u.ExtendedAttrs);n<d&&n<this.length;)this.isProtected(n)||this.setCell(n,c),n++;else for(n&&this.getWidth(n-1)===2&&this.setCellFromCodePoint(n-1,0,1,h?.fg||0,h?.bg||0,h?.extended||new u.ExtendedAttrs),d<this.length&&this.getWidth(d-1)===2&&this.setCellFromCodePoint(d,0,1,h?.fg||0,h?.bg||0,h?.extended||new u.ExtendedAttrs);n<d&&n<this.length;)this.setCell(n++,c)}resize(n,d){if(n===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const c=3*n;if(n>this.length){if(this._data.buffer.byteLength>=4*c)this._data=new Uint32Array(this._data.buffer,0,c);else{const h=new Uint32Array(c);h.set(this._data),this._data=h}for(let h=this.length;h<n;++h)this.setCell(h,d)}else{this._data=this._data.subarray(0,c);const h=Object.keys(this._combined);for(let S=0;S<h.length;S++){const k=parseInt(h[S],10);k>=n&&delete this._combined[k]}const _=Object.keys(this._extendedAttrs);for(let S=0;S<_.length;S++){const k=parseInt(_[S],10);k>=n&&delete this._extendedAttrs[k]}}return this.length=n,4*c*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const n=new Uint32Array(this._data.length);return n.set(this._data),this._data=n,1}return 0}fill(n,d=!1){if(d)for(let c=0;c<this.length;++c)this.isProtected(c)||this.setCell(c,n);else{this._combined={},this._extendedAttrs={};for(let c=0;c<this.length;++c)this.setCell(c,n)}}copyFrom(n){this.length!==n.length?this._data=new Uint32Array(n._data):this._data.set(n._data),this.length=n.length,this._combined={};for(const d in n._combined)this._combined[d]=n._combined[d];this._extendedAttrs={};for(const d in n._extendedAttrs)this._extendedAttrs[d]=n._extendedAttrs[d];this.isWrapped=n.isWrapped}clone(){const n=new y(0);n._data=new Uint32Array(this._data),n.length=this.length;for(const d in this._combined)n._combined[d]=this._combined[d];for(const d in this._extendedAttrs)n._extendedAttrs[d]=this._extendedAttrs[d];return n.isWrapped=this.isWrapped,n}getTrimmedLength(){for(let n=this.length-1;n>=0;--n)if(4194303&this._data[3*n+0])return n+(this._data[3*n+0]>>22);return 0}getNoBgTrimmedLength(){for(let n=this.length-1;n>=0;--n)if(4194303&this._data[3*n+0]||50331648&this._data[3*n+2])return n+(this._data[3*n+0]>>22);return 0}copyCellsFrom(n,d,c,h,_){const S=n._data;if(_)for(let E=h-1;E>=0;E--){for(let x=0;x<3;x++)this._data[3*(c+E)+x]=S[3*(d+E)+x];268435456&S[3*(d+E)+2]&&(this._extendedAttrs[c+E]=n._extendedAttrs[d+E])}else for(let E=0;E<h;E++){for(let x=0;x<3;x++)this._data[3*(c+E)+x]=S[3*(d+E)+x];268435456&S[3*(d+E)+2]&&(this._extendedAttrs[c+E]=n._extendedAttrs[d+E])}const k=Object.keys(n._combined);for(let E=0;E<k.length;E++){const x=parseInt(k[E],10);x>=d&&(this._combined[x-d+c]=n._combined[x])}}translateToString(n=!1,d=0,c=this.length){n&&(c=Math.min(c,this.getTrimmedLength()));let h="";for(;d<c;){const _=this._data[3*d+0],S=2097151&_;h+=2097152&_?this._combined[d]:S?(0,g.stringFromCodePoint)(S):l.WHITESPACE_CELL_CHAR,d+=_>>22||1}return h}}r.BufferLine=y},4841:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.getRangeLength=void 0,r.getRangeLength=function(o,u){if(o.start.y>o.end.y)throw new Error(`Buffer range end (${o.end.x}, ${o.end.y}) cannot be before start (${o.start.x}, ${o.start.y})`);return u*(o.end.y-o.start.y)+(o.end.x-o.start.x+1)}},4634:(w,r)=>{function o(u,f,l){if(f===u.length-1)return u[f].getTrimmedLength();const g=!u[f].hasContent(l-1)&&u[f].getWidth(l-1)===1,m=u[f+1].getWidth(0)===2;return g&&m?l-1:l}Object.defineProperty(r,"__esModule",{value:!0}),r.getWrappedLineTrimmedLength=r.reflowSmallerGetNewLineLengths=r.reflowLargerApplyNewLayout=r.reflowLargerCreateNewLayout=r.reflowLargerGetLinesToRemove=void 0,r.reflowLargerGetLinesToRemove=function(u,f,l,g,m){const y=[];for(let b=0;b<u.length-1;b++){let n=b,d=u.get(++n);if(!d.isWrapped)continue;const c=[u.get(b)];for(;n<u.length&&d.isWrapped;)c.push(d),d=u.get(++n);if(g>=b&&g<n){b+=c.length-1;continue}let h=0,_=o(c,h,f),S=1,k=0;for(;S<c.length;){const x=o(c,S,f),C=x-k,N=l-_,L=Math.min(C,N);c[h].copyCellsFrom(c[S],k,_,L,!1),_+=L,_===l&&(h++,_=0),k+=L,k===x&&(S++,k=0),_===0&&h!==0&&c[h-1].getWidth(l-1)===2&&(c[h].copyCellsFrom(c[h-1],l-1,_++,1,!1),c[h-1].setCell(l-1,m))}c[h].replaceCells(_,l,m);let E=0;for(let x=c.length-1;x>0&&(x>h||c[x].getTrimmedLength()===0);x--)E++;E>0&&(y.push(b+c.length-E),y.push(E)),b+=c.length-1}return y},r.reflowLargerCreateNewLayout=function(u,f){const l=[];let g=0,m=f[g],y=0;for(let b=0;b<u.length;b++)if(m===b){const n=f[++g];u.onDeleteEmitter.fire({index:b-y,amount:n}),b+=n-1,y+=n,m=f[++g]}else l.push(b);return{layout:l,countRemoved:y}},r.reflowLargerApplyNewLayout=function(u,f){const l=[];for(let g=0;g<f.length;g++)l.push(u.get(f[g]));for(let g=0;g<l.length;g++)u.set(g,l[g]);u.length=f.length},r.reflowSmallerGetNewLineLengths=function(u,f,l){const g=[],m=u.map(((d,c)=>o(u,c,f))).reduce(((d,c)=>d+c));let y=0,b=0,n=0;for(;n<m;){if(m-n<l){g.push(m-n);break}y+=l;const d=o(u,b,f);y>d&&(y-=d,b++);const c=u[b].getWidth(y-1)===2;c&&y--;const h=c?l-1:l;g.push(h),n+=h}return g},r.getWrappedLineTrimmedLength=o},5295:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferSet=void 0;const u=o(8460),f=o(844),l=o(9092);class g extends f.Disposable{constructor(y,b){super(),this._optionsService=y,this._bufferService=b,this._onBufferActivate=this.register(new u.EventEmitter),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 l.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new l.Buffer(!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(y){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(y),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(y,b){this._normal.resize(y,b),this._alt.resize(y,b),this.setupTabStops(y)}setupTabStops(y){this._normal.setupTabStops(y),this._alt.setupTabStops(y)}}r.BufferSet=g},511:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CellData=void 0;const u=o(482),f=o(643),l=o(3734);class g extends l.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new l.ExtendedAttrs,this.combinedData=""}static fromCharData(y){const b=new g;return b.setFromCharData(y),b}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,u.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(y){this.fg=y[f.CHAR_DATA_ATTR_INDEX],this.bg=0;let b=!1;if(y[f.CHAR_DATA_CHAR_INDEX].length>2)b=!0;else if(y[f.CHAR_DATA_CHAR_INDEX].length===2){const n=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=n&&n<=56319){const d=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=d&&d<=57343?this.content=1024*(n-55296)+d-56320+65536|y[f.CHAR_DATA_WIDTH_INDEX]<<22:b=!0}else b=!0}else this.content=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|y[f.CHAR_DATA_WIDTH_INDEX]<<22;b&&(this.combinedData=y[f.CHAR_DATA_CHAR_INDEX],this.content=2097152|y[f.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}r.CellData=g},643:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.WHITESPACE_CELL_CODE=r.WHITESPACE_CELL_WIDTH=r.WHITESPACE_CELL_CHAR=r.NULL_CELL_CODE=r.NULL_CELL_WIDTH=r.NULL_CELL_CHAR=r.CHAR_DATA_CODE_INDEX=r.CHAR_DATA_WIDTH_INDEX=r.CHAR_DATA_CHAR_INDEX=r.CHAR_DATA_ATTR_INDEX=r.DEFAULT_EXT=r.DEFAULT_ATTR=r.DEFAULT_COLOR=void 0,r.DEFAULT_COLOR=0,r.DEFAULT_ATTR=256|r.DEFAULT_COLOR<<9,r.DEFAULT_EXT=0,r.CHAR_DATA_ATTR_INDEX=0,r.CHAR_DATA_CHAR_INDEX=1,r.CHAR_DATA_WIDTH_INDEX=2,r.CHAR_DATA_CODE_INDEX=3,r.NULL_CELL_CHAR="",r.NULL_CELL_WIDTH=1,r.NULL_CELL_CODE=0,r.WHITESPACE_CELL_CHAR=" ",r.WHITESPACE_CELL_WIDTH=1,r.WHITESPACE_CELL_CODE=32},4863:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Marker=void 0;const u=o(8460),f=o(844);class l{get id(){return this._id}constructor(m){this.line=m,this.isDisposed=!1,this._disposables=[],this._id=l._nextId++,this._onDispose=this.register(new u.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,f.disposeArray)(this._disposables),this._disposables.length=0)}register(m){return this._disposables.push(m),m}}r.Marker=l,l._nextId=1},7116:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.DEFAULT_CHARSET=r.CHARSETS=void 0,r.CHARSETS={},r.DEFAULT_CHARSET=r.CHARSETS.B,r.CHARSETS[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:"≥","{":"π","|":"≠","}":"£","~":"·"},r.CHARSETS.A={"#":"£"},r.CHARSETS.B=void 0,r.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},r.CHARSETS.C=r.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},r.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},r.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},r.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},r.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},r.CHARSETS.E=r.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},r.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},r.CHARSETS.H=r.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},r.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(w,r)=>{var o,u,f;Object.defineProperty(r,"__esModule",{value:!0}),r.C1_ESCAPED=r.C1=r.C0=void 0,(function(l){l.NUL="\0",l.SOH="",l.STX="",l.ETX="",l.EOT="",l.ENQ="",l.ACK="",l.BEL="\x07",l.BS="\b",l.HT=" ",l.LF=`
|
|
15
|
+
`,l.VT="\v",l.FF="\f",l.CR="\r",l.SO="",l.SI="",l.DLE="",l.DC1="",l.DC2="",l.DC3="",l.DC4="",l.NAK="",l.SYN="",l.ETB="",l.CAN="",l.EM="",l.SUB="",l.ESC="\x1B",l.FS="",l.GS="",l.RS="",l.US="",l.SP=" ",l.DEL=""})(o||(r.C0=o={})),(function(l){l.PAD="",l.HOP="",l.BPH="",l.NBH="",l.IND="",l.NEL="
",l.SSA="",l.ESA="",l.HTS="",l.HTJ="",l.VTS="",l.PLD="",l.PLU="",l.RI="",l.SS2="",l.SS3="",l.DCS="",l.PU1="",l.PU2="",l.STS="",l.CCH="",l.MW="",l.SPA="",l.EPA="",l.SOS="",l.SGCI="",l.SCI="",l.CSI="",l.ST="",l.OSC="",l.PM="",l.APC=""})(u||(r.C1=u={})),(function(l){l.ST=`${o.ESC}\\`})(f||(r.C1_ESCAPED=f={}))},7399:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.evaluateKeyboardEvent=void 0;const u=o(2584),f={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:["'",'"']};r.evaluateKeyboardEvent=function(l,g,m,y){const b={type:0,cancel:!1,key:void 0},n=(l.shiftKey?1:0)|(l.altKey?2:0)|(l.ctrlKey?4:0)|(l.metaKey?8:0);switch(l.keyCode){case 0:l.key==="UIKeyInputUpArrow"?b.key=g?u.C0.ESC+"OA":u.C0.ESC+"[A":l.key==="UIKeyInputLeftArrow"?b.key=g?u.C0.ESC+"OD":u.C0.ESC+"[D":l.key==="UIKeyInputRightArrow"?b.key=g?u.C0.ESC+"OC":u.C0.ESC+"[C":l.key==="UIKeyInputDownArrow"&&(b.key=g?u.C0.ESC+"OB":u.C0.ESC+"[B");break;case 8:if(l.altKey){b.key=u.C0.ESC+u.C0.DEL;break}b.key=u.C0.DEL;break;case 9:if(l.shiftKey){b.key=u.C0.ESC+"[Z";break}b.key=u.C0.HT,b.cancel=!0;break;case 13:b.key=l.altKey?u.C0.ESC+u.C0.CR:u.C0.CR,b.cancel=!0;break;case 27:b.key=u.C0.ESC,l.altKey&&(b.key=u.C0.ESC+u.C0.ESC),b.cancel=!0;break;case 37:if(l.metaKey)break;n?(b.key=u.C0.ESC+"[1;"+(n+1)+"D",b.key===u.C0.ESC+"[1;3D"&&(b.key=u.C0.ESC+(m?"b":"[1;5D"))):b.key=g?u.C0.ESC+"OD":u.C0.ESC+"[D";break;case 39:if(l.metaKey)break;n?(b.key=u.C0.ESC+"[1;"+(n+1)+"C",b.key===u.C0.ESC+"[1;3C"&&(b.key=u.C0.ESC+(m?"f":"[1;5C"))):b.key=g?u.C0.ESC+"OC":u.C0.ESC+"[C";break;case 38:if(l.metaKey)break;n?(b.key=u.C0.ESC+"[1;"+(n+1)+"A",m||b.key!==u.C0.ESC+"[1;3A"||(b.key=u.C0.ESC+"[1;5A")):b.key=g?u.C0.ESC+"OA":u.C0.ESC+"[A";break;case 40:if(l.metaKey)break;n?(b.key=u.C0.ESC+"[1;"+(n+1)+"B",m||b.key!==u.C0.ESC+"[1;3B"||(b.key=u.C0.ESC+"[1;5B")):b.key=g?u.C0.ESC+"OB":u.C0.ESC+"[B";break;case 45:l.shiftKey||l.ctrlKey||(b.key=u.C0.ESC+"[2~");break;case 46:b.key=n?u.C0.ESC+"[3;"+(n+1)+"~":u.C0.ESC+"[3~";break;case 36:b.key=n?u.C0.ESC+"[1;"+(n+1)+"H":g?u.C0.ESC+"OH":u.C0.ESC+"[H";break;case 35:b.key=n?u.C0.ESC+"[1;"+(n+1)+"F":g?u.C0.ESC+"OF":u.C0.ESC+"[F";break;case 33:l.shiftKey?b.type=2:l.ctrlKey?b.key=u.C0.ESC+"[5;"+(n+1)+"~":b.key=u.C0.ESC+"[5~";break;case 34:l.shiftKey?b.type=3:l.ctrlKey?b.key=u.C0.ESC+"[6;"+(n+1)+"~":b.key=u.C0.ESC+"[6~";break;case 112:b.key=n?u.C0.ESC+"[1;"+(n+1)+"P":u.C0.ESC+"OP";break;case 113:b.key=n?u.C0.ESC+"[1;"+(n+1)+"Q":u.C0.ESC+"OQ";break;case 114:b.key=n?u.C0.ESC+"[1;"+(n+1)+"R":u.C0.ESC+"OR";break;case 115:b.key=n?u.C0.ESC+"[1;"+(n+1)+"S":u.C0.ESC+"OS";break;case 116:b.key=n?u.C0.ESC+"[15;"+(n+1)+"~":u.C0.ESC+"[15~";break;case 117:b.key=n?u.C0.ESC+"[17;"+(n+1)+"~":u.C0.ESC+"[17~";break;case 118:b.key=n?u.C0.ESC+"[18;"+(n+1)+"~":u.C0.ESC+"[18~";break;case 119:b.key=n?u.C0.ESC+"[19;"+(n+1)+"~":u.C0.ESC+"[19~";break;case 120:b.key=n?u.C0.ESC+"[20;"+(n+1)+"~":u.C0.ESC+"[20~";break;case 121:b.key=n?u.C0.ESC+"[21;"+(n+1)+"~":u.C0.ESC+"[21~";break;case 122:b.key=n?u.C0.ESC+"[23;"+(n+1)+"~":u.C0.ESC+"[23~";break;case 123:b.key=n?u.C0.ESC+"[24;"+(n+1)+"~":u.C0.ESC+"[24~";break;default:if(!l.ctrlKey||l.shiftKey||l.altKey||l.metaKey)if(m&&!y||!l.altKey||l.metaKey)!m||l.altKey||l.ctrlKey||l.shiftKey||!l.metaKey?l.key&&!l.ctrlKey&&!l.altKey&&!l.metaKey&&l.keyCode>=48&&l.key.length===1?b.key=l.key:l.key&&l.ctrlKey&&(l.key==="_"&&(b.key=u.C0.US),l.key==="@"&&(b.key=u.C0.NUL)):l.keyCode===65&&(b.type=1);else{const d=f[l.keyCode],c=d?.[l.shiftKey?1:0];if(c)b.key=u.C0.ESC+c;else if(l.keyCode>=65&&l.keyCode<=90){const h=l.ctrlKey?l.keyCode-64:l.keyCode+32;let _=String.fromCharCode(h);l.shiftKey&&(_=_.toUpperCase()),b.key=u.C0.ESC+_}else if(l.keyCode===32)b.key=u.C0.ESC+(l.ctrlKey?u.C0.NUL:" ");else if(l.key==="Dead"&&l.code.startsWith("Key")){let h=l.code.slice(3,4);l.shiftKey||(h=h.toLowerCase()),b.key=u.C0.ESC+h,b.cancel=!0}}else l.keyCode>=65&&l.keyCode<=90?b.key=String.fromCharCode(l.keyCode-64):l.keyCode===32?b.key=u.C0.NUL:l.keyCode>=51&&l.keyCode<=55?b.key=String.fromCharCode(l.keyCode-51+27):l.keyCode===56?b.key=u.C0.DEL:l.keyCode===219?b.key=u.C0.ESC:l.keyCode===220?b.key=u.C0.FS:l.keyCode===221&&(b.key=u.C0.GS)}return b}},482:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Utf8ToUtf32=r.StringToUtf32=r.utf32ToString=r.stringFromCodePoint=void 0,r.stringFromCodePoint=function(o){return o>65535?(o-=65536,String.fromCharCode(55296+(o>>10))+String.fromCharCode(o%1024+56320)):String.fromCharCode(o)},r.utf32ToString=function(o,u=0,f=o.length){let l="";for(let g=u;g<f;++g){let m=o[g];m>65535?(m-=65536,l+=String.fromCharCode(55296+(m>>10))+String.fromCharCode(m%1024+56320)):l+=String.fromCharCode(m)}return l},r.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(o,u){const f=o.length;if(!f)return 0;let l=0,g=0;if(this._interim){const m=o.charCodeAt(g++);56320<=m&&m<=57343?u[l++]=1024*(this._interim-55296)+m-56320+65536:(u[l++]=this._interim,u[l++]=m),this._interim=0}for(let m=g;m<f;++m){const y=o.charCodeAt(m);if(55296<=y&&y<=56319){if(++m>=f)return this._interim=y,l;const b=o.charCodeAt(m);56320<=b&&b<=57343?u[l++]=1024*(y-55296)+b-56320+65536:(u[l++]=y,u[l++]=b)}else y!==65279&&(u[l++]=y)}return l}},r.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(o,u){const f=o.length;if(!f)return 0;let l,g,m,y,b=0,n=0,d=0;if(this.interim[0]){let _=!1,S=this.interim[0];S&=(224&S)==192?31:(240&S)==224?15:7;let k,E=0;for(;(k=63&this.interim[++E])&&E<4;)S<<=6,S|=k;const x=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,C=x-E;for(;d<C;){if(d>=f)return 0;if(k=o[d++],(192&k)!=128){d--,_=!0;break}this.interim[E++]=k,S<<=6,S|=63&k}_||(x===2?S<128?d--:u[b++]=S:x===3?S<2048||S>=55296&&S<=57343||S===65279||(u[b++]=S):S<65536||S>1114111||(u[b++]=S)),this.interim.fill(0)}const c=f-4;let h=d;for(;h<f;){for(;!(!(h<c)||128&(l=o[h])||128&(g=o[h+1])||128&(m=o[h+2])||128&(y=o[h+3]));)u[b++]=l,u[b++]=g,u[b++]=m,u[b++]=y,h+=4;if(l=o[h++],l<128)u[b++]=l;else if((224&l)==192){if(h>=f)return this.interim[0]=l,b;if(g=o[h++],(192&g)!=128){h--;continue}if(n=(31&l)<<6|63&g,n<128){h--;continue}u[b++]=n}else if((240&l)==224){if(h>=f)return this.interim[0]=l,b;if(g=o[h++],(192&g)!=128){h--;continue}if(h>=f)return this.interim[0]=l,this.interim[1]=g,b;if(m=o[h++],(192&m)!=128){h--;continue}if(n=(15&l)<<12|(63&g)<<6|63&m,n<2048||n>=55296&&n<=57343||n===65279)continue;u[b++]=n}else if((248&l)==240){if(h>=f)return this.interim[0]=l,b;if(g=o[h++],(192&g)!=128){h--;continue}if(h>=f)return this.interim[0]=l,this.interim[1]=g,b;if(m=o[h++],(192&m)!=128){h--;continue}if(h>=f)return this.interim[0]=l,this.interim[1]=g,this.interim[2]=m,b;if(y=o[h++],(192&y)!=128){h--;continue}if(n=(7&l)<<18|(63&g)<<12|(63&m)<<6|63&y,n<65536||n>1114111)continue;u[b++]=n}}return b}}},225:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.UnicodeV6=void 0;const o=[[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]],u=[[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]];let f;r.UnicodeV6=class{constructor(){if(this.version="6",!f){f=new Uint8Array(65536),f.fill(1),f[0]=0,f.fill(0,1,32),f.fill(0,127,160),f.fill(2,4352,4448),f[9001]=2,f[9002]=2,f.fill(2,11904,42192),f[12351]=1,f.fill(2,44032,55204),f.fill(2,63744,64256),f.fill(2,65040,65050),f.fill(2,65072,65136),f.fill(2,65280,65377),f.fill(2,65504,65511);for(let l=0;l<o.length;++l)f.fill(0,o[l][0],o[l][1]+1)}}wcwidth(l){return l<32?0:l<127?1:l<65536?f[l]:(function(g,m){let y,b=0,n=m.length-1;if(g<m[0][0]||g>m[n][1])return!1;for(;n>=b;)if(y=b+n>>1,g>m[y][1])b=y+1;else{if(!(g<m[y][0]))return!0;n=y-1}return!1})(l,u)?0:l>=131072&&l<=196605||l>=196608&&l<=262141?2:1}}},5981:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.WriteBuffer=void 0;const u=o(8460),f=o(844);class l extends f.Disposable{constructor(m){super(),this._action=m,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new u.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(m,y){if(y!==void 0&&this._syncCalls>y)return void(this._syncCalls=0);if(this._pendingData+=m.length,this._writeBuffer.push(m),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let b;for(this._isSyncWriting=!0;b=this._writeBuffer.shift();){this._action(b);const n=this._callbacks.shift();n&&n()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(m,y){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=m.length,this._writeBuffer.push(m),this._callbacks.push(y),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=m.length,this._writeBuffer.push(m),this._callbacks.push(y)}_innerWrite(m=0,y=!0){const b=m||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const n=this._writeBuffer[this._bufferOffset],d=this._action(n,y);if(d){const h=_=>Date.now()-b>=12?setTimeout((()=>this._innerWrite(0,_))):this._innerWrite(b,_);return void d.catch((_=>(queueMicrotask((()=>{throw _})),Promise.resolve(!1)))).then(h)}const c=this._callbacks[this._bufferOffset];if(c&&c(),this._bufferOffset++,this._pendingData-=n.length,Date.now()-b>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(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()}}r.WriteBuffer=l},5941:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.toRgbString=r.parseColor=void 0;const o=/^([\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})$/,u=/^[\da-f]+$/;function f(l,g){const m=l.toString(16),y=m.length<2?"0"+m:m;switch(g){case 4:return m[0];case 8:return y;case 12:return(y+y).slice(0,3);default:return y+y}}r.parseColor=function(l){if(!l)return;let g=l.toLowerCase();if(g.indexOf("rgb:")===0){g=g.slice(4);const m=o.exec(g);if(m){const y=m[1]?15:m[4]?255:m[7]?4095:65535;return[Math.round(parseInt(m[1]||m[4]||m[7]||m[10],16)/y*255),Math.round(parseInt(m[2]||m[5]||m[8]||m[11],16)/y*255),Math.round(parseInt(m[3]||m[6]||m[9]||m[12],16)/y*255)]}}else if(g.indexOf("#")===0&&(g=g.slice(1),u.exec(g)&&[3,6,9,12].includes(g.length))){const m=g.length/3,y=[0,0,0];for(let b=0;b<3;++b){const n=parseInt(g.slice(m*b,m*b+m),16);y[b]=m===1?n<<4:m===2?n:m===3?n>>4:n>>8}return y}},r.toRgbString=function(l,g=16){const[m,y,b]=l;return`rgb:${f(m,g)}/${f(y,g)}/${f(b,g)}`}},5770:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.PAYLOAD_LIMIT=void 0,r.PAYLOAD_LIMIT=1e7},6351:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.DcsHandler=r.DcsParser=void 0;const u=o(482),f=o(8742),l=o(5770),g=[];r.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=g,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=g}registerHandler(y,b){this._handlers[y]===void 0&&(this._handlers[y]=[]);const n=this._handlers[y];return n.push(b),{dispose:()=>{const d=n.indexOf(b);d!==-1&&n.splice(d,1)}}}clearHandler(y){this._handlers[y]&&delete this._handlers[y]}setHandlerFallback(y){this._handlerFb=y}reset(){if(this._active.length)for(let y=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;y>=0;--y)this._active[y].unhook(!1);this._stack.paused=!1,this._active=g,this._ident=0}hook(y,b){if(this.reset(),this._ident=y,this._active=this._handlers[y]||g,this._active.length)for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(b);else this._handlerFb(this._ident,"HOOK",b)}put(y,b,n){if(this._active.length)for(let d=this._active.length-1;d>=0;d--)this._active[d].put(y,b,n);else this._handlerFb(this._ident,"PUT",(0,u.utf32ToString)(y,b,n))}unhook(y,b=!0){if(this._active.length){let n=!1,d=this._active.length-1,c=!1;if(this._stack.paused&&(d=this._stack.loopPosition-1,n=b,c=this._stack.fallThrough,this._stack.paused=!1),!c&&n===!1){for(;d>=0&&(n=this._active[d].unhook(y),n!==!0);d--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=d,this._stack.fallThrough=!1,n;d--}for(;d>=0;d--)if(n=this._active[d].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=d,this._stack.fallThrough=!0,n}else this._handlerFb(this._ident,"UNHOOK",y);this._active=g,this._ident=0}};const m=new f.Params;m.addParam(0),r.DcsHandler=class{constructor(y){this._handler=y,this._data="",this._params=m,this._hitLimit=!1}hook(y){this._params=y.length>1||y.params[0]?y.clone():m,this._data="",this._hitLimit=!1}put(y,b,n){this._hitLimit||(this._data+=(0,u.utf32ToString)(y,b,n),this._data.length>l.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(y){let b=!1;if(this._hitLimit)b=!1;else if(y&&(b=this._handler(this._data,this._params),b instanceof Promise))return b.then((n=>(this._params=m,this._data="",this._hitLimit=!1,n)));return this._params=m,this._data="",this._hitLimit=!1,b}}},2015:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.EscapeSequenceParser=r.VT500_TRANSITION_TABLE=r.TransitionTable=void 0;const u=o(844),f=o(8742),l=o(6242),g=o(6351);class m{constructor(d){this.table=new Uint8Array(d)}setDefault(d,c){this.table.fill(d<<4|c)}add(d,c,h,_){this.table[c<<8|d]=h<<4|_}addMany(d,c,h,_){for(let S=0;S<d.length;S++)this.table[c<<8|d[S]]=h<<4|_}}r.TransitionTable=m;const y=160;r.VT500_TRANSITION_TABLE=(function(){const n=new m(4095),d=Array.apply(null,Array(256)).map(((E,x)=>x)),c=(E,x)=>d.slice(E,x),h=c(32,127),_=c(0,24);_.push(25),_.push.apply(_,c(28,32));const S=c(0,14);let k;for(k in n.setDefault(1,0),n.addMany(h,0,2,0),S)n.addMany([24,26,153,154],k,3,0),n.addMany(c(128,144),k,3,0),n.addMany(c(144,152),k,3,0),n.add(156,k,0,0),n.add(27,k,11,1),n.add(157,k,4,8),n.addMany([152,158,159],k,0,7),n.add(155,k,11,3),n.add(144,k,11,9);return n.addMany(_,0,3,0),n.addMany(_,1,3,1),n.add(127,1,0,1),n.addMany(_,8,0,8),n.addMany(_,3,3,3),n.add(127,3,0,3),n.addMany(_,4,3,4),n.add(127,4,0,4),n.addMany(_,6,3,6),n.addMany(_,5,3,5),n.add(127,5,0,5),n.addMany(_,2,3,2),n.add(127,2,0,2),n.add(93,1,4,8),n.addMany(h,8,5,8),n.add(127,8,5,8),n.addMany([156,27,24,26,7],8,6,0),n.addMany(c(28,32),8,0,8),n.addMany([88,94,95],1,0,7),n.addMany(h,7,0,7),n.addMany(_,7,0,7),n.add(156,7,0,0),n.add(127,7,0,7),n.add(91,1,11,3),n.addMany(c(64,127),3,7,0),n.addMany(c(48,60),3,8,4),n.addMany([60,61,62,63],3,9,4),n.addMany(c(48,60),4,8,4),n.addMany(c(64,127),4,7,0),n.addMany([60,61,62,63],4,0,6),n.addMany(c(32,64),6,0,6),n.add(127,6,0,6),n.addMany(c(64,127),6,0,0),n.addMany(c(32,48),3,9,5),n.addMany(c(32,48),5,9,5),n.addMany(c(48,64),5,0,6),n.addMany(c(64,127),5,7,0),n.addMany(c(32,48),4,9,5),n.addMany(c(32,48),1,9,2),n.addMany(c(32,48),2,9,2),n.addMany(c(48,127),2,10,0),n.addMany(c(48,80),1,10,0),n.addMany(c(81,88),1,10,0),n.addMany([89,90,92],1,10,0),n.addMany(c(96,127),1,10,0),n.add(80,1,11,9),n.addMany(_,9,0,9),n.add(127,9,0,9),n.addMany(c(28,32),9,0,9),n.addMany(c(32,48),9,9,12),n.addMany(c(48,60),9,8,10),n.addMany([60,61,62,63],9,9,10),n.addMany(_,11,0,11),n.addMany(c(32,128),11,0,11),n.addMany(c(28,32),11,0,11),n.addMany(_,10,0,10),n.add(127,10,0,10),n.addMany(c(28,32),10,0,10),n.addMany(c(48,60),10,8,10),n.addMany([60,61,62,63],10,0,11),n.addMany(c(32,48),10,9,12),n.addMany(_,12,0,12),n.add(127,12,0,12),n.addMany(c(28,32),12,0,12),n.addMany(c(32,48),12,9,12),n.addMany(c(48,64),12,0,11),n.addMany(c(64,127),12,12,13),n.addMany(c(64,127),10,12,13),n.addMany(c(64,127),9,12,13),n.addMany(_,13,13,13),n.addMany(h,13,13,13),n.add(127,13,0,13),n.addMany([27,156,24,26],13,14,0),n.add(y,0,2,0),n.add(y,8,5,8),n.add(y,6,0,6),n.add(y,11,0,11),n.add(y,13,13,13),n})();class b extends u.Disposable{constructor(d=r.VT500_TRANSITION_TABLE){super(),this._transitions=d,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new f.Params,this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._printHandlerFb=(c,h,_)=>{},this._executeHandlerFb=c=>{},this._csiHandlerFb=(c,h)=>{},this._escHandlerFb=c=>{},this._errorHandlerFb=c=>c,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,u.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new l.OscParser),this._dcsParser=this.register(new g.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(d,c=[64,126]){let h=0;if(d.prefix){if(d.prefix.length>1)throw new Error("only one byte as prefix supported");if(h=d.prefix.charCodeAt(0),h&&60>h||h>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(d.intermediates){if(d.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let S=0;S<d.intermediates.length;++S){const k=d.intermediates.charCodeAt(S);if(32>k||k>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");h<<=8,h|=k}}if(d.final.length!==1)throw new Error("final must be a single byte");const _=d.final.charCodeAt(0);if(c[0]>_||_>c[1])throw new Error(`final must be in range ${c[0]} .. ${c[1]}`);return h<<=8,h|=_,h}identToString(d){const c=[];for(;d;)c.push(String.fromCharCode(255&d)),d>>=8;return c.reverse().join("")}setPrintHandler(d){this._printHandler=d}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(d,c){const h=this._identifier(d,[48,126]);this._escHandlers[h]===void 0&&(this._escHandlers[h]=[]);const _=this._escHandlers[h];return _.push(c),{dispose:()=>{const S=_.indexOf(c);S!==-1&&_.splice(S,1)}}}clearEscHandler(d){this._escHandlers[this._identifier(d,[48,126])]&&delete this._escHandlers[this._identifier(d,[48,126])]}setEscHandlerFallback(d){this._escHandlerFb=d}setExecuteHandler(d,c){this._executeHandlers[d.charCodeAt(0)]=c}clearExecuteHandler(d){this._executeHandlers[d.charCodeAt(0)]&&delete this._executeHandlers[d.charCodeAt(0)]}setExecuteHandlerFallback(d){this._executeHandlerFb=d}registerCsiHandler(d,c){const h=this._identifier(d);this._csiHandlers[h]===void 0&&(this._csiHandlers[h]=[]);const _=this._csiHandlers[h];return _.push(c),{dispose:()=>{const S=_.indexOf(c);S!==-1&&_.splice(S,1)}}}clearCsiHandler(d){this._csiHandlers[this._identifier(d)]&&delete this._csiHandlers[this._identifier(d)]}setCsiHandlerFallback(d){this._csiHandlerFb=d}registerDcsHandler(d,c){return this._dcsParser.registerHandler(this._identifier(d),c)}clearDcsHandler(d){this._dcsParser.clearHandler(this._identifier(d))}setDcsHandlerFallback(d){this._dcsParser.setHandlerFallback(d)}registerOscHandler(d,c){return this._oscParser.registerHandler(d,c)}clearOscHandler(d){this._oscParser.clearHandler(d)}setOscHandlerFallback(d){this._oscParser.setHandlerFallback(d)}setErrorHandler(d){this._errorHandler=d}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.precedingCodepoint=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(d,c,h,_,S){this._parseStack.state=d,this._parseStack.handlers=c,this._parseStack.handlerPos=h,this._parseStack.transition=_,this._parseStack.chunkPos=S}parse(d,c,h){let _,S=0,k=0,E=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,E=this._parseStack.chunkPos+1;else{if(h===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const x=this._parseStack.handlers;let C=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(h===!1&&C>-1){for(;C>=0&&(_=x[C](this._params),_!==!0);C--)if(_ instanceof Promise)return this._parseStack.handlerPos=C,_}this._parseStack.handlers=[];break;case 4:if(h===!1&&C>-1){for(;C>=0&&(_=x[C](),_!==!0);C--)if(_ instanceof Promise)return this._parseStack.handlerPos=C,_}this._parseStack.handlers=[];break;case 6:if(S=d[this._parseStack.chunkPos],_=this._dcsParser.unhook(S!==24&&S!==26,h),_)return _;S===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(S=d[this._parseStack.chunkPos],_=this._oscParser.end(S!==24&&S!==26,h),_)return _;S===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,E=this._parseStack.chunkPos+1,this.precedingCodepoint=0,this.currentState=15&this._parseStack.transition}for(let x=E;x<c;++x){switch(S=d[x],k=this._transitions.table[this.currentState<<8|(S<160?S:y)],k>>4){case 2:for(let P=x+1;;++P){if(P>=c||(S=d[P])<32||S>126&&S<y){this._printHandler(d,x,P),x=P-1;break}if(++P>=c||(S=d[P])<32||S>126&&S<y){this._printHandler(d,x,P),x=P-1;break}if(++P>=c||(S=d[P])<32||S>126&&S<y){this._printHandler(d,x,P),x=P-1;break}if(++P>=c||(S=d[P])<32||S>126&&S<y){this._printHandler(d,x,P),x=P-1;break}}break;case 3:this._executeHandlers[S]?this._executeHandlers[S]():this._executeHandlerFb(S),this.precedingCodepoint=0;break;case 0:break;case 1:if(this._errorHandler({position:x,code:S,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const C=this._csiHandlers[this._collect<<8|S];let N=C?C.length-1:-1;for(;N>=0&&(_=C[N](this._params),_!==!0);N--)if(_ instanceof Promise)return this._preserveStack(3,C,N,k,x),_;N<0&&this._csiHandlerFb(this._collect<<8|S,this._params),this.precedingCodepoint=0;break;case 8:do switch(S){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(S-48)}while(++x<c&&(S=d[x])>47&&S<60);x--;break;case 9:this._collect<<=8,this._collect|=S;break;case 10:const L=this._escHandlers[this._collect<<8|S];let R=L?L.length-1:-1;for(;R>=0&&(_=L[R](),_!==!0);R--)if(_ instanceof Promise)return this._preserveStack(4,L,R,k,x),_;R<0&&this._escHandlerFb(this._collect<<8|S),this.precedingCodepoint=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|S,this._params);break;case 13:for(let P=x+1;;++P)if(P>=c||(S=d[P])===24||S===26||S===27||S>127&&S<y){this._dcsParser.put(d,x,P),x=P-1;break}break;case 14:if(_=this._dcsParser.unhook(S!==24&&S!==26),_)return this._preserveStack(6,[],0,k,x),_;S===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0;break;case 4:this._oscParser.start();break;case 5:for(let P=x+1;;P++)if(P>=c||(S=d[P])<32||S>127&&S<y){this._oscParser.put(d,x,P),x=P-1;break}break;case 6:if(_=this._oscParser.end(S!==24&&S!==26),_)return this._preserveStack(5,[],0,k,x),_;S===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0}this.currentState=15&k}}}r.EscapeSequenceParser=b},6242:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.OscHandler=r.OscParser=void 0;const u=o(5770),f=o(482),l=[];r.OscParser=class{constructor(){this._state=0,this._active=l,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(g,m){this._handlers[g]===void 0&&(this._handlers[g]=[]);const y=this._handlers[g];return y.push(m),{dispose:()=>{const b=y.indexOf(m);b!==-1&&y.splice(b,1)}}}clearHandler(g){this._handlers[g]&&delete this._handlers[g]}setHandlerFallback(g){this._handlerFb=g}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=l}reset(){if(this._state===2)for(let g=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;g>=0;--g)this._active[g].end(!1);this._stack.paused=!1,this._active=l,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||l,this._active.length)for(let g=this._active.length-1;g>=0;g--)this._active[g].start();else this._handlerFb(this._id,"START")}_put(g,m,y){if(this._active.length)for(let b=this._active.length-1;b>=0;b--)this._active[b].put(g,m,y);else this._handlerFb(this._id,"PUT",(0,f.utf32ToString)(g,m,y))}start(){this.reset(),this._state=1}put(g,m,y){if(this._state!==3){if(this._state===1)for(;m<y;){const b=g[m++];if(b===59){this._state=2,this._start();break}if(b<48||57<b)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+b-48}this._state===2&&y-m>0&&this._put(g,m,y)}}end(g,m=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let y=!1,b=this._active.length-1,n=!1;if(this._stack.paused&&(b=this._stack.loopPosition-1,y=m,n=this._stack.fallThrough,this._stack.paused=!1),!n&&y===!1){for(;b>=0&&(y=this._active[b].end(g),y!==!0);b--)if(y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=b,this._stack.fallThrough=!1,y;b--}for(;b>=0;b--)if(y=this._active[b].end(!1),y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=b,this._stack.fallThrough=!0,y}else this._handlerFb(this._id,"END",g);this._active=l,this._id=-1,this._state=0}}},r.OscHandler=class{constructor(g){this._handler=g,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(g,m,y){this._hitLimit||(this._data+=(0,f.utf32ToString)(g,m,y),this._data.length>u.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(g){let m=!1;if(this._hitLimit)m=!1;else if(g&&(m=this._handler(this._data),m instanceof Promise))return m.then((y=>(this._data="",this._hitLimit=!1,y)));return this._data="",this._hitLimit=!1,m}}},8742:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Params=void 0;const o=2147483647;class u{static fromArray(l){const g=new u;if(!l.length)return g;for(let m=Array.isArray(l[0])?1:0;m<l.length;++m){const y=l[m];if(Array.isArray(y))for(let b=0;b<y.length;++b)g.addSubParam(y[b]);else g.addParam(y)}return g}constructor(l=32,g=32){if(this.maxLength=l,this.maxSubParamsLength=g,g>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(l),this.length=0,this._subParams=new Int32Array(g),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(l),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const l=new u(this.maxLength,this.maxSubParamsLength);return l.params.set(this.params),l.length=this.length,l._subParams.set(this._subParams),l._subParamsLength=this._subParamsLength,l._subParamsIdx.set(this._subParamsIdx),l._rejectDigits=this._rejectDigits,l._rejectSubDigits=this._rejectSubDigits,l._digitIsSub=this._digitIsSub,l}toArray(){const l=[];for(let g=0;g<this.length;++g){l.push(this.params[g]);const m=this._subParamsIdx[g]>>8,y=255&this._subParamsIdx[g];y-m>0&&l.push(Array.prototype.slice.call(this._subParams,m,y))}return l}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(l){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(l<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=l>o?o:l}}addSubParam(l){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(l<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=l>o?o:l,this._subParamsIdx[this.length-1]++}}hasSubParams(l){return(255&this._subParamsIdx[l])-(this._subParamsIdx[l]>>8)>0}getSubParams(l){const g=this._subParamsIdx[l]>>8,m=255&this._subParamsIdx[l];return m-g>0?this._subParams.subarray(g,m):null}getSubParamsAll(){const l={};for(let g=0;g<this.length;++g){const m=this._subParamsIdx[g]>>8,y=255&this._subParamsIdx[g];y-m>0&&(l[g]=this._subParams.slice(m,y))}return l}addDigit(l){let g;if(this._rejectDigits||!(g=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const m=this._digitIsSub?this._subParams:this.params,y=m[g-1];m[g-1]=~y?Math.min(10*y+l,o):l}}r.Params=u},5741:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.AddonManager=void 0,r.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let o=this._addons.length-1;o>=0;o--)this._addons[o].instance.dispose()}loadAddon(o,u){const f={instance:u,dispose:u.dispose,isDisposed:!1};this._addons.push(f),u.dispose=()=>this._wrappedAddonDispose(f),u.activate(o)}_wrappedAddonDispose(o){if(o.isDisposed)return;let u=-1;for(let f=0;f<this._addons.length;f++)if(this._addons[f]===o){u=f;break}if(u===-1)throw new Error("Could not dispose an addon that has not been loaded");o.isDisposed=!0,o.dispose.apply(o.instance),this._addons.splice(u,1)}}},8771:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferApiView=void 0;const u=o(3785),f=o(511);r.BufferApiView=class{constructor(l,g){this._buffer=l,this.type=g}init(l){return this._buffer=l,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(l){const g=this._buffer.lines.get(l);if(g)return new u.BufferLineApiView(g)}getNullCell(){return new f.CellData}}},3785:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferLineApiView=void 0;const u=o(511);r.BufferLineApiView=class{constructor(f){this._line=f}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(f,l){if(!(f<0||f>=this._line.length))return l?(this._line.loadCell(f,l),l):this._line.loadCell(f,new u.CellData)}translateToString(f,l,g){return this._line.translateToString(f,l,g)}}},8285:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferNamespaceApi=void 0;const u=o(8771),f=o(8460),l=o(844);class g extends l.Disposable{constructor(y){super(),this._core=y,this._onBufferChange=this.register(new f.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new u.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new u.BufferApiView(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)}}r.BufferNamespaceApi=g},7975:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ParserApi=void 0,r.ParserApi=class{constructor(o){this._core=o}registerCsiHandler(o,u){return this._core.registerCsiHandler(o,(f=>u(f.toArray())))}addCsiHandler(o,u){return this.registerCsiHandler(o,u)}registerDcsHandler(o,u){return this._core.registerDcsHandler(o,((f,l)=>u(f,l.toArray())))}addDcsHandler(o,u){return this.registerDcsHandler(o,u)}registerEscHandler(o,u){return this._core.registerEscHandler(o,u)}addEscHandler(o,u){return this.registerEscHandler(o,u)}registerOscHandler(o,u){return this._core.registerOscHandler(o,u)}addOscHandler(o,u){return this.registerOscHandler(o,u)}}},7090:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.UnicodeApi=void 0,r.UnicodeApi=class{constructor(o){this._core=o}register(o){this._core.unicodeService.register(o)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(o){this._core.unicodeService.activeVersion=o}}},744:function(w,r,o){var u=this&&this.__decorate||function(n,d,c,h){var _,S=arguments.length,k=S<3?d:h===null?h=Object.getOwnPropertyDescriptor(d,c):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(n,d,c,h);else for(var E=n.length-1;E>=0;E--)(_=n[E])&&(k=(S<3?_(k):S>3?_(d,c,k):_(d,c))||k);return S>3&&k&&Object.defineProperty(d,c,k),k},f=this&&this.__param||function(n,d){return function(c,h){d(c,h,n)}};Object.defineProperty(r,"__esModule",{value:!0}),r.BufferService=r.MINIMUM_ROWS=r.MINIMUM_COLS=void 0;const l=o(8460),g=o(844),m=o(5295),y=o(2585);r.MINIMUM_COLS=2,r.MINIMUM_ROWS=1;let b=r.BufferService=class extends g.Disposable{get buffer(){return this.buffers.active}constructor(n){super(),this.isUserScrolling=!1,this._onResize=this.register(new l.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new l.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(n.rawOptions.cols||0,r.MINIMUM_COLS),this.rows=Math.max(n.rawOptions.rows||0,r.MINIMUM_ROWS),this.buffers=this.register(new m.BufferSet(n,this))}resize(n,d){this.cols=n,this.rows=d,this.buffers.resize(n,d),this._onResize.fire({cols:n,rows:d})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(n,d=!1){const c=this.buffer;let h;h=this._cachedBlankLine,h&&h.length===this.cols&&h.getFg(0)===n.fg&&h.getBg(0)===n.bg||(h=c.getBlankLine(n,d),this._cachedBlankLine=h),h.isWrapped=d;const _=c.ybase+c.scrollTop,S=c.ybase+c.scrollBottom;if(c.scrollTop===0){const k=c.lines.isFull;S===c.lines.length-1?k?c.lines.recycle().copyFrom(h):c.lines.push(h.clone()):c.lines.splice(S+1,0,h.clone()),k?this.isUserScrolling&&(c.ydisp=Math.max(c.ydisp-1,0)):(c.ybase++,this.isUserScrolling||c.ydisp++)}else{const k=S-_+1;c.lines.shiftElements(_+1,k-1,-1),c.lines.set(S,h.clone())}this.isUserScrolling||(c.ydisp=c.ybase),this._onScroll.fire(c.ydisp)}scrollLines(n,d,c){const h=this.buffer;if(n<0){if(h.ydisp===0)return;this.isUserScrolling=!0}else n+h.ydisp>=h.ybase&&(this.isUserScrolling=!1);const _=h.ydisp;h.ydisp=Math.max(Math.min(h.ydisp+n,h.ybase),0),_!==h.ydisp&&(d||this._onScroll.fire(h.ydisp))}};r.BufferService=b=u([f(0,y.IOptionsService)],b)},7994:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CharsetService=void 0,r.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(o){this.glevel=o,this.charset=this._charsets[o]}setgCharset(o,u){this._charsets[o]=u,this.glevel===o&&(this.charset=u)}}},1753:function(w,r,o){var u=this&&this.__decorate||function(h,_,S,k){var E,x=arguments.length,C=x<3?_:k===null?k=Object.getOwnPropertyDescriptor(_,S):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(h,_,S,k);else for(var N=h.length-1;N>=0;N--)(E=h[N])&&(C=(x<3?E(C):x>3?E(_,S,C):E(_,S))||C);return x>3&&C&&Object.defineProperty(_,S,C),C},f=this&&this.__param||function(h,_){return function(S,k){_(S,k,h)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CoreMouseService=void 0;const l=o(2585),g=o(8460),m=o(844),y={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:h=>h.button!==4&&h.action===1&&(h.ctrl=!1,h.alt=!1,h.shift=!1,!0)},VT200:{events:19,restrict:h=>h.action!==32},DRAG:{events:23,restrict:h=>h.action!==32||h.button!==3},ANY:{events:31,restrict:h=>!0}};function b(h,_){let S=(h.ctrl?16:0)|(h.shift?4:0)|(h.alt?8:0);return h.button===4?(S|=64,S|=h.action):(S|=3&h.button,4&h.button&&(S|=64),8&h.button&&(S|=128),h.action===32?S|=32:h.action!==0||_||(S|=3)),S}const n=String.fromCharCode,d={DEFAULT:h=>{const _=[b(h,!1)+32,h.col+32,h.row+32];return _[0]>255||_[1]>255||_[2]>255?"":`\x1B[M${n(_[0])}${n(_[1])}${n(_[2])}`},SGR:h=>{const _=h.action===0&&h.button!==4?"m":"M";return`\x1B[<${b(h,!0)};${h.col};${h.row}${_}`},SGR_PIXELS:h=>{const _=h.action===0&&h.button!==4?"m":"M";return`\x1B[<${b(h,!0)};${h.x};${h.y}${_}`}};let c=r.CoreMouseService=class extends m.Disposable{constructor(h,_){super(),this._bufferService=h,this._coreService=_,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new g.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const S of Object.keys(y))this.addProtocol(S,y[S]);for(const S of Object.keys(d))this.addEncoding(S,d[S]);this.reset()}addProtocol(h,_){this._protocols[h]=_}addEncoding(h,_){this._encodings[h]=_}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(h){if(!this._protocols[h])throw new Error(`unknown protocol "${h}"`);this._activeProtocol=h,this._onProtocolChange.fire(this._protocols[h].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(h){if(!this._encodings[h])throw new Error(`unknown encoding "${h}"`);this._activeEncoding=h}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(h){if(h.col<0||h.col>=this._bufferService.cols||h.row<0||h.row>=this._bufferService.rows||h.button===4&&h.action===32||h.button===3&&h.action!==32||h.button!==4&&(h.action===2||h.action===3)||(h.col++,h.row++,h.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,h,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(h))return!1;const _=this._encodings[this._activeEncoding](h);return _&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(_):this._coreService.triggerDataEvent(_,!0)),this._lastEvent=h,!0}explainEvents(h){return{down:!!(1&h),up:!!(2&h),drag:!!(4&h),move:!!(8&h),wheel:!!(16&h)}}_equalEvents(h,_,S){if(S){if(h.x!==_.x||h.y!==_.y)return!1}else if(h.col!==_.col||h.row!==_.row)return!1;return h.button===_.button&&h.action===_.action&&h.ctrl===_.ctrl&&h.alt===_.alt&&h.shift===_.shift}};r.CoreMouseService=c=u([f(0,l.IBufferService),f(1,l.ICoreService)],c)},6975:function(w,r,o){var u=this&&this.__decorate||function(c,h,_,S){var k,E=arguments.length,x=E<3?h:S===null?S=Object.getOwnPropertyDescriptor(h,_):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")x=Reflect.decorate(c,h,_,S);else for(var C=c.length-1;C>=0;C--)(k=c[C])&&(x=(E<3?k(x):E>3?k(h,_,x):k(h,_))||x);return E>3&&x&&Object.defineProperty(h,_,x),x},f=this&&this.__param||function(c,h){return function(_,S){h(_,S,c)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CoreService=void 0;const l=o(1439),g=o(8460),m=o(844),y=o(2585),b=Object.freeze({insertMode:!1}),n=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let d=r.CoreService=class extends m.Disposable{constructor(c,h,_){super(),this._bufferService=c,this._logService=h,this._optionsService=_,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new g.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new g.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new g.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new g.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,l.clone)(b),this.decPrivateModes=(0,l.clone)(n)}reset(){this.modes=(0,l.clone)(b),this.decPrivateModes=(0,l.clone)(n)}triggerDataEvent(c,h=!1){if(this._optionsService.rawOptions.disableStdin)return;const _=this._bufferService.buffer;h&&this._optionsService.rawOptions.scrollOnUserInput&&_.ybase!==_.ydisp&&this._onRequestScrollToBottom.fire(),h&&this._onUserInput.fire(),this._logService.debug(`sending data "${c}"`,(()=>c.split("").map((S=>S.charCodeAt(0))))),this._onData.fire(c)}triggerBinaryEvent(c){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${c}"`,(()=>c.split("").map((h=>h.charCodeAt(0))))),this._onBinary.fire(c))}};r.CoreService=d=u([f(0,y.IBufferService),f(1,y.ILogService),f(2,y.IOptionsService)],d)},9074:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.DecorationService=void 0;const u=o(8055),f=o(8460),l=o(844),g=o(6106);let m=0,y=0;class b extends l.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new g.SortedList((c=>c?.marker.line)),this._onDecorationRegistered=this.register(new f.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new f.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,l.toDisposable)((()=>this.reset())))}registerDecoration(c){if(c.marker.isDisposed)return;const h=new n(c);if(h){const _=h.marker.onDispose((()=>h.dispose()));h.onDispose((()=>{h&&(this._decorations.delete(h)&&this._onDecorationRemoved.fire(h),_.dispose())})),this._decorations.insert(h),this._onDecorationRegistered.fire(h)}return h}reset(){for(const c of this._decorations.values())c.dispose();this._decorations.clear()}*getDecorationsAtCell(c,h,_){var S,k,E;let x=0,C=0;for(const N of this._decorations.getKeyIterator(h))x=(S=N.options.x)!==null&&S!==void 0?S:0,C=x+((k=N.options.width)!==null&&k!==void 0?k:1),c>=x&&c<C&&(!_||((E=N.options.layer)!==null&&E!==void 0?E:"bottom")===_)&&(yield N)}forEachDecorationAtCell(c,h,_,S){this._decorations.forEachByKey(h,(k=>{var E,x,C;m=(E=k.options.x)!==null&&E!==void 0?E:0,y=m+((x=k.options.width)!==null&&x!==void 0?x:1),c>=m&&c<y&&(!_||((C=k.options.layer)!==null&&C!==void 0?C:"bottom")===_)&&S(k)}))}}r.DecorationService=b;class n extends l.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=u.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=u.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(c){super(),this.options=c,this.onRenderEmitter=this.register(new f.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new f.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=c.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.InstantiationService=r.ServiceCollection=void 0;const u=o(2585),f=o(8343);class l{constructor(...m){this._entries=new Map;for(const[y,b]of m)this.set(y,b)}set(m,y){const b=this._entries.get(m);return this._entries.set(m,y),b}forEach(m){for(const[y,b]of this._entries.entries())m(y,b)}has(m){return this._entries.has(m)}get(m){return this._entries.get(m)}}r.ServiceCollection=l,r.InstantiationService=class{constructor(){this._services=new l,this._services.set(u.IInstantiationService,this)}setService(g,m){this._services.set(g,m)}getService(g){return this._services.get(g)}createInstance(g,...m){const y=(0,f.getServiceDependencies)(g).sort(((d,c)=>d.index-c.index)),b=[];for(const d of y){const c=this._services.get(d.id);if(!c)throw new Error(`[createInstance] ${g.name} depends on UNKNOWN service ${d.id}.`);b.push(c)}const n=y.length>0?y[0].index:m.length;if(m.length!==n)throw new Error(`[createInstance] First service dependency of ${g.name} at position ${n+1} conflicts with ${m.length} static arguments`);return new g(...m,...b)}}},7866:function(w,r,o){var u=this&&this.__decorate||function(n,d,c,h){var _,S=arguments.length,k=S<3?d:h===null?h=Object.getOwnPropertyDescriptor(d,c):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(n,d,c,h);else for(var E=n.length-1;E>=0;E--)(_=n[E])&&(k=(S<3?_(k):S>3?_(d,c,k):_(d,c))||k);return S>3&&k&&Object.defineProperty(d,c,k),k},f=this&&this.__param||function(n,d){return function(c,h){d(c,h,n)}};Object.defineProperty(r,"__esModule",{value:!0}),r.traceCall=r.setTraceLogger=r.LogService=void 0;const l=o(844),g=o(2585),m={trace:g.LogLevelEnum.TRACE,debug:g.LogLevelEnum.DEBUG,info:g.LogLevelEnum.INFO,warn:g.LogLevelEnum.WARN,error:g.LogLevelEnum.ERROR,off:g.LogLevelEnum.OFF};let y,b=r.LogService=class extends l.Disposable{get logLevel(){return this._logLevel}constructor(n){super(),this._optionsService=n,this._logLevel=g.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),y=this}_updateLogLevel(){this._logLevel=m[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(n){for(let d=0;d<n.length;d++)typeof n[d]=="function"&&(n[d]=n[d]())}_log(n,d,c){this._evalLazyOptionalParams(c),n.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+d,...c)}trace(n,...d){var c,h;this._logLevel<=g.LogLevelEnum.TRACE&&this._log((h=(c=this._optionsService.options.logger)===null||c===void 0?void 0:c.trace.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.log,n,d)}debug(n,...d){var c,h;this._logLevel<=g.LogLevelEnum.DEBUG&&this._log((h=(c=this._optionsService.options.logger)===null||c===void 0?void 0:c.debug.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.log,n,d)}info(n,...d){var c,h;this._logLevel<=g.LogLevelEnum.INFO&&this._log((h=(c=this._optionsService.options.logger)===null||c===void 0?void 0:c.info.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.info,n,d)}warn(n,...d){var c,h;this._logLevel<=g.LogLevelEnum.WARN&&this._log((h=(c=this._optionsService.options.logger)===null||c===void 0?void 0:c.warn.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.warn,n,d)}error(n,...d){var c,h;this._logLevel<=g.LogLevelEnum.ERROR&&this._log((h=(c=this._optionsService.options.logger)===null||c===void 0?void 0:c.error.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.error,n,d)}};r.LogService=b=u([f(0,g.IOptionsService)],b),r.setTraceLogger=function(n){y=n},r.traceCall=function(n,d,c){if(typeof c.value!="function")throw new Error("not supported");const h=c.value;c.value=function(..._){if(y.logLevel!==g.LogLevelEnum.TRACE)return h.apply(this,_);y.trace(`GlyphRenderer#${h.name}(${_.map((k=>JSON.stringify(k))).join(", ")})`);const S=h.apply(this,_);return y.trace(`GlyphRenderer#${h.name} return`,S),S}}},7302:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.OptionsService=r.DEFAULT_OPTIONS=void 0;const u=o(8460),f=o(844),l=o(6114);r.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rightClickSelectsWord:l.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const g=["normal","bold","100","200","300","400","500","600","700","800","900"];class m extends f.Disposable{constructor(b){super(),this._onOptionChange=this.register(new u.EventEmitter),this.onOptionChange=this._onOptionChange.event;const n=Object.assign({},r.DEFAULT_OPTIONS);for(const d in b)if(d in n)try{const c=b[d];n[d]=this._sanitizeAndValidateOption(d,c)}catch(c){console.error(c)}this.rawOptions=n,this.options=Object.assign({},n),this._setupOptions()}onSpecificOptionChange(b,n){return this.onOptionChange((d=>{d===b&&n(this.rawOptions[b])}))}onMultipleOptionChange(b,n){return this.onOptionChange((d=>{b.indexOf(d)!==-1&&n()}))}_setupOptions(){const b=d=>{if(!(d in r.DEFAULT_OPTIONS))throw new Error(`No option with key "${d}"`);return this.rawOptions[d]},n=(d,c)=>{if(!(d in r.DEFAULT_OPTIONS))throw new Error(`No option with key "${d}"`);c=this._sanitizeAndValidateOption(d,c),this.rawOptions[d]!==c&&(this.rawOptions[d]=c,this._onOptionChange.fire(d))};for(const d in this.rawOptions){const c={get:b.bind(this,d),set:n.bind(this,d)};Object.defineProperty(this.options,d,c)}}_sanitizeAndValidateOption(b,n){switch(b){case"cursorStyle":if(n||(n=r.DEFAULT_OPTIONS[b]),!(function(d){return d==="block"||d==="underline"||d==="bar"})(n))throw new Error(`"${n}" is not a valid value for ${b}`);break;case"wordSeparator":n||(n=r.DEFAULT_OPTIONS[b]);break;case"fontWeight":case"fontWeightBold":if(typeof n=="number"&&1<=n&&n<=1e3)break;n=g.includes(n)?n:r.DEFAULT_OPTIONS[b];break;case"cursorWidth":n=Math.floor(n);case"lineHeight":case"tabStopWidth":if(n<1)throw new Error(`${b} cannot be less than 1, value: ${n}`);break;case"minimumContrastRatio":n=Math.max(1,Math.min(21,Math.round(10*n)/10));break;case"scrollback":if((n=Math.min(n,4294967295))<0)throw new Error(`${b} cannot be less than 0, value: ${n}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(n<=0)throw new Error(`${b} cannot be less than or equal to 0, value: ${n}`);break;case"rows":case"cols":if(!n&&n!==0)throw new Error(`${b} must be numeric, value: ${n}`);break;case"windowsPty":n=n??{}}return n}}r.OptionsService=m},2660:function(w,r,o){var u=this&&this.__decorate||function(m,y,b,n){var d,c=arguments.length,h=c<3?y:n===null?n=Object.getOwnPropertyDescriptor(y,b):n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")h=Reflect.decorate(m,y,b,n);else for(var _=m.length-1;_>=0;_--)(d=m[_])&&(h=(c<3?d(h):c>3?d(y,b,h):d(y,b))||h);return c>3&&h&&Object.defineProperty(y,b,h),h},f=this&&this.__param||function(m,y){return function(b,n){y(b,n,m)}};Object.defineProperty(r,"__esModule",{value:!0}),r.OscLinkService=void 0;const l=o(2585);let g=r.OscLinkService=class{constructor(m){this._bufferService=m,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(m){const y=this._bufferService.buffer;if(m.id===void 0){const _=y.addMarker(y.ybase+y.y),S={data:m,id:this._nextId++,lines:[_]};return _.onDispose((()=>this._removeMarkerFromLink(S,_))),this._dataByLinkId.set(S.id,S),S.id}const b=m,n=this._getEntryIdKey(b),d=this._entriesWithId.get(n);if(d)return this.addLineToLink(d.id,y.ybase+y.y),d.id;const c=y.addMarker(y.ybase+y.y),h={id:this._nextId++,key:this._getEntryIdKey(b),data:b,lines:[c]};return c.onDispose((()=>this._removeMarkerFromLink(h,c))),this._entriesWithId.set(h.key,h),this._dataByLinkId.set(h.id,h),h.id}addLineToLink(m,y){const b=this._dataByLinkId.get(m);if(b&&b.lines.every((n=>n.line!==y))){const n=this._bufferService.buffer.addMarker(y);b.lines.push(n),n.onDispose((()=>this._removeMarkerFromLink(b,n)))}}getLinkData(m){var y;return(y=this._dataByLinkId.get(m))===null||y===void 0?void 0:y.data}_getEntryIdKey(m){return`${m.id};;${m.uri}`}_removeMarkerFromLink(m,y){const b=m.lines.indexOf(y);b!==-1&&(m.lines.splice(b,1),m.lines.length===0&&(m.data.id!==void 0&&this._entriesWithId.delete(m.key),this._dataByLinkId.delete(m.id)))}};r.OscLinkService=g=u([f(0,l.IBufferService)],g)},8343:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.createDecorator=r.getServiceDependencies=r.serviceRegistry=void 0;const o="di$target",u="di$dependencies";r.serviceRegistry=new Map,r.getServiceDependencies=function(f){return f[u]||[]},r.createDecorator=function(f){if(r.serviceRegistry.has(f))return r.serviceRegistry.get(f);const l=function(g,m,y){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(b,n,d){n[o]===n?n[u].push({id:b,index:d}):(n[u]=[{id:b,index:d}],n[o]=n)})(l,g,y)};return l.toString=()=>f,r.serviceRegistry.set(f,l),l}},2585:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.IDecorationService=r.IUnicodeService=r.IOscLinkService=r.IOptionsService=r.ILogService=r.LogLevelEnum=r.IInstantiationService=r.ICharsetService=r.ICoreService=r.ICoreMouseService=r.IBufferService=void 0;const u=o(8343);var f;r.IBufferService=(0,u.createDecorator)("BufferService"),r.ICoreMouseService=(0,u.createDecorator)("CoreMouseService"),r.ICoreService=(0,u.createDecorator)("CoreService"),r.ICharsetService=(0,u.createDecorator)("CharsetService"),r.IInstantiationService=(0,u.createDecorator)("InstantiationService"),(function(l){l[l.TRACE=0]="TRACE",l[l.DEBUG=1]="DEBUG",l[l.INFO=2]="INFO",l[l.WARN=3]="WARN",l[l.ERROR=4]="ERROR",l[l.OFF=5]="OFF"})(f||(r.LogLevelEnum=f={})),r.ILogService=(0,u.createDecorator)("LogService"),r.IOptionsService=(0,u.createDecorator)("OptionsService"),r.IOscLinkService=(0,u.createDecorator)("OscLinkService"),r.IUnicodeService=(0,u.createDecorator)("UnicodeService"),r.IDecorationService=(0,u.createDecorator)("DecorationService")},1480:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.UnicodeService=void 0;const u=o(8460),f=o(225);r.UnicodeService=class{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new u.EventEmitter,this.onChange=this._onChange.event;const l=new f.UnicodeV6;this.register(l),this._active=l.version,this._activeProvider=l}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(l){if(!this._providers[l])throw new Error(`unknown Unicode version "${l}"`);this._active=l,this._activeProvider=this._providers[l],this._onChange.fire(l)}register(l){this._providers[l.version]=l}wcwidth(l){return this._activeProvider.wcwidth(l)}getStringCellWidth(l){let g=0;const m=l.length;for(let y=0;y<m;++y){let b=l.charCodeAt(y);if(55296<=b&&b<=56319){if(++y>=m)return g+this.wcwidth(b);const n=l.charCodeAt(y);56320<=n&&n<=57343?b=1024*(b-55296)+n-56320+65536:g+=this.wcwidth(n)}g+=this.wcwidth(b)}return g}}}},a={};function p(w){var r=a[w];if(r!==void 0)return r.exports;var o=a[w]={exports:{}};return s[w].call(o.exports,o,o.exports,p),o.exports}var v={};return(()=>{var w=v;Object.defineProperty(w,"__esModule",{value:!0}),w.Terminal=void 0;const r=p(9042),o=p(3236),u=p(844),f=p(5741),l=p(8285),g=p(7975),m=p(7090),y=["cols","rows"];class b extends u.Disposable{constructor(d){super(),this._core=this.register(new o.Terminal(d)),this._addonManager=this.register(new f.AddonManager),this._publicOptions=Object.assign({},this._core.options);const c=_=>this._core.options[_],h=(_,S)=>{this._checkReadonlyOptions(_),this._core.options[_]=S};for(const _ in this._core.options){const S={get:c.bind(this,_),set:h.bind(this,_)};Object.defineProperty(this._publicOptions,_,S)}}_checkReadonlyOptions(d){if(y.includes(d))throw new Error(`Option "${d}" 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 g.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new m.UnicodeApi(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 l.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const d=this._core.coreService.decPrivateModes;let c="none";switch(this._core.coreMouseService.activeProtocol){case"X10":c="x10";break;case"VT200":c="vt200";break;case"DRAG":c="drag";break;case"ANY":c="any"}return{applicationCursorKeysMode:d.applicationCursorKeys,applicationKeypadMode:d.applicationKeypad,bracketedPasteMode:d.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:c,originMode:d.origin,reverseWraparoundMode:d.reverseWraparound,sendFocusMode:d.sendFocus,wraparoundMode:d.wraparound}}get options(){return this._publicOptions}set options(d){for(const c in d)this._publicOptions[c]=d[c]}blur(){this._core.blur()}focus(){this._core.focus()}resize(d,c){this._verifyIntegers(d,c),this._core.resize(d,c)}open(d){this._core.open(d)}attachCustomKeyEventHandler(d){this._core.attachCustomKeyEventHandler(d)}registerLinkProvider(d){return this._core.registerLinkProvider(d)}registerCharacterJoiner(d){return this._checkProposedApi(),this._core.registerCharacterJoiner(d)}deregisterCharacterJoiner(d){this._checkProposedApi(),this._core.deregisterCharacterJoiner(d)}registerMarker(d=0){return this._verifyIntegers(d),this._core.registerMarker(d)}registerDecoration(d){var c,h,_;return this._checkProposedApi(),this._verifyPositiveIntegers((c=d.x)!==null&&c!==void 0?c:0,(h=d.width)!==null&&h!==void 0?h:0,(_=d.height)!==null&&_!==void 0?_:0),this._core.registerDecoration(d)}hasSelection(){return this._core.hasSelection()}select(d,c,h){this._verifyIntegers(d,c,h),this._core.select(d,c,h)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(d,c){this._verifyIntegers(d,c),this._core.selectLines(d,c)}dispose(){super.dispose()}scrollLines(d){this._verifyIntegers(d),this._core.scrollLines(d)}scrollPages(d){this._verifyIntegers(d),this._core.scrollPages(d)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(d){this._verifyIntegers(d),this._core.scrollToLine(d)}clear(){this._core.clear()}write(d,c){this._core.write(d,c)}writeln(d,c){this._core.write(d),this._core.write(`\r
|
|
16
|
+
`,c)}paste(d){this._core.paste(d)}refresh(d,c){this._verifyIntegers(d,c),this._core.refresh(d,c)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(d){this._addonManager.loadAddon(this,d)}static get strings(){return r}_verifyIntegers(...d){for(const c of d)if(c===1/0||isNaN(c)||c%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...d){for(const c of d)if(c&&(c===1/0||isNaN(c)||c%1!=0||c<0))throw new Error("This API only accepts positive integers")}}w.Terminal=b})(),v})()))})(us)),us.exports}var ec=Jl();var tc=2,sc=1,rc=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let i=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(i._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let i=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,s=window.getComputedStyle(this._terminal.element.parentElement),a=parseInt(s.getPropertyValue("height")),p=Math.max(0,parseInt(s.getPropertyValue("width"))),v=window.getComputedStyle(this._terminal.element),w={top:parseInt(v.getPropertyValue("padding-top")),bottom:parseInt(v.getPropertyValue("padding-bottom")),right:parseInt(v.getPropertyValue("padding-right")),left:parseInt(v.getPropertyValue("padding-left"))},r=w.top+w.bottom,o=w.right+w.left,u=a-r,f=p-o-i;return{cols:Math.max(tc,Math.floor(f/e.css.cell.width)),rows:Math.max(sc,Math.floor(u/e.css.cell.height))}}};function ic(e={}){const{cwd:i,cols:s,rows:a,onOutput:p,onExit:v}=e,[w,r]=A.useState(null),[o,u]=A.useState(()=>be.isConnected()),[f,l]=A.useState(!1),[g,m]=A.useState(!1),[y,b]=A.useState(!1),n=A.useRef({onOutput:p,onExit:v});n.current={onOutput:p,onExit:v};const d=A.useRef(null);d.current=w,A.useEffect(()=>{if(!w)return;const k=be.getSocket(),E=()=>{u(!0),l(!1),r(null),b(!0)},x=()=>{u(!1),l(!1)},C=P=>{P.terminalId===w&&n.current.onOutput?.(P.data)},N=P=>{P.terminalId===w&&(l(!1),n.current.onExit?.(P.exitCode),r(null))},L=P=>{P.terminalId===w&&l(!0)},R=P=>{P.terminalId===w&&l(!1)};return k.on("connect",E),k.on("disconnect",x),k.on(Le.TERMINAL_STDOUT,C),k.on(Le.TERMINAL_EXIT,N),k.on(Le.TERMINAL_SUBSCRIBED,L),k.on(Le.TERMINAL_UNSUBSCRIBED,R),u(k.connected),k.connected&&k.emit(mt.SUBSCRIBE,{topic:"terminal",id:w},P=>{P.success&&l(!0)}),()=>{k.off("connect",E),k.off("disconnect",x),k.off(Le.TERMINAL_STDOUT,C),k.off(Le.TERMINAL_EXIT,N),k.off(Le.TERMINAL_SUBSCRIBED,L),k.off(Le.TERMINAL_UNSUBSCRIBED,R),k.emit(mt.UNSUBSCRIBE,{topic:"terminal",id:w})}},[w]);const c=A.useCallback(async()=>{const k=be.getSocket();if(!k.connected)return null;m(!0);try{const E=await ne.post("/terminals",{socketId:k.id,cwd:i,cols:s,rows:a});return r(E.terminalId),b(!1),E.terminalId}catch(E){return console.error("[useStandaloneTerminal] Failed to create terminal:",E),null}finally{m(!1)}},[i,s,a]),h=A.useCallback(async()=>{const k=d.current;if(k){try{await ne.delete(`/terminals/${k}`)}catch(E){console.error("[useStandaloneTerminal] Failed to destroy terminal:",E)}r(null),l(!1)}},[]),_=A.useCallback(k=>{const E=d.current;if(!E)return;be.getSocket().emit(mt.TERMINAL_INPUT,{terminalId:E,data:k})},[]),S=A.useCallback((k,E)=>{const x=d.current;if(!x)return;be.getSocket().emit(mt.TERMINAL_RESIZE,{terminalId:x,cols:k,rows:E})},[]);return A.useEffect(()=>()=>{const k=d.current;k&&ne.delete(`/terminals/${k}`).catch(()=>{})},[]),{terminalId:w,isConnected:o,isAttached:f,isCreating:g,needsRecreate:y,create:c,destroy:h,sendInput:_,resize:S}}function nc({terminalRef:e,xtermRef:i,fitAddonRef:s,isVisible:a=!0,onResize:p}){const v=A.useRef(null),w=A.useRef(null),r=A.useRef(0),o=A.useCallback(()=>{v.current!=null&&(window.clearTimeout(v.current),v.current=null),w.current!=null&&(window.cancelAnimationFrame(w.current),w.current=null)},[]),u=A.useCallback(()=>{const g=s.current,m=i.current,y=e.current;if(!g||!m||!y||y.clientWidth<=0||y.clientHeight<=0)return!1;try{return g.fit(),m.cols>0&&m.rows>0&&p(m.cols,m.rows),!0}catch{return!1}},[s,p,e,i]),f=A.useCallback((g=6)=>{o();const m=r.current+1;r.current=m;let y=0;const b=()=>{r.current===m&&(w.current=window.requestAnimationFrame(()=>{if(w.current=null,r.current!==m)return;const n=u(),d=y<2;y<g&&(!n||d)&&(y+=1,v.current=window.setTimeout(b,50))}))};b()},[o,u]),l=A.useCallback(()=>{r.current+=1,o()},[o]);return A.useEffect(()=>l,[l]),A.useEffect(()=>{a&&f(8)},[a,f]),A.useEffect(()=>{const g=e.current;if(!g)return;if(typeof ResizeObserver>"u"){f(8);return}const m=new ResizeObserver(()=>{f(4)});return m.observe(g),g.parentElement&&m.observe(g.parentElement),f(8),()=>{m.disconnect()}},[f,e]),{fitNow:u,scheduleFit:f}}const oc=_e.memo(function({cwd:i,isVisible:s=!0,onExit:a,onReady:p}){const v=A.useRef(null),w=A.useRef(null),r=A.useRef(null),o=A.useRef(!1),{terminalId:u,isAttached:f,needsRecreate:l,create:g,sendInput:m,resize:y}=ic({cwd:i,onOutput:A.useCallback(d=>{w.current?.write(d)},[]),onExit:A.useCallback(d=>{w.current?.writeln(`\r
|
|
17
|
+
\x1B[90m[Process exited with code ${d}]\x1B[0m`),a?.(d)},[a])}),{scheduleFit:b}=nc({terminalRef:v,xtermRef:w,fitAddonRef:r,isVisible:s,onResize:y}),n=A.useCallback(d=>{w.current?.paste(d)},[]);return A.useEffect(()=>{s||w.current?.blur()},[s]),A.useEffect(()=>{if(!l)return;const d=w.current;d&&d.writeln(`\r
|
|
18
|
+
\x1B[33m[Terminal disconnected — reconnecting...]\x1B[0m`),g()},[l,g]),A.useLayoutEffect(()=>{if(!v.current)return;const d=new ec.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, 'Courier New', monospace",lineHeight:1.4,theme:Bo(),scrollback:5e3,convertEol:!0}),c=new rc;return d.loadAddon(c),d.open(v.current),w.current=d,r.current=c,b(8),()=>{d.dispose(),w.current=null,r.current=null}},[b]),A.useEffect(()=>{o.current||(o.current=!0,g())},[g]),A.useEffect(()=>{const d=w.current;if(!d||!f)return;const c=d.onData(h=>{m(h)});return()=>c.dispose()},[m,f]),A.useEffect(()=>{f&&(b(4),p?.({sendInput:m,paste:n}))},[f,p,n,b,m]),t.jsxs("div",{className:"relative flex h-full w-full min-h-0 min-w-0 flex-col overflow-hidden bg-terminal",children:[!u&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-terminal-muted-foreground text-xs z-10 bg-terminal",children:"Starting terminal..."}),t.jsx("div",{ref:v,className:"terminal-xterm-host flex-1 min-h-0 min-w-0 w-full overflow-hidden"})]})}),ac=_e.memo(function({commands:i,onSelect:s}){const{t:a}=re();return i.length===0?null:t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-px h-4 bg-terminal-border mx-1 shrink-0"}),t.jsxs(Si,{children:[t.jsxs(yi,{className:"group mx-1 flex shrink-0 items-center gap-1.5 rounded px-2.5 py-1 text-xs font-medium text-terminal-muted-foreground transition-colors hover:bg-terminal-accent hover:text-terminal-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-terminal-muted-foreground data-[state=open]:bg-terminal-accent data-[state=open]:text-terminal-foreground",children:[t.jsx(Uo,{size:12}),t.jsx("span",{children:a("快捷命令")}),t.jsx(Ke,{size:10,className:"transition-transform group-data-[state=open]:rotate-180"})]}),t.jsx(wi,{align:"end",className:"w-72",children:t.jsx("div",{className:"max-h-[240px] overflow-y-auto",children:i.map((p,v)=>t.jsxs(zo,{icon:t.jsx(Oo,{className:"mt-0.5"}),onSelect:()=>s(p.command),className:"items-start",children:[t.jsx("span",{className:"block truncate font-medium text-foreground",children:p.name}),t.jsx("span",{className:"block truncate font-mono text-xs text-muted-foreground",children:p.command})]},v))})})]})]})}),Wi="\x1B",lc="\x07",cc="";function dc(e){const i=e.charCodeAt(0);return i>=64&&i<=126}function Sr(e,i){let s=i;for(;s<e.length;){if(e[s]===lc||e[s]===cc)return s+1;if(e[s]===Wi&&e[s+1]==="\\")return s+2;s+=1}return s}function yr(e,i){let s=i;for(;s<e.length&&!dc(e[s]);)s+=1;return s<e.length?s+1:s}function hc(e){let i="";for(let s=0;s<e.length;){if(e[s]===""){s=yr(e,s+1);continue}if(e[s]===""){s=Sr(e,s+1);continue}if(e[s]!==Wi){i+=e[s],s+=1;continue}const a=e[s+1];if(a==="["){s=yr(e,s+2);continue}if(a==="]"||a==="P"||a==="X"||a==="^"||a==="_"){s=Sr(e,s+2);continue}for(s+=1;s<e.length;){const p=e.charCodeAt(s);if(p<32||p>47)break;s+=1}s<e.length&&(s+=1)}return i}const uc=200,fc=1e3,mc=512*1024;function pc(e){let i=e.reduce((a,p)=>a+p.data.length,0),s=0;for(;e.length-s>fc||i>mc&&e.length-s>1;)i-=e[s].data.length,s+=1;return{entries:s>0?e.slice(s):e,trimmed:s>0}}function gc(e,i){const s=!!e&&e.runtimeInstanceId!==i.runtimeInstanceId,a=s||i.reset,p=a?[]:e?.entries??[],v=new Set(p.map(o=>o.seq)),w=[...p,...i.entries.filter(o=>!v.has(o.seq))].sort((o,u)=>o.seq-u.seq),r=pc(w);return{...i,entries:r.entries,reset:i.reset||s||!a&&(e?.reset??!1),truncated:i.truncated||!a&&(e?.truncated??!1)||r.trimmed}}function Zs(e,i=!0){return Ee({queryKey:ie.workspaceServices.list(e),queryFn:async()=>(await ne.get(`/workspaces/${encodeURIComponent(e)}/services`)).services,enabled:i&&!!e,refetchInterval:i&&e?3e3:!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:"always",refetchOnReconnect:"always"})}function vc(e,i,s,a=!0){const p=Pe(),v=ie.workspaceServices.logs(e,i);return Ee({queryKey:v,queryFn:async()=>{const w=p.getQueryData(v),r=w?Math.max(0,w.nextSeq-1):0,o=w===void 0?s:w.runtimeInstanceId,u=new URLSearchParams({limit:String(uc)});o!==null&&u.set("runtimeInstanceId",o),u.set("afterSeq",String(r));const f=await ne.get(`/workspaces/${encodeURIComponent(e)}/services/${encodeURIComponent(i)}/logs?${u}`);return gc(w,f)},enabled:a&&!!e&&!!i,refetchInterval:w=>w.state.data?.hasMore?250:1e3,refetchIntervalInBackground:!1,refetchOnWindowFocus:"always",refetchOnReconnect:"always"})}const _c=[];function fs(e){return JSON.stringify([e.command,...e.args])}function wr(e,i,s){if(!e)return s;const a=new Date(e);return Number.isNaN(a.getTime())?s:new Intl.DateTimeFormat(i,{dateStyle:"medium",timeStyle:"medium"}).format(a)}function bc(e){switch(e){case"RUNNING":return{label:"Running",dotClassName:"bg-terminal-green"};case"STARTING":return{label:"Starting",dotClassName:"bg-terminal-yellow"};case"STOPPING":return{label:"Stopping",dotClassName:"bg-terminal-yellow"};case"FAILED":return{label:"Failed",dotClassName:"bg-terminal-red"};case"EXITED":return{label:"Exited",dotClassName:"bg-terminal-muted-foreground"};default:return{label:"Stopped",dotClassName:"bg-terminal-bright-black"}}}function Cr({state:e}){const{t:i}=re(),s=bc(e);return t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5 text-xs text-terminal-foreground",children:[t.jsx("span",{className:Q("h-1.5 w-1.5 rounded-full",s.dotClassName),"aria-hidden":"true"}),i(s.label)]})}function xc({message:e,onRetry:i}){const{t:s}=re();return t.jsxs("div",{className:"flex min-h-24 items-center justify-center gap-2 px-4 text-xs text-terminal-foreground",role:"alert",children:[t.jsx(Nt,{size:14,className:"shrink-0 text-terminal-red","aria-hidden":"true"}),t.jsx("span",{children:e}),t.jsx("button",{type:"button",onClick:i,className:"flex h-7 w-7 shrink-0 items-center justify-center rounded text-terminal-muted-foreground transition-colors hover:bg-terminal-accent hover:text-terminal-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-terminal-muted-foreground",title:s("Retry"),"aria-label":s("Retry"),children:t.jsx(_t,{size:13})})]})}function Sc({workspaceId:e,enabled:i=!0}){const{locale:s,t:a}=re(),p=Zs(e,i),v=p.data??_c,[w,r]=A.useState(null),o=v.find(m=>m.name===w)??v[0]??null,u=vc(e,o?.name??"",o?.runtimeInstanceId??null,i&&!!o),f=A.useMemo(()=>hc(u.data?.entries.map(m=>m.data).join("")??""),[u.data?.entries]),l=A.useRef(null),g=A.useRef(!0);return A.useEffect(()=>{g.current=!0},[o?.id,o?.runtimeInstanceId]),A.useEffect(()=>{const m=l.current;m&&g.current&&(m.scrollTop=m.scrollHeight)},[f]),t.jsxs("div",{className:"flex h-full min-h-0 w-full min-w-0 flex-col bg-terminal text-terminal-foreground md:flex-row",children:[t.jsxs("aside",{className:"flex max-h-[44%] min-h-32 shrink-0 flex-col border-b border-terminal-border bg-terminal-chrome md:max-h-none md:min-h-0 md:w-72 md:border-b-0 md:border-r",children:[t.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between border-b border-terminal-border px-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Ns,{size:13,className:"shrink-0 text-terminal-muted-foreground","aria-hidden":"true"}),t.jsx("h2",{className:"truncate text-xs font-medium",children:a("Background services")})]}),!p.isLoading&&!p.isError&&t.jsx("span",{className:"text-[11px] tabular-nums text-terminal-muted-foreground",children:v.length})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto scrollbar-app-thin",children:p.isLoading?t.jsxs("div",{className:"flex min-h-24 items-center justify-center gap-2 text-xs text-terminal-muted-foreground",children:[t.jsx(xe,{size:"sm"}),a("Loading background services...")]}):p.isError?t.jsx(xc,{message:a("Failed to load background services."),onRetry:()=>{p.refetch()}}):v.length===0?t.jsxs("div",{className:"flex min-h-24 flex-col items-center justify-center gap-2 px-4 text-center text-xs text-terminal-muted-foreground",children:[t.jsx(Ns,{size:22,"aria-hidden":"true"}),t.jsx("span",{children:a("No background services")})]}):v.map(m=>{const y=m.name===o?.name;return t.jsxs("button",{type:"button",onClick:()=>r(m.name),"aria-pressed":y,className:Q("block w-full border-b border-terminal-border px-3 py-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-terminal-muted-foreground",y?"bg-terminal":"hover:bg-terminal-accent"),children:[t.jsxs("span",{className:"flex min-w-0 items-center justify-between gap-2",children:[t.jsx("span",{className:"truncate text-xs font-medium text-terminal-foreground",children:m.name}),t.jsx(Cr,{state:m.runtimeState})]}),t.jsx("span",{className:"mt-1 block truncate font-mono text-[11px] text-terminal-muted-foreground",title:fs(m),children:fs(m)}),t.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-1 text-[11px] text-terminal-muted-foreground",children:[t.jsx(qs,{size:10,className:"shrink-0","aria-hidden":"true"}),t.jsx("span",{className:"truncate",children:m.relativeCwd||"."})]}),t.jsxs("span",{className:`mt-1 flex min-w-0 items-center gap-1 ${m.startedAt?"text-[11px]":"text-xs"} text-terminal-muted-foreground`,children:[t.jsx(Ve,{size:10,className:"shrink-0","aria-hidden":"true"}),t.jsx("span",{className:"truncate",children:wr(m.startedAt,s,a("Not started"))})]})]},m.id)})})]}),t.jsx("section",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-terminal","aria-label":a("Background service logs"),children:o?t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:"shrink-0 border-b border-terminal-border bg-terminal-chrome",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 px-3 pt-2",children:[t.jsx("span",{className:"min-w-0 truncate text-xs font-semibold text-terminal-foreground",children:o.name}),t.jsx(Cr,{state:o.runtimeState})]}),t.jsxs("div",{className:"max-h-32 overflow-y-auto overscroll-y-contain px-3 pb-2 scrollbar-app-thin focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-terminal-muted-foreground",tabIndex:0,"aria-label":`${o.name} ${a("Details")}`,children:[t.jsxs("dl",{className:"mt-1.5 grid min-w-0 gap-x-4 gap-y-1 text-xs text-terminal-muted-foreground sm:grid-cols-2",children:[t.jsxs("div",{className:"flex min-w-0 gap-1.5",children:[t.jsxs("dt",{className:"shrink-0",children:[a("Command"),":"]}),t.jsx("dd",{className:"min-w-0 break-all font-mono text-terminal-foreground",children:fs(o)})]}),t.jsxs("div",{className:"flex min-w-0 gap-1.5",children:[t.jsxs("dt",{className:"shrink-0",children:[a("Working directory"),":"]}),t.jsx("dd",{className:"min-w-0 break-all font-mono text-terminal-foreground",children:o.relativeCwd||"."})]}),t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 sm:col-span-2",children:[t.jsx(Ve,{size:10,className:"shrink-0","aria-hidden":"true"}),t.jsxs("dt",{className:"shrink-0",children:[a("Started"),":"]}),t.jsx("dd",{className:"truncate text-terminal-foreground",children:wr(o.startedAt,s,a("Not started"))})]})]}),o.lastError&&t.jsxs("p",{className:"mt-1.5 flex min-w-0 items-start gap-1.5 break-words text-xs text-terminal-foreground",role:"alert",children:[t.jsx(Nt,{size:12,className:"mt-0.5 shrink-0 text-terminal-red","aria-hidden":"true"}),t.jsx("span",{className:"min-w-0",children:o.lastError})]})]})]}),(u.data?.truncated||u.data?.reset)&&t.jsx("div",{className:"shrink-0 border-b border-terminal-yellow/20 bg-terminal-yellow/10 px-3 py-1.5 text-xs text-terminal-foreground",children:a("Earlier log output is unavailable.")}),u.isError&&t.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-terminal-red/20 bg-terminal-red/10 px-3 py-1.5 text-xs text-terminal-foreground",role:"alert",children:[t.jsx("span",{children:a("Failed to refresh service logs.")}),t.jsx("button",{type:"button",onClick:()=>{u.refetch()},className:"flex h-6 w-6 items-center justify-center rounded text-terminal-foreground transition-colors hover:bg-terminal-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-terminal-muted-foreground",title:a("Retry"),"aria-label":a("Retry"),children:t.jsx(_t,{size:11})})]}),t.jsx("div",{ref:l,onScroll:m=>{const y=m.currentTarget;g.current=y.scrollHeight-y.scrollTop-y.clientHeight<32},className:"min-h-0 flex-1 overflow-auto p-3 scrollbar-app-thin",role:"log","aria-live":"off",tabIndex:0,children:u.isLoading&&!u.data?t.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-xs text-terminal-muted-foreground",children:[t.jsx(xe,{size:"sm"}),a("Loading service logs...")]}):f?t.jsx("pre",{className:"m-0 whitespace-pre-wrap break-words font-mono text-xs leading-5 text-terminal-foreground",children:f}):t.jsx("div",{className:"flex h-full items-center justify-center text-xs text-terminal-muted-foreground",children:a("No logs yet")})})]}):t.jsx("div",{className:"flex h-full items-center justify-center px-4 text-center text-xs text-terminal-muted-foreground",children:p.isLoading?a("Loading background services..."):a("Select a background service")})})]})}let ms=0;function kr(){return ms+=1,{id:`shell-${ms}`,order:ms}}const yc=_e.memo(function({cwd:i,isVisible:s=!0,workspaceId:a,quickCommands:p=[]}){const{t:v}=re(),[w,r]=A.useState(()=>[kr()]),[o,u]=A.useState(()=>w[0].id),[f,l]=A.useState(()=>new Set),[g,m]=A.useState(!1),[y,b]=A.useState(!1),[n,d]=A.useState(""),[c,h]=A.useState(null),[_,S]=A.useState("terminals"),k=A.useRef(new Map),E=a?_:"terminals",x=A.useCallback(M=>{k.current.delete(M),l(O=>{if(!O.has(M))return O;const q=new Set(O);return q.delete(M),q})},[]),C=A.useCallback(()=>{const M=kr();r(O=>[...O,M]),u(M.id)},[]),N=A.useCallback((M,O)=>{O.stopPropagation(),x(M),r(q=>{const V=q.filter($=>$.id!==M);return M===o&&V.length>0&&u(V[V.length-1].id),V})},[o,x]),L=A.useCallback(M=>{x(M),r(O=>{const q=O.filter(V=>V.id!==M);return M===o&&q.length>0&&u(q[q.length-1].id),q})},[o,x]),R=A.useCallback((M,O)=>{k.current.set(M,O),l(q=>{if(q.has(M))return q;const V=new Set(q);return V.add(M),V})},[]),P=A.useCallback(M=>{const O=k.current.get(o);O&&O.sendInput(M+"\r")},[o]),F=A.useCallback((M,O="")=>{h(M),d(O),b(!0)},[]),B=A.useCallback((M,O)=>{const q=k.current.get(M);return q?(q.paste(O),ke.success(v("Pasted into terminal")),!0):(ke.error(v("Terminal is not ready")),!1)},[v]),H=A.useCallback(async()=>{if(!k.current.has(o)){ke.error(v("Terminal is not ready"));return}const M=navigator.clipboard;if(!M?.readText){F(o);return}m(!0);try{const O=await M.readText();if(!O||O.includes(`
|
|
19
|
+
`)||O.includes("\r")){F(o,O);return}B(o,O)}catch{F(o)}finally{m(!1)}},[o,F,B,v]),U=A.useCallback(()=>{!n||!c||!B(c,n)||(b(!1),d(""),h(null))},[n,B,c]),T=A.useCallback(()=>{b(!1),d(""),h(null)},[]),D=f.has(o);return t.jsxs("div",{className:"flex h-full w-full min-h-0 min-w-0 flex-col overflow-hidden bg-terminal",children:[a&&t.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 border-b border-terminal-border bg-terminal-chrome px-2 select-none",children:[t.jsxs("button",{type:"button",onClick:()=>S("terminals"),"aria-pressed":E==="terminals",className:Q("flex h-7 items-center gap-1.5 rounded px-2.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-terminal-muted-foreground",E==="terminals"?"bg-terminal text-terminal-foreground":"text-terminal-muted-foreground hover:bg-terminal-accent hover:text-terminal-foreground"),children:[t.jsx(yt,{size:12,"aria-hidden":"true"}),v("Interactive terminals")]}),t.jsxs("button",{type:"button",onClick:()=>S("services"),"aria-pressed":E==="services",className:Q("flex h-7 items-center gap-1.5 rounded px-2.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-terminal-muted-foreground",E==="services"?"bg-terminal text-terminal-foreground":"text-terminal-muted-foreground hover:bg-terminal-accent hover:text-terminal-foreground"),children:[t.jsx(Ns,{size:12,"aria-hidden":"true"}),v("Background services")]})]}),t.jsxs("div",{"aria-hidden":E!=="terminals",className:Q("min-h-0 flex-1 flex-col",E==="terminals"?"flex":"hidden"),children:[t.jsxs("div",{className:"flex items-center bg-terminal-chrome border-b border-terminal-border shrink-0 select-none",children:[t.jsx("div",{className:"flex items-center overflow-x-auto scrollbar-app-thin flex-1 min-w-0",children:w.map(M=>t.jsxs("button",{onClick:()=>u(M.id),className:Q("flex items-center gap-1.5 px-3 py-1.5 text-xs border-r border-terminal-border whitespace-nowrap group transition-colors",M.id===o?"bg-terminal text-terminal-foreground":"text-terminal-muted-foreground hover:bg-terminal-accent hover:text-terminal-foreground"),children:[t.jsx(yt,{size:11,className:"shrink-0"}),t.jsx("span",{children:v("Shell {count}",{count:M.order})}),w.length>1&&t.jsx("span",{onClick:O=>N(M.id,O),className:"ml-1 p-0.5 rounded hover:bg-terminal-accent opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:t.jsx(tt,{size:10})})]},M.id))}),w.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"mx-0.5 block h-5 w-px shrink-0 bg-terminal-border md:hidden","aria-hidden":"true"}),t.jsx("button",{type:"button",onClick:H,disabled:!D||g,className:"flex h-11 w-11 shrink-0 items-center justify-center text-terminal-muted-foreground transition-colors hover:bg-terminal-accent hover:text-terminal-foreground active:bg-terminal-accent disabled:cursor-not-allowed disabled:opacity-40 md:hidden",title:v("Paste into terminal"),"aria-label":v("Paste into terminal"),children:g?t.jsx(xe,{size:"lg",className:"size-[18px]"}):t.jsx(ma,{size:18})})]}),t.jsx("button",{type:"button",onClick:C,className:"flex h-11 w-11 shrink-0 items-center justify-center text-terminal-muted-foreground transition-colors hover:bg-terminal-accent hover:text-terminal-foreground active:bg-terminal-accent md:h-auto md:w-auto md:px-2 md:py-1.5",title:v("New Terminal"),"aria-label":v("New Terminal"),children:t.jsx(pt,{size:14})}),p.length>0&&t.jsx(ac,{commands:p,onSelect:P})]}),t.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden relative",children:w.length===0?t.jsx("div",{className:"flex-1 flex items-center justify-center h-full text-terminal-muted-foreground",children:t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(yt,{size:28}),t.jsx("span",{className:"text-xs",children:v("No terminals open")}),t.jsx("button",{onClick:C,className:"mt-1 rounded bg-terminal-chrome px-3 py-1 text-xs text-terminal-foreground ring-1 ring-inset ring-terminal-border transition-colors hover:bg-terminal-accent",children:v("New Terminal")})]})}):w.map(M=>t.jsx("div",{"aria-hidden":M.id!==o,className:Q("absolute inset-0 h-full w-full min-h-0 min-w-0 overflow-hidden",M.id===o?"visible pointer-events-auto":"invisible pointer-events-none"),children:t.jsx(oc,{cwd:i,isVisible:s&&E==="terminals"&&M.id===o,onExit:()=>L(M.id),onReady:O=>R(M.id,O)})},M.id))})]}),a&&E==="services"&&t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(Sc,{workspaceId:a,enabled:s})}),t.jsx(At,{isOpen:y,onClose:T,title:v("Paste into terminal"),className:"max-sm:inset-x-0 max-sm:top-auto max-sm:bottom-0 max-sm:max-h-[70dvh] max-sm:w-full max-sm:max-w-none max-sm:translate-x-0 max-sm:translate-y-0 max-sm:rounded-b-none max-sm:rounded-t-lg max-sm:border-x-0 max-sm:border-b-0",action:t.jsxs(t.Fragment,{children:[t.jsx(ce,{variant:"ghost",size:"lg",onClick:T,className:"max-sm:h-11",children:v("Cancel")}),t.jsx(ce,{variant:"primary",size:"lg",onClick:U,disabled:!n,className:"max-sm:h-11",children:v("Paste")})]}),children:t.jsx(Do,{autoFocus:!0,value:n,onChange:M=>d(M.target.value),placeholder:v("Paste terminal input here"),"aria-label":v("Terminal paste content"),className:"min-h-32 resize-none bg-background font-mono"})})]})});function Er(e,i){(i==null||i>e.length)&&(i=e.length);for(var s=0,a=Array(i);s<i;s++)a[s]=e[s];return a}function wc(e){if(Array.isArray(e))return e}function Cc(e,i,s){return(i=Rc(i))in e?Object.defineProperty(e,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[i]=s,e}function kc(e,i){var s=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(s!=null){var a,p,v,w,r=[],o=!0,u=!1;try{if(v=(s=s.call(e)).next,i!==0)for(;!(o=(a=v.call(s)).done)&&(r.push(a.value),r.length!==i);o=!0);}catch(f){u=!0,p=f}finally{try{if(!o&&s.return!=null&&(w=s.return(),Object(w)!==w))return}finally{if(u)throw p}}return r}}function Ec(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
20
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function jr(e,i){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);i&&(a=a.filter(function(p){return Object.getOwnPropertyDescriptor(e,p).enumerable})),s.push.apply(s,a)}return s}function Tr(e){for(var i=1;i<arguments.length;i++){var s=arguments[i]!=null?arguments[i]:{};i%2?jr(Object(s),!0).forEach(function(a){Cc(e,a,s[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):jr(Object(s)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(s,a))})}return e}function jc(e,i){if(e==null)return{};var s,a,p=Tc(e,i);if(Object.getOwnPropertySymbols){var v=Object.getOwnPropertySymbols(e);for(a=0;a<v.length;a++)s=v[a],i.indexOf(s)===-1&&{}.propertyIsEnumerable.call(e,s)&&(p[s]=e[s])}return p}function Tc(e,i){if(e==null)return{};var s={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(i.indexOf(a)!==-1)continue;s[a]=e[a]}return s}function Nc(e,i){return wc(e)||kc(e,i)||Lc(e,i)||Ec()}function Ac(e,i){if(typeof e!="object"||!e)return e;var s=e[Symbol.toPrimitive];if(s!==void 0){var a=s.call(e,i);if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(e)}function Rc(e){var i=Ac(e,"string");return typeof i=="symbol"?i:i+""}function Lc(e,i){if(e){if(typeof e=="string")return Er(e,i);var s={}.toString.call(e).slice(8,-1);return s==="Object"&&e.constructor&&(s=e.constructor.name),s==="Map"||s==="Set"?Array.from(e):s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?Er(e,i):void 0}}function Mc(e,i,s){return i in e?Object.defineProperty(e,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[i]=s,e}function Nr(e,i){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);i&&(a=a.filter(function(p){return Object.getOwnPropertyDescriptor(e,p).enumerable})),s.push.apply(s,a)}return s}function Ar(e){for(var i=1;i<arguments.length;i++){var s=arguments[i]!=null?arguments[i]:{};i%2?Nr(Object(s),!0).forEach(function(a){Mc(e,a,s[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):Nr(Object(s)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(s,a))})}return e}function Pc(){for(var e=arguments.length,i=new Array(e),s=0;s<e;s++)i[s]=arguments[s];return function(a){return i.reduceRight(function(p,v){return v(p)},a)}}function St(e){return function i(){for(var s=this,a=arguments.length,p=new Array(a),v=0;v<a;v++)p[v]=arguments[v];return p.length>=e.length?e.apply(this,p):function(){for(var w=arguments.length,r=new Array(w),o=0;o<w;o++)r[o]=arguments[o];return i.apply(s,[].concat(p,r))}}}function Yt(e){return{}.toString.call(e).includes("Object")}function Dc(e){return!Object.keys(e).length}function Tt(e){return typeof e=="function"}function Bc(e,i){return Object.prototype.hasOwnProperty.call(e,i)}function Oc(e,i){return Yt(i)||Ge("changeType"),Object.keys(i).some(function(s){return!Bc(e,s)})&&Ge("changeField"),i}function Ic(e){Tt(e)||Ge("selectorType")}function Fc(e){Tt(e)||Yt(e)||Ge("handlerType"),Yt(e)&&Object.values(e).some(function(i){return!Tt(i)})&&Ge("handlersType")}function Hc(e){e||Ge("initialIsRequired"),Yt(e)||Ge("initialType"),Dc(e)&&Ge("initialContent")}function zc(e,i){throw new Error(e[i]||e.default)}var Wc={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},Ge=St(zc)(Wc),It={changes:Oc,selector:Ic,handler:Fc,initial:Hc};function $c(e){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};It.initial(e),It.handler(i);var s={current:e},a=St(Kc)(s,i),p=St(qc)(s),v=St(It.changes)(e),w=St(Uc)(s);function r(){var u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(f){return f};return It.selector(u),u(s.current)}function o(u){Pc(a,p,v,w)(u)}return[r,o]}function Uc(e,i){return Tt(i)?i(e.current):i}function qc(e,i){return e.current=Ar(Ar({},e.current),i),i}function Kc(e,i,s){return Tt(i)?i(e.current):Object.keys(s).forEach(function(a){var p;return(p=i[a])===null||p===void 0?void 0:p.call(i,e.current[a])}),s}var Xc={create:$c},Yc={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function Vc(e){return function i(){for(var s=this,a=arguments.length,p=new Array(a),v=0;v<a;v++)p[v]=arguments[v];return p.length>=e.length?e.apply(this,p):function(){for(var w=arguments.length,r=new Array(w),o=0;o<w;o++)r[o]=arguments[o];return i.apply(s,[].concat(p,r))}}}function Gc(e){return{}.toString.call(e).includes("Object")}function Qc(e){return e||Rr("configIsRequired"),Gc(e)||Rr("configType"),e.urls?(Zc(),{paths:{vs:e.urls.monacoBase}}):e}function Zc(){console.warn($i.deprecation)}function Jc(e,i){throw new Error(e[i]||e.default)}var $i={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
|
|
21
|
+
You are using deprecated way of configuration.
|
|
22
|
+
|
|
23
|
+
Instead of using
|
|
24
|
+
monaco.config({ urls: { monacoBase: '...' } })
|
|
25
|
+
use
|
|
26
|
+
monaco.config({ paths: { vs: '...' } })
|
|
27
|
+
|
|
28
|
+
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
29
|
+
`},Rr=Vc(Jc)($i),ed={config:Qc},td=function(){for(var i=arguments.length,s=new Array(i),a=0;a<i;a++)s[a]=arguments[a];return function(p){return s.reduceRight(function(v,w){return w(v)},p)}};function Ui(e,i){return Object.keys(i).forEach(function(s){i[s]instanceof Object&&e[s]&&Object.assign(i[s],Ui(e[s],i[s]))}),Tr(Tr({},e),i)}var sd={type:"cancelation",msg:"operation is manually canceled"};function ps(e){var i=!1,s=new Promise(function(a,p){e.then(function(v){return i?p(sd):a(v)}),e.catch(p)});return s.cancel=function(){return i=!0},s}var rd=["monaco"],id=Xc.create({config:Yc,isInitialized:!1,resolve:null,reject:null,monaco:null}),qi=Nc(id,2),Rt=qi[0],Jt=qi[1];function nd(e){var i=ed.config(e),s=i.monaco,a=jc(i,rd);Jt(function(p){return{config:Ui(p.config,a),monaco:s}})}function od(){var e=Rt(function(i){var s=i.monaco,a=i.isInitialized,p=i.resolve;return{monaco:s,isInitialized:a,resolve:p}});if(!e.isInitialized){if(Jt({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),ps(gs);if(window.monaco&&window.monaco.editor)return Ki(window.monaco),e.resolve(window.monaco),ps(gs);td(ad,cd)(dd)}return ps(gs)}function ad(e){return document.body.appendChild(e)}function ld(e){var i=document.createElement("script");return e&&(i.src=e),i}function cd(e){var i=Rt(function(a){var p=a.config,v=a.reject;return{config:p,reject:v}}),s=ld("".concat(i.config.paths.vs,"/loader.js"));return s.onload=function(){return e()},s.onerror=i.reject,s}function dd(){var e=Rt(function(s){var a=s.config,p=s.resolve,v=s.reject;return{config:a,resolve:p,reject:v}}),i=window.require;i.config(e.config),i(["vs/editor/editor.main"],function(s){var a=s.m||s;Ki(a),e.resolve(a)},function(s){e.reject(s)})}function Ki(e){Rt().monaco||Jt({monaco:e})}function hd(){return Rt(function(e){var i=e.monaco;return i})}var gs=new Promise(function(e,i){return Jt({resolve:e,reject:i})}),Xi={config:nd,init:od,__getMonacoInstance:hd},ud={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},vs=ud,fd={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},md=fd;function pd({children:e}){return _e.createElement("div",{style:md.container},e)}var gd=pd,vd=gd;function _d({width:e,height:i,isEditorReady:s,loading:a,_ref:p,className:v,wrapperProps:w}){return _e.createElement("section",{style:{...vs.wrapper,width:e,height:i},...w},!s&&_e.createElement(vd,null,a),_e.createElement("div",{ref:p,style:{...vs.fullWidth,...!s&&vs.hide},className:v}))}var bd=_d,Yi=A.memo(bd);function xd(e){A.useEffect(e,[])}var Vi=xd;function Sd(e,i,s=!0){let a=A.useRef(!0);A.useEffect(a.current||!s?()=>{a.current=!1}:e,i)}var Ne=Sd;function wt(){}function gt(e,i,s,a){return yd(e,a)||wd(e,i,s,a)}function yd(e,i){return e.editor.getModel(Gi(e,i))}function wd(e,i,s,a){return e.editor.createModel(i,s,a?Gi(e,a):void 0)}function Gi(e,i){return e.Uri.parse(i)}function Cd({original:e,modified:i,language:s,originalLanguage:a,modifiedLanguage:p,originalModelPath:v,modifiedModelPath:w,keepCurrentOriginalModel:r=!1,keepCurrentModifiedModel:o=!1,theme:u="light",loading:f="Loading...",options:l={},height:g="100%",width:m="100%",className:y,wrapperProps:b={},beforeMount:n=wt,onMount:d=wt}){let[c,h]=A.useState(!1),[_,S]=A.useState(!0),k=A.useRef(null),E=A.useRef(null),x=A.useRef(null),C=A.useRef(d),N=A.useRef(n),L=A.useRef(!1);Vi(()=>{let B=Xi.init();return B.then(H=>(E.current=H)&&S(!1)).catch(H=>H?.type!=="cancelation"&&console.error("Monaco initialization: error:",H)),()=>k.current?F():B.cancel()}),Ne(()=>{if(k.current&&E.current){let B=k.current.getOriginalEditor(),H=gt(E.current,e||"",a||s||"text",v||"");H!==B.getModel()&&B.setModel(H)}},[v],c),Ne(()=>{if(k.current&&E.current){let B=k.current.getModifiedEditor(),H=gt(E.current,i||"",p||s||"text",w||"");H!==B.getModel()&&B.setModel(H)}},[w],c),Ne(()=>{let B=k.current.getModifiedEditor();B.getOption(E.current.editor.EditorOption.readOnly)?B.setValue(i||""):i!==B.getValue()&&(B.executeEdits("",[{range:B.getModel().getFullModelRange(),text:i||"",forceMoveMarkers:!0}]),B.pushUndoStop())},[i],c),Ne(()=>{k.current?.getModel()?.original.setValue(e||"")},[e],c),Ne(()=>{let{original:B,modified:H}=k.current.getModel();E.current.editor.setModelLanguage(B,a||s||"text"),E.current.editor.setModelLanguage(H,p||s||"text")},[s,a,p],c),Ne(()=>{E.current?.editor.setTheme(u)},[u],c),Ne(()=>{k.current?.updateOptions(l)},[l],c);let R=A.useCallback(()=>{if(!E.current)return;N.current(E.current);let B=gt(E.current,e||"",a||s||"text",v||""),H=gt(E.current,i||"",p||s||"text",w||"");k.current?.setModel({original:B,modified:H})},[s,i,p,e,a,v,w]),P=A.useCallback(()=>{!L.current&&x.current&&(k.current=E.current.editor.createDiffEditor(x.current,{automaticLayout:!0,...l}),R(),E.current?.editor.setTheme(u),h(!0),L.current=!0)},[l,u,R]);A.useEffect(()=>{c&&C.current(k.current,E.current)},[c]),A.useEffect(()=>{!_&&!c&&P()},[_,c,P]);function F(){let B=k.current?.getModel();r||B?.original?.dispose(),o||B?.modified?.dispose(),k.current?.dispose()}return _e.createElement(Yi,{width:m,height:g,isEditorReady:c,loading:f,_ref:x,className:y,wrapperProps:b})}var kd=Cd;A.memo(kd);function Ed(e){let i=A.useRef();return A.useEffect(()=>{i.current=e},[e]),i.current}var jd=Ed,Ft=new Map;function Td({defaultValue:e,defaultLanguage:i,defaultPath:s,value:a,language:p,path:v,theme:w="light",line:r,loading:o="Loading...",options:u={},overrideServices:f={},saveViewState:l=!0,keepCurrentModel:g=!1,width:m="100%",height:y="100%",className:b,wrapperProps:n={},beforeMount:d=wt,onMount:c=wt,onChange:h,onValidate:_=wt}){let[S,k]=A.useState(!1),[E,x]=A.useState(!0),C=A.useRef(null),N=A.useRef(null),L=A.useRef(null),R=A.useRef(c),P=A.useRef(d),F=A.useRef(),B=A.useRef(a),H=jd(v),U=A.useRef(!1),T=A.useRef(!1);Vi(()=>{let O=Xi.init();return O.then(q=>(C.current=q)&&x(!1)).catch(q=>q?.type!=="cancelation"&&console.error("Monaco initialization: error:",q)),()=>N.current?M():O.cancel()}),Ne(()=>{let O=gt(C.current,e||a||"",i||p||"",v||s||"");O!==N.current?.getModel()&&(l&&Ft.set(H,N.current?.saveViewState()),N.current?.setModel(O),l&&N.current?.restoreViewState(Ft.get(v)))},[v],S),Ne(()=>{N.current?.updateOptions(u)},[u],S),Ne(()=>{!N.current||a===void 0||(N.current.getOption(C.current.editor.EditorOption.readOnly)?N.current.setValue(a):a!==N.current.getValue()&&(T.current=!0,N.current.executeEdits("",[{range:N.current.getModel().getFullModelRange(),text:a,forceMoveMarkers:!0}]),N.current.pushUndoStop(),T.current=!1))},[a],S),Ne(()=>{let O=N.current?.getModel();O&&p&&C.current?.editor.setModelLanguage(O,p)},[p],S),Ne(()=>{r!==void 0&&N.current?.revealLine(r)},[r],S),Ne(()=>{C.current?.editor.setTheme(w)},[w],S);let D=A.useCallback(()=>{if(!(!L.current||!C.current)&&!U.current){P.current(C.current);let O=v||s,q=gt(C.current,a||e||"",i||p||"",O||"");N.current=C.current?.editor.create(L.current,{model:q,automaticLayout:!0,...u},f),l&&N.current.restoreViewState(Ft.get(O)),C.current.editor.setTheme(w),r!==void 0&&N.current.revealLine(r),k(!0),U.current=!0}},[e,i,s,a,p,v,u,f,l,w,r]);A.useEffect(()=>{S&&R.current(N.current,C.current)},[S]),A.useEffect(()=>{!E&&!S&&D()},[E,S,D]),B.current=a,A.useEffect(()=>{S&&h&&(F.current?.dispose(),F.current=N.current?.onDidChangeModelContent(O=>{T.current||h(N.current.getValue(),O)}))},[S,h]),A.useEffect(()=>{if(S){let O=C.current.editor.onDidChangeMarkers(q=>{let V=N.current.getModel()?.uri;if(V&&q.find($=>$.path===V.path)){let $=C.current.editor.getModelMarkers({resource:V});_?.($)}});return()=>{O?.dispose()}}return()=>{}},[S,_]);function M(){F.current?.dispose(),g?l&&Ft.set(v,N.current.saveViewState()):N.current.getModel()?.dispose(),N.current.dispose()}return _e.createElement(Yi,{width:m,height:y,isEditorReady:S,loading:o,_ref:L,className:b,wrapperProps:n})}var Nd=Td,Ad=A.memo(Nd),Rd=Ad,Me=function(e,i){return Number(e.toFixed(i))},Ld=function(e,i){return typeof e=="number"?e:i},fe=function(e,i,s){s&&typeof s=="function"&&s(e,i)},Md=function(e){return-Math.cos(e*Math.PI)/2+.5},Pd=function(e){return e},Dd=function(e){return e*e},Bd=function(e){return e*(2-e)},Od=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},Id=function(e){return e*e*e},Fd=function(e){return--e*e*e+1},Hd=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},zd=function(e){return e*e*e*e},Wd=function(e){return 1- --e*e*e*e},$d=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},Ud=function(e){return e*e*e*e*e},qd=function(e){return 1+--e*e*e*e*e},Kd=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},Qi={easeOut:Md,linear:Pd,easeInQuad:Dd,easeOutQuad:Bd,easeInOutQuad:Od,easeInCubic:Id,easeOutCubic:Fd,easeInOutCubic:Hd,easeInQuart:zd,easeOutQuart:Wd,easeInOutQuart:$d,easeInQuint:Ud,easeOutQuint:qd,easeInOutQuint:Kd},Zi=function(e){typeof e=="number"&&cancelAnimationFrame(e)},Be=function(e){e.mounted&&(Zi(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function Ji(e,i,s,a){if(e.mounted){var p=new Date().getTime(),v=1;Be(e),e.animation=function(){if(!e.mounted)return Zi(e.animation);var w=new Date().getTime()-p,r=w/s,o=Qi[i],u=o(r);w>=s?(a(v),e.animation=null):e.animation&&(a(u),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function Xd(e){var i=e.scale,s=e.positionX,a=e.positionY;return!(Number.isNaN(i)||Number.isNaN(s)||Number.isNaN(a))}function st(e,i,s,a){var p=Xd(i);if(!(!e.mounted||!p)){var v=e.setTransformState,w=e.transformState,r=w.scale,o=w.positionX,u=w.positionY,f=i.scale-r,l=i.positionX-o,g=i.positionY-u;s===0?v(i.scale,i.positionX,i.positionY):Ji(e,a,s,function(m){var y=r+f*m,b=o+l*m,n=u+g*m;v(y,b,n)})}}function Yd(e,i,s){var a=e.offsetWidth,p=e.offsetHeight,v=i.offsetWidth,w=i.offsetHeight,r=v*s,o=w*s,u=a-r,f=p-o;return{wrapperWidth:a,wrapperHeight:p,newContentWidth:r,newDiffWidth:u,newContentHeight:o,newDiffHeight:f}}var Vd=function(e,i,s,a,p,v,w){var r=e>i?s*(w?1:.5):0,o=a>p?v*(w?1:.5):0,u=e-i-r,f=r,l=a-p-o,g=o;return{minPositionX:u,maxPositionX:f,minPositionY:l,maxPositionY:g}},Js=function(e,i){var s=e.wrapperComponent,a=e.contentComponent,p=e.setup.centerZoomedOut;if(!s||!a)throw new Error("Components are not mounted");var v=Yd(s,a,i),w=v.wrapperWidth,r=v.wrapperHeight,o=v.newContentWidth,u=v.newDiffWidth,f=v.newContentHeight,l=v.newDiffHeight,g=Vd(w,o,u,r,f,l,!!p);return g},Ps=function(e,i,s,a){return a?e<i?Me(i,2):e>s?Me(s,2):Me(e,2):Me(e,2)},ct=function(e,i){var s=Js(e,i);return e.bounds=s,s};function Lt(e,i,s,a,p,v,w){var r=s.minPositionX,o=s.minPositionY,u=s.maxPositionX,f=s.maxPositionY,l=0,g=0;w&&(l=p,g=v);var m=Ps(e,r-l,u+l,a),y=Ps(i,o-g,f+g,a);return{x:m,y}}function es(e,i,s,a,p,v){var w=e.transformState,r=w.scale,o=w.positionX,u=w.positionY,f=a-r;if(typeof i!="number"||typeof s!="number")return console.error("Mouse X and Y position were not provided!"),{x:o,y:u};var l=o-i*f,g=u-s*f,m=Lt(l,g,p,v,0,0,null);return m}function Mt(e,i,s,a,p){var v=p?a:0,w=i-v;return!Number.isNaN(s)&&e>=s?s:!Number.isNaN(i)&&e<=w?w:e}var Lr=function(e,i){var s=e.setup.panning.excluded,a=e.isInitialized,p=e.wrapperComponent,v=i.target,w="shadowRoot"in v&&"composedPath"in i,r=w?i.composedPath().some(function(f){return f instanceof Element?p?.contains(f):!1}):p?.contains(v),o=a&&v&&r;if(!o)return!1;var u=ts(v,s);return!u},Mr=function(e){var i=e.isInitialized,s=e.isPanning,a=e.setup,p=a.panning.disabled,v=i&&s&&!p;return!!v},Gd=function(e,i){var s=e.transformState,a=s.positionX,p=s.positionY;e.isPanning=!0;var v=i.clientX,w=i.clientY;e.startCoords={x:v-a,y:w-p}},Qd=function(e,i){var s=i.touches,a=e.transformState,p=a.positionX,v=a.positionY;e.isPanning=!0;var w=s.length===1;if(w){var r=s[0].clientX,o=s[0].clientY;e.startCoords={x:r-p,y:o-v}}};function Zd(e){var i=e.transformState,s=i.positionX,a=i.positionY,p=i.scale,v=e.setup,w=v.disabled,r=v.limitToBounds,o=v.centerZoomedOut,u=e.wrapperComponent;if(!(w||!u||!e.bounds)){var f=e.bounds,l=f.maxPositionX,g=f.minPositionX,m=f.maxPositionY,y=f.minPositionY,b=s>l||s<g,n=a>m||a<y,d=s>l?u.offsetWidth:e.setup.minPositionX||0,c=a>m?u.offsetHeight:e.setup.minPositionY||0,h=es(e,d,c,p,e.bounds,r||o),_=h.x,S=h.y;return{scale:p,positionX:b?_:s,positionY:n?S:a}}}function en(e,i,s,a,p){var v=e.setup.limitToBounds,w=e.wrapperComponent,r=e.bounds,o=e.transformState,u=o.scale,f=o.positionX,l=o.positionY;if(!(w===null||r===null||i===f&&s===l)){var g=Lt(i,s,r,v,a,p,w),m=g.x,y=g.y;e.setTransformState(u,m,y)}}var Jd=function(e,i,s){var a=e.startCoords,p=e.transformState,v=e.setup.panning,w=v.lockAxisX,r=v.lockAxisY,o=p.positionX,u=p.positionY;if(!a)return{x:o,y:u};var f=i-a.x,l=s-a.y,g=w?o:f,m=r?u:l;return{x:g,y:m}},et=function(e,i){var s=e.setup,a=e.transformState,p=a.scale,v=s.minScale,w=s.disablePadding;return i>0&&p>=v&&!w?i:0},eh=function(e){var i=e.mounted,s=e.setup,a=s.disabled,p=s.velocityAnimation,v=e.transformState.scale,w=p.disabled,r=!w||v>1||!a||i;return!!r},th=function(e){var i=e.mounted,s=e.velocity,a=e.bounds,p=e.setup,v=p.disabled,w=p.velocityAnimation,r=e.transformState.scale,o=w.disabled,u=!o||r>1||!v||i;return!(!u||!s||!a)};function sh(e,i){var s=e.setup.velocityAnimation,a=s.equalToMove,p=s.animationTime,v=s.sensitivity;return a?p*i*v:p}function Pr(e,i,s,a,p,v,w,r,o,u){if(p){if(i>w&&s>w){var f=w+(e-w)*u;return f>o?o:f<w?w:f}if(i<v&&s<v){var f=v+(e-v)*u;return f<r?r:f>v?v:f}}return a?i:Ps(e,v,w,p)}function rh(e,i){var s=1;return i?Math.min(s,e.offsetWidth/window.innerWidth):s}function ih(e,i){var s=eh(e);if(s){var a=e.lastMousePosition,p=e.velocityTime,v=e.setup,w=e.wrapperComponent,r=v.velocityAnimation.equalToMove,o=Date.now();if(a&&p&&w){var u=rh(w,r),f=i.x-a.x,l=i.y-a.y,g=f/u,m=l/u,y=o-p,b=f*f+l*l,n=Math.sqrt(b)/y;e.velocity={velocityX:g,velocityY:m,total:n}}e.lastMousePosition=i,e.velocityTime=o}}function nh(e){var i=e.velocity,s=e.bounds,a=e.setup,p=e.wrapperComponent,v=th(e);if(!(!v||!i||!s||!p)){var w=i.velocityX,r=i.velocityY,o=i.total,u=s.maxPositionX,f=s.minPositionX,l=s.maxPositionY,g=s.minPositionY,m=a.limitToBounds,y=a.alignmentAnimation,b=a.zoomAnimation,n=a.panning,d=n.lockAxisY,c=n.lockAxisX,h=b.animationType,_=y.sizeX,S=y.sizeY,k=y.velocityAlignmentTime,E=k,x=sh(e,o),C=Math.max(x,E),N=et(e,_),L=et(e,S),R=N*p.offsetWidth/100,P=L*p.offsetHeight/100,F=u+R,B=f-R,H=l+P,U=g-P,T=e.transformState,D=new Date().getTime();Ji(e,h,C,function(M){var O=e.transformState,q=O.scale,V=O.positionX,$=O.positionY,z=new Date().getTime()-D,W=z/E,j=Qi[y.animationType],I=1-j(Math.min(1,W)),K=1-M,X=V+w*K,J=$+r*K,G=Pr(X,T.positionX,V,c,m,f,u,B,F,I),Z=Pr(J,T.positionY,$,d,m,g,l,U,H,I);(V!==X||$!==J)&&e.setTransformState(q,G,Z)})}}function Dr(e,i){var s=e.transformState.scale;Be(e),ct(e,s),window.TouchEvent!==void 0&&i instanceof TouchEvent?Qd(e,i):Gd(e,i)}function er(e,i){var s=e.transformState.scale,a=e.setup,p=a.minScale,v=a.alignmentAnimation,w=v.disabled,r=v.sizeX,o=v.sizeY,u=v.animationTime,f=v.animationType,l=w||s<p||!r&&!o;if(!l){var g=Zd(e);g&&st(e,g,i??u,f)}}function Br(e,i,s){var a=e.startCoords,p=e.setup,v=p.alignmentAnimation,w=v.sizeX,r=v.sizeY;if(a){var o=Jd(e,i,s),u=o.x,f=o.y,l=et(e,w),g=et(e,r);ih(e,{x:u,y:f}),en(e,u,f,l,g)}}function oh(e){if(e.isPanning){var i=e.setup.panning.velocityDisabled,s=e.velocity,a=e.wrapperComponent,p=e.contentComponent;e.isPanning=!1,e.animate=!1,e.animation=null;var v=a?.getBoundingClientRect(),w=p?.getBoundingClientRect(),r=v?.width||0,o=v?.height||0,u=w?.width||0,f=w?.height||0,l=r<u||o<f,g=!i&&s&&s?.total>.1&&l;g?nh(e):er(e)}}function tr(e,i,s,a){var p=e.setup,v=p.minScale,w=p.maxScale,r=p.limitToBounds,o=Mt(Me(i,2),v,w,0,!1),u=ct(e,o),f=es(e,s,a,o,u,r),l=f.x,g=f.y;return{scale:o,positionX:l,positionY:g}}function tn(e,i,s){var a=e.transformState.scale,p=e.wrapperComponent,v=e.setup,w=v.minScale,r=v.limitToBounds,o=v.zoomAnimation,u=o.disabled,f=o.animationTime,l=o.animationType,g=u||a>=w;if((a>=1||r)&&er(e),!(g||!p||!e.mounted)){var m=i||p.offsetWidth/2,y=s||p.offsetHeight/2,b=tr(e,w,m,y);b&&st(e,b,f,l)}}var Qe=function(){return Qe=Object.assign||function(i){for(var s,a=1,p=arguments.length;a<p;a++){s=arguments[a];for(var v in s)Object.prototype.hasOwnProperty.call(s,v)&&(i[v]=s[v])}return i},Qe.apply(this,arguments)};function Or(e,i,s){for(var a=0,p=i.length,v;a<p;a++)(v||!(a in i))&&(v||(v=Array.prototype.slice.call(i,0,a)),v[a]=i[a]);return e.concat(v||Array.prototype.slice.call(i))}var Ht={scale:1,positionX:0,positionY:0},xt={disabled:!1,minPositionX:null,maxPositionX:null,minPositionY:null,maxPositionY:null,minScale:1,maxScale:8,limitToBounds:!0,centerZoomedOut:!1,centerOnInit:!1,disablePadding:!1,smooth:!0,wheel:{step:.2,disabled:!1,smoothStep:.001,wheelDisabled:!1,touchPadDisabled:!1,activationKeys:[],excluded:[]},panning:{disabled:!1,velocityDisabled:!1,lockAxisX:!1,lockAxisY:!1,allowLeftClickPan:!0,allowMiddleClickPan:!0,allowRightClickPan:!0,wheelPanning:!1,activationKeys:[],excluded:[]},pinch:{step:5,disabled:!1,excluded:[]},doubleClick:{disabled:!1,step:.7,mode:"zoomIn",animationType:"easeOut",animationTime:200,excluded:[]},zoomAnimation:{disabled:!1,size:.4,animationTime:200,animationType:"easeOut"},alignmentAnimation:{disabled:!1,sizeX:100,sizeY:100,animationTime:200,velocityAlignmentTime:400,animationType:"easeOut"},velocityAnimation:{disabled:!1,sensitivity:1,animationTime:400,animationType:"easeOut",equalToMove:!0}},Ds={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},sn=function(e){var i,s,a,p;return{previousScale:(i=e.initialScale)!==null&&i!==void 0?i:Ht.scale,scale:(s=e.initialScale)!==null&&s!==void 0?s:Ht.scale,positionX:(a=e.initialPositionX)!==null&&a!==void 0?a:Ht.positionX,positionY:(p=e.initialPositionY)!==null&&p!==void 0?p:Ht.positionY}},Ir=function(e){var i=Qe({},xt);return Object.keys(e).forEach(function(s){var a=typeof e[s]<"u",p=typeof xt[s]<"u";if(p&&a){var v=Object.prototype.toString.call(xt[s]),w=v==="[object Object]",r=v==="[object Array]";w?i[s]=Qe(Qe({},xt[s]),e[s]):r?i[s]=Or(Or([],xt[s],!0),e[s]):i[s]=e[s]}}),i},rn=function(e,i,s){var a=e.transformState.scale,p=e.wrapperComponent,v=e.setup,w=v.maxScale,r=v.minScale,o=v.zoomAnimation,u=v.smooth,f=o.size;if(!p)throw new Error("Wrapper is not mounted");var l=u?a*Math.exp(i*s):a+i*s,g=Mt(Me(l,3),r,w,f,!1);return g};function nn(e,i,s,a,p){var v=e.wrapperComponent,w=e.transformState,r=w.scale,o=w.positionX,u=w.positionY;if(!v)return console.error("No WrapperComponent found");var f=v.offsetWidth,l=v.offsetHeight,g=(f/2-o)/r,m=(l/2-u)/r,y=rn(e,i,s),b=tr(e,y,g,m);if(!b)return console.error("Error during zoom event. New transformation state was not calculated.");st(e,b,a,p)}function on(e,i,s,a){var p=e.setup,v=e.wrapperComponent,w=p.limitToBounds,r=sn(e.props),o=e.transformState,u=o.scale,f=o.positionX,l=o.positionY;if(v){var g=Js(e,r.scale),m=Lt(r.positionX,r.positionY,g,w,0,0,v),y={scale:r.scale,positionX:m.x,positionY:m.y};u===r.scale&&f===r.positionX&&l===r.positionY||(a?.(),st(e,y,i,s))}}function ah(e,i,s,a){var p=e.getBoundingClientRect(),v=i.getBoundingClientRect(),w=s.getBoundingClientRect(),r=v.x*a.scale,o=v.y*a.scale;return{x:(p.x-w.x+r)/a.scale,y:(p.y-w.y+o)/a.scale}}function lh(e,i,s){var a=e.wrapperComponent,p=e.contentComponent,v=e.transformState,w=e.setup,r=w.limitToBounds,o=w.minScale,u=w.maxScale;if(!a||!p)return v;var f=a.getBoundingClientRect(),l=i.getBoundingClientRect(),g=ah(i,a,p,v),m=g.x,y=g.y,b=l.width/v.scale,n=l.height/v.scale,d=a.offsetWidth/b,c=a.offsetHeight/n,h=Mt(s||Math.min(d,c),o,u,0,!1),_=(f.width-b*h)/2,S=(f.height-n*h)/2,k=(f.left-m)*h+_,E=(f.top-y)*h+S,x=Js(e,h),C=Lt(k,E,x,r,0,0,a),N=C.x,L=C.y;return{positionX:N,positionY:L,scale:h}}var ch=function(e){return function(i,s,a){i===void 0&&(i=.5),s===void 0&&(s=300),a===void 0&&(a="easeOut"),nn(e,1,i,s,a)}},dh=function(e){return function(i,s,a){i===void 0&&(i=.5),s===void 0&&(s=300),a===void 0&&(a="easeOut"),nn(e,-1,i,s,a)}},hh=function(e){return function(i,s,a,p,v){p===void 0&&(p=300),v===void 0&&(v="easeOut");var w=e.transformState,r=w.positionX,o=w.positionY,u=w.scale,f=e.wrapperComponent,l=e.contentComponent,g=e.setup.disabled;if(!(g||!f||!l)){var m={positionX:Number.isNaN(i)?r:i,positionY:Number.isNaN(s)?o:s,scale:Number.isNaN(a)?u:a};st(e,m,p,v)}}},uh=function(e){return function(i,s){i===void 0&&(i=200),s===void 0&&(s="easeOut"),on(e,i,s)}},fh=function(e){return function(i,s,a){s===void 0&&(s=200),a===void 0&&(a="easeOut");var p=e.transformState,v=e.wrapperComponent,w=e.contentComponent;if(v&&w){var r=an(i||p.scale,v,w);st(e,r,s,a)}}},mh=function(e){return function(i,s,a,p){a===void 0&&(a=600),p===void 0&&(p="easeOut"),Be(e);var v=e.wrapperComponent,w=typeof i=="string"?document.getElementById(i):i;if(v&&w&&v.contains(w)){var r=lh(e,w,s);st(e,r,a,p)}}},Vt=function(e){return{instance:e,zoomIn:ch(e),zoomOut:dh(e),setTransform:hh(e),resetTransform:uh(e),centerView:fh(e),zoomToElement:mh(e)}},Bs=function(e){return{instance:e,state:e.transformState}},de=function(e){var i={};return Object.assign(i,Bs(e)),Object.assign(i,Vt(e)),i},_s=!1;function bs(){try{var e={get passive(){return _s=!0,!1}};return e}catch{return _s=!1,_s}}var zt=".".concat(Ds.wrapperClass),ts=function(e,i){return i.some(function(s){return e.matches("".concat(zt," ").concat(s,", ").concat(zt," .").concat(s,", ").concat(zt," ").concat(s," *, ").concat(zt," .").concat(s," *"))})},Os=function(e){e&&clearTimeout(e)},ph=function(e,i,s){return"translate(".concat(e,"px, ").concat(i,"px) scale(").concat(s,")")},an=function(e,i,s){var a=s.offsetWidth*e,p=s.offsetHeight*e,v=(i.offsetWidth-a)/2,w=(i.offsetHeight-p)/2;return{scale:e,positionX:v,positionY:w}};function gh(e){return function(i){e.forEach(function(s){typeof s=="function"?s(i):s!=null&&(s.current=i)})}}var vh=function(e,i){var s=e.setup.wheel,a=s.disabled,p=s.wheelDisabled,v=s.touchPadDisabled,w=s.excluded,r=e.isInitialized,o=e.isPanning,u=i.target,f=r&&!o&&!a&&u;if(!f||p&&!i.ctrlKey||v&&i.ctrlKey)return!1;var l=ts(u,w);return!l},_h=function(e){return e?e.deltaY<0?1:-1:0};function bh(e,i){var s=_h(e),a=Ld(i,s);return a}function ln(e,i,s){var a=i.getBoundingClientRect(),p=0,v=0;if("clientX"in e)p=(e.clientX-a.left)/s,v=(e.clientY-a.top)/s;else{var w=e.touches[0];p=(w.clientX-a.left)/s,v=(w.clientY-a.top)/s}return(Number.isNaN(p)||Number.isNaN(v))&&console.error("No mouse or touch offset found"),{x:p,y:v}}var xh=function(e,i,s,a,p){var v=e.transformState.scale,w=e.wrapperComponent,r=e.setup,o=r.maxScale,u=r.minScale,f=r.zoomAnimation,l=r.disablePadding,g=f.size,m=f.disabled;if(!w)throw new Error("Wrapper is not mounted");var y=v+i*s,b=a?!1:!m,n=Mt(Me(y,3),u,o,g,b&&!l);return n},Sh=function(e,i){var s=e.previousWheelEvent,a=e.transformState.scale,p=e.setup,v=p.maxScale,w=p.minScale;return s?a<v||a>w||Math.sign(s.deltaY)!==Math.sign(i.deltaY)||s.deltaY>0&&s.deltaY<i.deltaY||s.deltaY<0&&s.deltaY>i.deltaY||Math.sign(s.deltaY)!==Math.sign(i.deltaY):!1},yh=function(e,i){var s=e.setup.pinch,a=s.disabled,p=s.excluded,v=e.isInitialized,w=i.target,r=v&&!a&&w;if(!r)return!1;var o=ts(w,p);return!o},wh=function(e){var i=e.setup.pinch.disabled,s=e.isInitialized,a=e.pinchStartDistance,p=s&&!i&&a;return!!p},Ch=function(e,i,s){var a=s.getBoundingClientRect(),p=e.touches,v=Me(p[0].clientX-a.left,5),w=Me(p[0].clientY-a.top,5),r=Me(p[1].clientX-a.left,5),o=Me(p[1].clientY-a.top,5);return{x:(v+r)/2/i,y:(w+o)/2/i}},cn=function(e){return Math.sqrt(Math.pow(e.touches[0].pageX-e.touches[1].pageX,2)+Math.pow(e.touches[0].pageY-e.touches[1].pageY,2))},kh=function(e,i){var s=e.pinchStartScale,a=e.pinchStartDistance,p=e.setup,v=p.maxScale,w=p.minScale,r=p.zoomAnimation,o=p.disablePadding,u=r.size,f=r.disabled;if(!s||a===null||!i)throw new Error("Pinch touches distance was not provided");if(i<0)return e.transformState.scale;var l=i/a,g=l*s;return Mt(Me(g,2),w,v,u,!f&&!o)},Eh=160,jh=100,Th=function(e,i){var s=e.props,a=s.onWheelStart,p=s.onZoomStart;e.wheelStopEventTimer||(Be(e),fe(de(e),i,a),fe(de(e),i,p))},Nh=function(e,i){var s=e.props,a=s.onWheel,p=s.onZoom,v=e.contentComponent,w=e.setup,r=e.transformState,o=r.scale,u=w.limitToBounds,f=w.centerZoomedOut,l=w.zoomAnimation,g=w.wheel,m=w.disablePadding,y=w.smooth,b=l.size,n=l.disabled,d=g.step,c=g.smoothStep;if(!v)throw new Error("Component not mounted");i.preventDefault(),i.stopPropagation();var h=bh(i,null),_=y?c*Math.abs(i.deltaY):d,S=xh(e,h,_,!i.ctrlKey);if(o!==S){var k=ct(e,S),E=ln(i,v,o),x=n||b===0||f||m,C=u&&x,N=es(e,E.x,E.y,S,k,C),L=N.x,R=N.y;e.previousWheelEvent=i,e.setTransformState(S,L,R),fe(de(e),i,a),fe(de(e),i,p)}},Ah=function(e,i){var s=e.props,a=s.onWheelStop,p=s.onZoomStop;Os(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(tn(e,i.x,i.y),e.wheelAnimationTimer=null)},jh);var v=Sh(e,i);v&&(Os(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,fe(de(e),i,a),fe(de(e),i,p))},Eh))},dn=function(e){for(var i=0,s=0,a=0;a<2;a+=1)i+=e.touches[a].clientX,s+=e.touches[a].clientY;var p=i/2,v=s/2;return{x:p,y:v}},Rh=function(e,i){var s=cn(i);e.pinchStartDistance=s,e.lastDistance=s,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var a=dn(i);e.pinchLastCenterX=a.x,e.pinchLastCenterY=a.y,Be(e)},Lh=function(e,i){var s=e.contentComponent,a=e.pinchStartDistance,p=e.wrapperComponent,v=e.transformState.scale,w=e.setup,r=w.limitToBounds,o=w.centerZoomedOut,u=w.zoomAnimation,f=w.alignmentAnimation,l=u.disabled,g=u.size;if(!(a===null||!s)){var m=Ch(i,v,s);if(!(!Number.isFinite(m.x)||!Number.isFinite(m.y))){var y=cn(i),b=kh(e,y),n=dn(i),d=n.x-(e.pinchLastCenterX||0),c=n.y-(e.pinchLastCenterY||0);if(!(b===v&&d===0&&c===0)){e.pinchLastCenterX=n.x,e.pinchLastCenterY=n.y;var h=ct(e,b),_=l||g===0||o,S=r&&_,k=es(e,m.x,m.y,b,h,S),E=k.x,x=k.y;e.pinchMidpoint=m,e.lastDistance=y;var C=f.sizeX,N=f.sizeY,L=et(e,C),R=et(e,N),P=E+d,F=x+c,B=Lt(P,F,h,r,L,R,p),H=B.x,U=B.y;e.setTransformState(b,H,U)}}}},Mh=function(e){var i=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,tn(e,i?.x,i?.y)},hn=function(e,i){var s=e.props.onZoomStop,a=e.setup.doubleClick.animationTime;Os(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,fe(de(e),i,s)},a)},Ph=function(e,i){var s=e.props,a=s.onZoomStart,p=s.onZoom,v=e.setup.doubleClick,w=v.animationTime,r=v.animationType;fe(de(e),i,a),on(e,w,r,function(){return fe(de(e),i,p)}),hn(e,i)};function Dh(e,i){return e==="toggle"?i===1?1:-1:e==="zoomOut"?-1:1}function Bh(e,i){var s=e.setup,a=e.doubleClickStopEventTimer,p=e.transformState,v=e.contentComponent,w=p.scale,r=e.props,o=r.onZoomStart,u=r.onZoom,f=s.doubleClick,l=f.disabled,g=f.mode,m=f.step,y=f.animationTime,b=f.animationType;if(!l&&!a){if(g==="reset")return Ph(e,i);if(!v)return console.error("No ContentComponent found");var n=Dh(g,e.transformState.scale),d=rn(e,n,m);if(w!==d){fe(de(e),i,o);var c=ln(i,v,w),h=tr(e,d,c.x,c.y);if(!h)return console.error("Error during zoom event. New transformation state was not calculated.");fe(de(e),i,u),st(e,h,y,b),hn(e,i)}}}var Oh=function(e,i){var s=e.isInitialized,a=e.setup,p=e.wrapperComponent,v=a.doubleClick,w=v.disabled,r=v.excluded,o=i.target,u=p?.contains(o),f=s&&o&&u&&!w;if(!f)return!1;var l=ts(o,r);return!l},Ih=(function(){function e(i){var s=this;this.mounted=!0,this.pinchLastCenterX=null,this.pinchLastCenterY=null,this.onChangeCallbacks=new Set,this.onInitCallbacks=new Set,this.wrapperComponent=null,this.contentComponent=null,this.isInitialized=!1,this.bounds=null,this.previousWheelEvent=null,this.wheelStopEventTimer=null,this.wheelAnimationTimer=null,this.isPanning=!1,this.isWheelPanning=!1,this.startCoords=null,this.lastTouch=null,this.distance=null,this.lastDistance=null,this.pinchStartDistance=null,this.pinchStartScale=null,this.pinchMidpoint=null,this.doubleClickStopEventTimer=null,this.velocity=null,this.velocityTime=null,this.lastMousePosition=null,this.animate=!1,this.animation=null,this.maxBounds=null,this.pressedKeys={},this.mount=function(){s.initializeWindowEvents()},this.unmount=function(){s.cleanupWindowEvents()},this.update=function(a){s.props=a,ct(s,s.transformState.scale),s.setup=Ir(a)},this.initializeWindowEvents=function(){var a,p,v=bs(),w=(a=s.wrapperComponent)===null||a===void 0?void 0:a.ownerDocument,r=w?.defaultView;(p=s.wrapperComponent)===null||p===void 0||p.addEventListener("wheel",s.onWheelPanning,v),r?.addEventListener("mousedown",s.onPanningStart,v),r?.addEventListener("mousemove",s.onPanning,v),r?.addEventListener("mouseup",s.onPanningStop,v),w?.addEventListener("mouseleave",s.clearPanning,v),r?.addEventListener("keyup",s.setKeyUnPressed,v),r?.addEventListener("keydown",s.setKeyPressed,v)},this.cleanupWindowEvents=function(){var a,p,v=bs(),w=(a=s.wrapperComponent)===null||a===void 0?void 0:a.ownerDocument,r=w?.defaultView;r?.removeEventListener("mousedown",s.onPanningStart,v),r?.removeEventListener("mousemove",s.onPanning,v),r?.removeEventListener("mouseup",s.onPanningStop,v),w?.removeEventListener("mouseleave",s.clearPanning,v),r?.removeEventListener("keyup",s.setKeyUnPressed,v),r?.removeEventListener("keydown",s.setKeyPressed,v),document.removeEventListener("mouseleave",s.clearPanning,v),Be(s),(p=s.observer)===null||p===void 0||p.disconnect()},this.handleInitializeWrapperEvents=function(a){var p=bs();a.addEventListener("wheel",s.onWheelZoom,p),a.addEventListener("dblclick",s.onDoubleClick,p),a.addEventListener("touchstart",s.onTouchPanningStart,p),a.addEventListener("touchmove",s.onTouchPanning,p),a.addEventListener("touchend",s.onTouchPanningStop,p)},this.handleInitialize=function(a,p){var v=!1,w=s.setup.centerOnInit,r=function(o,u){for(var f=0,l=o;f<l.length;f++){var g=l[f];if(g.target===u)return!0}return!1};s.applyTransformation(),s.onInitCallbacks.forEach(function(o){o(de(s))}),s.observer=new ResizeObserver(function(o){if(r(o,a)||r(o,p))if(w&&!v){var u=p.offsetWidth,f=p.offsetHeight;(u>0||f>0)&&(v=!0,s.setCenter())}else Be(s),ct(s,s.transformState.scale),er(s,0)}),s.observer.observe(a),s.observer.observe(p)},this.onWheelZoom=function(a){var p=s.setup.disabled;if(!p){var v=vh(s,a);if(v){var w=s.isPressingKeys(s.setup.wheel.activationKeys);w&&(Th(s,a),Nh(s,a),Ah(s,a))}}},this.onWheelPanning=function(a){var p=s.setup,v=p.disabled,w=p.wheel,r=p.panning;if(!(!s.wrapperComponent||!s.contentComponent||v||!w.wheelDisabled||r.disabled||!r.wheelPanning||a.ctrlKey)){a.preventDefault(),a.stopPropagation();var o=s.transformState,u=o.positionX,f=o.positionY,l=u-a.deltaX,g=f-a.deltaY,m=r.lockAxisX?u:l,y=r.lockAxisY?f:g,b=s.setup.alignmentAnimation,n=b.sizeX,d=b.sizeY,c=et(s,n),h=et(s,d);m===u&&y===f||en(s,m,y,c,h)}},this.onPanningStart=function(a){var p=s.setup.disabled,v=s.props.onPanningStart;if(!p){var w=Lr(s,a);if(w){var r=s.isPressingKeys(s.setup.panning.activationKeys);r&&(a.button===0&&!s.setup.panning.allowLeftClickPan||a.button===1&&!s.setup.panning.allowMiddleClickPan||a.button===2&&!s.setup.panning.allowRightClickPan||(a.preventDefault(),a.stopPropagation(),Be(s),Dr(s,a),fe(de(s),a,v)))}}},this.onPanning=function(a){var p=s.setup.disabled,v=s.props.onPanning;if(!p){var w=Mr(s);if(w){var r=s.isPressingKeys(s.setup.panning.activationKeys);r&&(a.preventDefault(),a.stopPropagation(),Br(s,a.clientX,a.clientY),fe(de(s),a,v))}}},this.onPanningStop=function(a){var p=s.props.onPanningStop;s.isPanning&&(oh(s),fe(de(s),a,p))},this.onPinchStart=function(a){var p=s.setup.disabled,v=s.props,w=v.onPinchingStart,r=v.onZoomStart;if(!p){var o=yh(s,a);o&&(Rh(s,a),Be(s),fe(de(s),a,w),fe(de(s),a,r))}},this.onPinch=function(a){var p=s.setup.disabled,v=s.props,w=v.onPinching,r=v.onZoom;if(!p){var o=wh(s);o&&(a.preventDefault(),a.stopPropagation(),Lh(s,a),fe(de(s),a,w),fe(de(s),a,r))}},this.onPinchStop=function(a){var p=s.props,v=p.onPinchingStop,w=p.onZoomStop;s.pinchStartScale&&(Mh(s),fe(de(s),a,v),fe(de(s),a,w))},this.onTouchPanningStart=function(a){var p=s.setup.disabled,v=s.props.onPanningStart;if(!p){var w=Lr(s,a);if(w){var r=s.lastTouch&&+new Date-s.lastTouch<200&&a.touches.length===1;if(!r){s.lastTouch=+new Date,Be(s);var o=a.touches,u=o.length===1,f=o.length===2;u&&(Be(s),Dr(s,a),fe(de(s),a,v)),f&&s.onPinchStart(a)}}}},this.onTouchPanning=function(a){var p=s.setup.disabled,v=s.props.onPanning;if(s.isPanning&&a.touches.length===1){if(p)return;var w=Mr(s);if(!w)return;a.preventDefault(),a.stopPropagation();var r=a.touches[0];Br(s,r.clientX,r.clientY),fe(de(s),a,v)}else a.touches.length>1&&s.onPinch(a)},this.onTouchPanningStop=function(a){s.onPanningStop(a),s.onPinchStop(a)},this.onDoubleClick=function(a){var p=s.setup.disabled;if(!p){var v=Oh(s,a);v&&Bh(s,a)}},this.clearPanning=function(a){s.isPanning&&s.onPanningStop(a)},this.setKeyPressed=function(a){s.pressedKeys[a.key]=!0},this.setKeyUnPressed=function(a){s.pressedKeys[a.key]=!1},this.isPressingKeys=function(a){return a.length?!!a.find(function(p){return s.pressedKeys[p]}):!0},this.setTransformState=function(a,p,v){var w=s.props.onTransformed;if(!Number.isNaN(a)&&!Number.isNaN(p)&&!Number.isNaN(v)){a!==s.transformState.scale&&(s.transformState.previousScale=s.transformState.scale,s.transformState.scale=a),s.transformState.positionX=p,s.transformState.positionY=v,s.applyTransformation();var r=de(s);s.onChangeCallbacks.forEach(function(o){return o(r)}),fe(r,{scale:a,positionX:p,positionY:v},w)}else console.error("Detected NaN set state values")},this.setCenter=function(){if(s.wrapperComponent&&s.contentComponent){var a=an(s.transformState.scale,s.wrapperComponent,s.contentComponent);s.setTransformState(a.scale,a.positionX,a.positionY)}},this.handleTransformStyles=function(a,p,v){return s.props.customTransform?s.props.customTransform(a,p,v):ph(a,p,v)},this.applyTransformation=function(){if(!(!s.mounted||!s.contentComponent)){var a=s.transformState,p=a.scale,v=a.positionX,w=a.positionY,r=s.handleTransformStyles(v,w,p);s.contentComponent.style.transform=r}},this.getContext=function(){return de(s)},this.onChange=function(a){return s.onChangeCallbacks.has(a)||s.onChangeCallbacks.add(a),function(){s.onChangeCallbacks.delete(a)}},this.onInit=function(a){return s.onInitCallbacks.has(a)||s.onInitCallbacks.add(a),function(){s.onInitCallbacks.delete(a)}},this.init=function(a,p){s.cleanupWindowEvents(),s.wrapperComponent=a,s.contentComponent=p,ct(s,s.transformState.scale),s.handleInitializeWrapperEvents(a),s.handleInitialize(a,p),s.initializeWindowEvents(),s.isInitialized=!0;var v=de(s);fe(v,void 0,s.props.onInit)},this.props=i,this.setup=Ir(this.props),this.transformState=sn(this.props)}return e})(),ss=_e.createContext(null),Fh=function(e,i){return typeof e=="function"?e(i):e},Hh=_e.forwardRef(function(e,i){var s=A.useRef(new Ih(e)).current,a=Fh(e.children,Vt(s));return A.useImperativeHandle(i,function(){return Vt(s)},[s]),A.useEffect(function(){s.update(e)},[s,e]),_e.createElement(ss.Provider,{value:s},a)});_e.forwardRef(function(e,i){var s=A.useRef(null),a=A.useContext(ss);return A.useEffect(function(){return a.onChange(function(p){if(s.current){var v=0,w=0;s.current.style.transform=a.handleTransformStyles(v,w,1/p.instance.transformState.scale)}})},[a]),_e.createElement("div",Qe({},e,{ref:gh([s,i])}))});function zh(e,i){i===void 0&&(i={});var s=i.insertAt;if(!(typeof document>"u")){var a=document.head||document.getElementsByTagName("head")[0],p=document.createElement("style");p.type="text/css",s==="top"&&a.firstChild?a.insertBefore(p,a.firstChild):a.appendChild(p),p.styleSheet?p.styleSheet.cssText=e:p.appendChild(document.createTextNode(e))}}var Wh=`.transform-component-module_wrapper__SPB86 {
|
|
30
|
+
position: relative;
|
|
31
|
+
width: -moz-fit-content;
|
|
32
|
+
width: fit-content;
|
|
33
|
+
height: -moz-fit-content;
|
|
34
|
+
height: fit-content;
|
|
35
|
+
overflow: hidden;
|
|
36
|
+
-webkit-touch-callout: none; /* iOS Safari */
|
|
37
|
+
-webkit-user-select: none; /* Safari */
|
|
38
|
+
-khtml-user-select: none; /* Konqueror HTML */
|
|
39
|
+
-moz-user-select: none; /* Firefox */
|
|
40
|
+
-ms-user-select: none; /* Internet Explorer/Edge */
|
|
41
|
+
user-select: none;
|
|
42
|
+
margin: 0;
|
|
43
|
+
padding: 0;
|
|
44
|
+
transform: translate3d(0, 0, 0);
|
|
45
|
+
}
|
|
46
|
+
.transform-component-module_content__FBWxo {
|
|
47
|
+
display: flex;
|
|
48
|
+
flex-wrap: wrap;
|
|
49
|
+
width: -moz-fit-content;
|
|
50
|
+
width: fit-content;
|
|
51
|
+
height: -moz-fit-content;
|
|
52
|
+
height: fit-content;
|
|
53
|
+
margin: 0;
|
|
54
|
+
padding: 0;
|
|
55
|
+
transform-origin: 0% 0%;
|
|
56
|
+
}
|
|
57
|
+
.transform-component-module_content__FBWxo img {
|
|
58
|
+
pointer-events: none;
|
|
59
|
+
}
|
|
60
|
+
`,Fr={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};zh(Wh);var $h=function(e){var i=e.children,s=e.wrapperClass,a=s===void 0?"":s,p=e.contentClass,v=p===void 0?"":p,w=e.wrapperStyle,r=e.contentStyle,o=e.wrapperProps,u=o===void 0?{}:o,f=e.contentProps,l=f===void 0?{}:f,g=A.useContext(ss),m=g.init,y=g.cleanupWindowEvents,b=A.useRef(null),n=A.useRef(null);return A.useEffect(function(){var d=b.current,c=n.current;return d!==null&&c!==null&&m&&m?.(d,c),function(){y?.()}},[]),_e.createElement("div",Qe({},u,{ref:b,className:"".concat(Ds.wrapperClass," ").concat(Fr.wrapper," ").concat(a),style:w}),_e.createElement("div",Qe({},l,{ref:n,className:"".concat(Ds.contentClass," ").concat(Fr.content," ").concat(v),style:r}),i))},un=function(){var e=A.useContext(ss);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},Uh=function(){var e=un();return Vt(e)};function qh(e){var i=un(),s=A.useState(e(Bs(i))),a=s[0],p=s[1];return A.useEffect(function(){var v=!0,w=i.onChange(function(r){v&&p(e(Bs(r.instance)))});return function(){w(),v=!1}},[e,i]),a}function Kh(e){switch(e.split(".").pop()?.toLowerCase()){case"ts":case"tsx":return"typescript";case"js":case"jsx":case"mjs":case"cjs":return"javascript";case"json":return"json";case"md":case"mdx":return"markdown";case"css":return"css";case"scss":return"scss";case"html":return"html";case"yml":case"yaml":return"yaml";case"sh":return"shell";case"py":return"python";case"go":return"go";case"rs":return"rust";default:return"plaintext"}}function Xh(e,i){return Ee({queryKey:ie.files.tree(e||"",i),queryFn:()=>ne.get("/files/tree",{params:{workingDir:e||"",path:i}}),enabled:!!e})}function Yh(e,i){return Ee({queryKey:ie.files.content(e||"",i||""),queryFn:()=>ne.get("/files/read",{params:{workingDir:e||"",path:i||""}}),enabled:!!e&&!!i})}function Vh(e){const i=Pe();return A.useCallback(()=>{e&&i.invalidateQueries({queryKey:["files","tree",e]})},[i,e])}function Gh(){const e=Pe();return Ct({mutationFn:i=>ne.post("/files/write",i),onSuccess:(i,s)=>{const a=ie.files.content(s.workingDir,s.path),p=e.getQueryData(a);e.setQueryData(a,{content:s.content,language:p?.language||Kh(s.path)})}})}function Qh(e,i){return e==="/"?`/${i}`:`${e}/${i}`}function Zh(e,i){return e==="/"?i:`${e.slice(1)}/${i}`}const Hr=({depth:e,active:i,onClick:s,leftIcon:a,rightIcon:p,label:v})=>t.jsxs("button",{type:"button",onClick:s,"aria-current":i||void 0,className:Q("w-full flex items-center gap-2 rounded-md px-2 py-1 text-left text-xs transition-colors outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/60",i?"bg-foreground/[0.06] font-medium text-foreground":"text-foreground/90 hover:bg-accent"),style:{paddingLeft:8+e*14},children:[t.jsx("span",{className:"shrink-0",children:p}),t.jsx("span",{className:"shrink-0 text-muted-foreground",children:a}),t.jsx("span",{className:"truncate",children:v})]}),fn=({workingDir:e,path:i,depth:s,expanded:a,toggleDir:p,onFileSelect:v,selectedFilePath:w})=>{const{t:r}=re(),{data:o,isLoading:u,isError:f}=Xh(e,i),l=A.useMemo(()=>o?.items??[],[o?.items]);return u?t.jsx("div",{className:"text-xs text-muted-foreground px-2 py-1",style:{paddingLeft:8+s*14},children:r("Loading...")}):f?t.jsx("div",{className:"text-xs text-destructive-ink px-2 py-1",style:{paddingLeft:8+s*14},children:r("Failed to load")}):t.jsx("div",{className:"space-y-0.5",children:l.map(g=>{if(g.type==="directory"){const b=Qh(i,g.name),n=a.has(b);return t.jsxs("div",{children:[t.jsx(Hr,{depth:s,onClick:()=>p(b),rightIcon:n?t.jsx(Ke,{size:14,className:"text-muted-foreground/70"}):t.jsx(Je,{size:14,className:"text-muted-foreground/70"}),leftIcon:n?t.jsx(gi,{size:14}):t.jsx(qs,{size:14}),label:g.name}),n&&t.jsx(fn,{workingDir:e,path:b,depth:s+1,expanded:a,toggleDir:p,onFileSelect:v,selectedFilePath:w})]},b)}const m=Zh(i,g.name),y=w===m;return t.jsx(Hr,{depth:s,active:y,onClick:()=>v(m),rightIcon:t.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:t.jsx(Io,{name:g.name}),label:g.name},m)})})},Jh=({workingDir:e,className:i,onFileSelect:s,selectedFilePath:a,onCollapse:p})=>{const{t:v}=re(),[w,r]=A.useState(()=>new Set),o=Vh(e),u=A.useCallback(f=>{r(l=>{const g=new Set(l);return g.has(f)?g.delete(f):g.add(f),g})},[]);return t.jsxs("div",{className:Q("h-full flex flex-col",i),children:[t.jsxs("div",{className:"px-3 py-2 border-b border-border bg-muted/40 flex items-center justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:v("Files")}),e?t.jsx("div",{title:e,className:"truncate font-mono text-[11px] text-muted-foreground",children:e}):t.jsx("div",{className:"truncate text-xs text-muted-foreground",children:v("No working directory")})]}),t.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e&&t.jsx($e,{size:"xs",label:v("Refresh file tree"),onClick:o,children:t.jsx(_t,{})}),p&&t.jsx($e,{size:"xs",label:v("Collapse file tree"),onClick:p,children:t.jsx(Na,{})})]})]}),t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin p-2",children:e?t.jsx(fn,{workingDir:e,path:"/",depth:0,expanded:w,toggleDir:u,onFileSelect:s,selectedFilePath:a}):t.jsx("div",{className:"text-xs text-muted-foreground px-2 py-2",children:v("No workspace selected.")})})]})},eu=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function tu(e){const i=e.split(".").pop()?.toLowerCase();return i?eu.has(i):!1}function su(e,i){const s=$s(),a=new URLSearchParams({workingDir:e,path:i});return`${s}/files/image?${a.toString()}`}const ru=({filePath:e})=>{const{t:i}=re(),{zoomIn:s,zoomOut:a,centerView:p}=Uh(),v=qh(r=>r.state.scale),w=Math.round(v*100);return t.jsxs("div",{className:"flex items-center gap-1 px-3 py-1.5 border-b border-border bg-muted/40 shrink-0",children:[t.jsx($e,{size:"xs",label:i("Zoom out"),onClick:()=>a(.5),children:t.jsx(Wa,{})}),t.jsxs(ce,{variant:"ghost",size:"xs",className:"min-w-10 tabular-nums",onClick:()=>p(1),title:i("Reset zoom"),children:[w,"%"]}),t.jsx($e,{size:"xs",label:i("Zoom in"),onClick:()=>s(.5),children:t.jsx(Ha,{})}),t.jsx($e,{size:"xs",label:i("Fit to view"),className:"ml-1",onClick:()=>p(1),children:t.jsx(ka,{})}),t.jsx("span",{title:e,className:"ml-2 truncate font-mono text-[11px] text-muted-foreground",children:e})]})},iu=({workingDir:e,filePath:i})=>{const{t:s}=re(),[a,p]=A.useState(!1),v=su(e,i);return a?t.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:s("Failed to load image.")}):t.jsx(Hh,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx(ru,{filePath:i}),t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden bg-[repeating-conic-gradient(#f3f3f3_0%_25%,#fff_0%_50%)] bg-[length:16px_16px]",children:t.jsx($h,{wrapperStyle:{width:"100%",height:"100%"},contentStyle:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx("img",{src:v,alt:i,className:"max-w-full max-h-full object-contain rounded shadow-raised",draggable:!1,onError:()=>p(!0)})})})]})})};function nu(e){const i=e.split("/");return i[i.length-1]||e}function ou(e){switch(e.split(".").pop()?.toLowerCase()){case"ts":case"tsx":return"typescript";case"js":case"jsx":case"mjs":case"cjs":return"javascript";case"json":return"json";case"md":case"mdx":return"markdown";case"css":return"css";case"scss":return"scss";case"html":return"html";case"yml":case"yaml":return"yaml";case"sh":return"shell";case"py":return"python";case"go":return"go";case"rs":return"rust";default:return"plaintext"}}const au=({active:e,name:i,isDirty:s,onClick:a,onClose:p})=>{const{t:v}=re();return t.jsxs("button",{type:"button",onClick:a,className:Q("group flex items-center gap-2 px-3 py-2 rounded-t-md border-t border-x -mb-px min-w-[120px] max-w-[240px] outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/60",e?"bg-background border-border text-foreground":"bg-foreground/[0.03] border-transparent text-muted-foreground hover:text-foreground hover:bg-foreground/[0.05]"),children:[t.jsx("span",{className:Q("w-2 h-2 rounded-full",s?"bg-warning":"bg-transparent")}),t.jsx("span",{className:"truncate flex-1 text-left text-xs",children:i}),t.jsx("span",{onClick:p,className:"opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100 pointer-coarse:opacity-100 p-0.5 hover:bg-foreground/[0.08] rounded transition-all shrink-0","aria-label":v("Close tab"),title:v("Close"),children:t.jsx(tt,{size:12})})]})},lu=_e.forwardRef(function({workingDir:i,className:s,readOnly:a=!1},p){const{t:v}=re(),[w,r]=A.useState([]),[o,u]=A.useState(null),[f,l]=A.useState(!1),[g,m]=A.useState(!1),[y,b]=A.useState(0),[n,d]=A.useState(null),c=A.useRef(null),h=Gh();A.useEffect(()=>{let $=!1;return Yn(async()=>{const{preloadMonaco:z}=await import("./monaco-B-6VmJO0.js").then(W=>W.m);return{preloadMonaco:z}},__vite__mapDeps([0,1,2,3])).then(({preloadMonaco:z})=>z()).then(()=>{$||l(!0)}).catch(()=>{$||m(!0)}),()=>{$=!0}},[]);const[_,S]=A.useState(280),[k,E]=A.useState(!1),[x,C]=A.useState(!1),N=A.useRef(280),L=A.useCallback(()=>{E($=>($?S(N.current):N.current=_,!$))},[_]),R=A.useCallback($=>{$.preventDefault(),C(!0);const z=$.clientX,W=_,j=K=>{const X=K.clientX-z,J=Math.min(480,Math.max(160,W+X));S(J)},I=()=>{C(!1),document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",I)};document.addEventListener("mousemove",j),document.addEventListener("mouseup",I)},[_]);A.useEffect(()=>{r([]),u(null),d(null)},[i]);const P=A.useMemo(()=>w.find($=>$.path===o)||null,[w,o]),{data:F,isFetching:B,isError:H,error:U}=Yh(i,P?.isImage?null:o);A.useEffect(()=>{!o||!F||r($=>$.map(z=>z.path!==o||z.isDirty||z.loaded?z:{...z,language:F.language||z.language,content:F.content,savedContent:F.content,isDirty:!1,loaded:!0}))},[o,F]);const T=A.useCallback(($,z,W)=>{r(j=>{if(j.find(X=>X.path===$))return j;const K=tu($);return[...j,{path:$,name:nu($),language:ou($),content:"",savedContent:"",isDirty:!1,loaded:K,isImage:K}]}),u($),d(z?{path:$,line:z,column:W}:null)},[]);_e.useImperativeHandle(p,()=>({openFile:T}),[T]);const D=A.useCallback($=>{r(z=>{const W=z.filter(j=>j.path!==$);return u(j=>j!==$?j:W.length?W[W.length-1].path:null),W})},[]),M=A.useCallback($=>{r(z=>z.map(W=>{if(W.path!==o)return W;const j=$!==W.savedContent;return{...W,content:$,isDirty:j}}))},[o]),O=A.useCallback(async()=>{a||!i||!P||(await h.mutateAsync({workingDir:i,path:P.path,content:P.content}),r($=>$.map(z=>z.path===P.path?{...z,savedContent:z.content,isDirty:!1,loaded:!0}:z)))},[P,a,h,i]),q=A.useRef(()=>{});A.useEffect(()=>{q.current=()=>{O().catch(()=>{})}},[O]),A.useEffect(()=>{const $=z=>{a||(z.metaKey||z.ctrlKey)&&z.key.toLowerCase()==="s"&&(z.preventDefault(),q.current())};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[a]);const V=A.useCallback(($,z)=>{c.current=$,b(W=>W+1),$.addCommand(z.KeyMod.CtrlCmd|z.KeyCode.KeyS,()=>{q.current()})},[]);return A.useEffect(()=>{if(!n||n.path!==o||!P?.loaded)return;const $=c.current,z=$?.getModel();if(!$||!z)return;const W=Math.min(n.line,z.getLineCount()),j=Math.min(n.column??1,z.getLineMaxColumn(W)),I={lineNumber:W,column:j};$.setPosition(I),$.revealPositionInCenter(I),$.focus(),d(null)},[o,P?.loaded,y,n]),t.jsxs("div",{className:Q("flex h-full overflow-hidden bg-background",s),style:x?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsx("div",{className:"border-r border-border bg-background shrink-0 overflow-hidden relative",style:{width:k?36:_,transition:x?"none":"width 0.15s ease"},children:k?t.jsx("div",{className:"h-full flex items-start pt-2 justify-center",children:t.jsx($e,{size:"sm",label:v("Expand file tree"),onClick:L,children:t.jsx(Ra,{className:"size-4"})})}):t.jsx(t.Fragment,{children:t.jsx(Jh,{workingDir:i,onFileSelect:T,selectedFilePath:P?.path||null,onCollapse:L},i||"no-working-dir")})}),!k&&t.jsx("div",{onMouseDown:R,className:Q("w-1 shrink-0 cursor-col-resize transition-colors",x?"bg-ring/40":"bg-transparent hover:bg-border")}),t.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1 px-2 pt-2 border-b border-border bg-muted overflow-x-auto shrink-0",children:[w.length===0?t.jsx("div",{className:"px-2 pb-2 text-xs text-muted-foreground",children:v("No open files")}):w.map($=>t.jsx(au,{active:$.path===o,name:$.name,isDirty:$.isDirty,onClick:()=>u($.path),onClose:z=>{z.stopPropagation(),D($.path)}},$.path)),t.jsxs("div",{className:"ml-auto flex items-center gap-2 pb-2 pr-1",children:[a&&t.jsx("span",{className:"text-xs text-muted-foreground",children:v("Read-only")}),h.isPending&&t.jsxs("span",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[t.jsx(xe,{}),v("Saving")]}),P?.isDirty&&!h.isPending&&t.jsx("span",{className:"text-xs text-warning-ink",children:v("Unsaved")})]})]}),t.jsx("div",{className:"flex-1 min-h-0 relative",children:i?P?P.isImage?t.jsx(iu,{workingDir:i,filePath:P.path}):g?t.jsx("div",{className:"h-full flex items-center justify-center text-destructive-ink text-sm",children:v("Failed to load editor.")}):f?t.jsxs(t.Fragment,{children:[t.jsx(Rd,{path:P.path,value:P.content,language:P.language,theme:"vs-light",height:"100%",onChange:a?void 0:$=>M($??""),onMount:V,options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",automaticLayout:!0,readOnly:a}}),B&&!P.loaded&&t.jsx("div",{className:"absolute inset-0 bg-background/60 flex items-center justify-center",children:t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[t.jsx(xe,{}),v("Loading file...")]})}),H&&t.jsx("div",{className:"absolute bottom-2 left-2 right-2 rounded-md bg-background shadow-raised",children:t.jsxs(Oe,{tone:"danger",size:"sm",children:[v("Failed to load file"),U instanceof Error?`: ${U.message}`:""]})})]}):t.jsxs("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:[t.jsx(xe,{className:"mr-2"}),v("Loading editor...")]}):t.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:v("Select a file from the tree to open.")}):t.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:v("No workspace selected.")})})]})]})});function cu(e,i={}){const s=Qt(p=>p.visibleContext),a=Ci(e,s);return Ee({queryKey:ie.git.changes(e||""),queryFn:()=>ne.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e&&(i.enabled??!0),refetchInterval:a,refetchIntervalInBackground:!1,refetchOnWindowFocus:a?"always":!1,refetchOnReconnect:a?"always":!1})}function du(e,i,s){const a=Qt(v=>v.visibleContext),p=Ci(e,a);return Ee({queryKey:ie.git.diff(e||"",i||"",s),queryFn:()=>ne.get("/git/diff",{params:{workingDir:e||"",path:i||"",type:s}}),enabled:!!e&&!!i,refetchInterval:p,refetchIntervalInBackground:!1,refetchOnWindowFocus:p?"always":!1,refetchOnReconnect:p?"always":!1})}function mn(e,i){return Ee({queryKey:ie.git.commitFiles(e||"",i||""),queryFn:()=>ne.get("/git/commit-files",{params:{workingDir:e||"",hash:i||""}}),enabled:!!e&&!!i})}function pn(e,i,s){return Ee({queryKey:ie.git.commitDiff(e||"",i||"",s||""),queryFn:()=>ne.get("/git/commit-diff",{params:{workingDir:e||"",hash:i||"",path:s||""}}),enabled:!!e&&!!i&&!!s})}const hu=new Set(["STARTING","RUNNING","STOPPING"]);function gn(e){return hu.has(e.runtimeState)||e.runtimeInstanceId!==null}function vn(e){return e instanceof Ze&&e.status===409&&e.details.code==="WORKSPACE_HAS_ACTIVE_SERVICE"}const zr="h-6 min-w-0 truncate rounded-md bg-foreground/[0.05] px-2 font-mono text-xs leading-6 text-foreground/85";function uu({from:e,to:i}){return t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{title:e,className:zr,children:e}),t.jsx(Ai,{size:14,className:"shrink-0 text-muted-foreground/70"}),t.jsx("span",{title:i,className:zr,children:i})]})}function fu({services:e,isLoading:i,isError:s}){const{t:a}=re();return i?t.jsx(xe,{size:"xs",label:a("正在检查后台服务..."),className:"text-xs"}):e.length>0?t.jsxs(Oe,{tone:"warning",title:a("合并前将停止 {count} 个后台服务",{count:e.length}),children:[t.jsx("p",{className:"break-all font-mono text-xs",children:e.map(p=>p.name).join(", ")}),t.jsx("p",{className:"mt-1",children:a("停止后不会自动恢复。")})]}):s?t.jsx("p",{className:"text-xs text-warning-ink",role:"status",children:a("无法检查后台服务状态,提交时会再次确认。")}):null}const mu={INVALID_BASE_BRANCH:"Choose an existing local branch different from the workspace branch.",BASE_BRANCH_UNRELATED:"The selected branch has no shared commit history with this workspace.",WORKSPACE_BASE_BRANCH_BUSY:"Wait for the Agent to finish or stop it before changing the base branch.",WORKSPACE_GIT_OPERATION_IN_PROGRESS:"Finish or abort the current Git operation before changing the base branch.",WORKSPACE_BASE_BRANCH_CHANGED:"The workspace changed. Refresh and select the base branch again.",INVALID_WORKSPACE_STATE:"Only active workspaces can change base branch. Refresh the list.",WORKSPACE_BASE_BRANCH_MANAGED:"TeamRun member base branches are managed by their parent workspace."};function _n(e){return e.isOpen?t.jsx(pu,{...e},e.workspaceId):null}function pu({isOpen:e,onClose:i,onBaseBranchSaved:s,projectId:a,workspaceId:p,branchName:v,targetBranch:w,commitMessage:r,isPending:o,canMerge:u,activeServices:f,isCheckingServices:l,serviceCheckFailed:g,error:m,onConfirm:y}){const{t:b}=re(),n=A.useId(),d=Yo(a),c=Vo(),h=d.data?.workspaces.find(T=>T.id===p),_=h?.baseBranch||d.data?.mainBranch||w,[S,k]=A.useState(null),E=S??_,x=d.data?.branches.filter(T=>T!==v)??[],C=!!h&&E!==_,N=o||c.isPending,L=d.isPending||d.isFetching||d.isError,R=c.error instanceof Ze?String(c.error.details.code):"",[P,F]=A.useState(null),B=P??r??"",H=()=>{N||i()},U=async()=>{if(!(!h||!C))try{await c.mutateAsync({id:p,baseBranch:E,expectedBaseBranch:h.baseBranch}),ke.success(b("Workspace base branch saved. Review the changes before merging.")),i(),s?.()}catch{}};return t.jsx(At,{isOpen:e,onClose:H,title:b("提交变更"),className:"max-w-md",action:t.jsxs(t.Fragment,{children:[t.jsx(ce,{variant:"ghost",onClick:H,disabled:N,children:b("取消")}),t.jsx(ce,{variant:"primary",onClick:()=>y(B.trim()||void 0,f.length>0),disabled:N||l||L||C||!u,loading:o||l,children:o||l?l?b("正在检查后台服务..."):f.length>0?b("正在停止服务并提交..."):b("正在提交..."):t.jsxs(t.Fragment,{children:[t.jsx(Ks,{}),f.length>0?b("停止服务并提交"):b("确认提交")]})})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsx(uu,{from:v,to:h?_:w}),d.isPending?t.jsx("p",{className:"text-xs text-muted-foreground",children:b("Loading...")}):d.isError?t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{role:"alert",className:"text-xs text-destructive-ink",children:b("Could not load branches. Refresh to try again.")}),t.jsx(ce,{size:"sm",onClick:()=>{d.refetch()},children:b("Refresh")})]}):h&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:n,className:"block text-[13px] font-medium text-foreground",children:b("Base branch for this workspace")}),t.jsx(Go,{id:n,label:b("Base branch for this workspace"),value:E,branches:x,disabled:N,isRefreshing:d.isFetching,onOpen:()=>{d.refetch()},onChange:T=>{k(T),c.reset()}}),t.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:b("Changing this base branch updates the comparison, update and merge target for this workspace only. Save and review the changes before merging.")}),C&&t.jsx(ce,{variant:"primary",size:"sm",onClick:()=>{U()},disabled:N||L||!x.includes(E),children:c.isPending?b("Saving"):b("Save base branch and review changes")}),c.isError&&t.jsx("p",{role:"alert",className:"text-xs text-destructive-ink",children:b(mu[R]??"Could not save the base branch. Refresh and try again.")})]}),!u&&t.jsx("p",{className:"text-xs text-muted-foreground",children:b("Review the changes and sync the base branch before submitting.")}),t.jsx(vi,{label:b("提交消息"),description:t.jsxs(t.Fragment,{children:[b("建议以 feat、fix、docs、refactor、chore 开头,保持提交记录清晰。feat 新增功能,fix 修复问题,docs 文档更新,refactor 代码重构,chore 日常维护。"),!B.trim()&&t.jsx("span",{className:"mt-1 block",children:b("留空将使用默认消息")})]}),children:t.jsx(_i,{value:B,onChange:T=>F(T.target.value),placeholder:b("请描述本次修改的内容"),minRows:4,className:"font-mono"})}),t.jsx(fu,{services:f,isLoading:l,isError:g}),m&&t.jsx(Oe,{tone:"danger",children:m})]})})}function at(e,i){const s=e[i];return typeof s=="string"&&s.length>0?s:void 0}function bn(e){if(!(e instanceof Ze)||e.status!==409)return;const i=e.details;if(i.code!=="MERGE_CONFLICT"||i.conflictOp!==kt.REBASE&&i.conflictOp!==kt.MERGE||!Array.isArray(i.conflictedFiles)||!i.conflictedFiles.every(a=>typeof a=="string"))return;const s=i.mergeStrategy==="squash"||i.mergeStrategy==="no_ff"?i.mergeStrategy:void 0;return{conflictOp:i.conflictOp,conflictedFiles:i.conflictedFiles,mergeAborted:typeof i.mergeAborted=="boolean"?i.mergeAborted:void 0,mergeStrategy:s,sourceBranch:at(i,"sourceBranch"),targetBranch:at(i,"targetBranch"),sourceWorktreePath:at(i,"sourceWorktreePath"),targetWorktreePath:at(i,"targetWorktreePath"),sourceWorkspaceId:at(i,"sourceWorkspaceId"),targetWorkspaceId:at(i,"targetWorkspaceId"),resolutionContextToken:at(i,"resolutionContextToken")}}function Wr(e,i,s,a){const p=bn(e);if(p){s(p);return}a(e instanceof Error?e.message:i)}function gu({projectId:e,workspaceId:i,branchName:s,targetBranch:a,commitMessage:p,committedFileCount:v,onRefreshCommitMessage:w,onConflict:r,onResolveConflicts:o}){const{t:u}=re(),{data:f,isLoading:l}=Qo(i),g=ki(),m=Ei(),y=ji(),[b,n]=A.useState(!1),[d,c]=A.useState(null),h=Zs(i,b),_=(h.data??[]).filter(gn);if(A.useEffect(()=>{b&&w?.()},[b,w]),l||!f)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground border-b border-border/60",children:[t.jsx(xe,{}),t.jsx("span",{className:"text-xs",children:u("正在检查工作区状态...")})]});const S=f.conflictedFiles.length>0,k=f.operation!=="idle",E=f.hasUncommittedChanges||f.untrackedCount>0,x=f.uncommittedCount+f.untrackedCount,C=!S&&!k&&!E,N=!E,L=f.operation==="idle"&&f.ahead===0&&f.behind===0&&!E&&!S,R=()=>{c(null),g.mutate(i,{onError:H=>{Wr(H,u("更新失败,请稍后重试"),U=>r(U),c)}})},P=()=>{c(null),n(!0)},F=(H,U)=>{c(null),m.mutate({id:i,commitMessage:H,stopActiveServices:U},{onSuccess:()=>n(!1),onError:T=>{if(vn(T)){c(u("后台服务仍在运行,请确认停止服务后再提交。"));return}Wr(T,u("提交失败,请稍后重试"),D=>{n(!1),r(D)},c)}})},B=()=>{m.isPending||(n(!1),c(null))};return L?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground border-b border-border/60",children:[t.jsx(Vn,{size:13,className:"shrink-0 text-muted-foreground/70"}),t.jsx("span",{className:"text-xs",children:u("当前分支还没有任何变更")})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"border-b border-border bg-background",children:t.jsxs("div",{className:"px-3 py-2",children:[d&&t.jsx(Oe,{tone:"danger",size:"sm",className:"mb-2",children:d}),E&&t.jsx(Oe,{tone:"warning",size:"sm",icon:t.jsx(ya,{}),className:"mb-2",children:u("{count} 个本地改动未处理,需要先整理后再继续",{count:x})}),S&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-foreground",children:[t.jsx(Nt,{size:13,className:"shrink-0 text-warning"}),t.jsx("span",{children:u("{count} 个文件存在冲突,需要处理后继续",{count:f.conflictedFiles.length})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[t.jsx(ce,{variant:"primary",size:"sm",onClick:o,children:u("处理冲突")}),t.jsx(ce,{variant:"secondary",size:"sm",onClick:()=>y.mutate(i),loading:y.isPending,children:y.isPending?u("正在撤销..."):u("撤销操作")})]})]}),k&&!S&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-foreground",children:[t.jsx(xe,{size:"xs",className:"text-info"}),t.jsx("span",{children:f.operation==="rebase"?u("正在同步源分支更新..."):u("正在提交变更...")})]}),t.jsxs(ce,{variant:"secondary",size:"sm",className:"ml-auto",onClick:()=>y.mutate(i),loading:y.isPending,children:[!y.isPending&&t.jsx(ti,{}),y.isPending?u("正在撤销..."):u("撤销操作")]})]}),!S&&!k&&(f.behind>0||f.ahead>0)&&t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[f.behind>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:u("源分支 {branch} 有 {count} 个更新",{branch:a,count:f.behind})}),t.jsxs(ce,{variant:"primary",size:"sm",onClick:R,disabled:!C,loading:g.isPending,children:[!g.isPending&&t.jsx(_t,{}),g.isPending?u("正在同步..."):u("同步更新")]})]}),f.ahead>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:u("{count} 个文件变更,可以安全提交",{count:v??f.ahead})}),t.jsx("span",{title:N?void 0:u("需要先处理本地改动"),className:Q("inline-flex",!N&&"cursor-not-allowed"),children:t.jsxs(ce,{variant:"primary",size:"sm",onClick:P,disabled:!N||m.isPending,children:[t.jsx(Ks,{}),u("提交变更")]})})]})]})]})}),t.jsx(_n,{projectId:e,workspaceId:i,canMerge:C&&f.ahead>0&&f.behind===0,isOpen:b,onClose:B,branchName:s,targetBranch:a,commitMessage:p,isPending:m.isPending,activeServices:_,isCheckingServices:h.isLoading,serviceCheckFailed:h.isError,error:d,onConfirm:F})]})}const xn=({line:e,lineNum:i})=>{let s="",a="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?s="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?s="bg-destructive/10":e.startsWith("@@")?(s="bg-info/5",a="text-info-ink"):(e.startsWith("diff ")||e.startsWith("index "))&&(a="text-muted-foreground"),t.jsxs("div",{className:Q("flex",s),children:[t.jsx("span",{"aria-hidden":"true",className:"w-10 shrink-0 select-none border-r border-border/60 pr-2 text-right text-muted-foreground/50",children:i}),t.jsx("span",{className:Q("whitespace-pre pl-2",a),children:e})]})},xs=50,Ss=400;function Sn(e){const i=e.split("/");return i[i.length-1]||e}function vu(e){const i=e.lastIndexOf("/");return i>0?e.slice(0,i):""}function _u(e){const s=Math.floor(Date.now()/1e3)-e;return s<60?Ye("{count}s ago",{count:s}):s<3600?Ye("{count}m ago",{count:Math.floor(s/60)}):s<86400?Ye("{count}h ago",{count:Math.floor(s/3600)}):s<604800?Ye("{count}d ago",{count:Math.floor(s/86400)}):new Date(e*1e3).toLocaleDateString()}function Ut(e,i){return e.kind==="working"?`${e.diffType}:${i}`:`${e.hash}:${i}`}const Is=({additions:e,deletions:i,className:s})=>e===void 0&&i===void 0?null:t.jsx(si,{additions:e,deletions:i,className:s}),yn=({diff:e})=>{const{t:i}=re(),[s,a]=A.useState(!1),p=A.useMemo(()=>e.split(`
|
|
61
|
+
`),[e]);if(!e.trim())return t.jsx("div",{className:"py-6 text-center text-muted-foreground text-xs",children:i("没有可显示的差异内容")});const v=!s&&p.length>Ss,w=v?p.slice(0,Ss):p;return t.jsxs("div",{className:"overflow-x-auto scrollbar-app-thin font-mono text-xs leading-5",children:[w.map((r,o)=>t.jsx(xn,{line:r,lineNum:o+1},o)),v&&t.jsx("button",{type:"button",onClick:()=>a(!0),className:"w-full py-2 text-xs text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:i("还有 {count} 行变更被折叠,点击展开全部",{count:p.length-Ss})})]})},bu=({workingDir:e,path:i,diffType:s,enabled:a})=>{const{t:p}=re(),{data:v,isLoading:w,isError:r}=du(e,a?i:null,s);return!a||w?t.jsxs("div",{className:"flex items-center justify-center gap-2 py-8 text-muted-foreground",children:[t.jsx(xe,{size:"sm"}),t.jsx("span",{className:"text-xs",children:p("正在加载差异...")})]}):r?t.jsx("div",{className:"py-6 text-center text-destructive-ink text-xs",children:p("差异加载失败")}):t.jsx(yn,{diff:v?.diff||""})},xu=({workingDir:e,hash:i,path:s,enabled:a})=>{const{t:p}=re(),{data:v,isLoading:w,isError:r}=pn(e,a?i:null,a?s:null);return!a||w?t.jsxs("div",{className:"flex items-center justify-center gap-2 py-8 text-muted-foreground",children:[t.jsx(xe,{size:"sm"}),t.jsx("span",{className:"text-xs",children:p("正在加载差异...")})]}):r?t.jsx("div",{className:"py-6 text-center text-destructive-ink text-xs",children:p("差异加载失败")}):t.jsx(yn,{diff:v?.diff||""})},ys=({entry:e,source:i,workingDir:s,flash:a,registerNode:p})=>{const[v,w]=A.useState(!1),[r,o]=A.useState(!1),u=A.useRef(null),f=Ut(i,e.path);A.useEffect(()=>(p(f,u.current),()=>p(f,null)),[f,p]),A.useEffect(()=>{const g=u.current;if(!g||r)return;const m=new IntersectionObserver(y=>{y.some(b=>b.isIntersecting)&&(o(!0),m.disconnect())},{rootMargin:"300px 0px"});return m.observe(g),()=>m.disconnect()},[r]);const l=vu(e.path);return t.jsxs("div",{ref:u,"data-card-key":f,className:Q("rounded-md border border-border bg-background overflow-hidden transition-shadow",a&&"ring-2 ring-info/40"),children:[t.jsxs("button",{type:"button",onClick:()=>w(g=>!g),className:"w-full flex items-center gap-2 px-3 py-2 bg-muted/40 hover:bg-muted/70 transition-colors text-left",children:[v?t.jsx(Je,{size:13,className:"text-muted-foreground/70 shrink-0"}):t.jsx(Ke,{size:13,className:"text-muted-foreground/70 shrink-0"}),t.jsx(bi,{status:e.status}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:Sn(e.path)}),l&&t.jsx("span",{className:"font-mono text-[11px] text-muted-foreground truncate",children:l}),t.jsx("span",{className:"ml-auto"}),t.jsx(Is,{additions:e.additions,deletions:e.deletions})]}),!v&&t.jsx("div",{className:"border-t border-border/60",children:i.kind==="working"?t.jsx(bu,{workingDir:s,path:e.path,diffType:i.diffType,enabled:r}):t.jsx(xu,{workingDir:s,hash:i.hash,path:e.path,enabled:r})})]})};function Su(e){const i={name:"",path:"",dirs:new Map,files:[]};for(const s of e){const a=s.path.split("/");let p=i;for(let v=0;v<a.length-1;v++){const w=a[v];p.dirs.has(w)||p.dirs.set(w,{name:w,path:p.path?`${p.path}/${w}`:w,dirs:new Map,files:[]}),p=p.dirs.get(w)}p.files.push(s)}return wn(i)}function wn(e){const i=new Map;for(const s of e.dirs.values()){let a=wn(s);for(;a.dirs.size===1&&a.files.length===0;){const p=[...a.dirs.values()][0];a={...p,name:`${a.name}/${p.name}`}}i.set(a.name,a)}return{...e,dirs:i}}const yu=({dir:e,depth:i,activeKey:s,onSelect:a})=>{const[p,v]=A.useState(!0);return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>v(w=>!w),className:"flex items-center gap-1.5 w-full px-2 py-1 rounded-sm hover:bg-muted/60 text-left",style:{paddingLeft:8+i*12},children:[p?t.jsx(gi,{size:12,className:"text-muted-foreground/70 shrink-0"}):t.jsx(qs,{size:12,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:e.name})]}),p&&t.jsx(Cn,{node:e,depth:i+1,activeKey:s,onSelect:a})]})},Cn=({node:e,depth:i,activeKey:s,onSelect:a})=>t.jsxs(t.Fragment,{children:[[...e.dirs.values()].sort((p,v)=>p.name.localeCompare(v.name)).map(p=>t.jsx(yu,{dir:p,depth:i,activeKey:s,onSelect:a},p.path)),e.files.slice().sort((p,v)=>p.path.localeCompare(v.path)).map(p=>{const v=s===p.cardKey;return t.jsxs("button",{type:"button",onClick:()=>a(p),className:Q("flex items-center gap-1.5 w-full px-2 py-1 rounded-sm text-left",v?"bg-muted":"hover:bg-muted/60"),style:{paddingLeft:8+i*12},title:p.path,children:[t.jsx("span",{className:Q("w-1.5 h-1.5 rounded-full shrink-0",Gn[Fo(p.status)])}),t.jsx("span",{className:Q("text-xs truncate",v?"text-foreground font-medium":"text-foreground/90"),children:Sn(p.path)})]},p.cardKey)})]}),wu=({workingDir:e,selectedHash:i,onSelectCommit:s})=>{const{t:a}=re(),{data:p,isLoading:v,fetchNextPage:w,hasNextPage:r,isFetchingNextPage:o}=Hs({queryKey:ie.git.log(e),queryFn:({pageParam:f=0})=>ne.get("/git/log",{params:{workingDir:e,limit:String(xs),skip:String(f)}}),initialPageParam:0,getNextPageParam:(f,l)=>f.commits.length<xs?void 0:l.length*xs}),u=p?.pages.flatMap(f=>f.commits)||[];return v?t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 text-muted-foreground text-xs",children:[t.jsx(xe,{size:"xs"}),t.jsx("span",{children:a("正在加载提交记录...")})]}):u.length===0?t.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:a("暂无提交记录")}):t.jsxs("div",{className:"space-y-px px-1.5 pb-1.5",children:[u.map(f=>{const l=i===f.hash;return t.jsxs("button",{type:"button",onClick:()=>s(f),className:Q("flex items-start gap-1.5 w-full px-1.5 py-1 rounded-sm text-left group",l?"bg-muted":"hover:bg-muted/60"),title:f.message,children:[t.jsx("span",{className:Q("w-1.5 h-1.5 rounded-full mt-1.5 shrink-0 transition-colors",l?"bg-primary":"bg-border group-hover:bg-muted-foreground/60")}),t.jsxs("span",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:Q("block text-xs truncate",l?"text-foreground font-medium":"text-foreground/90"),children:f.message}),t.jsxs("span",{className:"block text-[11px] text-muted-foreground truncate",children:[t.jsx("span",{className:"font-mono",children:f.shortHash})," · ",f.author," · ",_u(f.timestamp)]})]})]},f.hash)}),r&&t.jsx("button",{type:"button",onClick:()=>w(),disabled:o,className:"w-full py-1.5 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 rounded-sm transition-colors flex items-center justify-center gap-1.5",children:o?t.jsxs(t.Fragment,{children:[t.jsx(xe,{size:"xs"})," ",a("正在加载...")]}):a("加载更多提交")})]})},Cu=({projectId:e,workingDir:i,workspaceId:s,branchName:a,targetBranch:p,commitMessage:v,canRunGitOperations:w,onRefreshCommitMessage:r,onConflict:o,onResolveConflicts:u})=>{const{t:f}=re(),[l,g]=A.useState({kind:"overview"}),[m,y]=A.useState(""),[b,n]=A.useState(null),[d,c]=A.useState(null),{data:h,isLoading:_,isError:S}=cu(i),k=l.kind==="commit"?l.commit.hash:null,{data:E,isLoading:x}=mn(i,k),C=A.useRef(new Map),N=A.useRef(null),L=A.useRef(null),R=A.useCallback((z,W)=>{W?C.current.set(z,W):C.current.delete(z)},[]),{uncommitted:P,committed:F,commitFiles:B}=A.useMemo(()=>{const z=I=>!m.trim()||I.path.toLowerCase().includes(m.trim().toLowerCase());if(l.kind==="commit"){const I={kind:"commit",hash:l.commit.hash},K=(E?.files||[]).filter(z).map(X=>({...X,cardKey:Ut(I,X.path)}));return{uncommitted:[],committed:[],commitFiles:K}}const W=(h?.uncommitted||[]).filter(z).map(I=>({...I,cardKey:Ut({kind:"working",diffType:"uncommitted"},I.path)})),j=(h?.committed||[]).filter(z).map(I=>({...I,cardKey:Ut({kind:"working",diffType:"committed"},I.path)}));return{uncommitted:W,committed:j,commitFiles:[]}},[l,h,E,m]),H=l.kind==="commit"?B:[...P,...F],U=A.useMemo(()=>Su(H),[H]),T=A.useMemo(()=>{let z=0,W=0;for(const j of H)z+=j.additions??0,W+=j.deletions??0;return{additions:z,deletions:W,files:H.length}},[H]),D=A.useCallback(()=>{const z=N.current;if(!z)return;const W=z.getBoundingClientRect().top;let j=null,I=Number.NEGATIVE_INFINITY;for(const[K,X]of C.current){const J=X.getBoundingClientRect().top-W;J<=48&&J>I&&(I=J,j=K)}if(!j){let K=null,X=Number.POSITIVE_INFINITY;for(const[J,G]of C.current){const Z=G.getBoundingClientRect().top-W;Z<X&&(X=Z,K=J)}j=K}n(j)},[]);A.useEffect(()=>{const z=N.current;if(!z)return;let W=0;const j=()=>{cancelAnimationFrame(W),W=requestAnimationFrame(D)};return z.addEventListener("scroll",j,{passive:!0}),()=>{z.removeEventListener("scroll",j),cancelAnimationFrame(W)}},[D]);const M=A.useCallback(z=>{const W=C.current.get(z.cardKey);W&&(W.scrollIntoView({behavior:"smooth",block:"start"}),n(z.cardKey),c(z.cardKey),L.current&&clearTimeout(L.current),L.current=setTimeout(()=>c(null),1200))},[]),O=A.useCallback(z=>{g(W=>W.kind==="commit"&&W.commit.hash===z.hash?{kind:"overview"}:{kind:"commit",commit:z}),y(""),n(null),N.current?.scrollTo({top:0})},[]),q=A.useCallback(()=>{g({kind:"overview"}),y(""),n(null),N.current?.scrollTo({top:0})},[]);if(!i)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm bg-background h-full",children:f("未选择工作区")});const V=w&&e&&s&&a&&p,$=l.kind==="commit"?x:_;return t.jsxs("div",{className:"flex h-full w-full min-w-0 flex-col bg-background",children:[V&&o&&u&&t.jsx(gu,{projectId:e,workspaceId:s,branchName:a,targetBranch:p,commitMessage:v,committedFileCount:h?.committed?.length,onRefreshCommitMessage:r,onConflict:o,onResolveConflicts:u}),t.jsx("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border/60 shrink-0 min-h-[37px]",children:l.kind==="overview"?t.jsxs(t.Fragment,{children:[t.jsx(Xs,{size:14,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:f("代码审查")}),t.jsx("span",{className:"text-xs text-muted-foreground",children:f("{count} 个文件",{count:T.files})}),t.jsx(Is,{additions:T.additions,deletions:T.deletions}),a&&p&&t.jsxs("span",{className:"ml-auto flex items-center gap-1 text-[11px] text-muted-foreground font-mono truncate",children:[t.jsx("span",{className:"truncate",children:a}),t.jsx(Es,{size:10,className:"rotate-180 shrink-0"}),t.jsx("span",{className:"truncate",children:p})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",onClick:q,className:"flex items-center gap-1 px-1.5 py-0.5 -ml-1.5 rounded-sm text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors shrink-0",children:[t.jsx(Es,{size:12}),f("全部变更")]}),t.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground/50 text-xs",children:"/"}),t.jsx("span",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:l.commit.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate",children:l.commit.message}),t.jsx(Is,{className:"ml-auto",additions:T.additions,deletions:T.deletions})]})}),t.jsxs("div",{className:"flex flex-1 min-h-0",children:[t.jsx("div",{ref:N,className:"flex-1 min-w-0 overflow-y-auto scrollbar-app-thin",children:$?t.jsx("div",{className:"p-3 space-y-3",children:[0,1].map(z=>t.jsxs("div",{className:"rounded-md border border-border overflow-hidden",children:[t.jsx("div",{className:"h-8 bg-muted/60 animate-pulse motion-reduce:animate-none"}),t.jsxs("div",{className:"p-3 space-y-2",children:[t.jsx("div",{className:"h-3 w-2/3 bg-muted animate-pulse motion-reduce:animate-none rounded-sm"}),t.jsx("div",{className:"h-3 w-1/2 bg-muted animate-pulse motion-reduce:animate-none rounded-sm"}),t.jsx("div",{className:"h-3 w-3/4 bg-muted animate-pulse motion-reduce:animate-none rounded-sm"})]})]},z))}):S&&l.kind==="overview"?t.jsx("div",{className:"flex-1 flex items-center justify-center py-16 text-destructive-ink text-sm",children:f("变更加载失败")}):H.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted-foreground",children:[t.jsx(As,{size:28,className:"mb-2 text-muted-foreground/70"}),t.jsx("span",{className:"text-xs",children:m.trim()?f("没有匹配筛选条件的文件"):l.kind==="commit"?f("该提交没有文件变更"):f("没有待审查的变更")})]}):l.kind==="commit"?t.jsx("div",{className:"p-3 space-y-3",children:B.map(z=>t.jsx(ys,{entry:z,source:{kind:"commit",hash:l.commit.hash},workingDir:i,flash:d===z.cardKey,registerNode:R},z.cardKey))}):t.jsxs("div",{className:"p-3 space-y-4",children:[P.length>0&&t.jsxs("section",{children:[t.jsxs("div",{className:"sticky top-0 z-10 -mx-3 px-5 py-1.5 bg-background/95 backdrop-blur-sm",children:[t.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:f("未提交")}),t.jsx("span",{className:"ml-2 text-[11px] tabular-nums text-muted-foreground",children:P.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:P.map(z=>t.jsx(ys,{entry:z,source:{kind:"working",diffType:"uncommitted"},workingDir:i,flash:d===z.cardKey,registerNode:R},z.cardKey))})]}),F.length>0&&t.jsxs("section",{children:[t.jsxs("div",{className:"sticky top-0 z-10 -mx-3 px-5 py-1.5 bg-background/95 backdrop-blur-sm",children:[t.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:f("已提交")}),t.jsx("span",{className:"ml-2 text-[11px] tabular-nums text-muted-foreground",children:F.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:F.map(z=>t.jsx(ys,{entry:z,source:{kind:"working",diffType:"committed"},workingDir:i,flash:d===z.cardKey,registerNode:R},z.cardKey))})]})]})}),t.jsxs("aside",{className:"shrink-0 border-l border-border flex flex-col min-h-0",style:{width:"clamp(15rem, 24%, 22rem)"},children:[t.jsx("div",{className:"p-2 shrink-0",children:t.jsx(Ko,{size:"sm",value:m,onValueChange:y,placeholder:f("筛选文件...")})}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin px-1.5 pb-1.5 min-h-0",children:H.length===0?t.jsx("div",{className:"px-2 py-3 text-xs text-muted-foreground",children:m.trim()?f("无匹配文件"):f("暂无变更文件")}):t.jsx(Cn,{node:U,depth:0,activeKey:b,onSelect:M})}),t.jsxs("div",{className:"shrink-0 border-t border-border/60 max-h-[40%] flex flex-col min-h-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 shrink-0",children:[t.jsx(Kt,{size:12,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:f("提交记录")})]}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin min-h-0",children:t.jsx(wu,{workingDir:i,selectedHash:k,onSelectCommit:O})})]})]})]})]})},ws=50;function ku(e){const s=Math.floor(Date.now()/1e3)-e;return s<60?Ye("{count}s ago",{count:s}):s<3600?Ye("{count}m ago",{count:Math.floor(s/60)}):s<86400?Ye("{count}h ago",{count:Math.floor(s/3600)}):s<604800?Ye("{count}d ago",{count:Math.floor(s/86400)}):new Date(e*1e3).toLocaleDateString()}function Eu(e){const i=e.split("/");return i[i.length-1]||e}function ju(e){const i=e.lastIndexOf("/");return i>0?e.slice(0,i):""}const Tu=({workingDir:e,hash:i,filePath:s})=>{const{t:a}=re(),{data:p,isLoading:v,isError:w}=pn(e,i,s);if(v)return t.jsxs("div",{className:"flex-1 flex items-center justify-center gap-2 text-muted-foreground",children:[t.jsx(xe,{size:"md"}),t.jsx("span",{className:"text-xs",children:a("Loading diff...")})]});if(w)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive-ink text-xs",children:a("Failed to load diff.")});const r=p?.diff||"";if(!r.trim())return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-xs",children:a("No diff content available.")});const o=r.split(`
|
|
62
|
+
`);return t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin font-mono text-xs leading-5",children:o.map((u,f)=>t.jsx(xn,{line:u,lineNum:f+1},f))})},Nu=({workingDir:e,hash:i,selectedPath:s,onSelectFile:a})=>{const{t:p}=re(),{data:v,isLoading:w}=mn(e,i);if(w)return t.jsxs("div",{className:"pl-7 py-1 text-xs text-muted-foreground flex items-center gap-1",children:[t.jsx(xe,{size:"xs"}),t.jsx("span",{children:p("Loading...")})]});const r=v?.files||[];return r.length===0?t.jsx("div",{className:"pl-7 py-1 text-xs text-muted-foreground",children:p("No files changed")}):t.jsx("div",{className:"pl-7 pb-1 space-y-0.5",children:r.map(o=>{const u=ju(o.path);return t.jsxs("button",{type:"button",onClick:f=>{f.stopPropagation(),a(o.path)},className:Q("flex items-center gap-2 px-1.5 py-1 rounded-sm cursor-pointer w-full text-left",s===o.path?"bg-muted":"hover:bg-muted/60"),children:[t.jsx(bi,{status:o.status}),t.jsx("span",{className:"min-w-0 text-xs text-foreground truncate",children:Eu(o.path)}),u&&t.jsx("span",{className:"min-w-0 flex-1 truncate text-right font-mono text-[11px] text-muted-foreground [direction:rtl]",children:t.jsx("span",{dir:"ltr",children:u})})]},o.path)})})},Au=({workingDir:e})=>{const{t:i}=re(),s=Qt(E=>E.visibleContext),a=Zo(e,s),{data:p,isLoading:v,isError:w,fetchNextPage:r,hasNextPage:o,isFetchingNextPage:u}=Hs({queryKey:ie.git.log(e||""),queryFn:({pageParam:E=0})=>ne.get("/git/log",{params:{workingDir:e||"",limit:String(ws),skip:String(E)}}),initialPageParam:0,getNextPageParam:(E,x)=>E.commits.length<ws?void 0:x.length*ws,enabled:!!e,refetchInterval:a,refetchIntervalInBackground:!1,refetchOnWindowFocus:a?"always":!1,refetchOnReconnect:a?"always":!1}),f=p?.pages.flatMap(E=>E.commits)||[],[l,g]=A.useState(null),[m,y]=A.useState(null),[b,n]=A.useState(280),[d,c]=A.useState(!1),h=A.useCallback(E=>{E.preventDefault(),c(!0);const x=E.clientX,C=b,N=R=>{const P=Math.min(480,Math.max(180,C+(R.clientX-x)));n(P)},L=()=>{c(!1),document.removeEventListener("mousemove",N),document.removeEventListener("mouseup",L)};document.addEventListener("mousemove",N),document.addEventListener("mouseup",L)},[b]),_=E=>{l===E?(g(null),y(null)):(g(E),y(null))},S=A.useRef(null);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm bg-background h-full",children:i("No workspace selected.")});if(v)return t.jsxs("div",{className:"flex-1 flex items-center justify-center gap-2 text-muted-foreground bg-background h-full",children:[t.jsx(xe,{size:"md"}),t.jsx("span",{className:"text-sm",children:i("Loading history...")})]});if(w)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive-ink text-sm bg-background h-full",children:i("Failed to load history.")});if(f.length===0)return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-12 text-muted-foreground bg-background h-full",children:[t.jsx(Kt,{size:28,className:"mb-2 text-muted-foreground/70"}),t.jsx("span",{className:"text-xs",children:i("No commit history")})]});const k=f.find(E=>E.hash===l);return t.jsxs("div",{className:"flex h-full bg-background",style:d?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsxs("div",{className:"border-r border-border flex flex-col shrink-0",style:{width:b},children:[t.jsx("div",{className:"px-3 py-2.5 border-b border-border/60 shrink-0",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Kt,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:i("History")}),t.jsx("span",{className:"text-[11px] tabular-nums bg-muted px-1.5 py-0.5 rounded-full text-muted-foreground",children:f.length})]})}),t.jsxs("div",{ref:S,className:"flex-1 overflow-auto scrollbar-app-thin p-1.5",children:[f.map(E=>{const x=l===E.hash;return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>_(E.hash),className:Q("flex items-start gap-2 px-2 py-1.5 rounded-sm cursor-pointer w-full text-left group",x?"bg-muted":"hover:bg-muted/60"),children:[t.jsx("div",{className:"flex flex-col items-center shrink-0 pt-1",children:t.jsx("div",{className:Q("w-2 h-2 rounded-full shrink-0 transition-colors",x?"bg-primary":"bg-border group-hover:bg-muted-foreground/60")})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:E.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate flex-1",children:E.message}),t.jsx(Je,{size:12,className:Q("shrink-0 text-muted-foreground/70 transition-transform",x&&"rotate-90")})]}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.jsx("span",{className:"text-xs text-muted-foreground truncate",children:E.author}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:ku(E.timestamp)})]})]})]}),x&&t.jsxs(t.Fragment,{children:[E.body&&t.jsx("div",{className:"pl-7 pr-2 py-1.5 text-xs text-muted-foreground whitespace-pre-wrap leading-5 border-l-2 border-border ml-3",children:E.body}),t.jsx(Nu,{workingDir:e,hash:E.hash,selectedPath:m,onSelectFile:y})]})]},E.hash)}),o&&t.jsx("button",{type:"button",onClick:()=>r(),disabled:u,className:"w-full py-2 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 rounded-sm transition-colors flex items-center justify-center gap-1.5",children:u?t.jsxs(t.Fragment,{children:[t.jsx(xe,{size:"xs"})," ",i("Loading...")]}):i("Load more")})]})]}),t.jsx("div",{onMouseDown:h,className:Q("w-1 shrink-0 cursor-col-resize transition-colors",d?"bg-ring/40":"bg-transparent hover:bg-border")}),t.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:m&&l?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"px-3 py-2 border-b border-border/60 flex items-center gap-2 shrink-0",children:[t.jsx(As,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:m}),t.jsxs("span",{className:"font-mono text-[11px] text-muted-foreground",children:["(",k?.shortHash,")"]})]}),t.jsx(Tu,{workingDir:e,hash:l,filePath:m})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(As,{size:28,className:"text-muted-foreground/70"}),t.jsx("span",{className:"text-xs",children:i(l?"Select a file to view diff":"Select a commit to view changes")})]})})})]})},$r=$s();function kn(e){if(!$r)return e;try{const i=new URL($r);return new URL(e,i.origin).toString()}catch{return e}}const Ru=2500,Lu=6e4,Mu="/__agent_tower_preview_heartbeat";function En(e){return{...e,viewUrl:e.viewUrl?kn(e.viewUrl):null}}function Fs(e){return{...e,viewUrl:e.kind==="same-origin"?kn(e.viewUrl):e.viewUrl}}function Pu(e,i=!0){return Ee({queryKey:ie.previews.status(e??""),queryFn:async()=>{const s=await ne.get(`/previews/${e}/status`);return En(s)},enabled:!!e&&i,refetchOnWindowFocus:!1})}function Du(e){const i=Pe();return Ct({mutationFn:async s=>{const a=await ne.put(`/previews/${e}/config`,{target:s});return En(a)},onSuccess:s=>{e&&(i.setQueryData(ie.previews.status(e),s),i.invalidateQueries({queryKey:ie.workspaces.all}))}})}function Bu(){return window.location.protocol==="https:"?"remote":"local"}const Ur=new Map;async function Ou(e,i=fetch,s=Date.now){let a;try{a=new URL(e).origin}catch{return!1}const p=Ur.get(a);if(p&&(p.reachable||s()-p.checkedAt<Lu))return p.reachable;const v=new AbortController,w=setTimeout(()=>v.abort(),Ru);let r=!1;try{await i(`${a}${Mu}`,{mode:"no-cors",cache:"no-store",credentials:"omit",signal:v.signal}),r=!0}catch{r=!1}finally{clearTimeout(w)}return Ur.set(a,{reachable:r,checkedAt:s()}),r}async function Iu(e){const i=window.location.hostname,s={mode:Bu(),localHostname:i},a=Fs(await ne.post(`/previews/${e}/sessions`,s));if(a.kind!=="gateway"||await Ou(a.viewUrl))return a;ne.delete(`/previews/${e}/sessions/${a.id}`).catch(()=>{});const p={mode:"remote",localHostname:i};return Fs(await ne.post(`/previews/${e}/sessions`,p))}function Fu(e,i,s=!0){const[a,p]=A.useState(null),[v,w]=A.useState(!1),[r,o]=A.useState(null),[u,f]=A.useState(0);return A.useEffect(()=>{if(!s||!e||!i?.ready||!i.target){p(null),w(!1),o(null);return}let l=!1,g=null,m=null;p(null);const y=n=>{ne.delete(`/previews/${e}/sessions/${n}`).catch(()=>{})};return(async()=>{w(!0),o(null);try{const n=await Iu(e);if(l){n.kind==="gateway"&&y(n.id);return}if(p(n),n.kind!=="gateway")return;g=n.id,m=window.setInterval(async()=>{if(g)try{const d=Fs(await ne.post(`/previews/${e}/sessions/${g}/heartbeat`));l||(p(d),o(null))}catch(d){!l&&d instanceof Ze&&d.status===404?f(c=>c+1):l||o(d instanceof Error?d:new Error("Preview session heartbeat failed"))}},3e4)}catch(n){l||(p(null),o(n instanceof Error?n:new Error("Failed to open preview session")))}finally{l||w(!1)}})(),()=>{l=!0,m!==null&&window.clearInterval(m),g&&y(g)}},[s,u,i?.ready,i?.target,e]),{session:a,isOpening:v,error:r,retry:()=>f(l=>l+1)}}const Hu="agent-tower-preview",zu="agent-tower-preview-host";function Wu(){return"3000, localhost:3000, http://192.168.1.20:8080"}function $u(e){if(!e)return null;try{return new URL(e,window.location.href).origin}catch{return null}}function Cs(e){return e?{kind:e.kind,viewUrl:e.viewUrl}:null}function Uu(e){return t.jsx(qu,{...e},e.workspaceId??"no-workspace")}function qu({workspaceId:e,readOnly:i,navigationRequest:s,onNavigationRequestHandled:a}){const{t:p}=re(),[v,w]=A.useState(null),o=!(s?.source.kind==="visualization")&&!v,{data:u,isLoading:f,refetch:l,isFetching:g}=Pu(e,o),m=Du(e),{session:y,isOpening:b,error:n,retry:d}=Fu(e,u,o),c=A.useRef(null),h=A.useRef(null),_=A.useRef(null),S=A.useRef(null),k=A.useRef(null),E=A.useRef(null),[x,C]=A.useState(0),[N,L]=A.useState({target:null,address:"",iframeSrc:null,isFrameLoading:!1}),R=y?`${y.kind}:${$u(y.viewUrl)??""}`:null,P=Cs(y),F=u&&N.target!==u.target?{target:u.target,address:u.target??"",iframeSrc:null,isFrameLoading:!1}:u&&!u.ready&&N.iframeSrc?{...N,iframeSrc:null,isFrameLoading:!1}:N,B=A.useCallback($=>{L(z=>({...u&&z.target!==u.target?{target:u.target,address:u.target??"",iframeSrc:null,isFrameLoading:!1}:z,...$}))},[u]);A.useEffect(()=>{if(!y||y.target!==u?.target)return;const $=k.current!==R;k.current=R;const z=Cs(y);L(W=>{const j=s?.source.kind==="web"&&E.current!==s.id?Pt(s.source.url,y.target,z):null;if(!$&&W.iframeSrc&&W.target===y.target&&j?.kind!=="proxy")return W;let I=W.iframeSrc;if(j?.kind==="proxy")I=j.url;else if(!I||W.target!==y.target||$){const X=_.current;if(X&&z)I=po(z,X);else{const J=Pt(W.address||y.target,y.target,z);I=J?.kind==="proxy"?J.url:y.viewUrl}}_.current=null;const K=S.current;return K&&!K.closed&&I&&K.location.replace(I),S.current=null,{target:y.target,address:j?.kind==="proxy"?s?.source.kind==="web"?s.source.url:W.address:W.address||y.target,iframeSrc:I,isFrameLoading:!!I}})},[s,y,R,u?.target]),A.useEffect(()=>()=>{S.current?.close()},[]);const H=A.useCallback(async($,z=!1)=>{const W=Pt($,u?.target??null,Cs(y));if(!W||!e)return;if(w(null),W.kind==="proxy"){if(z){window.open(W.url,"_blank","noopener,noreferrer");return}L({target:u?.target??null,address:$,iframeSrc:W.url,isFrameLoading:!0});return}if(i)return;const j=z?window.open("about:blank","_blank"):null;j&&(j.opener=null);try{_.current=W.path,S.current=j;const I=await m.mutateAsync(W.target);L({target:I.target,address:$.trim(),iframeSrc:null,isFrameLoading:!!I.ready}),C(K=>K+1),ke.success(p("Preview target saved")),I.ready||(S.current?.close(),S.current=null)}catch(I){S.current?.close(),S.current=null,_.current=null;const K=I instanceof Error?I.message:p("Failed to save preview target");ke.error(K)}},[y,i,u?.target,p,m,e]);A.useEffect(()=>{if(!s||E.current===s.id||s.source.kind==="web"&&f)return;const $=window.setTimeout(()=>{E.current=s.id,a?.(s.id),s.source.kind==="visualization"?(w({source:s.source,iframeSrc:go(s.source.sessionId,s.source.file),isFrameLoading:!0}),C(z=>z+1)):(w(null),H(s.source.url))},0);return()=>window.clearTimeout($)},[f,H,s,a]),A.useEffect(()=>{if(v)return;const $=z=>{if(z.source!==c.current?.contentWindow)return;const W=z.data;if(!(!W||W.source!==Hu)){if(W.type==="location"&&typeof W.path=="string"){const j=vo(u?.target??null,W.path);j&&document.activeElement!==h.current&&B({target:u?.target??F.target,address:j,isFrameLoading:!1});return}(W.type==="navigate-target"||W.type==="navigate-loopback")&&typeof W.href=="string"&&H(W.href,W.newTab===!0)}};return window.addEventListener("message",$),()=>window.removeEventListener("message",$)},[F.target,H,B,u?.target,v]);const U=$=>{c.current?.contentWindow?.postMessage({source:zu,action:$},"*")},T=$=>{$.preventDefault(),H(F.address)},D=async()=>{if(v){w(z=>z&&{...z,isFrameLoading:!0}),C(z=>z+1);return}const $=await l();if(!$.data?.ready){B({target:$.data?.target??F.target,iframeSrc:null,isFrameLoading:!1});return}if(!y||!F.iframeSrc){d();return}B({isFrameLoading:!0}),U("reload")},M=()=>{if(v){window.open(v.iframeSrc,"_blank","noopener,noreferrer");return}if(!P||!y)return;const $=Pt(F.address||y.target,y.target,P),z=$?.kind==="proxy"?$.url:y.viewUrl;window.open(z,"_blank","noopener,noreferrer")};if(!e)return t.jsx("div",{className:"h-full flex items-center justify-center bg-background text-sm text-muted-foreground",children:p("No active workspace.")});const O=v?.iframeSrc??F.iframeSrc,q=!!v,V=!q&&(f||g||m.isPending||b);return t.jsxs("div",{className:"h-full flex flex-col bg-background",children:[t.jsxs("div",{className:"shrink-0 border-b border-border bg-muted/40 px-2 py-2",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx($e,{label:p("Back"),onClick:()=>{q?w(null):U("back")},disabled:!q&&!F.iframeSrc,children:t.jsx(Es,{})}),t.jsx($e,{label:p("Forward"),onClick:()=>U("forward"),disabled:q||!F.iframeSrc,children:t.jsx(Ai,{})}),t.jsx($e,{label:!q&&F.isFrameLoading?p("Stop loading"):p("Refresh preview"),onClick:!q&&F.isFrameLoading?()=>{U("stop"),B({isFrameLoading:!1})}:D,disabled:!q&&!F.isFrameLoading&&g,children:!q&&F.isFrameLoading?t.jsx(tt,{}):g?t.jsx(xe,{}):t.jsx(_t,{})}),t.jsx("form",{className:"min-w-0 flex-1",onSubmit:T,children:t.jsx(Xo,{ref:h,size:"sm",prefix:t.jsx(_a,{}),value:v?.source.file??F.address,onChange:$=>B({address:$.target.value}),onKeyDown:$=>{$.key==="Enter"&&$.nativeEvent.isComposing&&$.preventDefault()},disabled:q||i||m.isPending,placeholder:Wu(),"aria-label":p("Preview address")})}),t.jsx($e,{label:p("Open preview in new tab"),onClick:M,disabled:!O,children:t.jsx(Ws,{})})]}),t.jsxs("div",{className:"mt-1 flex min-h-4 items-center justify-between gap-2 px-1 text-xs leading-4",children:[t.jsx("span",{className:"truncate text-muted-foreground",children:q?p("Viewing agent visualization"):V?p("Checking preview target..."):n?n.message:u?.ready?`${p("Proxying")} ${u.target}`:u?.configured?`${p("Preview target is not reachable")}${u.error?`: ${u.error}`:""}`:p("Enter a URL the Agent Tower server can reach.")}),t.jsx("span",{className:"shrink-0 text-muted-foreground",children:q?p("Session file"):y?.kind==="gateway"?p("Direct gateway"):p("Via Agent Tower")})]})]}),t.jsx("div",{className:"relative flex-1 min-h-0 bg-background",children:O?t.jsx("iframe",{ref:c,src:O,title:p("Preview"),className:"absolute inset-0 h-full w-full border-0 bg-white",sandbox:q?"allow-modals allow-pointer-lock allow-presentation allow-scripts":"allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts",allow:"clipboard-read; clipboard-write; fullscreen",onLoad:()=>{q?w($=>$&&{...$,isFrameLoading:!1}):B({isFrameLoading:!1})}},x):t.jsx("div",{className:"absolute inset-0 flex items-center justify-center px-4 text-center text-sm text-muted-foreground",children:u?.configured?u.ready&&b?p("Checking preview target..."):p("Start the preview server, then refresh."):p("Configure a preview target the Agent Tower server can reach to display it here.")})})]})}const Ku={[We.ACTIVE]:"success",[We.MERGED]:"info",[We.HIBERNATED]:"warning",[We.ABANDONED]:"neutral"};function Xu(e){return e.length<=34?e:`...${e.slice(-31)}`}function Yu({workspaces:e,teamRun:i,selectedWorkspaceId:s,onSelectWorkspace:a,disabled:p,className:v,buttonClassName:w}){const{t:r}=re(),o=A.useMemo(()=>Gs(e,i),[e,i]),u=o.find(f=>f.workspace.id===s)??o[0];return o.length<=1?null:t.jsx("div",{className:Q("relative",v),children:t.jsxs(Si,{children:[t.jsxs(yi,{disabled:p,className:Q("group inline-flex h-8 max-w-[340px] items-center gap-2 rounded-md border border-border bg-background px-2.5 text-left text-xs text-foreground/80 outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring/60 disabled:cursor-not-allowed disabled:opacity-40 data-[state=open]:bg-accent",w),title:r("Workspace"),children:[t.jsx(Ts,{size:14,className:"shrink-0 text-muted-foreground"}),t.jsx(Wt,{size:"sm",shape:"tag",children:r(u.roleLabel)}),t.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",children:r(u.displayName)}),t.jsx("span",{className:"min-w-0 truncate font-mono text-[11px] text-muted-foreground",children:Xu(jt(u.workspace))}),t.jsx(Ke,{size:13,className:"shrink-0 text-muted-foreground/70 transition-transform group-data-[state=open]:rotate-180"})]}),t.jsx(wi,{className:"w-[420px] max-w-[calc(100vw-2rem)]",children:t.jsx(Wo,{value:u.workspace.id,onValueChange:a,children:o.map(f=>t.jsxs($o,{value:f.workspace.id,icon:t.jsx(ei,{className:"mt-0.5 size-3.5"}),className:"items-start",children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{className:"truncate",children:r(f.displayName)}),t.jsx(Wt,{size:"sm",shape:"tag",children:r(f.roleLabel)}),t.jsx(Wt,{size:"sm",tone:Ku[f.workspace.status],children:f.workspace.status})]}),t.jsx("span",{className:"mt-0.5 block truncate font-mono text-[11px] font-normal text-muted-foreground",children:jt(f.workspace)}),t.jsxs("span",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs font-normal text-muted-foreground",children:[f.ownerName&&t.jsxs("span",{children:[r("Owner"),": ",f.ownerName]}),f.parentBranchName&&t.jsxs("span",{children:[r("Parent"),": ",f.parentBranchName]}),t.jsx("span",{className:"font-mono text-[11px]",children:f.workspace.id.slice(0,8)})]})]},f.workspace.id))})})]})})}const Vu=[{key:"review",label:"Changes",icon:t.jsx(Xs,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(xi,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(yt,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(Ti,{size:14})}],Gu=[{key:"history",label:"History",icon:t.jsx(Kt,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(xi,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(yt,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(Ti,{size:14})}],Qu=({active:e,onClick:i,icon:s,label:a})=>t.jsxs("button",{type:"button",onClick:i,className:Q("flex shrink-0 items-center gap-2 px-4 py-2 text-xs font-medium transition-all rounded-t-md border-t border-x -mb-px whitespace-nowrap outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/60",e?"bg-background border-border text-foreground z-10":"bg-transparent border-transparent text-muted-foreground hover:text-foreground hover:bg-foreground/[0.05]"),children:[s,t.jsx("span",{children:a})]}),Zu=({active:e,onClick:i,icon:s,label:a})=>t.jsx("button",{type:"button",onClick:i,title:a,"aria-label":a,"aria-pressed":e,className:Q("flex h-9 w-9 items-center justify-center rounded-lg transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",e?"bg-background text-foreground shadow-raised ring-1 ring-border/80":"text-muted-foreground hover:bg-foreground/[0.05] hover:text-foreground"),children:s}),sm=_e.memo(function({className:i,sessionId:s,workspaceId:a,workingDir:p,projectId:v,hideChanges:w,gitAvailable:r=!0,readOnly:o,repoDeleted:u,teamRun:f,teamStatus:l,subtasks:g,handoff:m,gitProps:y,workspaces:b,selectedWorkspaceId:n,onSelectWorkspace:d,variant:c="tabs",expanded:h,onExpandedChange:_,minContentWidth:S=520,tabRef:k,previewRequest:E,onPreviewRequestHandled:x}){const{t:C}=re(),N=Qt(te=>te.setVisibleContext),L=c==="rail",[R,P]=A.useState(!1),F=L?h??R:!0,B=A.useCallback(te=>{h===void 0&&P(te),_?.(te)},[h,_]),H=g!=null,U=m!=null,T=A.useMemo(()=>{const te=w?Gu:Vu,me=r?te:te.filter(Re=>Re.key!=="review"&&Re.key!=="history"),De=o?me.filter(Re=>Re.key!=="terminal"):me,qe=H?[...De,{key:"subtasks",label:"Subtasks",icon:t.jsx(li,{size:14})}]:De,ve=U?[...qe,{key:"handoff",label:"Handoff note",icon:t.jsx(ja,{size:14})}]:qe;return f?[{key:"team-status",label:"Team Status",icon:t.jsx(vt,{size:14})},...ve]:ve},[r,w,o,f,H,U]),[D,M]=A.useState(()=>E?"preview":r?w?"history":"review":"editor"),O=A.useRef(null),q=A.useRef(0),[V,$]=A.useState(),z=A.useCallback(te=>{M(te),L&&B(!0)},[L,B]);A.useImperativeHandle(k,()=>({setTab:te=>z(te),openFile:(te,me,De)=>{z("editor"),requestAnimationFrame(()=>O.current?.openFile(te,me,De))},openPreview:(te,me)=>{q.current+=1,$({id:q.current,source:te,workspaceId:me}),z("preview")}}),[z]);const W=E??V,j=W?.workspaceId&&W.workspaceId!==a?void 0:W,I=A.useCallback(te=>{$(me=>me?.id===te?void 0:me),x?.(te)},[x]),{data:K}=Jo(v??""),X=A.useMemo(()=>{if(!K?.quickCommands)return[];try{return JSON.parse(K.quickCommands)}catch{return[]}},[K?.quickCommands]),[J,G]=A.useState([]),Z=A.useRef(void 0);A.useEffect(()=>{p&&p!==Z.current&&(Z.current=p,G(te=>te.includes(p)?te:[...te,p]))},[p]),A.useEffect(()=>{T.some(te=>te.key===D)||M(T[0]?.key??"editor")},[D,T]),A.useEffect(()=>{if(L&&!F)return;const te=D==="review"?"changes":D==="history"?"history":null;if(!a||!p||!te){N(null);return}return N({workspaceId:a,workingDir:p,tab:te}),()=>{N(null)}},[D,F,L,N,p,a]);const ae=!!d&&Gs(b,f).length>1,he=T.find(te=>te.key===D)??T[0],je=he?C(he.label):"",se=o?t.jsx(Oe,{size:"sm",className:"mx-2 mt-2",children:C(u?"项目已删除且本地仓库文件已清理。这里只保留历史视图。":"项目已删除。Workspace 以只读模式展示历史内容。")}):null,Ae=t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[ae&&D!=="subtasks"&&D!=="handoff"&&t.jsx("div",{className:"shrink-0 px-3 py-1.5 border-b border-border/60 bg-muted/40",children:t.jsx(Yu,{workspaces:b,teamRun:f,selectedWorkspaceId:n,onSelectWorkspace:d,buttonClassName:"h-7"})}),t.jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[D==="team-status"&&f&&l,D==="subtasks"&&g,D==="handoff"&&m,D==="editor"&&t.jsx(lu,{ref:O,workingDir:p,readOnly:o}),J.map(te=>{const me=D==="terminal"&&p===te;return t.jsx("div",{"aria-hidden":!me,className:"absolute inset-0 h-full w-full min-h-0 min-w-0 overflow-hidden",style:{display:me?"block":"none"},children:t.jsx(yc,{cwd:te,workspaceId:me?a:void 0,isVisible:me,quickCommands:X})},te)}),D==="preview"&&t.jsx(Uu,{workspaceId:a,readOnly:o,navigationRequest:j,onNavigationRequestHandled:I}),D==="review"&&t.jsx(Cu,{projectId:v,workingDir:p,workspaceId:a,branchName:y?.branchName,targetBranch:y?.targetBranch,commitMessage:y?.commitMessage,canRunGitOperations:y?.canRunGitOperations,onRefreshCommitMessage:y?.onRefreshCommitMessage,onConflict:y?.onConflict,onResolveConflicts:y?.onResolveConflicts}),D==="history"&&t.jsx(Au,{workingDir:p})]})]});return L?t.jsxs("div",{className:Q("flex h-full w-full min-w-0 bg-background",i),children:[t.jsx("div",{className:"flex h-full w-12 shrink-0 flex-col items-center gap-1 border-l border-border bg-muted/35 px-1.5 py-2",children:T.map(te=>t.jsx(Zu,{active:F&&D===te.key,onClick:()=>z(te.key),icon:te.icon,label:C(te.label)},te.key))}),F&&t.jsxs("div",{className:"flex h-full min-w-0 flex-1 flex-col border-l border-border bg-background",style:{minWidth:S},children:[se,t.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between gap-3 border-b border-border bg-background px-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-sm font-semibold text-foreground",children:[t.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-lg border border-border bg-muted/35 text-muted-foreground",children:he?.icon}),t.jsx("span",{className:"truncate",children:je})]}),t.jsx("button",{type:"button",onClick:()=>B(!1),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",title:C("收起"),"aria-label":C("收起"),children:t.jsx(Ma,{size:15})})]}),Ae]})]}):t.jsxs("div",{className:Q("flex h-full w-full min-w-0 flex-col bg-background",i),children:[o&&se,t.jsx("div",{className:"flex items-center overflow-x-auto scrollbar-app-thin px-2 pt-2 border-b border-border bg-muted shrink-0 gap-1 select-none",children:T.map(te=>t.jsx(Qu,{active:D===te.key,onClick:()=>z(te.key),icon:te.icon,label:C(te.label)},te.key))}),Ae]})}),Ju=3e3;function qr(e,i){const s=new Map(e.map(a=>[a.workspaceId,a]));for(const a of i){const p=s.get(a.workspaceId);(!p||a.updatedAt>=p.updatedAt)&&s.set(a.workspaceId,a)}return[...s.values()]}function rm(e){const i=Pe(),s=A.useRef({version:0,values:new Map}),[a,p]=A.useState(0),{data:v=[]}=Ee({queryKey:ie.workspaces.setupProgress(e??""),enabled:!!e,refetchOnMount:"always",refetchInterval:u=>u.state.data?.some(f=>f.status==="running")?3e3:!1,queryFn:async({signal:u})=>{const f=s.current.version,l=await ne.get(`/tasks/${e}/setup-progress`,{signal:u}),g=[...s.current.values.values()].filter(m=>m.version>f&&m.progress.taskId===e).map(m=>m.progress);return qr(l,g)}});A.useEffect(()=>{if(!e)return;const u=be.connect(),f=ie.workspaces.setupProgress(e),l=m=>{if(m.taskId!==e)return;const y=s.current.values.get(m.workspaceId);y&&y.progress.updatedAt>m.updatedAt||(s.current.values.set(m.workspaceId,{version:++s.current.version,progress:m}),i.setQueryData(f,b=>qr(b??[],[m])))},g=()=>{i.invalidateQueries({queryKey:f})};return u.on(Le.WORKSPACE_SETUP_PROGRESS,l),u.on("connect",g),()=>{u.off(Le.WORKSPACE_SETUP_PROGRESS,l),u.off("connect",g)}},[e,i]);const w=[...v].sort((u,f)=>f.updatedAt-u.updatedAt),r=w.find(u=>u.status==="running")??w.find(u=>u.status!=="running"&&u.updatedAt>a),o=r?.status!=="running"?r?.updatedAt??null:null;return A.useEffect(()=>{if(o===null)return;const u=setTimeout(()=>p(o),Ju);return()=>clearTimeout(u)},[o]),r??null}function im({isOpen:e,onClose:i,onStarted:s,taskId:a,projectId:p,taskTitle:v,taskDescription:w,taskPrompt:r,projectIsGitRepo:o=!0,projectWorktreeReady:u=!0,projectGitReason:f}){const{t:l}=re(),[g,m]=A.useState(""),[y,b]=A.useState(""),[n,d]=A.useState(He.WORKTREE),[c,h]=A.useState(null),[_,S]=A.useState("idle"),[k,E]=A.useState(null),x=Pe(),C=ea(a),N=Co(),L=ta(),{data:R,isLoading:P}=Us(),F=A.useMemo(()=>R?.filter(pi),[R]),B=c?.isGitRepo??o,H=c?.worktreeReady??u,U=c?.reason??f,T=B!==!1&&H!==!1;A.useEffect(()=>{if(!e||!F)return;const G=F.find(Z=>!ht(Z));m(Z=>Z&&F.some(ae=>ae.provider.id===Z)?Z:G?.provider.id??"")},[e,F]),A.useEffect(()=>{if(e){const G=[v];w&&G.push(w),b(r?.trim()||G.join(`
|
|
63
|
+
|
|
64
|
+
`)),h(null),d(o!==!1&&u!==!1?He.WORKTREE:He.MAIN_DIRECTORY),S("idle"),E(null)}},[e,o,u,a,v,w,r]),A.useEffect(()=>{T||d(He.MAIN_DIRECTORY)},[T]);const D=async()=>{if(!p||L.isPending)return;const G=await L.mutateAsync({id:p});h(G),G.worktreeReady&&d(He.WORKTREE)},M=_!=="idle",O=async()=>{if(!g||!y.trim())return;const G=F?.find(Z=>Z.provider.id===g);if(!(!G||ht(G))){E(null);try{await so(a,{providerId:g,prompt:y.trim(),workspaceKind:T?n:He.MAIN_DIRECTORY},{createWorkspace:Z=>C.mutateAsync({clientSubmissionId:Z,workspaceKind:T?n:He.MAIN_DIRECTORY}),startSession:Z=>N.mutateAsync(Z),onStep:S}),await x.invalidateQueries({queryKey:ie.workspaces.list(a)}),S("idle"),s?.(),i()}catch(Z){S("idle"),E(Z instanceof Error?Z.message:l("启动失败,请重试"))}}},q={idle:l("启动"),"creating-workspace":l("创建工作空间..."),"creating-session":l("创建会话..."),"starting-session":l("启动 Agent...")},V=(F??[]).map(G=>{const Z=G.provider,ae=ht(G),he=!ae,je=Z.executionPermission?l("Required permission: {mode}",{mode:l(ra[Z.executionPermission])}):void 0;return{value:Z.id,label:he?Z.name:`${Z.name}${l(" (不可用)")}`,description:[je,ae&&l(ae)].filter(Boolean).join(" · "),icon:t.jsx(Gt,{agentType:Z.agentType,className:"size-4"}),disabled:!he}}),$=F?.find(G=>G.provider.id===g),z=$?ht($):void 0,W=!!F?.length&&F.every(G=>!!ht(G)),j=!P&&!F?.length,I=l("工作树隔离改动,支持 TeamRun、Merge、Rebase 和冲突解决。"),K=l("本地模式会直接修改项目主目录,不会自动提交,也不能使用 Merge、Rebase 或冲突解决。"),X=l(U==="NO_HEAD"?"已检测到 Git,但需要先提交一次才能使用工作树模式。":"非 Git 项目只能使用本地模式。"),J=[{value:He.WORKTREE,label:l("工作树模式"),description:I,disabled:!T},{value:He.MAIN_DIRECTORY,label:l("本地模式"),description:K}];return t.jsx(At,{isOpen:e,onClose:M?()=>{}:i,title:l("启动 Agent"),action:t.jsxs(t.Fragment,{children:[t.jsx(ge,{variant:"outline",onClick:i,disabled:M,children:l("取消")}),t.jsx(ge,{onClick:O,disabled:M||!$||!y.trim()||!!z,children:q[_]})]}),children:t.jsxs("div",{className:"space-y-5",children:[t.jsx("div",{children:t.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-foreground/80 mb-2",children:l("Agent")}),t.jsx(Xe,{value:g,onChange:m,options:V,placeholder:l(P?"加载中...":"选择 Agent"),disabled:M||P}),z?t.jsx("p",{role:"alert",className:"mt-2 break-words text-xs leading-snug text-destructive-ink",children:l(z)}):null,W&&!$?t.jsxs("div",{role:"alert",className:"mt-2 space-y-1 break-words text-xs leading-snug text-destructive-ink",children:[t.jsx("p",{children:l("No available Provider for this session.")}),t.jsx("ul",{className:"space-y-1",children:F.map(G=>t.jsxs("li",{children:[G.provider.name,": ",l(ht(G))]},G.provider.id))})]}):null,j?t.jsx("p",{role:"alert",className:"mt-2 text-xs text-destructive-ink",children:l("No available Provider for this session.")}):null]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-foreground/80 mb-2",children:l("模式")}),T?t.jsx(Xe,{value:n,onChange:G=>d(G),options:J,disabled:M}):t.jsx(_o,{side:"bottom",className:"w-full",content:X,children:t.jsxs("div",{tabIndex:0,"aria-label":X,className:"rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[t.jsx(Xe,{value:n,onChange:G=>d(G),options:J,disabled:!0}),t.jsx("button",{type:"button",onClick:D,disabled:M||L.isPending,className:"mt-2 text-xs text-muted-foreground transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",children:L.isPending?l("检测中..."):l("重新检测 Git 状态")})]})})]})]})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-foreground/80 mb-2",children:l("任务描述")}),t.jsx("textarea",{value:y,onChange:G=>b(G.target.value),rows:5,disabled:M,placeholder:l("描述你想让 Agent 完成的任务..."),className:"w-full px-3 py-2 border border-border rounded-lg text-sm text-foreground placeholder:text-muted-foreground/70 focus:outline-none focus:ring-1 focus:ring-ring/60 focus:border-ring resize-none disabled:opacity-50 disabled:bg-muted/50"})]}),k&&t.jsx("div",{className:"text-sm text-destructive-ink bg-destructive/10 border border-destructive/25 rounded-lg px-3 py-2",children:k})]})})}function nm(e){const i=e?.tokenUsage;if(!(!i||typeof i.totalTokens!="number"))return i}function ef(e,i,s){const a=e?.providerId??s?.providerId??null,p=a?i?.find(o=>o.provider.id===a)?.provider:null,v=p?.name??a??e?.agentType??s?.agentType??null;if(!v)return null;const w=e?.agentType??p?.agentType??s?.agentType??null,r=a&&p?.name&&a!==p.name?`${p.name} (${a})`:v;return{label:v,title:r,agentType:w}}function om({session:e,providers:i,usage:s,compact:a=!1,providerIdFallback:p,agentTypeFallback:v,tokenTooltipSide:w="top"}){const{t:r}=re(),o=ef(e,i,{providerId:p,agentType:v});return!o&&!s?null:t.jsxs("div",{className:`flex shrink-0 items-center ${a?"gap-1":"gap-2"}`,children:[o&&t.jsxs("div",{className:`flex shrink-0 items-center rounded-lg text-muted-foreground ${a?"max-w-[130px] min-w-[82px] gap-1 px-1.5 py-1 text-xs":"max-w-[220px] min-w-[110px] gap-1.5 px-2 py-1.5 text-xs"}`,title:`${r("Provider")}: ${o.title}`,children:[t.jsx(Gt,{agentType:o.agentType,className:a?"size-3":"size-3.5"}),t.jsx("span",{className:"min-w-0 truncate",children:Qn(o.label,a?12:18)})]}),t.jsx(Ro,{usage:s,tooltipSide:w})]})}function jn(e){return e.length>0?e.map(i=>`- ${i}`).join(`
|
|
65
|
+
`):"- 未获取到冲突文件列表"}function Tn(e){if(!e)return[];const i=[];return e.workspaceId&&i.push(`- Workspace: \`${e.workspaceId}\``),e.worktreePath&&i.push(`- Worktree: \`${e.worktreePath}\``),e.sourceWorkspaceId&&i.push(`- Source workspace: \`${e.sourceWorkspaceId}\``),e.targetWorkspaceId&&i.push(`- Target workspace: \`${e.targetWorkspaceId}\``),e.sourceWorktreePath&&i.push(`- Source worktree: \`${e.sourceWorktreePath}\``),e.targetWorktreePath&&i.push(`- Target worktree: \`${e.targetWorktreePath}\``),e.operation&&e.operation!=="idle"&&i.push(`- Git 状态: \`${e.operation}\``),e.mergeStrategy&&i.push(`- Merge strategy: \`${e.mergeStrategy}\``),e.mergeAborted&&i.push("- Merge state: conflict detected and already aborted by Agent Tower"),i}function tf(e,i){if(!i?.mergeAborted)return["1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git commit` 完成合并"];const s=i.mergeStrategy==="squash"?`git merge --squash --no-commit ${e}`:`git merge --no-ff ${e}`,a=i.mergeStrategy==="squash"?"`git commit`":"`git merge --continue` 或 `git commit`";return["1. 注意:Agent Tower 检测到 merge 冲突后已经执行 abort,当前不要假设存在冲突标记或 `MERGE_HEAD`","2. 切换到 Target worktree / Target branch 上下文,确认工作区干净",`3. 重新执行 \`${s}\` 复现冲突`,"4. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","5. 对每个已解决的文件执行 `git add <file>`",`6. 执行 ${a} 完成合并`]}function sf(e){if(!e.mergeAborted)return"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 merge 提交,然后说明处理结果。";const i=e.targetWorktreePath?`目标 worktree \`${e.targetWorktreePath}\``:`目标分支 \`${e.targetBranch}\``,s=e.mergeStrategy==="squash"?`git merge --squash --no-commit ${e.sourceBranch}`:`git merge --no-ff ${e.sourceBranch}`;return`Agent Tower 已在检测到冲突后 abort 了 merge;请在${i}中确认工作区干净,重新执行 \`${s}\` 复现冲突,解决后完成提交并汇报验证结果。`}function rf(e,i,s,a,p){const v=jn(s),w=Tn(p);return a===kt.REBASE?["## Rebase 冲突解决","",`在将分支 \`${e}\` rebase 到 \`${i}\` 时发生了冲突。`,...w.length>0?["","### 上下文",...w]:[],"","### 冲突文件",v,"","### 解决步骤","1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git rebase --continue` 继续 rebase 流程"].join(`
|
|
66
|
+
`):["## Merge 冲突解决","",`在将分支 \`${e}\` 合并到 \`${i}\` 时发生了冲突。`,...w.length>0?["","### 上下文",...w]:[],"","### 冲突文件",v,"","### 解决步骤",...tf(e,p)].join(`
|
|
67
|
+
`)}function nf(e){const i=e.conflictOp===kt.REBASE?"Rebase":"Merge",s=jn(e.conflictedFiles),a=[...Tn(e),`- Source branch: \`${e.sourceBranch}\``,`- Target branch: \`${e.targetBranch}\``,`- Conflict type: \`${e.conflictOp}\``];return[`## 请求处理 ${i} 冲突`,"",`用户点击了“AI 辅助解决”,请在对应 workspace 中处理当前 ${i} 冲突,并在 Team Room 汇报处理结果和验证情况。`,"","### 上下文",...a,"","### 冲突文件",s,"","### 用户意图",e.conflictOp===kt.REBASE?"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 `git rebase --continue`,然后说明处理结果。":sf(e)].join(`
|
|
68
|
+
`)}function of(e){if(e.teamRunId)return{type:"team_room",message:nf(e)};const i=e.currentSessionId||e.selectedSessionId;return i?{type:"session",sessionId:i,message:rf(e.sourceBranch,e.targetBranch,e.conflictedFiles,e.conflictOp,e)}:{type:"none"}}function am({open:e,onOpenChange:i,workspaceId:s,resolutionContextToken:a,conflictOp:p,conflictedFiles:v,sourceBranch:w,targetBranch:r,operation:o,worktreePath:u,mergeAborted:f,mergeStrategy:l,sourceWorkspaceId:g,targetWorkspaceId:m,sourceWorktreePath:y,targetWorktreePath:b,sessions:n,currentSessionId:d,teamRunId:c}){const{t:h}=re(),[_,S]=A.useState(),[k,E]=A.useState(""),[x,C]=A.useState(!1),[N,L]=A.useState(""),R=A.useRef(!0);A.useEffect(()=>(R.current=!0,()=>{R.current=!1}),[]);const P=ko(),F=Zn(c??""),B=sa(),H=!!c,U=ri(a),T=U?ii(U.actor).find(j=>j.operationId===U.operationId):void 0,D=ui(a),M=D||T?.receiverSessionId||d||N,O=H?F.isPending:P.isPending,q=()=>{const j=of({workspaceId:s,worktreePath:u,operation:o,mergeAborted:f,mergeStrategy:l,sourceWorkspaceId:g,targetWorkspaceId:m,sourceWorktreePath:y,targetWorktreePath:b,sourceBranch:w,targetBranch:r,conflictedFiles:v,conflictOp:p,teamRunId:c,currentSessionId:M,selectedSessionId:N});if(j.type==="team_room"){F.mutate({content:j.message,kind:"chat"},{onSuccess:()=>{ke.success(h("已受理,等待发送到 Team Room")),i(!1)}});return}if(j.type!=="session")return;const I=_&&_.workspaceId===s&&_.original===a?_.token:a;rr({conflictOp:p,conflictedFiles:v,sourceBranch:w,targetBranch:r,mergeAborted:f,mergeStrategy:l,sourceWorkspaceId:g??s,targetWorkspaceId:m,sourceWorktreePath:y,targetWorktreePath:b,resolutionContextToken:I},j.sessionId),P.mutate({id:j.sessionId,message:j.message,systemAction:"resolve_conflicts",resolutionContextToken:I},{onSuccess:()=>{R.current&&(oi(I),i(!1))},onError:K=>{R.current&&E(K instanceof Error?K.message:String(K))}})},V=()=>{B.mutate({workspaceId:s},{onSuccess:()=>i(!1)})},$=p==="REBASE"?"Rebase":"Merge",z=!H&&!d&&!D&&!T?.receiverSessionId&&n.length>0,W=H||!!M;return t.jsx(At,{isOpen:e,onClose:()=>i(!1),title:h("解决 {opLabel} 冲突",{opLabel:$}),action:t.jsxs(t.Fragment,{children:[t.jsx(ce,{variant:"secondary",onClick:V,disabled:!!(b&&!m&&y!==b),children:h("在 IDE 中打开")}),t.jsx(ce,{variant:"primary",onClick:q,disabled:!W,loading:O,children:h(O?"发送中...":"AI 辅助解决")})]}),children:t.jsxs("div",{className:"space-y-4",children:[!H&&t.jsxs("div",{className:"space-y-2 text-sm",children:[k&&t.jsx("p",{role:"alert",className:"text-red-700",children:k}),t.jsx("p",{children:h("重新核验仅读取 Git,不自动发送。现场变化(包括部分 stage)可能无法继续 AI 恢复;请保留成果,在实际目标手工继续,或确认后明确中止并重做原操作。")}),t.jsxs("p",{children:[h("实际冲突目标目录"),":",t.jsx("code",{children:b??u})]}),(ni()||Eo())&&t.jsx("p",{role:"alert",children:h("浏览器存储不可用或资料损坏;本页仅在内存中保留,刷新后可能无法恢复。请先保存操作资料。")}),T?.expiresAt&&t.jsxs("p",{children:[h("恢复截止时间"),":",new Date(T.expiresAt).toLocaleString()]}),D&&t.jsx("p",{children:h("结果未知或待重试的原提交将先使用原 Session、UUID 和原请求核对;明确未受理后才使用新凭据。")}),t.jsx(ce,{variant:"secondary",disabled:x||O,onClick:async()=>{C(!0);try{const j=g??s,I=a?await ne.post(`/workspaces/${j}/conflict-context`,{resolutionContextToken:a}):await ne.get(`/workspaces/${j}/git-status`);if(!R.current)return;if(!I.resolutionContextToken)throw new Error(h("没有可核验的当前冲突。请求尚未受理;请保留原操作资料,确认 Git 状态后明确重新执行原操作。刷新或重试发送不会执行 Git。"));S({original:a,workspaceId:s,token:I.resolutionContextToken}),rr({conflictOp:p,conflictedFiles:v,sourceBranch:w,targetBranch:r,mergeAborted:f,mergeStrategy:l,sourceWorkspaceId:j,targetWorkspaceId:m,sourceWorktreePath:y,targetWorktreePath:b,resolutionContextToken:I.resolutionContextToken},M),E("")}catch(j){R.current&&E(j instanceof Error?j.message:String(j))}finally{R.current&&C(!1)}},children:h("只读核验当前冲突")})]}),t.jsxs("div",{children:[t.jsx("h4",{className:"text-[13px] font-medium text-foreground mb-1.5",children:h("冲突文件({count})",{count:v.length})}),t.jsx("div",{className:"max-h-40 overflow-y-auto rounded-lg border border-border/60 bg-foreground/[0.025]",children:v.map(j=>t.jsx("div",{className:"px-3 py-1.5 text-xs font-mono break-all text-foreground/85 border-b border-border/60 last:border-b-0",children:j},j))})]}),H&&t.jsx(Oe,{tone:"info",children:h("TeamRun 模式下会把处理冲突请求发送到 Team Room,由团队调度处理。")}),z&&t.jsx(vi,{label:h("选择 Session(AI 辅助解决)"),children:t.jsx(ia,{value:N,onValueChange:L,placeholder:h("选择一个 Session..."),options:n.map(j=>({value:j.id,label:`${j.agentType} — ${j.status}`}))})}),!H&&!M&&n.length===0&&t.jsx("p",{className:"text-sm text-muted-foreground",children:h("没有可用的 Session,请在 IDE 中手动解决冲突。")})]})})}function lm({recovery:e,onRecover:i}){const{t:s}=re(),[a,p]=A.useState(()=>Date.now());A.useEffect(()=>{const o=setInterval(()=>p(Date.now()),3e4);return()=>clearInterval(o)},[]);const{drafts:v,storageUnavailable:w,identityError:r}=e;return t.jsxs("div",{className:"space-y-2 px-4 text-sm",children:[w&&t.jsx("p",{role:"alert",children:s("浏览器存储不可用或资料损坏;本页仅在内存中保留,刷新后可能无法恢复。请先保存操作资料。")}),r&&t.jsx("p",{role:"alert",children:s("无法确认当前身份,暂不展示已保存的冲突资料。")}),v.map(o=>t.jsxs("div",{className:"rounded border p-2 space-y-1",children:[t.jsx("p",{children:s("已保留原冲突资料;关闭弹窗后可在此重新打开。仅当前身份和本标签页可恢复,关闭标签页或清理浏览器数据会删除资料。")}),t.jsx("p",{children:o.expiresAt&&o.expiresAt<=a?s("恢复证明已过期;保留成果,在实际目标手工继续,或确认后明确中止并重做。已提交但结果未知的请求仍可核对原 UUID。"):`${s("恢复截止时间")}:${o.expiresAt?new Date(o.expiresAt).toLocaleString():s("未知")}`}),t.jsx(ge,{variant:"outline",onClick:()=>i(o.details),children:s("恢复上次冲突资料")}),t.jsx(ge,{variant:"ghost",onClick:()=>oi(o.details.resolutionContextToken),children:s("清理本地操作资料")}),t.jsx("p",{className:"text-xs text-muted-foreground",children:s("清理不会取消服务端已受理请求;结果未知时请先核对原提交。")})]},o.operationId))]})}function cm(e,i=!0){const[,s]=A.useState(0),a=Ni({mutationKey:ie.accessAuth.identityChange})>0,p=Ee({queryKey:ie.accessAuth.conflictRecoveryIdentity,queryFn:({signal:l})=>ne.get("/conflict-recovery-identity",{signal:l}),enabled:i&&!a,staleTime:0,gcTime:0,retry:!1}),v=i&&!a&&p.isSuccess&&!p.isFetching?p.data.actor:void 0,[w,r]=A.useState({actor:v,enabled:i});(w.actor!==v||w.enabled!==i)&&r({actor:v,enabled:i}),A.useEffect(()=>{const l=()=>s(g=>g+1);return window.addEventListener(ir,l),()=>window.removeEventListener(ir,l)},[]);const o=v?ii(v).filter(l=>e.includes(l.details.sourceWorkspaceId??"")):[],u=w.enabled===i&&(!i||v&&w.actor===v)?w.details??null:null;return{drafts:o,actor:v,pendingConflictDetails:u,openDialog:l=>{let g=nr(l);if(i){if(!v||(ri(g.resolutionContextToken)?.actor??v)!==v)return;const m=g.sourceWorkspaceId;if(!m||!e.includes(m))return;const y=jo(v,m),b=o.find(n=>n.details.sourceWorkspaceId===m&&ui(n.details.resolutionContextToken));y?g=nr({conflictOp:g.conflictOp,conflictedFiles:[],resolutionContextToken:y.token}):b&&(g=b.details)}r({actor:v,enabled:i,details:g})},closeDialog:()=>r({actor:v,enabled:i}),storageUnavailable:ni(),identityError:i&&p.isError}}function af(e){return[...e?.uncommitted??[],...e?.committed??[]].reduce((s,a)=>({files:s.files+1,additions:s.additions+(a.additions??0),deletions:s.deletions+(a.deletions??0)}),{files:0,additions:0,deletions:0})}function Kr(e,i,s,a){const p=bn(e);if(p){s(p);return}a(e instanceof Error?e.message:i)}function dm({projectId:e,workspaceId:i,branchName:s,targetBranch:a,commitMessage:p,changes:v,gitStatus:w,isGitStatusLoading:r,canRunGitOperations:o,onOpenChanges:u,onRefreshCommitMessage:f,onConflict:l,className:g}){const{t:m}=re(),y=ki(),b=Ei(),n=ji(),[d,c]=A.useState(!1),[h,_]=A.useState(null),S=Zs(i,d),k=(S.data??[]).filter(gn),E=A.useMemo(()=>af(v),[v]),x=E.additions+E.deletions,C=E.files>0&&x>0,N=(w?.conflictedFiles.length??0)>0,L=!!(w&&w.operation!=="idle"),R=!!(w&&(w.hasUncommittedChanges||w.untrackedCount>0)),P=(w?.uncommittedCount??0)+(w?.untrackedCount??0),F=(w?.behind??0)>0,B=(w?.ahead??0)>0,H=r||!w&&o,U=!!(o&&i&&w&&F&&!N&&!L&&!R),T=!!(o&&i&&w&&B&&!F&&!N&&!L&&!R),D=!!(o&&i&&w&&!N&&!L&&!R);if(A.useEffect(()=>{d&&f?.()},[d,f]),!C)return null;const M=N?m("冲突"):w?.operation==="rebase"?m("变基中"):w?.operation==="merge"?m("合并中"):P>0?m("{count} 未提交",{count:P}):F?m("落后 {count}",{count:w?.behind??0}):m(B?"可合并":"已是最新"),O=m("{files} 个文件 · {lines} 行",{files:E.files,lines:x}),q=()=>{U&&(_(null),y.mutate(i,{onError:W=>{Kr(W,m("更新失败,请稍后重试"),j=>l(j),_)}}))},V=()=>{D&&(_(null),c(!0))},$=(W,j)=>{_(null),b.mutate({id:i,commitMessage:W,stopActiveServices:j},{onSuccess:()=>c(!1),onError:I=>{if(vn(I)){_(m("后台服务仍在运行,请确认停止服务后再提交。"));return}Kr(I,m("提交失败,请稍后重试"),K=>{c(!1),l(K)},_)}})},z=()=>{b.isPending||(c(!1),_(null))};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:Q("space-y-1",g),children:[t.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg bg-muted/25 px-2 py-1.5",children:[t.jsxs("button",{type:"button",onClick:u,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-1.5 py-0.5 text-left transition-colors hover:bg-muted/55 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40","aria-label":m("查看变更详情"),children:[t.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-background/70 text-muted-foreground",children:t.jsx(Xs,{size:13})}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:O}),t.jsx(si,{additions:E.additions,deletions:E.deletions,className:"hidden sm:inline-flex"}),N&&t.jsx(Nt,{size:13,className:"shrink-0 text-warning"}),t.jsxs("span",{className:"hidden min-w-0 basis-0 grow max-w-fit items-center gap-1 text-[11px] text-muted-foreground md:flex",children:[t.jsx("span",{className:"truncate font-mono",children:s}),t.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground/70",children:"→"}),t.jsx("span",{className:"truncate font-mono",children:a})]}),t.jsx(Wt,{className:"bg-background/75",children:M})]}),t.jsx(Je,{size:15,className:"shrink-0 text-muted-foreground/70"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[L&&t.jsx(ce,{variant:"secondary",size:"sm",className:"hidden sm:inline-flex",onClick:()=>n.mutate(i),loading:n.isPending,children:n.isPending?m("正在撤销..."):m("撤销操作")}),t.jsx("span",{title:m(F?"同步更新":"已是最新"),className:Q("inline-flex",(!U||H)&&"cursor-not-allowed"),children:t.jsxs(ce,{variant:"secondary",size:"sm",onClick:q,disabled:!U||H,loading:y.isPending,children:[!y.isPending&&t.jsx(_t,{}),y.isPending?m("正在同步..."):m("更新")]})}),t.jsx("span",{title:T?m("合并到 {target}",{target:a}):m("提交变更"),className:Q("inline-flex",(!D||H)&&"cursor-not-allowed"),children:t.jsxs(ce,{variant:"primary",size:"sm",onClick:V,disabled:!D||H,loading:b.isPending,children:[!b.isPending&&t.jsx(Ks,{}),b.isPending?m("正在提交..."):m("合并")]})})]})]}),h&&t.jsx(Oe,{tone:"danger",size:"sm",children:h})]}),t.jsx(_n,{projectId:e,workspaceId:i,canMerge:T,isOpen:d,onClose:z,onBaseBranchSaved:u,branchName:s,targetBranch:a,commitMessage:p,isPending:b.isPending,activeServices:k,isCheckingServices:S.isLoading,serviceCheckFailed:S.isError,error:h,onConfirm:$})]})}const Xr=["creating-workspace","creating-session","starting-session"];function hm({state:e,setupProgress:i,sessionStarted:s=!1,onRetry:a,compact:p=!1}){const{t:v}=re(),[w,r]=A.useState(!1),o=e?.status==="failed",u=i?.status==="failed",f=o||u,l=e?Xr.indexOf(e.status):Xr.length,g=[v("Preparing workspace"),v("Creating session"),v("Starting agent")],m=(e?.setupScript??"").split(`
|
|
69
|
+
`).map(n=>n.trim()).filter(Boolean),y=e||s?g.map((n,d)=>({label:n,status:o?"pending":d<l?"completed":d===l?"active":"pending"})):[];(i||m.length>0)&&y.push({label:i?.status==="running"?v("Running setup ({current}/{total})",{current:i.currentIndex??0,total:i.totalCommands}):i?.status==="completed"?v("Setup complete"):i?.status==="failed"?v("Setup failed"):v("Run setup script"),status:i?.status==="running"?"active":i?.status??"pending",description:i?.currentCommand||m.join(`
|
|
70
|
+
`)});const b=!!i?.output?.trim();return!e&&!i?null:t.jsxs("div",{className:`${p?"my-2 mb-4":"my-3 mb-6"} mx-auto w-full max-w-2xl rounded-xl border ${f?"border-destructive/30 bg-destructive/[0.03]":"border-border/70 bg-background"} px-4 py-3 text-left shadow-raised`,role:f?"alert":"status","aria-live":f?"assertive":"polite",children:[f&&(e?.error||i?.error||o)?t.jsx("p",{className:"mb-2 break-words text-xs text-destructive-ink",children:e?.error||i?.error||v("Agent start failed")}):null,t.jsx("div",{className:"space-y-2",children:y.map(({label:n,status:d,description:c})=>{const h=d==="completed",_=d==="active";return t.jsxs("div",{className:`flex items-start gap-2 text-sm ${d==="failed"?"text-destructive-ink":h||_?"text-info-ink":"text-muted-foreground"}`,children:[h?t.jsx(Jn,{className:"h-4 w-4 shrink-0"}):_?t.jsx(zs,{className:"h-4 w-4 shrink-0 animate-spin motion-reduce:animate-none"}):d==="failed"?t.jsx(ti,{className:"h-4 w-4 shrink-0"}):t.jsx(ua,{className:"h-4 w-4 shrink-0"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{children:n}),c&&t.jsx("code",{className:"mt-1 block whitespace-pre-wrap break-all rounded-md bg-muted/35 px-2.5 py-2 text-xs leading-relaxed text-muted-foreground",children:c})]})]},n)})}),(b||o)&&t.jsxs("div",{className:"mt-3 flex items-center justify-between gap-3 border-t border-border/50 pt-2",children:[b?t.jsxs("button",{type:"button",onClick:()=>r(n=>!n),className:"inline-flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground","aria-expanded":w,"aria-controls":"task-start-progress-details",children:[w?t.jsx(Ke,{className:"h-3.5 w-3.5"}):t.jsx(Je,{className:"h-3.5 w-3.5"}),v(w?"Hide setup output":"View setup output")]}):t.jsx("span",{}),o&&a?t.jsx(ge,{size:"sm",variant:"outline",onClick:a,children:v("Retry start")}):null]}),w&&t.jsx("div",{id:"task-start-progress-details",className:"mt-2 rounded-md bg-muted/35 px-2.5 py-2 text-xs leading-relaxed text-muted-foreground",children:t.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono",children:i?.output??""})})]})}function lf({agentType:e,workingDir:i}){return Ee({queryKey:ie.system.skillCatalog(e,i),queryFn:async()=>(await ne.get("/system/skill-catalog",{params:{agentType:String(e),...i?{workingDir:i}:{}}})).commands,enabled:e===ai.CODEX,staleTime:3e4})}function cf(e){const i=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,s=e.key==="Tab"&&!e.shiftKey;return i||s}function um({agentType:e,workingDir:i,input:s,setInput:a,textareaRef:p,minHeight:v,maxHeight:w}){const[r,o]=A.useState(0),{data:u=[]}=lf({agentType:e,workingDir:i}),l=A.useMemo(()=>e===ai.CODEX?ar(s):null,[e,s])?.query??null,g=A.useMemo(()=>l===null?[]:qo(u,l),[l,u]),m=A.useCallback(()=>{const n=p.current;n&&(n.style.height="auto",n.style.height=`${Math.max(v,Math.min(n.scrollHeight,w))}px`)},[w,v,p]);A.useEffect(()=>{o(0)},[e,l]),A.useEffect(()=>{r<g.length||o(0)},[g.length,r]);const y=A.useCallback(n=>{const d=ar(s);if(!d)return;const c=`${s.slice(0,d.replaceStart)}${n.command} `;a(c),requestAnimationFrame(()=>{const h=p.current;h&&(m(),h.focus(),h.setSelectionRange(c.length,c.length))})},[s,m,a,p]),b=A.useCallback(n=>l===null||g.length===0?!1:n.key==="ArrowDown"?(n.preventDefault(),o(d=>(d+1)%g.length),!0):n.key==="ArrowUp"?(n.preventDefault(),o(d=>(d-1+g.length)%g.length),!0):cf(n)?(n.preventDefault(),y(g[r]??g[0]),!0):!1,[y,g,l,r]);return{allSkills:u,query:l,filteredSkills:g,selectedIndex:r,setSelectedIndex:o,applySkill:y,handleKeyDown:b}}const ks=200,df=180;function fm({taskId:e,title:i,readOnly:s=!1,onTitleChange:a,className:p,titleClassName:v,compact:w=!1}){const{t:r}=re(),[o,u]=A.useState(!1),[f,l]=A.useState(i),[g,m]=A.useState(!1),y=A.useRef(null),b=A.useRef(null),n=eo();A.useEffect(()=>{o||l(i)},[i,o]),A.useEffect(()=>{o&&y.current&&(y.current.focus(),y.current.select())},[o]),A.useEffect(()=>{if(!o)return;const C=N=>{b.current&&!b.current.contains(N.target)&&h()};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[o,f]);const d=A.useCallback(()=>{s||(u(!0),l(i))},[s,i]),c=A.useCallback(()=>{u(!1),l(i)},[i]),h=A.useCallback(async()=>{const C=f.trim();if(!C){l(i),u(!1);return}if(C===i){u(!1);return}try{await n.mutateAsync({id:e,title:C}),a?.(C),u(!1)}catch(N){console.error("Failed to update task title:",N),l(i)}},[f,i,e,n,a]),_=A.useCallback(C=>{C.key==="Enter"&&!C.shiftKey?(C.preventDefault(),h()):C.key==="Escape"&&(C.preventDefault(),c())},[h,c]),S=A.useCallback(C=>{const N=C.target.value;N.length<=ks&&l(N)},[]),k=f.length,E=k>=df,x=k>=ks;return o?t.jsxs("div",{ref:b,className:Q("flex flex-col gap-2",p),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{ref:y,type:"text",value:f,onChange:S,onKeyDown:_,disabled:n.isPending,className:Q("flex-1 min-w-0 px-2 py-1 text-[15px] font-semibold bg-background border border-input rounded-md","focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent","disabled:opacity-50 disabled:cursor-not-allowed",w&&"text-base py-0.5",v),placeholder:r("输入任务标题")}),t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.jsx(ge,{size:w?"sm":"default",variant:"ghost",onClick:h,disabled:n.isPending||!f.trim(),className:"h-8 w-8 p-0",children:n.isPending?t.jsx(zs,{size:16,className:"animate-spin motion-reduce:[animation-duration:2.4s]"}):t.jsx(Et,{size:16})}),t.jsx(ge,{size:w?"sm":"default",variant:"ghost",onClick:c,disabled:n.isPending,className:"h-8 w-8 p-0",children:t.jsx(tt,{size:16})})]})]}),E&&t.jsxs("div",{className:Q("text-xs",x?"text-destructive-ink":"text-muted-foreground"),children:[k," / ",ks," ",r("字符")]})]}):t.jsxs("div",{ref:b,className:Q("group flex items-center gap-2 min-w-0",p),onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),children:[t.jsx("h2",{onClick:d,className:Q("flex-1 min-w-0 text-[15px] font-semibold text-foreground break-words line-clamp-2",!s&&"cursor-text hover:text-foreground/80 transition-colors",w&&"text-base",v),children:i}),!s&&g&&t.jsx(ge,{size:"sm",variant:"ghost",onClick:d,className:"h-7 w-7 p-0 shrink-0 opacity-60 hover:opacity-100",title:r("编辑标题"),children:t.jsx(na,{size:14})})]})}function hf(e){return Ee({queryKey:ie.tasks.handoff(e),queryFn:({signal:i})=>ne.get(`/tasks/${encodeURIComponent(e)}/handoff`,{signal:i}),enabled:!!e})}function uf(e){const i=Pe();return Ct({mutationFn:s=>ne.patch(`/tasks/${encodeURIComponent(e)}/handoff`,s),onMutate:()=>i.cancelQueries({queryKey:ie.tasks.handoff(e)}),onSuccess:s=>{i.setQueryData(ie.tasks.handoff(s.taskId),s)},onSettled:()=>i.invalidateQueries({queryKey:ie.tasks.handoff(e)})})}function Yr(e){try{const i=JSON.parse(sessionStorage.getItem(e)??"null");if(i&&typeof i=="object"&&"base"in i&&"content"in i&&typeof i.base=="string"&&typeof i.content=="string")return{base:i.base,content:i.content}}catch{}return null}function mm({taskId:e,readOnly:i=!1}){const{t:s}=re(),a=hf(e),p=uf(e),v=`task-handoff-draft:${e}`,[w,r]=A.useState(()=>Yr(v)),o=w!==null&&!i;A.useEffect(()=>{try{w?sessionStorage.setItem(v,JSON.stringify(w)):sessionStorage.removeItem(v)}catch{}},[w,v]);const u=async()=>{if(!(!w||p.isPending))try{await p.mutateAsync({oldString:w.base,newString:w.content});try{const m=Yr(v);m?.base===w.base&&m.content===w.content&&sessionStorage.removeItem(v)}catch{}r(null)}catch{}};if(a.isPending)return t.jsx("p",{className:"p-4 text-sm text-muted-foreground",children:s("Loading...")});if(!a.data)return t.jsx("div",{className:"p-3",children:t.jsx(Oe,{tone:"danger",action:t.jsx(ce,{variant:"link",size:"sm",onClick:()=>a.refetch(),children:s("Retry")}),children:s("Could not load the handoff note.")})});const f=o&&w.base!==a.data.content,l=p.error instanceof Ze?p.error.details.code:void 0,g=typeof l=="string"&&["HANDOFF_CHANGED","HANDOFF_NOT_EMPTY","HANDOFF_TEXT_NOT_FOUND","HANDOFF_TEXT_AMBIGUOUS"].includes(l);return t.jsxs("section",{className:"flex h-full min-h-0 flex-col","aria-label":s("Handoff note"),children:[t.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-between gap-2 border-b border-border/60 px-3 py-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:s(o?"Markdown":"Progress, decisions, and next steps")}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(Ho,{value:o?w.content:a.data.content,display:"text",size:"sm"}),o?t.jsxs(t.Fragment,{children:[t.jsx(ce,{variant:"ghost",size:"sm",disabled:p.isPending,onClick:()=>{r(null),p.reset()},children:s("Cancel")}),t.jsx(ce,{size:"sm",disabled:p.isPending||w.content===w.base,onClick:u,children:p.isPending?s("保存中..."):s("Save")})]}):!i&&t.jsx(ce,{variant:"secondary",size:"sm",onClick:()=>{p.reset(),r({base:a.data.content,content:a.data.content})},children:s("编辑")})]})]}),o&&(f||g)&&t.jsx(Oe,{tone:"warning",size:"sm",className:"mx-3 mt-3",role:"status",children:s("The handoff changed elsewhere. Your draft is preserved. Cancel editing to view the latest note.")}),o&&p.isError&&!g&&t.jsx(Oe,{tone:"danger",size:"sm",className:"mx-3 mt-3",role:"alert",children:s("Could not save the handoff note. Your draft is preserved.")}),o?t.jsx("div",{className:"flex min-h-0 flex-1 p-3",children:t.jsx(_i,{"aria-label":s("Handoff Markdown"),value:w.content,onChange:m=>r({...w,content:m.target.value}),maxLength:$a,disabled:p.isPending,className:"min-h-0 flex-1 font-mono",placeholder:s("Summarize progress, decisions, verification, open problems, and next steps."),onKeyDown:m=>{(m.metaKey||m.ctrlKey)&&m.key==="Enter"&&(m.preventDefault(),u())}})}):t.jsx("div",{className:"prose prose-sm max-w-none min-h-0 flex-1 overflow-y-auto p-4 dark:prose-invert [overflow-wrap:anywhere]",children:a.data.content?t.jsx(hi,{components:bo,children:a.data.content}):t.jsx("p",{className:"py-6 text-center text-muted-foreground",children:s("No handoff note yet. Record what has been done and what comes next.")})})]})}export{lm as C,xn as D,fm as E,Xs as G,Gf as R,om as S,Vf as T,dm as W,um as a,cu as b,Jf as c,jt as d,em as e,cm as f,Qf as g,nm as h,Xf as i,hm as j,sm as k,tm as l,Yf as m,mm as n,im as o,am as p,du as q,Zf as r,mn as s,pn as t,rm as u,Yu as v,gu as w,Xi as x};
|