agent-tower 0.6.0-beta.2 → 0.6.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +10 -2
- package/dist/app.js.map +1 -1
- package/dist/app.test.js +10 -0
- package/dist/app.test.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 +9 -1
- package/dist/core/container.js.map +1 -1
- package/dist/executors/__tests__/codex.executor.test.js +50 -0
- package/dist/executors/__tests__/codex.executor.test.js.map +1 -1
- package/dist/executors/codex.executor.d.ts +2 -0
- package/dist/executors/codex.executor.d.ts.map +1 -1
- package/dist/executors/codex.executor.js +8 -0
- package/dist/executors/codex.executor.js.map +1 -1
- package/dist/executors/execution-env.d.ts +1 -1
- package/dist/executors/execution-env.d.ts.map +1 -1
- package/dist/executors/execution-env.js +2 -0
- package/dist/executors/execution-env.js.map +1 -1
- package/dist/mcp/http-client.d.ts +24 -0
- package/dist/mcp/http-client.d.ts.map +1 -1
- package/dist/mcp/http-client.js +66 -8
- package/dist/mcp/http-client.js.map +1 -1
- package/dist/mcp/http-client.test.d.ts +2 -0
- package/dist/mcp/http-client.test.d.ts.map +1 -0
- package/dist/mcp/http-client.test.js +67 -0
- package/dist/mcp/http-client.test.js.map +1 -0
- package/dist/mcp/index.js +9 -2
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/server.d.ts +1 -0
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +7 -0
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tools/__tests__/workspace-services.test.d.ts +2 -0
- package/dist/mcp/tools/__tests__/workspace-services.test.d.ts.map +1 -0
- package/dist/mcp/tools/__tests__/workspace-services.test.js +84 -0
- package/dist/mcp/tools/__tests__/workspace-services.test.js.map +1 -0
- package/dist/mcp/tools/workspace-services.d.ts +6 -0
- package/dist/mcp/tools/workspace-services.d.ts.map +1 -0
- package/dist/mcp/tools/workspace-services.js +102 -0
- package/dist/mcp/tools/workspace-services.js.map +1 -0
- package/dist/mcp/types.d.ts +53 -0
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/mcp/types.js +29 -0
- package/dist/mcp/types.js.map +1 -1
- package/dist/middleware/__tests__/access-auth.test.js +229 -2
- package/dist/middleware/__tests__/access-auth.test.js.map +1 -1
- package/dist/middleware/access-auth.d.ts +7 -0
- package/dist/middleware/access-auth.d.ts.map +1 -1
- package/dist/middleware/access-auth.js +50 -9
- package/dist/middleware/access-auth.js.map +1 -1
- package/dist/prompts/agent-output-intents.d.ts +2 -0
- package/dist/prompts/agent-output-intents.d.ts.map +1 -0
- package/dist/prompts/agent-output-intents.js +11 -0
- package/dist/prompts/agent-output-intents.js.map +1 -0
- package/dist/prompts/agent-output-intents.test.d.ts +2 -0
- package/dist/prompts/agent-output-intents.test.d.ts.map +1 -0
- package/dist/prompts/agent-output-intents.test.js +12 -0
- package/dist/prompts/agent-output-intents.test.js.map +1 -0
- package/dist/prompts/workspace-background-service-policy.d.ts +9 -0
- package/dist/prompts/workspace-background-service-policy.d.ts.map +1 -0
- package/dist/prompts/workspace-background-service-policy.js +17 -0
- package/dist/prompts/workspace-background-service-policy.js.map +1 -0
- package/dist/prompts/workspace-background-service-policy.test.d.ts +2 -0
- package/dist/prompts/workspace-background-service-policy.test.d.ts.map +1 -0
- package/dist/prompts/workspace-background-service-policy.test.js +19 -0
- package/dist/prompts/workspace-background-service-policy.test.js.map +1 -0
- package/dist/routes/__tests__/previews.integration.test.js +1 -0
- package/dist/routes/__tests__/previews.integration.test.js.map +1 -1
- package/dist/routes/__tests__/previews.test.js +6 -1
- package/dist/routes/__tests__/previews.test.js.map +1 -1
- package/dist/routes/__tests__/providers.test.js +1 -0
- package/dist/routes/__tests__/providers.test.js.map +1 -1
- package/dist/routes/__tests__/sessions-visualizations.test.d.ts +2 -0
- package/dist/routes/__tests__/sessions-visualizations.test.d.ts.map +1 -0
- package/dist/routes/__tests__/sessions-visualizations.test.js +89 -0
- package/dist/routes/__tests__/sessions-visualizations.test.js.map +1 -0
- package/dist/routes/__tests__/workspace-services.test.d.ts +2 -0
- package/dist/routes/__tests__/workspace-services.test.d.ts.map +1 -0
- package/dist/routes/__tests__/workspace-services.test.js +148 -0
- package/dist/routes/__tests__/workspace-services.test.js.map +1 -0
- package/dist/routes/access-auth.d.ts.map +1 -1
- package/dist/routes/access-auth.js +24 -11
- package/dist/routes/access-auth.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.map +1 -1
- package/dist/routes/previews.js +4 -6
- package/dist/routes/previews.js.map +1 -1
- package/dist/routes/sessions.d.ts.map +1 -1
- package/dist/routes/sessions.js +93 -0
- package/dist/routes/sessions.js.map +1 -1
- package/dist/routes/tasks.d.ts.map +1 -1
- package/dist/routes/tasks.js +2 -2
- package/dist/routes/tasks.js.map +1 -1
- package/dist/routes/workspace-services.d.ts +7 -0
- package/dist/routes/workspace-services.d.ts.map +1 -0
- package/dist/routes/workspace-services.js +129 -0
- package/dist/routes/workspace-services.js.map +1 -0
- package/dist/runtime/__tests__/acp-agent-definitions.test.js +118 -0
- package/dist/runtime/__tests__/acp-agent-definitions.test.js.map +1 -1
- package/dist/runtime/__tests__/acp-driver-lifecycle.test.js +143 -1
- package/dist/runtime/__tests__/acp-driver-lifecycle.test.js.map +1 -1
- package/dist/runtime/__tests__/acp-driver.test.js +36 -0
- package/dist/runtime/__tests__/acp-driver.test.js.map +1 -1
- package/dist/runtime/__tests__/acp-process-manager.test.js +109 -1
- package/dist/runtime/__tests__/acp-process-manager.test.js.map +1 -1
- package/dist/runtime/__tests__/acp-projector.test.js +55 -0
- package/dist/runtime/__tests__/acp-projector.test.js.map +1 -1
- package/dist/runtime/__tests__/runtime-coordinator.test.js +5 -2
- package/dist/runtime/__tests__/runtime-coordinator.test.js.map +1 -1
- package/dist/runtime/acp/acp-driver.js +100 -28
- package/dist/runtime/acp/acp-driver.js.map +1 -1
- package/dist/runtime/acp/agents/codex-frame-normalizer.d.ts +4 -0
- package/dist/runtime/acp/agents/codex-frame-normalizer.d.ts.map +1 -0
- package/dist/runtime/acp/agents/codex-frame-normalizer.js +120 -0
- package/dist/runtime/acp/agents/codex-frame-normalizer.js.map +1 -0
- package/dist/runtime/acp/agents/codex.d.ts.map +1 -1
- package/dist/runtime/acp/agents/codex.js +35 -0
- package/dist/runtime/acp/agents/codex.js.map +1 -1
- package/dist/runtime/acp/agents/types.d.ts +7 -0
- package/dist/runtime/acp/agents/types.d.ts.map +1 -1
- package/dist/runtime/acp/codex-provider-config.d.ts +3 -0
- package/dist/runtime/acp/codex-provider-config.d.ts.map +1 -1
- package/dist/runtime/acp/codex-provider-config.js +34 -1
- package/dist/runtime/acp/codex-provider-config.js.map +1 -1
- package/dist/runtime/acp/process-manager.d.ts +3 -0
- package/dist/runtime/acp/process-manager.d.ts.map +1 -1
- package/dist/runtime/acp/process-manager.js +31 -12
- package/dist/runtime/acp/process-manager.js.map +1 -1
- package/dist/runtime/acp/projector.d.ts.map +1 -1
- package/dist/runtime/acp/projector.js +71 -5
- package/dist/runtime/acp/projector.js.map +1 -1
- package/dist/runtime/contracts.d.ts +1 -0
- package/dist/runtime/contracts.d.ts.map +1 -1
- package/dist/runtime/runtime-coordinator.d.ts.map +1 -1
- package/dist/runtime/runtime-coordinator.js +1 -0
- package/dist/runtime/runtime-coordinator.js.map +1 -1
- package/dist/services/__tests__/access-auth.service.test.js +41 -0
- package/dist/services/__tests__/access-auth.service.test.js.map +1 -1
- package/dist/services/__tests__/agent-artifact.service.test.d.ts +2 -0
- package/dist/services/__tests__/agent-artifact.service.test.d.ts.map +1 -0
- package/dist/services/__tests__/agent-artifact.service.test.js +133 -0
- package/dist/services/__tests__/agent-artifact.service.test.js.map +1 -0
- package/dist/services/__tests__/agent-visualization.service.test.d.ts +2 -0
- package/dist/services/__tests__/agent-visualization.service.test.d.ts.map +1 -0
- package/dist/services/__tests__/agent-visualization.service.test.js +57 -0
- package/dist/services/__tests__/agent-visualization.service.test.js.map +1 -0
- package/dist/services/__tests__/preview-runtime-manager.test.js +5 -0
- package/dist/services/__tests__/preview-runtime-manager.test.js.map +1 -1
- package/dist/services/__tests__/project.service.test.js +6 -2
- package/dist/services/__tests__/project.service.test.js.map +1 -1
- package/dist/services/__tests__/provider-config.service.test.js +32 -0
- package/dist/services/__tests__/provider-config.service.test.js.map +1 -1
- package/dist/services/__tests__/session-manager.lifecycle.test.js +153 -1
- package/dist/services/__tests__/session-manager.lifecycle.test.js.map +1 -1
- package/dist/services/__tests__/session-manager.team-run.test.js +18 -5
- package/dist/services/__tests__/session-manager.team-run.test.js.map +1 -1
- package/dist/services/__tests__/task.service.test.js +16 -3
- package/dist/services/__tests__/task.service.test.js.map +1 -1
- package/dist/services/__tests__/workspace-background-process-manager.test.d.ts +2 -0
- package/dist/services/__tests__/workspace-background-process-manager.test.d.ts.map +1 -0
- package/dist/services/__tests__/workspace-background-process-manager.test.js +412 -0
- package/dist/services/__tests__/workspace-background-process-manager.test.js.map +1 -0
- package/dist/services/__tests__/workspace-background-service.service.test.d.ts +2 -0
- package/dist/services/__tests__/workspace-background-service.service.test.d.ts.map +1 -0
- package/dist/services/__tests__/workspace-background-service.service.test.js +418 -0
- package/dist/services/__tests__/workspace-background-service.service.test.js.map +1 -0
- package/dist/services/__tests__/workspace.service.test.js +137 -0
- package/dist/services/__tests__/workspace.service.test.js.map +1 -1
- package/dist/services/access-auth.service.d.ts +15 -1
- package/dist/services/access-auth.service.d.ts.map +1 -1
- package/dist/services/access-auth.service.js +75 -15
- package/dist/services/access-auth.service.js.map +1 -1
- package/dist/services/agent-artifact.service.d.ts +28 -0
- package/dist/services/agent-artifact.service.d.ts.map +1 -0
- package/dist/services/agent-artifact.service.js +287 -0
- package/dist/services/agent-artifact.service.js.map +1 -0
- package/dist/services/agent-visualization.service.d.ts +12 -0
- package/dist/services/agent-visualization.service.d.ts.map +1 -0
- package/dist/services/agent-visualization.service.js +239 -0
- package/dist/services/agent-visualization.service.js.map +1 -0
- package/dist/services/mcp-config.service.d.ts.map +1 -1
- package/dist/services/mcp-config.service.js +8 -1
- package/dist/services/mcp-config.service.js.map +1 -1
- package/dist/services/mcp-config.service.test.js +14 -0
- package/dist/services/mcp-config.service.test.js.map +1 -1
- package/dist/services/preview-runtime-manager.d.ts.map +1 -1
- package/dist/services/preview-runtime-manager.js +15 -12
- package/dist/services/preview-runtime-manager.js.map +1 -1
- package/dist/services/project.service.d.ts +3 -0
- package/dist/services/project.service.d.ts.map +1 -1
- package/dist/services/project.service.js +43 -32
- package/dist/services/project.service.js.map +1 -1
- package/dist/services/provider-config.service.d.ts.map +1 -1
- package/dist/services/provider-config.service.js +11 -0
- package/dist/services/provider-config.service.js.map +1 -1
- package/dist/services/session-manager.d.ts +31 -29
- package/dist/services/session-manager.d.ts.map +1 -1
- package/dist/services/session-manager.js +43 -23
- package/dist/services/session-manager.js.map +1 -1
- package/dist/services/task-cleanup.service.d.ts +4 -1
- package/dist/services/task-cleanup.service.d.ts.map +1 -1
- package/dist/services/task-cleanup.service.js +13 -1
- package/dist/services/task-cleanup.service.js.map +1 -1
- package/dist/services/task.service.d.ts +15 -13
- package/dist/services/task.service.d.ts.map +1 -1
- package/dist/services/task.service.js +21 -8
- package/dist/services/task.service.js.map +1 -1
- package/dist/services/workspace-background-process-manager.d.ts +66 -0
- package/dist/services/workspace-background-process-manager.d.ts.map +1 -0
- package/dist/services/workspace-background-process-manager.js +328 -0
- package/dist/services/workspace-background-process-manager.js.map +1 -0
- package/dist/services/workspace-background-service.service.d.ts +39 -0
- package/dist/services/workspace-background-service.service.d.ts.map +1 -0
- package/dist/services/workspace-background-service.service.js +520 -0
- package/dist/services/workspace-background-service.service.js.map +1 -0
- package/dist/services/workspace-lifecycle-barrier.d.ts +10 -0
- package/dist/services/workspace-lifecycle-barrier.d.ts.map +1 -0
- package/dist/services/workspace-lifecycle-barrier.js +35 -0
- package/dist/services/workspace-lifecycle-barrier.js.map +1 -0
- package/dist/services/workspace.service.d.ts +36 -30
- package/dist/services/workspace.service.d.ts.map +1 -1
- package/dist/services/workspace.service.js +100 -39
- package/dist/services/workspace.service.js.map +1 -1
- package/dist/socket/__tests__/socket-gateway.test.js +23 -0
- package/dist/socket/__tests__/socket-gateway.test.js.map +1 -1
- package/dist/socket/middleware/__tests__/auth.test.js +3 -3
- package/dist/socket/middleware/__tests__/auth.test.js.map +1 -1
- package/dist/utils/agent-api-credential.d.ts +11 -0
- package/dist/utils/agent-api-credential.d.ts.map +1 -0
- package/dist/utils/agent-api-credential.js +40 -0
- package/dist/utils/agent-api-credential.js.map +1 -0
- package/dist/utils/internal-api-token.d.ts +2 -0
- package/dist/utils/internal-api-token.d.ts.map +1 -1
- package/dist/utils/internal-api-token.js +2 -0
- package/dist/utils/internal-api-token.js.map +1 -1
- package/dist/utils/process-launch.d.ts.map +1 -1
- package/dist/utils/process-launch.js +156 -22
- package/dist/utils/process-launch.js.map +1 -1
- package/dist/utils/process-launch.test.js +7 -0
- package/dist/utils/process-launch.test.js.map +1 -1
- package/dist/utils/unix-process-identity.d.ts +23 -0
- package/dist/utils/unix-process-identity.d.ts.map +1 -0
- package/dist/utils/unix-process-identity.js +165 -0
- package/dist/utils/unix-process-identity.js.map +1 -0
- package/dist/web/assets/{AgentDemoPage-XrttOpQW.js → AgentDemoPage-CLemSpf6.js} +1 -1
- package/dist/web/assets/{AgentEnvironmentSettingsPage-CAo0bCpZ.js → AgentEnvironmentSettingsPage-CPggaJvZ.js} +1 -1
- package/dist/web/assets/{AgentLogo-BCwbooTN.js → AgentLogo-DJFjaRFS.js} +1 -1
- package/dist/web/assets/ConversationPage-CB4PoHYi.js +3 -0
- package/dist/web/assets/CreateTaskInput-CXWGjX_a.js +1 -0
- package/dist/web/assets/{DemoPage-DHMh9-zU.js → DemoPage-djW4NeHW.js} +3 -3
- package/dist/web/assets/{GeneralSettingsPage-DvWaqR9O.js → GeneralSettingsPage-0a2VgV74.js} +1 -1
- package/dist/web/assets/{Icons-DADUmnB1.js → Icons-tvQ3lNxT.js} +1 -1
- package/dist/web/assets/{LoadingPreviewPage-Dk91Ua1W.js → LoadingPreviewPage-D8GpQ-Ic.js} +1 -1
- package/dist/web/assets/McpSettingsPage-BxPMmwHH.js +1 -0
- package/dist/web/assets/{MemberAvatar-l-WCdlLA.js → MemberAvatar-JbGgXa3r.js} +1 -1
- package/dist/web/assets/{NotificationSettingsPage-Byu8b9X3.js → NotificationSettingsPage-BtN0fYTA.js} +1 -1
- package/dist/web/assets/{ProfileSettingsPage-BdylqWUj.js → ProfileSettingsPage-CVSHbAtS.js} +1 -1
- package/dist/web/assets/ProjectKanbanPage-Dq0pufE1.js +90 -0
- package/dist/web/assets/ProjectSettingsPage-CChSA5A4.js +2 -0
- package/dist/web/assets/ProviderSettingsPage-giXaDHmU.js +95 -0
- package/dist/web/assets/{SettingsMasterDetail-DTGIIGdI.js → SettingsMasterDetail-D-TeBuLx.js} +1 -1
- package/dist/web/assets/{TeamSettingsPage-BXuG4Bou.js → TeamSettingsPage-DNLp2l2E.js} +1 -1
- package/dist/web/assets/{arc-DrcjdWTE.js → arc-B5sdSA9b.js} +1 -1
- package/dist/web/assets/{architectureDiagram-3BPJPVTR-CAoBhXSL.js → architectureDiagram-3BPJPVTR-ClsPKWjN.js} +1 -1
- package/dist/web/assets/{arrow-left-CCWDjOmp.js → arrow-left-B7C-fOb5.js} +1 -1
- package/dist/web/assets/{blockDiagram-GPEHLZMM-CcTSBbUq.js → blockDiagram-GPEHLZMM-HHViBKvL.js} +1 -1
- package/dist/web/assets/{c4Diagram-AAUBKEIU-BuUKdgUg.js → c4Diagram-AAUBKEIU-CRreiVUs.js} +1 -1
- package/dist/web/assets/channel-Bhjxgyee.js +1 -0
- package/dist/web/assets/check-Dtr-nHO5.js +1 -0
- package/dist/web/assets/{chevron-down-BQcW9sFf.js → chevron-down-BZnZAd2n.js} +1 -1
- package/dist/web/assets/{chevron-right-pH923eYp.js → chevron-right-nnOI2p8q.js} +1 -1
- package/dist/web/assets/{chevron-up-DyQW115F.js → chevron-up-Cl6FGZ8R.js} +1 -1
- package/dist/web/assets/{chunk-2J33WTMH-BWNSmQa8.js → chunk-2J33WTMH-_s2AOnis.js} +1 -1
- package/dist/web/assets/{chunk-4BX2VUAB-Blldhw0k.js → chunk-4BX2VUAB-Ds1jhNjB.js} +1 -1
- package/dist/web/assets/{chunk-55IACEB6-hTffyPXL.js → chunk-55IACEB6-B2SvpbB1.js} +1 -1
- package/dist/web/assets/{chunk-727SXJPM-Cd48r7c-.js → chunk-727SXJPM-B6qjWdxn.js} +1 -1
- package/dist/web/assets/{chunk-AQP2D5EJ-BdDrOIL7.js → chunk-AQP2D5EJ-myECS-o9.js} +1 -1
- package/dist/web/assets/{chunk-FMBD7UC4-6XIvQYVJ.js → chunk-FMBD7UC4-CFDf13jX.js} +1 -1
- package/dist/web/assets/{chunk-ND2GUHAM-BJlcb_pB.js → chunk-ND2GUHAM-62aJufBH.js} +1 -1
- package/dist/web/assets/{chunk-QZHKN3VN-3TZzFkxK.js → chunk-QZHKN3VN-DEWvzHCx.js} +1 -1
- package/dist/web/assets/{circle-alert-oa-BQ5e7.js → circle-alert-BSGJzTSj.js} +1 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-BxnIeW8e.js +1 -0
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-BxnIeW8e.js +1 -0
- package/dist/web/assets/{code-block-OCS4YCEC-xJQWFyR7.js → code-block-OCS4YCEC-DWj3hzdw.js} +1 -1
- package/dist/web/assets/{confirm-dialog-CRiC3xBd.js → confirm-dialog-oStWxmjS.js} +1 -1
- package/dist/web/assets/{cose-bilkent-S5V4N54A-Cjcm-rW_.js → cose-bilkent-S5V4N54A-DNYqhVNu.js} +1 -1
- package/dist/web/assets/cssMode-Cn68yhOS.js +1 -0
- package/dist/web/assets/{dagre-BM42HDAG-YqubcAJi.js → dagre-BM42HDAG-gQbGUd4s.js} +1 -1
- package/dist/web/assets/{diagram-2AECGRRQ-Dk4ayFqg.js → diagram-2AECGRRQ-BeMaPQBR.js} +1 -1
- package/dist/web/assets/{diagram-5GNKFQAL-CQ0joYfB.js → diagram-5GNKFQAL-CStJaSd8.js} +1 -1
- package/dist/web/assets/{diagram-KO2AKTUF-DmuZzIdW.js → diagram-KO2AKTUF-BmEeaazt.js} +1 -1
- package/dist/web/assets/{diagram-LMA3HP47-YTPEfEZy.js → diagram-LMA3HP47-ClNnKUvt.js} +1 -1
- package/dist/web/assets/{diagram-OG6HWLK6-DmwRuz8-.js → diagram-OG6HWLK6-C24GKhLk.js} +1 -1
- package/dist/web/assets/{erDiagram-TEJ5UH35-LRL_DMXa.js → erDiagram-TEJ5UH35-6Xp8w1WL.js} +1 -1
- package/dist/web/assets/{flowDiagram-I6XJVG4X-ELBDyOvk.js → flowDiagram-I6XJVG4X-BCih6e9O.js} +1 -1
- package/dist/web/assets/folder-picker-DcY2P8zf.js +1 -0
- package/dist/web/assets/{freemarker2-DxJFkRz5.js → freemarker2-C6kMBtOW.js} +1 -1
- package/dist/web/assets/{ganttDiagram-6RSMTGT7-D0e9ILuF.js → ganttDiagram-6RSMTGT7-_9GX-BOi.js} +1 -1
- package/dist/web/assets/{gitGraphDiagram-PVQCEYII-Ck6OXXw0.js → gitGraphDiagram-PVQCEYII-DEe9VMLq.js} +1 -1
- package/dist/web/assets/handlebars-BxZgdhY8.js +1 -0
- package/dist/web/assets/html-bhMfD_X9.js +1 -0
- package/dist/web/assets/htmlMode-CC7AVUJ4.js +1 -0
- package/dist/web/assets/index-018g9RN4.css +1 -0
- package/dist/web/assets/{index-D9kBRMR0.js → index-ToY1NCNr.js} +3 -3
- package/dist/web/assets/{index-CjdqAcbu.js → index-cl-QFuts.js} +4 -4
- package/dist/web/assets/{infoDiagram-5YYISTIA-Cx8be-MV.js → infoDiagram-5YYISTIA-CU3D8SMZ.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-Dlc7akl7.js → ishikawaDiagram-YF4QCWOH-ClffgdSa.js} +1 -1
- package/dist/web/assets/javascript-8UIdW5Gd.js +1 -0
- package/dist/web/assets/{journeyDiagram-JHISSGLW-BVDSbS9-.js → journeyDiagram-JHISSGLW-Cy7Rr0_y.js} +1 -1
- package/dist/web/assets/{jsonMode-B5CJhoWd.js → jsonMode-JLBoaKf1.js} +1 -1
- package/dist/web/assets/{kanban-definition-UN3LZRKU-nFR0zB7B.js → kanban-definition-UN3LZRKU-14piuQEq.js} +1 -1
- package/dist/web/assets/{layers-Bo4aml98.js → layers-C93epAjs.js} +1 -1
- package/dist/web/assets/{linear-BCWZjcpP.js → linear-BtH62ya4.js} +1 -1
- package/dist/web/assets/liquid-BntTiwt7.js +1 -0
- package/dist/web/assets/{lspLanguageFeatures-Cbk7wEkj.js → lspLanguageFeatures-Dk65AKZD.js} +1 -1
- package/dist/web/assets/mdx-ToUKdFio.js +1 -0
- package/dist/web/assets/{mermaid-NOHMQCX5-DWQaYVL0.js → mermaid-NOHMQCX5-CPO3gPWp.js} +66 -65
- package/dist/web/assets/{message-square-DxbkpGqF.js → message-square-BBENHwpb.js} +1 -1
- package/dist/web/assets/{mindmap-definition-RKZ34NQL-LI7W1FIX.js → mindmap-definition-RKZ34NQL-gWYqFXbP.js} +1 -1
- package/dist/web/assets/{modal-Cymk-6Df.js → modal-D-sNOVPw.js} +1 -1
- package/dist/web/assets/{monaco-Bc-Z2u8N.js → monaco-B9Zd90UG.js} +3 -3
- package/dist/web/assets/{pencil-DOL2nlgg.js → pencil-BRPix314.js} +1 -1
- package/dist/web/assets/{pieDiagram-4H26LBE5-mgUzAFkk.js → pieDiagram-4H26LBE5-C3cHgEuO.js} +1 -1
- package/dist/web/assets/python-BeGIUwrY.js +1 -0
- package/dist/web/assets/{quadrantDiagram-W4KKPZXB-CaDF2kqA.js → quadrantDiagram-W4KKPZXB-DZFYp-mp.js} +1 -1
- package/dist/web/assets/razor-CnCuqD7W.js +1 -0
- package/dist/web/assets/{requirementDiagram-4Y6WPE33-DhmHdr_0.js → requirementDiagram-4Y6WPE33-DSQRXAFH.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-5OEKKPKP-B7qnGfue.js → sankeyDiagram-5OEKKPKP-CEXk2v3C.js} +1 -1
- package/dist/web/assets/{select-BpKQyMvD.js → select-CGNclv1f.js} +1 -1
- package/dist/web/assets/{sequenceDiagram-3UESZ5HK-D2LhPgpM.js → sequenceDiagram-3UESZ5HK-CHVF_25M.js} +1 -1
- package/dist/web/assets/server-UA3ZvpjF.js +1 -0
- package/dist/web/assets/{stateDiagram-AJRCARHV-ClkO4Gu5.js → stateDiagram-AJRCARHV-TMqBR1_f.js} +1 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-DqCjP1u1.js +1 -0
- package/dist/web/assets/{switch-BJ4Ar_OA.js → switch-C7qsQ1x2.js} +1 -1
- package/dist/web/assets/{textarea-DjwjAAG8.js → textarea-CDdCks2T.js} +1 -1
- package/dist/web/assets/{timeline-definition-PNZ67QCA-DhGIG-GC.js → timeline-definition-PNZ67QCA-CxC3mFt7.js} +1 -1
- package/dist/web/assets/{trash-2-R46i6Uus.js → trash-2-Bye7VGcW.js} +1 -1
- package/dist/web/assets/{tsMode-CKaqpIrz.js → tsMode-8nvc-x2E.js} +1 -1
- package/dist/web/assets/typescript-P7JXXc42.js +1 -0
- package/dist/web/assets/{upload-CgWqsmdI.js → upload-wJO5M1ZY.js} +1 -1
- package/dist/web/assets/{use-profiles-BlGgvdYm.js → use-profiles-CYJIKesy.js} +1 -1
- package/dist/web/assets/{use-projects-Cuv0A0RC.js → use-projects-Ds_YI2En.js} +1 -1
- package/dist/web/assets/{use-providers-DLcAY6E1.js → use-providers-B9FaTKyw.js} +1 -1
- package/dist/web/assets/{useNormalizedLogs-tfxFAJOF.js → useNormalizedLogs-B8um63GF.js} +1 -1
- package/dist/web/assets/{vennDiagram-CIIHVFJN-BngQhsYJ.js → vennDiagram-CIIHVFJN-DX0jm9G-.js} +1 -1
- package/dist/web/assets/{wardley-L42UT6IY-BEY6sftT.js → wardley-L42UT6IY-Ce-rqtq2.js} +1 -1
- package/dist/web/assets/{wardleyDiagram-YWT4CUSO-IH_Yh-cw.js → wardleyDiagram-YWT4CUSO-Gpxnu2av.js} +1 -1
- package/dist/web/assets/xml-1G4iEdpK.js +1 -0
- package/dist/web/assets/{xychartDiagram-2RQKCTM6-BdrGFDsr.js → xychartDiagram-2RQKCTM6-COe6opx2.js} +1 -1
- package/dist/web/assets/yaml-HqUdsAk3.js +1 -0
- package/dist/web/index.html +2 -2
- package/node_modules/@agent-tower/shared/dist/agent-download-intent.d.ts +6 -0
- package/node_modules/@agent-tower/shared/dist/agent-download-intent.d.ts.map +1 -0
- package/node_modules/@agent-tower/shared/dist/agent-download-intent.js +46 -0
- package/node_modules/@agent-tower/shared/dist/agent-download-intent.js.map +1 -0
- package/node_modules/@agent-tower/shared/dist/index.d.ts +1 -0
- package/node_modules/@agent-tower/shared/dist/index.d.ts.map +1 -1
- package/node_modules/@agent-tower/shared/dist/index.js +1 -0
- package/node_modules/@agent-tower/shared/dist/index.js.map +1 -1
- package/node_modules/@agent-tower/shared/dist/provider-capabilities.d.ts +1 -0
- package/node_modules/@agent-tower/shared/dist/provider-capabilities.d.ts.map +1 -1
- package/node_modules/@agent-tower/shared/dist/provider-capabilities.js +4 -0
- package/node_modules/@agent-tower/shared/dist/provider-capabilities.js.map +1 -1
- package/node_modules/@agent-tower/shared/dist/types.d.ts +56 -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 +1 -1
- package/prisma/migrations/20260728000000_add_agent_artifacts/migration.sql +23 -0
- package/prisma/schema.prisma +48 -0
- package/dist/web/assets/ConversationPage-kyHuICil.js +0 -3
- package/dist/web/assets/CreateTaskInput-B67vzMJD.js +0 -1
- package/dist/web/assets/McpSettingsPage-CH8jFyxp.js +0 -1
- package/dist/web/assets/ProjectKanbanPage--cx6wNDR.js +0 -90
- package/dist/web/assets/ProjectSettingsPage-6psG0Vfc.js +0 -2
- package/dist/web/assets/ProviderSettingsPage-BPEEkhtA.js +0 -93
- package/dist/web/assets/channel-Bh_PCZNP.js +0 -1
- package/dist/web/assets/check-BN_PVKzE.js +0 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-B0lQFDoP.js +0 -1
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-B0lQFDoP.js +0 -1
- package/dist/web/assets/copy-DaoAUKTO.js +0 -1
- package/dist/web/assets/cssMode-_D6u4YDd.js +0 -1
- package/dist/web/assets/folder-picker-WUhXxIM5.js +0 -1
- package/dist/web/assets/handlebars-djdO6ZKR.js +0 -1
- package/dist/web/assets/html-CHeBxmFi.js +0 -1
- package/dist/web/assets/htmlMode-SZh8FaPi.js +0 -1
- package/dist/web/assets/index-CjAJoGg5.css +0 -1
- package/dist/web/assets/javascript-l6fV6hf7.js +0 -1
- package/dist/web/assets/liquid-DkFOeJ6J.js +0 -1
- package/dist/web/assets/mdx-BOPNdexu.js +0 -1
- package/dist/web/assets/python-D_wlYLCL.js +0 -1
- package/dist/web/assets/razor-DBFVg4JU.js +0 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-YnSeSD_N.js +0 -1
- package/dist/web/assets/typescript-DsixnGVt.js +0 -1
- package/dist/web/assets/xml-dEcQ1gzo.js +0 -1
- package/dist/web/assets/yaml-BfGVqGj4.js +0 -1
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/monaco-B9Zd90UG.js","assets/index-ToY1NCNr.js","assets/index-018g9RN4.css","assets/monaco-Dvl_Svmm.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{ah as td,ai as io,aj as sd,ak as rd,al as id,k as qe,r as _,am as ae,z as _s,m as kt,an as Cs,n as Bt,p as Ce,o as bt,q as de,u as le,j as t,a9 as xt,Y as ja,Z as nd,l as se,$ as Bs,B as Pe,ao as Na,ap as Ra,aq as Aa,af as Ss,X as Zt,ar as mn,as as od,O as vr,at as ad,D as ld,au as cd,av as dd,aw as ud,T as $s,t as st,U as rs,V as lt,W as Ps,P as We,ax as ks,Q as or,ay as hd,az as pn,ag as fd,ad as md,ae as pd,aA as Ta,aB as gn,aC as Ma,aD as Da,aE as Pa,aF as gd,aG as vd,a2 as xd,aH as bd,aI as _d,aJ as yd,_ as no,a8 as oo}from"./index-ToY1NCNr.js";import{S as ct,u as vn,A as xn,l as Sd,F as La,p as wd,m as Cd,o as kd,Q as bn,q as Ed,r as At,W as _t,t as Ia,C as ur,v as Lr,w as jd,x as Nd,y as Rd,T as Ad,h as Nt,b as Ur,z as Oa,B as Wt}from"./mermaid-NOHMQCX5-CPO3gPWp.js";import{C as _n}from"./confirm-dialog-oStWxmjS.js";import{c as Ba,a as Fa,b as za,I as Wa,d as Ha,A as ao,G as $a}from"./Icons-tvQ3lNxT.js";import{C as wt}from"./chevron-down-BZnZAd2n.js";import{C as Mt}from"./chevron-right-nnOI2p8q.js";import{d as yn,S as Td,u as Sn,A as hr,c as wn,G as Ua,Z as Md,e as Cn,T as kn,f as Dd,g as En,h as lo,i as Pd,b as qa,j as Ka,a as Va,k as Xa,R as Ya,P as Ga,l as qr,m as Ld,C as co,B as uo}from"./CreateTaskInput-CXWGjX_a.js";import{a as Id,F as Od,b as Bd}from"./folder-picker-DcY2P8zf.js";import{M as ni}from"./message-square-BBENHwpb.js";import{L as Fs}from"./layers-C93epAjs.js";import{P as jn,u as Qa,a as Za,T as Kr}from"./useNormalizedLogs-B8um63GF.js";import{u as Us}from"./use-providers-B9FaTKyw.js";import{A as oi}from"./AgentLogo-DJFjaRFS.js";import{M as Ht}from"./MemberAvatar-JbGgXa3r.js";import{C as Ja}from"./chevron-up-Cl6FGZ8R.js";import{C as Jt}from"./check-Dtr-nHO5.js";import{M as ds}from"./modal-D-sNOVPw.js";import{S as is}from"./select-CGNclv1f.js";import{P as ns,T as Nn}from"./trash-2-Bye7VGcW.js";import{T as Fd}from"./textarea-CDdCks2T.js";import{S as Gi,C as ho}from"./server-UA3ZvpjF.js";import{F as Rn,e as zd,d as Wd,f as Hd,u as $d}from"./use-projects-Ds_YI2En.js";import{U as Vr}from"./upload-wJO5M1ZY.js";import{A as zs}from"./arrow-left-B7C-fOb5.js";var Ud=class extends td{constructor(e,s){super(e,s)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:io()})}getOptimisticResult(e){return e.behavior=io(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,s){const{state:r}=e,o=super.createResult(e,s),{isFetching:p,isRefetching:m,isError:v,isRefetchError:n}=o,i=r.fetchMeta?.fetchMore?.direction,a=v&&i==="forward",u=p&&i==="forward",c=v&&i==="backward",g=p&&i==="backward";return{...o,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:rd(s,r.data),hasPreviousPage:sd(s,r.data),isFetchNextPageError:a,isFetchingNextPage:u,isFetchPreviousPageError:c,isFetchingPreviousPage:g,isRefetchError:n&&!a&&!c,isRefetching:m&&!u&&!g}}};function An(e,s){return id(e,Ud)}const qd=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],el=qe("arrow-right",qd);const Kd=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],tl=qe("ban",Kd);const Vd=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Xd=qe("chevron-left",Vd);const Yd=[["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"}]],Gd=qe("clipboard-paste",Yd);const Qd=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],os=qe("clock-3",Qd);const Zd=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],ai=qe("code-xml",Zd);const Jd=[["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"}]],fo=qe("copy-plus",Jd);const eu=[["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"}]],tu=qe("earth",eu);const su=[["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"}]],sl=qe("ellipsis-vertical",su);const ru=[["path",{d:"M14 22h4a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v6",key:"14cnrg"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M5 14a1 1 0 0 0-1 1v2a1 1 0 0 1-1 1 1 1 0 0 1 1 1v2a1 1 0 0 0 1 1",key:"sr0ebq"}],["path",{d:"M9 22a1 1 0 0 0 1-1v-2a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-2a1 1 0 0 0-1-1",key:"w793db"}]],iu=qe("file-braces-corner",ru);const nu=[["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"}]],Xr=qe("file-code-corner",nu);const ou=[["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"}]],au=qe("file-exclamation-point",ou);const lu=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],li=qe("folder-open",lu);const cu=[["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"}]],qs=qe("git-graph",cu);const du=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],Ws=qe("history",du);const uu=[["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"}]],hu=qe("maximize",uu);const fu=[["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"}]],mu=qe("panel-left-close",fu);const pu=[["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"}]],gu=qe("panel-left-open",pu);const vu=[["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"}]],xu=qe("panel-right-close",vu);const bu=[["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"}]],Qi=qe("panel-right-open",bu);const _u=[["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"}]],yu=qe("pen-line",_u);const Su=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],Qt=qe("play",Su);const wu=[["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"}]],rl=qe("settings-2",wu);const Cu=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],mo=qe("smartphone",Cu);const ku=[["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"}]],Ir=qe("user-plus",ku);const Eu=[["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"}]],ju=qe("zoom-in",Eu);const Nu=[["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"}]],Ru=qe("zoom-out",Nu),ci=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ks(e){const s=Object.prototype.toString.call(e);return s==="[object Window]"||s==="[object global]"}function Tn(e){return"nodeType"in e}function yt(e){var s,r;return e?Ks(e)?e:Tn(e)&&(s=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function Mn(e){const{Document:s}=yt(e);return e instanceof s}function xr(e){return Ks(e)?!1:e instanceof yt(e).HTMLElement}function il(e){return e instanceof yt(e).SVGElement}function Vs(e){return e?Ks(e)?e.document:Tn(e)?Mn(e)?e:xr(e)||il(e)?e.ownerDocument:document:document:document}const es=ci?_.useLayoutEffect:_.useEffect;function di(e){const s=_.useRef(e);return es(()=>{s.current=e}),_.useCallback(function(){for(var r=arguments.length,o=new Array(r),p=0;p<r;p++)o[p]=arguments[p];return s.current==null?void 0:s.current(...o)},[])}function Au(){const e=_.useRef(null),s=_.useCallback((o,p)=>{e.current=setInterval(o,p)},[]),r=_.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[s,r]}function fr(e,s){s===void 0&&(s=[e]);const r=_.useRef(e);return es(()=>{r.current!==e&&(r.current=e)},s),r}function br(e,s){const r=_.useRef();return _.useMemo(()=>{const o=e(r.current);return r.current=o,o},[...s])}function Yr(e){const s=di(e),r=_.useRef(null),o=_.useCallback(p=>{p!==r.current&&s?.(p,r.current),r.current=p},[]);return[r,o]}function Gr(e){const s=_.useRef();return _.useEffect(()=>{s.current=e},[e]),s.current}let Ni={};function ui(e,s){return _.useMemo(()=>{if(s)return s;const r=Ni[e]==null?0:Ni[e]+1;return Ni[e]=r,e+"-"+r},[e,s])}function nl(e){return function(s){for(var r=arguments.length,o=new Array(r>1?r-1:0),p=1;p<r;p++)o[p-1]=arguments[p];return o.reduce((m,v)=>{const n=Object.entries(v);for(const[i,a]of n){const u=m[i];u!=null&&(m[i]=u+e*a)}return m},{...s})}}const Os=nl(1),Qr=nl(-1);function Tu(e){return"clientX"in e&&"clientY"in e}function Dn(e){if(!e)return!1;const{KeyboardEvent:s}=yt(e.target);return s&&e instanceof s}function Mu(e){if(!e)return!1;const{TouchEvent:s}=yt(e.target);return s&&e instanceof s}function Zr(e){if(Mu(e)){if(e.touches&&e.touches.length){const{clientX:s,clientY:r}=e.touches[0];return{x:s,y:r}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:s,clientY:r}=e.changedTouches[0];return{x:s,y:r}}}return Tu(e)?{x:e.clientX,y:e.clientY}:null}const mr=Object.freeze({Translate:{toString(e){if(!e)return;const{x:s,y:r}=e;return"translate3d("+(s?Math.round(s):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:s,scaleY:r}=e;return"scaleX("+s+") scaleY("+r+")"}},Transform:{toString(e){if(e)return[mr.Translate.toString(e),mr.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:s,duration:r,easing:o}=e;return s+" "+r+"ms "+o}}}),po="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Du(e){return e.matches(po)?e:e.querySelector(po)}const Pu={display:"none"};function Lu(e){let{id:s,value:r}=e;return ae.createElement("div",{id:s,style:Pu},r)}function Iu(e){let{id:s,announcement:r,ariaLiveType:o="assertive"}=e;const p={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return ae.createElement("div",{id:s,style:p,role:"status","aria-live":o,"aria-atomic":!0},r)}function Ou(){const[e,s]=_.useState("");return{announce:_.useCallback(o=>{o!=null&&s(o)},[]),announcement:e}}const ol=_.createContext(null);function Bu(e){const s=_.useContext(ol);_.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(e)},[e,s])}function Fu(){const[e]=_.useState(()=>new Set),s=_.useCallback(o=>(e.add(o),()=>e.delete(o)),[e]);return[_.useCallback(o=>{let{type:p,event:m}=o;e.forEach(v=>{var n;return(n=v[p])==null?void 0:n.call(v,m)})},[e]),s]}const zu={draggable:`
|
|
3
|
+
To pick up a draggable item, press the space bar.
|
|
4
|
+
While dragging, use the arrow keys to move the item.
|
|
5
|
+
Press space again to drop the item in its new position, or press escape to cancel.
|
|
6
|
+
`},Wu={onDragStart(e){let{active:s}=e;return"Picked up draggable item "+s.id+"."},onDragOver(e){let{active:s,over:r}=e;return r?"Draggable item "+s.id+" was moved over droppable area "+r.id+".":"Draggable item "+s.id+" is no longer over a droppable area."},onDragEnd(e){let{active:s,over:r}=e;return r?"Draggable item "+s.id+" was dropped over droppable area "+r.id:"Draggable item "+s.id+" was dropped."},onDragCancel(e){let{active:s}=e;return"Dragging was cancelled. Draggable item "+s.id+" was dropped."}};function Hu(e){let{announcements:s=Wu,container:r,hiddenTextDescribedById:o,screenReaderInstructions:p=zu}=e;const{announce:m,announcement:v}=Ou(),n=ui("DndLiveRegion"),[i,a]=_.useState(!1);if(_.useEffect(()=>{a(!0)},[]),Bu(_.useMemo(()=>({onDragStart(c){let{active:g}=c;m(s.onDragStart({active:g}))},onDragMove(c){let{active:g,over:x}=c;s.onDragMove&&m(s.onDragMove({active:g,over:x}))},onDragOver(c){let{active:g,over:x}=c;m(s.onDragOver({active:g,over:x}))},onDragEnd(c){let{active:g,over:x}=c;m(s.onDragEnd({active:g,over:x}))},onDragCancel(c){let{active:g,over:x}=c;m(s.onDragCancel({active:g,over:x}))}}),[m,s])),!i)return null;const u=ae.createElement(ae.Fragment,null,ae.createElement(Lu,{id:o,value:p.draggable}),ae.createElement(Iu,{id:n,announcement:v}));return r?_s.createPortal(u,r):u}var ot;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(ot||(ot={}));function Jr(){}function $u(e,s){return _.useMemo(()=>({sensor:e,options:s??{}}),[e,s])}function Uu(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return _.useMemo(()=>[...s].filter(o=>o!=null),[...s])}const Ot=Object.freeze({x:0,y:0});function qu(e,s){const r=Zr(e);if(!r)return"0 0";const o={x:(r.x-s.left)/s.width*100,y:(r.y-s.top)/s.height*100};return o.x+"% "+o.y+"%"}function Ku(e,s){let{data:{value:r}}=e,{data:{value:o}}=s;return o-r}function Vu(e,s){if(!e||e.length===0)return null;const[r]=e;return r[s]}function Xu(e,s){const r=Math.max(s.top,e.top),o=Math.max(s.left,e.left),p=Math.min(s.left+s.width,e.left+e.width),m=Math.min(s.top+s.height,e.top+e.height),v=p-o,n=m-r;if(o<p&&r<m){const i=s.width*s.height,a=e.width*e.height,u=v*n,c=u/(i+a-u);return Number(c.toFixed(4))}return 0}const Yu=e=>{let{collisionRect:s,droppableRects:r,droppableContainers:o}=e;const p=[];for(const m of o){const{id:v}=m,n=r.get(v);if(n){const i=Xu(n,s);i>0&&p.push({id:v,data:{droppableContainer:m,value:i}})}}return p.sort(Ku)};function Gu(e,s,r){return{...e,scaleX:s&&r?s.width/r.width:1,scaleY:s&&r?s.height/r.height:1}}function al(e,s){return e&&s?{x:e.left-s.left,y:e.top-s.top}:Ot}function Qu(e){return function(r){for(var o=arguments.length,p=new Array(o>1?o-1:0),m=1;m<o;m++)p[m-1]=arguments[m];return p.reduce((v,n)=>({...v,top:v.top+e*n.y,bottom:v.bottom+e*n.y,left:v.left+e*n.x,right:v.right+e*n.x}),{...r})}}const Zu=Qu(1);function ll(e){if(e.startsWith("matrix3d(")){const s=e.slice(9,-1).split(/, /);return{x:+s[12],y:+s[13],scaleX:+s[0],scaleY:+s[5]}}else if(e.startsWith("matrix(")){const s=e.slice(7,-1).split(/, /);return{x:+s[4],y:+s[5],scaleX:+s[0],scaleY:+s[3]}}return null}function Ju(e,s,r){const o=ll(s);if(!o)return e;const{scaleX:p,scaleY:m,x:v,y:n}=o,i=e.left-v-(1-p)*parseFloat(r),a=e.top-n-(1-m)*parseFloat(r.slice(r.indexOf(" ")+1)),u=p?e.width/p:e.width,c=m?e.height/m:e.height;return{width:u,height:c,top:a,right:i+u,bottom:a+c,left:i}}const eh={ignoreTransform:!1};function _r(e,s){s===void 0&&(s=eh);let r=e.getBoundingClientRect();if(s.ignoreTransform){const{transform:a,transformOrigin:u}=yt(e).getComputedStyle(e);a&&(r=Ju(r,a,u))}const{top:o,left:p,width:m,height:v,bottom:n,right:i}=r;return{top:o,left:p,width:m,height:v,bottom:n,right:i}}function go(e){return _r(e,{ignoreTransform:!0})}function th(e){const s=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function sh(e,s){return s===void 0&&(s=yt(e).getComputedStyle(e)),s.position==="fixed"}function rh(e,s){s===void 0&&(s=yt(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(p=>{const m=s[p];return typeof m=="string"?r.test(m):!1})}function Pn(e,s){const r=[];function o(p){if(s!=null&&r.length>=s||!p)return r;if(Mn(p)&&p.scrollingElement!=null&&!r.includes(p.scrollingElement))return r.push(p.scrollingElement),r;if(!xr(p)||il(p)||r.includes(p))return r;const m=yt(e).getComputedStyle(p);return p!==e&&rh(p,m)&&r.push(p),sh(p,m)?r:o(p.parentNode)}return e?o(e):r}function cl(e){const[s]=Pn(e,1);return s??null}function Ri(e){return!ci||!e?null:Ks(e)?e:Tn(e)?Mn(e)||e===Vs(e).scrollingElement?window:xr(e)?e:null:null}function dl(e){return Ks(e)?e.scrollX:e.scrollLeft}function ul(e){return Ks(e)?e.scrollY:e.scrollTop}function Zi(e){return{x:dl(e),y:ul(e)}}var dt;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(dt||(dt={}));function hl(e){return!ci||!e?!1:e===document.scrollingElement}function fl(e){const s={x:0,y:0},r=hl(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},o={x:e.scrollWidth-r.width,y:e.scrollHeight-r.height},p=e.scrollTop<=s.y,m=e.scrollLeft<=s.x,v=e.scrollTop>=o.y,n=e.scrollLeft>=o.x;return{isTop:p,isLeft:m,isBottom:v,isRight:n,maxScroll:o,minScroll:s}}const ih={x:.2,y:.2};function nh(e,s,r,o,p){let{top:m,left:v,right:n,bottom:i}=r;o===void 0&&(o=10),p===void 0&&(p=ih);const{isTop:a,isBottom:u,isLeft:c,isRight:g}=fl(e),x={x:0,y:0},S={x:0,y:0},w={height:s.height*p.y,width:s.width*p.x};return!a&&m<=s.top+w.height?(x.y=dt.Backward,S.y=o*Math.abs((s.top+w.height-m)/w.height)):!u&&i>=s.bottom-w.height&&(x.y=dt.Forward,S.y=o*Math.abs((s.bottom-w.height-i)/w.height)),!g&&n>=s.right-w.width?(x.x=dt.Forward,S.x=o*Math.abs((s.right-w.width-n)/w.width)):!c&&v<=s.left+w.width&&(x.x=dt.Backward,S.x=o*Math.abs((s.left+w.width-v)/w.width)),{direction:x,speed:S}}function oh(e){if(e===document.scrollingElement){const{innerWidth:m,innerHeight:v}=window;return{top:0,left:0,right:m,bottom:v,width:m,height:v}}const{top:s,left:r,right:o,bottom:p}=e.getBoundingClientRect();return{top:s,left:r,right:o,bottom:p,width:e.clientWidth,height:e.clientHeight}}function ml(e){return e.reduce((s,r)=>Os(s,Zi(r)),Ot)}function ah(e){return e.reduce((s,r)=>s+dl(r),0)}function lh(e){return e.reduce((s,r)=>s+ul(r),0)}function pl(e,s){if(s===void 0&&(s=_r),!e)return;const{top:r,left:o,bottom:p,right:m}=s(e);cl(e)&&(p<=0||m<=0||r>=window.innerHeight||o>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const ch=[["x",["left","right"],ah],["y",["top","bottom"],lh]];class Ln{constructor(s,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const o=Pn(r),p=ml(o);this.rect={...s},this.width=s.width,this.height=s.height;for(const[m,v,n]of ch)for(const i of v)Object.defineProperty(this,i,{get:()=>{const a=n(o),u=p[m]-a;return this.rect[i]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class ar{constructor(s){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var o;return(o=this.target)==null?void 0:o.removeEventListener(...r)})},this.target=s}add(s,r,o){var p;(p=this.target)==null||p.addEventListener(s,r,o),this.listeners.push([s,r,o])}}function dh(e){const{EventTarget:s}=yt(e);return e instanceof s?e:Vs(e)}function Ai(e,s){const r=Math.abs(e.x),o=Math.abs(e.y);return typeof s=="number"?Math.sqrt(r**2+o**2)>s:"x"in s&&"y"in s?r>s.x&&o>s.y:"x"in s?r>s.x:"y"in s?o>s.y:!1}var Rt;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Rt||(Rt={}));function vo(e){e.preventDefault()}function uh(e){e.stopPropagation()}var Ue;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(Ue||(Ue={}));const gl={start:[Ue.Space,Ue.Enter],cancel:[Ue.Esc],end:[Ue.Space,Ue.Enter,Ue.Tab]},hh=(e,s)=>{let{currentCoordinates:r}=s;switch(e.code){case Ue.Right:return{...r,x:r.x+25};case Ue.Left:return{...r,x:r.x-25};case Ue.Down:return{...r,y:r.y+25};case Ue.Up:return{...r,y:r.y-25}}};class vl{constructor(s){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=s;const{event:{target:r}}=s;this.props=s,this.listeners=new ar(Vs(r)),this.windowListeners=new ar(yt(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Rt.Resize,this.handleCancel),this.windowListeners.add(Rt.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Rt.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,o=s.node.current;o&&pl(o),r(Ot)}handleKeyDown(s){if(Dn(s)){const{active:r,context:o,options:p}=this.props,{keyboardCodes:m=gl,coordinateGetter:v=hh,scrollBehavior:n="smooth"}=p,{code:i}=s;if(m.end.includes(i)){this.handleEnd(s);return}if(m.cancel.includes(i)){this.handleCancel(s);return}const{collisionRect:a}=o.current,u=a?{x:a.left,y:a.top}:Ot;this.referenceCoordinates||(this.referenceCoordinates=u);const c=v(s,{active:r,context:o.current,currentCoordinates:u});if(c){const g=Qr(c,u),x={x:0,y:0},{scrollableAncestors:S}=o.current;for(const w of S){const l=s.code,{isTop:h,isRight:d,isLeft:f,isBottom:y,maxScroll:C,minScroll:k}=fl(w),E=oh(w),b={x:Math.min(l===Ue.Right?E.right-E.width/2:E.right,Math.max(l===Ue.Right?E.left:E.left+E.width/2,c.x)),y:Math.min(l===Ue.Down?E.bottom-E.height/2:E.bottom,Math.max(l===Ue.Down?E.top:E.top+E.height/2,c.y))},j=l===Ue.Right&&!d||l===Ue.Left&&!f,R=l===Ue.Down&&!y||l===Ue.Up&&!h;if(j&&b.x!==c.x){const L=w.scrollLeft+g.x,T=l===Ue.Right&&L<=C.x||l===Ue.Left&&L>=k.x;if(T&&!g.y){w.scrollTo({left:L,behavior:n});return}T?x.x=w.scrollLeft-L:x.x=l===Ue.Right?w.scrollLeft-C.x:w.scrollLeft-k.x,x.x&&w.scrollBy({left:-x.x,behavior:n});break}else if(R&&b.y!==c.y){const L=w.scrollTop+g.y,T=l===Ue.Down&&L<=C.y||l===Ue.Up&&L>=k.y;if(T&&!g.x){w.scrollTo({top:L,behavior:n});return}T?x.y=w.scrollTop-L:x.y=l===Ue.Down?w.scrollTop-C.y:w.scrollTop-k.y,x.y&&w.scrollBy({top:-x.y,behavior:n});break}}this.handleMove(s,Os(Qr(c,this.referenceCoordinates),x))}}}handleMove(s,r){const{onMove:o}=this.props;s.preventDefault(),o(r)}handleEnd(s){const{onEnd:r}=this.props;s.preventDefault(),this.detach(),r()}handleCancel(s){const{onCancel:r}=this.props;s.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}vl.activators=[{eventName:"onKeyDown",handler:(e,s,r)=>{let{keyboardCodes:o=gl,onActivation:p}=s,{active:m}=r;const{code:v}=e.nativeEvent;if(o.start.includes(v)){const n=m.activatorNode.current;return n&&e.target!==n?!1:(e.preventDefault(),p?.({event:e.nativeEvent}),!0)}return!1}}];function xo(e){return!!(e&&"distance"in e)}function bo(e){return!!(e&&"delay"in e)}class In{constructor(s,r,o){var p;o===void 0&&(o=dh(s.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=s,this.events=r;const{event:m}=s,{target:v}=m;this.props=s,this.events=r,this.document=Vs(v),this.documentListeners=new ar(this.document),this.listeners=new ar(o),this.windowListeners=new ar(yt(v)),this.initialCoordinates=(p=Zr(m))!=null?p:Ot,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:s,props:{options:{activationConstraint:r,bypassActivationConstraint:o}}}=this;if(this.listeners.add(s.move.name,this.handleMove,{passive:!1}),this.listeners.add(s.end.name,this.handleEnd),s.cancel&&this.listeners.add(s.cancel.name,this.handleCancel),this.windowListeners.add(Rt.Resize,this.handleCancel),this.windowListeners.add(Rt.DragStart,vo),this.windowListeners.add(Rt.VisibilityChange,this.handleCancel),this.windowListeners.add(Rt.ContextMenu,vo),this.documentListeners.add(Rt.Keydown,this.handleKeydown),r){if(o!=null&&o({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(bo(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(xo(r)){this.handlePending(r);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(s,r){const{active:o,onPending:p}=this.props;p(o,s,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:s}=this,{onStart:r}=this.props;s&&(this.activated=!0,this.documentListeners.add(Rt.Click,uh,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Rt.SelectionChange,this.removeTextSelection),r(s))}handleMove(s){var r;const{activated:o,initialCoordinates:p,props:m}=this,{onMove:v,options:{activationConstraint:n}}=m;if(!p)return;const i=(r=Zr(s))!=null?r:Ot,a=Qr(p,i);if(!o&&n){if(xo(n)){if(n.tolerance!=null&&Ai(a,n.tolerance))return this.handleCancel();if(Ai(a,n.distance))return this.handleStart()}if(bo(n)&&Ai(a,n.tolerance))return this.handleCancel();this.handlePending(n,a);return}s.cancelable&&s.preventDefault(),v(i)}handleEnd(){const{onAbort:s,onEnd:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleCancel(){const{onAbort:s,onCancel:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleKeydown(s){s.code===Ue.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const fh={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class On extends In{constructor(s){const{event:r}=s,o=Vs(r.target);super(s,fh,o)}}On.activators=[{eventName:"onPointerDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;return!r.isPrimary||r.button!==0?!1:(o?.({event:r}),!0)}}];const mh={move:{name:"mousemove"},end:{name:"mouseup"}};var Ji;(function(e){e[e.RightClick=2]="RightClick"})(Ji||(Ji={}));class ph extends In{constructor(s){super(s,mh,Vs(s.event.target))}}ph.activators=[{eventName:"onMouseDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;return r.button===Ji.RightClick?!1:(o?.({event:r}),!0)}}];const Ti={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class gh extends In{constructor(s){super(s,Ti)}static setup(){return window.addEventListener(Ti.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(Ti.move.name,s)};function s(){}}}gh.activators=[{eventName:"onTouchStart",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;const{touches:p}=r;return p.length>1?!1:(o?.({event:r}),!0)}}];var lr;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(lr||(lr={}));var ei;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(ei||(ei={}));function vh(e){let{acceleration:s,activator:r=lr.Pointer,canScroll:o,draggingRect:p,enabled:m,interval:v=5,order:n=ei.TreeOrder,pointerCoordinates:i,scrollableAncestors:a,scrollableAncestorRects:u,delta:c,threshold:g}=e;const x=bh({delta:c,disabled:!m}),[S,w]=Au(),l=_.useRef({x:0,y:0}),h=_.useRef({x:0,y:0}),d=_.useMemo(()=>{switch(r){case lr.Pointer:return i?{top:i.y,bottom:i.y,left:i.x,right:i.x}:null;case lr.DraggableRect:return p}},[r,p,i]),f=_.useRef(null),y=_.useCallback(()=>{const k=f.current;if(!k)return;const E=l.current.x*h.current.x,b=l.current.y*h.current.y;k.scrollBy(E,b)},[]),C=_.useMemo(()=>n===ei.TreeOrder?[...a].reverse():a,[n,a]);_.useEffect(()=>{if(!m||!a.length||!d){w();return}for(const k of C){if(o?.(k)===!1)continue;const E=a.indexOf(k),b=u[E];if(!b)continue;const{direction:j,speed:R}=nh(k,b,d,s,g);for(const L of["x","y"])x[L][j[L]]||(R[L]=0,j[L]=0);if(R.x>0||R.y>0){w(),f.current=k,S(y,v),l.current=R,h.current=j;return}}l.current={x:0,y:0},h.current={x:0,y:0},w()},[s,y,o,w,m,v,JSON.stringify(d),JSON.stringify(x),S,a,C,u,JSON.stringify(g)])}const xh={x:{[dt.Backward]:!1,[dt.Forward]:!1},y:{[dt.Backward]:!1,[dt.Forward]:!1}};function bh(e){let{delta:s,disabled:r}=e;const o=Gr(s);return br(p=>{if(r||!o||!p)return xh;const m={x:Math.sign(s.x-o.x),y:Math.sign(s.y-o.y)};return{x:{[dt.Backward]:p.x[dt.Backward]||m.x===-1,[dt.Forward]:p.x[dt.Forward]||m.x===1},y:{[dt.Backward]:p.y[dt.Backward]||m.y===-1,[dt.Forward]:p.y[dt.Forward]||m.y===1}}},[r,s,o])}function _h(e,s){const r=s!=null?e.get(s):void 0,o=r?r.node.current:null;return br(p=>{var m;return s==null?null:(m=o??p)!=null?m:null},[o,s])}function yh(e,s){return _.useMemo(()=>e.reduce((r,o)=>{const{sensor:p}=o,m=p.activators.map(v=>({eventName:v.eventName,handler:s(v.handler,o)}));return[...r,...m]},[]),[e,s])}var pr;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(pr||(pr={}));var en;(function(e){e.Optimized="optimized"})(en||(en={}));const _o=new Map;function Sh(e,s){let{dragging:r,dependencies:o,config:p}=s;const[m,v]=_.useState(null),{frequency:n,measure:i,strategy:a}=p,u=_.useRef(e),c=l(),g=fr(c),x=_.useCallback(function(h){h===void 0&&(h=[]),!g.current&&v(d=>d===null?h:d.concat(h.filter(f=>!d.includes(f))))},[g]),S=_.useRef(null),w=br(h=>{if(c&&!r)return _o;if(!h||h===_o||u.current!==e||m!=null){const d=new Map;for(let f of e){if(!f)continue;if(m&&m.length>0&&!m.includes(f.id)&&f.rect.current){d.set(f.id,f.rect.current);continue}const y=f.node.current,C=y?new Ln(i(y),y):null;f.rect.current=C,C&&d.set(f.id,C)}return d}return h},[e,m,r,c,i]);return _.useEffect(()=>{u.current=e},[e]),_.useEffect(()=>{c||x()},[r,c]),_.useEffect(()=>{m&&m.length>0&&v(null)},[JSON.stringify(m)]),_.useEffect(()=>{c||typeof n!="number"||S.current!==null||(S.current=setTimeout(()=>{x(),S.current=null},n))},[n,c,x,...o]),{droppableRects:w,measureDroppableContainers:x,measuringScheduled:m!=null};function l(){switch(a){case pr.Always:return!1;case pr.BeforeDragging:return r;default:return!r}}}function Bn(e,s){return br(r=>e?r||(typeof s=="function"?s(e):e):null,[s,e])}function wh(e,s){return Bn(e,s)}function Ch(e){let{callback:s,disabled:r}=e;const o=di(s),p=_.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:m}=window;return new m(o)},[o,r]);return _.useEffect(()=>()=>p?.disconnect(),[p]),p}function hi(e){let{callback:s,disabled:r}=e;const o=di(s),p=_.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:m}=window;return new m(o)},[r]);return _.useEffect(()=>()=>p?.disconnect(),[p]),p}function kh(e){return new Ln(_r(e),e)}function yo(e,s,r){s===void 0&&(s=kh);const[o,p]=_.useState(null);function m(){p(i=>{if(!e)return null;if(e.isConnected===!1){var a;return(a=i??r)!=null?a:null}const u=s(e);return JSON.stringify(i)===JSON.stringify(u)?i:u})}const v=Ch({callback(i){if(e)for(const a of i){const{type:u,target:c}=a;if(u==="childList"&&c instanceof HTMLElement&&c.contains(e)){m();break}}}}),n=hi({callback:m});return es(()=>{m(),e?(n?.observe(e),v?.observe(document.body,{childList:!0,subtree:!0})):(n?.disconnect(),v?.disconnect())},[e]),o}function Eh(e){const s=Bn(e);return al(e,s)}const So=[];function jh(e){const s=_.useRef(e),r=br(o=>e?o&&o!==So&&e&&s.current&&e.parentNode===s.current.parentNode?o:Pn(e):So,[e]);return _.useEffect(()=>{s.current=e},[e]),r}function Nh(e){const[s,r]=_.useState(null),o=_.useRef(e),p=_.useCallback(m=>{const v=Ri(m.target);v&&r(n=>n?(n.set(v,Zi(v)),new Map(n)):null)},[]);return _.useEffect(()=>{const m=o.current;if(e!==m){v(m);const n=e.map(i=>{const a=Ri(i);return a?(a.addEventListener("scroll",p,{passive:!0}),[a,Zi(a)]):null}).filter(i=>i!=null);r(n.length?new Map(n):null),o.current=e}return()=>{v(e),v(m)};function v(n){n.forEach(i=>{const a=Ri(i);a?.removeEventListener("scroll",p)})}},[p,e]),_.useMemo(()=>e.length?s?Array.from(s.values()).reduce((m,v)=>Os(m,v),Ot):ml(e):Ot,[e,s])}function wo(e,s){s===void 0&&(s=[]);const r=_.useRef(null);return _.useEffect(()=>{r.current=null},s),_.useEffect(()=>{const o=e!==Ot;o&&!r.current&&(r.current=e),!o&&r.current&&(r.current=null)},[e]),r.current?Qr(e,r.current):Ot}function Rh(e){_.useEffect(()=>{if(!ci)return;const s=e.map(r=>{let{sensor:o}=r;return o.setup==null?void 0:o.setup()});return()=>{for(const r of s)r?.()}},e.map(s=>{let{sensor:r}=s;return r}))}function Ah(e,s){return _.useMemo(()=>e.reduce((r,o)=>{let{eventName:p,handler:m}=o;return r[p]=v=>{m(v,s)},r},{}),[e,s])}function xl(e){return _.useMemo(()=>e?th(e):null,[e])}const Co=[];function Th(e,s){s===void 0&&(s=_r);const[r]=e,o=xl(r?yt(r):null),[p,m]=_.useState(Co);function v(){m(()=>e.length?e.map(i=>hl(i)?o:new Ln(s(i),i)):Co)}const n=hi({callback:v});return es(()=>{n?.disconnect(),v(),e.forEach(i=>n?.observe(i))},[e]),p}function bl(e){if(!e)return null;if(e.children.length>1)return e;const s=e.children[0];return xr(s)?s:e}function Mh(e){let{measure:s}=e;const[r,o]=_.useState(null),p=_.useCallback(a=>{for(const{target:u}of a)if(xr(u)){o(c=>{const g=s(u);return c?{...c,width:g.width,height:g.height}:g});break}},[s]),m=hi({callback:p}),v=_.useCallback(a=>{const u=bl(a);m?.disconnect(),u&&m?.observe(u),o(u?s(u):null)},[s,m]),[n,i]=Yr(v);return _.useMemo(()=>({nodeRef:n,rect:r,setRef:i}),[r,n,i])}const Dh=[{sensor:On,options:{}},{sensor:vl,options:{}}],Ph={current:{}},Hr={draggable:{measure:go},droppable:{measure:go,strategy:pr.WhileDragging,frequency:en.Optimized},dragOverlay:{measure:_r}};class cr extends Map{get(s){var r;return s!=null&&(r=super.get(s))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(s=>{let{disabled:r}=s;return!r})}getNodeFor(s){var r,o;return(r=(o=this.get(s))==null?void 0:o.node.current)!=null?r:void 0}}const Lh={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new cr,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Jr},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Hr,measureDroppableContainers:Jr,windowRect:null,measuringScheduled:!1},_l={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Jr,draggableNodes:new Map,over:null,measureDroppableContainers:Jr},yr=_.createContext(_l),yl=_.createContext(Lh);function Ih(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new cr}}}function Oh(e,s){switch(s.type){case ot.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case ot.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:s.coordinates.x-e.draggable.initialCoordinates.x,y:s.coordinates.y-e.draggable.initialCoordinates.y}}};case ot.DragEnd:case ot.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ot.RegisterDroppable:{const{element:r}=s,{id:o}=r,p=new cr(e.droppable.containers);return p.set(o,r),{...e,droppable:{...e.droppable,containers:p}}}case ot.SetDroppableDisabled:{const{id:r,key:o,disabled:p}=s,m=e.droppable.containers.get(r);if(!m||o!==m.key)return e;const v=new cr(e.droppable.containers);return v.set(r,{...m,disabled:p}),{...e,droppable:{...e.droppable,containers:v}}}case ot.UnregisterDroppable:{const{id:r,key:o}=s,p=e.droppable.containers.get(r);if(!p||o!==p.key)return e;const m=new cr(e.droppable.containers);return m.delete(r),{...e,droppable:{...e.droppable,containers:m}}}default:return e}}function Bh(e){let{disabled:s}=e;const{active:r,activatorEvent:o,draggableNodes:p}=_.useContext(yr),m=Gr(o),v=Gr(r?.id);return _.useEffect(()=>{if(!s&&!o&&m&&v!=null){if(!Dn(m)||document.activeElement===m.target)return;const n=p.get(v);if(!n)return;const{activatorNode:i,node:a}=n;if(!i.current&&!a.current)return;requestAnimationFrame(()=>{for(const u of[i.current,a.current]){if(!u)continue;const c=Du(u);if(c){c.focus();break}}})}},[o,s,p,v,m]),null}function Sl(e,s){let{transform:r,...o}=s;return e!=null&&e.length?e.reduce((p,m)=>m({transform:p,...o}),r):r}function Fh(e){return _.useMemo(()=>({draggable:{...Hr.draggable,...e?.draggable},droppable:{...Hr.droppable,...e?.droppable},dragOverlay:{...Hr.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function zh(e){let{activeNode:s,measure:r,initialRect:o,config:p=!0}=e;const m=_.useRef(!1),{x:v,y:n}=typeof p=="boolean"?{x:p,y:p}:p;es(()=>{if(!v&&!n||!s){m.current=!1;return}if(m.current||!o)return;const a=s?.node.current;if(!a||a.isConnected===!1)return;const u=r(a),c=al(u,o);if(v||(c.x=0),n||(c.y=0),m.current=!0,Math.abs(c.x)>0||Math.abs(c.y)>0){const g=cl(a);g&&g.scrollBy({top:c.y,left:c.x})}},[s,v,n,o,r])}const fi=_.createContext({...Ot,scaleX:1,scaleY:1});var ss;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(ss||(ss={}));const Wh=_.memo(function(s){var r,o,p,m;let{id:v,accessibility:n,autoScroll:i=!0,children:a,sensors:u=Dh,collisionDetection:c=Yu,measuring:g,modifiers:x,...S}=s;const w=_.useReducer(Oh,void 0,Ih),[l,h]=w,[d,f]=Fu(),[y,C]=_.useState(ss.Uninitialized),k=y===ss.Initialized,{draggable:{active:E,nodes:b,translate:j},droppable:{containers:R}}=l,L=E!=null?b.get(E):null,T=_.useRef({initial:null,translated:null}),D=_.useMemo(()=>{var ve;return E!=null?{id:E,data:(ve=L?.data)!=null?ve:Ph,rect:T}:null},[E,L]),F=_.useRef(null),[I,H]=_.useState(null),[K,A]=_.useState(null),P=fr(S,Object.values(S)),M=ui("DndDescribedBy",v),O=_.useMemo(()=>R.getEnabled(),[R]),$=Fh(g),{droppableRects:U,measureDroppableContainers:B,measuringScheduled:z}=Sh(O,{dragging:k,dependencies:[j.x,j.y],config:$.droppable}),q=_h(b,E),N=_.useMemo(()=>K?Zr(K):null,[K]),W=oe(),X=wh(q,$.draggable.measure);zh({activeNode:E!=null?b.get(E):null,config:W.layoutShiftCompensation,initialRect:X,measure:$.draggable.measure});const V=yo(q,$.draggable.measure,X),ie=yo(q?q.parentElement:null),ee=_.useRef({activatorEvent:null,active:null,activeNode:q,collisionRect:null,collisions:null,droppableRects:U,draggableNodes:b,draggingNode:null,draggingNodeRect:null,droppableContainers:R,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),pe=R.getNodeFor((r=ee.current.over)==null?void 0:r.id),he=Mh({measure:$.dragOverlay.measure}),G=(o=he.nodeRef.current)!=null?o:q,ge=k?(p=he.rect)!=null?p:V:null,ne=!!(he.nodeRef.current&&he.rect),Re=Eh(ne?null:V),Ze=xl(G?yt(G):null),Xe=jh(k?pe??q:null),ye=Th(Xe),He=Sl(x,{transform:{x:j.x-Re.x,y:j.y-Re.y,scaleX:1,scaleY:1},activatorEvent:K,active:D,activeNodeRect:V,containerNodeRect:ie,draggingNodeRect:ge,over:ee.current.over,overlayNodeRect:he.rect,scrollableAncestors:Xe,scrollableAncestorRects:ye,windowRect:Ze}),Ie=N?Os(N,j):null,tt=Nh(Xe),Ke=wo(tt),Be=wo(tt,[V]),Je=Os(He,Ke),Te=ge?Zu(ge,He):null,je=D&&Te?c({active:D,collisionRect:Te,droppableRects:U,droppableContainers:O,pointerCoordinates:Ie}):null,_e=Vu(je,"id"),[$e,be]=_.useState(null),pt=ne?He:Os(He,Be),Ye=Gu(pt,(m=$e?.rect)!=null?m:null,V),Dt=_.useRef(null),J=_.useCallback((ve,xe)=>{let{sensor:Me,options:we}=xe;if(F.current==null)return;const Le=b.get(F.current);if(!Le)return;const ke=ve.nativeEvent,me=new Me({active:F.current,activeNode:Le,event:ke,options:we,context:ee,onAbort(Ae){if(!b.get(Ae))return;const{onDragAbort:ut}=P.current,at={id:Ae};ut?.(at),d({type:"onDragAbort",event:at})},onPending(Ae,Qe,ut,at){if(!b.get(Ae))return;const{onDragPending:rt}=P.current,it={id:Ae,constraint:Qe,initialCoordinates:ut,offset:at};rt?.(it),d({type:"onDragPending",event:it})},onStart(Ae){const Qe=F.current;if(Qe==null)return;const ut=b.get(Qe);if(!ut)return;const{onDragStart:at}=P.current,$t={activatorEvent:ke,active:{id:Qe,data:ut.data,rect:T}};_s.unstable_batchedUpdates(()=>{at?.($t),C(ss.Initializing),h({type:ot.DragStart,initialCoordinates:Ae,active:Qe}),d({type:"onDragStart",event:$t}),H(Dt.current),A(ke)})},onMove(Ae){h({type:ot.DragMove,coordinates:Ae})},onEnd:De(ot.DragEnd),onCancel:De(ot.DragCancel)});Dt.current=me;function De(Ae){return async function(){const{active:ut,collisions:at,over:$t,scrollAdjustedTranslate:rt}=ee.current;let it=null;if(ut&&rt){const{cancelDrop:gt}=P.current;it={activatorEvent:ke,active:ut,collisions:at,delta:rt,over:$t},Ae===ot.DragEnd&&typeof gt=="function"&&await Promise.resolve(gt(it))&&(Ae=ot.DragCancel)}F.current=null,_s.unstable_batchedUpdates(()=>{h({type:Ae}),C(ss.Uninitialized),be(null),H(null),A(null),Dt.current=null;const gt=Ae===ot.DragEnd?"onDragEnd":"onDragCancel";if(it){const Ut=P.current[gt];Ut?.(it),d({type:gt,event:it})}})}}},[b]),fe=_.useCallback((ve,xe)=>(Me,we)=>{const Le=Me.nativeEvent,ke=b.get(we);if(F.current!==null||!ke||Le.dndKit||Le.defaultPrevented)return;const me={active:ke};ve(Me,xe.options,me)===!0&&(Le.dndKit={capturedBy:xe.sensor},F.current=we,J(Me,xe))},[b,J]),ue=yh(u,fe);Rh(u),es(()=>{V&&y===ss.Initializing&&C(ss.Initialized)},[V,y]),_.useEffect(()=>{const{onDragMove:ve}=P.current,{active:xe,activatorEvent:Me,collisions:we,over:Le}=ee.current;if(!xe||!Me)return;const ke={active:xe,activatorEvent:Me,collisions:we,delta:{x:Je.x,y:Je.y},over:Le};_s.unstable_batchedUpdates(()=>{ve?.(ke),d({type:"onDragMove",event:ke})})},[Je.x,Je.y]),_.useEffect(()=>{const{active:ve,activatorEvent:xe,collisions:Me,droppableContainers:we,scrollAdjustedTranslate:Le}=ee.current;if(!ve||F.current==null||!xe||!Le)return;const{onDragOver:ke}=P.current,me=we.get(_e),De=me&&me.rect.current?{id:me.id,rect:me.rect.current,data:me.data,disabled:me.disabled}:null,Ae={active:ve,activatorEvent:xe,collisions:Me,delta:{x:Le.x,y:Le.y},over:De};_s.unstable_batchedUpdates(()=>{be(De),ke?.(Ae),d({type:"onDragOver",event:Ae})})},[_e]),es(()=>{ee.current={activatorEvent:K,active:D,activeNode:q,collisionRect:Te,collisions:je,droppableRects:U,draggableNodes:b,draggingNode:G,draggingNodeRect:ge,droppableContainers:R,over:$e,scrollableAncestors:Xe,scrollAdjustedTranslate:Je},T.current={initial:ge,translated:Te}},[D,q,je,Te,b,G,ge,U,R,$e,Xe,Je]),vh({...W,delta:j,draggingRect:Te,pointerCoordinates:Ie,scrollableAncestors:Xe,scrollableAncestorRects:ye});const Y=_.useMemo(()=>({active:D,activeNode:q,activeNodeRect:V,activatorEvent:K,collisions:je,containerNodeRect:ie,dragOverlay:he,draggableNodes:b,droppableContainers:R,droppableRects:U,over:$e,measureDroppableContainers:B,scrollableAncestors:Xe,scrollableAncestorRects:ye,measuringConfiguration:$,measuringScheduled:z,windowRect:Ze}),[D,q,V,K,je,ie,he,b,R,U,$e,B,Xe,ye,$,z,Ze]),te=_.useMemo(()=>({activatorEvent:K,activators:ue,active:D,activeNodeRect:V,ariaDescribedById:{draggable:M},dispatch:h,draggableNodes:b,over:$e,measureDroppableContainers:B}),[K,ue,D,V,h,M,b,$e,B]);return ae.createElement(ol.Provider,{value:f},ae.createElement(yr.Provider,{value:te},ae.createElement(yl.Provider,{value:Y},ae.createElement(fi.Provider,{value:Ye},a)),ae.createElement(Bh,{disabled:n?.restoreFocus===!1})),ae.createElement(Hu,{...n,hiddenTextDescribedById:M}));function oe(){const ve=I?.autoScrollEnabled===!1,xe=typeof i=="object"?i.enabled===!1:i===!1,Me=k&&!ve&&!xe;return typeof i=="object"?{...i,enabled:Me}:{enabled:Me}}}),Hh=_.createContext(null),ko="button",$h="Draggable";function Uh(e){let{id:s,data:r,disabled:o=!1,attributes:p}=e;const m=ui($h),{activators:v,activatorEvent:n,active:i,activeNodeRect:a,ariaDescribedById:u,draggableNodes:c,over:g}=_.useContext(yr),{role:x=ko,roleDescription:S="draggable",tabIndex:w=0}=p??{},l=i?.id===s,h=_.useContext(l?fi:Hh),[d,f]=Yr(),[y,C]=Yr(),k=Ah(v,s),E=fr(r);es(()=>(c.set(s,{id:s,key:m,node:d,activatorNode:y,data:E}),()=>{const j=c.get(s);j&&j.key===m&&c.delete(s)}),[c,s]);const b=_.useMemo(()=>({role:x,tabIndex:w,"aria-disabled":o,"aria-pressed":l&&x===ko?!0:void 0,"aria-roledescription":S,"aria-describedby":u.draggable}),[o,x,w,l,S,u.draggable]);return{active:i,activatorEvent:n,activeNodeRect:a,attributes:b,isDragging:l,listeners:o?void 0:k,node:d,over:g,setNodeRef:f,setActivatorNodeRef:C,transform:h}}function qh(){return _.useContext(yl)}const Kh="Droppable",Vh={timeout:25};function Xh(e){let{data:s,disabled:r=!1,id:o,resizeObserverConfig:p}=e;const m=ui(Kh),{active:v,dispatch:n,over:i,measureDroppableContainers:a}=_.useContext(yr),u=_.useRef({disabled:r}),c=_.useRef(!1),g=_.useRef(null),x=_.useRef(null),{disabled:S,updateMeasurementsFor:w,timeout:l}={...Vh,...p},h=fr(w??o),d=_.useCallback(()=>{if(!c.current){c.current=!0;return}x.current!=null&&clearTimeout(x.current),x.current=setTimeout(()=>{a(Array.isArray(h.current)?h.current:[h.current]),x.current=null},l)},[l]),f=hi({callback:d,disabled:S||!v}),y=_.useCallback((b,j)=>{f&&(j&&(f.unobserve(j),c.current=!1),b&&f.observe(b))},[f]),[C,k]=Yr(y),E=fr(s);return _.useEffect(()=>{!f||!C.current||(f.disconnect(),c.current=!1,f.observe(C.current))},[C,f]),_.useEffect(()=>(n({type:ot.RegisterDroppable,element:{id:o,key:m,disabled:r,node:C,rect:g,data:E}}),()=>n({type:ot.UnregisterDroppable,key:m,id:o})),[o]),_.useEffect(()=>{r!==u.current.disabled&&(n({type:ot.SetDroppableDisabled,id:o,key:m,disabled:r}),u.current.disabled=r)},[o,m,r,n]),{active:v,rect:g,isOver:i?.id===o,node:C,over:i,setNodeRef:k}}function Yh(e){let{animation:s,children:r}=e;const[o,p]=_.useState(null),[m,v]=_.useState(null),n=Gr(r);return!r&&!o&&n&&p(n),es(()=>{if(!m)return;const i=o?.key,a=o?.props.id;if(i==null||a==null){p(null);return}Promise.resolve(s(a,m)).then(()=>{p(null)})},[s,o,m]),ae.createElement(ae.Fragment,null,r,o?_.cloneElement(o,{ref:v}):null)}const Gh={x:0,y:0,scaleX:1,scaleY:1};function Qh(e){let{children:s}=e;return ae.createElement(yr.Provider,{value:_l},ae.createElement(fi.Provider,{value:Gh},s))}const Zh={position:"fixed",touchAction:"none"},Jh=e=>Dn(e)?"transform 250ms ease":void 0,ef=_.forwardRef((e,s)=>{let{as:r,activatorEvent:o,adjustScale:p,children:m,className:v,rect:n,style:i,transform:a,transition:u=Jh}=e;if(!n)return null;const c=p?a:{...a,scaleX:1,scaleY:1},g={...Zh,width:n.width,height:n.height,top:n.top,left:n.left,transform:mr.Transform.toString(c),transformOrigin:p&&o?qu(o,n):void 0,transition:typeof u=="function"?u(o):u,...i};return ae.createElement(r,{className:v,style:g,ref:s},m)}),tf=e=>s=>{let{active:r,dragOverlay:o}=s;const p={},{styles:m,className:v}=e;if(m!=null&&m.active)for(const[n,i]of Object.entries(m.active))i!==void 0&&(p[n]=r.node.style.getPropertyValue(n),r.node.style.setProperty(n,i));if(m!=null&&m.dragOverlay)for(const[n,i]of Object.entries(m.dragOverlay))i!==void 0&&o.node.style.setProperty(n,i);return v!=null&&v.active&&r.node.classList.add(v.active),v!=null&&v.dragOverlay&&o.node.classList.add(v.dragOverlay),function(){for(const[i,a]of Object.entries(p))r.node.style.setProperty(i,a);v!=null&&v.active&&r.node.classList.remove(v.active)}},sf=e=>{let{transform:{initial:s,final:r}}=e;return[{transform:mr.Transform.toString(s)},{transform:mr.Transform.toString(r)}]},rf={duration:250,easing:"ease",keyframes:sf,sideEffects:tf({styles:{active:{opacity:"0"}}})};function nf(e){let{config:s,draggableNodes:r,droppableContainers:o,measuringConfiguration:p}=e;return di((m,v)=>{if(s===null)return;const n=r.get(m);if(!n)return;const i=n.node.current;if(!i)return;const a=bl(v);if(!a)return;const{transform:u}=yt(v).getComputedStyle(v),c=ll(u);if(!c)return;const g=typeof s=="function"?s:of(s);return pl(i,p.draggable.measure),g({active:{id:m,data:n.data,node:i,rect:p.draggable.measure(i)},draggableNodes:r,dragOverlay:{node:v,rect:p.dragOverlay.measure(a)},droppableContainers:o,measuringConfiguration:p,transform:c})})}function of(e){const{duration:s,easing:r,sideEffects:o,keyframes:p}={...rf,...e};return m=>{let{active:v,dragOverlay:n,transform:i,...a}=m;if(!s)return;const u={x:n.rect.left-v.rect.left,y:n.rect.top-v.rect.top},c={scaleX:i.scaleX!==1?v.rect.width*i.scaleX/n.rect.width:1,scaleY:i.scaleY!==1?v.rect.height*i.scaleY/n.rect.height:1},g={x:i.x-u.x,y:i.y-u.y,...c},x=p({...a,active:v,dragOverlay:n,transform:{initial:i,final:g}}),[S]=x,w=x[x.length-1];if(JSON.stringify(S)===JSON.stringify(w))return;const l=o?.({active:v,dragOverlay:n,...a}),h=n.node.animate(x,{duration:s,easing:r,fill:"forwards"});return new Promise(d=>{h.onfinish=()=>{l?.(),d()}})}}let Eo=0;function af(e){return _.useMemo(()=>{if(e!=null)return Eo++,Eo},[e])}const lf=ae.memo(e=>{let{adjustScale:s=!1,children:r,dropAnimation:o,style:p,transition:m,modifiers:v,wrapperElement:n="div",className:i,zIndex:a=999}=e;const{activatorEvent:u,active:c,activeNodeRect:g,containerNodeRect:x,draggableNodes:S,droppableContainers:w,dragOverlay:l,over:h,measuringConfiguration:d,scrollableAncestors:f,scrollableAncestorRects:y,windowRect:C}=qh(),k=_.useContext(fi),E=af(c?.id),b=Sl(v,{activatorEvent:u,active:c,activeNodeRect:g,containerNodeRect:x,draggingNodeRect:l.rect,over:h,overlayNodeRect:l.rect,scrollableAncestors:f,scrollableAncestorRects:y,transform:k,windowRect:C}),j=Bn(g),R=nf({config:o,draggableNodes:S,droppableContainers:w,measuringConfiguration:d}),L=j?l.setRef:void 0;return ae.createElement(Qh,null,ae.createElement(Yh,{animation:R},c&&E?ae.createElement(ef,{key:E,id:c.id,ref:L,as:n,activatorEvent:u,adjustScale:s,className:i,transition:m,rect:j,style:{zIndex:a,...p},transform:b},r):null))}),wl=768;function cf(e){const s=window.matchMedia(`(max-width: ${wl-1}px)`);return s.addEventListener("change",e),()=>s.removeEventListener("change",e)}function df(){return window.innerWidth<wl}function uf(){return!1}function Cl(){return _.useSyncExternalStore(cf,df,uf)}const hf=1500,ff=2e3,mf=5e3;function kl(e,s){return e&&s?.workingDir===e&&s.tab==="changes"?hf:!1}function pf(e,s){return e&&s?.workspaceId===e&&s.tab==="changes"?ff:!1}function gf(e,s){return e&&s?.workingDir===e&&s.tab==="history"?mf:!1}function Fn(e){return kt({queryKey:de.workspaces.list(e),queryFn:()=>Ce.get(`/tasks/${e}/workspaces`),enabled:!!e})}function El(e){const s=bt();return Bt({mutationFn:r=>Ce.post(`/tasks/${e}/workspaces`,r),onSuccess:()=>{s.invalidateQueries({queryKey:de.workspaces.list(e)}),s.invalidateQueries({queryKey:de.tasks.all})}})}function jl(){const e=bt();return Bt({mutationFn:({id:s,commitMessage:r})=>Ce.post(`/workspaces/${s}/merge`,{commitMessage:r}),onSuccess:()=>{e.invalidateQueries({queryKey:de.workspaces.all}),e.invalidateQueries({queryKey:de.tasks.all}),e.invalidateQueries({queryKey:de.git.all})},onError:()=>{e.invalidateQueries({queryKey:de.git.all})}})}function vf(){const e=bt();return Bt({mutationFn:s=>Ce.post(`/workspaces/${s}/reactivate`),onSuccess:()=>{e.invalidateQueries({queryKey:de.workspaces.all}),e.invalidateQueries({queryKey:de.tasks.all})}})}function zn(){return Bt({mutationFn:({workspaceId:e,editorType:s})=>Ce.post(`/workspaces/${e}/open-editor`,{editorType:s})})}function Wn(e,s={}){const r=Cs(p=>p.visibleContext),o=pf(e,r);return kt({queryKey:de.workspaces.gitStatus(e),queryFn:()=>Ce.get(`/workspaces/${e}/git-status`),enabled:!!e&&(s.enabled??!0),refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1})}function Nl(){const e=bt();return Bt({mutationFn:s=>Ce.post(`/workspaces/${s}/rebase`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:de.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:de.git.all})},onError:(s,r)=>{e.invalidateQueries({queryKey:de.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:de.git.all})}})}function Hn(){const e=bt();return Bt({mutationFn:s=>Ce.post(`/workspaces/${s}/abort-operation`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:de.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:de.git.all})}})}function xf(e,s){const r=[];if(!e||e.length===0)return r;const o=e.some(m=>m.status==="ACTIVE");return e.some(m=>m.sessions?.some(v=>v.status===ct.RUNNING||v.status===ct.PENDING))&&r.push(s("正在运行的 Agent 将被停止")),o&&(r.push(s("分支上未合并的变更将丢失")),r.push(s("关联的工作目录(worktree)将被清理"))),r}function $n({isOpen:e,onClose:s,onConfirm:r,taskId:o,taskTitle:p,workspaces:m,isLoading:v}){const{t:n}=le(),{data:i,isLoading:a}=Fn(m===void 0&&e?o:""),u=m??i,c=m===void 0&&e&&a,g=_.useMemo(()=>xf(u,n),[u,n]);return t.jsx(_n,{isOpen:e,onClose:s,onConfirm:r,title:n("删除任务"),description:t.jsxs(t.Fragment,{children:[t.jsx("p",{children:n("确认删除任务「{title}」?此操作不可撤销。",{title:p})}),c?t.jsx("p",{className:"mt-2 text-xs text-neutral-400",children:n("加载中...")}):g.length>0?t.jsx("ul",{className:"mt-2 space-y-1",children:g.map((x,S)=>t.jsxs("li",{className:"flex items-start gap-1.5 text-amber-600",children:[t.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-amber-400"}),t.jsx("span",{children:x})]},S))}):null]}),confirmText:n("删除"),variant:"danger",isLoading:v||c})}const Se={Review:"Review",Running:"Running",Pending:"Pending",Done:"Done",Cancelled:"Cancelled"},tn={[Se.Review]:{label:"Review",icon:Ha,iconClass:"text-warning",accentClass:"text-warning"},[Se.Running]:{label:"Running",icon:Wa,iconClass:"text-info",accentClass:"text-info"},[Se.Pending]:{label:"Pending",icon:za,iconClass:"text-muted-foreground",accentClass:"text-muted-foreground"},[Se.Done]:{label:"Done",icon:Fa,iconClass:"text-success/80",accentClass:"text-success"},[Se.Cancelled]:{label:"Cancelled",icon:Ba,iconClass:"text-muted-foreground/70",accentClass:"text-muted-foreground/70"}},bf=[Se.Review,Se.Running,Se.Pending,Se.Done,Se.Cancelled],Rl=_.createContext(null),_f=3e4;function yf(e=_f){const[,s]=_.useState(0);_.useEffect(()=>{const r=setInterval(()=>s(o=>o+1),e);return()=>clearInterval(r)},[e])}function Sf(e){const s=Math.max(0,Math.floor((Date.now()-new Date(e).getTime())/1e3));return s<60?xt("{count}s ago",{count:s}):s<3600?xt("{count}m ago",{count:Math.floor(s/60)}):s<86400?xt("{count}h ago",{count:Math.floor(s/3600)}):xt("{count}d ago",{count:Math.floor(s/86400)})}function wf({task:e,status:s,isSelected:r,project:o,onSelectTask:p,onTaskStatusChange:m,onDeleteTask:v,disableDrag:n}){const{t:i}=le(),a=_.useContext(Rl),u=_.useRef(null),c=!!e.projectArchivedAt,g=c||!!n,{attributes:x,listeners:S,setNodeRef:w,isDragging:l}=Uh({id:e.id,data:{task:e,fromStatus:s},disabled:g}),h=_.useCallback(T=>{u.current=T,w(T),a&&(T?a.registry.set(e.id,T):a.registry.delete(e.id))},[w,a,e.id]);_.useEffect(()=>()=>{a?.registry.delete(e.id)},[e.id,a]);const[d,f]=_.useState(null),[y,C]=_.useState(!1),k=_.useRef(null),E=_.useRef(null),b=_.useCallback(T=>{c||!m&&!v||(T.preventDefault(),f({x:T.clientX,y:T.clientY}))},[c,m,v]),j=_.useCallback(()=>{E.current&&(clearTimeout(E.current),E.current=null)},[]),R=_.useCallback(T=>{if(!n||c||!m&&!v)return;const D=T.touches[0];if(!D)return;const{clientX:F,clientY:I}=D;E.current=setTimeout(()=>{E.current=null,f({x:F,y:I})},500)},[n,c,m,v]);_.useEffect(()=>{if(!d)return;const T=D=>{k.current&&!k.current.contains(D.target)&&f(null)};return document.addEventListener("mousedown",T),document.addEventListener("touchstart",T),()=>{document.removeEventListener("mousedown",T),document.removeEventListener("touchstart",T)}},[d]);const L=o?o.name:void 0;return t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:h,onClick:()=>p(e.id),onContextMenu:b,onTouchStart:R,onTouchEnd:j,onTouchMove:j,title:L,"aria-label":L?`${e.title} — ${L}`:e.title,className:`flex items-center gap-2.5 ml-4 mr-2 px-2 py-2 rounded-md text-sm text-left transition-colors group animate-task-enter
|
|
7
|
+
${l?"opacity-30":""}
|
|
8
|
+
${r?"bg-accent":"hover:bg-accent/50"}`,...g?{}:S,...g?{}:x,children:[t.jsx("span",{className:"shrink-0 flex items-center",children:(()=>{const{icon:T,iconClass:D}=tn[s];return t.jsx(T,{className:`${D} ${s===Se.Running?"animate-pulse":""}`})})()}),t.jsx("span",{className:`min-w-0 flex-1 truncate ${r?"text-foreground font-medium":"text-foreground/90"}`,children:e.title}),e.projectArchivedAt&&t.jsx("span",{className:"inline-flex shrink-0 items-center rounded-full bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:e.projectRepoDeletedAt?i("源码已删除"):i("已删除")}),e.updatedAt&&t.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground/50 tabular-nums",children:Sf(e.updatedAt)}),o&&t.jsx("span",{className:`shrink-0 w-1.5 h-1.5 rounded-full ${o.color.replace("text-","bg-")}`})]}),d&&t.jsxs("div",{ref:k,className:"fixed z-[100] w-44 bg-popover rounded-lg border border-border shadow-lg py-1 animate-in fade-in zoom-in-95 duration-100",style:{left:d.x,top:d.y},children:[m&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted-foreground/70 uppercase tracking-wider",children:i("Move to")}),bf.filter(T=>T!==s).map(T=>{const{icon:D,label:F,accentClass:I}=tn[T];return t.jsxs("button",{onClick:()=>{m(e.id,T),f(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs hover:bg-accent/50 transition-colors",children:[t.jsx(D,{className:`w-3.5 h-3.5 ${I}`}),t.jsx("span",{className:"text-foreground/80",children:i(F)})]},T)})]}),v&&t.jsxs(t.Fragment,{children:[m&&t.jsx("div",{className:"my-1 border-t border-border/60"}),t.jsxs("button",{onClick:()=>{C(!0),f(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-destructive hover:bg-destructive/10 transition-colors",children:[t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"w-3.5 h-3.5",children:[t.jsx("path",{d:"M3 6h18"}),t.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),t.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]}),t.jsx("span",{children:i("Delete Task")})]})]})]}),t.jsx($n,{isOpen:y,onClose:()=>C(!1),onConfirm:()=>{v?.(e.id),C(!1)},taskId:e.id,taskTitle:e.title})]})}const Cf=_.memo(function({title:s,tasks:r,status:o,defaultOpen:p,selectedTaskId:m,onSelectTask:v,projects:n,isDragging:i,dragFromStatus:a,onTaskStatusChange:u,onDeleteTask:c,disableDrag:g}){const{t:x}=le(),[S,w]=_.useState(p);yf();const l=r.length===0,h=i&&a===o,d=i&&a!==o,{setNodeRef:f,isOver:y}=Xh({id:`group-${o}`,data:{status:o}}),C=o===Se.Review,k=x(s),E=i?h&&(S||!0):S;return t.jsxs("div",{className:"mb-2","data-task-group-status":o,children:[t.jsxs("button",{onClick:()=>!i&&w(b=>!b),className:"flex items-center gap-1.5 w-full px-4 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors group/header",children:[t.jsx("span",{className:"flex-1 text-left",children:k}),C&&!l?t.jsx("span",{className:"px-1.5 py-0.5 bg-warning/15 text-warning text-[11px] font-semibold rounded-full animate-hop",children:r.length}):t.jsx("span",{className:"text-[11px] text-muted-foreground/50 font-normal tabular-nums",children:r.length}),t.jsx("span",{className:"text-muted-foreground/50",children:E?t.jsx(wt,{size:12}):t.jsx(Mt,{size:12})})]}),d&&t.jsx("div",{ref:f,className:`mx-2 my-1 flex items-center justify-center rounded-lg border-2 border-dashed transition-all duration-150 h-10
|
|
9
|
+
${y?"border-info bg-info/10 text-info":"border-border bg-muted/30 text-muted-foreground/70"}`,children:t.jsx("span",{className:"text-xs font-medium",children:y?x("Drop into {title}",{title:k}):x("Drop here")})}),E&&!d&&t.jsx("div",{ref:h?void 0:f,className:`flex flex-col mt-0.5 min-h-[40px] rounded-md transition-colors
|
|
10
|
+
${y&&!h?"bg-info/10 ring-1 ring-info/30":""}
|
|
11
|
+
${l&&i?"border border-dashed border-border mx-2":""}`,children:l?t.jsx("span",{className:"text-xs text-muted-foreground/50 py-2 px-4",children:x("No tasks")}):r.map(b=>{const j=m===b.id,R=b.projectId?n.find(L=>L.id===b.projectId):void 0;return t.jsx(wf,{task:b,status:o,isSelected:j,project:R,onSelectTask:v,onTaskStatusChange:b.projectArchivedAt?void 0:u,onDeleteTask:b.projectArchivedAt?void 0:c,disableDrag:g},b.id)})})]})}),kf=12,Ef=50;function jf({isOpen:e,onClose:s,tasks:r,projects:o,onSelectTask:p}){const{t:m}=le(),[v,n]=_.useState(""),[i,a]=_.useState(0),u=_.useRef(null);_.useEffect(()=>{e&&(n(""),a(0))},[e]);const c=_.useMemo(()=>{const S=v.trim().toLowerCase();return S?r.filter(w=>w.title.toLowerCase().includes(S)).slice(0,Ef):r.slice(0,kf)},[r,v]);_.useEffect(()=>{a(0)},[v]),_.useEffect(()=>{u.current?.children[i]?.scrollIntoView({block:"nearest"})},[i]);const g=_.useCallback(S=>{p(S),s()},[p,s]),x=_.useCallback(S=>{if(S.key==="Escape")S.preventDefault(),s();else if(S.key==="ArrowDown")S.preventDefault(),a(w=>Math.min(w+1,c.length-1));else if(S.key==="ArrowUp")S.preventDefault(),a(w=>Math.max(w-1,0));else if(S.key==="Enter"&&!S.nativeEvent.isComposing){S.preventDefault();const w=c[i];w&&g(w.id)}},[s,c,i,g]);return e?t.jsxs("div",{className:"fixed inset-0 z-90",role:"dialog","aria-modal":"true",children:[t.jsx("div",{className:"absolute inset-0 bg-black/20",onClick:s}),t.jsxs("div",{className:"absolute left-1/2 top-[18vh] w-[min(560px,calc(100vw-2rem))] -translate-x-1/2 bg-popover rounded-xl border border-border shadow-lg overflow-hidden animate-in fade-in zoom-in-95 duration-100",children:[t.jsxs("div",{className:"flex items-center gap-2.5 px-4 border-b border-border/60",children:[t.jsx(yn,{size:15,className:"text-muted-foreground/70 shrink-0"}),t.jsx("input",{value:v,onChange:S=>n(S.target.value),onKeyDown:x,placeholder:m("Search tasks..."),"aria-label":m("Search tasks..."),autoFocus:!0,className:"flex-1 py-3 bg-transparent border-none focus:outline-none text-sm text-foreground placeholder-muted-foreground/60"})]}),c.length>0?t.jsxs(t.Fragment,{children:[!v.trim()&&t.jsx("div",{className:"px-4 pt-2.5 pb-1 text-[11px] font-medium text-muted-foreground/70",children:m("Recent tasks")}),t.jsx("div",{ref:u,className:"max-h-[46vh] overflow-y-auto scrollbar-app-thin pb-1.5 pt-0.5",children:c.map((S,w)=>{const l=o.find(f=>f.id===S.projectId),{icon:h,iconClass:d}=tn[S.status];return t.jsxs("button",{onClick:()=>g(S.id),onMouseEnter:()=>a(w),className:`w-full flex items-center gap-2.5 px-4 py-2 text-left transition-colors
|
|
12
|
+
${w===i?"bg-accent":""}`,children:[t.jsx(h,{className:`${d} shrink-0`}),t.jsx("span",{className:"flex-1 min-w-0 truncate text-sm text-foreground/90",title:S.title,children:S.title}),l&&t.jsx("span",{className:"shrink-0 max-w-[120px] truncate text-xs text-muted-foreground/70",children:l.name})]},S.id)})})]}):t.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground/70",children:m("No matching tasks")})]})]}):null}const Nf=260,Rf=220;function Af(e){const s={[Se.Review]:[],[Se.Running]:[],[Se.Pending]:[],[Se.Done]:[],[Se.Cancelled]:[]};for(const r of e)s[r.status].push(r);return s}const Tf=[{status:Se.Review,title:"Review",defaultOpen:!0},{status:Se.Running,title:"Running",defaultOpen:!0},{status:Se.Pending,title:"Pending",defaultOpen:!1},{status:Se.Done,title:"Done",defaultOpen:!1},{status:Se.Cancelled,title:"Cancelled",defaultOpen:!1}];function jo({tasks:e=[],projects:s=[],selectedTaskId:r,onSelectTask:o,filterProjectId:p,setFilterProjectId:m,width:v=320,onCreateTask:n,onCreateProject:i,isCreateActive:a,onTaskStatusChange:u,onDeleteTask:c}){const{t:g}=le(),{preserveDesktopSearch:x}=ja(),S=Cl(),[w,l]=_.useState(null),[h,d]=_.useState(null),[f,y]=_.useState(!1),C=_.useRef(new Map),k=_.useRef(new Set),E=_.useRef(new Map),b=_.useMemo(()=>({registry:C.current}),[]),j=_.useCallback(M=>{M.remove(),k.current.delete(M)},[]),R=p?e.filter(M=>M.projectId===p):e,L=_.useCallback((M,O)=>{const $=document.querySelector(`[data-task-group-status="${M}"]`);if(!$)return null;const B=($.querySelector("button")??$).getBoundingClientRect();return B.width===0||B.height===0?null:new DOMRect(B.left+8,B.bottom+4,O.width,O.height)},[]),T=_.useCallback((M,O,$,U=!1)=>{const B=document.createElement("div");B.setAttribute("aria-hidden","true"),B.innerHTML=$;const z=B.firstElementChild;z&&(z.style.cssText="",z.className=z.className.replace(/\bopacity-\S*/g,"").replace(/\banimate-task-enter\b/g,""),z.style.pointerEvents="none",z.style.width=`${M.width}px`,z.style.height=`${M.height}px`,z.style.margin="0",z.style.backgroundColor="var(--sidebar-accent)",z.style.borderRadius="0.375rem",z.style.boxShadow="0 6px 16px rgba(15, 23, 42, 0.10), 0 1px 3px rgba(15, 23, 42, 0.08)",z.style.opacity="0.96",z.style.transition="none",z.setAttribute("tabindex","-1")),Object.assign(B.style,{position:"fixed",left:`${M.left}px`,top:`${M.top}px`,width:`${M.width}px`,height:`${M.height}px`,zIndex:"9999",pointerEvents:"none",overflow:"visible",transformOrigin:"top left",willChange:"transform, opacity"}),document.body.appendChild(B),k.current.add(B);const q=O.left-M.left,N=O.top-M.top;B.animate([{transform:"translate(0, 0)",opacity:.96,offset:0},{transform:`translate(${q}px, ${N}px)`,opacity:U?.12:.96,offset:1}],{duration:U?Rf:Nf,easing:"cubic-bezier(0.2, 0, 0, 1)",fill:"forwards"}).finished.then(()=>j(B),()=>j(B))},[j]);_.useLayoutEffect(()=>{const M=window.matchMedia("(prefers-reduced-motion: reduce)").matches,O=new Map;for(const $ of R){const U=C.current.get($.id);if(!U)continue;const B={status:$.status,rect:U.getBoundingClientRect(),html:U.outerHTML};if(O.set($.id,B),M)continue;const z=E.current.get($.id);if(!z||z.status===$.status)continue;const q=B.rect.left-z.rect.left,N=B.rect.top-z.rect.top;Math.abs(q)<1&&Math.abs(N)<1||T(z.rect,B.rect,z.html)}if(!M)for(const[$,U]of E.current){if(O.has($))continue;const B=R.find(q=>q.id===$);if(!B||B.status===U.status)continue;const z=L(B.status,U.rect);z&&T(U.rect,z,U.html,!0)}E.current=O},[R,T,L]),_.useEffect(()=>()=>{for(const M of k.current)M.remove();k.current.clear()},[]);const D=Uu($u(On,{activationConstraint:{distance:8}})),F=_.useCallback(M=>{const O=M.active.data.current?.task,$=M.active.data.current?.fromStatus;O&&l(O),$&&d($)},[]),I=_.useCallback(M=>{l(null),d(null);const{active:O,over:$}=M;if(!$)return;const U=O.data.current?.task,B=O.data.current?.fromStatus,z=$.data.current?.status;!U||!B||!z||U.projectArchivedAt||B!==z&&u?.(U.id,z)},[u]),A=!!!(p?s.find(M=>M.id===p)??null:null)?.archivedAt,P=Af(R);return t.jsxs("div",{className:"h-full flex flex-col flex-shrink-0",style:{width:v},children:[t.jsxs("div",{className:"px-2 pt-2 pb-1 flex-shrink-0",children:[i&&t.jsxs("button",{onClick:i,className:"w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-sm text-foreground/80 hover:bg-accent/50 transition-colors",title:g("New Project"),children:[t.jsx(Id,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:g("New Project")})]}),t.jsxs("button",{onClick:n,disabled:!A,className:`w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-sm transition-colors disabled:opacity-30 disabled:cursor-not-allowed
|
|
13
|
+
${a?"bg-accent text-foreground":"text-foreground/80 hover:bg-accent/50"}`,title:g(A?"New Task":"Deleted projects are read-only"),children:[t.jsx(Td,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:g("New Task")})]}),t.jsxs("button",{onClick:()=>y(!0),className:"w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-sm text-foreground/80 hover:bg-accent/50 transition-colors",title:g("Search"),children:[t.jsx(yn,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:g("Search")})]}),t.jsxs(nd,{to:x("/conversations"),className:"w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-sm text-foreground/80 hover:bg-accent/50 transition-colors",title:g("对话"),children:[t.jsx(ni,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:g("对话")})]})]}),R.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-6 text-center select-none",children:[t.jsx(Fs,{size:36,className:"text-muted-foreground/40 mb-3",strokeWidth:1.5}),t.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:g("No tasks")}),A&&n?t.jsx("button",{onClick:n,className:"px-3.5 py-1.5 rounded-md bg-brand text-brand-foreground text-xs font-medium hover:bg-brand/90 transition-colors",children:g("New Task")}):null]}):t.jsx(Rl.Provider,{value:b,children:t.jsxs(Wh,{sensors:D,onDragStart:F,onDragEnd:I,children:[t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin pt-3 pb-4 relative",children:Tf.map(({status:M,title:O,defaultOpen:$})=>t.jsx(Cf,{title:O,tasks:P[M],status:M,defaultOpen:$,selectedTaskId:r,onSelectTask:o,projects:s,isDragging:w!==null,dragFromStatus:h,onTaskStatusChange:u,onDeleteTask:c,disableDrag:S},M))}),t.jsx(lf,{dropAnimation:null,children:w?t.jsx("div",{className:"bg-popover shadow-lg rounded-md border border-border px-4 py-2 text-sm max-w-[280px] opacity-90",children:t.jsx("span",{className:"block truncate font-medium text-foreground/80",title:w.title,children:w.title})}):null})]})}),R.length>0?t.jsxs("div",{className:"px-4 py-3 border-t border-border/60 text-xs text-muted-foreground/70 flex items-center justify-between",children:[t.jsx("span",{children:g("{count} tasks",{count:R.length})}),p?t.jsx("button",{onClick:()=>m(null),className:"hover:text-foreground underline decoration-border underline-offset-2",children:g("Clear filter")}):null]}):t.jsx("div",{className:"px-4 py-3 border-t border-border/60 text-xs text-muted-foreground/70 flex items-center justify-between",children:t.jsx("span",{children:g("{count} tasks",{count:0})})}),t.jsx(jf,{isOpen:f,onClose:()=>y(!1),tasks:R,projects:s,onSelectTask:o})]})}const Mf=10,Df=24,Al=Mf*Df,Pf=8;function Lf(e,s=Al){return e>s+Pf}function If(e,s){return e.includes(s)?e:[...e,s]}function Of(e,s){return e.filter(r=>r!==s)}function Bf(e,s){const r=new Map(s.map(o=>[o.id,o]));return e.map(o=>r.get(o)).filter(o=>!!o).map(o=>({memberId:o.id,label:o.name}))}const mi=new Set(["RUNNING","WAITING_ROOM_REPLY","QUEUED","SESSION_ENDED"]);function No(e){if(!e)return 0;const s=Date.parse(e);return Number.isNaN(s)?0:s}function Ff(e,s=[],r=[]){const o=new Set(r.filter(m=>mi.has(m.status)).map(m=>m.workRequestId));return[...e.map(m=>({kind:"message",key:`message:${m.id}`,sortTime:m.createdAt,order:0,message:m})),...s.filter(m=>m.status==="PENDING_APPROVAL").filter(m=>!o.has(m.id)).map(m=>({kind:"pendingApproval",key:`pending-approval:${m.id}`,sortTime:m.updatedAt??m.createdAt,order:1,request:m}))].sort((m,v)=>{const n=No(m.sortTime)-No(v.sortTime);return n!==0?n:m.order!==v.order?m.order-v.order:m.key.localeCompare(v.key)})}function zf(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 Wf(e){switch(e){case"FAILED":return"text-red-500";case"RUNNING":case"WAITING_ROOM_REPLY":case"QUEUED":case"SESSION_ENDED":return"text-neutral-500";default:return"text-neutral-500"}}function Hf(e,s){const r=e.reduce((p,m)=>(p[m.status]=(p[m.status]??0)+1,p),{});return[["RUNNING","running"],["QUEUED","queued"],["WAITING_ROOM_REPLY","waiting"],["SESSION_ENDED","ended"]].map(([p,m])=>{const v=r[p];return v?`${v} ${s(m)}`:null}).filter(p=>!!p).join(" · ")}function $f(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(min-width: 768px)").matches}function Uf({status:e}){const{t:s}=le();return e==="RUNNING"?t.jsxs(t.Fragment,{children:[s("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:s(zf(e))})}function qf({invocations:e,memberById:s,workRequestById:r,onViewInvocationSession:o,onStopMember:p,isStopPending:m,stoppingMemberId:v,stopPromptInvocationId:n,onToggleStopConfirm:i}){const{t:a}=le(),[u,c]=_.useState($f),g=_.useMemo(()=>e.filter(S=>mi.has(S.status)).sort((S,w)=>Date.parse(w.updatedAt??w.createdAt??"")-Date.parse(S.updatedAt??S.createdAt??"")),[e]);if(g.length===0)return null;const x=Hf(g,a);return t.jsxs("div",{className:"border-t border-neutral-200 bg-neutral-50/80",children:[t.jsxs("button",{type:"button",onClick:()=>c(S=>!S),"aria-expanded":u,className:"flex h-8 w-full items-center justify-between gap-3 px-3 text-left text-xs text-neutral-600 transition-colors hover:bg-neutral-100",children:[t.jsxs("span",{className:"min-w-0 truncate",children:[t.jsx("span",{className:"font-medium text-neutral-800",children:a("Active work")}),t.jsx("span",{className:"mx-1.5 text-neutral-300",children:"·"}),t.jsx("span",{children:x})]}),u?t.jsx(wt,{size:15,className:"shrink-0 text-neutral-400"}):t.jsx(Ja,{size:15,className:"shrink-0 text-neutral-400"})]}),u&&t.jsx("div",{className:"max-h-32 overflow-y-auto border-t border-neutral-200",children:g.map(S=>{const w=s.get(S.memberId),l=r.get(S.workRequestId),h=!!(S.sessionId&&o),d=!!w,f=n===S.id,y=m&&v===S.memberId,C=l?.instruction??S.workRequestId;return t.jsxs("div",{className:"border-t border-neutral-100 first:border-t-0",children:[t.jsxs("div",{title:C,className:se("group flex h-8 items-center gap-2 px-3 text-xs text-neutral-700",h?"cursor-pointer hover:bg-white":"cursor-default"),role:h?"button":void 0,tabIndex:h?0:void 0,onClick:()=>S.sessionId&&o?.(S.sessionId),onKeyDown:k=>{!h||!S.sessionId||(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),o?.(S.sessionId))},children:[t.jsx(Ht,{name:w?.name??a("Agent"),avatar:w?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[t.jsx("span",{className:"truncate font-medium text-neutral-800",children:w?.name??a("Agent")}),t.jsx("span",{className:se("shrink-0",Wf(S.status)),children:t.jsx(Uf,{status:S.status})})]}),h&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),S.sessionId&&o?.(S.sessionId)},onKeyDown:k=>k.stopPropagation(),className:"hidden shrink-0 rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700 group-hover:inline-flex",title:a("View log"),"aria-label":`${a("View log")} ${w?.name??a("Agent")}`,children:t.jsx(Qi,{size:13})}),d&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),i(S.id)},onKeyDown:k=>k.stopPropagation(),disabled:y,className:"shrink-0 rounded-md p-1 text-neutral-400 transition-colors hover:bg-red-50 hover:text-red-700 disabled:cursor-not-allowed disabled:opacity-50",title:a("Stop"),"aria-label":`${a("Stop")} ${w?.name??a("Agent")}`,children:t.jsx(Bs,{size:12})})]}),d&&f&&w&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 border-t border-neutral-100 bg-white px-3 py-2",children:[t.jsx("span",{className:"mr-1 text-[11px] text-neutral-600",children:a("Stop running work?")}),t.jsxs(Pe,{type:"button",size:"xs",variant:"outline",disabled:y,onClick:()=>p(w.id,!1),children:[t.jsx(Bs,{size:11}),t.jsx("span",{children:a(y?"Stopping":"Stop only")})]}),t.jsxs(Pe,{type:"button",size:"xs",variant:"outline",disabled:y,className:"border-red-200 bg-red-50 text-red-700 hover:bg-red-100 hover:text-red-800",onClick:()=>p(w.id,!0),children:[t.jsx(tl,{size:11}),t.jsx("span",{children:a(y?"Stopping":"Stop + clear queue")})]})]})]},S.id)})})]})}const sn=vr(),Kf=240;let Ro=0;function Vf(e,s){return Ro+=1,{id:`pending-room-message-${Date.now()}-${Ro}`,teamRunId:e,senderType:s.senderType??"user",senderId:s.senderId??null,senderInvocationId:s.senderInvocationId??null,kind:s.kind??((s.mentions?.length??0)>0?"work_request":"chat"),visibility:"PUBLIC",content:s.content,mentions:s.mentions??[],workRequestIds:[],artifactRefs:s.artifactRefs??[],attachmentIds:s.attachmentIds??[],createdAt:new Date().toISOString(),pendingStatus:"sending"}}function Tl(e){return"pendingStatus"in e}function Xf(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function Yf(e){return`${e.mimeType.startsWith("image/")?"!":""}[${e.originalName}](${e.storagePath})`}function rn(e,s){if(s.length===0)return e;const r=new Set(s.map(Yf));return e.split(`
|
|
14
|
+
`).map(o=>{const p=o.match(/^\s*/)?.[0]??"",m=o.trimStart();for(const v of r){if(m===v)return null;if(m.startsWith(`${v} `)||m.startsWith(`${v} `))return`${p}${m.slice(v.length).trimStart()}`}return o}).filter(o=>o!=null).join(`
|
|
15
|
+
`).replace(/\n{3,}/g,`
|
|
16
|
+
|
|
17
|
+
`).trim()}function Gf(e){if(!e)return"";const s=new Date(e);return Number.isNaN(s.getTime())?"":s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function nn(e,s){return e instanceof Error?e.message:s}function Qf(e,s=Kf){const r=(e??"").replace(/\s+/g," ").trim();return r.length<=s?r:`${r.slice(0,s-3).trimEnd()}...`}function Zf(e,s){const o=e.slice(0,s).match(/(^|\s)@([^\s@]*)$/);return!o||o.index==null?null:{start:o.index+o[1].length,end:s,query:o[2]??""}}function Jf(e,s){const r=s.trim().toLowerCase();return r?[e.name,e.providerId,...e.aliases??[]].some(p=>p.toLowerCase().includes(r)):!0}function Ao(e){return e.membershipStatus!=="REMOVED"}function em(e,s){return e.label??s.get(e.memberId)?.name??e.memberId}function tm(e,s){return(e.recipientMemberIds??[]).map(r=>s.get(r)?.name??r)}function sm(e,s){const r=e.mentions??[],o=e.contentPreview??e.content;if(r.length===0)return o;const p=r.map(v=>em(v,s)).filter(v=>v&&!o.includes(`@${v}`));if(p.length===0)return o;const m=p.map(v=>`@${v}`).join(" ");return o.trimEnd()?`${o.trimEnd()} ${m}`:m}function rm(e,s,r){if(e.senderType!=="agent")return null;if(e.senderId&&s.has(e.senderId))return s.get(e.senderId)??null;if(e.senderInvocationId){const o=r.get(e.senderInvocationId);if(o?.memberId&&s.has(o.memberId))return s.get(o.memberId)??null}return null}function im({content:e,isUser:s,workingDir:r,onOpenWorkspaceFile:o,onOpenPreviewUrl:p,onOpenVisualization:m,downloadSessionId:v}){const n=_.useMemo(()=>m||v?wd(e):e,[e,v,m]),i=Cd(n),a=_.useMemo(()=>kd({workingDir:r,onOpenWorkspaceFile:o,onOpenPreviewUrl:p,onOpenVisualization:m,downloadSessionId:v}),[v,p,m,o,r]);return t.jsx("div",{className:se("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-neutral-400","prose-blockquote:my-2 prose-blockquote:border-l-2 prose-blockquote:border-neutral-300 prose-blockquote:pl-3 prose-blockquote:text-neutral-600","prose-pre:my-3 prose-pre:max-w-full prose-pre:overflow-x-auto prose-pre:rounded-md prose-pre:border prose-pre:border-neutral-800 prose-pre:bg-neutral-950 prose-pre:p-3 prose-pre:text-xs prose-pre:leading-relaxed prose-pre:shadow-inner","prose-code:break-words prose-code:rounded prose-code:bg-neutral-100 prose-code:px-1 prose-code:py-0.5 prose-code:text-[0.9em] prose-code:font-medium prose-code:text-neutral-800","prose-pre:prose-code:bg-transparent prose-pre:prose-code:p-0 prose-pre:prose-code:text-neutral-100","prose-headings:mb-2 prose-headings:mt-3 prose-headings:font-semibold prose-headings:leading-snug","prose-a:text-blue-600 prose-a:underline-offset-2 hover:prose-a:text-blue-700","prose-hr:my-3 prose-hr:border-neutral-200",s?["text-white prose-strong:text-white prose-headings:text-white prose-blockquote:border-white/30 prose-blockquote:text-neutral-200","prose-code:bg-white/15 prose-code:text-white prose-pre:border-neutral-700 prose-a:text-blue-200 hover:prose-a:text-blue-100 prose-hr:border-white/15"]:"text-neutral-800 prose-strong:text-neutral-900"),children:t.jsx(bn,{components:a,plugins:i,controls:i?Ed:void 0,children:n})})}function nm({hasAttachmentIds:e,attachments:s,isLoading:r,onOpenImage:o}){if(!e)return null;if(r&&s.length===0)return t.jsx("div",{className:"mt-3 text-xs text-neutral-400",children:"Loading attachments..."});if(s.length===0)return null;const p=s.filter(v=>v.mimeType.startsWith("image/")),m=new Map(p.map((v,n)=>[v.id,n]));return t.jsx("div",{className:"mt-3 flex flex-wrap gap-2 text-neutral-700",children:s.map(v=>{const n=`${sn}${v.url}`;if(v.mimeType.startsWith("image/")){const a=m.get(v.id)??0;return t.jsxs("button",{type:"button",onClick:()=>o(p,a),className:"group relative h-24 w-24 overflow-hidden rounded-lg border border-neutral-200 bg-neutral-50 shadow-sm transition-opacity hover:opacity-90",title:v.originalName,children:[t.jsx("img",{src:n,alt:v.originalName,className:"h-full w-full object-cover",loading:"lazy"}),t.jsx("span",{className:"absolute inset-x-0 bottom-0 truncate bg-black/55 px-1.5 py-1 text-left text-[10px] text-white",children:v.originalName})]},v.id)}return t.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"flex max-w-[220px] items-center gap-2 rounded-lg border border-neutral-200 bg-white px-3 py-2 text-xs text-neutral-700 shadow-sm hover:bg-neutral-50",title:v.originalName,children:[t.jsx(La,{size:16,className:"shrink-0 text-neutral-400","aria-hidden":!0}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate font-medium",children:v.originalName}),t.jsx("span",{className:"text-neutral-400",children:Xf(v.sizeBytes)})]}),t.jsx(mn,{size:13,className:"shrink-0 text-neutral-400","aria-hidden":!0})]},v.id)})})}function om({message:e,content:s,attachmentIds:r,isUser:o,tone:p,onOpenImage:m,workingDir:v,onOpenWorkspaceFile:n,onOpenPreviewUrl:i,onOpenVisualization:a,downloadSessionId:u}){const c=_.useMemo(()=>Array.from(new Set(r??[])),[r]),{data:g=[],isLoading:x}=Sd(c),S=g.length>0?rn(s,g):s;return t.jsxs(t.Fragment,{children:[S.trim()&&t.jsx(cm,{message:e,content:S,attachments:g,isUser:o,tone:p,workingDir:v,onOpenWorkspaceFile:n,onOpenPreviewUrl:i,onOpenVisualization:a,downloadSessionId:u}),t.jsx(nm,{hasAttachmentIds:c.length>0,attachments:g,isLoading:x,onOpenImage:m})]})}function am({images:e,index:s,onClose:r,onSelect:o}){const p=e[s];if(!p)return null;const m=s>0,v=s<e.length-1;return t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 p-4",role:"dialog","aria-modal":"true",children:[t.jsx("button",{type:"button",onClick:r,className:"absolute right-4 top-4 rounded-full bg-white/10 p-2 text-white transition-colors hover:bg-white/20","aria-label":"Close image preview",children:t.jsx(Zt,{size:20})}),m&&t.jsx("button",{type:"button",onClick:()=>o(s-1),className:"absolute left-4 top-1/2 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20","aria-label":"Previous image",children:t.jsx(Xd,{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:`${sn}${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-white",children:[t.jsx("span",{className:"max-w-[70vw] truncate",children:p.originalName}),t.jsxs("a",{href:`${sn}${p.url}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-md bg-white/10 px-2 py-1 text-xs hover:bg-white/20",children:[t.jsx(mn,{size:13,"aria-hidden":!0}),"Open"]})]})]}),v&&t.jsx("button",{type:"button",onClick:()=>o(s+1),className:"absolute right-4 top-1/2 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20","aria-label":"Next image",children:t.jsx(Mt,{size:24,"aria-hidden":!0})})]})}function lm({draft:e,attachmentMarkdown:s,attachmentIds:r,mentions:o}){const m=[e.trim(),s].filter(Boolean).join(`
|
|
18
|
+
|
|
19
|
+
`);return m?{content:m,mentions:o,senderType:"user",...r.length>0?{attachmentIds:r}:{}}:null}function cm({message:e,content:s,attachments:r,isUser:o,tone:p=o?"user":"agent",workingDir:m,onOpenWorkspaceFile:v,onOpenPreviewUrl:n,onOpenVisualization:i,downloadSessionId:a}){const{t:u}=le(),c=_.useId(),g=_.useRef(null),[x,S]=_.useState(null),[w,l]=_.useState(!1),[h,d]=_.useState(null),f=ad(e.teamRunId,e.id,!1),y=f.data?.content,C=y?rn(y,r):void 0,E=!!(C&&C!==s)?C:s,b=!!(e.isTruncated&&!Tl(e)),j=x?.messageId===e.id&&x.content===E&&x.expanded,R=_.useCallback(()=>{const I=g.current;I&&l(Lf(I.scrollHeight))},[]);_.useLayoutEffect(()=>{R();const I=g.current;if(!I)return;const H=window.requestAnimationFrame(R),K=typeof ResizeObserver>"u"?null:new ResizeObserver(R);return K?.observe(I),window.addEventListener("resize",R),()=>{window.cancelAnimationFrame(H),K?.disconnect(),window.removeEventListener("resize",R)}},[E,R]);const L=_.useCallback(async()=>{if(d(null),j){S({messageId:e.id,content:E,expanded:!1});return}if(b&&!y){const I=await f.refetch();if(I.error){d(nn(I.error,u("Failed to load full message")));return}const H=I.data?.content?rn(I.data.content,r):E;S({messageId:e.id,content:H,expanded:!0});return}S({messageId:e.id,content:E,expanded:!0})},[r,b,y,f,j,e.id,E,u]),T=(w||b)&&!j,D=w||b,F=f.isFetching;return t.jsxs("div",{className:"relative",children:[t.jsxs("div",{id:c,ref:g,onLoadCapture:R,className:se("relative transition-[max-height] duration-200 ease-out",T?"overflow-hidden":""),style:T?{maxHeight:Al}:void 0,children:[t.jsx(im,{content:E,isUser:o,workingDir:m,onOpenWorkspaceFile:v,onOpenPreviewUrl:n,onOpenVisualization:i,downloadSessionId:a}),T&&t.jsx("div",{className:se("pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-gradient-to-b from-transparent",p==="system"?"to-amber-50":p==="user"?"to-neutral-900":"to-neutral-100")})]}),D&&t.jsxs("button",{type:"button","aria-expanded":j,"aria-controls":c,"aria-label":u(j?"Collapse message":"Expand full message"),disabled:F,onClick:()=>{L()},className:se("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-neutral-300",p==="system"?"bg-amber-100 text-amber-800 hover:bg-amber-200":p==="user"?"bg-white/10 text-neutral-100 hover:bg-white/15 hover:text-white":"bg-neutral-100 text-neutral-600 hover:bg-neutral-200 hover:text-neutral-900",F?"cursor-wait opacity-70":""),children:[j?t.jsx(Ja,{size:13}):t.jsx(wt,{size:13}),t.jsx("span",{children:u(F?"Loading":j?"Collapse message":"Expand full message")})]}),h&&t.jsx("div",{className:se("mt-1 text-xs",p==="user"?"text-red-200":"text-red-600"),children:h})]})}function Ml({senderName:e,avatar:s,createdAt:r,isUser:o,isSystem:p,children:m,headerAddon:v,bubbleClassName:n,isPending:i}){return p?t.jsx("div",{className:"flex justify-center",children:t.jsx("div",{className:"max-w-[min(100%,42rem)] rounded-lg border border-amber-200/80 bg-amber-50 px-3 py-2 text-xs text-amber-900 shadow-sm",children:m})}):t.jsxs("div",{className:se("group flex items-start gap-3",o?"justify-end pl-8 sm:pl-14":"justify-start pr-8 sm:pr-14"),children:[!o&&t.jsx(Ht,{name:e,avatar:s??null,className:"mt-0.5 h-8 w-8 text-[11px]"}),t.jsxs("div",{className:se("flex min-w-0 max-w-[min(86%,46rem)] flex-col",o?"items-end":"items-start"),children:[t.jsxs("div",{className:se("mb-1.5 flex max-w-full items-center gap-1.5 px-0.5 text-[11px] text-neutral-500",o?"justify-end":"justify-start"),children:[t.jsx("span",{className:"truncate font-semibold text-neutral-700",children:e}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-neutral-300","aria-hidden":!0}),t.jsx(os,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"shrink-0",children:Gf(r)}),v]}),t.jsx("div",{className:se("max-w-full rounded-lg px-3.5 py-3 text-sm leading-6 transition-colors",o?"rounded-tr-[2px] border border-neutral-900 bg-neutral-900 text-white shadow-sm":"rounded-tl-[2px] bg-neutral-100 text-neutral-900 shadow-sm",n,i?"opacity-70":""),children:m})]}),o&&t.jsx(Ht,{name:e,avatar:null,className:"mt-0.5 h-8 w-8 border-neutral-300 bg-neutral-900 text-white text-[11px]"})]})}function dm({provider:e}){return t.jsxs("span",{className:"ml-0.5 inline-flex max-w-[10rem] shrink items-center gap-1 rounded-full bg-neutral-900/5 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-500",children:[t.jsx(oi,{agentType:e.agentType,className:"size-2.5"}),t.jsx("span",{className:"truncate",children:e.name})]})}function um({message:e,senderName:s,senderMember:r,senderProvider:o,memberById:p,displayContent:m,onOpenImage:v,workingDir:n,onOpenWorkspaceFile:i,onOpenPreviewUrl:a,onOpenVisualization:u,previewWorkspaceId:c,previewSessionId:g}){const{t:x}=le(),S=e.senderType==="user",w=e.senderType==="system",l=Tl(e)?e.pendingStatus:null,h=e.mentions??[],d=e.workRequestIds?.length??0,f=e.visibility==="PRIVATE",y=_.useCallback(b=>{a?.(b,c)},[a,c]),C=_.useCallback(b=>{g&&u?.(g,b,c)},[u,g,c]),k=f?tm(e,p):[],E=t.jsxs(t.Fragment,{children:[!S&&!w&&o&&t.jsx(dm,{provider:o}),f&&t.jsxs("span",{className:"ml-0.5 inline-flex max-w-[18rem] shrink items-center gap-1 rounded-full bg-sky-50 px-1.5 py-0.5 text-[10px] font-medium leading-none text-sky-700",title:k.join(", "),children:[t.jsx(od,{size:10}),t.jsxs("span",{className:"truncate",children:[x("Private"),k.length>0?`: ${k.join(", ")}`:""]})]}),!w&&d>0&&h.length===0&&t.jsxs("span",{className:"ml-0.5 shrink-0 rounded-full bg-neutral-900/8 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-600",children:[x("Work requests"),": ",d]}),l==="sending"&&t.jsx("span",{className:"ml-0.5 shrink-0 rounded-full bg-neutral-900/8 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-500",children:x("发送中...")}),l==="failed"&&t.jsx("span",{className:"ml-0.5 shrink-0 rounded-full bg-red-50 px-1.5 py-0.5 text-[10px] font-medium leading-none text-red-600",children:x("发送失败")})]});return t.jsx(Ml,{senderName:s,avatar:r?.avatar??null,createdAt:e.createdAt,isUser:S,isSystem:w,headerAddon:E,bubbleClassName:S&&l==="failed"?"border-red-200 bg-red-50 text-red-900":void 0,isPending:l==="sending",children:t.jsx(om,{message:e,content:m,attachmentIds:e.attachmentIds,isUser:S&&l!=="failed",tone:w?"system":void 0,onOpenImage:v,workingDir:n,onOpenWorkspaceFile:i,onOpenPreviewUrl:a?y:void 0,onOpenVisualization:u&&g?C:void 0,downloadSessionId:g})})}function hm({request:e,member:s,onApprove:r,onReject:o,isActionPending:p,isApprovePending:m,isRejectPending:v}){const{t:n}=le();return t.jsx(Ml,{senderName:s?.name??n("Agent"),avatar:s?.avatar??null,createdAt:e.createdAt,bubbleClassName:"border border-amber-200/80 bg-amber-50/80",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-amber-200 bg-amber-50 px-2 py-0.5 text-[11px] font-medium text-amber-700",children:[t.jsx(os,{size:11}),n("Pending approval")]}),t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[n("Requester"),": ",n(e.requesterType==="user"?"User":e.requesterType==="system"?"System":"Agent")]})]}),t.jsx("div",{className:"text-sm leading-6 text-neutral-800 [overflow-wrap:anywhere]",children:e.instructionPreview??Qf(e.instruction)}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs(Pe,{type:"button",size:"xs",variant:"outline",disabled:p,className:"border-emerald-200 bg-emerald-50 text-emerald-700 hover:bg-emerald-100 hover:text-emerald-800",onClick:r,children:[t.jsx(Jt,{size:12}),t.jsx("span",{children:n(m?"Approving":"Approve")})]}),t.jsxs(Pe,{type:"button",size:"xs",variant:"outline",disabled:p,onClick:o,children:[t.jsx(Zt,{size:12}),t.jsx("span",{children:n(v?"Rejecting":"Reject")})]})]})]})})}function Dl({teamRun:e,messages:s,readOnly:r,readOnlyMessage:o,onSendMessage:p,onViewInvocationSession:m,changeSummaryBar:v,compactComposer:n,centered:i,workingDir:a,onOpenWorkspaceFile:u,onOpenPreviewUrl:c,onOpenVisualization:g}){const{t:x}=le(),S=Na(e.id),w=Ra(e.id),l=Aa(e.id),[h,d]=_.useState(""),[f,y]=_.useState(!1),[C,k]=_.useState(null),[E,b]=_.useState(0),[j,R]=_.useState([]),[L,T]=_.useState(!1),[D,F]=_.useState(null),[I,H]=_.useState([]),[K,A]=_.useState(null),P=_.useRef(null),M=_.useRef(null),{files:O,addFiles:$,removeFile:U,clear:B,restoreFiles:z,buildMarkdownLinks:q,getDoneAttachments:N,isUploading:W}=vn(),X=O.some(Y=>Y.status==="done"&&Y.attachment),[V,ie]=_.useState(null),{scrollRef:ee,contentRef:pe,isAtBottom:he,scrollToBottom:G}=Sn({resize:"smooth",initial:"instant"}),{data:ge}=Us(),ne=_.useMemo(()=>{const Y=new Map;for(const te of ge??[])Y.set(te.provider.id,te.provider);return Y},[ge]),Re=_.useMemo(()=>new Map((e.members??[]).map(Y=>[Y.id,Y])),[e.members]),Ze=_.useMemo(()=>(e.members??[]).filter(Ao),[e.members]),Xe=_.useMemo(()=>new Map((e.invocations??[]).map(Y=>[Y.id,Y])),[e.invocations]),ye=_.useMemo(()=>{const Y=new Set(s.map(oe=>oe.id)),te=I.filter(oe=>!Y.has(oe.id));return[...s,...te].sort((oe,ve)=>{const xe=Date.parse(oe.createdAt??""),Me=Date.parse(ve.createdAt??"");return(Number.isNaN(xe)?0:xe)-(Number.isNaN(Me)?0:Me)})},[s,I]),He=_.useMemo(()=>new Map((e.workRequests??[]).map(Y=>[Y.id,Y])),[e.workRequests]),Ie=_.useMemo(()=>Ff(ye,e.workRequests??[],e.invocations??[]),[ye,e.invocations,e.workRequests]),tt=_.useMemo(()=>(e.invocations??[]).filter(Y=>mi.has(Y.status)),[e.invocations]),Ke=_.useMemo(()=>j.map(Y=>Re.get(Y)).filter(Y=>!!Y).filter(Ao),[Re,j]),Be=_.useMemo(()=>{const Y=C?.query??"";return Ze.filter(te=>Jf(te,Y)).sort((te,oe)=>{const ve=j.includes(te.id),xe=j.includes(oe.id);return ve!==xe?ve?1:-1:te.name.localeCompare(oe.name)})},[Ze,C?.query,j]),Je=!r&&(f||!!C)&&Be.length>0,Te=_.useCallback((Y,te)=>{if(te==null){k(null);return}k(Zf(Y,te)),b(0)},[]),je=_.useCallback(Y=>{R(Me=>If(Me,Y.id));const te=`@${Y.name} `;if(C){const Me=`${h.slice(0,C.start)}${te}${h.slice(C.end)}`,we=C.start+te.length;d(Me),k(null),y(!1),requestAnimationFrame(()=>{P.current?.focus(),P.current?.setSelectionRange(we,we)});return}const oe=h.length===0||/\s$/.test(h)?"":" ",ve=`${h}${oe}${te}`,xe=ve.length;d(ve),y(!1),requestAnimationFrame(()=>{P.current?.focus(),P.current?.setSelectionRange(xe,xe)})},[h,C]),_e=_.useCallback(Y=>{R(te=>Of(te,Y))},[]),$e=_.useCallback(Y=>{const te=Y.target.value;d(te),F(null);const oe=Y.target;oe.style.height="auto",oe.style.height=`${Math.max(n?40:72,Math.min(oe.scrollHeight,n?140:240))}px`,y(!1),Te(te,oe.selectionStart)},[n,Te]),be=_.useCallback(Y=>{const te=Y.target.files;te&&te.length>0&&($(Array.from(te)),F(null)),Y.target.value=""},[$]),pt=_.useCallback(Y=>{const te=[];for(const oe of Y.clipboardData.items)if(oe.kind==="file"){const ve=oe.getAsFile();ve&&te.push(ve)}te.length>0&&(Y.preventDefault(),$(te),F(null))},[$]),Ye=_.useCallback(async()=>{if(r||L||W)return;const Y=q(),te=N().map(ke=>ke.id),oe=Bf(j,Ze),ve=lm({draft:h,attachmentMarkdown:Y,attachmentIds:te,mentions:oe});if(!ve||!h.trim()&&!X)return;const xe=Vf(e.id,ve),Me=h,we=j,Le=O;H(ke=>[...ke,xe]),d(""),R([]),y(!1),k(null),B(),P.current&&(P.current.style.height=n?"40px":"72px"),requestAnimationFrame(()=>G()),T(!0),F(null);try{const ke=await p(ve);H(me=>me.filter(De=>De.id!==xe.id)),ke&&typeof ke=="object"&&"id"in ke&&requestAnimationFrame(()=>G())}catch(ke){const me=ke instanceof Error?ke.message:"Failed to send room message";H(De=>De.map(Ae=>Ae.id===xe.id?{...Ae,pendingStatus:"failed",error:me}:Ae)),d(De=>De.length===0?Me:De),R(De=>De.length===0?we:De),z(Le),F(me),requestAnimationFrame(()=>G())}finally{T(!1)}},[Ze,O,q,B,n,h,N,X,L,W,p,r,z,G,j,e.id]),Dt=_.useCallback(Y=>{const te=Y.nativeEvent.isComposing||Y.nativeEvent.keyCode===229;if(Je){if(Y.key==="ArrowDown"){Y.preventDefault(),b(oe=>(oe+1)%Be.length);return}if(Y.key==="ArrowUp"){Y.preventDefault(),b(oe=>(oe-1+Be.length)%Be.length);return}if(Y.key==="Enter"&&!te||Y.key==="Tab"){Y.preventDefault();const oe=Be[E]??Be[0];oe&&je(oe);return}if(Y.key==="Escape"){Y.preventDefault(),k(null),y(!1);return}}Y.key==="Enter"&&!Y.shiftKey&&!Y.repeat&&!te&&(Y.preventDefault(),Ye())},[je,Ye,E,Be,Je]);_.useEffect(()=>{d(""),R([]),y(!1),k(null),F(null),H([]),B(),A(null),P.current&&(P.current.style.height=n?"40px":"72px")},[B,n,e.id]);const J=S.isError?S.error:w.isError?w.error:null,fe=S.isPending||w.isPending,ue=_.useCallback((Y,te)=>{l.mutate({memberId:Y,cancelQueued:te},{onSuccess:()=>A(null)})},[l]);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[V&&t.jsx(am,{images:V.images,index:V.index,onClose:()=>ie(null),onSelect:Y=>ie(te=>te&&{...te,index:Y})}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:ee,className:se("h-full overflow-y-auto scrollbar-app-thin bg-white",n?"px-3 py-3":"px-4 py-4"),children:t.jsxs("div",{ref:pe,className:se(n?"space-y-2.5":"space-y-3",i&&"max-w-4xl mx-auto"),children:[Ie.length===0?t.jsxs("div",{className:"flex min-h-[180px] flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-neutral-200 bg-white text-neutral-500",children:[t.jsx(Ss,{size:24,className:"text-neutral-400"}),t.jsx("span",{className:"text-sm",children:x("No room messages yet")})]}):Ie.map(Y=>{if(Y.kind==="pendingApproval"){const me=Y.request,De=Re.get(me.targetMemberId),Ae=S.isPending&&S.variables===me.id,Qe=w.isPending&&w.variables===me.id;return t.jsx(hm,{request:me,member:De,onApprove:()=>S.mutate(me.id),onReject:()=>w.mutate(me.id),isActionPending:fe,isApprovePending:Ae,isRejectPending:Qe},Y.key)}const te=Y.message,oe=rm(te,Re,Xe),ve=te.senderType==="user"?x("你"):te.senderType==="system"?x("System"):oe?.name??x("Agent"),xe=sm(te,Re),Me=oe?.providerId?ne.get(oe.providerId)??null:null,we=te.senderInvocationId?Xe.get(te.senderInvocationId):void 0,Le=we?.workspaceId??void 0,ke=we?.sessionId??void 0;return t.jsx(um,{message:te,senderName:ve,senderMember:oe,senderProvider:Me,memberById:Re,displayContent:xe,onOpenImage:(me,De)=>ie({images:me,index:De}),workingDir:a,onOpenWorkspaceFile:u,onOpenPreviewUrl:c,onOpenVisualization:g,previewWorkspaceId:Le,previewSessionId:ke},Y.key)}),J&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:nn(J,x("Failed to update work request"))}),l.isError&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:nn(l.error,x("Failed to stop member work"))})]})}),!he&&t.jsxs("button",{type:"button",onClick:()=>G(),className:"absolute bottom-3 left-1/2 z-10 flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-neutral-200 bg-white/90 px-3 py-1.5 text-xs text-neutral-600 shadow-md backdrop-blur-sm hover:bg-white hover:text-neutral-900 transition-colors",children:[t.jsx(hr,{size:14}),t.jsx("span",{children:x("Back to bottom")})]})]}),t.jsx("div",{className:se("shrink-0 border-t border-transparent bg-white",n?"px-3 pb-2 pt-1.5":"px-6 pb-6 pt-2"),children:t.jsxs("div",{className:se(i&&"max-w-4xl mx-auto"),children:[t.jsx(qf,{invocations:tt,memberById:Re,workRequestById:He,onViewInvocationSession:m,onStopMember:ue,isStopPending:l.isPending,stoppingMemberId:l.variables?.memberId??null,stopPromptInvocationId:K,onToggleStopConfirm:Y=>A(te=>te===Y?null:Y)}),!r&&v,r?t.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-4 py-3 text-sm text-neutral-500",children:o??x("This project is read-only")}):t.jsxs("div",{className:"relative rounded-xl border border-neutral-200 bg-white shadow-sm transition-all duration-200 hover:shadow-md focus-within:border-neutral-300 focus-within:shadow-md",children:[Je&&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-neutral-200 bg-white shadow-xl",children:[t.jsx("div",{className:"border-b border-neutral-100 px-3 py-2 text-xs font-medium text-neutral-500",children:x(C?"Mention members":"Team members")}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:Be.map((Y,te)=>{const oe=j.includes(Y.id),ve=te===E;return t.jsxs("button",{type:"button",onMouseEnter:()=>b(te),onMouseDown:xe=>{xe.preventDefault(),je(Y)},className:se("flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors",ve?"bg-neutral-100":"hover:bg-neutral-50"),children:[t.jsx(Ht,{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-neutral-900",children:Y.name}),oe&&t.jsx("span",{className:"rounded-full bg-neutral-900 px-1.5 py-0.5 text-[10px] font-medium text-white",children:x("selected")})]}),t.jsx("div",{className:"truncate text-xs text-neutral-500",children:[Y.providerId,Y.id.slice(0,8)].filter(Boolean).join(" · ")})]}),t.jsx(ao,{size:15,className:"text-neutral-400"})]},Y.id)})})]}),Ke.length>0&&t.jsx("div",{className:"flex flex-wrap items-center gap-1.5 border-b border-neutral-100 px-3 py-2",children:Ke.map(Y=>t.jsxs("span",{className:"inline-flex max-w-full items-center gap-1.5 rounded-full border border-neutral-200 bg-neutral-50 px-2 py-1 text-xs text-neutral-700",children:[t.jsxs("span",{className:"truncate font-medium",children:["@",Y.name]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:Y.id.slice(0,8)}),t.jsx("button",{type:"button",onClick:()=>_e(Y.id),className:"shrink-0 rounded-full p-0.5 text-neutral-400 transition-colors hover:bg-neutral-200 hover:text-neutral-700",title:x("Remove mention"),"aria-label":`${x("Remove mention")} ${Y.name}`,children:t.jsx(Zt,{size:12})})]},Y.id))}),t.jsx(xn,{files:O,onRemove:U}),t.jsx("textarea",{ref:P,value:h,rows:n?1:void 0,onChange:$e,onKeyDown:Dt,onPaste:pt,onClick:Y=>Te(h,Y.currentTarget.selectionStart),onSelect:Y=>Te(h,Y.currentTarget.selectionStart),placeholder:x("Message the team room..."),className:se("w-full resize-none border-none bg-transparent text-neutral-900 placeholder-neutral-400 focus:outline-none",n?"px-3 pb-1 pt-2.5 text-[15px] leading-5":"px-4 pb-2 pt-4 text-sm leading-relaxed"),style:n?{minHeight:40,maxHeight:140}:{minHeight:60,maxHeight:220}}),t.jsxs("div",{className:se("flex items-center justify-between",n?"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:M,type:"file",multiple:!0,className:"hidden",onChange:be}),t.jsx("button",{type:"button",onClick:()=>M.current?.click(),title:x("Upload file"),"aria-label":x("Upload file"),className:"rounded-lg p-2 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",children:t.jsx(jn,{size:18})}),t.jsx("button",{type:"button",onClick:()=>{y(Y=>!Y),k(null),requestAnimationFrame(()=>P.current?.focus())},disabled:Ke.length===0&&Ze.length===0,title:x("Mention members"),"aria-label":x("Mention members"),className:se("rounded-lg transition-colors",n?"p-1.5":"p-2",f?"bg-neutral-100 text-neutral-700":"text-neutral-400 hover:bg-neutral-100 hover:text-neutral-600",Ke.length===0&&Ze.length===0?"cursor-not-allowed opacity-50":""),children:t.jsx(ao,{size:n?15:18})}),Ke.length>0&&t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[Ke.length," ",x("selected")]})]}),t.jsx("button",{type:"button",onClick:()=>{Ye()},disabled:r||L||W||!h.trim()&&!X,title:x(W?"Uploading...":L?"发送中...":"发送"),"aria-label":x(W?"Uploading...":L?"发送中...":"发送"),className:se("rounded-lg transition-all duration-200",n?"p-1.5":"p-2",(h.trim()||X)&&!r&&!L&&!W?"bg-neutral-900 text-white shadow-md hover:bg-black":"cursor-not-allowed bg-transparent text-neutral-300",L||W?"opacity-70":""),children:t.jsx(wn,{size:n?15:18})})]}),D&&t.jsx("div",{className:"border-t border-neutral-100 px-3 py-2 text-xs text-red-600",children:D})]})]})})]})}function fm(e){return e?e.slice(0,8):""}function To(e){const s=e?Date.parse(e):0;return Number.isNaN(s)?0:s}function Un(e){return e?.workspaceKind===_t.MAIN_DIRECTORY}function Hs(e){return e?Un(e)?"Project directory":e.branchName:"—"}function as(e){return e?.workingDir||e?.worktreePath||void 0}function qn(e,s){if(!e?.length)return[];const r=new Map((s?.members??[]).map(m=>[m.id,m])),o=new Map(e.map(m=>[m.id,m])),p=s?.mainWorkspaceId??null;return e.map(m=>{const v=m.parentWorkspaceId?o.get(m.parentWorkspaceId):void 0,n=m.ownerMemberId?r.get(m.ownerMemberId):void 0,i=!!(p&&m.id===p),a=i?"main":m.parentWorkspaceId?"child":"root",u=n?.name??(m.ownerMemberId?`Member ${fm(m.ownerMemberId)}`:void 0),c=Un(m)?"Project directory":i?"Main workspace":a==="child"?u?`${u} workspace`:"Child workspace":s?"Root workspace":"Workspace";return{workspace:m,kind:a,roleLabel:i?"Main":a==="child"?"Child":"Root",displayName:c,ownerName:u,parentBranchName:v?Hs(v):void 0,isMain:i}}).sort((m,v)=>{const n=a=>a.kind==="main"?0:a.kind==="child"?1:2,i=n(m)-n(v);return i!==0?i:To(m.workspace.createdAt)-To(v.workspace.createdAt)})}function Pl(e,s,r){if(e?.length)return r&&e.some(o=>o.id===r)?r:s?.mainWorkspaceId&&e.some(o=>o.id===s.mainWorkspaceId)?s.mainWorkspaceId:e.find(o=>o.status===At.ACTIVE)?.id??e[0]?.id}function Ll(e,s){return!e||e.status!==At.ACTIVE||Un(e)?!1:!s||e.parentWorkspaceId?!0:!!(s.mainWorkspaceId&&e.id===s.mainWorkspaceId)}function Il(e,s,r){return e?.parentWorkspaceId?s?.find(p=>p.id===e.parentWorkspaceId)?.branchName??e.baseBranch??r:r}const Kn={readRoom:!1,postRoomMessage:!1,mentionMembers:!1,stopMemberWork:!1,markReadyForReview:!1,readFiles:!1,writeFiles:!1,runCommands:!1,readDiff:!1,mergeWorkspace:!1},mm=[{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:"合并工作区"}],Ol=[{value:"none",label:"无"},{value:"shared",label:"共享"},{value:"dedicated",label:"独占"}],pm=[{value:"MENTION_ONLY",label:"仅提及"},{value:"USER_MESSAGES",label:"所有用户消息"}],Bl=[{value:"new_per_request",label:"每次新会话"},{value:"resume_last",label:"复用上次会话"}],gm=[{value:"own_only",label:"仅自己队列"},{value:"team_pending",label:"全队列待处理"}];function sr(){return{name:"",aliasesText:"",providerId:"",rolePrompt:"",capabilities:{...Kn},workspacePolicy:"none",triggerPolicy:"MENTION_ONLY",sessionPolicy:"new_per_request",queueManagementPolicy:"own_only",avatar:""}}function Ts(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...Kn,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function Mi(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...Kn,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function vm(e){return Array.from(new Set(e.split(/[\n,]/).map(s=>s.trim()).filter(Boolean)))}function xm(e){return{name:e.name.trim(),aliases:vm(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 Mo(e,s){return e instanceof Error?e.message:s}function Do(e){return e.membershipStatus!=="REMOVED"}function on(e){return e.status==="RUNNING"||e.status==="WAITING_ROOM_REPLY"||e.status==="SESSION_ENDED"||e.status==="QUEUED"}function Po(e){return on(e)?"bg-emerald-500":e.status==="FAILED"?"bg-red-500":"bg-neutral-300"}function Lo(e){return Ol.find(s=>s.value===e)?.label??e}function bm(e){return Bl.find(s=>s.value===e)?.label??e}function zt({children:e}){return t.jsx("span",{className:"text-xs font-medium text-neutral-600",children:e})}function Io({icon:e,title:s,description:r,action:o}){return t.jsxs("div",{className:"flex min-h-[18rem] flex-col items-center justify-center rounded-lg border border-dashed border-neutral-200 bg-white 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-neutral-100 text-neutral-500",children:e}),t.jsx("div",{className:"text-sm font-medium text-neutral-900",children:s}),r?t.jsx("div",{className:"mt-1 max-w-sm text-xs leading-relaxed text-neutral-500",children:r}):null,o?t.jsx("div",{className:"mt-4",children:o}):null]})}function _m({isOpen:e,onClose:s,teamRun:r}){const{t:o}=le(),{data:p=[]}=ld(),{data:m=[]}=Us(),v=cd(r.id),n=dd(r.id),i=ud(r.id),a=_.useRef(!1),[u,c]=_.useState("edit"),[g,x]=_.useState(null),[S,w]=_.useState(""),[l,h]=_.useState(sr()),[d,f]=_.useState(null),[y,C]=_.useState(null),k=r.members??[],E=_.useMemo(()=>k.filter(Do),[k]),b=_.useMemo(()=>y&&Do(y)&&!E.some(q=>q.id===y.id)?[...E,y]:E,[y,E]),j=g?E.find(q=>q.id===g)??null:null,R=y?.id===g?y:j,L=S?p.find(q=>q.id===S)??null:null,T=v.isPending||n.isPending||i.isPending,D=b.filter(on).length,F=_.useMemo(()=>{const q=m.map(({provider:N,availability:W})=>({value:N.id,label:N.name+(W.type==="NOT_FOUND"?o(" (不可用)"):""),icon:t.jsx(oi,{agentType:N.agentType,className:"size-4"}),disabled:W.type==="NOT_FOUND"}));return l.providerId&&!q.some(N=>N.value===l.providerId)&&q.unshift({value:l.providerId,label:`${l.providerId}${o(" (不可用)")}`,disabled:!0}),q},[l.providerId,m,o]);_.useEffect(()=>{if(!e){a.current=!1,C(null);return}if(a.current)return;a.current=!0;const q=b[0]??null;c(q?"edit":"add-preset"),x(q?.id??null),w(""),h(q?Ts(q):sr()),f(null)},[b,e]),_.useEffect(()=>{y&&E.some(q=>q.id===y.id)&&C(null)},[y,E]),_.useEffect(()=>{u==="add-preset"&&L&&h(Mi(L))},[u,L]);const I=(q,N)=>{h(W=>({...W,[q]:N}))},H=(q,N)=>{h(W=>({...W,capabilities:{...W.capabilities,[q]:N}}))},K=q=>{c("edit"),x(q.id),w(""),h(Ts(q))},A=()=>{c("add-preset"),x(null);const q=L??p[0]??null;w(q?.id??""),h(q?Mi(q):sr())},P=()=>{c("add-custom"),x(null),w(""),h(sr())},M=!!(l.name.trim()&&l.providerId.trim()&&l.rolePrompt.trim()),O=u==="add-preset"?!!S:u==="edit"?!!(R&&M):M,$=async()=>{try{if(u==="add-preset"){if(!S)return;const N=await v.mutateAsync({memberPresetId:S});st.success(o("Member added")),C(N),c("edit"),x(N.id),w(""),h(Ts(N));return}const q=xm(l);if(!q.name||!q.providerId||!q.rolePrompt){st.error(o("Name, provider, and role prompt are required"));return}if(u==="add-custom"){const N=await v.mutateAsync({member:q});st.success(o("Member added")),C(N),c("edit"),x(N.id),h(Ts(N));return}if(R){const N=await n.mutateAsync({memberId:R.id,data:q});st.success(o("Member updated")),C(W=>W?.id===N.id?N:W),x(N.id),h(Ts(N))}}catch(q){st.error(Mo(q,o("Failed to save member")))}},U=async()=>{if(d)try{if(await i.mutateAsync({memberId:d.id,stopActive:!0,cancelQueued:!0}),g===d.id){const q=b.find(N=>N.id!==d.id)??null;x(q?.id??null),c(q?"edit":"add-preset"),h(q?Ts(q):sr())}C(q=>q?.id===d.id?null:q),f(null),st.success(o("Member removed"))}catch(q){st.error(Mo(q,o("Failed to remove member")))}},B=()=>t.jsxs("div",{className:"flex min-h-0 flex-col lg:flex-1",children:[t.jsx("div",{className:"border-b border-neutral-100 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-neutral-900",children:[t.jsx(Ir,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o("Add member from preset")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:o("Choose a saved preset to add a ready-to-run member snapshot.")})]}),t.jsxs(Pe,{type:"button",variant:"outline",size:"sm",onClick:P,disabled:T,children:[t.jsx(fo,{size:13}),o("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(Io,{icon:t.jsx(Ir,{size:18}),title:o("No member presets"),description:o("Create a custom member for this TeamRun, or add presets from Team Collaboration Settings."),action:t.jsxs(Pe,{type:"button",variant:"outline",size:"sm",onClick:P,disabled:T,children:[t.jsx(ns,{size:13}),o("Custom member")]})}):t.jsx("div",{className:"grid grid-cols-1 gap-2 xl:grid-cols-2",children:p.map(q=>{const N=S===q.id;return t.jsxs("button",{type:"button",onClick:()=>{w(q.id),h(Mi(q))},className:se("flex min-h-[4.25rem] items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors",N?"border-neutral-900 bg-neutral-50 shadow-sm":"border-neutral-200 bg-white hover:border-neutral-300 hover:bg-neutral-50"),children:[t.jsx(Ht,{name:q.name,avatar:q.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-neutral-900",children:q.name}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:q.providerId}),t.jsxs("span",{className:"mt-1 block truncate text-[10px] text-neutral-400",children:[o(Lo(q.workspacePolicy))," · ",o(bm(q.sessionPolicy))]})]}),N?t.jsx(Jt,{size:16,className:"shrink-0 text-neutral-900"}):null]},q.id)})})})]}),z=()=>{const q=u==="edit";return q&&!R?t.jsx("div",{className:"p-5",children:t.jsx(Io,{icon:t.jsx(Ss,{size:18}),title:o("Select a member"),description:o("Choose a member on the left to edit its future TeamRun configuration."),action:t.jsxs(Pe,{type:"button",variant:"outline",size:"sm",onClick:A,disabled:T,children:[t.jsx(ns,{size:13}),o("Add member")]})})}):t.jsxs("div",{className:"flex min-h-0 flex-col lg:flex-1",children:[t.jsx("div",{className:"border-b border-neutral-100 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-neutral-900",children:[q?t.jsx(rl,{size:15,className:"text-neutral-500"}):t.jsx(ns,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o(q?"Edit member":"Custom member")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:o(q?"Provider, role, workspace, and session changes apply to future work only.":"Create a one-off member snapshot for this TeamRun.")})]}),q&&R?t.jsxs(Pe,{type:"button",variant:"outline",size:"sm",onClick:()=>f(R),disabled:T,className:"border-red-200 text-red-700 hover:bg-red-50 hover:text-red-800",children:[t.jsx(Nn,{size:13}),o("Remove")]}):t.jsxs(Pe,{type:"button",variant:"outline",size:"sm",onClick:A,disabled:T,children:[t.jsx(Ir,{size:13}),o("Use preset")]})]})}),t.jsxs("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:[q&&R?t.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg border border-neutral-200 bg-neutral-50 px-3 py-2.5",children:[t.jsx(Ht,{name:R.name,avatar:R.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:se("h-2 w-2 shrink-0 rounded-full",Po(R))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:R.name})]}),t.jsxs("div",{className:"mt-0.5 truncate text-xs text-neutral-500",children:[R.providerId," · ",o(Lo(R.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(zt,{children:o("Name")}),t.jsx("input",{value:l.name,onChange:N=>I("name",N.target.value),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(zt,{children:o("Aliases")}),t.jsx("input",{value:l.aliasesText,onChange:N=>I("aliasesText",N.target.value),placeholder:o("Comma separated"),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(zt,{children:o("Provider")}),t.jsx(is,{value:l.providerId,onChange:N=>I("providerId",N),options:F})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(zt,{children:o("Avatar")}),t.jsx("input",{value:l.avatar,onChange:N=>I("avatar",N.target.value),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]})]}),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(zt,{children:o("Workspace policy")}),t.jsx(is,{value:l.workspacePolicy,onChange:N=>I("workspacePolicy",N),options:Ol.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(zt,{children:o("Trigger policy")}),t.jsx(is,{value:l.triggerPolicy,onChange:N=>I("triggerPolicy",N),options:pm.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(zt,{children:o("Session policy")}),t.jsx(is,{value:l.sessionPolicy,onChange:N=>I("sessionPolicy",N),options:Bl.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(zt,{children:o("Queue policy")}),t.jsx(is,{value:l.queueManagementPolicy,onChange:N=>I("queueManagementPolicy",N),options:gm.map(N=>({value:N.value,label:o(N.label)}))})]})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(zt,{children:o("Role prompt")}),t.jsx("textarea",{value:l.rolePrompt,onChange:N=>I("rolePrompt",N.target.value),rows:7,className:"w-full resize-y rounded-lg border border-neutral-200 px-3 py-2 text-sm leading-relaxed outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(zt,{children:o("Capabilities")}),t.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-3",children:mm.map(N=>t.jsxs("label",{className:"flex min-h-9 items-center gap-2 rounded-md border border-neutral-200 bg-white px-2.5 py-2 text-xs text-neutral-700",children:[t.jsx("input",{type:"checkbox",checked:!!l.capabilities[N.key],onChange:W=>H(N.key,W.target.checked)}),t.jsx("span",{className:"min-w-0 truncate",children:o(N.label)})]},N.key))})]})]})]})]})};return t.jsxs(t.Fragment,{children:[t.jsx(ds,{isOpen:e,onClose:T?()=>{}:s,title:o("Manage Team Members"),className:"max-w-6xl",action:t.jsxs(t.Fragment,{children:[t.jsx(Pe,{type:"button",variant:"outline",onClick:s,disabled:T,children:o("Close")}),t.jsx(Pe,{type:"button",onClick:$,disabled:T||!O,children:o(T?"Processing...":u==="edit"?"Save member":"Add member")})]}),children:t.jsxs("div",{className:"grid min-h-0 grid-cols-1 overflow-visible rounded-lg border border-neutral-200 bg-white 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-neutral-200 bg-neutral-50/70 lg:border-b-0 lg:border-r",children:[t.jsx("div",{className:"border-b border-neutral-200 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-neutral-900",children:[t.jsx(Ss,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o("Members")})]}),t.jsxs("div",{className:"mt-1 text-xs text-neutral-500",children:[b.length," ",o("active")," · ",D," ",o("working")]})]}),t.jsx(Pe,{type:"button",size:"icon-sm",variant:"outline",onClick:A,disabled:T,title:o("Add member"),children:t.jsx(ns,{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:b.length===0?t.jsx("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-3 py-5 text-center text-xs text-neutral-400",children:o("No active members")}):t.jsx("div",{className:"space-y-1",children:b.map(q=>{const N=u==="edit"&&g===q.id;return t.jsxs("button",{type:"button",onClick:()=>K(q),className:se("group flex w-full items-center gap-2 rounded-lg border px-2.5 py-2 text-left transition-colors",N?"border-neutral-300 bg-white shadow-sm":"border-transparent hover:border-neutral-200 hover:bg-white"),children:[t.jsx(Ht,{name:q.name,avatar:q.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:se("h-1.5 w-1.5 shrink-0 rounded-full",Po(q))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:q.name})]}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:q.providerId})]}),t.jsx(yu,{size:13,className:se("shrink-0 text-neutral-300 transition-opacity",N?"opacity-100":"opacity-0 group-hover:opacity-100")})]},q.id)})})}),t.jsx("div",{className:"border-t border-neutral-200 p-2",children:t.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[t.jsxs("button",{type:"button",onClick:A,disabled:T,className:se("inline-flex h-8 items-center justify-center gap-1.5 rounded-md text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",u==="add-preset"?"bg-neutral-900 text-white":"bg-white text-neutral-600 hover:bg-neutral-100"),children:[t.jsx(Ir,{size:12}),o("Preset")]}),t.jsxs("button",{type:"button",onClick:P,disabled:T,className:se("inline-flex h-8 items-center justify-center gap-1.5 rounded-md text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",u==="add-custom"?"bg-neutral-900 text-white":"bg-white text-neutral-600 hover:bg-neutral-100"),children:[t.jsx(fo,{size:12}),o("Custom")]})]})})]}),t.jsx("section",{className:"flex min-h-0 min-w-0 flex-col",children:u==="add-preset"?B():z()})]})}),t.jsx(_n,{isOpen:!!d,onClose:()=>f(null),onConfirm:U,title:o("Remove member"),variant:"danger",isLoading:i.isPending,confirmText:o("Remove"),description:t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{children:d?o("Remove this member from future TeamRun work?"):""}),d&&on(d)?t.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-left text-red-700",children:[t.jsx($s,{size:15,className:"mt-0.5 shrink-0"}),t.jsx("span",{className:"text-sm font-medium",children:o("确认后会停止当前工作并取消队列")})]}):null]})})]})}const ym=[],Sm=[],wm=[],Cm=240;function km(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 Oo={running:0,"waiting room reply":1,queued:2,"session ended":3,"pending approval":4,idle:5,removed:6};function Di(e){if(!e)return"";const s=new Date(e);return Number.isNaN(s.getTime())?"":s.toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Bo(e,s){return e instanceof Error?e.message:s}function Em(e,s=Cm){const r=(e??"").replace(/\s+/g," ").trim();return r.length<=s?r:`${r.slice(0,s-3).trimEnd()}...`}function Or(e){return e?e.instructionPreview??Em(e.instruction):""}function jm(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 Nm(e){switch(e){case"running":return"border-emerald-200 bg-emerald-50 text-emerald-700";case"waiting room reply":return"border-amber-200 bg-amber-50 text-amber-700";case"queued":case"session ended":return"border-blue-200 bg-blue-50 text-blue-700";case"pending approval":return"border-neutral-200 bg-neutral-50 text-neutral-600";case"removed":return"border-neutral-200 bg-neutral-50 text-neutral-400";case"idle":return"border-neutral-200 bg-white text-neutral-500"}}function Rm(e){switch(e){case"running":return"bg-emerald-500";case"waiting room reply":return"bg-amber-500";case"queued":case"session ended":return"bg-blue-500";case"pending approval":return"bg-neutral-400";case"removed":return"bg-neutral-300";case"idle":return"bg-neutral-300"}}function Am(e){switch(e){case"user":return"User";case"agent":return"Agent";case"system":return"System"}}function Tm(e){switch(e){case"RUNNING":return"border-emerald-200 bg-emerald-50 text-emerald-700";case"WAITING_ROOM_REPLY":return"border-amber-200 bg-amber-50 text-amber-700";case"QUEUED":case"SESSION_ENDED":return"border-blue-200 bg-blue-50 text-blue-700";case"COMPLETED":return"border-neutral-200 bg-neutral-50 text-neutral-700";case"FAILED":return"border-red-200 bg-red-50 text-red-700";case"CANCELLED":return"border-neutral-200 bg-white text-neutral-500"}}function Mm(e){switch(e){case At.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case At.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case At.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case At.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function Dm(e){switch(e){case"Main":return"border-indigo-200 bg-indigo-50 text-indigo-700";case"Child":return"border-cyan-200 bg-cyan-50 text-cyan-700";default:return"border-neutral-200 bg-neutral-50 text-neutral-600"}}function Pm(e){return[...e].sort((s,r)=>Date.parse(r.updatedAt??r.createdAt??"")-Date.parse(s.updatedAt??s.createdAt??""))}function Lm(e,s){return s.find(r=>r.memberId===e.id&&mi.has(r.status))}function Fl({teamRun:e,workspaces:s,selectedWorkspaceId:r,onSelectWorkspace:o,onViewInvocationSession:p}){const{t:m}=le(),v=Na(e.id),n=Ra(e.id),i=Aa(e.id),[a,u]=_.useState(null),[c,g]=_.useState(null),[x,S]=_.useState(!1),[w,l]=_.useState(!1),h=e.members??ym,d=_.useMemo(()=>h.filter(I=>I.membershipStatus!=="REMOVED"),[h]),f=e.workRequests??Sm,y=e.invocations??wm,C=_.useMemo(()=>qn(s,e),[e,s]),k=_.useMemo(()=>new Map(f.map(I=>[I.id,I])),[f]),E=_.useMemo(()=>[...f].filter(I=>I.status==="PENDING_APPROVAL").sort((I,H)=>Date.parse(H.updatedAt??H.createdAt??"")-Date.parse(I.updatedAt??I.createdAt??"")),[f]),b=_.useMemo(()=>[...f].filter(I=>I.status==="QUEUED").sort((I,H)=>Date.parse(H.updatedAt??H.createdAt??"")-Date.parse(I.updatedAt??I.createdAt??"")),[f]),j=_.useMemo(()=>[...h].map(I=>({member:I,status:km(I.status)})).sort((I,H)=>Oo[I.status]-Oo[H.status]),[h]),R=v.isError?v.error:n.isError?n.error:null,L=v.isPending||n.isPending,T=C.find(I=>I.workspace.id===r),D=e.messages??[],F=j.filter(({status:I})=>I==="running"||I==="waiting room reply").length;return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[t.jsx(_m,{isOpen:w,onClose:()=>l(!1),teamRun:e}),t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-neutral-200 px-4 py-3 shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(Fs,{size:14,className:"text-neutral-500 shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:m("Team Status")})]}),t.jsxs("div",{className:"flex items-center gap-1.5 rounded-full border border-neutral-200 bg-neutral-50 px-2 py-0.5 text-[10px] font-medium text-neutral-500",children:[t.jsx("span",{children:m("Team mode")}),t.jsx("span",{className:"text-neutral-700",children:e.mode})]})]}),t.jsxs("div",{className:"flex items-center gap-3 border-b border-neutral-100 px-4 py-1.5 shrink-0 text-[10px] text-neutral-500",children:[t.jsxs("span",{className:"inline-flex items-center gap-1",title:m("Messages"),children:[t.jsx(ni,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:D.length})]}),t.jsxs("span",{className:"inline-flex items-center gap-1",title:m("Members"),children:[t.jsx(Ss,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:F>0?`${F}/${d.length}`:d.length}),F>0&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500"})]}),b.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1",title:m("Queue"),children:[t.jsx(os,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:b.length})]}),E.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-600",title:m("Pending approval"),children:[t.jsx(os,{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-[11px] font-medium uppercase tracking-wide text-amber-600",children:[t.jsx(os,{size:13}),t.jsx("span",{children:m("Pending approval")}),t.jsx("span",{className:"ml-auto rounded-full bg-amber-100 px-1.5 py-0.5 text-[10px] font-semibold text-amber-700",children:E.length})]}),t.jsx("div",{className:"space-y-1.5",children:E.map(I=>{const H=h.find(P=>P.id===I.targetMemberId),K=v.isPending&&v.variables===I.id,A=n.isPending&&n.variables===I.id;return t.jsxs("div",{className:"rounded-md border border-amber-200 bg-amber-50/50 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(Ht,{name:H?.name??"Agent",avatar:H?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:H?.name??I.targetMemberId})]}),t.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-neutral-600 line-clamp-2",children:Or(I)})]})}),t.jsxs("div",{className:"mt-1.5 flex items-center gap-x-2 text-[10px] text-neutral-400",children:[t.jsx("span",{children:m(Am(I.requesterType))}),t.jsx("span",{children:Di(I.createdAt)})]}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>v.mutate(I.id),disabled:L,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-emerald-200 bg-emerald-50 px-2 text-[11px] font-medium text-emerald-700 transition-colors hover:bg-emerald-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Jt,{size:11}),t.jsx("span",{className:"truncate",children:m(K?"Approving":"Approve")})]}),t.jsxs("button",{type:"button",onClick:()=>n.mutate(I.id),disabled:L,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-neutral-200 bg-neutral-50 px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Zt,{size:11}),t.jsx("span",{className:"truncate",children:m(A?"Rejecting":"Reject")})]})]})]},I.id)})}),R&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Bo(R,m("Failed to update work request"))})]}),t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[t.jsx(Ss,{size:13}),t.jsx("span",{children:m("Members")}),t.jsx("span",{className:"ml-auto text-[10px] font-normal text-neutral-400",children:d.length}),t.jsx("button",{type:"button",onClick:()=>l(!0),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700",title:m("Manage Team Members"),"aria-label":m("Manage Team Members"),children:t.jsx(rl,{size:13})})]}),h.length===0?t.jsx("div",{className:"py-3 text-center text-xs text-neutral-400",children:m("No members")}):t.jsx("div",{className:"space-y-px rounded-md border border-neutral-200 overflow-hidden",children:j.map(({member:I,status:H})=>{const K=Lm(I,y),A=Pm(y.filter(z=>z.memberId===I.id)),P=K?k.get(K.workRequestId):void 0,M=c===I.id,O=H==="running"||H==="waiting room reply",$=O&&!!K,U=a===I.id,B=i.isPending&&i.variables?.memberId===I.id;return t.jsxs("div",{className:se("bg-white",M&&"bg-neutral-50/50"),children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[t.jsx(Ht,{name:I.name,avatar:I.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:se("h-1.5 w-1.5 shrink-0 rounded-full",Rm(H))}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:I.name}),t.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Nm(H)),children:m(jm(H))})]}),O&&P?.instruction&&t.jsx("div",{className:"mt-0.5 truncate pl-3 text-[10px] text-neutral-500",children:Or(P)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[$&&t.jsx("button",{type:"button",onClick:()=>u(U?null:I.id),disabled:i.isPending,className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-red-50 hover:text-red-600 disabled:cursor-not-allowed disabled:opacity-50",title:m("Stop"),"aria-label":m("Stop"),children:t.jsx(Bs,{size:12})}),K?.sessionId&&p&&t.jsx("button",{type:"button",onClick:()=>p(K.sessionId),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700",title:m("View log"),"aria-label":m("View log"),children:t.jsx(Qi,{size:12})}),t.jsx("button",{type:"button",onClick:()=>g(M?null:I.id),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",title:m("Details"),"aria-label":m("Details"),"aria-expanded":M,children:M?t.jsx(wt,{size:13}):t.jsx(Mt,{size:13})})]})]}),$&&U&&t.jsxs("div",{className:"mx-3 mb-2 rounded-md border border-neutral-200 bg-neutral-50 p-2",children:[t.jsx("div",{className:"mb-1.5 text-[11px] text-neutral-600",children:m("Stop running work?")}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{i.mutate({memberId:I.id,cancelQueued:!1},{onSuccess:()=>u(null)})},disabled:i.isPending,className:"inline-flex h-6 items-center gap-1 rounded-md border border-neutral-200 bg-white px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Bs,{size:10}),t.jsx("span",{children:B&&i.variables?.cancelQueued===!1?m("Stopping"):m("Stop only")})]}),t.jsxs("button",{type:"button",onClick:()=>{i.mutate({memberId:I.id,cancelQueued:!0},{onSuccess:()=>u(null)})},disabled:i.isPending,className:"inline-flex h-6 items-center gap-1 rounded-md border border-red-200 bg-red-50 px-2 text-[11px] font-medium text-red-700 transition-colors hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(tl,{size:10}),t.jsx("span",{children:B&&i.variables?.cancelQueued===!0?m("Stopping"):m("Stop + clear queue")})]})]})]}),M&&t.jsxs("div",{className:"border-t border-neutral-100 px-3 py-2",children:[t.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-1.5 text-[10px] text-neutral-400",children:[t.jsx("span",{children:I.providerId}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:I.workspacePolicy}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:I.sessionPolicy==="resume_last"?m("Resume last session"):m("New session per request")})]}),t.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-[11px] font-medium text-neutral-500",children:m("Invocation history")}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:A.length})]}),A.length===0?t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:m("No invocations yet")}):t.jsx("div",{className:"space-y-1",children:A.map(z=>{const q=k.get(z.workRequestId),N=!!(z.sessionId&&p);return t.jsx("div",{className:"rounded-md border border-neutral-100 bg-white 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:se("rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Tm(z.status)),children:z.status}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:Di(z.updatedAt??z.createdAt)})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:Or(q)||z.workRequestId})]}),N&&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-neutral-200 bg-white px-1.5 text-[10px] font-medium text-neutral-600 transition-colors hover:bg-neutral-100",title:m("View log"),"aria-label":m("View log"),children:[t.jsx(Qi,{size:10}),t.jsx("span",{children:m("Log")})]})]})},z.id)})})]}),j[j.length-1]?.member.id!==I.id&&!M&&t.jsx("div",{className:"mx-3 border-b border-neutral-100"})]},I.id)})}),i.isError&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Bo(i.error,m("Failed to stop member work"))})]}),b.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[t.jsx(os,{size:13}),t.jsx("span",{children:m("Queue")}),t.jsx("span",{className:"ml-auto rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-semibold text-neutral-600",children:b.length})]}),t.jsx("div",{className:"space-y-1",children:b.map(I=>{const H=h.find(K=>K.id===I.targetMemberId);return t.jsx("div",{className:"rounded-md border border-neutral-200 bg-white 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(Ht,{name:H?.name??"Agent",avatar:H?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:H?.name??I.targetMemberId})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:Or(I)})]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:Di(I.createdAt)})]})},I.id)})})]}),C.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>S(I=>!I),className:"flex w-full items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500 transition-colors hover:text-neutral-700","aria-expanded":x,"aria-label":m("Workspaces"),children:[t.jsx(Fs,{size:13}),t.jsx("span",{children:m("Workspaces")}),t.jsxs("span",{className:"ml-auto flex items-center gap-1.5",children:[T&&t.jsx("span",{className:"max-w-[120px] truncate font-mono text-[10px] font-normal text-neutral-400",children:Hs(T.workspace)}),t.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-semibold text-neutral-600",children:C.length}),x?t.jsx(wt,{size:13,className:"text-neutral-400"}):t.jsx(Mt,{size:13,className:"text-neutral-400"})]})]}),x&&t.jsx("div",{className:"space-y-1.5",children:C.map(I=>{const H=r===I.workspace.id;return t.jsx("div",{className:se("rounded-md border bg-white px-3 py-2",H?"border-neutral-400 shadow-sm":"border-neutral-200"),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-neutral-900",children:m(I.displayName)}),t.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Dm(I.roleLabel)),children:m(I.roleLabel)}),t.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Mm(I.workspace.status)),children:I.workspace.status})]}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] text-neutral-500",children:Hs(I.workspace)}),t.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[I.ownerName&&t.jsxs("span",{children:[m("Owner"),": ",I.ownerName]}),I.parentBranchName&&t.jsxs("span",{children:[m("Parent"),": ",I.parentBranchName]})]})]}),t.jsxs("button",{type:"button",onClick:()=>o?.(I.workspace.id),disabled:!o||H,className:"inline-flex h-6 shrink-0 items-center gap-1 rounded-md border border-neutral-200 bg-neutral-50 px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",title:m("View workspace"),children:[H?t.jsx(Jt,{size:11}):t.jsx(Ua,{size:11}),t.jsx("span",{children:m(H?"Selected":"Select")})]})]})},I.workspace.id)})})]}),E.length===0&&b.length===0&&j.every(({status:I})=>I==="idle")&&t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:m("All members idle")})]})]})}var Pi={exports:{}},Fo;function Im(){return Fo||(Fo=1,(function(e,s){(function(r,o){e.exports=o()})(self,(()=>(()=>{var r={4567:function(v,n,i){var a=this&&this.__decorate||function(f,y,C,k){var E,b=arguments.length,j=b<3?y:k===null?k=Object.getOwnPropertyDescriptor(y,C):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(f,y,C,k);else for(var R=f.length-1;R>=0;R--)(E=f[R])&&(j=(b<3?E(j):b>3?E(y,C,j):E(y,C))||j);return b>3&&j&&Object.defineProperty(y,C,j),j},u=this&&this.__param||function(f,y){return function(C,k){y(C,k,f)}};Object.defineProperty(n,"__esModule",{value:!0}),n.AccessibilityManager=void 0;const c=i(9042),g=i(6114),x=i(9924),S=i(844),w=i(5596),l=i(4725),h=i(3656);let d=n.AccessibilityManager=class extends S.Disposable{constructor(f,y){super(),this._terminal=f,this._renderService=y,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 C=0;C<this._terminal.rows;C++)this._rowElements[C]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[C]);if(this._topBoundaryFocusListener=C=>this._handleBoundaryFocus(C,0),this._bottomBoundaryFocusListener=C=>this._handleBoundaryFocus(C,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 x.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((C=>this._handleResize(C.rows)))),this.register(this._terminal.onRender((C=>this._refreshRows(C.start,C.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((C=>this._handleChar(C)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
|
|
20
|
+
`)))),this.register(this._terminal.onA11yTab((C=>this._handleTab(C)))),this.register(this._terminal.onKey((C=>this._handleKey(C.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this._screenDprMonitor=new w.ScreenDprMonitor(window),this.register(this._screenDprMonitor),this._screenDprMonitor.setListener((()=>this._refreshRowsDimensions())),this.register((0,h.addDisposableDomListener)(window,"resize",(()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,S.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(f){for(let y=0;y<f;y++)this._handleChar(" ")}_handleChar(f){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==f&&(this._charsToAnnounce+=f):this._charsToAnnounce+=f,f===`
|
|
21
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=c.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(f){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(f)||this._charsToConsume.push(f)}_refreshRows(f,y){this._liveRegionDebouncer.refresh(f,y,this._terminal.rows)}_renderRows(f,y){const C=this._terminal.buffer,k=C.lines.length.toString();for(let E=f;E<=y;E++){const b=C.translateBufferLineToString(C.ydisp+E,!0),j=(C.ydisp+E+1).toString(),R=this._rowElements[E];R&&(b.length===0?R.innerText=" ":R.textContent=b,R.setAttribute("aria-posinset",j),R.setAttribute("aria-setsize",k))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(f,y){const C=f.target,k=this._rowElements[y===0?1:this._rowElements.length-2];if(C.getAttribute("aria-posinset")===(y===0?"1":`${this._terminal.buffer.lines.length}`)||f.relatedTarget!==k)return;let E,b;if(y===0?(E=C,b=this._rowElements.pop(),this._rowContainer.removeChild(b)):(E=this._rowElements.shift(),b=C,this._rowContainer.removeChild(E)),E.removeEventListener("focus",this._topBoundaryFocusListener),b.removeEventListener("focus",this._bottomBoundaryFocusListener),y===0){const j=this._createAccessibilityTreeNode();this._rowElements.unshift(j),this._rowContainer.insertAdjacentElement("afterbegin",j)}else{const j=this._createAccessibilityTreeNode();this._rowElements.push(j),this._rowContainer.appendChild(j)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(y===0?-1:1),this._rowElements[y===0?1:this._rowElements.length-2].focus(),f.preventDefault(),f.stopImmediatePropagation()}_handleResize(f){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let y=this._rowContainer.children.length;y<this._terminal.rows;y++)this._rowElements[y]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[y]);for(;this._rowElements.length>f;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const f=document.createElement("div");return f.setAttribute("role","listitem"),f.tabIndex=-1,this._refreshRowDimensions(f),f}_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 f=0;f<this._terminal.rows;f++)this._refreshRowDimensions(this._rowElements[f])}}_refreshRowDimensions(f){f.style.height=`${this._renderService.dimensions.css.cell.height}px`}};n.AccessibilityManager=d=a([u(1,l.IRenderService)],d)},3614:(v,n)=>{function i(g){return g.replace(/\r?\n/g,"\r")}function a(g,x){return x?"\x1B[200~"+g+"\x1B[201~":g}function u(g,x,S,w){g=a(g=i(g),S.decPrivateModes.bracketedPasteMode&&w.rawOptions.ignoreBracketedPasteMode!==!0),S.triggerDataEvent(g,!0),x.value=""}function c(g,x,S){const w=S.getBoundingClientRect(),l=g.clientX-w.left-10,h=g.clientY-w.top-10;x.style.width="20px",x.style.height="20px",x.style.left=`${l}px`,x.style.top=`${h}px`,x.style.zIndex="1000",x.focus()}Object.defineProperty(n,"__esModule",{value:!0}),n.rightClickHandler=n.moveTextAreaUnderMouseCursor=n.paste=n.handlePasteEvent=n.copyHandler=n.bracketTextForPaste=n.prepareTextForTerminal=void 0,n.prepareTextForTerminal=i,n.bracketTextForPaste=a,n.copyHandler=function(g,x){g.clipboardData&&g.clipboardData.setData("text/plain",x.selectionText),g.preventDefault()},n.handlePasteEvent=function(g,x,S,w){g.stopPropagation(),g.clipboardData&&u(g.clipboardData.getData("text/plain"),x,S,w)},n.paste=u,n.moveTextAreaUnderMouseCursor=c,n.rightClickHandler=function(g,x,S,w,l){c(g,x,S),l&&w.rightClickSelect(g),x.value=w.selectionText,x.select()}},7239:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ColorContrastCache=void 0;const a=i(1505);n.ColorContrastCache=class{constructor(){this._color=new a.TwoKeyMap,this._css=new a.TwoKeyMap}setCss(u,c,g){this._css.set(u,c,g)}getCss(u,c){return this._css.get(u,c)}setColor(u,c,g){this._color.set(u,c,g)}getColor(u,c){return this._color.get(u,c)}clear(){this._color.clear(),this._css.clear()}}},3656:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.addDisposableDomListener=void 0,n.addDisposableDomListener=function(i,a,u,c){i.addEventListener(a,u,c);let g=!1;return{dispose:()=>{g||(g=!0,i.removeEventListener(a,u,c))}}}},6465:function(v,n,i){var a=this&&this.__decorate||function(l,h,d,f){var y,C=arguments.length,k=C<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(l,h,d,f);else for(var E=l.length-1;E>=0;E--)(y=l[E])&&(k=(C<3?y(k):C>3?y(h,d,k):y(h,d))||k);return C>3&&k&&Object.defineProperty(h,d,k),k},u=this&&this.__param||function(l,h){return function(d,f){h(d,f,l)}};Object.defineProperty(n,"__esModule",{value:!0}),n.Linkifier2=void 0;const c=i(3656),g=i(8460),x=i(844),S=i(2585);let w=n.Linkifier2=class extends x.Disposable{get currentLink(){return this._currentLink}constructor(l){super(),this._bufferService=l,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,x.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,x.toDisposable)((()=>{this._lastMouseEvent=void 0}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0})))}registerLinkProvider(l){return this._linkProviders.push(l),{dispose:()=>{const h=this._linkProviders.indexOf(l);h!==-1&&this._linkProviders.splice(h,1)}}}attachToDom(l,h,d){this._element=l,this._mouseService=h,this._renderService=d,this.register((0,c.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,c.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,c.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,c.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(l){if(this._lastMouseEvent=l,!this._element||!this._mouseService)return;const h=this._positionFromMouseEvent(l,this._element,this._mouseService);if(!h)return;this._isMouseOut=!1;const d=l.composedPath();for(let f=0;f<d.length;f++){const y=d[f];if(y.classList.contains("xterm"))break;if(y.classList.contains("xterm-hover"))return}this._lastBufferCell&&h.x===this._lastBufferCell.x&&h.y===this._lastBufferCell.y||(this._handleHover(h),this._lastBufferCell=h)}_handleHover(l){if(this._activeLine!==l.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(l,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,l)||(this._clearCurrentLink(),this._askForLink(l,!0))}_askForLink(l,h){var d,f;this._activeProviderReplies&&h||((d=this._activeProviderReplies)===null||d===void 0||d.forEach((C=>{C?.forEach((k=>{k.link.dispose&&k.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=l.y);let y=!1;for(const[C,k]of this._linkProviders.entries())h?!((f=this._activeProviderReplies)===null||f===void 0)&&f.get(C)&&(y=this._checkLinkProviderResult(C,l,y)):k.provideLinks(l.y,(E=>{var b,j;if(this._isMouseOut)return;const R=E?.map((L=>({link:L})));(b=this._activeProviderReplies)===null||b===void 0||b.set(C,R),y=this._checkLinkProviderResult(C,l,y),((j=this._activeProviderReplies)===null||j===void 0?void 0:j.size)===this._linkProviders.length&&this._removeIntersectingLinks(l.y,this._activeProviderReplies)}))}_removeIntersectingLinks(l,h){const d=new Set;for(let f=0;f<h.size;f++){const y=h.get(f);if(y)for(let C=0;C<y.length;C++){const k=y[C],E=k.link.range.start.y<l?0:k.link.range.start.x,b=k.link.range.end.y>l?this._bufferService.cols:k.link.range.end.x;for(let j=E;j<=b;j++){if(d.has(j)){y.splice(C--,1);break}d.add(j)}}}}_checkLinkProviderResult(l,h,d){var f;if(!this._activeProviderReplies)return d;const y=this._activeProviderReplies.get(l);let C=!1;for(let k=0;k<l;k++)this._activeProviderReplies.has(k)&&!this._activeProviderReplies.get(k)||(C=!0);if(!C&&y){const k=y.find((E=>this._linkAtPosition(E.link,h)));k&&(d=!0,this._handleNewLink(k))}if(this._activeProviderReplies.size===this._linkProviders.length&&!d)for(let k=0;k<this._activeProviderReplies.size;k++){const E=(f=this._activeProviderReplies.get(k))===null||f===void 0?void 0:f.find((b=>this._linkAtPosition(b.link,h)));if(E){d=!0,this._handleNewLink(E);break}}return d}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(l){if(!this._element||!this._mouseService||!this._currentLink)return;const h=this._positionFromMouseEvent(l,this._element,this._mouseService);h&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,h)&&this._currentLink.link.activate(l,this._currentLink.link.text)}_clearCurrentLink(l,h){this._element&&this._currentLink&&this._lastMouseEvent&&(!l||!h||this._currentLink.link.range.start.y>=l&&this._currentLink.link.range.end.y<=h)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,x.disposeArray)(this._linkCacheDisposables))}_handleNewLink(l){if(!this._element||!this._lastMouseEvent||!this._mouseService)return;const h=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);h&&this._linkAtPosition(l.link,h)&&(this._currentLink=l,this._currentLink.state={decorations:{underline:l.link.decorations===void 0||l.link.decorations.underline,pointerCursor:l.link.decorations===void 0||l.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,l.link,this._lastMouseEvent),l.link.decorations={},Object.defineProperties(l.link.decorations,{pointerCursor:{get:()=>{var d,f;return(f=(d=this._currentLink)===null||d===void 0?void 0:d.state)===null||f===void 0?void 0:f.decorations.pointerCursor},set:d=>{var f,y;!((f=this._currentLink)===null||f===void 0)&&f.state&&this._currentLink.state.decorations.pointerCursor!==d&&(this._currentLink.state.decorations.pointerCursor=d,this._currentLink.state.isHovered&&((y=this._element)===null||y===void 0||y.classList.toggle("xterm-cursor-pointer",d)))}},underline:{get:()=>{var d,f;return(f=(d=this._currentLink)===null||d===void 0?void 0:d.state)===null||f===void 0?void 0:f.decorations.underline},set:d=>{var f,y,C;!((f=this._currentLink)===null||f===void 0)&&f.state&&((C=(y=this._currentLink)===null||y===void 0?void 0:y.state)===null||C===void 0?void 0:C.decorations.underline)!==d&&(this._currentLink.state.decorations.underline=d,this._currentLink.state.isHovered&&this._fireUnderlineEvent(l.link,d))}}}),this._renderService&&this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((d=>{if(!this._currentLink)return;const f=d.start===0?0:d.start+1+this._bufferService.buffer.ydisp,y=this._bufferService.buffer.ydisp+1+d.end;if(this._currentLink.link.range.start.y>=f&&this._currentLink.link.range.end.y<=y&&(this._clearCurrentLink(f,y),this._lastMouseEvent&&this._element)){const C=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);C&&this._askForLink(C,!1)}}))))}_linkHover(l,h,d){var f;!((f=this._currentLink)===null||f===void 0)&&f.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(h,!0),this._currentLink.state.decorations.pointerCursor&&l.classList.add("xterm-cursor-pointer")),h.hover&&h.hover(d,h.text)}_fireUnderlineEvent(l,h){const d=l.range,f=this._bufferService.buffer.ydisp,y=this._createLinkUnderlineEvent(d.start.x-1,d.start.y-f-1,d.end.x,d.end.y-f-1,void 0);(h?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(y)}_linkLeave(l,h,d){var f;!((f=this._currentLink)===null||f===void 0)&&f.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(h,!1),this._currentLink.state.decorations.pointerCursor&&l.classList.remove("xterm-cursor-pointer")),h.leave&&h.leave(d,h.text)}_linkAtPosition(l,h){const d=l.range.start.y*this._bufferService.cols+l.range.start.x,f=l.range.end.y*this._bufferService.cols+l.range.end.x,y=h.y*this._bufferService.cols+h.x;return d<=y&&y<=f}_positionFromMouseEvent(l,h,d){const f=d.getCoords(l,h,this._bufferService.cols,this._bufferService.rows);if(f)return{x:f[0],y:f[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(l,h,d,f,y){return{x1:l,y1:h,x2:d,y2:f,cols:this._bufferService.cols,fg:y}}};n.Linkifier2=w=a([u(0,S.IBufferService)],w)},9042:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.tooMuchOutput=n.promptLabel=void 0,n.promptLabel="Terminal input",n.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(v,n,i){var a=this&&this.__decorate||function(w,l,h,d){var f,y=arguments.length,C=y<3?l:d===null?d=Object.getOwnPropertyDescriptor(l,h):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(w,l,h,d);else for(var k=w.length-1;k>=0;k--)(f=w[k])&&(C=(y<3?f(C):y>3?f(l,h,C):f(l,h))||C);return y>3&&C&&Object.defineProperty(l,h,C),C},u=this&&this.__param||function(w,l){return function(h,d){l(h,d,w)}};Object.defineProperty(n,"__esModule",{value:!0}),n.OscLinkProvider=void 0;const c=i(511),g=i(2585);let x=n.OscLinkProvider=class{constructor(w,l,h){this._bufferService=w,this._optionsService=l,this._oscLinkService=h}provideLinks(w,l){var h;const d=this._bufferService.buffer.lines.get(w-1);if(!d)return void l(void 0);const f=[],y=this._optionsService.rawOptions.linkHandler,C=new c.CellData,k=d.getTrimmedLength();let E=-1,b=-1,j=!1;for(let R=0;R<k;R++)if(b!==-1||d.hasContent(R)){if(d.loadCell(R,C),C.hasExtendedAttrs()&&C.extended.urlId){if(b===-1){b=R,E=C.extended.urlId;continue}j=C.extended.urlId!==E}else b!==-1&&(j=!0);if(j||b!==-1&&R===k-1){const L=(h=this._oscLinkService.getLinkData(E))===null||h===void 0?void 0:h.uri;if(L){const T={start:{x:b+1,y:w},end:{x:R+(j||R!==k-1?0:1),y:w}};let D=!1;if(!y?.allowNonHttpProtocols)try{const F=new URL(L);["http:","https:"].includes(F.protocol)||(D=!0)}catch{D=!0}D||f.push({text:L,range:T,activate:(F,I)=>y?y.activate(F,I,T):S(0,I),hover:(F,I)=>{var H;return(H=y?.hover)===null||H===void 0?void 0:H.call(y,F,I,T)},leave:(F,I)=>{var H;return(H=y?.leave)===null||H===void 0?void 0:H.call(y,F,I,T)}})}j=!1,C.hasExtendedAttrs()&&C.extended.urlId?(b=R,E=C.extended.urlId):(b=-1,E=-1)}}l(f)}};function S(w,l){if(confirm(`Do you want to navigate to ${l}?
|
|
22
|
+
|
|
23
|
+
WARNING: This link could potentially be dangerous`)){const h=window.open();if(h){try{h.opener=null}catch{}h.location.href=l}else console.warn("Opening link blocked as opener could not be cleared")}}n.OscLinkProvider=x=a([u(0,g.IBufferService),u(1,g.IOptionsService),u(2,g.IOscLinkService)],x)},6193:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.RenderDebouncer=void 0,n.RenderDebouncer=class{constructor(i,a){this._parentWindow=i,this._renderCallback=a,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._parentWindow.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(i){return this._refreshCallbacks.push(i),this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(i,a,u){this._rowCount=u,i=i!==void 0?i:0,a=a!==void 0?a:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,i):i,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,a):a,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 i=Math.max(this._rowStart,0),a=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(i,a),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const i of this._refreshCallbacks)i(0);this._refreshCallbacks=[]}}},5596:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ScreenDprMonitor=void 0;const a=i(844);class u extends a.Disposable{constructor(g){super(),this._parentWindow=g,this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this.register((0,a.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)}}n.ScreenDprMonitor=u},3236:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Terminal=void 0;const a=i(3614),u=i(3656),c=i(6465),g=i(9042),x=i(3730),S=i(1680),w=i(3107),l=i(5744),h=i(2950),d=i(1296),f=i(428),y=i(4269),C=i(5114),k=i(8934),E=i(3230),b=i(9312),j=i(4725),R=i(6731),L=i(8055),T=i(8969),D=i(8460),F=i(844),I=i(6114),H=i(8437),K=i(2584),A=i(7399),P=i(5941),M=i(9074),O=i(2585),$=i(5435),U=i(4567),B=typeof window<"u"?window.document:null;class z extends T.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(N={}){super(N),this.browser=I,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new F.MutableDisposable),this._onCursorMove=this.register(new D.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new D.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new D.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new D.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new D.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new D.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new D.EventEmitter),this._onBlur=this.register(new D.EventEmitter),this._onA11yCharEmitter=this.register(new D.EventEmitter),this._onA11yTabEmitter=this.register(new D.EventEmitter),this._onWillOpen=this.register(new D.EventEmitter),this._setup(),this.linkifier2=this.register(this._instantiationService.createInstance(c.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(x.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(((W,X)=>this.refresh(W,X)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((W=>this._reportWindowsOptions(W)))),this.register(this._inputHandler.onColor((W=>this._handleColorEvent(W)))),this.register((0,D.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,D.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,D.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,D.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((W=>this._afterResize(W.cols,W.rows)))),this.register((0,F.toDisposable)((()=>{var W,X;this._customKeyEventHandler=void 0,(X=(W=this.element)===null||W===void 0?void 0:W.parentNode)===null||X===void 0||X.removeChild(this.element)})))}_handleColorEvent(N){if(this._themeService)for(const W of N){let X,V="";switch(W.index){case 256:X="foreground",V="10";break;case 257:X="background",V="11";break;case 258:X="cursor",V="12";break;default:X="ansi",V="4;"+W.index}switch(W.type){case 0:const ie=L.color.toColorRGB(X==="ansi"?this._themeService.colors.ansi[W.index]:this._themeService.colors[X]);this.coreService.triggerDataEvent(`${K.C0.ESC}]${V};${(0,P.toRgbString)(ie)}${K.C1_ESCAPED.ST}`);break;case 1:if(X==="ansi")this._themeService.modifyColors((ee=>ee.ansi[W.index]=L.rgba.toColor(...W.color)));else{const ee=X;this._themeService.modifyColors((pe=>pe[ee]=L.rgba.toColor(...W.color)))}break;case 2:this._themeService.restoreColor(W.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(N){N?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(U.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(N){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(K.C0.ESC+"[I"),this.updateCursorStyle(N),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var N;return(N=this.textarea)===null||N===void 0?void 0:N.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(K.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 N=this.buffer.ybase+this.buffer.y,W=this.buffer.lines.get(N);if(!W)return;const X=Math.min(this.buffer.x,this.cols-1),V=this._renderService.dimensions.css.cell.height,ie=W.getWidth(X),ee=this._renderService.dimensions.css.cell.width*ie,pe=this.buffer.y*this._renderService.dimensions.css.cell.height,he=X*this._renderService.dimensions.css.cell.width;this.textarea.style.left=he+"px",this.textarea.style.top=pe+"px",this.textarea.style.width=ee+"px",this.textarea.style.height=V+"px",this.textarea.style.lineHeight=V+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,u.addDisposableDomListener)(this.element,"copy",(W=>{this.hasSelection()&&(0,a.copyHandler)(W,this._selectionService)})));const N=W=>(0,a.handlePasteEvent)(W,this.textarea,this.coreService,this.optionsService);this.register((0,u.addDisposableDomListener)(this.textarea,"paste",N)),this.register((0,u.addDisposableDomListener)(this.element,"paste",N)),I.isFirefox?this.register((0,u.addDisposableDomListener)(this.element,"mousedown",(W=>{W.button===2&&(0,a.rightClickHandler)(W,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,u.addDisposableDomListener)(this.element,"contextmenu",(W=>{(0,a.rightClickHandler)(W,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),I.isLinux&&this.register((0,u.addDisposableDomListener)(this.element,"auxclick",(W=>{W.button===1&&(0,a.moveTextAreaUnderMouseCursor)(W,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,u.addDisposableDomListener)(this.textarea,"keyup",(N=>this._keyUp(N)),!0)),this.register((0,u.addDisposableDomListener)(this.textarea,"keydown",(N=>this._keyDown(N)),!0)),this.register((0,u.addDisposableDomListener)(this.textarea,"keypress",(N=>this._keyPress(N)),!0)),this.register((0,u.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,u.addDisposableDomListener)(this.textarea,"compositionupdate",(N=>this._compositionHelper.compositionupdate(N)))),this.register((0,u.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,u.addDisposableDomListener)(this.textarea,"input",(N=>this._inputEvent(N)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(N){var W;if(!N)throw new Error("Terminal requires a parent element.");N.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this._document=N.ownerDocument,this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),N.appendChild(this.element);const X=B.createDocumentFragment();this._viewportElement=B.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),X.appendChild(this._viewportElement),this._viewportScrollArea=B.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=B.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=B.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),X.appendChild(this.screenElement),this.textarea=B.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",g.promptLabel),I.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(C.CoreBrowserService,this.textarea,(W=this._document.defaultView)!==null&&W!==void 0?W:window),this._instantiationService.setService(j.ICoreBrowserService,this._coreBrowserService),this.register((0,u.addDisposableDomListener)(this.textarea,"focus",(V=>this._handleTextAreaFocus(V)))),this.register((0,u.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(f.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(j.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(R.ThemeService),this._instantiationService.setService(j.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(y.CharacterJoinerService),this._instantiationService.setService(j.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(E.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(j.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((V=>this._onRender.fire(V)))),this.onResize((V=>this._renderService.resize(V.cols,V.rows))),this._compositionView=B.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(h.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this.element.appendChild(X);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(j.IMouseService,this._mouseService),this.viewport=this._instantiationService.createInstance(S.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((V=>this.scrollLines(V.amount,V.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(b.SelectionService,this.element,this.screenElement,this.linkifier2)),this._instantiationService.setService(j.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((V=>this.scrollLines(V.amount,V.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((V=>this._renderService.handleSelectionChanged(V.start,V.end,V.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((V=>{this.textarea.value=V,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((V=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,u.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.linkifier2.attachToDom(this.screenElement,this._mouseService,this._renderService),this.register(this._instantiationService.createInstance(w.BufferDecorationRenderer,this.screenElement)),this.register((0,u.addDisposableDomListener)(this.element,"mousedown",(V=>this._selectionService.handleMouseDown(V)))),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(U.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(V=>this._handleScreenReaderModeOptionChange(V)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(l.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(V=>{!this._overviewRulerRenderer&&V&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(l.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(d.DomRenderer,this.element,this.screenElement,this._viewportElement,this.linkifier2)}bindMouse(){const N=this,W=this.element;function X(ee){const pe=N._mouseService.getMouseReportCoords(ee,N.screenElement);if(!pe)return!1;let he,G;switch(ee.overrideType||ee.type){case"mousemove":G=32,ee.buttons===void 0?(he=3,ee.button!==void 0&&(he=ee.button<3?ee.button:3)):he=1&ee.buttons?0:4&ee.buttons?1:2&ee.buttons?2:3;break;case"mouseup":G=0,he=ee.button<3?ee.button:3;break;case"mousedown":G=1,he=ee.button<3?ee.button:3;break;case"wheel":if(N.viewport.getLinesScrolled(ee)===0)return!1;G=ee.deltaY<0?0:1,he=4;break;default:return!1}return!(G===void 0||he===void 0||he>4)&&N.coreMouseService.triggerMouseEvent({col:pe.col,row:pe.row,x:pe.x,y:pe.y,button:he,action:G,ctrl:ee.ctrlKey,alt:ee.altKey,shift:ee.shiftKey})}const V={mouseup:null,wheel:null,mousedrag:null,mousemove:null},ie={mouseup:ee=>(X(ee),ee.buttons||(this._document.removeEventListener("mouseup",V.mouseup),V.mousedrag&&this._document.removeEventListener("mousemove",V.mousedrag)),this.cancel(ee)),wheel:ee=>(X(ee),this.cancel(ee,!0)),mousedrag:ee=>{ee.buttons&&X(ee)},mousemove:ee=>{ee.buttons||X(ee)}};this.register(this.coreMouseService.onProtocolChange((ee=>{ee?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(ee)),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&ee?V.mousemove||(W.addEventListener("mousemove",ie.mousemove),V.mousemove=ie.mousemove):(W.removeEventListener("mousemove",V.mousemove),V.mousemove=null),16&ee?V.wheel||(W.addEventListener("wheel",ie.wheel,{passive:!1}),V.wheel=ie.wheel):(W.removeEventListener("wheel",V.wheel),V.wheel=null),2&ee?V.mouseup||(W.addEventListener("mouseup",ie.mouseup),V.mouseup=ie.mouseup):(this._document.removeEventListener("mouseup",V.mouseup),W.removeEventListener("mouseup",V.mouseup),V.mouseup=null),4&ee?V.mousedrag||(V.mousedrag=ie.mousedrag):(this._document.removeEventListener("mousemove",V.mousedrag),V.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,u.addDisposableDomListener)(W,"mousedown",(ee=>{if(ee.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(ee))return X(ee),V.mouseup&&this._document.addEventListener("mouseup",V.mouseup),V.mousedrag&&this._document.addEventListener("mousemove",V.mousedrag),this.cancel(ee)}))),this.register((0,u.addDisposableDomListener)(W,"wheel",(ee=>{if(!V.wheel){if(!this.buffer.hasScrollback){const pe=this.viewport.getLinesScrolled(ee);if(pe===0)return;const he=K.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(ee.deltaY<0?"A":"B");let G="";for(let ge=0;ge<Math.abs(pe);ge++)G+=he;return this.coreService.triggerDataEvent(G,!0),this.cancel(ee,!0)}return this.viewport.handleWheel(ee)?this.cancel(ee):void 0}}),{passive:!1})),this.register((0,u.addDisposableDomListener)(W,"touchstart",(ee=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(ee),this.cancel(ee)}),{passive:!0})),this.register((0,u.addDisposableDomListener)(W,"touchmove",(ee=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(ee)?void 0:this.cancel(ee)}),{passive:!1}))}refresh(N,W){var X;(X=this._renderService)===null||X===void 0||X.refreshRows(N,W)}updateCursorStyle(N){var W;!((W=this._selectionService)===null||W===void 0)&&W.shouldColumnSelect(N)?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(N,W,X=0){var V;X===1?(super.scrollLines(N,W,X),this.refresh(0,this.rows-1)):(V=this.viewport)===null||V===void 0||V.scrollLines(N)}paste(N){(0,a.paste)(N,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(N){this._customKeyEventHandler=N}registerLinkProvider(N){return this.linkifier2.registerLinkProvider(N)}registerCharacterJoiner(N){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const W=this._characterJoinerService.register(N);return this.refresh(0,this.rows-1),W}deregisterCharacterJoiner(N){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(N)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(N){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+N)}registerDecoration(N){return this._decorationService.registerDecoration(N)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(N,W,X){this._selectionService.setSelection(N,W,X)}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 N;(N=this._selectionService)===null||N===void 0||N.clearSelection()}selectAll(){var N;(N=this._selectionService)===null||N===void 0||N.selectAll()}selectLines(N,W){var X;(X=this._selectionService)===null||X===void 0||X.selectLines(N,W)}_keyDown(N){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1)return!1;const W=this.browser.isMac&&this.options.macOptionIsMeta&&N.altKey;if(!W&&!this._compositionHelper.keydown(N))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;W||N.key!=="Dead"&&N.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const X=(0,A.evaluateKeyboardEvent)(N,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(N),X.type===3||X.type===2){const V=this.rows-1;return this.scrollLines(X.type===2?-V:V),this.cancel(N,!0)}return X.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,N)||(X.cancel&&this.cancel(N,!0),!X.key||!!(N.key&&!N.ctrlKey&&!N.altKey&&!N.metaKey&&N.key.length===1&&N.key.charCodeAt(0)>=65&&N.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(X.key!==K.C0.ETX&&X.key!==K.C0.CR||(this.textarea.value=""),this._onKey.fire({key:X.key,domEvent:N}),this._showCursor(),this.coreService.triggerDataEvent(X.key,!0),!this.optionsService.rawOptions.screenReaderMode||N.altKey||N.ctrlKey?this.cancel(N,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(N,W){const X=N.isMac&&!this.options.macOptionIsMeta&&W.altKey&&!W.ctrlKey&&!W.metaKey||N.isWindows&&W.altKey&&W.ctrlKey&&!W.metaKey||N.isWindows&&W.getModifierState("AltGraph");return W.type==="keypress"?X:X&&(!W.keyCode||W.keyCode>47)}_keyUp(N){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1||((function(W){return W.keyCode===16||W.keyCode===17||W.keyCode===18})(N)||this.focus(),this.updateCursorStyle(N),this._keyPressHandled=!1)}_keyPress(N){let W;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1)return!1;if(this.cancel(N),N.charCode)W=N.charCode;else if(N.which===null||N.which===void 0)W=N.keyCode;else{if(N.which===0||N.charCode===0)return!1;W=N.which}return!(!W||(N.altKey||N.ctrlKey||N.metaKey)&&!this._isThirdLevelShift(this.browser,N)||(W=String.fromCharCode(W),this._onKey.fire({key:W,domEvent:N}),this._showCursor(),this.coreService.triggerDataEvent(W,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(N){if(N.data&&N.inputType==="insertText"&&(!N.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const W=N.data;return this.coreService.triggerDataEvent(W,!0),this.cancel(N),!0}return!1}resize(N,W){N!==this.cols||W!==this.rows?super.resize(N,W):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(N,W){var X,V;(X=this._charSizeService)===null||X===void 0||X.measure(),(V=this.viewport)===null||V===void 0||V.syncScrollArea(!0)}clear(){var N;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 W=1;W<this.rows;W++)this.buffer.lines.push(this.buffer.getBlankLine(H.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(N=this.viewport)===null||N===void 0||N.reset(),this.refresh(0,this.rows-1)}}reset(){var N,W;this.options.rows=this.rows,this.options.cols=this.cols;const X=this._customKeyEventHandler;this._setup(),super.reset(),(N=this._selectionService)===null||N===void 0||N.reset(),this._decorationService.reset(),(W=this.viewport)===null||W===void 0||W.reset(),this._customKeyEventHandler=X,this.refresh(0,this.rows-1)}clearTextureAtlas(){var N;(N=this._renderService)===null||N===void 0||N.clearTextureAtlas()}_reportFocus(){var N;!((N=this.element)===null||N===void 0)&&N.classList.contains("focus")?this.coreService.triggerDataEvent(K.C0.ESC+"[I"):this.coreService.triggerDataEvent(K.C0.ESC+"[O")}_reportWindowsOptions(N){if(this._renderService)switch(N){case $.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const W=this._renderService.dimensions.css.canvas.width.toFixed(0),X=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${K.C0.ESC}[4;${X};${W}t`);break;case $.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const V=this._renderService.dimensions.css.cell.width.toFixed(0),ie=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${K.C0.ESC}[6;${ie};${V}t`)}}cancel(N,W){if(this.options.cancelEvents||W)return N.preventDefault(),N.stopPropagation(),!1}}n.Terminal=z},9924:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.TimeBasedDebouncer=void 0,n.TimeBasedDebouncer=class{constructor(i,a=1e3){this._renderCallback=i,this._debounceThresholdMS=a,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(i,a,u){this._rowCount=u,i=i!==void 0?i:0,a=a!==void 0?a:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,i):i,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,a):a;const c=Date.now();if(c-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=c,this._innerRefresh();else if(!this._additionalRefreshRequested){const g=c-this._lastRefreshMs,x=this._debounceThresholdMS-g;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),x)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const i=Math.max(this._rowStart,0),a=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(i,a)}}},1680:function(v,n,i){var a=this&&this.__decorate||function(h,d,f,y){var C,k=arguments.length,E=k<3?d:y===null?y=Object.getOwnPropertyDescriptor(d,f):y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(h,d,f,y);else for(var b=h.length-1;b>=0;b--)(C=h[b])&&(E=(k<3?C(E):k>3?C(d,f,E):C(d,f))||E);return k>3&&E&&Object.defineProperty(d,f,E),E},u=this&&this.__param||function(h,d){return function(f,y){d(f,y,h)}};Object.defineProperty(n,"__esModule",{value:!0}),n.Viewport=void 0;const c=i(3656),g=i(4725),x=i(8460),S=i(844),w=i(2585);let l=n.Viewport=class extends S.Disposable{constructor(h,d,f,y,C,k,E,b){super(),this._viewportElement=h,this._scrollArea=d,this._bufferService=f,this._optionsService=y,this._charSizeService=C,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 x.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,c.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((j=>this._activeBuffer=j.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((j=>this._renderDimensions=j))),this._handleThemeChange(b.colors),this.register(b.onChangeColors((j=>this._handleThemeChange(j)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(h){this._viewportElement.style.backgroundColor=h.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(h){if(h)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 d=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderService.dimensions.css.canvas.height);this._lastRecordedBufferHeight!==d&&(this._lastRecordedBufferHeight=d,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const h=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==h&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=h),this._refreshAnimationFrame=null}syncScrollArea(h=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(h);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(h)}_handleScroll(h){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 d=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:d,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const h=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(h*(this._smoothScrollState.target-this._smoothScrollState.origin)),h<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(h,d){const f=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(d<0&&this._viewportElement.scrollTop!==0||d>0&&f<this._lastRecordedBufferHeight)||(h.cancelable&&h.preventDefault(),!1)}handleWheel(h){const d=this._getPixelsScrolled(h);return d!==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+d:this._smoothScrollState.target+=d,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=d,this._bubbleScroll(h,d))}scrollLines(h){if(h!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const d=h*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+d,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:h,suppressScrollEvent:!1})}_getPixelsScrolled(h){if(h.deltaY===0||h.shiftKey)return 0;let d=this._applyScrollModifier(h.deltaY,h);return h.deltaMode===WheelEvent.DOM_DELTA_LINE?d*=this._currentRowHeight:h.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(d*=this._currentRowHeight*this._bufferService.rows),d}getBufferElements(h,d){var f;let y,C="";const k=[],E=d??this._bufferService.buffer.lines.length,b=this._bufferService.buffer.lines;for(let j=h;j<E;j++){const R=b.get(j);if(!R)continue;const L=(f=b.get(j+1))===null||f===void 0?void 0:f.isWrapped;if(C+=R.translateToString(!L),!L||j===b.length-1){const T=document.createElement("div");T.textContent=C,k.push(T),C.length>0&&(y=T),C=""}}return{bufferElements:k,cursorElement:y}}getLinesScrolled(h){if(h.deltaY===0||h.shiftKey)return 0;let d=this._applyScrollModifier(h.deltaY,h);return h.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(d/=this._currentRowHeight+0,this._wheelPartialScroll+=d,d=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):h.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(d*=this._bufferService.rows),d}_applyScrollModifier(h,d){const f=this._optionsService.rawOptions.fastScrollModifier;return f==="alt"&&d.altKey||f==="ctrl"&&d.ctrlKey||f==="shift"&&d.shiftKey?h*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:h*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(h){this._lastTouchY=h.touches[0].pageY}handleTouchMove(h){const d=this._lastTouchY-h.touches[0].pageY;return this._lastTouchY=h.touches[0].pageY,d!==0&&(this._viewportElement.scrollTop+=d,this._bubbleScroll(h,d))}};n.Viewport=l=a([u(2,w.IBufferService),u(3,w.IOptionsService),u(4,g.ICharSizeService),u(5,g.IRenderService),u(6,g.ICoreBrowserService),u(7,g.IThemeService)],l)},3107:function(v,n,i){var a=this&&this.__decorate||function(l,h,d,f){var y,C=arguments.length,k=C<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(l,h,d,f);else for(var E=l.length-1;E>=0;E--)(y=l[E])&&(k=(C<3?y(k):C>3?y(h,d,k):y(h,d))||k);return C>3&&k&&Object.defineProperty(h,d,k),k},u=this&&this.__param||function(l,h){return function(d,f){h(d,f,l)}};Object.defineProperty(n,"__esModule",{value:!0}),n.BufferDecorationRenderer=void 0;const c=i(3656),g=i(4725),x=i(844),S=i(2585);let w=n.BufferDecorationRenderer=class extends x.Disposable{constructor(l,h,d,f){super(),this._screenElement=l,this._bufferService=h,this._decorationService=d,this._renderService=f,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,c.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((y=>this._removeDecoration(y)))),this.register((0,x.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 l of this._decorationService.decorations)this._renderDecoration(l);this._dimensionsChanged=!1}_renderDecoration(l){this._refreshStyle(l),this._dimensionsChanged&&this._refreshXPosition(l)}_createElement(l){var h,d;const f=document.createElement("div");f.classList.add("xterm-decoration"),f.classList.toggle("xterm-decoration-top-layer",((h=l?.options)===null||h===void 0?void 0:h.layer)==="top"),f.style.width=`${Math.round((l.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,f.style.height=(l.options.height||1)*this._renderService.dimensions.css.cell.height+"px",f.style.top=(l.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",f.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const y=(d=l.options.x)!==null&&d!==void 0?d:0;return y&&y>this._bufferService.cols&&(f.style.display="none"),this._refreshXPosition(l,f),f}_refreshStyle(l){const h=l.marker.line-this._bufferService.buffers.active.ydisp;if(h<0||h>=this._bufferService.rows)l.element&&(l.element.style.display="none",l.onRenderEmitter.fire(l.element));else{let d=this._decorationElements.get(l);d||(d=this._createElement(l),l.element=d,this._decorationElements.set(l,d),this._container.appendChild(d),l.onDispose((()=>{this._decorationElements.delete(l),d.remove()}))),d.style.top=h*this._renderService.dimensions.css.cell.height+"px",d.style.display=this._altBufferIsActive?"none":"block",l.onRenderEmitter.fire(d)}}_refreshXPosition(l,h=l.element){var d;if(!h)return;const f=(d=l.options.x)!==null&&d!==void 0?d:0;(l.options.anchor||"left")==="right"?h.style.right=f?f*this._renderService.dimensions.css.cell.width+"px":"":h.style.left=f?f*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(l){var h;(h=this._decorationElements.get(l))===null||h===void 0||h.remove(),this._decorationElements.delete(l),l.dispose()}};n.BufferDecorationRenderer=w=a([u(1,S.IBufferService),u(2,S.IDecorationService),u(3,g.IRenderService)],w)},5871:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ColorZoneStore=void 0,n.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(i){if(i.options.overviewRulerOptions){for(const a of this._zones)if(a.color===i.options.overviewRulerOptions.color&&a.position===i.options.overviewRulerOptions.position){if(this._lineIntersectsZone(a,i.marker.line))return;if(this._lineAdjacentToZone(a,i.marker.line,i.options.overviewRulerOptions.position))return void this._addLineToZone(a,i.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=i.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=i.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=i.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=i.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:i.options.overviewRulerOptions.color,position:i.options.overviewRulerOptions.position,startBufferLine:i.marker.line,endBufferLine:i.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(i){this._linePadding=i}_lineIntersectsZone(i,a){return a>=i.startBufferLine&&a<=i.endBufferLine}_lineAdjacentToZone(i,a,u){return a>=i.startBufferLine-this._linePadding[u||"full"]&&a<=i.endBufferLine+this._linePadding[u||"full"]}_addLineToZone(i,a){i.startBufferLine=Math.min(i.startBufferLine,a),i.endBufferLine=Math.max(i.endBufferLine,a)}}},5744:function(v,n,i){var a=this&&this.__decorate||function(y,C,k,E){var b,j=arguments.length,R=j<3?C:E===null?E=Object.getOwnPropertyDescriptor(C,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(y,C,k,E);else for(var L=y.length-1;L>=0;L--)(b=y[L])&&(R=(j<3?b(R):j>3?b(C,k,R):b(C,k))||R);return j>3&&R&&Object.defineProperty(C,k,R),R},u=this&&this.__param||function(y,C){return function(k,E){C(k,E,y)}};Object.defineProperty(n,"__esModule",{value:!0}),n.OverviewRulerRenderer=void 0;const c=i(5871),g=i(3656),x=i(4725),S=i(844),w=i(2585),l={full:0,left:0,center:0,right:0},h={full:0,left:0,center:0,right:0},d={full:0,left:0,center:0,right:0};let f=n.OverviewRulerRenderer=class extends S.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(y,C,k,E,b,j,R){var L;super(),this._viewportElement=y,this._screenElement=C,this._bufferService=k,this._decorationService=E,this._renderService=b,this._optionsService=j,this._coreBrowseService=R,this._colorZoneStore=new c.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 T=this._canvas.getContext("2d");if(!T)throw new Error("Ctx cannot be null");this._ctx=T,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,S.toDisposable)((()=>{var D;(D=this._canvas)===null||D===void 0||D.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 y=Math.floor(this._canvas.width/3),C=Math.ceil(this._canvas.width/3);h.full=this._canvas.width,h.left=y,h.center=C,h.right=y,this._refreshDrawHeightConstants(),d.full=0,d.left=0,d.center=h.left,d.right=h.left+h.center}_refreshDrawHeightConstants(){l.full=Math.round(2*this._coreBrowseService.dpr);const y=this._canvas.height/this._bufferService.buffer.lines.length,C=Math.round(Math.max(Math.min(y,12),6)*this._coreBrowseService.dpr);l.left=C,l.center=C,l.right=C}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.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 C of this._decorationService.decorations)this._colorZoneStore.addDecoration(C);this._ctx.lineWidth=1;const y=this._colorZoneStore.zones;for(const C of y)C.position!=="full"&&this._renderColorZone(C);for(const C of y)C.position==="full"&&this._renderColorZone(C);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(y){this._ctx.fillStyle=y.color,this._ctx.fillRect(d[y.position||"full"],Math.round((this._canvas.height-1)*(y.startBufferLine/this._bufferService.buffers.active.lines.length)-l[y.position||"full"]/2),h[y.position||"full"],Math.round((this._canvas.height-1)*((y.endBufferLine-y.startBufferLine)/this._bufferService.buffers.active.lines.length)+l[y.position||"full"]))}_queueRefresh(y,C){this._shouldUpdateDimensions=y||this._shouldUpdateDimensions,this._shouldUpdateAnchor=C||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowseService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};n.OverviewRulerRenderer=f=a([u(2,w.IBufferService),u(3,w.IDecorationService),u(4,x.IRenderService),u(5,w.IOptionsService),u(6,x.ICoreBrowserService)],f)},2950:function(v,n,i){var a=this&&this.__decorate||function(w,l,h,d){var f,y=arguments.length,C=y<3?l:d===null?d=Object.getOwnPropertyDescriptor(l,h):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(w,l,h,d);else for(var k=w.length-1;k>=0;k--)(f=w[k])&&(C=(y<3?f(C):y>3?f(l,h,C):f(l,h))||C);return y>3&&C&&Object.defineProperty(l,h,C),C},u=this&&this.__param||function(w,l){return function(h,d){l(h,d,w)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CompositionHelper=void 0;const c=i(4725),g=i(2585),x=i(2584);let S=n.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(w,l,h,d,f,y){this._textarea=w,this._compositionView=l,this._bufferService=h,this._optionsService=d,this._coreService=f,this._renderService=y,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(w){this._compositionView.textContent=w.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(w){if(this._isComposing||this._isSendingComposition){if(w.keyCode===229||w.keyCode===16||w.keyCode===17||w.keyCode===18)return!1;this._finalizeComposition(!1)}return w.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(w){if(this._compositionView.classList.remove("active"),this._isComposing=!1,w){const l={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let h;this._isSendingComposition=!1,l.start+=this._dataAlreadySent.length,h=this._isComposing?this._textarea.value.substring(l.start,l.end):this._textarea.value.substring(l.start),h.length>0&&this._coreService.triggerDataEvent(h,!0)}}),0)}else{this._isSendingComposition=!1;const l=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(l,!0)}}_handleAnyTextareaChanges(){const w=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const l=this._textarea.value,h=l.replace(w,"");this._dataAlreadySent=h,l.length>w.length?this._coreService.triggerDataEvent(h,!0):l.length<w.length?this._coreService.triggerDataEvent(`${x.C0.DEL}`,!0):l.length===w.length&&l!==w&&this._coreService.triggerDataEvent(l,!0)}}),0)}updateCompositionElements(w){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const l=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),h=this._renderService.dimensions.css.cell.height,d=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,f=l*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=f+"px",this._compositionView.style.top=d+"px",this._compositionView.style.height=h+"px",this._compositionView.style.lineHeight=h+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const y=this._compositionView.getBoundingClientRect();this._textarea.style.left=f+"px",this._textarea.style.top=d+"px",this._textarea.style.width=Math.max(y.width,1)+"px",this._textarea.style.height=Math.max(y.height,1)+"px",this._textarea.style.lineHeight=y.height+"px"}w||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};n.CompositionHelper=S=a([u(2,g.IBufferService),u(3,g.IOptionsService),u(4,g.ICoreService),u(5,c.IRenderService)],S)},9806:(v,n)=>{function i(a,u,c){const g=c.getBoundingClientRect(),x=a.getComputedStyle(c),S=parseInt(x.getPropertyValue("padding-left")),w=parseInt(x.getPropertyValue("padding-top"));return[u.clientX-g.left-S,u.clientY-g.top-w]}Object.defineProperty(n,"__esModule",{value:!0}),n.getCoords=n.getCoordsRelativeToElement=void 0,n.getCoordsRelativeToElement=i,n.getCoords=function(a,u,c,g,x,S,w,l,h){if(!S)return;const d=i(a,u,c);return d?(d[0]=Math.ceil((d[0]+(h?w/2:0))/w),d[1]=Math.ceil(d[1]/l),d[0]=Math.min(Math.max(d[0],1),g+(h?1:0)),d[1]=Math.min(Math.max(d[1],1),x),d):void 0}},9504:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.moveToCellSequence=void 0;const a=i(2584);function u(l,h,d,f){const y=l-c(l,d),C=h-c(h,d),k=Math.abs(y-C)-(function(E,b,j){let R=0;const L=E-c(E,j),T=b-c(b,j);for(let D=0;D<Math.abs(L-T);D++){const F=g(E,b)==="A"?-1:1,I=j.buffer.lines.get(L+F*D);I?.isWrapped&&R++}return R})(l,h,d);return w(k,S(g(l,h),f))}function c(l,h){let d=0,f=h.buffer.lines.get(l),y=f?.isWrapped;for(;y&&l>=0&&l<h.rows;)d++,f=h.buffer.lines.get(--l),y=f?.isWrapped;return d}function g(l,h){return l>h?"A":"B"}function x(l,h,d,f,y,C){let k=l,E=h,b="";for(;k!==d||E!==f;)k+=y?1:-1,y&&k>C.cols-1?(b+=C.buffer.translateBufferLineToString(E,!1,l,k),k=0,l=0,E++):!y&&k<0&&(b+=C.buffer.translateBufferLineToString(E,!1,0,l+1),k=C.cols-1,l=k,E--);return b+C.buffer.translateBufferLineToString(E,!1,l,k)}function S(l,h){const d=h?"O":"[";return a.C0.ESC+d+l}function w(l,h){l=Math.floor(l);let d="";for(let f=0;f<l;f++)d+=h;return d}n.moveToCellSequence=function(l,h,d,f){const y=d.buffer.x,C=d.buffer.y;if(!d.buffer.hasScrollback)return(function(b,j,R,L,T,D){return u(j,L,T,D).length===0?"":w(x(b,j,b,j-c(j,T),!1,T).length,S("D",D))})(y,C,0,h,d,f)+u(C,h,d,f)+(function(b,j,R,L,T,D){let F;F=u(j,L,T,D).length>0?L-c(L,T):j;const I=L,H=(function(K,A,P,M,O,$){let U;return U=u(P,M,O,$).length>0?M-c(M,O):A,K<P&&U<=M||K>=P&&U<M?"C":"D"})(b,j,R,L,T,D);return w(x(b,F,R,I,H==="C",T).length,S(H,D))})(y,C,l,h,d,f);let k;if(C===h)return k=y>l?"D":"C",w(Math.abs(y-l),S(k,f));k=C>h?"D":"C";const E=Math.abs(C-h);return w((function(b,j){return j.cols-b})(C>h?l:y,d)+(E-1)*d.cols+1+((C>h?y:l)-1),S(k,f))}},1296:function(v,n,i){var a=this&&this.__decorate||function(T,D,F,I){var H,K=arguments.length,A=K<3?D:I===null?I=Object.getOwnPropertyDescriptor(D,F):I;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(T,D,F,I);else for(var P=T.length-1;P>=0;P--)(H=T[P])&&(A=(K<3?H(A):K>3?H(D,F,A):H(D,F))||A);return K>3&&A&&Object.defineProperty(D,F,A),A},u=this&&this.__param||function(T,D){return function(F,I){D(F,I,T)}};Object.defineProperty(n,"__esModule",{value:!0}),n.DomRenderer=void 0;const c=i(3787),g=i(2550),x=i(2223),S=i(6171),w=i(4725),l=i(8055),h=i(8460),d=i(844),f=i(2585),y="xterm-dom-renderer-owner-",C="xterm-rows",k="xterm-fg-",E="xterm-bg-",b="xterm-focus",j="xterm-selection";let R=1,L=n.DomRenderer=class extends d.Disposable{constructor(T,D,F,I,H,K,A,P,M,O){super(),this._element=T,this._screenElement=D,this._viewportElement=F,this._linkifier2=I,this._charSizeService=K,this._optionsService=A,this._bufferService=P,this._coreBrowserService=M,this._themeService=O,this._terminalClass=R++,this._rowElements=[],this.onRequestRedraw=this.register(new h.EventEmitter).event,this._rowContainer=document.createElement("div"),this._rowContainer.classList.add(C),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(j),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,S.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors(($=>this._injectCss($)))),this._injectCss(this._themeService.colors),this._rowFactory=H.createInstance(c.DomRendererRowFactory,document),this._element.classList.add(y+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline(($=>this._handleLinkHover($)))),this.register(this._linkifier2.onHideLinkUnderline(($=>this._handleLinkLeave($)))),this.register((0,d.toDisposable)((()=>{this._element.classList.remove(y+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 T=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*T,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*T),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/T),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/T),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(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 D=`${this._terminalSelector} .${C} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=D,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(T){this._themeStyleElement||(this._themeStyleElement=document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let D=`${this._terminalSelector} .${C} { color: ${T.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;D+=`${this._terminalSelector} .${C} .xterm-dim { color: ${l.color.multiplyOpacity(T.foreground,.5).css};}`,D+=`${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;}`,D+="@keyframes blink_box_shadow_"+this._terminalClass+" { 50% { border-bottom-style: hidden; }}",D+="@keyframes blink_block_"+this._terminalClass+` { 0% { background-color: ${T.cursor.css}; color: ${T.cursorAccent.css}; } 50% { background-color: inherit; color: ${T.cursor.css}; }}`,D+=`${this._terminalSelector} .${C}.${b} .xterm-cursor.xterm-cursor-blink:not(.xterm-cursor-block) { animation: blink_box_shadow_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${C}.${b} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: blink_block_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-block { background-color: ${T.cursor.css}; color: ${T.cursorAccent.css};}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${T.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${T.cursor.css} inset;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${T.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,D+=`${this._terminalSelector} .${j} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${j} div { position: absolute; background-color: ${T.selectionBackgroundOpaque.css};}${this._terminalSelector} .${j} div { position: absolute; background-color: ${T.selectionInactiveBackgroundOpaque.css};}`;for(const[F,I]of T.ansi.entries())D+=`${this._terminalSelector} .${k}${F} { color: ${I.css}; }${this._terminalSelector} .${k}${F}.xterm-dim { color: ${l.color.multiplyOpacity(I,.5).css}; }${this._terminalSelector} .${E}${F} { background-color: ${I.css}; }`;D+=`${this._terminalSelector} .${k}${x.INVERTED_DEFAULT_COLOR} { color: ${l.color.opaque(T.background).css}; }${this._terminalSelector} .${k}${x.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${l.color.multiplyOpacity(l.color.opaque(T.background),.5).css}; }${this._terminalSelector} .${E}${x.INVERTED_DEFAULT_COLOR} { background-color: ${T.foreground.css}; }`,this._themeStyleElement.textContent=D}_setDefaultSpacing(){const T=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${T}px`,this._rowFactory.defaultSpacing=T}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(T,D){for(let F=this._rowElements.length;F<=D;F++){const I=document.createElement("div");this._rowContainer.appendChild(I),this._rowElements.push(I)}for(;this._rowElements.length>D;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(T,D){this._refreshRowElements(T,D),this._updateDimensions()}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(b)}handleFocus(){this._rowContainer.classList.add(b),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(T,D,F){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(T,D,F),this.renderRows(0,this._bufferService.rows-1),!T||!D)return;const I=T[1]-this._bufferService.buffer.ydisp,H=D[1]-this._bufferService.buffer.ydisp,K=Math.max(I,0),A=Math.min(H,this._bufferService.rows-1);if(K>=this._bufferService.rows||A<0)return;const P=document.createDocumentFragment();if(F){const M=T[0]>D[0];P.appendChild(this._createSelectionElement(K,M?D[0]:T[0],M?T[0]:D[0],A-K+1))}else{const M=I===K?T[0]:0,O=K===H?D[0]:this._bufferService.cols;P.appendChild(this._createSelectionElement(K,M,O));const $=A-K-1;if(P.appendChild(this._createSelectionElement(K+1,0,this._bufferService.cols,$)),K!==A){const U=H===A?D[0]:this._bufferService.cols;P.appendChild(this._createSelectionElement(A,0,U))}}this._selectionContainer.appendChild(P)}_createSelectionElement(T,D,F,I=1){const H=document.createElement("div");return H.style.height=I*this.dimensions.css.cell.height+"px",H.style.top=T*this.dimensions.css.cell.height+"px",H.style.left=D*this.dimensions.css.cell.width+"px",H.style.width=this.dimensions.css.cell.width*(F-D)+"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 T of this._rowElements)T.replaceChildren()}renderRows(T,D){const F=this._bufferService.buffer,I=F.ybase+F.y,H=Math.min(F.x,this._bufferService.cols-1),K=this._optionsService.rawOptions.cursorBlink,A=this._optionsService.rawOptions.cursorStyle,P=this._optionsService.rawOptions.cursorInactiveStyle;for(let M=T;M<=D;M++){const O=M+F.ydisp,$=this._rowElements[M],U=F.lines.get(O);if(!$||!U)break;$.replaceChildren(...this._rowFactory.createRow(U,O,O===I,A,P,H,K,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${y}${this._terminalClass}`}_handleLinkHover(T){this._setCellUnderline(T.x1,T.x2,T.y1,T.y2,T.cols,!0)}_handleLinkLeave(T){this._setCellUnderline(T.x1,T.x2,T.y1,T.y2,T.cols,!1)}_setCellUnderline(T,D,F,I,H,K){F<0&&(T=0),I<0&&(D=0);const A=this._bufferService.rows-1;F=Math.max(Math.min(F,A),0),I=Math.max(Math.min(I,A),0),H=Math.min(H,this._bufferService.cols);const P=this._bufferService.buffer,M=P.ybase+P.y,O=Math.min(P.x,H-1),$=this._optionsService.rawOptions.cursorBlink,U=this._optionsService.rawOptions.cursorStyle,B=this._optionsService.rawOptions.cursorInactiveStyle;for(let z=F;z<=I;++z){const q=z+P.ydisp,N=this._rowElements[z],W=P.lines.get(q);if(!N||!W)break;N.replaceChildren(...this._rowFactory.createRow(W,q,q===M,U,B,O,$,this.dimensions.css.cell.width,this._widthCache,K?z===F?T:0:-1,K?(z===I?D:H)-1:-1))}}};n.DomRenderer=L=a([u(4,f.IInstantiationService),u(5,w.ICharSizeService),u(6,f.IOptionsService),u(7,f.IBufferService),u(8,w.ICoreBrowserService),u(9,w.IThemeService)],L)},3787:function(v,n,i){var a=this&&this.__decorate||function(k,E,b,j){var R,L=arguments.length,T=L<3?E:j===null?j=Object.getOwnPropertyDescriptor(E,b):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(k,E,b,j);else for(var D=k.length-1;D>=0;D--)(R=k[D])&&(T=(L<3?R(T):L>3?R(E,b,T):R(E,b))||T);return L>3&&T&&Object.defineProperty(E,b,T),T},u=this&&this.__param||function(k,E){return function(b,j){E(b,j,k)}};Object.defineProperty(n,"__esModule",{value:!0}),n.DomRendererRowFactory=void 0;const c=i(2223),g=i(643),x=i(511),S=i(2585),w=i(8055),l=i(4725),h=i(4269),d=i(6171),f=i(3734);let y=n.DomRendererRowFactory=class{constructor(k,E,b,j,R,L,T){this._document=k,this._characterJoinerService=E,this._optionsService=b,this._coreBrowserService=j,this._coreService=R,this._decorationService=L,this._themeService=T,this._workCell=new x.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(k,E,b){this._selectionStart=k,this._selectionEnd=E,this._columnSelectMode=b}createRow(k,E,b,j,R,L,T,D,F,I,H){const K=[],A=this._characterJoinerService.getJoinedCharacters(E),P=this._themeService.colors;let M,O=k.getNoBgTrimmedLength();b&&O<L+1&&(O=L+1);let $=0,U="",B=0,z=0,q=0,N=!1,W=0,X=!1,V=0;const ie=[],ee=I!==-1&&H!==-1;for(let pe=0;pe<O;pe++){k.loadCell(pe,this._workCell);let he=this._workCell.getWidth();if(he===0)continue;let G=!1,ge=pe,ne=this._workCell;if(A.length>0&&pe===A[0][0]){G=!0;const be=A.shift();ne=new h.JoinedCellData(this._workCell,k.translateToString(!0,be[0],be[1]),be[1]-be[0]),ge=be[1]-1,he=ne.getWidth()}const Re=this._isCellInSelection(pe,E),Ze=b&&pe===L,Xe=ee&&pe>=I&&pe<=H;let ye=!1;this._decorationService.forEachDecorationAtCell(pe,E,void 0,(be=>{ye=!0}));let He=ne.getChars()||g.WHITESPACE_CELL_CHAR;if(He===" "&&(ne.isUnderline()||ne.isOverline())&&(He=" "),V=he*D-F.get(He,ne.isBold(),ne.isItalic()),M){if($&&(Re&&X||!Re&&!X&&ne.bg===B)&&(Re&&X&&P.selectionForeground||ne.fg===z)&&ne.extended.ext===q&&Xe===N&&V===W&&!Ze&&!G&&!ye){U+=He,$++;continue}$&&(M.textContent=U),M=this._document.createElement("span"),$=0,U=""}else M=this._document.createElement("span");if(B=ne.bg,z=ne.fg,q=ne.extended.ext,N=Xe,W=V,X=Re,G&&L>=pe&&L<=ge&&(L=pe),!this._coreService.isCursorHidden&&Ze){if(ie.push("xterm-cursor"),this._coreBrowserService.isFocused)T&&ie.push("xterm-cursor-blink"),ie.push(j==="bar"?"xterm-cursor-bar":j==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(R)switch(R){case"outline":ie.push("xterm-cursor-outline");break;case"block":ie.push("xterm-cursor-block");break;case"bar":ie.push("xterm-cursor-bar");break;case"underline":ie.push("xterm-cursor-underline")}}if(ne.isBold()&&ie.push("xterm-bold"),ne.isItalic()&&ie.push("xterm-italic"),ne.isDim()&&ie.push("xterm-dim"),U=ne.isInvisible()?g.WHITESPACE_CELL_CHAR:ne.getChars()||g.WHITESPACE_CELL_CHAR,ne.isUnderline()&&(ie.push(`xterm-underline-${ne.extended.underlineStyle}`),U===" "&&(U=" "),!ne.isUnderlineColorDefault()))if(ne.isUnderlineColorRGB())M.style.textDecorationColor=`rgb(${f.AttributeData.toColorRGB(ne.getUnderlineColor()).join(",")})`;else{let be=ne.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&ne.isBold()&&be<8&&(be+=8),M.style.textDecorationColor=P.ansi[be].css}ne.isOverline()&&(ie.push("xterm-overline"),U===" "&&(U=" ")),ne.isStrikethrough()&&ie.push("xterm-strikethrough"),Xe&&(M.style.textDecoration="underline");let Ie=ne.getFgColor(),tt=ne.getFgColorMode(),Ke=ne.getBgColor(),Be=ne.getBgColorMode();const Je=!!ne.isInverse();if(Je){const be=Ie;Ie=Ke,Ke=be;const pt=tt;tt=Be,Be=pt}let Te,je,_e,$e=!1;switch(this._decorationService.forEachDecorationAtCell(pe,E,void 0,(be=>{be.options.layer!=="top"&&$e||(be.backgroundColorRGB&&(Be=50331648,Ke=be.backgroundColorRGB.rgba>>8&16777215,Te=be.backgroundColorRGB),be.foregroundColorRGB&&(tt=50331648,Ie=be.foregroundColorRGB.rgba>>8&16777215,je=be.foregroundColorRGB),$e=be.options.layer==="top")})),!$e&&Re&&(Te=this._coreBrowserService.isFocused?P.selectionBackgroundOpaque:P.selectionInactiveBackgroundOpaque,Ke=Te.rgba>>8&16777215,Be=50331648,$e=!0,P.selectionForeground&&(tt=50331648,Ie=P.selectionForeground.rgba>>8&16777215,je=P.selectionForeground)),$e&&ie.push("xterm-decoration-top"),Be){case 16777216:case 33554432:_e=P.ansi[Ke],ie.push(`xterm-bg-${Ke}`);break;case 50331648:_e=w.rgba.toColor(Ke>>16,Ke>>8&255,255&Ke),this._addStyle(M,`background-color:#${C((Ke>>>0).toString(16),"0",6)}`);break;default:Je?(_e=P.foreground,ie.push(`xterm-bg-${c.INVERTED_DEFAULT_COLOR}`)):_e=P.background}switch(Te||ne.isDim()&&(Te=w.color.multiplyOpacity(_e,.5)),tt){case 16777216:case 33554432:ne.isBold()&&Ie<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Ie+=8),this._applyMinimumContrast(M,_e,P.ansi[Ie],ne,Te,void 0)||ie.push(`xterm-fg-${Ie}`);break;case 50331648:const be=w.rgba.toColor(Ie>>16&255,Ie>>8&255,255&Ie);this._applyMinimumContrast(M,_e,be,ne,Te,je)||this._addStyle(M,`color:#${C(Ie.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(M,_e,P.foreground,ne,Te,void 0)||Je&&ie.push(`xterm-fg-${c.INVERTED_DEFAULT_COLOR}`)}ie.length&&(M.className=ie.join(" "),ie.length=0),Ze||G||ye?M.textContent=U:$++,V!==this.defaultSpacing&&(M.style.letterSpacing=`${V}px`),K.push(M),pe=ge}return M&&$&&(M.textContent=U),K}_applyMinimumContrast(k,E,b,j,R,L){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,d.excludeFromContrastRatioDemands)(j.getCode()))return!1;const T=this._getContrastCache(j);let D;if(R||L||(D=T.getColor(E.rgba,b.rgba)),D===void 0){const F=this._optionsService.rawOptions.minimumContrastRatio/(j.isDim()?2:1);D=w.color.ensureContrastRatio(R||E,L||b,F),T.setColor((R||E).rgba,(L||b).rgba,D??null)}return!!D&&(this._addStyle(k,`color:${D.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 b=this._selectionStart,j=this._selectionEnd;return!(!b||!j)&&(this._columnSelectMode?b[0]<=j[0]?k>=b[0]&&E>=b[1]&&k<j[0]&&E<=j[1]:k<b[0]&&E>=b[1]&&k>=j[0]&&E<=j[1]:E>b[1]&&E<j[1]||b[1]===j[1]&&E===b[1]&&k>=b[0]&&k<j[0]||b[1]<j[1]&&E===j[1]&&k<j[0]||b[1]<j[1]&&E===b[1]&&k>=b[0])}};function C(k,E,b){for(;k.length<b;)k=E+k;return k}n.DomRendererRowFactory=y=a([u(1,l.ICharacterJoinerService),u(2,S.IOptionsService),u(3,l.ICoreBrowserService),u(4,S.ICoreService),u(5,S.IDecorationService),u(6,l.IThemeService)],y)},2550:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.WidthCache=void 0,n.WidthCache=class{constructor(i){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=i.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 a=i.createElement("span"),u=i.createElement("span");u.style.fontWeight="bold";const c=i.createElement("span");c.style.fontStyle="italic";const g=i.createElement("span");g.style.fontWeight="bold",g.style.fontStyle="italic",this._measureElements=[a,u,c,g],this._container.appendChild(a),this._container.appendChild(u),this._container.appendChild(c),this._container.appendChild(g),i.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(i,a,u,c){i===this._font&&a===this._fontSize&&u===this._weight&&c===this._weightBold||(this._font=i,this._fontSize=a,this._weight=u,this._weightBold=c,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${u}`,this._measureElements[1].style.fontWeight=`${c}`,this._measureElements[2].style.fontWeight=`${u}`,this._measureElements[3].style.fontWeight=`${c}`,this.clear())}get(i,a,u){let c=0;if(!a&&!u&&i.length===1&&(c=i.charCodeAt(0))<256)return this._flat[c]!==-9999?this._flat[c]:this._flat[c]=this._measure(i,0);let g=i;a&&(g+="B"),u&&(g+="I");let x=this._holey.get(g);if(x===void 0){let S=0;a&&(S|=1),u&&(S|=2),x=this._measure(i,S),this._holey.set(g,x)}return x}_measure(i,a){const u=this._measureElements[a];return u.textContent=i.repeat(32),u.offsetWidth/32}}},2223:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.TEXT_BASELINE=n.DIM_OPACITY=n.INVERTED_DEFAULT_COLOR=void 0;const a=i(6114);n.INVERTED_DEFAULT_COLOR=257,n.DIM_OPACITY=.5,n.TEXT_BASELINE=a.isFirefox||a.isLegacyEdge?"bottom":"ideographic"},6171:(v,n)=>{function i(a){return 57508<=a&&a<=57558}Object.defineProperty(n,"__esModule",{value:!0}),n.createRenderDimensions=n.excludeFromContrastRatioDemands=n.isRestrictedPowerlineGlyph=n.isPowerlineGlyph=n.throwIfFalsy=void 0,n.throwIfFalsy=function(a){if(!a)throw new Error("value must not be falsy");return a},n.isPowerlineGlyph=i,n.isRestrictedPowerlineGlyph=function(a){return 57520<=a&&a<=57527},n.excludeFromContrastRatioDemands=function(a){return i(a)||(function(u){return 9472<=u&&u<=9631})(a)},n.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:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.SelectionModel=void 0,n.SelectionModel=class{constructor(i){this._bufferService=i,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 i=this.selectionStart[0]+this.selectionStartLength;return i>this._bufferService.cols?i%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)-1]:[i%this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)]:[i,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const i=this.selectionStart[0]+this.selectionStartLength;return i>this._bufferService.cols?[i%this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)]:[Math.max(i,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const i=this.selectionStart,a=this.selectionEnd;return!(!i||!a)&&(i[1]>a[1]||i[1]===a[1]&&i[0]>a[0])}handleTrim(i){return this.selectionStart&&(this.selectionStart[1]-=i),this.selectionEnd&&(this.selectionEnd[1]-=i),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(v,n,i){var a=this&&this.__decorate||function(l,h,d,f){var y,C=arguments.length,k=C<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(l,h,d,f);else for(var E=l.length-1;E>=0;E--)(y=l[E])&&(k=(C<3?y(k):C>3?y(h,d,k):y(h,d))||k);return C>3&&k&&Object.defineProperty(h,d,k),k},u=this&&this.__param||function(l,h){return function(d,f){h(d,f,l)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CharSizeService=void 0;const c=i(2585),g=i(8460),x=i(844);let S=n.CharSizeService=class extends x.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(l,h,d){super(),this._optionsService=d,this.width=0,this.height=0,this._onCharSizeChange=this.register(new g.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event,this._measureStrategy=new w(l,h,this._optionsService),this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const l=this._measureStrategy.measure();l.width===this.width&&l.height===this.height||(this.width=l.width,this.height=l.height,this._onCharSizeChange.fire())}};n.CharSizeService=S=a([u(2,c.IOptionsService)],S);class w{constructor(h,d,f){this._document=h,this._parentElement=d,this._optionsService=f,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 h={height:Number(this._measureElement.offsetHeight),width:Number(this._measureElement.offsetWidth)};return h.width!==0&&h.height!==0&&(this._result.width=h.width/32,this._result.height=Math.ceil(h.height)),this._result}}},4269:function(v,n,i){var a=this&&this.__decorate||function(h,d,f,y){var C,k=arguments.length,E=k<3?d:y===null?y=Object.getOwnPropertyDescriptor(d,f):y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(h,d,f,y);else for(var b=h.length-1;b>=0;b--)(C=h[b])&&(E=(k<3?C(E):k>3?C(d,f,E):C(d,f))||E);return k>3&&E&&Object.defineProperty(d,f,E),E},u=this&&this.__param||function(h,d){return function(f,y){d(f,y,h)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CharacterJoinerService=n.JoinedCellData=void 0;const c=i(3734),g=i(643),x=i(511),S=i(2585);class w extends c.AttributeData{constructor(d,f,y){super(),this.content=0,this.combinedData="",this.fg=d.fg,this.bg=d.bg,this.combinedData=f,this._width=y}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(d){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}n.JoinedCellData=w;let l=n.CharacterJoinerService=class zl{constructor(d){this._bufferService=d,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new x.CellData}register(d){const f={id:this._nextCharacterJoinerId++,handler:d};return this._characterJoiners.push(f),f.id}deregister(d){for(let f=0;f<this._characterJoiners.length;f++)if(this._characterJoiners[f].id===d)return this._characterJoiners.splice(f,1),!0;return!1}getJoinedCharacters(d){if(this._characterJoiners.length===0)return[];const f=this._bufferService.buffer.lines.get(d);if(!f||f.length===0)return[];const y=[],C=f.translateToString(!0);let k=0,E=0,b=0,j=f.getFg(0),R=f.getBg(0);for(let L=0;L<f.getTrimmedLength();L++)if(f.loadCell(L,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==j||this._workCell.bg!==R){if(L-k>1){const T=this._getJoinedRanges(C,b,E,f,k);for(let D=0;D<T.length;D++)y.push(T[D])}k=L,b=E,j=this._workCell.fg,R=this._workCell.bg}E+=this._workCell.getChars().length||g.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-k>1){const L=this._getJoinedRanges(C,b,E,f,k);for(let T=0;T<L.length;T++)y.push(L[T])}return y}_getJoinedRanges(d,f,y,C,k){const E=d.substring(f,y);let b=[];try{b=this._characterJoiners[0].handler(E)}catch(j){console.error(j)}for(let j=1;j<this._characterJoiners.length;j++)try{const R=this._characterJoiners[j].handler(E);for(let L=0;L<R.length;L++)zl._mergeRanges(b,R[L])}catch(R){console.error(R)}return this._stringRangesToCellRanges(b,C,k),b}_stringRangesToCellRanges(d,f,y){let C=0,k=!1,E=0,b=d[C];if(b){for(let j=y;j<this._bufferService.cols;j++){const R=f.getWidth(j),L=f.getString(j).length||g.WHITESPACE_CELL_CHAR.length;if(R!==0){if(!k&&b[0]<=E&&(b[0]=j,k=!0),b[1]<=E){if(b[1]=j,b=d[++C],!b)break;b[0]<=E?(b[0]=j,k=!0):k=!1}E+=L}}b&&(b[1]=this._bufferService.cols)}}static _mergeRanges(d,f){let y=!1;for(let C=0;C<d.length;C++){const k=d[C];if(y){if(f[1]<=k[0])return d[C-1][1]=f[1],d;if(f[1]<=k[1])return d[C-1][1]=Math.max(f[1],k[1]),d.splice(C,1),d;d.splice(C,1),C--}else{if(f[1]<=k[0])return d.splice(C,0,f),d;if(f[1]<=k[1])return k[0]=Math.min(f[0],k[0]),d;f[0]<k[1]&&(k[0]=Math.min(f[0],k[0]),y=!0)}}return y?d[d.length-1][1]=f[1]:d.push(f),d}};n.CharacterJoinerService=l=a([u(0,S.IBufferService)],l)},5114:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CoreBrowserService=void 0,n.CoreBrowserService=class{constructor(i,a){this._textarea=i,this.window=a,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(v,n,i){var a=this&&this.__decorate||function(S,w,l,h){var d,f=arguments.length,y=f<3?w:h===null?h=Object.getOwnPropertyDescriptor(w,l):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")y=Reflect.decorate(S,w,l,h);else for(var C=S.length-1;C>=0;C--)(d=S[C])&&(y=(f<3?d(y):f>3?d(w,l,y):d(w,l))||y);return f>3&&y&&Object.defineProperty(w,l,y),y},u=this&&this.__param||function(S,w){return function(l,h){w(l,h,S)}};Object.defineProperty(n,"__esModule",{value:!0}),n.MouseService=void 0;const c=i(4725),g=i(9806);let x=n.MouseService=class{constructor(S,w){this._renderService=S,this._charSizeService=w}getCoords(S,w,l,h,d){return(0,g.getCoords)(window,S,w,l,h,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,d)}getMouseReportCoords(S,w){const l=(0,g.getCoordsRelativeToElement)(window,S,w);if(this._charSizeService.hasValidSize)return l[0]=Math.min(Math.max(l[0],0),this._renderService.dimensions.css.canvas.width-1),l[1]=Math.min(Math.max(l[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(l[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(l[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(l[0]),y:Math.floor(l[1])}}};n.MouseService=x=a([u(0,c.IRenderService),u(1,c.ICharSizeService)],x)},3230:function(v,n,i){var a=this&&this.__decorate||function(y,C,k,E){var b,j=arguments.length,R=j<3?C:E===null?E=Object.getOwnPropertyDescriptor(C,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(y,C,k,E);else for(var L=y.length-1;L>=0;L--)(b=y[L])&&(R=(j<3?b(R):j>3?b(C,k,R):b(C,k))||R);return j>3&&R&&Object.defineProperty(C,k,R),R},u=this&&this.__param||function(y,C){return function(k,E){C(k,E,y)}};Object.defineProperty(n,"__esModule",{value:!0}),n.RenderService=void 0;const c=i(3656),g=i(6193),x=i(5596),S=i(4725),w=i(8460),l=i(844),h=i(7226),d=i(2585);let f=n.RenderService=class extends l.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(y,C,k,E,b,j,R,L){if(super(),this._rowCount=y,this._charSizeService=E,this._renderer=this.register(new l.MutableDisposable),this._pausedResizeTask=new h.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 w.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new w.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new w.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new w.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new g.RenderDebouncer(R.window,((T,D)=>this._renderRows(T,D))),this.register(this._renderDebouncer),this._screenDprMonitor=new x.ScreenDprMonitor(R.window),this._screenDprMonitor.setListener((()=>this.handleDevicePixelRatioChange())),this.register(this._screenDprMonitor),this.register(j.onResize((()=>this._fullRefresh()))),this.register(j.buffers.onBufferActivate((()=>{var T;return(T=this._renderer.value)===null||T===void 0?void 0:T.clear()}))),this.register(k.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(b.onDecorationRegistered((()=>this._fullRefresh()))),this.register(b.onDecorationRemoved((()=>this._fullRefresh()))),this.register(k.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio"],(()=>{this.clear(),this.handleResize(j.cols,j.rows),this._fullRefresh()}))),this.register(k.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(j.buffer.y,j.buffer.y,!0)))),this.register((0,c.addDisposableDomListener)(R.window,"resize",(()=>this.handleDevicePixelRatioChange()))),this.register(L.onChangeColors((()=>this._fullRefresh()))),"IntersectionObserver"in R.window){const T=new R.window.IntersectionObserver((D=>this._handleIntersectionChange(D[D.length-1])),{threshold:0});T.observe(C),this.register({dispose:()=>T.disconnect()})}}_handleIntersectionChange(y){this._isPaused=y.isIntersecting===void 0?y.intersectionRatio===0:!y.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(y,C,k=!1){this._isPaused?this._needsFullRefresh=!0:(k||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(y,C,this._rowCount))}_renderRows(y,C){this._renderer.value&&(y=Math.min(y,this._rowCount-1),C=Math.min(C,this._rowCount-1),this._renderer.value.renderRows(y,C),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:y,end:C}),this._onRender.fire({start:y,end:C}),this._isNextRenderRedrawOnly=!0)}resize(y,C){this._rowCount=C,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(y){this._renderer.value=y,this._renderer.value.onRequestRedraw((C=>this.refreshRows(C.start,C.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh()}addRefreshCallback(y){return this._renderDebouncer.addRefreshCallback(y)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var y,C;this._renderer.value&&((C=(y=this._renderer.value).clearTextureAtlas)===null||C===void 0||C.call(y),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(y,C){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value.handleResize(y,C))):this._renderer.value.handleResize(y,C),this._fullRefresh())}handleCharSizeChanged(){var y;(y=this._renderer.value)===null||y===void 0||y.handleCharSizeChanged()}handleBlur(){var y;(y=this._renderer.value)===null||y===void 0||y.handleBlur()}handleFocus(){var y;(y=this._renderer.value)===null||y===void 0||y.handleFocus()}handleSelectionChanged(y,C,k){var E;this._selectionState.start=y,this._selectionState.end=C,this._selectionState.columnSelectMode=k,(E=this._renderer.value)===null||E===void 0||E.handleSelectionChanged(y,C,k)}handleCursorMove(){var y;(y=this._renderer.value)===null||y===void 0||y.handleCursorMove()}clear(){var y;(y=this._renderer.value)===null||y===void 0||y.clear()}};n.RenderService=f=a([u(2,d.IOptionsService),u(3,S.ICharSizeService),u(4,d.IDecorationService),u(5,d.IBufferService),u(6,S.ICoreBrowserService),u(7,S.IThemeService)],f)},9312:function(v,n,i){var a=this&&this.__decorate||function(b,j,R,L){var T,D=arguments.length,F=D<3?j:L===null?L=Object.getOwnPropertyDescriptor(j,R):L;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")F=Reflect.decorate(b,j,R,L);else for(var I=b.length-1;I>=0;I--)(T=b[I])&&(F=(D<3?T(F):D>3?T(j,R,F):T(j,R))||F);return D>3&&F&&Object.defineProperty(j,R,F),F},u=this&&this.__param||function(b,j){return function(R,L){j(R,L,b)}};Object.defineProperty(n,"__esModule",{value:!0}),n.SelectionService=void 0;const c=i(9806),g=i(9504),x=i(456),S=i(4725),w=i(8460),l=i(844),h=i(6114),d=i(4841),f=i(511),y=i(2585),C=" ",k=new RegExp(C,"g");let E=n.SelectionService=class extends l.Disposable{constructor(b,j,R,L,T,D,F,I,H){super(),this._element=b,this._screenElement=j,this._linkifier=R,this._bufferService=L,this._coreService=T,this._mouseService=D,this._optionsService=F,this._renderService=I,this._coreBrowserService=H,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new f.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new w.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new w.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new w.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new w.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=K=>this._handleMouseMove(K),this._mouseUpListener=K=>this._handleMouseUp(K),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((K=>this._handleTrim(K))),this.register(this._bufferService.buffers.onBufferActivate((K=>this._handleBufferActivate(K)))),this.enable(),this._model=new x.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,l.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 b=this._model.finalSelectionStart,j=this._model.finalSelectionEnd;return!(!b||!j||b[0]===j[0]&&b[1]===j[1])}get selectionText(){const b=this._model.finalSelectionStart,j=this._model.finalSelectionEnd;if(!b||!j)return"";const R=this._bufferService.buffer,L=[];if(this._activeSelectionMode===3){if(b[0]===j[0])return"";const T=b[0]<j[0]?b[0]:j[0],D=b[0]<j[0]?j[0]:b[0];for(let F=b[1];F<=j[1];F++){const I=R.translateBufferLineToString(F,!0,T,D);L.push(I)}}else{const T=b[1]===j[1]?j[0]:void 0;L.push(R.translateBufferLineToString(b[1],!0,b[0],T));for(let D=b[1]+1;D<=j[1]-1;D++){const F=R.lines.get(D),I=R.translateBufferLineToString(D,!0);F?.isWrapped?L[L.length-1]+=I:L.push(I)}if(b[1]!==j[1]){const D=R.lines.get(j[1]),F=R.translateBufferLineToString(j[1],!0,0,j[0]);D&&D.isWrapped?L[L.length-1]+=F:L.push(F)}}return L.map((T=>T.replace(k," "))).join(h.isWindows?`\r
|
|
24
|
+
`:`
|
|
25
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(b){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),h.isLinux&&b&&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(b){const j=this._getMouseBufferCoords(b),R=this._model.finalSelectionStart,L=this._model.finalSelectionEnd;return!!(R&&L&&j)&&this._areCoordsInSelection(j,R,L)}isCellInSelection(b,j){const R=this._model.finalSelectionStart,L=this._model.finalSelectionEnd;return!(!R||!L)&&this._areCoordsInSelection([b,j],R,L)}_areCoordsInSelection(b,j,R){return b[1]>j[1]&&b[1]<R[1]||j[1]===R[1]&&b[1]===j[1]&&b[0]>=j[0]&&b[0]<R[0]||j[1]<R[1]&&b[1]===R[1]&&b[0]<R[0]||j[1]<R[1]&&b[1]===j[1]&&b[0]>=j[0]}_selectWordAtCursor(b,j){var R,L;const T=(L=(R=this._linkifier.currentLink)===null||R===void 0?void 0:R.link)===null||L===void 0?void 0:L.range;if(T)return this._model.selectionStart=[T.start.x-1,T.start.y-1],this._model.selectionStartLength=(0,d.getRangeLength)(T,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const D=this._getMouseBufferCoords(b);return!!D&&(this._selectWordAt(D,j),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(b,j){this._model.clearSelection(),b=Math.max(b,0),j=Math.min(j,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,b],this._model.selectionEnd=[this._bufferService.cols,j],this.refresh(),this._onSelectionChange.fire()}_handleTrim(b){this._model.handleTrim(b)&&this.refresh()}_getMouseBufferCoords(b){const j=this._mouseService.getCoords(b,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(j)return j[0]--,j[1]--,j[1]+=this._bufferService.buffer.ydisp,j}_getMouseEventScrollAmount(b){let j=(0,c.getCoordsRelativeToElement)(this._coreBrowserService.window,b,this._screenElement)[1];const R=this._renderService.dimensions.css.canvas.height;return j>=0&&j<=R?0:(j>R&&(j-=R),j=Math.min(Math.max(j,-50),50),j/=50,j/Math.abs(j)+Math.round(14*j))}shouldForceSelection(b){return h.isMac?b.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:b.shiftKey}handleMouseDown(b){if(this._mouseDownTimeStamp=b.timeStamp,(b.button!==2||!this.hasSelection)&&b.button===0){if(!this._enabled){if(!this.shouldForceSelection(b))return;b.stopPropagation()}b.preventDefault(),this._dragScrollAmount=0,this._enabled&&b.shiftKey?this._handleIncrementalClick(b):b.detail===1?this._handleSingleClick(b):b.detail===2?this._handleDoubleClick(b):b.detail===3&&this._handleTripleClick(b),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(b){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(b))}_handleSingleClick(b){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(b)?3:0,this._model.selectionStart=this._getMouseBufferCoords(b),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const j=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);j&&j.length!==this._model.selectionStart[0]&&j.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(b){this._selectWordAtCursor(b,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(b){const j=this._getMouseBufferCoords(b);j&&(this._activeSelectionMode=2,this._selectLineAt(j[1]))}shouldColumnSelect(b){return b.altKey&&!(h.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(b){if(b.stopImmediatePropagation(),!this._model.selectionStart)return;const j=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(b),!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(b),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const R=this._bufferService.buffer;if(this._model.selectionEnd[1]<R.lines.length){const L=R.lines.get(this._model.selectionEnd[1]);L&&L.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]++}j&&j[0]===this._model.selectionEnd[0]&&j[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 b=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(b.ydisp+this._bufferService.rows,b.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=b.ydisp),this.refresh()}}_handleMouseUp(b){const j=b.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&j<500&&b.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const R=this._mouseService.getCoords(b,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(R&&R[0]!==void 0&&R[1]!==void 0){const L=(0,g.moveToCellSequence)(R[0]-1,R[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(L,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const b=this._model.finalSelectionStart,j=this._model.finalSelectionEnd,R=!(!b||!j||b[0]===j[0]&&b[1]===j[1]);R?b&&j&&(this._oldSelectionStart&&this._oldSelectionEnd&&b[0]===this._oldSelectionStart[0]&&b[1]===this._oldSelectionStart[1]&&j[0]===this._oldSelectionEnd[0]&&j[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(b,j,R)):this._oldHasSelection&&this._fireOnSelectionChange(b,j,R)}_fireOnSelectionChange(b,j,R){this._oldSelectionStart=b,this._oldSelectionEnd=j,this._oldHasSelection=R,this._onSelectionChange.fire()}_handleBufferActivate(b){this.clearSelection(),this._trimListener.dispose(),this._trimListener=b.activeBuffer.lines.onTrim((j=>this._handleTrim(j)))}_convertViewportColToCharacterIndex(b,j){let R=j;for(let L=0;j>=L;L++){const T=b.loadCell(L,this._workCell).getChars().length;this._workCell.getWidth()===0?R--:T>1&&j!==L&&(R+=T-1)}return R}setSelection(b,j,R){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[b,j],this._model.selectionStartLength=R,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(b){this._isClickInSelection(b)||(this._selectWordAtCursor(b,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(b,j,R=!0,L=!0){if(b[0]>=this._bufferService.cols)return;const T=this._bufferService.buffer,D=T.lines.get(b[1]);if(!D)return;const F=T.translateBufferLineToString(b[1],!1);let I=this._convertViewportColToCharacterIndex(D,b[0]),H=I;const K=b[0]-I;let A=0,P=0,M=0,O=0;if(F.charAt(I)===" "){for(;I>0&&F.charAt(I-1)===" ";)I--;for(;H<F.length&&F.charAt(H+1)===" ";)H++}else{let B=b[0],z=b[0];D.getWidth(B)===0&&(A++,B--),D.getWidth(z)===2&&(P++,z++);const q=D.getString(z).length;for(q>1&&(O+=q-1,H+=q-1);B>0&&I>0&&!this._isCharWordSeparator(D.loadCell(B-1,this._workCell));){D.loadCell(B-1,this._workCell);const N=this._workCell.getChars().length;this._workCell.getWidth()===0?(A++,B--):N>1&&(M+=N-1,I-=N-1),I--,B--}for(;z<D.length&&H+1<F.length&&!this._isCharWordSeparator(D.loadCell(z+1,this._workCell));){D.loadCell(z+1,this._workCell);const N=this._workCell.getChars().length;this._workCell.getWidth()===2?(P++,z++):N>1&&(O+=N-1,H+=N-1),H++,z++}}H++;let $=I+K-A+M,U=Math.min(this._bufferService.cols,H-I+A+P-M-O);if(j||F.slice(I,H).trim()!==""){if(R&&$===0&&D.getCodePoint(0)!==32){const B=T.lines.get(b[1]-1);if(B&&D.isWrapped&&B.getCodePoint(this._bufferService.cols-1)!==32){const z=this._getWordAt([this._bufferService.cols-1,b[1]-1],!1,!0,!1);if(z){const q=this._bufferService.cols-z.start;$-=q,U+=q}}}if(L&&$+U===this._bufferService.cols&&D.getCodePoint(this._bufferService.cols-1)!==32){const B=T.lines.get(b[1]+1);if(B?.isWrapped&&B.getCodePoint(0)!==32){const z=this._getWordAt([0,b[1]+1],!1,!1,!0);z&&(U+=z.length)}}return{start:$,length:U}}}_selectWordAt(b,j){const R=this._getWordAt(b,j);if(R){for(;R.start<0;)R.start+=this._bufferService.cols,b[1]--;this._model.selectionStart=[R.start,b[1]],this._model.selectionStartLength=R.length}}_selectToWordAt(b){const j=this._getWordAt(b,!0);if(j){let R=b[1];for(;j.start<0;)j.start+=this._bufferService.cols,R--;if(!this._model.areSelectionValuesReversed())for(;j.start+j.length>this._bufferService.cols;)j.length-=this._bufferService.cols,R++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?j.start:j.start+j.length,R]}}_isCharWordSeparator(b){return b.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(b.getChars())>=0}_selectLineAt(b){const j=this._bufferService.buffer.getWrappedRangeForLine(b),R={start:{x:0,y:j.first},end:{x:this._bufferService.cols-1,y:j.last}};this._model.selectionStart=[0,j.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,d.getRangeLength)(R,this._bufferService.cols)}};n.SelectionService=E=a([u(3,y.IBufferService),u(4,y.ICoreService),u(5,S.IMouseService),u(6,y.IOptionsService),u(7,S.IRenderService),u(8,S.ICoreBrowserService)],E)},4725:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.IThemeService=n.ICharacterJoinerService=n.ISelectionService=n.IRenderService=n.IMouseService=n.ICoreBrowserService=n.ICharSizeService=void 0;const a=i(8343);n.ICharSizeService=(0,a.createDecorator)("CharSizeService"),n.ICoreBrowserService=(0,a.createDecorator)("CoreBrowserService"),n.IMouseService=(0,a.createDecorator)("MouseService"),n.IRenderService=(0,a.createDecorator)("RenderService"),n.ISelectionService=(0,a.createDecorator)("SelectionService"),n.ICharacterJoinerService=(0,a.createDecorator)("CharacterJoinerService"),n.IThemeService=(0,a.createDecorator)("ThemeService")},6731:function(v,n,i){var a=this&&this.__decorate||function(E,b,j,R){var L,T=arguments.length,D=T<3?b:R===null?R=Object.getOwnPropertyDescriptor(b,j):R;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(E,b,j,R);else for(var F=E.length-1;F>=0;F--)(L=E[F])&&(D=(T<3?L(D):T>3?L(b,j,D):L(b,j))||D);return T>3&&D&&Object.defineProperty(b,j,D),D},u=this&&this.__param||function(E,b){return function(j,R){b(j,R,E)}};Object.defineProperty(n,"__esModule",{value:!0}),n.ThemeService=n.DEFAULT_ANSI_COLORS=void 0;const c=i(7239),g=i(8055),x=i(8460),S=i(844),w=i(2585),l=g.css.toColor("#ffffff"),h=g.css.toColor("#000000"),d=g.css.toColor("#ffffff"),f=g.css.toColor("#000000"),y={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};n.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")],b=[0,95,135,175,215,255];for(let j=0;j<216;j++){const R=b[j/36%6|0],L=b[j/6%6|0],T=b[j%6];E.push({css:g.channels.toCss(R,L,T),rgba:g.channels.toRgba(R,L,T)})}for(let j=0;j<24;j++){const R=8+10*j;E.push({css:g.channels.toCss(R,R,R),rgba:g.channels.toRgba(R,R,R)})}return E})());let C=n.ThemeService=class extends S.Disposable{get colors(){return this._colors}constructor(E){super(),this._optionsService=E,this._contrastCache=new c.ColorContrastCache,this._halfContrastCache=new c.ColorContrastCache,this._onChangeColors=this.register(new x.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:l,background:h,cursor:d,cursorAccent:f,selectionForeground:void 0,selectionBackgroundTransparent:y,selectionBackgroundOpaque:g.color.blend(h,y),selectionInactiveBackgroundTransparent:y,selectionInactiveBackgroundOpaque:g.color.blend(h,y),ansi:n.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 b=this._colors;if(b.foreground=k(E.foreground,l),b.background=k(E.background,h),b.cursor=k(E.cursor,d),b.cursorAccent=k(E.cursorAccent,f),b.selectionBackgroundTransparent=k(E.selectionBackground,y),b.selectionBackgroundOpaque=g.color.blend(b.background,b.selectionBackgroundTransparent),b.selectionInactiveBackgroundTransparent=k(E.selectionInactiveBackground,b.selectionBackgroundTransparent),b.selectionInactiveBackgroundOpaque=g.color.blend(b.background,b.selectionInactiveBackgroundTransparent),b.selectionForeground=E.selectionForeground?k(E.selectionForeground,g.NULL_COLOR):void 0,b.selectionForeground===g.NULL_COLOR&&(b.selectionForeground=void 0),g.color.isOpaque(b.selectionBackgroundTransparent)&&(b.selectionBackgroundTransparent=g.color.opacity(b.selectionBackgroundTransparent,.3)),g.color.isOpaque(b.selectionInactiveBackgroundTransparent)&&(b.selectionInactiveBackgroundTransparent=g.color.opacity(b.selectionInactiveBackgroundTransparent,.3)),b.ansi=n.DEFAULT_ANSI_COLORS.slice(),b.ansi[0]=k(E.black,n.DEFAULT_ANSI_COLORS[0]),b.ansi[1]=k(E.red,n.DEFAULT_ANSI_COLORS[1]),b.ansi[2]=k(E.green,n.DEFAULT_ANSI_COLORS[2]),b.ansi[3]=k(E.yellow,n.DEFAULT_ANSI_COLORS[3]),b.ansi[4]=k(E.blue,n.DEFAULT_ANSI_COLORS[4]),b.ansi[5]=k(E.magenta,n.DEFAULT_ANSI_COLORS[5]),b.ansi[6]=k(E.cyan,n.DEFAULT_ANSI_COLORS[6]),b.ansi[7]=k(E.white,n.DEFAULT_ANSI_COLORS[7]),b.ansi[8]=k(E.brightBlack,n.DEFAULT_ANSI_COLORS[8]),b.ansi[9]=k(E.brightRed,n.DEFAULT_ANSI_COLORS[9]),b.ansi[10]=k(E.brightGreen,n.DEFAULT_ANSI_COLORS[10]),b.ansi[11]=k(E.brightYellow,n.DEFAULT_ANSI_COLORS[11]),b.ansi[12]=k(E.brightBlue,n.DEFAULT_ANSI_COLORS[12]),b.ansi[13]=k(E.brightMagenta,n.DEFAULT_ANSI_COLORS[13]),b.ansi[14]=k(E.brightCyan,n.DEFAULT_ANSI_COLORS[14]),b.ansi[15]=k(E.brightWhite,n.DEFAULT_ANSI_COLORS[15]),E.extendedAnsi){const j=Math.min(b.ansi.length-16,E.extendedAnsi.length);for(let R=0;R<j;R++)b.ansi[R+16]=k(E.extendedAnsi[R],n.DEFAULT_ANSI_COLORS[R+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 b=0;b<this._restoreColors.ansi.length;++b)this._colors.ansi[b]=this._restoreColors.ansi[b]}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,b){if(E!==void 0)try{return g.css.toColor(E)}catch{}return b}n.ThemeService=C=a([u(0,w.IOptionsService)],C)},6349:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CircularList=void 0;const a=i(8460),u=i(844);class c extends u.Disposable{constructor(x){super(),this._maxLength=x,this.onDeleteEmitter=this.register(new a.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new a.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new a.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(x){if(this._maxLength===x)return;const S=new Array(x);for(let w=0;w<Math.min(x,this.length);w++)S[w]=this._array[this._getCyclicIndex(w)];this._array=S,this._maxLength=x,this._startIndex=0}get length(){return this._length}set length(x){if(x>this._length)for(let S=this._length;S<x;S++)this._array[S]=void 0;this._length=x}get(x){return this._array[this._getCyclicIndex(x)]}set(x,S){this._array[this._getCyclicIndex(x)]=S}push(x){this._array[this._getCyclicIndex(this._length)]=x,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(x,S,...w){if(S){for(let l=x;l<this._length-S;l++)this._array[this._getCyclicIndex(l)]=this._array[this._getCyclicIndex(l+S)];this._length-=S,this.onDeleteEmitter.fire({index:x,amount:S})}for(let l=this._length-1;l>=x;l--)this._array[this._getCyclicIndex(l+w.length)]=this._array[this._getCyclicIndex(l)];for(let l=0;l<w.length;l++)this._array[this._getCyclicIndex(x+l)]=w[l];if(w.length&&this.onInsertEmitter.fire({index:x,amount:w.length}),this._length+w.length>this._maxLength){const l=this._length+w.length-this._maxLength;this._startIndex+=l,this._length=this._maxLength,this.onTrimEmitter.fire(l)}else this._length+=w.length}trimStart(x){x>this._length&&(x=this._length),this._startIndex+=x,this._length-=x,this.onTrimEmitter.fire(x)}shiftElements(x,S,w){if(!(S<=0)){if(x<0||x>=this._length)throw new Error("start argument out of range");if(x+w<0)throw new Error("Cannot shift elements in list beyond index 0");if(w>0){for(let h=S-1;h>=0;h--)this.set(x+h+w,this.get(x+h));const l=x+S+w-this._length;if(l>0)for(this._length+=l;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let l=0;l<S;l++)this.set(x+l+w,this.get(x+l))}}_getCyclicIndex(x){return(this._startIndex+x)%this._maxLength}}n.CircularList=c},1439:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.clone=void 0,n.clone=function i(a,u=5){if(typeof a!="object")return a;const c=Array.isArray(a)?[]:{};for(const g in a)c[g]=u<=1?a[g]:a[g]&&i(a[g],u-1);return c}},8055:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.contrastRatio=n.toPaddedHex=n.rgba=n.rgb=n.css=n.color=n.channels=n.NULL_COLOR=void 0;const a=i(6114);let u=0,c=0,g=0,x=0;var S,w,l,h,d;function f(C){const k=C.toString(16);return k.length<2?"0"+k:k}function y(C,k){return C<k?(k+.05)/(C+.05):(C+.05)/(k+.05)}n.NULL_COLOR={css:"#00000000",rgba:0},(function(C){C.toCss=function(k,E,b,j){return j!==void 0?`#${f(k)}${f(E)}${f(b)}${f(j)}`:`#${f(k)}${f(E)}${f(b)}`},C.toRgba=function(k,E,b,j=255){return(k<<24|E<<16|b<<8|j)>>>0}})(S||(n.channels=S={})),(function(C){function k(E,b){return x=Math.round(255*b),[u,c,g]=d.toChannels(E.rgba),{css:S.toCss(u,c,g,x),rgba:S.toRgba(u,c,g,x)}}C.blend=function(E,b){if(x=(255&b.rgba)/255,x===1)return{css:b.css,rgba:b.rgba};const j=b.rgba>>24&255,R=b.rgba>>16&255,L=b.rgba>>8&255,T=E.rgba>>24&255,D=E.rgba>>16&255,F=E.rgba>>8&255;return u=T+Math.round((j-T)*x),c=D+Math.round((R-D)*x),g=F+Math.round((L-F)*x),{css:S.toCss(u,c,g),rgba:S.toRgba(u,c,g)}},C.isOpaque=function(E){return(255&E.rgba)==255},C.ensureContrastRatio=function(E,b,j){const R=d.ensureContrastRatio(E.rgba,b.rgba,j);if(R)return d.toColor(R>>24&255,R>>16&255,R>>8&255)},C.opaque=function(E){const b=(255|E.rgba)>>>0;return[u,c,g]=d.toChannels(b),{css:S.toCss(u,c,g),rgba:b}},C.opacity=k,C.multiplyOpacity=function(E,b){return x=255&E.rgba,k(E,x*b/255)},C.toColorRGB=function(E){return[E.rgba>>24&255,E.rgba>>16&255,E.rgba>>8&255]}})(w||(n.color=w={})),(function(C){let k,E;if(!a.isNode){const b=document.createElement("canvas");b.width=1,b.height=1;const j=b.getContext("2d",{willReadFrequently:!0});j&&(k=j,k.globalCompositeOperation="copy",E=k.createLinearGradient(0,0,1,1))}C.toColor=function(b){if(b.match(/#[\da-f]{3,8}/i))switch(b.length){case 4:return u=parseInt(b.slice(1,2).repeat(2),16),c=parseInt(b.slice(2,3).repeat(2),16),g=parseInt(b.slice(3,4).repeat(2),16),d.toColor(u,c,g);case 5:return u=parseInt(b.slice(1,2).repeat(2),16),c=parseInt(b.slice(2,3).repeat(2),16),g=parseInt(b.slice(3,4).repeat(2),16),x=parseInt(b.slice(4,5).repeat(2),16),d.toColor(u,c,g,x);case 7:return{css:b,rgba:(parseInt(b.slice(1),16)<<8|255)>>>0};case 9:return{css:b,rgba:parseInt(b.slice(1),16)>>>0}}const j=b.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(j)return u=parseInt(j[1]),c=parseInt(j[2]),g=parseInt(j[3]),x=Math.round(255*(j[5]===void 0?1:parseFloat(j[5]))),d.toColor(u,c,g,x);if(!k||!E)throw new Error("css.toColor: Unsupported css format");if(k.fillStyle=E,k.fillStyle=b,typeof k.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(k.fillRect(0,0,1,1),[u,c,g,x]=k.getImageData(0,0,1,1).data,x!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:S.toRgba(u,c,g,x),css:b}}})(l||(n.css=l={})),(function(C){function k(E,b,j){const R=E/255,L=b/255,T=j/255;return .2126*(R<=.03928?R/12.92:Math.pow((R+.055)/1.055,2.4))+.7152*(L<=.03928?L/12.92:Math.pow((L+.055)/1.055,2.4))+.0722*(T<=.03928?T/12.92:Math.pow((T+.055)/1.055,2.4))}C.relativeLuminance=function(E){return k(E>>16&255,E>>8&255,255&E)},C.relativeLuminance2=k})(h||(n.rgb=h={})),(function(C){function k(b,j,R){const L=b>>24&255,T=b>>16&255,D=b>>8&255;let F=j>>24&255,I=j>>16&255,H=j>>8&255,K=y(h.relativeLuminance2(F,I,H),h.relativeLuminance2(L,T,D));for(;K<R&&(F>0||I>0||H>0);)F-=Math.max(0,Math.ceil(.1*F)),I-=Math.max(0,Math.ceil(.1*I)),H-=Math.max(0,Math.ceil(.1*H)),K=y(h.relativeLuminance2(F,I,H),h.relativeLuminance2(L,T,D));return(F<<24|I<<16|H<<8|255)>>>0}function E(b,j,R){const L=b>>24&255,T=b>>16&255,D=b>>8&255;let F=j>>24&255,I=j>>16&255,H=j>>8&255,K=y(h.relativeLuminance2(F,I,H),h.relativeLuminance2(L,T,D));for(;K<R&&(F<255||I<255||H<255);)F=Math.min(255,F+Math.ceil(.1*(255-F))),I=Math.min(255,I+Math.ceil(.1*(255-I))),H=Math.min(255,H+Math.ceil(.1*(255-H))),K=y(h.relativeLuminance2(F,I,H),h.relativeLuminance2(L,T,D));return(F<<24|I<<16|H<<8|255)>>>0}C.ensureContrastRatio=function(b,j,R){const L=h.relativeLuminance(b>>8),T=h.relativeLuminance(j>>8);if(y(L,T)<R){if(T<L){const I=k(b,j,R),H=y(L,h.relativeLuminance(I>>8));if(H<R){const K=E(b,j,R);return H>y(L,h.relativeLuminance(K>>8))?I:K}return I}const D=E(b,j,R),F=y(L,h.relativeLuminance(D>>8));if(F<R){const I=k(b,j,R);return F>y(L,h.relativeLuminance(I>>8))?D:I}return D}},C.reduceLuminance=k,C.increaseLuminance=E,C.toChannels=function(b){return[b>>24&255,b>>16&255,b>>8&255,255&b]},C.toColor=function(b,j,R,L){return{css:S.toCss(b,j,R,L),rgba:S.toRgba(b,j,R,L)}}})(d||(n.rgba=d={})),n.toPaddedHex=f,n.contrastRatio=y},8969:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CoreTerminal=void 0;const a=i(844),u=i(2585),c=i(4348),g=i(7866),x=i(744),S=i(7302),w=i(6975),l=i(8460),h=i(1753),d=i(1480),f=i(7994),y=i(9282),C=i(5435),k=i(5981),E=i(2660);let b=!1;class j extends a.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new l.EventEmitter),this._onScroll.event((L=>{var T;(T=this._onScrollApi)===null||T===void 0||T.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 T in L)this.optionsService.options[T]=L[T]}constructor(L){super(),this._windowsWrappingHeuristics=this.register(new a.MutableDisposable),this._onBinary=this.register(new l.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new l.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new l.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new l.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new l.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new l.EventEmitter),this._instantiationService=new c.InstantiationService,this.optionsService=this.register(new S.OptionsService(L)),this._instantiationService.setService(u.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(x.BufferService)),this._instantiationService.setService(u.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(g.LogService)),this._instantiationService.setService(u.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(w.CoreService)),this._instantiationService.setService(u.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(h.CoreMouseService)),this._instantiationService.setService(u.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(d.UnicodeService)),this._instantiationService.setService(u.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(f.CharsetService),this._instantiationService.setService(u.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(E.OscLinkService),this._instantiationService.setService(u.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new C.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,l.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,l.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,l.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,l.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((T=>{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((T=>{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(((T,D)=>this._inputHandler.parse(T,D)))),this.register((0,l.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(L,T){this._writeBuffer.write(L,T)}writeSync(L,T){this._logService.logLevel<=u.LogLevelEnum.WARN&&!b&&(this._logService.warn("writeSync is unreliable and will be removed soon."),b=!0),this._writeBuffer.writeSync(L,T)}resize(L,T){isNaN(L)||isNaN(T)||(L=Math.max(L,x.MINIMUM_COLS),T=Math.max(T,x.MINIMUM_ROWS),this._bufferService.resize(L,T))}scroll(L,T=!1){this._bufferService.scroll(L,T)}scrollLines(L,T,D){this._bufferService.scrollLines(L,T,D)}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 T=L-this._bufferService.buffer.ydisp;T!==0&&this.scrollLines(T)}registerEscHandler(L,T){return this._inputHandler.registerEscHandler(L,T)}registerDcsHandler(L,T){return this._inputHandler.registerDcsHandler(L,T)}registerCsiHandler(L,T){return this._inputHandler.registerCsiHandler(L,T)}registerOscHandler(L,T){return this._inputHandler.registerOscHandler(L,T)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let L=!1;const T=this.optionsService.rawOptions.windowsPty;T&&T.buildNumber!==void 0&&T.buildNumber!==void 0?L=T.backend==="conpty"&&T.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(y.updateWindowsModeWrappedState.bind(null,this._bufferService))),L.push(this.registerCsiHandler({final:"H"},(()=>((0,y.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,a.toDisposable)((()=>{for(const T of L)T.dispose()}))}}}n.CoreTerminal=j},8460:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.forwardEvent=n.EventEmitter=void 0,n.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=i=>(this._listeners.push(i),{dispose:()=>{if(!this._disposed){for(let a=0;a<this._listeners.length;a++)if(this._listeners[a]===i)return void this._listeners.splice(a,1)}}})),this._event}fire(i,a){const u=[];for(let c=0;c<this._listeners.length;c++)u.push(this._listeners[c]);for(let c=0;c<u.length;c++)u[c].call(void 0,i,a)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},n.forwardEvent=function(i,a){return i((u=>a.fire(u)))}},5435:function(v,n,i){var a=this&&this.__decorate||function(K,A,P,M){var O,$=arguments.length,U=$<3?A:M===null?M=Object.getOwnPropertyDescriptor(A,P):M;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")U=Reflect.decorate(K,A,P,M);else for(var B=K.length-1;B>=0;B--)(O=K[B])&&(U=($<3?O(U):$>3?O(A,P,U):O(A,P))||U);return $>3&&U&&Object.defineProperty(A,P,U),U},u=this&&this.__param||function(K,A){return function(P,M){A(P,M,K)}};Object.defineProperty(n,"__esModule",{value:!0}),n.InputHandler=n.WindowsOptionsReportType=void 0;const c=i(2584),g=i(7116),x=i(2015),S=i(844),w=i(482),l=i(8437),h=i(8460),d=i(643),f=i(511),y=i(3734),C=i(2585),k=i(6242),E=i(6351),b=i(5941),j={"(":0,")":1,"*":2,"+":3,"-":1,".":2},R=131072;function L(K,A){if(K>24)return A.setWinLines||!1;switch(K){case 1:return!!A.restoreWin;case 2:return!!A.minimizeWin;case 3:return!!A.setWinPosition;case 4:return!!A.setWinSizePixels;case 5:return!!A.raiseWin;case 6:return!!A.lowerWin;case 7:return!!A.refreshWin;case 8:return!!A.setWinSizeChars;case 9:return!!A.maximizeWin;case 10:return!!A.fullscreenWin;case 11:return!!A.getWinState;case 13:return!!A.getWinPosition;case 14:return!!A.getWinSizePixels;case 15:return!!A.getScreenSizePixels;case 16:return!!A.getCellSizePixels;case 18:return!!A.getWinSizeChars;case 19:return!!A.getScreenSizeChars;case 20:return!!A.getIconTitle;case 21:return!!A.getWinTitle;case 22:return!!A.pushTitle;case 23:return!!A.popTitle;case 24:return!!A.setWinLines}return!1}var T;(function(K){K[K.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",K[K.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(T||(n.WindowsOptionsReportType=T={}));let D=0;class F extends S.Disposable{getAttrData(){return this._curAttrData}constructor(A,P,M,O,$,U,B,z,q=new x.EscapeSequenceParser){super(),this._bufferService=A,this._charsetService=P,this._coreService=M,this._logService=O,this._optionsService=$,this._oscLinkService=U,this._coreMouseService=B,this._unicodeService=z,this._parser=q,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new w.StringToUtf32,this._utf8Decoder=new w.Utf8ToUtf32,this._workCell=new f.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=l.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=l.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new h.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new h.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new h.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new h.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new h.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new h.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new h.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new h.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new h.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new h.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new h.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new h.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new h.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 I(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((N=>this._activeBuffer=N.activeBuffer))),this._parser.setCsiHandlerFallback(((N,W)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(N),params:W.toArray()})})),this._parser.setEscHandlerFallback((N=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(N)})})),this._parser.setExecuteHandlerFallback((N=>{this._logService.debug("Unknown EXECUTE code: ",{code:N})})),this._parser.setOscHandlerFallback(((N,W,X)=>{this._logService.debug("Unknown OSC code: ",{identifier:N,action:W,data:X})})),this._parser.setDcsHandlerFallback(((N,W,X)=>{W==="HOOK"&&(X=X.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(N),action:W,payload:X})})),this._parser.setPrintHandler(((N,W,X)=>this.print(N,W,X))),this._parser.registerCsiHandler({final:"@"},(N=>this.insertChars(N))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(N=>this.scrollLeft(N))),this._parser.registerCsiHandler({final:"A"},(N=>this.cursorUp(N))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(N=>this.scrollRight(N))),this._parser.registerCsiHandler({final:"B"},(N=>this.cursorDown(N))),this._parser.registerCsiHandler({final:"C"},(N=>this.cursorForward(N))),this._parser.registerCsiHandler({final:"D"},(N=>this.cursorBackward(N))),this._parser.registerCsiHandler({final:"E"},(N=>this.cursorNextLine(N))),this._parser.registerCsiHandler({final:"F"},(N=>this.cursorPrecedingLine(N))),this._parser.registerCsiHandler({final:"G"},(N=>this.cursorCharAbsolute(N))),this._parser.registerCsiHandler({final:"H"},(N=>this.cursorPosition(N))),this._parser.registerCsiHandler({final:"I"},(N=>this.cursorForwardTab(N))),this._parser.registerCsiHandler({final:"J"},(N=>this.eraseInDisplay(N,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(N=>this.eraseInDisplay(N,!0))),this._parser.registerCsiHandler({final:"K"},(N=>this.eraseInLine(N,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(N=>this.eraseInLine(N,!0))),this._parser.registerCsiHandler({final:"L"},(N=>this.insertLines(N))),this._parser.registerCsiHandler({final:"M"},(N=>this.deleteLines(N))),this._parser.registerCsiHandler({final:"P"},(N=>this.deleteChars(N))),this._parser.registerCsiHandler({final:"S"},(N=>this.scrollUp(N))),this._parser.registerCsiHandler({final:"T"},(N=>this.scrollDown(N))),this._parser.registerCsiHandler({final:"X"},(N=>this.eraseChars(N))),this._parser.registerCsiHandler({final:"Z"},(N=>this.cursorBackwardTab(N))),this._parser.registerCsiHandler({final:"`"},(N=>this.charPosAbsolute(N))),this._parser.registerCsiHandler({final:"a"},(N=>this.hPositionRelative(N))),this._parser.registerCsiHandler({final:"b"},(N=>this.repeatPrecedingCharacter(N))),this._parser.registerCsiHandler({final:"c"},(N=>this.sendDeviceAttributesPrimary(N))),this._parser.registerCsiHandler({prefix:">",final:"c"},(N=>this.sendDeviceAttributesSecondary(N))),this._parser.registerCsiHandler({final:"d"},(N=>this.linePosAbsolute(N))),this._parser.registerCsiHandler({final:"e"},(N=>this.vPositionRelative(N))),this._parser.registerCsiHandler({final:"f"},(N=>this.hVPosition(N))),this._parser.registerCsiHandler({final:"g"},(N=>this.tabClear(N))),this._parser.registerCsiHandler({final:"h"},(N=>this.setMode(N))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(N=>this.setModePrivate(N))),this._parser.registerCsiHandler({final:"l"},(N=>this.resetMode(N))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(N=>this.resetModePrivate(N))),this._parser.registerCsiHandler({final:"m"},(N=>this.charAttributes(N))),this._parser.registerCsiHandler({final:"n"},(N=>this.deviceStatus(N))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(N=>this.deviceStatusPrivate(N))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(N=>this.softReset(N))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(N=>this.setCursorStyle(N))),this._parser.registerCsiHandler({final:"r"},(N=>this.setScrollRegion(N))),this._parser.registerCsiHandler({final:"s"},(N=>this.saveCursor(N))),this._parser.registerCsiHandler({final:"t"},(N=>this.windowOptions(N))),this._parser.registerCsiHandler({final:"u"},(N=>this.restoreCursor(N))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(N=>this.insertColumns(N))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(N=>this.deleteColumns(N))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(N=>this.selectProtected(N))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(N=>this.requestMode(N,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(N=>this.requestMode(N,!1))),this._parser.setExecuteHandler(c.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(c.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(c.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(c.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(c.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(c.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(c.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(c.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(c.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new k.OscHandler((N=>(this.setTitle(N),this.setIconName(N),!0)))),this._parser.registerOscHandler(1,new k.OscHandler((N=>this.setIconName(N)))),this._parser.registerOscHandler(2,new k.OscHandler((N=>this.setTitle(N)))),this._parser.registerOscHandler(4,new k.OscHandler((N=>this.setOrReportIndexedColor(N)))),this._parser.registerOscHandler(8,new k.OscHandler((N=>this.setHyperlink(N)))),this._parser.registerOscHandler(10,new k.OscHandler((N=>this.setOrReportFgColor(N)))),this._parser.registerOscHandler(11,new k.OscHandler((N=>this.setOrReportBgColor(N)))),this._parser.registerOscHandler(12,new k.OscHandler((N=>this.setOrReportCursorColor(N)))),this._parser.registerOscHandler(104,new k.OscHandler((N=>this.restoreIndexedColor(N)))),this._parser.registerOscHandler(110,new k.OscHandler((N=>this.restoreFgColor(N)))),this._parser.registerOscHandler(111,new k.OscHandler((N=>this.restoreBgColor(N)))),this._parser.registerOscHandler(112,new k.OscHandler((N=>this.restoreCursorColor(N)))),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 N in g.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:N},(()=>this.selectCharset("("+N))),this._parser.registerEscHandler({intermediates:")",final:N},(()=>this.selectCharset(")"+N))),this._parser.registerEscHandler({intermediates:"*",final:N},(()=>this.selectCharset("*"+N))),this._parser.registerEscHandler({intermediates:"+",final:N},(()=>this.selectCharset("+"+N))),this._parser.registerEscHandler({intermediates:"-",final:N},(()=>this.selectCharset("-"+N))),this._parser.registerEscHandler({intermediates:".",final:N},(()=>this.selectCharset("."+N))),this._parser.registerEscHandler({intermediates:"/",final:N},(()=>this.selectCharset("/"+N)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((N=>(this._logService.error("Parsing error: ",N),N))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new E.DcsHandler(((N,W)=>this.requestStatusString(N,W))))}_preserveStack(A,P,M,O){this._parseStack.paused=!0,this._parseStack.cursorStartX=A,this._parseStack.cursorStartY=P,this._parseStack.decodedLength=M,this._parseStack.position=O}_logSlowResolvingAsync(A){this._logService.logLevel<=C.LogLevelEnum.WARN&&Promise.race([A,new Promise(((P,M)=>setTimeout((()=>M("#SLOW_TIMEOUT")),5e3)))]).catch((P=>{if(P!=="#SLOW_TIMEOUT")throw P;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(A,P){let M,O=this._activeBuffer.x,$=this._activeBuffer.y,U=0;const B=this._parseStack.paused;if(B){if(M=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,P))return this._logSlowResolvingAsync(M),M;O=this._parseStack.cursorStartX,$=this._parseStack.cursorStartY,this._parseStack.paused=!1,A.length>R&&(U=this._parseStack.position+R)}if(this._logService.logLevel<=C.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof A=="string"?` "${A}"`:` "${Array.prototype.map.call(A,(z=>String.fromCharCode(z))).join("")}"`),typeof A=="string"?A.split("").map((z=>z.charCodeAt(0))):A),this._parseBuffer.length<A.length&&this._parseBuffer.length<R&&(this._parseBuffer=new Uint32Array(Math.min(A.length,R))),B||this._dirtyRowTracker.clearRange(),A.length>R)for(let z=U;z<A.length;z+=R){const q=z+R<A.length?z+R:A.length,N=typeof A=="string"?this._stringDecoder.decode(A.substring(z,q),this._parseBuffer):this._utf8Decoder.decode(A.subarray(z,q),this._parseBuffer);if(M=this._parser.parse(this._parseBuffer,N))return this._preserveStack(O,$,N,z),this._logSlowResolvingAsync(M),M}else if(!B){const z=typeof A=="string"?this._stringDecoder.decode(A,this._parseBuffer):this._utf8Decoder.decode(A,this._parseBuffer);if(M=this._parser.parse(this._parseBuffer,z))return this._preserveStack(O,$,z,0),this._logSlowResolvingAsync(M),M}this._activeBuffer.x===O&&this._activeBuffer.y===$||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowTracker.start,this._dirtyRowTracker.end)}print(A,P,M){let O,$;const U=this._charsetService.charset,B=this._optionsService.rawOptions.screenReaderMode,z=this._bufferService.cols,q=this._coreService.decPrivateModes.wraparound,N=this._coreService.modes.insertMode,W=this._curAttrData;let X=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&M-P>0&&X.getWidth(this._activeBuffer.x-1)===2&&X.setCellFromCodePoint(this._activeBuffer.x-1,0,1,W.fg,W.bg,W.extended);for(let V=P;V<M;++V){if(O=A[V],$=this._unicodeService.wcwidth(O),O<127&&U){const ie=U[String.fromCharCode(O)];ie&&(O=ie.charCodeAt(0))}if(B&&this._onA11yChar.fire((0,w.stringFromCodePoint)(O)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),$||!this._activeBuffer.x){if(this._activeBuffer.x+$-1>=z){if(q){for(;this._activeBuffer.x<z;)X.setCellFromCodePoint(this._activeBuffer.x++,0,1,W.fg,W.bg,W.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),X=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)}else if(this._activeBuffer.x=z-1,$===2)continue}if(N&&(X.insertCells(this._activeBuffer.x,$,this._activeBuffer.getNullCell(W),W),X.getWidth(z-1)===2&&X.setCellFromCodePoint(z-1,d.NULL_CELL_CODE,d.NULL_CELL_WIDTH,W.fg,W.bg,W.extended)),X.setCellFromCodePoint(this._activeBuffer.x++,O,$,W.fg,W.bg,W.extended),$>0)for(;--$;)X.setCellFromCodePoint(this._activeBuffer.x++,0,0,W.fg,W.bg,W.extended)}else X.getWidth(this._activeBuffer.x-1)?X.addCodepointToCell(this._activeBuffer.x-1,O):X.addCodepointToCell(this._activeBuffer.x-2,O)}M-P>0&&(X.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-P>0&&X.getWidth(this._activeBuffer.x)===0&&!X.hasContent(this._activeBuffer.x)&&X.setCellFromCodePoint(this._activeBuffer.x,0,1,W.fg,W.bg,W.extended),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(A,P){return A.final!=="t"||A.prefix||A.intermediates?this._parser.registerCsiHandler(A,P):this._parser.registerCsiHandler(A,(M=>!L(M.params[0],this._optionsService.rawOptions.windowOptions)||P(M)))}registerDcsHandler(A,P){return this._parser.registerDcsHandler(A,new E.DcsHandler(P))}registerEscHandler(A,P){return this._parser.registerEscHandler(A,P)}registerOscHandler(A,P){return this._parser.registerOscHandler(A,new k.OscHandler(P))}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 A;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&&(!((A=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))===null||A===void 0)&&A.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);P.hasWidth(this._activeBuffer.x)&&!P.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const A=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-A),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(A=this._bufferService.cols-1){this._activeBuffer.x=Math.min(A,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(A,P){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=A,this._activeBuffer.y=this._activeBuffer.scrollTop+P):(this._activeBuffer.x=A,this._activeBuffer.y=P),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(A,P){this._restrictCursor(),this._setCursor(this._activeBuffer.x+A,this._activeBuffer.y+P)}cursorUp(A){const P=this._activeBuffer.y-this._activeBuffer.scrollTop;return P>=0?this._moveCursor(0,-Math.min(P,A.params[0]||1)):this._moveCursor(0,-(A.params[0]||1)),!0}cursorDown(A){const P=this._activeBuffer.scrollBottom-this._activeBuffer.y;return P>=0?this._moveCursor(0,Math.min(P,A.params[0]||1)):this._moveCursor(0,A.params[0]||1),!0}cursorForward(A){return this._moveCursor(A.params[0]||1,0),!0}cursorBackward(A){return this._moveCursor(-(A.params[0]||1),0),!0}cursorNextLine(A){return this.cursorDown(A),this._activeBuffer.x=0,!0}cursorPrecedingLine(A){return this.cursorUp(A),this._activeBuffer.x=0,!0}cursorCharAbsolute(A){return this._setCursor((A.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(A){return this._setCursor(A.length>=2?(A.params[1]||1)-1:0,(A.params[0]||1)-1),!0}charPosAbsolute(A){return this._setCursor((A.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(A){return this._moveCursor(A.params[0]||1,0),!0}linePosAbsolute(A){return this._setCursor(this._activeBuffer.x,(A.params[0]||1)-1),!0}vPositionRelative(A){return this._moveCursor(0,A.params[0]||1),!0}hVPosition(A){return this.cursorPosition(A),!0}tabClear(A){const P=A.params[0];return P===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:P===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(A){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let P=A.params[0]||1;for(;P--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(A){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let P=A.params[0]||1;for(;P--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(A){const P=A.params[0];return P===1&&(this._curAttrData.bg|=536870912),P!==2&&P!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(A,P,M,O=!1,$=!1){const U=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);U.replaceCells(P,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),$),O&&(U.isWrapped=!1)}_resetBufferLine(A,P=!1){const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);M&&(M.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),P),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+A),M.isWrapped=!1)}eraseInDisplay(A,P=!1){let M;switch(this._restrictCursor(this._bufferService.cols),A.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,P);M<this._bufferService.rows;M++)this._resetBufferLine(M,P);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,P),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(M+1).isWrapped=!1);M--;)this._resetBufferLine(M,P);this._dirtyRowTracker.markDirty(0);break;case 2:for(M=this._bufferService.rows,this._dirtyRowTracker.markDirty(M-1);M--;)this._resetBufferLine(M,P);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(A,P=!1){switch(this._restrictCursor(this._bufferService.cols),A.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,P);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,P);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,P)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(A){this._restrictCursor();let P=A.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,$=this._bufferService.rows-1+this._activeBuffer.ybase-O+1;for(;P--;)this._activeBuffer.lines.splice($-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(A){this._restrictCursor();let P=A.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;P--;)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(A){this._restrictCursor();const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return P&&(P.insertCells(this._activeBuffer.x,A.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(A){this._restrictCursor();const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return P&&(P.deleteCells(this._activeBuffer.x,A.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(A){let P=A.params[0]||1;for(;P--;)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(A){let P=A.params[0]||1;for(;P--;)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(l.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=A.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,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=A.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,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=A.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,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=A.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,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(A){this._restrictCursor();const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return P&&(P.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(A.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(A){if(!this._parser.precedingCodepoint)return!0;const P=A.params[0]||1,M=new Uint32Array(P);for(let O=0;O<P;++O)M[O]=this._parser.precedingCodepoint;return this.print(M,0,M.length),!0}sendDeviceAttributesPrimary(A){return A.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(c.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(c.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(A){return A.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(c.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(c.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(A.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(c.C0.ESC+"[>83;40003;0c")),!0}_is(A){return(this._optionsService.rawOptions.termName+"").indexOf(A)===0}setMode(A){for(let P=0;P<A.length;P++)switch(A.params[P]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(A){for(let P=0;P<A.length;P++)switch(A.params[P]){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(A){for(let P=0;P<A.length;P++)switch(A.params[P]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(A){for(let P=0;P<A.length;P++)switch(A.params[P]){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(),A.params[P]===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(A,P){const M=this._coreService.decPrivateModes,{activeProtocol:O,activeEncoding:$}=this._coreMouseService,U=this._coreService,{buffers:B,cols:z}=this._bufferService,{active:q,alt:N}=B,W=this._optionsService.rawOptions,X=pe=>pe?1:2,V=A.params[0];return ie=V,ee=P?V===2?4:V===4?X(U.modes.insertMode):V===12?3:V===20?X(W.convertEol):0:V===1?X(M.applicationCursorKeys):V===3?W.windowOptions.setWinLines?z===80?2:z===132?1:0:0:V===6?X(M.origin):V===7?X(M.wraparound):V===8?3:V===9?X(O==="X10"):V===12?X(W.cursorBlink):V===25?X(!U.isCursorHidden):V===45?X(M.reverseWraparound):V===66?X(M.applicationKeypad):V===67?4:V===1e3?X(O==="VT200"):V===1002?X(O==="DRAG"):V===1003?X(O==="ANY"):V===1004?X(M.sendFocus):V===1005?4:V===1006?X($==="SGR"):V===1015?4:V===1016?X($==="SGR_PIXELS"):V===1048?1:V===47||V===1047||V===1049?X(q===N):V===2004?X(M.bracketedPasteMode):0,U.triggerDataEvent(`${c.C0.ESC}[${P?"":"?"}${ie};${ee}$y`),!0;var ie,ee}_updateAttrColor(A,P,M,O,$){return P===2?(A|=50331648,A&=-16777216,A|=y.AttributeData.fromColorRGB([M,O,$])):P===5&&(A&=-50331904,A|=33554432|255&M),A}_extractColor(A,P,M){const O=[0,0,-1,0,0,0];let $=0,U=0;do{if(O[U+$]=A.params[P+U],A.hasSubParams(P+U)){const B=A.getSubParams(P+U);let z=0;do O[1]===5&&($=1),O[U+z+1+$]=B[z];while(++z<B.length&&z+U+1+$<O.length);break}if(O[1]===5&&U+$>=2||O[1]===2&&U+$>=5)break;O[1]&&($=1)}while(++U+P<A.length&&U+$<O.length);for(let B=2;B<O.length;++B)O[B]===-1&&(O[B]=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 U}_processUnderline(A,P){P.extended=P.extended.clone(),(!~A||A>5)&&(A=1),P.extended.underlineStyle=A,P.fg|=268435456,A===0&&(P.fg&=-268435457),P.updateExtended()}_processSGR0(A){A.fg=l.DEFAULT_ATTR_DATA.fg,A.bg=l.DEFAULT_ATTR_DATA.bg,A.extended=A.extended.clone(),A.extended.underlineStyle=0,A.extended.underlineColor&=-67108864,A.updateExtended()}charAttributes(A){if(A.length===1&&A.params[0]===0)return this._processSGR0(this._curAttrData),!0;const P=A.length;let M;const O=this._curAttrData;for(let $=0;$<P;$++)M=A.params[$],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(A.hasSubParams($)?A.getSubParams($)[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&l.DEFAULT_ATTR_DATA.fg):M===49?(O.bg&=-67108864,O.bg|=16777215&l.DEFAULT_ATTR_DATA.bg):M===38||M===48||M===58?$+=this._extractColor(A,$,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&l.DEFAULT_ATTR_DATA.fg,O.bg&=-67108864,O.bg|=16777215&l.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",M);return!0}deviceStatus(A){switch(A.params[0]){case 5:this._coreService.triggerDataEvent(`${c.C0.ESC}[0n`);break;case 6:const P=this._activeBuffer.y+1,M=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${c.C0.ESC}[${P};${M}R`)}return!0}deviceStatusPrivate(A){if(A.params[0]===6){const P=this._activeBuffer.y+1,M=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${c.C0.ESC}[?${P};${M}R`)}return!0}softReset(A){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=l.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(A){const P=A.params[0]||1;switch(P){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=P%2==1;return this._optionsService.options.cursorBlink=M,!0}setScrollRegion(A){const P=A.params[0]||1;let M;return(A.length<2||(M=A.params[1])>this._bufferService.rows||M===0)&&(M=this._bufferService.rows),M>P&&(this._activeBuffer.scrollTop=P-1,this._activeBuffer.scrollBottom=M-1,this._setCursor(0,0)),!0}windowOptions(A){if(!L(A.params[0],this._optionsService.rawOptions.windowOptions))return!0;const P=A.length>1?A.params[1]:0;switch(A.params[0]){case 14:P!==2&&this._onRequestWindowsOptionsReport.fire(T.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(T.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${c.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:P!==0&&P!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),P!==0&&P!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:P!==0&&P!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),P!==0&&P!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(A){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(A){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(A){return this._windowTitle=A,this._onTitleChange.fire(A),!0}setIconName(A){return this._iconName=A,!0}setOrReportIndexedColor(A){const P=[],M=A.split(";");for(;M.length>1;){const O=M.shift(),$=M.shift();if(/^\d+$/.exec(O)){const U=parseInt(O);if(H(U))if($==="?")P.push({type:0,index:U});else{const B=(0,b.parseColor)($);B&&P.push({type:1,index:U,color:B})}}}return P.length&&this._onColor.fire(P),!0}setHyperlink(A){const P=A.split(";");return!(P.length<2)&&(P[1]?this._createHyperlink(P[0],P[1]):!P[0]&&this._finishHyperlink())}_createHyperlink(A,P){this._getCurrentLinkId()&&this._finishHyperlink();const M=A.split(":");let O;const $=M.findIndex((U=>U.startsWith("id=")));return $!==-1&&(O=M[$].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:O,uri:P}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(A,P){const M=A.split(";");for(let O=0;O<M.length&&!(P>=this._specialColors.length);++O,++P)if(M[O]==="?")this._onColor.fire([{type:0,index:this._specialColors[P]}]);else{const $=(0,b.parseColor)(M[O]);$&&this._onColor.fire([{type:1,index:this._specialColors[P],color:$}])}return!0}setOrReportFgColor(A){return this._setOrReportSpecialColor(A,0)}setOrReportBgColor(A){return this._setOrReportSpecialColor(A,1)}setOrReportCursorColor(A){return this._setOrReportSpecialColor(A,2)}restoreIndexedColor(A){if(!A)return this._onColor.fire([{type:2}]),!0;const P=[],M=A.split(";");for(let O=0;O<M.length;++O)if(/^\d+$/.exec(M[O])){const $=parseInt(M[O]);H($)&&P.push({type:2,index:$})}return P.length&&this._onColor.fire(P),!0}restoreFgColor(A){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(A){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(A){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(A){return A.length!==2?(this.selectDefaultCharset(),!0):(A[0]==="/"||this._charsetService.setgCharset(j[A[0]],g.CHARSETS[A[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 A=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,A,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=l.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=l.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(A){return this._charsetService.setgLevel(A),!0}screenAlignmentPattern(){const A=new f.CellData;A.content=4194373,A.fg=this._curAttrData.fg,A.bg=this._curAttrData.bg,this._setCursor(0,0);for(let P=0;P<this._bufferService.rows;++P){const M=this._activeBuffer.ybase+this._activeBuffer.y+P,O=this._activeBuffer.lines.get(M);O&&(O.fill(A),O.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(A,P){const M=this._bufferService.buffer,O=this._optionsService.rawOptions;return($=>(this._coreService.triggerDataEvent(`${c.C0.ESC}${$}${c.C0.ESC}\\`),!0))(A==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:A==='"p'?'P1$r61;1"p':A==="r"?`P1$r${M.scrollTop+1};${M.scrollBottom+1}r`:A==="m"?"P1$r0m":A===" q"?`P1$r${{block:2,underline:4,bar:6}[O.cursorStyle]-(O.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(A,P){this._dirtyRowTracker.markRangeDirty(A,P)}}n.InputHandler=F;let I=class{constructor(K){this._bufferService=K,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(K){K<this.start?this.start=K:K>this.end&&(this.end=K)}markRangeDirty(K,A){K>A&&(D=K,K=A,A=D),K<this.start&&(this.start=K),A>this.end&&(this.end=A)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function H(K){return 0<=K&&K<256}I=a([u(0,C.IBufferService)],I)},844:(v,n)=>{function i(a){for(const u of a)u.dispose();a.length=0}Object.defineProperty(n,"__esModule",{value:!0}),n.getDisposeArrayDisposable=n.disposeArray=n.toDisposable=n.MutableDisposable=n.Disposable=void 0,n.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const a of this._disposables)a.dispose();this._disposables.length=0}register(a){return this._disposables.push(a),a}unregister(a){const u=this._disposables.indexOf(a);u!==-1&&this._disposables.splice(u,1)}},n.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(a){var u;this._isDisposed||a===this._value||((u=this._value)===null||u===void 0||u.dispose(),this._value=a)}clear(){this.value=void 0}dispose(){var a;this._isDisposed=!0,(a=this._value)===null||a===void 0||a.dispose(),this._value=void 0}},n.toDisposable=function(a){return{dispose:a}},n.disposeArray=i,n.getDisposeArrayDisposable=function(a){return{dispose:()=>i(a)}}},1505:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.FourKeyMap=n.TwoKeyMap=void 0;class i{constructor(){this._data={}}set(u,c,g){this._data[u]||(this._data[u]={}),this._data[u][c]=g}get(u,c){return this._data[u]?this._data[u][c]:void 0}clear(){this._data={}}}n.TwoKeyMap=i,n.FourKeyMap=class{constructor(){this._data=new i}set(a,u,c,g,x){this._data.get(a,u)||this._data.set(a,u,new i),this._data.get(a,u).set(c,g,x)}get(a,u,c,g){var x;return(x=this._data.get(a,u))===null||x===void 0?void 0:x.get(c,g)}clear(){this._data.clear()}}},6114:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.isChromeOS=n.isLinux=n.isWindows=n.isIphone=n.isIpad=n.isMac=n.getSafariVersion=n.isSafari=n.isLegacyEdge=n.isFirefox=n.isNode=void 0,n.isNode=typeof navigator>"u";const i=n.isNode?"node":navigator.userAgent,a=n.isNode?"node":navigator.platform;n.isFirefox=i.includes("Firefox"),n.isLegacyEdge=i.includes("Edge"),n.isSafari=/^((?!chrome|android).)*safari/i.test(i),n.getSafariVersion=function(){if(!n.isSafari)return 0;const u=i.match(/Version\/(\d+)/);return u===null||u.length<2?0:parseInt(u[1])},n.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(a),n.isIpad=a==="iPad",n.isIphone=a==="iPhone",n.isWindows=["Windows","Win16","Win32","WinCE"].includes(a),n.isLinux=a.indexOf("Linux")>=0,n.isChromeOS=/\bCrOS\b/.test(i)},6106:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.SortedList=void 0;let i=0;n.SortedList=class{constructor(a){this._getKey=a,this._array=[]}clear(){this._array.length=0}insert(a){this._array.length!==0?(i=this._search(this._getKey(a)),this._array.splice(i,0,a)):this._array.push(a)}delete(a){if(this._array.length===0)return!1;const u=this._getKey(a);if(u===void 0||(i=this._search(u),i===-1)||this._getKey(this._array[i])!==u)return!1;do if(this._array[i]===a)return this._array.splice(i,1),!0;while(++i<this._array.length&&this._getKey(this._array[i])===u);return!1}*getKeyIterator(a){if(this._array.length!==0&&(i=this._search(a),!(i<0||i>=this._array.length)&&this._getKey(this._array[i])===a))do yield this._array[i];while(++i<this._array.length&&this._getKey(this._array[i])===a)}forEachByKey(a,u){if(this._array.length!==0&&(i=this._search(a),!(i<0||i>=this._array.length)&&this._getKey(this._array[i])===a))do u(this._array[i]);while(++i<this._array.length&&this._getKey(this._array[i])===a)}values(){return[...this._array].values()}_search(a){let u=0,c=this._array.length-1;for(;c>=u;){let g=u+c>>1;const x=this._getKey(this._array[g]);if(x>a)c=g-1;else{if(!(x<a)){for(;g>0&&this._getKey(this._array[g-1])===a;)g--;return g}u=g+1}}return u}}},7226:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DebouncedIdleTask=n.IdleTaskQueue=n.PriorityTaskQueue=void 0;const a=i(6114);class u{constructor(){this._tasks=[],this._i=0}enqueue(x){this._tasks.push(x),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(x){this._idleCallback=void 0;let S=0,w=0,l=x.timeRemaining(),h=0;for(;this._i<this._tasks.length;){if(S=Date.now(),this._tasks[this._i]()||this._i++,S=Math.max(1,Date.now()-S),w=Math.max(S,w),h=x.timeRemaining(),1.5*w>h)return l-S<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(l-S))}ms`),void this._start();l=h}this.clear()}}class c extends u{_requestCallback(x){return setTimeout((()=>x(this._createDeadline(16))))}_cancelCallback(x){clearTimeout(x)}_createDeadline(x){const S=Date.now()+x;return{timeRemaining:()=>Math.max(0,S-Date.now())}}}n.PriorityTaskQueue=c,n.IdleTaskQueue=!a.isNode&&"requestIdleCallback"in window?class extends u{_requestCallback(g){return requestIdleCallback(g)}_cancelCallback(g){cancelIdleCallback(g)}}:c,n.DebouncedIdleTask=class{constructor(){this._queue=new n.IdleTaskQueue}set(g){this._queue.clear(),this._queue.enqueue(g)}flush(){this._queue.flush()}}},9282:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.updateWindowsModeWrappedState=void 0;const a=i(643);n.updateWindowsModeWrappedState=function(u){const c=u.buffer.lines.get(u.buffer.ybase+u.buffer.y-1),g=c?.get(u.cols-1),x=u.buffer.lines.get(u.buffer.ybase+u.buffer.y);x&&g&&(x.isWrapped=g[a.CHAR_DATA_CODE_INDEX]!==a.NULL_CELL_CODE&&g[a.CHAR_DATA_CODE_INDEX]!==a.WHITESPACE_CELL_CODE)}},3734:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ExtendedAttrs=n.AttributeData=void 0;class i{constructor(){this.fg=0,this.bg=0,this.extended=new a}static toColorRGB(c){return[c>>>16&255,c>>>8&255,255&c]}static fromColorRGB(c){return(255&c[0])<<16|(255&c[1])<<8|255&c[2]}clone(){const c=new i;return c.fg=this.fg,c.bg=this.bg,c.extended=this.extended.clone(),c}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}}n.AttributeData=i;class a{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(c){this._ext=c}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(c){this._ext&=-469762049,this._ext|=c<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(c){this._ext&=-67108864,this._ext|=67108863&c}get urlId(){return this._urlId}set urlId(c){this._urlId=c}constructor(c=0,g=0){this._ext=0,this._urlId=0,this._ext=c,this._urlId=g}clone(){return new a(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}n.ExtendedAttrs=a},9092:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Buffer=n.MAX_BUFFER_SIZE=void 0;const a=i(6349),u=i(7226),c=i(3734),g=i(8437),x=i(4634),S=i(511),w=i(643),l=i(4863),h=i(7116);n.MAX_BUFFER_SIZE=4294967295,n.Buffer=class{constructor(d,f,y){this._hasScrollback=d,this._optionsService=f,this._bufferService=y,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=h.DEFAULT_CHARSET,this.markers=[],this._nullCell=S.CellData.fromCharData([0,w.NULL_CELL_CHAR,w.NULL_CELL_WIDTH,w.NULL_CELL_CODE]),this._whitespaceCell=S.CellData.fromCharData([0,w.WHITESPACE_CELL_CHAR,w.WHITESPACE_CELL_WIDTH,w.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new u.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new a.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(d){return d?(this._nullCell.fg=d.fg,this._nullCell.bg=d.bg,this._nullCell.extended=d.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new c.ExtendedAttrs),this._nullCell}getWhitespaceCell(d){return d?(this._whitespaceCell.fg=d.fg,this._whitespaceCell.bg=d.bg,this._whitespaceCell.extended=d.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new c.ExtendedAttrs),this._whitespaceCell}getBlankLine(d,f){return new g.BufferLine(this._bufferService.cols,this.getNullCell(d),f)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const d=this.ybase+this.y-this.ydisp;return d>=0&&d<this._rows}_getCorrectBufferLength(d){if(!this._hasScrollback)return d;const f=d+this._optionsService.rawOptions.scrollback;return f>n.MAX_BUFFER_SIZE?n.MAX_BUFFER_SIZE:f}fillViewportRows(d){if(this.lines.length===0){d===void 0&&(d=g.DEFAULT_ATTR_DATA);let f=this._rows;for(;f--;)this.lines.push(this.getBlankLine(d))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new a.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(d,f){const y=this.getNullCell(g.DEFAULT_ATTR_DATA);let C=0;const k=this._getCorrectBufferLength(f);if(k>this.lines.maxLength&&(this.lines.maxLength=k),this.lines.length>0){if(this._cols<d)for(let b=0;b<this.lines.length;b++)C+=+this.lines.get(b).resize(d,y);let E=0;if(this._rows<f)for(let b=this._rows;b<f;b++)this.lines.length<f+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(d,y)):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(d,y)));else for(let b=this._rows;b>f;b--)this.lines.length>f+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(k<this.lines.maxLength){const b=this.lines.length-k;b>0&&(this.lines.trimStart(b),this.ybase=Math.max(this.ybase-b,0),this.ydisp=Math.max(this.ydisp-b,0),this.savedY=Math.max(this.savedY-b,0)),this.lines.maxLength=k}this.x=Math.min(this.x,d-1),this.y=Math.min(this.y,f-1),E&&(this.y+=E),this.savedX=Math.min(this.savedX,d-1),this.scrollTop=0}if(this.scrollBottom=f-1,this._isReflowEnabled&&(this._reflow(d,f),this._cols>d))for(let E=0;E<this.lines.length;E++)C+=+this.lines.get(E).resize(d,y);this._cols=d,this._rows=f,this._memoryCleanupQueue.clear(),C>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let d=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,d=!1);let f=0;for(;this._memoryCleanupPosition<this.lines.length;)if(f+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),f>100)return!0;return d}get _isReflowEnabled(){const d=this._optionsService.rawOptions.windowsPty;return d&&d.buildNumber?this._hasScrollback&&d.backend==="conpty"&&d.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(d,f){this._cols!==d&&(d>this._cols?this._reflowLarger(d,f):this._reflowSmaller(d,f))}_reflowLarger(d,f){const y=(0,x.reflowLargerGetLinesToRemove)(this.lines,this._cols,d,this.ybase+this.y,this.getNullCell(g.DEFAULT_ATTR_DATA));if(y.length>0){const C=(0,x.reflowLargerCreateNewLayout)(this.lines,y);(0,x.reflowLargerApplyNewLayout)(this.lines,C.layout),this._reflowLargerAdjustViewport(d,f,C.countRemoved)}}_reflowLargerAdjustViewport(d,f,y){const C=this.getNullCell(g.DEFAULT_ATTR_DATA);let k=y;for(;k-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<f&&this.lines.push(new g.BufferLine(d,C))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-y,0)}_reflowSmaller(d,f){const y=this.getNullCell(g.DEFAULT_ATTR_DATA),C=[];let k=0;for(let E=this.lines.length-1;E>=0;E--){let b=this.lines.get(E);if(!b||!b.isWrapped&&b.getTrimmedLength()<=d)continue;const j=[b];for(;b.isWrapped&&E>0;)b=this.lines.get(--E),j.unshift(b);const R=this.ybase+this.y;if(R>=E&&R<E+j.length)continue;const L=j[j.length-1].getTrimmedLength(),T=(0,x.reflowSmallerGetNewLineLengths)(j,this._cols,d),D=T.length-j.length;let F;F=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+D):Math.max(0,this.lines.length-this.lines.maxLength+D);const I=[];for(let O=0;O<D;O++){const $=this.getBlankLine(g.DEFAULT_ATTR_DATA,!0);I.push($)}I.length>0&&(C.push({start:E+j.length+k,newLines:I}),k+=I.length),j.push(...I);let H=T.length-1,K=T[H];K===0&&(H--,K=T[H]);let A=j.length-D-1,P=L;for(;A>=0;){const O=Math.min(P,K);if(j[H]===void 0)break;if(j[H].copyCellsFrom(j[A],P-O,K-O,O,!0),K-=O,K===0&&(H--,K=T[H]),P-=O,P===0){A--;const $=Math.max(A,0);P=(0,x.getWrappedLineTrimmedLength)(j,$,this._cols)}}for(let O=0;O<j.length;O++)T[O]<d&&j[O].setCell(T[O],y);let M=D-F;for(;M-- >0;)this.ybase===0?this.y<f-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+k)-f&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+D,this.ybase+f-1)}if(C.length>0){const E=[],b=[];for(let H=0;H<this.lines.length;H++)b.push(this.lines.get(H));const j=this.lines.length;let R=j-1,L=0,T=C[L];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+k);let D=0;for(let H=Math.min(this.lines.maxLength-1,j+k-1);H>=0;H--)if(T&&T.start>R+D){for(let K=T.newLines.length-1;K>=0;K--)this.lines.set(H--,T.newLines[K]);H++,E.push({index:R+1,amount:T.newLines.length}),D+=T.newLines.length,T=C[++L]}else this.lines.set(H,b[R--]);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 I=Math.max(0,j+k-this.lines.maxLength);I>0&&this.lines.onTrimEmitter.fire(I)}}translateBufferLineToString(d,f,y=0,C){const k=this.lines.get(d);return k?k.translateToString(f,y,C):""}getWrappedRangeForLine(d){let f=d,y=d;for(;f>0&&this.lines.get(f).isWrapped;)f--;for(;y+1<this.lines.length&&this.lines.get(y+1).isWrapped;)y++;return{first:f,last:y}}setupTabStops(d){for(d!=null?this.tabs[d]||(d=this.prevStop(d)):(this.tabs={},d=0);d<this._cols;d+=this._optionsService.rawOptions.tabStopWidth)this.tabs[d]=!0}prevStop(d){for(d==null&&(d=this.x);!this.tabs[--d]&&d>0;);return d>=this._cols?this._cols-1:d<0?0:d}nextStop(d){for(d==null&&(d=this.x);!this.tabs[++d]&&d<this._cols;);return d>=this._cols?this._cols-1:d<0?0:d}clearMarkers(d){this._isClearing=!0;for(let f=0;f<this.markers.length;f++)this.markers[f].line===d&&(this.markers[f].dispose(),this.markers.splice(f--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let d=0;d<this.markers.length;d++)this.markers[d].dispose(),this.markers.splice(d--,1);this._isClearing=!1}addMarker(d){const f=new l.Marker(d);return this.markers.push(f),f.register(this.lines.onTrim((y=>{f.line-=y,f.line<0&&f.dispose()}))),f.register(this.lines.onInsert((y=>{f.line>=y.index&&(f.line+=y.amount)}))),f.register(this.lines.onDelete((y=>{f.line>=y.index&&f.line<y.index+y.amount&&f.dispose(),f.line>y.index&&(f.line-=y.amount)}))),f.register(f.onDispose((()=>this._removeMarker(f)))),f}_removeMarker(d){this._isClearing||this.markers.splice(this.markers.indexOf(d),1)}}},8437:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferLine=n.DEFAULT_ATTR_DATA=void 0;const a=i(3734),u=i(511),c=i(643),g=i(482);n.DEFAULT_ATTR_DATA=Object.freeze(new a.AttributeData);let x=0;class S{constructor(l,h,d=!1){this.isWrapped=d,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*l);const f=h||u.CellData.fromCharData([0,c.NULL_CELL_CHAR,c.NULL_CELL_WIDTH,c.NULL_CELL_CODE]);for(let y=0;y<l;++y)this.setCell(y,f);this.length=l}get(l){const h=this._data[3*l+0],d=2097151&h;return[this._data[3*l+1],2097152&h?this._combined[l]:d?(0,g.stringFromCodePoint)(d):"",h>>22,2097152&h?this._combined[l].charCodeAt(this._combined[l].length-1):d]}set(l,h){this._data[3*l+1]=h[c.CHAR_DATA_ATTR_INDEX],h[c.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[l]=h[1],this._data[3*l+0]=2097152|l|h[c.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*l+0]=h[c.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|h[c.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(l){return this._data[3*l+0]>>22}hasWidth(l){return 12582912&this._data[3*l+0]}getFg(l){return this._data[3*l+1]}getBg(l){return this._data[3*l+2]}hasContent(l){return 4194303&this._data[3*l+0]}getCodePoint(l){const h=this._data[3*l+0];return 2097152&h?this._combined[l].charCodeAt(this._combined[l].length-1):2097151&h}isCombined(l){return 2097152&this._data[3*l+0]}getString(l){const h=this._data[3*l+0];return 2097152&h?this._combined[l]:2097151&h?(0,g.stringFromCodePoint)(2097151&h):""}isProtected(l){return 536870912&this._data[3*l+2]}loadCell(l,h){return x=3*l,h.content=this._data[x+0],h.fg=this._data[x+1],h.bg=this._data[x+2],2097152&h.content&&(h.combinedData=this._combined[l]),268435456&h.bg&&(h.extended=this._extendedAttrs[l]),h}setCell(l,h){2097152&h.content&&(this._combined[l]=h.combinedData),268435456&h.bg&&(this._extendedAttrs[l]=h.extended),this._data[3*l+0]=h.content,this._data[3*l+1]=h.fg,this._data[3*l+2]=h.bg}setCellFromCodePoint(l,h,d,f,y,C){268435456&y&&(this._extendedAttrs[l]=C),this._data[3*l+0]=h|d<<22,this._data[3*l+1]=f,this._data[3*l+2]=y}addCodepointToCell(l,h){let d=this._data[3*l+0];2097152&d?this._combined[l]+=(0,g.stringFromCodePoint)(h):(2097151&d?(this._combined[l]=(0,g.stringFromCodePoint)(2097151&d)+(0,g.stringFromCodePoint)(h),d&=-2097152,d|=2097152):d=h|4194304,this._data[3*l+0]=d)}insertCells(l,h,d,f){if((l%=this.length)&&this.getWidth(l-1)===2&&this.setCellFromCodePoint(l-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new a.ExtendedAttrs),h<this.length-l){const y=new u.CellData;for(let C=this.length-l-h-1;C>=0;--C)this.setCell(l+h+C,this.loadCell(l+C,y));for(let C=0;C<h;++C)this.setCell(l+C,d)}else for(let y=l;y<this.length;++y)this.setCell(y,d);this.getWidth(this.length-1)===2&&this.setCellFromCodePoint(this.length-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new a.ExtendedAttrs)}deleteCells(l,h,d,f){if(l%=this.length,h<this.length-l){const y=new u.CellData;for(let C=0;C<this.length-l-h;++C)this.setCell(l+C,this.loadCell(l+h+C,y));for(let C=this.length-h;C<this.length;++C)this.setCell(C,d)}else for(let y=l;y<this.length;++y)this.setCell(y,d);l&&this.getWidth(l-1)===2&&this.setCellFromCodePoint(l-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new a.ExtendedAttrs),this.getWidth(l)!==0||this.hasContent(l)||this.setCellFromCodePoint(l,0,1,f?.fg||0,f?.bg||0,f?.extended||new a.ExtendedAttrs)}replaceCells(l,h,d,f,y=!1){if(y)for(l&&this.getWidth(l-1)===2&&!this.isProtected(l-1)&&this.setCellFromCodePoint(l-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new a.ExtendedAttrs),h<this.length&&this.getWidth(h-1)===2&&!this.isProtected(h)&&this.setCellFromCodePoint(h,0,1,f?.fg||0,f?.bg||0,f?.extended||new a.ExtendedAttrs);l<h&&l<this.length;)this.isProtected(l)||this.setCell(l,d),l++;else for(l&&this.getWidth(l-1)===2&&this.setCellFromCodePoint(l-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new a.ExtendedAttrs),h<this.length&&this.getWidth(h-1)===2&&this.setCellFromCodePoint(h,0,1,f?.fg||0,f?.bg||0,f?.extended||new a.ExtendedAttrs);l<h&&l<this.length;)this.setCell(l++,d)}resize(l,h){if(l===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const d=3*l;if(l>this.length){if(this._data.buffer.byteLength>=4*d)this._data=new Uint32Array(this._data.buffer,0,d);else{const f=new Uint32Array(d);f.set(this._data),this._data=f}for(let f=this.length;f<l;++f)this.setCell(f,h)}else{this._data=this._data.subarray(0,d);const f=Object.keys(this._combined);for(let C=0;C<f.length;C++){const k=parseInt(f[C],10);k>=l&&delete this._combined[k]}const y=Object.keys(this._extendedAttrs);for(let C=0;C<y.length;C++){const k=parseInt(y[C],10);k>=l&&delete this._extendedAttrs[k]}}return this.length=l,4*d*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const l=new Uint32Array(this._data.length);return l.set(this._data),this._data=l,1}return 0}fill(l,h=!1){if(h)for(let d=0;d<this.length;++d)this.isProtected(d)||this.setCell(d,l);else{this._combined={},this._extendedAttrs={};for(let d=0;d<this.length;++d)this.setCell(d,l)}}copyFrom(l){this.length!==l.length?this._data=new Uint32Array(l._data):this._data.set(l._data),this.length=l.length,this._combined={};for(const h in l._combined)this._combined[h]=l._combined[h];this._extendedAttrs={};for(const h in l._extendedAttrs)this._extendedAttrs[h]=l._extendedAttrs[h];this.isWrapped=l.isWrapped}clone(){const l=new S(0);l._data=new Uint32Array(this._data),l.length=this.length;for(const h in this._combined)l._combined[h]=this._combined[h];for(const h in this._extendedAttrs)l._extendedAttrs[h]=this._extendedAttrs[h];return l.isWrapped=this.isWrapped,l}getTrimmedLength(){for(let l=this.length-1;l>=0;--l)if(4194303&this._data[3*l+0])return l+(this._data[3*l+0]>>22);return 0}getNoBgTrimmedLength(){for(let l=this.length-1;l>=0;--l)if(4194303&this._data[3*l+0]||50331648&this._data[3*l+2])return l+(this._data[3*l+0]>>22);return 0}copyCellsFrom(l,h,d,f,y){const C=l._data;if(y)for(let E=f-1;E>=0;E--){for(let b=0;b<3;b++)this._data[3*(d+E)+b]=C[3*(h+E)+b];268435456&C[3*(h+E)+2]&&(this._extendedAttrs[d+E]=l._extendedAttrs[h+E])}else for(let E=0;E<f;E++){for(let b=0;b<3;b++)this._data[3*(d+E)+b]=C[3*(h+E)+b];268435456&C[3*(h+E)+2]&&(this._extendedAttrs[d+E]=l._extendedAttrs[h+E])}const k=Object.keys(l._combined);for(let E=0;E<k.length;E++){const b=parseInt(k[E],10);b>=h&&(this._combined[b-h+d]=l._combined[b])}}translateToString(l=!1,h=0,d=this.length){l&&(d=Math.min(d,this.getTrimmedLength()));let f="";for(;h<d;){const y=this._data[3*h+0],C=2097151&y;f+=2097152&y?this._combined[h]:C?(0,g.stringFromCodePoint)(C):c.WHITESPACE_CELL_CHAR,h+=y>>22||1}return f}}n.BufferLine=S},4841:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.getRangeLength=void 0,n.getRangeLength=function(i,a){if(i.start.y>i.end.y)throw new Error(`Buffer range end (${i.end.x}, ${i.end.y}) cannot be before start (${i.start.x}, ${i.start.y})`);return a*(i.end.y-i.start.y)+(i.end.x-i.start.x+1)}},4634:(v,n)=>{function i(a,u,c){if(u===a.length-1)return a[u].getTrimmedLength();const g=!a[u].hasContent(c-1)&&a[u].getWidth(c-1)===1,x=a[u+1].getWidth(0)===2;return g&&x?c-1:c}Object.defineProperty(n,"__esModule",{value:!0}),n.getWrappedLineTrimmedLength=n.reflowSmallerGetNewLineLengths=n.reflowLargerApplyNewLayout=n.reflowLargerCreateNewLayout=n.reflowLargerGetLinesToRemove=void 0,n.reflowLargerGetLinesToRemove=function(a,u,c,g,x){const S=[];for(let w=0;w<a.length-1;w++){let l=w,h=a.get(++l);if(!h.isWrapped)continue;const d=[a.get(w)];for(;l<a.length&&h.isWrapped;)d.push(h),h=a.get(++l);if(g>=w&&g<l){w+=d.length-1;continue}let f=0,y=i(d,f,u),C=1,k=0;for(;C<d.length;){const b=i(d,C,u),j=b-k,R=c-y,L=Math.min(j,R);d[f].copyCellsFrom(d[C],k,y,L,!1),y+=L,y===c&&(f++,y=0),k+=L,k===b&&(C++,k=0),y===0&&f!==0&&d[f-1].getWidth(c-1)===2&&(d[f].copyCellsFrom(d[f-1],c-1,y++,1,!1),d[f-1].setCell(c-1,x))}d[f].replaceCells(y,c,x);let E=0;for(let b=d.length-1;b>0&&(b>f||d[b].getTrimmedLength()===0);b--)E++;E>0&&(S.push(w+d.length-E),S.push(E)),w+=d.length-1}return S},n.reflowLargerCreateNewLayout=function(a,u){const c=[];let g=0,x=u[g],S=0;for(let w=0;w<a.length;w++)if(x===w){const l=u[++g];a.onDeleteEmitter.fire({index:w-S,amount:l}),w+=l-1,S+=l,x=u[++g]}else c.push(w);return{layout:c,countRemoved:S}},n.reflowLargerApplyNewLayout=function(a,u){const c=[];for(let g=0;g<u.length;g++)c.push(a.get(u[g]));for(let g=0;g<c.length;g++)a.set(g,c[g]);a.length=u.length},n.reflowSmallerGetNewLineLengths=function(a,u,c){const g=[],x=a.map(((h,d)=>i(a,d,u))).reduce(((h,d)=>h+d));let S=0,w=0,l=0;for(;l<x;){if(x-l<c){g.push(x-l);break}S+=c;const h=i(a,w,u);S>h&&(S-=h,w++);const d=a[w].getWidth(S-1)===2;d&&S--;const f=d?c-1:c;g.push(f),l+=f}return g},n.getWrappedLineTrimmedLength=i},5295:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferSet=void 0;const a=i(8460),u=i(844),c=i(9092);class g extends u.Disposable{constructor(S,w){super(),this._optionsService=S,this._bufferService=w,this._onBufferActivate=this.register(new a.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 c.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new c.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(S){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(S),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(S,w){this._normal.resize(S,w),this._alt.resize(S,w),this.setupTabStops(S)}setupTabStops(S){this._normal.setupTabStops(S),this._alt.setupTabStops(S)}}n.BufferSet=g},511:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CellData=void 0;const a=i(482),u=i(643),c=i(3734);class g extends c.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new c.ExtendedAttrs,this.combinedData=""}static fromCharData(S){const w=new g;return w.setFromCharData(S),w}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,a.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(S){this.fg=S[u.CHAR_DATA_ATTR_INDEX],this.bg=0;let w=!1;if(S[u.CHAR_DATA_CHAR_INDEX].length>2)w=!0;else if(S[u.CHAR_DATA_CHAR_INDEX].length===2){const l=S[u.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=l&&l<=56319){const h=S[u.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=h&&h<=57343?this.content=1024*(l-55296)+h-56320+65536|S[u.CHAR_DATA_WIDTH_INDEX]<<22:w=!0}else w=!0}else this.content=S[u.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|S[u.CHAR_DATA_WIDTH_INDEX]<<22;w&&(this.combinedData=S[u.CHAR_DATA_CHAR_INDEX],this.content=2097152|S[u.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}n.CellData=g},643:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.WHITESPACE_CELL_CODE=n.WHITESPACE_CELL_WIDTH=n.WHITESPACE_CELL_CHAR=n.NULL_CELL_CODE=n.NULL_CELL_WIDTH=n.NULL_CELL_CHAR=n.CHAR_DATA_CODE_INDEX=n.CHAR_DATA_WIDTH_INDEX=n.CHAR_DATA_CHAR_INDEX=n.CHAR_DATA_ATTR_INDEX=n.DEFAULT_EXT=n.DEFAULT_ATTR=n.DEFAULT_COLOR=void 0,n.DEFAULT_COLOR=0,n.DEFAULT_ATTR=256|n.DEFAULT_COLOR<<9,n.DEFAULT_EXT=0,n.CHAR_DATA_ATTR_INDEX=0,n.CHAR_DATA_CHAR_INDEX=1,n.CHAR_DATA_WIDTH_INDEX=2,n.CHAR_DATA_CODE_INDEX=3,n.NULL_CELL_CHAR="",n.NULL_CELL_WIDTH=1,n.NULL_CELL_CODE=0,n.WHITESPACE_CELL_CHAR=" ",n.WHITESPACE_CELL_WIDTH=1,n.WHITESPACE_CELL_CODE=32},4863:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Marker=void 0;const a=i(8460),u=i(844);class c{get id(){return this._id}constructor(x){this.line=x,this.isDisposed=!1,this._disposables=[],this._id=c._nextId++,this._onDispose=this.register(new a.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,u.disposeArray)(this._disposables),this._disposables.length=0)}register(x){return this._disposables.push(x),x}}n.Marker=c,c._nextId=1},7116:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DEFAULT_CHARSET=n.CHARSETS=void 0,n.CHARSETS={},n.DEFAULT_CHARSET=n.CHARSETS.B,n.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:"≥","{":"π","|":"≠","}":"£","~":"·"},n.CHARSETS.A={"#":"£"},n.CHARSETS.B=void 0,n.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},n.CHARSETS.C=n.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},n.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},n.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},n.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},n.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},n.CHARSETS.E=n.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},n.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},n.CHARSETS.H=n.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},n.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(v,n)=>{var i,a,u;Object.defineProperty(n,"__esModule",{value:!0}),n.C1_ESCAPED=n.C1=n.C0=void 0,(function(c){c.NUL="\0",c.SOH="",c.STX="",c.ETX="",c.EOT="",c.ENQ="",c.ACK="",c.BEL="\x07",c.BS="\b",c.HT=" ",c.LF=`
|
|
26
|
+
`,c.VT="\v",c.FF="\f",c.CR="\r",c.SO="",c.SI="",c.DLE="",c.DC1="",c.DC2="",c.DC3="",c.DC4="",c.NAK="",c.SYN="",c.ETB="",c.CAN="",c.EM="",c.SUB="",c.ESC="\x1B",c.FS="",c.GS="",c.RS="",c.US="",c.SP=" ",c.DEL=""})(i||(n.C0=i={})),(function(c){c.PAD="",c.HOP="",c.BPH="",c.NBH="",c.IND="",c.NEL="
",c.SSA="",c.ESA="",c.HTS="",c.HTJ="",c.VTS="",c.PLD="",c.PLU="",c.RI="",c.SS2="",c.SS3="",c.DCS="",c.PU1="",c.PU2="",c.STS="",c.CCH="",c.MW="",c.SPA="",c.EPA="",c.SOS="",c.SGCI="",c.SCI="",c.CSI="",c.ST="",c.OSC="",c.PM="",c.APC=""})(a||(n.C1=a={})),(function(c){c.ST=`${i.ESC}\\`})(u||(n.C1_ESCAPED=u={}))},7399:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.evaluateKeyboardEvent=void 0;const a=i(2584),u={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:["'",'"']};n.evaluateKeyboardEvent=function(c,g,x,S){const w={type:0,cancel:!1,key:void 0},l=(c.shiftKey?1:0)|(c.altKey?2:0)|(c.ctrlKey?4:0)|(c.metaKey?8:0);switch(c.keyCode){case 0:c.key==="UIKeyInputUpArrow"?w.key=g?a.C0.ESC+"OA":a.C0.ESC+"[A":c.key==="UIKeyInputLeftArrow"?w.key=g?a.C0.ESC+"OD":a.C0.ESC+"[D":c.key==="UIKeyInputRightArrow"?w.key=g?a.C0.ESC+"OC":a.C0.ESC+"[C":c.key==="UIKeyInputDownArrow"&&(w.key=g?a.C0.ESC+"OB":a.C0.ESC+"[B");break;case 8:if(c.altKey){w.key=a.C0.ESC+a.C0.DEL;break}w.key=a.C0.DEL;break;case 9:if(c.shiftKey){w.key=a.C0.ESC+"[Z";break}w.key=a.C0.HT,w.cancel=!0;break;case 13:w.key=c.altKey?a.C0.ESC+a.C0.CR:a.C0.CR,w.cancel=!0;break;case 27:w.key=a.C0.ESC,c.altKey&&(w.key=a.C0.ESC+a.C0.ESC),w.cancel=!0;break;case 37:if(c.metaKey)break;l?(w.key=a.C0.ESC+"[1;"+(l+1)+"D",w.key===a.C0.ESC+"[1;3D"&&(w.key=a.C0.ESC+(x?"b":"[1;5D"))):w.key=g?a.C0.ESC+"OD":a.C0.ESC+"[D";break;case 39:if(c.metaKey)break;l?(w.key=a.C0.ESC+"[1;"+(l+1)+"C",w.key===a.C0.ESC+"[1;3C"&&(w.key=a.C0.ESC+(x?"f":"[1;5C"))):w.key=g?a.C0.ESC+"OC":a.C0.ESC+"[C";break;case 38:if(c.metaKey)break;l?(w.key=a.C0.ESC+"[1;"+(l+1)+"A",x||w.key!==a.C0.ESC+"[1;3A"||(w.key=a.C0.ESC+"[1;5A")):w.key=g?a.C0.ESC+"OA":a.C0.ESC+"[A";break;case 40:if(c.metaKey)break;l?(w.key=a.C0.ESC+"[1;"+(l+1)+"B",x||w.key!==a.C0.ESC+"[1;3B"||(w.key=a.C0.ESC+"[1;5B")):w.key=g?a.C0.ESC+"OB":a.C0.ESC+"[B";break;case 45:c.shiftKey||c.ctrlKey||(w.key=a.C0.ESC+"[2~");break;case 46:w.key=l?a.C0.ESC+"[3;"+(l+1)+"~":a.C0.ESC+"[3~";break;case 36:w.key=l?a.C0.ESC+"[1;"+(l+1)+"H":g?a.C0.ESC+"OH":a.C0.ESC+"[H";break;case 35:w.key=l?a.C0.ESC+"[1;"+(l+1)+"F":g?a.C0.ESC+"OF":a.C0.ESC+"[F";break;case 33:c.shiftKey?w.type=2:c.ctrlKey?w.key=a.C0.ESC+"[5;"+(l+1)+"~":w.key=a.C0.ESC+"[5~";break;case 34:c.shiftKey?w.type=3:c.ctrlKey?w.key=a.C0.ESC+"[6;"+(l+1)+"~":w.key=a.C0.ESC+"[6~";break;case 112:w.key=l?a.C0.ESC+"[1;"+(l+1)+"P":a.C0.ESC+"OP";break;case 113:w.key=l?a.C0.ESC+"[1;"+(l+1)+"Q":a.C0.ESC+"OQ";break;case 114:w.key=l?a.C0.ESC+"[1;"+(l+1)+"R":a.C0.ESC+"OR";break;case 115:w.key=l?a.C0.ESC+"[1;"+(l+1)+"S":a.C0.ESC+"OS";break;case 116:w.key=l?a.C0.ESC+"[15;"+(l+1)+"~":a.C0.ESC+"[15~";break;case 117:w.key=l?a.C0.ESC+"[17;"+(l+1)+"~":a.C0.ESC+"[17~";break;case 118:w.key=l?a.C0.ESC+"[18;"+(l+1)+"~":a.C0.ESC+"[18~";break;case 119:w.key=l?a.C0.ESC+"[19;"+(l+1)+"~":a.C0.ESC+"[19~";break;case 120:w.key=l?a.C0.ESC+"[20;"+(l+1)+"~":a.C0.ESC+"[20~";break;case 121:w.key=l?a.C0.ESC+"[21;"+(l+1)+"~":a.C0.ESC+"[21~";break;case 122:w.key=l?a.C0.ESC+"[23;"+(l+1)+"~":a.C0.ESC+"[23~";break;case 123:w.key=l?a.C0.ESC+"[24;"+(l+1)+"~":a.C0.ESC+"[24~";break;default:if(!c.ctrlKey||c.shiftKey||c.altKey||c.metaKey)if(x&&!S||!c.altKey||c.metaKey)!x||c.altKey||c.ctrlKey||c.shiftKey||!c.metaKey?c.key&&!c.ctrlKey&&!c.altKey&&!c.metaKey&&c.keyCode>=48&&c.key.length===1?w.key=c.key:c.key&&c.ctrlKey&&(c.key==="_"&&(w.key=a.C0.US),c.key==="@"&&(w.key=a.C0.NUL)):c.keyCode===65&&(w.type=1);else{const h=u[c.keyCode],d=h?.[c.shiftKey?1:0];if(d)w.key=a.C0.ESC+d;else if(c.keyCode>=65&&c.keyCode<=90){const f=c.ctrlKey?c.keyCode-64:c.keyCode+32;let y=String.fromCharCode(f);c.shiftKey&&(y=y.toUpperCase()),w.key=a.C0.ESC+y}else if(c.keyCode===32)w.key=a.C0.ESC+(c.ctrlKey?a.C0.NUL:" ");else if(c.key==="Dead"&&c.code.startsWith("Key")){let f=c.code.slice(3,4);c.shiftKey||(f=f.toLowerCase()),w.key=a.C0.ESC+f,w.cancel=!0}}else c.keyCode>=65&&c.keyCode<=90?w.key=String.fromCharCode(c.keyCode-64):c.keyCode===32?w.key=a.C0.NUL:c.keyCode>=51&&c.keyCode<=55?w.key=String.fromCharCode(c.keyCode-51+27):c.keyCode===56?w.key=a.C0.DEL:c.keyCode===219?w.key=a.C0.ESC:c.keyCode===220?w.key=a.C0.FS:c.keyCode===221&&(w.key=a.C0.GS)}return w}},482:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Utf8ToUtf32=n.StringToUtf32=n.utf32ToString=n.stringFromCodePoint=void 0,n.stringFromCodePoint=function(i){return i>65535?(i-=65536,String.fromCharCode(55296+(i>>10))+String.fromCharCode(i%1024+56320)):String.fromCharCode(i)},n.utf32ToString=function(i,a=0,u=i.length){let c="";for(let g=a;g<u;++g){let x=i[g];x>65535?(x-=65536,c+=String.fromCharCode(55296+(x>>10))+String.fromCharCode(x%1024+56320)):c+=String.fromCharCode(x)}return c},n.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(i,a){const u=i.length;if(!u)return 0;let c=0,g=0;if(this._interim){const x=i.charCodeAt(g++);56320<=x&&x<=57343?a[c++]=1024*(this._interim-55296)+x-56320+65536:(a[c++]=this._interim,a[c++]=x),this._interim=0}for(let x=g;x<u;++x){const S=i.charCodeAt(x);if(55296<=S&&S<=56319){if(++x>=u)return this._interim=S,c;const w=i.charCodeAt(x);56320<=w&&w<=57343?a[c++]=1024*(S-55296)+w-56320+65536:(a[c++]=S,a[c++]=w)}else S!==65279&&(a[c++]=S)}return c}},n.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(i,a){const u=i.length;if(!u)return 0;let c,g,x,S,w=0,l=0,h=0;if(this.interim[0]){let y=!1,C=this.interim[0];C&=(224&C)==192?31:(240&C)==224?15:7;let k,E=0;for(;(k=63&this.interim[++E])&&E<4;)C<<=6,C|=k;const b=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,j=b-E;for(;h<j;){if(h>=u)return 0;if(k=i[h++],(192&k)!=128){h--,y=!0;break}this.interim[E++]=k,C<<=6,C|=63&k}y||(b===2?C<128?h--:a[w++]=C:b===3?C<2048||C>=55296&&C<=57343||C===65279||(a[w++]=C):C<65536||C>1114111||(a[w++]=C)),this.interim.fill(0)}const d=u-4;let f=h;for(;f<u;){for(;!(!(f<d)||128&(c=i[f])||128&(g=i[f+1])||128&(x=i[f+2])||128&(S=i[f+3]));)a[w++]=c,a[w++]=g,a[w++]=x,a[w++]=S,f+=4;if(c=i[f++],c<128)a[w++]=c;else if((224&c)==192){if(f>=u)return this.interim[0]=c,w;if(g=i[f++],(192&g)!=128){f--;continue}if(l=(31&c)<<6|63&g,l<128){f--;continue}a[w++]=l}else if((240&c)==224){if(f>=u)return this.interim[0]=c,w;if(g=i[f++],(192&g)!=128){f--;continue}if(f>=u)return this.interim[0]=c,this.interim[1]=g,w;if(x=i[f++],(192&x)!=128){f--;continue}if(l=(15&c)<<12|(63&g)<<6|63&x,l<2048||l>=55296&&l<=57343||l===65279)continue;a[w++]=l}else if((248&c)==240){if(f>=u)return this.interim[0]=c,w;if(g=i[f++],(192&g)!=128){f--;continue}if(f>=u)return this.interim[0]=c,this.interim[1]=g,w;if(x=i[f++],(192&x)!=128){f--;continue}if(f>=u)return this.interim[0]=c,this.interim[1]=g,this.interim[2]=x,w;if(S=i[f++],(192&S)!=128){f--;continue}if(l=(7&c)<<18|(63&g)<<12|(63&x)<<6|63&S,l<65536||l>1114111)continue;a[w++]=l}}return w}}},225:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.UnicodeV6=void 0;const i=[[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]],a=[[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 u;n.UnicodeV6=class{constructor(){if(this.version="6",!u){u=new Uint8Array(65536),u.fill(1),u[0]=0,u.fill(0,1,32),u.fill(0,127,160),u.fill(2,4352,4448),u[9001]=2,u[9002]=2,u.fill(2,11904,42192),u[12351]=1,u.fill(2,44032,55204),u.fill(2,63744,64256),u.fill(2,65040,65050),u.fill(2,65072,65136),u.fill(2,65280,65377),u.fill(2,65504,65511);for(let c=0;c<i.length;++c)u.fill(0,i[c][0],i[c][1]+1)}}wcwidth(c){return c<32?0:c<127?1:c<65536?u[c]:(function(g,x){let S,w=0,l=x.length-1;if(g<x[0][0]||g>x[l][1])return!1;for(;l>=w;)if(S=w+l>>1,g>x[S][1])w=S+1;else{if(!(g<x[S][0]))return!0;l=S-1}return!1})(c,a)?0:c>=131072&&c<=196605||c>=196608&&c<=262141?2:1}}},5981:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.WriteBuffer=void 0;const a=i(8460),u=i(844);class c extends u.Disposable{constructor(x){super(),this._action=x,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new a.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(x,S){if(S!==void 0&&this._syncCalls>S)return void(this._syncCalls=0);if(this._pendingData+=x.length,this._writeBuffer.push(x),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let w;for(this._isSyncWriting=!0;w=this._writeBuffer.shift();){this._action(w);const l=this._callbacks.shift();l&&l()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(x,S){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+=x.length,this._writeBuffer.push(x),this._callbacks.push(S),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=x.length,this._writeBuffer.push(x),this._callbacks.push(S)}_innerWrite(x=0,S=!0){const w=x||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const l=this._writeBuffer[this._bufferOffset],h=this._action(l,S);if(h){const f=y=>Date.now()-w>=12?setTimeout((()=>this._innerWrite(0,y))):this._innerWrite(w,y);return void h.catch((y=>(queueMicrotask((()=>{throw y})),Promise.resolve(!1)))).then(f)}const d=this._callbacks[this._bufferOffset];if(d&&d(),this._bufferOffset++,this._pendingData-=l.length,Date.now()-w>=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()}}n.WriteBuffer=c},5941:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.toRgbString=n.parseColor=void 0;const i=/^([\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})$/,a=/^[\da-f]+$/;function u(c,g){const x=c.toString(16),S=x.length<2?"0"+x:x;switch(g){case 4:return x[0];case 8:return S;case 12:return(S+S).slice(0,3);default:return S+S}}n.parseColor=function(c){if(!c)return;let g=c.toLowerCase();if(g.indexOf("rgb:")===0){g=g.slice(4);const x=i.exec(g);if(x){const S=x[1]?15:x[4]?255:x[7]?4095:65535;return[Math.round(parseInt(x[1]||x[4]||x[7]||x[10],16)/S*255),Math.round(parseInt(x[2]||x[5]||x[8]||x[11],16)/S*255),Math.round(parseInt(x[3]||x[6]||x[9]||x[12],16)/S*255)]}}else if(g.indexOf("#")===0&&(g=g.slice(1),a.exec(g)&&[3,6,9,12].includes(g.length))){const x=g.length/3,S=[0,0,0];for(let w=0;w<3;++w){const l=parseInt(g.slice(x*w,x*w+x),16);S[w]=x===1?l<<4:x===2?l:x===3?l>>4:l>>8}return S}},n.toRgbString=function(c,g=16){const[x,S,w]=c;return`rgb:${u(x,g)}/${u(S,g)}/${u(w,g)}`}},5770:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.PAYLOAD_LIMIT=void 0,n.PAYLOAD_LIMIT=1e7},6351:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DcsHandler=n.DcsParser=void 0;const a=i(482),u=i(8742),c=i(5770),g=[];n.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(S,w){this._handlers[S]===void 0&&(this._handlers[S]=[]);const l=this._handlers[S];return l.push(w),{dispose:()=>{const h=l.indexOf(w);h!==-1&&l.splice(h,1)}}}clearHandler(S){this._handlers[S]&&delete this._handlers[S]}setHandlerFallback(S){this._handlerFb=S}reset(){if(this._active.length)for(let S=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;S>=0;--S)this._active[S].unhook(!1);this._stack.paused=!1,this._active=g,this._ident=0}hook(S,w){if(this.reset(),this._ident=S,this._active=this._handlers[S]||g,this._active.length)for(let l=this._active.length-1;l>=0;l--)this._active[l].hook(w);else this._handlerFb(this._ident,"HOOK",w)}put(S,w,l){if(this._active.length)for(let h=this._active.length-1;h>=0;h--)this._active[h].put(S,w,l);else this._handlerFb(this._ident,"PUT",(0,a.utf32ToString)(S,w,l))}unhook(S,w=!0){if(this._active.length){let l=!1,h=this._active.length-1,d=!1;if(this._stack.paused&&(h=this._stack.loopPosition-1,l=w,d=this._stack.fallThrough,this._stack.paused=!1),!d&&l===!1){for(;h>=0&&(l=this._active[h].unhook(S),l!==!0);h--)if(l instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=h,this._stack.fallThrough=!1,l;h--}for(;h>=0;h--)if(l=this._active[h].unhook(!1),l instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=h,this._stack.fallThrough=!0,l}else this._handlerFb(this._ident,"UNHOOK",S);this._active=g,this._ident=0}};const x=new u.Params;x.addParam(0),n.DcsHandler=class{constructor(S){this._handler=S,this._data="",this._params=x,this._hitLimit=!1}hook(S){this._params=S.length>1||S.params[0]?S.clone():x,this._data="",this._hitLimit=!1}put(S,w,l){this._hitLimit||(this._data+=(0,a.utf32ToString)(S,w,l),this._data.length>c.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(S){let w=!1;if(this._hitLimit)w=!1;else if(S&&(w=this._handler(this._data,this._params),w instanceof Promise))return w.then((l=>(this._params=x,this._data="",this._hitLimit=!1,l)));return this._params=x,this._data="",this._hitLimit=!1,w}}},2015:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.EscapeSequenceParser=n.VT500_TRANSITION_TABLE=n.TransitionTable=void 0;const a=i(844),u=i(8742),c=i(6242),g=i(6351);class x{constructor(h){this.table=new Uint8Array(h)}setDefault(h,d){this.table.fill(h<<4|d)}add(h,d,f,y){this.table[d<<8|h]=f<<4|y}addMany(h,d,f,y){for(let C=0;C<h.length;C++)this.table[d<<8|h[C]]=f<<4|y}}n.TransitionTable=x;const S=160;n.VT500_TRANSITION_TABLE=(function(){const l=new x(4095),h=Array.apply(null,Array(256)).map(((E,b)=>b)),d=(E,b)=>h.slice(E,b),f=d(32,127),y=d(0,24);y.push(25),y.push.apply(y,d(28,32));const C=d(0,14);let k;for(k in l.setDefault(1,0),l.addMany(f,0,2,0),C)l.addMany([24,26,153,154],k,3,0),l.addMany(d(128,144),k,3,0),l.addMany(d(144,152),k,3,0),l.add(156,k,0,0),l.add(27,k,11,1),l.add(157,k,4,8),l.addMany([152,158,159],k,0,7),l.add(155,k,11,3),l.add(144,k,11,9);return l.addMany(y,0,3,0),l.addMany(y,1,3,1),l.add(127,1,0,1),l.addMany(y,8,0,8),l.addMany(y,3,3,3),l.add(127,3,0,3),l.addMany(y,4,3,4),l.add(127,4,0,4),l.addMany(y,6,3,6),l.addMany(y,5,3,5),l.add(127,5,0,5),l.addMany(y,2,3,2),l.add(127,2,0,2),l.add(93,1,4,8),l.addMany(f,8,5,8),l.add(127,8,5,8),l.addMany([156,27,24,26,7],8,6,0),l.addMany(d(28,32),8,0,8),l.addMany([88,94,95],1,0,7),l.addMany(f,7,0,7),l.addMany(y,7,0,7),l.add(156,7,0,0),l.add(127,7,0,7),l.add(91,1,11,3),l.addMany(d(64,127),3,7,0),l.addMany(d(48,60),3,8,4),l.addMany([60,61,62,63],3,9,4),l.addMany(d(48,60),4,8,4),l.addMany(d(64,127),4,7,0),l.addMany([60,61,62,63],4,0,6),l.addMany(d(32,64),6,0,6),l.add(127,6,0,6),l.addMany(d(64,127),6,0,0),l.addMany(d(32,48),3,9,5),l.addMany(d(32,48),5,9,5),l.addMany(d(48,64),5,0,6),l.addMany(d(64,127),5,7,0),l.addMany(d(32,48),4,9,5),l.addMany(d(32,48),1,9,2),l.addMany(d(32,48),2,9,2),l.addMany(d(48,127),2,10,0),l.addMany(d(48,80),1,10,0),l.addMany(d(81,88),1,10,0),l.addMany([89,90,92],1,10,0),l.addMany(d(96,127),1,10,0),l.add(80,1,11,9),l.addMany(y,9,0,9),l.add(127,9,0,9),l.addMany(d(28,32),9,0,9),l.addMany(d(32,48),9,9,12),l.addMany(d(48,60),9,8,10),l.addMany([60,61,62,63],9,9,10),l.addMany(y,11,0,11),l.addMany(d(32,128),11,0,11),l.addMany(d(28,32),11,0,11),l.addMany(y,10,0,10),l.add(127,10,0,10),l.addMany(d(28,32),10,0,10),l.addMany(d(48,60),10,8,10),l.addMany([60,61,62,63],10,0,11),l.addMany(d(32,48),10,9,12),l.addMany(y,12,0,12),l.add(127,12,0,12),l.addMany(d(28,32),12,0,12),l.addMany(d(32,48),12,9,12),l.addMany(d(48,64),12,0,11),l.addMany(d(64,127),12,12,13),l.addMany(d(64,127),10,12,13),l.addMany(d(64,127),9,12,13),l.addMany(y,13,13,13),l.addMany(f,13,13,13),l.add(127,13,0,13),l.addMany([27,156,24,26],13,14,0),l.add(S,0,2,0),l.add(S,8,5,8),l.add(S,6,0,6),l.add(S,11,0,11),l.add(S,13,13,13),l})();class w extends a.Disposable{constructor(h=n.VT500_TRANSITION_TABLE){super(),this._transitions=h,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new u.Params,this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._printHandlerFb=(d,f,y)=>{},this._executeHandlerFb=d=>{},this._csiHandlerFb=(d,f)=>{},this._escHandlerFb=d=>{},this._errorHandlerFb=d=>d,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,a.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new c.OscParser),this._dcsParser=this.register(new g.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(h,d=[64,126]){let f=0;if(h.prefix){if(h.prefix.length>1)throw new Error("only one byte as prefix supported");if(f=h.prefix.charCodeAt(0),f&&60>f||f>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(h.intermediates){if(h.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let C=0;C<h.intermediates.length;++C){const k=h.intermediates.charCodeAt(C);if(32>k||k>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");f<<=8,f|=k}}if(h.final.length!==1)throw new Error("final must be a single byte");const y=h.final.charCodeAt(0);if(d[0]>y||y>d[1])throw new Error(`final must be in range ${d[0]} .. ${d[1]}`);return f<<=8,f|=y,f}identToString(h){const d=[];for(;h;)d.push(String.fromCharCode(255&h)),h>>=8;return d.reverse().join("")}setPrintHandler(h){this._printHandler=h}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(h,d){const f=this._identifier(h,[48,126]);this._escHandlers[f]===void 0&&(this._escHandlers[f]=[]);const y=this._escHandlers[f];return y.push(d),{dispose:()=>{const C=y.indexOf(d);C!==-1&&y.splice(C,1)}}}clearEscHandler(h){this._escHandlers[this._identifier(h,[48,126])]&&delete this._escHandlers[this._identifier(h,[48,126])]}setEscHandlerFallback(h){this._escHandlerFb=h}setExecuteHandler(h,d){this._executeHandlers[h.charCodeAt(0)]=d}clearExecuteHandler(h){this._executeHandlers[h.charCodeAt(0)]&&delete this._executeHandlers[h.charCodeAt(0)]}setExecuteHandlerFallback(h){this._executeHandlerFb=h}registerCsiHandler(h,d){const f=this._identifier(h);this._csiHandlers[f]===void 0&&(this._csiHandlers[f]=[]);const y=this._csiHandlers[f];return y.push(d),{dispose:()=>{const C=y.indexOf(d);C!==-1&&y.splice(C,1)}}}clearCsiHandler(h){this._csiHandlers[this._identifier(h)]&&delete this._csiHandlers[this._identifier(h)]}setCsiHandlerFallback(h){this._csiHandlerFb=h}registerDcsHandler(h,d){return this._dcsParser.registerHandler(this._identifier(h),d)}clearDcsHandler(h){this._dcsParser.clearHandler(this._identifier(h))}setDcsHandlerFallback(h){this._dcsParser.setHandlerFallback(h)}registerOscHandler(h,d){return this._oscParser.registerHandler(h,d)}clearOscHandler(h){this._oscParser.clearHandler(h)}setOscHandlerFallback(h){this._oscParser.setHandlerFallback(h)}setErrorHandler(h){this._errorHandler=h}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(h,d,f,y,C){this._parseStack.state=h,this._parseStack.handlers=d,this._parseStack.handlerPos=f,this._parseStack.transition=y,this._parseStack.chunkPos=C}parse(h,d,f){let y,C=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(f===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const b=this._parseStack.handlers;let j=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(f===!1&&j>-1){for(;j>=0&&(y=b[j](this._params),y!==!0);j--)if(y instanceof Promise)return this._parseStack.handlerPos=j,y}this._parseStack.handlers=[];break;case 4:if(f===!1&&j>-1){for(;j>=0&&(y=b[j](),y!==!0);j--)if(y instanceof Promise)return this._parseStack.handlerPos=j,y}this._parseStack.handlers=[];break;case 6:if(C=h[this._parseStack.chunkPos],y=this._dcsParser.unhook(C!==24&&C!==26,f),y)return y;C===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(C=h[this._parseStack.chunkPos],y=this._oscParser.end(C!==24&&C!==26,f),y)return y;C===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 b=E;b<d;++b){switch(C=h[b],k=this._transitions.table[this.currentState<<8|(C<160?C:S)],k>>4){case 2:for(let D=b+1;;++D){if(D>=d||(C=h[D])<32||C>126&&C<S){this._printHandler(h,b,D),b=D-1;break}if(++D>=d||(C=h[D])<32||C>126&&C<S){this._printHandler(h,b,D),b=D-1;break}if(++D>=d||(C=h[D])<32||C>126&&C<S){this._printHandler(h,b,D),b=D-1;break}if(++D>=d||(C=h[D])<32||C>126&&C<S){this._printHandler(h,b,D),b=D-1;break}}break;case 3:this._executeHandlers[C]?this._executeHandlers[C]():this._executeHandlerFb(C),this.precedingCodepoint=0;break;case 0:break;case 1:if(this._errorHandler({position:b,code:C,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const j=this._csiHandlers[this._collect<<8|C];let R=j?j.length-1:-1;for(;R>=0&&(y=j[R](this._params),y!==!0);R--)if(y instanceof Promise)return this._preserveStack(3,j,R,k,b),y;R<0&&this._csiHandlerFb(this._collect<<8|C,this._params),this.precedingCodepoint=0;break;case 8:do switch(C){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(C-48)}while(++b<d&&(C=h[b])>47&&C<60);b--;break;case 9:this._collect<<=8,this._collect|=C;break;case 10:const L=this._escHandlers[this._collect<<8|C];let T=L?L.length-1:-1;for(;T>=0&&(y=L[T](),y!==!0);T--)if(y instanceof Promise)return this._preserveStack(4,L,T,k,b),y;T<0&&this._escHandlerFb(this._collect<<8|C),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|C,this._params);break;case 13:for(let D=b+1;;++D)if(D>=d||(C=h[D])===24||C===26||C===27||C>127&&C<S){this._dcsParser.put(h,b,D),b=D-1;break}break;case 14:if(y=this._dcsParser.unhook(C!==24&&C!==26),y)return this._preserveStack(6,[],0,k,b),y;C===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 D=b+1;;D++)if(D>=d||(C=h[D])<32||C>127&&C<S){this._oscParser.put(h,b,D),b=D-1;break}break;case 6:if(y=this._oscParser.end(C!==24&&C!==26),y)return this._preserveStack(5,[],0,k,b),y;C===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0}this.currentState=15&k}}}n.EscapeSequenceParser=w},6242:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.OscHandler=n.OscParser=void 0;const a=i(5770),u=i(482),c=[];n.OscParser=class{constructor(){this._state=0,this._active=c,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(g,x){this._handlers[g]===void 0&&(this._handlers[g]=[]);const S=this._handlers[g];return S.push(x),{dispose:()=>{const w=S.indexOf(x);w!==-1&&S.splice(w,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=c}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=c,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||c,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,x,S){if(this._active.length)for(let w=this._active.length-1;w>=0;w--)this._active[w].put(g,x,S);else this._handlerFb(this._id,"PUT",(0,u.utf32ToString)(g,x,S))}start(){this.reset(),this._state=1}put(g,x,S){if(this._state!==3){if(this._state===1)for(;x<S;){const w=g[x++];if(w===59){this._state=2,this._start();break}if(w<48||57<w)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+w-48}this._state===2&&S-x>0&&this._put(g,x,S)}}end(g,x=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let S=!1,w=this._active.length-1,l=!1;if(this._stack.paused&&(w=this._stack.loopPosition-1,S=x,l=this._stack.fallThrough,this._stack.paused=!1),!l&&S===!1){for(;w>=0&&(S=this._active[w].end(g),S!==!0);w--)if(S instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=w,this._stack.fallThrough=!1,S;w--}for(;w>=0;w--)if(S=this._active[w].end(!1),S instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=w,this._stack.fallThrough=!0,S}else this._handlerFb(this._id,"END",g);this._active=c,this._id=-1,this._state=0}}},n.OscHandler=class{constructor(g){this._handler=g,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(g,x,S){this._hitLimit||(this._data+=(0,u.utf32ToString)(g,x,S),this._data.length>a.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(g){let x=!1;if(this._hitLimit)x=!1;else if(g&&(x=this._handler(this._data),x instanceof Promise))return x.then((S=>(this._data="",this._hitLimit=!1,S)));return this._data="",this._hitLimit=!1,x}}},8742:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Params=void 0;const i=2147483647;class a{static fromArray(c){const g=new a;if(!c.length)return g;for(let x=Array.isArray(c[0])?1:0;x<c.length;++x){const S=c[x];if(Array.isArray(S))for(let w=0;w<S.length;++w)g.addSubParam(S[w]);else g.addParam(S)}return g}constructor(c=32,g=32){if(this.maxLength=c,this.maxSubParamsLength=g,g>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(c),this.length=0,this._subParams=new Int32Array(g),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(c),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const c=new a(this.maxLength,this.maxSubParamsLength);return c.params.set(this.params),c.length=this.length,c._subParams.set(this._subParams),c._subParamsLength=this._subParamsLength,c._subParamsIdx.set(this._subParamsIdx),c._rejectDigits=this._rejectDigits,c._rejectSubDigits=this._rejectSubDigits,c._digitIsSub=this._digitIsSub,c}toArray(){const c=[];for(let g=0;g<this.length;++g){c.push(this.params[g]);const x=this._subParamsIdx[g]>>8,S=255&this._subParamsIdx[g];S-x>0&&c.push(Array.prototype.slice.call(this._subParams,x,S))}return c}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(c){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(c<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=c>i?i:c}}addSubParam(c){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(c<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=c>i?i:c,this._subParamsIdx[this.length-1]++}}hasSubParams(c){return(255&this._subParamsIdx[c])-(this._subParamsIdx[c]>>8)>0}getSubParams(c){const g=this._subParamsIdx[c]>>8,x=255&this._subParamsIdx[c];return x-g>0?this._subParams.subarray(g,x):null}getSubParamsAll(){const c={};for(let g=0;g<this.length;++g){const x=this._subParamsIdx[g]>>8,S=255&this._subParamsIdx[g];S-x>0&&(c[g]=this._subParams.slice(x,S))}return c}addDigit(c){let g;if(this._rejectDigits||!(g=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const x=this._digitIsSub?this._subParams:this.params,S=x[g-1];x[g-1]=~S?Math.min(10*S+c,i):c}}n.Params=a},5741:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.AddonManager=void 0,n.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let i=this._addons.length-1;i>=0;i--)this._addons[i].instance.dispose()}loadAddon(i,a){const u={instance:a,dispose:a.dispose,isDisposed:!1};this._addons.push(u),a.dispose=()=>this._wrappedAddonDispose(u),a.activate(i)}_wrappedAddonDispose(i){if(i.isDisposed)return;let a=-1;for(let u=0;u<this._addons.length;u++)if(this._addons[u]===i){a=u;break}if(a===-1)throw new Error("Could not dispose an addon that has not been loaded");i.isDisposed=!0,i.dispose.apply(i.instance),this._addons.splice(a,1)}}},8771:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferApiView=void 0;const a=i(3785),u=i(511);n.BufferApiView=class{constructor(c,g){this._buffer=c,this.type=g}init(c){return this._buffer=c,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(c){const g=this._buffer.lines.get(c);if(g)return new a.BufferLineApiView(g)}getNullCell(){return new u.CellData}}},3785:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferLineApiView=void 0;const a=i(511);n.BufferLineApiView=class{constructor(u){this._line=u}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(u,c){if(!(u<0||u>=this._line.length))return c?(this._line.loadCell(u,c),c):this._line.loadCell(u,new a.CellData)}translateToString(u,c,g){return this._line.translateToString(u,c,g)}}},8285:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferNamespaceApi=void 0;const a=i(8771),u=i(8460),c=i(844);class g extends c.Disposable{constructor(S){super(),this._core=S,this._onBufferChange=this.register(new u.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new a.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new a.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)}}n.BufferNamespaceApi=g},7975:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ParserApi=void 0,n.ParserApi=class{constructor(i){this._core=i}registerCsiHandler(i,a){return this._core.registerCsiHandler(i,(u=>a(u.toArray())))}addCsiHandler(i,a){return this.registerCsiHandler(i,a)}registerDcsHandler(i,a){return this._core.registerDcsHandler(i,((u,c)=>a(u,c.toArray())))}addDcsHandler(i,a){return this.registerDcsHandler(i,a)}registerEscHandler(i,a){return this._core.registerEscHandler(i,a)}addEscHandler(i,a){return this.registerEscHandler(i,a)}registerOscHandler(i,a){return this._core.registerOscHandler(i,a)}addOscHandler(i,a){return this.registerOscHandler(i,a)}}},7090:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.UnicodeApi=void 0,n.UnicodeApi=class{constructor(i){this._core=i}register(i){this._core.unicodeService.register(i)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(i){this._core.unicodeService.activeVersion=i}}},744:function(v,n,i){var a=this&&this.__decorate||function(l,h,d,f){var y,C=arguments.length,k=C<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(l,h,d,f);else for(var E=l.length-1;E>=0;E--)(y=l[E])&&(k=(C<3?y(k):C>3?y(h,d,k):y(h,d))||k);return C>3&&k&&Object.defineProperty(h,d,k),k},u=this&&this.__param||function(l,h){return function(d,f){h(d,f,l)}};Object.defineProperty(n,"__esModule",{value:!0}),n.BufferService=n.MINIMUM_ROWS=n.MINIMUM_COLS=void 0;const c=i(8460),g=i(844),x=i(5295),S=i(2585);n.MINIMUM_COLS=2,n.MINIMUM_ROWS=1;let w=n.BufferService=class extends g.Disposable{get buffer(){return this.buffers.active}constructor(l){super(),this.isUserScrolling=!1,this._onResize=this.register(new c.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new c.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(l.rawOptions.cols||0,n.MINIMUM_COLS),this.rows=Math.max(l.rawOptions.rows||0,n.MINIMUM_ROWS),this.buffers=this.register(new x.BufferSet(l,this))}resize(l,h){this.cols=l,this.rows=h,this.buffers.resize(l,h),this._onResize.fire({cols:l,rows:h})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(l,h=!1){const d=this.buffer;let f;f=this._cachedBlankLine,f&&f.length===this.cols&&f.getFg(0)===l.fg&&f.getBg(0)===l.bg||(f=d.getBlankLine(l,h),this._cachedBlankLine=f),f.isWrapped=h;const y=d.ybase+d.scrollTop,C=d.ybase+d.scrollBottom;if(d.scrollTop===0){const k=d.lines.isFull;C===d.lines.length-1?k?d.lines.recycle().copyFrom(f):d.lines.push(f.clone()):d.lines.splice(C+1,0,f.clone()),k?this.isUserScrolling&&(d.ydisp=Math.max(d.ydisp-1,0)):(d.ybase++,this.isUserScrolling||d.ydisp++)}else{const k=C-y+1;d.lines.shiftElements(y+1,k-1,-1),d.lines.set(C,f.clone())}this.isUserScrolling||(d.ydisp=d.ybase),this._onScroll.fire(d.ydisp)}scrollLines(l,h,d){const f=this.buffer;if(l<0){if(f.ydisp===0)return;this.isUserScrolling=!0}else l+f.ydisp>=f.ybase&&(this.isUserScrolling=!1);const y=f.ydisp;f.ydisp=Math.max(Math.min(f.ydisp+l,f.ybase),0),y!==f.ydisp&&(h||this._onScroll.fire(f.ydisp))}};n.BufferService=w=a([u(0,S.IOptionsService)],w)},7994:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CharsetService=void 0,n.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(i){this.glevel=i,this.charset=this._charsets[i]}setgCharset(i,a){this._charsets[i]=a,this.glevel===i&&(this.charset=a)}}},1753:function(v,n,i){var a=this&&this.__decorate||function(f,y,C,k){var E,b=arguments.length,j=b<3?y:k===null?k=Object.getOwnPropertyDescriptor(y,C):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(f,y,C,k);else for(var R=f.length-1;R>=0;R--)(E=f[R])&&(j=(b<3?E(j):b>3?E(y,C,j):E(y,C))||j);return b>3&&j&&Object.defineProperty(y,C,j),j},u=this&&this.__param||function(f,y){return function(C,k){y(C,k,f)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CoreMouseService=void 0;const c=i(2585),g=i(8460),x=i(844),S={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:f=>f.button!==4&&f.action===1&&(f.ctrl=!1,f.alt=!1,f.shift=!1,!0)},VT200:{events:19,restrict:f=>f.action!==32},DRAG:{events:23,restrict:f=>f.action!==32||f.button!==3},ANY:{events:31,restrict:f=>!0}};function w(f,y){let C=(f.ctrl?16:0)|(f.shift?4:0)|(f.alt?8:0);return f.button===4?(C|=64,C|=f.action):(C|=3&f.button,4&f.button&&(C|=64),8&f.button&&(C|=128),f.action===32?C|=32:f.action!==0||y||(C|=3)),C}const l=String.fromCharCode,h={DEFAULT:f=>{const y=[w(f,!1)+32,f.col+32,f.row+32];return y[0]>255||y[1]>255||y[2]>255?"":`\x1B[M${l(y[0])}${l(y[1])}${l(y[2])}`},SGR:f=>{const y=f.action===0&&f.button!==4?"m":"M";return`\x1B[<${w(f,!0)};${f.col};${f.row}${y}`},SGR_PIXELS:f=>{const y=f.action===0&&f.button!==4?"m":"M";return`\x1B[<${w(f,!0)};${f.x};${f.y}${y}`}};let d=n.CoreMouseService=class extends x.Disposable{constructor(f,y){super(),this._bufferService=f,this._coreService=y,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 C of Object.keys(S))this.addProtocol(C,S[C]);for(const C of Object.keys(h))this.addEncoding(C,h[C]);this.reset()}addProtocol(f,y){this._protocols[f]=y}addEncoding(f,y){this._encodings[f]=y}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(f){if(!this._protocols[f])throw new Error(`unknown protocol "${f}"`);this._activeProtocol=f,this._onProtocolChange.fire(this._protocols[f].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(f){if(!this._encodings[f])throw new Error(`unknown encoding "${f}"`);this._activeEncoding=f}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(f){if(f.col<0||f.col>=this._bufferService.cols||f.row<0||f.row>=this._bufferService.rows||f.button===4&&f.action===32||f.button===3&&f.action!==32||f.button!==4&&(f.action===2||f.action===3)||(f.col++,f.row++,f.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,f,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(f))return!1;const y=this._encodings[this._activeEncoding](f);return y&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(y):this._coreService.triggerDataEvent(y,!0)),this._lastEvent=f,!0}explainEvents(f){return{down:!!(1&f),up:!!(2&f),drag:!!(4&f),move:!!(8&f),wheel:!!(16&f)}}_equalEvents(f,y,C){if(C){if(f.x!==y.x||f.y!==y.y)return!1}else if(f.col!==y.col||f.row!==y.row)return!1;return f.button===y.button&&f.action===y.action&&f.ctrl===y.ctrl&&f.alt===y.alt&&f.shift===y.shift}};n.CoreMouseService=d=a([u(0,c.IBufferService),u(1,c.ICoreService)],d)},6975:function(v,n,i){var a=this&&this.__decorate||function(d,f,y,C){var k,E=arguments.length,b=E<3?f:C===null?C=Object.getOwnPropertyDescriptor(f,y):C;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(d,f,y,C);else for(var j=d.length-1;j>=0;j--)(k=d[j])&&(b=(E<3?k(b):E>3?k(f,y,b):k(f,y))||b);return E>3&&b&&Object.defineProperty(f,y,b),b},u=this&&this.__param||function(d,f){return function(y,C){f(y,C,d)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CoreService=void 0;const c=i(1439),g=i(8460),x=i(844),S=i(2585),w=Object.freeze({insertMode:!1}),l=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let h=n.CoreService=class extends x.Disposable{constructor(d,f,y){super(),this._bufferService=d,this._logService=f,this._optionsService=y,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,c.clone)(w),this.decPrivateModes=(0,c.clone)(l)}reset(){this.modes=(0,c.clone)(w),this.decPrivateModes=(0,c.clone)(l)}triggerDataEvent(d,f=!1){if(this._optionsService.rawOptions.disableStdin)return;const y=this._bufferService.buffer;f&&this._optionsService.rawOptions.scrollOnUserInput&&y.ybase!==y.ydisp&&this._onRequestScrollToBottom.fire(),f&&this._onUserInput.fire(),this._logService.debug(`sending data "${d}"`,(()=>d.split("").map((C=>C.charCodeAt(0))))),this._onData.fire(d)}triggerBinaryEvent(d){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${d}"`,(()=>d.split("").map((f=>f.charCodeAt(0))))),this._onBinary.fire(d))}};n.CoreService=h=a([u(0,S.IBufferService),u(1,S.ILogService),u(2,S.IOptionsService)],h)},9074:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DecorationService=void 0;const a=i(8055),u=i(8460),c=i(844),g=i(6106);let x=0,S=0;class w extends c.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new g.SortedList((d=>d?.marker.line)),this._onDecorationRegistered=this.register(new u.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new u.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,c.toDisposable)((()=>this.reset())))}registerDecoration(d){if(d.marker.isDisposed)return;const f=new l(d);if(f){const y=f.marker.onDispose((()=>f.dispose()));f.onDispose((()=>{f&&(this._decorations.delete(f)&&this._onDecorationRemoved.fire(f),y.dispose())})),this._decorations.insert(f),this._onDecorationRegistered.fire(f)}return f}reset(){for(const d of this._decorations.values())d.dispose();this._decorations.clear()}*getDecorationsAtCell(d,f,y){var C,k,E;let b=0,j=0;for(const R of this._decorations.getKeyIterator(f))b=(C=R.options.x)!==null&&C!==void 0?C:0,j=b+((k=R.options.width)!==null&&k!==void 0?k:1),d>=b&&d<j&&(!y||((E=R.options.layer)!==null&&E!==void 0?E:"bottom")===y)&&(yield R)}forEachDecorationAtCell(d,f,y,C){this._decorations.forEachByKey(f,(k=>{var E,b,j;x=(E=k.options.x)!==null&&E!==void 0?E:0,S=x+((b=k.options.width)!==null&&b!==void 0?b:1),d>=x&&d<S&&(!y||((j=k.options.layer)!==null&&j!==void 0?j:"bottom")===y)&&C(k)}))}}n.DecorationService=w;class l extends c.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=a.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=a.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(d){super(),this.options=d,this.onRenderEmitter=this.register(new u.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new u.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=d.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.InstantiationService=n.ServiceCollection=void 0;const a=i(2585),u=i(8343);class c{constructor(...x){this._entries=new Map;for(const[S,w]of x)this.set(S,w)}set(x,S){const w=this._entries.get(x);return this._entries.set(x,S),w}forEach(x){for(const[S,w]of this._entries.entries())x(S,w)}has(x){return this._entries.has(x)}get(x){return this._entries.get(x)}}n.ServiceCollection=c,n.InstantiationService=class{constructor(){this._services=new c,this._services.set(a.IInstantiationService,this)}setService(g,x){this._services.set(g,x)}getService(g){return this._services.get(g)}createInstance(g,...x){const S=(0,u.getServiceDependencies)(g).sort(((h,d)=>h.index-d.index)),w=[];for(const h of S){const d=this._services.get(h.id);if(!d)throw new Error(`[createInstance] ${g.name} depends on UNKNOWN service ${h.id}.`);w.push(d)}const l=S.length>0?S[0].index:x.length;if(x.length!==l)throw new Error(`[createInstance] First service dependency of ${g.name} at position ${l+1} conflicts with ${x.length} static arguments`);return new g(...x,...w)}}},7866:function(v,n,i){var a=this&&this.__decorate||function(l,h,d,f){var y,C=arguments.length,k=C<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(l,h,d,f);else for(var E=l.length-1;E>=0;E--)(y=l[E])&&(k=(C<3?y(k):C>3?y(h,d,k):y(h,d))||k);return C>3&&k&&Object.defineProperty(h,d,k),k},u=this&&this.__param||function(l,h){return function(d,f){h(d,f,l)}};Object.defineProperty(n,"__esModule",{value:!0}),n.traceCall=n.setTraceLogger=n.LogService=void 0;const c=i(844),g=i(2585),x={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 S,w=n.LogService=class extends c.Disposable{get logLevel(){return this._logLevel}constructor(l){super(),this._optionsService=l,this._logLevel=g.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),S=this}_updateLogLevel(){this._logLevel=x[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(l){for(let h=0;h<l.length;h++)typeof l[h]=="function"&&(l[h]=l[h]())}_log(l,h,d){this._evalLazyOptionalParams(d),l.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+h,...d)}trace(l,...h){var d,f;this._logLevel<=g.LogLevelEnum.TRACE&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.trace.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.log,l,h)}debug(l,...h){var d,f;this._logLevel<=g.LogLevelEnum.DEBUG&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.debug.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.log,l,h)}info(l,...h){var d,f;this._logLevel<=g.LogLevelEnum.INFO&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.info.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.info,l,h)}warn(l,...h){var d,f;this._logLevel<=g.LogLevelEnum.WARN&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.warn.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.warn,l,h)}error(l,...h){var d,f;this._logLevel<=g.LogLevelEnum.ERROR&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.error.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.error,l,h)}};n.LogService=w=a([u(0,g.IOptionsService)],w),n.setTraceLogger=function(l){S=l},n.traceCall=function(l,h,d){if(typeof d.value!="function")throw new Error("not supported");const f=d.value;d.value=function(...y){if(S.logLevel!==g.LogLevelEnum.TRACE)return f.apply(this,y);S.trace(`GlyphRenderer#${f.name}(${y.map((k=>JSON.stringify(k))).join(", ")})`);const C=f.apply(this,y);return S.trace(`GlyphRenderer#${f.name} return`,C),C}}},7302:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.OptionsService=n.DEFAULT_OPTIONS=void 0;const a=i(8460),u=i(844),c=i(6114);n.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:c.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 x extends u.Disposable{constructor(w){super(),this._onOptionChange=this.register(new a.EventEmitter),this.onOptionChange=this._onOptionChange.event;const l=Object.assign({},n.DEFAULT_OPTIONS);for(const h in w)if(h in l)try{const d=w[h];l[h]=this._sanitizeAndValidateOption(h,d)}catch(d){console.error(d)}this.rawOptions=l,this.options=Object.assign({},l),this._setupOptions()}onSpecificOptionChange(w,l){return this.onOptionChange((h=>{h===w&&l(this.rawOptions[w])}))}onMultipleOptionChange(w,l){return this.onOptionChange((h=>{w.indexOf(h)!==-1&&l()}))}_setupOptions(){const w=h=>{if(!(h in n.DEFAULT_OPTIONS))throw new Error(`No option with key "${h}"`);return this.rawOptions[h]},l=(h,d)=>{if(!(h in n.DEFAULT_OPTIONS))throw new Error(`No option with key "${h}"`);d=this._sanitizeAndValidateOption(h,d),this.rawOptions[h]!==d&&(this.rawOptions[h]=d,this._onOptionChange.fire(h))};for(const h in this.rawOptions){const d={get:w.bind(this,h),set:l.bind(this,h)};Object.defineProperty(this.options,h,d)}}_sanitizeAndValidateOption(w,l){switch(w){case"cursorStyle":if(l||(l=n.DEFAULT_OPTIONS[w]),!(function(h){return h==="block"||h==="underline"||h==="bar"})(l))throw new Error(`"${l}" is not a valid value for ${w}`);break;case"wordSeparator":l||(l=n.DEFAULT_OPTIONS[w]);break;case"fontWeight":case"fontWeightBold":if(typeof l=="number"&&1<=l&&l<=1e3)break;l=g.includes(l)?l:n.DEFAULT_OPTIONS[w];break;case"cursorWidth":l=Math.floor(l);case"lineHeight":case"tabStopWidth":if(l<1)throw new Error(`${w} cannot be less than 1, value: ${l}`);break;case"minimumContrastRatio":l=Math.max(1,Math.min(21,Math.round(10*l)/10));break;case"scrollback":if((l=Math.min(l,4294967295))<0)throw new Error(`${w} cannot be less than 0, value: ${l}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(l<=0)throw new Error(`${w} cannot be less than or equal to 0, value: ${l}`);break;case"rows":case"cols":if(!l&&l!==0)throw new Error(`${w} must be numeric, value: ${l}`);break;case"windowsPty":l=l??{}}return l}}n.OptionsService=x},2660:function(v,n,i){var a=this&&this.__decorate||function(x,S,w,l){var h,d=arguments.length,f=d<3?S:l===null?l=Object.getOwnPropertyDescriptor(S,w):l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")f=Reflect.decorate(x,S,w,l);else for(var y=x.length-1;y>=0;y--)(h=x[y])&&(f=(d<3?h(f):d>3?h(S,w,f):h(S,w))||f);return d>3&&f&&Object.defineProperty(S,w,f),f},u=this&&this.__param||function(x,S){return function(w,l){S(w,l,x)}};Object.defineProperty(n,"__esModule",{value:!0}),n.OscLinkService=void 0;const c=i(2585);let g=n.OscLinkService=class{constructor(x){this._bufferService=x,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(x){const S=this._bufferService.buffer;if(x.id===void 0){const y=S.addMarker(S.ybase+S.y),C={data:x,id:this._nextId++,lines:[y]};return y.onDispose((()=>this._removeMarkerFromLink(C,y))),this._dataByLinkId.set(C.id,C),C.id}const w=x,l=this._getEntryIdKey(w),h=this._entriesWithId.get(l);if(h)return this.addLineToLink(h.id,S.ybase+S.y),h.id;const d=S.addMarker(S.ybase+S.y),f={id:this._nextId++,key:this._getEntryIdKey(w),data:w,lines:[d]};return d.onDispose((()=>this._removeMarkerFromLink(f,d))),this._entriesWithId.set(f.key,f),this._dataByLinkId.set(f.id,f),f.id}addLineToLink(x,S){const w=this._dataByLinkId.get(x);if(w&&w.lines.every((l=>l.line!==S))){const l=this._bufferService.buffer.addMarker(S);w.lines.push(l),l.onDispose((()=>this._removeMarkerFromLink(w,l)))}}getLinkData(x){var S;return(S=this._dataByLinkId.get(x))===null||S===void 0?void 0:S.data}_getEntryIdKey(x){return`${x.id};;${x.uri}`}_removeMarkerFromLink(x,S){const w=x.lines.indexOf(S);w!==-1&&(x.lines.splice(w,1),x.lines.length===0&&(x.data.id!==void 0&&this._entriesWithId.delete(x.key),this._dataByLinkId.delete(x.id)))}};n.OscLinkService=g=a([u(0,c.IBufferService)],g)},8343:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.createDecorator=n.getServiceDependencies=n.serviceRegistry=void 0;const i="di$target",a="di$dependencies";n.serviceRegistry=new Map,n.getServiceDependencies=function(u){return u[a]||[]},n.createDecorator=function(u){if(n.serviceRegistry.has(u))return n.serviceRegistry.get(u);const c=function(g,x,S){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(w,l,h){l[i]===l?l[a].push({id:w,index:h}):(l[a]=[{id:w,index:h}],l[i]=l)})(c,g,S)};return c.toString=()=>u,n.serviceRegistry.set(u,c),c}},2585:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.IDecorationService=n.IUnicodeService=n.IOscLinkService=n.IOptionsService=n.ILogService=n.LogLevelEnum=n.IInstantiationService=n.ICharsetService=n.ICoreService=n.ICoreMouseService=n.IBufferService=void 0;const a=i(8343);var u;n.IBufferService=(0,a.createDecorator)("BufferService"),n.ICoreMouseService=(0,a.createDecorator)("CoreMouseService"),n.ICoreService=(0,a.createDecorator)("CoreService"),n.ICharsetService=(0,a.createDecorator)("CharsetService"),n.IInstantiationService=(0,a.createDecorator)("InstantiationService"),(function(c){c[c.TRACE=0]="TRACE",c[c.DEBUG=1]="DEBUG",c[c.INFO=2]="INFO",c[c.WARN=3]="WARN",c[c.ERROR=4]="ERROR",c[c.OFF=5]="OFF"})(u||(n.LogLevelEnum=u={})),n.ILogService=(0,a.createDecorator)("LogService"),n.IOptionsService=(0,a.createDecorator)("OptionsService"),n.IOscLinkService=(0,a.createDecorator)("OscLinkService"),n.IUnicodeService=(0,a.createDecorator)("UnicodeService"),n.IDecorationService=(0,a.createDecorator)("DecorationService")},1480:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.UnicodeService=void 0;const a=i(8460),u=i(225);n.UnicodeService=class{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new a.EventEmitter,this.onChange=this._onChange.event;const c=new u.UnicodeV6;this.register(c),this._active=c.version,this._activeProvider=c}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(c){if(!this._providers[c])throw new Error(`unknown Unicode version "${c}"`);this._active=c,this._activeProvider=this._providers[c],this._onChange.fire(c)}register(c){this._providers[c.version]=c}wcwidth(c){return this._activeProvider.wcwidth(c)}getStringCellWidth(c){let g=0;const x=c.length;for(let S=0;S<x;++S){let w=c.charCodeAt(S);if(55296<=w&&w<=56319){if(++S>=x)return g+this.wcwidth(w);const l=c.charCodeAt(S);56320<=l&&l<=57343?w=1024*(w-55296)+l-56320+65536:g+=this.wcwidth(l)}g+=this.wcwidth(w)}return g}}}},o={};function p(v){var n=o[v];if(n!==void 0)return n.exports;var i=o[v]={exports:{}};return r[v].call(i.exports,i,i.exports,p),i.exports}var m={};return(()=>{var v=m;Object.defineProperty(v,"__esModule",{value:!0}),v.Terminal=void 0;const n=p(9042),i=p(3236),a=p(844),u=p(5741),c=p(8285),g=p(7975),x=p(7090),S=["cols","rows"];class w extends a.Disposable{constructor(h){super(),this._core=this.register(new i.Terminal(h)),this._addonManager=this.register(new u.AddonManager),this._publicOptions=Object.assign({},this._core.options);const d=y=>this._core.options[y],f=(y,C)=>{this._checkReadonlyOptions(y),this._core.options[y]=C};for(const y in this._core.options){const C={get:d.bind(this,y),set:f.bind(this,y)};Object.defineProperty(this._publicOptions,y,C)}}_checkReadonlyOptions(h){if(S.includes(h))throw new Error(`Option "${h}" 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 x.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 c.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const h=this._core.coreService.decPrivateModes;let d="none";switch(this._core.coreMouseService.activeProtocol){case"X10":d="x10";break;case"VT200":d="vt200";break;case"DRAG":d="drag";break;case"ANY":d="any"}return{applicationCursorKeysMode:h.applicationCursorKeys,applicationKeypadMode:h.applicationKeypad,bracketedPasteMode:h.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:d,originMode:h.origin,reverseWraparoundMode:h.reverseWraparound,sendFocusMode:h.sendFocus,wraparoundMode:h.wraparound}}get options(){return this._publicOptions}set options(h){for(const d in h)this._publicOptions[d]=h[d]}blur(){this._core.blur()}focus(){this._core.focus()}resize(h,d){this._verifyIntegers(h,d),this._core.resize(h,d)}open(h){this._core.open(h)}attachCustomKeyEventHandler(h){this._core.attachCustomKeyEventHandler(h)}registerLinkProvider(h){return this._core.registerLinkProvider(h)}registerCharacterJoiner(h){return this._checkProposedApi(),this._core.registerCharacterJoiner(h)}deregisterCharacterJoiner(h){this._checkProposedApi(),this._core.deregisterCharacterJoiner(h)}registerMarker(h=0){return this._verifyIntegers(h),this._core.registerMarker(h)}registerDecoration(h){var d,f,y;return this._checkProposedApi(),this._verifyPositiveIntegers((d=h.x)!==null&&d!==void 0?d:0,(f=h.width)!==null&&f!==void 0?f:0,(y=h.height)!==null&&y!==void 0?y:0),this._core.registerDecoration(h)}hasSelection(){return this._core.hasSelection()}select(h,d,f){this._verifyIntegers(h,d,f),this._core.select(h,d,f)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(h,d){this._verifyIntegers(h,d),this._core.selectLines(h,d)}dispose(){super.dispose()}scrollLines(h){this._verifyIntegers(h),this._core.scrollLines(h)}scrollPages(h){this._verifyIntegers(h),this._core.scrollPages(h)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(h){this._verifyIntegers(h),this._core.scrollToLine(h)}clear(){this._core.clear()}write(h,d){this._core.write(h,d)}writeln(h,d){this._core.write(h),this._core.write(`\r
|
|
27
|
+
`,d)}paste(h){this._core.paste(h)}refresh(h,d){this._verifyIntegers(h,d),this._core.refresh(h,d)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(h){this._addonManager.loadAddon(this,h)}static get strings(){return n}_verifyIntegers(...h){for(const d of h)if(d===1/0||isNaN(d)||d%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...h){for(const d of h)if(d&&(d===1/0||isNaN(d)||d%1!=0||d<0))throw new Error("This API only accepts positive integers")}}v.Terminal=w})(),m})()))})(Pi)),Pi.exports}var Om=Im();var Bm=2,Fm=1,zm=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let s=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(s._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 s=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,r=window.getComputedStyle(this._terminal.element.parentElement),o=parseInt(r.getPropertyValue("height")),p=Math.max(0,parseInt(r.getPropertyValue("width"))),m=window.getComputedStyle(this._terminal.element),v={top:parseInt(m.getPropertyValue("padding-top")),bottom:parseInt(m.getPropertyValue("padding-bottom")),right:parseInt(m.getPropertyValue("padding-right")),left:parseInt(m.getPropertyValue("padding-left"))},n=v.top+v.bottom,i=v.right+v.left,a=o-n,u=p-i-s;return{cols:Math.max(Bm,Math.floor(u/e.css.cell.width)),rows:Math.max(Fm,Math.floor(a/e.css.cell.height))}}};function Wm(e={}){const{cwd:s,cols:r,rows:o,onOutput:p,onExit:m}=e,[v,n]=_.useState(null),[i,a]=_.useState(()=>rs.isConnected()),[u,c]=_.useState(!1),[g,x]=_.useState(!1),[S,w]=_.useState(!1),l=_.useRef({onOutput:p,onExit:m});l.current={onOutput:p,onExit:m};const h=_.useRef(null);h.current=v,_.useEffect(()=>{if(!v)return;const k=rs.getSocket(),E=()=>{a(!0),c(!1),n(null),w(!0)},b=()=>{a(!1),c(!1)},j=D=>{D.terminalId===v&&l.current.onOutput?.(D.data)},R=D=>{D.terminalId===v&&(c(!1),l.current.onExit?.(D.exitCode),n(null))},L=D=>{D.terminalId===v&&c(!0)},T=D=>{D.terminalId===v&&c(!1)};return k.on("connect",E),k.on("disconnect",b),k.on(lt.TERMINAL_STDOUT,j),k.on(lt.TERMINAL_EXIT,R),k.on(lt.TERMINAL_SUBSCRIBED,L),k.on(lt.TERMINAL_UNSUBSCRIBED,T),a(k.connected),k.connected&&k.emit(Ps.SUBSCRIBE,{topic:"terminal",id:v},D=>{D.success&&c(!0)}),()=>{k.off("connect",E),k.off("disconnect",b),k.off(lt.TERMINAL_STDOUT,j),k.off(lt.TERMINAL_EXIT,R),k.off(lt.TERMINAL_SUBSCRIBED,L),k.off(lt.TERMINAL_UNSUBSCRIBED,T),k.emit(Ps.UNSUBSCRIBE,{topic:"terminal",id:v})}},[v]);const d=_.useCallback(async()=>{const k=rs.getSocket();if(!k.connected)return null;x(!0);try{const E=await Ce.post("/terminals",{socketId:k.id,cwd:s,cols:r,rows:o});return n(E.terminalId),w(!1),E.terminalId}catch(E){return console.error("[useStandaloneTerminal] Failed to create terminal:",E),null}finally{x(!1)}},[s,r,o]),f=_.useCallback(async()=>{const k=h.current;if(k){try{await Ce.delete(`/terminals/${k}`)}catch(E){console.error("[useStandaloneTerminal] Failed to destroy terminal:",E)}n(null),c(!1)}},[]),y=_.useCallback(k=>{const E=h.current;if(!E)return;rs.getSocket().emit(Ps.TERMINAL_INPUT,{terminalId:E,data:k})},[]),C=_.useCallback((k,E)=>{const b=h.current;if(!b)return;rs.getSocket().emit(Ps.TERMINAL_RESIZE,{terminalId:b,cols:k,rows:E})},[]);return _.useEffect(()=>()=>{const k=h.current;k&&Ce.delete(`/terminals/${k}`).catch(()=>{})},[]),{terminalId:v,isConnected:i,isAttached:u,isCreating:g,needsRecreate:S,create:d,destroy:f,sendInput:y,resize:C}}function Hm({terminalRef:e,xtermRef:s,fitAddonRef:r,isVisible:o=!0,onResize:p}){const m=_.useRef(null),v=_.useRef(null),n=_.useRef(0),i=_.useCallback(()=>{m.current!=null&&(window.clearTimeout(m.current),m.current=null),v.current!=null&&(window.cancelAnimationFrame(v.current),v.current=null)},[]),a=_.useCallback(()=>{const g=r.current,x=s.current,S=e.current;if(!g||!x||!S||S.clientWidth<=0||S.clientHeight<=0)return!1;try{return g.fit(),x.cols>0&&x.rows>0&&p(x.cols,x.rows),!0}catch{return!1}},[r,p,e,s]),u=_.useCallback((g=6)=>{i();const x=n.current+1;n.current=x;let S=0;const w=()=>{n.current===x&&(v.current=window.requestAnimationFrame(()=>{if(v.current=null,n.current!==x)return;const l=a(),h=S<2;S<g&&(!l||h)&&(S+=1,m.current=window.setTimeout(w,50))}))};w()},[i,a]),c=_.useCallback(()=>{n.current+=1,i()},[i]);return _.useEffect(()=>c,[c]),_.useEffect(()=>{o&&u(8)},[o,u]),_.useEffect(()=>{const g=e.current;if(!g)return;if(typeof ResizeObserver>"u"){u(8);return}const x=new ResizeObserver(()=>{u(4)});return x.observe(g),g.parentElement&&x.observe(g.parentElement),u(8),()=>{x.disconnect()}},[u,e]),{fitNow:a,scheduleFit:u}}const $m={background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#d4d4d4",selectionBackground:"#264f78",black:"#1e1e1e",red:"#f44747",green:"#6a9955",yellow:"#d7ba7d",blue:"#569cd6",magenta:"#c586c0",cyan:"#4ec9b0",white:"#d4d4d4",brightBlack:"#808080",brightRed:"#f44747",brightGreen:"#6a9955",brightYellow:"#d7ba7d",brightBlue:"#569cd6",brightMagenta:"#c586c0",brightCyan:"#4ec9b0",brightWhite:"#ffffff"},Um=ae.memo(function({cwd:s,isVisible:r=!0,onExit:o,onReady:p}){const m=_.useRef(null),v=_.useRef(null),n=_.useRef(null),i=_.useRef(!1),{terminalId:a,isAttached:u,needsRecreate:c,create:g,sendInput:x,resize:S}=Wm({cwd:s,onOutput:_.useCallback(h=>{v.current?.write(h)},[]),onExit:_.useCallback(h=>{v.current?.writeln(`\r
|
|
28
|
+
\x1B[90m[Process exited with code ${h}]\x1B[0m`),o?.(h)},[o])}),{scheduleFit:w}=Hm({terminalRef:m,xtermRef:v,fitAddonRef:n,isVisible:r,onResize:S}),l=_.useCallback(h=>{v.current?.paste(h)},[]);return _.useEffect(()=>{r||v.current?.blur()},[r]),_.useEffect(()=>{if(!c)return;const h=v.current;h&&h.writeln(`\r
|
|
29
|
+
\x1B[33m[Terminal disconnected — reconnecting...]\x1B[0m`),g()},[c,g]),_.useLayoutEffect(()=>{if(!m.current)return;const h=new Om.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, 'Courier New', monospace",lineHeight:1.4,theme:$m,scrollback:5e3,convertEol:!0}),d=new zm;return h.loadAddon(d),h.open(m.current),v.current=h,n.current=d,w(8),()=>{h.dispose(),v.current=null,n.current=null}},[w]),_.useEffect(()=>{i.current||(i.current=!0,g())},[g]),_.useEffect(()=>{const h=v.current;if(!h||!u)return;const d=h.onData(f=>{x(f)});return()=>d.dispose()},[x,u]),_.useEffect(()=>{u&&(w(4),p?.({sendInput:x,paste:l}))},[u,p,l,w,x]),t.jsxs("div",{className:"relative flex h-full w-full min-h-0 min-w-0 flex-col overflow-hidden bg-[#1e1e1e]",children:[!a&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-neutral-500 text-xs z-10 bg-[#1e1e1e]",children:"Starting terminal..."}),t.jsx("div",{ref:m,className:"terminal-xterm-host flex-1 min-h-0 min-w-0 w-full overflow-hidden"})]})}),qm=ae.memo(function({commands:s,onSelect:r}){const{t:o}=le(),[p,m]=_.useState(!1),v=_.useRef(null),n=_.useRef(null);return _.useEffect(()=>{if(!p)return;const i=a=>{v.current&&!v.current.contains(a.target)&&n.current&&!n.current.contains(a.target)&&m(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[p]),s.length===0?null:t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-px h-4 bg-[#444] mx-1 shrink-0"}),t.jsxs("div",{className:"relative",children:[t.jsxs("button",{ref:n,onClick:()=>m(!p),className:`flex items-center gap-1.5 px-2.5 py-1 mx-1 rounded text-[11px] font-medium transition-colors shrink-0 ${p?"bg-amber-500/20 text-amber-300":"bg-amber-500/10 text-amber-400/80 hover:bg-amber-500/20 hover:text-amber-300"}`,children:[t.jsx(Md,{size:12}),t.jsx("span",{children:o("快捷命令")}),t.jsx(wt,{size:10,className:`transition-transform ${p?"rotate-180":""}`})]}),p&&t.jsx("div",{ref:v,className:"absolute right-0 top-full mt-1 w-72 bg-[#2d2d2d] border border-[#444] rounded-lg shadow-xl z-[100] overflow-hidden",children:t.jsx("div",{className:"max-h-[240px] overflow-y-auto",children:s.map((i,a)=>t.jsxs("button",{onClick:()=>{r(i.command),m(!1)},className:"w-full flex items-start gap-2.5 px-3 py-2 hover:bg-[#383838] transition-colors text-left group",children:[t.jsx(Qt,{size:12,className:"text-green-500 mt-0.5 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-[12px] font-medium text-neutral-200",children:i.name}),t.jsx("div",{className:"text-[11px] font-mono text-neutral-500 truncate",children:i.command})]})]},a))})})]})]})}),Wl="\x1B",Km="\x07",Vm="";function Xm(e){const s=e.charCodeAt(0);return s>=64&&s<=126}function zo(e,s){let r=s;for(;r<e.length;){if(e[r]===Km||e[r]===Vm)return r+1;if(e[r]===Wl&&e[r+1]==="\\")return r+2;r+=1}return r}function Wo(e,s){let r=s;for(;r<e.length&&!Xm(e[r]);)r+=1;return r<e.length?r+1:r}function Ym(e){let s="";for(let r=0;r<e.length;){if(e[r]===""){r=Wo(e,r+1);continue}if(e[r]===""){r=zo(e,r+1);continue}if(e[r]!==Wl){s+=e[r],r+=1;continue}const o=e[r+1];if(o==="["){r=Wo(e,r+2);continue}if(o==="]"||o==="P"||o==="X"||o==="^"||o==="_"){r=zo(e,r+2);continue}for(r+=1;r<e.length;){const p=e.charCodeAt(r);if(p<32||p>47)break;r+=1}r<e.length&&(r+=1)}return s}const Gm=200,Qm=1e3,Zm=512*1024;function Jm(e){let s=e.reduce((o,p)=>o+p.data.length,0),r=0;for(;e.length-r>Qm||s>Zm&&e.length-r>1;)s-=e[r].data.length,r+=1;return{entries:r>0?e.slice(r):e,trimmed:r>0}}function ep(e,s){const r=!!e&&e.runtimeInstanceId!==s.runtimeInstanceId,o=r||s.reset,p=o?[]:e?.entries??[],m=new Set(p.map(i=>i.seq)),v=[...p,...s.entries.filter(i=>!m.has(i.seq))].sort((i,a)=>i.seq-a.seq),n=Jm(v);return{...s,entries:n.entries,reset:s.reset||r||!o&&(e?.reset??!1),truncated:s.truncated||!o&&(e?.truncated??!1)||n.trimmed}}function tp(e,s=!0){return kt({queryKey:de.workspaceServices.list(e),queryFn:async()=>(await Ce.get(`/workspaces/${encodeURIComponent(e)}/services`)).services,enabled:s&&!!e,refetchInterval:s&&e?3e3:!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:"always",refetchOnReconnect:"always"})}function sp(e,s,r,o=!0){const p=bt(),m=de.workspaceServices.logs(e,s);return kt({queryKey:m,queryFn:async()=>{const v=p.getQueryData(m),n=v?Math.max(0,v.nextSeq-1):0,i=v===void 0?r:v.runtimeInstanceId,a=new URLSearchParams({limit:String(Gm)});i!==null&&a.set("runtimeInstanceId",i),a.set("afterSeq",String(n));const u=await Ce.get(`/workspaces/${encodeURIComponent(e)}/services/${encodeURIComponent(s)}/logs?${a}`);return ep(v,u)},enabled:o&&!!e&&!!s,refetchInterval:v=>v.state.data?.hasMore?250:1e3,refetchIntervalInBackground:!1,refetchOnWindowFocus:"always",refetchOnReconnect:"always"})}const rp=[];function Li(e){return JSON.stringify([e.command,...e.args])}function Ho(e,s,r){if(!e)return r;const o=new Date(e);return Number.isNaN(o.getTime())?r:new Intl.DateTimeFormat(s,{dateStyle:"medium",timeStyle:"medium"}).format(o)}function ip(e){switch(e){case"RUNNING":return{label:"Running",dotClassName:"bg-emerald-400"};case"STARTING":return{label:"Starting",dotClassName:"bg-amber-400"};case"STOPPING":return{label:"Stopping",dotClassName:"bg-amber-400"};case"FAILED":return{label:"Failed",dotClassName:"bg-red-400"};case"EXITED":return{label:"Exited",dotClassName:"bg-neutral-400"};default:return{label:"Stopped",dotClassName:"bg-neutral-500"}}}function $o({state:e}){const{t:s}=le(),r=ip(e);return t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5 text-[11px] text-neutral-300",children:[t.jsx("span",{className:se("h-1.5 w-1.5 rounded-full",r.dotClassName),"aria-hidden":"true"}),s(r.label)]})}function np({message:e,onRetry:s}){const{t:r}=le();return t.jsxs("div",{className:"flex min-h-24 items-center justify-center gap-2 px-4 text-xs text-red-300",role:"alert",children:[t.jsx($s,{size:14,className:"shrink-0","aria-hidden":"true"}),t.jsx("span",{children:e}),t.jsx("button",{type:"button",onClick:s,className:"flex h-7 w-7 shrink-0 items-center justify-center rounded text-neutral-400 transition-colors hover:bg-[#333] hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-400",title:r("Retry"),"aria-label":r("Retry"),children:t.jsx(ks,{size:13})})]})}function op({workspaceId:e,enabled:s=!0}){const{locale:r,t:o}=le(),p=tp(e,s),m=p.data??rp,[v,n]=_.useState(null),i=m.find(x=>x.name===v)??m[0]??null,a=sp(e,i?.name??"",i?.runtimeInstanceId??null,s&&!!i),u=_.useMemo(()=>Ym(a.data?.entries.map(x=>x.data).join("")??""),[a.data?.entries]),c=_.useRef(null),g=_.useRef(!0);return _.useEffect(()=>{g.current=!0},[i?.id,i?.runtimeInstanceId]),_.useEffect(()=>{const x=c.current;x&&g.current&&(x.scrollTop=x.scrollHeight)},[u]),t.jsxs("div",{className:"flex h-full min-h-0 w-full min-w-0 flex-col bg-[#1e1e1e] text-neutral-200 md:flex-row",children:[t.jsxs("aside",{className:"flex max-h-[44%] min-h-32 shrink-0 flex-col border-b border-[#343434] bg-[#252526] 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-[#343434] px-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Gi,{size:13,className:"shrink-0 text-neutral-400","aria-hidden":"true"}),t.jsx("h2",{className:"truncate text-xs font-medium",children:o("Background services")})]}),!p.isLoading&&!p.isError&&t.jsx("span",{className:"text-[11px] tabular-nums text-neutral-500",children:m.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-neutral-500",children:[t.jsx(We,{size:14,className:"animate-spin","aria-hidden":"true"}),o("Loading background services...")]}):p.isError?t.jsx(np,{message:o("Failed to load background services."),onRetry:()=>{p.refetch()}}):m.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-neutral-500",children:[t.jsx(Gi,{size:22,"aria-hidden":"true"}),t.jsx("span",{children:o("No background services")})]}):m.map(x=>{const S=x.name===i?.name;return t.jsxs("button",{type:"button",onClick:()=>n(x.name),"aria-pressed":S,className:se("block w-full border-b border-[#343434] px-3 py-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-neutral-400",S?"bg-[#1e1e1e]":"hover:bg-[#2d2d2d]"),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-neutral-100",children:x.name}),t.jsx($o,{state:x.runtimeState})]}),t.jsx("span",{className:"mt-1 block truncate font-mono text-[10px] text-neutral-500",title:Li(x),children:Li(x)}),t.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-1 text-[10px] text-neutral-500",children:[t.jsx(Rn,{size:10,className:"shrink-0","aria-hidden":"true"}),t.jsx("span",{className:"truncate",children:x.relativeCwd||"."})]}),t.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-1 text-[10px] text-neutral-500",children:[t.jsx(os,{size:10,className:"shrink-0","aria-hidden":"true"}),t.jsx("span",{className:"truncate",children:Ho(x.startedAt,r,o("Not started"))})]})]},x.id)})})]}),t.jsx("section",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-[#1e1e1e]","aria-label":o("Background service logs"),children:i?t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:"shrink-0 border-b border-[#343434] bg-[#252526]",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-neutral-100",children:i.name}),t.jsx($o,{state:i.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-neutral-400",tabIndex:0,"aria-label":`${i.name} ${o("Details")}`,children:[t.jsxs("dl",{className:"mt-1.5 grid min-w-0 gap-x-4 gap-y-1 text-[10px] text-neutral-500 sm:grid-cols-2",children:[t.jsxs("div",{className:"flex min-w-0 gap-1.5",children:[t.jsxs("dt",{className:"shrink-0",children:[o("Command"),":"]}),t.jsx("dd",{className:"min-w-0 break-all font-mono text-neutral-400",children:Li(i)})]}),t.jsxs("div",{className:"flex min-w-0 gap-1.5",children:[t.jsxs("dt",{className:"shrink-0",children:[o("Working directory"),":"]}),t.jsx("dd",{className:"min-w-0 break-all font-mono text-neutral-400",children:i.relativeCwd||"."})]}),t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 sm:col-span-2",children:[t.jsx(os,{size:10,className:"shrink-0","aria-hidden":"true"}),t.jsxs("dt",{className:"shrink-0",children:[o("Started"),":"]}),t.jsx("dd",{className:"truncate text-neutral-400",children:Ho(i.startedAt,r,o("Not started"))})]})]}),i.lastError&&t.jsx("p",{className:"mt-1.5 break-words text-[10px] text-red-300",role:"alert",children:i.lastError})]})]}),(a.data?.truncated||a.data?.reset)&&t.jsx("div",{className:"shrink-0 border-b border-amber-400/20 bg-amber-400/10 px-3 py-1.5 text-[10px] text-amber-200",children:o("Earlier log output is unavailable.")}),a.isError&&t.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-red-400/20 bg-red-400/10 px-3 py-1.5 text-[10px] text-red-200",role:"alert",children:[t.jsx("span",{children:o("Failed to refresh service logs.")}),t.jsx("button",{type:"button",onClick:()=>{a.refetch()},className:"flex h-6 w-6 items-center justify-center rounded text-red-100 transition-colors hover:bg-red-300/15 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-red-200",title:o("Retry"),"aria-label":o("Retry"),children:t.jsx(ks,{size:11})})]}),t.jsx("div",{ref:c,onScroll:x=>{const S=x.currentTarget;g.current=S.scrollHeight-S.scrollTop-S.clientHeight<32},className:"min-h-0 flex-1 overflow-auto p-3 scrollbar-app-thin",role:"log","aria-live":"off",tabIndex:0,children:a.isLoading&&!a.data?t.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-xs text-neutral-500",children:[t.jsx(We,{size:14,className:"animate-spin","aria-hidden":"true"}),o("Loading service logs...")]}):u?t.jsx("pre",{className:"m-0 whitespace-pre-wrap break-words font-mono text-[11px] leading-5 text-neutral-300",children:u}):t.jsx("div",{className:"flex h-full items-center justify-center text-xs text-neutral-500",children:o("No logs yet")})})]}):t.jsx("div",{className:"flex h-full items-center justify-center px-4 text-center text-xs text-neutral-500",children:p.isLoading?o("Loading background services..."):o("Select a background service")})})]})}let Ii=0;function Uo(){return Ii+=1,{id:`shell-${Ii}`,order:Ii}}const ap=ae.memo(function({cwd:s,isVisible:r=!0,workspaceId:o,quickCommands:p=[]}){const{t:m}=le(),[v,n]=_.useState(()=>[Uo()]),[i,a]=_.useState(()=>v[0].id),[u,c]=_.useState(()=>new Set),[g,x]=_.useState(!1),[S,w]=_.useState(!1),[l,h]=_.useState(""),[d,f]=_.useState(null),[y,C]=_.useState("terminals"),k=_.useRef(new Map),E=o?y:"terminals",b=_.useCallback(M=>{k.current.delete(M),c(O=>{if(!O.has(M))return O;const $=new Set(O);return $.delete(M),$})},[]),j=_.useCallback(()=>{const M=Uo();n(O=>[...O,M]),a(M.id)},[]),R=_.useCallback((M,O)=>{O.stopPropagation(),b(M),n($=>{const U=$.filter(B=>B.id!==M);return M===i&&U.length>0&&a(U[U.length-1].id),U})},[i,b]),L=_.useCallback(M=>{b(M),n(O=>{const $=O.filter(U=>U.id!==M);return M===i&&$.length>0&&a($[$.length-1].id),$})},[i,b]),T=_.useCallback((M,O)=>{k.current.set(M,O),c($=>{if($.has(M))return $;const U=new Set($);return U.add(M),U})},[]),D=_.useCallback(M=>{const O=k.current.get(i);O&&O.sendInput(M+"\r")},[i]),F=_.useCallback((M,O="")=>{f(M),h(O),w(!0)},[]),I=_.useCallback((M,O)=>{const $=k.current.get(M);return $?($.paste(O),st.success(m("Pasted into terminal")),!0):(st.error(m("Terminal is not ready")),!1)},[m]),H=_.useCallback(async()=>{if(!k.current.has(i)){st.error(m("Terminal is not ready"));return}const M=navigator.clipboard;if(!M?.readText){F(i);return}x(!0);try{const O=await M.readText();if(!O||O.includes(`
|
|
30
|
+
`)||O.includes("\r")){F(i,O);return}I(i,O)}catch{F(i)}finally{x(!1)}},[i,F,I,m]),K=_.useCallback(()=>{!l||!d||!I(d,l)||(w(!1),h(""),f(null))},[l,I,d]),A=_.useCallback(()=>{w(!1),h(""),f(null)},[]),P=u.has(i);return t.jsxs("div",{className:"flex h-full w-full min-h-0 min-w-0 flex-col overflow-hidden bg-[#1e1e1e]",children:[o&&t.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 border-b border-[#343434] bg-[#202020] px-2 select-none",children:[t.jsxs("button",{type:"button",onClick:()=>C("terminals"),"aria-pressed":E==="terminals",className:se("flex h-7 items-center gap-1.5 rounded px-2.5 text-[11px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-400",E==="terminals"?"bg-[#3a3a3a] text-neutral-100":"text-neutral-500 hover:bg-[#2d2d2d] hover:text-neutral-300"),children:[t.jsx(or,{size:12,"aria-hidden":"true"}),m("Interactive terminals")]}),t.jsxs("button",{type:"button",onClick:()=>C("services"),"aria-pressed":E==="services",className:se("flex h-7 items-center gap-1.5 rounded px-2.5 text-[11px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-400",E==="services"?"bg-[#3a3a3a] text-neutral-100":"text-neutral-500 hover:bg-[#2d2d2d] hover:text-neutral-300"),children:[t.jsx(Gi,{size:12,"aria-hidden":"true"}),m("Background services")]})]}),t.jsxs("div",{"aria-hidden":E!=="terminals",className:se("min-h-0 flex-1 flex-col",E==="terminals"?"flex":"hidden"),children:[t.jsxs("div",{className:"flex items-center bg-[#252526] border-b border-[#333] shrink-0 select-none",children:[t.jsx("div",{className:"flex items-center overflow-x-auto scrollbar-app-thin flex-1 min-w-0",children:v.map(M=>t.jsxs("button",{onClick:()=>a(M.id),className:se("flex items-center gap-1.5 px-3 py-1.5 text-[11px] border-r border-[#333] whitespace-nowrap group transition-colors",M.id===i?"bg-[#1e1e1e] text-neutral-200":"bg-[#2d2d2d] text-neutral-500 hover:text-neutral-300"),children:[t.jsx(or,{size:11,className:"shrink-0"}),t.jsx("span",{children:m("Shell {count}",{count:M.order})}),v.length>1&&t.jsx("span",{onClick:O=>R(M.id,O),className:"ml-1 p-0.5 rounded hover:bg-[#444] opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:t.jsx(Zt,{size:10})})]},M.id))}),v.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"mx-0.5 block h-5 w-px shrink-0 bg-[#3a3a3a] md:hidden","aria-hidden":"true"}),t.jsx("button",{type:"button",onClick:H,disabled:!P||g,className:"flex h-11 w-11 shrink-0 items-center justify-center text-neutral-400 transition-colors hover:bg-[#333] hover:text-neutral-100 active:bg-[#3a3a3a] disabled:cursor-not-allowed disabled:opacity-40 md:hidden",title:m("Paste into terminal"),"aria-label":m("Paste into terminal"),children:g?t.jsx(We,{size:18,className:"animate-spin"}):t.jsx(Gd,{size:18})})]}),t.jsx("button",{type:"button",onClick:j,className:"flex h-11 w-11 shrink-0 items-center justify-center text-neutral-500 transition-colors hover:bg-[#333] hover:text-neutral-300 active:bg-[#3a3a3a] md:h-auto md:w-auto md:px-2 md:py-1.5",title:m("New Terminal"),"aria-label":m("New Terminal"),children:t.jsx(ns,{size:14})}),p.length>0&&t.jsx(qm,{commands:p,onSelect:D})]}),t.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden relative",children:v.length===0?t.jsx("div",{className:"flex-1 flex items-center justify-center h-full text-neutral-500",children:t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(or,{size:28}),t.jsx("span",{className:"text-xs",children:m("No terminals open")}),t.jsx("button",{onClick:j,className:"mt-1 px-3 py-1 text-xs bg-[#333] hover:bg-[#444] rounded transition-colors text-neutral-300",children:m("New Terminal")})]})}):v.map(M=>t.jsx("div",{"aria-hidden":M.id!==i,className:se("absolute inset-0 h-full w-full min-h-0 min-w-0 overflow-hidden",M.id===i?"visible pointer-events-auto":"invisible pointer-events-none"),children:t.jsx(Um,{cwd:s,isVisible:r&&E==="terminals"&&M.id===i,onExit:()=>L(M.id),onReady:O=>T(M.id,O)})},M.id))})]}),o&&E==="services"&&t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(op,{workspaceId:o,enabled:r})}),t.jsx(ds,{isOpen:S,onClose:A,title:m("Paste into terminal"),className:"fixed inset-x-0 bottom-0 max-h-[70dvh] max-w-none rounded-b-none rounded-t-lg border-x-0 border-b-0 sm:relative sm:inset-auto sm:max-w-lg sm:rounded-lg sm:border",action:t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:A,className:"min-h-11 px-4 text-sm font-medium text-neutral-600 transition-colors hover:text-neutral-900",children:m("Cancel")}),t.jsx("button",{type:"button",onClick:K,disabled:!l,className:"min-h-11 rounded-md bg-neutral-900 px-4 text-sm font-medium text-white transition-colors hover:bg-black disabled:cursor-not-allowed disabled:opacity-40",children:m("Paste")})]}),children:t.jsx(Fd,{autoFocus:!0,value:l,onChange:M=>h(M.target.value),placeholder:m("Paste terminal input here"),"aria-label":m("Terminal paste content"),className:"min-h-32 resize-none bg-white font-mono"})})]})});function qo(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,o=Array(s);r<s;r++)o[r]=e[r];return o}function lp(e){if(Array.isArray(e))return e}function cp(e,s,r){return(s=gp(s))in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function dp(e,s){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o,p,m,v,n=[],i=!0,a=!1;try{if(m=(r=r.call(e)).next,s!==0)for(;!(i=(o=m.call(r)).done)&&(n.push(o.value),n.length!==s);i=!0);}catch(u){a=!0,p=u}finally{try{if(!i&&r.return!=null&&(v=r.return(),Object(v)!==v))return}finally{if(a)throw p}}return n}}function up(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
31
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ko(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);s&&(o=o.filter(function(p){return Object.getOwnPropertyDescriptor(e,p).enumerable})),r.push.apply(r,o)}return r}function Vo(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Ko(Object(r),!0).forEach(function(o){cp(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ko(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function hp(e,s){if(e==null)return{};var r,o,p=fp(e,s);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(e);for(o=0;o<m.length;o++)r=m[o],s.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(p[r]=e[r])}return p}function fp(e,s){if(e==null)return{};var r={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(s.indexOf(o)!==-1)continue;r[o]=e[o]}return r}function mp(e,s){return lp(e)||dp(e,s)||vp(e,s)||up()}function pp(e,s){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var o=r.call(e,s);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}function gp(e){var s=pp(e,"string");return typeof s=="symbol"?s:s+""}function vp(e,s){if(e){if(typeof e=="string")return qo(e,s);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?qo(e,s):void 0}}function xp(e,s,r){return s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function Xo(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);s&&(o=o.filter(function(p){return Object.getOwnPropertyDescriptor(e,p).enumerable})),r.push.apply(r,o)}return r}function Yo(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Xo(Object(r),!0).forEach(function(o){xp(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Xo(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function bp(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return function(o){return s.reduceRight(function(p,m){return m(p)},o)}}function nr(e){return function s(){for(var r=this,o=arguments.length,p=new Array(o),m=0;m<o;m++)p[m]=arguments[m];return p.length>=e.length?e.apply(this,p):function(){for(var v=arguments.length,n=new Array(v),i=0;i<v;i++)n[i]=arguments[i];return s.apply(r,[].concat(p,n))}}}function ti(e){return{}.toString.call(e).includes("Object")}function _p(e){return!Object.keys(e).length}function gr(e){return typeof e=="function"}function yp(e,s){return Object.prototype.hasOwnProperty.call(e,s)}function Sp(e,s){return ti(s)||ls("changeType"),Object.keys(s).some(function(r){return!yp(e,r)})&&ls("changeField"),s}function wp(e){gr(e)||ls("selectorType")}function Cp(e){gr(e)||ti(e)||ls("handlerType"),ti(e)&&Object.values(e).some(function(s){return!gr(s)})&&ls("handlersType")}function kp(e){e||ls("initialIsRequired"),ti(e)||ls("initialType"),_p(e)&&ls("initialContent")}function Ep(e,s){throw new Error(e[s]||e.default)}var jp={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"},ls=nr(Ep)(jp),Br={changes:Sp,selector:wp,handler:Cp,initial:kp};function Np(e){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Br.initial(e),Br.handler(s);var r={current:e},o=nr(Tp)(r,s),p=nr(Ap)(r),m=nr(Br.changes)(e),v=nr(Rp)(r);function n(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(u){return u};return Br.selector(a),a(r.current)}function i(a){bp(o,p,m,v)(a)}return[n,i]}function Rp(e,s){return gr(s)?s(e.current):s}function Ap(e,s){return e.current=Yo(Yo({},e.current),s),s}function Tp(e,s,r){return gr(s)?s(e.current):Object.keys(r).forEach(function(o){var p;return(p=s[o])===null||p===void 0?void 0:p.call(s,e.current[o])}),r}var Mp={create:Np},Dp={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function Pp(e){return function s(){for(var r=this,o=arguments.length,p=new Array(o),m=0;m<o;m++)p[m]=arguments[m];return p.length>=e.length?e.apply(this,p):function(){for(var v=arguments.length,n=new Array(v),i=0;i<v;i++)n[i]=arguments[i];return s.apply(r,[].concat(p,n))}}}function Lp(e){return{}.toString.call(e).includes("Object")}function Ip(e){return e||Go("configIsRequired"),Lp(e)||Go("configType"),e.urls?(Op(),{paths:{vs:e.urls.monacoBase}}):e}function Op(){console.warn(Hl.deprecation)}function Bp(e,s){throw new Error(e[s]||e.default)}var Hl={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!
|
|
32
|
+
You are using deprecated way of configuration.
|
|
33
|
+
|
|
34
|
+
Instead of using
|
|
35
|
+
monaco.config({ urls: { monacoBase: '...' } })
|
|
36
|
+
use
|
|
37
|
+
monaco.config({ paths: { vs: '...' } })
|
|
38
|
+
|
|
39
|
+
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
40
|
+
`},Go=Pp(Bp)(Hl),Fp={config:Ip},zp=function(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return function(p){return r.reduceRight(function(m,v){return v(m)},p)}};function $l(e,s){return Object.keys(s).forEach(function(r){s[r]instanceof Object&&e[r]&&Object.assign(s[r],$l(e[r],s[r]))}),Vo(Vo({},e),s)}var Wp={type:"cancelation",msg:"operation is manually canceled"};function Oi(e){var s=!1,r=new Promise(function(o,p){e.then(function(m){return s?p(Wp):o(m)}),e.catch(p)});return r.cancel=function(){return s=!0},r}var Hp=["monaco"],$p=Mp.create({config:Dp,isInitialized:!1,resolve:null,reject:null,monaco:null}),Ul=mp($p,2),Sr=Ul[0],pi=Ul[1];function Up(e){var s=Fp.config(e),r=s.monaco,o=hp(s,Hp);pi(function(p){return{config:$l(p.config,o),monaco:r}})}function qp(){var e=Sr(function(s){var r=s.monaco,o=s.isInitialized,p=s.resolve;return{monaco:r,isInitialized:o,resolve:p}});if(!e.isInitialized){if(pi({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),Oi(Bi);if(window.monaco&&window.monaco.editor)return ql(window.monaco),e.resolve(window.monaco),Oi(Bi);zp(Kp,Xp)(Yp)}return Oi(Bi)}function Kp(e){return document.body.appendChild(e)}function Vp(e){var s=document.createElement("script");return e&&(s.src=e),s}function Xp(e){var s=Sr(function(o){var p=o.config,m=o.reject;return{config:p,reject:m}}),r=Vp("".concat(s.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=s.reject,r}function Yp(){var e=Sr(function(r){var o=r.config,p=r.resolve,m=r.reject;return{config:o,resolve:p,reject:m}}),s=window.require;s.config(e.config),s(["vs/editor/editor.main"],function(r){var o=r.m||r;ql(o),e.resolve(o)},function(r){e.reject(r)})}function ql(e){Sr().monaco||pi({monaco:e})}function Gp(){return Sr(function(e){var s=e.monaco;return s})}var Bi=new Promise(function(e,s){return pi({resolve:e,reject:s})}),Kl={config:Up,init:qp,__getMonacoInstance:Gp},Qp={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},Fi=Qp,Zp={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Jp=Zp;function eg({children:e}){return ae.createElement("div",{style:Jp.container},e)}var tg=eg,sg=tg;function rg({width:e,height:s,isEditorReady:r,loading:o,_ref:p,className:m,wrapperProps:v}){return ae.createElement("section",{style:{...Fi.wrapper,width:e,height:s},...v},!r&&ae.createElement(sg,null,o),ae.createElement("div",{ref:p,style:{...Fi.fullWidth,...!r&&Fi.hide},className:m}))}var ig=rg,Vl=_.memo(ig);function ng(e){_.useEffect(e,[])}var Xl=ng;function og(e,s,r=!0){let o=_.useRef(!0);_.useEffect(o.current||!r?()=>{o.current=!1}:e,s)}var Ct=og;function dr(){}function Ls(e,s,r,o){return ag(e,o)||lg(e,s,r,o)}function ag(e,s){return e.editor.getModel(Yl(e,s))}function lg(e,s,r,o){return e.editor.createModel(s,r,o?Yl(e,o):void 0)}function Yl(e,s){return e.Uri.parse(s)}function cg({original:e,modified:s,language:r,originalLanguage:o,modifiedLanguage:p,originalModelPath:m,modifiedModelPath:v,keepCurrentOriginalModel:n=!1,keepCurrentModifiedModel:i=!1,theme:a="light",loading:u="Loading...",options:c={},height:g="100%",width:x="100%",className:S,wrapperProps:w={},beforeMount:l=dr,onMount:h=dr}){let[d,f]=_.useState(!1),[y,C]=_.useState(!0),k=_.useRef(null),E=_.useRef(null),b=_.useRef(null),j=_.useRef(h),R=_.useRef(l),L=_.useRef(!1);Xl(()=>{let I=Kl.init();return I.then(H=>(E.current=H)&&C(!1)).catch(H=>H?.type!=="cancelation"&&console.error("Monaco initialization: error:",H)),()=>k.current?F():I.cancel()}),Ct(()=>{if(k.current&&E.current){let I=k.current.getOriginalEditor(),H=Ls(E.current,e||"",o||r||"text",m||"");H!==I.getModel()&&I.setModel(H)}},[m],d),Ct(()=>{if(k.current&&E.current){let I=k.current.getModifiedEditor(),H=Ls(E.current,s||"",p||r||"text",v||"");H!==I.getModel()&&I.setModel(H)}},[v],d),Ct(()=>{let I=k.current.getModifiedEditor();I.getOption(E.current.editor.EditorOption.readOnly)?I.setValue(s||""):s!==I.getValue()&&(I.executeEdits("",[{range:I.getModel().getFullModelRange(),text:s||"",forceMoveMarkers:!0}]),I.pushUndoStop())},[s],d),Ct(()=>{k.current?.getModel()?.original.setValue(e||"")},[e],d),Ct(()=>{let{original:I,modified:H}=k.current.getModel();E.current.editor.setModelLanguage(I,o||r||"text"),E.current.editor.setModelLanguage(H,p||r||"text")},[r,o,p],d),Ct(()=>{E.current?.editor.setTheme(a)},[a],d),Ct(()=>{k.current?.updateOptions(c)},[c],d);let T=_.useCallback(()=>{if(!E.current)return;R.current(E.current);let I=Ls(E.current,e||"",o||r||"text",m||""),H=Ls(E.current,s||"",p||r||"text",v||"");k.current?.setModel({original:I,modified:H})},[r,s,p,e,o,m,v]),D=_.useCallback(()=>{!L.current&&b.current&&(k.current=E.current.editor.createDiffEditor(b.current,{automaticLayout:!0,...c}),T(),E.current?.editor.setTheme(a),f(!0),L.current=!0)},[c,a,T]);_.useEffect(()=>{d&&j.current(k.current,E.current)},[d]),_.useEffect(()=>{!y&&!d&&D()},[y,d,D]);function F(){let I=k.current?.getModel();n||I?.original?.dispose(),i||I?.modified?.dispose(),k.current?.dispose()}return ae.createElement(Vl,{width:x,height:g,isEditorReady:d,loading:u,_ref:b,className:S,wrapperProps:w})}var dg=cg;_.memo(dg);function ug(e){let s=_.useRef();return _.useEffect(()=>{s.current=e},[e]),s.current}var hg=ug,Fr=new Map;function fg({defaultValue:e,defaultLanguage:s,defaultPath:r,value:o,language:p,path:m,theme:v="light",line:n,loading:i="Loading...",options:a={},overrideServices:u={},saveViewState:c=!0,keepCurrentModel:g=!1,width:x="100%",height:S="100%",className:w,wrapperProps:l={},beforeMount:h=dr,onMount:d=dr,onChange:f,onValidate:y=dr}){let[C,k]=_.useState(!1),[E,b]=_.useState(!0),j=_.useRef(null),R=_.useRef(null),L=_.useRef(null),T=_.useRef(d),D=_.useRef(h),F=_.useRef(),I=_.useRef(o),H=hg(m),K=_.useRef(!1),A=_.useRef(!1);Xl(()=>{let O=Kl.init();return O.then($=>(j.current=$)&&b(!1)).catch($=>$?.type!=="cancelation"&&console.error("Monaco initialization: error:",$)),()=>R.current?M():O.cancel()}),Ct(()=>{let O=Ls(j.current,e||o||"",s||p||"",m||r||"");O!==R.current?.getModel()&&(c&&Fr.set(H,R.current?.saveViewState()),R.current?.setModel(O),c&&R.current?.restoreViewState(Fr.get(m)))},[m],C),Ct(()=>{R.current?.updateOptions(a)},[a],C),Ct(()=>{!R.current||o===void 0||(R.current.getOption(j.current.editor.EditorOption.readOnly)?R.current.setValue(o):o!==R.current.getValue()&&(A.current=!0,R.current.executeEdits("",[{range:R.current.getModel().getFullModelRange(),text:o,forceMoveMarkers:!0}]),R.current.pushUndoStop(),A.current=!1))},[o],C),Ct(()=>{let O=R.current?.getModel();O&&p&&j.current?.editor.setModelLanguage(O,p)},[p],C),Ct(()=>{n!==void 0&&R.current?.revealLine(n)},[n],C),Ct(()=>{j.current?.editor.setTheme(v)},[v],C);let P=_.useCallback(()=>{if(!(!L.current||!j.current)&&!K.current){D.current(j.current);let O=m||r,$=Ls(j.current,o||e||"",s||p||"",O||"");R.current=j.current?.editor.create(L.current,{model:$,automaticLayout:!0,...a},u),c&&R.current.restoreViewState(Fr.get(O)),j.current.editor.setTheme(v),n!==void 0&&R.current.revealLine(n),k(!0),K.current=!0}},[e,s,r,o,p,m,a,u,c,v,n]);_.useEffect(()=>{C&&T.current(R.current,j.current)},[C]),_.useEffect(()=>{!E&&!C&&P()},[E,C,P]),I.current=o,_.useEffect(()=>{C&&f&&(F.current?.dispose(),F.current=R.current?.onDidChangeModelContent(O=>{A.current||f(R.current.getValue(),O)}))},[C,f]),_.useEffect(()=>{if(C){let O=j.current.editor.onDidChangeMarkers($=>{let U=R.current.getModel()?.uri;if(U&&$.find(B=>B.path===U.path)){let B=j.current.editor.getModelMarkers({resource:U});y?.(B)}});return()=>{O?.dispose()}}return()=>{}},[C,y]);function M(){F.current?.dispose(),g?c&&Fr.set(m,R.current.saveViewState()):R.current.getModel()?.dispose(),R.current.dispose()}return ae.createElement(Vl,{width:x,height:S,isEditorReady:C,loading:i,_ref:L,className:w,wrapperProps:l})}var mg=fg,pg=_.memo(mg),gg=pg,Tt=function(e,s){return Number(e.toFixed(s))},vg=function(e,s){return typeof e=="number"?e:s},Ge=function(e,s,r){r&&typeof r=="function"&&r(e,s)},xg=function(e){return-Math.cos(e*Math.PI)/2+.5},bg=function(e){return e},_g=function(e){return e*e},yg=function(e){return e*(2-e)},Sg=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},wg=function(e){return e*e*e},Cg=function(e){return--e*e*e+1},kg=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},Eg=function(e){return e*e*e*e},jg=function(e){return 1- --e*e*e*e},Ng=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},Rg=function(e){return e*e*e*e*e},Ag=function(e){return 1+--e*e*e*e*e},Tg=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},Gl={easeOut:xg,linear:bg,easeInQuad:_g,easeOutQuad:yg,easeInOutQuad:Sg,easeInCubic:wg,easeOutCubic:Cg,easeInOutCubic:kg,easeInQuart:Eg,easeOutQuart:jg,easeInOutQuart:Ng,easeInQuint:Rg,easeOutQuint:Ag,easeInOutQuint:Tg},Ql=function(e){typeof e=="number"&&cancelAnimationFrame(e)},It=function(e){e.mounted&&(Ql(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function Zl(e,s,r,o){if(e.mounted){var p=new Date().getTime(),m=1;It(e),e.animation=function(){if(!e.mounted)return Ql(e.animation);var v=new Date().getTime()-p,n=v/r,i=Gl[s],a=i(n);v>=r?(o(m),e.animation=null):e.animation&&(o(a),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function Mg(e){var s=e.scale,r=e.positionX,o=e.positionY;return!(Number.isNaN(s)||Number.isNaN(r)||Number.isNaN(o))}function hs(e,s,r,o){var p=Mg(s);if(!(!e.mounted||!p)){var m=e.setTransformState,v=e.transformState,n=v.scale,i=v.positionX,a=v.positionY,u=s.scale-n,c=s.positionX-i,g=s.positionY-a;r===0?m(s.scale,s.positionX,s.positionY):Zl(e,o,r,function(x){var S=n+u*x,w=i+c*x,l=a+g*x;m(S,w,l)})}}function Dg(e,s,r){var o=e.offsetWidth,p=e.offsetHeight,m=s.offsetWidth,v=s.offsetHeight,n=m*r,i=v*r,a=o-n,u=p-i;return{wrapperWidth:o,wrapperHeight:p,newContentWidth:n,newDiffWidth:a,newContentHeight:i,newDiffHeight:u}}var Pg=function(e,s,r,o,p,m,v){var n=e>s?r*(v?1:.5):0,i=o>p?m*(v?1:.5):0,a=e-s-n,u=n,c=o-p-i,g=i;return{minPositionX:a,maxPositionX:u,minPositionY:c,maxPositionY:g}},Vn=function(e,s){var r=e.wrapperComponent,o=e.contentComponent,p=e.setup.centerZoomedOut;if(!r||!o)throw new Error("Components are not mounted");var m=Dg(r,o,s),v=m.wrapperWidth,n=m.wrapperHeight,i=m.newContentWidth,a=m.newDiffWidth,u=m.newContentHeight,c=m.newDiffHeight,g=Pg(v,i,a,n,u,c,!!p);return g},an=function(e,s,r,o){return o?e<s?Tt(s,2):e>r?Tt(r,2):Tt(e,2):Tt(e,2)},ys=function(e,s){var r=Vn(e,s);return e.bounds=r,r};function wr(e,s,r,o,p,m,v){var n=r.minPositionX,i=r.minPositionY,a=r.maxPositionX,u=r.maxPositionY,c=0,g=0;v&&(c=p,g=m);var x=an(e,n-c,a+c,o),S=an(s,i-g,u+g,o);return{x,y:S}}function gi(e,s,r,o,p,m){var v=e.transformState,n=v.scale,i=v.positionX,a=v.positionY,u=o-n;if(typeof s!="number"||typeof r!="number")return console.error("Mouse X and Y position were not provided!"),{x:i,y:a};var c=i-s*u,g=a-r*u,x=wr(c,g,p,m,0,0,null);return x}function Cr(e,s,r,o,p){var m=p?o:0,v=s-m;return!Number.isNaN(r)&&e>=r?r:!Number.isNaN(s)&&e<=v?v:e}var Qo=function(e,s){var r=e.setup.panning.excluded,o=e.isInitialized,p=e.wrapperComponent,m=s.target,v="shadowRoot"in m&&"composedPath"in s,n=v?s.composedPath().some(function(u){return u instanceof Element?p?.contains(u):!1}):p?.contains(m),i=o&&m&&n;if(!i)return!1;var a=vi(m,r);return!a},Zo=function(e){var s=e.isInitialized,r=e.isPanning,o=e.setup,p=o.panning.disabled,m=s&&r&&!p;return!!m},Lg=function(e,s){var r=e.transformState,o=r.positionX,p=r.positionY;e.isPanning=!0;var m=s.clientX,v=s.clientY;e.startCoords={x:m-o,y:v-p}},Ig=function(e,s){var r=s.touches,o=e.transformState,p=o.positionX,m=o.positionY;e.isPanning=!0;var v=r.length===1;if(v){var n=r[0].clientX,i=r[0].clientY;e.startCoords={x:n-p,y:i-m}}};function Og(e){var s=e.transformState,r=s.positionX,o=s.positionY,p=s.scale,m=e.setup,v=m.disabled,n=m.limitToBounds,i=m.centerZoomedOut,a=e.wrapperComponent;if(!(v||!a||!e.bounds)){var u=e.bounds,c=u.maxPositionX,g=u.minPositionX,x=u.maxPositionY,S=u.minPositionY,w=r>c||r<g,l=o>x||o<S,h=r>c?a.offsetWidth:e.setup.minPositionX||0,d=o>x?a.offsetHeight:e.setup.minPositionY||0,f=gi(e,h,d,p,e.bounds,n||i),y=f.x,C=f.y;return{scale:p,positionX:w?y:r,positionY:l?C:o}}}function Jl(e,s,r,o,p){var m=e.setup.limitToBounds,v=e.wrapperComponent,n=e.bounds,i=e.transformState,a=i.scale,u=i.positionX,c=i.positionY;if(!(v===null||n===null||s===u&&r===c)){var g=wr(s,r,n,m,o,p,v),x=g.x,S=g.y;e.setTransformState(a,x,S)}}var Bg=function(e,s,r){var o=e.startCoords,p=e.transformState,m=e.setup.panning,v=m.lockAxisX,n=m.lockAxisY,i=p.positionX,a=p.positionY;if(!o)return{x:i,y:a};var u=s-o.x,c=r-o.y,g=v?i:u,x=n?a:c;return{x:g,y:x}},us=function(e,s){var r=e.setup,o=e.transformState,p=o.scale,m=r.minScale,v=r.disablePadding;return s>0&&p>=m&&!v?s:0},Fg=function(e){var s=e.mounted,r=e.setup,o=r.disabled,p=r.velocityAnimation,m=e.transformState.scale,v=p.disabled,n=!v||m>1||!o||s;return!!n},zg=function(e){var s=e.mounted,r=e.velocity,o=e.bounds,p=e.setup,m=p.disabled,v=p.velocityAnimation,n=e.transformState.scale,i=v.disabled,a=!i||n>1||!m||s;return!(!a||!r||!o)};function Wg(e,s){var r=e.setup.velocityAnimation,o=r.equalToMove,p=r.animationTime,m=r.sensitivity;return o?p*s*m:p}function Jo(e,s,r,o,p,m,v,n,i,a){if(p){if(s>v&&r>v){var u=v+(e-v)*a;return u>i?i:u<v?v:u}if(s<m&&r<m){var u=m+(e-m)*a;return u<n?n:u>m?m:u}}return o?s:an(e,m,v,p)}function Hg(e,s){var r=1;return s?Math.min(r,e.offsetWidth/window.innerWidth):r}function $g(e,s){var r=Fg(e);if(r){var o=e.lastMousePosition,p=e.velocityTime,m=e.setup,v=e.wrapperComponent,n=m.velocityAnimation.equalToMove,i=Date.now();if(o&&p&&v){var a=Hg(v,n),u=s.x-o.x,c=s.y-o.y,g=u/a,x=c/a,S=i-p,w=u*u+c*c,l=Math.sqrt(w)/S;e.velocity={velocityX:g,velocityY:x,total:l}}e.lastMousePosition=s,e.velocityTime=i}}function Ug(e){var s=e.velocity,r=e.bounds,o=e.setup,p=e.wrapperComponent,m=zg(e);if(!(!m||!s||!r||!p)){var v=s.velocityX,n=s.velocityY,i=s.total,a=r.maxPositionX,u=r.minPositionX,c=r.maxPositionY,g=r.minPositionY,x=o.limitToBounds,S=o.alignmentAnimation,w=o.zoomAnimation,l=o.panning,h=l.lockAxisY,d=l.lockAxisX,f=w.animationType,y=S.sizeX,C=S.sizeY,k=S.velocityAlignmentTime,E=k,b=Wg(e,i),j=Math.max(b,E),R=us(e,y),L=us(e,C),T=R*p.offsetWidth/100,D=L*p.offsetHeight/100,F=a+T,I=u-T,H=c+D,K=g-D,A=e.transformState,P=new Date().getTime();Zl(e,f,j,function(M){var O=e.transformState,$=O.scale,U=O.positionX,B=O.positionY,z=new Date().getTime()-P,q=z/E,N=Gl[S.animationType],W=1-N(Math.min(1,q)),X=1-M,V=U+v*X,ie=B+n*X,ee=Jo(V,A.positionX,U,d,x,u,a,I,F,W),pe=Jo(ie,A.positionY,B,h,x,g,c,K,H,W);(U!==V||B!==ie)&&e.setTransformState($,ee,pe)})}}function ea(e,s){var r=e.transformState.scale;It(e),ys(e,r),window.TouchEvent!==void 0&&s instanceof TouchEvent?Ig(e,s):Lg(e,s)}function Xn(e,s){var r=e.transformState.scale,o=e.setup,p=o.minScale,m=o.alignmentAnimation,v=m.disabled,n=m.sizeX,i=m.sizeY,a=m.animationTime,u=m.animationType,c=v||r<p||!n&&!i;if(!c){var g=Og(e);g&&hs(e,g,s??a,u)}}function ta(e,s,r){var o=e.startCoords,p=e.setup,m=p.alignmentAnimation,v=m.sizeX,n=m.sizeY;if(o){var i=Bg(e,s,r),a=i.x,u=i.y,c=us(e,v),g=us(e,n);$g(e,{x:a,y:u}),Jl(e,a,u,c,g)}}function qg(e){if(e.isPanning){var s=e.setup.panning.velocityDisabled,r=e.velocity,o=e.wrapperComponent,p=e.contentComponent;e.isPanning=!1,e.animate=!1,e.animation=null;var m=o?.getBoundingClientRect(),v=p?.getBoundingClientRect(),n=m?.width||0,i=m?.height||0,a=v?.width||0,u=v?.height||0,c=n<a||i<u,g=!s&&r&&r?.total>.1&&c;g?Ug(e):Xn(e)}}function Yn(e,s,r,o){var p=e.setup,m=p.minScale,v=p.maxScale,n=p.limitToBounds,i=Cr(Tt(s,2),m,v,0,!1),a=ys(e,i),u=gi(e,r,o,i,a,n),c=u.x,g=u.y;return{scale:i,positionX:c,positionY:g}}function ec(e,s,r){var o=e.transformState.scale,p=e.wrapperComponent,m=e.setup,v=m.minScale,n=m.limitToBounds,i=m.zoomAnimation,a=i.disabled,u=i.animationTime,c=i.animationType,g=a||o>=v;if((o>=1||n)&&Xn(e),!(g||!p||!e.mounted)){var x=s||p.offsetWidth/2,S=r||p.offsetHeight/2,w=Yn(e,v,x,S);w&&hs(e,w,u,c)}}var cs=function(){return cs=Object.assign||function(s){for(var r,o=1,p=arguments.length;o<p;o++){r=arguments[o];for(var m in r)Object.prototype.hasOwnProperty.call(r,m)&&(s[m]=r[m])}return s},cs.apply(this,arguments)};function sa(e,s,r){for(var o=0,p=s.length,m;o<p;o++)(m||!(o in s))&&(m||(m=Array.prototype.slice.call(s,0,o)),m[o]=s[o]);return e.concat(m||Array.prototype.slice.call(s))}var zr={scale:1,positionX:0,positionY:0},rr={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}},ln={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},tc=function(e){var s,r,o,p;return{previousScale:(s=e.initialScale)!==null&&s!==void 0?s:zr.scale,scale:(r=e.initialScale)!==null&&r!==void 0?r:zr.scale,positionX:(o=e.initialPositionX)!==null&&o!==void 0?o:zr.positionX,positionY:(p=e.initialPositionY)!==null&&p!==void 0?p:zr.positionY}},ra=function(e){var s=cs({},rr);return Object.keys(e).forEach(function(r){var o=typeof e[r]<"u",p=typeof rr[r]<"u";if(p&&o){var m=Object.prototype.toString.call(rr[r]),v=m==="[object Object]",n=m==="[object Array]";v?s[r]=cs(cs({},rr[r]),e[r]):n?s[r]=sa(sa([],rr[r],!0),e[r]):s[r]=e[r]}}),s},sc=function(e,s,r){var o=e.transformState.scale,p=e.wrapperComponent,m=e.setup,v=m.maxScale,n=m.minScale,i=m.zoomAnimation,a=m.smooth,u=i.size;if(!p)throw new Error("Wrapper is not mounted");var c=a?o*Math.exp(s*r):o+s*r,g=Cr(Tt(c,3),n,v,u,!1);return g};function rc(e,s,r,o,p){var m=e.wrapperComponent,v=e.transformState,n=v.scale,i=v.positionX,a=v.positionY;if(!m)return console.error("No WrapperComponent found");var u=m.offsetWidth,c=m.offsetHeight,g=(u/2-i)/n,x=(c/2-a)/n,S=sc(e,s,r),w=Yn(e,S,g,x);if(!w)return console.error("Error during zoom event. New transformation state was not calculated.");hs(e,w,o,p)}function ic(e,s,r,o){var p=e.setup,m=e.wrapperComponent,v=p.limitToBounds,n=tc(e.props),i=e.transformState,a=i.scale,u=i.positionX,c=i.positionY;if(m){var g=Vn(e,n.scale),x=wr(n.positionX,n.positionY,g,v,0,0,m),S={scale:n.scale,positionX:x.x,positionY:x.y};a===n.scale&&u===n.positionX&&c===n.positionY||(o?.(),hs(e,S,s,r))}}function Kg(e,s,r,o){var p=e.getBoundingClientRect(),m=s.getBoundingClientRect(),v=r.getBoundingClientRect(),n=m.x*o.scale,i=m.y*o.scale;return{x:(p.x-v.x+n)/o.scale,y:(p.y-v.y+i)/o.scale}}function Vg(e,s,r){var o=e.wrapperComponent,p=e.contentComponent,m=e.transformState,v=e.setup,n=v.limitToBounds,i=v.minScale,a=v.maxScale;if(!o||!p)return m;var u=o.getBoundingClientRect(),c=s.getBoundingClientRect(),g=Kg(s,o,p,m),x=g.x,S=g.y,w=c.width/m.scale,l=c.height/m.scale,h=o.offsetWidth/w,d=o.offsetHeight/l,f=Cr(r||Math.min(h,d),i,a,0,!1),y=(u.width-w*f)/2,C=(u.height-l*f)/2,k=(u.left-x)*f+y,E=(u.top-S)*f+C,b=Vn(e,f),j=wr(k,E,b,n,0,0,o),R=j.x,L=j.y;return{positionX:R,positionY:L,scale:f}}var Xg=function(e){return function(s,r,o){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),rc(e,1,s,r,o)}},Yg=function(e){return function(s,r,o){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),rc(e,-1,s,r,o)}},Gg=function(e){return function(s,r,o,p,m){p===void 0&&(p=300),m===void 0&&(m="easeOut");var v=e.transformState,n=v.positionX,i=v.positionY,a=v.scale,u=e.wrapperComponent,c=e.contentComponent,g=e.setup.disabled;if(!(g||!u||!c)){var x={positionX:Number.isNaN(s)?n:s,positionY:Number.isNaN(r)?i:r,scale:Number.isNaN(o)?a:o};hs(e,x,p,m)}}},Qg=function(e){return function(s,r){s===void 0&&(s=200),r===void 0&&(r="easeOut"),ic(e,s,r)}},Zg=function(e){return function(s,r,o){r===void 0&&(r=200),o===void 0&&(o="easeOut");var p=e.transformState,m=e.wrapperComponent,v=e.contentComponent;if(m&&v){var n=nc(s||p.scale,m,v);hs(e,n,r,o)}}},Jg=function(e){return function(s,r,o,p){o===void 0&&(o=600),p===void 0&&(p="easeOut"),It(e);var m=e.wrapperComponent,v=typeof s=="string"?document.getElementById(s):s;if(m&&v&&m.contains(v)){var n=Vg(e,v,r);hs(e,n,o,p)}}},si=function(e){return{instance:e,zoomIn:Xg(e),zoomOut:Yg(e),setTransform:Gg(e),resetTransform:Qg(e),centerView:Zg(e),zoomToElement:Jg(e)}},cn=function(e){return{instance:e,state:e.transformState}},Ve=function(e){var s={};return Object.assign(s,cn(e)),Object.assign(s,si(e)),s},zi=!1;function Wi(){try{var e={get passive(){return zi=!0,!1}};return e}catch{return zi=!1,zi}}var Wr=".".concat(ln.wrapperClass),vi=function(e,s){return s.some(function(r){return e.matches("".concat(Wr," ").concat(r,", ").concat(Wr," .").concat(r,", ").concat(Wr," ").concat(r," *, ").concat(Wr," .").concat(r," *"))})},dn=function(e){e&&clearTimeout(e)},ev=function(e,s,r){return"translate(".concat(e,"px, ").concat(s,"px) scale(").concat(r,")")},nc=function(e,s,r){var o=r.offsetWidth*e,p=r.offsetHeight*e,m=(s.offsetWidth-o)/2,v=(s.offsetHeight-p)/2;return{scale:e,positionX:m,positionY:v}};function tv(e){return function(s){e.forEach(function(r){typeof r=="function"?r(s):r!=null&&(r.current=s)})}}var sv=function(e,s){var r=e.setup.wheel,o=r.disabled,p=r.wheelDisabled,m=r.touchPadDisabled,v=r.excluded,n=e.isInitialized,i=e.isPanning,a=s.target,u=n&&!i&&!o&&a;if(!u||p&&!s.ctrlKey||m&&s.ctrlKey)return!1;var c=vi(a,v);return!c},rv=function(e){return e?e.deltaY<0?1:-1:0};function iv(e,s){var r=rv(e),o=vg(s,r);return o}function oc(e,s,r){var o=s.getBoundingClientRect(),p=0,m=0;if("clientX"in e)p=(e.clientX-o.left)/r,m=(e.clientY-o.top)/r;else{var v=e.touches[0];p=(v.clientX-o.left)/r,m=(v.clientY-o.top)/r}return(Number.isNaN(p)||Number.isNaN(m))&&console.error("No mouse or touch offset found"),{x:p,y:m}}var nv=function(e,s,r,o,p){var m=e.transformState.scale,v=e.wrapperComponent,n=e.setup,i=n.maxScale,a=n.minScale,u=n.zoomAnimation,c=n.disablePadding,g=u.size,x=u.disabled;if(!v)throw new Error("Wrapper is not mounted");var S=m+s*r,w=o?!1:!x,l=Cr(Tt(S,3),a,i,g,w&&!c);return l},ov=function(e,s){var r=e.previousWheelEvent,o=e.transformState.scale,p=e.setup,m=p.maxScale,v=p.minScale;return r?o<m||o>v||Math.sign(r.deltaY)!==Math.sign(s.deltaY)||r.deltaY>0&&r.deltaY<s.deltaY||r.deltaY<0&&r.deltaY>s.deltaY||Math.sign(r.deltaY)!==Math.sign(s.deltaY):!1},av=function(e,s){var r=e.setup.pinch,o=r.disabled,p=r.excluded,m=e.isInitialized,v=s.target,n=m&&!o&&v;if(!n)return!1;var i=vi(v,p);return!i},lv=function(e){var s=e.setup.pinch.disabled,r=e.isInitialized,o=e.pinchStartDistance,p=r&&!s&&o;return!!p},cv=function(e,s,r){var o=r.getBoundingClientRect(),p=e.touches,m=Tt(p[0].clientX-o.left,5),v=Tt(p[0].clientY-o.top,5),n=Tt(p[1].clientX-o.left,5),i=Tt(p[1].clientY-o.top,5);return{x:(m+n)/2/s,y:(v+i)/2/s}},ac=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))},dv=function(e,s){var r=e.pinchStartScale,o=e.pinchStartDistance,p=e.setup,m=p.maxScale,v=p.minScale,n=p.zoomAnimation,i=p.disablePadding,a=n.size,u=n.disabled;if(!r||o===null||!s)throw new Error("Pinch touches distance was not provided");if(s<0)return e.transformState.scale;var c=s/o,g=c*r;return Cr(Tt(g,2),v,m,a,!u&&!i)},uv=160,hv=100,fv=function(e,s){var r=e.props,o=r.onWheelStart,p=r.onZoomStart;e.wheelStopEventTimer||(It(e),Ge(Ve(e),s,o),Ge(Ve(e),s,p))},mv=function(e,s){var r=e.props,o=r.onWheel,p=r.onZoom,m=e.contentComponent,v=e.setup,n=e.transformState,i=n.scale,a=v.limitToBounds,u=v.centerZoomedOut,c=v.zoomAnimation,g=v.wheel,x=v.disablePadding,S=v.smooth,w=c.size,l=c.disabled,h=g.step,d=g.smoothStep;if(!m)throw new Error("Component not mounted");s.preventDefault(),s.stopPropagation();var f=iv(s,null),y=S?d*Math.abs(s.deltaY):h,C=nv(e,f,y,!s.ctrlKey);if(i!==C){var k=ys(e,C),E=oc(s,m,i),b=l||w===0||u||x,j=a&&b,R=gi(e,E.x,E.y,C,k,j),L=R.x,T=R.y;e.previousWheelEvent=s,e.setTransformState(C,L,T),Ge(Ve(e),s,o),Ge(Ve(e),s,p)}},pv=function(e,s){var r=e.props,o=r.onWheelStop,p=r.onZoomStop;dn(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(ec(e,s.x,s.y),e.wheelAnimationTimer=null)},hv);var m=ov(e,s);m&&(dn(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,Ge(Ve(e),s,o),Ge(Ve(e),s,p))},uv))},lc=function(e){for(var s=0,r=0,o=0;o<2;o+=1)s+=e.touches[o].clientX,r+=e.touches[o].clientY;var p=s/2,m=r/2;return{x:p,y:m}},gv=function(e,s){var r=ac(s);e.pinchStartDistance=r,e.lastDistance=r,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var o=lc(s);e.pinchLastCenterX=o.x,e.pinchLastCenterY=o.y,It(e)},vv=function(e,s){var r=e.contentComponent,o=e.pinchStartDistance,p=e.wrapperComponent,m=e.transformState.scale,v=e.setup,n=v.limitToBounds,i=v.centerZoomedOut,a=v.zoomAnimation,u=v.alignmentAnimation,c=a.disabled,g=a.size;if(!(o===null||!r)){var x=cv(s,m,r);if(!(!Number.isFinite(x.x)||!Number.isFinite(x.y))){var S=ac(s),w=dv(e,S),l=lc(s),h=l.x-(e.pinchLastCenterX||0),d=l.y-(e.pinchLastCenterY||0);if(!(w===m&&h===0&&d===0)){e.pinchLastCenterX=l.x,e.pinchLastCenterY=l.y;var f=ys(e,w),y=c||g===0||i,C=n&&y,k=gi(e,x.x,x.y,w,f,C),E=k.x,b=k.y;e.pinchMidpoint=x,e.lastDistance=S;var j=u.sizeX,R=u.sizeY,L=us(e,j),T=us(e,R),D=E+h,F=b+d,I=wr(D,F,f,n,L,T,p),H=I.x,K=I.y;e.setTransformState(w,H,K)}}}},xv=function(e){var s=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,ec(e,s?.x,s?.y)},cc=function(e,s){var r=e.props.onZoomStop,o=e.setup.doubleClick.animationTime;dn(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,Ge(Ve(e),s,r)},o)},bv=function(e,s){var r=e.props,o=r.onZoomStart,p=r.onZoom,m=e.setup.doubleClick,v=m.animationTime,n=m.animationType;Ge(Ve(e),s,o),ic(e,v,n,function(){return Ge(Ve(e),s,p)}),cc(e,s)};function _v(e,s){return e==="toggle"?s===1?1:-1:e==="zoomOut"?-1:1}function yv(e,s){var r=e.setup,o=e.doubleClickStopEventTimer,p=e.transformState,m=e.contentComponent,v=p.scale,n=e.props,i=n.onZoomStart,a=n.onZoom,u=r.doubleClick,c=u.disabled,g=u.mode,x=u.step,S=u.animationTime,w=u.animationType;if(!c&&!o){if(g==="reset")return bv(e,s);if(!m)return console.error("No ContentComponent found");var l=_v(g,e.transformState.scale),h=sc(e,l,x);if(v!==h){Ge(Ve(e),s,i);var d=oc(s,m,v),f=Yn(e,h,d.x,d.y);if(!f)return console.error("Error during zoom event. New transformation state was not calculated.");Ge(Ve(e),s,a),hs(e,f,S,w),cc(e,s)}}}var Sv=function(e,s){var r=e.isInitialized,o=e.setup,p=e.wrapperComponent,m=o.doubleClick,v=m.disabled,n=m.excluded,i=s.target,a=p?.contains(i),u=r&&i&&a&&!v;if(!u)return!1;var c=vi(i,n);return!c},wv=(function(){function e(s){var r=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(){r.initializeWindowEvents()},this.unmount=function(){r.cleanupWindowEvents()},this.update=function(o){r.props=o,ys(r,r.transformState.scale),r.setup=ra(o)},this.initializeWindowEvents=function(){var o,p,m=Wi(),v=(o=r.wrapperComponent)===null||o===void 0?void 0:o.ownerDocument,n=v?.defaultView;(p=r.wrapperComponent)===null||p===void 0||p.addEventListener("wheel",r.onWheelPanning,m),n?.addEventListener("mousedown",r.onPanningStart,m),n?.addEventListener("mousemove",r.onPanning,m),n?.addEventListener("mouseup",r.onPanningStop,m),v?.addEventListener("mouseleave",r.clearPanning,m),n?.addEventListener("keyup",r.setKeyUnPressed,m),n?.addEventListener("keydown",r.setKeyPressed,m)},this.cleanupWindowEvents=function(){var o,p,m=Wi(),v=(o=r.wrapperComponent)===null||o===void 0?void 0:o.ownerDocument,n=v?.defaultView;n?.removeEventListener("mousedown",r.onPanningStart,m),n?.removeEventListener("mousemove",r.onPanning,m),n?.removeEventListener("mouseup",r.onPanningStop,m),v?.removeEventListener("mouseleave",r.clearPanning,m),n?.removeEventListener("keyup",r.setKeyUnPressed,m),n?.removeEventListener("keydown",r.setKeyPressed,m),document.removeEventListener("mouseleave",r.clearPanning,m),It(r),(p=r.observer)===null||p===void 0||p.disconnect()},this.handleInitializeWrapperEvents=function(o){var p=Wi();o.addEventListener("wheel",r.onWheelZoom,p),o.addEventListener("dblclick",r.onDoubleClick,p),o.addEventListener("touchstart",r.onTouchPanningStart,p),o.addEventListener("touchmove",r.onTouchPanning,p),o.addEventListener("touchend",r.onTouchPanningStop,p)},this.handleInitialize=function(o,p){var m=!1,v=r.setup.centerOnInit,n=function(i,a){for(var u=0,c=i;u<c.length;u++){var g=c[u];if(g.target===a)return!0}return!1};r.applyTransformation(),r.onInitCallbacks.forEach(function(i){i(Ve(r))}),r.observer=new ResizeObserver(function(i){if(n(i,o)||n(i,p))if(v&&!m){var a=p.offsetWidth,u=p.offsetHeight;(a>0||u>0)&&(m=!0,r.setCenter())}else It(r),ys(r,r.transformState.scale),Xn(r,0)}),r.observer.observe(o),r.observer.observe(p)},this.onWheelZoom=function(o){var p=r.setup.disabled;if(!p){var m=sv(r,o);if(m){var v=r.isPressingKeys(r.setup.wheel.activationKeys);v&&(fv(r,o),mv(r,o),pv(r,o))}}},this.onWheelPanning=function(o){var p=r.setup,m=p.disabled,v=p.wheel,n=p.panning;if(!(!r.wrapperComponent||!r.contentComponent||m||!v.wheelDisabled||n.disabled||!n.wheelPanning||o.ctrlKey)){o.preventDefault(),o.stopPropagation();var i=r.transformState,a=i.positionX,u=i.positionY,c=a-o.deltaX,g=u-o.deltaY,x=n.lockAxisX?a:c,S=n.lockAxisY?u:g,w=r.setup.alignmentAnimation,l=w.sizeX,h=w.sizeY,d=us(r,l),f=us(r,h);x===a&&S===u||Jl(r,x,S,d,f)}},this.onPanningStart=function(o){var p=r.setup.disabled,m=r.props.onPanningStart;if(!p){var v=Qo(r,o);if(v){var n=r.isPressingKeys(r.setup.panning.activationKeys);n&&(o.button===0&&!r.setup.panning.allowLeftClickPan||o.button===1&&!r.setup.panning.allowMiddleClickPan||o.button===2&&!r.setup.panning.allowRightClickPan||(o.preventDefault(),o.stopPropagation(),It(r),ea(r,o),Ge(Ve(r),o,m)))}}},this.onPanning=function(o){var p=r.setup.disabled,m=r.props.onPanning;if(!p){var v=Zo(r);if(v){var n=r.isPressingKeys(r.setup.panning.activationKeys);n&&(o.preventDefault(),o.stopPropagation(),ta(r,o.clientX,o.clientY),Ge(Ve(r),o,m))}}},this.onPanningStop=function(o){var p=r.props.onPanningStop;r.isPanning&&(qg(r),Ge(Ve(r),o,p))},this.onPinchStart=function(o){var p=r.setup.disabled,m=r.props,v=m.onPinchingStart,n=m.onZoomStart;if(!p){var i=av(r,o);i&&(gv(r,o),It(r),Ge(Ve(r),o,v),Ge(Ve(r),o,n))}},this.onPinch=function(o){var p=r.setup.disabled,m=r.props,v=m.onPinching,n=m.onZoom;if(!p){var i=lv(r);i&&(o.preventDefault(),o.stopPropagation(),vv(r,o),Ge(Ve(r),o,v),Ge(Ve(r),o,n))}},this.onPinchStop=function(o){var p=r.props,m=p.onPinchingStop,v=p.onZoomStop;r.pinchStartScale&&(xv(r),Ge(Ve(r),o,m),Ge(Ve(r),o,v))},this.onTouchPanningStart=function(o){var p=r.setup.disabled,m=r.props.onPanningStart;if(!p){var v=Qo(r,o);if(v){var n=r.lastTouch&&+new Date-r.lastTouch<200&&o.touches.length===1;if(!n){r.lastTouch=+new Date,It(r);var i=o.touches,a=i.length===1,u=i.length===2;a&&(It(r),ea(r,o),Ge(Ve(r),o,m)),u&&r.onPinchStart(o)}}}},this.onTouchPanning=function(o){var p=r.setup.disabled,m=r.props.onPanning;if(r.isPanning&&o.touches.length===1){if(p)return;var v=Zo(r);if(!v)return;o.preventDefault(),o.stopPropagation();var n=o.touches[0];ta(r,n.clientX,n.clientY),Ge(Ve(r),o,m)}else o.touches.length>1&&r.onPinch(o)},this.onTouchPanningStop=function(o){r.onPanningStop(o),r.onPinchStop(o)},this.onDoubleClick=function(o){var p=r.setup.disabled;if(!p){var m=Sv(r,o);m&&yv(r,o)}},this.clearPanning=function(o){r.isPanning&&r.onPanningStop(o)},this.setKeyPressed=function(o){r.pressedKeys[o.key]=!0},this.setKeyUnPressed=function(o){r.pressedKeys[o.key]=!1},this.isPressingKeys=function(o){return o.length?!!o.find(function(p){return r.pressedKeys[p]}):!0},this.setTransformState=function(o,p,m){var v=r.props.onTransformed;if(!Number.isNaN(o)&&!Number.isNaN(p)&&!Number.isNaN(m)){o!==r.transformState.scale&&(r.transformState.previousScale=r.transformState.scale,r.transformState.scale=o),r.transformState.positionX=p,r.transformState.positionY=m,r.applyTransformation();var n=Ve(r);r.onChangeCallbacks.forEach(function(i){return i(n)}),Ge(n,{scale:o,positionX:p,positionY:m},v)}else console.error("Detected NaN set state values")},this.setCenter=function(){if(r.wrapperComponent&&r.contentComponent){var o=nc(r.transformState.scale,r.wrapperComponent,r.contentComponent);r.setTransformState(o.scale,o.positionX,o.positionY)}},this.handleTransformStyles=function(o,p,m){return r.props.customTransform?r.props.customTransform(o,p,m):ev(o,p,m)},this.applyTransformation=function(){if(!(!r.mounted||!r.contentComponent)){var o=r.transformState,p=o.scale,m=o.positionX,v=o.positionY,n=r.handleTransformStyles(m,v,p);r.contentComponent.style.transform=n}},this.getContext=function(){return Ve(r)},this.onChange=function(o){return r.onChangeCallbacks.has(o)||r.onChangeCallbacks.add(o),function(){r.onChangeCallbacks.delete(o)}},this.onInit=function(o){return r.onInitCallbacks.has(o)||r.onInitCallbacks.add(o),function(){r.onInitCallbacks.delete(o)}},this.init=function(o,p){r.cleanupWindowEvents(),r.wrapperComponent=o,r.contentComponent=p,ys(r,r.transformState.scale),r.handleInitializeWrapperEvents(o),r.handleInitialize(o,p),r.initializeWindowEvents(),r.isInitialized=!0;var m=Ve(r);Ge(m,void 0,r.props.onInit)},this.props=s,this.setup=ra(this.props),this.transformState=tc(this.props)}return e})(),xi=ae.createContext(null),Cv=function(e,s){return typeof e=="function"?e(s):e},kv=ae.forwardRef(function(e,s){var r=_.useRef(new wv(e)).current,o=Cv(e.children,si(r));return _.useImperativeHandle(s,function(){return si(r)},[r]),_.useEffect(function(){r.update(e)},[r,e]),ae.createElement(xi.Provider,{value:r},o)});ae.forwardRef(function(e,s){var r=_.useRef(null),o=_.useContext(xi);return _.useEffect(function(){return o.onChange(function(p){if(r.current){var m=0,v=0;r.current.style.transform=o.handleTransformStyles(m,v,1/p.instance.transformState.scale)}})},[o]),ae.createElement("div",cs({},e,{ref:tv([r,s])}))});function Ev(e,s){s===void 0&&(s={});var r=s.insertAt;if(!(typeof document>"u")){var o=document.head||document.getElementsByTagName("head")[0],p=document.createElement("style");p.type="text/css",r==="top"&&o.firstChild?o.insertBefore(p,o.firstChild):o.appendChild(p),p.styleSheet?p.styleSheet.cssText=e:p.appendChild(document.createTextNode(e))}}var jv=`.transform-component-module_wrapper__SPB86 {
|
|
41
|
+
position: relative;
|
|
42
|
+
width: -moz-fit-content;
|
|
43
|
+
width: fit-content;
|
|
44
|
+
height: -moz-fit-content;
|
|
45
|
+
height: fit-content;
|
|
46
|
+
overflow: hidden;
|
|
47
|
+
-webkit-touch-callout: none; /* iOS Safari */
|
|
48
|
+
-webkit-user-select: none; /* Safari */
|
|
49
|
+
-khtml-user-select: none; /* Konqueror HTML */
|
|
50
|
+
-moz-user-select: none; /* Firefox */
|
|
51
|
+
-ms-user-select: none; /* Internet Explorer/Edge */
|
|
52
|
+
user-select: none;
|
|
53
|
+
margin: 0;
|
|
54
|
+
padding: 0;
|
|
55
|
+
transform: translate3d(0, 0, 0);
|
|
56
|
+
}
|
|
57
|
+
.transform-component-module_content__FBWxo {
|
|
58
|
+
display: flex;
|
|
59
|
+
flex-wrap: wrap;
|
|
60
|
+
width: -moz-fit-content;
|
|
61
|
+
width: fit-content;
|
|
62
|
+
height: -moz-fit-content;
|
|
63
|
+
height: fit-content;
|
|
64
|
+
margin: 0;
|
|
65
|
+
padding: 0;
|
|
66
|
+
transform-origin: 0% 0%;
|
|
67
|
+
}
|
|
68
|
+
.transform-component-module_content__FBWxo img {
|
|
69
|
+
pointer-events: none;
|
|
70
|
+
}
|
|
71
|
+
`,ia={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};Ev(jv);var Nv=function(e){var s=e.children,r=e.wrapperClass,o=r===void 0?"":r,p=e.contentClass,m=p===void 0?"":p,v=e.wrapperStyle,n=e.contentStyle,i=e.wrapperProps,a=i===void 0?{}:i,u=e.contentProps,c=u===void 0?{}:u,g=_.useContext(xi),x=g.init,S=g.cleanupWindowEvents,w=_.useRef(null),l=_.useRef(null);return _.useEffect(function(){var h=w.current,d=l.current;return h!==null&&d!==null&&x&&x?.(h,d),function(){S?.()}},[]),ae.createElement("div",cs({},a,{ref:w,className:"".concat(ln.wrapperClass," ").concat(ia.wrapper," ").concat(o),style:v}),ae.createElement("div",cs({},c,{ref:l,className:"".concat(ln.contentClass," ").concat(ia.content," ").concat(m),style:n}),s))},dc=function(){var e=_.useContext(xi);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},Rv=function(){var e=dc();return si(e)};function Av(e){var s=dc(),r=_.useState(e(cn(s))),o=r[0],p=r[1];return _.useEffect(function(){var m=!0,v=s.onChange(function(n){m&&p(e(cn(n.instance)))});return function(){v(),m=!1}},[e,s]),o}function Tv(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 Mv(e,s){return kt({queryKey:de.files.tree(e||"",s),queryFn:()=>Ce.get("/files/tree",{params:{workingDir:e||"",path:s}}),enabled:!!e})}function Dv(e,s){return kt({queryKey:de.files.content(e||"",s||""),queryFn:()=>Ce.get("/files/read",{params:{workingDir:e||"",path:s||""}}),enabled:!!e&&!!s})}function Pv(e){const s=bt();return _.useCallback(()=>{e&&s.invalidateQueries({queryKey:["files","tree",e]})},[s,e])}function Lv(){const e=bt();return Bt({mutationFn:s=>Ce.post("/files/write",s),onSuccess:(s,r)=>{const o=de.files.content(r.workingDir,r.path),p=e.getQueryData(o);e.setQueryData(o,{content:r.content,language:p?.language||Tv(r.path)})}})}function Iv(e,s){return e==="/"?`/${s}`:`${e}/${s}`}function Ov(e,s){return e==="/"?s:`${e.slice(1)}/${s}`}const Bv=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function Fv(e){if(e.type==="directory")return null;const s=e.name.split(".").pop()?.toLowerCase();return s&&Bv.has(s)?Ia:s==="ts"||s==="tsx"||s==="js"||s==="jsx"?Xr:s==="json"?iu:s==="md"||s==="mdx"||s==="txt"?La:Od}const na=({depth:e,active:s,onClick:r,leftIcon:o,rightIcon:p,label:m})=>t.jsxs("button",{type:"button",onClick:r,className:se("w-full flex items-center gap-2 rounded px-2 py-1 text-left text-xs hover:bg-neutral-100",s&&"bg-neutral-100 text-neutral-900"),style:{paddingLeft:8+e*14},children:[t.jsx("span",{className:"shrink-0",children:p}),t.jsx("span",{className:"shrink-0 text-neutral-500",children:o}),t.jsx("span",{className:"truncate text-neutral-700",children:m})]}),uc=({workingDir:e,path:s,depth:r,expanded:o,toggleDir:p,onFileSelect:m,selectedFilePath:v})=>{const{t:n}=le(),{data:i,isLoading:a,isError:u}=Mv(e,s),c=_.useMemo(()=>i?.items??[],[i?.items]);return a?t.jsx("div",{className:"text-xs text-neutral-400 px-2 py-1",style:{paddingLeft:8+r*14},children:n("Loading...")}):u?t.jsx("div",{className:"text-xs text-red-600 px-2 py-1",style:{paddingLeft:8+r*14},children:n("Failed to load")}):t.jsx("div",{className:"space-y-0.5",children:c.map(g=>{if(g.type==="directory"){const h=Iv(s,g.name),d=o.has(h);return t.jsxs("div",{children:[t.jsx(na,{depth:r,onClick:()=>p(h),rightIcon:d?t.jsx(wt,{size:14,className:"text-neutral-400"}):t.jsx(Mt,{size:14,className:"text-neutral-400"}),leftIcon:d?t.jsx(li,{size:14,className:"text-amber-500"}):t.jsx(Rn,{size:14,className:"text-amber-500"}),label:g.name}),d&&t.jsx(uc,{workingDir:e,path:h,depth:r+1,expanded:o,toggleDir:p,onFileSelect:m,selectedFilePath:v})]},h)}const x=Ov(s,g.name),S=Fv(g),w=v===x,l=S===Ia;return t.jsx(na,{depth:r,active:w,onClick:()=>m(x),rightIcon:t.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:S?t.jsx(S,{size:14,className:l?"text-emerald-600":"text-sky-600"}):null,label:g.name},x)})})},zv=({workingDir:e,className:s,onFileSelect:r,selectedFilePath:o,onCollapse:p})=>{const{t:m}=le(),[v,n]=_.useState(()=>new Set),i=Pv(e),a=_.useCallback(u=>{n(c=>{const g=new Set(c);return g.has(u)?g.delete(u):g.add(u),g})},[]);return t.jsxs("div",{className:se("h-full flex flex-col",s),children:[t.jsxs("div",{className:"px-3 py-2 border-b border-neutral-200 bg-neutral-50/80 flex items-center justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[11px] font-semibold text-neutral-600 uppercase tracking-wider",children:m("Files")}),t.jsx("div",{className:"text-[11px] text-neutral-400 truncate",children:e||m("No working directory")})]}),t.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e&&t.jsx("button",{type:"button",onClick:i,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:m("Refresh file tree"),children:t.jsx(ks,{size:13})}),p&&t.jsx("button",{type:"button",onClick:p,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:m("Collapse file tree"),children:t.jsx(mu,{size:13})})]})]}),t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin p-2",children:e?t.jsx(uc,{workingDir:e,path:"/",depth:0,expanded:v,toggleDir:a,onFileSelect:r,selectedFilePath:o}):t.jsx("div",{className:"text-xs text-neutral-500 px-2 py-2",children:m("No workspace selected.")})})]})},Wv=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function Hv(e){const s=e.split(".").pop()?.toLowerCase();return s?Wv.has(s):!1}function $v(e,s){const r=vr(),o=new URLSearchParams({workingDir:e,path:s});return`${r}/files/image?${o.toString()}`}const Uv=({filePath:e})=>{const{t:s}=le(),{zoomIn:r,zoomOut:o,centerView:p}=Rv(),m=Av(n=>n.state.scale),v=Math.round(m*100);return t.jsxs("div",{className:"flex items-center gap-1 px-3 py-1.5 border-b border-neutral-200 bg-neutral-50/80 shrink-0",children:[t.jsx("button",{type:"button",onClick:()=>o(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:s("Zoom out"),children:t.jsx(Ru,{size:14})}),t.jsxs("button",{type:"button",onClick:()=>p(1),className:"px-1.5 py-0.5 rounded hover:bg-neutral-200 text-[11px] text-neutral-600 tabular-nums min-w-[40px] text-center transition-colors",title:s("Reset zoom"),children:[v,"%"]}),t.jsx("button",{type:"button",onClick:()=>r(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:s("Zoom in"),children:t.jsx(ju,{size:14})}),t.jsx("button",{type:"button",onClick:()=>p(1),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors ml-1",title:s("Fit to view"),children:t.jsx(hu,{size:13})}),t.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},qv=({workingDir:e,filePath:s})=>{const{t:r}=le(),[o,p]=_.useState(!1),m=$v(e,s);return o?t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:r("Failed to load image.")}):t.jsx(kv,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx(Uv,{filePath:s}),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(Nv,{wrapperStyle:{width:"100%",height:"100%"},contentStyle:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx("img",{src:m,alt:s,className:"max-w-full max-h-full object-contain rounded shadow-sm",draggable:!1,onError:()=>p(!0)})})})]})})};function Kv(e){const s=e.split("/");return s[s.length-1]||e}function Vv(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 Xv=({active:e,name:s,isDirty:r,onClick:o,onClose:p})=>{const{t:m}=le();return t.jsxs("button",{type:"button",onClick:o,className:se("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]",e?"bg-white border-neutral-200 text-neutral-900":"bg-neutral-100/60 border-transparent text-neutral-500 hover:text-neutral-700 hover:bg-neutral-100"),children:[t.jsx("span",{className:se("w-2 h-2 rounded-full",r?"bg-amber-500":"bg-transparent")}),t.jsx("span",{className:"truncate flex-1 text-left text-xs",children:s}),t.jsx("span",{onClick:p,className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-neutral-200 rounded transition-all shrink-0","aria-label":m("Close tab"),title:m("Close"),children:t.jsx(Zt,{size:12})})]})},Yv=ae.forwardRef(function({workingDir:s,className:r,readOnly:o=!1},p){const{t:m}=le(),[v,n]=_.useState([]),[i,a]=_.useState(null),[u,c]=_.useState(!1),[g,x]=_.useState(!1),[S,w]=_.useState(0),[l,h]=_.useState(null),d=_.useRef(null),f=Lv();_.useEffect(()=>{let B=!1;return hd(async()=>{const{preloadMonaco:z}=await import("./monaco-B9Zd90UG.js").then(q=>q.m);return{preloadMonaco:z}},__vite__mapDeps([0,1,2,3])).then(({preloadMonaco:z})=>z()).then(()=>{B||c(!0)}).catch(()=>{B||x(!0)}),()=>{B=!0}},[]);const[y,C]=_.useState(280),[k,E]=_.useState(!1),[b,j]=_.useState(!1),R=_.useRef(280),L=_.useCallback(()=>{E(B=>(B?C(R.current):R.current=y,!B))},[y]),T=_.useCallback(B=>{B.preventDefault(),j(!0);const z=B.clientX,q=y,N=X=>{const V=X.clientX-z,ie=Math.min(480,Math.max(160,q+V));C(ie)},W=()=>{j(!1),document.removeEventListener("mousemove",N),document.removeEventListener("mouseup",W)};document.addEventListener("mousemove",N),document.addEventListener("mouseup",W)},[y]);_.useEffect(()=>{n([]),a(null),h(null)},[s]);const D=_.useMemo(()=>v.find(B=>B.path===i)||null,[v,i]),{data:F,isFetching:I,isError:H,error:K}=Dv(s,D?.isImage?null:i);_.useEffect(()=>{!i||!F||n(B=>B.map(z=>z.path!==i||z.isDirty||z.loaded?z:{...z,language:F.language||z.language,content:F.content,savedContent:F.content,isDirty:!1,loaded:!0}))},[i,F]);const A=_.useCallback((B,z,q)=>{n(N=>{if(N.find(V=>V.path===B))return N;const X=Hv(B);return[...N,{path:B,name:Kv(B),language:Vv(B),content:"",savedContent:"",isDirty:!1,loaded:X,isImage:X}]}),a(B),h(z?{path:B,line:z,column:q}:null)},[]);ae.useImperativeHandle(p,()=>({openFile:A}),[A]);const P=_.useCallback(B=>{n(z=>{const q=z.filter(N=>N.path!==B);return a(N=>N!==B?N:q.length?q[q.length-1].path:null),q})},[]),M=_.useCallback(B=>{n(z=>z.map(q=>{if(q.path!==i)return q;const N=B!==q.savedContent;return{...q,content:B,isDirty:N}}))},[i]),O=_.useCallback(async()=>{o||!s||!D||(await f.mutateAsync({workingDir:s,path:D.path,content:D.content}),n(B=>B.map(z=>z.path===D.path?{...z,savedContent:z.content,isDirty:!1,loaded:!0}:z)))},[D,o,f,s]),$=_.useRef(()=>{});_.useEffect(()=>{$.current=()=>{O().catch(()=>{})}},[O]),_.useEffect(()=>{const B=z=>{o||(z.metaKey||z.ctrlKey)&&z.key.toLowerCase()==="s"&&(z.preventDefault(),$.current())};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[o]);const U=_.useCallback((B,z)=>{d.current=B,w(q=>q+1),B.addCommand(z.KeyMod.CtrlCmd|z.KeyCode.KeyS,()=>{$.current()})},[]);return _.useEffect(()=>{if(!l||l.path!==i||!D?.loaded)return;const B=d.current,z=B?.getModel();if(!B||!z)return;const q=Math.min(l.line,z.getLineCount()),N=Math.min(l.column??1,z.getLineMaxColumn(q)),W={lineNumber:q,column:N};B.setPosition(W),B.revealPositionInCenter(W),B.focus(),h(null)},[i,D?.loaded,S,l]),t.jsxs("div",{className:se("flex h-full overflow-hidden bg-white",r),style:b?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsx("div",{className:"border-r border-neutral-200 bg-white shrink-0 overflow-hidden relative",style:{width:k?36:y,transition:b?"none":"width 0.15s ease"},children:k?t.jsx("div",{className:"h-full flex items-start pt-2 justify-center",children:t.jsx("button",{type:"button",onClick:L,className:"p-1.5 rounded hover:bg-neutral-100 text-neutral-500 hover:text-neutral-700 transition-colors",title:m("Expand file tree"),children:t.jsx(gu,{size:16})})}):t.jsx(t.Fragment,{children:t.jsx(zv,{workingDir:s,onFileSelect:A,selectedFilePath:D?.path||null,onCollapse:L},s||"no-working-dir")})}),!k&&t.jsx("div",{onMouseDown:T,className:se("w-1 shrink-0 cursor-col-resize transition-colors",b?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),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-neutral-200 bg-neutral-100/80 overflow-x-auto shrink-0",children:[v.length===0?t.jsx("div",{className:"px-2 pb-2 text-xs text-neutral-500",children:m("No open files")}):v.map(B=>t.jsx(Xv,{active:B.path===i,name:B.name,isDirty:B.isDirty,onClick:()=>a(B.path),onClose:z=>{z.stopPropagation(),P(B.path)}},B.path)),t.jsxs("div",{className:"ml-auto flex items-center gap-2 pb-2 pr-1",children:[o&&t.jsx("span",{className:"text-[11px] text-neutral-400",children:m("Read-only")}),f.isPending&&t.jsxs("span",{className:"flex items-center gap-2 text-xs text-neutral-500",children:[t.jsx(We,{size:14,className:"animate-spin"}),m("Saving")]}),D?.isDirty&&!f.isPending&&t.jsx("span",{className:"text-[11px] text-amber-600",children:m("Unsaved")})]})]}),t.jsx("div",{className:"flex-1 min-h-0 relative",children:s?D?D.isImage?t.jsx(qv,{workingDir:s,filePath:D.path}):g?t.jsx("div",{className:"h-full flex items-center justify-center text-red-600 text-sm",children:m("Failed to load editor.")}):u?t.jsxs(t.Fragment,{children:[t.jsx(gg,{path:D.path,value:D.content,language:D.language,theme:"vs-light",height:"100%",onChange:o?void 0:B=>M(B??""),onMount:U,options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",automaticLayout:!0,readOnly:o}}),I&&!D.loaded&&t.jsx("div",{className:"absolute inset-0 bg-white/60 flex items-center justify-center",children:t.jsxs("div",{className:"flex items-center gap-2 text-xs text-neutral-600",children:[t.jsx(We,{size:14,className:"animate-spin"}),m("Loading file...")]})}),H&&t.jsxs("div",{className:"absolute bottom-2 left-2 right-2 text-xs text-red-700 bg-red-50 border border-red-200 rounded px-2 py-1",children:[m("Failed to load file"),K instanceof Error?`: ${K.message}`:""]})]}):t.jsxs("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:[t.jsx(We,{size:14,className:"animate-spin mr-2"}),m("Loading editor...")]}):t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:m("Select a file from the tree to open.")}):t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:m("No workspace selected.")})})]})]})});function bi(e,s={}){const r=Cs(p=>p.visibleContext),o=kl(e,r);return kt({queryKey:de.git.changes(e||""),queryFn:()=>Ce.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e&&(s.enabled??!0),refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1})}function hc(e,s,r){const o=Cs(m=>m.visibleContext),p=kl(e,o);return kt({queryKey:de.git.diff(e||"",s||"",r),queryFn:()=>Ce.get("/git/diff",{params:{workingDir:e||"",path:s||"",type:r}}),enabled:!!e&&!!s,refetchInterval:p,refetchIntervalInBackground:!1,refetchOnWindowFocus:p?"always":!1,refetchOnReconnect:p?"always":!1})}function Gn(e,s){return kt({queryKey:de.git.commitFiles(e||"",s||""),queryFn:()=>Ce.get("/git/commit-files",{params:{workingDir:e||"",hash:s||""}}),enabled:!!e&&!!s})}function Qn(e,s,r){return kt({queryKey:de.git.commitDiff(e||"",s||"",r||""),queryFn:()=>Ce.get("/git/commit-diff",{params:{workingDir:e||"",hash:s||"",path:r||""}}),enabled:!!e&&!!s&&!!r})}function fc({isOpen:e,onClose:s,branchName:r,targetBranch:o,commitMessage:p,isPending:m,error:v,onConfirm:n}){const{t:i}=le(),[a,u]=_.useState(""),[c,g]=_.useState(!1);_.useEffect(()=>{e&&(g(!1),u(p??""))},[e]),_.useEffect(()=>{c||!e||u(p??"")},[p,c,e]);const x=()=>{m||s()};return t.jsx(ds,{isOpen:e,onClose:x,title:i("提交变更"),className:"max-w-md",action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:x,disabled:m,className:"px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:i("取消")}),t.jsx("button",{onClick:()=>n(a.trim()||void 0),disabled:m,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium text-primary-foreground bg-primary hover:bg-primary/90 rounded-md transition-colors disabled:opacity-50",children:m?t.jsxs(t.Fragment,{children:[t.jsx(We,{size:14,className:"animate-spin"}),i("正在提交...")]}):t.jsxs(t.Fragment,{children:[t.jsx(Vr,{size:14}),i("确认提交")]})})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-muted font-mono text-xs text-muted-foreground",children:r}),t.jsx(el,{size:14,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-muted font-mono text-xs text-muted-foreground",children:o})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-foreground mb-1.5",children:i("提交消息")}),t.jsx("textarea",{value:a,onChange:S=>{g(!0),u(S.target.value)},placeholder:i("请描述本次修改的内容"),rows:4,className:"w-full px-3 py-2 rounded-md border border-input text-sm font-mono text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2 focus:ring-ring/30 focus:border-ring resize-none"}),t.jsx("p",{className:"mt-1.5 text-[11px] text-muted-foreground/70 leading-relaxed",children:i("建议以 feat、fix、docs、refactor、chore 开头,保持提交记录清晰。feat 新增功能,fix 修复问题,docs 文档更新,refactor 代码重构,chore 日常维护。")}),!a.trim()&&t.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground/70",children:i("留空将使用默认消息")})]}),v&&t.jsx("div",{className:"px-3 py-2 rounded-md bg-red-50 border border-red-200 text-sm text-red-700",children:v})]})})}function Ms(e,s){const r=e[s];return typeof r=="string"&&r.length>0?r:void 0}function mc(e){if(!(e instanceof pn)||e.status!==409)return;const s=e.details;if(s.code!=="MERGE_CONFLICT"||s.conflictOp!==ur.REBASE&&s.conflictOp!==ur.MERGE||!Array.isArray(s.conflictedFiles)||!s.conflictedFiles.every(o=>typeof o=="string"))return;const r=s.mergeStrategy==="squash"||s.mergeStrategy==="no_ff"?s.mergeStrategy:void 0;return{conflictOp:s.conflictOp,conflictedFiles:s.conflictedFiles,mergeAborted:typeof s.mergeAborted=="boolean"?s.mergeAborted:void 0,mergeStrategy:r,sourceBranch:Ms(s,"sourceBranch"),targetBranch:Ms(s,"targetBranch"),sourceWorktreePath:Ms(s,"sourceWorktreePath"),targetWorktreePath:Ms(s,"targetWorktreePath"),sourceWorkspaceId:Ms(s,"sourceWorkspaceId"),targetWorkspaceId:Ms(s,"targetWorkspaceId")}}function oa(e,s,r,o){const p=mc(e);if(p){r(p);return}o(e instanceof Error?e.message:s)}function pc({workspaceId:e,branchName:s,targetBranch:r,commitMessage:o,committedFileCount:p,onRefreshCommitMessage:m,onConflict:v,onResolveConflicts:n}){const{t:i}=le(),{data:a,isLoading:u}=Wn(e),c=Nl(),g=jl(),x=Hn(),[S,w]=_.useState(!1),[l,h]=_.useState(null);if(_.useEffect(()=>{S&&m?.()},[S,m]),u||!a)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground/70 border-b border-border/60",children:[t.jsx(We,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:i("正在检查工作区状态...")})]});const d=a.conflictedFiles.length>0,f=a.operation!=="idle",y=a.hasUncommittedChanges||a.untrackedCount>0,C=a.uncommittedCount+a.untrackedCount,k=!d&&!f&&!y,E=a.operation==="idle"&&a.ahead===0&&a.behind===0&&!y&&!d,b=()=>{h(null),c.mutate(e,{onError:T=>{oa(T,i("更新失败,请稍后重试"),D=>v(D),h)}})},j=()=>{h(null),w(!0)},R=T=>{h(null),g.mutate({id:e,commitMessage:T},{onSuccess:()=>w(!1),onError:D=>{oa(D,i("提交失败,请稍后重试"),F=>{w(!1),v(F)},h)}})},L=()=>{g.isPending||(w(!1),h(null))};return E?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground/70 border-b border-border/60",children:[t.jsx(fd,{size:13}),t.jsx("span",{className:"text-xs",children:i("当前分支还没有任何变更")})]}):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:[l&&t.jsx("div",{className:"mb-2 px-2.5 py-1.5 rounded-md bg-red-50 border border-red-200 text-[11px] text-red-700",children:l}),y&&t.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2.5 py-1.5 rounded-md bg-amber-50 border border-amber-200 text-[11px] text-amber-800",children:[t.jsx(au,{size:12,className:"shrink-0"}),t.jsx("span",{children:i("{count} 个本地改动未处理,需要先整理后再继续",{count:C})})]}),d&&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-amber-700",children:[t.jsx($s,{size:13,className:"shrink-0"}),t.jsx("span",{children:i("{count} 个文件存在冲突,需要处理后继续",{count:a.conflictedFiles.length})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[t.jsx("button",{onClick:n,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-amber-800 bg-amber-100 hover:bg-amber-200 border border-amber-200 transition-colors",children:i("处理冲突")}),t.jsx("button",{onClick:()=>x.mutate(e),disabled:x.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs text-muted-foreground hover:bg-muted border border-border transition-colors disabled:opacity-50",children:x.isPending?i("正在撤销..."):i("撤销操作")})]})]}),f&&!d&&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-info",children:[t.jsx(We,{size:13,className:"animate-spin shrink-0"}),t.jsx("span",{children:a.operation==="rebase"?i("正在同步源分支更新..."):i("正在提交变更...")})]}),t.jsxs("button",{onClick:()=>x.mutate(e),disabled:x.isPending,className:"flex items-center gap-1.5 ml-auto px-2.5 py-1 rounded-md text-xs text-muted-foreground hover:bg-muted border border-border transition-colors disabled:opacity-50",children:[t.jsx(md,{size:12}),x.isPending?i("正在撤销..."):i("撤销操作")]})]}),!d&&!f&&(a.behind>0||a.ahead>0)&&t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[a.behind>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:i("源分支 {branch} 有 {count} 个更新",{branch:r,count:a.behind})}),t.jsxs("button",{onClick:b,disabled:!k||c.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-primary-foreground bg-primary hover:bg-primary/90 transition-colors disabled:opacity-50",children:[t.jsx(ks,{size:12}),c.isPending?i("正在同步..."):i("同步更新")]})]}),a.ahead>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:i("{count} 个文件变更,可以安全提交",{count:p??a.ahead})}),a.behind===0&&!y?t.jsxs("button",{onClick:j,disabled:g.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-primary-foreground bg-primary hover:bg-primary/90 transition-colors disabled:opacity-50",children:[t.jsx(Vr,{size:12}),i("提交变更")]}):t.jsxs("button",{disabled:!0,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs text-muted-foreground/60 bg-muted/60 border border-border cursor-not-allowed",title:i(y?"需要先处理本地改动":"需要先同步源分支更新"),children:[t.jsx(Vr,{size:12}),i("提交变更")]})]})]})]})}),t.jsx(fc,{isOpen:S,onClose:L,branchName:s,targetBranch:r,commitMessage:o,isPending:g.isPending,error:l,onConfirm:R})]})}const Hi=50,$i=400,aa={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"},la={M:"bg-amber-500",A:"bg-emerald-500",D:"bg-red-500",R:"bg-blue-500"};function gc(e){const s=e.split("/");return s[s.length-1]||e}function Gv(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function Qv(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?xt("{count}s ago",{count:r}):r<3600?xt("{count}m ago",{count:Math.floor(r/60)}):r<86400?xt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?xt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function $r(e,s){return e.kind==="working"?`${e.diffType}:${s}`:`${e.hash}:${s}`}const un=({additions:e,deletions:s,className:r})=>e===void 0&&s===void 0?null:t.jsxs("span",{className:se("flex items-center gap-1 font-mono text-[11px] shrink-0",r),children:[e!==void 0&&e>0&&t.jsxs("span",{className:"text-emerald-600",children:["+",e]}),s!==void 0&&s>0&&t.jsxs("span",{className:"text-red-600",children:["-",s]}),(e??0)===0&&(s??0)===0&&t.jsx("span",{className:"text-muted-foreground/60",children:"0"})]}),Zv=({line:e,lineNum:s})=>{let r="",o="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?r="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?r="bg-destructive/10":e.startsWith("@@")?(r="bg-info/5",o="text-info"):(e.startsWith("diff ")||e.startsWith("index "))&&(o="text-muted-foreground/70"),t.jsxs("div",{className:se("flex",r),children:[t.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-muted-foreground/60 select-none border-r border-border/60",children:s}),t.jsx("span",{className:se("pl-2 whitespace-pre",o),children:e})]})},vc=({diff:e})=>{const{t:s}=le(),[r,o]=_.useState(!1),p=_.useMemo(()=>e.split(`
|
|
72
|
+
`),[e]);if(!e.trim())return t.jsx("div",{className:"py-6 text-center text-muted-foreground/70 text-xs",children:s("没有可显示的差异内容")});const m=!r&&p.length>$i,v=m?p.slice(0,$i):p;return t.jsxs("div",{className:"overflow-x-auto scrollbar-app-thin font-mono text-xs leading-5",children:[v.map((n,i)=>t.jsx(Zv,{line:n,lineNum:i+1},i)),m&&t.jsx("button",{type:"button",onClick:()=>o(!0),className:"w-full py-2 text-xs text-info hover:bg-info/5 transition-colors",children:s("还有 {count} 行变更被折叠,点击展开全部",{count:p.length-$i})})]})},Jv=({workingDir:e,path:s,diffType:r,enabled:o})=>{const{t:p}=le(),{data:m,isLoading:v,isError:n}=hc(e,o?s:null,r);return!o||v?t.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[t.jsx(We,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:p("正在加载差异...")})]}):n?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:p("差异加载失败")}):t.jsx(vc,{diff:m?.diff||""})},e0=({workingDir:e,hash:s,path:r,enabled:o})=>{const{t:p}=le(),{data:m,isLoading:v,isError:n}=Qn(e,o?s:null,o?r:null);return!o||v?t.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[t.jsx(We,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:p("正在加载差异...")})]}):n?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:p("差异加载失败")}):t.jsx(vc,{diff:m?.diff||""})},Ui=({entry:e,source:s,workingDir:r,flash:o,registerNode:p})=>{const[m,v]=_.useState(!1),[n,i]=_.useState(!1),a=_.useRef(null),u=$r(s,e.path);_.useEffect(()=>(p(u,a.current),()=>p(u,null)),[u,p]),_.useEffect(()=>{const x=a.current;if(!x||n)return;const S=new IntersectionObserver(w=>{w.some(l=>l.isIntersecting)&&(i(!0),S.disconnect())},{rootMargin:"300px 0px"});return S.observe(x),()=>S.disconnect()},[n]);const c=aa[e.status]||aa.M,g=Gv(e.path);return t.jsxs("div",{ref:a,"data-card-key":u,className:se("rounded-md border border-border bg-background overflow-hidden transition-shadow",o&&"ring-2 ring-info/40"),children:[t.jsxs("button",{type:"button",onClick:()=>v(x=>!x),className:"w-full flex items-center gap-2 px-3 py-2 bg-muted/40 hover:bg-muted/70 transition-colors text-left",children:[m?t.jsx(Mt,{size:13,className:"text-muted-foreground/70 shrink-0"}):t.jsx(wt,{size:13,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:se("w-4 h-4 flex items-center justify-center text-[11px] font-semibold border rounded-sm shrink-0",c),children:e.status}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:gc(e.path)}),g&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate",children:g}),t.jsx("span",{className:"ml-auto"}),t.jsx(un,{additions:e.additions,deletions:e.deletions})]}),!m&&t.jsx("div",{className:"border-t border-border/60",children:s.kind==="working"?t.jsx(Jv,{workingDir:r,path:e.path,diffType:s.diffType,enabled:n}):t.jsx(e0,{workingDir:r,hash:s.hash,path:e.path,enabled:n})})]})};function t0(e){const s={name:"",path:"",dirs:new Map,files:[]};for(const r of e){const o=r.path.split("/");let p=s;for(let m=0;m<o.length-1;m++){const v=o[m];p.dirs.has(v)||p.dirs.set(v,{name:v,path:p.path?`${p.path}/${v}`:v,dirs:new Map,files:[]}),p=p.dirs.get(v)}p.files.push(r)}return xc(s)}function xc(e){const s=new Map;for(const r of e.dirs.values()){let o=xc(r);for(;o.dirs.size===1&&o.files.length===0;){const p=[...o.dirs.values()][0];o={...p,name:`${o.name}/${p.name}`}}s.set(o.name,o)}return{...e,dirs:s}}const s0=({dir:e,depth:s,activeKey:r,onSelect:o})=>{const[p,m]=_.useState(!0);return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>m(v=>!v),className:"flex items-center gap-1.5 w-full px-2 py-1 rounded-sm hover:bg-muted/60 text-left",style:{paddingLeft:8+s*12},children:[p?t.jsx(li,{size:12,className:"text-muted-foreground/70 shrink-0"}):t.jsx(Rn,{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(bc,{node:e,depth:s+1,activeKey:r,onSelect:o})]})},bc=({node:e,depth:s,activeKey:r,onSelect:o})=>t.jsxs(t.Fragment,{children:[[...e.dirs.values()].sort((p,m)=>p.name.localeCompare(m.name)).map(p=>t.jsx(s0,{dir:p,depth:s,activeKey:r,onSelect:o},p.path)),e.files.slice().sort((p,m)=>p.path.localeCompare(m.path)).map(p=>{const m=r===p.cardKey;return t.jsxs("button",{type:"button",onClick:()=>o(p),className:se("flex items-center gap-1.5 w-full px-2 py-1 rounded-sm text-left",m?"bg-muted":"hover:bg-muted/60"),style:{paddingLeft:8+s*12},title:p.path,children:[t.jsx("span",{className:se("w-1.5 h-1.5 rounded-full shrink-0",la[p.status]||la.M)}),t.jsx("span",{className:se("text-xs truncate",m?"text-foreground font-medium":"text-foreground/90"),children:gc(p.path)})]},p.cardKey)})]}),r0=({workingDir:e,selectedHash:s,onSelectCommit:r})=>{const{t:o}=le(),{data:p,isLoading:m,fetchNextPage:v,hasNextPage:n,isFetchingNextPage:i}=An({queryKey:de.git.log(e),queryFn:({pageParam:u=0})=>Ce.get("/git/log",{params:{workingDir:e,limit:String(Hi),skip:String(u)}}),initialPageParam:0,getNextPageParam:(u,c)=>u.commits.length<Hi?void 0:c.length*Hi}),a=p?.pages.flatMap(u=>u.commits)||[];return m?t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 text-muted-foreground/70 text-[11px]",children:[t.jsx(We,{size:11,className:"animate-spin"}),t.jsx("span",{children:o("正在加载提交记录...")})]}):a.length===0?t.jsx("div",{className:"px-3 py-2 text-[11px] text-muted-foreground/60",children:o("暂无提交记录")}):t.jsxs("div",{className:"space-y-px px-1.5 pb-1.5",children:[a.map(u=>{const c=s===u.hash;return t.jsxs("button",{type:"button",onClick:()=>r(u),className:se("flex items-start gap-1.5 w-full px-1.5 py-1 rounded-sm text-left group",c?"bg-muted":"hover:bg-muted/60"),title:u.message,children:[t.jsx("span",{className:se("w-1.5 h-1.5 rounded-full mt-1.5 shrink-0 transition-colors",c?"bg-brand":"bg-border group-hover:bg-muted-foreground/60")}),t.jsxs("span",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:se("block text-xs truncate",c?"text-foreground font-medium":"text-foreground/90"),children:u.message}),t.jsxs("span",{className:"block text-[11px] text-muted-foreground/70 truncate",children:[t.jsx("span",{className:"font-mono",children:u.shortHash})," · ",u.author," · ",Qv(u.timestamp)]})]})]},u.hash)}),n&&t.jsx("button",{type:"button",onClick:()=>v(),disabled:i,className:"w-full py-1.5 text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted/60 rounded-sm transition-colors flex items-center justify-center gap-1.5",children:i?t.jsxs(t.Fragment,{children:[t.jsx(We,{size:11,className:"animate-spin"})," ",o("正在加载...")]}):o("加载更多提交")})]})},i0=({workingDir:e,workspaceId:s,branchName:r,targetBranch:o,commitMessage:p,canRunGitOperations:m,onRefreshCommitMessage:v,onConflict:n,onResolveConflicts:i})=>{const{t:a}=le(),[u,c]=_.useState({kind:"overview"}),[g,x]=_.useState(""),[S,w]=_.useState(null),[l,h]=_.useState(null),{data:d,isLoading:f,isError:y}=bi(e),C=u.kind==="commit"?u.commit.hash:null,{data:k,isLoading:E}=Gn(e,C),b=_.useRef(new Map),j=_.useRef(null),R=_.useRef(null),L=_.useCallback((B,z)=>{z?b.current.set(B,z):b.current.delete(B)},[]),{uncommitted:T,committed:D,commitFiles:F}=_.useMemo(()=>{const B=N=>!g.trim()||N.path.toLowerCase().includes(g.trim().toLowerCase());if(u.kind==="commit"){const N={kind:"commit",hash:u.commit.hash},W=(k?.files||[]).filter(B).map(X=>({...X,cardKey:$r(N,X.path)}));return{uncommitted:[],committed:[],commitFiles:W}}const z=(d?.uncommitted||[]).filter(B).map(N=>({...N,cardKey:$r({kind:"working",diffType:"uncommitted"},N.path)})),q=(d?.committed||[]).filter(B).map(N=>({...N,cardKey:$r({kind:"working",diffType:"committed"},N.path)}));return{uncommitted:z,committed:q,commitFiles:[]}},[u,d,k,g]),I=u.kind==="commit"?F:[...T,...D],H=_.useMemo(()=>t0(I),[I]),K=_.useMemo(()=>{let B=0,z=0;for(const q of I)B+=q.additions??0,z+=q.deletions??0;return{additions:B,deletions:z,files:I.length}},[I]),A=_.useCallback(()=>{const B=j.current;if(!B)return;const z=B.getBoundingClientRect().top;let q=null,N=Number.NEGATIVE_INFINITY;for(const[W,X]of b.current){const V=X.getBoundingClientRect().top-z;V<=48&&V>N&&(N=V,q=W)}if(!q){let W=null,X=Number.POSITIVE_INFINITY;for(const[V,ie]of b.current){const ee=ie.getBoundingClientRect().top-z;ee<X&&(X=ee,W=V)}q=W}w(q)},[]);_.useEffect(()=>{const B=j.current;if(!B)return;let z=0;const q=()=>{cancelAnimationFrame(z),z=requestAnimationFrame(A)};return B.addEventListener("scroll",q,{passive:!0}),()=>{B.removeEventListener("scroll",q),cancelAnimationFrame(z)}},[A]);const P=_.useCallback(B=>{const z=b.current.get(B.cardKey);z&&(z.scrollIntoView({behavior:"smooth",block:"start"}),w(B.cardKey),h(B.cardKey),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>h(null),1200))},[]),M=_.useCallback(B=>{c(z=>z.kind==="commit"&&z.commit.hash===B.hash?{kind:"overview"}:{kind:"commit",commit:B}),x(""),w(null),j.current?.scrollTo({top:0})},[]),O=_.useCallback(()=>{c({kind:"overview"}),x(""),w(null),j.current?.scrollTo({top:0})},[]);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm bg-background h-full",children:a("未选择工作区")});const $=m&&s&&r&&o,U=u.kind==="commit"?E:f;return t.jsxs("div",{className:"flex h-full w-full min-w-0 flex-col bg-background",children:[$&&n&&i&&t.jsx(pc,{workspaceId:s,branchName:r,targetBranch:o,commitMessage:p,committedFileCount:d?.committed?.length,onRefreshCommitMessage:v,onConflict:n,onResolveConflicts:i}),t.jsx("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border/60 shrink-0 min-h-[37px]",children:u.kind==="overview"?t.jsxs(t.Fragment,{children:[t.jsx(qs,{size:14,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:a("代码审查")}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:a("{count} 个文件",{count:K.files})}),t.jsx(un,{additions:K.additions,deletions:K.deletions}),r&&o&&t.jsxs("span",{className:"ml-auto flex items-center gap-1 text-[11px] text-muted-foreground/70 font-mono truncate",children:[t.jsx("span",{className:"truncate",children:r}),t.jsx(zs,{size:10,className:"rotate-180 shrink-0"}),t.jsx("span",{className:"truncate",children:o})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",onClick:O,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(zs,{size:12}),a("全部变更")]}),t.jsx("span",{className:"text-muted-foreground/40 text-xs",children:"/"}),t.jsx("span",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:u.commit.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate",children:u.commit.message}),t.jsx(un,{className:"ml-auto",additions:K.additions,deletions:K.deletions})]})}),t.jsxs("div",{className:"flex flex-1 min-h-0",children:[t.jsx("div",{ref:j,className:"flex-1 min-w-0 overflow-y-auto scrollbar-app-thin",children:U?t.jsx("div",{className:"p-3 space-y-3",children:[0,1].map(B=>t.jsxs("div",{className:"rounded-md border border-border overflow-hidden",children:[t.jsx("div",{className:"h-8 bg-muted/60 animate-pulse"}),t.jsxs("div",{className:"p-3 space-y-2",children:[t.jsx("div",{className:"h-3 w-2/3 bg-muted animate-pulse rounded-sm"}),t.jsx("div",{className:"h-3 w-1/2 bg-muted animate-pulse rounded-sm"}),t.jsx("div",{className:"h-3 w-3/4 bg-muted animate-pulse rounded-sm"})]})]},B))}):y&&u.kind==="overview"?t.jsx("div",{className:"flex-1 flex items-center justify-center py-16 text-destructive text-sm",children:a("变更加载失败")}):I.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted-foreground/60",children:[t.jsx(Xr,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:g.trim()?a("没有匹配筛选条件的文件"):u.kind==="commit"?a("该提交没有文件变更"):a("没有待审查的变更")})]}):u.kind==="commit"?t.jsx("div",{className:"p-3 space-y-3",children:F.map(B=>t.jsx(Ui,{entry:B,source:{kind:"commit",hash:u.commit.hash},workingDir:e,flash:l===B.cardKey,registerNode:L},B.cardKey))}):t.jsxs("div",{className:"p-3 space-y-4",children:[T.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-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:a("未提交")}),t.jsx("span",{className:"ml-2 text-[11px] text-muted-foreground/70",children:T.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:T.map(B=>t.jsx(Ui,{entry:B,source:{kind:"working",diffType:"uncommitted"},workingDir:e,flash:l===B.cardKey,registerNode:L},B.cardKey))})]}),D.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-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:a("已提交")}),t.jsx("span",{className:"ml-2 text-[11px] text-muted-foreground/70",children:D.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:D.map(B=>t.jsx(Ui,{entry:B,source:{kind:"working",diffType:"committed"},workingDir:e,flash:l===B.cardKey,registerNode:L},B.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.jsxs("div",{className:"relative",children:[t.jsx(yn,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground/60"}),t.jsx("input",{value:g,onChange:B=>x(B.target.value),placeholder:a("筛选文件..."),className:"w-full pl-6.5 pr-2 py-1.5 rounded-md border border-input bg-background text-xs text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2 focus:ring-ring/30 focus:border-ring"})]})}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin px-1.5 pb-1.5 min-h-0",children:I.length===0?t.jsx("div",{className:"px-2 py-3 text-[11px] text-muted-foreground/60",children:g.trim()?a("无匹配文件"):a("暂无变更文件")}):t.jsx(bc,{node:H,depth:0,activeKey:S,onSelect:P})}),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(Ws,{size:12,className:"text-muted-foreground"}),t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:a("提交记录")})]}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin min-h-0",children:t.jsx(r0,{workingDir:e,selectedHash:C,onSelectCommit:M})})]})]})]})]})},qi=50,ca={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"};function n0(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?xt("{count}s ago",{count:r}):r<3600?xt("{count}m ago",{count:Math.floor(r/60)}):r<86400?xt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?xt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function o0(e){const s=e.split("/");return s[s.length-1]||e}function a0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}const l0=({line:e,lineNum:s})=>{let r="",o="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?r="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?r="bg-destructive/10":e.startsWith("@@")?(r="bg-info/5",o="text-info"):(e.startsWith("diff ")||e.startsWith("index "))&&(o="text-muted-foreground/70"),t.jsxs("div",{className:se("flex",r),children:[t.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-muted-foreground/60 select-none border-r border-border/60",children:s}),t.jsx("span",{className:se("pl-2 whitespace-pre",o),children:e})]})},c0=({workingDir:e,hash:s,filePath:r})=>{const{t:o}=le(),{data:p,isLoading:m,isError:v}=Qn(e,s,r);if(m)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:[t.jsx(We,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(v)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive text-xs",children:o("Failed to load diff.")});const n=p?.diff||"";if(!n.trim())return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground/70 text-xs",children:o("No diff content available.")});const i=n.split(`
|
|
73
|
+
`);return t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin font-mono text-xs leading-5",children:i.map((a,u)=>t.jsx(l0,{line:a,lineNum:u+1},u))})},d0=({workingDir:e,hash:s,selectedPath:r,onSelectFile:o})=>{const{t:p}=le(),{data:m,isLoading:v}=Gn(e,s);if(v)return t.jsxs("div",{className:"pl-7 py-1 text-xs text-muted-foreground/70 flex items-center gap-1",children:[t.jsx(We,{size:12,className:"animate-spin"}),t.jsx("span",{children:p("Loading...")})]});const n=m?.files||[];return n.length===0?t.jsx("div",{className:"pl-7 py-1 text-xs text-muted-foreground/70",children:p("No files changed")}):t.jsx("div",{className:"pl-7 pb-1 space-y-0.5",children:n.map(i=>{const a=ca[i.status]||ca.M,u=a0(i.path);return t.jsxs("button",{type:"button",onClick:c=>{c.stopPropagation(),o(i.path)},className:se("flex items-center gap-2 px-1.5 py-1 rounded-sm cursor-pointer w-full text-left",r===i.path?"bg-muted":"hover:bg-muted/60"),children:[t.jsx("span",{className:se("w-4 h-4 flex items-center justify-center text-[11px] font-semibold border rounded-sm shrink-0",a),children:i.status}),t.jsx("span",{className:"text-xs text-foreground truncate",children:o0(i.path)}),u&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate ml-auto shrink-0",children:u})]},i.path)})})},u0=({workingDir:e})=>{const{t:s}=le(),r=Cs(E=>E.visibleContext),o=gf(e,r),{data:p,isLoading:m,isError:v,fetchNextPage:n,hasNextPage:i,isFetchingNextPage:a}=An({queryKey:de.git.log(e||""),queryFn:({pageParam:E=0})=>Ce.get("/git/log",{params:{workingDir:e||"",limit:String(qi),skip:String(E)}}),initialPageParam:0,getNextPageParam:(E,b)=>E.commits.length<qi?void 0:b.length*qi,enabled:!!e,refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1}),u=p?.pages.flatMap(E=>E.commits)||[],[c,g]=_.useState(null),[x,S]=_.useState(null),[w,l]=_.useState(280),[h,d]=_.useState(!1),f=_.useCallback(E=>{E.preventDefault(),d(!0);const b=E.clientX,j=w,R=T=>{const D=Math.min(480,Math.max(180,j+(T.clientX-b)));l(D)},L=()=>{d(!1),document.removeEventListener("mousemove",R),document.removeEventListener("mouseup",L)};document.addEventListener("mousemove",R),document.addEventListener("mouseup",L)},[w]),y=E=>{c===E?(g(null),S(null)):(g(E),S(null))},C=_.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:s("No workspace selected.")});if(m)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground bg-background h-full",children:[t.jsx(We,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading history...")})]});if(v)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive text-sm bg-background h-full",children:s("Failed to load history.")});if(u.length===0)return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-12 text-muted-foreground/60 bg-background h-full",children:[t.jsx(Ws,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:s("No commit history")})]});const k=u.find(E=>E.hash===c);return t.jsxs("div",{className:"flex h-full bg-background",style:h?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsxs("div",{className:"border-r border-border flex flex-col shrink-0",style:{width:w},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(Ws,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:s("History")}),t.jsx("span",{className:"text-[11px] bg-muted px-1.5 py-0.5 rounded-full text-muted-foreground",children:u.length})]})}),t.jsxs("div",{ref:C,className:"flex-1 overflow-auto scrollbar-app-thin p-1.5",children:[u.map(E=>{const b=c===E.hash;return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>y(E.hash),className:se("flex items-start gap-2 px-2 py-1.5 rounded-sm cursor-pointer w-full text-left group",b?"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:se("w-2 h-2 rounded-full shrink-0 transition-colors",b?"bg-brand":"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(Mt,{size:12,className:se("shrink-0 text-muted-foreground/70 transition-transform",b&&"rotate-90")})]}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:E.author}),t.jsx("span",{className:"text-[11px] text-muted-foreground/70",children:n0(E.timestamp)})]})]})]}),b&&t.jsxs(t.Fragment,{children:[E.body&&t.jsx("div",{className:"pl-7 pr-2 py-1.5 text-[11px] text-muted-foreground whitespace-pre-wrap leading-5 border-l-2 border-border ml-3",children:E.body}),t.jsx(d0,{workingDir:e,hash:E.hash,selectedPath:x,onSelectFile:S})]})]},E.hash)}),i&&t.jsx("button",{type:"button",onClick:()=>n(),disabled:a,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:a?t.jsxs(t.Fragment,{children:[t.jsx(We,{size:12,className:"animate-spin"})," ",s("Loading...")]}):s("Load more")})]})]}),t.jsx("div",{onMouseDown:f,className:se("w-1 shrink-0 cursor-col-resize transition-colors",h?"bg-info/60":"bg-transparent hover:bg-info/30")}),t.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:x&&c?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(Xr,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:x}),t.jsxs("span",{className:"text-[11px] text-muted-foreground/70",children:["(",k?.shortHash,")"]})]}),t.jsx(c0,{workingDir:e,hash:c,filePath:x})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground/60",children:t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(Xr,{size:28}),t.jsx("span",{className:"text-xs",children:s(c?"Select a file to view diff":"Select a commit to view changes")})]})})})]})},da=vr();function h0(e){if(!da)return e;try{const s=new URL(da);return new URL(e,s.origin).toString()}catch{return e}}function _c(e){return{...e,viewUrl:e.viewUrl?h0(e.viewUrl):null}}function f0(e,s=!0){return kt({queryKey:de.previews.status(e??""),queryFn:async()=>{const r=await Ce.get(`/previews/${e}/status`);return _c(r)},enabled:!!e&&s,refetchOnWindowFocus:!1})}function m0(e){const s=bt();return Bt({mutationFn:async r=>{const o=await Ce.put(`/previews/${e}/config`,{target:r});return _c(o)},onSuccess:r=>{e&&(s.setQueryData(de.previews.status(e),r),s.invalidateQueries({queryKey:de.workspaces.all}))}})}function p0(){return window.location.protocol==="https:"?"remote":"local"}function g0(e,s,r=!0){const[o,p]=_.useState(null),[m,v]=_.useState(!1),[n,i]=_.useState(null),[a,u]=_.useState(0);return _.useEffect(()=>{if(!r||!e||!s?.ready||!s.target){p(null),v(!1),i(null);return}let c=!1,g=null,x=null;p(null);const S=l=>{Ce.delete(`/previews/${e}/sessions/${l}`).catch(()=>{})};return(async()=>{v(!0),i(null);try{const l={mode:p0(),localHostname:window.location.hostname},h=await Ce.post(`/previews/${e}/sessions`,l);if(c){S(h.id);return}g=h.id,p(h),x=window.setInterval(async()=>{if(g)try{const d=await Ce.post(`/previews/${e}/sessions/${g}/heartbeat`);c||(p(d),i(null))}catch(d){!c&&d instanceof pn&&d.status===404?u(f=>f+1):c||i(d instanceof Error?d:new Error("Preview session heartbeat failed"))}},3e4)}catch(l){c||(p(null),i(l instanceof Error?l:new Error("Failed to open preview session")))}finally{c||v(!1)}})(),()=>{c=!0,x!==null&&window.clearInterval(x),g&&S(g)}},[r,a,s?.ready,s?.target,e]),{session:o,isOpening:m,error:n,retry:()=>u(c=>c+1)}}const v0="agent-tower-preview",x0="agent-tower-preview-host";function b0(){return"3000, localhost:3000, http://127.0.0.1:5173"}function _0(e){if(!e)return null;try{return new URL(e).origin}catch{return null}}function y0(e){return t.jsx(S0,{...e},e.workspaceId??"no-workspace")}function S0({workspaceId:e,readOnly:s,navigationRequest:r,onNavigationRequestHandled:o}){const{t:p}=le(),[m,v]=_.useState(null),i=!(r?.source.kind==="visualization")&&!m,{data:a,isLoading:u,refetch:c,isFetching:g}=f0(e,i),x=m0(e),{session:S,isOpening:w,error:l,retry:h}=g0(e,a,i),d=_.useRef(null),f=_.useRef(null),y=_.useRef(null),C=_.useRef(null),k=_.useRef(null),E=_.useRef(null),[b,j]=_.useState(0),[R,L]=_.useState({target:null,address:"",iframeSrc:null,isFrameLoading:!1}),T=_0(S?.viewUrl),D=a&&R.target!==a.target?{target:a.target,address:a.target??"",iframeSrc:null,isFrameLoading:!1}:a&&!a.ready&&R.iframeSrc?{...R,iframeSrc:null,isFrameLoading:!1}:R,F=_.useCallback(U=>{L(B=>({...a&&B.target!==a.target?{target:a.target,address:a.target??"",iframeSrc:null,isFrameLoading:!1}:B,...U}))},[a]);_.useEffect(()=>{if(!S||S.target!==a?.target)return;const U=k.current!==T;k.current=T,L(B=>{const z=r?.source.kind==="web"&&E.current!==r.id?Lr(r.source.url,S.target,S.viewUrl):null;if(!U&&B.iframeSrc&&B.target===S.target&&z?.kind!=="proxy")return B;let q=B.iframeSrc;if(z?.kind==="proxy")q=z.url;else if(!q||B.target!==S.target||U){const W=y.current;if(W)q=jd(S.viewUrl,W);else{const X=Lr(B.address||S.target,S.target,S.viewUrl);q=X?.kind==="proxy"?X.url:S.viewUrl}}y.current=null;const N=C.current;return N&&!N.closed&&q&&N.location.replace(q),C.current=null,{target:S.target,address:z?.kind==="proxy"?r?.source.kind==="web"?r.source.url:B.address:B.address||S.target,iframeSrc:q,isFrameLoading:!!q}})},[r,S,T,a?.target]),_.useEffect(()=>()=>{C.current?.close()},[]);const I=_.useCallback(async(U,B=!1)=>{const z=Lr(U,a?.target??null,S?.viewUrl??null);if(!z||!e)return;if(v(null),z.kind==="proxy"){if(B){window.open(z.url,"_blank","noopener,noreferrer");return}L({target:a?.target??null,address:U,iframeSrc:z.url,isFrameLoading:!0});return}if(s)return;const q=B?window.open("about:blank","_blank"):null;q&&(q.opener=null);try{y.current=z.path,C.current=q;const N=await x.mutateAsync(z.target);L({target:N.target,address:U.trim(),iframeSrc:null,isFrameLoading:!!N.ready}),j(W=>W+1),st.success(p("Preview target saved")),N.ready||(C.current?.close(),C.current=null)}catch(N){C.current?.close(),C.current=null,y.current=null;const W=N instanceof Error?N.message:p("Failed to save preview target");st.error(W)}},[S?.viewUrl,s,a?.target,p,x,e]);_.useEffect(()=>{if(!r||E.current===r.id||r.source.kind==="web"&&u)return;const U=window.setTimeout(()=>{E.current=r.id,o?.(r.id),r.source.kind==="visualization"?(v({source:r.source,iframeSrc:Nd(r.source.sessionId,r.source.file),isFrameLoading:!0}),j(B=>B+1)):(v(null),I(r.source.url))},0);return()=>window.clearTimeout(U)},[u,I,r,o]),_.useEffect(()=>{if(m)return;const U=B=>{if(B.source!==d.current?.contentWindow)return;const z=B.data;if(!(!z||z.source!==v0)){if(z.type==="location"&&typeof z.href=="string"){const q=Rd(a?.target??null,S?.viewUrl??null,z.href,window.location.href);q&&document.activeElement!==f.current&&F({target:a?.target??D.target,address:q,isFrameLoading:!1});return}z.type==="navigate-loopback"&&typeof z.href=="string"&&I(z.href,z.newTab===!0)}};return window.addEventListener("message",U),()=>window.removeEventListener("message",U)},[D.target,I,F,S?.viewUrl,a?.target,m]);const H=U=>{d.current?.contentWindow?.postMessage({source:x0,action:U},"*")},K=U=>{U.preventDefault(),I(D.address)},A=async()=>{if(m){v(B=>B&&{...B,isFrameLoading:!0}),j(B=>B+1);return}const U=await c();if(!U.data?.ready){F({target:U.data?.target??D.target,iframeSrc:null,isFrameLoading:!1});return}if(!S||!D.iframeSrc){h();return}F({isFrameLoading:!0}),H("reload")},P=()=>{if(m){window.open(m.iframeSrc,"_blank","noopener,noreferrer");return}if(!S?.viewUrl)return;const U=Lr(D.address||S.target,S.target,S.viewUrl),B=U?.kind==="proxy"?U.url:S.viewUrl;window.open(B,"_blank","noopener,noreferrer")};if(!e)return t.jsx("div",{className:"h-full flex items-center justify-center bg-white text-sm text-neutral-500",children:p("No active workspace.")});const M=m?.iframeSrc??D.iframeSrc,O=!!m,$=!O&&(u||g||x.isPending||w);return t.jsxs("div",{className:"h-full flex flex-col bg-white",children:[t.jsxs("div",{className:"shrink-0 border-b border-neutral-200 bg-neutral-50 px-2 py-2",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(Pe,{type:"button",size:"icon-sm",variant:"ghost",onClick:()=>{O?v(null):H("back")},disabled:!O&&!D.iframeSrc,title:p("Back"),"aria-label":p("Back"),children:t.jsx(zs,{})}),t.jsx(Pe,{type:"button",size:"icon-sm",variant:"ghost",onClick:()=>H("forward"),disabled:O||!D.iframeSrc,title:p("Forward"),"aria-label":p("Forward"),children:t.jsx(el,{})}),t.jsx(Pe,{type:"button",size:"icon-sm",variant:"ghost",onClick:!O&&D.isFrameLoading?()=>{H("stop"),F({isFrameLoading:!1})}:A,disabled:!O&&!D.isFrameLoading&&g,title:!O&&D.isFrameLoading?p("Stop loading"):p("Refresh preview"),"aria-label":!O&&D.isFrameLoading?p("Stop loading"):p("Refresh preview"),children:!O&&D.isFrameLoading?t.jsx(Zt,{}):g?t.jsx(We,{className:"animate-spin"}):t.jsx(ks,{})}),t.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:K,children:[t.jsx(tu,{className:"pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-neutral-400"}),t.jsx("input",{ref:f,value:m?.source.file??D.address,onChange:U=>F({address:U.target.value}),onKeyDown:U=>{U.key==="Enter"&&U.nativeEvent.isComposing&&U.preventDefault()},disabled:O||s||x.isPending,placeholder:b0(),"aria-label":p("Preview address"),className:"h-8 w-full min-w-0 rounded-md border border-neutral-200 bg-white pl-8 pr-2.5 text-xs text-neutral-800 outline-none transition-colors placeholder:text-neutral-400 focus:border-neutral-400 disabled:bg-neutral-100 disabled:text-neutral-400"})]}),t.jsx(Pe,{type:"button",size:"icon-sm",variant:"ghost",onClick:P,disabled:!M,title:p("Open preview in new tab"),"aria-label":p("Open preview in new tab"),children:t.jsx(mn,{})})]}),t.jsxs("div",{className:"mt-1 flex min-h-4 items-center justify-between gap-2 px-1 text-[11px] leading-4",children:[t.jsx("span",{className:"truncate text-neutral-500",children:O?p("Viewing agent visualization"):$?p("Checking preview target..."):l?l.message:a?.ready?`${p("Proxying")} ${a.target}`:a?.configured?`${p("Preview target is not reachable")}${a.error?`: ${a.error}`:""}`:p("Enter a local preview URL on the Agent Tower machine.")}),t.jsx("span",{className:"shrink-0 text-neutral-400",children:p(O?"Session file":"Loopback only")})]})]}),t.jsx("div",{className:"relative flex-1 min-h-0 bg-white",children:M?t.jsx("iframe",{ref:d,src:M,title:p("Preview"),className:"absolute inset-0 h-full w-full border-0 bg-white",sandbox:O?"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:()=>{O?v(U=>U&&{...U,isFrameLoading:!1}):F({isFrameLoading:!1})}},b):t.jsx("div",{className:"absolute inset-0 flex items-center justify-center px-4 text-center text-sm text-neutral-500",children:a?.configured?a.ready&&w?p("Checking preview target..."):p("Start the preview server, then refresh."):p("Configure a local preview target to display it here.")})})]})}function w0(e){switch(e){case At.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case At.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case At.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case At.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function ua(e){switch(e){case"Main":return"border-indigo-200 bg-indigo-50 text-indigo-700";case"Child":return"border-cyan-200 bg-cyan-50 text-cyan-700";default:return"border-neutral-200 bg-neutral-50 text-neutral-600"}}function C0(e){return e.length<=34?e:`...${e.slice(-31)}`}function yc({workspaces:e,teamRun:s,selectedWorkspaceId:r,onSelectWorkspace:o,disabled:p,className:m,buttonClassName:v}){const{t:n}=le(),[i,a]=_.useState(!1),u=_.useRef(null),c=_.useMemo(()=>qn(e,s),[e,s]),g=c.find(x=>x.workspace.id===r)??c[0];return _.useEffect(()=>{if(!i)return;const x=S=>{u.current&&!u.current.contains(S.target)&&a(!1)};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[i]),c.length<=1?null:t.jsxs("div",{ref:u,className:se("relative",m),children:[t.jsxs("button",{type:"button",onClick:()=>a(x=>!x),disabled:p,className:se("inline-flex h-8 max-w-[340px] items-center gap-2 rounded-md border border-neutral-200 bg-white px-2.5 text-left text-xs text-neutral-700 transition-colors hover:border-neutral-300 hover:bg-neutral-50 disabled:cursor-not-allowed disabled:opacity-50",v),title:n("Workspace"),children:[t.jsx(Fs,{size:14,className:"shrink-0 text-neutral-500"}),t.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",ua(g.roleLabel)),children:n(g.roleLabel)}),t.jsx("span",{className:"min-w-0 truncate font-medium text-neutral-900",children:n(g.displayName)}),t.jsx("span",{className:"min-w-0 truncate font-mono text-[11px] text-neutral-500",children:C0(Hs(g.workspace))}),t.jsx(wt,{size:13,className:se("shrink-0 text-neutral-400 transition-transform",i&&"rotate-180")})]}),i&&t.jsx("div",{className:"absolute left-0 top-full z-50 mt-2 w-[420px] max-w-[calc(100vw-2rem)] rounded-lg border border-neutral-200 bg-white py-1.5 shadow-lg",children:c.map(x=>{const S=x.workspace.id===g.workspace.id;return t.jsxs("button",{type:"button",onClick:()=>{o(x.workspace.id),a(!1)},className:se("flex w-full items-start gap-2 px-3 py-2 text-left transition-colors hover:bg-neutral-50",S&&"bg-neutral-50"),children:[t.jsx("div",{className:"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-md border border-neutral-200 bg-white text-neutral-500",children:S?t.jsx(Jt,{size:13}):t.jsx(Ua,{size:13})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:n(x.displayName)}),t.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",ua(x.roleLabel)),children:n(x.roleLabel)}),t.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",w0(x.workspace.status)),children:x.workspace.status})]}),t.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-neutral-500",children:Hs(x.workspace)}),t.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[x.ownerName&&t.jsxs("span",{children:[n("Owner"),": ",x.ownerName]}),x.parentBranchName&&t.jsxs("span",{children:[n("Parent"),": ",x.parentBranchName]}),t.jsx("span",{children:x.workspace.id.slice(0,8)})]})]})]},x.workspace.id)})})]})}const k0=[{key:"review",label:"Changes",icon:t.jsx(qs,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(ai,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(or,{size:14})},{key:"preview",label:"Preview",icon:t.jsx($a,{size:14})}],E0=[{key:"history",label:"History",icon:t.jsx(Ws,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(ai,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(or,{size:14})},{key:"preview",label:"Preview",icon:t.jsx($a,{size:14})}],j0=({active:e,onClick:s,icon:r,label:o})=>t.jsxs("button",{type:"button",onClick:s,className:se("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",e?"bg-white border-neutral-200 text-neutral-900 shadow-[0_-2px_6px_rgba(0,0,0,0.02)] z-10":"bg-transparent border-transparent text-neutral-500 hover:text-neutral-700 hover:bg-neutral-200/50"),children:[r,t.jsx("span",{children:o})]}),N0=({active:e,onClick:s,icon:r,label:o})=>t.jsx("button",{type:"button",onClick:s,title:o,"aria-label":o,"aria-pressed":e,className:se("flex h-9 w-9 items-center justify-center rounded-lg border text-muted-foreground transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",e?"border-neutral-900 bg-neutral-900 text-white shadow-sm":"border-transparent hover:border-border hover:bg-background hover:text-foreground"),children:r}),Sc=ae.memo(function({className:s,sessionId:r,workspaceId:o,workingDir:p,projectId:m,hideChanges:v,gitAvailable:n=!0,readOnly:i,repoDeleted:a,teamRun:u,teamStatus:c,gitProps:g,workspaces:x,selectedWorkspaceId:S,onSelectWorkspace:w,variant:l="tabs",expanded:h,onExpandedChange:d,minContentWidth:f=520,tabRef:y,previewRequest:C,onPreviewRequestHandled:k}){const{t:E}=le(),b=Cs(G=>G.setVisibleContext),j=l==="rail",[R,L]=_.useState(!1),T=j?h??R:!0,D=_.useCallback(G=>{h===void 0&&L(G),d?.(G)},[h,d]),F=_.useMemo(()=>{const G=v?E0:k0,ge=n?G:G.filter(Re=>Re.key!=="review"&&Re.key!=="history"),ne=i?ge.filter(Re=>Re.key!=="terminal"):ge;return u?[{key:"team-status",label:"Team Status",icon:t.jsx(Ss,{size:14})},...ne]:ne},[n,v,i,u]),[I,H]=_.useState(()=>C?"preview":n?v?"history":"review":"editor"),K=_.useRef(null),A=_.useRef(0),[P,M]=_.useState(),O=_.useCallback(G=>{H(G),j&&D(!0)},[j,D]);_.useImperativeHandle(y,()=>({setTab:G=>O(G),openFile:(G,ge,ne)=>{O("editor"),requestAnimationFrame(()=>K.current?.openFile(G,ge,ne))},openPreview:(G,ge)=>{A.current+=1,M({id:A.current,source:G,workspaceId:ge}),O("preview")}}),[O]);const $=C??P,U=$?.workspaceId&&$.workspaceId!==o?void 0:$,B=_.useCallback(G=>{M(ge=>ge?.id===G?void 0:ge),k?.(G)},[k]),{data:z}=zd(m??""),q=_.useMemo(()=>{if(!z?.quickCommands)return[];try{return JSON.parse(z.quickCommands)}catch{return[]}},[z?.quickCommands]),[N,W]=_.useState([]),X=_.useRef(void 0);_.useEffect(()=>{p&&p!==X.current&&(X.current=p,W(G=>G.includes(p)?G:[...G,p]))},[p]),_.useEffect(()=>{F.some(G=>G.key===I)||H(F[0]?.key??"editor")},[I,F]),_.useEffect(()=>{if(j&&!T)return;const G=I==="review"?"changes":I==="history"?"history":null;if(!o||!p||!G){b(null);return}return b({workspaceId:o,workingDir:p,tab:G}),()=>{b(null)}},[I,T,j,b,p,o]);const V=!!w&&qn(x,u).length>1,ie=F.find(G=>G.key===I)??F[0],ee=ie?E(ie.label):"",pe=i?t.jsx("div",{className:"mx-2 mt-2 rounded-lg border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:E(a?"项目已删除且本地仓库文件已清理。这里只保留历史视图。":"项目已删除。Workspace 以只读模式展示历史内容。")}):null,he=t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[V&&t.jsx("div",{className:"shrink-0 px-3 py-1.5 border-b border-neutral-100 bg-neutral-50/60",children:t.jsx(yc,{workspaces:x,teamRun:u,selectedWorkspaceId:S,onSelectWorkspace:w,buttonClassName:"h-7 text-[11px]"})}),t.jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[I==="team-status"&&u&&c,I==="editor"&&t.jsx(Yv,{ref:K,workingDir:p,readOnly:i}),N.map(G=>{const ge=I==="terminal"&&p===G;return t.jsx("div",{"aria-hidden":!ge,className:"absolute inset-0 h-full w-full min-h-0 min-w-0 overflow-hidden",style:{display:ge?"block":"none"},children:t.jsx(ap,{cwd:G,workspaceId:ge?o:void 0,isVisible:ge,quickCommands:q})},G)}),I==="preview"&&t.jsx(y0,{workspaceId:o,readOnly:i,navigationRequest:U,onNavigationRequestHandled:B}),I==="review"&&t.jsx(i0,{workingDir:p,workspaceId:o,branchName:g?.branchName,targetBranch:g?.targetBranch,commitMessage:g?.commitMessage,canRunGitOperations:g?.canRunGitOperations,onRefreshCommitMessage:g?.onRefreshCommitMessage,onConflict:g?.onConflict,onResolveConflicts:g?.onResolveConflicts}),I==="history"&&t.jsx(u0,{workingDir:p})]})]});return j?t.jsxs("div",{className:se("flex h-full w-full min-w-0 bg-white",s),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:F.map(G=>t.jsx(N0,{active:T&&I===G.key,onClick:()=>O(G.key),icon:G.icon,label:E(G.label)},G.key))}),T&&t.jsxs("div",{className:"flex h-full min-w-0 flex-1 flex-col border-l border-border bg-background",style:{minWidth:f},children:[pe,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:ie?.icon}),t.jsx("span",{className:"truncate",children:ee})]}),t.jsx("button",{type:"button",onClick:()=>D(!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:E("收起"),"aria-label":E("收起"),children:t.jsx(xu,{size:15})})]}),he]})]}):t.jsxs("div",{className:se("flex h-full w-full min-w-0 flex-col bg-white",s),children:[i&&pe,t.jsx("div",{className:"flex items-center overflow-x-auto scrollbar-app-thin px-2 pt-2 border-b border-neutral-200 bg-neutral-100/80 shrink-0 gap-1 select-none",children:F.map(G=>t.jsx(j0,{active:I===G.key,onClick:()=>O(G.key),icon:G.icon,label:E(G.label)},G.key))}),he]})}),ha=1500,R0=3e3;function A0(e){const[s,r]=_.useState(null),o=_.useRef(0),p=_.useRef(null),m=_.useRef(null);return _.useEffect(()=>{if(!e)return;const v=()=>{m.current&&(clearTimeout(m.current),m.current=null)},n=rs.connect(),i=u=>{r(u),m.current=setTimeout(()=>r(null),R0)},a=u=>{if(u.taskId!==e)return;const c={status:u.status,currentCommand:u.currentCommand,currentIndex:u.currentIndex,totalCommands:u.totalCommands,error:u.error};if(u.status==="running"){v(),p.current=null,o.current===0&&(o.current=Date.now()),r(c);return}const g=o.current>0?Date.now()-o.current:0,x=ha-g;o.current===0?(o.current=Date.now(),r({status:"running",totalCommands:u.totalCommands,currentIndex:u.totalCommands}),p.current=c,m.current=setTimeout(()=>i(c),ha)):x>0?(p.current=c,v(),m.current=setTimeout(()=>i(c),x)):i(c)};return n.on(lt.WORKSPACE_SETUP_PROGRESS,a),()=>{n.off(lt.WORKSPACE_SETUP_PROGRESS,a),v(),o.current=0,p.current=null}},[e]),s}function wc({isOpen:e,onClose:s,onStarted:r,taskId:o,projectId:p,taskTitle:m,taskDescription:v,taskPrompt:n,projectIsGitRepo:i=!0,projectWorktreeReady:a=!0,projectGitReason:u}){const{t:c}=le(),[g,x]=_.useState(""),[S,w]=_.useState(""),[l,h]=_.useState(_t.WORKTREE),[d,f]=_.useState(null),[y,C]=_.useState("idle"),[k,E]=_.useState(null),b=bt(),j=El(o),R=Cn(),L=Wd(),{data:T,isLoading:D}=Us(),F=d?.isGitRepo??i,I=d?.worktreeReady??a,H=d?.reason??u,K=F!==!1&&I!==!1;_.useEffect(()=>{if(!e||!T)return;const N=T.find(W=>W.availability.type!=="NOT_FOUND");N&&x(N.provider.id)},[e,T]),_.useEffect(()=>{if(e){const N=[m];v&&N.push(v),w(n?.trim()||N.join(`
|
|
74
|
+
|
|
75
|
+
`)),f(null),h(i!==!1&&a!==!1?_t.WORKTREE:_t.MAIN_DIRECTORY),C("idle"),E(null)}},[e,i,a,o,m,v,n]),_.useEffect(()=>{K||h(_t.MAIN_DIRECTORY)},[K]);const A=async()=>{if(!p||L.isPending)return;const N=await L.mutateAsync({id:p});f(N),N.worktreeReady&&h(_t.WORKTREE)},P=y!=="idle",M=async()=>{if(!(!g||!S.trim())){E(null);try{C("creating-workspace");const N=await j.mutateAsync({workspaceKind:K?l:_t.MAIN_DIRECTORY});C("creating-session");const W=await Ce.post(`/workspaces/${N.id}/sessions`,{providerId:g,prompt:S.trim()});C("starting-session"),await R.mutateAsync(W.id),await b.invalidateQueries({queryKey:de.workspaces.list(o)}),C("idle"),r?.(),s()}catch(N){C("idle"),E(N instanceof Error?N.message:c("启动失败,请重试"))}}},O={idle:c("启动"),"creating-workspace":c("创建工作空间..."),"creating-session":c("创建会话..."),"starting-session":c("启动 Agent...")},$=(T??[]).map(({provider:N,availability:W})=>{const X=W.type!=="NOT_FOUND";return{value:N.id,label:X?N.name:`${N.name}${c(" (不可用)")}`,icon:t.jsx(oi,{agentType:N.agentType,className:"size-4"}),disabled:!X}}),U=c("工作树隔离改动,支持 TeamRun、Merge、Rebase 和冲突解决。"),B=c("本地模式会直接修改项目主目录,不会自动提交,也不能使用 Merge、Rebase 或冲突解决。"),z=c(H==="NO_HEAD"?"已检测到 Git,但需要先提交一次才能使用工作树模式。":"非 Git 项目只能使用本地模式。"),q=[{value:_t.WORKTREE,label:c("工作树模式"),description:U,disabled:!K},{value:_t.MAIN_DIRECTORY,label:c("本地模式"),description:B}];return t.jsx(ds,{isOpen:e,onClose:P?()=>{}:s,title:c("启动 Agent"),action:t.jsxs(t.Fragment,{children:[t.jsx(Pe,{variant:"outline",onClick:s,disabled:P,children:c("取消")}),t.jsx(Pe,{onClick:M,disabled:P||!g||!S.trim(),children:O[y]})]}),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-neutral-700 mb-2",children:c("Agent")}),t.jsx(is,{value:g,onChange:x,options:$,placeholder:c(D?"加载中...":"选择 Agent"),disabled:P||D})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:c("模式")}),K?t.jsx(is,{value:l,onChange:N=>h(N),options:q,disabled:P}):t.jsx(Ad,{side:"bottom",className:"w-full",content:z,children:t.jsxs("div",{tabIndex:0,"aria-label":z,className:"rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[t.jsx(is,{value:l,onChange:N=>h(N),options:q,disabled:!0}),t.jsx("button",{type:"button",onClick:A,disabled:P||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?c("检测中..."):c("重新检测 Git 状态")})]})})]})]})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:c("任务描述")}),t.jsx("textarea",{value:S,onChange:N=>w(N.target.value),rows:5,disabled:P,placeholder:c("描述你想让 Agent 完成的任务..."),className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm text-neutral-900 placeholder-neutral-400 focus:outline-none focus:ring-1 focus:ring-neutral-300 focus:border-neutral-300 resize-none disabled:opacity-50 disabled:bg-neutral-50"})]}),k&&t.jsx("div",{className:"text-sm text-red-600 bg-red-50 border border-red-100 rounded-lg px-3 py-2",children:k})]})})}function Cc(e){const s=e?.tokenUsage;if(!(!s||typeof s.totalTokens!="number"))return s}function T0(e,s,r){const o=e?.providerId??r?.providerId??null,p=o?s?.find(i=>i.provider.id===o)?.provider:null,m=p?.name??o??e?.agentType??r?.agentType??null;if(!m)return null;const v=e?.agentType??p?.agentType??r?.agentType??null,n=o&&p?.name&&o!==p.name?`${p.name} (${o})`:m;return{label:m,title:n,agentType:v}}function kc({session:e,providers:s,usage:r,compact:o=!1,providerIdFallback:p,agentTypeFallback:m,tokenTooltipSide:v="top"}){const{t:n}=le(),i=T0(e,s,{providerId:p,agentType:m});return!i&&!r?null:t.jsxs("div",{className:`flex shrink-0 items-center ${o?"gap-1":"gap-2"}`,children:[i&&t.jsxs("div",{className:`flex shrink-0 items-center rounded-lg text-neutral-500 ${o?"max-w-[130px] min-w-[82px] gap-1 px-1.5 py-1 text-[11px]":"max-w-[220px] min-w-[110px] gap-1.5 px-2 py-1.5 text-xs"}`,title:`${n("Provider")}: ${i.title}`,children:[t.jsx(oi,{agentType:i.agentType,className:o?"size-3":"size-3.5"}),t.jsx("span",{className:"min-w-0 truncate",children:pd(i.label,o?12:18)})]}),t.jsx(kn,{usage:r,tooltipSide:v})]})}function M0({isOpen:e,onClose:s,taskId:r}){const{t:o}=le(),[p,m]=_.useState("AUTO"),[v,n]=_.useState(null),[i,a]=_.useState([]),[u,c]=_.useState(null),g=Ta();_.useEffect(()=>{e&&(m("AUTO"),n(null),a([]),c(null))},[e]);const x=g.isPending,S=!!v||i.length>0,w=async()=>{if(!x){if(!v&&i.length===0){c(o("请选择至少一个团队模板或成员预设。"));return}c(null);try{await g.mutateAsync({taskId:r,mode:p,...v?{teamTemplateId:v}:{},...i.length>0?{memberPresetIds:i}:{}}),s()}catch(h){if(h instanceof pn&&h.status===409){c(o("该任务已经存在 TeamRun。请刷新后再试。"));return}c(h instanceof Error?h.message:o("创建 TeamRun 失败"))}}},l=x||!S;return t.jsxs(ds,{isOpen:e,onClose:x?()=>{}:s,title:o("创建 TeamRun"),className:"max-w-5xl",action:t.jsxs(t.Fragment,{children:[t.jsx(Pe,{type:"button",variant:"outline",onClick:s,disabled:x,children:o("取消")}),t.jsx(Pe,{type:"button",onClick:w,disabled:l,children:o(x?"处理中...":"创建 TeamRun")})]}),children:[t.jsx(Dd,{mode:p,setMode:m,selectedTemplateId:v,setSelectedTemplateId:n,selectedMemberPresetIds:i,setSelectedMemberPresetIds:a,disabled:x}),u&&t.jsx("div",{role:"alert",className:"rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700",children:u})]})}function D0({workspaceId:e,gitStatus:s,onResolve:r}){const{t:o}=le(),p=Hn();if(s.operation==="idle"||s.conflictedFiles.length===0)return null;const m=s.operation==="rebase"?"Rebase":"Merge";return t.jsxs("div",{className:"mx-6 mt-3 flex items-center gap-3 rounded-lg border border-warning/25 bg-warning/[0.06] px-4 py-2.5",children:[t.jsx($s,{size:15,className:"text-warning shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:[t.jsxs("span",{className:"text-sm font-medium text-foreground",children:[m," ",o("冲突")]}),t.jsxs("span",{className:"inline-flex items-center rounded-full bg-warning/15 px-2 py-0.5 text-xs font-semibold text-warning tabular-nums",children:[s.conflictedFiles.length," ",o("个文件")]})]}),t.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[t.jsx(Pe,{variant:"ghost",size:"sm",onClick:()=>p.mutate(e),disabled:p.isPending,className:"text-muted-foreground hover:text-foreground",children:o("中止操作")}),t.jsx(Pe,{size:"sm",onClick:r,children:o("解决冲突")})]})]})}function Ec(e){return e.length>0?e.map(s=>`- ${s}`).join(`
|
|
76
|
+
`):"- 未获取到冲突文件列表"}function jc(e){if(!e)return[];const s=[];return e.workspaceId&&s.push(`- Workspace: \`${e.workspaceId}\``),e.worktreePath&&s.push(`- Worktree: \`${e.worktreePath}\``),e.sourceWorkspaceId&&s.push(`- Source workspace: \`${e.sourceWorkspaceId}\``),e.targetWorkspaceId&&s.push(`- Target workspace: \`${e.targetWorkspaceId}\``),e.sourceWorktreePath&&s.push(`- Source worktree: \`${e.sourceWorktreePath}\``),e.targetWorktreePath&&s.push(`- Target worktree: \`${e.targetWorktreePath}\``),e.operation&&e.operation!=="idle"&&s.push(`- Git 状态: \`${e.operation}\``),e.mergeStrategy&&s.push(`- Merge strategy: \`${e.mergeStrategy}\``),e.mergeAborted&&s.push("- Merge state: conflict detected and already aborted by Agent Tower"),s}function P0(e,s){if(!s?.mergeAborted)return["1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git commit` 完成合并"];const r=s.mergeStrategy==="squash"?`git merge --squash --no-commit ${e}`:`git merge --no-ff ${e}`,o=s.mergeStrategy==="squash"?"`git commit`":"`git merge --continue` 或 `git commit`";return["1. 注意:Agent Tower 检测到 merge 冲突后已经执行 abort,当前不要假设存在冲突标记或 `MERGE_HEAD`","2. 切换到 Target worktree / Target branch 上下文,确认工作区干净",`3. 重新执行 \`${r}\` 复现冲突`,"4. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","5. 对每个已解决的文件执行 `git add <file>`",`6. 执行 ${o} 完成合并`]}function L0(e){if(!e.mergeAborted)return"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 merge 提交,然后说明处理结果。";const s=e.targetWorktreePath?`目标 worktree \`${e.targetWorktreePath}\``:`目标分支 \`${e.targetBranch}\``,r=e.mergeStrategy==="squash"?`git merge --squash --no-commit ${e.sourceBranch}`:`git merge --no-ff ${e.sourceBranch}`;return`Agent Tower 已在检测到冲突后 abort 了 merge;请在${s}中确认工作区干净,重新执行 \`${r}\` 复现冲突,解决后完成提交并汇报验证结果。`}function I0(e,s,r,o,p){const m=Ec(r),v=jc(p);return o===ur.REBASE?["## Rebase 冲突解决","",`在将分支 \`${e}\` rebase 到 \`${s}\` 时发生了冲突。`,...v.length>0?["","### 上下文",...v]:[],"","### 冲突文件",m,"","### 解决步骤","1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git rebase --continue` 继续 rebase 流程"].join(`
|
|
77
|
+
`):["## Merge 冲突解决","",`在将分支 \`${e}\` 合并到 \`${s}\` 时发生了冲突。`,...v.length>0?["","### 上下文",...v]:[],"","### 冲突文件",m,"","### 解决步骤",...P0(e,p)].join(`
|
|
78
|
+
`)}function O0(e){const s=e.conflictOp===ur.REBASE?"Rebase":"Merge",r=Ec(e.conflictedFiles),o=[...jc(e),`- Source branch: \`${e.sourceBranch}\``,`- Target branch: \`${e.targetBranch}\``,`- Conflict type: \`${e.conflictOp}\``];return[`## 请求处理 ${s} 冲突`,"",`用户点击了“AI 辅助解决”,请在对应 workspace 中处理当前 ${s} 冲突,并在 Team Room 汇报处理结果和验证情况。`,"","### 上下文",...o,"","### 冲突文件",r,"","### 用户意图",e.conflictOp===ur.REBASE?"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 `git rebase --continue`,然后说明处理结果。":L0(e)].join(`
|
|
79
|
+
`)}function B0(e){if(e.teamRunId)return{type:"team_room",message:O0(e)};const s=e.currentSessionId||e.selectedSessionId;return s?{type:"session",sessionId:s,message:I0(e.sourceBranch,e.targetBranch,e.conflictedFiles,e.conflictOp,e)}:{type:"none"}}function Nc({open:e,onOpenChange:s,workspaceId:r,conflictOp:o,conflictedFiles:p,sourceBranch:m,targetBranch:v,operation:n,worktreePath:i,mergeAborted:a,mergeStrategy:u,sourceWorkspaceId:c,targetWorkspaceId:g,sourceWorktreePath:x,targetWorktreePath:S,sessions:w,currentSessionId:l,teamRunId:h}){const{t:d}=le(),[f,y]=_.useState(""),C=En(),k=gn(h??""),E=zn(),b=!!h,j=l||f,R=b?k.isPending:C.isPending,L=()=>{const H=B0({workspaceId:r,worktreePath:i,operation:n,mergeAborted:a,mergeStrategy:u,sourceWorkspaceId:c,targetWorkspaceId:g,sourceWorktreePath:x,targetWorktreePath:S,sourceBranch:m,targetBranch:v,conflictedFiles:p,conflictOp:o,teamRunId:h,currentSessionId:l,selectedSessionId:f});if(H.type==="team_room"){k.mutate({content:H.message,kind:"chat"},{onSuccess:()=>{st.success(d("已发送到 Team Room")),s(!1)}});return}H.type==="session"&&C.mutate({id:H.sessionId,message:H.message},{onSuccess:()=>s(!1)})},T=()=>{E.mutate({workspaceId:r},{onSuccess:()=>s(!1)})},D=o==="REBASE"?"Rebase":"Merge",F=!b&&!l&&w.length>0,I=b||!!j;return t.jsx(ds,{isOpen:e,onClose:()=>s(!1),title:d("解决 {opLabel} 冲突",{opLabel:D}),action:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Pe,{variant:"outline",onClick:T,children:d("在 IDE 中打开")}),t.jsx(Pe,{onClick:L,disabled:!I||R,children:d(R?"发送中...":"AI 辅助解决")})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:d("冲突文件({count})",{count:p.length})}),t.jsx("div",{className:"max-h-40 overflow-y-auto rounded-md border border-neutral-200 bg-neutral-50",children:p.map(H=>t.jsx("div",{className:"px-3 py-1.5 text-xs font-mono text-neutral-700 border-b border-neutral-100 last:border-b-0",children:H},H))})]}),b&&t.jsx("div",{className:"rounded-md border border-blue-100 bg-blue-50 px-3 py-2 text-sm text-blue-800",children:d("TeamRun 模式下会把处理冲突请求发送到 Team Room,由团队调度处理。")}),F&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:d("选择 Session(AI 辅助解决)")}),t.jsxs("select",{value:f,onChange:H=>y(H.target.value),className:"w-full px-3 py-2 text-sm border border-neutral-200 rounded-md bg-white focus:outline-none focus:ring-2 focus:ring-neutral-300",children:[t.jsx("option",{value:"",children:d("选择一个 Session...")}),w.map(H=>t.jsxs("option",{value:H.id,children:[H.agentType," — ",H.status]},H.id))]})]}),!b&&!j&&w.length===0&&t.jsx("p",{className:"text-sm text-neutral-500",children:d("没有可用的 Session,请在 IDE 中手动解决冲突。")})]})})}function F0(e){return[...e?.uncommitted??[],...e?.committed??[]].reduce((r,o)=>({files:r.files+1,additions:r.additions+(o.additions??0),deletions:r.deletions+(o.deletions??0)}),{files:0,additions:0,deletions:0})}function fa(e,s,r,o){const p=mc(e);if(p){r(p);return}o(e instanceof Error?e.message:s)}function Rc({workspaceId:e,branchName:s,targetBranch:r,commitMessage:o,changes:p,gitStatus:m,isGitStatusLoading:v,canRunGitOperations:n,onOpenChanges:i,onRefreshCommitMessage:a,onConflict:u,className:c}){const{t:g}=le(),x=Nl(),S=jl(),w=Hn(),[l,h]=_.useState(!1),[d,f]=_.useState(null),y=_.useMemo(()=>F0(p),[p]),C=y.additions+y.deletions,k=y.files>0&&C>0,E=(m?.conflictedFiles.length??0)>0,b=!!(m&&m.operation!=="idle"),j=!!(m&&(m.hasUncommittedChanges||m.untrackedCount>0)),R=(m?.uncommittedCount??0)+(m?.untrackedCount??0),L=(m?.behind??0)>0,T=(m?.ahead??0)>0,D=v||!m&&n,F=!!(n&&e&&m&&L&&!E&&!b&&!j),I=!!(n&&e&&m&&T&&!L&&!E&&!b&&!j);if(_.useEffect(()=>{l&&a?.()},[l,a]),!k)return null;const H=E?g("冲突"):m?.operation==="rebase"?g("变基中"):m?.operation==="merge"?g("合并中"):R>0?g("{count} 未提交",{count:R}):L?g("落后 {count}",{count:m?.behind??0}):g(T?"可合并":"已是最新"),K=g("{files} 个文件 · {lines} 行",{files:y.files,lines:C}),A=()=>{F&&(f(null),x.mutate(e,{onError:$=>{fa($,g("更新失败,请稍后重试"),U=>u(U),f)}}))},P=()=>{I&&(f(null),h(!0))},M=$=>{f(null),S.mutate({id:e,commitMessage:$},{onSuccess:()=>h(!1),onError:U=>{fa(U,g("提交失败,请稍后重试"),B=>{h(!1),u(B)},f)}})},O=()=>{S.isPending||(h(!1),f(null))};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:se("space-y-1",c),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:i,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":g("查看变更详情"),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(qs,{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:K}),t.jsxs("span",{className:"hidden shrink-0 items-center gap-1 font-mono text-[11px] sm:inline-flex",children:[y.additions>0&&t.jsxs("span",{className:"text-success",children:["+",y.additions]}),y.deletions>0&&t.jsxs("span",{className:"text-destructive",children:["-",y.deletions]})]}),E&&t.jsx($s,{size:13,className:"shrink-0 text-amber-600"}),t.jsxs("span",{className:"hidden min-w-0 items-center gap-1 text-[11px] text-muted-foreground md:flex",children:[t.jsx("span",{className:"truncate font-mono",children:s}),t.jsx("span",{className:"text-muted-foreground/40",children:"→"}),t.jsx("span",{className:"truncate font-mono",children:r})]}),t.jsx("span",{className:"shrink-0 rounded-full bg-background/75 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:H})]}),t.jsx(Mt,{size:15,className:"shrink-0 text-muted-foreground/60"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[b&&t.jsx("button",{type:"button",onClick:()=>w.mutate(e),disabled:w.isPending,className:"hidden h-7 items-center rounded-md border border-border/70 bg-background px-2 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50 sm:inline-flex",children:w.isPending?g("正在撤销..."):g("撤销操作")}),t.jsxs("button",{type:"button",onClick:A,disabled:!F||x.isPending||D,className:"inline-flex h-7 items-center gap-1.5 rounded-md border border-border/70 bg-background px-2 text-xs font-medium text-foreground/80 transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-45",title:g(L?"同步更新":"已是最新"),children:[x.isPending?t.jsx(We,{size:12,className:"animate-spin"}):t.jsx(ks,{size:12}),t.jsx("span",{children:x.isPending?g("正在同步..."):g("更新")})]}),t.jsxs("button",{type:"button",onClick:P,disabled:!I||S.isPending||D,className:"inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-2 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:bg-muted disabled:text-muted-foreground",title:I?g("合并到 {target}",{target:r}):g("提交变更"),children:[S.isPending?t.jsx(We,{size:12,className:"animate-spin"}):t.jsx(Vr,{size:12}),t.jsx("span",{children:S.isPending?g("正在提交..."):g("合并")})]})]})]}),d&&t.jsx("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-1.5 text-xs text-destructive",children:d})]}),t.jsx(fc,{isOpen:l,onClose:O,branchName:s,targetBranch:r,commitMessage:o,isPending:S.isPending,error:d,onConfirm:M})]})}function z0({agentType:e,workingDir:s}){return kt({queryKey:de.system.skillCatalog(e,s),queryFn:async()=>(await Ce.get("/system/skill-catalog",{params:{agentType:String(e),...s?{workingDir:s}:{}}})).commands,enabled:e===Nt.CODEX,staleTime:3e4})}function W0(e){const s=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,r=e.key==="Tab"&&!e.shiftKey;return s||r}function Ac({agentType:e,workingDir:s,input:r,setInput:o,textareaRef:p,minHeight:m,maxHeight:v}){const[n,i]=_.useState(0),{data:a=[]}=z0({agentType:e,workingDir:s}),c=_.useMemo(()=>e===Nt.CODEX?lo(r):null,[e,r])?.query??null,g=_.useMemo(()=>c===null?[]:Pd(a,c),[c,a]),x=_.useCallback(()=>{const l=p.current;l&&(l.style.height="auto",l.style.height=`${Math.max(m,Math.min(l.scrollHeight,v))}px`)},[v,m,p]);_.useEffect(()=>{i(0)},[e,c]),_.useEffect(()=>{n<g.length||i(0)},[g.length,n]);const S=_.useCallback(l=>{const h=lo(r);if(!h)return;const d=`${r.slice(0,h.replaceStart)}${l.command} `;o(d),requestAnimationFrame(()=>{const f=p.current;f&&(x(),f.focus(),f.setSelectionRange(d.length,d.length))})},[r,x,o,p]),w=_.useCallback(l=>c===null||g.length===0?!1:l.key==="ArrowDown"?(l.preventDefault(),i(h=>(h+1)%g.length),!0):l.key==="ArrowUp"?(l.preventDefault(),i(h=>(h-1+g.length)%g.length),!0):W0(l)?(l.preventDefault(),S(g[n]??g[0]),!0):!1,[S,g,c,n]);return{allSkills:a,query:c,filteredSkills:g,selectedIndex:n,setSelectedIndex:i,applySkill:S,handleKeyDown:w}}const H0=vr(),$0=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${H0}/attachments/by-path?path=${encodeURIComponent(e)}`:e,Ds=520,Ki=48,U0=4,q0=420;function K0(){const{t:e}=le();return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-background text-muted-foreground/70 select-none",children:[t.jsx("div",{className:"w-16 h-16 bg-muted/50 rounded-2xl border border-border/60 flex items-center justify-center mb-6",children:t.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-muted-foreground/50",children:[t.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"currentColor"}),t.jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),t.jsx("h3",{className:"text-foreground font-medium mb-2 text-lg",children:"Agent Tower"}),t.jsx("p",{className:"text-sm max-w-sm text-center text-muted-foreground leading-relaxed",children:e("Select a task from the sidebar to view logs, monitor execution, or interact with an agent.")})]})}const ma=[{status:Se.Review,className:"bg-warning/10 text-warning",hoverClass:"hover:bg-warning/15",icon:t.jsx(Ha,{className:"w-3 h-3"})},{status:Se.Running,className:"bg-info/10 text-info",hoverClass:"hover:bg-info/15",icon:t.jsx(Wa,{className:"w-3 h-3"})},{status:Se.Pending,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-muted",icon:t.jsx(za,{className:"w-3 h-3"})},{status:Se.Done,className:"bg-success/10 text-success",hoverClass:"hover:bg-success/15",icon:t.jsx(Fa,{className:"w-3 h-3"})},{status:Se.Cancelled,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-border",icon:t.jsx(Ba,{className:"w-3 h-3"})}];function V0({status:e,onChangeStatus:s}){const{t:r}=le(),[o,p]=_.useState(!1),m=_.useRef(null);_.useEffect(()=>{if(!o)return;const n=i=>{m.current&&!m.current.contains(i.target)&&p(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[o]);const v=ma.find(n=>n.status===e);return t.jsxs("div",{className:"relative",ref:m,children:[t.jsxs("button",{onClick:()=>s&&p(n=>!n),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium transition-colors ${v.className} ${s?"cursor-pointer hover:opacity-80":""}`,children:[v.icon,t.jsx("span",{children:r(e)}),s&&t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",className:`ml-0.5 transition-transform ${o?"rotate-180":""}`,children:t.jsx("path",{d:"M2 3.5L5 6.5L8 3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})]}),o&&t.jsx("div",{className:"absolute right-0 top-full mt-2 w-40 bg-background rounded-lg border border-border shadow-lg z-50 py-1 animate-in fade-in zoom-in-95 duration-100",children:ma.filter(n=>n.status!==e).map(n=>t.jsxs("button",{onClick:()=>{s?.(n.status),p(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-xs font-medium transition-colors ${n.hoverClass}`,children:[t.jsx("span",{className:n.className.split(" ").find(i=>i.startsWith("text-")),children:n.icon}),t.jsx("span",{className:"text-foreground/80",children:r(n.status)})]},n.status))})]})}function pa({state:e,onRetry:s}){const{t:r}=le(),o=e.status==="creating-workspace"?r("Creating Workspace..."):e.status==="creating-session"?r("Creating Session..."):e.status==="starting-session"?r("Starting Agent..."):r("启动 Agent 失败");return e.status==="failed"?t.jsxs("div",{className:"mb-6 max-w-sm rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-2 text-left",children:[t.jsx("p",{className:"text-sm font-medium text-destructive",children:o}),e.error?t.jsx("p",{className:"mt-1 text-xs text-destructive/80 break-words",children:e.error}):null,s?t.jsxs(Pe,{size:"sm",variant:"outline",className:"mt-3",onClick:s,children:[t.jsx(Qt,{size:14,className:"mr-1.5"}),r("重试启动 Agent")]}):null]}):t.jsxs("div",{className:"mb-6 flex items-center gap-2 rounded-full border border-border bg-muted/30 px-3 py-1.5 text-sm text-muted-foreground",children:[t.jsxs("svg",{className:"h-3.5 w-3.5 animate-spin shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:o})]})}function X0({task:e,onDeleteTask:s,isDeleting:r,onTaskStatusChange:o,autoStartState:p,onAutoStartRecovered:m}){const{t:v}=le(),[n,i]=_.useState(""),[a,u]=_.useState(!1),[c,g]=_.useState(!1),[x,S]=_.useState(!1),[w,l]=_.useState(!1),[h,d]=_.useState(!1),[f,y]=_.useState(!1),[C,k]=_.useState(null),E=_.useRef(null),[b,j]=_.useState(!1),[R,L]=_.useState(null),[T,D]=_.useState(void 0),[F,I]=_.useState(!1),H=_.useRef(null),K=_.useRef(null),A=_.useRef(null),P=_.useRef(null),{scrollRef:M,contentRef:O,isAtBottom:$,scrollToBottom:U,stopScroll:B}=Sn({resize:"smooth",initial:"instant"}),[z,q]=_.useState(!1),[N,W]=_.useState(Ds),[X,V]=_.useState(!1),ie=_.useRef(0),ee=_.useRef(Ds),pe=_.useRef(null),he=_.useCallback((Q,re,Oe)=>{E.current?.openFile(Q,re,Oe)},[]),{data:G,isLoading:ge}=Fn(e?.id??""),ne=A0(e?.id),{data:Re}=Ma(e?.id??""),{data:Ze}=Da(Re?.id??""),Xe=gn(Re?.id??""),ye=Re??null,He=!!ye,Ie=e?.isGitRepo!==!1&&e?.worktreeReady!==!1,tt=Re===null&&Ie,Ke=!!(e?.id&&Re===null),{data:Be,isLoading:Je}=Pa(e?.id??"",Ke);_.useEffect(()=>{I(!1),L(null),D(void 0)},[e?.id]);const Te=_.useMemo(()=>Pl(G,ye,T),[T,ye,G]);_.useEffect(()=>{T&&!G?.some(Q=>Q.id===T)&&D(void 0)},[T,G]);const je=_.useMemo(()=>G?.find(Q=>Q.id===Te),[Te,G]),_e=je?.status===At.ACTIVE?je.id:void 0,$e=Ie&&Ll(je,ye);_.useEffect(()=>{if(!F||!G)return;G.some(re=>re.status==="ACTIVE"&&re.sessions&&re.sessions.length>0)&&I(!1)},[G,F]);const be=_.useMemo(()=>{if(F||!G)return null;const Q=mt=>{const ji=mt.createdAt,tr=mt.endedAt??mt.startedAt??ji;if(!tr)return 0;const As=Date.parse(tr);return Number.isNaN(As)?0:As},re=(mt,ji)=>{const tr=mt.filter(As=>ji.includes(As.status));return tr.length===0?null:tr.sort((As,ed)=>Q(ed)-Q(As))[0]??null},Oe=G.filter(mt=>mt.status==="ACTIVE"&&Array.isArray(mt.sessions)).flatMap(mt=>mt.sessions??[]),ht=re(Oe,[ct.RUNNING])??re(Oe,[ct.PENDING])??re(Oe,[ct.COMPLETED,ct.FAILED,ct.CANCELLED]);if(ht)return ht;const ft=G.filter(mt=>(mt.status==="MERGED"||mt.status==="ABANDONED"||mt.status==="HIBERNATED")&&Array.isArray(mt.sessions)).flatMap(mt=>mt.sessions??[]);return re(ft,[ct.COMPLETED,ct.FAILED,ct.CANCELLED])},[G,F]),pt=be?.id??"",Ye=He?R??"":pt,Dt=_.useMemo(()=>{if(!R||!G)return null;for(const Q of G){const re=Q.sessions?.find(Oe=>Oe.id===R);if(re)return re}return null},[R,G]),J=_.useMemo(()=>{if(!R||!ye?.invocations)return null;const Q=ye.invocations.filter(re=>re.sessionId===R);return Q.length===0?null:Q.sort((re,Oe)=>{const ht=Date.parse(re.updatedAt??re.createdAt??""),ft=Date.parse(Oe.updatedAt??Oe.createdAt??"");return(Number.isNaN(ft)?0:ft)-(Number.isNaN(ht)?0:ht)})[0]??null},[R,ye?.invocations]),fe=_.useMemo(()=>!J?.memberId||!ye?.members?null:ye.members.find(Q=>Q.id===J.memberId)??null,[J?.memberId,ye?.members]),ue=R?Dt:be??null,Y=ue?.id,te=_.useMemo(()=>{if(ue?.workspaceId)return ue.workspaceId;if(!(!ue||!G))return G.find(Q=>Q.sessions?.some(re=>re.id===ue.id))?.id},[ue,G]),oe=_.useCallback((Q,re)=>{const ht=(re&&G?.some(ft=>ft.id===re)?re:void 0)??te??Te??void 0;ht&&D(ht),E.current?.openPreview(Q,ht)},[te,Te,G]),ve=_.useCallback((Q,re)=>{oe({kind:"web",url:Q},re)},[oe]),xe=_.useCallback((Q,re,Oe)=>{oe({kind:"visualization",sessionId:Q,file:re},Oe)},[oe]),Me=_.useCallback(Q=>{ve(Q,te)},[te,ve]),we=_.useCallback(Q=>{Y&&xe(Y,Q,te)},[Y,te,xe]),{isActive:Le,isCancelling:ke}=qa(Y??"",ue?.status),me=!!e?.projectArchivedAt,De=!!e?.projectRepoDeletedAt,Ae=v(De?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),{data:Qe}=Us(),[ut,at]=_.useState(null);_.useEffect(()=>{at(be?.providerId??null)},[be?.providerId]);const $t=_.useMemo(()=>!be||!G?!1:!G.some(re=>re.status==="ACTIVE"&&re.sessions?.some(Oe=>Oe.id===be.id)),[be,G]),rt=_.useMemo(()=>{if(!(!G||F)){if(je)return as(je);for(const Q of G)if(Q.status==="ACTIVE"&&as(Q))return as(Q);return as(G[0])}},[F,je,G]),it=Ka({agentType:be?.agentType,workingDir:rt,input:n,setInput:i,textareaRef:A,minHeight:60,maxHeight:300}),gt=Ac({agentType:be?.agentType,workingDir:rt,input:n,setInput:i,textareaRef:A,minHeight:60,maxHeight:300}),Ut=Cs(Q=>Q.setVisibleContext),qt=!!($e&&_e&&rt&&!me),{data:Et,isLoading:Kt}=Wn(_e??"",{enabled:qt}),{data:Vt}=bi(rt,{enabled:qt});_.useEffect(()=>{if(!(z||!qt||!_e||!rt))return Ut({workspaceId:_e,workingDir:rt,tab:"changes"}),()=>{Ut(null)}},[z,_e,Ut,qt,rt]);const Es=je?.sessions??[],js=Hs(je),Xs=je?.commitMessage,fs=_.useMemo(()=>Il(je,G,e?.mainBranch??""),[je,e?.mainBranch,G]),vt=_.useMemo(()=>Et?.conflictOp&&Et.conflictedFiles.length>0?{conflictOp:Et.conflictOp,conflictedFiles:Et.conflictedFiles}:C,[Et?.conflictOp,Et?.conflictedFiles,C]),Ys=vt?.targetWorkspaceId??_e,kr=vt?.targetWorktreePath??je?.worktreePath,Er=vt?.sourceBranch??js,ms=vt?.targetBranch??fs,nt=bt(),Xt=_.useCallback(async()=>e?.id?nt.fetchQuery({queryKey:de.tasks.body(e.id),queryFn:()=>Ce.get(`/tasks/${e.id}/body`)}):null,[nt,e?.id]),ps=_.useCallback(()=>e?.id?nt.invalidateQueries({queryKey:de.workspaces.list(e.id)}):Promise.resolve(),[e?.id,nt]);_.useEffect(()=>{if(!b)return;const Q=re=>{K.current&&!K.current.contains(re.target)&&j(!1)};return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[b]);const jr=En(),gs=zn(),Nr=gd(),Gs=El(e?.id??""),Qs=Cn(),Yt=vf(),Ft=_.useMemo(()=>!G||G.some(re=>re.status==="ACTIVE")?null:G.find(re=>re.status==="HIBERNATED")??null,[G]),Zs=_.useRef(null);_.useEffect(()=>{Ft&&Zs.current!==Ft.id&&(Yt.isPending||(Zs.current=Ft.id,Yt.mutate(Ft.id,{onSettled:()=>{Zs.current=null}})))},[Ft,Yt]);const Rr=_.useCallback(async()=>{if(!e?.id)return;const Q=be?.providerId??Qe?.find(re=>re.availability.type!=="NOT_FOUND")?.provider.id;if(Q){l(!1),d(!0);try{const Oe=(await Xt())?.prompt??e.title;await Nr.mutateAsync(e.id),I(!0);const ht=await Gs.mutateAsync({workspaceKind:Ie?void 0:_t.MAIN_DIRECTORY}),ft=await Ce.post(`/workspaces/${ht.id}/sessions`,{providerId:Q,prompt:Oe});await Qs.mutateAsync(ft.id),await nt.invalidateQueries({queryKey:de.workspaces.list(e.id)})}catch(re){console.error("[retry] failed:",re),I(!1)}finally{d(!1)}}},[e?.id,e?.title,Ie,be?.providerId,Qe,Xt,Nr,Gs,Qs,nt]),Ns=_.useCallback(async()=>{e?.id&&(await Xt(),u(!0))},[Xt,e?.id]),Js=_.useCallback(()=>{je?.id&&gs.mutate({workspaceId:je.id})},[gs,je?.id]),Ar=_.useCallback(()=>{!e?.id||!s||(s(e.id),S(!1))},[e?.id,s]),Tr=_.useCallback(Q=>{L(Q),requestAnimationFrame(()=>{U()})},[U]),_i=_.useCallback(()=>{L(null)},[]),vs=_.useCallback(Q=>{k(Q??null),y(!0)},[]),yi=_.useCallback(Q=>Xe.mutateAsync(Q),[Xe]),ts=_.useCallback(()=>{nt.invalidateQueries({queryKey:vd.all})},[nt]),{isConnected:er,isLoadingSnapshot:Mr,isOutputActive:Dr,lastExitAt:Pr,logs:xs,entries:bs,attach:Z}=Qa({sessionId:Ye,sessionStatus:ue?.status,sessionStartedAt:ue?.startedAt??ue?.createdAt,sessionEndedAt:ue?.endedAt??(Le?null:ue?.updatedAt),onExit:_.useCallback(()=>{nt.invalidateQueries({queryKey:["workspaces"]})},[nt])});_.useEffect(()=>{if(!e?.id)return;const Q=rs.connect();Q.emit(Ps.SUBSCRIBE,{topic:"task",id:e.id});const re=ft=>{ft.taskId===e.id&&(nt.invalidateQueries({queryKey:["tasks"]}),ts())},Oe=ft=>{ft.taskId===e.id&&(nt.invalidateQueries({queryKey:de.workspaces.list(e.id)}),ts())},ht=ft=>{ft.taskId===e.id&&(nt.invalidateQueries({queryKey:de.workspaces.list(e.id)}),ts())};return Q.on(lt.TASK_UPDATED,re),Q.on(lt.WORKSPACE_COMMIT_MESSAGE_UPDATED,Oe),Q.on(lt.WORKSPACE_HIBERNATED,ht),()=>{Q.off(lt.TASK_UPDATED,re),Q.off(lt.WORKSPACE_COMMIT_MESSAGE_UPDATED,Oe),Q.off(lt.WORKSPACE_HIBERNATED,ht),Q.emit(Ps.UNSUBSCRIBE,{topic:"task",id:e.id})}},[e?.id,nt,ts]),_.useEffect(()=>{if(!Ye)return;const Q=rs.connect(),re=Oe=>{Oe.sessionId===Ye&&(nt.invalidateQueries({queryKey:["workspaces"]}),ts())};return Q.on(lt.SESSION_COMPLETED,re),()=>{Q.off(lt.SESSION_COMPLETED,re)}},[Ye,nt,ts]);const{todos:ce}=Za(bs),{files:ze,addFiles:Ne,removeFile:St,clear:Pt,buildMarkdownLinks:Fe,hasFiles:jt,isUploading:Lt}=vn(),Rs=_.useMemo(()=>Cc(ue),[ue?.tokenUsage]),Jn=Va(xs,Rs);_.useEffect(()=>{Ye&&er&&Z()},[Ye,er,Z]);const eo=_.useRef(e?.id);_.useEffect(()=>{if(eo.current!==e?.id&&M.current){const Q=M.current;requestAnimationFrame(()=>{Q.scrollTop=Q.scrollHeight})}eo.current=e?.id},[e?.id,M]);const Si=Xa(),wi=_.useRef(!1),to=_.useCallback(async()=>{if(!n.trim()&&!jt||!Ye||wi.current||Lt)return;wi.current=!0;const Q=Fe(),re=[n.trim(),Q].filter(Boolean).join(`
|
|
80
|
+
|
|
81
|
+
`);i(""),Pt(),A.current&&(A.current.style.height="60px"),jr.mutate({id:Ye,message:re,providerId:ut??void 0},{onSuccess:()=>{Z()},onSettled:()=>{wi.current=!1}})},[n,Ye,jr,Z,jt,Lt,Fe,Pt,ut]),qc=_.useCallback(async()=>{Ye&&(await Si.mutateAsync(Ye),nt.invalidateQueries({queryKey:["workspaces"]}))},[Ye,Si,nt]),Kc=_.useCallback(Q=>{const re=Q.target.files;re&&re.length>0&&Ne(Array.from(re)),Q.target.value=""},[Ne]),Vc=_.useCallback(Q=>{const re=Q.clipboardData.items,Oe=[];for(const ht of re)if(ht.kind==="file"){const ft=ht.getAsFile();ft&&Oe.push(ft)}Oe.length>0&&(Q.preventDefault(),Ne(Oe))},[Ne]),[so,Ci]=_.useState(!1),Xc=_.useCallback(Q=>{Q.preventDefault(),Ci(!0)},[]),Yc=_.useCallback(Q=>{Q.preventDefault(),Ci(!1)},[]),Gc=_.useCallback(Q=>{Q.preventDefault(),Ci(!1);const re=Q.dataTransfer.files;re.length>0&&Ne(Array.from(re))},[Ne]),Gt=_.useCallback(Q=>{const re=pe.current?.getBoundingClientRect().width??(typeof window<"u"?window.innerWidth:void 0),Oe=re?Math.max(Ds,re-Ki-U0-q0):Ds;return Math.max(Ds,Math.min(Math.round(Q),Oe))},[]),ki=_.useCallback(Q=>{const re=Q.clientX-ie.current;W(Gt(ee.current-re))},[Gt]),Ei=_.useCallback(()=>{V(!1),document.body.style.cursor="",document.body.style.userSelect=""},[]);_.useEffect(()=>{if(X)return document.addEventListener("mousemove",ki),document.addEventListener("mouseup",Ei),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",ki),document.removeEventListener("mouseup",Ei),document.body.style.cursor="",document.body.style.userSelect=""}},[Ei,ki,X]);const Qc=_.useCallback(Q=>{Q.preventDefault(),ie.current=Q.clientX,ee.current=N,V(!0)},[N]);_.useEffect(()=>{!z||X||W(Q=>Gt(Q))},[Gt,z,X]),_.useEffect(()=>{if(!z)return;const Q=()=>{W(re=>Gt(re))};return window.addEventListener("resize",Q),()=>window.removeEventListener("resize",Q)},[Gt,z]);const Zc=_.useCallback(()=>{W(Q=>Gt(Q)),q(!0),requestAnimationFrame(()=>{E.current?.setTab("review")})},[Gt]),Jc=_.useCallback(Q=>{i(Q.target.value);const re=Q.target;re.style.height="auto";const Oe=re.scrollHeight;re.style.height=`${Math.max(60,Math.min(Oe,300))}px`},[]),ro=qt&&_e?t.jsx(Rc,{workspaceId:_e,branchName:js,targetBranch:fs,commitMessage:Xs,changes:Vt,gitStatus:Et,isGitStatusLoading:Kt,canRunGitOperations:$e,onOpenChanges:Zc,onRefreshCommitMessage:ps,onConflict:vs,className:"mb-1.5"}):null;return e?t.jsxs("div",{className:"flex-1 flex flex-col h-full bg-background relative overflow-hidden",children:[t.jsxs("div",{className:"px-6 py-3 flex items-center justify-between border-b border-border/60 bg-background z-20 flex-shrink-0",children:[t.jsxs("div",{className:"flex flex-col min-w-0 flex-1 mr-4",children:[t.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${e.projectColor.replace("text-","bg-")}`}),t.jsx("span",{className:"text-xs text-muted-foreground truncate",children:e.projectName}),e.projectArchivedAt&&t.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground shrink-0",children:e.projectRepoDeletedAt?v("源码已删除"):v("已删除")}),t.jsx("span",{className:"text-muted-foreground/40 text-xs",children:"/"}),t.jsx("span",{className:"text-xs text-muted-foreground/70 font-mono truncate",children:e.branch})]}),t.jsx("h2",{className:"text-lg font-semibold text-foreground break-words line-clamp-2",children:e.title})]}),t.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[t.jsx(V0,{status:e.status,onChangeStatus:!me&&o?Q=>o(e.id,Q):void 0}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:Js,disabled:!rt||me,className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground/70 hover:text-foreground hover:bg-muted transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:v("Open in IDE"),children:t.jsx(ai,{size:16})}),(s||tt)&&!me&&t.jsxs("div",{className:"relative",ref:K,children:[t.jsx("button",{onClick:()=>j(Q=>!Q),className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground/70 hover:text-foreground hover:bg-muted transition-colors",title:v("More actions"),children:t.jsx(sl,{size:16})}),b&&t.jsxs("div",{className:"absolute right-0 top-full mt-2 w-44 bg-background rounded-lg border border-border shadow-lg z-50 py-1",children:[tt&&t.jsxs("button",{onClick:()=>{g(!0),j(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50 transition-colors",children:[t.jsx(ns,{size:15}),t.jsx("span",{children:v("创建 TeamRun")})]}),t.jsxs("button",{onClick:()=>{l(!0),j(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50 transition-colors",children:[t.jsx(xd,{size:15}),t.jsx("span",{children:v("重新开始")})]}),s&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"my-1 border-t border-border/60"}),t.jsxs("button",{onClick:()=>{S(!0),j(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-destructive hover:bg-destructive/10 transition-colors",children:[t.jsx(Nn,{size:15}),t.jsx("span",{children:v("删除任务")})]})]})]})]})]})]})]}),$e&&_e&&Et&&t.jsx(D0,{workspaceId:_e,gitStatus:Et,onResolve:()=>vs()}),t.jsxs("div",{ref:pe,className:"flex-1 flex overflow-hidden",children:[t.jsx("div",{className:"flex min-w-0 flex-1 flex-col bg-background relative",children:He&&ye?R?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-border px-4 py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-xs font-semibold text-foreground",children:v("Invocation details")}),t.jsx("div",{className:"truncate text-[11px] text-muted-foreground",children:R})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(kc,{session:ue,providers:Qe,usage:Jn,providerIdFallback:fe?.providerId,agentTypeFallback:ue?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Pe,{type:"button",size:"sm",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-border/70 bg-background/60 px-2 text-xs font-medium text-muted-foreground hover:border-muted-foreground/40 hover:bg-muted hover:text-foreground",onClick:_i,children:[t.jsx(zs,{size:13}),t.jsx("span",{children:v("Team room")})]})]})]}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:M,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsx("div",{ref:O,className:"w-full max-w-4xl mx-auto",children:Mr?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:v("Loading logs...")})]}):xs.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:v(Le?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(Ur,{logs:xs,downloadSessionId:Y,isOutputActive:Dr,lastExitAt:Pr,onUserToggleDetails:B,workingDir:rt,onOpenWorkspaceFile:he,onOpenPreviewUrl:Me,onOpenVisualization:we})})}),!$&&t.jsxs("button",{onClick:()=>U(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-background/90 backdrop-blur-sm border border-border rounded-full shadow-md text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-all","aria-label":v("Scroll to bottom"),children:[t.jsx(hr,{size:14}),t.jsx("span",{children:v("回到底部")})]})]}),ce.length>0&&t.jsx("div",{className:"px-6 pt-2 pb-1 bg-background flex-shrink-0 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx(Kr,{todos:ce})})})]}):t.jsx(Dl,{teamRun:ye,messages:Ze??ye.messages??[],readOnly:me,readOnlyMessage:Ae,onSendMessage:yi,onViewInvocationSession:Tr,changeSummaryBar:ro,centered:!0,workingDir:rt,onOpenWorkspaceFile:he,onOpenPreviewUrl:ve,onOpenVisualization:xe}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:M,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsxs("div",{ref:O,className:"w-full min-w-0 max-w-4xl mx-auto",children:[(Je||Be?.body)&&t.jsx("div",{className:"mb-4 pb-4 border-b border-border/60 min-w-0",children:Je?t.jsx("p",{className:"text-sm text-muted-foreground/70 italic",children:v("Loading...")}):Be?.body?t.jsx("div",{className:"text-sm text-muted-foreground leading-relaxed prose prose-sm max-w-none break-words overflow-hidden",children:t.jsx(bn,{urlTransform:$0,components:Oa,children:Be.body})}):null}),ne&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-muted-foreground/70 text-sm",children:[ne.status==="running"&&t.jsxs(t.Fragment,{children:[t.jsxs("svg",{className:"animate-spin h-3.5 w-3.5 shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:v("Setup ({current}/{total}): {command}",{current:ne.currentIndex,total:ne.totalCommands,command:ne.currentCommand})})]}),ne.status==="completed"&&t.jsx("span",{className:"text-success",children:v("Setup 完成")}),ne.status==="failed"&&t.jsx("span",{className:"text-destructive/80",children:v("Setup 失败: {error}",{error:ne.error})})]}),!me&&p&&(ge||pt)?t.jsx("div",{className:"flex justify-center py-3",children:t.jsx(pa,{state:p,onRetry:p.status==="failed"?Ns:void 0})}):null,ge?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:v("Loading...")})]}):pt?Mr?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:v("Loading logs...")})]}):xs.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:v(Le?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(Ur,{logs:xs,downloadSessionId:Y,isOutputActive:Dr,lastExitAt:Pr,onUserToggleDetails:B,workingDir:rt,onOpenWorkspaceFile:he,onOpenPreviewUrl:Me,onOpenVisualization:we}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[t.jsx("div",{className:"w-14 h-14 bg-muted/50 rounded-2xl border border-border/60 flex items-center justify-center mb-5",children:t.jsx(Qt,{size:24,className:"text-muted-foreground/70 ml-0.5"})}),t.jsx("h3",{className:"text-base font-medium text-foreground mb-1.5",children:v(me?"项目为只读历史":"尚未启动 Agent")}),t.jsx("p",{className:"text-sm text-muted-foreground mb-6 max-w-xs",children:me?Ae:v("选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。")}),!me&&p?t.jsx(pa,{state:p}):null,!me&&t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[t.jsxs(Pe,{onClick:Ns,disabled:!!(p&&p.status!=="failed"),children:[t.jsx(Qt,{size:16,className:"mr-1.5"}),p?.status==="failed"?v("重试启动 Agent"):v("启动 Agent")]}),tt&&t.jsxs(Pe,{variant:"outline",onClick:()=>g(!0),children:[t.jsx(ns,{size:16,className:"mr-1.5"}),v("创建 TeamRun")]})]})]})]})}),!$&&t.jsxs("button",{onClick:()=>U(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-background/90 backdrop-blur-sm border border-border rounded-full shadow-md text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-all","aria-label":v("Scroll to bottom"),children:[t.jsx(hr,{size:14}),t.jsx("span",{children:v("回到底部")})]})]}),ce.length>0&&t.jsx("div",{className:"px-6 pt-2 pb-1 bg-background flex-shrink-0 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx(Kr,{todos:ce})})}),me?t.jsx("div",{className:"p-6 pt-3 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx("div",{className:"bg-muted/50 rounded-xl border border-border px-4 py-3 text-sm text-muted-foreground",children:Ae})})}):$t?t.jsx("div",{className:"p-6 pt-3 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsxs("div",{className:"flex items-center justify-between bg-muted/50 rounded-xl border border-border px-4 py-3",children:[t.jsx("span",{className:"text-sm text-muted-foreground",children:v("代码已合并,以上为历史沟通记录")}),t.jsxs(Pe,{size:"sm",onClick:Ns,children:[t.jsx(Qt,{size:14,className:"mr-1.5"}),v("启动新 Agent")]})]})})}):t.jsxs("div",{className:"p-6 pt-2 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-transparent",onDragOver:Xc,onDragLeave:Yc,onDrop:Gc,children:[t.jsxs("div",{className:"max-w-4xl mx-auto",children:[ro,Ye?t.jsx(Ya,{sessionId:Ye}):null,t.jsxs("div",{ref:H,className:`relative bg-background rounded-xl border hover:border-ring/40 focus-within:border-ring/60 transition-colors duration-200 ${so?"border-info bg-info/5":"border-border"}`,children:[t.jsx(xn,{files:ze,onRemove:St}),t.jsx("textarea",{ref:A,value:n,onChange:Jc,onPaste:Vc,onKeyDown:Q=>{gt.handleKeyDown(Q)||it.handleKeyDown(Q)||Q.key==="Enter"&&!Q.shiftKey&&!Q.repeat&&!Q.nativeEvent.isComposing&&Q.nativeEvent.keyCode!==229&&(Q.preventDefault(),to())},rows:1,placeholder:v(so?"Drop files here...":pt&&!Le?"Continue conversation...":"Message Agent..."),className:"w-full px-4 pt-4 pb-2 bg-transparent border-none focus:outline-none resize-none text-sm text-foreground placeholder-muted-foreground/70 leading-relaxed",style:{minHeight:"60px",maxHeight:"300px"}}),t.jsx("input",{ref:P,type:"file",multiple:!0,className:"hidden",onChange:Kc}),t.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[t.jsx("div",{className:"flex items-center gap-1",children:t.jsx("button",{onClick:()=>P.current?.click(),className:"p-2 text-muted-foreground/70 hover:text-muted-foreground hover:bg-muted rounded-lg transition-colors",title:v("Upload file"),children:t.jsx(jn,{size:18})})}),t.jsxs("div",{className:"flex items-center gap-2",children:[be&&Qe&&t.jsx(Ga,{providers:Qe,currentProviderId:ut,agentType:be.agentType,runtimeType:be.runtimeType,onSelect:at}),t.jsx(kn,{usage:Jn}),Le&&!n.trim()&&!jt?t.jsx("button",{onClick:qc,disabled:Si.isPending||ke,className:"p-2 rounded-lg transition-all duration-200 bg-destructive text-white hover:bg-destructive/90 disabled:opacity-50",children:t.jsx(Bs,{size:14})}):t.jsx("button",{onClick:to,disabled:!n.trim()&&!jt||Lt,className:`p-2 rounded-lg transition-all duration-200 ${(n.trim()||jt)&&!Lt?"bg-primary text-primary-foreground hover:bg-primary/90":"bg-transparent text-muted-foreground/50 cursor-not-allowed"}`,children:t.jsx(wn,{size:18})})]})]})]})]}),t.jsx(qr,{open:it.query!==null,anchorRef:H,commands:it.filteredCommands,selectedIndex:it.selectedIndex,query:it.query??"",hasCatalog:it.allCommands.length>0,onSelect:it.applyCommand}),t.jsx(qr,{open:gt.query!==null,anchorRef:H,commands:gt.filteredSkills,selectedIndex:gt.selectedIndex,query:gt.query??"",hasCatalog:gt.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",onSelect:gt.applySkill})]})]})}),z&&t.jsx("div",{className:"w-1 cursor-col-resize hover:bg-border active:bg-ring/40 transition-colors z-50 -ml-[2px] flex-shrink-0 h-full",onMouseDown:Qc,role:"separator","aria-orientation":"vertical","aria-label":v("调整工作区宽度")}),t.jsx("div",{className:"flex h-full flex-shrink-0 bg-background",style:{width:z?Ki+N:Ki},children:t.jsx(Sc,{sessionId:pt||void 0,workspaceId:Te,workingDir:rt,projectId:e.projectId,readOnly:me,repoDeleted:De,teamRun:ye,teamStatus:ye?t.jsx(Fl,{teamRun:ye,workspaces:G,selectedWorkspaceId:Te,onSelectWorkspace:D,onViewInvocationSession:Tr}):void 0,workspaces:G,selectedWorkspaceId:Te,onSelectWorkspace:D,variant:"rail",expanded:z,onExpandedChange:Q=>{Q&&W(re=>Gt(re)),q(Q)},minContentWidth:Ds,tabRef:E,gitAvailable:Ie,gitProps:$e&&_e?{branchName:js,targetBranch:fs,commitMessage:Xs,canRunGitOperations:!0,onRefreshCommitMessage:ps,onConflict:vs,onResolveConflicts:()=>vs()}:void 0})})]}),!me&&t.jsx(wc,{isOpen:a,onClose:()=>u(!1),taskId:e.id,projectId:e.projectId,taskTitle:Be?.title??e.title,taskDescription:Be?.body??"",taskPrompt:Be?.prompt,projectIsGitRepo:e.isGitRepo,projectWorktreeReady:e.worktreeReady,projectGitReason:e.reason,onStarted:()=>m?.(e.id)}),tt&&!me&&t.jsx(M0,{isOpen:c,onClose:()=>g(!1),taskId:e.id}),$e&&Ys&&vt&&t.jsx(Nc,{open:f,onOpenChange:Q=>{y(Q),Q||k(null)},workspaceId:Ys,conflictOp:vt.conflictOp,conflictedFiles:vt.conflictedFiles,sourceBranch:Er,targetBranch:ms,operation:Et?.operation,worktreePath:kr,mergeAborted:vt.mergeAborted,mergeStrategy:vt.mergeStrategy,sourceWorkspaceId:vt.sourceWorkspaceId,targetWorkspaceId:vt.targetWorkspaceId,sourceWorktreePath:vt.sourceWorktreePath,targetWorktreePath:vt.targetWorktreePath,sessions:Es,currentSessionId:He?void 0:pt,teamRunId:ye?.id}),t.jsx(_n,{isOpen:w,onClose:()=>l(!1),onConfirm:Rr,title:v("重新开始任务"),description:t.jsx("p",{children:v("将归档当前工作区并自动在新 Worktree 中重新启动 Agent,旧工作区内容保留供参考。")}),confirmText:v("确认重试"),variant:"default",isLoading:h}),t.jsx($n,{isOpen:x,onClose:()=>S(!1),onConfirm:Ar,taskId:e.id,taskTitle:e.title,workspaces:G,isLoading:r})]}):t.jsx(K0,{})}function Zn(e){switch(e){case Wt.TODO:return Se.Pending;case Wt.IN_PROGRESS:return Se.Running;case Wt.IN_REVIEW:return Se.Review;case Wt.DONE:return Se.Done;case Wt.CANCELLED:return Se.Cancelled}}function Y0(e){switch(e){case Se.Pending:return Wt.TODO;case Se.Running:return Wt.IN_PROGRESS;case Se.Review:return Wt.IN_REVIEW;case Se.Done:return Wt.DONE;case Se.Cancelled:return Wt.CANCELLED}}function G0(e){switch(e){case Nt.CLAUDE_CODE:return"Claude Code";case Nt.GEMINI_CLI:return"Gemini CLI";case Nt.CURSOR_AGENT:return"Cursor Agent";case Nt.CODEX:return"Codex";case Nt.QWEN_CODE:return"Qwen Code";case Nt.KIRO_CLI:return"Kiro CLI";case Nt.OPENCODE:return"OpenCode";case Nt.PI_CODING_AGENT:return"Pi Coding Agent";case Nt.GROK_BUILD:return"Grok Build";case Nt.MINION_CODE:return"Minion Code"}}const ri=["text-indigo-600","text-emerald-600","text-rose-600","text-amber-600","text-cyan-600","text-violet-600","text-teal-600","text-pink-600"];function Tc(e,s){let r=0;for(let o=0;o<e.length;o++)r=(r<<5)-r+e.charCodeAt(o)|0;return Math.abs(r)%s}function Q0(e){return{id:e.id,name:e.name,color:e.color||ri[Tc(e.name,ri.length)],isGitRepo:e.isGitRepo,worktreeReady:e.worktreeReady,reason:e.reason,archivedAt:e.archivedAt??null,repoDeletedAt:e.repoDeletedAt??null}}function Z0(e,s){const r=e.preferredWorkspace?e.preferredWorkspace.workspaceKind===_t.MAIN_DIRECTORY?"Project directory":e.preferredWorkspace.branchName:"—";return{id:e.id,projectId:e.projectId,title:e.title,status:Zn(e.status),agent:e.latestAgentType?G0(e.latestAgentType):"—",branch:r,description:"",updatedAt:new Date(e.updatedAt).toISOString(),isGitRepo:s?.isGitRepo,worktreeReady:s?.worktreeReady,reason:s?.reason,projectArchivedAt:s?.archivedAt??null,projectRepoDeletedAt:s?.repoDeletedAt??null}}function J0(e,s){const r=e.preferredWorkspace?e.preferredWorkspace.workspaceKind===_t.MAIN_DIRECTORY?"Project directory":e.preferredWorkspace.branchName:"—";return{id:e.id,projectId:s.id,projectName:s.name,projectColor:s.color||ri[Tc(s.name,ri.length)],title:e.title,status:Zn(e.status),branch:r,mainBranch:s.mainBranch??"main",description:"",isGitRepo:s.isGitRepo,worktreeReady:s.worktreeReady,reason:s.reason,projectArchivedAt:s.archivedAt??null,projectRepoDeletedAt:s.repoDeletedAt??null}}const ga={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"};function ex(e){const s=e.split("/");return s[s.length-1]||e}function tx(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function sx({workingDir:e,filePath:s,type:r}){const{t:o}=le(),{data:p,isLoading:m,isError:v}=hc(e,s,r);if(m)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[t.jsx(We,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(v)return t.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:o("Failed to load diff.")});const n=p?.diff||"";if(!n.trim())return t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:o("No diff content available.")});const i=n.split(`
|
|
82
|
+
`);return t.jsx("div",{className:"overflow-x-auto scrollbar-app-thin bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:i.map((a,u)=>{let c="",g="text-neutral-400";return a.startsWith("+")&&!a.startsWith("+++")?(c="bg-emerald-950/40",g="text-emerald-400"):a.startsWith("-")&&!a.startsWith("---")?(c="bg-red-950/40",g="text-red-400"):a.startsWith("@@")&&(c="bg-blue-950/30",g="text-blue-400"),t.jsx("div",{className:se("px-3 whitespace-pre",c,g),children:a},u)})})}function rx({entry:e,type:s,workingDir:r}){const[o,p]=_.useState(!1),m=ga[e.status]||ga.M,v=tx(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(n=>!n),className:se("flex items-center gap-2.5 w-full px-4 py-3 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("span",{className:se("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",m),children:e.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:ex(e.path)}),v&&t.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:v})]}),t.jsx("span",{className:"text-neutral-400 shrink-0",children:o?t.jsx(wt,{size:14}):t.jsx(Mt,{size:14})})]}),o&&t.jsx(sx,{workingDir:r,filePath:e.path,type:s})]})}function va({title:e,entries:s,type:r,workingDir:o,defaultOpen:p}){const{t:m}=le(),[v,n]=_.useState(p);return s.length===0?null:t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>n(i=>!i),className:"flex items-center gap-2 w-full px-4 py-2.5 active:bg-neutral-50",children:[t.jsx("span",{className:"text-neutral-400",children:v?t.jsx(wt,{size:14}):t.jsx(Mt,{size:14})}),t.jsx("span",{className:"text-xs font-semibold text-neutral-500 uppercase tracking-wider",children:m(e)}),t.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:s.length})]}),v&&t.jsx("div",{className:"divide-y divide-neutral-100",children:s.map(i=>t.jsx(rx,{entry:i,type:r,workingDir:o},`${r}:${i.path}`))})]})}function ix({workingDir:e}){const{t:s}=le(),{data:r,isLoading:o,isError:p}=bi(e);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:s("No workspace selected.")});if(o)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[t.jsx(We,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading changes...")})]});if(p)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:s("Failed to load changes.")});const m=r?.uncommitted||[],v=r?.committed||[];return m.length+v.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[t.jsx(qs,{size:28,className:"mb-3"}),t.jsx("span",{className:"text-sm",children:s("No pending changes")})]}):t.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin overscroll-y-contain",children:[t.jsx(va,{title:"Uncommitted",entries:m,type:"uncommitted",workingDir:e,defaultOpen:!0}),t.jsx(va,{title:"Committed",entries:v,type:"committed",workingDir:e,defaultOpen:!1})]})}const Vi=50,xa={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"};function nx(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?xt("{count}s ago",{count:r}):r<3600?xt("{count}m ago",{count:Math.floor(r/60)}):r<86400?xt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?xt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function ox(e){const s=e.split("/");return s[s.length-1]||e}function ax(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function lx({workingDir:e,hash:s,filePath:r}){const{t:o}=le(),{data:p,isLoading:m,isError:v}=Qn(e,s,r);if(m)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[t.jsx(We,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(v)return t.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:o("Failed to load diff.")});const n=p?.diff||"";if(!n.trim())return t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:o("No diff content available.")});const i=n.split(`
|
|
83
|
+
`);return t.jsx("div",{className:"overflow-x-auto scrollbar-app-thin bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:i.map((a,u)=>{let c="",g="text-neutral-400";return a.startsWith("+")&&!a.startsWith("+++")?(c="bg-emerald-950/40",g="text-emerald-400"):a.startsWith("-")&&!a.startsWith("---")?(c="bg-red-950/40",g="text-red-400"):a.startsWith("@@")&&(c="bg-blue-950/30",g="text-blue-400"),t.jsx("div",{className:se("px-3 whitespace-pre",c,g),children:a},u)})})}function cx({entry:e,workingDir:s,hash:r}){const[o,p]=_.useState(!1),m=xa[e.status]||xa.M,v=ax(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(n=>!n),className:se("flex items-center gap-2.5 w-full px-4 py-2.5 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("span",{className:se("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",m),children:e.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:ox(e.path)}),v&&t.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:v})]}),t.jsx("span",{className:"text-neutral-400 shrink-0",children:o?t.jsx(wt,{size:14}):t.jsx(Mt,{size:14})})]}),o&&t.jsx(lx,{workingDir:s,hash:r,filePath:e.path})]})}function dx({commit:e,workingDir:s}){const{t:r}=le(),[o,p]=_.useState(!1),{data:m,isLoading:v}=Gn(s,o?e.hash:null),n=m?.files||[];return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(i=>!i),className:se("flex items-start gap-3 w-full px-4 py-3 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("div",{className:"flex flex-col items-center shrink-0 pt-0.5",children:t.jsx("div",{className:se("w-2.5 h-2.5 rounded-full shrink-0",o?"bg-blue-500":"bg-neutral-300")})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs font-mono text-blue-600 shrink-0",children:e.shortHash}),t.jsx("span",{className:"text-sm text-neutral-900 truncate flex-1",children:e.message})]}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsx("span",{className:"text-[11px] text-neutral-500 truncate",children:e.author}),t.jsx("span",{className:"text-[11px] text-neutral-400",children:nx(e.timestamp)})]})]}),t.jsx("span",{className:"text-neutral-400 shrink-0 pt-0.5",children:o?t.jsx(wt,{size:14}):t.jsx(Mt,{size:14})})]}),o&&t.jsxs("div",{className:"pl-4 border-l-2 border-blue-100 ml-[22px]",children:[e.body&&t.jsx("div",{className:"px-3 py-2 text-xs text-neutral-600 whitespace-pre-wrap leading-4",children:e.body}),v?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-neutral-400",children:[t.jsx(We,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:r("Loading files...")})]}):n.length===0?t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:r("No files changed")}):t.jsx("div",{className:"divide-y divide-neutral-100",children:n.map(i=>t.jsx(cx,{entry:i,workingDir:s,hash:e.hash},i.path))})]})]})}function ux({workingDir:e}){const{t:s}=le(),{data:r,isLoading:o,isError:p,fetchNextPage:m,hasNextPage:v,isFetchingNextPage:n}=An({queryKey:de.git.log(e||""),queryFn:({pageParam:a=0})=>Ce.get("/git/log",{params:{workingDir:e||"",limit:String(Vi),skip:String(a)}}),initialPageParam:0,getNextPageParam:(a,u)=>a.commits.length<Vi?void 0:u.length*Vi,enabled:!!e}),i=r?.pages.flatMap(a=>a.commits)||[];return e?o?t.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[t.jsx(We,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading history...")})]}):p?t.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:s("Failed to load history.")}):i.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[t.jsx(Ws,{size:28,className:"mb-3"}),t.jsx("span",{className:"text-sm",children:s("No commit history")})]}):t.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin overscroll-y-contain",children:[t.jsx("div",{className:"divide-y divide-neutral-100",children:i.map(a=>t.jsx(dx,{commit:a,workingDir:e},a.hash))}),v&&t.jsx("button",{type:"button",onClick:()=>m(),disabled:n,className:"w-full py-4 text-sm text-neutral-500 active:text-neutral-700 active:bg-neutral-50 flex items-center justify-center gap-2",children:n?t.jsxs(t.Fragment,{children:[t.jsx(We,{size:14,className:"animate-spin"})," ",s("Loading...")]}):s("Load more")})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:s("No workspace selected.")})}const hx=vr(),fx=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${hx}/attachments/by-path?path=${encodeURIComponent(e)}`:e;function mx({status:e}){const s={[Se.Running]:"bg-blue-500",[Se.Review]:"bg-amber-500",[Se.Pending]:"bg-neutral-400",[Se.Done]:"bg-emerald-500",[Se.Cancelled]:"bg-neutral-400"};return t.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${s[e]}`})}const px=[{key:"chat",label:"Chat",icon:ni},{key:"changes",label:"Changes",icon:qs},{key:"history",label:"History",icon:Ws},{key:"workspace",label:"Workspace",icon:li}],gx=[{key:"chat",label:"Team room",icon:ni},{key:"team-status",label:"Team Status",icon:Ss},{key:"changes",label:"Changes",icon:qs},{key:"workspace",label:"Workspace",icon:li}];function ba({state:e,onRetry:s}){const{t:r}=le(),o=e.status==="creating-workspace"?r("Creating Workspace..."):e.status==="creating-session"?r("Creating Session..."):e.status==="starting-session"?r("Starting Agent..."):r("启动 Agent 失败");return e.status==="failed"?t.jsxs("div",{className:"mb-5 w-full max-w-[280px] rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-left",children:[t.jsx("p",{className:"text-xs font-medium text-red-600",children:o}),e.error?t.jsx("p",{className:"mt-1 text-[11px] text-red-500 break-words",children:e.error}):null,s?t.jsxs(Pe,{size:"sm",variant:"outline",className:"mt-3",onClick:s,children:[t.jsx(Qt,{size:14,className:"mr-1.5"}),r("重试启动 Agent")]}):null]}):t.jsxs("div",{className:"mb-5 flex items-center gap-2 rounded-full border border-neutral-200 bg-neutral-50 px-3 py-1.5 text-xs text-neutral-500",children:[t.jsxs("svg",{className:"h-3.5 w-3.5 animate-spin shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:o})]})}function vx({task:e,onBack:s,onDeleteTask:r,isDeleting:o,autoStartState:p,onAutoStartRecovered:m}){const{t:v}=le(),n=Cs(Z=>Z.setVisibleContext),[i,a]=_.useState("chat"),[u,c]=_.useState(""),[g,x]=_.useState(!1),[S,w]=_.useState(!1),[l,h]=_.useState(!1),[d,f]=_.useState(null),[y,C]=_.useState(void 0),k=_.useRef(0),[E,b]=_.useState(),j=_.useRef(null),R=_.useRef(null),L=_.useRef(null),T=_.useRef(null),{scrollRef:D,contentRef:F,isAtBottom:I,scrollToBottom:H,stopScroll:K}=Sn({resize:"smooth",initial:"instant"}),A=bt();_.useEffect(()=>{if(!l)return;const Z=ce=>{R.current&&!R.current.contains(ce.target)&&h(!1)};return document.addEventListener("mousedown",Z),()=>document.removeEventListener("mousedown",Z)},[l]);const{data:P,isLoading:M}=Fn(e.id),{data:O}=Ma(e.id),{data:$}=Da(O?.id??""),U=gn(O?.id??""),B=O??null,z=e.isGitRepo!==!1&&e.worktreeReady!==!1,q=_.useMemo(()=>(B?gx:px).filter(Z=>z||Z.key!=="changes"&&Z.key!=="history"),[z,B]),N=O===null,{data:W,isLoading:X}=Pa(e.id,N),V=!!e.projectArchivedAt,ie=!!e.projectRepoDeletedAt,ee=v(ie?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。");_.useEffect(()=>{C(void 0),f(null),b(void 0)},[e.id]),_.useEffect(()=>{B&&i==="history"&&a("chat"),!B&&i==="team-status"&&a("chat"),q.some(Z=>Z.key===i)||a("chat")},[i,q,B]);const pe=_.useMemo(()=>Pl(P,B,y),[y,B,P]);_.useEffect(()=>{y&&!P?.some(Z=>Z.id===y)&&C(void 0)},[y,P]);const he=_.useMemo(()=>P?.find(Z=>Z.id===pe),[pe,P]),G=_.useMemo(()=>{if(P){if(he)return as(he);for(const Z of P)if(Z.status==="ACTIVE"&&as(Z))return as(Z);return as(P[0])}},[he,P]),ge=he?.status===At.ACTIVE?he.id:void 0,ne=z&&Ll(he,B),Re=he?.branchName??"",Ze=he?.commitMessage,Xe=_.useMemo(()=>Il(he,P,e?.mainBranch??""),[he,e?.mainBranch,P]),ye=!!(ne&&ge&&G&&!V),{data:He,isLoading:Ie}=Wn(ge??"",{enabled:ye}),{data:tt}=bi(G,{enabled:ye}),Ke=tt?.committed?.length,[Be,Je]=_.useState(!1),[Te,je]=_.useState(null);_.useEffect(()=>{const Z=z&&(i==="changes"||i==="chat"&&ye)?"changes":z&&i==="history"?"history":null;if(!ge||!G||!Z){n(null);return}return n({workspaceId:ge,workingDir:G,tab:Z}),()=>{n(null)}},[i,z,ge,n,ye,G]);const _e=_.useMemo(()=>He?.conflictOp&&He.conflictedFiles.length>0?{conflictOp:He.conflictOp,conflictedFiles:He.conflictedFiles}:Te,[He?.conflictOp,He?.conflictedFiles,Te]),$e=_e?.targetWorkspaceId??ge,be=_e?.targetWorktreePath??he?.worktreePath,pt=_e?.sourceBranch??Re,Ye=_e?.targetBranch??Xe,Dt=he?.sessions??[],J=_.useCallback(Z=>{je(Z??null),Je(!0)},[]),fe=_.useCallback(()=>e?.id?A.invalidateQueries({queryKey:de.workspaces.list(e.id)}):Promise.resolve(),[e?.id,A]),ue=_.useCallback(async()=>A.fetchQuery({queryKey:de.tasks.body(e.id),queryFn:()=>Ce.get(`/tasks/${e.id}/body`)}),[A,e.id]),Y=_.useMemo(()=>{if(!P)return null;const Z=P.filter(Fe=>Fe.status==="ACTIVE"&&Array.isArray(Fe.sessions)).flatMap(Fe=>Fe.sessions??[]),ce=Fe=>{const jt=Fe.createdAt,Lt=Fe.endedAt??Fe.startedAt??jt;if(!Lt)return 0;const Rs=Date.parse(Lt);return Number.isNaN(Rs)?0:Rs},ze=Fe=>{const jt=Z.filter(Lt=>Fe.includes(Lt.status));return jt.length===0?null:jt.sort((Lt,Rs)=>ce(Rs)-ce(Lt))[0]??null},Ne=ze([ct.RUNNING])??ze([ct.PENDING])??ze([ct.COMPLETED,ct.FAILED,ct.CANCELLED]);if(Ne)return Ne;const Pt=P.filter(Fe=>(Fe.status==="ABANDONED"||Fe.status==="MERGED"||Fe.status==="HIBERNATED")&&Array.isArray(Fe.sessions)).flatMap(Fe=>Fe.sessions??[]).filter(Fe=>[ct.COMPLETED,ct.FAILED,ct.CANCELLED].includes(Fe.status));return Pt.length===0?null:Pt.sort((Fe,jt)=>ce(jt)-ce(Fe))[0]??null},[P]),te=Y?.id??"",oe=B?d??"":te,ve=_.useMemo(()=>{if(!d||!P)return null;for(const Z of P){const ce=Z.sessions?.find(ze=>ze.id===d);if(ce)return ce}return null},[d,P]),xe=_.useMemo(()=>{if(!d||!B?.invocations)return null;const Z=B.invocations.filter(ce=>ce.sessionId===d);return Z.length===0?null:Z.sort((ce,ze)=>{const Ne=Date.parse(ce.updatedAt??ce.createdAt??""),St=Date.parse(ze.updatedAt??ze.createdAt??"");return(Number.isNaN(St)?0:St)-(Number.isNaN(Ne)?0:Ne)})[0]??null},[d,B?.invocations]),Me=_.useMemo(()=>!xe?.memberId||!B?.members?null:B.members.find(Z=>Z.id===xe.memberId)??null,[xe?.memberId,B?.members]),we=d?ve:Y??null,Le=we?.id,ke=_.useMemo(()=>{if(we?.workspaceId)return we.workspaceId;if(!(!we||!P))return P.find(Z=>Z.sessions?.some(ce=>ce.id===we.id))?.id},[we,P]),me=_.useCallback((Z,ce)=>{const Ne=(ce&&P?.some(St=>St.id===ce)?ce:void 0)??ke??pe??void 0;Ne&&C(Ne),k.current+=1,b({id:k.current,source:Z,workspaceId:Ne}),a("workspace")},[ke,pe,P]),De=_.useCallback((Z,ce)=>{me({kind:"web",url:Z},ce)},[me]),Ae=_.useCallback((Z,ce,ze)=>{me({kind:"visualization",sessionId:Z,file:ce},ze)},[me]),Qe=_.useCallback(Z=>{De(Z,ke)},[ke,De]),ut=_.useCallback(Z=>{Le&&Ae(Le,Z,ke)},[Le,ke,Ae]),{isActive:at,isCancelling:$t}=qa(Le??"",we?.status),rt=_.useMemo(()=>!Y||!P?!1:!P.some(ce=>ce.status==="ACTIVE"&&ce.sessions?.some(ze=>ze.id===Y.id)),[Y,P]),{data:it}=Us(),[gt,Ut]=_.useState(null),qt=gt?.sessionId===te?gt.providerId:Y?.providerId??null,Et=_.useCallback(Z=>{Ut({sessionId:te,providerId:Z})},[te]),Kt=Ka({agentType:Y?.agentType,workingDir:G,input:u,setInput:c,textareaRef:L,minHeight:40,maxHeight:140}),Vt=Ac({agentType:Y?.agentType,workingDir:G,input:u,setInput:c,textareaRef:L,minHeight:40,maxHeight:140}),Es=G&&he?he.id:void 0,js=En(),Xs=zn(),fs=Xa(),{isConnected:vt,isLoadingSnapshot:Ys,isOutputActive:kr,lastExitAt:Er,logs:ms,entries:nt,attach:Xt}=Qa({sessionId:oe,sessionStatus:we?.status,sessionStartedAt:we?.startedAt??we?.createdAt,sessionEndedAt:we?.endedAt??(at?null:we?.updatedAt),onExit:_.useCallback(()=>{A.invalidateQueries({queryKey:["workspaces"]})},[A])}),{todos:ps}=Za(nt),{files:jr,addFiles:gs,removeFile:Nr,clear:Gs,buildMarkdownLinks:Qs,hasFiles:Yt,isUploading:Ft}=vn(),Zs=_.useMemo(()=>Cc(we),[we?.tokenUsage]),Rr=Va(ms,Zs);_.useEffect(()=>{oe&&vt&&Xt()},[oe,vt,Xt]);const Ns=_.useRef(null);_.useEffect(()=>{if(Ns.current!==e.id&&D.current){const Z=D.current;requestAnimationFrame(()=>{Z.scrollTop=Z.scrollHeight})}Ns.current=e.id},[e.id,D]);const Js=_.useRef(!1),Ar=_.useCallback(async()=>{if(!u.trim()&&!Yt||!te||Js.current||Ft)return;Js.current=!0;const Z=Qs(),ce=[u.trim(),Z].filter(Boolean).join(`
|
|
84
|
+
|
|
85
|
+
`);c(""),Gs(),L.current&&(L.current.style.height="40px"),js.mutate({id:te,message:ce,providerId:qt??void 0},{onSuccess:()=>Xt(),onSettled:()=>{Js.current=!1}})},[u,te,js,Xt,Yt,Ft,Qs,Gs,qt]),Tr=_.useCallback(async()=>{te&&(await fs.mutateAsync(te),A.invalidateQueries({queryKey:["workspaces"]}))},[te,fs,A]),_i=_.useCallback(Z=>U.mutateAsync(Z),[U]),vs=_.useCallback(Z=>{f(Z),a("chat"),requestAnimationFrame(()=>{H()})},[H]),yi=_.useCallback(()=>{f(null)},[]),ts=_.useCallback(()=>{a("changes")},[]),er=ye&&ge?t.jsx(Rc,{workspaceId:ge,branchName:Re,targetBranch:Xe,commitMessage:Ze,changes:tt,gitStatus:He,isGitStatusLoading:Ie,canRunGitOperations:ne,onOpenChanges:ts,onRefreshCommitMessage:fe,onConflict:J,className:"mb-2"}):null,Mr=_.useCallback(Z=>{const ce=Z.target.files;ce&&ce.length>0&&gs(Array.from(ce)),Z.target.value=""},[gs]),Dr=_.useCallback(Z=>{const ce=Z.clipboardData.items,ze=[];for(const Ne of ce)if(Ne.kind==="file"){const St=Ne.getAsFile();St&&ze.push(St)}ze.length>0&&(Z.preventDefault(),gs(ze))},[gs]),Pr=_.useCallback(Z=>{c(Z.target.value);const ce=Z.target;ce.style.height="auto",ce.style.height=`${Math.max(40,Math.min(ce.scrollHeight,140))}px`},[]),xs=_.useCallback(()=>{Es&&Xs.mutate({workspaceId:Es})},[Xs,Es]),bs=_.useRef(null);return _.useEffect(()=>{const Z=window.visualViewport;if(!Z)return;let ce=!1;const ze=()=>{bs.current&&(bs.current.style.height=`${Z.height}px`,bs.current.style.top=`${Z.offsetTop}px`)},Ne=()=>ze(),St=()=>{ce||ze()},Pt=()=>{ce=!0},Fe=()=>{ce=!1,requestAnimationFrame(ze)};return Z.addEventListener("resize",Ne),Z.addEventListener("scroll",St),document.addEventListener("touchstart",Pt,{passive:!0}),document.addEventListener("touchend",Fe,{passive:!0}),document.addEventListener("touchcancel",Fe,{passive:!0}),()=>{Z.removeEventListener("resize",Ne),Z.removeEventListener("scroll",St),document.removeEventListener("touchstart",Pt),document.removeEventListener("touchend",Fe),document.removeEventListener("touchcancel",Fe)}},[]),_.useEffect(()=>{const Z=bs.current;if(!Z)return;const ce=ze=>{let Ne=ze.target;for(;Ne&&Ne!==Z;){if(Ne.tagName==="TEXTAREA"){if(Ne.scrollHeight>Ne.clientHeight)return;Ne=Ne.parentElement;continue}const Pt=window.getComputedStyle(Ne).overflowY;if((Pt==="auto"||Pt==="scroll")&&Ne.scrollHeight>Ne.clientHeight)return;Ne=Ne.parentElement}ze.preventDefault()};return Z.addEventListener("touchmove",ce,{passive:!1}),()=>Z.removeEventListener("touchmove",ce)},[]),t.jsxs("div",{ref:bs,className:"fixed inset-x-0 top-0 flex flex-col h-dvh bg-white overflow-hidden overscroll-none",children:[t.jsxs("header",{className:"shrink-0 bg-white border-b border-neutral-200 z-20",children:[t.jsxs("div",{className:"flex items-center h-11 px-2.5 gap-1.5",children:[t.jsx("button",{onClick:s,className:"p-1.5 -ml-0.5 text-neutral-600 active:text-neutral-900",children:t.jsx(zs,{size:18})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("h1",{className:"text-[13px] font-bold text-neutral-900 truncate leading-tight",children:e.title}),t.jsxs("div",{className:"flex min-w-0 items-center gap-1 text-[11px] text-neutral-500 leading-tight",children:[t.jsx("span",{className:`truncate font-medium ${e.projectColor}`,children:e.projectName}),e.projectArchivedAt&&t.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?v("源码已删除"):v("已删除")}),t.jsx("span",{className:"text-neutral-300",children:"/"}),t.jsx("span",{className:"font-mono truncate",children:e.branch})]})]}),t.jsx(mx,{status:e.status}),t.jsx("button",{onClick:xs,disabled:!Es||V,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:t.jsx(ai,{size:16})}),r&&!V&&t.jsxs("div",{className:"relative",ref:R,children:[t.jsx("button",{onClick:()=>h(Z=>!Z),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:t.jsx(sl,{size:16})}),l&&t.jsx("div",{className:"absolute right-0 top-full mt-1 w-40 bg-white rounded-lg border border-neutral-200 shadow-lg z-50 py-1",children:t.jsxs("button",{onClick:()=>{w(!0),h(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 active:bg-red-50",children:[t.jsx(Nn,{size:15}),t.jsx("span",{children:v("删除任务")})]})})]})]}),t.jsx("div",{className:"flex border-t border-neutral-100",children:q.map(({key:Z,label:ce,icon:ze})=>t.jsxs("button",{onClick:()=>a(Z),className:`flex min-w-0 flex-1 items-center justify-center gap-1 px-1 py-2 text-[11px] font-medium transition-colors ${i===Z?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[t.jsx(ze,{size:13,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:v(ce)})]},Z))})]}),i==="chat"&&(B?t.jsx("main",{className:"flex-1 min-h-0 overflow-hidden",children:d?t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[t.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-neutral-200 px-3 py-2.5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-xs font-semibold text-neutral-900",children:v("Invocation details")}),t.jsx("div",{className:"truncate text-[11px] text-neutral-500",children:d})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.jsx(kc,{session:we,providers:it,usage:Rr,compact:!0,providerIdFallback:Me?.providerId,agentTypeFallback:we?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Pe,{type:"button",size:"xs",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-neutral-200/70 bg-white/60 px-1.5 text-[11px] font-medium text-neutral-500 hover:border-neutral-300 hover:bg-neutral-100 hover:text-neutral-900 active:bg-neutral-100",onClick:yi,children:[t.jsx(zs,{size:12}),t.jsx("span",{children:v("Team room")})]})]})]}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:D,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:t.jsx("div",{ref:F,children:Ys?t.jsx(Xi,{label:v("Loading logs...")}):ms.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:v(at?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(Ur,{logs:ms,downloadSessionId:Le,isOutputActive:kr,lastExitAt:Er,onUserToggleDetails:K,onOpenPreviewUrl:Qe,onOpenVisualization:ut})})}),!I&&t.jsxs("button",{onClick:()=>H(),className:"absolute bottom-2 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1 px-2.5 py-1 bg-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-[11px] text-neutral-600 active:bg-white transition-all","aria-label":v("Scroll to bottom"),children:[t.jsx(hr,{size:12}),t.jsx("span",{children:v("回到底部")})]})]}),ps.length>0&&t.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:t.jsx(Kr,{todos:ps,compact:!0})})]}):t.jsx(Dl,{teamRun:B,messages:$??B.messages??[],readOnly:V,readOnlyMessage:ee,onSendMessage:_i,onViewInvocationSession:vs,changeSummaryBar:er,compactComposer:!0,workingDir:G,onOpenPreviewUrl:De,onOpenVisualization:Ae})}):t.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:D,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:t.jsxs("div",{ref:F,children:[t.jsx("div",{className:"mb-3 pb-2 border-b border-neutral-100",children:X?t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:v("Loading...")}):W?.body?t.jsx("div",{className:"text-[13px] text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:t.jsx(bn,{urlTransform:fx,components:Oa,children:W.body})}):t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),!V&&p&&(M||te)?t.jsx("div",{className:"flex justify-center py-2",children:t.jsx(ba,{state:p,onRetry:p.status==="failed"?async()=>{await ue(),x(!0)}:void 0})}):null,M?t.jsx(Xi,{label:"Loading..."}):te?Ys?t.jsx(Xi,{label:"Loading logs..."}):ms.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:at?"Waiting for agent output...":"No logs recorded."}):t.jsx(Ur,{logs:ms,downloadSessionId:Le,isOutputActive:kr,lastExitAt:Er,onUserToggleDetails:K,onOpenPreviewUrl:Qe,onOpenVisualization:ut}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[t.jsx("div",{className:"w-12 h-12 bg-neutral-50 rounded-xl border border-neutral-100 flex items-center justify-center mb-4",children:t.jsx(Qt,{size:20,className:"text-neutral-400 ml-0.5"})}),t.jsx("h3",{className:"text-sm font-medium text-neutral-900 mb-1",children:v("尚未启动 Agent")}),t.jsx("p",{className:"text-xs text-neutral-500 mb-5 max-w-[240px]",children:V?ee:v("选择一个 Agent 来执行此任务")}),!V&&p?t.jsx(ba,{state:p}):null,!V&&t.jsxs(Pe,{onClick:async()=>{await ue(),x(!0)},disabled:!!(p&&p.status!=="failed"),children:[t.jsx(Qt,{size:16,className:"mr-1.5"}),p?.status==="failed"?v("重试启动 Agent"):v("启动 Agent")]})]})]})}),!I&&t.jsxs("button",{onClick:()=>H(),className:"absolute bottom-2 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1 px-2.5 py-1 bg-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-[11px] text-neutral-600 active:bg-white transition-all","aria-label":"Scroll to bottom",children:[t.jsx(hr,{size:12}),t.jsx("span",{children:v("回到底部")})]})]}),ps.length>0&&t.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:t.jsx(Kr,{todos:ps,compact:!0})}),V?t.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:t.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:ee})}):rt?t.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:t.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2",children:[t.jsx("span",{className:"text-xs text-neutral-500",children:v("代码已合并,以上为历史沟通记录")}),t.jsxs(Pe,{size:"sm",onClick:async()=>{await ue(),x(!0)},children:[t.jsx(Qt,{size:14,className:"mr-1.5"}),v("启动新 Agent")]})]})}):te&&t.jsxs("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:[er,t.jsx(Ya,{sessionId:oe||te,compact:!0}),t.jsxs("div",{ref:j,className:"relative bg-white rounded-xl border border-neutral-200 shadow-sm focus-within:border-neutral-300",children:[t.jsx(xn,{files:jr,onRemove:Nr}),t.jsx("textarea",{ref:L,value:u,onChange:Pr,onPaste:Dr,onKeyDown:Z=>{Vt.handleKeyDown(Z)||Kt.handleKeyDown(Z)||Z.key==="Enter"&&!Z.shiftKey&&!Z.repeat&&!Z.nativeEvent.isComposing&&Z.nativeEvent.keyCode!==229&&(Z.preventDefault(),Ar())},rows:1,placeholder:at?"Message Agent...":"Continue conversation...",className:"w-full px-3 pt-2.5 pb-1 bg-transparent border-none focus:outline-none resize-none text-[15px] text-neutral-900 placeholder-neutral-400",style:{minHeight:40,maxHeight:140}}),t.jsx("input",{ref:T,type:"file",multiple:!0,className:"hidden",onChange:Mr}),t.jsxs("div",{className:"flex items-center justify-between px-2 pb-1.5",children:[t.jsx("div",{className:"flex items-center gap-0.5",children:t.jsx("button",{onClick:()=>T.current?.click(),className:"p-1 text-neutral-400 active:text-neutral-600 rounded-lg",children:t.jsx(jn,{size:15})})}),t.jsxs("div",{className:"flex items-center gap-1",children:[Y&&it&&t.jsx(Ga,{providers:it,currentProviderId:qt,agentType:Y.agentType,runtimeType:Y.runtimeType,onSelect:Et}),t.jsx(kn,{usage:Rr}),at&&!u.trim()&&!Yt?t.jsx("button",{onClick:Tr,disabled:fs.isPending||$t,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:t.jsx(Bs,{size:12})}):t.jsx("button",{onClick:Ar,disabled:!u.trim()&&!Yt||Ft,className:`p-1.5 rounded-lg transition-colors ${(u.trim()||Yt)&&!Ft?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:t.jsx(wn,{size:15})})]})]})]}),t.jsx(qr,{open:Kt.query!==null,anchorRef:j,commands:Kt.filteredCommands,selectedIndex:Kt.selectedIndex,query:Kt.query??"",hasCatalog:Kt.allCommands.length>0,compact:!0,onSelect:Kt.applyCommand}),t.jsx(qr,{open:Vt.query!==null,anchorRef:j,commands:Vt.filteredSkills,selectedIndex:Vt.selectedIndex,query:Vt.query??"",hasCatalog:Vt.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",compact:!0,onSelect:Vt.applySkill})]})]})),i==="team-status"&&B&&t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:t.jsx(Fl,{teamRun:B,workspaces:P,selectedWorkspaceId:pe,onSelectWorkspace:C,onViewInvocationSession:vs})}),i==="changes"&&z&&t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[P&&P.length>1&&t.jsx("div",{className:"shrink-0 border-b border-neutral-100 bg-white px-3 py-2",children:t.jsx(yc,{workspaces:P,teamRun:B,selectedWorkspaceId:pe,onSelectWorkspace:C,className:"w-full",buttonClassName:"w-full max-w-none min-w-0 justify-start"})}),ne&&ge&&t.jsx("div",{className:"shrink-0",children:t.jsx(pc,{workspaceId:ge,branchName:Re,targetBranch:Xe,commitMessage:Ze,committedFileCount:Ke,onRefreshCommitMessage:fe,onConflict:J,onResolveConflicts:()=>J()})}),t.jsx(ix,{workingDir:G})]}),i==="history"&&t.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:t.jsx(ux,{workingDir:G})}),i==="workspace"&&t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(Sc,{sessionId:te||void 0,workspaceId:pe,workingDir:G,projectId:e.projectId,className:"h-full",hideChanges:!0,gitAvailable:z,readOnly:V,repoDeleted:ie,previewRequest:E,onPreviewRequestHandled:Z=>{b(ce=>ce?.id===Z?void 0:ce)}})}),!V&&t.jsx(wc,{isOpen:g,onClose:()=>x(!1),taskId:e.id,projectId:e.projectId,taskTitle:W?.title??e.title,taskDescription:W?.body??"",taskPrompt:W?.prompt,projectIsGitRepo:e.isGitRepo,projectWorktreeReady:e.worktreeReady,projectGitReason:e.reason,onStarted:()=>m?.(e.id)}),t.jsx($n,{isOpen:S,onClose:()=>w(!1),onConfirm:()=>{r?.(e.id),w(!1)},taskId:e.id,taskTitle:e.title,workspaces:P,isLoading:o}),Be&&_e&&$e&&t.jsx(Nc,{open:Be,onOpenChange:Z=>{Je(Z),Z||je(null)},workspaceId:$e,conflictOp:_e.conflictOp,conflictedFiles:_e.conflictedFiles,sourceBranch:pt,targetBranch:Ye,operation:He?.operation,worktreePath:be,mergeAborted:_e.mergeAborted,mergeStrategy:_e.mergeStrategy,sourceWorkspaceId:_e.sourceWorkspaceId,targetWorkspaceId:_e.targetWorkspaceId,sourceWorktreePath:_e.sourceWorktreePath,targetWorktreePath:_e.targetWorktreePath,sessions:Dt,currentSessionId:B?void 0:te,teamRunId:B?.id})]})}function Xi({label:e}){return t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:e})]})}var xx=Object.defineProperty,ii=Object.getOwnPropertySymbols,Mc=Object.prototype.hasOwnProperty,Dc=Object.prototype.propertyIsEnumerable,_a=(e,s,r)=>s in e?xx(e,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[s]=r,hn=(e,s)=>{for(var r in s||(s={}))Mc.call(s,r)&&_a(e,r,s[r]);if(ii)for(var r of ii(s))Dc.call(s,r)&&_a(e,r,s[r]);return e},fn=(e,s)=>{var r={};for(var o in e)Mc.call(e,o)&&s.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&ii)for(var o of ii(e))s.indexOf(o)<0&&Dc.call(e,o)&&(r[o]=e[o]);return r};var ws;(e=>{const s=class Ee{constructor(i,a,u,c){if(this.version=i,this.errorCorrectionLevel=a,this.modules=[],this.isFunction=[],i<Ee.MIN_VERSION||i>Ee.MAX_VERSION)throw new RangeError("Version value out of range");if(c<-1||c>7)throw new RangeError("Mask value out of range");this.size=i*4+17;let g=[];for(let S=0;S<this.size;S++)g.push(!1);for(let S=0;S<this.size;S++)this.modules.push(g.slice()),this.isFunction.push(g.slice());this.drawFunctionPatterns();const x=this.addEccAndInterleave(u);if(this.drawCodewords(x),c==-1){let S=1e9;for(let w=0;w<8;w++){this.applyMask(w),this.drawFormatBits(w);const l=this.getPenaltyScore();l<S&&(c=w,S=l),this.applyMask(w)}}p(0<=c&&c<=7),this.mask=c,this.applyMask(c),this.drawFormatBits(c),this.isFunction=[]}static encodeText(i,a){const u=e.QrSegment.makeSegments(i);return Ee.encodeSegments(u,a)}static encodeBinary(i,a){const u=e.QrSegment.makeBytes(i);return Ee.encodeSegments([u],a)}static encodeSegments(i,a,u=1,c=40,g=-1,x=!0){if(!(Ee.MIN_VERSION<=u&&u<=c&&c<=Ee.MAX_VERSION)||g<-1||g>7)throw new RangeError("Invalid value");let S,w;for(S=u;;S++){const f=Ee.getNumDataCodewords(S,a)*8,y=v.getTotalBits(i,S);if(y<=f){w=y;break}if(S>=c)throw new RangeError("Data too long")}for(const f of[Ee.Ecc.MEDIUM,Ee.Ecc.QUARTILE,Ee.Ecc.HIGH])x&&w<=Ee.getNumDataCodewords(S,f)*8&&(a=f);let l=[];for(const f of i){r(f.mode.modeBits,4,l),r(f.numChars,f.mode.numCharCountBits(S),l);for(const y of f.getData())l.push(y)}p(l.length==w);const h=Ee.getNumDataCodewords(S,a)*8;p(l.length<=h),r(0,Math.min(4,h-l.length),l),r(0,(8-l.length%8)%8,l),p(l.length%8==0);for(let f=236;l.length<h;f^=253)r(f,8,l);let d=[];for(;d.length*8<l.length;)d.push(0);return l.forEach((f,y)=>d[y>>>3]|=f<<7-(y&7)),new Ee(S,a,d,g)}getModule(i,a){return 0<=i&&i<this.size&&0<=a&&a<this.size&&this.modules[a][i]}getModules(){return this.modules}drawFunctionPatterns(){for(let u=0;u<this.size;u++)this.setFunctionModule(6,u,u%2==0),this.setFunctionModule(u,6,u%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const i=this.getAlignmentPatternPositions(),a=i.length;for(let u=0;u<a;u++)for(let c=0;c<a;c++)u==0&&c==0||u==0&&c==a-1||u==a-1&&c==0||this.drawAlignmentPattern(i[u],i[c]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(i){const a=this.errorCorrectionLevel.formatBits<<3|i;let u=a;for(let g=0;g<10;g++)u=u<<1^(u>>>9)*1335;const c=(a<<10|u)^21522;p(c>>>15==0);for(let g=0;g<=5;g++)this.setFunctionModule(8,g,o(c,g));this.setFunctionModule(8,7,o(c,6)),this.setFunctionModule(8,8,o(c,7)),this.setFunctionModule(7,8,o(c,8));for(let g=9;g<15;g++)this.setFunctionModule(14-g,8,o(c,g));for(let g=0;g<8;g++)this.setFunctionModule(this.size-1-g,8,o(c,g));for(let g=8;g<15;g++)this.setFunctionModule(8,this.size-15+g,o(c,g));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let i=this.version;for(let u=0;u<12;u++)i=i<<1^(i>>>11)*7973;const a=this.version<<12|i;p(a>>>18==0);for(let u=0;u<18;u++){const c=o(a,u),g=this.size-11+u%3,x=Math.floor(u/3);this.setFunctionModule(g,x,c),this.setFunctionModule(x,g,c)}}drawFinderPattern(i,a){for(let u=-4;u<=4;u++)for(let c=-4;c<=4;c++){const g=Math.max(Math.abs(c),Math.abs(u)),x=i+c,S=a+u;0<=x&&x<this.size&&0<=S&&S<this.size&&this.setFunctionModule(x,S,g!=2&&g!=4)}}drawAlignmentPattern(i,a){for(let u=-2;u<=2;u++)for(let c=-2;c<=2;c++)this.setFunctionModule(i+c,a+u,Math.max(Math.abs(c),Math.abs(u))!=1)}setFunctionModule(i,a,u){this.modules[a][i]=u,this.isFunction[a][i]=!0}addEccAndInterleave(i){const a=this.version,u=this.errorCorrectionLevel;if(i.length!=Ee.getNumDataCodewords(a,u))throw new RangeError("Invalid argument");const c=Ee.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][a],g=Ee.ECC_CODEWORDS_PER_BLOCK[u.ordinal][a],x=Math.floor(Ee.getNumRawDataModules(a)/8),S=c-x%c,w=Math.floor(x/c);let l=[];const h=Ee.reedSolomonComputeDivisor(g);for(let f=0,y=0;f<c;f++){let C=i.slice(y,y+w-g+(f<S?0:1));y+=C.length;const k=Ee.reedSolomonComputeRemainder(C,h);f<S&&C.push(0),l.push(C.concat(k))}let d=[];for(let f=0;f<l[0].length;f++)l.forEach((y,C)=>{(f!=w-g||C>=S)&&d.push(y[f])});return p(d.length==x),d}drawCodewords(i){if(i.length!=Math.floor(Ee.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let a=0;for(let u=this.size-1;u>=1;u-=2){u==6&&(u=5);for(let c=0;c<this.size;c++)for(let g=0;g<2;g++){const x=u-g,w=(u+1&2)==0?this.size-1-c:c;!this.isFunction[w][x]&&a<i.length*8&&(this.modules[w][x]=o(i[a>>>3],7-(a&7)),a++)}}p(a==i.length*8)}applyMask(i){if(i<0||i>7)throw new RangeError("Mask value out of range");for(let a=0;a<this.size;a++)for(let u=0;u<this.size;u++){let c;switch(i){case 0:c=(u+a)%2==0;break;case 1:c=a%2==0;break;case 2:c=u%3==0;break;case 3:c=(u+a)%3==0;break;case 4:c=(Math.floor(u/3)+Math.floor(a/2))%2==0;break;case 5:c=u*a%2+u*a%3==0;break;case 6:c=(u*a%2+u*a%3)%2==0;break;case 7:c=((u+a)%2+u*a%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[a][u]&&c&&(this.modules[a][u]=!this.modules[a][u])}}getPenaltyScore(){let i=0;for(let g=0;g<this.size;g++){let x=!1,S=0,w=[0,0,0,0,0,0,0];for(let l=0;l<this.size;l++)this.modules[g][l]==x?(S++,S==5?i+=Ee.PENALTY_N1:S>5&&i++):(this.finderPenaltyAddHistory(S,w),x||(i+=this.finderPenaltyCountPatterns(w)*Ee.PENALTY_N3),x=this.modules[g][l],S=1);i+=this.finderPenaltyTerminateAndCount(x,S,w)*Ee.PENALTY_N3}for(let g=0;g<this.size;g++){let x=!1,S=0,w=[0,0,0,0,0,0,0];for(let l=0;l<this.size;l++)this.modules[l][g]==x?(S++,S==5?i+=Ee.PENALTY_N1:S>5&&i++):(this.finderPenaltyAddHistory(S,w),x||(i+=this.finderPenaltyCountPatterns(w)*Ee.PENALTY_N3),x=this.modules[l][g],S=1);i+=this.finderPenaltyTerminateAndCount(x,S,w)*Ee.PENALTY_N3}for(let g=0;g<this.size-1;g++)for(let x=0;x<this.size-1;x++){const S=this.modules[g][x];S==this.modules[g][x+1]&&S==this.modules[g+1][x]&&S==this.modules[g+1][x+1]&&(i+=Ee.PENALTY_N2)}let a=0;for(const g of this.modules)a=g.reduce((x,S)=>x+(S?1:0),a);const u=this.size*this.size,c=Math.ceil(Math.abs(a*20-u*10)/u)-1;return p(0<=c&&c<=9),i+=c*Ee.PENALTY_N4,p(0<=i&&i<=2568888),i}getAlignmentPatternPositions(){if(this.version==1)return[];{const i=Math.floor(this.version/7)+2,a=this.version==32?26:Math.ceil((this.version*4+4)/(i*2-2))*2;let u=[6];for(let c=this.size-7;u.length<i;c-=a)u.splice(1,0,c);return u}}static getNumRawDataModules(i){if(i<Ee.MIN_VERSION||i>Ee.MAX_VERSION)throw new RangeError("Version number out of range");let a=(16*i+128)*i+64;if(i>=2){const u=Math.floor(i/7)+2;a-=(25*u-10)*u-55,i>=7&&(a-=36)}return p(208<=a&&a<=29648),a}static getNumDataCodewords(i,a){return Math.floor(Ee.getNumRawDataModules(i)/8)-Ee.ECC_CODEWORDS_PER_BLOCK[a.ordinal][i]*Ee.NUM_ERROR_CORRECTION_BLOCKS[a.ordinal][i]}static reedSolomonComputeDivisor(i){if(i<1||i>255)throw new RangeError("Degree out of range");let a=[];for(let c=0;c<i-1;c++)a.push(0);a.push(1);let u=1;for(let c=0;c<i;c++){for(let g=0;g<a.length;g++)a[g]=Ee.reedSolomonMultiply(a[g],u),g+1<a.length&&(a[g]^=a[g+1]);u=Ee.reedSolomonMultiply(u,2)}return a}static reedSolomonComputeRemainder(i,a){let u=a.map(c=>0);for(const c of i){const g=c^u.shift();u.push(0),a.forEach((x,S)=>u[S]^=Ee.reedSolomonMultiply(x,g))}return u}static reedSolomonMultiply(i,a){if(i>>>8||a>>>8)throw new RangeError("Byte out of range");let u=0;for(let c=7;c>=0;c--)u=u<<1^(u>>>7)*285,u^=(a>>>c&1)*i;return p(u>>>8==0),u}finderPenaltyCountPatterns(i){const a=i[1];p(a<=this.size*3);const u=a>0&&i[2]==a&&i[3]==a*3&&i[4]==a&&i[5]==a;return(u&&i[0]>=a*4&&i[6]>=a?1:0)+(u&&i[6]>=a*4&&i[0]>=a?1:0)}finderPenaltyTerminateAndCount(i,a,u){return i&&(this.finderPenaltyAddHistory(a,u),a=0),a+=this.size,this.finderPenaltyAddHistory(a,u),this.finderPenaltyCountPatterns(u)}finderPenaltyAddHistory(i,a){a[0]==0&&(i+=this.size),a.pop(),a.unshift(i)}};s.MIN_VERSION=1,s.MAX_VERSION=40,s.PENALTY_N1=3,s.PENALTY_N2=3,s.PENALTY_N3=40,s.PENALTY_N4=10,s.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],s.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=s;function r(n,i,a){if(i<0||i>31||n>>>i)throw new RangeError("Value out of range");for(let u=i-1;u>=0;u--)a.push(n>>>u&1)}function o(n,i){return(n>>>i&1)!=0}function p(n){if(!n)throw new Error("Assertion error")}const m=class et{constructor(i,a,u){if(this.mode=i,this.numChars=a,this.bitData=u,a<0)throw new RangeError("Invalid argument");this.bitData=u.slice()}static makeBytes(i){let a=[];for(const u of i)r(u,8,a);return new et(et.Mode.BYTE,i.length,a)}static makeNumeric(i){if(!et.isNumeric(i))throw new RangeError("String contains non-numeric characters");let a=[];for(let u=0;u<i.length;){const c=Math.min(i.length-u,3);r(parseInt(i.substring(u,u+c),10),c*3+1,a),u+=c}return new et(et.Mode.NUMERIC,i.length,a)}static makeAlphanumeric(i){if(!et.isAlphanumeric(i))throw new RangeError("String contains unencodable characters in alphanumeric mode");let a=[],u;for(u=0;u+2<=i.length;u+=2){let c=et.ALPHANUMERIC_CHARSET.indexOf(i.charAt(u))*45;c+=et.ALPHANUMERIC_CHARSET.indexOf(i.charAt(u+1)),r(c,11,a)}return u<i.length&&r(et.ALPHANUMERIC_CHARSET.indexOf(i.charAt(u)),6,a),new et(et.Mode.ALPHANUMERIC,i.length,a)}static makeSegments(i){return i==""?[]:et.isNumeric(i)?[et.makeNumeric(i)]:et.isAlphanumeric(i)?[et.makeAlphanumeric(i)]:[et.makeBytes(et.toUtf8ByteArray(i))]}static makeEci(i){let a=[];if(i<0)throw new RangeError("ECI assignment value out of range");if(i<128)r(i,8,a);else if(i<16384)r(2,2,a),r(i,14,a);else if(i<1e6)r(6,3,a),r(i,21,a);else throw new RangeError("ECI assignment value out of range");return new et(et.Mode.ECI,0,a)}static isNumeric(i){return et.NUMERIC_REGEX.test(i)}static isAlphanumeric(i){return et.ALPHANUMERIC_REGEX.test(i)}getData(){return this.bitData.slice()}static getTotalBits(i,a){let u=0;for(const c of i){const g=c.mode.numCharCountBits(a);if(c.numChars>=1<<g)return 1/0;u+=4+g+c.bitData.length}return u}static toUtf8ByteArray(i){i=encodeURI(i);let a=[];for(let u=0;u<i.length;u++)i.charAt(u)!="%"?a.push(i.charCodeAt(u)):(a.push(parseInt(i.substring(u+1,u+3),16)),u+=2);return a}};m.NUMERIC_REGEX=/^[0-9]*$/,m.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,m.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let v=m;e.QrSegment=m})(ws||(ws={}));(e=>{(s=>{const r=class{constructor(p,m){this.ordinal=p,this.formatBits=m}};r.LOW=new r(0,1),r.MEDIUM=new r(1,0),r.QUARTILE=new r(2,3),r.HIGH=new r(3,2),s.Ecc=r})(e.QrCode||(e.QrCode={}))})(ws||(ws={}));(e=>{(s=>{const r=class{constructor(p,m){this.modeBits=p,this.numBitsCharCount=m}numCharCountBits(p){return this.numBitsCharCount[Math.floor((p+7)/17)]}};r.NUMERIC=new r(1,[10,12,14]),r.ALPHANUMERIC=new r(2,[9,11,13]),r.BYTE=new r(4,[8,16,16]),r.KANJI=new r(8,[8,10,12]),r.ECI=new r(7,[0,0,0]),s.Mode=r})(e.QrSegment||(e.QrSegment={}))})(ws||(ws={}));var Is=ws;var bx={L:Is.QrCode.Ecc.LOW,M:Is.QrCode.Ecc.MEDIUM,Q:Is.QrCode.Ecc.QUARTILE,H:Is.QrCode.Ecc.HIGH},Pc=128,Lc="L",Ic="#FFFFFF",Oc="#000000",Bc=!1,Fc=1,_x=4,yx=0,Sx=.1;function zc(e,s=0){const r=[];return e.forEach(function(o,p){let m=null;o.forEach(function(v,n){if(!v&&m!==null){r.push(`M${m+s} ${p+s}h${n-m}v1H${m+s}z`),m=null;return}if(n===o.length-1){if(!v)return;m===null?r.push(`M${n+s},${p+s} h1v1H${n+s}z`):r.push(`M${m+s},${p+s} h${n+1-m}v1H${m+s}z`);return}v&&m===null&&(m=n)})}),r.join("")}function Wc(e,s){return e.slice().map((r,o)=>o<s.y||o>=s.y+s.h?r:r.map((p,m)=>m<s.x||m>=s.x+s.w?p:!1))}function wx(e,s,r,o){if(o==null)return null;const p=e.length+r*2,m=Math.floor(s*Sx),v=p/s,n=(o.width||m)*v,i=(o.height||m)*v,a=o.x==null?e.length/2-n/2:o.x*v,u=o.y==null?e.length/2-i/2:o.y*v,c=o.opacity==null?1:o.opacity;let g=null;if(o.excavate){let S=Math.floor(a),w=Math.floor(u),l=Math.ceil(n+a-S),h=Math.ceil(i+u-w);g={x:S,y:w,w:l,h}}const x=o.crossOrigin;return{x:a,y:u,h:i,w:n,excavation:g,opacity:c,crossOrigin:x}}function Cx(e,s){return s!=null?Math.max(Math.floor(s),0):e?_x:yx}function Hc({value:e,level:s,minVersion:r,includeMargin:o,marginSize:p,imageSettings:m,size:v,boostLevel:n}){let i=ae.useMemo(()=>{const S=(Array.isArray(e)?e:[e]).reduce((w,l)=>(w.push(...Is.QrSegment.makeSegments(l)),w),[]);return Is.QrCode.encodeSegments(S,bx[s],r,void 0,void 0,n)},[e,s,r,n]);const{cells:a,margin:u,numCells:c,calculatedImageSettings:g}=ae.useMemo(()=>{let x=i.getModules();const S=Cx(o,p),w=x.length+S*2,l=wx(x,v,S,m);return{cells:x,margin:S,numCells:w,calculatedImageSettings:l}},[i,v,m,o,p]);return{qrcode:i,margin:u,cells:a,numCells:c,calculatedImageSettings:g}}var kx=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),Ex=ae.forwardRef(function(s,r){const o=s,{value:p,size:m=Pc,level:v=Lc,bgColor:n=Ic,fgColor:i=Oc,includeMargin:a=Bc,minVersion:u=Fc,boostLevel:c,marginSize:g,imageSettings:x}=o,w=fn(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:l}=w,h=fn(w,["style"]),d=x?.src,f=ae.useRef(null),y=ae.useRef(null),C=ae.useCallback(F=>{f.current=F,typeof r=="function"?r(F):r&&(r.current=F)},[r]),[k,E]=ae.useState(!1),{margin:b,cells:j,numCells:R,calculatedImageSettings:L}=Hc({value:p,level:v,minVersion:u,boostLevel:c,includeMargin:a,marginSize:g,imageSettings:x,size:m});ae.useEffect(()=>{if(f.current!=null){const F=f.current,I=F.getContext("2d");if(!I)return;let H=j;const K=y.current,A=L!=null&&K!==null&&K.complete&&K.naturalHeight!==0&&K.naturalWidth!==0;A&&L.excavation!=null&&(H=Wc(j,L.excavation));const P=window.devicePixelRatio||1;F.height=F.width=m*P;const M=m/R*P;I.scale(M,M),I.fillStyle=n,I.fillRect(0,0,R,R),I.fillStyle=i,kx?I.fill(new Path2D(zc(H,b))):j.forEach(function(O,$){O.forEach(function(U,B){U&&I.fillRect(B+b,$+b,1,1)})}),L&&(I.globalAlpha=L.opacity),A&&I.drawImage(K,L.x+b,L.y+b,L.w,L.h)}}),ae.useEffect(()=>{E(!1)},[d]);const T=hn({height:m,width:m},l);let D=null;return d!=null&&(D=ae.createElement("img",{src:d,key:d,style:{display:"none"},onLoad:()=>{E(!0)},ref:y,crossOrigin:L?.crossOrigin})),ae.createElement(ae.Fragment,null,ae.createElement("canvas",hn({style:T,height:m,width:m,ref:C,role:"img"},h)),D)});Ex.displayName="QRCodeCanvas";var $c=ae.forwardRef(function(s,r){const o=s,{value:p,size:m=Pc,level:v=Lc,bgColor:n=Ic,fgColor:i=Oc,includeMargin:a=Bc,minVersion:u=Fc,boostLevel:c,title:g,marginSize:x,imageSettings:S}=o,w=fn(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:l,cells:h,numCells:d,calculatedImageSettings:f}=Hc({value:p,level:v,minVersion:u,boostLevel:c,includeMargin:a,marginSize:x,imageSettings:S,size:m});let y=h,C=null;S!=null&&f!=null&&(f.excavation!=null&&(y=Wc(h,f.excavation)),C=ae.createElement("image",{href:S.src,height:f.h,width:f.w,x:f.x+l,y:f.y+l,preserveAspectRatio:"none",opacity:f.opacity,crossOrigin:f.crossOrigin}));const k=zc(y,l);return ae.createElement("svg",hn({height:m,width:m,viewBox:`0 0 ${d} ${d}`,ref:r,role:"img"},w),!!g&&ae.createElement("title",null,g),ae.createElement("path",{fill:n,d:`M0,0 h${d}v${d}H0z`,shapeRendering:"crispEdges"}),ae.createElement("path",{fill:i,d:k,shapeRendering:"crispEdges"}),C)});$c.displayName="QRCodeSVG";function Uc(){return parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10)}function jx(){return kt({queryKey:de.tunnel.status,queryFn:()=>Ce.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?5e3:!1})}function Nx(){const e=bt();return Bt({mutationFn:()=>Ce.post("/tunnel/start",{port:Uc()}),onSuccess:()=>{e.invalidateQueries({queryKey:de.tunnel.status})}})}function Rx(){const e=bt();return Bt({mutationFn:()=>Ce.post("/tunnel/regenerate",{port:Uc()}),onSuccess:()=>{e.invalidateQueries({queryKey:de.tunnel.status})}})}function Ax(){const e=bt();return Bt({mutationFn:()=>Ce.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:de.tunnel.status})}})}function Tx(e){if(!e||e.status==="stopped")return{button:"text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100",dot:"",label:"Use Agent Tower on your phone",icon:"idle"};switch(e.status){case"healthy":case"checking":return{button:"text-emerald-600 hover:bg-emerald-50",dot:"bg-emerald-500",label:e.status==="healthy"?"Tunnel healthy":"Checking tunnel health",icon:"ok"};case"degraded":case"localUnhealthy":case"linkReplaced":return{button:"text-amber-600 hover:bg-amber-50",dot:"bg-amber-500",label:"Tunnel needs attention",icon:"warn"};case"exited":case"error":return{button:"text-red-600 hover:bg-red-50",dot:"bg-red-500",label:"Tunnel unavailable",icon:"error"};case"starting":return{button:"text-amber-600 hover:bg-amber-50",dot:"bg-amber-500",label:"Tunnel starting",icon:"loading"}}}function Mx(e){if(!e||e.status==="stopped")return"Tunnel is off";switch(e.status){case"healthy":return"Tunnel healthy";case"checking":return"Checking tunnel health";case"degraded":return"Observing original link";case"localUnhealthy":return"Local service unavailable";case"exited":return"Tunnel process exited";case"error":return"Tunnel error";case"linkReplaced":return"New link generated";case"starting":return"Tunnel starting"}}function Dx(e){if(!e||e.status==="stopped")return"Start a temporary Quick Tunnel when you need to share this Agent Tower session.";switch(e.status){case"healthy":return"The Cloudflare tunnel is running and the local Agent Tower health check passed.";case"checking":return"The Cloudflare tunnel is running. Agent Tower is waiting for the first local health check.";case"degraded":return"The original public URL is currently unreachable. Agent Tower is watching for it to recover and will not generate a new link automatically.";case"localUnhealthy":return"The local Agent Tower target is not responding, so the tunnel cannot be considered healthy.";case"exited":return"The tunnel process has exited. The old Quick Tunnel link is unlikely to recover.";case"error":return"The tunnel reported an error. Check the diagnostics before generating a new link.";case"linkReplaced":return"A new Quick Tunnel link was generated. The old link and token are no longer valid.";case"starting":return"Agent Tower is asking Cloudflare Quick Tunnel for a temporary public URL."}}function ya(e){if(!e)return"Never";const s=new Date(e).getTime();if(!Number.isFinite(s))return e;const r=Math.max(0,Math.round((Date.now()-s)/1e3));if(r<60)return`${r}s ago`;const o=Math.round(r/60);if(o<60)return`${o}m ago`;const p=Math.round(o/60);return p<24?`${p}h ago`:`${Math.round(p/24)}d ago`}function ir(e){const s=e?.trim();return s||null}function Px(e){if(!e)return"";const s=[ir(e.lastLocalError),ir(e.lastRemoteError),ir(e.lastError)].filter(p=>p!==null),r=ir(e.lastProcessOutput),o=!!r&&(e.status==="error"||e.status==="exited"||!!ir(e.lastError));return r&&o&&s.push(r),s.join(`
|
|
86
|
+
`)}function Sa(){const{t:e}=le(),{data:s}=jx(),r=Nx(),o=Ax(),p=Rx(),[m,v]=_.useState(!1),[n,i]=_.useState(null),a=_.useRef(null),[u,c]=_.useState({top:0,right:0}),[g,x]=_.useState(!1),[S,w]=_.useState(!1),l=s?.status!==void 0&&s.status!=="stopped",h=r.isPending||s?.status==="starting",d=p.isPending,f=s?.shareableUrl,y=s?.token,C=Tx(s),k=Mx(s),E=Px(s);_.useEffect(()=>{if(m&&a.current){const F=a.current.getBoundingClientRect();c({top:F.bottom+8,right:window.innerWidth-F.right})}},[m]);const b=_.useCallback(()=>{v(!0)},[l]),j=_.useCallback(()=>{r.mutate(void 0,{onSuccess:()=>v(!0)})},[r]),R=_.useCallback(()=>{f&&(navigator.clipboard.writeText(f),i("url"),setTimeout(()=>i(null),2e3))},[f]),L=_.useCallback(()=>{y&&(navigator.clipboard.writeText(y),i("token"),setTimeout(()=>i(null),2e3))},[y]),T=_.useCallback(()=>{o.mutate(),v(!1),x(!1),w(!1)},[o]),D=_.useCallback(()=>{p.mutate(void 0,{onSuccess:()=>{w(!1),v(!0)}})},[p]);return t.jsxs("div",{className:"relative",children:[t.jsx("button",{ref:a,onClick:b,disabled:h,className:`p-1.5 rounded-md transition-colors ${C.button}`,title:e(C.label),children:h?t.jsx(We,{size:16,className:"animate-spin"}):C.icon==="warn"?t.jsx($s,{size:16}):t.jsx(mo,{size:16})}),l&&!h&&t.jsx("span",{className:`absolute top-0.5 right-0.5 w-2 h-2 ${C.dot} rounded-full`}),m&&!l&&_s.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>v(!1)}),t.jsxs("div",{className:"fixed z-[101] w-80 max-w-[calc(100vw-1rem)] bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:u.top,right:u.right},children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"mt-0.5 flex size-7 items-center justify-center rounded-md bg-neutral-100 text-neutral-700",children:t.jsx(mo,{size:16})}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-neutral-900",children:e("Use Agent Tower on your phone")}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:e("After enabling the tunnel, you can scan a QR code with your phone to visit this Agent Tower instance, assign tasks, and check agent status.")})]})]}),t.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(Zt,{size:14})})]}),t.jsxs("button",{onClick:j,disabled:h,className:"mt-3 w-full px-3 py-2 text-xs font-medium text-white bg-neutral-900 hover:bg-neutral-800 rounded-md transition-colors disabled:opacity-50 flex items-center justify-center gap-1.5",children:[h&&t.jsx(We,{size:13,className:"animate-spin"}),e(h?"Starting tunnel...":"Enable phone access")]})]})]}),document.body),m&&l&&_s.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>v(!1)}),t.jsxs("div",{className:"fixed z-[101] w-96 max-w-[calc(100vw-1rem)] bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:u.top,right:u.right},children:[t.jsxs("div",{className:"flex items-start justify-between mb-2",children:[t.jsxs("div",{children:[t.jsxs("span",{className:`text-xs font-medium flex items-center gap-1.5 ${s?.status==="healthy"||s?.status==="checking"?"text-emerald-600":s?.status==="exited"||s?.status==="error"?"text-red-600":"text-amber-600"}`,children:[t.jsx("span",{className:`w-1.5 h-1.5 ${C.dot} rounded-full inline-block`}),e(k)]}),t.jsx("p",{className:"mt-1 text-xs text-neutral-500 leading-relaxed",children:e(Dx(s))})]}),t.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(Zt,{size:14})})]}),y&&t.jsxs("div",{className:"flex items-center gap-1.5 mb-2 px-2 py-1 bg-neutral-50 rounded text-xs text-neutral-700",children:[t.jsx(Ld,{size:12}),t.jsx("span",{children:e("Token protected")})]}),f&&t.jsx("div",{className:"flex justify-center py-3",children:t.jsx($c,{value:f,size:160})}),f||s?.url?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{readOnly:!0,value:f??s?.url??"",className:"flex-1 min-w-0 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-700 select-all",onFocus:F=>F.target.select()}),t.jsx("button",{onClick:R,disabled:!f,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors disabled:opacity-40",title:e("Copy shareable link"),children:n==="url"?t.jsx(Jt,{size:14,className:"text-emerald-500"}):t.jsx(ho,{size:14})})]}):t.jsx("div",{className:"rounded-md border border-neutral-200 bg-neutral-50 px-2 py-1.5 text-xs text-neutral-500",children:e("No tunnel link available")}),t.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-xs",children:[t.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[t.jsx("div",{className:"text-neutral-500",children:e("Last checked")}),t.jsx("div",{className:"mt-0.5 text-neutral-800",children:ya(s?.lastCheckedAt)})]}),t.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[t.jsx("div",{className:"text-neutral-500",children:e("Last healthy")}),t.jsx("div",{className:"mt-0.5 text-neutral-800",children:ya(s?.lastHealthyAt)})]})]}),E&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800 whitespace-pre-wrap break-words max-h-28 overflow-auto",children:E}),s?.status==="degraded"&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800",children:e("Agent Tower is keeping the same URL and waiting for Cloudflare Quick Tunnel to recover.")}),s?.status==="linkReplaced"&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800",children:e("The previous tunnel link and token are no longer valid.")}),y&&t.jsxs("div",{className:"mt-2",children:[t.jsx("button",{onClick:()=>x(!g),className:"text-xs text-neutral-500 hover:text-neutral-700 transition-colors",children:e(g?"Hide token":"Show token")}),g&&t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.jsx("code",{className:"flex-1 min-w-0 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-600 break-all",children:y}),t.jsx("button",{onClick:L,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors shrink-0",title:e("Copy token"),children:n==="token"?t.jsx(Jt,{size:14,className:"text-emerald-500"}):t.jsx(ho,{size:14})})]})]}),S&&t.jsxs("div",{className:"mt-3 rounded-md border border-red-200 bg-red-50 p-2 text-xs text-red-700",children:[t.jsx("div",{children:e("Generating a new link will invalidate the current link. People using the old URL must receive the new one.")}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsx("button",{onClick:()=>w(!1),className:"flex-1 px-2 py-1 rounded-md bg-white text-neutral-700 border border-neutral-200 hover:bg-neutral-50",children:e("Cancel")}),t.jsx("button",{onClick:D,disabled:d,className:"flex-1 px-2 py-1 rounded-md bg-red-600 text-white hover:bg-red-700 disabled:opacity-50",children:e(d?"Generating...":"Regenerate link")})]})]}),!S&&t.jsxs("button",{onClick:()=>w(!0),disabled:d||s?.canRegenerate===!1,className:"mt-3 w-full px-3 py-1.5 text-xs text-amber-700 hover:bg-amber-50 rounded-md transition-colors disabled:opacity-40 flex items-center justify-center gap-1.5",children:[t.jsx(ks,{size:13}),e("Regenerate link")]}),t.jsx("button",{onClick:T,disabled:o.isPending,className:"mt-2 w-full px-3 py-1.5 text-xs text-red-600 hover:bg-red-50 rounded-md transition-colors",children:o.isPending?e("Stopping..."):e("Stop Tunnel")})]})]}),document.body)]})}function Yi({isOpen:e,onClose:s}){const{t:r}=le(),o=Hd(),[p,m]=_.useState(""),[v,n]=_.useState(""),[i,a]=_.useState(null),[u,c]=_.useState(!1),[g,x]=_.useState(!1),S=p.trim(),w=v.trim(),l=u||o.isPending,h=_.useMemo(()=>!!(S&&w&&!l),[S,w,l]),d=_.useCallback(()=>{m(""),n(""),a(null),x(!1)},[]),f=_.useCallback(()=>{l||(d(),s())},[l,s,d]);_.useEffect(()=>{e||d()},[e,d]);const y=_.useCallback(async b=>{try{await o.mutateAsync({name:S,repoPath:w,initEmptyRepo:b}),d(),s()}catch(j){const R=j instanceof Error?j.message:r("Failed to create project");a(R),st.error(R)}},[o,s,d,r,S,w]),C=_.useCallback(async()=>{if(!(!S||!w||l)){a(null),c(!0);try{const b=await Ce.get("/filesystem/validate",{params:{path:w}});if(!b.valid){a(b.error??r("Selected path is not a valid directory"));return}if(b.isGitRepo){await y(!1);return}if(b.reason==="no_git"&&b.isEmpty){x(!0);return}if(b.reason==="no_git"){await y(!1);return}await y(!1)}catch(b){a(b instanceof Error?b.message:r("Could not check project path"))}finally{c(!1)}}},[y,l,r,S,w]),k=_.useCallback(()=>{x(!1),y(!1)},[y]),E=_.useCallback(()=>{x(!1),y(!0)},[y]);return t.jsxs(t.Fragment,{children:[t.jsx(ds,{isOpen:e,onClose:f,title:r("Create New Project"),action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:f,disabled:l,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:r("Cancel")}),t.jsx("button",{onClick:C,disabled:!h,className:`px-4 py-2 text-sm font-medium rounded-lg transition-all ${h?"bg-neutral-900 text-white hover:bg-black":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:u?r("Checking..."):o.isPending?r("Creating..."):r("Create Project")})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Project Name")}),t.jsx("input",{type:"text",value:p,onChange:b=>m(b.target.value),placeholder:r("e.g., Agent Tower"),disabled:l,className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:border-neutral-400 transition-colors disabled:bg-neutral-50 disabled:text-neutral-400",autoFocus:!0})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Project Path")}),t.jsx(Bd,{value:v,onChange:n,validationMode:"directory"})]}),i&&t.jsx("p",{className:"text-xs text-red-500 leading-relaxed",children:i})]})}),t.jsx(ds,{isOpen:g,onClose:()=>{o.isPending||x(!1)},title:r("Initialize Git repository?"),action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>x(!1),disabled:o.isPending,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:r("Cancel")}),t.jsx("button",{onClick:k,disabled:o.isPending,className:"px-4 py-2 text-sm font-medium rounded-lg border border-neutral-200 text-neutral-700 hover:bg-neutral-50 transition-colors disabled:opacity-50",children:r("Create Local Project")}),t.jsx("button",{onClick:E,disabled:o.isPending,className:"px-4 py-2 text-sm font-medium rounded-lg bg-neutral-900 text-white hover:bg-black transition-colors disabled:opacity-50",children:o.isPending?r("Creating..."):r("Initialize and Create")})]}),children:t.jsxs("div",{className:"space-y-3 text-sm text-neutral-600 leading-relaxed",children:[t.jsx("p",{children:r("This directory is empty and does not have Git version control yet. Agent Tower can initialize Git and create the initial commit before creating the project.")}),t.jsx("p",{children:r("You can also create it as a local project now. Local projects only support local Solo tasks until Git is initialized.")})]})})]})}function wa(e){if(!e)return 0;const s=Date.parse(e);return Number.isNaN(s)?0:s}function Lx(e){return e.map((s,r)=>({project:s,index:r,activityTime:wa(s.lastActivityAt??s.createdAt),createdTime:wa(s.createdAt)})).sort((s,r)=>{const o=r.activityTime-s.activityTime;if(o!==0)return o;const p=r.createdTime-s.createdTime;return p!==0?p:s.index-r.index}).map(({project:s})=>s)}function Ca({projects:e,filterProjectId:s,setFilterProjectId:r,onCreateProject:o,className:p}){const{t:m}=le(),[v,n]=_.useState(!1),i=e.filter(u=>!u.archivedAt),a=s?e.find(u=>u.id===s)??null:null;return t.jsxs("div",{className:se("relative flex items-center min-w-0",p),children:[t.jsx("span",{className:"mx-1.5 text-muted-foreground/40 select-none",children:"/"}),t.jsxs("button",{onClick:()=>n(u=>!u),className:"flex items-center gap-1.5 px-2 py-1 rounded-md text-sm text-foreground/90 hover:bg-accent transition-colors min-w-0",children:[a?t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${a.color.replace("text-","bg-")}`}):t.jsx(Fs,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"truncate max-w-[200px] font-medium",children:a?a.name:m("All Projects")}),t.jsx(wt,{size:13,className:`text-muted-foreground/70 shrink-0 transition-transform duration-200 ${v?"rotate-180":""}`})]}),v?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>n(!1)}),t.jsxs("div",{className:"absolute left-4 top-full mt-1.5 w-60 bg-popover border border-border rounded-lg shadow-lg shadow-black/5 z-40 py-1 animate-in fade-in zoom-in-95 duration-100 origin-top-left",children:[t.jsxs("button",{onClick:()=>{r(null),n(!1)},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 hover:bg-accent/50 transition-colors",children:[t.jsx(Fs,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:`flex-1 truncate ${s===null?"text-foreground font-medium":"text-muted-foreground"}`,children:m("All Projects")}),s===null?t.jsx(Jt,{size:14,className:"text-foreground shrink-0"}):null]}),t.jsx("div",{className:"h-px bg-border/60 my-1 mx-2"}),t.jsx("div",{className:"max-h-[40vh] overflow-y-auto scrollbar-app-thin",children:i.map(u=>{const c=s===u.id;return t.jsxs("button",{onClick:()=>{r(u.id),n(!1)},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 hover:bg-accent/50 transition-colors",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${u.color.replace("text-","bg-")}`}),t.jsx("span",{className:`flex-1 truncate ${c?"text-foreground font-medium":"text-muted-foreground"}`,children:u.name}),c?t.jsx(Jt,{size:14,className:"text-foreground shrink-0"}):null]},u.id)})}),t.jsx("div",{className:"h-px bg-border/60 my-1 mx-2"}),t.jsxs("button",{onClick:()=>{n(!1),o()},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 text-muted-foreground hover:text-foreground hover:bg-accent/50 transition-colors",children:[t.jsx(ns,{size:13}),t.jsx("span",{children:m("Create New Project...")})]})]})]}):null]})}function ka(){return t.jsx("div",{className:"px-4 pt-6 space-y-5 animate-pulse","aria-hidden":!0,children:Array.from({length:6}).map((e,s)=>t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("div",{className:"w-4 h-4 rounded-full bg-muted shrink-0 mt-0.5"}),t.jsxs("div",{className:"flex-1 space-y-2",children:[t.jsx("div",{className:"h-3 rounded bg-muted",style:{width:`${70-s%3*12}%`}}),t.jsx("div",{className:"h-2.5 rounded bg-muted/70",style:{width:`${45+s%2*18}%`}})]})]},s))})}const Ix=260,Ox=600,Ea=400,Bx=100,Fx=1e3;function zx(e){const s=e.workspaces?.find(o=>o.status==="ACTIVE")??e.workspaces?.[0],r=s?.sessions?.at(-1);return{id:e.id,projectId:e.projectId,title:e.titlePreview??e.title,status:e.status,...s?{preferredWorkspace:{...s.workspaceKind===_t.MAIN_DIRECTORY?{workspaceKind:_t.MAIN_DIRECTORY}:{},branchName:s.branchName}}:{},...r?{latestAgentType:r.agentType}:{},...e.workspaces?.some(o=>o.sessions?.some(p=>p.status==="RUNNING"||p.status==="PENDING"))?{hasRunningSession:!0}:{},updatedAt:e.updatedAt?new Date(e.updatedAt).getTime():Date.now()}}function Wx(){const{t:e,locale:s}=le(),[r,o]=_.useState(null),[p,m]=_.useState(null),[v,n]=_.useState(Ea),[i,a]=_.useState(!1),[u,c]=_.useState("idle"),[g,x]=_.useState({}),S=_.useRef(!1),w=_.useRef(0),l=_.useRef(Ea),h=_.useRef(null),d=bt(),{data:f,isLoading:y}=Us(),{data:C,isLoading:k}=$d({limit:Bx}),E=_.useMemo(()=>C?.data??[],[C?.data]),b=p&&E.some(J=>J.id===p)?p:null,{data:j,isLoading:R}=bd({...b?{projectId:b}:{},limit:Fx}),L=_.useMemo(()=>j?.data??[],[j?.data]),[T,D]=_.useState([]),F=_.useMemo(()=>{if(T.length===0)return L;const J=new Set(L.map(fe=>fe.id));return[...T.filter(fe=>!J.has(fe.id)),...L]},[L,T]),[I,H]=_.useState(null),K=_.useMemo(()=>r&&F.some(J=>J.id===r)?r:I&&r===I?I:null,[r,F,I]);_.useEffect(()=>{I&&F.some(J=>J.id===I)&&H(null)},[I,F]),_.useEffect(()=>{if(T.length===0)return;const J=new Set(L.map(fe=>fe.id));T.some(fe=>J.has(fe.id))&&D(fe=>fe.filter(ue=>!J.has(ue.id)))},[L,T]);const A=_.useMemo(()=>Lx(E),[E]),P=_.useMemo(()=>A.map(Q0),[A]),M=_.useMemo(()=>A.filter(J=>!J.archivedAt),[A]),O=_.useMemo(()=>{if(!f)return[];const J=localStorage.getItem("providerUsageCount"),fe=J?JSON.parse(J):{};return[...f].sort((ue,Y)=>{const te=ue.availability.type!=="NOT_FOUND",oe=Y.availability.type!=="NOT_FOUND";if(te!==oe)return te?-1:1;const ve=fe[ue.provider.id]??0;return(fe[Y.provider.id]??0)-ve})},[f]),$=_.useMemo(()=>F.map(J=>Z0(J,E.find(fe=>fe.id===J.projectId))),[E,F]),U=_.useMemo(()=>{if(!K)return null;const J=F.find(ue=>ue.id===K);if(!J)return null;const fe=E.find(ue=>ue.id===J.projectId);if(!fe){const ue=J.preferredWorkspace?J.preferredWorkspace.workspaceKind===_t.MAIN_DIRECTORY?"Project directory":J.preferredWorkspace.branchName:"—";return{id:J.id,projectId:J.projectId,projectName:"Unknown",projectColor:"text-muted-foreground",title:J.title,status:Zn(J.status),branch:ue,mainBranch:"main",description:"",isGitRepo:!1,worktreeReady:!1,reason:"NO_GIT",projectArchivedAt:null,projectRepoDeletedAt:null}}return J0(J,fe)},[K,F,E]),B=Ta(),z=_d(),q=yd(),N=Cn(),W=_.useCallback(J=>{const fe=zx(J);D(ue=>ue.some(Y=>Y.id===J.id)?ue.map(Y=>Y.id===J.id?fe:Y):[fe,...ue]),d.setQueryData(de.tasks.detail(J.id),J),H(J.id),o(J.id)},[d]),X=_.useCallback((J,fe,ue)=>{const Y=J.id,te=[J.title,J.description].filter(Boolean).join(`
|
|
87
|
+
|
|
88
|
+
`);x(oe=>({...oe,[Y]:{status:"creating-workspace"}})),(async()=>{try{const oe=await Ce.post(`/tasks/${Y}/workspaces`,{workspaceKind:ue});x(xe=>({...xe,[Y]:{status:"creating-session"}}));const ve=await Ce.post(`/workspaces/${oe.id}/sessions`,{providerId:fe,prompt:te});x(xe=>({...xe,[Y]:{status:"starting-session"}})),await N.mutateAsync(ve.id),await d.invalidateQueries({queryKey:de.workspaces.list(Y)}),await d.invalidateQueries({queryKey:de.tasks.all}),x(xe=>{const{[Y]:Me,...we}=xe;return we})}catch(oe){const ve=oe instanceof Error?oe.message:e("启动 Agent 失败");x(xe=>({...xe,[Y]:{status:"failed",error:ve}})),st.error(e("任务已创建,但启动 Agent 失败,可在详情中重试")),d.invalidateQueries({queryKey:de.workspaces.list(Y)}),d.invalidateQueries({queryKey:de.tasks.all})}})()},[d,N,e]),V=_.useCallback(J=>{x(fe=>{const{[J]:ue,...Y}=fe;return Y}),d.invalidateQueries({queryKey:de.workspaces.list(J)}),d.invalidateQueries({queryKey:de.tasks.all})},[d]),ie=_.useCallback(J=>{z.mutate(J,{onSuccess:()=>{K===J&&o(null),x(fe=>{const{[J]:ue,...Y}=fe;return Y}),D(fe=>fe.filter(ue=>ue.id!==J)),d.invalidateQueries({queryKey:de.tasks.all})},onError:()=>{st.error(e("删除任务失败"))}})},[z,K,d,e]),ee=_.useCallback((J,fe)=>{q.mutate({id:J,status:Y0(fe)},{onError:()=>{st.error(e("状态变更失败,该操作不被允许"))}})},[q,e]),pe=_.useCallback(J=>{J.preventDefault(),S.current=!0,w.current=J.clientX,l.current=v,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[v]);_.useEffect(()=>{const J=ue=>{if(!S.current)return;const Y=ue.clientX-w.current,te=Math.max(Ix,Math.min(Ox,l.current+Y));n(te)},fe=()=>{S.current&&(S.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",J),document.addEventListener("mouseup",fe),()=>{document.removeEventListener("mousemove",J),document.removeEventListener("mouseup",fe)}},[]);const he=_.useCallback(()=>{a(!0)},[]),G=_.useCallback(()=>{if(M.length===0){st.error(e("没有可用项目,请先创建或恢复项目"));return}o(null)},[M,e]),ge=_.useCallback(()=>{a(!1)},[]),ne=_.useCallback(async J=>{const{title:fe,description:ue,projectId:Y,providerId:te,mode:oe,workspaceMode:ve,teamRunMode:xe,teamTemplateId:Me,memberPresetIds:we,attachmentLinks:Le}=J,ke=[ue,Le].filter(Boolean).join(`
|
|
89
|
+
|
|
90
|
+
`);let me=null;try{if(c("creating-task"),me=await Ce.post(`/projects/${Y}/tasks`,{title:fe,description:ke||void 0}),localStorage.setItem("lastSelectedProjectId",Y),oe==="SOLO"&&te){localStorage.setItem("lastSelectedProviderId",te);const Ae=localStorage.getItem("providerUsageCount"),Qe=Ae?JSON.parse(Ae):{};Qe[te]=(Qe[te]??0)+1,localStorage.setItem("providerUsageCount",JSON.stringify(Qe))}oe==="TEAM"?(c("creating-teamrun"),await B.mutateAsync({taskId:me.id,mode:xe,...Me?{teamTemplateId:Me}:{},...we.length>0?{memberPresetIds:we}:{}})):te&&X(me,te,ve),b&&Y!==b&&m(null),W(me),c("idle"),d.invalidateQueries({queryKey:de.tasks.all}),d.invalidateQueries({queryKey:de.projects.all})}catch(De){if(c("idle"),me&&oe==="TEAM"){try{await z.mutateAsync(me.id)}catch{}throw st.error(e("TeamRun 创建失败,请检查团队配置后重试")),De}else if(me)b&&Y!==b&&m(null),W(me),d.invalidateQueries({queryKey:de.tasks.all}),d.invalidateQueries({queryKey:de.projects.all});else throw st.error(De instanceof Error?De.message:e("Failed to create task")),De}},[M,B,X,z,d,e,b,W]),Re=k||R,Ze=_.useMemo(()=>M.map(J=>({id:J.id,name:J.name,color:P.find(fe=>fe.id===J.id)?.color,repoPath:J.repoPath,isGitRepo:J.isGitRepo,worktreeReady:J.worktreeReady,reason:J.reason})),[M,P]),Xe=_.useMemo(()=>O.map(({provider:J,availability:fe})=>({id:J.id,name:J.name,agentType:J.agentType,available:fe.type!=="NOT_FOUND"})),[O]),ye=_.useMemo(()=>{if(b&&M.find(fe=>fe.id===b))return b;const J=localStorage.getItem("lastSelectedProjectId");return J&&M.find(fe=>fe.id===J)?J:M[0]?.id??""},[M,b]),[He,Ie]=_.useState(ye);_.useEffect(()=>{Ie(ye)},[ye]);const tt=_.useMemo(()=>M.find(J=>J.id===He)?.name??M.find(J=>J.id===ye)?.name??e("Project"),[M,He,ye,e]),Ke=s==="zh-CN"?`你需要在 ${tt} 中做点什么?`:`What do you need to do in ${tt}?`,Be=_.useMemo(()=>{const J=localStorage.getItem("lastSelectedProviderId");return J&&O.find(ue=>ue.provider.id===J&&ue.availability.type!=="NOT_FOUND")?J:O.find(ue=>ue.availability.type!=="NOT_FOUND")?.provider.id??""},[O]),Je=Cl(),[Te,je]=_.useState(!1),{usesIntegratedTitlebar:_e,desktopPlatform:$e,hasMacTrafficLights:be}=ja(),pt=_e&&$e==="win32",Ye=_.useCallback(()=>{if(M.length===0){st.error(e("没有可用项目,请先创建或恢复项目"));return}je(!0)},[M,e]),Dt=_.useCallback(async J=>{await ne(J),je(!1)},[ne]);return Je?Te?t.jsxs("div",{className:"flex flex-col h-dvh bg-background overflow-hidden text-sm",children:[t.jsx("header",{className:"h-12 border-b border-border/60 flex items-center px-4 shrink-0",children:t.jsx("button",{onClick:()=>je(!1),className:"text-sm text-muted-foreground active:text-foreground",children:e("Cancel")})}),t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-4 pb-[8vh]",children:[t.jsx("h1",{className:"max-w-full text-center text-[20px] font-medium tracking-tight leading-snug text-foreground mb-5 break-words",children:Ke}),t.jsx(co,{projects:Ze,providers:Xe,isProvidersLoading:y,onSubmit:Dt,defaultProjectId:ye,defaultProviderId:Be,onProjectChange:Ie,createStep:u})]})]}):K&&U?t.jsxs(t.Fragment,{children:[t.jsx(vx,{task:U,onBack:()=>o(null),onDeleteTask:U.projectArchivedAt?void 0:ie,isDeleting:z.isPending,autoStartState:g[U.id]??null,onAutoStartRecovered:V}),t.jsx(Yi,{isOpen:i,onClose:ge})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-col h-dvh bg-sidebar overflow-hidden text-sm",children:[t.jsxs("header",{className:"h-12 bg-sidebar flex items-center px-4 justify-between shrink-0 z-20",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(uo,{}),t.jsx(Ca,{projects:P,filterProjectId:b,setFilterProjectId:m,onCreateProject:he})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(Sa,{}),t.jsx("button",{onClick:()=>oo.getState().openSettings(),className:"p-1.5 text-muted-foreground/70 active:text-foreground rounded-md",children:t.jsx(no,{size:16})})]})]}),Re&&$.length===0?t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(ka,{})}):t.jsx(jo,{tasks:$,projects:P,selectedTaskId:null,onSelectTask:o,filterProjectId:b,setFilterProjectId:m,width:"100%",onCreateTask:Ye,onCreateProject:he,onTaskStatusChange:ee})]}),t.jsx(Yi,{isOpen:i,onClose:ge})]}):t.jsxs("div",{ref:h,className:"flex flex-col h-screen bg-sidebar overflow-hidden text-sm",children:[t.jsxs("header",{className:se("h-12 bg-sidebar flex items-center px-4 justify-between flex-shrink-0 z-20 relative",_e&&"app-region-drag",pt&&"pr-[150px]"),children:[t.jsxs("div",{className:se("flex items-center gap-2 min-w-0",be&&"pl-[72px]"),children:[t.jsx(uo,{}),t.jsx(Ca,{projects:P,filterProjectId:b,setFilterProjectId:m,onCreateProject:he,className:_e?"app-region-no-drag":void 0})]}),t.jsxs("div",{className:se("flex items-center gap-1",_e&&"app-region-no-drag"),children:[t.jsx("div",{className:_e?"app-region-no-drag":void 0,children:t.jsx(Sa,{})}),t.jsx("button",{onClick:()=>oo.getState().openSettings(),className:se("p-1.5 text-muted-foreground/70 hover:text-foreground hover:bg-accent rounded-md transition-colors",_e&&"app-region-no-drag"),children:t.jsx(no,{size:16})})]})]}),t.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[Re&&$.length===0?t.jsx("div",{className:"h-full overflow-hidden flex-shrink-0",style:{width:v},children:t.jsx(ka,{})}):t.jsx(jo,{tasks:$,projects:P,selectedTaskId:K,onSelectTask:o,filterProjectId:b,setFilterProjectId:m,width:v,onCreateTask:G,onCreateProject:he,isCreateActive:!K,onTaskStatusChange:ee,onDeleteTask:ie}),t.jsx("div",{onMouseDown:pe,className:"w-1 cursor-col-resize hover:bg-border active:bg-ring/40 transition-colors z-50 -ml-[2px] flex-shrink-0 h-full",title:e("Drag to resize")}),t.jsx("div",{className:"flex-1 flex min-w-0 mb-2 mr-2 rounded-xl border border-border/50 bg-background overflow-hidden",children:K&&U?t.jsx(X0,{task:U,onDeleteTask:U.projectArchivedAt?void 0:ie,isDeleting:z.isPending,onTaskStatusChange:U.projectArchivedAt?void 0:ee,autoStartState:g[U.id]??null,onAutoStartRecovered:V}):K&&!U?t.jsx("div",{className:"flex-1 flex items-center justify-center bg-background min-w-0",children:t.jsx("span",{className:"text-sm text-muted-foreground/70",children:e("Loading...")})}):t.jsx("div",{className:"flex-1 flex flex-col items-center justify-center bg-background min-w-0 px-8 pb-[10vh]",children:t.jsxs("div",{className:"w-full max-w-2xl flex flex-col items-center animate-[fadeInUp_0.5s_cubic-bezier(0.16,1,0.3,1)]",children:[t.jsx("h1",{className:"max-w-full text-center text-[26px] font-medium tracking-tight leading-snug text-foreground mb-6 break-words",children:Ke}),t.jsx(co,{projects:Ze,providers:Xe,isProvidersLoading:y,onSubmit:ne,defaultProjectId:ye,defaultProviderId:Be,onProjectChange:Ie,createStep:u})]})})})]}),t.jsx(Yi,{isOpen:i,onClose:ge})]})}const mb=Object.freeze(Object.defineProperty({__proto__:null,ProjectKanbanPage:Wx},Symbol.toStringTag,{value:"Module"}));export{mb as P,Kl as l};
|