agent-tower 0.5.3-beta.6 → 0.5.3-beta.8
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 +13 -0
- package/dist/app.js.map +1 -1
- package/dist/cli.js +26 -3
- package/dist/cli.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 +8 -0
- package/dist/core/container.js.map +1 -1
- package/dist/executors/__tests__/base.executor.test.js +83 -10
- package/dist/executors/__tests__/base.executor.test.js.map +1 -1
- package/dist/executors/__tests__/claude-code.executor.test.d.ts +2 -0
- package/dist/executors/__tests__/claude-code.executor.test.d.ts.map +1 -0
- package/dist/executors/__tests__/claude-code.executor.test.js +72 -0
- package/dist/executors/__tests__/claude-code.executor.test.js.map +1 -0
- package/dist/executors/__tests__/providers-availability.test.d.ts +2 -0
- package/dist/executors/__tests__/providers-availability.test.d.ts.map +1 -0
- package/dist/executors/__tests__/providers-availability.test.js +92 -0
- package/dist/executors/__tests__/providers-availability.test.js.map +1 -0
- package/dist/executors/__tests__/stdin-prompt.executors.test.d.ts +2 -0
- package/dist/executors/__tests__/stdin-prompt.executors.test.d.ts.map +1 -0
- package/dist/executors/__tests__/stdin-prompt.executors.test.js +177 -0
- package/dist/executors/__tests__/stdin-prompt.executors.test.js.map +1 -0
- package/dist/executors/base.executor.d.ts.map +1 -1
- package/dist/executors/base.executor.js +131 -33
- package/dist/executors/base.executor.js.map +1 -1
- package/dist/executors/claude-code.executor.d.ts.map +1 -1
- package/dist/executors/claude-code.executor.js +22 -52
- package/dist/executors/claude-code.executor.js.map +1 -1
- package/dist/executors/codex.executor.js +4 -4
- package/dist/executors/codex.executor.js.map +1 -1
- package/dist/executors/cursor-agent.executor.d.ts.map +1 -1
- package/dist/executors/cursor-agent.executor.js +4 -6
- package/dist/executors/cursor-agent.executor.js.map +1 -1
- package/dist/executors/gemini-cli.executor.d.ts.map +1 -1
- package/dist/executors/gemini-cli.executor.js +9 -8
- package/dist/executors/gemini-cli.executor.js.map +1 -1
- package/dist/executors/image-utils.d.ts.map +1 -1
- package/dist/executors/image-utils.js +4 -22
- package/dist/executors/image-utils.js.map +1 -1
- package/dist/index.js +37 -2
- package/dist/index.js.map +1 -1
- package/dist/middleware/__tests__/agent-cli-local-only.test.d.ts +2 -0
- package/dist/middleware/__tests__/agent-cli-local-only.test.d.ts.map +1 -0
- package/dist/middleware/__tests__/agent-cli-local-only.test.js +119 -0
- package/dist/middleware/__tests__/agent-cli-local-only.test.js.map +1 -0
- package/dist/middleware/agent-cli-local-only.d.ts +5 -0
- package/dist/middleware/agent-cli-local-only.d.ts.map +1 -0
- package/dist/middleware/agent-cli-local-only.js +80 -0
- package/dist/middleware/agent-cli-local-only.js.map +1 -0
- package/dist/pipeline/agent-pipeline.d.ts.map +1 -1
- package/dist/pipeline/agent-pipeline.js +27 -2
- package/dist/pipeline/agent-pipeline.js.map +1 -1
- package/dist/routes/__tests__/agent-cli-environment.test.d.ts +2 -0
- package/dist/routes/__tests__/agent-cli-environment.test.d.ts.map +1 -0
- package/dist/routes/__tests__/agent-cli-environment.test.js +139 -0
- package/dist/routes/__tests__/agent-cli-environment.test.js.map +1 -0
- package/dist/routes/agent-cli-environment.d.ts +3 -0
- package/dist/routes/agent-cli-environment.d.ts.map +1 -0
- package/dist/routes/agent-cli-environment.js +92 -0
- package/dist/routes/agent-cli-environment.js.map +1 -0
- 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/services/__tests__/conversation.service.test.js +63 -0
- package/dist/services/__tests__/conversation.service.test.js.map +1 -1
- package/dist/services/__tests__/team-reconciler.service.test.js +2 -2
- package/dist/services/__tests__/team-reconciler.service.test.js.map +1 -1
- package/dist/services/__tests__/team-run.service.test.js +17 -16
- package/dist/services/__tests__/team-run.service.test.js.map +1 -1
- package/dist/services/agent-cli/__tests__/detection.test.d.ts +2 -0
- package/dist/services/agent-cli/__tests__/detection.test.d.ts.map +1 -0
- package/dist/services/agent-cli/__tests__/detection.test.js +77 -0
- package/dist/services/agent-cli/__tests__/detection.test.js.map +1 -0
- package/dist/services/agent-cli/__tests__/environment-task-manager.test.d.ts +2 -0
- package/dist/services/agent-cli/__tests__/environment-task-manager.test.d.ts.map +1 -0
- package/dist/services/agent-cli/__tests__/environment-task-manager.test.js +228 -0
- package/dist/services/agent-cli/__tests__/environment-task-manager.test.js.map +1 -0
- package/dist/services/agent-cli/__tests__/manifest-downloader.test.d.ts +2 -0
- package/dist/services/agent-cli/__tests__/manifest-downloader.test.d.ts.map +1 -0
- package/dist/services/agent-cli/__tests__/manifest-downloader.test.js +127 -0
- package/dist/services/agent-cli/__tests__/manifest-downloader.test.js.map +1 -0
- package/dist/services/agent-cli/detection.d.ts +27 -0
- package/dist/services/agent-cli/detection.d.ts.map +1 -0
- package/dist/services/agent-cli/detection.js +144 -0
- package/dist/services/agent-cli/detection.js.map +1 -0
- package/dist/services/agent-cli/downloader.d.ts +24 -0
- package/dist/services/agent-cli/downloader.d.ts.map +1 -0
- package/dist/services/agent-cli/downloader.js +152 -0
- package/dist/services/agent-cli/downloader.js.map +1 -0
- package/dist/services/agent-cli/environment.service.d.ts +35 -0
- package/dist/services/agent-cli/environment.service.d.ts.map +1 -0
- package/dist/services/agent-cli/environment.service.js +127 -0
- package/dist/services/agent-cli/environment.service.js.map +1 -0
- package/dist/services/agent-cli/manifest-validator.d.ts +4 -0
- package/dist/services/agent-cli/manifest-validator.d.ts.map +1 -0
- package/dist/services/agent-cli/manifest-validator.js +56 -0
- package/dist/services/agent-cli/manifest-validator.js.map +1 -0
- package/dist/services/agent-cli/manifest.d.ts +6 -0
- package/dist/services/agent-cli/manifest.d.ts.map +1 -0
- package/dist/services/agent-cli/manifest.js +180 -0
- package/dist/services/agent-cli/manifest.js.map +1 -0
- package/dist/services/agent-cli/security.d.ts +28 -0
- package/dist/services/agent-cli/security.d.ts.map +1 -0
- package/dist/services/agent-cli/security.js +148 -0
- package/dist/services/agent-cli/security.js.map +1 -0
- package/dist/services/agent-cli/task-manager.d.ts +39 -0
- package/dist/services/agent-cli/task-manager.d.ts.map +1 -0
- package/dist/services/agent-cli/task-manager.js +228 -0
- package/dist/services/agent-cli/task-manager.js.map +1 -0
- package/dist/services/conversation.service.d.ts.map +1 -1
- package/dist/services/conversation.service.js +17 -1
- package/dist/services/conversation.service.js.map +1 -1
- package/dist/services/mcp-config.service.js +1 -1
- package/dist/services/mcp-config.service.js.map +1 -1
- package/dist/services/mcp-config.service.test.js +19 -3
- package/dist/services/mcp-config.service.test.js.map +1 -1
- package/dist/services/session-manager.d.ts +9 -8
- package/dist/services/session-manager.d.ts.map +1 -1
- package/dist/services/session-manager.js +129 -16
- package/dist/services/session-manager.js.map +1 -1
- package/dist/services/task.service.d.ts +2 -2
- package/dist/services/team-run.service.d.ts.map +1 -1
- package/dist/services/team-run.service.js +4 -7
- package/dist/services/team-run.service.js.map +1 -1
- package/dist/services/terminal-manager.d.ts.map +1 -1
- package/dist/services/terminal-manager.js +39 -7
- package/dist/services/terminal-manager.js.map +1 -1
- package/dist/services/workspace.service.d.ts +7 -7
- package/dist/utils/error-log.d.ts +20 -0
- package/dist/utils/error-log.d.ts.map +1 -0
- package/dist/utils/error-log.js +176 -0
- package/dist/utils/error-log.js.map +1 -0
- package/dist/utils/error-log.test.d.ts +2 -0
- package/dist/utils/error-log.test.d.ts.map +1 -0
- package/dist/utils/error-log.test.js +233 -0
- package/dist/utils/error-log.test.js.map +1 -0
- package/dist/utils/prisma-cli-env.d.ts +3 -0
- package/dist/utils/prisma-cli-env.d.ts.map +1 -0
- package/dist/utils/prisma-cli-env.js +15 -0
- package/dist/utils/prisma-cli-env.js.map +1 -0
- package/dist/utils/prisma-cli-env.test.d.ts +2 -0
- package/dist/utils/prisma-cli-env.test.d.ts.map +1 -0
- package/dist/utils/prisma-cli-env.test.js +34 -0
- package/dist/utils/prisma-cli-env.test.js.map +1 -0
- package/dist/utils/process-launch.d.ts +4 -0
- package/dist/utils/process-launch.d.ts.map +1 -1
- package/dist/utils/process-launch.js +106 -16
- package/dist/utils/process-launch.js.map +1 -1
- package/dist/utils/process-launch.test.js +138 -3
- package/dist/utils/process-launch.test.js.map +1 -1
- package/dist/web/assets/{AgentDemoPage-BqUFGORQ.js → AgentDemoPage-gztcIidI.js} +1 -1
- package/dist/web/assets/AgentEnvironmentSettingsPage-CPNttAOj.js +1 -0
- package/dist/web/assets/AgentLogo-Bqjt1u2k.js +1 -0
- package/dist/web/assets/ConversationPage-DdfPLaBU.js +3 -0
- package/dist/web/assets/CreateTaskInput-DQSvlvL0.js +1 -0
- package/dist/web/assets/{DemoPage-DohwggTK.js → DemoPage-BHRQrxxs.js} +3 -3
- package/dist/web/assets/{GeneralSettingsPage-BqSO35vU.js → GeneralSettingsPage-c6tWGPk7.js} +1 -1
- package/dist/web/assets/{Icons-B5Qr68Dp.js → Icons-hnXjnfjL.js} +1 -1
- package/dist/web/assets/{LoadingPreviewPage-DBVTXpq2.js → LoadingPreviewPage-D_TI4PEx.js} +1 -1
- package/dist/web/assets/McpSettingsPage-D6b7ZWOS.js +1 -0
- package/dist/web/assets/{MemberAvatar-DmWOKCwf.js → MemberAvatar-DKsedKpu.js} +1 -1
- package/dist/web/assets/NotificationSettingsPage-Cv91U2pg.js +1 -0
- package/dist/web/assets/{ProfileSettingsPage-BcUtq3sY.js → ProfileSettingsPage-K_eadHzF.js} +1 -1
- package/dist/web/assets/ProjectKanbanPage-Cw4kAimX.js +89 -0
- package/dist/web/assets/{ProjectKanbanPage-G5OQeJvU.css → ProjectKanbanPage-DcpNTP1B.css} +1 -1
- package/dist/web/assets/ProjectSettingsPage-Vw4sQoAf.js +2 -0
- package/dist/web/assets/{ProviderSettingsPage-CX8WeQ3x.js → ProviderSettingsPage-DeNiqchP.js} +13 -13
- package/dist/web/assets/{SettingsMasterDetail-BtiI8TDc.js → SettingsMasterDetail-BusgjyV7.js} +1 -1
- package/dist/web/assets/TeamSettingsPage-DIQuN3Y5.js +1 -0
- package/dist/web/assets/{arc-BP5t0cJz.js → arc-cT4PVtdQ.js} +1 -1
- package/dist/web/assets/architectureDiagram-3BPJPVTR-DYwJxluW.js +36 -0
- package/dist/web/assets/{arrow-left-CH7x-bnE.js → arrow-left-DWeEJsaX.js} +1 -1
- package/dist/web/assets/{blockDiagram-GPEHLZMM-C0obS1hu.js → blockDiagram-GPEHLZMM-CaXsST1G.js} +1 -1
- package/dist/web/assets/{c4Diagram-AAUBKEIU-DLOq2msX.js → c4Diagram-AAUBKEIU-DKqAyb1m.js} +1 -1
- package/dist/web/assets/channel--M3xJN0e.js +1 -0
- package/dist/web/assets/check-CjNklwnC.js +1 -0
- package/dist/web/assets/{chevron-down-CBY3fFTT.js → chevron-down-o4IZE_P6.js} +1 -1
- package/dist/web/assets/chevron-right-DSyyoNau.js +1 -0
- package/dist/web/assets/{chevron-up-721LBv_e.js → chevron-up-BsLA8Xot.js} +1 -1
- package/dist/web/assets/{chunk-2J33WTMH-C07Su0AF.js → chunk-2J33WTMH-DoC7k16y.js} +1 -1
- package/dist/web/assets/{chunk-4BX2VUAB-DAdn-ED3.js → chunk-4BX2VUAB-CMKi8GO_.js} +1 -1
- package/dist/web/assets/{chunk-55IACEB6-BL4-BcAX.js → chunk-55IACEB6-Lyg5IKqI.js} +1 -1
- package/dist/web/assets/{chunk-727SXJPM-BmmMDMNV.js → chunk-727SXJPM-ColYow00.js} +1 -1
- package/dist/web/assets/{chunk-AQP2D5EJ-CeLsYTvJ.js → chunk-AQP2D5EJ-CoT-4pKg.js} +1 -1
- package/dist/web/assets/{chunk-FMBD7UC4-Bs7S01MB.js → chunk-FMBD7UC4-DVIaL62f.js} +1 -1
- package/dist/web/assets/{chunk-ND2GUHAM-uqytV5JO.js → chunk-ND2GUHAM-BNuafnYz.js} +1 -1
- package/dist/web/assets/{chunk-QZHKN3VN-DGM3LKCe.js → chunk-QZHKN3VN-mqqlxbRp.js} +1 -1
- package/dist/web/assets/{circle-alert-Dkp6R_Ml.js → circle-alert-FqsC_oWX.js} +1 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-BkKX675E.js +1 -0
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-BkKX675E.js +1 -0
- package/dist/web/assets/{code-block-OCS4YCEC-C_fs5i5h.js → code-block-OCS4YCEC-BHWPqjt4.js} +1 -1
- package/dist/web/assets/confirm-dialog-BRqwAzwk.js +1 -0
- package/dist/web/assets/copy-r1RvUhIY.js +1 -0
- package/dist/web/assets/cose-bilkent-S5V4N54A-Dx6hZ-zB.js +1 -0
- package/dist/web/assets/{dagre-BM42HDAG-D0-HOAOA.js → dagre-BM42HDAG-jCqcQJ4A.js} +1 -1
- package/dist/web/assets/{diagram-2AECGRRQ-Cyt7AAOQ.js → diagram-2AECGRRQ-BFaFAwAW.js} +1 -1
- package/dist/web/assets/{diagram-5GNKFQAL-BBv9SoKB.js → diagram-5GNKFQAL-D0VOgGBN.js} +1 -1
- package/dist/web/assets/{diagram-KO2AKTUF-DV5NTHkX.js → diagram-KO2AKTUF-OkBj16PX.js} +1 -1
- package/dist/web/assets/{diagram-LMA3HP47-eNPojcJF.js → diagram-LMA3HP47-Ca28pfZT.js} +1 -1
- package/dist/web/assets/{diagram-OG6HWLK6-DYNkChUG.js → diagram-OG6HWLK6-BdQf7KOI.js} +1 -1
- package/dist/web/assets/{erDiagram-TEJ5UH35-ZXZ2vyVY.js → erDiagram-TEJ5UH35-Bf80VYE6.js} +1 -1
- package/dist/web/assets/{flowDiagram-I6XJVG4X-E8oqHUJx.js → flowDiagram-I6XJVG4X-BZWZqm_C.js} +1 -1
- package/dist/web/assets/{folder-BxT7ExMF.js → folder-C-l50KQ-.js} +1 -1
- package/dist/web/assets/folder-picker-ROPpPW7C.js +1 -0
- package/dist/web/assets/ganttDiagram-6RSMTGT7-CWf25QDV.js +292 -0
- package/dist/web/assets/{gitGraphDiagram-PVQCEYII-3dNQBESX.js → gitGraphDiagram-PVQCEYII-9cyYoW83.js} +1 -1
- package/dist/web/assets/index-3VWij2vw.js +122 -0
- package/dist/web/assets/index-C4wUDrio.css +1 -0
- package/dist/web/assets/{index-DhYpUXuu.js → index-Cask0_DN.js} +4 -4
- package/dist/web/assets/{infoDiagram-5YYISTIA-DkDDpqvX.js → infoDiagram-5YYISTIA-DWSuhoXN.js} +1 -1
- package/dist/web/assets/{input-CupQF5Np.js → input-Dyl1onpD.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-BSm79ZFA.js → ishikawaDiagram-YF4QCWOH-BfxkZcbP.js} +1 -1
- package/dist/web/assets/{journeyDiagram-JHISSGLW-BCP6kLky.js → journeyDiagram-JHISSGLW-keJyzDNt.js} +1 -1
- package/dist/web/assets/{kanban-definition-UN3LZRKU-jzLQwKw3.js → kanban-definition-UN3LZRKU-wo8SY3VQ.js} +1 -1
- package/dist/web/assets/{layers-CCP9NEZU.js → layers-CT4P8Wt_.js} +1 -1
- package/dist/web/assets/{linear-DWq5jvYH.js → linear-DXmYF97H.js} +1 -1
- package/dist/web/assets/mermaid-NOHMQCX5-DjJdrIaK.js +123 -0
- package/dist/web/assets/{message-square-tSoG7yGO.js → message-square-B0uoScMB.js} +1 -1
- package/dist/web/assets/{mindmap-definition-RKZ34NQL-C5FxGBPQ.js → mindmap-definition-RKZ34NQL-BR1VqGMr.js} +1 -1
- package/dist/web/assets/modal-CN741Elc.js +1 -0
- package/dist/web/assets/{pencil-BOmVWDhP.js → pencil-B05Eh9uE.js} +1 -1
- package/dist/web/assets/{pieDiagram-4H26LBE5-CmWVRs82.js → pieDiagram-4H26LBE5-DmIVi6kN.js} +1 -1
- package/dist/web/assets/{quadrantDiagram-W4KKPZXB-B4s3NNDO.js → quadrantDiagram-W4KKPZXB-Bh1fx3P_.js} +1 -1
- package/dist/web/assets/{requirementDiagram-4Y6WPE33-C2KmzOV2.js → requirementDiagram-4Y6WPE33-BheNLVEb.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-5OEKKPKP-CJbPnzq8.js → sankeyDiagram-5OEKKPKP-CWuQByUh.js} +1 -1
- package/dist/web/assets/select-B2NVUyiF.js +1 -0
- package/dist/web/assets/{sequenceDiagram-3UESZ5HK-BFea2ow4.js → sequenceDiagram-3UESZ5HK-Blll85Hd.js} +1 -1
- package/dist/web/assets/{stateDiagram-AJRCARHV-osdtBRSX.js → stateDiagram-AJRCARHV-C31npQBQ.js} +1 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-BXcVcTJl.js +1 -0
- package/dist/web/assets/switch-BiB7Kgpg.js +1 -0
- package/dist/web/assets/{textarea-Cj61Z7ha.js → textarea-Du_ydNYw.js} +1 -1
- package/dist/web/assets/{timeline-definition-PNZ67QCA-BlXV0jf2.js → timeline-definition-PNZ67QCA-BXjt2YG8.js} +1 -1
- package/dist/web/assets/{trash-2-D2zJVeEr.js → trash-2-CWVsy23V.js} +1 -1
- package/dist/web/assets/upload-C-wK_vWU.js +1 -0
- package/dist/web/assets/{use-profiles-BSYIQUHp.js → use-profiles-DwPVupVL.js} +1 -1
- package/dist/web/assets/{use-providers-Ct5qGj1d.js → use-providers-C-PIoFvi.js} +1 -1
- package/dist/web/assets/useNormalizedLogs-CGOi3cNq.js +1 -0
- package/dist/web/assets/{vennDiagram-CIIHVFJN-CCuhn7zI.js → vennDiagram-CIIHVFJN-DKpjIApG.js} +1 -1
- package/dist/web/assets/{wardley-L42UT6IY-Xu-SY-Xt.js → wardley-L42UT6IY-DvryVGdS.js} +1 -1
- package/dist/web/assets/{wardleyDiagram-YWT4CUSO-BDVBG-Eu.js → wardleyDiagram-YWT4CUSO-CtUF9zNr.js} +1 -1
- package/dist/web/assets/{xychartDiagram-2RQKCTM6-DC5IWyMr.js → xychartDiagram-2RQKCTM6-Qx4Q-1Xq.js} +1 -1
- package/dist/web/index.html +2 -2
- package/node_modules/@agent-tower/shared/dist/types.d.ts +123 -0
- package/node_modules/@agent-tower/shared/dist/types.d.ts.map +1 -1
- package/node_modules/@prisma/client/.prisma/client/edge.js +2 -2
- package/node_modules/@prisma/client/.prisma/client/index.js +2 -2
- package/package.json +1 -1
- package/dist/web/assets/AgentLogo-O_lfAIQi.js +0 -1
- package/dist/web/assets/ConversationPage-t8BHC8qL.js +0 -3
- package/dist/web/assets/CreateTaskInput-D5aroK_o.js +0 -2
- package/dist/web/assets/McpSettingsPage-B4hjk8Q6.js +0 -1
- package/dist/web/assets/NotificationSettingsPage-DiUyq7V-.js +0 -1
- package/dist/web/assets/ProjectKanbanPage-klp2fAN1.js +0 -89
- package/dist/web/assets/ProjectSettingsPage-D2gQsbTJ.js +0 -2
- package/dist/web/assets/TeamSettingsPage-CZgtzFUH.js +0 -1
- package/dist/web/assets/architectureDiagram-3BPJPVTR-B4nGdxyB.js +0 -36
- package/dist/web/assets/channel-ByQ8jatA.js +0 -1
- package/dist/web/assets/check-EXzHBr5H.js +0 -1
- package/dist/web/assets/chevron-right-DZo7j27r.js +0 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-BTR6CDm1.js +0 -1
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-BTR6CDm1.js +0 -1
- package/dist/web/assets/confirm-dialog-IGqDL03n.js +0 -1
- package/dist/web/assets/cose-bilkent-S5V4N54A-2VABc7UM.js +0 -1
- package/dist/web/assets/folder-picker-57gIIPSi.js +0 -1
- package/dist/web/assets/ganttDiagram-6RSMTGT7-CEAjt7Nr.js +0 -292
- package/dist/web/assets/index-B2TV-FU2.js +0 -120
- package/dist/web/assets/index-D1vY2KQU.css +0 -1
- package/dist/web/assets/loader-circle-RvIxJahM.js +0 -1
- package/dist/web/assets/mermaid-NOHMQCX5-v8DEF9xx.js +0 -122
- package/dist/web/assets/modal-Dc2shjmi.js +0 -1
- package/dist/web/assets/rotate-ccw-BJfFrvl2.js +0 -1
- package/dist/web/assets/select-C_UWYFsQ.js +0 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-ChsboHHf.js +0 -1
- package/dist/web/assets/switch-C6O0UllM.js +0 -1
- package/dist/web/assets/terminal-BKrr_mRJ.js +0 -1
- package/dist/web/assets/upload-Q5mYpwnh.js +0 -1
- package/dist/web/assets/useNormalizedLogs-DqPhzW9t.js +0 -1
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DhYpUXuu.js","assets/index-B2TV-FU2.js","assets/index-D1vY2KQU.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{a3 as tn,a4 as Xn,a5 as Hc,a6 as $c,a7 as Uc,a8 as Bi,a9 as qc,aa as Kc,k as ot,ab as Xc,ac as Vc,r as C,ad as Yc,ae as Gc,af as Qc,ag as Zc,ah as Vn,ai as Yn,aj as Jc,ak as ed,al as td,h as Te,am as ae,H as es,i as Tt,l as St,m as ge,q as ne,u as ce,j as t,Z as pt,M as ma,N as sd,g as te,B as Re,an as pa,ao as ga,ap as va,a2 as us,X as ns,aq as rd,ar as id,s as nd,as as od,at as ad,au as ld,t as ct,I as Jt,J as at,K as ks,av as xa,aw as sn,a0 as cd,ax as _a,ay as rn,az as ba,aA as ya,aB as Sa,aC as dd,aD as ud,aE as hd,aF as fd,aG as md,O as Gn,Y as Qn}from"./index-B2TV-FU2.js";import{S as it,Q as nn,h as pd,i as on,W as jt,j as Rt,C as Gs,A as Bt,b as Nr,T as It}from"./mermaid-NOHMQCX5-v8DEF9xx.js";import{C as an}from"./confirm-dialog-IGqDL03n.js";import{c as wa,a as Ca,b as ka,I as Ea,d as ja,A as Zn,G as Na}from"./Icons-B5Qr68Dp.js";import{C as yt}from"./chevron-down-CBY3fFTT.js";import{C as Mt}from"./chevron-right-DZo7j27r.js";import{f as ln,S as gd,b as cn,u as dn,A as Qs,c as un,d as hn,g as vd,F as Ra,G as Aa,Z as xd,I as Ma,T as fn,h as _d,a as Ta,P as Da,i as bd,C as Jn,B as eo,e as to}from"./CreateTaskInput-D5aroK_o.js";import{a as yd,F as Sd,f as wd,g as Cd,e as kd,u as Ed}from"./folder-picker-57gIIPSi.js";import{M as qr}from"./message-square-tSoG7yGO.js";import{L as As}from"./layers-CCP9NEZU.js";import{S as Ms,P as mn,u as La,a as Pa,T as Rr}from"./useNormalizedLogs-DqPhzW9t.js";import{u as Ds}from"./use-providers-Ct5qGj1d.js";import{A as Kr}from"./AgentLogo-O_lfAIQi.js";import{M as Ft}from"./MemberAvatar-DmWOKCwf.js";import{C as Oa}from"./chevron-up-721LBv_e.js";import{C as qt}from"./check-EXzHBr5H.js";import{M as hs,T as rr}from"./modal-Dc2shjmi.js";import{S as cs}from"./select-C_UWYFsQ.js";import{P as ts,T as pn}from"./trash-2-D2zJVeEr.js";import{T as Ar,C as so}from"./terminal-BKrr_mRJ.js";import{F as Ia}from"./folder-BxT7ExMF.js";import{L as Ye}from"./loader-circle-RvIxJahM.js";import{U as Mr,C as jd}from"./upload-Q5mYpwnh.js";import{A as Zs}from"./arrow-left-CH7x-bnE.js";import{R as Nd}from"./rotate-ccw-BJfFrvl2.js";import"./circle-alert-Dkp6R_Ml.js";var Rd=class extends tn{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:Xn()})}getOptimisticResult(e){return e.behavior=Xn(),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:i}=o,n=r.fetchMeta?.fetchMore?.direction,l=v&&n==="forward",u=p&&n==="forward",c=v&&n==="backward",g=p&&n==="backward";return{...o,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:$c(s,r.data),hasPreviousPage:Hc(s,r.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:c,isFetchingPreviousPage:g,isRefetchError:i&&!l&&!c,isRefetching:m&&!u&&!g}}};function ro(e,s){const r=new Set(s);return e.filter(o=>!r.has(o))}function Ad(e,s,r){const o=e.slice(0);return o[s]=r,o}var Md=class extends Uc{#r;#e;#i;#n;#t;#s;#o;#a;#l;#c=[];constructor(e,s,r){super(),this.#r=e,this.#n=r,this.#i=[],this.#t=[],this.#e=[],this.setQueries(s)}onSubscribe(){this.listeners.size===1&&this.#t.forEach(e=>{e.subscribe(s=>{this.#f(e,s)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach(e=>{e.destroy()})}setQueries(e,s){this.#i=e,this.#n=s,Bi.batch(()=>{const r=this.#t,o=this.#h(this.#i);o.forEach(u=>u.observer.setOptions(u.defaultedQueryOptions));const p=o.map(u=>u.observer),m=p.map(u=>u.getCurrentResult()),v=r.length!==p.length,i=p.some((u,c)=>u!==r[c]),n=v||i,l=n?!0:m.some((u,c)=>{const g=this.#e[c];return!g||!qc(u,g)});!n&&!l||(n&&(this.#c=o,this.#t=p),this.#e=m,this.hasListeners()&&(n&&(ro(r,p).forEach(u=>{u.destroy()}),ro(p,r).forEach(u=>{u.subscribe(c=>{this.#f(u,c)})})),this.#m()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,s){const r=this.#h(e),o=r.map(m=>m.observer.getOptimisticResult(m.defaultedQueryOptions)),p=r.map(m=>m.defaultedQueryOptions.queryHash);return[o,m=>this.#u(m??o,s,p),()=>this.#d(o,r)]}#d(e,s){return s.map((r,o)=>{const p=e[o];return r.defaultedQueryOptions.notifyOnChangeProps?p:r.observer.trackResult(p,m=>{s.forEach(v=>{v.observer.trackProp(m)})})})}#u(e,s,r){if(s){const o=this.#l,p=r!==void 0&&o!==void 0&&(o.length!==r.length||r.some((m,v)=>m!==o[v]));return(!this.#s||this.#e!==this.#a||p||s!==this.#o)&&(this.#o=s,this.#a=this.#e,r!==void 0&&(this.#l=r),this.#s=Kc(this.#s,s(e))),this.#s}return e}#h(e){const s=new Map;this.#t.forEach(o=>{const p=o.options.queryHash;if(!p)return;const m=s.get(p);m?m.push(o):s.set(p,[o])});const r=[];return e.forEach(o=>{const p=this.#r.defaultQueryOptions(o),v=s.get(p.queryHash)?.shift()??new tn(this.#r,p);r.push({defaultedQueryOptions:p,observer:v})}),r}#f(e,s){const r=this.#t.indexOf(e);r!==-1&&(this.#e=Ad(this.#e,r,s),this.#m())}#m(){if(this.hasListeners()){const e=this.#s,s=this.#d(this.#e,this.#c),r=this.#u(s,this.#n?.combine);e!==r&&Bi.batch(()=>{this.listeners.forEach(o=>{o(this.#e)})})}}};function Td({queries:e,...s},r){const o=ot(),p=Xc(),m=Vc(),v=C.useMemo(()=>e.map(x=>{const a=o.defaultQueryOptions(x);return a._optimisticResults=p?"isRestoring":"optimistic",a}),[e,o,p]);v.forEach(x=>{Yc(x);const a=o.getQueryCache().get(x.queryHash);Gc(x,m,a)}),Qc(m);const[i]=C.useState(()=>new Md(o,v,s)),[n,l,u]=i.getOptimisticResult(v,s.combine),c=!p&&s.subscribed!==!1;C.useSyncExternalStore(C.useCallback(x=>c?i.subscribe(Bi.batchCalls(x)):Zc,[i,c]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),C.useEffect(()=>{i.setQueries(v,s)},[v,s,i]);const _=n.some((x,a)=>Vn(v[a],x))?n.flatMap((x,a)=>{const h=v[a];if(h){const d=new tn(o,h);if(Vn(h,x))return Yn(h,d,m);Jc(x,p)&&Yn(h,d,m)}return[]}):[];if(_.length>0)throw Promise.all(_);const y=n.find((x,a)=>{const h=v[a];return h&&ed({result:x,errorResetBoundary:m,throwOnError:h.throwOnError,query:o.getQueryCache().get(h.queryHash),suspense:h.suspense})});if(y?.error)throw y.error;return l(u())}function gn(e,s){return td(e,Rd)}const Dd=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Ld=Te("arrow-right",Dd);const Pd=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ba=Te("ban",Pd);const Od=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Id=Te("chevron-left",Od);const Bd=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Es=Te("clock-3",Bd);const Fd=[["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"}]],Xr=Te("code-xml",Fd);const zd=[["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"}]],io=Te("copy-plus",zd);const Wd=[["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"}]],Fa=Te("ellipsis-vertical",Wd);const Hd=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],vn=Te("external-link",Hd);const $d=[["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"}]],Ud=Te("file-braces-corner",$d);const qd=[["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"}]],Tr=Te("file-code-corner",qd);const Kd=[["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"}]],Xd=Te("file-exclamation-point",Kd);const Vd=[["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"}]],Vr=Te("folder-open",Vd);const Yd=[["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"}]],Ls=Te("git-graph",Yd);const Gd=[["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"}]],Ts=Te("history",Gd);const Qd=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Zd=Te("info",Qd);const Jd=[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]],eu=Te("lock-keyhole",Jd);const tu=[["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"}]],su=Te("maximize",tu);const ru=[["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"}]],iu=Te("panel-left-close",ru);const nu=[["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"}]],ou=Te("panel-left-open",nu);const au=[["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"}]],lu=Te("panel-right-close",au);const cu=[["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"}]],Fi=Te("panel-right-open",cu);const du=[["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"}]],uu=Te("pen-line",du);const hu=[["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"}]],Ut=Te("play",hu);const fu=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],ir=Te("refresh-cw",fu);const mu=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],pu=Te("save",mu);const gu=[["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"}]],za=Te("settings-2",gu);const vu=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],no=Te("smartphone",vu);const xu=[["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"}]],xr=Te("user-plus",xu);const _u=[["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"}]],bu=Te("zoom-in",_u);const yu=[["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"}]],Su=Te("zoom-out",yu),Yr=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ps(e){const s=Object.prototype.toString.call(e);return s==="[object Window]"||s==="[object global]"}function xn(e){return"nodeType"in e}function bt(e){var s,r;return e?Ps(e)?e:xn(e)&&(s=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function _n(e){const{Document:s}=bt(e);return e instanceof s}function nr(e){return Ps(e)?!1:e instanceof bt(e).HTMLElement}function Wa(e){return e instanceof bt(e).SVGElement}function Os(e){return e?Ps(e)?e.document:xn(e)?_n(e)?e:nr(e)||Wa(e)?e.ownerDocument:document:document:document}const Kt=Yr?C.useLayoutEffect:C.useEffect;function Gr(e){const s=C.useRef(e);return Kt(()=>{s.current=e}),C.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 wu(){const e=C.useRef(null),s=C.useCallback((o,p)=>{e.current=setInterval(o,p)},[]),r=C.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[s,r]}function Js(e,s){s===void 0&&(s=[e]);const r=C.useRef(e);return Kt(()=>{r.current!==e&&(r.current=e)},s),r}function or(e,s){const r=C.useRef();return C.useMemo(()=>{const o=e(r.current);return r.current=o,o},[...s])}function Dr(e){const s=Gr(e),r=C.useRef(null),o=C.useCallback(p=>{p!==r.current&&s?.(p,r.current),r.current=p},[]);return[r,o]}function Lr(e){const s=C.useRef();return C.useEffect(()=>{s.current=e},[e]),s.current}let vi={};function Qr(e,s){return C.useMemo(()=>{if(s)return s;const r=vi[e]==null?0:vi[e]+1;return vi[e]=r,e+"-"+r},[e,s])}function Ha(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 i=Object.entries(v);for(const[n,l]of i){const u=m[n];u!=null&&(m[n]=u+e*l)}return m},{...s})}}const Rs=Ha(1),Pr=Ha(-1);function Cu(e){return"clientX"in e&&"clientY"in e}function bn(e){if(!e)return!1;const{KeyboardEvent:s}=bt(e.target);return s&&e instanceof s}function ku(e){if(!e)return!1;const{TouchEvent:s}=bt(e.target);return s&&e instanceof s}function Or(e){if(ku(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 Cu(e)?{x:e.clientX,y:e.clientY}:null}const er=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[er.Translate.toString(e),er.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:s,duration:r,easing:o}=e;return s+" "+r+"ms "+o}}}),oo="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Eu(e){return e.matches(oo)?e:e.querySelector(oo)}const ju={display:"none"};function Nu(e){let{id:s,value:r}=e;return ae.createElement("div",{id:s,style:ju},r)}function Ru(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 Au(){const[e,s]=C.useState("");return{announce:C.useCallback(o=>{o!=null&&s(o)},[]),announcement:e}}const $a=C.createContext(null);function Mu(e){const s=C.useContext($a);C.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(e)},[e,s])}function Tu(){const[e]=C.useState(()=>new Set),s=C.useCallback(o=>(e.add(o),()=>e.delete(o)),[e]);return[C.useCallback(o=>{let{type:p,event:m}=o;e.forEach(v=>{var i;return(i=v[p])==null?void 0:i.call(v,m)})},[e]),s]}const Du={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
|
-
`},Lu={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 Pu(e){let{announcements:s=Lu,container:r,hiddenTextDescribedById:o,screenReaderInstructions:p=Du}=e;const{announce:m,announcement:v}=Au(),i=Qr("DndLiveRegion"),[n,l]=C.useState(!1);if(C.useEffect(()=>{l(!0)},[]),Mu(C.useMemo(()=>({onDragStart(c){let{active:g}=c;m(s.onDragStart({active:g}))},onDragMove(c){let{active:g,over:_}=c;s.onDragMove&&m(s.onDragMove({active:g,over:_}))},onDragOver(c){let{active:g,over:_}=c;m(s.onDragOver({active:g,over:_}))},onDragEnd(c){let{active:g,over:_}=c;m(s.onDragEnd({active:g,over:_}))},onDragCancel(c){let{active:g,over:_}=c;m(s.onDragCancel({active:g,over:_}))}}),[m,s])),!n)return null;const u=ae.createElement(ae.Fragment,null,ae.createElement(Nu,{id:o,value:p.draggable}),ae.createElement(Ru,{id:i,announcement:v}));return r?es.createPortal(u,r):u}var nt;(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"})(nt||(nt={}));function Ir(){}function Ou(e,s){return C.useMemo(()=>({sensor:e,options:s??{}}),[e,s])}function Iu(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return C.useMemo(()=>[...s].filter(o=>o!=null),[...s])}const Lt=Object.freeze({x:0,y:0});function Bu(e,s){const r=Or(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 Fu(e,s){let{data:{value:r}}=e,{data:{value:o}}=s;return o-r}function zu(e,s){if(!e||e.length===0)return null;const[r]=e;return r[s]}function Wu(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,i=m-r;if(o<p&&r<m){const n=s.width*s.height,l=e.width*e.height,u=v*i,c=u/(n+l-u);return Number(c.toFixed(4))}return 0}const Hu=e=>{let{collisionRect:s,droppableRects:r,droppableContainers:o}=e;const p=[];for(const m of o){const{id:v}=m,i=r.get(v);if(i){const n=Wu(i,s);n>0&&p.push({id:v,data:{droppableContainer:m,value:n}})}}return p.sort(Fu)};function $u(e,s,r){return{...e,scaleX:s&&r?s.width/r.width:1,scaleY:s&&r?s.height/r.height:1}}function Ua(e,s){return e&&s?{x:e.left-s.left,y:e.top-s.top}:Lt}function Uu(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,i)=>({...v,top:v.top+e*i.y,bottom:v.bottom+e*i.y,left:v.left+e*i.x,right:v.right+e*i.x}),{...r})}}const qu=Uu(1);function qa(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 Ku(e,s,r){const o=qa(s);if(!o)return e;const{scaleX:p,scaleY:m,x:v,y:i}=o,n=e.left-v-(1-p)*parseFloat(r),l=e.top-i-(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:l,right:n+u,bottom:l+c,left:n}}const Xu={ignoreTransform:!1};function ar(e,s){s===void 0&&(s=Xu);let r=e.getBoundingClientRect();if(s.ignoreTransform){const{transform:l,transformOrigin:u}=bt(e).getComputedStyle(e);l&&(r=Ku(r,l,u))}const{top:o,left:p,width:m,height:v,bottom:i,right:n}=r;return{top:o,left:p,width:m,height:v,bottom:i,right:n}}function ao(e){return ar(e,{ignoreTransform:!0})}function Vu(e){const s=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function Yu(e,s){return s===void 0&&(s=bt(e).getComputedStyle(e)),s.position==="fixed"}function Gu(e,s){s===void 0&&(s=bt(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 yn(e,s){const r=[];function o(p){if(s!=null&&r.length>=s||!p)return r;if(_n(p)&&p.scrollingElement!=null&&!r.includes(p.scrollingElement))return r.push(p.scrollingElement),r;if(!nr(p)||Wa(p)||r.includes(p))return r;const m=bt(e).getComputedStyle(p);return p!==e&&Gu(p,m)&&r.push(p),Yu(p,m)?r:o(p.parentNode)}return e?o(e):r}function Ka(e){const[s]=yn(e,1);return s??null}function xi(e){return!Yr||!e?null:Ps(e)?e:xn(e)?_n(e)||e===Os(e).scrollingElement?window:nr(e)?e:null:null}function Xa(e){return Ps(e)?e.scrollX:e.scrollLeft}function Va(e){return Ps(e)?e.scrollY:e.scrollTop}function zi(e){return{x:Xa(e),y:Va(e)}}var lt;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(lt||(lt={}));function Ya(e){return!Yr||!e?!1:e===document.scrollingElement}function Ga(e){const s={x:0,y:0},r=Ya(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,i=e.scrollLeft>=o.x;return{isTop:p,isLeft:m,isBottom:v,isRight:i,maxScroll:o,minScroll:s}}const Qu={x:.2,y:.2};function Zu(e,s,r,o,p){let{top:m,left:v,right:i,bottom:n}=r;o===void 0&&(o=10),p===void 0&&(p=Qu);const{isTop:l,isBottom:u,isLeft:c,isRight:g}=Ga(e),_={x:0,y:0},y={x:0,y:0},x={height:s.height*p.y,width:s.width*p.x};return!l&&m<=s.top+x.height?(_.y=lt.Backward,y.y=o*Math.abs((s.top+x.height-m)/x.height)):!u&&n>=s.bottom-x.height&&(_.y=lt.Forward,y.y=o*Math.abs((s.bottom-x.height-n)/x.height)),!g&&i>=s.right-x.width?(_.x=lt.Forward,y.x=o*Math.abs((s.right-x.width-i)/x.width)):!c&&v<=s.left+x.width&&(_.x=lt.Backward,y.x=o*Math.abs((s.left+x.width-v)/x.width)),{direction:_,speed:y}}function Ju(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 Qa(e){return e.reduce((s,r)=>Rs(s,zi(r)),Lt)}function eh(e){return e.reduce((s,r)=>s+Xa(r),0)}function th(e){return e.reduce((s,r)=>s+Va(r),0)}function Za(e,s){if(s===void 0&&(s=ar),!e)return;const{top:r,left:o,bottom:p,right:m}=s(e);Ka(e)&&(p<=0||m<=0||r>=window.innerHeight||o>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const sh=[["x",["left","right"],eh],["y",["top","bottom"],th]];class Sn{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=yn(r),p=Qa(o);this.rect={...s},this.width=s.width,this.height=s.height;for(const[m,v,i]of sh)for(const n of v)Object.defineProperty(this,n,{get:()=>{const l=i(o),u=p[m]-l;return this.rect[n]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Ks{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 rh(e){const{EventTarget:s}=bt(e);return e instanceof s?e:Os(e)}function _i(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 Nt;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Nt||(Nt={}));function lo(e){e.preventDefault()}function ih(e){e.stopPropagation()}var $e;(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"})($e||($e={}));const Ja={start:[$e.Space,$e.Enter],cancel:[$e.Esc],end:[$e.Space,$e.Enter,$e.Tab]},nh=(e,s)=>{let{currentCoordinates:r}=s;switch(e.code){case $e.Right:return{...r,x:r.x+25};case $e.Left:return{...r,x:r.x-25};case $e.Down:return{...r,y:r.y+25};case $e.Up:return{...r,y:r.y-25}}};class el{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 Ks(Os(r)),this.windowListeners=new Ks(bt(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Nt.Resize,this.handleCancel),this.windowListeners.add(Nt.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Nt.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,o=s.node.current;o&&Za(o),r(Lt)}handleKeyDown(s){if(bn(s)){const{active:r,context:o,options:p}=this.props,{keyboardCodes:m=Ja,coordinateGetter:v=nh,scrollBehavior:i="smooth"}=p,{code:n}=s;if(m.end.includes(n)){this.handleEnd(s);return}if(m.cancel.includes(n)){this.handleCancel(s);return}const{collisionRect:l}=o.current,u=l?{x:l.left,y:l.top}:Lt;this.referenceCoordinates||(this.referenceCoordinates=u);const c=v(s,{active:r,context:o.current,currentCoordinates:u});if(c){const g=Pr(c,u),_={x:0,y:0},{scrollableAncestors:y}=o.current;for(const x of y){const a=s.code,{isTop:h,isRight:d,isLeft:f,isBottom:b,maxScroll:w,minScroll:k}=Ga(x),j=Ju(x),S={x:Math.min(a===$e.Right?j.right-j.width/2:j.right,Math.max(a===$e.Right?j.left:j.left+j.width/2,c.x)),y:Math.min(a===$e.Down?j.bottom-j.height/2:j.bottom,Math.max(a===$e.Down?j.top:j.top+j.height/2,c.y))},E=a===$e.Right&&!d||a===$e.Left&&!f,R=a===$e.Down&&!b||a===$e.Up&&!h;if(E&&S.x!==c.x){const L=x.scrollLeft+g.x,T=a===$e.Right&&L<=w.x||a===$e.Left&&L>=k.x;if(T&&!g.y){x.scrollTo({left:L,behavior:i});return}T?_.x=x.scrollLeft-L:_.x=a===$e.Right?x.scrollLeft-w.x:x.scrollLeft-k.x,_.x&&x.scrollBy({left:-_.x,behavior:i});break}else if(R&&S.y!==c.y){const L=x.scrollTop+g.y,T=a===$e.Down&&L<=w.y||a===$e.Up&&L>=k.y;if(T&&!g.x){x.scrollTo({top:L,behavior:i});return}T?_.y=x.scrollTop-L:_.y=a===$e.Down?x.scrollTop-w.y:x.scrollTop-k.y,_.y&&x.scrollBy({top:-_.y,behavior:i});break}}this.handleMove(s,Rs(Pr(c,this.referenceCoordinates),_))}}}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()}}el.activators=[{eventName:"onKeyDown",handler:(e,s,r)=>{let{keyboardCodes:o=Ja,onActivation:p}=s,{active:m}=r;const{code:v}=e.nativeEvent;if(o.start.includes(v)){const i=m.activatorNode.current;return i&&e.target!==i?!1:(e.preventDefault(),p?.({event:e.nativeEvent}),!0)}return!1}}];function co(e){return!!(e&&"distance"in e)}function uo(e){return!!(e&&"delay"in e)}class wn{constructor(s,r,o){var p;o===void 0&&(o=rh(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=Os(v),this.documentListeners=new Ks(this.document),this.listeners=new Ks(o),this.windowListeners=new Ks(bt(v)),this.initialCoordinates=(p=Or(m))!=null?p:Lt,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(Nt.Resize,this.handleCancel),this.windowListeners.add(Nt.DragStart,lo),this.windowListeners.add(Nt.VisibilityChange,this.handleCancel),this.windowListeners.add(Nt.ContextMenu,lo),this.documentListeners.add(Nt.Keydown,this.handleKeydown),r){if(o!=null&&o({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(uo(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(co(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(Nt.Click,ih,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Nt.SelectionChange,this.removeTextSelection),r(s))}handleMove(s){var r;const{activated:o,initialCoordinates:p,props:m}=this,{onMove:v,options:{activationConstraint:i}}=m;if(!p)return;const n=(r=Or(s))!=null?r:Lt,l=Pr(p,n);if(!o&&i){if(co(i)){if(i.tolerance!=null&&_i(l,i.tolerance))return this.handleCancel();if(_i(l,i.distance))return this.handleStart()}if(uo(i)&&_i(l,i.tolerance))return this.handleCancel();this.handlePending(i,l);return}s.cancelable&&s.preventDefault(),v(n)}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===$e.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const oh={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Cn extends wn{constructor(s){const{event:r}=s,o=Os(r.target);super(s,oh,o)}}Cn.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 ah={move:{name:"mousemove"},end:{name:"mouseup"}};var Wi;(function(e){e[e.RightClick=2]="RightClick"})(Wi||(Wi={}));class lh extends wn{constructor(s){super(s,ah,Os(s.event.target))}}lh.activators=[{eventName:"onMouseDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;return r.button===Wi.RightClick?!1:(o?.({event:r}),!0)}}];const bi={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class ch extends wn{constructor(s){super(s,bi)}static setup(){return window.addEventListener(bi.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(bi.move.name,s)};function s(){}}}ch.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 Xs;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Xs||(Xs={}));var Br;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Br||(Br={}));function dh(e){let{acceleration:s,activator:r=Xs.Pointer,canScroll:o,draggingRect:p,enabled:m,interval:v=5,order:i=Br.TreeOrder,pointerCoordinates:n,scrollableAncestors:l,scrollableAncestorRects:u,delta:c,threshold:g}=e;const _=hh({delta:c,disabled:!m}),[y,x]=wu(),a=C.useRef({x:0,y:0}),h=C.useRef({x:0,y:0}),d=C.useMemo(()=>{switch(r){case Xs.Pointer:return n?{top:n.y,bottom:n.y,left:n.x,right:n.x}:null;case Xs.DraggableRect:return p}},[r,p,n]),f=C.useRef(null),b=C.useCallback(()=>{const k=f.current;if(!k)return;const j=a.current.x*h.current.x,S=a.current.y*h.current.y;k.scrollBy(j,S)},[]),w=C.useMemo(()=>i===Br.TreeOrder?[...l].reverse():l,[i,l]);C.useEffect(()=>{if(!m||!l.length||!d){x();return}for(const k of w){if(o?.(k)===!1)continue;const j=l.indexOf(k),S=u[j];if(!S)continue;const{direction:E,speed:R}=Zu(k,S,d,s,g);for(const L of["x","y"])_[L][E[L]]||(R[L]=0,E[L]=0);if(R.x>0||R.y>0){x(),f.current=k,y(b,v),a.current=R,h.current=E;return}}a.current={x:0,y:0},h.current={x:0,y:0},x()},[s,b,o,x,m,v,JSON.stringify(d),JSON.stringify(_),y,l,w,u,JSON.stringify(g)])}const uh={x:{[lt.Backward]:!1,[lt.Forward]:!1},y:{[lt.Backward]:!1,[lt.Forward]:!1}};function hh(e){let{delta:s,disabled:r}=e;const o=Lr(s);return or(p=>{if(r||!o||!p)return uh;const m={x:Math.sign(s.x-o.x),y:Math.sign(s.y-o.y)};return{x:{[lt.Backward]:p.x[lt.Backward]||m.x===-1,[lt.Forward]:p.x[lt.Forward]||m.x===1},y:{[lt.Backward]:p.y[lt.Backward]||m.y===-1,[lt.Forward]:p.y[lt.Forward]||m.y===1}}},[r,s,o])}function fh(e,s){const r=s!=null?e.get(s):void 0,o=r?r.node.current:null;return or(p=>{var m;return s==null?null:(m=o??p)!=null?m:null},[o,s])}function mh(e,s){return C.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 tr;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(tr||(tr={}));var Hi;(function(e){e.Optimized="optimized"})(Hi||(Hi={}));const ho=new Map;function ph(e,s){let{dragging:r,dependencies:o,config:p}=s;const[m,v]=C.useState(null),{frequency:i,measure:n,strategy:l}=p,u=C.useRef(e),c=a(),g=Js(c),_=C.useCallback(function(h){h===void 0&&(h=[]),!g.current&&v(d=>d===null?h:d.concat(h.filter(f=>!d.includes(f))))},[g]),y=C.useRef(null),x=or(h=>{if(c&&!r)return ho;if(!h||h===ho||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 b=f.node.current,w=b?new Sn(n(b),b):null;f.rect.current=w,w&&d.set(f.id,w)}return d}return h},[e,m,r,c,n]);return C.useEffect(()=>{u.current=e},[e]),C.useEffect(()=>{c||_()},[r,c]),C.useEffect(()=>{m&&m.length>0&&v(null)},[JSON.stringify(m)]),C.useEffect(()=>{c||typeof i!="number"||y.current!==null||(y.current=setTimeout(()=>{_(),y.current=null},i))},[i,c,_,...o]),{droppableRects:x,measureDroppableContainers:_,measuringScheduled:m!=null};function a(){switch(l){case tr.Always:return!1;case tr.BeforeDragging:return r;default:return!r}}}function kn(e,s){return or(r=>e?r||(typeof s=="function"?s(e):e):null,[s,e])}function gh(e,s){return kn(e,s)}function vh(e){let{callback:s,disabled:r}=e;const o=Gr(s),p=C.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:m}=window;return new m(o)},[o,r]);return C.useEffect(()=>()=>p?.disconnect(),[p]),p}function Zr(e){let{callback:s,disabled:r}=e;const o=Gr(s),p=C.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:m}=window;return new m(o)},[r]);return C.useEffect(()=>()=>p?.disconnect(),[p]),p}function xh(e){return new Sn(ar(e),e)}function fo(e,s,r){s===void 0&&(s=xh);const[o,p]=C.useState(null);function m(){p(n=>{if(!e)return null;if(e.isConnected===!1){var l;return(l=n??r)!=null?l:null}const u=s(e);return JSON.stringify(n)===JSON.stringify(u)?n:u})}const v=vh({callback(n){if(e)for(const l of n){const{type:u,target:c}=l;if(u==="childList"&&c instanceof HTMLElement&&c.contains(e)){m();break}}}}),i=Zr({callback:m});return Kt(()=>{m(),e?(i?.observe(e),v?.observe(document.body,{childList:!0,subtree:!0})):(i?.disconnect(),v?.disconnect())},[e]),o}function _h(e){const s=kn(e);return Ua(e,s)}const mo=[];function bh(e){const s=C.useRef(e),r=or(o=>e?o&&o!==mo&&e&&s.current&&e.parentNode===s.current.parentNode?o:yn(e):mo,[e]);return C.useEffect(()=>{s.current=e},[e]),r}function yh(e){const[s,r]=C.useState(null),o=C.useRef(e),p=C.useCallback(m=>{const v=xi(m.target);v&&r(i=>i?(i.set(v,zi(v)),new Map(i)):null)},[]);return C.useEffect(()=>{const m=o.current;if(e!==m){v(m);const i=e.map(n=>{const l=xi(n);return l?(l.addEventListener("scroll",p,{passive:!0}),[l,zi(l)]):null}).filter(n=>n!=null);r(i.length?new Map(i):null),o.current=e}return()=>{v(e),v(m)};function v(i){i.forEach(n=>{const l=xi(n);l?.removeEventListener("scroll",p)})}},[p,e]),C.useMemo(()=>e.length?s?Array.from(s.values()).reduce((m,v)=>Rs(m,v),Lt):Qa(e):Lt,[e,s])}function po(e,s){s===void 0&&(s=[]);const r=C.useRef(null);return C.useEffect(()=>{r.current=null},s),C.useEffect(()=>{const o=e!==Lt;o&&!r.current&&(r.current=e),!o&&r.current&&(r.current=null)},[e]),r.current?Pr(e,r.current):Lt}function Sh(e){C.useEffect(()=>{if(!Yr)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 wh(e,s){return C.useMemo(()=>e.reduce((r,o)=>{let{eventName:p,handler:m}=o;return r[p]=v=>{m(v,s)},r},{}),[e,s])}function tl(e){return C.useMemo(()=>e?Vu(e):null,[e])}const go=[];function Ch(e,s){s===void 0&&(s=ar);const[r]=e,o=tl(r?bt(r):null),[p,m]=C.useState(go);function v(){m(()=>e.length?e.map(n=>Ya(n)?o:new Sn(s(n),n)):go)}const i=Zr({callback:v});return Kt(()=>{i?.disconnect(),v(),e.forEach(n=>i?.observe(n))},[e]),p}function sl(e){if(!e)return null;if(e.children.length>1)return e;const s=e.children[0];return nr(s)?s:e}function kh(e){let{measure:s}=e;const[r,o]=C.useState(null),p=C.useCallback(l=>{for(const{target:u}of l)if(nr(u)){o(c=>{const g=s(u);return c?{...c,width:g.width,height:g.height}:g});break}},[s]),m=Zr({callback:p}),v=C.useCallback(l=>{const u=sl(l);m?.disconnect(),u&&m?.observe(u),o(u?s(u):null)},[s,m]),[i,n]=Dr(v);return C.useMemo(()=>({nodeRef:i,rect:r,setRef:n}),[r,i,n])}const Eh=[{sensor:Cn,options:{}},{sensor:el,options:{}}],jh={current:{}},Er={draggable:{measure:ao},droppable:{measure:ao,strategy:tr.WhileDragging,frequency:Hi.Optimized},dragOverlay:{measure:ar}};class Vs 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 Nh={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Vs,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Ir},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Er,measureDroppableContainers:Ir,windowRect:null,measuringScheduled:!1},rl={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Ir,draggableNodes:new Map,over:null,measureDroppableContainers:Ir},lr=C.createContext(rl),il=C.createContext(Nh);function Rh(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Vs}}}function Ah(e,s){switch(s.type){case nt.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case nt.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 nt.DragEnd:case nt.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case nt.RegisterDroppable:{const{element:r}=s,{id:o}=r,p=new Vs(e.droppable.containers);return p.set(o,r),{...e,droppable:{...e.droppable,containers:p}}}case nt.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 Vs(e.droppable.containers);return v.set(r,{...m,disabled:p}),{...e,droppable:{...e.droppable,containers:v}}}case nt.UnregisterDroppable:{const{id:r,key:o}=s,p=e.droppable.containers.get(r);if(!p||o!==p.key)return e;const m=new Vs(e.droppable.containers);return m.delete(r),{...e,droppable:{...e.droppable,containers:m}}}default:return e}}function Mh(e){let{disabled:s}=e;const{active:r,activatorEvent:o,draggableNodes:p}=C.useContext(lr),m=Lr(o),v=Lr(r?.id);return C.useEffect(()=>{if(!s&&!o&&m&&v!=null){if(!bn(m)||document.activeElement===m.target)return;const i=p.get(v);if(!i)return;const{activatorNode:n,node:l}=i;if(!n.current&&!l.current)return;requestAnimationFrame(()=>{for(const u of[n.current,l.current]){if(!u)continue;const c=Eu(u);if(c){c.focus();break}}})}},[o,s,p,v,m]),null}function nl(e,s){let{transform:r,...o}=s;return e!=null&&e.length?e.reduce((p,m)=>m({transform:p,...o}),r):r}function Th(e){return C.useMemo(()=>({draggable:{...Er.draggable,...e?.draggable},droppable:{...Er.droppable,...e?.droppable},dragOverlay:{...Er.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Dh(e){let{activeNode:s,measure:r,initialRect:o,config:p=!0}=e;const m=C.useRef(!1),{x:v,y:i}=typeof p=="boolean"?{x:p,y:p}:p;Kt(()=>{if(!v&&!i||!s){m.current=!1;return}if(m.current||!o)return;const l=s?.node.current;if(!l||l.isConnected===!1)return;const u=r(l),c=Ua(u,o);if(v||(c.x=0),i||(c.y=0),m.current=!0,Math.abs(c.x)>0||Math.abs(c.y)>0){const g=Ka(l);g&&g.scrollBy({top:c.y,left:c.x})}},[s,v,i,o,r])}const Jr=C.createContext({...Lt,scaleX:1,scaleY:1});var Zt;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Zt||(Zt={}));const Lh=C.memo(function(s){var r,o,p,m;let{id:v,accessibility:i,autoScroll:n=!0,children:l,sensors:u=Eh,collisionDetection:c=Hu,measuring:g,modifiers:_,...y}=s;const x=C.useReducer(Ah,void 0,Rh),[a,h]=x,[d,f]=Tu(),[b,w]=C.useState(Zt.Uninitialized),k=b===Zt.Initialized,{draggable:{active:j,nodes:S,translate:E},droppable:{containers:R}}=a,L=j!=null?S.get(j):null,T=C.useRef({initial:null,translated:null}),A=C.useMemo(()=>{var be;return j!=null?{id:j,data:(be=L?.data)!=null?be:jh,rect:T}:null},[j,L]),B=C.useRef(null),[D,z]=C.useState(null),[H,M]=C.useState(null),O=Js(y,Object.values(y)),P=Qr("DndDescribedBy",v),I=C.useMemo(()=>R.getEnabled(),[R]),$=Th(g),{droppableRects:Y,measureDroppableContainers:q,measuringScheduled:V}=ph(I,{dragging:k,dependencies:[E.x,E.y],config:$.droppable}),F=fh(S,j),N=C.useMemo(()=>H?Or(H):null,[H]),W=ve(),X=gh(F,$.draggable.measure);Dh({activeNode:j!=null?S.get(j):null,config:W.layoutShiftCompensation,initialRect:X,measure:$.draggable.measure});const K=fo(F,$.draggable.measure,X),ie=fo(F?F.parentElement:null),Z=C.useRef({activatorEvent:null,active:null,activeNode:F,collisionRect:null,collisions:null,droppableRects:Y,draggableNodes:S,draggingNode:null,draggingNodeRect:null,droppableContainers:R,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),re=R.getNodeFor((r=Z.current.over)==null?void 0:r.id),he=kh({measure:$.dragOverlay.measure}),fe=(o=he.nodeRef.current)!=null?o:F,Be=k?(p=he.rect)!=null?p:K:null,le=!!(he.nodeRef.current&&he.rect),Ge=_h(le?null:K),we=tl(fe?bt(fe):null),qe=bh(k?re??F:null),Fe=Ch(qe),De=nl(_,{transform:{x:E.x-Ge.x,y:E.y-Ge.y,scaleX:1,scaleY:1},activatorEvent:H,active:A,activeNodeRect:K,containerNodeRect:ie,draggingNodeRect:Be,over:Z.current.over,overlayNodeRect:he.rect,scrollableAncestors:qe,scrollableAncestorRects:Fe,windowRect:we}),ze=N?Rs(N,E):null,Ae=yh(qe),Ke=po(Ae),Ee=po(Ae,[K]),Ce=Rs(De,Ke),ke=Be?qu(Be,De):null,st=A&&ke?c({active:A,collisionRect:ke,droppableRects:Y,droppableContainers:I,pointerCoordinates:ze}):null,je=zu(st,"id"),[We,ue]=C.useState(null),dt=le?De:Rs(De,Ee),wt=$u(dt,(m=We?.rect)!=null?m:null,K),G=C.useRef(null),U=C.useCallback((be,me)=>{let{sensor:Me,options:Se}=me;if(B.current==null)return;const Pe=S.get(B.current);if(!Pe)return;const He=be.nativeEvent,ut=new Me({active:B.current,activeNode:Pe,event:He,options:Se,context:Z,onAbort(xe){if(!S.get(xe))return;const{onDragAbort:Qe}=O.current,et={id:xe};Qe?.(et),d({type:"onDragAbort",event:et})},onPending(xe,ht,Qe,et){if(!S.get(xe))return;const{onDragPending:gt}=O.current,vt={id:xe,constraint:ht,initialCoordinates:Qe,offset:et};gt?.(vt),d({type:"onDragPending",event:vt})},onStart(xe){const ht=B.current;if(ht==null)return;const Qe=S.get(ht);if(!Qe)return;const{onDragStart:et}=O.current,mt={activatorEvent:He,active:{id:ht,data:Qe.data,rect:T}};es.unstable_batchedUpdates(()=>{et?.(mt),w(Zt.Initializing),h({type:nt.DragStart,initialCoordinates:xe,active:ht}),d({type:"onDragStart",event:mt}),z(G.current),M(He)})},onMove(xe){h({type:nt.DragMove,coordinates:xe})},onEnd:Je(nt.DragEnd),onCancel:Je(nt.DragCancel)});G.current=ut;function Je(xe){return async function(){const{active:Qe,collisions:et,over:mt,scrollAdjustedTranslate:gt}=Z.current;let vt=null;if(Qe&>){const{cancelDrop:Xe}=O.current;vt={activatorEvent:He,active:Qe,collisions:et,delta:gt,over:mt},xe===nt.DragEnd&&typeof Xe=="function"&&await Promise.resolve(Xe(vt))&&(xe=nt.DragCancel)}B.current=null,es.unstable_batchedUpdates(()=>{h({type:xe}),w(Zt.Uninitialized),ue(null),z(null),M(null),G.current=null;const Xe=xe===nt.DragEnd?"onDragEnd":"onDragCancel";if(vt){const Xt=O.current[Xe];Xt?.(vt),d({type:Xe,event:vt})}})}}},[S]),Q=C.useCallback((be,me)=>(Me,Se)=>{const Pe=Me.nativeEvent,He=S.get(Se);if(B.current!==null||!He||Pe.dndKit||Pe.defaultPrevented)return;const ut={active:He};be(Me,me.options,ut)===!0&&(Pe.dndKit={capturedBy:me.sensor},B.current=Se,U(Me,me))},[S,U]),se=mh(u,Q);Sh(u),Kt(()=>{K&&b===Zt.Initializing&&w(Zt.Initialized)},[K,b]),C.useEffect(()=>{const{onDragMove:be}=O.current,{active:me,activatorEvent:Me,collisions:Se,over:Pe}=Z.current;if(!me||!Me)return;const He={active:me,activatorEvent:Me,collisions:Se,delta:{x:Ce.x,y:Ce.y},over:Pe};es.unstable_batchedUpdates(()=>{be?.(He),d({type:"onDragMove",event:He})})},[Ce.x,Ce.y]),C.useEffect(()=>{const{active:be,activatorEvent:me,collisions:Me,droppableContainers:Se,scrollAdjustedTranslate:Pe}=Z.current;if(!be||B.current==null||!me||!Pe)return;const{onDragOver:He}=O.current,ut=Se.get(je),Je=ut&&ut.rect.current?{id:ut.id,rect:ut.rect.current,data:ut.data,disabled:ut.disabled}:null,xe={active:be,activatorEvent:me,collisions:Me,delta:{x:Pe.x,y:Pe.y},over:Je};es.unstable_batchedUpdates(()=>{ue(Je),He?.(xe),d({type:"onDragOver",event:xe})})},[je]),Kt(()=>{Z.current={activatorEvent:H,active:A,activeNode:F,collisionRect:ke,collisions:st,droppableRects:Y,draggableNodes:S,draggingNode:fe,draggingNodeRect:Be,droppableContainers:R,over:We,scrollableAncestors:qe,scrollAdjustedTranslate:Ce},T.current={initial:Be,translated:ke}},[A,F,st,ke,S,fe,Be,Y,R,We,qe,Ce]),dh({...W,delta:E,draggingRect:ke,pointerCoordinates:ze,scrollableAncestors:qe,scrollableAncestorRects:Fe});const de=C.useMemo(()=>({active:A,activeNode:F,activeNodeRect:K,activatorEvent:H,collisions:st,containerNodeRect:ie,dragOverlay:he,draggableNodes:S,droppableContainers:R,droppableRects:Y,over:We,measureDroppableContainers:q,scrollableAncestors:qe,scrollableAncestorRects:Fe,measuringConfiguration:$,measuringScheduled:V,windowRect:we}),[A,F,K,H,st,ie,he,S,R,Y,We,q,qe,Fe,$,V,we]),Ne=C.useMemo(()=>({activatorEvent:H,activators:se,active:A,activeNodeRect:K,ariaDescribedById:{draggable:P},dispatch:h,draggableNodes:S,over:We,measureDroppableContainers:q}),[H,se,A,K,h,P,S,We,q]);return ae.createElement($a.Provider,{value:f},ae.createElement(lr.Provider,{value:Ne},ae.createElement(il.Provider,{value:de},ae.createElement(Jr.Provider,{value:wt},l)),ae.createElement(Mh,{disabled:i?.restoreFocus===!1})),ae.createElement(Pu,{...i,hiddenTextDescribedById:P}));function ve(){const be=D?.autoScrollEnabled===!1,me=typeof n=="object"?n.enabled===!1:n===!1,Me=k&&!be&&!me;return typeof n=="object"?{...n,enabled:Me}:{enabled:Me}}}),Ph=C.createContext(null),vo="button",Oh="Draggable";function Ih(e){let{id:s,data:r,disabled:o=!1,attributes:p}=e;const m=Qr(Oh),{activators:v,activatorEvent:i,active:n,activeNodeRect:l,ariaDescribedById:u,draggableNodes:c,over:g}=C.useContext(lr),{role:_=vo,roleDescription:y="draggable",tabIndex:x=0}=p??{},a=n?.id===s,h=C.useContext(a?Jr:Ph),[d,f]=Dr(),[b,w]=Dr(),k=wh(v,s),j=Js(r);Kt(()=>(c.set(s,{id:s,key:m,node:d,activatorNode:b,data:j}),()=>{const E=c.get(s);E&&E.key===m&&c.delete(s)}),[c,s]);const S=C.useMemo(()=>({role:_,tabIndex:x,"aria-disabled":o,"aria-pressed":a&&_===vo?!0:void 0,"aria-roledescription":y,"aria-describedby":u.draggable}),[o,_,x,a,y,u.draggable]);return{active:n,activatorEvent:i,activeNodeRect:l,attributes:S,isDragging:a,listeners:o?void 0:k,node:d,over:g,setNodeRef:f,setActivatorNodeRef:w,transform:h}}function Bh(){return C.useContext(il)}const Fh="Droppable",zh={timeout:25};function Wh(e){let{data:s,disabled:r=!1,id:o,resizeObserverConfig:p}=e;const m=Qr(Fh),{active:v,dispatch:i,over:n,measureDroppableContainers:l}=C.useContext(lr),u=C.useRef({disabled:r}),c=C.useRef(!1),g=C.useRef(null),_=C.useRef(null),{disabled:y,updateMeasurementsFor:x,timeout:a}={...zh,...p},h=Js(x??o),d=C.useCallback(()=>{if(!c.current){c.current=!0;return}_.current!=null&&clearTimeout(_.current),_.current=setTimeout(()=>{l(Array.isArray(h.current)?h.current:[h.current]),_.current=null},a)},[a]),f=Zr({callback:d,disabled:y||!v}),b=C.useCallback((S,E)=>{f&&(E&&(f.unobserve(E),c.current=!1),S&&f.observe(S))},[f]),[w,k]=Dr(b),j=Js(s);return C.useEffect(()=>{!f||!w.current||(f.disconnect(),c.current=!1,f.observe(w.current))},[w,f]),C.useEffect(()=>(i({type:nt.RegisterDroppable,element:{id:o,key:m,disabled:r,node:w,rect:g,data:j}}),()=>i({type:nt.UnregisterDroppable,key:m,id:o})),[o]),C.useEffect(()=>{r!==u.current.disabled&&(i({type:nt.SetDroppableDisabled,id:o,key:m,disabled:r}),u.current.disabled=r)},[o,m,r,i]),{active:v,rect:g,isOver:n?.id===o,node:w,over:n,setNodeRef:k}}function Hh(e){let{animation:s,children:r}=e;const[o,p]=C.useState(null),[m,v]=C.useState(null),i=Lr(r);return!r&&!o&&i&&p(i),Kt(()=>{if(!m)return;const n=o?.key,l=o?.props.id;if(n==null||l==null){p(null);return}Promise.resolve(s(l,m)).then(()=>{p(null)})},[s,o,m]),ae.createElement(ae.Fragment,null,r,o?C.cloneElement(o,{ref:v}):null)}const $h={x:0,y:0,scaleX:1,scaleY:1};function Uh(e){let{children:s}=e;return ae.createElement(lr.Provider,{value:rl},ae.createElement(Jr.Provider,{value:$h},s))}const qh={position:"fixed",touchAction:"none"},Kh=e=>bn(e)?"transform 250ms ease":void 0,Xh=C.forwardRef((e,s)=>{let{as:r,activatorEvent:o,adjustScale:p,children:m,className:v,rect:i,style:n,transform:l,transition:u=Kh}=e;if(!i)return null;const c=p?l:{...l,scaleX:1,scaleY:1},g={...qh,width:i.width,height:i.height,top:i.top,left:i.left,transform:er.Transform.toString(c),transformOrigin:p&&o?Bu(o,i):void 0,transition:typeof u=="function"?u(o):u,...n};return ae.createElement(r,{className:v,style:g,ref:s},m)}),Vh=e=>s=>{let{active:r,dragOverlay:o}=s;const p={},{styles:m,className:v}=e;if(m!=null&&m.active)for(const[i,n]of Object.entries(m.active))n!==void 0&&(p[i]=r.node.style.getPropertyValue(i),r.node.style.setProperty(i,n));if(m!=null&&m.dragOverlay)for(const[i,n]of Object.entries(m.dragOverlay))n!==void 0&&o.node.style.setProperty(i,n);return v!=null&&v.active&&r.node.classList.add(v.active),v!=null&&v.dragOverlay&&o.node.classList.add(v.dragOverlay),function(){for(const[n,l]of Object.entries(p))r.node.style.setProperty(n,l);v!=null&&v.active&&r.node.classList.remove(v.active)}},Yh=e=>{let{transform:{initial:s,final:r}}=e;return[{transform:er.Transform.toString(s)},{transform:er.Transform.toString(r)}]},Gh={duration:250,easing:"ease",keyframes:Yh,sideEffects:Vh({styles:{active:{opacity:"0"}}})};function Qh(e){let{config:s,draggableNodes:r,droppableContainers:o,measuringConfiguration:p}=e;return Gr((m,v)=>{if(s===null)return;const i=r.get(m);if(!i)return;const n=i.node.current;if(!n)return;const l=sl(v);if(!l)return;const{transform:u}=bt(v).getComputedStyle(v),c=qa(u);if(!c)return;const g=typeof s=="function"?s:Zh(s);return Za(n,p.draggable.measure),g({active:{id:m,data:i.data,node:n,rect:p.draggable.measure(n)},draggableNodes:r,dragOverlay:{node:v,rect:p.dragOverlay.measure(l)},droppableContainers:o,measuringConfiguration:p,transform:c})})}function Zh(e){const{duration:s,easing:r,sideEffects:o,keyframes:p}={...Gh,...e};return m=>{let{active:v,dragOverlay:i,transform:n,...l}=m;if(!s)return;const u={x:i.rect.left-v.rect.left,y:i.rect.top-v.rect.top},c={scaleX:n.scaleX!==1?v.rect.width*n.scaleX/i.rect.width:1,scaleY:n.scaleY!==1?v.rect.height*n.scaleY/i.rect.height:1},g={x:n.x-u.x,y:n.y-u.y,...c},_=p({...l,active:v,dragOverlay:i,transform:{initial:n,final:g}}),[y]=_,x=_[_.length-1];if(JSON.stringify(y)===JSON.stringify(x))return;const a=o?.({active:v,dragOverlay:i,...l}),h=i.node.animate(_,{duration:s,easing:r,fill:"forwards"});return new Promise(d=>{h.onfinish=()=>{a?.(),d()}})}}let xo=0;function Jh(e){return C.useMemo(()=>{if(e!=null)return xo++,xo},[e])}const ef=ae.memo(e=>{let{adjustScale:s=!1,children:r,dropAnimation:o,style:p,transition:m,modifiers:v,wrapperElement:i="div",className:n,zIndex:l=999}=e;const{activatorEvent:u,active:c,activeNodeRect:g,containerNodeRect:_,draggableNodes:y,droppableContainers:x,dragOverlay:a,over:h,measuringConfiguration:d,scrollableAncestors:f,scrollableAncestorRects:b,windowRect:w}=Bh(),k=C.useContext(Jr),j=Jh(c?.id),S=nl(v,{activatorEvent:u,active:c,activeNodeRect:g,containerNodeRect:_,draggingNodeRect:a.rect,over:h,overlayNodeRect:a.rect,scrollableAncestors:f,scrollableAncestorRects:b,transform:k,windowRect:w}),E=kn(g),R=Qh({config:o,draggableNodes:y,droppableContainers:x,measuringConfiguration:d}),L=E?a.setRef:void 0;return ae.createElement(Uh,null,ae.createElement(Hh,{animation:R},c&&j?ae.createElement(Xh,{key:j,id:c.id,ref:L,as:i,activatorEvent:u,adjustScale:s,className:n,transition:m,rect:E,style:{zIndex:l,...p},transform:S},r):null))}),ol=768;function tf(e){const s=window.matchMedia(`(max-width: ${ol-1}px)`);return s.addEventListener("change",e),()=>s.removeEventListener("change",e)}function sf(){return window.innerWidth<ol}function rf(){return!1}function al(){return C.useSyncExternalStore(tf,sf,rf)}function En(e){return Tt({queryKey:ne.workspaces.list(e),queryFn:()=>ge.get(`/tasks/${e}/workspaces`),enabled:!!e})}function ll(e){const s=ot();return St({mutationFn:r=>ge.post(`/tasks/${e}/workspaces`,r),onSuccess:()=>{s.invalidateQueries({queryKey:ne.workspaces.list(e)}),s.invalidateQueries({queryKey:ne.tasks.all})}})}function cl(){const e=ot();return St({mutationFn:({id:s,commitMessage:r})=>ge.post(`/workspaces/${s}/merge`,{commitMessage:r}),onSuccess:()=>{e.invalidateQueries({queryKey:ne.workspaces.all}),e.invalidateQueries({queryKey:ne.tasks.all}),e.invalidateQueries({queryKey:ne.git.all})},onError:()=>{e.invalidateQueries({queryKey:ne.git.all})}})}function nf(){const e=ot();return St({mutationFn:s=>ge.post(`/workspaces/${s}/reactivate`),onSuccess:()=>{e.invalidateQueries({queryKey:ne.workspaces.all}),e.invalidateQueries({queryKey:ne.tasks.all})}})}function jn(){return St({mutationFn:({workspaceId:e,editorType:s})=>ge.post(`/workspaces/${e}/open-editor`,{editorType:s})})}function Nn(e,s={}){return Tt({queryKey:ne.workspaces.gitStatus(e),queryFn:()=>ge.get(`/workspaces/${e}/git-status`),enabled:!!e&&(s.enabled??!0)})}function dl(){const e=ot();return St({mutationFn:s=>ge.post(`/workspaces/${s}/rebase`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:ne.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:ne.git.all})},onError:(s,r)=>{e.invalidateQueries({queryKey:ne.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:ne.git.all})}})}function Rn(){const e=ot();return St({mutationFn:s=>ge.post(`/workspaces/${s}/abort-operation`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:ne.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:ne.git.all})}})}function of(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===it.RUNNING||v.status===it.PENDING))&&r.push(s("正在运行的 Agent 将被停止")),o&&(r.push(s("分支上未合并的变更将丢失")),r.push(s("关联的工作目录(worktree)将被清理"))),r}function An({isOpen:e,onClose:s,onConfirm:r,taskId:o,taskTitle:p,workspaces:m,isLoading:v}){const{t:i}=ce(),{data:n,isLoading:l}=En(m===void 0&&e?o:""),u=m??n,c=m===void 0&&e&&l,g=C.useMemo(()=>of(u,i),[u,i]);return t.jsx(an,{isOpen:e,onClose:s,onConfirm:r,title:i("删除任务"),description:t.jsxs(t.Fragment,{children:[t.jsx("p",{children:i("确认删除任务「{title}」?此操作不可撤销。",{title:p})}),c?t.jsx("p",{className:"mt-2 text-xs text-neutral-400",children:i("加载中...")}):g.length>0?t.jsx("ul",{className:"mt-2 space-y-1",children:g.map((_,y)=>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:_})]},y))}):null]}),confirmText:i("删除"),variant:"danger",isLoading:v||c})}const pe={Review:"Review",Running:"Running",Pending:"Pending",Done:"Done",Cancelled:"Cancelled"},$i={[pe.Review]:{label:"Review",icon:ja,iconClass:"text-warning",accentClass:"text-warning"},[pe.Running]:{label:"Running",icon:Ea,iconClass:"text-info",accentClass:"text-info"},[pe.Pending]:{label:"Pending",icon:ka,iconClass:"text-muted-foreground",accentClass:"text-muted-foreground"},[pe.Done]:{label:"Done",icon:Ca,iconClass:"text-success/80",accentClass:"text-success"},[pe.Cancelled]:{label:"Cancelled",icon:wa,iconClass:"text-muted-foreground/70",accentClass:"text-muted-foreground/70"}},af=[pe.Review,pe.Running,pe.Pending,pe.Done,pe.Cancelled],ul=C.createContext(null),lf=3e4;function cf(e=lf){const[,s]=C.useState(0);C.useEffect(()=>{const r=setInterval(()=>s(o=>o+1),e);return()=>clearInterval(r)},[e])}function df(e){const s=Math.max(0,Math.floor((Date.now()-new Date(e).getTime())/1e3));return s<60?pt("{count}s ago",{count:s}):s<3600?pt("{count}m ago",{count:Math.floor(s/60)}):s<86400?pt("{count}h ago",{count:Math.floor(s/3600)}):pt("{count}d ago",{count:Math.floor(s/86400)})}function uf({task:e,status:s,isSelected:r,isAgentActive:o,project:p,onSelectTask:m,onTaskStatusChange:v,onDeleteTask:i,disableDrag:n}){const{t:l}=ce(),u=C.useContext(ul),c=C.useRef(null),g=!!e.projectArchivedAt,_=g||!!n,{attributes:y,listeners:x,setNodeRef:a,isDragging:h}=Ih({id:e.id,data:{task:e,fromStatus:s},disabled:_}),d=C.useCallback(A=>{c.current=A,a(A),u&&(A?u.registry.set(e.id,A):u.registry.delete(e.id))},[a,u,e.id]);C.useEffect(()=>()=>{u?.registry.delete(e.id)},[e.id,u]);const[f,b]=C.useState(null),[w,k]=C.useState(!1),j=C.useRef(null),S=C.useRef(null),E=C.useCallback(A=>{g||!v&&!i||(A.preventDefault(),b({x:A.clientX,y:A.clientY}))},[g,v,i]),R=C.useCallback(()=>{S.current&&(clearTimeout(S.current),S.current=null)},[]),L=C.useCallback(A=>{if(!n||g||!v&&!i)return;const B=A.touches[0];if(!B)return;const{clientX:D,clientY:z}=B;S.current=setTimeout(()=>{S.current=null,b({x:D,y:z})},500)},[n,g,v,i]);C.useEffect(()=>{if(!f)return;const A=B=>{j.current&&!j.current.contains(B.target)&&b(null)};return document.addEventListener("mousedown",A),document.addEventListener("touchstart",A),()=>{document.removeEventListener("mousedown",A),document.removeEventListener("touchstart",A)}},[f]);const T=p?p.name:void 0;return t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:d,onClick:()=>m(e.id),onContextMenu:E,onTouchStart:L,onTouchEnd:R,onTouchMove:R,title:T,"aria-label":T?`${e.title} — ${T}`: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
|
-
${h?"opacity-30":""}
|
|
8
|
-
${r?"bg-accent":"hover:bg-accent/50"}`,..._?{}:x,..._?{}:y,children:[t.jsx("span",{className:"shrink-0 flex items-center",children:(()=>{const{icon:A,iconClass:B}=$i[s];return t.jsx(A,{className:`${B} ${s===pe.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?l("源码已删除"):l("已删除")}),o&&t.jsxs("span",{className:"relative inline-flex h-2 w-2 shrink-0 align-middle",children:[t.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-success/70"}),t.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-success"})]}),e.updatedAt&&t.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground/50 tabular-nums",children:df(e.updatedAt)}),p&&t.jsx("span",{className:`shrink-0 w-1.5 h-1.5 rounded-full ${p.color.replace("text-","bg-")}`})]}),f&&t.jsxs("div",{ref:j,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:f.x,top:f.y},children:[v&&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:l("Move to")}),af.filter(A=>A!==s).map(A=>{const{icon:B,label:D,accentClass:z}=$i[A];return t.jsxs("button",{onClick:()=>{v(e.id,A),b(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs hover:bg-accent/50 transition-colors",children:[t.jsx(B,{className:`w-3.5 h-3.5 ${z}`}),t.jsx("span",{className:"text-foreground/80",children:l(D)})]},A)})]}),i&&t.jsxs(t.Fragment,{children:[v&&t.jsx("div",{className:"my-1 border-t border-border/60"}),t.jsxs("button",{onClick:()=>{k(!0),b(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:l("Delete Task")})]})]})]}),t.jsx(An,{isOpen:w,onClose:()=>k(!1),onConfirm:()=>{i?.(e.id),k(!1)},taskId:e.id,taskTitle:e.title})]})}const hf=C.memo(function({title:s,tasks:r,status:o,defaultOpen:p,selectedTaskId:m,onSelectTask:v,projects:i,activeTaskIds:n,isDragging:l,dragFromStatus:u,onTaskStatusChange:c,onDeleteTask:g,disableDrag:_}){const{t:y}=ce(),[x,a]=C.useState(p);cf();const h=r.length===0,d=l&&u===o,f=l&&u!==o,{setNodeRef:b,isOver:w}=Wh({id:`group-${o}`,data:{status:o}}),k=o===pe.Review,j=y(s),S=l?d&&(x||!0):x;return t.jsxs("div",{className:"mb-2","data-task-group-status":o,children:[t.jsxs("button",{onClick:()=>!l&&a(E=>!E),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:j}),k&&!h?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:S?t.jsx(yt,{size:12}):t.jsx(Mt,{size:12})})]}),f&&t.jsx("div",{ref:b,className:`mx-2 my-1 flex items-center justify-center rounded-lg border-2 border-dashed transition-all duration-150 h-10
|
|
9
|
-
${w?"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:w?y("Drop into {title}",{title:j}):y("Drop here")})}),S&&!f&&t.jsx("div",{ref:d?void 0:b,className:`flex flex-col mt-0.5 min-h-[40px] rounded-md transition-colors
|
|
10
|
-
${w&&!d?"bg-info/10 ring-1 ring-info/30":""}
|
|
11
|
-
${h&&l?"border border-dashed border-border mx-2":""}`,children:h?t.jsx("span",{className:"text-xs text-muted-foreground/50 py-2 px-4",children:y("No tasks")}):r.map(E=>{const R=m===E.id,L=n?.has(E.id)??!1,T=E.projectId?i.find(A=>A.id===E.projectId):void 0;return t.jsx(uf,{task:E,status:o,isSelected:R,isAgentActive:L,project:T,onSelectTask:v,onTaskStatusChange:E.projectArchivedAt?void 0:c,onDeleteTask:E.projectArchivedAt?void 0:g,disableDrag:_},E.id)})})]})}),ff=12,mf=50;function pf({isOpen:e,onClose:s,tasks:r,projects:o,onSelectTask:p}){const{t:m}=ce(),[v,i]=C.useState(""),[n,l]=C.useState(0),u=C.useRef(null);C.useEffect(()=>{e&&(i(""),l(0))},[e]);const c=C.useMemo(()=>{const y=v.trim().toLowerCase();return y?r.filter(x=>x.title.toLowerCase().includes(y)).slice(0,mf):r.slice(0,ff)},[r,v]);C.useEffect(()=>{l(0)},[v]),C.useEffect(()=>{u.current?.children[n]?.scrollIntoView({block:"nearest"})},[n]);const g=C.useCallback(y=>{p(y),s()},[p,s]),_=C.useCallback(y=>{if(y.key==="Escape")y.preventDefault(),s();else if(y.key==="ArrowDown")y.preventDefault(),l(x=>Math.min(x+1,c.length-1));else if(y.key==="ArrowUp")y.preventDefault(),l(x=>Math.max(x-1,0));else if(y.key==="Enter"&&!y.nativeEvent.isComposing){y.preventDefault();const x=c[n];x&&g(x.id)}},[s,c,n,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(ln,{size:15,className:"text-muted-foreground/70 shrink-0"}),t.jsx("input",{value:v,onChange:y=>i(y.target.value),onKeyDown:_,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((y,x)=>{const a=o.find(f=>f.id===y.projectId),{icon:h,iconClass:d}=$i[y.status];return t.jsxs("button",{onClick:()=>g(y.id),onMouseEnter:()=>l(x),className:`w-full flex items-center gap-2.5 px-4 py-2 text-left transition-colors
|
|
12
|
-
${x===n?"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:y.title,children:y.title}),a&&t.jsx("span",{className:"shrink-0 max-w-[120px] truncate text-xs text-muted-foreground/70",children:a.name})]},y.id)})})]}):t.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground/70",children:m("No matching tasks")})]})]}):null}const gf=260,vf=220;function xf(e){const s={[pe.Review]:[],[pe.Running]:[],[pe.Pending]:[],[pe.Done]:[],[pe.Cancelled]:[]};for(const r of e)s[r.status].push(r);return s}const _f=[{status:pe.Review,title:"Review",defaultOpen:!0},{status:pe.Running,title:"Running",defaultOpen:!0},{status:pe.Pending,title:"Pending",defaultOpen:!1},{status:pe.Done,title:"Done",defaultOpen:!1},{status:pe.Cancelled,title:"Cancelled",defaultOpen:!1}];function _o({tasks:e=[],projects:s=[],selectedTaskId:r,onSelectTask:o,filterProjectId:p,setFilterProjectId:m,width:v=320,onCreateTask:i,onCreateProject:n,isCreateActive:l,activeTaskIds:u,onTaskStatusChange:c,onDeleteTask:g}){const{t:_}=ce(),{preserveDesktopSearch:y}=ma(),x=al(),[a,h]=C.useState(null),[d,f]=C.useState(null),[b,w]=C.useState(!1),k=C.useRef(new Map),j=C.useRef(new Set),S=C.useRef(new Map),E=C.useMemo(()=>({registry:k.current}),[]),R=C.useCallback(I=>{I.remove(),j.current.delete(I)},[]),L=p?e.filter(I=>I.projectId===p):e,T=C.useCallback((I,$)=>{const Y=document.querySelector(`[data-task-group-status="${I}"]`);if(!Y)return null;const V=(Y.querySelector("button")??Y).getBoundingClientRect();return V.width===0||V.height===0?null:new DOMRect(V.left+8,V.bottom+4,$.width,$.height)},[]),A=C.useCallback((I,$,Y,q=!1)=>{const V=document.createElement("div");V.setAttribute("aria-hidden","true"),V.innerHTML=Y;const F=V.firstElementChild;F&&(F.style.cssText="",F.className=F.className.replace(/\bopacity-\S*/g,"").replace(/\banimate-task-enter\b/g,""),F.style.pointerEvents="none",F.style.width=`${I.width}px`,F.style.height=`${I.height}px`,F.style.margin="0",F.style.backgroundColor="var(--sidebar-accent)",F.style.borderRadius="0.375rem",F.style.boxShadow="0 6px 16px rgba(15, 23, 42, 0.10), 0 1px 3px rgba(15, 23, 42, 0.08)",F.style.opacity="0.96",F.style.transition="none",F.setAttribute("tabindex","-1")),Object.assign(V.style,{position:"fixed",left:`${I.left}px`,top:`${I.top}px`,width:`${I.width}px`,height:`${I.height}px`,zIndex:"9999",pointerEvents:"none",overflow:"visible",transformOrigin:"top left",willChange:"transform, opacity"}),document.body.appendChild(V),j.current.add(V);const N=$.left-I.left,W=$.top-I.top;V.animate([{transform:"translate(0, 0)",opacity:.96,offset:0},{transform:`translate(${N}px, ${W}px)`,opacity:q?.12:.96,offset:1}],{duration:q?vf:gf,easing:"cubic-bezier(0.2, 0, 0, 1)",fill:"forwards"}).finished.then(()=>R(V),()=>R(V))},[R]);C.useLayoutEffect(()=>{const I=window.matchMedia("(prefers-reduced-motion: reduce)").matches,$=new Map;for(const Y of L){const q=k.current.get(Y.id);if(!q)continue;const V={status:Y.status,rect:q.getBoundingClientRect(),html:q.outerHTML};if($.set(Y.id,V),I)continue;const F=S.current.get(Y.id);if(!F||F.status===Y.status)continue;const N=V.rect.left-F.rect.left,W=V.rect.top-F.rect.top;Math.abs(N)<1&&Math.abs(W)<1||A(F.rect,V.rect,F.html)}if(!I)for(const[Y,q]of S.current){if($.has(Y))continue;const V=L.find(N=>N.id===Y);if(!V||V.status===q.status)continue;const F=T(V.status,q.rect);F&&A(q.rect,F,q.html,!0)}S.current=$},[L,A,T]),C.useEffect(()=>()=>{for(const I of j.current)I.remove();j.current.clear()},[]);const B=Iu(Ou(Cn,{activationConstraint:{distance:8}})),D=C.useCallback(I=>{const $=I.active.data.current?.task,Y=I.active.data.current?.fromStatus;$&&h($),Y&&f(Y)},[]),z=C.useCallback(I=>{h(null),f(null);const{active:$,over:Y}=I;if(!Y)return;const q=$.data.current?.task,V=$.data.current?.fromStatus,F=Y.data.current?.status;!q||!V||!F||q.projectArchivedAt||V!==F&&c?.(q.id,F)},[c]),O=!!!(p?s.find(I=>I.id===p)??null:null)?.archivedAt,P=xf(L);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:[n&&t.jsxs("button",{onClick:n,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:_("New Project"),children:[t.jsx(yd,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:_("New Project")})]}),t.jsxs("button",{onClick:i,disabled:!O,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
|
-
${l?"bg-accent text-foreground":"text-foreground/80 hover:bg-accent/50"}`,title:_(O?"New Task":"Deleted projects are read-only"),children:[t.jsx(gd,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:_("New Task")})]}),t.jsxs("button",{onClick:()=>w(!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:_("Search"),children:[t.jsx(ln,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:_("Search")})]}),t.jsxs(sd,{to:y("/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:_("对话"),children:[t.jsx(qr,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:_("对话")})]})]}),L.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-6 text-center select-none",children:[t.jsx(As,{size:36,className:"text-muted-foreground/40 mb-3",strokeWidth:1.5}),t.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:_("No tasks")}),O&&i?t.jsx("button",{onClick:i,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:_("New Task")}):null]}):t.jsx(ul.Provider,{value:E,children:t.jsxs(Lh,{sensors:B,onDragStart:D,onDragEnd:z,children:[t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin pt-3 pb-4 relative",children:_f.map(({status:I,title:$,defaultOpen:Y})=>t.jsx(hf,{title:$,tasks:P[I],status:I,defaultOpen:Y,selectedTaskId:r,onSelectTask:o,projects:s,activeTaskIds:u,isDragging:a!==null,dragFromStatus:d,onTaskStatusChange:c,onDeleteTask:g,disableDrag:x},I))}),t.jsx(ef,{dropAnimation:null,children:a?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:a.title,children:a.title})}):null})]})}),L.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:_("{count} tasks",{count:L.length})}),p?t.jsx("button",{onClick:()=>m(null),className:"hover:text-foreground underline decoration-border underline-offset-2",children:_("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:_("{count} tasks",{count:0})})}),t.jsx(pf,{isOpen:b,onClose:()=>w(!1),tasks:L,projects:s,onSelectTask:o})]})}const bf=10,yf=24,hl=bf*yf,Sf=8;function wf(e,s=hl){return e>s+Sf}function Cf(e,s){return e.includes(s)?e:[...e,s]}function kf(e,s){return e.filter(r=>r!==s)}function Ef(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 ei=new Set(["RUNNING","WAITING_ROOM_REPLY","QUEUED","SESSION_ENDED"]);function bo(e){if(!e)return 0;const s=Date.parse(e);return Number.isNaN(s)?0:s}function jf(e,s=[],r=[]){const o=new Set(r.filter(m=>ei.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 i=bo(m.sortTime)-bo(v.sortTime);return i!==0?i:m.order!==v.order?m.order-v.order:m.key.localeCompare(v.key)})}function Nf(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 Rf(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 Af(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 Mf(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(min-width: 768px)").matches}function Tf({status:e}){const{t:s}=ce();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(Nf(e))})}function Df({invocations:e,memberById:s,workRequestById:r,onViewInvocationSession:o,onStopMember:p,isStopPending:m,stoppingMemberId:v,stopPromptInvocationId:i,onToggleStopConfirm:n}){const{t:l}=ce(),[u,c]=C.useState(Mf),g=C.useMemo(()=>e.filter(y=>ei.has(y.status)).sort((y,x)=>Date.parse(x.updatedAt??x.createdAt??"")-Date.parse(y.updatedAt??y.createdAt??"")),[e]);if(g.length===0)return null;const _=Af(g,l);return t.jsxs("div",{className:"border-t border-neutral-200 bg-neutral-50/80",children:[t.jsxs("button",{type:"button",onClick:()=>c(y=>!y),"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:l("Active work")}),t.jsx("span",{className:"mx-1.5 text-neutral-300",children:"·"}),t.jsx("span",{children:_})]}),u?t.jsx(yt,{size:15,className:"shrink-0 text-neutral-400"}):t.jsx(Oa,{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(y=>{const x=s.get(y.memberId),a=r.get(y.workRequestId),h=!!(y.sessionId&&o),d=!!x,f=i===y.id,b=m&&v===y.memberId,w=a?.instruction??y.workRequestId;return t.jsxs("div",{className:"border-t border-neutral-100 first:border-t-0",children:[t.jsxs("div",{title:w,className:te("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:()=>y.sessionId&&o?.(y.sessionId),onKeyDown:k=>{!h||!y.sessionId||(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),o?.(y.sessionId))},children:[t.jsx(Ft,{name:x?.name??l("Agent"),avatar:x?.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:x?.name??l("Agent")}),t.jsx("span",{className:te("shrink-0",Rf(y.status)),children:t.jsx(Tf,{status:y.status})})]}),h&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),y.sessionId&&o?.(y.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:l("View log"),"aria-label":`${l("View log")} ${x?.name??l("Agent")}`,children:t.jsx(Fi,{size:13})}),d&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),n(y.id)},onKeyDown:k=>k.stopPropagation(),disabled:b,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:l("Stop"),"aria-label":`${l("Stop")} ${x?.name??l("Agent")}`,children:t.jsx(Ms,{size:12})})]}),d&&f&&x&&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:l("Stop running work?")}),t.jsxs(Re,{type:"button",size:"xs",variant:"outline",disabled:b,onClick:()=>p(x.id,!1),children:[t.jsx(Ms,{size:11}),t.jsx("span",{children:l(b?"Stopping":"Stop only")})]}),t.jsxs(Re,{type:"button",size:"xs",variant:"outline",disabled:b,className:"border-red-200 bg-red-50 text-red-700 hover:bg-red-100 hover:text-red-800",onClick:()=>p(x.id,!0),children:[t.jsx(Ba,{size:11}),t.jsx("span",{children:l(b?"Stopping":"Stop + clear queue")})]})]})]},y.id)})})]})}const Fr="/api",Lf=240,Pf=/(^|\n)(```|~~~)[^\S\r\n]*mermaid(?:[\s\r\n]|$)/i;let Ui=null;function Of(e){return Pf.test(e)}function If(){return Ui??=id(async()=>{const{mermaid:e}=await import("./index-DhYpUXuu.js").then(s=>s.bm);return{mermaid:e}},__vite__mapDeps([0,1,2])).then(({mermaid:e})=>({mermaid:e})),Ui}function Bf(e){const s=Of(e),[r,o]=C.useState();return C.useEffect(()=>{if(!s){o(void 0);return}let p=!0;return If().then(m=>{p&&o(m)}).catch(()=>{Ui=null,p&&o(void 0)}),()=>{p=!1}},[s]),s?r:void 0}let yo=0;function Ff(e,s){return yo+=1,{id:`pending-room-message-${Date.now()}-${yo}`,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 fl(e){return"pendingStatus"in e}const zf=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${Fr}/attachments/by-path?path=${encodeURIComponent(e)}`:e;function Wf(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function Hf(e){return`${e.mimeType.startsWith("image/")?"!":""}[${e.originalName}](${e.storagePath})`}function qi(e,s){if(s.length===0)return e;const r=new Set(s.map(Hf));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 $f(e){if(!e)return"";const s=new Date(e);return Number.isNaN(s.getTime())?"":s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Ki(e,s){return e instanceof Error?e.message:s}function Uf(e,s=Lf){const r=(e??"").replace(/\s+/g," ").trim();return r.length<=s?r:`${r.slice(0,s-3).trimEnd()}...`}function qf(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 Kf(e,s){const r=s.trim().toLowerCase();return r?[e.name,e.providerId,...e.aliases??[]].some(p=>p.toLowerCase().includes(r)):!0}function So(e){return e.membershipStatus!=="REMOVED"}function Xf(e,s){return e.label??s.get(e.memberId)?.name??e.memberId}function Vf(e,s){return(e.recipientMemberIds??[]).map(r=>s.get(r)?.name??r)}function Yf(e,s){const r=e.mentions??[],o=e.contentPreview??e.content;if(r.length===0)return o;const p=r.map(v=>Xf(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 Gf(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 Qf({content:e,isUser:s}){const r=Bf(e);return t.jsx("div",{className:te("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(nn,{urlTransform:zf,components:on,plugins:r,controls:r?pd:void 0,children:e})})}function Zf({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,i)=>[v.id,i]));return t.jsx("div",{className:"mt-3 flex flex-wrap gap-2 text-neutral-700",children:s.map(v=>{const i=`${Fr}${v.url}`;if(v.mimeType.startsWith("image/")){const l=m.get(v.id)??0;return t.jsxs("button",{type:"button",onClick:()=>o(p,l),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:i,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:i,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(Ra,{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:Wf(v.sizeBytes)})]}),t.jsx(vn,{size:13,className:"shrink-0 text-neutral-400","aria-hidden":!0})]},v.id)})})}function Jf({message:e,content:s,attachmentIds:r,isUser:o,tone:p,onOpenImage:m}){const v=C.useMemo(()=>Array.from(new Set(r??[])),[r]),{data:i=[],isLoading:n}=vd(v),l=i.length>0?qi(s,i):s;return t.jsxs(t.Fragment,{children:[l.trim()&&t.jsx(sm,{message:e,content:l,attachments:i,isUser:o,tone:p}),t.jsx(Zf,{hasAttachmentIds:v.length>0,attachments:i,isLoading:n,onOpenImage:m})]})}function em({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(ns,{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(Id,{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:`${Fr}${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:`${Fr}${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(vn,{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 tm({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 sm({message:e,content:s,attachments:r,isUser:o,tone:p=o?"user":"agent"}){const{t:m}=ce(),v=C.useId(),i=C.useRef(null),[n,l]=C.useState(null),[u,c]=C.useState(!1),[g,_]=C.useState(null),y=rd(e.teamRunId,e.id,!1),x=y.data?.content,a=x?qi(x,r):void 0,d=!!(a&&a!==s)?a:s,f=!!(e.isTruncated&&!fl(e)),b=n?.messageId===e.id&&n.content===d&&n.expanded,w=C.useCallback(()=>{const R=i.current;R&&c(wf(R.scrollHeight))},[]);C.useLayoutEffect(()=>{w();const R=i.current;if(!R)return;const L=window.requestAnimationFrame(w),T=typeof ResizeObserver>"u"?null:new ResizeObserver(w);return T?.observe(R),window.addEventListener("resize",w),()=>{window.cancelAnimationFrame(L),T?.disconnect(),window.removeEventListener("resize",w)}},[d,w]);const k=C.useCallback(async()=>{if(_(null),b){l({messageId:e.id,content:d,expanded:!1});return}if(f&&!x){const R=await y.refetch();if(R.error){_(Ki(R.error,m("Failed to load full message")));return}const L=R.data?.content?qi(R.data.content,r):d;l({messageId:e.id,content:L,expanded:!0});return}l({messageId:e.id,content:d,expanded:!0})},[r,f,x,y,b,e.id,d,m]),j=(u||f)&&!b,S=u||f,E=y.isFetching;return t.jsxs("div",{className:"relative",children:[t.jsxs("div",{id:v,ref:i,onLoadCapture:w,className:te("relative transition-[max-height] duration-200 ease-out",j?"overflow-hidden":""),style:j?{maxHeight:hl}:void 0,children:[t.jsx(Qf,{content:d,isUser:o}),j&&t.jsx("div",{className:te("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")})]}),S&&t.jsxs("button",{type:"button","aria-expanded":b,"aria-controls":v,"aria-label":m(b?"Collapse message":"Expand full message"),disabled:E,onClick:()=>{k()},className:te("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",E?"cursor-wait opacity-70":""),children:[b?t.jsx(Oa,{size:13}):t.jsx(yt,{size:13}),t.jsx("span",{children:m(E?"Loading":b?"Collapse message":"Expand full message")})]}),g&&t.jsx("div",{className:te("mt-1 text-xs",p==="user"?"text-red-200":"text-red-600"),children:g})]})}function ml({senderName:e,avatar:s,createdAt:r,isUser:o,isSystem:p,children:m,headerAddon:v,bubbleClassName:i,isPending:n}){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:te("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(Ft,{name:e,avatar:s??null,className:"mt-0.5 h-8 w-8 text-[11px]"}),t.jsxs("div",{className:te("flex min-w-0 max-w-[min(86%,46rem)] flex-col",o?"items-end":"items-start"),children:[t.jsxs("div",{className:te("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(Es,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"shrink-0",children:$f(r)}),v]}),t.jsx("div",{className:te("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",i,n?"opacity-70":""),children:m})]}),o&&t.jsx(Ft,{name:e,avatar:null,className:"mt-0.5 h-8 w-8 border-neutral-300 bg-neutral-900 text-white text-[11px]"})]})}function rm({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(Kr,{agentType:e.agentType,className:"size-2.5"}),t.jsx("span",{className:"truncate",children:e.name})]})}function im({message:e,senderName:s,senderMember:r,senderProvider:o,memberById:p,displayContent:m,onOpenImage:v}){const{t:i}=ce(),n=e.senderType==="user",l=e.senderType==="system",u=fl(e)?e.pendingStatus:null,c=e.mentions??[],g=e.workRequestIds?.length??0,_=e.visibility==="PRIVATE",y=_?Vf(e,p):[],x=t.jsxs(t.Fragment,{children:[!n&&!l&&o&&t.jsx(rm,{provider:o}),_&&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:y.join(", "),children:[t.jsx(eu,{size:10}),t.jsxs("span",{className:"truncate",children:[i("Private"),y.length>0?`: ${y.join(", ")}`:""]})]}),!l&&g>0&&c.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:[i("Work requests"),": ",g]}),u==="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:i("发送中...")}),u==="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:i("发送失败")})]});return t.jsx(ml,{senderName:s,avatar:r?.avatar??null,createdAt:e.createdAt,isUser:n,isSystem:l,headerAddon:x,bubbleClassName:n&&u==="failed"?"border-red-200 bg-red-50 text-red-900":void 0,isPending:u==="sending",children:t.jsx(Jf,{message:e,content:m,attachmentIds:e.attachmentIds,isUser:n&&u!=="failed",tone:l?"system":void 0,onOpenImage:v})})}function nm({request:e,member:s,onApprove:r,onReject:o,isActionPending:p,isApprovePending:m,isRejectPending:v}){const{t:i}=ce();return t.jsx(ml,{senderName:s?.name??i("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(Es,{size:11}),i("Pending approval")]}),t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[i("Requester"),": ",i(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??Uf(e.instruction)}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs(Re,{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(qt,{size:12}),t.jsx("span",{children:i(m?"Approving":"Approve")})]}),t.jsxs(Re,{type:"button",size:"xs",variant:"outline",disabled:p,onClick:o,children:[t.jsx(ns,{size:12}),t.jsx("span",{children:i(v?"Rejecting":"Reject")})]})]})]})})}function pl({teamRun:e,messages:s,readOnly:r,readOnlyMessage:o,onSendMessage:p,onViewInvocationSession:m,changeSummaryBar:v,compactComposer:i,centered:n}){const{t:l}=ce(),u=pa(e.id),c=ga(e.id),g=va(e.id),[_,y]=C.useState(""),[x,a]=C.useState(!1),[h,d]=C.useState(null),[f,b]=C.useState(0),[w,k]=C.useState([]),[j,S]=C.useState(!1),[E,R]=C.useState(null),[L,T]=C.useState([]),[A,B]=C.useState(null),D=C.useRef(null),z=C.useRef(null),{files:H,addFiles:M,removeFile:O,clear:P,restoreFiles:I,buildMarkdownLinks:$,getDoneAttachments:Y,isUploading:q}=cn(),V=H.some(G=>G.status==="done"&&G.attachment),[F,N]=C.useState(null),{scrollRef:W,contentRef:X,isAtBottom:K,scrollToBottom:ie}=dn({resize:"smooth",initial:"instant"}),{data:Z}=Ds(),re=C.useMemo(()=>{const G=new Map;for(const U of Z??[])G.set(U.provider.id,U.provider);return G},[Z]),he=C.useMemo(()=>new Map((e.members??[]).map(G=>[G.id,G])),[e.members]),fe=C.useMemo(()=>(e.members??[]).filter(So),[e.members]),Be=C.useMemo(()=>new Map((e.invocations??[]).map(G=>[G.id,G])),[e.invocations]),le=C.useMemo(()=>{const G=new Set(s.map(Q=>Q.id)),U=L.filter(Q=>!G.has(Q.id));return[...s,...U].sort((Q,se)=>{const de=Date.parse(Q.createdAt??""),Ne=Date.parse(se.createdAt??"");return(Number.isNaN(de)?0:de)-(Number.isNaN(Ne)?0:Ne)})},[s,L]),Ge=C.useMemo(()=>new Map((e.workRequests??[]).map(G=>[G.id,G])),[e.workRequests]),we=C.useMemo(()=>jf(le,e.workRequests??[],e.invocations??[]),[le,e.invocations,e.workRequests]),qe=C.useMemo(()=>(e.invocations??[]).filter(G=>ei.has(G.status)),[e.invocations]),Fe=C.useMemo(()=>w.map(G=>he.get(G)).filter(G=>!!G).filter(So),[he,w]),De=C.useMemo(()=>{const G=h?.query??"";return fe.filter(U=>Kf(U,G)).sort((U,Q)=>{const se=w.includes(U.id),de=w.includes(Q.id);return se!==de?se?1:-1:U.name.localeCompare(Q.name)})},[fe,h?.query,w]),ze=!r&&(x||!!h)&&De.length>0,Ae=C.useCallback((G,U)=>{if(U==null){d(null);return}d(qf(G,U)),b(0)},[]),Ke=C.useCallback(G=>{k(Ne=>Cf(Ne,G.id));const U=`@${G.name} `;if(h){const Ne=`${_.slice(0,h.start)}${U}${_.slice(h.end)}`,ve=h.start+U.length;y(Ne),d(null),a(!1),requestAnimationFrame(()=>{D.current?.focus(),D.current?.setSelectionRange(ve,ve)});return}const Q=_.length===0||/\s$/.test(_)?"":" ",se=`${_}${Q}${U}`,de=se.length;y(se),a(!1),requestAnimationFrame(()=>{D.current?.focus(),D.current?.setSelectionRange(de,de)})},[_,h]),Ee=C.useCallback(G=>{k(U=>kf(U,G))},[]),Ce=C.useCallback(G=>{const U=G.target.value;y(U),R(null);const Q=G.target;Q.style.height="auto",Q.style.height=`${Math.max(i?40:72,Math.min(Q.scrollHeight,i?140:240))}px`,a(!1),Ae(U,Q.selectionStart)},[i,Ae]),ke=C.useCallback(G=>{const U=G.target.files;U&&U.length>0&&(M(Array.from(U)),R(null)),G.target.value=""},[M]),st=C.useCallback(G=>{const U=[];for(const Q of G.clipboardData.items)if(Q.kind==="file"){const se=Q.getAsFile();se&&U.push(se)}U.length>0&&(G.preventDefault(),M(U),R(null))},[M]),je=C.useCallback(async()=>{if(r||j||q)return;const G=$(),U=Y().map(me=>me.id),Q=Ef(w,fe),se=tm({draft:_,attachmentMarkdown:G,attachmentIds:U,mentions:Q});if(!se||!_.trim()&&!V)return;const de=Ff(e.id,se),Ne=_,ve=w,be=H;T(me=>[...me,de]),y(""),k([]),a(!1),d(null),P(),D.current&&(D.current.style.height=i?"40px":"72px"),requestAnimationFrame(()=>ie()),S(!0),R(null);try{const me=await p(se);T(Me=>Me.filter(Se=>Se.id!==de.id)),me&&typeof me=="object"&&"id"in me&&requestAnimationFrame(()=>ie())}catch(me){const Me=me instanceof Error?me.message:"Failed to send room message";T(Se=>Se.map(Pe=>Pe.id===de.id?{...Pe,pendingStatus:"failed",error:Me}:Pe)),y(Se=>Se.length===0?Ne:Se),k(Se=>Se.length===0?ve:Se),I(be),R(Me),requestAnimationFrame(()=>ie())}finally{S(!1)}},[fe,H,$,P,i,_,Y,V,j,q,p,r,I,ie,w,e.id]),We=C.useCallback(G=>{const U=G.nativeEvent.isComposing||G.nativeEvent.keyCode===229;if(ze){if(G.key==="ArrowDown"){G.preventDefault(),b(Q=>(Q+1)%De.length);return}if(G.key==="ArrowUp"){G.preventDefault(),b(Q=>(Q-1+De.length)%De.length);return}if(G.key==="Enter"&&!U||G.key==="Tab"){G.preventDefault();const Q=De[f]??De[0];Q&&Ke(Q);return}if(G.key==="Escape"){G.preventDefault(),d(null),a(!1);return}}G.key==="Enter"&&!G.shiftKey&&!G.repeat&&!U&&(G.preventDefault(),je())},[Ke,je,f,De,ze]);C.useEffect(()=>{y(""),k([]),a(!1),d(null),R(null),T([]),P(),B(null),D.current&&(D.current.style.height=i?"40px":"72px")},[P,i,e.id]);const ue=u.isError?u.error:c.isError?c.error:null,dt=u.isPending||c.isPending,wt=C.useCallback((G,U)=>{g.mutate({memberId:G,cancelQueued:U},{onSuccess:()=>B(null)})},[g]);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[F&&t.jsx(em,{images:F.images,index:F.index,onClose:()=>N(null),onSelect:G=>N(U=>U&&{...U,index:G})}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:W,className:te("h-full overflow-y-auto scrollbar-app-thin bg-white",i?"px-3 py-3":"px-4 py-4"),children:t.jsxs("div",{ref:X,className:te(i?"space-y-2.5":"space-y-3",n&&"max-w-4xl mx-auto"),children:[we.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(us,{size:24,className:"text-neutral-400"}),t.jsx("span",{className:"text-sm",children:l("No room messages yet")})]}):we.map(G=>{if(G.kind==="pendingApproval"){const ve=G.request,be=he.get(ve.targetMemberId),me=u.isPending&&u.variables===ve.id,Me=c.isPending&&c.variables===ve.id;return t.jsx(nm,{request:ve,member:be,onApprove:()=>u.mutate(ve.id),onReject:()=>c.mutate(ve.id),isActionPending:dt,isApprovePending:me,isRejectPending:Me},G.key)}const U=G.message,Q=Gf(U,he,Be),se=U.senderType==="user"?l("你"):U.senderType==="system"?l("System"):Q?.name??l("Agent"),de=Yf(U,he),Ne=Q?.providerId?re.get(Q.providerId)??null:null;return t.jsx(im,{message:U,senderName:se,senderMember:Q,senderProvider:Ne,memberById:he,displayContent:de,onOpenImage:(ve,be)=>N({images:ve,index:be})},G.key)}),ue&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Ki(ue,l("Failed to update work request"))}),g.isError&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Ki(g.error,l("Failed to stop member work"))})]})}),!K&&t.jsxs("button",{type:"button",onClick:()=>ie(),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(Qs,{size:14}),t.jsx("span",{children:l("Back to bottom")})]})]}),t.jsx("div",{className:te("shrink-0 border-t border-transparent bg-white",i?"px-3 pb-2 pt-1.5":"px-6 pb-6 pt-2"),children:t.jsxs("div",{className:te(n&&"max-w-4xl mx-auto"),children:[t.jsx(Df,{invocations:qe,memberById:he,workRequestById:Ge,onViewInvocationSession:m,onStopMember:wt,isStopPending:g.isPending,stoppingMemberId:g.variables?.memberId??null,stopPromptInvocationId:A,onToggleStopConfirm:G=>B(U=>U===G?null:G)}),!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??l("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:[ze&&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:l(h?"Mention members":"Team members")}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:De.map((G,U)=>{const Q=w.includes(G.id),se=U===f;return t.jsxs("button",{type:"button",onMouseEnter:()=>b(U),onMouseDown:de=>{de.preventDefault(),Ke(G)},className:te("flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors",se?"bg-neutral-100":"hover:bg-neutral-50"),children:[t.jsx(Ft,{name:G.name,avatar:G.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:G.name}),Q&&t.jsx("span",{className:"rounded-full bg-neutral-900 px-1.5 py-0.5 text-[10px] font-medium text-white",children:l("selected")})]}),t.jsx("div",{className:"truncate text-xs text-neutral-500",children:[G.providerId,G.id.slice(0,8)].filter(Boolean).join(" · ")})]}),t.jsx(Zn,{size:15,className:"text-neutral-400"})]},G.id)})})]}),Fe.length>0&&t.jsx("div",{className:"flex flex-wrap items-center gap-1.5 border-b border-neutral-100 px-3 py-2",children:Fe.map(G=>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:["@",G.name]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:G.id.slice(0,8)}),t.jsx("button",{type:"button",onClick:()=>Ee(G.id),className:"shrink-0 rounded-full p-0.5 text-neutral-400 transition-colors hover:bg-neutral-200 hover:text-neutral-700",title:l("Remove mention"),"aria-label":`${l("Remove mention")} ${G.name}`,children:t.jsx(ns,{size:12})})]},G.id))}),t.jsx(un,{files:H,onRemove:O}),t.jsx("textarea",{ref:D,value:_,rows:i?1:void 0,onChange:Ce,onKeyDown:We,onPaste:st,onClick:G=>Ae(_,G.currentTarget.selectionStart),onSelect:G=>Ae(_,G.currentTarget.selectionStart),placeholder:l("Message the team room..."),className:te("w-full resize-none border-none bg-transparent text-neutral-900 placeholder-neutral-400 focus:outline-none",i?"px-3 pb-1 pt-2.5 text-[15px] leading-5":"px-4 pb-2 pt-4 text-sm leading-relaxed"),style:i?{minHeight:40,maxHeight:140}:{minHeight:60,maxHeight:220}}),t.jsxs("div",{className:te("flex items-center justify-between",i?"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:z,type:"file",multiple:!0,className:"hidden",onChange:ke}),t.jsx("button",{type:"button",onClick:()=>z.current?.click(),title:l("Upload file"),"aria-label":l("Upload file"),className:"rounded-lg p-2 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",children:t.jsx(mn,{size:18})}),t.jsx("button",{type:"button",onClick:()=>{a(G=>!G),d(null),requestAnimationFrame(()=>D.current?.focus())},disabled:Fe.length===0&&fe.length===0,title:l("Mention members"),"aria-label":l("Mention members"),className:te("rounded-lg transition-colors",i?"p-1.5":"p-2",x?"bg-neutral-100 text-neutral-700":"text-neutral-400 hover:bg-neutral-100 hover:text-neutral-600",Fe.length===0&&fe.length===0?"cursor-not-allowed opacity-50":""),children:t.jsx(Zn,{size:i?15:18})}),Fe.length>0&&t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[Fe.length," ",l("selected")]})]}),t.jsx("button",{type:"button",onClick:()=>{je()},disabled:r||j||q||!_.trim()&&!V,title:l(q?"Uploading...":j?"发送中...":"发送"),"aria-label":l(q?"Uploading...":j?"发送中...":"发送"),className:te("rounded-lg transition-all duration-200",i?"p-1.5":"p-2",(_.trim()||V)&&!r&&!j&&!q?"bg-neutral-900 text-white shadow-md hover:bg-black":"cursor-not-allowed bg-transparent text-neutral-300",j||q?"opacity-70":""),children:t.jsx(hn,{size:i?15:18})})]}),E&&t.jsx("div",{className:"border-t border-neutral-100 px-3 py-2 text-xs text-red-600",children:E})]})]})})]})}function om(e){return e?e.slice(0,8):""}function wo(e){const s=e?Date.parse(e):0;return Number.isNaN(s)?0:s}function Mn(e){return e?.workspaceKind===jt.MAIN_DIRECTORY}function fs(e){return e?Mn(e)?"Project directory":e.branchName:"—"}function ss(e){return e?.workingDir||e?.worktreePath||void 0}function Tn(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,i=m.ownerMemberId?r.get(m.ownerMemberId):void 0,n=!!(p&&m.id===p),l=n?"main":m.parentWorkspaceId?"child":"root",u=i?.name??(m.ownerMemberId?`Member ${om(m.ownerMemberId)}`:void 0),c=Mn(m)?"Project directory":n?"Main workspace":l==="child"?u?`${u} workspace`:"Child workspace":s?"Root workspace":"Workspace";return{workspace:m,kind:l,roleLabel:n?"Main":l==="child"?"Child":"Root",displayName:c,ownerName:u,parentBranchName:v?fs(v):void 0,isMain:n}}).sort((m,v)=>{const i=l=>l.kind==="main"?0:l.kind==="child"?1:2,n=i(m)-i(v);return n!==0?n:wo(m.workspace.createdAt)-wo(v.workspace.createdAt)})}function gl(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===Rt.ACTIVE)?.id??e[0]?.id}function vl(e,s){return!e||e.status!==Rt.ACTIVE||Mn(e)?!1:!s||e.parentWorkspaceId?!0:!!(s.mainWorkspaceId&&e.id===s.mainWorkspaceId)}function xl(e,s,r){return e?.parentWorkspaceId?s?.find(p=>p.id===e.parentWorkspaceId)?.branchName??e.baseBranch??r:r}const Dn={readRoom:!1,postRoomMessage:!1,mentionMembers:!1,stopMemberWork:!1,markReadyForReview:!1,readFiles:!1,writeFiles:!1,runCommands:!1,readDiff:!1,mergeWorkspace:!1},am=[{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:"合并工作区"}],_l=[{value:"none",label:"无"},{value:"shared",label:"共享"},{value:"dedicated",label:"独占"}],lm=[{value:"MENTION_ONLY",label:"仅提及"},{value:"USER_MESSAGES",label:"所有用户消息"}],bl=[{value:"new_per_request",label:"每次新会话"},{value:"resume_last",label:"复用上次会话"}],cm=[{value:"own_only",label:"仅自己队列"},{value:"team_pending",label:"全队列待处理"}];function Hs(){return{name:"",aliasesText:"",providerId:"",rolePrompt:"",capabilities:{...Dn},workspacePolicy:"none",triggerPolicy:"MENTION_ONLY",sessionPolicy:"new_per_request",queueManagementPolicy:"own_only",avatar:""}}function Ss(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...Dn,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function yi(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...Dn,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function dm(e){return Array.from(new Set(e.split(/[\n,]/).map(s=>s.trim()).filter(Boolean)))}function um(e){return{name:e.name.trim(),aliases:dm(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 Co(e,s){return e instanceof Error?e.message:s}function ko(e){return e.membershipStatus!=="REMOVED"}function Xi(e){return e.status==="RUNNING"||e.status==="WAITING_ROOM_REPLY"||e.status==="SESSION_ENDED"||e.status==="QUEUED"}function Eo(e){return Xi(e)?"bg-emerald-500":e.status==="FAILED"?"bg-red-500":"bg-neutral-300"}function jo(e){return _l.find(s=>s.value===e)?.label??e}function hm(e){return bl.find(s=>s.value===e)?.label??e}function Ot({children:e}){return t.jsx("span",{className:"text-xs font-medium text-neutral-600",children:e})}function No({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 fm({isOpen:e,onClose:s,teamRun:r}){const{t:o}=ce(),{data:p=[]}=nd(),{data:m=[]}=Ds(),v=od(r.id),i=ad(r.id),n=ld(r.id),l=C.useRef(!1),[u,c]=C.useState("edit"),[g,_]=C.useState(null),[y,x]=C.useState(""),[a,h]=C.useState(Hs()),[d,f]=C.useState(null),[b,w]=C.useState(null),k=r.members??[],j=C.useMemo(()=>k.filter(ko),[k]),S=C.useMemo(()=>b&&ko(b)&&!j.some(F=>F.id===b.id)?[...j,b]:j,[b,j]),E=g?j.find(F=>F.id===g)??null:null,R=b?.id===g?b:E,L=y?p.find(F=>F.id===y)??null:null,T=v.isPending||i.isPending||n.isPending,A=S.filter(Xi).length,B=C.useMemo(()=>{const F=m.map(({provider:N,availability:W})=>({value:N.id,label:N.name+(W.type==="NOT_FOUND"?o(" (不可用)"):""),icon:t.jsx(Kr,{agentType:N.agentType,className:"size-4"}),disabled:W.type==="NOT_FOUND"}));return a.providerId&&!F.some(N=>N.value===a.providerId)&&F.unshift({value:a.providerId,label:`${a.providerId}${o(" (不可用)")}`,disabled:!0}),F},[a.providerId,m,o]);C.useEffect(()=>{if(!e){l.current=!1,w(null);return}if(l.current)return;l.current=!0;const F=S[0]??null;c(F?"edit":"add-preset"),_(F?.id??null),x(""),h(F?Ss(F):Hs()),f(null)},[S,e]),C.useEffect(()=>{b&&j.some(F=>F.id===b.id)&&w(null)},[b,j]),C.useEffect(()=>{u==="add-preset"&&L&&h(yi(L))},[u,L]);const D=(F,N)=>{h(W=>({...W,[F]:N}))},z=(F,N)=>{h(W=>({...W,capabilities:{...W.capabilities,[F]:N}}))},H=F=>{c("edit"),_(F.id),x(""),h(Ss(F))},M=()=>{c("add-preset"),_(null);const F=L??p[0]??null;x(F?.id??""),h(F?yi(F):Hs())},O=()=>{c("add-custom"),_(null),x(""),h(Hs())},P=!!(a.name.trim()&&a.providerId.trim()&&a.rolePrompt.trim()),I=u==="add-preset"?!!y:u==="edit"?!!(R&&P):P,$=async()=>{try{if(u==="add-preset"){if(!y)return;const N=await v.mutateAsync({memberPresetId:y});ct.success(o("Member added")),w(N),c("edit"),_(N.id),x(""),h(Ss(N));return}const F=um(a);if(!F.name||!F.providerId||!F.rolePrompt){ct.error(o("Name, provider, and role prompt are required"));return}if(u==="add-custom"){const N=await v.mutateAsync({member:F});ct.success(o("Member added")),w(N),c("edit"),_(N.id),h(Ss(N));return}if(R){const N=await i.mutateAsync({memberId:R.id,data:F});ct.success(o("Member updated")),w(W=>W?.id===N.id?N:W),_(N.id),h(Ss(N))}}catch(F){ct.error(Co(F,o("Failed to save member")))}},Y=async()=>{if(d)try{if(await n.mutateAsync({memberId:d.id,stopActive:!0,cancelQueued:!0}),g===d.id){const F=S.find(N=>N.id!==d.id)??null;_(F?.id??null),c(F?"edit":"add-preset"),h(F?Ss(F):Hs())}w(F=>F?.id===d.id?null:F),f(null),ct.success(o("Member removed"))}catch(F){ct.error(Co(F,o("Failed to remove member")))}},q=()=>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(xr,{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(Re,{type:"button",variant:"outline",size:"sm",onClick:O,disabled:T,children:[t.jsx(io,{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(No,{icon:t.jsx(xr,{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(Re,{type:"button",variant:"outline",size:"sm",onClick:O,disabled:T,children:[t.jsx(ts,{size:13}),o("Custom member")]})}):t.jsx("div",{className:"grid grid-cols-1 gap-2 xl:grid-cols-2",children:p.map(F=>{const N=y===F.id;return t.jsxs("button",{type:"button",onClick:()=>{x(F.id),h(yi(F))},className:te("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(Ft,{name:F.name,avatar:F.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:F.name}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:F.providerId}),t.jsxs("span",{className:"mt-1 block truncate text-[10px] text-neutral-400",children:[o(jo(F.workspacePolicy))," · ",o(hm(F.sessionPolicy))]})]}),N?t.jsx(qt,{size:16,className:"shrink-0 text-neutral-900"}):null]},F.id)})})})]}),V=()=>{const F=u==="edit";return F&&!R?t.jsx("div",{className:"p-5",children:t.jsx(No,{icon:t.jsx(us,{size:18}),title:o("Select a member"),description:o("Choose a member on the left to edit its future TeamRun configuration."),action:t.jsxs(Re,{type:"button",variant:"outline",size:"sm",onClick:M,disabled:T,children:[t.jsx(ts,{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:[F?t.jsx(za,{size:15,className:"text-neutral-500"}):t.jsx(ts,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o(F?"Edit member":"Custom member")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:o(F?"Provider, role, workspace, and session changes apply to future work only.":"Create a one-off member snapshot for this TeamRun.")})]}),F&&R?t.jsxs(Re,{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(pn,{size:13}),o("Remove")]}):t.jsxs(Re,{type:"button",variant:"outline",size:"sm",onClick:M,disabled:T,children:[t.jsx(xr,{size:13}),o("Use preset")]})]})}),t.jsxs("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:[F&&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(Ft,{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:te("h-2 w-2 shrink-0 rounded-full",Eo(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(jo(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(Ot,{children:o("Name")}),t.jsx("input",{value:a.name,onChange:N=>D("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(Ot,{children:o("Aliases")}),t.jsx("input",{value:a.aliasesText,onChange:N=>D("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(Ot,{children:o("Provider")}),t.jsx(cs,{value:a.providerId,onChange:N=>D("providerId",N),options:B})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ot,{children:o("Avatar")}),t.jsx("input",{value:a.avatar,onChange:N=>D("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(Ot,{children:o("Workspace policy")}),t.jsx(cs,{value:a.workspacePolicy,onChange:N=>D("workspacePolicy",N),options:_l.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ot,{children:o("Trigger policy")}),t.jsx(cs,{value:a.triggerPolicy,onChange:N=>D("triggerPolicy",N),options:lm.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ot,{children:o("Session policy")}),t.jsx(cs,{value:a.sessionPolicy,onChange:N=>D("sessionPolicy",N),options:bl.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ot,{children:o("Queue policy")}),t.jsx(cs,{value:a.queueManagementPolicy,onChange:N=>D("queueManagementPolicy",N),options:cm.map(N=>({value:N.value,label:o(N.label)}))})]})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Ot,{children:o("Role prompt")}),t.jsx("textarea",{value:a.rolePrompt,onChange:N=>D("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(Ot,{children:o("Capabilities")}),t.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-3",children:am.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:!!a.capabilities[N.key],onChange:W=>z(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(hs,{isOpen:e,onClose:T?()=>{}:s,title:o("Manage Team Members"),className:"max-w-6xl",action:t.jsxs(t.Fragment,{children:[t.jsx(Re,{type:"button",variant:"outline",onClick:s,disabled:T,children:o("Close")}),t.jsx(Re,{type:"button",onClick:$,disabled:T||!I,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(us,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o("Members")})]}),t.jsxs("div",{className:"mt-1 text-xs text-neutral-500",children:[S.length," ",o("active")," · ",A," ",o("working")]})]}),t.jsx(Re,{type:"button",size:"icon-sm",variant:"outline",onClick:M,disabled:T,title:o("Add member"),children:t.jsx(ts,{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:S.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:S.map(F=>{const N=u==="edit"&&g===F.id;return t.jsxs("button",{type:"button",onClick:()=>H(F),className:te("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(Ft,{name:F.name,avatar:F.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:te("h-1.5 w-1.5 shrink-0 rounded-full",Eo(F))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:F.name})]}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:F.providerId})]}),t.jsx(uu,{size:13,className:te("shrink-0 text-neutral-300 transition-opacity",N?"opacity-100":"opacity-0 group-hover:opacity-100")})]},F.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:M,disabled:T,className:te("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(xr,{size:12}),o("Preset")]}),t.jsxs("button",{type:"button",onClick:O,disabled:T,className:te("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(io,{size:12}),o("Custom")]})]})})]}),t.jsx("section",{className:"flex min-h-0 min-w-0 flex-col",children:u==="add-preset"?q():V()})]})}),t.jsx(an,{isOpen:!!d,onClose:()=>f(null),onConfirm:Y,title:o("Remove member"),variant:"danger",isLoading:n.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&&Xi(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(rr,{size:15,className:"mt-0.5 shrink-0"}),t.jsx("span",{className:"text-sm font-medium",children:o("确认后会停止当前工作并取消队列")})]}):null]})})]})}const mm=[],pm=[],gm=[],vm=240;function xm(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 Ro={running:0,"waiting room reply":1,queued:2,"session ended":3,"pending approval":4,idle:5,removed:6};function Si(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 Ao(e,s){return e instanceof Error?e.message:s}function _m(e,s=vm){const r=(e??"").replace(/\s+/g," ").trim();return r.length<=s?r:`${r.slice(0,s-3).trimEnd()}...`}function _r(e){return e?e.instructionPreview??_m(e.instruction):""}function bm(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 ym(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 Sm(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 wm(e){switch(e){case"user":return"User";case"agent":return"Agent";case"system":return"System"}}function Cm(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 km(e){switch(e){case Rt.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case Rt.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case Rt.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case Rt.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function Em(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 jm(e){return[...e].sort((s,r)=>Date.parse(r.updatedAt??r.createdAt??"")-Date.parse(s.updatedAt??s.createdAt??""))}function Nm(e,s){return s.find(r=>r.memberId===e.id&&ei.has(r.status))}function yl({teamRun:e,workspaces:s,selectedWorkspaceId:r,onSelectWorkspace:o,onViewInvocationSession:p}){const{t:m}=ce(),v=pa(e.id),i=ga(e.id),n=va(e.id),[l,u]=C.useState(null),[c,g]=C.useState(null),[_,y]=C.useState(!1),[x,a]=C.useState(!1),h=e.members??mm,d=C.useMemo(()=>h.filter(D=>D.membershipStatus!=="REMOVED"),[h]),f=e.workRequests??pm,b=e.invocations??gm,w=C.useMemo(()=>Tn(s,e),[e,s]),k=C.useMemo(()=>new Map(f.map(D=>[D.id,D])),[f]),j=C.useMemo(()=>[...f].filter(D=>D.status==="PENDING_APPROVAL").sort((D,z)=>Date.parse(z.updatedAt??z.createdAt??"")-Date.parse(D.updatedAt??D.createdAt??"")),[f]),S=C.useMemo(()=>[...f].filter(D=>D.status==="QUEUED").sort((D,z)=>Date.parse(z.updatedAt??z.createdAt??"")-Date.parse(D.updatedAt??D.createdAt??"")),[f]),E=C.useMemo(()=>[...h].map(D=>({member:D,status:xm(D.status)})).sort((D,z)=>Ro[D.status]-Ro[z.status]),[h]),R=v.isError?v.error:i.isError?i.error:null,L=v.isPending||i.isPending,T=w.find(D=>D.workspace.id===r),A=e.messages??[],B=E.filter(({status:D})=>D==="running"||D==="waiting room reply").length;return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[t.jsx(fm,{isOpen:x,onClose:()=>a(!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(As,{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(qr,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:A.length})]}),t.jsxs("span",{className:"inline-flex items-center gap-1",title:m("Members"),children:[t.jsx(us,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:B>0?`${B}/${d.length}`:d.length}),B>0&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500"})]}),S.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1",title:m("Queue"),children:[t.jsx(Es,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:S.length})]}),j.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-600",title:m("Pending approval"),children:[t.jsx(Es,{size:11}),t.jsx("span",{className:"tabular-nums",children:j.length})]})]}),t.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-app-thin px-4 py-3 space-y-3",children:[j.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(Es,{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:j.length})]}),t.jsx("div",{className:"space-y-1.5",children:j.map(D=>{const z=h.find(O=>O.id===D.targetMemberId),H=v.isPending&&v.variables===D.id,M=i.isPending&&i.variables===D.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(Ft,{name:z?.name??"Agent",avatar:z?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:z?.name??D.targetMemberId})]}),t.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-neutral-600 line-clamp-2",children:_r(D)})]})}),t.jsxs("div",{className:"mt-1.5 flex items-center gap-x-2 text-[10px] text-neutral-400",children:[t.jsx("span",{children:m(wm(D.requesterType))}),t.jsx("span",{children:Si(D.createdAt)})]}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>v.mutate(D.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(qt,{size:11}),t.jsx("span",{className:"truncate",children:m(H?"Approving":"Approve")})]}),t.jsxs("button",{type:"button",onClick:()=>i.mutate(D.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(ns,{size:11}),t.jsx("span",{className:"truncate",children:m(M?"Rejecting":"Reject")})]})]})]},D.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:Ao(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(us,{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:()=>a(!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(za,{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:E.map(({member:D,status:z})=>{const H=Nm(D,b),M=jm(b.filter(V=>V.memberId===D.id)),O=H?k.get(H.workRequestId):void 0,P=c===D.id,I=z==="running"||z==="waiting room reply",$=I&&!!H,Y=l===D.id,q=n.isPending&&n.variables?.memberId===D.id;return t.jsxs("div",{className:te("bg-white",P&&"bg-neutral-50/50"),children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[t.jsx(Ft,{name:D.name,avatar:D.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:te("h-1.5 w-1.5 shrink-0 rounded-full",Sm(z))}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:D.name}),t.jsx("span",{className:te("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",ym(z)),children:m(bm(z))})]}),I&&O?.instruction&&t.jsx("div",{className:"mt-0.5 truncate pl-3 text-[10px] text-neutral-500",children:_r(O)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[$&&t.jsx("button",{type:"button",onClick:()=>u(Y?null:D.id),disabled:n.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(Ms,{size:12})}),H?.sessionId&&p&&t.jsx("button",{type:"button",onClick:()=>p(H.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(Fi,{size:12})}),t.jsx("button",{type:"button",onClick:()=>g(P?null:D.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":P,children:P?t.jsx(yt,{size:13}):t.jsx(Mt,{size:13})})]})]}),$&&Y&&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:()=>{n.mutate({memberId:D.id,cancelQueued:!1},{onSuccess:()=>u(null)})},disabled:n.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(Ms,{size:10}),t.jsx("span",{children:q&&n.variables?.cancelQueued===!1?m("Stopping"):m("Stop only")})]}),t.jsxs("button",{type:"button",onClick:()=>{n.mutate({memberId:D.id,cancelQueued:!0},{onSuccess:()=>u(null)})},disabled:n.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(Ba,{size:10}),t.jsx("span",{children:q&&n.variables?.cancelQueued===!0?m("Stopping"):m("Stop + clear queue")})]})]})]}),P&&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:D.providerId}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:D.workspacePolicy}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:D.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:M.length})]}),M.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:M.map(V=>{const F=k.get(V.workRequestId),N=!!(V.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:te("rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Cm(V.status)),children:V.status}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:Si(V.updatedAt??V.createdAt)})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:_r(F)||V.workRequestId})]}),N&&t.jsxs("button",{type:"button",onClick:()=>V.sessionId&&p?.(V.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(Fi,{size:10}),t.jsx("span",{children:m("Log")})]})]})},V.id)})})]}),E[E.length-1]?.member.id!==D.id&&!P&&t.jsx("div",{className:"mx-3 border-b border-neutral-100"})]},D.id)})}),n.isError&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Ao(n.error,m("Failed to stop member work"))})]}),S.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(Es,{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:S.length})]}),t.jsx("div",{className:"space-y-1",children:S.map(D=>{const z=h.find(H=>H.id===D.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(Ft,{name:z?.name??"Agent",avatar:z?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:z?.name??D.targetMemberId})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:_r(D)})]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:Si(D.createdAt)})]})},D.id)})})]}),w.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>y(D=>!D),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":_,"aria-label":m("Workspaces"),children:[t.jsx(As,{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:fs(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:w.length}),_?t.jsx(yt,{size:13,className:"text-neutral-400"}):t.jsx(Mt,{size:13,className:"text-neutral-400"})]})]}),_&&t.jsx("div",{className:"space-y-1.5",children:w.map(D=>{const z=r===D.workspace.id;return t.jsx("div",{className:te("rounded-md border bg-white px-3 py-2",z?"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(D.displayName)}),t.jsx("span",{className:te("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Em(D.roleLabel)),children:m(D.roleLabel)}),t.jsx("span",{className:te("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",km(D.workspace.status)),children:D.workspace.status})]}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] text-neutral-500",children:fs(D.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:[D.ownerName&&t.jsxs("span",{children:[m("Owner"),": ",D.ownerName]}),D.parentBranchName&&t.jsxs("span",{children:[m("Parent"),": ",D.parentBranchName]})]})]}),t.jsxs("button",{type:"button",onClick:()=>o?.(D.workspace.id),disabled:!o||z,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:[z?t.jsx(qt,{size:11}):t.jsx(Aa,{size:11}),t.jsx("span",{children:m(z?"Selected":"Select")})]})]})},D.workspace.id)})})]}),j.length===0&&S.length===0&&E.every(({status:D})=>D==="idle")&&t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:m("All members idle")})]})]})}var wi={exports:{}},Mo;function Rm(){return Mo||(Mo=1,(function(e,s){(function(r,o){e.exports=o()})(self,(()=>(()=>{var r={4567:function(v,i,n){var l=this&&this.__decorate||function(f,b,w,k){var j,S=arguments.length,E=S<3?b:k===null?k=Object.getOwnPropertyDescriptor(b,w):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(f,b,w,k);else for(var R=f.length-1;R>=0;R--)(j=f[R])&&(E=(S<3?j(E):S>3?j(b,w,E):j(b,w))||E);return S>3&&E&&Object.defineProperty(b,w,E),E},u=this&&this.__param||function(f,b){return function(w,k){b(w,k,f)}};Object.defineProperty(i,"__esModule",{value:!0}),i.AccessibilityManager=void 0;const c=n(9042),g=n(6114),_=n(9924),y=n(844),x=n(5596),a=n(4725),h=n(3656);let d=i.AccessibilityManager=class extends y.Disposable{constructor(f,b){super(),this._terminal=f,this._renderService=b,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 w=0;w<this._terminal.rows;w++)this._rowElements[w]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[w]);if(this._topBoundaryFocusListener=w=>this._handleBoundaryFocus(w,0),this._bottomBoundaryFocusListener=w=>this._handleBoundaryFocus(w,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 _.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((w=>this._handleResize(w.rows)))),this.register(this._terminal.onRender((w=>this._refreshRows(w.start,w.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((w=>this._handleChar(w)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
|
|
20
|
-
`)))),this.register(this._terminal.onA11yTab((w=>this._handleTab(w)))),this.register(this._terminal.onKey((w=>this._handleKey(w.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this._screenDprMonitor=new x.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,y.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(f){for(let b=0;b<f;b++)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,b){this._liveRegionDebouncer.refresh(f,b,this._terminal.rows)}_renderRows(f,b){const w=this._terminal.buffer,k=w.lines.length.toString();for(let j=f;j<=b;j++){const S=w.translateBufferLineToString(w.ydisp+j,!0),E=(w.ydisp+j+1).toString(),R=this._rowElements[j];R&&(S.length===0?R.innerText=" ":R.textContent=S,R.setAttribute("aria-posinset",E),R.setAttribute("aria-setsize",k))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(f,b){const w=f.target,k=this._rowElements[b===0?1:this._rowElements.length-2];if(w.getAttribute("aria-posinset")===(b===0?"1":`${this._terminal.buffer.lines.length}`)||f.relatedTarget!==k)return;let j,S;if(b===0?(j=w,S=this._rowElements.pop(),this._rowContainer.removeChild(S)):(j=this._rowElements.shift(),S=w,this._rowContainer.removeChild(j)),j.removeEventListener("focus",this._topBoundaryFocusListener),S.removeEventListener("focus",this._bottomBoundaryFocusListener),b===0){const E=this._createAccessibilityTreeNode();this._rowElements.unshift(E),this._rowContainer.insertAdjacentElement("afterbegin",E)}else{const E=this._createAccessibilityTreeNode();this._rowElements.push(E),this._rowContainer.appendChild(E)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(b===0?-1:1),this._rowElements[b===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 b=this._rowContainer.children.length;b<this._terminal.rows;b++)this._rowElements[b]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[b]);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`}};i.AccessibilityManager=d=l([u(1,a.IRenderService)],d)},3614:(v,i)=>{function n(g){return g.replace(/\r?\n/g,"\r")}function l(g,_){return _?"\x1B[200~"+g+"\x1B[201~":g}function u(g,_,y,x){g=l(g=n(g),y.decPrivateModes.bracketedPasteMode&&x.rawOptions.ignoreBracketedPasteMode!==!0),y.triggerDataEvent(g,!0),_.value=""}function c(g,_,y){const x=y.getBoundingClientRect(),a=g.clientX-x.left-10,h=g.clientY-x.top-10;_.style.width="20px",_.style.height="20px",_.style.left=`${a}px`,_.style.top=`${h}px`,_.style.zIndex="1000",_.focus()}Object.defineProperty(i,"__esModule",{value:!0}),i.rightClickHandler=i.moveTextAreaUnderMouseCursor=i.paste=i.handlePasteEvent=i.copyHandler=i.bracketTextForPaste=i.prepareTextForTerminal=void 0,i.prepareTextForTerminal=n,i.bracketTextForPaste=l,i.copyHandler=function(g,_){g.clipboardData&&g.clipboardData.setData("text/plain",_.selectionText),g.preventDefault()},i.handlePasteEvent=function(g,_,y,x){g.stopPropagation(),g.clipboardData&&u(g.clipboardData.getData("text/plain"),_,y,x)},i.paste=u,i.moveTextAreaUnderMouseCursor=c,i.rightClickHandler=function(g,_,y,x,a){c(g,_,y),a&&x.rightClickSelect(g),_.value=x.selectionText,_.select()}},7239:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ColorContrastCache=void 0;const l=n(1505);i.ColorContrastCache=class{constructor(){this._color=new l.TwoKeyMap,this._css=new l.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,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.addDisposableDomListener=void 0,i.addDisposableDomListener=function(n,l,u,c){n.addEventListener(l,u,c);let g=!1;return{dispose:()=>{g||(g=!0,n.removeEventListener(l,u,c))}}}},6465:function(v,i,n){var l=this&&this.__decorate||function(a,h,d,f){var b,w=arguments.length,k=w<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,f);else for(var j=a.length-1;j>=0;j--)(b=a[j])&&(k=(w<3?b(k):w>3?b(h,d,k):b(h,d))||k);return w>3&&k&&Object.defineProperty(h,d,k),k},u=this&&this.__param||function(a,h){return function(d,f){h(d,f,a)}};Object.defineProperty(i,"__esModule",{value:!0}),i.Linkifier2=void 0;const c=n(3656),g=n(8460),_=n(844),y=n(2585);let x=i.Linkifier2=class extends _.Disposable{get currentLink(){return this._currentLink}constructor(a){super(),this._bufferService=a,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,_.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,_.toDisposable)((()=>{this._lastMouseEvent=void 0}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0})))}registerLinkProvider(a){return this._linkProviders.push(a),{dispose:()=>{const h=this._linkProviders.indexOf(a);h!==-1&&this._linkProviders.splice(h,1)}}}attachToDom(a,h,d){this._element=a,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(a){if(this._lastMouseEvent=a,!this._element||!this._mouseService)return;const h=this._positionFromMouseEvent(a,this._element,this._mouseService);if(!h)return;this._isMouseOut=!1;const d=a.composedPath();for(let f=0;f<d.length;f++){const b=d[f];if(b.classList.contains("xterm"))break;if(b.classList.contains("xterm-hover"))return}this._lastBufferCell&&h.x===this._lastBufferCell.x&&h.y===this._lastBufferCell.y||(this._handleHover(h),this._lastBufferCell=h)}_handleHover(a){if(this._activeLine!==a.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(a,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,a)||(this._clearCurrentLink(),this._askForLink(a,!0))}_askForLink(a,h){var d,f;this._activeProviderReplies&&h||((d=this._activeProviderReplies)===null||d===void 0||d.forEach((w=>{w?.forEach((k=>{k.link.dispose&&k.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=a.y);let b=!1;for(const[w,k]of this._linkProviders.entries())h?!((f=this._activeProviderReplies)===null||f===void 0)&&f.get(w)&&(b=this._checkLinkProviderResult(w,a,b)):k.provideLinks(a.y,(j=>{var S,E;if(this._isMouseOut)return;const R=j?.map((L=>({link:L})));(S=this._activeProviderReplies)===null||S===void 0||S.set(w,R),b=this._checkLinkProviderResult(w,a,b),((E=this._activeProviderReplies)===null||E===void 0?void 0:E.size)===this._linkProviders.length&&this._removeIntersectingLinks(a.y,this._activeProviderReplies)}))}_removeIntersectingLinks(a,h){const d=new Set;for(let f=0;f<h.size;f++){const b=h.get(f);if(b)for(let w=0;w<b.length;w++){const k=b[w],j=k.link.range.start.y<a?0:k.link.range.start.x,S=k.link.range.end.y>a?this._bufferService.cols:k.link.range.end.x;for(let E=j;E<=S;E++){if(d.has(E)){b.splice(w--,1);break}d.add(E)}}}}_checkLinkProviderResult(a,h,d){var f;if(!this._activeProviderReplies)return d;const b=this._activeProviderReplies.get(a);let w=!1;for(let k=0;k<a;k++)this._activeProviderReplies.has(k)&&!this._activeProviderReplies.get(k)||(w=!0);if(!w&&b){const k=b.find((j=>this._linkAtPosition(j.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 j=(f=this._activeProviderReplies.get(k))===null||f===void 0?void 0:f.find((S=>this._linkAtPosition(S.link,h)));if(j){d=!0,this._handleNewLink(j);break}}return d}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(a){if(!this._element||!this._mouseService||!this._currentLink)return;const h=this._positionFromMouseEvent(a,this._element,this._mouseService);h&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,h)&&this._currentLink.link.activate(a,this._currentLink.link.text)}_clearCurrentLink(a,h){this._element&&this._currentLink&&this._lastMouseEvent&&(!a||!h||this._currentLink.link.range.start.y>=a&&this._currentLink.link.range.end.y<=h)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,_.disposeArray)(this._linkCacheDisposables))}_handleNewLink(a){if(!this._element||!this._lastMouseEvent||!this._mouseService)return;const h=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);h&&this._linkAtPosition(a.link,h)&&(this._currentLink=a,this._currentLink.state={decorations:{underline:a.link.decorations===void 0||a.link.decorations.underline,pointerCursor:a.link.decorations===void 0||a.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,a.link,this._lastMouseEvent),a.link.decorations={},Object.defineProperties(a.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,b;!((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&&((b=this._element)===null||b===void 0||b.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,b,w;!((f=this._currentLink)===null||f===void 0)&&f.state&&((w=(b=this._currentLink)===null||b===void 0?void 0:b.state)===null||w===void 0?void 0:w.decorations.underline)!==d&&(this._currentLink.state.decorations.underline=d,this._currentLink.state.isHovered&&this._fireUnderlineEvent(a.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,b=this._bufferService.buffer.ydisp+1+d.end;if(this._currentLink.link.range.start.y>=f&&this._currentLink.link.range.end.y<=b&&(this._clearCurrentLink(f,b),this._lastMouseEvent&&this._element)){const w=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);w&&this._askForLink(w,!1)}}))))}_linkHover(a,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&&a.classList.add("xterm-cursor-pointer")),h.hover&&h.hover(d,h.text)}_fireUnderlineEvent(a,h){const d=a.range,f=this._bufferService.buffer.ydisp,b=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(b)}_linkLeave(a,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&&a.classList.remove("xterm-cursor-pointer")),h.leave&&h.leave(d,h.text)}_linkAtPosition(a,h){const d=a.range.start.y*this._bufferService.cols+a.range.start.x,f=a.range.end.y*this._bufferService.cols+a.range.end.x,b=h.y*this._bufferService.cols+h.x;return d<=b&&b<=f}_positionFromMouseEvent(a,h,d){const f=d.getCoords(a,h,this._bufferService.cols,this._bufferService.rows);if(f)return{x:f[0],y:f[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(a,h,d,f,b){return{x1:a,y1:h,x2:d,y2:f,cols:this._bufferService.cols,fg:b}}};i.Linkifier2=x=l([u(0,y.IBufferService)],x)},9042:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.tooMuchOutput=i.promptLabel=void 0,i.promptLabel="Terminal input",i.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(v,i,n){var l=this&&this.__decorate||function(x,a,h,d){var f,b=arguments.length,w=b<3?a:d===null?d=Object.getOwnPropertyDescriptor(a,h):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(x,a,h,d);else for(var k=x.length-1;k>=0;k--)(f=x[k])&&(w=(b<3?f(w):b>3?f(a,h,w):f(a,h))||w);return b>3&&w&&Object.defineProperty(a,h,w),w},u=this&&this.__param||function(x,a){return function(h,d){a(h,d,x)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OscLinkProvider=void 0;const c=n(511),g=n(2585);let _=i.OscLinkProvider=class{constructor(x,a,h){this._bufferService=x,this._optionsService=a,this._oscLinkService=h}provideLinks(x,a){var h;const d=this._bufferService.buffer.lines.get(x-1);if(!d)return void a(void 0);const f=[],b=this._optionsService.rawOptions.linkHandler,w=new c.CellData,k=d.getTrimmedLength();let j=-1,S=-1,E=!1;for(let R=0;R<k;R++)if(S!==-1||d.hasContent(R)){if(d.loadCell(R,w),w.hasExtendedAttrs()&&w.extended.urlId){if(S===-1){S=R,j=w.extended.urlId;continue}E=w.extended.urlId!==j}else S!==-1&&(E=!0);if(E||S!==-1&&R===k-1){const L=(h=this._oscLinkService.getLinkData(j))===null||h===void 0?void 0:h.uri;if(L){const T={start:{x:S+1,y:x},end:{x:R+(E||R!==k-1?0:1),y:x}};let A=!1;if(!b?.allowNonHttpProtocols)try{const B=new URL(L);["http:","https:"].includes(B.protocol)||(A=!0)}catch{A=!0}A||f.push({text:L,range:T,activate:(B,D)=>b?b.activate(B,D,T):y(0,D),hover:(B,D)=>{var z;return(z=b?.hover)===null||z===void 0?void 0:z.call(b,B,D,T)},leave:(B,D)=>{var z;return(z=b?.leave)===null||z===void 0?void 0:z.call(b,B,D,T)}})}E=!1,w.hasExtendedAttrs()&&w.extended.urlId?(S=R,j=w.extended.urlId):(S=-1,j=-1)}}a(f)}};function y(x,a){if(confirm(`Do you want to navigate to ${a}?
|
|
22
|
-
|
|
23
|
-
WARNING: This link could potentially be dangerous`)){const h=window.open();if(h){try{h.opener=null}catch{}h.location.href=a}else console.warn("Opening link blocked as opener could not be cleared")}}i.OscLinkProvider=_=l([u(0,g.IBufferService),u(1,g.IOptionsService),u(2,g.IOscLinkService)],_)},6193:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.RenderDebouncer=void 0,i.RenderDebouncer=class{constructor(n,l){this._parentWindow=n,this._renderCallback=l,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._parentWindow.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(n){return this._refreshCallbacks.push(n),this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(n,l,u){this._rowCount=u,n=n!==void 0?n:0,l=l!==void 0?l:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,n):n,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,l):l,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 n=Math.max(this._rowStart,0),l=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(n,l),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const n of this._refreshCallbacks)n(0);this._refreshCallbacks=[]}}},5596:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ScreenDprMonitor=void 0;const l=n(844);class u extends l.Disposable{constructor(g){super(),this._parentWindow=g,this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this.register((0,l.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)}}i.ScreenDprMonitor=u},3236:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Terminal=void 0;const l=n(3614),u=n(3656),c=n(6465),g=n(9042),_=n(3730),y=n(1680),x=n(3107),a=n(5744),h=n(2950),d=n(1296),f=n(428),b=n(4269),w=n(5114),k=n(8934),j=n(3230),S=n(9312),E=n(4725),R=n(6731),L=n(8055),T=n(8969),A=n(8460),B=n(844),D=n(6114),z=n(8437),H=n(2584),M=n(7399),O=n(5941),P=n(9074),I=n(2585),$=n(5435),Y=n(4567),q=typeof window<"u"?window.document:null;class V 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=D,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new B.MutableDisposable),this._onCursorMove=this.register(new A.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new A.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new A.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new A.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new A.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new A.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new A.EventEmitter),this._onBlur=this.register(new A.EventEmitter),this._onA11yCharEmitter=this.register(new A.EventEmitter),this._onA11yTabEmitter=this.register(new A.EventEmitter),this._onWillOpen=this.register(new A.EventEmitter),this._setup(),this.linkifier2=this.register(this._instantiationService.createInstance(c.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(_.OscLinkProvider)),this._decorationService=this._instantiationService.createInstance(P.DecorationService),this._instantiationService.setService(I.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,A.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,A.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,A.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,A.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((W=>this._afterResize(W.cols,W.rows)))),this.register((0,B.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,K="";switch(W.index){case 256:X="foreground",K="10";break;case 257:X="background",K="11";break;case 258:X="cursor",K="12";break;default:X="ansi",K="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(`${H.C0.ESC}]${K};${(0,O.toRgbString)(ie)}${H.C1_ESCAPED.ST}`);break;case 1:if(X==="ansi")this._themeService.modifyColors((Z=>Z.ansi[W.index]=L.rgba.toColor(...W.color)));else{const Z=X;this._themeService.modifyColors((re=>re[Z]=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(Y.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(N){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(H.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(H.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),K=this._renderService.dimensions.css.cell.height,ie=W.getWidth(X),Z=this._renderService.dimensions.css.cell.width*ie,re=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=re+"px",this.textarea.style.width=Z+"px",this.textarea.style.height=K+"px",this.textarea.style.lineHeight=K+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,u.addDisposableDomListener)(this.element,"copy",(W=>{this.hasSelection()&&(0,l.copyHandler)(W,this._selectionService)})));const N=W=>(0,l.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)),D.isFirefox?this.register((0,u.addDisposableDomListener)(this.element,"mousedown",(W=>{W.button===2&&(0,l.rightClickHandler)(W,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,u.addDisposableDomListener)(this.element,"contextmenu",(W=>{(0,l.rightClickHandler)(W,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),D.isLinux&&this.register((0,u.addDisposableDomListener)(this.element,"auxclick",(W=>{W.button===1&&(0,l.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=q.createDocumentFragment();this._viewportElement=q.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),X.appendChild(this._viewportElement),this._viewportScrollArea=q.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=q.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=q.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),X.appendChild(this.screenElement),this.textarea=q.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",g.promptLabel),D.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(w.CoreBrowserService,this.textarea,(W=this._document.defaultView)!==null&&W!==void 0?W:window),this._instantiationService.setService(E.ICoreBrowserService,this._coreBrowserService),this.register((0,u.addDisposableDomListener)(this.textarea,"focus",(K=>this._handleTextAreaFocus(K)))),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(E.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(R.ThemeService),this._instantiationService.setService(E.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(b.CharacterJoinerService),this._instantiationService.setService(E.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(j.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(E.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((K=>this._onRender.fire(K)))),this.onResize((K=>this._renderService.resize(K.cols,K.rows))),this._compositionView=q.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(E.IMouseService,this._mouseService),this.viewport=this._instantiationService.createInstance(y.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((K=>this.scrollLines(K.amount,K.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(S.SelectionService,this.element,this.screenElement,this.linkifier2)),this._instantiationService.setService(E.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((K=>this.scrollLines(K.amount,K.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((K=>this._renderService.handleSelectionChanged(K.start,K.end,K.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((K=>{this.textarea.value=K,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((K=>{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(x.BufferDecorationRenderer,this.screenElement)),this.register((0,u.addDisposableDomListener)(this.element,"mousedown",(K=>this._selectionService.handleMouseDown(K)))),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(Y.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(K=>this._handleScreenReaderModeOptionChange(K)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(a.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(K=>{!this._overviewRulerRenderer&&K&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(a.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(Z){const re=N._mouseService.getMouseReportCoords(Z,N.screenElement);if(!re)return!1;let he,fe;switch(Z.overrideType||Z.type){case"mousemove":fe=32,Z.buttons===void 0?(he=3,Z.button!==void 0&&(he=Z.button<3?Z.button:3)):he=1&Z.buttons?0:4&Z.buttons?1:2&Z.buttons?2:3;break;case"mouseup":fe=0,he=Z.button<3?Z.button:3;break;case"mousedown":fe=1,he=Z.button<3?Z.button:3;break;case"wheel":if(N.viewport.getLinesScrolled(Z)===0)return!1;fe=Z.deltaY<0?0:1,he=4;break;default:return!1}return!(fe===void 0||he===void 0||he>4)&&N.coreMouseService.triggerMouseEvent({col:re.col,row:re.row,x:re.x,y:re.y,button:he,action:fe,ctrl:Z.ctrlKey,alt:Z.altKey,shift:Z.shiftKey})}const K={mouseup:null,wheel:null,mousedrag:null,mousemove:null},ie={mouseup:Z=>(X(Z),Z.buttons||(this._document.removeEventListener("mouseup",K.mouseup),K.mousedrag&&this._document.removeEventListener("mousemove",K.mousedrag)),this.cancel(Z)),wheel:Z=>(X(Z),this.cancel(Z,!0)),mousedrag:Z=>{Z.buttons&&X(Z)},mousemove:Z=>{Z.buttons||X(Z)}};this.register(this.coreMouseService.onProtocolChange((Z=>{Z?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(Z)),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&Z?K.mousemove||(W.addEventListener("mousemove",ie.mousemove),K.mousemove=ie.mousemove):(W.removeEventListener("mousemove",K.mousemove),K.mousemove=null),16&Z?K.wheel||(W.addEventListener("wheel",ie.wheel,{passive:!1}),K.wheel=ie.wheel):(W.removeEventListener("wheel",K.wheel),K.wheel=null),2&Z?K.mouseup||(W.addEventListener("mouseup",ie.mouseup),K.mouseup=ie.mouseup):(this._document.removeEventListener("mouseup",K.mouseup),W.removeEventListener("mouseup",K.mouseup),K.mouseup=null),4&Z?K.mousedrag||(K.mousedrag=ie.mousedrag):(this._document.removeEventListener("mousemove",K.mousedrag),K.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,u.addDisposableDomListener)(W,"mousedown",(Z=>{if(Z.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(Z))return X(Z),K.mouseup&&this._document.addEventListener("mouseup",K.mouseup),K.mousedrag&&this._document.addEventListener("mousemove",K.mousedrag),this.cancel(Z)}))),this.register((0,u.addDisposableDomListener)(W,"wheel",(Z=>{if(!K.wheel){if(!this.buffer.hasScrollback){const re=this.viewport.getLinesScrolled(Z);if(re===0)return;const he=H.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(Z.deltaY<0?"A":"B");let fe="";for(let Be=0;Be<Math.abs(re);Be++)fe+=he;return this.coreService.triggerDataEvent(fe,!0),this.cancel(Z,!0)}return this.viewport.handleWheel(Z)?this.cancel(Z):void 0}}),{passive:!1})),this.register((0,u.addDisposableDomListener)(W,"touchstart",(Z=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(Z),this.cancel(Z)}),{passive:!0})),this.register((0,u.addDisposableDomListener)(W,"touchmove",(Z=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(Z)?void 0:this.cancel(Z)}),{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 K;X===1?(super.scrollLines(N,W,X),this.refresh(0,this.rows-1)):(K=this.viewport)===null||K===void 0||K.scrollLines(N)}paste(N){(0,l.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,M.evaluateKeyboardEvent)(N,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(N),X.type===3||X.type===2){const K=this.rows-1;return this.scrollLines(X.type===2?-K:K),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!==H.C0.ETX&&X.key!==H.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,K;(X=this._charSizeService)===null||X===void 0||X.measure(),(K=this.viewport)===null||K===void 0||K.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(z.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(H.C0.ESC+"[I"):this.coreService.triggerDataEvent(H.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(`${H.C0.ESC}[4;${X};${W}t`);break;case $.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const K=this._renderService.dimensions.css.cell.width.toFixed(0),ie=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${H.C0.ESC}[6;${ie};${K}t`)}}cancel(N,W){if(this.options.cancelEvents||W)return N.preventDefault(),N.stopPropagation(),!1}}i.Terminal=V},9924:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.TimeBasedDebouncer=void 0,i.TimeBasedDebouncer=class{constructor(n,l=1e3){this._renderCallback=n,this._debounceThresholdMS=l,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(n,l,u){this._rowCount=u,n=n!==void 0?n:0,l=l!==void 0?l:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,n):n,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,l):l;const c=Date.now();if(c-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=c,this._innerRefresh();else if(!this._additionalRefreshRequested){const g=c-this._lastRefreshMs,_=this._debounceThresholdMS-g;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),_)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const n=Math.max(this._rowStart,0),l=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(n,l)}}},1680:function(v,i,n){var l=this&&this.__decorate||function(h,d,f,b){var w,k=arguments.length,j=k<3?d:b===null?b=Object.getOwnPropertyDescriptor(d,f):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(h,d,f,b);else for(var S=h.length-1;S>=0;S--)(w=h[S])&&(j=(k<3?w(j):k>3?w(d,f,j):w(d,f))||j);return k>3&&j&&Object.defineProperty(d,f,j),j},u=this&&this.__param||function(h,d){return function(f,b){d(f,b,h)}};Object.defineProperty(i,"__esModule",{value:!0}),i.Viewport=void 0;const c=n(3656),g=n(4725),_=n(8460),y=n(844),x=n(2585);let a=i.Viewport=class extends y.Disposable{constructor(h,d,f,b,w,k,j,S){super(),this._viewportElement=h,this._scrollArea=d,this._bufferService=f,this._optionsService=b,this._charSizeService=w,this._renderService=k,this._coreBrowserService=j,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 _.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((E=>this._activeBuffer=E.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((E=>this._renderDimensions=E))),this._handleThemeChange(S.colors),this.register(S.onChangeColors((E=>this._handleThemeChange(E)))),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 b,w="";const k=[],j=d??this._bufferService.buffer.lines.length,S=this._bufferService.buffer.lines;for(let E=h;E<j;E++){const R=S.get(E);if(!R)continue;const L=(f=S.get(E+1))===null||f===void 0?void 0:f.isWrapped;if(w+=R.translateToString(!L),!L||E===S.length-1){const T=document.createElement("div");T.textContent=w,k.push(T),w.length>0&&(b=T),w=""}}return{bufferElements:k,cursorElement:b}}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))}};i.Viewport=a=l([u(2,x.IBufferService),u(3,x.IOptionsService),u(4,g.ICharSizeService),u(5,g.IRenderService),u(6,g.ICoreBrowserService),u(7,g.IThemeService)],a)},3107:function(v,i,n){var l=this&&this.__decorate||function(a,h,d,f){var b,w=arguments.length,k=w<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,f);else for(var j=a.length-1;j>=0;j--)(b=a[j])&&(k=(w<3?b(k):w>3?b(h,d,k):b(h,d))||k);return w>3&&k&&Object.defineProperty(h,d,k),k},u=this&&this.__param||function(a,h){return function(d,f){h(d,f,a)}};Object.defineProperty(i,"__esModule",{value:!0}),i.BufferDecorationRenderer=void 0;const c=n(3656),g=n(4725),_=n(844),y=n(2585);let x=i.BufferDecorationRenderer=class extends _.Disposable{constructor(a,h,d,f){super(),this._screenElement=a,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((b=>this._removeDecoration(b)))),this.register((0,_.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 a of this._decorationService.decorations)this._renderDecoration(a);this._dimensionsChanged=!1}_renderDecoration(a){this._refreshStyle(a),this._dimensionsChanged&&this._refreshXPosition(a)}_createElement(a){var h,d;const f=document.createElement("div");f.classList.add("xterm-decoration"),f.classList.toggle("xterm-decoration-top-layer",((h=a?.options)===null||h===void 0?void 0:h.layer)==="top"),f.style.width=`${Math.round((a.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,f.style.height=(a.options.height||1)*this._renderService.dimensions.css.cell.height+"px",f.style.top=(a.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 b=(d=a.options.x)!==null&&d!==void 0?d:0;return b&&b>this._bufferService.cols&&(f.style.display="none"),this._refreshXPosition(a,f),f}_refreshStyle(a){const h=a.marker.line-this._bufferService.buffers.active.ydisp;if(h<0||h>=this._bufferService.rows)a.element&&(a.element.style.display="none",a.onRenderEmitter.fire(a.element));else{let d=this._decorationElements.get(a);d||(d=this._createElement(a),a.element=d,this._decorationElements.set(a,d),this._container.appendChild(d),a.onDispose((()=>{this._decorationElements.delete(a),d.remove()}))),d.style.top=h*this._renderService.dimensions.css.cell.height+"px",d.style.display=this._altBufferIsActive?"none":"block",a.onRenderEmitter.fire(d)}}_refreshXPosition(a,h=a.element){var d;if(!h)return;const f=(d=a.options.x)!==null&&d!==void 0?d:0;(a.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(a){var h;(h=this._decorationElements.get(a))===null||h===void 0||h.remove(),this._decorationElements.delete(a),a.dispose()}};i.BufferDecorationRenderer=x=l([u(1,y.IBufferService),u(2,y.IDecorationService),u(3,g.IRenderService)],x)},5871:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ColorZoneStore=void 0,i.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(n){if(n.options.overviewRulerOptions){for(const l of this._zones)if(l.color===n.options.overviewRulerOptions.color&&l.position===n.options.overviewRulerOptions.position){if(this._lineIntersectsZone(l,n.marker.line))return;if(this._lineAdjacentToZone(l,n.marker.line,n.options.overviewRulerOptions.position))return void this._addLineToZone(l,n.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=n.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=n.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=n.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=n.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:n.options.overviewRulerOptions.color,position:n.options.overviewRulerOptions.position,startBufferLine:n.marker.line,endBufferLine:n.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(n){this._linePadding=n}_lineIntersectsZone(n,l){return l>=n.startBufferLine&&l<=n.endBufferLine}_lineAdjacentToZone(n,l,u){return l>=n.startBufferLine-this._linePadding[u||"full"]&&l<=n.endBufferLine+this._linePadding[u||"full"]}_addLineToZone(n,l){n.startBufferLine=Math.min(n.startBufferLine,l),n.endBufferLine=Math.max(n.endBufferLine,l)}}},5744:function(v,i,n){var l=this&&this.__decorate||function(b,w,k,j){var S,E=arguments.length,R=E<3?w:j===null?j=Object.getOwnPropertyDescriptor(w,k):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(b,w,k,j);else for(var L=b.length-1;L>=0;L--)(S=b[L])&&(R=(E<3?S(R):E>3?S(w,k,R):S(w,k))||R);return E>3&&R&&Object.defineProperty(w,k,R),R},u=this&&this.__param||function(b,w){return function(k,j){w(k,j,b)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OverviewRulerRenderer=void 0;const c=n(5871),g=n(3656),_=n(4725),y=n(844),x=n(2585),a={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=i.OverviewRulerRenderer=class extends y.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(b,w,k,j,S,E,R){var L;super(),this._viewportElement=b,this._screenElement=w,this._bufferService=k,this._decorationService=j,this._renderService=S,this._optionsService=E,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,y.toDisposable)((()=>{var A;(A=this._canvas)===null||A===void 0||A.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 b=Math.floor(this._canvas.width/3),w=Math.ceil(this._canvas.width/3);h.full=this._canvas.width,h.left=b,h.center=w,h.right=b,this._refreshDrawHeightConstants(),d.full=0,d.left=0,d.center=h.left,d.right=h.left+h.center}_refreshDrawHeightConstants(){a.full=Math.round(2*this._coreBrowseService.dpr);const b=this._canvas.height/this._bufferService.buffer.lines.length,w=Math.round(Math.max(Math.min(b,12),6)*this._coreBrowseService.dpr);a.left=w,a.center=w,a.right=w}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.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 w of this._decorationService.decorations)this._colorZoneStore.addDecoration(w);this._ctx.lineWidth=1;const b=this._colorZoneStore.zones;for(const w of b)w.position!=="full"&&this._renderColorZone(w);for(const w of b)w.position==="full"&&this._renderColorZone(w);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(b){this._ctx.fillStyle=b.color,this._ctx.fillRect(d[b.position||"full"],Math.round((this._canvas.height-1)*(b.startBufferLine/this._bufferService.buffers.active.lines.length)-a[b.position||"full"]/2),h[b.position||"full"],Math.round((this._canvas.height-1)*((b.endBufferLine-b.startBufferLine)/this._bufferService.buffers.active.lines.length)+a[b.position||"full"]))}_queueRefresh(b,w){this._shouldUpdateDimensions=b||this._shouldUpdateDimensions,this._shouldUpdateAnchor=w||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowseService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};i.OverviewRulerRenderer=f=l([u(2,x.IBufferService),u(3,x.IDecorationService),u(4,_.IRenderService),u(5,x.IOptionsService),u(6,_.ICoreBrowserService)],f)},2950:function(v,i,n){var l=this&&this.__decorate||function(x,a,h,d){var f,b=arguments.length,w=b<3?a:d===null?d=Object.getOwnPropertyDescriptor(a,h):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(x,a,h,d);else for(var k=x.length-1;k>=0;k--)(f=x[k])&&(w=(b<3?f(w):b>3?f(a,h,w):f(a,h))||w);return b>3&&w&&Object.defineProperty(a,h,w),w},u=this&&this.__param||function(x,a){return function(h,d){a(h,d,x)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CompositionHelper=void 0;const c=n(4725),g=n(2585),_=n(2584);let y=i.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(x,a,h,d,f,b){this._textarea=x,this._compositionView=a,this._bufferService=h,this._optionsService=d,this._coreService=f,this._renderService=b,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(x){this._compositionView.textContent=x.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(x){if(this._isComposing||this._isSendingComposition){if(x.keyCode===229||x.keyCode===16||x.keyCode===17||x.keyCode===18)return!1;this._finalizeComposition(!1)}return x.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(x){if(this._compositionView.classList.remove("active"),this._isComposing=!1,x){const a={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let h;this._isSendingComposition=!1,a.start+=this._dataAlreadySent.length,h=this._isComposing?this._textarea.value.substring(a.start,a.end):this._textarea.value.substring(a.start),h.length>0&&this._coreService.triggerDataEvent(h,!0)}}),0)}else{this._isSendingComposition=!1;const a=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(a,!0)}}_handleAnyTextareaChanges(){const x=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const a=this._textarea.value,h=a.replace(x,"");this._dataAlreadySent=h,a.length>x.length?this._coreService.triggerDataEvent(h,!0):a.length<x.length?this._coreService.triggerDataEvent(`${_.C0.DEL}`,!0):a.length===x.length&&a!==x&&this._coreService.triggerDataEvent(a,!0)}}),0)}updateCompositionElements(x){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const a=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=a*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 b=this._compositionView.getBoundingClientRect();this._textarea.style.left=f+"px",this._textarea.style.top=d+"px",this._textarea.style.width=Math.max(b.width,1)+"px",this._textarea.style.height=Math.max(b.height,1)+"px",this._textarea.style.lineHeight=b.height+"px"}x||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};i.CompositionHelper=y=l([u(2,g.IBufferService),u(3,g.IOptionsService),u(4,g.ICoreService),u(5,c.IRenderService)],y)},9806:(v,i)=>{function n(l,u,c){const g=c.getBoundingClientRect(),_=l.getComputedStyle(c),y=parseInt(_.getPropertyValue("padding-left")),x=parseInt(_.getPropertyValue("padding-top"));return[u.clientX-g.left-y,u.clientY-g.top-x]}Object.defineProperty(i,"__esModule",{value:!0}),i.getCoords=i.getCoordsRelativeToElement=void 0,i.getCoordsRelativeToElement=n,i.getCoords=function(l,u,c,g,_,y,x,a,h){if(!y)return;const d=n(l,u,c);return d?(d[0]=Math.ceil((d[0]+(h?x/2:0))/x),d[1]=Math.ceil(d[1]/a),d[0]=Math.min(Math.max(d[0],1),g+(h?1:0)),d[1]=Math.min(Math.max(d[1],1),_),d):void 0}},9504:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.moveToCellSequence=void 0;const l=n(2584);function u(a,h,d,f){const b=a-c(a,d),w=h-c(h,d),k=Math.abs(b-w)-(function(j,S,E){let R=0;const L=j-c(j,E),T=S-c(S,E);for(let A=0;A<Math.abs(L-T);A++){const B=g(j,S)==="A"?-1:1,D=E.buffer.lines.get(L+B*A);D?.isWrapped&&R++}return R})(a,h,d);return x(k,y(g(a,h),f))}function c(a,h){let d=0,f=h.buffer.lines.get(a),b=f?.isWrapped;for(;b&&a>=0&&a<h.rows;)d++,f=h.buffer.lines.get(--a),b=f?.isWrapped;return d}function g(a,h){return a>h?"A":"B"}function _(a,h,d,f,b,w){let k=a,j=h,S="";for(;k!==d||j!==f;)k+=b?1:-1,b&&k>w.cols-1?(S+=w.buffer.translateBufferLineToString(j,!1,a,k),k=0,a=0,j++):!b&&k<0&&(S+=w.buffer.translateBufferLineToString(j,!1,0,a+1),k=w.cols-1,a=k,j--);return S+w.buffer.translateBufferLineToString(j,!1,a,k)}function y(a,h){const d=h?"O":"[";return l.C0.ESC+d+a}function x(a,h){a=Math.floor(a);let d="";for(let f=0;f<a;f++)d+=h;return d}i.moveToCellSequence=function(a,h,d,f){const b=d.buffer.x,w=d.buffer.y;if(!d.buffer.hasScrollback)return(function(S,E,R,L,T,A){return u(E,L,T,A).length===0?"":x(_(S,E,S,E-c(E,T),!1,T).length,y("D",A))})(b,w,0,h,d,f)+u(w,h,d,f)+(function(S,E,R,L,T,A){let B;B=u(E,L,T,A).length>0?L-c(L,T):E;const D=L,z=(function(H,M,O,P,I,$){let Y;return Y=u(O,P,I,$).length>0?P-c(P,I):M,H<O&&Y<=P||H>=O&&Y<P?"C":"D"})(S,E,R,L,T,A);return x(_(S,B,R,D,z==="C",T).length,y(z,A))})(b,w,a,h,d,f);let k;if(w===h)return k=b>a?"D":"C",x(Math.abs(b-a),y(k,f));k=w>h?"D":"C";const j=Math.abs(w-h);return x((function(S,E){return E.cols-S})(w>h?a:b,d)+(j-1)*d.cols+1+((w>h?b:a)-1),y(k,f))}},1296:function(v,i,n){var l=this&&this.__decorate||function(T,A,B,D){var z,H=arguments.length,M=H<3?A:D===null?D=Object.getOwnPropertyDescriptor(A,B):D;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")M=Reflect.decorate(T,A,B,D);else for(var O=T.length-1;O>=0;O--)(z=T[O])&&(M=(H<3?z(M):H>3?z(A,B,M):z(A,B))||M);return H>3&&M&&Object.defineProperty(A,B,M),M},u=this&&this.__param||function(T,A){return function(B,D){A(B,D,T)}};Object.defineProperty(i,"__esModule",{value:!0}),i.DomRenderer=void 0;const c=n(3787),g=n(2550),_=n(2223),y=n(6171),x=n(4725),a=n(8055),h=n(8460),d=n(844),f=n(2585),b="xterm-dom-renderer-owner-",w="xterm-rows",k="xterm-fg-",j="xterm-bg-",S="xterm-focus",E="xterm-selection";let R=1,L=i.DomRenderer=class extends d.Disposable{constructor(T,A,B,D,z,H,M,O,P,I){super(),this._element=T,this._screenElement=A,this._viewportElement=B,this._linkifier2=D,this._charSizeService=H,this._optionsService=M,this._bufferService=O,this._coreBrowserService=P,this._themeService=I,this._terminalClass=R++,this._rowElements=[],this.onRequestRedraw=this.register(new h.EventEmitter).event,this._rowContainer=document.createElement("div"),this._rowContainer.classList.add(w),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(E),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,y.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors(($=>this._injectCss($)))),this._injectCss(this._themeService.colors),this._rowFactory=z.createInstance(c.DomRendererRowFactory,document),this._element.classList.add(b+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(b+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 B of this._rowElements)B.style.width=`${this.dimensions.css.canvas.width}px`,B.style.height=`${this.dimensions.css.cell.height}px`,B.style.lineHeight=`${this.dimensions.css.cell.height}px`,B.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const A=`${this._terminalSelector} .${w} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=A,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 A=`${this._terminalSelector} .${w} { color: ${T.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;A+=`${this._terminalSelector} .${w} .xterm-dim { color: ${a.color.multiplyOpacity(T.foreground,.5).css};}`,A+=`${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;}`,A+="@keyframes blink_box_shadow_"+this._terminalClass+" { 50% { border-bottom-style: hidden; }}",A+="@keyframes blink_block_"+this._terminalClass+` { 0% { background-color: ${T.cursor.css}; color: ${T.cursorAccent.css}; } 50% { background-color: inherit; color: ${T.cursor.css}; }}`,A+=`${this._terminalSelector} .${w}.${S} .xterm-cursor.xterm-cursor-blink:not(.xterm-cursor-block) { animation: blink_box_shadow_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${w}.${S} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: blink_block_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${w} .xterm-cursor.xterm-cursor-block { background-color: ${T.cursor.css}; color: ${T.cursorAccent.css};}${this._terminalSelector} .${w} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${T.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${w} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${T.cursor.css} inset;}${this._terminalSelector} .${w} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${T.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,A+=`${this._terminalSelector} .${E} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${E} div { position: absolute; background-color: ${T.selectionBackgroundOpaque.css};}${this._terminalSelector} .${E} div { position: absolute; background-color: ${T.selectionInactiveBackgroundOpaque.css};}`;for(const[B,D]of T.ansi.entries())A+=`${this._terminalSelector} .${k}${B} { color: ${D.css}; }${this._terminalSelector} .${k}${B}.xterm-dim { color: ${a.color.multiplyOpacity(D,.5).css}; }${this._terminalSelector} .${j}${B} { background-color: ${D.css}; }`;A+=`${this._terminalSelector} .${k}${_.INVERTED_DEFAULT_COLOR} { color: ${a.color.opaque(T.background).css}; }${this._terminalSelector} .${k}${_.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${a.color.multiplyOpacity(a.color.opaque(T.background),.5).css}; }${this._terminalSelector} .${j}${_.INVERTED_DEFAULT_COLOR} { background-color: ${T.foreground.css}; }`,this._themeStyleElement.textContent=A}_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,A){for(let B=this._rowElements.length;B<=A;B++){const D=document.createElement("div");this._rowContainer.appendChild(D),this._rowElements.push(D)}for(;this._rowElements.length>A;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(T,A){this._refreshRowElements(T,A),this._updateDimensions()}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(S)}handleFocus(){this._rowContainer.classList.add(S),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(T,A,B){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(T,A,B),this.renderRows(0,this._bufferService.rows-1),!T||!A)return;const D=T[1]-this._bufferService.buffer.ydisp,z=A[1]-this._bufferService.buffer.ydisp,H=Math.max(D,0),M=Math.min(z,this._bufferService.rows-1);if(H>=this._bufferService.rows||M<0)return;const O=document.createDocumentFragment();if(B){const P=T[0]>A[0];O.appendChild(this._createSelectionElement(H,P?A[0]:T[0],P?T[0]:A[0],M-H+1))}else{const P=D===H?T[0]:0,I=H===z?A[0]:this._bufferService.cols;O.appendChild(this._createSelectionElement(H,P,I));const $=M-H-1;if(O.appendChild(this._createSelectionElement(H+1,0,this._bufferService.cols,$)),H!==M){const Y=z===M?A[0]:this._bufferService.cols;O.appendChild(this._createSelectionElement(M,0,Y))}}this._selectionContainer.appendChild(O)}_createSelectionElement(T,A,B,D=1){const z=document.createElement("div");return z.style.height=D*this.dimensions.css.cell.height+"px",z.style.top=T*this.dimensions.css.cell.height+"px",z.style.left=A*this.dimensions.css.cell.width+"px",z.style.width=this.dimensions.css.cell.width*(B-A)+"px",z}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,A){const B=this._bufferService.buffer,D=B.ybase+B.y,z=Math.min(B.x,this._bufferService.cols-1),H=this._optionsService.rawOptions.cursorBlink,M=this._optionsService.rawOptions.cursorStyle,O=this._optionsService.rawOptions.cursorInactiveStyle;for(let P=T;P<=A;P++){const I=P+B.ydisp,$=this._rowElements[P],Y=B.lines.get(I);if(!$||!Y)break;$.replaceChildren(...this._rowFactory.createRow(Y,I,I===D,M,O,z,H,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${b}${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,A,B,D,z,H){B<0&&(T=0),D<0&&(A=0);const M=this._bufferService.rows-1;B=Math.max(Math.min(B,M),0),D=Math.max(Math.min(D,M),0),z=Math.min(z,this._bufferService.cols);const O=this._bufferService.buffer,P=O.ybase+O.y,I=Math.min(O.x,z-1),$=this._optionsService.rawOptions.cursorBlink,Y=this._optionsService.rawOptions.cursorStyle,q=this._optionsService.rawOptions.cursorInactiveStyle;for(let V=B;V<=D;++V){const F=V+O.ydisp,N=this._rowElements[V],W=O.lines.get(F);if(!N||!W)break;N.replaceChildren(...this._rowFactory.createRow(W,F,F===P,Y,q,I,$,this.dimensions.css.cell.width,this._widthCache,H?V===B?T:0:-1,H?(V===D?A:z)-1:-1))}}};i.DomRenderer=L=l([u(4,f.IInstantiationService),u(5,x.ICharSizeService),u(6,f.IOptionsService),u(7,f.IBufferService),u(8,x.ICoreBrowserService),u(9,x.IThemeService)],L)},3787:function(v,i,n){var l=this&&this.__decorate||function(k,j,S,E){var R,L=arguments.length,T=L<3?j:E===null?E=Object.getOwnPropertyDescriptor(j,S):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(k,j,S,E);else for(var A=k.length-1;A>=0;A--)(R=k[A])&&(T=(L<3?R(T):L>3?R(j,S,T):R(j,S))||T);return L>3&&T&&Object.defineProperty(j,S,T),T},u=this&&this.__param||function(k,j){return function(S,E){j(S,E,k)}};Object.defineProperty(i,"__esModule",{value:!0}),i.DomRendererRowFactory=void 0;const c=n(2223),g=n(643),_=n(511),y=n(2585),x=n(8055),a=n(4725),h=n(4269),d=n(6171),f=n(3734);let b=i.DomRendererRowFactory=class{constructor(k,j,S,E,R,L,T){this._document=k,this._characterJoinerService=j,this._optionsService=S,this._coreBrowserService=E,this._coreService=R,this._decorationService=L,this._themeService=T,this._workCell=new _.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(k,j,S){this._selectionStart=k,this._selectionEnd=j,this._columnSelectMode=S}createRow(k,j,S,E,R,L,T,A,B,D,z){const H=[],M=this._characterJoinerService.getJoinedCharacters(j),O=this._themeService.colors;let P,I=k.getNoBgTrimmedLength();S&&I<L+1&&(I=L+1);let $=0,Y="",q=0,V=0,F=0,N=!1,W=0,X=!1,K=0;const ie=[],Z=D!==-1&&z!==-1;for(let re=0;re<I;re++){k.loadCell(re,this._workCell);let he=this._workCell.getWidth();if(he===0)continue;let fe=!1,Be=re,le=this._workCell;if(M.length>0&&re===M[0][0]){fe=!0;const ue=M.shift();le=new h.JoinedCellData(this._workCell,k.translateToString(!0,ue[0],ue[1]),ue[1]-ue[0]),Be=ue[1]-1,he=le.getWidth()}const Ge=this._isCellInSelection(re,j),we=S&&re===L,qe=Z&&re>=D&&re<=z;let Fe=!1;this._decorationService.forEachDecorationAtCell(re,j,void 0,(ue=>{Fe=!0}));let De=le.getChars()||g.WHITESPACE_CELL_CHAR;if(De===" "&&(le.isUnderline()||le.isOverline())&&(De=" "),K=he*A-B.get(De,le.isBold(),le.isItalic()),P){if($&&(Ge&&X||!Ge&&!X&&le.bg===q)&&(Ge&&X&&O.selectionForeground||le.fg===V)&&le.extended.ext===F&&qe===N&&K===W&&!we&&!fe&&!Fe){Y+=De,$++;continue}$&&(P.textContent=Y),P=this._document.createElement("span"),$=0,Y=""}else P=this._document.createElement("span");if(q=le.bg,V=le.fg,F=le.extended.ext,N=qe,W=K,X=Ge,fe&&L>=re&&L<=Be&&(L=re),!this._coreService.isCursorHidden&&we){if(ie.push("xterm-cursor"),this._coreBrowserService.isFocused)T&&ie.push("xterm-cursor-blink"),ie.push(E==="bar"?"xterm-cursor-bar":E==="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(le.isBold()&&ie.push("xterm-bold"),le.isItalic()&&ie.push("xterm-italic"),le.isDim()&&ie.push("xterm-dim"),Y=le.isInvisible()?g.WHITESPACE_CELL_CHAR:le.getChars()||g.WHITESPACE_CELL_CHAR,le.isUnderline()&&(ie.push(`xterm-underline-${le.extended.underlineStyle}`),Y===" "&&(Y=" "),!le.isUnderlineColorDefault()))if(le.isUnderlineColorRGB())P.style.textDecorationColor=`rgb(${f.AttributeData.toColorRGB(le.getUnderlineColor()).join(",")})`;else{let ue=le.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&le.isBold()&&ue<8&&(ue+=8),P.style.textDecorationColor=O.ansi[ue].css}le.isOverline()&&(ie.push("xterm-overline"),Y===" "&&(Y=" ")),le.isStrikethrough()&&ie.push("xterm-strikethrough"),qe&&(P.style.textDecoration="underline");let ze=le.getFgColor(),Ae=le.getFgColorMode(),Ke=le.getBgColor(),Ee=le.getBgColorMode();const Ce=!!le.isInverse();if(Ce){const ue=ze;ze=Ke,Ke=ue;const dt=Ae;Ae=Ee,Ee=dt}let ke,st,je,We=!1;switch(this._decorationService.forEachDecorationAtCell(re,j,void 0,(ue=>{ue.options.layer!=="top"&&We||(ue.backgroundColorRGB&&(Ee=50331648,Ke=ue.backgroundColorRGB.rgba>>8&16777215,ke=ue.backgroundColorRGB),ue.foregroundColorRGB&&(Ae=50331648,ze=ue.foregroundColorRGB.rgba>>8&16777215,st=ue.foregroundColorRGB),We=ue.options.layer==="top")})),!We&&Ge&&(ke=this._coreBrowserService.isFocused?O.selectionBackgroundOpaque:O.selectionInactiveBackgroundOpaque,Ke=ke.rgba>>8&16777215,Ee=50331648,We=!0,O.selectionForeground&&(Ae=50331648,ze=O.selectionForeground.rgba>>8&16777215,st=O.selectionForeground)),We&&ie.push("xterm-decoration-top"),Ee){case 16777216:case 33554432:je=O.ansi[Ke],ie.push(`xterm-bg-${Ke}`);break;case 50331648:je=x.rgba.toColor(Ke>>16,Ke>>8&255,255&Ke),this._addStyle(P,`background-color:#${w((Ke>>>0).toString(16),"0",6)}`);break;default:Ce?(je=O.foreground,ie.push(`xterm-bg-${c.INVERTED_DEFAULT_COLOR}`)):je=O.background}switch(ke||le.isDim()&&(ke=x.color.multiplyOpacity(je,.5)),Ae){case 16777216:case 33554432:le.isBold()&&ze<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ze+=8),this._applyMinimumContrast(P,je,O.ansi[ze],le,ke,void 0)||ie.push(`xterm-fg-${ze}`);break;case 50331648:const ue=x.rgba.toColor(ze>>16&255,ze>>8&255,255&ze);this._applyMinimumContrast(P,je,ue,le,ke,st)||this._addStyle(P,`color:#${w(ze.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(P,je,O.foreground,le,ke,void 0)||Ce&&ie.push(`xterm-fg-${c.INVERTED_DEFAULT_COLOR}`)}ie.length&&(P.className=ie.join(" "),ie.length=0),we||fe||Fe?P.textContent=Y:$++,K!==this.defaultSpacing&&(P.style.letterSpacing=`${K}px`),H.push(P),re=Be}return P&&$&&(P.textContent=Y),H}_applyMinimumContrast(k,j,S,E,R,L){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,d.excludeFromContrastRatioDemands)(E.getCode()))return!1;const T=this._getContrastCache(E);let A;if(R||L||(A=T.getColor(j.rgba,S.rgba)),A===void 0){const B=this._optionsService.rawOptions.minimumContrastRatio/(E.isDim()?2:1);A=x.color.ensureContrastRatio(R||j,L||S,B),T.setColor((R||j).rgba,(L||S).rgba,A??null)}return!!A&&(this._addStyle(k,`color:${A.css}`),!0)}_getContrastCache(k){return k.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(k,j){k.setAttribute("style",`${k.getAttribute("style")||""}${j};`)}_isCellInSelection(k,j){const S=this._selectionStart,E=this._selectionEnd;return!(!S||!E)&&(this._columnSelectMode?S[0]<=E[0]?k>=S[0]&&j>=S[1]&&k<E[0]&&j<=E[1]:k<S[0]&&j>=S[1]&&k>=E[0]&&j<=E[1]:j>S[1]&&j<E[1]||S[1]===E[1]&&j===S[1]&&k>=S[0]&&k<E[0]||S[1]<E[1]&&j===E[1]&&k<E[0]||S[1]<E[1]&&j===S[1]&&k>=S[0])}};function w(k,j,S){for(;k.length<S;)k=j+k;return k}i.DomRendererRowFactory=b=l([u(1,a.ICharacterJoinerService),u(2,y.IOptionsService),u(3,a.ICoreBrowserService),u(4,y.ICoreService),u(5,y.IDecorationService),u(6,a.IThemeService)],b)},2550:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WidthCache=void 0,i.WidthCache=class{constructor(n){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=n.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 l=n.createElement("span"),u=n.createElement("span");u.style.fontWeight="bold";const c=n.createElement("span");c.style.fontStyle="italic";const g=n.createElement("span");g.style.fontWeight="bold",g.style.fontStyle="italic",this._measureElements=[l,u,c,g],this._container.appendChild(l),this._container.appendChild(u),this._container.appendChild(c),this._container.appendChild(g),n.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(n,l,u,c){n===this._font&&l===this._fontSize&&u===this._weight&&c===this._weightBold||(this._font=n,this._fontSize=l,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(n,l,u){let c=0;if(!l&&!u&&n.length===1&&(c=n.charCodeAt(0))<256)return this._flat[c]!==-9999?this._flat[c]:this._flat[c]=this._measure(n,0);let g=n;l&&(g+="B"),u&&(g+="I");let _=this._holey.get(g);if(_===void 0){let y=0;l&&(y|=1),u&&(y|=2),_=this._measure(n,y),this._holey.set(g,_)}return _}_measure(n,l){const u=this._measureElements[l];return u.textContent=n.repeat(32),u.offsetWidth/32}}},2223:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.TEXT_BASELINE=i.DIM_OPACITY=i.INVERTED_DEFAULT_COLOR=void 0;const l=n(6114);i.INVERTED_DEFAULT_COLOR=257,i.DIM_OPACITY=.5,i.TEXT_BASELINE=l.isFirefox||l.isLegacyEdge?"bottom":"ideographic"},6171:(v,i)=>{function n(l){return 57508<=l&&l<=57558}Object.defineProperty(i,"__esModule",{value:!0}),i.createRenderDimensions=i.excludeFromContrastRatioDemands=i.isRestrictedPowerlineGlyph=i.isPowerlineGlyph=i.throwIfFalsy=void 0,i.throwIfFalsy=function(l){if(!l)throw new Error("value must not be falsy");return l},i.isPowerlineGlyph=n,i.isRestrictedPowerlineGlyph=function(l){return 57520<=l&&l<=57527},i.excludeFromContrastRatioDemands=function(l){return n(l)||(function(u){return 9472<=u&&u<=9631})(l)},i.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,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.SelectionModel=void 0,i.SelectionModel=class{constructor(n){this._bufferService=n,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 n=this.selectionStart[0]+this.selectionStartLength;return n>this._bufferService.cols?n%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(n/this._bufferService.cols)-1]:[n%this._bufferService.cols,this.selectionStart[1]+Math.floor(n/this._bufferService.cols)]:[n,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const n=this.selectionStart[0]+this.selectionStartLength;return n>this._bufferService.cols?[n%this._bufferService.cols,this.selectionStart[1]+Math.floor(n/this._bufferService.cols)]:[Math.max(n,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const n=this.selectionStart,l=this.selectionEnd;return!(!n||!l)&&(n[1]>l[1]||n[1]===l[1]&&n[0]>l[0])}handleTrim(n){return this.selectionStart&&(this.selectionStart[1]-=n),this.selectionEnd&&(this.selectionEnd[1]-=n),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(v,i,n){var l=this&&this.__decorate||function(a,h,d,f){var b,w=arguments.length,k=w<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,f);else for(var j=a.length-1;j>=0;j--)(b=a[j])&&(k=(w<3?b(k):w>3?b(h,d,k):b(h,d))||k);return w>3&&k&&Object.defineProperty(h,d,k),k},u=this&&this.__param||function(a,h){return function(d,f){h(d,f,a)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CharSizeService=void 0;const c=n(2585),g=n(8460),_=n(844);let y=i.CharSizeService=class extends _.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(a,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 x(a,h,this._optionsService),this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const a=this._measureStrategy.measure();a.width===this.width&&a.height===this.height||(this.width=a.width,this.height=a.height,this._onCharSizeChange.fire())}};i.CharSizeService=y=l([u(2,c.IOptionsService)],y);class x{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,i,n){var l=this&&this.__decorate||function(h,d,f,b){var w,k=arguments.length,j=k<3?d:b===null?b=Object.getOwnPropertyDescriptor(d,f):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(h,d,f,b);else for(var S=h.length-1;S>=0;S--)(w=h[S])&&(j=(k<3?w(j):k>3?w(d,f,j):w(d,f))||j);return k>3&&j&&Object.defineProperty(d,f,j),j},u=this&&this.__param||function(h,d){return function(f,b){d(f,b,h)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CharacterJoinerService=i.JoinedCellData=void 0;const c=n(3734),g=n(643),_=n(511),y=n(2585);class x extends c.AttributeData{constructor(d,f,b){super(),this.content=0,this.combinedData="",this.fg=d.fg,this.bg=d.bg,this.combinedData=f,this._width=b}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()]}}i.JoinedCellData=x;let a=i.CharacterJoinerService=class Sl{constructor(d){this._bufferService=d,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new _.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 b=[],w=f.translateToString(!0);let k=0,j=0,S=0,E=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!==E||this._workCell.bg!==R){if(L-k>1){const T=this._getJoinedRanges(w,S,j,f,k);for(let A=0;A<T.length;A++)b.push(T[A])}k=L,S=j,E=this._workCell.fg,R=this._workCell.bg}j+=this._workCell.getChars().length||g.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-k>1){const L=this._getJoinedRanges(w,S,j,f,k);for(let T=0;T<L.length;T++)b.push(L[T])}return b}_getJoinedRanges(d,f,b,w,k){const j=d.substring(f,b);let S=[];try{S=this._characterJoiners[0].handler(j)}catch(E){console.error(E)}for(let E=1;E<this._characterJoiners.length;E++)try{const R=this._characterJoiners[E].handler(j);for(let L=0;L<R.length;L++)Sl._mergeRanges(S,R[L])}catch(R){console.error(R)}return this._stringRangesToCellRanges(S,w,k),S}_stringRangesToCellRanges(d,f,b){let w=0,k=!1,j=0,S=d[w];if(S){for(let E=b;E<this._bufferService.cols;E++){const R=f.getWidth(E),L=f.getString(E).length||g.WHITESPACE_CELL_CHAR.length;if(R!==0){if(!k&&S[0]<=j&&(S[0]=E,k=!0),S[1]<=j){if(S[1]=E,S=d[++w],!S)break;S[0]<=j?(S[0]=E,k=!0):k=!1}j+=L}}S&&(S[1]=this._bufferService.cols)}}static _mergeRanges(d,f){let b=!1;for(let w=0;w<d.length;w++){const k=d[w];if(b){if(f[1]<=k[0])return d[w-1][1]=f[1],d;if(f[1]<=k[1])return d[w-1][1]=Math.max(f[1],k[1]),d.splice(w,1),d;d.splice(w,1),w--}else{if(f[1]<=k[0])return d.splice(w,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]),b=!0)}}return b?d[d.length-1][1]=f[1]:d.push(f),d}};i.CharacterJoinerService=a=l([u(0,y.IBufferService)],a)},5114:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CoreBrowserService=void 0,i.CoreBrowserService=class{constructor(n,l){this._textarea=n,this.window=l,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,i,n){var l=this&&this.__decorate||function(y,x,a,h){var d,f=arguments.length,b=f<3?x:h===null?h=Object.getOwnPropertyDescriptor(x,a):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(y,x,a,h);else for(var w=y.length-1;w>=0;w--)(d=y[w])&&(b=(f<3?d(b):f>3?d(x,a,b):d(x,a))||b);return f>3&&b&&Object.defineProperty(x,a,b),b},u=this&&this.__param||function(y,x){return function(a,h){x(a,h,y)}};Object.defineProperty(i,"__esModule",{value:!0}),i.MouseService=void 0;const c=n(4725),g=n(9806);let _=i.MouseService=class{constructor(y,x){this._renderService=y,this._charSizeService=x}getCoords(y,x,a,h,d){return(0,g.getCoords)(window,y,x,a,h,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,d)}getMouseReportCoords(y,x){const a=(0,g.getCoordsRelativeToElement)(window,y,x);if(this._charSizeService.hasValidSize)return a[0]=Math.min(Math.max(a[0],0),this._renderService.dimensions.css.canvas.width-1),a[1]=Math.min(Math.max(a[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(a[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(a[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(a[0]),y:Math.floor(a[1])}}};i.MouseService=_=l([u(0,c.IRenderService),u(1,c.ICharSizeService)],_)},3230:function(v,i,n){var l=this&&this.__decorate||function(b,w,k,j){var S,E=arguments.length,R=E<3?w:j===null?j=Object.getOwnPropertyDescriptor(w,k):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(b,w,k,j);else for(var L=b.length-1;L>=0;L--)(S=b[L])&&(R=(E<3?S(R):E>3?S(w,k,R):S(w,k))||R);return E>3&&R&&Object.defineProperty(w,k,R),R},u=this&&this.__param||function(b,w){return function(k,j){w(k,j,b)}};Object.defineProperty(i,"__esModule",{value:!0}),i.RenderService=void 0;const c=n(3656),g=n(6193),_=n(5596),y=n(4725),x=n(8460),a=n(844),h=n(7226),d=n(2585);let f=i.RenderService=class extends a.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(b,w,k,j,S,E,R,L){if(super(),this._rowCount=b,this._charSizeService=j,this._renderer=this.register(new a.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 x.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new x.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new x.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new x.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new g.RenderDebouncer(R.window,((T,A)=>this._renderRows(T,A))),this.register(this._renderDebouncer),this._screenDprMonitor=new _.ScreenDprMonitor(R.window),this._screenDprMonitor.setListener((()=>this.handleDevicePixelRatioChange())),this.register(this._screenDprMonitor),this.register(E.onResize((()=>this._fullRefresh()))),this.register(E.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(S.onDecorationRegistered((()=>this._fullRefresh()))),this.register(S.onDecorationRemoved((()=>this._fullRefresh()))),this.register(k.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio"],(()=>{this.clear(),this.handleResize(E.cols,E.rows),this._fullRefresh()}))),this.register(k.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(E.buffer.y,E.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((A=>this._handleIntersectionChange(A[A.length-1])),{threshold:0});T.observe(w),this.register({dispose:()=>T.disconnect()})}}_handleIntersectionChange(b){this._isPaused=b.isIntersecting===void 0?b.intersectionRatio===0:!b.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(b,w,k=!1){this._isPaused?this._needsFullRefresh=!0:(k||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(b,w,this._rowCount))}_renderRows(b,w){this._renderer.value&&(b=Math.min(b,this._rowCount-1),w=Math.min(w,this._rowCount-1),this._renderer.value.renderRows(b,w),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:b,end:w}),this._onRender.fire({start:b,end:w}),this._isNextRenderRedrawOnly=!0)}resize(b,w){this._rowCount=w,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(b){this._renderer.value=b,this._renderer.value.onRequestRedraw((w=>this.refreshRows(w.start,w.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh()}addRefreshCallback(b){return this._renderDebouncer.addRefreshCallback(b)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var b,w;this._renderer.value&&((w=(b=this._renderer.value).clearTextureAtlas)===null||w===void 0||w.call(b),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(b,w){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value.handleResize(b,w))):this._renderer.value.handleResize(b,w),this._fullRefresh())}handleCharSizeChanged(){var b;(b=this._renderer.value)===null||b===void 0||b.handleCharSizeChanged()}handleBlur(){var b;(b=this._renderer.value)===null||b===void 0||b.handleBlur()}handleFocus(){var b;(b=this._renderer.value)===null||b===void 0||b.handleFocus()}handleSelectionChanged(b,w,k){var j;this._selectionState.start=b,this._selectionState.end=w,this._selectionState.columnSelectMode=k,(j=this._renderer.value)===null||j===void 0||j.handleSelectionChanged(b,w,k)}handleCursorMove(){var b;(b=this._renderer.value)===null||b===void 0||b.handleCursorMove()}clear(){var b;(b=this._renderer.value)===null||b===void 0||b.clear()}};i.RenderService=f=l([u(2,d.IOptionsService),u(3,y.ICharSizeService),u(4,d.IDecorationService),u(5,d.IBufferService),u(6,y.ICoreBrowserService),u(7,y.IThemeService)],f)},9312:function(v,i,n){var l=this&&this.__decorate||function(S,E,R,L){var T,A=arguments.length,B=A<3?E:L===null?L=Object.getOwnPropertyDescriptor(E,R):L;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")B=Reflect.decorate(S,E,R,L);else for(var D=S.length-1;D>=0;D--)(T=S[D])&&(B=(A<3?T(B):A>3?T(E,R,B):T(E,R))||B);return A>3&&B&&Object.defineProperty(E,R,B),B},u=this&&this.__param||function(S,E){return function(R,L){E(R,L,S)}};Object.defineProperty(i,"__esModule",{value:!0}),i.SelectionService=void 0;const c=n(9806),g=n(9504),_=n(456),y=n(4725),x=n(8460),a=n(844),h=n(6114),d=n(4841),f=n(511),b=n(2585),w=" ",k=new RegExp(w,"g");let j=i.SelectionService=class extends a.Disposable{constructor(S,E,R,L,T,A,B,D,z){super(),this._element=S,this._screenElement=E,this._linkifier=R,this._bufferService=L,this._coreService=T,this._mouseService=A,this._optionsService=B,this._renderService=D,this._coreBrowserService=z,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 x.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new x.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new x.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new x.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=H=>this._handleMouseMove(H),this._mouseUpListener=H=>this._handleMouseUp(H),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((H=>this._handleTrim(H))),this.register(this._bufferService.buffers.onBufferActivate((H=>this._handleBufferActivate(H)))),this.enable(),this._model=new _.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,a.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 S=this._model.finalSelectionStart,E=this._model.finalSelectionEnd;return!(!S||!E||S[0]===E[0]&&S[1]===E[1])}get selectionText(){const S=this._model.finalSelectionStart,E=this._model.finalSelectionEnd;if(!S||!E)return"";const R=this._bufferService.buffer,L=[];if(this._activeSelectionMode===3){if(S[0]===E[0])return"";const T=S[0]<E[0]?S[0]:E[0],A=S[0]<E[0]?E[0]:S[0];for(let B=S[1];B<=E[1];B++){const D=R.translateBufferLineToString(B,!0,T,A);L.push(D)}}else{const T=S[1]===E[1]?E[0]:void 0;L.push(R.translateBufferLineToString(S[1],!0,S[0],T));for(let A=S[1]+1;A<=E[1]-1;A++){const B=R.lines.get(A),D=R.translateBufferLineToString(A,!0);B?.isWrapped?L[L.length-1]+=D:L.push(D)}if(S[1]!==E[1]){const A=R.lines.get(E[1]),B=R.translateBufferLineToString(E[1],!0,0,E[0]);A&&A.isWrapped?L[L.length-1]+=B:L.push(B)}}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(S){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),h.isLinux&&S&&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(S){const E=this._getMouseBufferCoords(S),R=this._model.finalSelectionStart,L=this._model.finalSelectionEnd;return!!(R&&L&&E)&&this._areCoordsInSelection(E,R,L)}isCellInSelection(S,E){const R=this._model.finalSelectionStart,L=this._model.finalSelectionEnd;return!(!R||!L)&&this._areCoordsInSelection([S,E],R,L)}_areCoordsInSelection(S,E,R){return S[1]>E[1]&&S[1]<R[1]||E[1]===R[1]&&S[1]===E[1]&&S[0]>=E[0]&&S[0]<R[0]||E[1]<R[1]&&S[1]===R[1]&&S[0]<R[0]||E[1]<R[1]&&S[1]===E[1]&&S[0]>=E[0]}_selectWordAtCursor(S,E){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 A=this._getMouseBufferCoords(S);return!!A&&(this._selectWordAt(A,E),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(S,E){this._model.clearSelection(),S=Math.max(S,0),E=Math.min(E,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,S],this._model.selectionEnd=[this._bufferService.cols,E],this.refresh(),this._onSelectionChange.fire()}_handleTrim(S){this._model.handleTrim(S)&&this.refresh()}_getMouseBufferCoords(S){const E=this._mouseService.getCoords(S,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(E)return E[0]--,E[1]--,E[1]+=this._bufferService.buffer.ydisp,E}_getMouseEventScrollAmount(S){let E=(0,c.getCoordsRelativeToElement)(this._coreBrowserService.window,S,this._screenElement)[1];const R=this._renderService.dimensions.css.canvas.height;return E>=0&&E<=R?0:(E>R&&(E-=R),E=Math.min(Math.max(E,-50),50),E/=50,E/Math.abs(E)+Math.round(14*E))}shouldForceSelection(S){return h.isMac?S.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:S.shiftKey}handleMouseDown(S){if(this._mouseDownTimeStamp=S.timeStamp,(S.button!==2||!this.hasSelection)&&S.button===0){if(!this._enabled){if(!this.shouldForceSelection(S))return;S.stopPropagation()}S.preventDefault(),this._dragScrollAmount=0,this._enabled&&S.shiftKey?this._handleIncrementalClick(S):S.detail===1?this._handleSingleClick(S):S.detail===2?this._handleDoubleClick(S):S.detail===3&&this._handleTripleClick(S),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(S){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(S))}_handleSingleClick(S){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(S)?3:0,this._model.selectionStart=this._getMouseBufferCoords(S),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const E=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);E&&E.length!==this._model.selectionStart[0]&&E.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(S){this._selectWordAtCursor(S,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(S){const E=this._getMouseBufferCoords(S);E&&(this._activeSelectionMode=2,this._selectLineAt(E[1]))}shouldColumnSelect(S){return S.altKey&&!(h.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(S){if(S.stopImmediatePropagation(),!this._model.selectionStart)return;const E=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(S),!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(S),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]++}E&&E[0]===this._model.selectionEnd[0]&&E[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});const S=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(S.ydisp+this._bufferService.rows,S.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=S.ydisp),this.refresh()}}_handleMouseUp(S){const E=S.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&E<500&&S.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const R=this._mouseService.getCoords(S,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 S=this._model.finalSelectionStart,E=this._model.finalSelectionEnd,R=!(!S||!E||S[0]===E[0]&&S[1]===E[1]);R?S&&E&&(this._oldSelectionStart&&this._oldSelectionEnd&&S[0]===this._oldSelectionStart[0]&&S[1]===this._oldSelectionStart[1]&&E[0]===this._oldSelectionEnd[0]&&E[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(S,E,R)):this._oldHasSelection&&this._fireOnSelectionChange(S,E,R)}_fireOnSelectionChange(S,E,R){this._oldSelectionStart=S,this._oldSelectionEnd=E,this._oldHasSelection=R,this._onSelectionChange.fire()}_handleBufferActivate(S){this.clearSelection(),this._trimListener.dispose(),this._trimListener=S.activeBuffer.lines.onTrim((E=>this._handleTrim(E)))}_convertViewportColToCharacterIndex(S,E){let R=E;for(let L=0;E>=L;L++){const T=S.loadCell(L,this._workCell).getChars().length;this._workCell.getWidth()===0?R--:T>1&&E!==L&&(R+=T-1)}return R}setSelection(S,E,R){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[S,E],this._model.selectionStartLength=R,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(S){this._isClickInSelection(S)||(this._selectWordAtCursor(S,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(S,E,R=!0,L=!0){if(S[0]>=this._bufferService.cols)return;const T=this._bufferService.buffer,A=T.lines.get(S[1]);if(!A)return;const B=T.translateBufferLineToString(S[1],!1);let D=this._convertViewportColToCharacterIndex(A,S[0]),z=D;const H=S[0]-D;let M=0,O=0,P=0,I=0;if(B.charAt(D)===" "){for(;D>0&&B.charAt(D-1)===" ";)D--;for(;z<B.length&&B.charAt(z+1)===" ";)z++}else{let q=S[0],V=S[0];A.getWidth(q)===0&&(M++,q--),A.getWidth(V)===2&&(O++,V++);const F=A.getString(V).length;for(F>1&&(I+=F-1,z+=F-1);q>0&&D>0&&!this._isCharWordSeparator(A.loadCell(q-1,this._workCell));){A.loadCell(q-1,this._workCell);const N=this._workCell.getChars().length;this._workCell.getWidth()===0?(M++,q--):N>1&&(P+=N-1,D-=N-1),D--,q--}for(;V<A.length&&z+1<B.length&&!this._isCharWordSeparator(A.loadCell(V+1,this._workCell));){A.loadCell(V+1,this._workCell);const N=this._workCell.getChars().length;this._workCell.getWidth()===2?(O++,V++):N>1&&(I+=N-1,z+=N-1),z++,V++}}z++;let $=D+H-M+P,Y=Math.min(this._bufferService.cols,z-D+M+O-P-I);if(E||B.slice(D,z).trim()!==""){if(R&&$===0&&A.getCodePoint(0)!==32){const q=T.lines.get(S[1]-1);if(q&&A.isWrapped&&q.getCodePoint(this._bufferService.cols-1)!==32){const V=this._getWordAt([this._bufferService.cols-1,S[1]-1],!1,!0,!1);if(V){const F=this._bufferService.cols-V.start;$-=F,Y+=F}}}if(L&&$+Y===this._bufferService.cols&&A.getCodePoint(this._bufferService.cols-1)!==32){const q=T.lines.get(S[1]+1);if(q?.isWrapped&&q.getCodePoint(0)!==32){const V=this._getWordAt([0,S[1]+1],!1,!1,!0);V&&(Y+=V.length)}}return{start:$,length:Y}}}_selectWordAt(S,E){const R=this._getWordAt(S,E);if(R){for(;R.start<0;)R.start+=this._bufferService.cols,S[1]--;this._model.selectionStart=[R.start,S[1]],this._model.selectionStartLength=R.length}}_selectToWordAt(S){const E=this._getWordAt(S,!0);if(E){let R=S[1];for(;E.start<0;)E.start+=this._bufferService.cols,R--;if(!this._model.areSelectionValuesReversed())for(;E.start+E.length>this._bufferService.cols;)E.length-=this._bufferService.cols,R++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?E.start:E.start+E.length,R]}}_isCharWordSeparator(S){return S.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(S.getChars())>=0}_selectLineAt(S){const E=this._bufferService.buffer.getWrappedRangeForLine(S),R={start:{x:0,y:E.first},end:{x:this._bufferService.cols-1,y:E.last}};this._model.selectionStart=[0,E.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,d.getRangeLength)(R,this._bufferService.cols)}};i.SelectionService=j=l([u(3,b.IBufferService),u(4,b.ICoreService),u(5,y.IMouseService),u(6,b.IOptionsService),u(7,y.IRenderService),u(8,y.ICoreBrowserService)],j)},4725:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.IThemeService=i.ICharacterJoinerService=i.ISelectionService=i.IRenderService=i.IMouseService=i.ICoreBrowserService=i.ICharSizeService=void 0;const l=n(8343);i.ICharSizeService=(0,l.createDecorator)("CharSizeService"),i.ICoreBrowserService=(0,l.createDecorator)("CoreBrowserService"),i.IMouseService=(0,l.createDecorator)("MouseService"),i.IRenderService=(0,l.createDecorator)("RenderService"),i.ISelectionService=(0,l.createDecorator)("SelectionService"),i.ICharacterJoinerService=(0,l.createDecorator)("CharacterJoinerService"),i.IThemeService=(0,l.createDecorator)("ThemeService")},6731:function(v,i,n){var l=this&&this.__decorate||function(j,S,E,R){var L,T=arguments.length,A=T<3?S:R===null?R=Object.getOwnPropertyDescriptor(S,E):R;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(j,S,E,R);else for(var B=j.length-1;B>=0;B--)(L=j[B])&&(A=(T<3?L(A):T>3?L(S,E,A):L(S,E))||A);return T>3&&A&&Object.defineProperty(S,E,A),A},u=this&&this.__param||function(j,S){return function(E,R){S(E,R,j)}};Object.defineProperty(i,"__esModule",{value:!0}),i.ThemeService=i.DEFAULT_ANSI_COLORS=void 0;const c=n(7239),g=n(8055),_=n(8460),y=n(844),x=n(2585),a=g.css.toColor("#ffffff"),h=g.css.toColor("#000000"),d=g.css.toColor("#ffffff"),f=g.css.toColor("#000000"),b={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};i.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const j=[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")],S=[0,95,135,175,215,255];for(let E=0;E<216;E++){const R=S[E/36%6|0],L=S[E/6%6|0],T=S[E%6];j.push({css:g.channels.toCss(R,L,T),rgba:g.channels.toRgba(R,L,T)})}for(let E=0;E<24;E++){const R=8+10*E;j.push({css:g.channels.toCss(R,R,R),rgba:g.channels.toRgba(R,R,R)})}return j})());let w=i.ThemeService=class extends y.Disposable{get colors(){return this._colors}constructor(j){super(),this._optionsService=j,this._contrastCache=new c.ColorContrastCache,this._halfContrastCache=new c.ColorContrastCache,this._onChangeColors=this.register(new _.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:a,background:h,cursor:d,cursorAccent:f,selectionForeground:void 0,selectionBackgroundTransparent:b,selectionBackgroundOpaque:g.color.blend(h,b),selectionInactiveBackgroundTransparent:b,selectionInactiveBackgroundOpaque:g.color.blend(h,b),ansi:i.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(j={}){const S=this._colors;if(S.foreground=k(j.foreground,a),S.background=k(j.background,h),S.cursor=k(j.cursor,d),S.cursorAccent=k(j.cursorAccent,f),S.selectionBackgroundTransparent=k(j.selectionBackground,b),S.selectionBackgroundOpaque=g.color.blend(S.background,S.selectionBackgroundTransparent),S.selectionInactiveBackgroundTransparent=k(j.selectionInactiveBackground,S.selectionBackgroundTransparent),S.selectionInactiveBackgroundOpaque=g.color.blend(S.background,S.selectionInactiveBackgroundTransparent),S.selectionForeground=j.selectionForeground?k(j.selectionForeground,g.NULL_COLOR):void 0,S.selectionForeground===g.NULL_COLOR&&(S.selectionForeground=void 0),g.color.isOpaque(S.selectionBackgroundTransparent)&&(S.selectionBackgroundTransparent=g.color.opacity(S.selectionBackgroundTransparent,.3)),g.color.isOpaque(S.selectionInactiveBackgroundTransparent)&&(S.selectionInactiveBackgroundTransparent=g.color.opacity(S.selectionInactiveBackgroundTransparent,.3)),S.ansi=i.DEFAULT_ANSI_COLORS.slice(),S.ansi[0]=k(j.black,i.DEFAULT_ANSI_COLORS[0]),S.ansi[1]=k(j.red,i.DEFAULT_ANSI_COLORS[1]),S.ansi[2]=k(j.green,i.DEFAULT_ANSI_COLORS[2]),S.ansi[3]=k(j.yellow,i.DEFAULT_ANSI_COLORS[3]),S.ansi[4]=k(j.blue,i.DEFAULT_ANSI_COLORS[4]),S.ansi[5]=k(j.magenta,i.DEFAULT_ANSI_COLORS[5]),S.ansi[6]=k(j.cyan,i.DEFAULT_ANSI_COLORS[6]),S.ansi[7]=k(j.white,i.DEFAULT_ANSI_COLORS[7]),S.ansi[8]=k(j.brightBlack,i.DEFAULT_ANSI_COLORS[8]),S.ansi[9]=k(j.brightRed,i.DEFAULT_ANSI_COLORS[9]),S.ansi[10]=k(j.brightGreen,i.DEFAULT_ANSI_COLORS[10]),S.ansi[11]=k(j.brightYellow,i.DEFAULT_ANSI_COLORS[11]),S.ansi[12]=k(j.brightBlue,i.DEFAULT_ANSI_COLORS[12]),S.ansi[13]=k(j.brightMagenta,i.DEFAULT_ANSI_COLORS[13]),S.ansi[14]=k(j.brightCyan,i.DEFAULT_ANSI_COLORS[14]),S.ansi[15]=k(j.brightWhite,i.DEFAULT_ANSI_COLORS[15]),j.extendedAnsi){const E=Math.min(S.ansi.length-16,j.extendedAnsi.length);for(let R=0;R<E;R++)S.ansi[R+16]=k(j.extendedAnsi[R],i.DEFAULT_ANSI_COLORS[R+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(j){this._restoreColor(j),this._onChangeColors.fire(this.colors)}_restoreColor(j){if(j!==void 0)switch(j){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[j]=this._restoreColors.ansi[j]}else for(let S=0;S<this._restoreColors.ansi.length;++S)this._colors.ansi[S]=this._restoreColors.ansi[S]}modifyColors(j){j(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(j,S){if(j!==void 0)try{return g.css.toColor(j)}catch{}return S}i.ThemeService=w=l([u(0,x.IOptionsService)],w)},6349:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CircularList=void 0;const l=n(8460),u=n(844);class c extends u.Disposable{constructor(_){super(),this._maxLength=_,this.onDeleteEmitter=this.register(new l.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new l.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new l.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(_){if(this._maxLength===_)return;const y=new Array(_);for(let x=0;x<Math.min(_,this.length);x++)y[x]=this._array[this._getCyclicIndex(x)];this._array=y,this._maxLength=_,this._startIndex=0}get length(){return this._length}set length(_){if(_>this._length)for(let y=this._length;y<_;y++)this._array[y]=void 0;this._length=_}get(_){return this._array[this._getCyclicIndex(_)]}set(_,y){this._array[this._getCyclicIndex(_)]=y}push(_){this._array[this._getCyclicIndex(this._length)]=_,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(_,y,...x){if(y){for(let a=_;a<this._length-y;a++)this._array[this._getCyclicIndex(a)]=this._array[this._getCyclicIndex(a+y)];this._length-=y,this.onDeleteEmitter.fire({index:_,amount:y})}for(let a=this._length-1;a>=_;a--)this._array[this._getCyclicIndex(a+x.length)]=this._array[this._getCyclicIndex(a)];for(let a=0;a<x.length;a++)this._array[this._getCyclicIndex(_+a)]=x[a];if(x.length&&this.onInsertEmitter.fire({index:_,amount:x.length}),this._length+x.length>this._maxLength){const a=this._length+x.length-this._maxLength;this._startIndex+=a,this._length=this._maxLength,this.onTrimEmitter.fire(a)}else this._length+=x.length}trimStart(_){_>this._length&&(_=this._length),this._startIndex+=_,this._length-=_,this.onTrimEmitter.fire(_)}shiftElements(_,y,x){if(!(y<=0)){if(_<0||_>=this._length)throw new Error("start argument out of range");if(_+x<0)throw new Error("Cannot shift elements in list beyond index 0");if(x>0){for(let h=y-1;h>=0;h--)this.set(_+h+x,this.get(_+h));const a=_+y+x-this._length;if(a>0)for(this._length+=a;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let a=0;a<y;a++)this.set(_+a+x,this.get(_+a))}}_getCyclicIndex(_){return(this._startIndex+_)%this._maxLength}}i.CircularList=c},1439:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.clone=void 0,i.clone=function n(l,u=5){if(typeof l!="object")return l;const c=Array.isArray(l)?[]:{};for(const g in l)c[g]=u<=1?l[g]:l[g]&&n(l[g],u-1);return c}},8055:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.contrastRatio=i.toPaddedHex=i.rgba=i.rgb=i.css=i.color=i.channels=i.NULL_COLOR=void 0;const l=n(6114);let u=0,c=0,g=0,_=0;var y,x,a,h,d;function f(w){const k=w.toString(16);return k.length<2?"0"+k:k}function b(w,k){return w<k?(k+.05)/(w+.05):(w+.05)/(k+.05)}i.NULL_COLOR={css:"#00000000",rgba:0},(function(w){w.toCss=function(k,j,S,E){return E!==void 0?`#${f(k)}${f(j)}${f(S)}${f(E)}`:`#${f(k)}${f(j)}${f(S)}`},w.toRgba=function(k,j,S,E=255){return(k<<24|j<<16|S<<8|E)>>>0}})(y||(i.channels=y={})),(function(w){function k(j,S){return _=Math.round(255*S),[u,c,g]=d.toChannels(j.rgba),{css:y.toCss(u,c,g,_),rgba:y.toRgba(u,c,g,_)}}w.blend=function(j,S){if(_=(255&S.rgba)/255,_===1)return{css:S.css,rgba:S.rgba};const E=S.rgba>>24&255,R=S.rgba>>16&255,L=S.rgba>>8&255,T=j.rgba>>24&255,A=j.rgba>>16&255,B=j.rgba>>8&255;return u=T+Math.round((E-T)*_),c=A+Math.round((R-A)*_),g=B+Math.round((L-B)*_),{css:y.toCss(u,c,g),rgba:y.toRgba(u,c,g)}},w.isOpaque=function(j){return(255&j.rgba)==255},w.ensureContrastRatio=function(j,S,E){const R=d.ensureContrastRatio(j.rgba,S.rgba,E);if(R)return d.toColor(R>>24&255,R>>16&255,R>>8&255)},w.opaque=function(j){const S=(255|j.rgba)>>>0;return[u,c,g]=d.toChannels(S),{css:y.toCss(u,c,g),rgba:S}},w.opacity=k,w.multiplyOpacity=function(j,S){return _=255&j.rgba,k(j,_*S/255)},w.toColorRGB=function(j){return[j.rgba>>24&255,j.rgba>>16&255,j.rgba>>8&255]}})(x||(i.color=x={})),(function(w){let k,j;if(!l.isNode){const S=document.createElement("canvas");S.width=1,S.height=1;const E=S.getContext("2d",{willReadFrequently:!0});E&&(k=E,k.globalCompositeOperation="copy",j=k.createLinearGradient(0,0,1,1))}w.toColor=function(S){if(S.match(/#[\da-f]{3,8}/i))switch(S.length){case 4:return u=parseInt(S.slice(1,2).repeat(2),16),c=parseInt(S.slice(2,3).repeat(2),16),g=parseInt(S.slice(3,4).repeat(2),16),d.toColor(u,c,g);case 5:return u=parseInt(S.slice(1,2).repeat(2),16),c=parseInt(S.slice(2,3).repeat(2),16),g=parseInt(S.slice(3,4).repeat(2),16),_=parseInt(S.slice(4,5).repeat(2),16),d.toColor(u,c,g,_);case 7:return{css:S,rgba:(parseInt(S.slice(1),16)<<8|255)>>>0};case 9:return{css:S,rgba:parseInt(S.slice(1),16)>>>0}}const E=S.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(E)return u=parseInt(E[1]),c=parseInt(E[2]),g=parseInt(E[3]),_=Math.round(255*(E[5]===void 0?1:parseFloat(E[5]))),d.toColor(u,c,g,_);if(!k||!j)throw new Error("css.toColor: Unsupported css format");if(k.fillStyle=j,k.fillStyle=S,typeof k.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(k.fillRect(0,0,1,1),[u,c,g,_]=k.getImageData(0,0,1,1).data,_!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:y.toRgba(u,c,g,_),css:S}}})(a||(i.css=a={})),(function(w){function k(j,S,E){const R=j/255,L=S/255,T=E/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))}w.relativeLuminance=function(j){return k(j>>16&255,j>>8&255,255&j)},w.relativeLuminance2=k})(h||(i.rgb=h={})),(function(w){function k(S,E,R){const L=S>>24&255,T=S>>16&255,A=S>>8&255;let B=E>>24&255,D=E>>16&255,z=E>>8&255,H=b(h.relativeLuminance2(B,D,z),h.relativeLuminance2(L,T,A));for(;H<R&&(B>0||D>0||z>0);)B-=Math.max(0,Math.ceil(.1*B)),D-=Math.max(0,Math.ceil(.1*D)),z-=Math.max(0,Math.ceil(.1*z)),H=b(h.relativeLuminance2(B,D,z),h.relativeLuminance2(L,T,A));return(B<<24|D<<16|z<<8|255)>>>0}function j(S,E,R){const L=S>>24&255,T=S>>16&255,A=S>>8&255;let B=E>>24&255,D=E>>16&255,z=E>>8&255,H=b(h.relativeLuminance2(B,D,z),h.relativeLuminance2(L,T,A));for(;H<R&&(B<255||D<255||z<255);)B=Math.min(255,B+Math.ceil(.1*(255-B))),D=Math.min(255,D+Math.ceil(.1*(255-D))),z=Math.min(255,z+Math.ceil(.1*(255-z))),H=b(h.relativeLuminance2(B,D,z),h.relativeLuminance2(L,T,A));return(B<<24|D<<16|z<<8|255)>>>0}w.ensureContrastRatio=function(S,E,R){const L=h.relativeLuminance(S>>8),T=h.relativeLuminance(E>>8);if(b(L,T)<R){if(T<L){const D=k(S,E,R),z=b(L,h.relativeLuminance(D>>8));if(z<R){const H=j(S,E,R);return z>b(L,h.relativeLuminance(H>>8))?D:H}return D}const A=j(S,E,R),B=b(L,h.relativeLuminance(A>>8));if(B<R){const D=k(S,E,R);return B>b(L,h.relativeLuminance(D>>8))?A:D}return A}},w.reduceLuminance=k,w.increaseLuminance=j,w.toChannels=function(S){return[S>>24&255,S>>16&255,S>>8&255,255&S]},w.toColor=function(S,E,R,L){return{css:y.toCss(S,E,R,L),rgba:y.toRgba(S,E,R,L)}}})(d||(i.rgba=d={})),i.toPaddedHex=f,i.contrastRatio=b},8969:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CoreTerminal=void 0;const l=n(844),u=n(2585),c=n(4348),g=n(7866),_=n(744),y=n(7302),x=n(6975),a=n(8460),h=n(1753),d=n(1480),f=n(7994),b=n(9282),w=n(5435),k=n(5981),j=n(2660);let S=!1;class E extends l.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new a.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 l.MutableDisposable),this._onBinary=this.register(new a.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new a.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new a.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new a.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new a.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new a.EventEmitter),this._instantiationService=new c.InstantiationService,this.optionsService=this.register(new y.OptionsService(L)),this._instantiationService.setService(u.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(_.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(x.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(j.OscLinkService),this._instantiationService.setService(u.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new w.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,a.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,a.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,a.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,a.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,A)=>this._inputHandler.parse(T,A)))),this.register((0,a.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(L,T){this._writeBuffer.write(L,T)}writeSync(L,T){this._logService.logLevel<=u.LogLevelEnum.WARN&&!S&&(this._logService.warn("writeSync is unreliable and will be removed soon."),S=!0),this._writeBuffer.writeSync(L,T)}resize(L,T){isNaN(L)||isNaN(T)||(L=Math.max(L,_.MINIMUM_COLS),T=Math.max(T,_.MINIMUM_ROWS),this._bufferService.resize(L,T))}scroll(L,T=!1){this._bufferService.scroll(L,T)}scrollLines(L,T,A){this._bufferService.scrollLines(L,T,A)}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(b.updateWindowsModeWrappedState.bind(null,this._bufferService))),L.push(this.registerCsiHandler({final:"H"},(()=>((0,b.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,l.toDisposable)((()=>{for(const T of L)T.dispose()}))}}}i.CoreTerminal=E},8460:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.forwardEvent=i.EventEmitter=void 0,i.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=n=>(this._listeners.push(n),{dispose:()=>{if(!this._disposed){for(let l=0;l<this._listeners.length;l++)if(this._listeners[l]===n)return void this._listeners.splice(l,1)}}})),this._event}fire(n,l){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,n,l)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},i.forwardEvent=function(n,l){return n((u=>l.fire(u)))}},5435:function(v,i,n){var l=this&&this.__decorate||function(H,M,O,P){var I,$=arguments.length,Y=$<3?M:P===null?P=Object.getOwnPropertyDescriptor(M,O):P;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")Y=Reflect.decorate(H,M,O,P);else for(var q=H.length-1;q>=0;q--)(I=H[q])&&(Y=($<3?I(Y):$>3?I(M,O,Y):I(M,O))||Y);return $>3&&Y&&Object.defineProperty(M,O,Y),Y},u=this&&this.__param||function(H,M){return function(O,P){M(O,P,H)}};Object.defineProperty(i,"__esModule",{value:!0}),i.InputHandler=i.WindowsOptionsReportType=void 0;const c=n(2584),g=n(7116),_=n(2015),y=n(844),x=n(482),a=n(8437),h=n(8460),d=n(643),f=n(511),b=n(3734),w=n(2585),k=n(6242),j=n(6351),S=n(5941),E={"(":0,")":1,"*":2,"+":3,"-":1,".":2},R=131072;function L(H,M){if(H>24)return M.setWinLines||!1;switch(H){case 1:return!!M.restoreWin;case 2:return!!M.minimizeWin;case 3:return!!M.setWinPosition;case 4:return!!M.setWinSizePixels;case 5:return!!M.raiseWin;case 6:return!!M.lowerWin;case 7:return!!M.refreshWin;case 8:return!!M.setWinSizeChars;case 9:return!!M.maximizeWin;case 10:return!!M.fullscreenWin;case 11:return!!M.getWinState;case 13:return!!M.getWinPosition;case 14:return!!M.getWinSizePixels;case 15:return!!M.getScreenSizePixels;case 16:return!!M.getCellSizePixels;case 18:return!!M.getWinSizeChars;case 19:return!!M.getScreenSizeChars;case 20:return!!M.getIconTitle;case 21:return!!M.getWinTitle;case 22:return!!M.pushTitle;case 23:return!!M.popTitle;case 24:return!!M.setWinLines}return!1}var T;(function(H){H[H.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",H[H.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(T||(i.WindowsOptionsReportType=T={}));let A=0;class B extends y.Disposable{getAttrData(){return this._curAttrData}constructor(M,O,P,I,$,Y,q,V,F=new _.EscapeSequenceParser){super(),this._bufferService=M,this._charsetService=O,this._coreService=P,this._logService=I,this._optionsService=$,this._oscLinkService=Y,this._coreMouseService=q,this._unicodeService=V,this._parser=F,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new x.StringToUtf32,this._utf8Decoder=new x.Utf8ToUtf32,this._workCell=new f.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=a.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=a.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 D(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 j.DcsHandler(((N,W)=>this.requestStatusString(N,W))))}_preserveStack(M,O,P,I){this._parseStack.paused=!0,this._parseStack.cursorStartX=M,this._parseStack.cursorStartY=O,this._parseStack.decodedLength=P,this._parseStack.position=I}_logSlowResolvingAsync(M){this._logService.logLevel<=w.LogLevelEnum.WARN&&Promise.race([M,new Promise(((O,P)=>setTimeout((()=>P("#SLOW_TIMEOUT")),5e3)))]).catch((O=>{if(O!=="#SLOW_TIMEOUT")throw O;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(M,O){let P,I=this._activeBuffer.x,$=this._activeBuffer.y,Y=0;const q=this._parseStack.paused;if(q){if(P=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,O))return this._logSlowResolvingAsync(P),P;I=this._parseStack.cursorStartX,$=this._parseStack.cursorStartY,this._parseStack.paused=!1,M.length>R&&(Y=this._parseStack.position+R)}if(this._logService.logLevel<=w.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof M=="string"?` "${M}"`:` "${Array.prototype.map.call(M,(V=>String.fromCharCode(V))).join("")}"`),typeof M=="string"?M.split("").map((V=>V.charCodeAt(0))):M),this._parseBuffer.length<M.length&&this._parseBuffer.length<R&&(this._parseBuffer=new Uint32Array(Math.min(M.length,R))),q||this._dirtyRowTracker.clearRange(),M.length>R)for(let V=Y;V<M.length;V+=R){const F=V+R<M.length?V+R:M.length,N=typeof M=="string"?this._stringDecoder.decode(M.substring(V,F),this._parseBuffer):this._utf8Decoder.decode(M.subarray(V,F),this._parseBuffer);if(P=this._parser.parse(this._parseBuffer,N))return this._preserveStack(I,$,N,V),this._logSlowResolvingAsync(P),P}else if(!q){const V=typeof M=="string"?this._stringDecoder.decode(M,this._parseBuffer):this._utf8Decoder.decode(M,this._parseBuffer);if(P=this._parser.parse(this._parseBuffer,V))return this._preserveStack(I,$,V,0),this._logSlowResolvingAsync(P),P}this._activeBuffer.x===I&&this._activeBuffer.y===$||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowTracker.start,this._dirtyRowTracker.end)}print(M,O,P){let I,$;const Y=this._charsetService.charset,q=this._optionsService.rawOptions.screenReaderMode,V=this._bufferService.cols,F=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&&P-O>0&&X.getWidth(this._activeBuffer.x-1)===2&&X.setCellFromCodePoint(this._activeBuffer.x-1,0,1,W.fg,W.bg,W.extended);for(let K=O;K<P;++K){if(I=M[K],$=this._unicodeService.wcwidth(I),I<127&&Y){const ie=Y[String.fromCharCode(I)];ie&&(I=ie.charCodeAt(0))}if(q&&this._onA11yChar.fire((0,x.stringFromCodePoint)(I)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),$||!this._activeBuffer.x){if(this._activeBuffer.x+$-1>=V){if(F){for(;this._activeBuffer.x<V;)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=V-1,$===2)continue}if(N&&(X.insertCells(this._activeBuffer.x,$,this._activeBuffer.getNullCell(W),W),X.getWidth(V-1)===2&&X.setCellFromCodePoint(V-1,d.NULL_CELL_CODE,d.NULL_CELL_WIDTH,W.fg,W.bg,W.extended)),X.setCellFromCodePoint(this._activeBuffer.x++,I,$,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,I):X.addCodepointToCell(this._activeBuffer.x-2,I)}P-O>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<V&&P-O>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(M,O){return M.final!=="t"||M.prefix||M.intermediates?this._parser.registerCsiHandler(M,O):this._parser.registerCsiHandler(M,(P=>!L(P.params[0],this._optionsService.rawOptions.windowOptions)||O(P)))}registerDcsHandler(M,O){return this._parser.registerDcsHandler(M,new j.DcsHandler(O))}registerEscHandler(M,O){return this._parser.registerEscHandler(M,O)}registerOscHandler(M,O){return this._parser.registerOscHandler(M,new k.OscHandler(O))}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 M;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&&(!((M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))===null||M===void 0)&&M.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);O.hasWidth(this._activeBuffer.x)&&!O.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const M=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-M),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(M=this._bufferService.cols-1){this._activeBuffer.x=Math.min(M,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(M,O){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=M,this._activeBuffer.y=this._activeBuffer.scrollTop+O):(this._activeBuffer.x=M,this._activeBuffer.y=O),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(M,O){this._restrictCursor(),this._setCursor(this._activeBuffer.x+M,this._activeBuffer.y+O)}cursorUp(M){const O=this._activeBuffer.y-this._activeBuffer.scrollTop;return O>=0?this._moveCursor(0,-Math.min(O,M.params[0]||1)):this._moveCursor(0,-(M.params[0]||1)),!0}cursorDown(M){const O=this._activeBuffer.scrollBottom-this._activeBuffer.y;return O>=0?this._moveCursor(0,Math.min(O,M.params[0]||1)):this._moveCursor(0,M.params[0]||1),!0}cursorForward(M){return this._moveCursor(M.params[0]||1,0),!0}cursorBackward(M){return this._moveCursor(-(M.params[0]||1),0),!0}cursorNextLine(M){return this.cursorDown(M),this._activeBuffer.x=0,!0}cursorPrecedingLine(M){return this.cursorUp(M),this._activeBuffer.x=0,!0}cursorCharAbsolute(M){return this._setCursor((M.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(M){return this._setCursor(M.length>=2?(M.params[1]||1)-1:0,(M.params[0]||1)-1),!0}charPosAbsolute(M){return this._setCursor((M.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(M){return this._moveCursor(M.params[0]||1,0),!0}linePosAbsolute(M){return this._setCursor(this._activeBuffer.x,(M.params[0]||1)-1),!0}vPositionRelative(M){return this._moveCursor(0,M.params[0]||1),!0}hVPosition(M){return this.cursorPosition(M),!0}tabClear(M){const O=M.params[0];return O===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:O===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(M){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let O=M.params[0]||1;for(;O--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(M){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let O=M.params[0]||1;for(;O--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(M){const O=M.params[0];return O===1&&(this._curAttrData.bg|=536870912),O!==2&&O!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(M,O,P,I=!1,$=!1){const Y=this._activeBuffer.lines.get(this._activeBuffer.ybase+M);Y.replaceCells(O,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),$),I&&(Y.isWrapped=!1)}_resetBufferLine(M,O=!1){const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+M);P&&(P.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),O),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+M),P.isWrapped=!1)}eraseInDisplay(M,O=!1){let P;switch(this._restrictCursor(this._bufferService.cols),M.params[0]){case 0:for(P=this._activeBuffer.y,this._dirtyRowTracker.markDirty(P),this._eraseInBufferLine(P++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,O);P<this._bufferService.rows;P++)this._resetBufferLine(P,O);this._dirtyRowTracker.markDirty(P);break;case 1:for(P=this._activeBuffer.y,this._dirtyRowTracker.markDirty(P),this._eraseInBufferLine(P,0,this._activeBuffer.x+1,!0,O),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(P+1).isWrapped=!1);P--;)this._resetBufferLine(P,O);this._dirtyRowTracker.markDirty(0);break;case 2:for(P=this._bufferService.rows,this._dirtyRowTracker.markDirty(P-1);P--;)this._resetBufferLine(P,O);this._dirtyRowTracker.markDirty(0);break;case 3:const I=this._activeBuffer.lines.length-this._bufferService.rows;I>0&&(this._activeBuffer.lines.trimStart(I),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-I,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-I,0),this._onScroll.fire(0))}return!0}eraseInLine(M,O=!1){switch(this._restrictCursor(this._bufferService.cols),M.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,O);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,O);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,O)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(M){this._restrictCursor();let O=M.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=this._activeBuffer.ybase+this._activeBuffer.y,I=this._bufferService.rows-1-this._activeBuffer.scrollBottom,$=this._bufferService.rows-1+this._activeBuffer.ybase-I+1;for(;O--;)this._activeBuffer.lines.splice($-1,1),this._activeBuffer.lines.splice(P,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(M){this._restrictCursor();let O=M.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=this._activeBuffer.ybase+this._activeBuffer.y;let I;for(I=this._bufferService.rows-1-this._activeBuffer.scrollBottom,I=this._bufferService.rows-1+this._activeBuffer.ybase-I;O--;)this._activeBuffer.lines.splice(P,1),this._activeBuffer.lines.splice(I,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(M){this._restrictCursor();const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return O&&(O.insertCells(this._activeBuffer.x,M.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(M){this._restrictCursor();const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return O&&(O.deleteCells(this._activeBuffer.x,M.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(M){let O=M.params[0]||1;for(;O--;)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(M){let O=M.params[0]||1;for(;O--;)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(a.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(M){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=M.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);I.deleteCells(0,O,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),I.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(M){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=M.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);I.insertCells(0,O,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),I.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(M){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=M.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);I.insertCells(this._activeBuffer.x,O,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),I.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(M){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=M.params[0]||1;for(let P=this._activeBuffer.scrollTop;P<=this._activeBuffer.scrollBottom;++P){const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+P);I.deleteCells(this._activeBuffer.x,O,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),I.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(M){this._restrictCursor();const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return O&&(O.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(M.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(M){if(!this._parser.precedingCodepoint)return!0;const O=M.params[0]||1,P=new Uint32Array(O);for(let I=0;I<O;++I)P[I]=this._parser.precedingCodepoint;return this.print(P,0,P.length),!0}sendDeviceAttributesPrimary(M){return M.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(M){return M.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(M.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(c.C0.ESC+"[>83;40003;0c")),!0}_is(M){return(this._optionsService.rawOptions.termName+"").indexOf(M)===0}setMode(M){for(let O=0;O<M.length;O++)switch(M.params[O]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(M){for(let O=0;O<M.length;O++)switch(M.params[O]){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(M){for(let O=0;O<M.length;O++)switch(M.params[O]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(M){for(let O=0;O<M.length;O++)switch(M.params[O]){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(),M.params[O]===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(M,O){const P=this._coreService.decPrivateModes,{activeProtocol:I,activeEncoding:$}=this._coreMouseService,Y=this._coreService,{buffers:q,cols:V}=this._bufferService,{active:F,alt:N}=q,W=this._optionsService.rawOptions,X=re=>re?1:2,K=M.params[0];return ie=K,Z=O?K===2?4:K===4?X(Y.modes.insertMode):K===12?3:K===20?X(W.convertEol):0:K===1?X(P.applicationCursorKeys):K===3?W.windowOptions.setWinLines?V===80?2:V===132?1:0:0:K===6?X(P.origin):K===7?X(P.wraparound):K===8?3:K===9?X(I==="X10"):K===12?X(W.cursorBlink):K===25?X(!Y.isCursorHidden):K===45?X(P.reverseWraparound):K===66?X(P.applicationKeypad):K===67?4:K===1e3?X(I==="VT200"):K===1002?X(I==="DRAG"):K===1003?X(I==="ANY"):K===1004?X(P.sendFocus):K===1005?4:K===1006?X($==="SGR"):K===1015?4:K===1016?X($==="SGR_PIXELS"):K===1048?1:K===47||K===1047||K===1049?X(F===N):K===2004?X(P.bracketedPasteMode):0,Y.triggerDataEvent(`${c.C0.ESC}[${O?"":"?"}${ie};${Z}$y`),!0;var ie,Z}_updateAttrColor(M,O,P,I,$){return O===2?(M|=50331648,M&=-16777216,M|=b.AttributeData.fromColorRGB([P,I,$])):O===5&&(M&=-50331904,M|=33554432|255&P),M}_extractColor(M,O,P){const I=[0,0,-1,0,0,0];let $=0,Y=0;do{if(I[Y+$]=M.params[O+Y],M.hasSubParams(O+Y)){const q=M.getSubParams(O+Y);let V=0;do I[1]===5&&($=1),I[Y+V+1+$]=q[V];while(++V<q.length&&V+Y+1+$<I.length);break}if(I[1]===5&&Y+$>=2||I[1]===2&&Y+$>=5)break;I[1]&&($=1)}while(++Y+O<M.length&&Y+$<I.length);for(let q=2;q<I.length;++q)I[q]===-1&&(I[q]=0);switch(I[0]){case 38:P.fg=this._updateAttrColor(P.fg,I[1],I[3],I[4],I[5]);break;case 48:P.bg=this._updateAttrColor(P.bg,I[1],I[3],I[4],I[5]);break;case 58:P.extended=P.extended.clone(),P.extended.underlineColor=this._updateAttrColor(P.extended.underlineColor,I[1],I[3],I[4],I[5])}return Y}_processUnderline(M,O){O.extended=O.extended.clone(),(!~M||M>5)&&(M=1),O.extended.underlineStyle=M,O.fg|=268435456,M===0&&(O.fg&=-268435457),O.updateExtended()}_processSGR0(M){M.fg=a.DEFAULT_ATTR_DATA.fg,M.bg=a.DEFAULT_ATTR_DATA.bg,M.extended=M.extended.clone(),M.extended.underlineStyle=0,M.extended.underlineColor&=-67108864,M.updateExtended()}charAttributes(M){if(M.length===1&&M.params[0]===0)return this._processSGR0(this._curAttrData),!0;const O=M.length;let P;const I=this._curAttrData;for(let $=0;$<O;$++)P=M.params[$],P>=30&&P<=37?(I.fg&=-50331904,I.fg|=16777216|P-30):P>=40&&P<=47?(I.bg&=-50331904,I.bg|=16777216|P-40):P>=90&&P<=97?(I.fg&=-50331904,I.fg|=16777224|P-90):P>=100&&P<=107?(I.bg&=-50331904,I.bg|=16777224|P-100):P===0?this._processSGR0(I):P===1?I.fg|=134217728:P===3?I.bg|=67108864:P===4?(I.fg|=268435456,this._processUnderline(M.hasSubParams($)?M.getSubParams($)[0]:1,I)):P===5?I.fg|=536870912:P===7?I.fg|=67108864:P===8?I.fg|=1073741824:P===9?I.fg|=2147483648:P===2?I.bg|=134217728:P===21?this._processUnderline(2,I):P===22?(I.fg&=-134217729,I.bg&=-134217729):P===23?I.bg&=-67108865:P===24?(I.fg&=-268435457,this._processUnderline(0,I)):P===25?I.fg&=-536870913:P===27?I.fg&=-67108865:P===28?I.fg&=-1073741825:P===29?I.fg&=2147483647:P===39?(I.fg&=-67108864,I.fg|=16777215&a.DEFAULT_ATTR_DATA.fg):P===49?(I.bg&=-67108864,I.bg|=16777215&a.DEFAULT_ATTR_DATA.bg):P===38||P===48||P===58?$+=this._extractColor(M,$,I):P===53?I.bg|=1073741824:P===55?I.bg&=-1073741825:P===59?(I.extended=I.extended.clone(),I.extended.underlineColor=-1,I.updateExtended()):P===100?(I.fg&=-67108864,I.fg|=16777215&a.DEFAULT_ATTR_DATA.fg,I.bg&=-67108864,I.bg|=16777215&a.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",P);return!0}deviceStatus(M){switch(M.params[0]){case 5:this._coreService.triggerDataEvent(`${c.C0.ESC}[0n`);break;case 6:const O=this._activeBuffer.y+1,P=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${c.C0.ESC}[${O};${P}R`)}return!0}deviceStatusPrivate(M){if(M.params[0]===6){const O=this._activeBuffer.y+1,P=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${c.C0.ESC}[?${O};${P}R`)}return!0}softReset(M){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=a.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(M){const O=M.params[0]||1;switch(O){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 P=O%2==1;return this._optionsService.options.cursorBlink=P,!0}setScrollRegion(M){const O=M.params[0]||1;let P;return(M.length<2||(P=M.params[1])>this._bufferService.rows||P===0)&&(P=this._bufferService.rows),P>O&&(this._activeBuffer.scrollTop=O-1,this._activeBuffer.scrollBottom=P-1,this._setCursor(0,0)),!0}windowOptions(M){if(!L(M.params[0],this._optionsService.rawOptions.windowOptions))return!0;const O=M.length>1?M.params[1]:0;switch(M.params[0]){case 14:O!==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:O!==0&&O!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),O!==0&&O!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:O!==0&&O!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),O!==0&&O!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(M){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(M){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(M){return this._windowTitle=M,this._onTitleChange.fire(M),!0}setIconName(M){return this._iconName=M,!0}setOrReportIndexedColor(M){const O=[],P=M.split(";");for(;P.length>1;){const I=P.shift(),$=P.shift();if(/^\d+$/.exec(I)){const Y=parseInt(I);if(z(Y))if($==="?")O.push({type:0,index:Y});else{const q=(0,S.parseColor)($);q&&O.push({type:1,index:Y,color:q})}}}return O.length&&this._onColor.fire(O),!0}setHyperlink(M){const O=M.split(";");return!(O.length<2)&&(O[1]?this._createHyperlink(O[0],O[1]):!O[0]&&this._finishHyperlink())}_createHyperlink(M,O){this._getCurrentLinkId()&&this._finishHyperlink();const P=M.split(":");let I;const $=P.findIndex((Y=>Y.startsWith("id=")));return $!==-1&&(I=P[$].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:I,uri:O}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(M,O){const P=M.split(";");for(let I=0;I<P.length&&!(O>=this._specialColors.length);++I,++O)if(P[I]==="?")this._onColor.fire([{type:0,index:this._specialColors[O]}]);else{const $=(0,S.parseColor)(P[I]);$&&this._onColor.fire([{type:1,index:this._specialColors[O],color:$}])}return!0}setOrReportFgColor(M){return this._setOrReportSpecialColor(M,0)}setOrReportBgColor(M){return this._setOrReportSpecialColor(M,1)}setOrReportCursorColor(M){return this._setOrReportSpecialColor(M,2)}restoreIndexedColor(M){if(!M)return this._onColor.fire([{type:2}]),!0;const O=[],P=M.split(";");for(let I=0;I<P.length;++I)if(/^\d+$/.exec(P[I])){const $=parseInt(P[I]);z($)&&O.push({type:2,index:$})}return O.length&&this._onColor.fire(O),!0}restoreFgColor(M){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(M){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(M){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(M){return M.length!==2?(this.selectDefaultCharset(),!0):(M[0]==="/"||this._charsetService.setgCharset(E[M[0]],g.CHARSETS[M[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 M=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,M,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=a.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=a.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(M){return this._charsetService.setgLevel(M),!0}screenAlignmentPattern(){const M=new f.CellData;M.content=4194373,M.fg=this._curAttrData.fg,M.bg=this._curAttrData.bg,this._setCursor(0,0);for(let O=0;O<this._bufferService.rows;++O){const P=this._activeBuffer.ybase+this._activeBuffer.y+O,I=this._activeBuffer.lines.get(P);I&&(I.fill(M),I.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(M,O){const P=this._bufferService.buffer,I=this._optionsService.rawOptions;return($=>(this._coreService.triggerDataEvent(`${c.C0.ESC}${$}${c.C0.ESC}\\`),!0))(M==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:M==='"p'?'P1$r61;1"p':M==="r"?`P1$r${P.scrollTop+1};${P.scrollBottom+1}r`:M==="m"?"P1$r0m":M===" q"?`P1$r${{block:2,underline:4,bar:6}[I.cursorStyle]-(I.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(M,O){this._dirtyRowTracker.markRangeDirty(M,O)}}i.InputHandler=B;let D=class{constructor(H){this._bufferService=H,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(H){H<this.start?this.start=H:H>this.end&&(this.end=H)}markRangeDirty(H,M){H>M&&(A=H,H=M,M=A),H<this.start&&(this.start=H),M>this.end&&(this.end=M)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function z(H){return 0<=H&&H<256}D=l([u(0,w.IBufferService)],D)},844:(v,i)=>{function n(l){for(const u of l)u.dispose();l.length=0}Object.defineProperty(i,"__esModule",{value:!0}),i.getDisposeArrayDisposable=i.disposeArray=i.toDisposable=i.MutableDisposable=i.Disposable=void 0,i.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const l of this._disposables)l.dispose();this._disposables.length=0}register(l){return this._disposables.push(l),l}unregister(l){const u=this._disposables.indexOf(l);u!==-1&&this._disposables.splice(u,1)}},i.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(l){var u;this._isDisposed||l===this._value||((u=this._value)===null||u===void 0||u.dispose(),this._value=l)}clear(){this.value=void 0}dispose(){var l;this._isDisposed=!0,(l=this._value)===null||l===void 0||l.dispose(),this._value=void 0}},i.toDisposable=function(l){return{dispose:l}},i.disposeArray=n,i.getDisposeArrayDisposable=function(l){return{dispose:()=>n(l)}}},1505:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.FourKeyMap=i.TwoKeyMap=void 0;class n{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={}}}i.TwoKeyMap=n,i.FourKeyMap=class{constructor(){this._data=new n}set(l,u,c,g,_){this._data.get(l,u)||this._data.set(l,u,new n),this._data.get(l,u).set(c,g,_)}get(l,u,c,g){var _;return(_=this._data.get(l,u))===null||_===void 0?void 0:_.get(c,g)}clear(){this._data.clear()}}},6114:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.isChromeOS=i.isLinux=i.isWindows=i.isIphone=i.isIpad=i.isMac=i.getSafariVersion=i.isSafari=i.isLegacyEdge=i.isFirefox=i.isNode=void 0,i.isNode=typeof navigator>"u";const n=i.isNode?"node":navigator.userAgent,l=i.isNode?"node":navigator.platform;i.isFirefox=n.includes("Firefox"),i.isLegacyEdge=n.includes("Edge"),i.isSafari=/^((?!chrome|android).)*safari/i.test(n),i.getSafariVersion=function(){if(!i.isSafari)return 0;const u=n.match(/Version\/(\d+)/);return u===null||u.length<2?0:parseInt(u[1])},i.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(l),i.isIpad=l==="iPad",i.isIphone=l==="iPhone",i.isWindows=["Windows","Win16","Win32","WinCE"].includes(l),i.isLinux=l.indexOf("Linux")>=0,i.isChromeOS=/\bCrOS\b/.test(n)},6106:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.SortedList=void 0;let n=0;i.SortedList=class{constructor(l){this._getKey=l,this._array=[]}clear(){this._array.length=0}insert(l){this._array.length!==0?(n=this._search(this._getKey(l)),this._array.splice(n,0,l)):this._array.push(l)}delete(l){if(this._array.length===0)return!1;const u=this._getKey(l);if(u===void 0||(n=this._search(u),n===-1)||this._getKey(this._array[n])!==u)return!1;do if(this._array[n]===l)return this._array.splice(n,1),!0;while(++n<this._array.length&&this._getKey(this._array[n])===u);return!1}*getKeyIterator(l){if(this._array.length!==0&&(n=this._search(l),!(n<0||n>=this._array.length)&&this._getKey(this._array[n])===l))do yield this._array[n];while(++n<this._array.length&&this._getKey(this._array[n])===l)}forEachByKey(l,u){if(this._array.length!==0&&(n=this._search(l),!(n<0||n>=this._array.length)&&this._getKey(this._array[n])===l))do u(this._array[n]);while(++n<this._array.length&&this._getKey(this._array[n])===l)}values(){return[...this._array].values()}_search(l){let u=0,c=this._array.length-1;for(;c>=u;){let g=u+c>>1;const _=this._getKey(this._array[g]);if(_>l)c=g-1;else{if(!(_<l)){for(;g>0&&this._getKey(this._array[g-1])===l;)g--;return g}u=g+1}}return u}}},7226:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DebouncedIdleTask=i.IdleTaskQueue=i.PriorityTaskQueue=void 0;const l=n(6114);class u{constructor(){this._tasks=[],this._i=0}enqueue(_){this._tasks.push(_),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(_){this._idleCallback=void 0;let y=0,x=0,a=_.timeRemaining(),h=0;for(;this._i<this._tasks.length;){if(y=Date.now(),this._tasks[this._i]()||this._i++,y=Math.max(1,Date.now()-y),x=Math.max(y,x),h=_.timeRemaining(),1.5*x>h)return a-y<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(a-y))}ms`),void this._start();a=h}this.clear()}}class c extends u{_requestCallback(_){return setTimeout((()=>_(this._createDeadline(16))))}_cancelCallback(_){clearTimeout(_)}_createDeadline(_){const y=Date.now()+_;return{timeRemaining:()=>Math.max(0,y-Date.now())}}}i.PriorityTaskQueue=c,i.IdleTaskQueue=!l.isNode&&"requestIdleCallback"in window?class extends u{_requestCallback(g){return requestIdleCallback(g)}_cancelCallback(g){cancelIdleCallback(g)}}:c,i.DebouncedIdleTask=class{constructor(){this._queue=new i.IdleTaskQueue}set(g){this._queue.clear(),this._queue.enqueue(g)}flush(){this._queue.flush()}}},9282:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.updateWindowsModeWrappedState=void 0;const l=n(643);i.updateWindowsModeWrappedState=function(u){const c=u.buffer.lines.get(u.buffer.ybase+u.buffer.y-1),g=c?.get(u.cols-1),_=u.buffer.lines.get(u.buffer.ybase+u.buffer.y);_&&g&&(_.isWrapped=g[l.CHAR_DATA_CODE_INDEX]!==l.NULL_CELL_CODE&&g[l.CHAR_DATA_CODE_INDEX]!==l.WHITESPACE_CELL_CODE)}},3734:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ExtendedAttrs=i.AttributeData=void 0;class n{constructor(){this.fg=0,this.bg=0,this.extended=new l}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 n;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}}i.AttributeData=n;class l{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 l(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}i.ExtendedAttrs=l},9092:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Buffer=i.MAX_BUFFER_SIZE=void 0;const l=n(6349),u=n(7226),c=n(3734),g=n(8437),_=n(4634),y=n(511),x=n(643),a=n(4863),h=n(7116);i.MAX_BUFFER_SIZE=4294967295,i.Buffer=class{constructor(d,f,b){this._hasScrollback=d,this._optionsService=f,this._bufferService=b,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=y.CellData.fromCharData([0,x.NULL_CELL_CHAR,x.NULL_CELL_WIDTH,x.NULL_CELL_CODE]),this._whitespaceCell=y.CellData.fromCharData([0,x.WHITESPACE_CELL_CHAR,x.WHITESPACE_CELL_WIDTH,x.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 l.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>i.MAX_BUFFER_SIZE?i.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 l.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(d,f){const b=this.getNullCell(g.DEFAULT_ATTR_DATA);let w=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 S=0;S<this.lines.length;S++)w+=+this.lines.get(S).resize(d,b);let j=0;if(this._rows<f)for(let S=this._rows;S<f;S++)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,b)):this.ybase>0&&this.lines.length<=this.ybase+this.y+j+1?(this.ybase--,j++,this.ydisp>0&&this.ydisp--):this.lines.push(new g.BufferLine(d,b)));else for(let S=this._rows;S>f;S--)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 S=this.lines.length-k;S>0&&(this.lines.trimStart(S),this.ybase=Math.max(this.ybase-S,0),this.ydisp=Math.max(this.ydisp-S,0),this.savedY=Math.max(this.savedY-S,0)),this.lines.maxLength=k}this.x=Math.min(this.x,d-1),this.y=Math.min(this.y,f-1),j&&(this.y+=j),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 j=0;j<this.lines.length;j++)w+=+this.lines.get(j).resize(d,b);this._cols=d,this._rows=f,this._memoryCleanupQueue.clear(),w>.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 b=(0,_.reflowLargerGetLinesToRemove)(this.lines,this._cols,d,this.ybase+this.y,this.getNullCell(g.DEFAULT_ATTR_DATA));if(b.length>0){const w=(0,_.reflowLargerCreateNewLayout)(this.lines,b);(0,_.reflowLargerApplyNewLayout)(this.lines,w.layout),this._reflowLargerAdjustViewport(d,f,w.countRemoved)}}_reflowLargerAdjustViewport(d,f,b){const w=this.getNullCell(g.DEFAULT_ATTR_DATA);let k=b;for(;k-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<f&&this.lines.push(new g.BufferLine(d,w))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-b,0)}_reflowSmaller(d,f){const b=this.getNullCell(g.DEFAULT_ATTR_DATA),w=[];let k=0;for(let j=this.lines.length-1;j>=0;j--){let S=this.lines.get(j);if(!S||!S.isWrapped&&S.getTrimmedLength()<=d)continue;const E=[S];for(;S.isWrapped&&j>0;)S=this.lines.get(--j),E.unshift(S);const R=this.ybase+this.y;if(R>=j&&R<j+E.length)continue;const L=E[E.length-1].getTrimmedLength(),T=(0,_.reflowSmallerGetNewLineLengths)(E,this._cols,d),A=T.length-E.length;let B;B=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+A):Math.max(0,this.lines.length-this.lines.maxLength+A);const D=[];for(let I=0;I<A;I++){const $=this.getBlankLine(g.DEFAULT_ATTR_DATA,!0);D.push($)}D.length>0&&(w.push({start:j+E.length+k,newLines:D}),k+=D.length),E.push(...D);let z=T.length-1,H=T[z];H===0&&(z--,H=T[z]);let M=E.length-A-1,O=L;for(;M>=0;){const I=Math.min(O,H);if(E[z]===void 0)break;if(E[z].copyCellsFrom(E[M],O-I,H-I,I,!0),H-=I,H===0&&(z--,H=T[z]),O-=I,O===0){M--;const $=Math.max(M,0);O=(0,_.getWrappedLineTrimmedLength)(E,$,this._cols)}}for(let I=0;I<E.length;I++)T[I]<d&&E[I].setCell(T[I],b);let P=A-B;for(;P-- >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+A,this.ybase+f-1)}if(w.length>0){const j=[],S=[];for(let z=0;z<this.lines.length;z++)S.push(this.lines.get(z));const E=this.lines.length;let R=E-1,L=0,T=w[L];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+k);let A=0;for(let z=Math.min(this.lines.maxLength-1,E+k-1);z>=0;z--)if(T&&T.start>R+A){for(let H=T.newLines.length-1;H>=0;H--)this.lines.set(z--,T.newLines[H]);z++,j.push({index:R+1,amount:T.newLines.length}),A+=T.newLines.length,T=w[++L]}else this.lines.set(z,S[R--]);let B=0;for(let z=j.length-1;z>=0;z--)j[z].index+=B,this.lines.onInsertEmitter.fire(j[z]),B+=j[z].amount;const D=Math.max(0,E+k-this.lines.maxLength);D>0&&this.lines.onTrimEmitter.fire(D)}}translateBufferLineToString(d,f,b=0,w){const k=this.lines.get(d);return k?k.translateToString(f,b,w):""}getWrappedRangeForLine(d){let f=d,b=d;for(;f>0&&this.lines.get(f).isWrapped;)f--;for(;b+1<this.lines.length&&this.lines.get(b+1).isWrapped;)b++;return{first:f,last:b}}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 a.Marker(d);return this.markers.push(f),f.register(this.lines.onTrim((b=>{f.line-=b,f.line<0&&f.dispose()}))),f.register(this.lines.onInsert((b=>{f.line>=b.index&&(f.line+=b.amount)}))),f.register(this.lines.onDelete((b=>{f.line>=b.index&&f.line<b.index+b.amount&&f.dispose(),f.line>b.index&&(f.line-=b.amount)}))),f.register(f.onDispose((()=>this._removeMarker(f)))),f}_removeMarker(d){this._isClearing||this.markers.splice(this.markers.indexOf(d),1)}}},8437:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferLine=i.DEFAULT_ATTR_DATA=void 0;const l=n(3734),u=n(511),c=n(643),g=n(482);i.DEFAULT_ATTR_DATA=Object.freeze(new l.AttributeData);let _=0;class y{constructor(a,h,d=!1){this.isWrapped=d,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*a);const f=h||u.CellData.fromCharData([0,c.NULL_CELL_CHAR,c.NULL_CELL_WIDTH,c.NULL_CELL_CODE]);for(let b=0;b<a;++b)this.setCell(b,f);this.length=a}get(a){const h=this._data[3*a+0],d=2097151&h;return[this._data[3*a+1],2097152&h?this._combined[a]:d?(0,g.stringFromCodePoint)(d):"",h>>22,2097152&h?this._combined[a].charCodeAt(this._combined[a].length-1):d]}set(a,h){this._data[3*a+1]=h[c.CHAR_DATA_ATTR_INDEX],h[c.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[a]=h[1],this._data[3*a+0]=2097152|a|h[c.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*a+0]=h[c.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|h[c.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(a){return this._data[3*a+0]>>22}hasWidth(a){return 12582912&this._data[3*a+0]}getFg(a){return this._data[3*a+1]}getBg(a){return this._data[3*a+2]}hasContent(a){return 4194303&this._data[3*a+0]}getCodePoint(a){const h=this._data[3*a+0];return 2097152&h?this._combined[a].charCodeAt(this._combined[a].length-1):2097151&h}isCombined(a){return 2097152&this._data[3*a+0]}getString(a){const h=this._data[3*a+0];return 2097152&h?this._combined[a]:2097151&h?(0,g.stringFromCodePoint)(2097151&h):""}isProtected(a){return 536870912&this._data[3*a+2]}loadCell(a,h){return _=3*a,h.content=this._data[_+0],h.fg=this._data[_+1],h.bg=this._data[_+2],2097152&h.content&&(h.combinedData=this._combined[a]),268435456&h.bg&&(h.extended=this._extendedAttrs[a]),h}setCell(a,h){2097152&h.content&&(this._combined[a]=h.combinedData),268435456&h.bg&&(this._extendedAttrs[a]=h.extended),this._data[3*a+0]=h.content,this._data[3*a+1]=h.fg,this._data[3*a+2]=h.bg}setCellFromCodePoint(a,h,d,f,b,w){268435456&b&&(this._extendedAttrs[a]=w),this._data[3*a+0]=h|d<<22,this._data[3*a+1]=f,this._data[3*a+2]=b}addCodepointToCell(a,h){let d=this._data[3*a+0];2097152&d?this._combined[a]+=(0,g.stringFromCodePoint)(h):(2097151&d?(this._combined[a]=(0,g.stringFromCodePoint)(2097151&d)+(0,g.stringFromCodePoint)(h),d&=-2097152,d|=2097152):d=h|4194304,this._data[3*a+0]=d)}insertCells(a,h,d,f){if((a%=this.length)&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs),h<this.length-a){const b=new u.CellData;for(let w=this.length-a-h-1;w>=0;--w)this.setCell(a+h+w,this.loadCell(a+w,b));for(let w=0;w<h;++w)this.setCell(a+w,d)}else for(let b=a;b<this.length;++b)this.setCell(b,d);this.getWidth(this.length-1)===2&&this.setCellFromCodePoint(this.length-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs)}deleteCells(a,h,d,f){if(a%=this.length,h<this.length-a){const b=new u.CellData;for(let w=0;w<this.length-a-h;++w)this.setCell(a+w,this.loadCell(a+h+w,b));for(let w=this.length-h;w<this.length;++w)this.setCell(w,d)}else for(let b=a;b<this.length;++b)this.setCell(b,d);a&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs),this.getWidth(a)!==0||this.hasContent(a)||this.setCellFromCodePoint(a,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs)}replaceCells(a,h,d,f,b=!1){if(b)for(a&&this.getWidth(a-1)===2&&!this.isProtected(a-1)&&this.setCellFromCodePoint(a-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.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 l.ExtendedAttrs);a<h&&a<this.length;)this.isProtected(a)||this.setCell(a,d),a++;else for(a&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs),h<this.length&&this.getWidth(h-1)===2&&this.setCellFromCodePoint(h,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs);a<h&&a<this.length;)this.setCell(a++,d)}resize(a,h){if(a===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const d=3*a;if(a>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<a;++f)this.setCell(f,h)}else{this._data=this._data.subarray(0,d);const f=Object.keys(this._combined);for(let w=0;w<f.length;w++){const k=parseInt(f[w],10);k>=a&&delete this._combined[k]}const b=Object.keys(this._extendedAttrs);for(let w=0;w<b.length;w++){const k=parseInt(b[w],10);k>=a&&delete this._extendedAttrs[k]}}return this.length=a,4*d*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const a=new Uint32Array(this._data.length);return a.set(this._data),this._data=a,1}return 0}fill(a,h=!1){if(h)for(let d=0;d<this.length;++d)this.isProtected(d)||this.setCell(d,a);else{this._combined={},this._extendedAttrs={};for(let d=0;d<this.length;++d)this.setCell(d,a)}}copyFrom(a){this.length!==a.length?this._data=new Uint32Array(a._data):this._data.set(a._data),this.length=a.length,this._combined={};for(const h in a._combined)this._combined[h]=a._combined[h];this._extendedAttrs={};for(const h in a._extendedAttrs)this._extendedAttrs[h]=a._extendedAttrs[h];this.isWrapped=a.isWrapped}clone(){const a=new y(0);a._data=new Uint32Array(this._data),a.length=this.length;for(const h in this._combined)a._combined[h]=this._combined[h];for(const h in this._extendedAttrs)a._extendedAttrs[h]=this._extendedAttrs[h];return a.isWrapped=this.isWrapped,a}getTrimmedLength(){for(let a=this.length-1;a>=0;--a)if(4194303&this._data[3*a+0])return a+(this._data[3*a+0]>>22);return 0}getNoBgTrimmedLength(){for(let a=this.length-1;a>=0;--a)if(4194303&this._data[3*a+0]||50331648&this._data[3*a+2])return a+(this._data[3*a+0]>>22);return 0}copyCellsFrom(a,h,d,f,b){const w=a._data;if(b)for(let j=f-1;j>=0;j--){for(let S=0;S<3;S++)this._data[3*(d+j)+S]=w[3*(h+j)+S];268435456&w[3*(h+j)+2]&&(this._extendedAttrs[d+j]=a._extendedAttrs[h+j])}else for(let j=0;j<f;j++){for(let S=0;S<3;S++)this._data[3*(d+j)+S]=w[3*(h+j)+S];268435456&w[3*(h+j)+2]&&(this._extendedAttrs[d+j]=a._extendedAttrs[h+j])}const k=Object.keys(a._combined);for(let j=0;j<k.length;j++){const S=parseInt(k[j],10);S>=h&&(this._combined[S-h+d]=a._combined[S])}}translateToString(a=!1,h=0,d=this.length){a&&(d=Math.min(d,this.getTrimmedLength()));let f="";for(;h<d;){const b=this._data[3*h+0],w=2097151&b;f+=2097152&b?this._combined[h]:w?(0,g.stringFromCodePoint)(w):c.WHITESPACE_CELL_CHAR,h+=b>>22||1}return f}}i.BufferLine=y},4841:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.getRangeLength=void 0,i.getRangeLength=function(n,l){if(n.start.y>n.end.y)throw new Error(`Buffer range end (${n.end.x}, ${n.end.y}) cannot be before start (${n.start.x}, ${n.start.y})`);return l*(n.end.y-n.start.y)+(n.end.x-n.start.x+1)}},4634:(v,i)=>{function n(l,u,c){if(u===l.length-1)return l[u].getTrimmedLength();const g=!l[u].hasContent(c-1)&&l[u].getWidth(c-1)===1,_=l[u+1].getWidth(0)===2;return g&&_?c-1:c}Object.defineProperty(i,"__esModule",{value:!0}),i.getWrappedLineTrimmedLength=i.reflowSmallerGetNewLineLengths=i.reflowLargerApplyNewLayout=i.reflowLargerCreateNewLayout=i.reflowLargerGetLinesToRemove=void 0,i.reflowLargerGetLinesToRemove=function(l,u,c,g,_){const y=[];for(let x=0;x<l.length-1;x++){let a=x,h=l.get(++a);if(!h.isWrapped)continue;const d=[l.get(x)];for(;a<l.length&&h.isWrapped;)d.push(h),h=l.get(++a);if(g>=x&&g<a){x+=d.length-1;continue}let f=0,b=n(d,f,u),w=1,k=0;for(;w<d.length;){const S=n(d,w,u),E=S-k,R=c-b,L=Math.min(E,R);d[f].copyCellsFrom(d[w],k,b,L,!1),b+=L,b===c&&(f++,b=0),k+=L,k===S&&(w++,k=0),b===0&&f!==0&&d[f-1].getWidth(c-1)===2&&(d[f].copyCellsFrom(d[f-1],c-1,b++,1,!1),d[f-1].setCell(c-1,_))}d[f].replaceCells(b,c,_);let j=0;for(let S=d.length-1;S>0&&(S>f||d[S].getTrimmedLength()===0);S--)j++;j>0&&(y.push(x+d.length-j),y.push(j)),x+=d.length-1}return y},i.reflowLargerCreateNewLayout=function(l,u){const c=[];let g=0,_=u[g],y=0;for(let x=0;x<l.length;x++)if(_===x){const a=u[++g];l.onDeleteEmitter.fire({index:x-y,amount:a}),x+=a-1,y+=a,_=u[++g]}else c.push(x);return{layout:c,countRemoved:y}},i.reflowLargerApplyNewLayout=function(l,u){const c=[];for(let g=0;g<u.length;g++)c.push(l.get(u[g]));for(let g=0;g<c.length;g++)l.set(g,c[g]);l.length=u.length},i.reflowSmallerGetNewLineLengths=function(l,u,c){const g=[],_=l.map(((h,d)=>n(l,d,u))).reduce(((h,d)=>h+d));let y=0,x=0,a=0;for(;a<_;){if(_-a<c){g.push(_-a);break}y+=c;const h=n(l,x,u);y>h&&(y-=h,x++);const d=l[x].getWidth(y-1)===2;d&&y--;const f=d?c-1:c;g.push(f),a+=f}return g},i.getWrappedLineTrimmedLength=n},5295:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferSet=void 0;const l=n(8460),u=n(844),c=n(9092);class g extends u.Disposable{constructor(y,x){super(),this._optionsService=y,this._bufferService=x,this._onBufferActivate=this.register(new l.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(y){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(y),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(y,x){this._normal.resize(y,x),this._alt.resize(y,x),this.setupTabStops(y)}setupTabStops(y){this._normal.setupTabStops(y),this._alt.setupTabStops(y)}}i.BufferSet=g},511:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CellData=void 0;const l=n(482),u=n(643),c=n(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(y){const x=new g;return x.setFromCharData(y),x}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,l.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(y){this.fg=y[u.CHAR_DATA_ATTR_INDEX],this.bg=0;let x=!1;if(y[u.CHAR_DATA_CHAR_INDEX].length>2)x=!0;else if(y[u.CHAR_DATA_CHAR_INDEX].length===2){const a=y[u.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=a&&a<=56319){const h=y[u.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=h&&h<=57343?this.content=1024*(a-55296)+h-56320+65536|y[u.CHAR_DATA_WIDTH_INDEX]<<22:x=!0}else x=!0}else this.content=y[u.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|y[u.CHAR_DATA_WIDTH_INDEX]<<22;x&&(this.combinedData=y[u.CHAR_DATA_CHAR_INDEX],this.content=2097152|y[u.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}i.CellData=g},643:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WHITESPACE_CELL_CODE=i.WHITESPACE_CELL_WIDTH=i.WHITESPACE_CELL_CHAR=i.NULL_CELL_CODE=i.NULL_CELL_WIDTH=i.NULL_CELL_CHAR=i.CHAR_DATA_CODE_INDEX=i.CHAR_DATA_WIDTH_INDEX=i.CHAR_DATA_CHAR_INDEX=i.CHAR_DATA_ATTR_INDEX=i.DEFAULT_EXT=i.DEFAULT_ATTR=i.DEFAULT_COLOR=void 0,i.DEFAULT_COLOR=0,i.DEFAULT_ATTR=256|i.DEFAULT_COLOR<<9,i.DEFAULT_EXT=0,i.CHAR_DATA_ATTR_INDEX=0,i.CHAR_DATA_CHAR_INDEX=1,i.CHAR_DATA_WIDTH_INDEX=2,i.CHAR_DATA_CODE_INDEX=3,i.NULL_CELL_CHAR="",i.NULL_CELL_WIDTH=1,i.NULL_CELL_CODE=0,i.WHITESPACE_CELL_CHAR=" ",i.WHITESPACE_CELL_WIDTH=1,i.WHITESPACE_CELL_CODE=32},4863:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Marker=void 0;const l=n(8460),u=n(844);class c{get id(){return this._id}constructor(_){this.line=_,this.isDisposed=!1,this._disposables=[],this._id=c._nextId++,this._onDispose=this.register(new l.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(_){return this._disposables.push(_),_}}i.Marker=c,c._nextId=1},7116:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DEFAULT_CHARSET=i.CHARSETS=void 0,i.CHARSETS={},i.DEFAULT_CHARSET=i.CHARSETS.B,i.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:"≥","{":"π","|":"≠","}":"£","~":"·"},i.CHARSETS.A={"#":"£"},i.CHARSETS.B=void 0,i.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},i.CHARSETS.C=i.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},i.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},i.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},i.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},i.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},i.CHARSETS.E=i.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},i.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},i.CHARSETS.H=i.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},i.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(v,i)=>{var n,l,u;Object.defineProperty(i,"__esModule",{value:!0}),i.C1_ESCAPED=i.C1=i.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=""})(n||(i.C0=n={})),(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=""})(l||(i.C1=l={})),(function(c){c.ST=`${n.ESC}\\`})(u||(i.C1_ESCAPED=u={}))},7399:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.evaluateKeyboardEvent=void 0;const l=n(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:["'",'"']};i.evaluateKeyboardEvent=function(c,g,_,y){const x={type:0,cancel:!1,key:void 0},a=(c.shiftKey?1:0)|(c.altKey?2:0)|(c.ctrlKey?4:0)|(c.metaKey?8:0);switch(c.keyCode){case 0:c.key==="UIKeyInputUpArrow"?x.key=g?l.C0.ESC+"OA":l.C0.ESC+"[A":c.key==="UIKeyInputLeftArrow"?x.key=g?l.C0.ESC+"OD":l.C0.ESC+"[D":c.key==="UIKeyInputRightArrow"?x.key=g?l.C0.ESC+"OC":l.C0.ESC+"[C":c.key==="UIKeyInputDownArrow"&&(x.key=g?l.C0.ESC+"OB":l.C0.ESC+"[B");break;case 8:if(c.altKey){x.key=l.C0.ESC+l.C0.DEL;break}x.key=l.C0.DEL;break;case 9:if(c.shiftKey){x.key=l.C0.ESC+"[Z";break}x.key=l.C0.HT,x.cancel=!0;break;case 13:x.key=c.altKey?l.C0.ESC+l.C0.CR:l.C0.CR,x.cancel=!0;break;case 27:x.key=l.C0.ESC,c.altKey&&(x.key=l.C0.ESC+l.C0.ESC),x.cancel=!0;break;case 37:if(c.metaKey)break;a?(x.key=l.C0.ESC+"[1;"+(a+1)+"D",x.key===l.C0.ESC+"[1;3D"&&(x.key=l.C0.ESC+(_?"b":"[1;5D"))):x.key=g?l.C0.ESC+"OD":l.C0.ESC+"[D";break;case 39:if(c.metaKey)break;a?(x.key=l.C0.ESC+"[1;"+(a+1)+"C",x.key===l.C0.ESC+"[1;3C"&&(x.key=l.C0.ESC+(_?"f":"[1;5C"))):x.key=g?l.C0.ESC+"OC":l.C0.ESC+"[C";break;case 38:if(c.metaKey)break;a?(x.key=l.C0.ESC+"[1;"+(a+1)+"A",_||x.key!==l.C0.ESC+"[1;3A"||(x.key=l.C0.ESC+"[1;5A")):x.key=g?l.C0.ESC+"OA":l.C0.ESC+"[A";break;case 40:if(c.metaKey)break;a?(x.key=l.C0.ESC+"[1;"+(a+1)+"B",_||x.key!==l.C0.ESC+"[1;3B"||(x.key=l.C0.ESC+"[1;5B")):x.key=g?l.C0.ESC+"OB":l.C0.ESC+"[B";break;case 45:c.shiftKey||c.ctrlKey||(x.key=l.C0.ESC+"[2~");break;case 46:x.key=a?l.C0.ESC+"[3;"+(a+1)+"~":l.C0.ESC+"[3~";break;case 36:x.key=a?l.C0.ESC+"[1;"+(a+1)+"H":g?l.C0.ESC+"OH":l.C0.ESC+"[H";break;case 35:x.key=a?l.C0.ESC+"[1;"+(a+1)+"F":g?l.C0.ESC+"OF":l.C0.ESC+"[F";break;case 33:c.shiftKey?x.type=2:c.ctrlKey?x.key=l.C0.ESC+"[5;"+(a+1)+"~":x.key=l.C0.ESC+"[5~";break;case 34:c.shiftKey?x.type=3:c.ctrlKey?x.key=l.C0.ESC+"[6;"+(a+1)+"~":x.key=l.C0.ESC+"[6~";break;case 112:x.key=a?l.C0.ESC+"[1;"+(a+1)+"P":l.C0.ESC+"OP";break;case 113:x.key=a?l.C0.ESC+"[1;"+(a+1)+"Q":l.C0.ESC+"OQ";break;case 114:x.key=a?l.C0.ESC+"[1;"+(a+1)+"R":l.C0.ESC+"OR";break;case 115:x.key=a?l.C0.ESC+"[1;"+(a+1)+"S":l.C0.ESC+"OS";break;case 116:x.key=a?l.C0.ESC+"[15;"+(a+1)+"~":l.C0.ESC+"[15~";break;case 117:x.key=a?l.C0.ESC+"[17;"+(a+1)+"~":l.C0.ESC+"[17~";break;case 118:x.key=a?l.C0.ESC+"[18;"+(a+1)+"~":l.C0.ESC+"[18~";break;case 119:x.key=a?l.C0.ESC+"[19;"+(a+1)+"~":l.C0.ESC+"[19~";break;case 120:x.key=a?l.C0.ESC+"[20;"+(a+1)+"~":l.C0.ESC+"[20~";break;case 121:x.key=a?l.C0.ESC+"[21;"+(a+1)+"~":l.C0.ESC+"[21~";break;case 122:x.key=a?l.C0.ESC+"[23;"+(a+1)+"~":l.C0.ESC+"[23~";break;case 123:x.key=a?l.C0.ESC+"[24;"+(a+1)+"~":l.C0.ESC+"[24~";break;default:if(!c.ctrlKey||c.shiftKey||c.altKey||c.metaKey)if(_&&!y||!c.altKey||c.metaKey)!_||c.altKey||c.ctrlKey||c.shiftKey||!c.metaKey?c.key&&!c.ctrlKey&&!c.altKey&&!c.metaKey&&c.keyCode>=48&&c.key.length===1?x.key=c.key:c.key&&c.ctrlKey&&(c.key==="_"&&(x.key=l.C0.US),c.key==="@"&&(x.key=l.C0.NUL)):c.keyCode===65&&(x.type=1);else{const h=u[c.keyCode],d=h?.[c.shiftKey?1:0];if(d)x.key=l.C0.ESC+d;else if(c.keyCode>=65&&c.keyCode<=90){const f=c.ctrlKey?c.keyCode-64:c.keyCode+32;let b=String.fromCharCode(f);c.shiftKey&&(b=b.toUpperCase()),x.key=l.C0.ESC+b}else if(c.keyCode===32)x.key=l.C0.ESC+(c.ctrlKey?l.C0.NUL:" ");else if(c.key==="Dead"&&c.code.startsWith("Key")){let f=c.code.slice(3,4);c.shiftKey||(f=f.toLowerCase()),x.key=l.C0.ESC+f,x.cancel=!0}}else c.keyCode>=65&&c.keyCode<=90?x.key=String.fromCharCode(c.keyCode-64):c.keyCode===32?x.key=l.C0.NUL:c.keyCode>=51&&c.keyCode<=55?x.key=String.fromCharCode(c.keyCode-51+27):c.keyCode===56?x.key=l.C0.DEL:c.keyCode===219?x.key=l.C0.ESC:c.keyCode===220?x.key=l.C0.FS:c.keyCode===221&&(x.key=l.C0.GS)}return x}},482:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Utf8ToUtf32=i.StringToUtf32=i.utf32ToString=i.stringFromCodePoint=void 0,i.stringFromCodePoint=function(n){return n>65535?(n-=65536,String.fromCharCode(55296+(n>>10))+String.fromCharCode(n%1024+56320)):String.fromCharCode(n)},i.utf32ToString=function(n,l=0,u=n.length){let c="";for(let g=l;g<u;++g){let _=n[g];_>65535?(_-=65536,c+=String.fromCharCode(55296+(_>>10))+String.fromCharCode(_%1024+56320)):c+=String.fromCharCode(_)}return c},i.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(n,l){const u=n.length;if(!u)return 0;let c=0,g=0;if(this._interim){const _=n.charCodeAt(g++);56320<=_&&_<=57343?l[c++]=1024*(this._interim-55296)+_-56320+65536:(l[c++]=this._interim,l[c++]=_),this._interim=0}for(let _=g;_<u;++_){const y=n.charCodeAt(_);if(55296<=y&&y<=56319){if(++_>=u)return this._interim=y,c;const x=n.charCodeAt(_);56320<=x&&x<=57343?l[c++]=1024*(y-55296)+x-56320+65536:(l[c++]=y,l[c++]=x)}else y!==65279&&(l[c++]=y)}return c}},i.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(n,l){const u=n.length;if(!u)return 0;let c,g,_,y,x=0,a=0,h=0;if(this.interim[0]){let b=!1,w=this.interim[0];w&=(224&w)==192?31:(240&w)==224?15:7;let k,j=0;for(;(k=63&this.interim[++j])&&j<4;)w<<=6,w|=k;const S=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,E=S-j;for(;h<E;){if(h>=u)return 0;if(k=n[h++],(192&k)!=128){h--,b=!0;break}this.interim[j++]=k,w<<=6,w|=63&k}b||(S===2?w<128?h--:l[x++]=w:S===3?w<2048||w>=55296&&w<=57343||w===65279||(l[x++]=w):w<65536||w>1114111||(l[x++]=w)),this.interim.fill(0)}const d=u-4;let f=h;for(;f<u;){for(;!(!(f<d)||128&(c=n[f])||128&(g=n[f+1])||128&(_=n[f+2])||128&(y=n[f+3]));)l[x++]=c,l[x++]=g,l[x++]=_,l[x++]=y,f+=4;if(c=n[f++],c<128)l[x++]=c;else if((224&c)==192){if(f>=u)return this.interim[0]=c,x;if(g=n[f++],(192&g)!=128){f--;continue}if(a=(31&c)<<6|63&g,a<128){f--;continue}l[x++]=a}else if((240&c)==224){if(f>=u)return this.interim[0]=c,x;if(g=n[f++],(192&g)!=128){f--;continue}if(f>=u)return this.interim[0]=c,this.interim[1]=g,x;if(_=n[f++],(192&_)!=128){f--;continue}if(a=(15&c)<<12|(63&g)<<6|63&_,a<2048||a>=55296&&a<=57343||a===65279)continue;l[x++]=a}else if((248&c)==240){if(f>=u)return this.interim[0]=c,x;if(g=n[f++],(192&g)!=128){f--;continue}if(f>=u)return this.interim[0]=c,this.interim[1]=g,x;if(_=n[f++],(192&_)!=128){f--;continue}if(f>=u)return this.interim[0]=c,this.interim[1]=g,this.interim[2]=_,x;if(y=n[f++],(192&y)!=128){f--;continue}if(a=(7&c)<<18|(63&g)<<12|(63&_)<<6|63&y,a<65536||a>1114111)continue;l[x++]=a}}return x}}},225:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeV6=void 0;const n=[[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]],l=[[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;i.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<n.length;++c)u.fill(0,n[c][0],n[c][1]+1)}}wcwidth(c){return c<32?0:c<127?1:c<65536?u[c]:(function(g,_){let y,x=0,a=_.length-1;if(g<_[0][0]||g>_[a][1])return!1;for(;a>=x;)if(y=x+a>>1,g>_[y][1])x=y+1;else{if(!(g<_[y][0]))return!0;a=y-1}return!1})(c,l)?0:c>=131072&&c<=196605||c>=196608&&c<=262141?2:1}}},5981:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WriteBuffer=void 0;const l=n(8460),u=n(844);class c extends u.Disposable{constructor(_){super(),this._action=_,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new l.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(_,y){if(y!==void 0&&this._syncCalls>y)return void(this._syncCalls=0);if(this._pendingData+=_.length,this._writeBuffer.push(_),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let x;for(this._isSyncWriting=!0;x=this._writeBuffer.shift();){this._action(x);const a=this._callbacks.shift();a&&a()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(_,y){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=_.length,this._writeBuffer.push(_),this._callbacks.push(y),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=_.length,this._writeBuffer.push(_),this._callbacks.push(y)}_innerWrite(_=0,y=!0){const x=_||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const a=this._writeBuffer[this._bufferOffset],h=this._action(a,y);if(h){const f=b=>Date.now()-x>=12?setTimeout((()=>this._innerWrite(0,b))):this._innerWrite(x,b);return void h.catch((b=>(queueMicrotask((()=>{throw b})),Promise.resolve(!1)))).then(f)}const d=this._callbacks[this._bufferOffset];if(d&&d(),this._bufferOffset++,this._pendingData-=a.length,Date.now()-x>=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()}}i.WriteBuffer=c},5941:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.toRgbString=i.parseColor=void 0;const n=/^([\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})$/,l=/^[\da-f]+$/;function u(c,g){const _=c.toString(16),y=_.length<2?"0"+_:_;switch(g){case 4:return _[0];case 8:return y;case 12:return(y+y).slice(0,3);default:return y+y}}i.parseColor=function(c){if(!c)return;let g=c.toLowerCase();if(g.indexOf("rgb:")===0){g=g.slice(4);const _=n.exec(g);if(_){const y=_[1]?15:_[4]?255:_[7]?4095:65535;return[Math.round(parseInt(_[1]||_[4]||_[7]||_[10],16)/y*255),Math.round(parseInt(_[2]||_[5]||_[8]||_[11],16)/y*255),Math.round(parseInt(_[3]||_[6]||_[9]||_[12],16)/y*255)]}}else if(g.indexOf("#")===0&&(g=g.slice(1),l.exec(g)&&[3,6,9,12].includes(g.length))){const _=g.length/3,y=[0,0,0];for(let x=0;x<3;++x){const a=parseInt(g.slice(_*x,_*x+_),16);y[x]=_===1?a<<4:_===2?a:_===3?a>>4:a>>8}return y}},i.toRgbString=function(c,g=16){const[_,y,x]=c;return`rgb:${u(_,g)}/${u(y,g)}/${u(x,g)}`}},5770:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.PAYLOAD_LIMIT=void 0,i.PAYLOAD_LIMIT=1e7},6351:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DcsHandler=i.DcsParser=void 0;const l=n(482),u=n(8742),c=n(5770),g=[];i.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=g,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=g}registerHandler(y,x){this._handlers[y]===void 0&&(this._handlers[y]=[]);const a=this._handlers[y];return a.push(x),{dispose:()=>{const h=a.indexOf(x);h!==-1&&a.splice(h,1)}}}clearHandler(y){this._handlers[y]&&delete this._handlers[y]}setHandlerFallback(y){this._handlerFb=y}reset(){if(this._active.length)for(let y=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;y>=0;--y)this._active[y].unhook(!1);this._stack.paused=!1,this._active=g,this._ident=0}hook(y,x){if(this.reset(),this._ident=y,this._active=this._handlers[y]||g,this._active.length)for(let a=this._active.length-1;a>=0;a--)this._active[a].hook(x);else this._handlerFb(this._ident,"HOOK",x)}put(y,x,a){if(this._active.length)for(let h=this._active.length-1;h>=0;h--)this._active[h].put(y,x,a);else this._handlerFb(this._ident,"PUT",(0,l.utf32ToString)(y,x,a))}unhook(y,x=!0){if(this._active.length){let a=!1,h=this._active.length-1,d=!1;if(this._stack.paused&&(h=this._stack.loopPosition-1,a=x,d=this._stack.fallThrough,this._stack.paused=!1),!d&&a===!1){for(;h>=0&&(a=this._active[h].unhook(y),a!==!0);h--)if(a instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=h,this._stack.fallThrough=!1,a;h--}for(;h>=0;h--)if(a=this._active[h].unhook(!1),a instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=h,this._stack.fallThrough=!0,a}else this._handlerFb(this._ident,"UNHOOK",y);this._active=g,this._ident=0}};const _=new u.Params;_.addParam(0),i.DcsHandler=class{constructor(y){this._handler=y,this._data="",this._params=_,this._hitLimit=!1}hook(y){this._params=y.length>1||y.params[0]?y.clone():_,this._data="",this._hitLimit=!1}put(y,x,a){this._hitLimit||(this._data+=(0,l.utf32ToString)(y,x,a),this._data.length>c.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(y){let x=!1;if(this._hitLimit)x=!1;else if(y&&(x=this._handler(this._data,this._params),x instanceof Promise))return x.then((a=>(this._params=_,this._data="",this._hitLimit=!1,a)));return this._params=_,this._data="",this._hitLimit=!1,x}}},2015:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.EscapeSequenceParser=i.VT500_TRANSITION_TABLE=i.TransitionTable=void 0;const l=n(844),u=n(8742),c=n(6242),g=n(6351);class _{constructor(h){this.table=new Uint8Array(h)}setDefault(h,d){this.table.fill(h<<4|d)}add(h,d,f,b){this.table[d<<8|h]=f<<4|b}addMany(h,d,f,b){for(let w=0;w<h.length;w++)this.table[d<<8|h[w]]=f<<4|b}}i.TransitionTable=_;const y=160;i.VT500_TRANSITION_TABLE=(function(){const a=new _(4095),h=Array.apply(null,Array(256)).map(((j,S)=>S)),d=(j,S)=>h.slice(j,S),f=d(32,127),b=d(0,24);b.push(25),b.push.apply(b,d(28,32));const w=d(0,14);let k;for(k in a.setDefault(1,0),a.addMany(f,0,2,0),w)a.addMany([24,26,153,154],k,3,0),a.addMany(d(128,144),k,3,0),a.addMany(d(144,152),k,3,0),a.add(156,k,0,0),a.add(27,k,11,1),a.add(157,k,4,8),a.addMany([152,158,159],k,0,7),a.add(155,k,11,3),a.add(144,k,11,9);return a.addMany(b,0,3,0),a.addMany(b,1,3,1),a.add(127,1,0,1),a.addMany(b,8,0,8),a.addMany(b,3,3,3),a.add(127,3,0,3),a.addMany(b,4,3,4),a.add(127,4,0,4),a.addMany(b,6,3,6),a.addMany(b,5,3,5),a.add(127,5,0,5),a.addMany(b,2,3,2),a.add(127,2,0,2),a.add(93,1,4,8),a.addMany(f,8,5,8),a.add(127,8,5,8),a.addMany([156,27,24,26,7],8,6,0),a.addMany(d(28,32),8,0,8),a.addMany([88,94,95],1,0,7),a.addMany(f,7,0,7),a.addMany(b,7,0,7),a.add(156,7,0,0),a.add(127,7,0,7),a.add(91,1,11,3),a.addMany(d(64,127),3,7,0),a.addMany(d(48,60),3,8,4),a.addMany([60,61,62,63],3,9,4),a.addMany(d(48,60),4,8,4),a.addMany(d(64,127),4,7,0),a.addMany([60,61,62,63],4,0,6),a.addMany(d(32,64),6,0,6),a.add(127,6,0,6),a.addMany(d(64,127),6,0,0),a.addMany(d(32,48),3,9,5),a.addMany(d(32,48),5,9,5),a.addMany(d(48,64),5,0,6),a.addMany(d(64,127),5,7,0),a.addMany(d(32,48),4,9,5),a.addMany(d(32,48),1,9,2),a.addMany(d(32,48),2,9,2),a.addMany(d(48,127),2,10,0),a.addMany(d(48,80),1,10,0),a.addMany(d(81,88),1,10,0),a.addMany([89,90,92],1,10,0),a.addMany(d(96,127),1,10,0),a.add(80,1,11,9),a.addMany(b,9,0,9),a.add(127,9,0,9),a.addMany(d(28,32),9,0,9),a.addMany(d(32,48),9,9,12),a.addMany(d(48,60),9,8,10),a.addMany([60,61,62,63],9,9,10),a.addMany(b,11,0,11),a.addMany(d(32,128),11,0,11),a.addMany(d(28,32),11,0,11),a.addMany(b,10,0,10),a.add(127,10,0,10),a.addMany(d(28,32),10,0,10),a.addMany(d(48,60),10,8,10),a.addMany([60,61,62,63],10,0,11),a.addMany(d(32,48),10,9,12),a.addMany(b,12,0,12),a.add(127,12,0,12),a.addMany(d(28,32),12,0,12),a.addMany(d(32,48),12,9,12),a.addMany(d(48,64),12,0,11),a.addMany(d(64,127),12,12,13),a.addMany(d(64,127),10,12,13),a.addMany(d(64,127),9,12,13),a.addMany(b,13,13,13),a.addMany(f,13,13,13),a.add(127,13,0,13),a.addMany([27,156,24,26],13,14,0),a.add(y,0,2,0),a.add(y,8,5,8),a.add(y,6,0,6),a.add(y,11,0,11),a.add(y,13,13,13),a})();class x extends l.Disposable{constructor(h=i.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,b)=>{},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,l.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 w=0;w<h.intermediates.length;++w){const k=h.intermediates.charCodeAt(w);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 b=h.final.charCodeAt(0);if(d[0]>b||b>d[1])throw new Error(`final must be in range ${d[0]} .. ${d[1]}`);return f<<=8,f|=b,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 b=this._escHandlers[f];return b.push(d),{dispose:()=>{const w=b.indexOf(d);w!==-1&&b.splice(w,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 b=this._csiHandlers[f];return b.push(d),{dispose:()=>{const w=b.indexOf(d);w!==-1&&b.splice(w,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,b,w){this._parseStack.state=h,this._parseStack.handlers=d,this._parseStack.handlerPos=f,this._parseStack.transition=b,this._parseStack.chunkPos=w}parse(h,d,f){let b,w=0,k=0,j=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,j=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 S=this._parseStack.handlers;let E=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(f===!1&&E>-1){for(;E>=0&&(b=S[E](this._params),b!==!0);E--)if(b instanceof Promise)return this._parseStack.handlerPos=E,b}this._parseStack.handlers=[];break;case 4:if(f===!1&&E>-1){for(;E>=0&&(b=S[E](),b!==!0);E--)if(b instanceof Promise)return this._parseStack.handlerPos=E,b}this._parseStack.handlers=[];break;case 6:if(w=h[this._parseStack.chunkPos],b=this._dcsParser.unhook(w!==24&&w!==26,f),b)return b;w===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(w=h[this._parseStack.chunkPos],b=this._oscParser.end(w!==24&&w!==26,f),b)return b;w===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,j=this._parseStack.chunkPos+1,this.precedingCodepoint=0,this.currentState=15&this._parseStack.transition}for(let S=j;S<d;++S){switch(w=h[S],k=this._transitions.table[this.currentState<<8|(w<160?w:y)],k>>4){case 2:for(let A=S+1;;++A){if(A>=d||(w=h[A])<32||w>126&&w<y){this._printHandler(h,S,A),S=A-1;break}if(++A>=d||(w=h[A])<32||w>126&&w<y){this._printHandler(h,S,A),S=A-1;break}if(++A>=d||(w=h[A])<32||w>126&&w<y){this._printHandler(h,S,A),S=A-1;break}if(++A>=d||(w=h[A])<32||w>126&&w<y){this._printHandler(h,S,A),S=A-1;break}}break;case 3:this._executeHandlers[w]?this._executeHandlers[w]():this._executeHandlerFb(w),this.precedingCodepoint=0;break;case 0:break;case 1:if(this._errorHandler({position:S,code:w,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const E=this._csiHandlers[this._collect<<8|w];let R=E?E.length-1:-1;for(;R>=0&&(b=E[R](this._params),b!==!0);R--)if(b instanceof Promise)return this._preserveStack(3,E,R,k,S),b;R<0&&this._csiHandlerFb(this._collect<<8|w,this._params),this.precedingCodepoint=0;break;case 8:do switch(w){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(w-48)}while(++S<d&&(w=h[S])>47&&w<60);S--;break;case 9:this._collect<<=8,this._collect|=w;break;case 10:const L=this._escHandlers[this._collect<<8|w];let T=L?L.length-1:-1;for(;T>=0&&(b=L[T](),b!==!0);T--)if(b instanceof Promise)return this._preserveStack(4,L,T,k,S),b;T<0&&this._escHandlerFb(this._collect<<8|w),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|w,this._params);break;case 13:for(let A=S+1;;++A)if(A>=d||(w=h[A])===24||w===26||w===27||w>127&&w<y){this._dcsParser.put(h,S,A),S=A-1;break}break;case 14:if(b=this._dcsParser.unhook(w!==24&&w!==26),b)return this._preserveStack(6,[],0,k,S),b;w===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 A=S+1;;A++)if(A>=d||(w=h[A])<32||w>127&&w<y){this._oscParser.put(h,S,A),S=A-1;break}break;case 6:if(b=this._oscParser.end(w!==24&&w!==26),b)return this._preserveStack(5,[],0,k,S),b;w===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0}this.currentState=15&k}}}i.EscapeSequenceParser=x},6242:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.OscHandler=i.OscParser=void 0;const l=n(5770),u=n(482),c=[];i.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,_){this._handlers[g]===void 0&&(this._handlers[g]=[]);const y=this._handlers[g];return y.push(_),{dispose:()=>{const x=y.indexOf(_);x!==-1&&y.splice(x,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,_,y){if(this._active.length)for(let x=this._active.length-1;x>=0;x--)this._active[x].put(g,_,y);else this._handlerFb(this._id,"PUT",(0,u.utf32ToString)(g,_,y))}start(){this.reset(),this._state=1}put(g,_,y){if(this._state!==3){if(this._state===1)for(;_<y;){const x=g[_++];if(x===59){this._state=2,this._start();break}if(x<48||57<x)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+x-48}this._state===2&&y-_>0&&this._put(g,_,y)}}end(g,_=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let y=!1,x=this._active.length-1,a=!1;if(this._stack.paused&&(x=this._stack.loopPosition-1,y=_,a=this._stack.fallThrough,this._stack.paused=!1),!a&&y===!1){for(;x>=0&&(y=this._active[x].end(g),y!==!0);x--)if(y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=x,this._stack.fallThrough=!1,y;x--}for(;x>=0;x--)if(y=this._active[x].end(!1),y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=x,this._stack.fallThrough=!0,y}else this._handlerFb(this._id,"END",g);this._active=c,this._id=-1,this._state=0}}},i.OscHandler=class{constructor(g){this._handler=g,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(g,_,y){this._hitLimit||(this._data+=(0,u.utf32ToString)(g,_,y),this._data.length>l.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(g){let _=!1;if(this._hitLimit)_=!1;else if(g&&(_=this._handler(this._data),_ instanceof Promise))return _.then((y=>(this._data="",this._hitLimit=!1,y)));return this._data="",this._hitLimit=!1,_}}},8742:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Params=void 0;const n=2147483647;class l{static fromArray(c){const g=new l;if(!c.length)return g;for(let _=Array.isArray(c[0])?1:0;_<c.length;++_){const y=c[_];if(Array.isArray(y))for(let x=0;x<y.length;++x)g.addSubParam(y[x]);else g.addParam(y)}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 l(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 _=this._subParamsIdx[g]>>8,y=255&this._subParamsIdx[g];y-_>0&&c.push(Array.prototype.slice.call(this._subParams,_,y))}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>n?n: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>n?n: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,_=255&this._subParamsIdx[c];return _-g>0?this._subParams.subarray(g,_):null}getSubParamsAll(){const c={};for(let g=0;g<this.length;++g){const _=this._subParamsIdx[g]>>8,y=255&this._subParamsIdx[g];y-_>0&&(c[g]=this._subParams.slice(_,y))}return c}addDigit(c){let g;if(this._rejectDigits||!(g=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const _=this._digitIsSub?this._subParams:this.params,y=_[g-1];_[g-1]=~y?Math.min(10*y+c,n):c}}i.Params=l},5741:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.AddonManager=void 0,i.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let n=this._addons.length-1;n>=0;n--)this._addons[n].instance.dispose()}loadAddon(n,l){const u={instance:l,dispose:l.dispose,isDisposed:!1};this._addons.push(u),l.dispose=()=>this._wrappedAddonDispose(u),l.activate(n)}_wrappedAddonDispose(n){if(n.isDisposed)return;let l=-1;for(let u=0;u<this._addons.length;u++)if(this._addons[u]===n){l=u;break}if(l===-1)throw new Error("Could not dispose an addon that has not been loaded");n.isDisposed=!0,n.dispose.apply(n.instance),this._addons.splice(l,1)}}},8771:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferApiView=void 0;const l=n(3785),u=n(511);i.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 l.BufferLineApiView(g)}getNullCell(){return new u.CellData}}},3785:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferLineApiView=void 0;const l=n(511);i.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 l.CellData)}translateToString(u,c,g){return this._line.translateToString(u,c,g)}}},8285:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferNamespaceApi=void 0;const l=n(8771),u=n(8460),c=n(844);class g extends c.Disposable{constructor(y){super(),this._core=y,this._onBufferChange=this.register(new u.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new l.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new l.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)}}i.BufferNamespaceApi=g},7975:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ParserApi=void 0,i.ParserApi=class{constructor(n){this._core=n}registerCsiHandler(n,l){return this._core.registerCsiHandler(n,(u=>l(u.toArray())))}addCsiHandler(n,l){return this.registerCsiHandler(n,l)}registerDcsHandler(n,l){return this._core.registerDcsHandler(n,((u,c)=>l(u,c.toArray())))}addDcsHandler(n,l){return this.registerDcsHandler(n,l)}registerEscHandler(n,l){return this._core.registerEscHandler(n,l)}addEscHandler(n,l){return this.registerEscHandler(n,l)}registerOscHandler(n,l){return this._core.registerOscHandler(n,l)}addOscHandler(n,l){return this.registerOscHandler(n,l)}}},7090:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeApi=void 0,i.UnicodeApi=class{constructor(n){this._core=n}register(n){this._core.unicodeService.register(n)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(n){this._core.unicodeService.activeVersion=n}}},744:function(v,i,n){var l=this&&this.__decorate||function(a,h,d,f){var b,w=arguments.length,k=w<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,f);else for(var j=a.length-1;j>=0;j--)(b=a[j])&&(k=(w<3?b(k):w>3?b(h,d,k):b(h,d))||k);return w>3&&k&&Object.defineProperty(h,d,k),k},u=this&&this.__param||function(a,h){return function(d,f){h(d,f,a)}};Object.defineProperty(i,"__esModule",{value:!0}),i.BufferService=i.MINIMUM_ROWS=i.MINIMUM_COLS=void 0;const c=n(8460),g=n(844),_=n(5295),y=n(2585);i.MINIMUM_COLS=2,i.MINIMUM_ROWS=1;let x=i.BufferService=class extends g.Disposable{get buffer(){return this.buffers.active}constructor(a){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(a.rawOptions.cols||0,i.MINIMUM_COLS),this.rows=Math.max(a.rawOptions.rows||0,i.MINIMUM_ROWS),this.buffers=this.register(new _.BufferSet(a,this))}resize(a,h){this.cols=a,this.rows=h,this.buffers.resize(a,h),this._onResize.fire({cols:a,rows:h})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(a,h=!1){const d=this.buffer;let f;f=this._cachedBlankLine,f&&f.length===this.cols&&f.getFg(0)===a.fg&&f.getBg(0)===a.bg||(f=d.getBlankLine(a,h),this._cachedBlankLine=f),f.isWrapped=h;const b=d.ybase+d.scrollTop,w=d.ybase+d.scrollBottom;if(d.scrollTop===0){const k=d.lines.isFull;w===d.lines.length-1?k?d.lines.recycle().copyFrom(f):d.lines.push(f.clone()):d.lines.splice(w+1,0,f.clone()),k?this.isUserScrolling&&(d.ydisp=Math.max(d.ydisp-1,0)):(d.ybase++,this.isUserScrolling||d.ydisp++)}else{const k=w-b+1;d.lines.shiftElements(b+1,k-1,-1),d.lines.set(w,f.clone())}this.isUserScrolling||(d.ydisp=d.ybase),this._onScroll.fire(d.ydisp)}scrollLines(a,h,d){const f=this.buffer;if(a<0){if(f.ydisp===0)return;this.isUserScrolling=!0}else a+f.ydisp>=f.ybase&&(this.isUserScrolling=!1);const b=f.ydisp;f.ydisp=Math.max(Math.min(f.ydisp+a,f.ybase),0),b!==f.ydisp&&(h||this._onScroll.fire(f.ydisp))}};i.BufferService=x=l([u(0,y.IOptionsService)],x)},7994:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CharsetService=void 0,i.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(n){this.glevel=n,this.charset=this._charsets[n]}setgCharset(n,l){this._charsets[n]=l,this.glevel===n&&(this.charset=l)}}},1753:function(v,i,n){var l=this&&this.__decorate||function(f,b,w,k){var j,S=arguments.length,E=S<3?b:k===null?k=Object.getOwnPropertyDescriptor(b,w):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(f,b,w,k);else for(var R=f.length-1;R>=0;R--)(j=f[R])&&(E=(S<3?j(E):S>3?j(b,w,E):j(b,w))||E);return S>3&&E&&Object.defineProperty(b,w,E),E},u=this&&this.__param||function(f,b){return function(w,k){b(w,k,f)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CoreMouseService=void 0;const c=n(2585),g=n(8460),_=n(844),y={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 x(f,b){let w=(f.ctrl?16:0)|(f.shift?4:0)|(f.alt?8:0);return f.button===4?(w|=64,w|=f.action):(w|=3&f.button,4&f.button&&(w|=64),8&f.button&&(w|=128),f.action===32?w|=32:f.action!==0||b||(w|=3)),w}const a=String.fromCharCode,h={DEFAULT:f=>{const b=[x(f,!1)+32,f.col+32,f.row+32];return b[0]>255||b[1]>255||b[2]>255?"":`\x1B[M${a(b[0])}${a(b[1])}${a(b[2])}`},SGR:f=>{const b=f.action===0&&f.button!==4?"m":"M";return`\x1B[<${x(f,!0)};${f.col};${f.row}${b}`},SGR_PIXELS:f=>{const b=f.action===0&&f.button!==4?"m":"M";return`\x1B[<${x(f,!0)};${f.x};${f.y}${b}`}};let d=i.CoreMouseService=class extends _.Disposable{constructor(f,b){super(),this._bufferService=f,this._coreService=b,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 w of Object.keys(y))this.addProtocol(w,y[w]);for(const w of Object.keys(h))this.addEncoding(w,h[w]);this.reset()}addProtocol(f,b){this._protocols[f]=b}addEncoding(f,b){this._encodings[f]=b}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 b=this._encodings[this._activeEncoding](f);return b&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(b):this._coreService.triggerDataEvent(b,!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,b,w){if(w){if(f.x!==b.x||f.y!==b.y)return!1}else if(f.col!==b.col||f.row!==b.row)return!1;return f.button===b.button&&f.action===b.action&&f.ctrl===b.ctrl&&f.alt===b.alt&&f.shift===b.shift}};i.CoreMouseService=d=l([u(0,c.IBufferService),u(1,c.ICoreService)],d)},6975:function(v,i,n){var l=this&&this.__decorate||function(d,f,b,w){var k,j=arguments.length,S=j<3?f:w===null?w=Object.getOwnPropertyDescriptor(f,b):w;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(d,f,b,w);else for(var E=d.length-1;E>=0;E--)(k=d[E])&&(S=(j<3?k(S):j>3?k(f,b,S):k(f,b))||S);return j>3&&S&&Object.defineProperty(f,b,S),S},u=this&&this.__param||function(d,f){return function(b,w){f(b,w,d)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CoreService=void 0;const c=n(1439),g=n(8460),_=n(844),y=n(2585),x=Object.freeze({insertMode:!1}),a=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let h=i.CoreService=class extends _.Disposable{constructor(d,f,b){super(),this._bufferService=d,this._logService=f,this._optionsService=b,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)(x),this.decPrivateModes=(0,c.clone)(a)}reset(){this.modes=(0,c.clone)(x),this.decPrivateModes=(0,c.clone)(a)}triggerDataEvent(d,f=!1){if(this._optionsService.rawOptions.disableStdin)return;const b=this._bufferService.buffer;f&&this._optionsService.rawOptions.scrollOnUserInput&&b.ybase!==b.ydisp&&this._onRequestScrollToBottom.fire(),f&&this._onUserInput.fire(),this._logService.debug(`sending data "${d}"`,(()=>d.split("").map((w=>w.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))}};i.CoreService=h=l([u(0,y.IBufferService),u(1,y.ILogService),u(2,y.IOptionsService)],h)},9074:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DecorationService=void 0;const l=n(8055),u=n(8460),c=n(844),g=n(6106);let _=0,y=0;class x 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 a(d);if(f){const b=f.marker.onDispose((()=>f.dispose()));f.onDispose((()=>{f&&(this._decorations.delete(f)&&this._onDecorationRemoved.fire(f),b.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,b){var w,k,j;let S=0,E=0;for(const R of this._decorations.getKeyIterator(f))S=(w=R.options.x)!==null&&w!==void 0?w:0,E=S+((k=R.options.width)!==null&&k!==void 0?k:1),d>=S&&d<E&&(!b||((j=R.options.layer)!==null&&j!==void 0?j:"bottom")===b)&&(yield R)}forEachDecorationAtCell(d,f,b,w){this._decorations.forEachByKey(f,(k=>{var j,S,E;_=(j=k.options.x)!==null&&j!==void 0?j:0,y=_+((S=k.options.width)!==null&&S!==void 0?S:1),d>=_&&d<y&&(!b||((E=k.options.layer)!==null&&E!==void 0?E:"bottom")===b)&&w(k)}))}}i.DecorationService=x;class a extends c.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=l.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=l.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,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.InstantiationService=i.ServiceCollection=void 0;const l=n(2585),u=n(8343);class c{constructor(..._){this._entries=new Map;for(const[y,x]of _)this.set(y,x)}set(_,y){const x=this._entries.get(_);return this._entries.set(_,y),x}forEach(_){for(const[y,x]of this._entries.entries())_(y,x)}has(_){return this._entries.has(_)}get(_){return this._entries.get(_)}}i.ServiceCollection=c,i.InstantiationService=class{constructor(){this._services=new c,this._services.set(l.IInstantiationService,this)}setService(g,_){this._services.set(g,_)}getService(g){return this._services.get(g)}createInstance(g,..._){const y=(0,u.getServiceDependencies)(g).sort(((h,d)=>h.index-d.index)),x=[];for(const h of y){const d=this._services.get(h.id);if(!d)throw new Error(`[createInstance] ${g.name} depends on UNKNOWN service ${h.id}.`);x.push(d)}const a=y.length>0?y[0].index:_.length;if(_.length!==a)throw new Error(`[createInstance] First service dependency of ${g.name} at position ${a+1} conflicts with ${_.length} static arguments`);return new g(..._,...x)}}},7866:function(v,i,n){var l=this&&this.__decorate||function(a,h,d,f){var b,w=arguments.length,k=w<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,d,f);else for(var j=a.length-1;j>=0;j--)(b=a[j])&&(k=(w<3?b(k):w>3?b(h,d,k):b(h,d))||k);return w>3&&k&&Object.defineProperty(h,d,k),k},u=this&&this.__param||function(a,h){return function(d,f){h(d,f,a)}};Object.defineProperty(i,"__esModule",{value:!0}),i.traceCall=i.setTraceLogger=i.LogService=void 0;const c=n(844),g=n(2585),_={trace:g.LogLevelEnum.TRACE,debug:g.LogLevelEnum.DEBUG,info:g.LogLevelEnum.INFO,warn:g.LogLevelEnum.WARN,error:g.LogLevelEnum.ERROR,off:g.LogLevelEnum.OFF};let y,x=i.LogService=class extends c.Disposable{get logLevel(){return this._logLevel}constructor(a){super(),this._optionsService=a,this._logLevel=g.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),y=this}_updateLogLevel(){this._logLevel=_[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(a){for(let h=0;h<a.length;h++)typeof a[h]=="function"&&(a[h]=a[h]())}_log(a,h,d){this._evalLazyOptionalParams(d),a.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+h,...d)}trace(a,...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,a,h)}debug(a,...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,a,h)}info(a,...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,a,h)}warn(a,...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,a,h)}error(a,...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,a,h)}};i.LogService=x=l([u(0,g.IOptionsService)],x),i.setTraceLogger=function(a){y=a},i.traceCall=function(a,h,d){if(typeof d.value!="function")throw new Error("not supported");const f=d.value;d.value=function(...b){if(y.logLevel!==g.LogLevelEnum.TRACE)return f.apply(this,b);y.trace(`GlyphRenderer#${f.name}(${b.map((k=>JSON.stringify(k))).join(", ")})`);const w=f.apply(this,b);return y.trace(`GlyphRenderer#${f.name} return`,w),w}}},7302:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.OptionsService=i.DEFAULT_OPTIONS=void 0;const l=n(8460),u=n(844),c=n(6114);i.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 _ extends u.Disposable{constructor(x){super(),this._onOptionChange=this.register(new l.EventEmitter),this.onOptionChange=this._onOptionChange.event;const a=Object.assign({},i.DEFAULT_OPTIONS);for(const h in x)if(h in a)try{const d=x[h];a[h]=this._sanitizeAndValidateOption(h,d)}catch(d){console.error(d)}this.rawOptions=a,this.options=Object.assign({},a),this._setupOptions()}onSpecificOptionChange(x,a){return this.onOptionChange((h=>{h===x&&a(this.rawOptions[x])}))}onMultipleOptionChange(x,a){return this.onOptionChange((h=>{x.indexOf(h)!==-1&&a()}))}_setupOptions(){const x=h=>{if(!(h in i.DEFAULT_OPTIONS))throw new Error(`No option with key "${h}"`);return this.rawOptions[h]},a=(h,d)=>{if(!(h in i.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:x.bind(this,h),set:a.bind(this,h)};Object.defineProperty(this.options,h,d)}}_sanitizeAndValidateOption(x,a){switch(x){case"cursorStyle":if(a||(a=i.DEFAULT_OPTIONS[x]),!(function(h){return h==="block"||h==="underline"||h==="bar"})(a))throw new Error(`"${a}" is not a valid value for ${x}`);break;case"wordSeparator":a||(a=i.DEFAULT_OPTIONS[x]);break;case"fontWeight":case"fontWeightBold":if(typeof a=="number"&&1<=a&&a<=1e3)break;a=g.includes(a)?a:i.DEFAULT_OPTIONS[x];break;case"cursorWidth":a=Math.floor(a);case"lineHeight":case"tabStopWidth":if(a<1)throw new Error(`${x} cannot be less than 1, value: ${a}`);break;case"minimumContrastRatio":a=Math.max(1,Math.min(21,Math.round(10*a)/10));break;case"scrollback":if((a=Math.min(a,4294967295))<0)throw new Error(`${x} cannot be less than 0, value: ${a}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(a<=0)throw new Error(`${x} cannot be less than or equal to 0, value: ${a}`);break;case"rows":case"cols":if(!a&&a!==0)throw new Error(`${x} must be numeric, value: ${a}`);break;case"windowsPty":a=a??{}}return a}}i.OptionsService=_},2660:function(v,i,n){var l=this&&this.__decorate||function(_,y,x,a){var h,d=arguments.length,f=d<3?y:a===null?a=Object.getOwnPropertyDescriptor(y,x):a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")f=Reflect.decorate(_,y,x,a);else for(var b=_.length-1;b>=0;b--)(h=_[b])&&(f=(d<3?h(f):d>3?h(y,x,f):h(y,x))||f);return d>3&&f&&Object.defineProperty(y,x,f),f},u=this&&this.__param||function(_,y){return function(x,a){y(x,a,_)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OscLinkService=void 0;const c=n(2585);let g=i.OscLinkService=class{constructor(_){this._bufferService=_,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(_){const y=this._bufferService.buffer;if(_.id===void 0){const b=y.addMarker(y.ybase+y.y),w={data:_,id:this._nextId++,lines:[b]};return b.onDispose((()=>this._removeMarkerFromLink(w,b))),this._dataByLinkId.set(w.id,w),w.id}const x=_,a=this._getEntryIdKey(x),h=this._entriesWithId.get(a);if(h)return this.addLineToLink(h.id,y.ybase+y.y),h.id;const d=y.addMarker(y.ybase+y.y),f={id:this._nextId++,key:this._getEntryIdKey(x),data:x,lines:[d]};return d.onDispose((()=>this._removeMarkerFromLink(f,d))),this._entriesWithId.set(f.key,f),this._dataByLinkId.set(f.id,f),f.id}addLineToLink(_,y){const x=this._dataByLinkId.get(_);if(x&&x.lines.every((a=>a.line!==y))){const a=this._bufferService.buffer.addMarker(y);x.lines.push(a),a.onDispose((()=>this._removeMarkerFromLink(x,a)))}}getLinkData(_){var y;return(y=this._dataByLinkId.get(_))===null||y===void 0?void 0:y.data}_getEntryIdKey(_){return`${_.id};;${_.uri}`}_removeMarkerFromLink(_,y){const x=_.lines.indexOf(y);x!==-1&&(_.lines.splice(x,1),_.lines.length===0&&(_.data.id!==void 0&&this._entriesWithId.delete(_.key),this._dataByLinkId.delete(_.id)))}};i.OscLinkService=g=l([u(0,c.IBufferService)],g)},8343:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.createDecorator=i.getServiceDependencies=i.serviceRegistry=void 0;const n="di$target",l="di$dependencies";i.serviceRegistry=new Map,i.getServiceDependencies=function(u){return u[l]||[]},i.createDecorator=function(u){if(i.serviceRegistry.has(u))return i.serviceRegistry.get(u);const c=function(g,_,y){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(x,a,h){a[n]===a?a[l].push({id:x,index:h}):(a[l]=[{id:x,index:h}],a[n]=a)})(c,g,y)};return c.toString=()=>u,i.serviceRegistry.set(u,c),c}},2585:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.IDecorationService=i.IUnicodeService=i.IOscLinkService=i.IOptionsService=i.ILogService=i.LogLevelEnum=i.IInstantiationService=i.ICharsetService=i.ICoreService=i.ICoreMouseService=i.IBufferService=void 0;const l=n(8343);var u;i.IBufferService=(0,l.createDecorator)("BufferService"),i.ICoreMouseService=(0,l.createDecorator)("CoreMouseService"),i.ICoreService=(0,l.createDecorator)("CoreService"),i.ICharsetService=(0,l.createDecorator)("CharsetService"),i.IInstantiationService=(0,l.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||(i.LogLevelEnum=u={})),i.ILogService=(0,l.createDecorator)("LogService"),i.IOptionsService=(0,l.createDecorator)("OptionsService"),i.IOscLinkService=(0,l.createDecorator)("OscLinkService"),i.IUnicodeService=(0,l.createDecorator)("UnicodeService"),i.IDecorationService=(0,l.createDecorator)("DecorationService")},1480:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeService=void 0;const l=n(8460),u=n(225);i.UnicodeService=class{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new l.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 _=c.length;for(let y=0;y<_;++y){let x=c.charCodeAt(y);if(55296<=x&&x<=56319){if(++y>=_)return g+this.wcwidth(x);const a=c.charCodeAt(y);56320<=a&&a<=57343?x=1024*(x-55296)+a-56320+65536:g+=this.wcwidth(a)}g+=this.wcwidth(x)}return g}}}},o={};function p(v){var i=o[v];if(i!==void 0)return i.exports;var n=o[v]={exports:{}};return r[v].call(n.exports,n,n.exports,p),n.exports}var m={};return(()=>{var v=m;Object.defineProperty(v,"__esModule",{value:!0}),v.Terminal=void 0;const i=p(9042),n=p(3236),l=p(844),u=p(5741),c=p(8285),g=p(7975),_=p(7090),y=["cols","rows"];class x extends l.Disposable{constructor(h){super(),this._core=this.register(new n.Terminal(h)),this._addonManager=this.register(new u.AddonManager),this._publicOptions=Object.assign({},this._core.options);const d=b=>this._core.options[b],f=(b,w)=>{this._checkReadonlyOptions(b),this._core.options[b]=w};for(const b in this._core.options){const w={get:d.bind(this,b),set:f.bind(this,b)};Object.defineProperty(this._publicOptions,b,w)}}_checkReadonlyOptions(h){if(y.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 _.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,b;return this._checkProposedApi(),this._verifyPositiveIntegers((d=h.x)!==null&&d!==void 0?d:0,(f=h.width)!==null&&f!==void 0?f:0,(b=h.height)!==null&&b!==void 0?b: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 i}_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=x})(),m})()))})(wi)),wi.exports}var Am=Rm();var Mm=2,Tm=1,Dm=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"))},i=v.top+v.bottom,n=v.right+v.left,l=o-i,u=p-n-s;return{cols:Math.max(Mm,Math.floor(u/e.css.cell.width)),rows:Math.max(Tm,Math.floor(l/e.css.cell.height))}}};function Lm(e={}){const{cwd:s,cols:r,rows:o,onOutput:p,onExit:m}=e,[v,i]=C.useState(null),[n,l]=C.useState(()=>Jt.isConnected()),[u,c]=C.useState(!1),[g,_]=C.useState(!1),[y,x]=C.useState(!1),a=C.useRef({onOutput:p,onExit:m});a.current={onOutput:p,onExit:m};const h=C.useRef(null);h.current=v,C.useEffect(()=>{if(!v)return;const k=Jt.getSocket(),j=()=>{l(!0),c(!1),i(null),x(!0)},S=()=>{l(!1),c(!1)},E=A=>{A.terminalId===v&&a.current.onOutput?.(A.data)},R=A=>{A.terminalId===v&&(c(!1),a.current.onExit?.(A.exitCode),i(null))},L=A=>{A.terminalId===v&&c(!0)},T=A=>{A.terminalId===v&&c(!1)};return k.on("connect",j),k.on("disconnect",S),k.on(at.TERMINAL_STDOUT,E),k.on(at.TERMINAL_EXIT,R),k.on(at.TERMINAL_SUBSCRIBED,L),k.on(at.TERMINAL_UNSUBSCRIBED,T),l(k.connected),k.connected&&k.emit(ks.SUBSCRIBE,{topic:"terminal",id:v},A=>{A.success&&c(!0)}),()=>{k.off("connect",j),k.off("disconnect",S),k.off(at.TERMINAL_STDOUT,E),k.off(at.TERMINAL_EXIT,R),k.off(at.TERMINAL_SUBSCRIBED,L),k.off(at.TERMINAL_UNSUBSCRIBED,T),k.emit(ks.UNSUBSCRIBE,{topic:"terminal",id:v})}},[v]);const d=C.useCallback(async()=>{const k=Jt.getSocket();if(!k.connected)return null;_(!0);try{const j=await ge.post("/terminals",{socketId:k.id,cwd:s,cols:r,rows:o});return i(j.terminalId),x(!1),j.terminalId}catch(j){return console.error("[useStandaloneTerminal] Failed to create terminal:",j),null}finally{_(!1)}},[s,r,o]),f=C.useCallback(async()=>{const k=h.current;if(k){try{await ge.delete(`/terminals/${k}`)}catch(j){console.error("[useStandaloneTerminal] Failed to destroy terminal:",j)}i(null),c(!1)}},[]),b=C.useCallback(k=>{const j=h.current;if(!j)return;Jt.getSocket().emit(ks.TERMINAL_INPUT,{terminalId:j,data:k})},[]),w=C.useCallback((k,j)=>{const S=h.current;if(!S)return;Jt.getSocket().emit(ks.TERMINAL_RESIZE,{terminalId:S,cols:k,rows:j})},[]);return C.useEffect(()=>()=>{const k=h.current;k&&ge.delete(`/terminals/${k}`).catch(()=>{})},[]),{terminalId:v,isConnected:n,isAttached:u,isCreating:g,needsRecreate:y,create:d,destroy:f,sendInput:b,resize:w}}const Pm={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"},Om=ae.memo(function({cwd:s,isVisible:r=!0,onExit:o,onReady:p}){const m=C.useRef(null),v=C.useRef(null),i=C.useRef(null),n=C.useRef(!1),{terminalId:l,isAttached:u,needsRecreate:c,create:g,sendInput:_,resize:y}=Lm({cwd:s,onOutput:C.useCallback(x=>{v.current?.write(x)},[]),onExit:C.useCallback(x=>{v.current?.writeln(`\r
|
|
28
|
-
\x1B[90m[Process exited with code ${x}]\x1B[0m`),o?.(x)},[o])});return C.useEffect(()=>{if(!c)return;const x=v.current;x&&x.writeln(`\r
|
|
29
|
-
\x1B[33m[Terminal disconnected — reconnecting...]\x1B[0m`),g()},[c,g]),C.useLayoutEffect(()=>{if(!m.current)return;const x=new Am.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, 'Courier New', monospace",lineHeight:1.4,theme:Pm,scrollback:5e3,convertEol:!0}),a=new Dm;x.loadAddon(a),x.open(m.current);const h=(d=0)=>{if(!(d>=5))try{const b=m.current;if(!b||b.clientWidth===0||b.clientHeight===0){setTimeout(()=>h(d+1),50);return}a.fit(),y(x.cols,x.rows)}catch{setTimeout(()=>h(d+1),50)}};return h(0),setTimeout(()=>h(1),100),v.current=x,i.current=a,()=>{x.dispose(),v.current=null,i.current=null}},[y]),C.useEffect(()=>{n.current||(n.current=!0,g())},[g]),C.useEffect(()=>{const x=v.current;if(!x||!u)return;const a=x.onData(h=>{_(h)});return()=>a.dispose()},[_,u]),C.useEffect(()=>{u&&p?.({sendInput:_})},[u,_,p]),C.useEffect(()=>{if(!r)return;const x=i.current,a=v.current,h=m.current;if(!x||!a||!h)return;let d=!1,f;const b=w=>{d||w>=5||(f=requestAnimationFrame(()=>{if(!d)if(h.clientWidth>0&&h.clientHeight>0)try{x.fit(),y(a.cols,a.rows)}catch{}else setTimeout(()=>b(w+1),30)}))};return b(0),()=>{d=!0,f!=null&&cancelAnimationFrame(f)}},[r,y]),C.useEffect(()=>{if(!m.current)return;const x=new ResizeObserver(()=>{requestAnimationFrame(()=>{try{const a=i.current,h=v.current,d=m.current;a&&h&&d&&d.clientWidth>0&&d.clientHeight>0&&(a.fit(),y(h.cols,h.rows))}catch{}})});return x.observe(m.current),()=>x.disconnect()},[y]),t.jsxs("div",{className:"relative flex h-full flex-col bg-[#1e1e1e]",children:[!l&&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:"flex-1 overflow-hidden px-1 pt-1"})]})}),Im=ae.memo(function({commands:s,onSelect:r}){const{t:o}=ce(),[p,m]=C.useState(!1),v=C.useRef(null),i=C.useRef(null);return C.useEffect(()=>{if(!p)return;const n=l=>{v.current&&!v.current.contains(l.target)&&i.current&&!i.current.contains(l.target)&&m(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[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:i,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(xd,{size:12}),t.jsx("span",{children:o("快捷命令")}),t.jsx(yt,{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((n,l)=>t.jsxs("button",{onClick:()=>{r(n.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(Ut,{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:n.name}),t.jsx("div",{className:"text-[11px] font-mono text-neutral-500 truncate",children:n.command})]})]},l))})})]})]})});let Ci=0;function To(){return Ci+=1,{id:`shell-${Ci}`,order:Ci}}const Bm=ae.memo(function({cwd:s,isVisible:r=!0,quickCommands:o=[]}){const{t:p}=ce(),[m,v]=C.useState(()=>[To()]),[i,n]=C.useState(()=>m[0].id),l=C.useRef(new Map),u=C.useCallback(()=>{const x=To();v(a=>[...a,x]),n(x.id)},[]),c=C.useCallback((x,a)=>{a.stopPropagation(),l.current.delete(x),v(h=>{const d=h.filter(f=>f.id!==x);return x===i&&d.length>0&&n(d[d.length-1].id),d})},[i]),g=C.useCallback(x=>{l.current.delete(x),v(a=>{const h=a.filter(d=>d.id!==x);return x===i&&h.length>0&&n(h[h.length-1].id),h})},[i]),_=C.useCallback((x,a)=>{l.current.set(x,a.sendInput)},[]),y=C.useCallback(x=>{const a=l.current.get(i);a&&a(x+"\r")},[i]);return t.jsxs("div",{className:"flex h-full flex-col bg-[#1e1e1e]",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 flex-1 min-w-0",children:m.map(x=>t.jsxs("button",{onClick:()=>n(x.id),className:te("flex items-center gap-1.5 px-3 py-1.5 text-[11px] border-r border-[#333] whitespace-nowrap group transition-colors",x.id===i?"bg-[#1e1e1e] text-neutral-200":"bg-[#2d2d2d] text-neutral-500 hover:text-neutral-300"),children:[t.jsx(Ar,{size:11,className:"shrink-0"}),t.jsx("span",{children:p("Shell {count}",{count:x.order})}),m.length>1&&t.jsx("span",{onClick:a=>c(x.id,a),className:"ml-1 p-0.5 rounded hover:bg-[#444] opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:t.jsx(ns,{size:10})})]},x.id))}),t.jsx("button",{onClick:u,className:"flex items-center justify-center px-2 py-1.5 text-neutral-500 hover:text-neutral-300 hover:bg-[#333] transition-colors shrink-0",title:p("New Terminal"),children:t.jsx(ts,{size:14})}),o.length>0&&t.jsx(Im,{commands:o,onSelect:y})]}),t.jsx("div",{className:"flex-1 overflow-hidden relative",children:m.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(Ar,{size:28}),t.jsx("span",{className:"text-xs",children:p("No terminals open")}),t.jsx("button",{onClick:u,className:"mt-1 px-3 py-1 text-xs bg-[#333] hover:bg-[#444] rounded transition-colors text-neutral-300",children:p("New Terminal")})]})}):m.map(x=>t.jsx("div",{className:"absolute inset-0",style:{display:x.id===i?"block":"none"},children:t.jsx(Om,{cwd:s,isVisible:r&&x.id===i,onExit:()=>g(x.id),onReady:a=>_(x.id,a)})},x.id))})]})});function Do(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 Fm(e){if(Array.isArray(e))return e}function zm(e,s,r){return(s=Xm(s))in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function Wm(e,s){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o,p,m,v,i=[],n=!0,l=!1;try{if(m=(r=r.call(e)).next,s!==0)for(;!(n=(o=m.call(r)).done)&&(i.push(o.value),i.length!==s);n=!0);}catch(u){l=!0,p=u}finally{try{if(!n&&r.return!=null&&(v=r.return(),Object(v)!==v))return}finally{if(l)throw p}}return i}}function Hm(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
30
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Lo(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 Po(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Lo(Object(r),!0).forEach(function(o){zm(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Lo(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function $m(e,s){if(e==null)return{};var r,o,p=Um(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 Um(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 qm(e,s){return Fm(e)||Wm(e,s)||Vm(e,s)||Hm()}function Km(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 Xm(e){var s=Km(e,"string");return typeof s=="symbol"?s:s+""}function Vm(e,s){if(e){if(typeof e=="string")return Do(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)?Do(e,s):void 0}}function Ym(e,s,r){return s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function Oo(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 Io(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Oo(Object(r),!0).forEach(function(o){Ym(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Oo(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function Gm(){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 qs(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,i=new Array(v),n=0;n<v;n++)i[n]=arguments[n];return s.apply(r,[].concat(p,i))}}}function zr(e){return{}.toString.call(e).includes("Object")}function Qm(e){return!Object.keys(e).length}function sr(e){return typeof e=="function"}function Zm(e,s){return Object.prototype.hasOwnProperty.call(e,s)}function Jm(e,s){return zr(s)||rs("changeType"),Object.keys(s).some(function(r){return!Zm(e,r)})&&rs("changeField"),s}function ep(e){sr(e)||rs("selectorType")}function tp(e){sr(e)||zr(e)||rs("handlerType"),zr(e)&&Object.values(e).some(function(s){return!sr(s)})&&rs("handlersType")}function sp(e){e||rs("initialIsRequired"),zr(e)||rs("initialType"),Qm(e)&&rs("initialContent")}function rp(e,s){throw new Error(e[s]||e.default)}var ip={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"},rs=qs(rp)(ip),br={changes:Jm,selector:ep,handler:tp,initial:sp};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=qs(lp)(r,s),p=qs(ap)(r),m=qs(br.changes)(e),v=qs(op)(r);function i(){var l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(u){return u};return br.selector(l),l(r.current)}function n(l){Gm(o,p,m,v)(l)}return[i,n]}function op(e,s){return sr(s)?s(e.current):s}function ap(e,s){return e.current=Io(Io({},e.current),s),s}function lp(e,s,r){return sr(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 cp={create:np},dp={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function up(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,i=new Array(v),n=0;n<v;n++)i[n]=arguments[n];return s.apply(r,[].concat(p,i))}}}function hp(e){return{}.toString.call(e).includes("Object")}function fp(e){return e||Bo("configIsRequired"),hp(e)||Bo("configType"),e.urls?(mp(),{paths:{vs:e.urls.monacoBase}}):e}function mp(){console.warn(wl.deprecation)}function pp(e,s){throw new Error(e[s]||e.default)}var wl={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!
|
|
31
|
-
You are using deprecated way of configuration.
|
|
32
|
-
|
|
33
|
-
Instead of using
|
|
34
|
-
monaco.config({ urls: { monacoBase: '...' } })
|
|
35
|
-
use
|
|
36
|
-
monaco.config({ paths: { vs: '...' } })
|
|
37
|
-
|
|
38
|
-
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
39
|
-
`},Bo=up(pp)(wl),gp={config:fp},vp=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 Cl(e,s){return Object.keys(s).forEach(function(r){s[r]instanceof Object&&e[r]&&Object.assign(s[r],Cl(e[r],s[r]))}),Po(Po({},e),s)}var xp={type:"cancelation",msg:"operation is manually canceled"};function ki(e){var s=!1,r=new Promise(function(o,p){e.then(function(m){return s?p(xp):o(m)}),e.catch(p)});return r.cancel=function(){return s=!0},r}var _p=["monaco"],bp=cp.create({config:dp,isInitialized:!1,resolve:null,reject:null,monaco:null}),kl=qm(bp,2),cr=kl[0],ti=kl[1];function yp(e){var s=gp.config(e),r=s.monaco,o=$m(s,_p);ti(function(p){return{config:Cl(p.config,o),monaco:r}})}function Sp(){var e=cr(function(s){var r=s.monaco,o=s.isInitialized,p=s.resolve;return{monaco:r,isInitialized:o,resolve:p}});if(!e.isInitialized){if(ti({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),ki(Ei);if(window.monaco&&window.monaco.editor)return El(window.monaco),e.resolve(window.monaco),ki(Ei);vp(wp,kp)(Ep)}return ki(Ei)}function wp(e){return document.body.appendChild(e)}function Cp(e){var s=document.createElement("script");return e&&(s.src=e),s}function kp(e){var s=cr(function(o){var p=o.config,m=o.reject;return{config:p,reject:m}}),r=Cp("".concat(s.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=s.reject,r}function Ep(){var e=cr(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;El(o),e.resolve(o)},function(r){e.reject(r)})}function El(e){cr().monaco||ti({monaco:e})}function jp(){return cr(function(e){var s=e.monaco;return s})}var Ei=new Promise(function(e,s){return ti({resolve:e,reject:s})}),jl={config:yp,init:Sp,__getMonacoInstance:jp},Np={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},ji=Np,Rp={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Ap=Rp;function Mp({children:e}){return ae.createElement("div",{style:Ap.container},e)}var Tp=Mp,Dp=Tp;function Lp({width:e,height:s,isEditorReady:r,loading:o,_ref:p,className:m,wrapperProps:v}){return ae.createElement("section",{style:{...ji.wrapper,width:e,height:s},...v},!r&&ae.createElement(Dp,null,o),ae.createElement("div",{ref:p,style:{...ji.fullWidth,...!r&&ji.hide},className:m}))}var Pp=Lp,Nl=C.memo(Pp);function Op(e){C.useEffect(e,[])}var Rl=Op;function Ip(e,s,r=!0){let o=C.useRef(!0);C.useEffect(o.current||!r?()=>{o.current=!1}:e,s)}var kt=Ip;function Ys(){}function js(e,s,r,o){return Bp(e,o)||Fp(e,s,r,o)}function Bp(e,s){return e.editor.getModel(Al(e,s))}function Fp(e,s,r,o){return e.editor.createModel(s,r,o?Al(e,o):void 0)}function Al(e,s){return e.Uri.parse(s)}function zp({original:e,modified:s,language:r,originalLanguage:o,modifiedLanguage:p,originalModelPath:m,modifiedModelPath:v,keepCurrentOriginalModel:i=!1,keepCurrentModifiedModel:n=!1,theme:l="light",loading:u="Loading...",options:c={},height:g="100%",width:_="100%",className:y,wrapperProps:x={},beforeMount:a=Ys,onMount:h=Ys}){let[d,f]=C.useState(!1),[b,w]=C.useState(!0),k=C.useRef(null),j=C.useRef(null),S=C.useRef(null),E=C.useRef(h),R=C.useRef(a),L=C.useRef(!1);Rl(()=>{let D=jl.init();return D.then(z=>(j.current=z)&&w(!1)).catch(z=>z?.type!=="cancelation"&&console.error("Monaco initialization: error:",z)),()=>k.current?B():D.cancel()}),kt(()=>{if(k.current&&j.current){let D=k.current.getOriginalEditor(),z=js(j.current,e||"",o||r||"text",m||"");z!==D.getModel()&&D.setModel(z)}},[m],d),kt(()=>{if(k.current&&j.current){let D=k.current.getModifiedEditor(),z=js(j.current,s||"",p||r||"text",v||"");z!==D.getModel()&&D.setModel(z)}},[v],d),kt(()=>{let D=k.current.getModifiedEditor();D.getOption(j.current.editor.EditorOption.readOnly)?D.setValue(s||""):s!==D.getValue()&&(D.executeEdits("",[{range:D.getModel().getFullModelRange(),text:s||"",forceMoveMarkers:!0}]),D.pushUndoStop())},[s],d),kt(()=>{k.current?.getModel()?.original.setValue(e||"")},[e],d),kt(()=>{let{original:D,modified:z}=k.current.getModel();j.current.editor.setModelLanguage(D,o||r||"text"),j.current.editor.setModelLanguage(z,p||r||"text")},[r,o,p],d),kt(()=>{j.current?.editor.setTheme(l)},[l],d),kt(()=>{k.current?.updateOptions(c)},[c],d);let T=C.useCallback(()=>{if(!j.current)return;R.current(j.current);let D=js(j.current,e||"",o||r||"text",m||""),z=js(j.current,s||"",p||r||"text",v||"");k.current?.setModel({original:D,modified:z})},[r,s,p,e,o,m,v]),A=C.useCallback(()=>{!L.current&&S.current&&(k.current=j.current.editor.createDiffEditor(S.current,{automaticLayout:!0,...c}),T(),j.current?.editor.setTheme(l),f(!0),L.current=!0)},[c,l,T]);C.useEffect(()=>{d&&E.current(k.current,j.current)},[d]),C.useEffect(()=>{!b&&!d&&A()},[b,d,A]);function B(){let D=k.current?.getModel();i||D?.original?.dispose(),n||D?.modified?.dispose(),k.current?.dispose()}return ae.createElement(Nl,{width:_,height:g,isEditorReady:d,loading:u,_ref:S,className:y,wrapperProps:x})}var Wp=zp;C.memo(Wp);function Hp(e){let s=C.useRef();return C.useEffect(()=>{s.current=e},[e]),s.current}var $p=Hp,yr=new Map;function Up({defaultValue:e,defaultLanguage:s,defaultPath:r,value:o,language:p,path:m,theme:v="light",line:i,loading:n="Loading...",options:l={},overrideServices:u={},saveViewState:c=!0,keepCurrentModel:g=!1,width:_="100%",height:y="100%",className:x,wrapperProps:a={},beforeMount:h=Ys,onMount:d=Ys,onChange:f,onValidate:b=Ys}){let[w,k]=C.useState(!1),[j,S]=C.useState(!0),E=C.useRef(null),R=C.useRef(null),L=C.useRef(null),T=C.useRef(d),A=C.useRef(h),B=C.useRef(),D=C.useRef(o),z=$p(m),H=C.useRef(!1),M=C.useRef(!1);Rl(()=>{let I=jl.init();return I.then($=>(E.current=$)&&S(!1)).catch($=>$?.type!=="cancelation"&&console.error("Monaco initialization: error:",$)),()=>R.current?P():I.cancel()}),kt(()=>{let I=js(E.current,e||o||"",s||p||"",m||r||"");I!==R.current?.getModel()&&(c&&yr.set(z,R.current?.saveViewState()),R.current?.setModel(I),c&&R.current?.restoreViewState(yr.get(m)))},[m],w),kt(()=>{R.current?.updateOptions(l)},[l],w),kt(()=>{!R.current||o===void 0||(R.current.getOption(E.current.editor.EditorOption.readOnly)?R.current.setValue(o):o!==R.current.getValue()&&(M.current=!0,R.current.executeEdits("",[{range:R.current.getModel().getFullModelRange(),text:o,forceMoveMarkers:!0}]),R.current.pushUndoStop(),M.current=!1))},[o],w),kt(()=>{let I=R.current?.getModel();I&&p&&E.current?.editor.setModelLanguage(I,p)},[p],w),kt(()=>{i!==void 0&&R.current?.revealLine(i)},[i],w),kt(()=>{E.current?.editor.setTheme(v)},[v],w);let O=C.useCallback(()=>{if(!(!L.current||!E.current)&&!H.current){A.current(E.current);let I=m||r,$=js(E.current,o||e||"",s||p||"",I||"");R.current=E.current?.editor.create(L.current,{model:$,automaticLayout:!0,...l},u),c&&R.current.restoreViewState(yr.get(I)),E.current.editor.setTheme(v),i!==void 0&&R.current.revealLine(i),k(!0),H.current=!0}},[e,s,r,o,p,m,l,u,c,v,i]);C.useEffect(()=>{w&&T.current(R.current,E.current)},[w]),C.useEffect(()=>{!j&&!w&&O()},[j,w,O]),D.current=o,C.useEffect(()=>{w&&f&&(B.current?.dispose(),B.current=R.current?.onDidChangeModelContent(I=>{M.current||f(R.current.getValue(),I)}))},[w,f]),C.useEffect(()=>{if(w){let I=E.current.editor.onDidChangeMarkers($=>{let Y=R.current.getModel()?.uri;if(Y&&$.find(q=>q.path===Y.path)){let q=E.current.editor.getModelMarkers({resource:Y});b?.(q)}});return()=>{I?.dispose()}}return()=>{}},[w,b]);function P(){B.current?.dispose(),g?c&&yr.set(m,R.current.saveViewState()):R.current.getModel()?.dispose(),R.current.dispose()}return ae.createElement(Nl,{width:_,height:y,isEditorReady:w,loading:n,_ref:L,className:x,wrapperProps:a})}var qp=Up,Kp=C.memo(qp),Xp=Kp,At=function(e,s){return Number(e.toFixed(s))},Vp=function(e,s){return typeof e=="number"?e:s},Ze=function(e,s,r){r&&typeof r=="function"&&r(e,s)},Yp=function(e){return-Math.cos(e*Math.PI)/2+.5},Gp=function(e){return e},Qp=function(e){return e*e},Zp=function(e){return e*(2-e)},Jp=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},eg=function(e){return e*e*e},tg=function(e){return--e*e*e+1},sg=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},rg=function(e){return e*e*e*e},ig=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},og=function(e){return e*e*e*e*e},ag=function(e){return 1+--e*e*e*e*e},lg=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},Ml={easeOut:Yp,linear:Gp,easeInQuad:Qp,easeOutQuad:Zp,easeInOutQuad:Jp,easeInCubic:eg,easeOutCubic:tg,easeInOutCubic:sg,easeInQuart:rg,easeOutQuart:ig,easeInOutQuart:ng,easeInQuint:og,easeOutQuint:ag,easeInOutQuint:lg},Tl=function(e){typeof e=="number"&&cancelAnimationFrame(e)},Dt=function(e){e.mounted&&(Tl(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function Dl(e,s,r,o){if(e.mounted){var p=new Date().getTime(),m=1;Dt(e),e.animation=function(){if(!e.mounted)return Tl(e.animation);var v=new Date().getTime()-p,i=v/r,n=Ml[s],l=n(i);v>=r?(o(m),e.animation=null):e.animation&&(o(l),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function cg(e){var s=e.scale,r=e.positionX,o=e.positionY;return!(Number.isNaN(s)||Number.isNaN(r)||Number.isNaN(o))}function as(e,s,r,o){var p=cg(s);if(!(!e.mounted||!p)){var m=e.setTransformState,v=e.transformState,i=v.scale,n=v.positionX,l=v.positionY,u=s.scale-i,c=s.positionX-n,g=s.positionY-l;r===0?m(s.scale,s.positionX,s.positionY):Dl(e,o,r,function(_){var y=i+u*_,x=n+c*_,a=l+g*_;m(y,x,a)})}}function dg(e,s,r){var o=e.offsetWidth,p=e.offsetHeight,m=s.offsetWidth,v=s.offsetHeight,i=m*r,n=v*r,l=o-i,u=p-n;return{wrapperWidth:o,wrapperHeight:p,newContentWidth:i,newDiffWidth:l,newContentHeight:n,newDiffHeight:u}}var ug=function(e,s,r,o,p,m,v){var i=e>s?r*(v?1:.5):0,n=o>p?m*(v?1:.5):0,l=e-s-i,u=i,c=o-p-n,g=n;return{minPositionX:l,maxPositionX:u,minPositionY:c,maxPositionY:g}},Ln=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,i=m.wrapperHeight,n=m.newContentWidth,l=m.newDiffWidth,u=m.newContentHeight,c=m.newDiffHeight,g=ug(v,n,l,i,u,c,!!p);return g},Vi=function(e,s,r,o){return o?e<s?At(s,2):e>r?At(r,2):At(e,2):At(e,2)},ds=function(e,s){var r=Ln(e,s);return e.bounds=r,r};function dr(e,s,r,o,p,m,v){var i=r.minPositionX,n=r.minPositionY,l=r.maxPositionX,u=r.maxPositionY,c=0,g=0;v&&(c=p,g=m);var _=Vi(e,i-c,l+c,o),y=Vi(s,n-g,u+g,o);return{x:_,y}}function si(e,s,r,o,p,m){var v=e.transformState,i=v.scale,n=v.positionX,l=v.positionY,u=o-i;if(typeof s!="number"||typeof r!="number")return console.error("Mouse X and Y position were not provided!"),{x:n,y:l};var c=n-s*u,g=l-r*u,_=dr(c,g,p,m,0,0,null);return _}function ur(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 Fo=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,i=v?s.composedPath().some(function(u){return u instanceof Element?p?.contains(u):!1}):p?.contains(m),n=o&&m&&i;if(!n)return!1;var l=ri(m,r);return!l},zo=function(e){var s=e.isInitialized,r=e.isPanning,o=e.setup,p=o.panning.disabled,m=s&&r&&!p;return!!m},hg=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}},fg=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 i=r[0].clientX,n=r[0].clientY;e.startCoords={x:i-p,y:n-m}}};function mg(e){var s=e.transformState,r=s.positionX,o=s.positionY,p=s.scale,m=e.setup,v=m.disabled,i=m.limitToBounds,n=m.centerZoomedOut,l=e.wrapperComponent;if(!(v||!l||!e.bounds)){var u=e.bounds,c=u.maxPositionX,g=u.minPositionX,_=u.maxPositionY,y=u.minPositionY,x=r>c||r<g,a=o>_||o<y,h=r>c?l.offsetWidth:e.setup.minPositionX||0,d=o>_?l.offsetHeight:e.setup.minPositionY||0,f=si(e,h,d,p,e.bounds,i||n),b=f.x,w=f.y;return{scale:p,positionX:x?b:r,positionY:a?w:o}}}function Ll(e,s,r,o,p){var m=e.setup.limitToBounds,v=e.wrapperComponent,i=e.bounds,n=e.transformState,l=n.scale,u=n.positionX,c=n.positionY;if(!(v===null||i===null||s===u&&r===c)){var g=dr(s,r,i,m,o,p,v),_=g.x,y=g.y;e.setTransformState(l,_,y)}}var pg=function(e,s,r){var o=e.startCoords,p=e.transformState,m=e.setup.panning,v=m.lockAxisX,i=m.lockAxisY,n=p.positionX,l=p.positionY;if(!o)return{x:n,y:l};var u=s-o.x,c=r-o.y,g=v?n:u,_=i?l:c;return{x:g,y:_}},os=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},gg=function(e){var s=e.mounted,r=e.setup,o=r.disabled,p=r.velocityAnimation,m=e.transformState.scale,v=p.disabled,i=!v||m>1||!o||s;return!!i},vg=function(e){var s=e.mounted,r=e.velocity,o=e.bounds,p=e.setup,m=p.disabled,v=p.velocityAnimation,i=e.transformState.scale,n=v.disabled,l=!n||i>1||!m||s;return!(!l||!r||!o)};function xg(e,s){var r=e.setup.velocityAnimation,o=r.equalToMove,p=r.animationTime,m=r.sensitivity;return o?p*s*m:p}function Wo(e,s,r,o,p,m,v,i,n,l){if(p){if(s>v&&r>v){var u=v+(e-v)*l;return u>n?n:u<v?v:u}if(s<m&&r<m){var u=m+(e-m)*l;return u<i?i:u>m?m:u}}return o?s:Vi(e,m,v,p)}function _g(e,s){var r=1;return s?Math.min(r,e.offsetWidth/window.innerWidth):r}function bg(e,s){var r=gg(e);if(r){var o=e.lastMousePosition,p=e.velocityTime,m=e.setup,v=e.wrapperComponent,i=m.velocityAnimation.equalToMove,n=Date.now();if(o&&p&&v){var l=_g(v,i),u=s.x-o.x,c=s.y-o.y,g=u/l,_=c/l,y=n-p,x=u*u+c*c,a=Math.sqrt(x)/y;e.velocity={velocityX:g,velocityY:_,total:a}}e.lastMousePosition=s,e.velocityTime=n}}function yg(e){var s=e.velocity,r=e.bounds,o=e.setup,p=e.wrapperComponent,m=vg(e);if(!(!m||!s||!r||!p)){var v=s.velocityX,i=s.velocityY,n=s.total,l=r.maxPositionX,u=r.minPositionX,c=r.maxPositionY,g=r.minPositionY,_=o.limitToBounds,y=o.alignmentAnimation,x=o.zoomAnimation,a=o.panning,h=a.lockAxisY,d=a.lockAxisX,f=x.animationType,b=y.sizeX,w=y.sizeY,k=y.velocityAlignmentTime,j=k,S=xg(e,n),E=Math.max(S,j),R=os(e,b),L=os(e,w),T=R*p.offsetWidth/100,A=L*p.offsetHeight/100,B=l+T,D=u-T,z=c+A,H=g-A,M=e.transformState,O=new Date().getTime();Dl(e,f,E,function(P){var I=e.transformState,$=I.scale,Y=I.positionX,q=I.positionY,V=new Date().getTime()-O,F=V/j,N=Ml[y.animationType],W=1-N(Math.min(1,F)),X=1-P,K=Y+v*X,ie=q+i*X,Z=Wo(K,M.positionX,Y,d,_,u,l,D,B,W),re=Wo(ie,M.positionY,q,h,_,g,c,H,z,W);(Y!==K||q!==ie)&&e.setTransformState($,Z,re)})}}function Ho(e,s){var r=e.transformState.scale;Dt(e),ds(e,r),window.TouchEvent!==void 0&&s instanceof TouchEvent?fg(e,s):hg(e,s)}function Pn(e,s){var r=e.transformState.scale,o=e.setup,p=o.minScale,m=o.alignmentAnimation,v=m.disabled,i=m.sizeX,n=m.sizeY,l=m.animationTime,u=m.animationType,c=v||r<p||!i&&!n;if(!c){var g=mg(e);g&&as(e,g,s??l,u)}}function $o(e,s,r){var o=e.startCoords,p=e.setup,m=p.alignmentAnimation,v=m.sizeX,i=m.sizeY;if(o){var n=pg(e,s,r),l=n.x,u=n.y,c=os(e,v),g=os(e,i);bg(e,{x:l,y:u}),Ll(e,l,u,c,g)}}function Sg(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(),i=m?.width||0,n=m?.height||0,l=v?.width||0,u=v?.height||0,c=i<l||n<u,g=!s&&r&&r?.total>.1&&c;g?yg(e):Pn(e)}}function On(e,s,r,o){var p=e.setup,m=p.minScale,v=p.maxScale,i=p.limitToBounds,n=ur(At(s,2),m,v,0,!1),l=ds(e,n),u=si(e,r,o,n,l,i),c=u.x,g=u.y;return{scale:n,positionX:c,positionY:g}}function Pl(e,s,r){var o=e.transformState.scale,p=e.wrapperComponent,m=e.setup,v=m.minScale,i=m.limitToBounds,n=m.zoomAnimation,l=n.disabled,u=n.animationTime,c=n.animationType,g=l||o>=v;if((o>=1||i)&&Pn(e),!(g||!p||!e.mounted)){var _=s||p.offsetWidth/2,y=r||p.offsetHeight/2,x=On(e,v,_,y);x&&as(e,x,u,c)}}var is=function(){return is=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},is.apply(this,arguments)};function Uo(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 Sr={scale:1,positionX:0,positionY:0},$s={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}},Yi={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},Ol=function(e){var s,r,o,p;return{previousScale:(s=e.initialScale)!==null&&s!==void 0?s:Sr.scale,scale:(r=e.initialScale)!==null&&r!==void 0?r:Sr.scale,positionX:(o=e.initialPositionX)!==null&&o!==void 0?o:Sr.positionX,positionY:(p=e.initialPositionY)!==null&&p!==void 0?p:Sr.positionY}},qo=function(e){var s=is({},$s);return Object.keys(e).forEach(function(r){var o=typeof e[r]<"u",p=typeof $s[r]<"u";if(p&&o){var m=Object.prototype.toString.call($s[r]),v=m==="[object Object]",i=m==="[object Array]";v?s[r]=is(is({},$s[r]),e[r]):i?s[r]=Uo(Uo([],$s[r],!0),e[r]):s[r]=e[r]}}),s},Il=function(e,s,r){var o=e.transformState.scale,p=e.wrapperComponent,m=e.setup,v=m.maxScale,i=m.minScale,n=m.zoomAnimation,l=m.smooth,u=n.size;if(!p)throw new Error("Wrapper is not mounted");var c=l?o*Math.exp(s*r):o+s*r,g=ur(At(c,3),i,v,u,!1);return g};function Bl(e,s,r,o,p){var m=e.wrapperComponent,v=e.transformState,i=v.scale,n=v.positionX,l=v.positionY;if(!m)return console.error("No WrapperComponent found");var u=m.offsetWidth,c=m.offsetHeight,g=(u/2-n)/i,_=(c/2-l)/i,y=Il(e,s,r),x=On(e,y,g,_);if(!x)return console.error("Error during zoom event. New transformation state was not calculated.");as(e,x,o,p)}function Fl(e,s,r,o){var p=e.setup,m=e.wrapperComponent,v=p.limitToBounds,i=Ol(e.props),n=e.transformState,l=n.scale,u=n.positionX,c=n.positionY;if(m){var g=Ln(e,i.scale),_=dr(i.positionX,i.positionY,g,v,0,0,m),y={scale:i.scale,positionX:_.x,positionY:_.y};l===i.scale&&u===i.positionX&&c===i.positionY||(o?.(),as(e,y,s,r))}}function wg(e,s,r,o){var p=e.getBoundingClientRect(),m=s.getBoundingClientRect(),v=r.getBoundingClientRect(),i=m.x*o.scale,n=m.y*o.scale;return{x:(p.x-v.x+i)/o.scale,y:(p.y-v.y+n)/o.scale}}function Cg(e,s,r){var o=e.wrapperComponent,p=e.contentComponent,m=e.transformState,v=e.setup,i=v.limitToBounds,n=v.minScale,l=v.maxScale;if(!o||!p)return m;var u=o.getBoundingClientRect(),c=s.getBoundingClientRect(),g=wg(s,o,p,m),_=g.x,y=g.y,x=c.width/m.scale,a=c.height/m.scale,h=o.offsetWidth/x,d=o.offsetHeight/a,f=ur(r||Math.min(h,d),n,l,0,!1),b=(u.width-x*f)/2,w=(u.height-a*f)/2,k=(u.left-_)*f+b,j=(u.top-y)*f+w,S=Ln(e,f),E=dr(k,j,S,i,0,0,o),R=E.x,L=E.y;return{positionX:R,positionY:L,scale:f}}var kg=function(e){return function(s,r,o){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),Bl(e,1,s,r,o)}},Eg=function(e){return function(s,r,o){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),Bl(e,-1,s,r,o)}},jg=function(e){return function(s,r,o,p,m){p===void 0&&(p=300),m===void 0&&(m="easeOut");var v=e.transformState,i=v.positionX,n=v.positionY,l=v.scale,u=e.wrapperComponent,c=e.contentComponent,g=e.setup.disabled;if(!(g||!u||!c)){var _={positionX:Number.isNaN(s)?i:s,positionY:Number.isNaN(r)?n:r,scale:Number.isNaN(o)?l:o};as(e,_,p,m)}}},Ng=function(e){return function(s,r){s===void 0&&(s=200),r===void 0&&(r="easeOut"),Fl(e,s,r)}},Rg=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 i=zl(s||p.scale,m,v);as(e,i,r,o)}}},Ag=function(e){return function(s,r,o,p){o===void 0&&(o=600),p===void 0&&(p="easeOut"),Dt(e);var m=e.wrapperComponent,v=typeof s=="string"?document.getElementById(s):s;if(m&&v&&m.contains(v)){var i=Cg(e,v,r);as(e,i,o,p)}}},Wr=function(e){return{instance:e,zoomIn:kg(e),zoomOut:Eg(e),setTransform:jg(e),resetTransform:Ng(e),centerView:Rg(e),zoomToElement:Ag(e)}},Gi=function(e){return{instance:e,state:e.transformState}},Ue=function(e){var s={};return Object.assign(s,Gi(e)),Object.assign(s,Wr(e)),s},Ni=!1;function Ri(){try{var e={get passive(){return Ni=!0,!1}};return e}catch{return Ni=!1,Ni}}var wr=".".concat(Yi.wrapperClass),ri=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," *"))})},Qi=function(e){e&&clearTimeout(e)},Mg=function(e,s,r){return"translate(".concat(e,"px, ").concat(s,"px) scale(").concat(r,")")},zl=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 Tg(e){return function(s){e.forEach(function(r){typeof r=="function"?r(s):r!=null&&(r.current=s)})}}var Dg=function(e,s){var r=e.setup.wheel,o=r.disabled,p=r.wheelDisabled,m=r.touchPadDisabled,v=r.excluded,i=e.isInitialized,n=e.isPanning,l=s.target,u=i&&!n&&!o&&l;if(!u||p&&!s.ctrlKey||m&&s.ctrlKey)return!1;var c=ri(l,v);return!c},Lg=function(e){return e?e.deltaY<0?1:-1:0};function Pg(e,s){var r=Lg(e),o=Vp(s,r);return o}function Wl(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 Og=function(e,s,r,o,p){var m=e.transformState.scale,v=e.wrapperComponent,i=e.setup,n=i.maxScale,l=i.minScale,u=i.zoomAnimation,c=i.disablePadding,g=u.size,_=u.disabled;if(!v)throw new Error("Wrapper is not mounted");var y=m+s*r,x=o?!1:!_,a=ur(At(y,3),l,n,g,x&&!c);return a},Ig=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},Bg=function(e,s){var r=e.setup.pinch,o=r.disabled,p=r.excluded,m=e.isInitialized,v=s.target,i=m&&!o&&v;if(!i)return!1;var n=ri(v,p);return!n},Fg=function(e){var s=e.setup.pinch.disabled,r=e.isInitialized,o=e.pinchStartDistance,p=r&&!s&&o;return!!p},zg=function(e,s,r){var o=r.getBoundingClientRect(),p=e.touches,m=At(p[0].clientX-o.left,5),v=At(p[0].clientY-o.top,5),i=At(p[1].clientX-o.left,5),n=At(p[1].clientY-o.top,5);return{x:(m+i)/2/s,y:(v+n)/2/s}},Hl=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))},Wg=function(e,s){var r=e.pinchStartScale,o=e.pinchStartDistance,p=e.setup,m=p.maxScale,v=p.minScale,i=p.zoomAnimation,n=p.disablePadding,l=i.size,u=i.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 ur(At(g,2),v,m,l,!u&&!n)},Hg=160,$g=100,Ug=function(e,s){var r=e.props,o=r.onWheelStart,p=r.onZoomStart;e.wheelStopEventTimer||(Dt(e),Ze(Ue(e),s,o),Ze(Ue(e),s,p))},qg=function(e,s){var r=e.props,o=r.onWheel,p=r.onZoom,m=e.contentComponent,v=e.setup,i=e.transformState,n=i.scale,l=v.limitToBounds,u=v.centerZoomedOut,c=v.zoomAnimation,g=v.wheel,_=v.disablePadding,y=v.smooth,x=c.size,a=c.disabled,h=g.step,d=g.smoothStep;if(!m)throw new Error("Component not mounted");s.preventDefault(),s.stopPropagation();var f=Pg(s,null),b=y?d*Math.abs(s.deltaY):h,w=Og(e,f,b,!s.ctrlKey);if(n!==w){var k=ds(e,w),j=Wl(s,m,n),S=a||x===0||u||_,E=l&&S,R=si(e,j.x,j.y,w,k,E),L=R.x,T=R.y;e.previousWheelEvent=s,e.setTransformState(w,L,T),Ze(Ue(e),s,o),Ze(Ue(e),s,p)}},Kg=function(e,s){var r=e.props,o=r.onWheelStop,p=r.onZoomStop;Qi(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(Pl(e,s.x,s.y),e.wheelAnimationTimer=null)},$g);var m=Ig(e,s);m&&(Qi(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,Ze(Ue(e),s,o),Ze(Ue(e),s,p))},Hg))},$l=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}},Xg=function(e,s){var r=Hl(s);e.pinchStartDistance=r,e.lastDistance=r,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var o=$l(s);e.pinchLastCenterX=o.x,e.pinchLastCenterY=o.y,Dt(e)},Vg=function(e,s){var r=e.contentComponent,o=e.pinchStartDistance,p=e.wrapperComponent,m=e.transformState.scale,v=e.setup,i=v.limitToBounds,n=v.centerZoomedOut,l=v.zoomAnimation,u=v.alignmentAnimation,c=l.disabled,g=l.size;if(!(o===null||!r)){var _=zg(s,m,r);if(!(!Number.isFinite(_.x)||!Number.isFinite(_.y))){var y=Hl(s),x=Wg(e,y),a=$l(s),h=a.x-(e.pinchLastCenterX||0),d=a.y-(e.pinchLastCenterY||0);if(!(x===m&&h===0&&d===0)){e.pinchLastCenterX=a.x,e.pinchLastCenterY=a.y;var f=ds(e,x),b=c||g===0||n,w=i&&b,k=si(e,_.x,_.y,x,f,w),j=k.x,S=k.y;e.pinchMidpoint=_,e.lastDistance=y;var E=u.sizeX,R=u.sizeY,L=os(e,E),T=os(e,R),A=j+h,B=S+d,D=dr(A,B,f,i,L,T,p),z=D.x,H=D.y;e.setTransformState(x,z,H)}}}},Yg=function(e){var s=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,Pl(e,s?.x,s?.y)},Ul=function(e,s){var r=e.props.onZoomStop,o=e.setup.doubleClick.animationTime;Qi(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,Ze(Ue(e),s,r)},o)},Gg=function(e,s){var r=e.props,o=r.onZoomStart,p=r.onZoom,m=e.setup.doubleClick,v=m.animationTime,i=m.animationType;Ze(Ue(e),s,o),Fl(e,v,i,function(){return Ze(Ue(e),s,p)}),Ul(e,s)};function Qg(e,s){return e==="toggle"?s===1?1:-1:e==="zoomOut"?-1:1}function Zg(e,s){var r=e.setup,o=e.doubleClickStopEventTimer,p=e.transformState,m=e.contentComponent,v=p.scale,i=e.props,n=i.onZoomStart,l=i.onZoom,u=r.doubleClick,c=u.disabled,g=u.mode,_=u.step,y=u.animationTime,x=u.animationType;if(!c&&!o){if(g==="reset")return Gg(e,s);if(!m)return console.error("No ContentComponent found");var a=Qg(g,e.transformState.scale),h=Il(e,a,_);if(v!==h){Ze(Ue(e),s,n);var d=Wl(s,m,v),f=On(e,h,d.x,d.y);if(!f)return console.error("Error during zoom event. New transformation state was not calculated.");Ze(Ue(e),s,l),as(e,f,y,x),Ul(e,s)}}}var Jg=function(e,s){var r=e.isInitialized,o=e.setup,p=e.wrapperComponent,m=o.doubleClick,v=m.disabled,i=m.excluded,n=s.target,l=p?.contains(n),u=r&&n&&l&&!v;if(!u)return!1;var c=ri(n,i);return!c},ev=(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,ds(r,r.transformState.scale),r.setup=qo(o)},this.initializeWindowEvents=function(){var o,p,m=Ri(),v=(o=r.wrapperComponent)===null||o===void 0?void 0:o.ownerDocument,i=v?.defaultView;(p=r.wrapperComponent)===null||p===void 0||p.addEventListener("wheel",r.onWheelPanning,m),i?.addEventListener("mousedown",r.onPanningStart,m),i?.addEventListener("mousemove",r.onPanning,m),i?.addEventListener("mouseup",r.onPanningStop,m),v?.addEventListener("mouseleave",r.clearPanning,m),i?.addEventListener("keyup",r.setKeyUnPressed,m),i?.addEventListener("keydown",r.setKeyPressed,m)},this.cleanupWindowEvents=function(){var o,p,m=Ri(),v=(o=r.wrapperComponent)===null||o===void 0?void 0:o.ownerDocument,i=v?.defaultView;i?.removeEventListener("mousedown",r.onPanningStart,m),i?.removeEventListener("mousemove",r.onPanning,m),i?.removeEventListener("mouseup",r.onPanningStop,m),v?.removeEventListener("mouseleave",r.clearPanning,m),i?.removeEventListener("keyup",r.setKeyUnPressed,m),i?.removeEventListener("keydown",r.setKeyPressed,m),document.removeEventListener("mouseleave",r.clearPanning,m),Dt(r),(p=r.observer)===null||p===void 0||p.disconnect()},this.handleInitializeWrapperEvents=function(o){var p=Ri();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,i=function(n,l){for(var u=0,c=n;u<c.length;u++){var g=c[u];if(g.target===l)return!0}return!1};r.applyTransformation(),r.onInitCallbacks.forEach(function(n){n(Ue(r))}),r.observer=new ResizeObserver(function(n){if(i(n,o)||i(n,p))if(v&&!m){var l=p.offsetWidth,u=p.offsetHeight;(l>0||u>0)&&(m=!0,r.setCenter())}else Dt(r),ds(r,r.transformState.scale),Pn(r,0)}),r.observer.observe(o),r.observer.observe(p)},this.onWheelZoom=function(o){var p=r.setup.disabled;if(!p){var m=Dg(r,o);if(m){var v=r.isPressingKeys(r.setup.wheel.activationKeys);v&&(Ug(r,o),qg(r,o),Kg(r,o))}}},this.onWheelPanning=function(o){var p=r.setup,m=p.disabled,v=p.wheel,i=p.panning;if(!(!r.wrapperComponent||!r.contentComponent||m||!v.wheelDisabled||i.disabled||!i.wheelPanning||o.ctrlKey)){o.preventDefault(),o.stopPropagation();var n=r.transformState,l=n.positionX,u=n.positionY,c=l-o.deltaX,g=u-o.deltaY,_=i.lockAxisX?l:c,y=i.lockAxisY?u:g,x=r.setup.alignmentAnimation,a=x.sizeX,h=x.sizeY,d=os(r,a),f=os(r,h);_===l&&y===u||Ll(r,_,y,d,f)}},this.onPanningStart=function(o){var p=r.setup.disabled,m=r.props.onPanningStart;if(!p){var v=Fo(r,o);if(v){var i=r.isPressingKeys(r.setup.panning.activationKeys);i&&(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(),Dt(r),Ho(r,o),Ze(Ue(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 i=r.isPressingKeys(r.setup.panning.activationKeys);i&&(o.preventDefault(),o.stopPropagation(),$o(r,o.clientX,o.clientY),Ze(Ue(r),o,m))}}},this.onPanningStop=function(o){var p=r.props.onPanningStop;r.isPanning&&(Sg(r),Ze(Ue(r),o,p))},this.onPinchStart=function(o){var p=r.setup.disabled,m=r.props,v=m.onPinchingStart,i=m.onZoomStart;if(!p){var n=Bg(r,o);n&&(Xg(r,o),Dt(r),Ze(Ue(r),o,v),Ze(Ue(r),o,i))}},this.onPinch=function(o){var p=r.setup.disabled,m=r.props,v=m.onPinching,i=m.onZoom;if(!p){var n=Fg(r);n&&(o.preventDefault(),o.stopPropagation(),Vg(r,o),Ze(Ue(r),o,v),Ze(Ue(r),o,i))}},this.onPinchStop=function(o){var p=r.props,m=p.onPinchingStop,v=p.onZoomStop;r.pinchStartScale&&(Yg(r),Ze(Ue(r),o,m),Ze(Ue(r),o,v))},this.onTouchPanningStart=function(o){var p=r.setup.disabled,m=r.props.onPanningStart;if(!p){var v=Fo(r,o);if(v){var i=r.lastTouch&&+new Date-r.lastTouch<200&&o.touches.length===1;if(!i){r.lastTouch=+new Date,Dt(r);var n=o.touches,l=n.length===1,u=n.length===2;l&&(Dt(r),Ho(r,o),Ze(Ue(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 i=o.touches[0];$o(r,i.clientX,i.clientY),Ze(Ue(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=Jg(r,o);m&&Zg(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 i=Ue(r);r.onChangeCallbacks.forEach(function(n){return n(i)}),Ze(i,{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=zl(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):Mg(o,p,m)},this.applyTransformation=function(){if(!(!r.mounted||!r.contentComponent)){var o=r.transformState,p=o.scale,m=o.positionX,v=o.positionY,i=r.handleTransformStyles(m,v,p);r.contentComponent.style.transform=i}},this.getContext=function(){return Ue(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,ds(r,r.transformState.scale),r.handleInitializeWrapperEvents(o),r.handleInitialize(o,p),r.initializeWindowEvents(),r.isInitialized=!0;var m=Ue(r);Ze(m,void 0,r.props.onInit)},this.props=s,this.setup=qo(this.props),this.transformState=Ol(this.props)}return e})(),ii=ae.createContext(null),tv=function(e,s){return typeof e=="function"?e(s):e},sv=ae.forwardRef(function(e,s){var r=C.useRef(new ev(e)).current,o=tv(e.children,Wr(r));return C.useImperativeHandle(s,function(){return Wr(r)},[r]),C.useEffect(function(){r.update(e)},[r,e]),ae.createElement(ii.Provider,{value:r},o)});ae.forwardRef(function(e,s){var r=C.useRef(null),o=C.useContext(ii);return C.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",is({},e,{ref:Tg([r,s])}))});function rv(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 iv=`.transform-component-module_wrapper__SPB86 {
|
|
40
|
-
position: relative;
|
|
41
|
-
width: -moz-fit-content;
|
|
42
|
-
width: fit-content;
|
|
43
|
-
height: -moz-fit-content;
|
|
44
|
-
height: fit-content;
|
|
45
|
-
overflow: hidden;
|
|
46
|
-
-webkit-touch-callout: none; /* iOS Safari */
|
|
47
|
-
-webkit-user-select: none; /* Safari */
|
|
48
|
-
-khtml-user-select: none; /* Konqueror HTML */
|
|
49
|
-
-moz-user-select: none; /* Firefox */
|
|
50
|
-
-ms-user-select: none; /* Internet Explorer/Edge */
|
|
51
|
-
user-select: none;
|
|
52
|
-
margin: 0;
|
|
53
|
-
padding: 0;
|
|
54
|
-
transform: translate3d(0, 0, 0);
|
|
55
|
-
}
|
|
56
|
-
.transform-component-module_content__FBWxo {
|
|
57
|
-
display: flex;
|
|
58
|
-
flex-wrap: wrap;
|
|
59
|
-
width: -moz-fit-content;
|
|
60
|
-
width: fit-content;
|
|
61
|
-
height: -moz-fit-content;
|
|
62
|
-
height: fit-content;
|
|
63
|
-
margin: 0;
|
|
64
|
-
padding: 0;
|
|
65
|
-
transform-origin: 0% 0%;
|
|
66
|
-
}
|
|
67
|
-
.transform-component-module_content__FBWxo img {
|
|
68
|
-
pointer-events: none;
|
|
69
|
-
}
|
|
70
|
-
`,Ko={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};rv(iv);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,i=e.contentStyle,n=e.wrapperProps,l=n===void 0?{}:n,u=e.contentProps,c=u===void 0?{}:u,g=C.useContext(ii),_=g.init,y=g.cleanupWindowEvents,x=C.useRef(null),a=C.useRef(null);return C.useEffect(function(){var h=x.current,d=a.current;return h!==null&&d!==null&&_&&_?.(h,d),function(){y?.()}},[]),ae.createElement("div",is({},l,{ref:x,className:"".concat(Yi.wrapperClass," ").concat(Ko.wrapper," ").concat(o),style:v}),ae.createElement("div",is({},c,{ref:a,className:"".concat(Yi.contentClass," ").concat(Ko.content," ").concat(m),style:i}),s))},ql=function(){var e=C.useContext(ii);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},ov=function(){var e=ql();return Wr(e)};function av(e){var s=ql(),r=C.useState(e(Gi(s))),o=r[0],p=r[1];return C.useEffect(function(){var m=!0,v=s.onChange(function(i){m&&p(e(Gi(i.instance)))});return function(){v(),m=!1}},[e,s]),o}function lv(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 cv(e,s){return Tt({queryKey:ne.files.tree(e||"",s),queryFn:()=>ge.get("/files/tree",{params:{workingDir:e||"",path:s}}),enabled:!!e})}function dv(e,s){return Tt({queryKey:ne.files.content(e||"",s||""),queryFn:()=>ge.get("/files/read",{params:{workingDir:e||"",path:s||""}}),enabled:!!e&&!!s})}function uv(e){const s=ot();return C.useCallback(()=>{e&&s.invalidateQueries({queryKey:["files","tree",e]})},[s,e])}function hv(){const e=ot();return St({mutationFn:s=>ge.post("/files/write",s),onSuccess:(s,r)=>{const o=ne.files.content(r.workingDir,r.path),p=e.getQueryData(o);e.setQueryData(o,{content:r.content,language:p?.language||lv(r.path)})}})}function fv(e,s){return e==="/"?`/${s}`:`${e}/${s}`}function mv(e,s){return e==="/"?s:`${e.slice(1)}/${s}`}const pv=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function gv(e){if(e.type==="directory")return null;const s=e.name.split(".").pop()?.toLowerCase();return s&&pv.has(s)?Ma:s==="ts"||s==="tsx"||s==="js"||s==="jsx"?Tr:s==="json"?Ud:s==="md"||s==="mdx"||s==="txt"?Ra:Sd}const Xo=({depth:e,active:s,onClick:r,leftIcon:o,rightIcon:p,label:m})=>t.jsxs("button",{type:"button",onClick:r,className:te("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})]}),Kl=({workingDir:e,path:s,depth:r,expanded:o,toggleDir:p,onFileSelect:m,selectedFilePath:v})=>{const{t:i}=ce(),{data:n,isLoading:l,isError:u}=cv(e,s),c=C.useMemo(()=>n?.items??[],[n?.items]);return l?t.jsx("div",{className:"text-xs text-neutral-400 px-2 py-1",style:{paddingLeft:8+r*14},children:i("Loading...")}):u?t.jsx("div",{className:"text-xs text-red-600 px-2 py-1",style:{paddingLeft:8+r*14},children:i("Failed to load")}):t.jsx("div",{className:"space-y-0.5",children:c.map(g=>{if(g.type==="directory"){const h=fv(s,g.name),d=o.has(h);return t.jsxs("div",{children:[t.jsx(Xo,{depth:r,onClick:()=>p(h),rightIcon:d?t.jsx(yt,{size:14,className:"text-neutral-400"}):t.jsx(Mt,{size:14,className:"text-neutral-400"}),leftIcon:d?t.jsx(Vr,{size:14,className:"text-amber-500"}):t.jsx(Ia,{size:14,className:"text-amber-500"}),label:g.name}),d&&t.jsx(Kl,{workingDir:e,path:h,depth:r+1,expanded:o,toggleDir:p,onFileSelect:m,selectedFilePath:v})]},h)}const _=mv(s,g.name),y=gv(g),x=v===_,a=y===Ma;return t.jsx(Xo,{depth:r,active:x,onClick:()=>m(_),rightIcon:t.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:y?t.jsx(y,{size:14,className:a?"text-emerald-600":"text-sky-600"}):null,label:g.name},_)})})},vv=({workingDir:e,className:s,onFileSelect:r,selectedFilePath:o,onCollapse:p})=>{const{t:m}=ce(),[v,i]=C.useState(()=>new Set),n=uv(e),l=C.useCallback(u=>{i(c=>{const g=new Set(c);return g.has(u)?g.delete(u):g.add(u),g})},[]);return t.jsxs("div",{className:te("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:n,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(ir,{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(iu,{size:13})})]})]}),t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin p-2",children:e?t.jsx(Kl,{workingDir:e,path:"/",depth:0,expanded:v,toggleDir:l,onFileSelect:r,selectedFilePath:o}):t.jsx("div",{className:"text-xs text-neutral-500 px-2 py-2",children:m("No workspace selected.")})})]})},xv=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function _v(e){const s=e.split(".").pop()?.toLowerCase();return s?xv.has(s):!1}function bv(e,s){const r="/api",o=new URLSearchParams({workingDir:e,path:s});return`${r}/files/image?${o.toString()}`}const yv=({filePath:e})=>{const{t:s}=ce(),{zoomIn:r,zoomOut:o,centerView:p}=ov(),m=av(i=>i.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(Su,{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(bu,{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(su,{size:13})}),t.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},Sv=({workingDir:e,filePath:s})=>{const{t:r}=ce(),[o,p]=C.useState(!1),m=bv(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(sv,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx(yv,{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 wv(e){const s=e.split("/");return s[s.length-1]||e}function Cv(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 kv=({active:e,name:s,isDirty:r,onClick:o,onClose:p})=>{const{t:m}=ce();return t.jsxs("button",{type:"button",onClick:o,className:te("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:te("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(ns,{size:12})})]})},Ev=({workingDir:e,className:s,readOnly:r=!1})=>{const{t:o}=ce(),[p,m]=C.useState([]),[v,i]=C.useState(null),n=hv(),[l,u]=C.useState(280),[c,g]=C.useState(!1),[_,y]=C.useState(!1),x=C.useRef(280),a=C.useCallback(()=>{g(A=>(A?u(x.current):x.current=l,!A))},[l]),h=C.useCallback(A=>{A.preventDefault(),y(!0);const B=A.clientX,D=l,z=M=>{const O=M.clientX-B,P=Math.min(480,Math.max(160,D+O));u(P)},H=()=>{y(!1),document.removeEventListener("mousemove",z),document.removeEventListener("mouseup",H)};document.addEventListener("mousemove",z),document.addEventListener("mouseup",H)},[l]);C.useEffect(()=>{m([]),i(null)},[e]);const d=C.useMemo(()=>p.find(A=>A.path===v)||null,[p,v]),{data:f,isFetching:b,isError:w,error:k}=dv(e,d?.isImage?null:v);C.useEffect(()=>{!v||!f||m(A=>A.map(B=>B.path!==v||B.isDirty||B.loaded?B:{...B,language:f.language||B.language,content:f.content,savedContent:f.content,isDirty:!1,loaded:!0}))},[v,f]);const j=C.useCallback(A=>{m(B=>{if(B.find(H=>H.path===A))return B;const z=_v(A);return[...B,{path:A,name:wv(A),language:Cv(A),content:"",savedContent:"",isDirty:!1,loaded:z,isImage:z}]}),i(A)},[]),S=C.useCallback(A=>{m(B=>{const D=B.filter(z=>z.path!==A);return i(z=>z!==A?z:D.length?D[D.length-1].path:null),D})},[]),E=C.useCallback(A=>{m(B=>B.map(D=>{if(D.path!==v)return D;const z=A!==D.savedContent;return{...D,content:A,isDirty:z}}))},[v]),R=C.useCallback(async()=>{r||!e||!d||(await n.mutateAsync({workingDir:e,path:d.path,content:d.content}),m(A=>A.map(B=>B.path===d.path?{...B,savedContent:B.content,isDirty:!1,loaded:!0}:B)))},[d,r,n,e]),L=C.useRef(()=>{});C.useEffect(()=>{L.current=()=>{R().catch(()=>{})}},[R]),C.useEffect(()=>{const A=B=>{r||(B.metaKey||B.ctrlKey)&&B.key.toLowerCase()==="s"&&(B.preventDefault(),L.current())};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[r]);const T=C.useCallback((A,B)=>{A.addCommand(B.KeyMod.CtrlCmd|B.KeyCode.KeyS,()=>{L.current()})},[]);return t.jsxs("div",{className:te("flex h-full overflow-hidden bg-white",s),style:_?{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:c?36:l,transition:_?"none":"width 0.15s ease"},children:c?t.jsx("div",{className:"h-full flex items-start pt-2 justify-center",children:t.jsx("button",{type:"button",onClick:a,className:"p-1.5 rounded hover:bg-neutral-100 text-neutral-500 hover:text-neutral-700 transition-colors",title:o("Expand file tree"),children:t.jsx(ou,{size:16})})}):t.jsx(t.Fragment,{children:t.jsx(vv,{workingDir:e,onFileSelect:j,selectedFilePath:d?.path||null,onCollapse:a},e||"no-working-dir")})}),!c&&t.jsx("div",{onMouseDown:h,className:te("w-1 shrink-0 cursor-col-resize transition-colors",_?"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:[p.length===0?t.jsx("div",{className:"px-2 pb-2 text-xs text-neutral-500",children:o("No open files")}):p.map(A=>t.jsx(kv,{active:A.path===v,name:A.name,isDirty:A.isDirty,onClick:()=>i(A.path),onClose:B=>{B.stopPropagation(),S(A.path)}},A.path)),t.jsxs("div",{className:"ml-auto flex items-center gap-2 pb-2 pr-1",children:[r&&t.jsx("span",{className:"text-[11px] text-neutral-400",children:o("Read-only")}),n.isPending&&t.jsxs("span",{className:"flex items-center gap-2 text-xs text-neutral-500",children:[t.jsx(Ye,{size:14,className:"animate-spin"}),o("Saving")]}),d?.isDirty&&!n.isPending&&t.jsx("span",{className:"text-[11px] text-amber-600",children:o("Unsaved")})]})]}),t.jsx("div",{className:"flex-1 min-h-0 relative",children:e?d?d.isImage?t.jsx(Sv,{workingDir:e,filePath:d.path}):t.jsxs(t.Fragment,{children:[t.jsx(Xp,{path:d.path,value:d.content,language:d.language,theme:"vs-light",height:"100%",onChange:r?void 0:A=>E(A??""),onMount:T,options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",automaticLayout:!0,readOnly:r}}),b&&!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(Ye,{size:14,className:"animate-spin"}),o("Loading file...")]})}),w&&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:[o("Failed to load file"),k instanceof Error?`: ${k.message}`:""]})]}):t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:o("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:o("No workspace selected.")})})]})]})};function ni(e,s={}){return Tt({queryKey:ne.git.changes(e||""),queryFn:()=>ge.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e&&(s.enabled??!0)})}function Xl(e,s,r){return Tt({queryKey:ne.git.diff(e||"",s||"",r),queryFn:()=>ge.get("/git/diff",{params:{workingDir:e||"",path:s||"",type:r}}),enabled:!!e&&!!s})}function In(e,s){return Tt({queryKey:ne.git.commitFiles(e||"",s||""),queryFn:()=>ge.get("/git/commit-files",{params:{workingDir:e||"",hash:s||""}}),enabled:!!e&&!!s})}function Bn(e,s,r){return Tt({queryKey:ne.git.commitDiff(e||"",s||"",r||""),queryFn:()=>ge.get("/git/commit-diff",{params:{workingDir:e||"",hash:s||"",path:r||""}}),enabled:!!e&&!!s&&!!r})}function Vl({isOpen:e,onClose:s,branchName:r,targetBranch:o,commitMessage:p,isPending:m,error:v,onConfirm:i}){const{t:n}=ce(),[l,u]=C.useState(""),[c,g]=C.useState(!1);C.useEffect(()=>{e&&(g(!1),u(p??""))},[e]),C.useEffect(()=>{c||!e||u(p??"")},[p,c,e]);const _=()=>{m||s()};return t.jsx(hs,{isOpen:e,onClose:_,title:n("提交变更"),className:"max-w-md",action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:_,disabled:m,className:"px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:n("取消")}),t.jsx("button",{onClick:()=>i(l.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(Ye,{size:14,className:"animate-spin"}),n("正在提交...")]}):t.jsxs(t.Fragment,{children:[t.jsx(Mr,{size:14}),n("确认提交")]})})]}),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(Ld,{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:n("提交消息")}),t.jsx("textarea",{value:l,onChange:y=>{g(!0),u(y.target.value)},placeholder:n("请描述本次修改的内容"),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:n("建议以 feat、fix、docs、refactor、chore 开头,保持提交记录清晰。feat 新增功能,fix 修复问题,docs 文档更新,refactor 代码重构,chore 日常维护。")}),!l.trim()&&t.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground/70",children:n("留空将使用默认消息")})]}),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 ws(e,s){const r=e[s];return typeof r=="string"&&r.length>0?r:void 0}function Yl(e){if(!(e instanceof xa)||e.status!==409)return;const s=e.details;if(s.code!=="MERGE_CONFLICT"||s.conflictOp!==Gs.REBASE&&s.conflictOp!==Gs.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:ws(s,"sourceBranch"),targetBranch:ws(s,"targetBranch"),sourceWorktreePath:ws(s,"sourceWorktreePath"),targetWorktreePath:ws(s,"targetWorktreePath"),sourceWorkspaceId:ws(s,"sourceWorkspaceId"),targetWorkspaceId:ws(s,"targetWorkspaceId")}}function Vo(e,s,r,o){const p=Yl(e);if(p){r(p);return}o(e instanceof Error?e.message:s)}function Gl({workspaceId:e,branchName:s,targetBranch:r,commitMessage:o,committedFileCount:p,onRefreshCommitMessage:m,onConflict:v,onResolveConflicts:i}){const{t:n}=ce(),{data:l,isLoading:u}=Nn(e),c=dl(),g=cl(),_=Rn(),[y,x]=C.useState(!1),[a,h]=C.useState(null);if(C.useEffect(()=>{y&&m?.()},[y,m]),u||!l)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(Ye,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:n("正在检查工作区状态...")})]});const d=l.conflictedFiles.length>0,f=l.operation!=="idle",b=l.hasUncommittedChanges||l.untrackedCount>0,w=l.uncommittedCount+l.untrackedCount,k=!d&&!f&&!b,j=l.operation==="idle"&&l.ahead===0&&l.behind===0&&!b&&!d,S=()=>{h(null),c.mutate(e,{onError:T=>{Vo(T,n("更新失败,请稍后重试"),A=>v(A),h)}})},E=()=>{h(null),x(!0)},R=T=>{h(null),g.mutate({id:e,commitMessage:T},{onSuccess:()=>x(!1),onError:A=>{Vo(A,n("提交失败,请稍后重试"),B=>{x(!1),v(B)},h)}})},L=()=>{g.isPending||(x(!1),h(null))};return j?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(Zd,{size:13}),t.jsx("span",{className:"text-xs",children:n("当前分支还没有任何变更")})]}):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:[a&&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:a}),b&&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(Xd,{size:12,className:"shrink-0"}),t.jsx("span",{children:n("{count} 个本地改动未处理,需要先整理后再继续",{count:w})})]}),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(rr,{size:13,className:"shrink-0"}),t.jsx("span",{children:n("{count} 个文件存在冲突,需要处理后继续",{count:l.conflictedFiles.length})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[t.jsx("button",{onClick:i,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:n("处理冲突")}),t.jsx("button",{onClick:()=>_.mutate(e),disabled:_.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:_.isPending?n("正在撤销..."):n("撤销操作")})]})]}),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(Ye,{size:13,className:"animate-spin shrink-0"}),t.jsx("span",{children:l.operation==="rebase"?n("正在同步源分支更新..."):n("正在提交变更...")})]}),t.jsxs("button",{onClick:()=>_.mutate(e),disabled:_.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(jd,{size:12}),_.isPending?n("正在撤销..."):n("撤销操作")]})]}),!d&&!f&&(l.behind>0||l.ahead>0)&&t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[l.behind>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:n("源分支 {branch} 有 {count} 个更新",{branch:r,count:l.behind})}),t.jsxs("button",{onClick:S,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(ir,{size:12}),c.isPending?n("正在同步..."):n("同步更新")]})]}),l.ahead>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:n("{count} 个文件变更,可以安全提交",{count:p??l.ahead})}),l.behind===0&&!b?t.jsxs("button",{onClick:E,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(Mr,{size:12}),n("提交变更")]}):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:n(b?"需要先处理本地改动":"需要先同步源分支更新"),children:[t.jsx(Mr,{size:12}),n("提交变更")]})]})]})]})}),t.jsx(Vl,{isOpen:y,onClose:L,branchName:s,targetBranch:r,commitMessage:o,isPending:g.isPending,error:a,onConfirm:R})]})}const Ai=50,Mi=400,Yo={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"},Go={M:"bg-amber-500",A:"bg-emerald-500",D:"bg-red-500",R:"bg-blue-500"};function Ql(e){const s=e.split("/");return s[s.length-1]||e}function jv(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function Nv(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?pt("{count}s ago",{count:r}):r<3600?pt("{count}m ago",{count:Math.floor(r/60)}):r<86400?pt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?pt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function jr(e,s){return e.kind==="working"?`${e.diffType}:${s}`:`${e.hash}:${s}`}const Zi=({additions:e,deletions:s,className:r})=>e===void 0&&s===void 0?null:t.jsxs("span",{className:te("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"})]}),Rv=({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:te("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:te("pl-2 whitespace-pre",o),children:e})]})},Zl=({diff:e})=>{const{t:s}=ce(),[r,o]=C.useState(!1),p=C.useMemo(()=>e.split(`
|
|
71
|
-
`),[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>Mi,v=m?p.slice(0,Mi):p;return t.jsxs("div",{className:"overflow-x-auto scrollbar-app-thin font-mono text-xs leading-5",children:[v.map((i,n)=>t.jsx(Rv,{line:i,lineNum:n+1},n)),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-Mi})})]})},Av=({workingDir:e,path:s,diffType:r,enabled:o})=>{const{t:p}=ce(),{data:m,isLoading:v,isError:i}=Xl(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(Ye,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:p("正在加载差异...")})]}):i?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:p("差异加载失败")}):t.jsx(Zl,{diff:m?.diff||""})},Mv=({workingDir:e,hash:s,path:r,enabled:o})=>{const{t:p}=ce(),{data:m,isLoading:v,isError:i}=Bn(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(Ye,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:p("正在加载差异...")})]}):i?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:p("差异加载失败")}):t.jsx(Zl,{diff:m?.diff||""})},Ti=({entry:e,source:s,workingDir:r,flash:o,registerNode:p})=>{const[m,v]=C.useState(!1),[i,n]=C.useState(!1),l=C.useRef(null),u=jr(s,e.path);C.useEffect(()=>(p(u,l.current),()=>p(u,null)),[u,p]),C.useEffect(()=>{const _=l.current;if(!_||i)return;const y=new IntersectionObserver(x=>{x.some(a=>a.isIntersecting)&&(n(!0),y.disconnect())},{rootMargin:"300px 0px"});return y.observe(_),()=>y.disconnect()},[i]);const c=Yo[e.status]||Yo.M,g=jv(e.path);return t.jsxs("div",{ref:l,"data-card-key":u,className:te("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(_=>!_),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(yt,{size:13,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:te("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:Ql(e.path)}),g&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate",children:g}),t.jsx("span",{className:"ml-auto"}),t.jsx(Zi,{additions:e.additions,deletions:e.deletions})]}),!m&&t.jsx("div",{className:"border-t border-border/60",children:s.kind==="working"?t.jsx(Av,{workingDir:r,path:e.path,diffType:s.diffType,enabled:i}):t.jsx(Mv,{workingDir:r,hash:s.hash,path:e.path,enabled:i})})]})};function Tv(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 Jl(s)}function Jl(e){const s=new Map;for(const r of e.dirs.values()){let o=Jl(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 Dv=({dir:e,depth:s,activeKey:r,onSelect:o})=>{const[p,m]=C.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(Vr,{size:12,className:"text-muted-foreground/70 shrink-0"}):t.jsx(Ia,{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(ec,{node:e,depth:s+1,activeKey:r,onSelect:o})]})},ec=({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(Dv,{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:te("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:te("w-1.5 h-1.5 rounded-full shrink-0",Go[p.status]||Go.M)}),t.jsx("span",{className:te("text-xs truncate",m?"text-foreground font-medium":"text-foreground/90"),children:Ql(p.path)})]},p.cardKey)})]}),Lv=({workingDir:e,selectedHash:s,onSelectCommit:r})=>{const{t:o}=ce(),{data:p,isLoading:m,fetchNextPage:v,hasNextPage:i,isFetchingNextPage:n}=gn({queryKey:ne.git.log(e),queryFn:({pageParam:u=0})=>ge.get("/git/log",{params:{workingDir:e,limit:String(Ai),skip:String(u)}}),initialPageParam:0,getNextPageParam:(u,c)=>u.commits.length<Ai?void 0:c.length*Ai}),l=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(Ye,{size:11,className:"animate-spin"}),t.jsx("span",{children:o("正在加载提交记录...")})]}):l.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:[l.map(u=>{const c=s===u.hash;return t.jsxs("button",{type:"button",onClick:()=>r(u),className:te("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:te("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:te("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," · ",Nv(u.timestamp)]})]})]},u.hash)}),i&&t.jsx("button",{type:"button",onClick:()=>v(),disabled:n,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:n?t.jsxs(t.Fragment,{children:[t.jsx(Ye,{size:11,className:"animate-spin"})," ",o("正在加载...")]}):o("加载更多提交")})]})},Pv=({workingDir:e,workspaceId:s,branchName:r,targetBranch:o,commitMessage:p,canRunGitOperations:m,onRefreshCommitMessage:v,onConflict:i,onResolveConflicts:n})=>{const{t:l}=ce(),[u,c]=C.useState({kind:"overview"}),[g,_]=C.useState(""),[y,x]=C.useState(null),[a,h]=C.useState(null),{data:d,isLoading:f,isError:b}=ni(e),w=u.kind==="commit"?u.commit.hash:null,{data:k,isLoading:j}=In(e,w),S=C.useRef(new Map),E=C.useRef(null),R=C.useRef(null),L=C.useCallback((q,V)=>{V?S.current.set(q,V):S.current.delete(q)},[]),{uncommitted:T,committed:A,commitFiles:B}=C.useMemo(()=>{const q=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(q).map(X=>({...X,cardKey:jr(N,X.path)}));return{uncommitted:[],committed:[],commitFiles:W}}const V=(d?.uncommitted||[]).filter(q).map(N=>({...N,cardKey:jr({kind:"working",diffType:"uncommitted"},N.path)})),F=(d?.committed||[]).filter(q).map(N=>({...N,cardKey:jr({kind:"working",diffType:"committed"},N.path)}));return{uncommitted:V,committed:F,commitFiles:[]}},[u,d,k,g]),D=u.kind==="commit"?B:[...T,...A],z=C.useMemo(()=>Tv(D),[D]),H=C.useMemo(()=>{let q=0,V=0;for(const F of D)q+=F.additions??0,V+=F.deletions??0;return{additions:q,deletions:V,files:D.length}},[D]),M=C.useCallback(()=>{const q=E.current;if(!q)return;const V=q.getBoundingClientRect().top;let F=null,N=Number.NEGATIVE_INFINITY;for(const[W,X]of S.current){const K=X.getBoundingClientRect().top-V;K<=48&&K>N&&(N=K,F=W)}if(!F){let W=null,X=Number.POSITIVE_INFINITY;for(const[K,ie]of S.current){const Z=ie.getBoundingClientRect().top-V;Z<X&&(X=Z,W=K)}F=W}x(F)},[]);C.useEffect(()=>{const q=E.current;if(!q)return;let V=0;const F=()=>{cancelAnimationFrame(V),V=requestAnimationFrame(M)};return q.addEventListener("scroll",F,{passive:!0}),()=>{q.removeEventListener("scroll",F),cancelAnimationFrame(V)}},[M]);const O=C.useCallback(q=>{const V=S.current.get(q.cardKey);V&&(V.scrollIntoView({behavior:"smooth",block:"start"}),x(q.cardKey),h(q.cardKey),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>h(null),1200))},[]),P=C.useCallback(q=>{c(V=>V.kind==="commit"&&V.commit.hash===q.hash?{kind:"overview"}:{kind:"commit",commit:q}),_(""),x(null),E.current?.scrollTo({top:0})},[]),I=C.useCallback(()=>{c({kind:"overview"}),_(""),x(null),E.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:l("未选择工作区")});const $=m&&s&&r&&o,Y=u.kind==="commit"?j:f;return t.jsxs("div",{className:"flex h-full w-full min-w-0 flex-col bg-background",children:[$&&i&&n&&t.jsx(Gl,{workspaceId:s,branchName:r,targetBranch:o,commitMessage:p,committedFileCount:d?.committed?.length,onRefreshCommitMessage:v,onConflict:i,onResolveConflicts:n}),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(Ls,{size:14,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:l("代码审查")}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:l("{count} 个文件",{count:H.files})}),t.jsx(Zi,{additions:H.additions,deletions:H.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:I,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}),l("全部变更")]}),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(Zi,{className:"ml-auto",additions:H.additions,deletions:H.deletions})]})}),t.jsxs("div",{className:"flex flex-1 min-h-0",children:[t.jsx("div",{ref:E,className:"flex-1 min-w-0 overflow-y-auto scrollbar-app-thin",children:Y?t.jsx("div",{className:"p-3 space-y-3",children:[0,1].map(q=>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"})]})]},q))}):b&&u.kind==="overview"?t.jsx("div",{className:"flex-1 flex items-center justify-center py-16 text-destructive text-sm",children:l("变更加载失败")}):D.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted-foreground/60",children:[t.jsx(Tr,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:g.trim()?l("没有匹配筛选条件的文件"):u.kind==="commit"?l("该提交没有文件变更"):l("没有待审查的变更")})]}):u.kind==="commit"?t.jsx("div",{className:"p-3 space-y-3",children:B.map(q=>t.jsx(Ti,{entry:q,source:{kind:"commit",hash:u.commit.hash},workingDir:e,flash:a===q.cardKey,registerNode:L},q.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:l("未提交")}),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(q=>t.jsx(Ti,{entry:q,source:{kind:"working",diffType:"uncommitted"},workingDir:e,flash:a===q.cardKey,registerNode:L},q.cardKey))})]}),A.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:l("已提交")}),t.jsx("span",{className:"ml-2 text-[11px] text-muted-foreground/70",children:A.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:A.map(q=>t.jsx(Ti,{entry:q,source:{kind:"working",diffType:"committed"},workingDir:e,flash:a===q.cardKey,registerNode:L},q.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(ln,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground/60"}),t.jsx("input",{value:g,onChange:q=>_(q.target.value),placeholder:l("筛选文件..."),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:D.length===0?t.jsx("div",{className:"px-2 py-3 text-[11px] text-muted-foreground/60",children:g.trim()?l("无匹配文件"):l("暂无变更文件")}):t.jsx(ec,{node:z,depth:0,activeKey:y,onSelect:O})}),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(Ts,{size:12,className:"text-muted-foreground"}),t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:l("提交记录")})]}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin min-h-0",children:t.jsx(Lv,{workingDir:e,selectedHash:w,onSelectCommit:P})})]})]})]})]})},Di=50,Qo={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 Ov(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?pt("{count}s ago",{count:r}):r<3600?pt("{count}m ago",{count:Math.floor(r/60)}):r<86400?pt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?pt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function Iv(e){const s=e.split("/");return s[s.length-1]||e}function Bv(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}const Fv=({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:te("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:te("pl-2 whitespace-pre",o),children:e})]})},zv=({workingDir:e,hash:s,filePath:r})=>{const{t:o}=ce(),{data:p,isLoading:m,isError:v}=Bn(e,s,r);if(m)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:[t.jsx(Ye,{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 i=p?.diff||"";if(!i.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 n=i.split(`
|
|
72
|
-
`);return t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin font-mono text-xs leading-5",children:n.map((l,u)=>t.jsx(Fv,{line:l,lineNum:u+1},u))})},Wv=({workingDir:e,hash:s,selectedPath:r,onSelectFile:o})=>{const{t:p}=ce(),{data:m,isLoading:v}=In(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(Ye,{size:12,className:"animate-spin"}),t.jsx("span",{children:p("Loading...")})]});const i=m?.files||[];return i.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:i.map(n=>{const l=Qo[n.status]||Qo.M,u=Bv(n.path);return t.jsxs("button",{type:"button",onClick:c=>{c.stopPropagation(),o(n.path)},className:te("flex items-center gap-2 px-1.5 py-1 rounded-sm cursor-pointer w-full text-left",r===n.path?"bg-muted":"hover:bg-muted/60"),children:[t.jsx("span",{className:te("w-4 h-4 flex items-center justify-center text-[11px] font-semibold border rounded-sm shrink-0",l),children:n.status}),t.jsx("span",{className:"text-xs text-foreground truncate",children:Iv(n.path)}),u&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate ml-auto shrink-0",children:u})]},n.path)})})},Hv=({workingDir:e})=>{const{t:s}=ce(),{data:r,isLoading:o,isError:p,fetchNextPage:m,hasNextPage:v,isFetchingNextPage:i}=gn({queryKey:ne.git.log(e||""),queryFn:({pageParam:w=0})=>ge.get("/git/log",{params:{workingDir:e||"",limit:String(Di),skip:String(w)}}),initialPageParam:0,getNextPageParam:(w,k)=>w.commits.length<Di?void 0:k.length*Di,enabled:!!e}),n=r?.pages.flatMap(w=>w.commits)||[],[l,u]=C.useState(null),[c,g]=C.useState(null),[_,y]=C.useState(280),[x,a]=C.useState(!1),h=C.useCallback(w=>{w.preventDefault(),a(!0);const k=w.clientX,j=_,S=R=>{const L=Math.min(480,Math.max(180,j+(R.clientX-k)));y(L)},E=()=>{a(!1),document.removeEventListener("mousemove",S),document.removeEventListener("mouseup",E)};document.addEventListener("mousemove",S),document.addEventListener("mouseup",E)},[_]),d=w=>{l===w?(u(null),g(null)):(u(w),g(null))},f=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(o)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground bg-background h-full",children:[t.jsx(Ye,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading history...")})]});if(p)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(n.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(Ts,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:s("No commit history")})]});const b=n.find(w=>w.hash===l);return t.jsxs("div",{className:"flex h-full bg-background",style:x?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsxs("div",{className:"border-r border-border flex flex-col shrink-0",style:{width:_},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(Ts,{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:n.length})]})}),t.jsxs("div",{ref:f,className:"flex-1 overflow-auto scrollbar-app-thin p-1.5",children:[n.map(w=>{const k=l===w.hash;return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>d(w.hash),className:te("flex items-start gap-2 px-2 py-1.5 rounded-sm cursor-pointer w-full text-left group",k?"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:te("w-2 h-2 rounded-full shrink-0 transition-colors",k?"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:w.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate flex-1",children:w.message}),t.jsx(Mt,{size:12,className:te("shrink-0 text-muted-foreground/70 transition-transform",k&&"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:w.author}),t.jsx("span",{className:"text-[11px] text-muted-foreground/70",children:Ov(w.timestamp)})]})]})]}),k&&t.jsxs(t.Fragment,{children:[w.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:w.body}),t.jsx(Wv,{workingDir:e,hash:w.hash,selectedPath:c,onSelectFile:g})]})]},w.hash)}),v&&t.jsx("button",{type:"button",onClick:()=>m(),disabled:i,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:i?t.jsxs(t.Fragment,{children:[t.jsx(Ye,{size:12,className:"animate-spin"})," ",s("Loading...")]}):s("Load more")})]})]}),t.jsx("div",{onMouseDown:h,className:te("w-1 shrink-0 cursor-col-resize transition-colors",x?"bg-info/60":"bg-transparent hover:bg-info/30")}),t.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:c&&l?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"px-3 py-2 border-b border-border/60 flex items-center gap-2 shrink-0",children:[t.jsx(Tr,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:c}),t.jsxs("span",{className:"text-[11px] text-muted-foreground/70",children:["(",b?.shortHash,")"]})]}),t.jsx(zv,{workingDir:e,hash:l,filePath:c})]}):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(Tr,{size:28}),t.jsx("span",{className:"text-xs",children:s(l?"Select a file to view diff":"Select a commit to view changes")})]})})})]})};function $v(e){return Tt({queryKey:ne.previews.status(e??""),queryFn:async()=>{const s=await ge.get(`/previews/${e}/status`);return{...s,viewUrl:s.viewUrl?s.viewUrl:null}},enabled:!!e,refetchOnWindowFocus:!1})}function Uv(e){const s=ot();return St({mutationFn:r=>ge.put(`/previews/${e}/config`,{target:r}),onSuccess:()=>{e&&(s.invalidateQueries({queryKey:ne.previews.status(e)}),s.invalidateQueries({queryKey:ne.workspaces.all}))}})}function qv(){return"3000, localhost:3000, http://127.0.0.1:5173"}function Kv({workspaceId:e,readOnly:s}){const{t:r}=ce(),{data:o,isLoading:p,refetch:m,isFetching:v}=$v(e),i=Uv(e),[n,l]=C.useState(""),[u,c]=C.useState(0);C.useEffect(()=>{l(o?.target??"")},[o?.target]);const g=C.useMemo(()=>!o?.ready||!o.viewUrl?null:`${o.viewUrl}?_=${u}`,[u,o?.ready,o?.viewUrl]),_=async()=>{if(e)try{await i.mutateAsync(n.trim()||null),c(x=>x+1),ct.success(r("Preview target saved"))}catch(x){const a=x instanceof Error?x.message:r("Failed to save preview target");ct.error(a)}},y=async()=>{await m(),c(x=>x+1)};return e?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-3 py-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{value:n,onChange:x=>l(x.target.value),onKeyDown:x=>{x.key==="Enter"&&!x.nativeEvent.isComposing&&(x.preventDefault(),_())},disabled:s||i.isPending,placeholder:qv(),className:"h-8 min-w-0 flex-1 rounded-md border border-neutral-200 bg-white px-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.jsxs(Re,{type:"button",size:"sm",variant:"outline",onClick:_,disabled:s||i.isPending,title:r("Save preview target"),children:[i.isPending?t.jsx(Ye,{className:"animate-spin"}):t.jsx(pu,{}),t.jsx("span",{className:"hidden xl:inline",children:r("Save")})]}),t.jsxs(Re,{type:"button",size:"sm",variant:"outline",onClick:y,disabled:v,title:r("Refresh preview"),children:[v?t.jsx(Ye,{className:"animate-spin"}):t.jsx(ir,{}),t.jsx("span",{className:"hidden xl:inline",children:r("Refresh")})]}),o?.ready&&o.viewUrl&&t.jsx(Re,{type:"button",size:"sm",variant:"outline",asChild:!0,title:r("Open preview in new tab"),children:t.jsx("a",{href:o.viewUrl,target:"_blank",rel:"noopener noreferrer",children:t.jsx(vn,{})})})]}),t.jsxs("div",{className:"mt-1 flex min-h-4 items-center justify-between gap-2 text-[11px] leading-4",children:[t.jsx("span",{className:"truncate text-neutral-500",children:p?r("Checking preview target..."):o?.ready?`${r("Proxying")} ${o.target}`:o?.configured?`${r("Preview target is not reachable")}${o.error?`: ${o.error}`:""}`:r("Enter a local preview URL on the Agent Tower machine.")}),t.jsx("span",{className:"shrink-0 text-neutral-400",children:r("Loopback only")})]})]}),t.jsx("div",{className:"relative flex-1 min-h-0 bg-white",children:g?t.jsx("iframe",{src:g,title:r("Preview"),className:"absolute inset-0 h-full w-full border-0 bg-white",sandbox:"allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups allow-same-origin allow-scripts"},g):t.jsx("div",{className:"absolute inset-0 flex items-center justify-center px-4 text-center text-sm text-neutral-500",children:o?.configured?r("Start the preview server, then refresh."):r("Configure a local preview target to display it here.")})})]}):t.jsx("div",{className:"h-full flex items-center justify-center bg-white text-sm text-neutral-500",children:r("No active workspace.")})}function Xv(e){switch(e){case Rt.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case Rt.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case Rt.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case Rt.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function Zo(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 Vv(e){return e.length<=34?e:`...${e.slice(-31)}`}function tc({workspaces:e,teamRun:s,selectedWorkspaceId:r,onSelectWorkspace:o,disabled:p,className:m,buttonClassName:v}){const{t:i}=ce(),[n,l]=C.useState(!1),u=C.useRef(null),c=C.useMemo(()=>Tn(e,s),[e,s]),g=c.find(_=>_.workspace.id===r)??c[0];return C.useEffect(()=>{if(!n)return;const _=y=>{u.current&&!u.current.contains(y.target)&&l(!1)};return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[n]),c.length<=1?null:t.jsxs("div",{ref:u,className:te("relative",m),children:[t.jsxs("button",{type:"button",onClick:()=>l(_=>!_),disabled:p,className:te("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:i("Workspace"),children:[t.jsx(As,{size:14,className:"shrink-0 text-neutral-500"}),t.jsx("span",{className:te("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",Zo(g.roleLabel)),children:i(g.roleLabel)}),t.jsx("span",{className:"min-w-0 truncate font-medium text-neutral-900",children:i(g.displayName)}),t.jsx("span",{className:"min-w-0 truncate font-mono text-[11px] text-neutral-500",children:Vv(fs(g.workspace))}),t.jsx(yt,{size:13,className:te("shrink-0 text-neutral-400 transition-transform",n&&"rotate-180")})]}),n&&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(_=>{const y=_.workspace.id===g.workspace.id;return t.jsxs("button",{type:"button",onClick:()=>{o(_.workspace.id),l(!1)},className:te("flex w-full items-start gap-2 px-3 py-2 text-left transition-colors hover:bg-neutral-50",y&&"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:y?t.jsx(qt,{size:13}):t.jsx(Aa,{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:i(_.displayName)}),t.jsx("span",{className:te("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",Zo(_.roleLabel)),children:i(_.roleLabel)}),t.jsx("span",{className:te("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",Xv(_.workspace.status)),children:_.workspace.status})]}),t.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-neutral-500",children:fs(_.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:[_.ownerName&&t.jsxs("span",{children:[i("Owner"),": ",_.ownerName]}),_.parentBranchName&&t.jsxs("span",{children:[i("Parent"),": ",_.parentBranchName]}),t.jsx("span",{children:_.workspace.id.slice(0,8)})]})]})]},_.workspace.id)})})]})}const Yv=[{key:"review",label:"Changes",icon:t.jsx(Ls,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(Xr,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(Ar,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(Na,{size:14})}],Gv=[{key:"history",label:"History",icon:t.jsx(Ts,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(Xr,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(Ar,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(Na,{size:14})}],Qv=({active:e,onClick:s,icon:r,label:o})=>t.jsxs("button",{type:"button",onClick:s,className:te("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})]}),Zv=({active:e,onClick:s,icon:r,label:o})=>t.jsx("button",{type:"button",onClick:s,title:o,"aria-label":o,"aria-pressed":e,className:te("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:i=!0,readOnly:n,repoDeleted:l,teamRun:u,teamStatus:c,gitProps:g,workspaces:_,selectedWorkspaceId:y,onSelectWorkspace:x,variant:a="tabs",expanded:h,onExpandedChange:d,minContentWidth:f=520,tabRef:b}){const{t:w}=ce(),k=sn(F=>F.setVisibleContext),j=a==="rail",[S,E]=C.useState(!1),R=j?h??S:!0,L=C.useCallback(F=>{h===void 0&&E(F),d?.(F)},[h,d]),T=C.useMemo(()=>{const F=v?Gv:Yv,N=i?F:F.filter(X=>X.key!=="review"&&X.key!=="history"),W=n?N.filter(X=>X.key!=="terminal"):N;return u?[{key:"team-status",label:"Team Status",icon:t.jsx(us,{size:14})},...W]:W},[i,v,n,u]),[A,B]=C.useState(i?v?"history":"review":"editor"),D=C.useCallback(F=>{B(F),j&&L(!0)},[j,L]);C.useImperativeHandle(b,()=>({setTab:F=>D(F)}),[D]);const{data:z}=wd(m??""),H=C.useMemo(()=>{if(!z?.quickCommands)return[];try{return JSON.parse(z.quickCommands)}catch{return[]}},[z?.quickCommands]),[M,O]=C.useState([]),P=C.useRef(void 0);C.useEffect(()=>{p&&p!==P.current&&(P.current=p,O(F=>F.includes(p)?F:[...F,p]))},[p]),C.useEffect(()=>{T.some(F=>F.key===A)||B(T[0]?.key??"editor")},[A,T]),C.useEffect(()=>{if(j&&!R)return;const F=A==="review"?"changes":A==="history"?"history":null;if(!o||!p||!F){k(null);return}return k({workspaceId:o,workingDir:p,tab:F}),()=>{k(null)}},[A,R,j,k,p,o]);const I=!!x&&Tn(_,u).length>1,$=T.find(F=>F.key===A)??T[0],Y=$?w($.label):"",q=n?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:w(l?"项目已删除且本地仓库文件已清理。这里只保留历史视图。":"项目已删除。Workspace 以只读模式展示历史内容。")}):null,V=t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[I&&t.jsx("div",{className:"shrink-0 px-3 py-1.5 border-b border-neutral-100 bg-neutral-50/60",children:t.jsx(tc,{workspaces:_,teamRun:u,selectedWorkspaceId:y,onSelectWorkspace:x,buttonClassName:"h-7 text-[11px]"})}),t.jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[A==="team-status"&&u&&c,A==="editor"&&t.jsx(Ev,{workingDir:p,readOnly:n}),M.map(F=>{const N=A==="terminal"&&p===F;return t.jsx("div",{className:"h-full absolute inset-0",style:{display:N?"block":"none"},children:t.jsx(Bm,{cwd:F,isVisible:N,quickCommands:H})},F)}),A==="preview"&&t.jsx(Kv,{workspaceId:o,readOnly:n}),A==="review"&&t.jsx(Pv,{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}),A==="history"&&t.jsx(Hv,{workingDir:p})]})]});return j?t.jsxs("div",{className:te("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:T.map(F=>t.jsx(Zv,{active:R&&A===F.key,onClick:()=>D(F.key),icon:F.icon,label:w(F.label)},F.key))}),R&&t.jsxs("div",{className:"flex h-full min-w-0 flex-1 flex-col border-l border-border bg-background",style:{minWidth:f},children:[q,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:$?.icon}),t.jsx("span",{className:"truncate",children:Y})]}),t.jsx("button",{type:"button",onClick:()=>L(!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:w("收起"),"aria-label":w("收起"),children:t.jsx(lu,{size:15})})]}),V]})]}):t.jsxs("div",{className:te("flex h-full w-full min-w-0 flex-col bg-white",s),children:[n&&q,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:T.map(F=>t.jsx(Qv,{active:A===F.key,onClick:()=>D(F.key),icon:F.icon,label:w(F.label)},F.key))}),V]})}),Jo=1500,Jv=3e3;function e0(e){const[s,r]=C.useState(null),o=C.useRef(0),p=C.useRef(null),m=C.useRef(null);return C.useEffect(()=>{if(!e)return;const v=()=>{m.current&&(clearTimeout(m.current),m.current=null)},i=Jt.connect(),n=u=>{r(u),m.current=setTimeout(()=>r(null),Jv)},l=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,_=Jo-g;o.current===0?(o.current=Date.now(),r({status:"running",totalCommands:u.totalCommands,currentIndex:u.totalCommands}),p.current=c,m.current=setTimeout(()=>n(c),Jo)):_>0?(p.current=c,v(),m.current=setTimeout(()=>n(c),_)):n(c)};return i.on(at.WORKSPACE_SETUP_PROGRESS,l),()=>{i.off(at.WORKSPACE_SETUP_PROGRESS,l),v(),o.current=0,p.current=null}},[e]),s}function Fn(){const e=ot();return St({mutationFn:s=>ge.post(`/sessions/${s}/start`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:ne.sessions.detail(r)}),e.invalidateQueries({queryKey:ne.tasks.all})}})}function rc(){const e=ot();return St({mutationFn:s=>ge.post(`/sessions/${s}/stop`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:ne.sessions.detail(r)})}})}function zn(){const e=ot();return St({mutationFn:({id:s,message:r,providerId:o})=>ge.post(`/sessions/${s}/message`,{message:r,providerId:o}),onSuccess:()=>{e.invalidateQueries({queryKey:ne.workspaces.all}),e.invalidateQueries({queryKey:ne.tasks.all})}})}function ic({isOpen:e,onClose:s,onStarted:r,taskId:o,taskTitle:p,taskDescription:m,taskPrompt:v,projectIsGitRepo:i=!0}){const{t:n}=ce(),[l,u]=C.useState(""),[c,g]=C.useState(""),[_,y]=C.useState(jt.WORKTREE),[x,a]=C.useState("idle"),[h,d]=C.useState(null),f=ot(),b=ll(o),w=Fn(),{data:k,isLoading:j}=Ds();C.useEffect(()=>{if(!e||!k)return;const A=k.find(B=>B.availability.type!=="NOT_FOUND");A&&u(A.provider.id)},[e,k]),C.useEffect(()=>{if(e){const A=[p];m&&A.push(m),g(v?.trim()||A.join(`
|
|
73
|
-
|
|
74
|
-
`)),y(i?jt.WORKTREE:jt.MAIN_DIRECTORY),a("idle"),d(null)}},[e,i,p,m,v]),C.useEffect(()=>{i||y(jt.MAIN_DIRECTORY)},[i]);const S=x!=="idle",E=async()=>{if(!(!l||!c.trim())){d(null);try{a("creating-workspace");const A=await b.mutateAsync({workspaceKind:i?_:jt.MAIN_DIRECTORY});a("creating-session");const B=await ge.post(`/workspaces/${A.id}/sessions`,{providerId:l,prompt:c.trim()});a("starting-session"),await w.mutateAsync(B.id),await f.invalidateQueries({queryKey:ne.workspaces.list(o)}),a("idle"),r?.(),s()}catch(A){a("idle"),d(A instanceof Error?A.message:n("启动失败,请重试"))}}},R={idle:n("启动"),"creating-workspace":n("创建工作空间..."),"creating-session":n("创建会话..."),"starting-session":n("启动 Agent...")},L=(k??[]).map(({provider:A,availability:B})=>{const D=B.type!=="NOT_FOUND";return{value:A.id,label:D?A.name:`${A.name}${n(" (不可用)")}`,icon:t.jsx(Kr,{agentType:A.agentType,className:"size-4"}),disabled:!D}}),T=[{value:jt.WORKTREE,label:n("工作树模式"),disabled:!i},{value:jt.MAIN_DIRECTORY,label:n("本地模式")}];return t.jsx(hs,{isOpen:e,onClose:S?()=>{}:s,title:n("启动 Agent"),action:t.jsxs(t.Fragment,{children:[t.jsx(Re,{variant:"outline",onClick:s,disabled:S,children:n("取消")}),t.jsx(Re,{onClick:E,disabled:S||!l||!c.trim(),children:R[x]})]}),children:t.jsxs("div",{className:"space-y-5",children:[t.jsxs("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:n("Agent")}),t.jsx(cs,{value:l,onChange:u,options:L,placeholder:n(j?"加载中...":"选择 Agent"),disabled:S||j})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:n("模式")}),t.jsx(cs,{value:_,onChange:A=>y(A),options:T,disabled:S||!i})]})]}),!i&&t.jsx("div",{className:"mt-2 rounded-lg border border-sky-200 bg-sky-50 px-3 py-2 text-xs leading-relaxed text-sky-800",children:n("Local projects only support local Solo tasks. Initialize Git to use worktrees and TeamRun.")}),_===jt.MAIN_DIRECTORY&&t.jsx("div",{className:"mt-2 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs leading-relaxed text-amber-800",children:n("Agent 将直接修改项目主目录;不会自动提交,也不能使用 Merge、Rebase 或冲突解决流程。")})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:n("任务描述")}),t.jsx("textarea",{value:c,onChange:A=>g(A.target.value),rows:5,disabled:S,placeholder:n("描述你想让 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"})]}),h&&t.jsx("div",{className:"text-sm text-red-600 bg-red-50 border border-red-100 rounded-lg px-3 py-2",children:h})]})})}function nc(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(n=>n.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,i=o&&p?.name&&o!==p.name?`${p.name} (${o})`:m;return{label:m,title:i,agentType:v}}function oc({session:e,providers:s,usage:r,compact:o=!1,providerIdFallback:p,agentTypeFallback:m,tokenTooltipSide:v="top"}){const{t:i}=ce(),n=t0(e,s,{providerId:p,agentType:m});return!n&&!r?null:t.jsxs("div",{className:`flex shrink-0 items-center ${o?"gap-1":"gap-2"}`,children:[n&&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:`${i("Provider")}: ${n.title}`,children:[t.jsx(Kr,{agentType:n.agentType,className:o?"size-3":"size-3.5"}),t.jsx("span",{className:"min-w-0 truncate",children:cd(n.label,o?12:18)})]}),t.jsx(fn,{usage:r,tooltipSide:v})]})}function s0({isOpen:e,onClose:s,taskId:r}){const{t:o}=ce(),[p,m]=C.useState("AUTO"),[v,i]=C.useState(null),[n,l]=C.useState([]),[u,c]=C.useState(null),g=_a();C.useEffect(()=>{e&&(m("AUTO"),i(null),l([]),c(null))},[e]);const _=g.isPending,y=!!v||n.length>0,x=async()=>{if(!_){if(!v&&n.length===0){c(o("请选择至少一个团队模板或成员预设。"));return}c(null);try{await g.mutateAsync({taskId:r,mode:p,...v?{teamTemplateId:v}:{},...n.length>0?{memberPresetIds:n}:{}}),s()}catch(h){if(h instanceof xa&&h.status===409){c(o("该任务已经存在 TeamRun。请刷新后再试。"));return}c(h instanceof Error?h.message:o("创建 TeamRun 失败"))}}},a=_||!y;return t.jsxs(hs,{isOpen:e,onClose:_?()=>{}:s,title:o("创建 TeamRun"),className:"max-w-5xl",action:t.jsxs(t.Fragment,{children:[t.jsx(Re,{type:"button",variant:"outline",onClick:s,disabled:_,children:o("取消")}),t.jsx(Re,{type:"button",onClick:x,disabled:a,children:o(_?"处理中...":"创建 TeamRun")})]}),children:[t.jsx(_d,{mode:p,setMode:m,selectedTemplateId:v,setSelectedTemplateId:i,selectedMemberPresetIds:n,setSelectedMemberPresetIds:l,disabled:_}),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 r0({commands:e,selectedIndex:s,query:r,hasCatalog:o,title:p="Slash Commands",queryPrefix:m="/",emptyCatalogMessage:v="No slash commands catalog for this agent yet.",emptyQueryMessage:i,insertionHint:n="Enter / Tab to insert",compact:l=!1,onSelect:u}){const c=l?"px-1.5 pb-1.5":"px-2 pb-2",g=l?"px-2 py-1.5":"px-2.5 py-2",_=l?"max-h-36":"max-h-48";return t.jsxs("div",{className:l?"pt-1.5":"pt-2",children:[t.jsxs("div",{className:`mb-1 flex items-center justify-between ${l?"px-2 pt-0.5":"px-3 pt-1"}`,children:[t.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-neutral-400",children:p}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:n})]}),e.length===0?t.jsx("div",{className:`${l?"px-2 pb-2 pt-1.5 text-[11px]":"px-3 pb-3 pt-2 text-xs"} text-neutral-400`,children:o?i??`No matches for ${m}${r}`:v}):t.jsx("div",{className:`${c} ${_} overflow-y-auto`,children:e.map((y,x)=>t.jsxs("button",{type:"button",onMouseDown:a=>a.preventDefault(),onClick:()=>u(y),className:`w-full rounded-lg border text-left transition-colors ${x===s?"border-neutral-300 bg-neutral-50":"border-transparent hover:border-neutral-200 hover:bg-neutral-50/80"} ${g}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"font-mono text-[13px] text-neutral-900",children:y.command}),y.kind&&y.kind!=="builtin"?t.jsx("span",{className:"rounded-full border border-neutral-200 px-1.5 py-0.5 text-[9px] uppercase tracking-[0.12em] text-neutral-500",children:y.scope?`${y.scope} ${y.kind}`:y.kind}):null]}),t.jsx("div",{className:`${l?"mt-0.5 text-[11px]":"mt-1 text-xs"} text-neutral-500`,children:y.description})]},y.command))})]})}const Qt=12,Cr=8;function Hr({open:e,anchorRef:s,commands:r,selectedIndex:o,query:p,hasCatalog:m,title:v,queryPrefix:i,emptyCatalogMessage:n,emptyQueryMessage:l,insertionHint:u,compact:c=!1,onSelect:g}){const _=C.useRef(null),[y,x]=C.useState(null);return C.useLayoutEffect(()=>{if(!e){x(null);return}const a=s.current;if(!a)return;let h=0;const d=()=>{const w=s.current;if(!w)return;const k=w.getBoundingClientRect(),j=window.innerWidth,S=window.innerHeight,E=c?260:320,R=c?j-Qt*2:560,L=Math.min(Math.max(k.width,E),Math.max(E,R)),T=Math.min(Math.max(Qt,k.left),Math.max(Qt,j-Qt-L)),A=S-k.bottom-Cr-Qt,B=k.top-Cr-Qt,D=_.current?.offsetHeight??(c?220:280),z=c?240:320,H=A<180&&B>A,O=Math.max(120,Math.min(z,H?B:A)),P=H?Math.max(Qt,k.top-Cr-Math.min(D,O)):Math.min(S-Qt-Math.min(D,O),k.bottom+Cr);x({top:P,left:T,width:L,maxHeight:O})},f=()=>{cancelAnimationFrame(h),h=requestAnimationFrame(d)};f();const b=new ResizeObserver(f);return b.observe(a),_.current&&b.observe(_.current),window.addEventListener("resize",f),window.addEventListener("scroll",f,!0),window.visualViewport?.addEventListener("resize",f),window.visualViewport?.addEventListener("scroll",f),()=>{cancelAnimationFrame(h),b.disconnect(),window.removeEventListener("resize",f),window.removeEventListener("scroll",f,!0),window.visualViewport?.removeEventListener("resize",f),window.visualViewport?.removeEventListener("scroll",f)}},[s,r.length,c,e,p,o]),!e||!y||typeof document>"u"?null:es.createPortal(t.jsx("div",{className:"pointer-events-none fixed inset-0 z-[120]",children:t.jsx("div",{ref:_,className:"pointer-events-auto fixed overflow-hidden rounded-xl border border-neutral-200 bg-white shadow-lg shadow-neutral-200/70",style:{top:y.top,left:y.left,width:y.width,maxHeight:y.maxHeight},children:t.jsx(r0,{commands:r,selectedIndex:o,query:p,hasCatalog:m,title:v,queryPrefix:i,emptyCatalogMessage:n,emptyQueryMessage:l,insertionHint:u,compact:c,onSelect:g})})}),document.body)}function i0({workspaceId:e,gitStatus:s,onResolve:r}){const{t:o}=ce(),p=Rn();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(rr,{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(Re,{variant:"ghost",size:"sm",onClick:()=>p.mutate(e),disabled:p.isPending,className:"text-muted-foreground hover:text-foreground",children:o("中止操作")}),t.jsx(Re,{size:"sm",onClick:r,children:o("解决冲突")})]})]})}function ac(e){return e.length>0?e.map(s=>`- ${s}`).join(`
|
|
75
|
-
`):"- 未获取到冲突文件列表"}function lc(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 n0(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 o0(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 a0(e,s,r,o,p){const m=ac(r),v=lc(p);return o===Gs.REBASE?["## Rebase 冲突解决","",`在将分支 \`${e}\` rebase 到 \`${s}\` 时发生了冲突。`,...v.length>0?["","### 上下文",...v]:[],"","### 冲突文件",m,"","### 解决步骤","1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git rebase --continue` 继续 rebase 流程"].join(`
|
|
76
|
-
`):["## Merge 冲突解决","",`在将分支 \`${e}\` 合并到 \`${s}\` 时发生了冲突。`,...v.length>0?["","### 上下文",...v]:[],"","### 冲突文件",m,"","### 解决步骤",...n0(e,p)].join(`
|
|
77
|
-
`)}function l0(e){const s=e.conflictOp===Gs.REBASE?"Rebase":"Merge",r=ac(e.conflictedFiles),o=[...lc(e),`- Source branch: \`${e.sourceBranch}\``,`- Target branch: \`${e.targetBranch}\``,`- Conflict type: \`${e.conflictOp}\``];return[`## 请求处理 ${s} 冲突`,"",`用户点击了“AI 辅助解决”,请在对应 workspace 中处理当前 ${s} 冲突,并在 Team Room 汇报处理结果和验证情况。`,"","### 上下文",...o,"","### 冲突文件",r,"","### 用户意图",e.conflictOp===Gs.REBASE?"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 `git rebase --continue`,然后说明处理结果。":o0(e)].join(`
|
|
78
|
-
`)}function c0(e){if(e.teamRunId)return{type:"team_room",message:l0(e)};const s=e.currentSessionId||e.selectedSessionId;return s?{type:"session",sessionId:s,message:a0(e.sourceBranch,e.targetBranch,e.conflictedFiles,e.conflictOp,e)}:{type:"none"}}function cc({open:e,onOpenChange:s,workspaceId:r,conflictOp:o,conflictedFiles:p,sourceBranch:m,targetBranch:v,operation:i,worktreePath:n,mergeAborted:l,mergeStrategy:u,sourceWorkspaceId:c,targetWorkspaceId:g,sourceWorktreePath:_,targetWorktreePath:y,sessions:x,currentSessionId:a,teamRunId:h}){const{t:d}=ce(),[f,b]=C.useState(""),w=zn(),k=rn(h??""),j=jn(),S=!!h,E=a||f,R=S?k.isPending:w.isPending,L=()=>{const z=c0({workspaceId:r,worktreePath:n,operation:i,mergeAborted:l,mergeStrategy:u,sourceWorkspaceId:c,targetWorkspaceId:g,sourceWorktreePath:_,targetWorktreePath:y,sourceBranch:m,targetBranch:v,conflictedFiles:p,conflictOp:o,teamRunId:h,currentSessionId:a,selectedSessionId:f});if(z.type==="team_room"){k.mutate({content:z.message,kind:"chat"},{onSuccess:()=>{ct.success(d("已发送到 Team Room")),s(!1)}});return}z.type==="session"&&w.mutate({id:z.sessionId,message:z.message},{onSuccess:()=>s(!1)})},T=()=>{j.mutate({workspaceId:r},{onSuccess:()=>s(!1)})},A=o==="REBASE"?"Rebase":"Merge",B=!S&&!a&&x.length>0,D=S||!!E;return t.jsx(hs,{isOpen:e,onClose:()=>s(!1),title:d("解决 {opLabel} 冲突",{opLabel:A}),action:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Re,{variant:"outline",onClick:T,children:d("在 IDE 中打开")}),t.jsx(Re,{onClick:L,disabled:!D||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(z=>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:z},z))})]}),S&&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,由团队调度处理。")}),B&&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:z=>b(z.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...")}),x.map(z=>t.jsxs("option",{value:z.id,children:[z.agentType," — ",z.status]},z.id))]})]}),!S&&!E&&x.length===0&&t.jsx("p",{className:"text-sm text-neutral-500",children:d("没有可用的 Session,请在 IDE 中手动解决冲突。")})]})})}function d0(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 ea(e,s,r,o){const p=Yl(e);if(p){r(p);return}o(e instanceof Error?e.message:s)}function dc({workspaceId:e,branchName:s,targetBranch:r,commitMessage:o,changes:p,gitStatus:m,isGitStatusLoading:v,canRunGitOperations:i,onOpenChanges:n,onRefreshCommitMessage:l,onConflict:u,className:c}){const{t:g}=ce(),_=dl(),y=cl(),x=Rn(),[a,h]=C.useState(!1),[d,f]=C.useState(null),b=C.useMemo(()=>d0(p),[p]),w=b.additions+b.deletions,k=b.files>0&&w>0,j=(m?.conflictedFiles.length??0)>0,S=!!(m&&m.operation!=="idle"),E=!!(m&&(m.hasUncommittedChanges||m.untrackedCount>0)),R=(m?.uncommittedCount??0)+(m?.untrackedCount??0),L=(m?.behind??0)>0,T=(m?.ahead??0)>0,A=v||!m&&i,B=!!(i&&e&&m&&L&&!j&&!S&&!E),D=!!(i&&e&&m&&T&&!L&&!j&&!S&&!E);if(C.useEffect(()=>{a&&l?.()},[a,l]),!k)return null;const z=j?g("冲突"):m?.operation==="rebase"?g("变基中"):m?.operation==="merge"?g("合并中"):R>0?g("{count} 未提交",{count:R}):L?g("落后 {count}",{count:m?.behind??0}):g(T?"可合并":"已是最新"),H=g("{files} 个文件 · {lines} 行",{files:b.files,lines:w}),M=()=>{B&&(f(null),_.mutate(e,{onError:$=>{ea($,g("更新失败,请稍后重试"),Y=>u(Y),f)}}))},O=()=>{D&&(f(null),h(!0))},P=$=>{f(null),y.mutate({id:e,commitMessage:$},{onSuccess:()=>h(!1),onError:Y=>{ea(Y,g("提交失败,请稍后重试"),q=>{h(!1),u(q)},f)}})},I=()=>{y.isPending||(h(!1),f(null))};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:te("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:n,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(Ls,{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:H}),t.jsxs("span",{className:"hidden shrink-0 items-center gap-1 font-mono text-[11px] sm:inline-flex",children:[b.additions>0&&t.jsxs("span",{className:"text-success",children:["+",b.additions]}),b.deletions>0&&t.jsxs("span",{className:"text-destructive",children:["-",b.deletions]})]}),j&&t.jsx(rr,{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:z})]}),t.jsx(Mt,{size:15,className:"shrink-0 text-muted-foreground/60"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[S&&t.jsx("button",{type:"button",onClick:()=>x.mutate(e),disabled:x.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:x.isPending?g("正在撤销..."):g("撤销操作")}),t.jsxs("button",{type:"button",onClick:M,disabled:!B||_.isPending||A,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:[_.isPending?t.jsx(Ye,{size:12,className:"animate-spin"}):t.jsx(ir,{size:12}),t.jsx("span",{children:_.isPending?g("正在同步..."):g("更新")})]}),t.jsxs("button",{type:"button",onClick:O,disabled:!D||y.isPending||A,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:D?g("合并到 {target}",{target:r}):g("提交变更"),children:[y.isPending?t.jsx(Ye,{size:12,className:"animate-spin"}):t.jsx(Mr,{size:12}),t.jsx("span",{children:y.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(Vl,{isOpen:a,onClose:I,branchName:s,targetBranch:r,commitMessage:o,isPending:y.isPending,error:d,onConfirm:P})]})}function u0({agentType:e,workingDir:s}){return Tt({queryKey:ne.system.slashCommandCatalog(e,s),queryFn:async()=>(await ge.get("/system/slash-command-catalog",{params:{agentType:String(e),...s?{workingDir:s}:{}}})).commands,enabled:!!e,staleTime:3e4})}function h0(e,s){const r=new Set,o=[];for(const p of[...e,...s]){const m=p.command.trim().toLowerCase();!m||r.has(m)||(r.add(m),o.push(p.kind?p:{...p,kind:"builtin"}))}return o}function oi(e){return e.trim().toLowerCase().replace(/^[/$]/,"")}function f0(e){return oi(e.command)}function m0(e,s){if(!s)return 1e3;const r=f0(e),o=e.aliases?.map(oi)??[],p=[r,...o];let m=0;for(const i of p)i===s?m=Math.max(m,500):i.startsWith(s)?m=Math.max(m,400-(i.length-s.length)):i.includes(s)&&(m=Math.max(m,250-i.indexOf(s)));return m>0?m:`${r} ${o.join(" ")} ${e.description}`.toLowerCase().includes(s)?100:0}function ta(e){const s=/(^|[\s])\$([^\s]*)$/.exec(e);if(!s||s.index===void 0)return null;const r=s.index+s[1].length;return{query:oi(s[2]),replaceStart:r}}function uc(e,s){const r=oi(s);return r?e.map((o,p)=>({command:o,index:p,score:m0(o,r)})).filter(o=>o.score>0).sort((o,p)=>p.score-o.score||o.index-p.index||o.command.command.localeCompare(p.command.command)).map(o=>o.command):e.slice()}const p0=[{command:"/permissions",description:"Manage what Codex can do without approval"},{command:"/sandbox-add-read-dir",description:"Grant read access to another directory"},{command:"/agent",description:"Switch between built-in agent personas"},{command:"/apps",description:"Manage connected apps"},{command:"/clear",description:"Start a fresh conversation"},{command:"/compact",description:"Replace chat context with a summary"},{command:"/copy",description:"Copy the last assistant message to your clipboard"},{command:"/diff",description:"Show the current git diff"},{command:"/experimental",description:"Toggle experimental features"},{command:"/feedback",description:"Share feedback on Codex CLI"},{command:"/init",description:"Create or update AGENTS.md for the repo"},{command:"/logout",description:"Sign out of Codex"},{command:"/mcp",description:"Manage MCP servers"},{command:"/mention",description:"Add files or directories to the conversation context"},{command:"/model",description:"Change the active model"},{command:"/fast",description:"Toggle low reasoning mode"},{command:"/plan",description:"Toggle plan mode for code changes"},{command:"/personality",description:"Select how Codex communicates"},{command:"/ps",description:"List running background tasks"},{command:"/fork",description:"Fork the current conversation state"},{command:"/resume",description:"Resume a previous conversation"},{command:"/new",description:"Open a conversation picker to start or resume"},{command:"/quit",description:"Exit Codex CLI",aliases:["exit"]},{command:"/review",description:"Run a code review"},{command:"/status",description:"Show session and configuration status"},{command:"/debug-config",description:"Inspect the effective configuration"},{command:"/statusline",description:"Configure the custom status line"},{command:"/skills",description:"Browse available skills and insert a $skill mention"}],g0=[{command:"/clear",description:"Clear the conversation history"},{command:"/compact",description:"Compact the conversation context",aliases:["compact focus"]},{command:"/config",description:"Open the configuration panel"},{command:"/cost",description:"Show token usage and cost"},{command:"/doctor",description:"Check Claude Code installation health"},{command:"/help",description:"Show help and available commands"},{command:"/init",description:"Initialize project instructions"},{command:"/login",description:"Sign in to Claude Code"},{command:"/logout",description:"Sign out of Claude Code"},{command:"/mcp",description:"Manage MCP servers"},{command:"/memory",description:"Edit project memory files"},{command:"/model",description:"Change the active model"},{command:"/permissions",description:"Review or update tool permissions"},{command:"/pr_comments",description:"Read pull request review comments"},{command:"/review",description:"Run a code review"},{command:"/status",description:"Show account and system status"},{command:"/terminal-setup",description:"Configure terminal newline shortcuts"},{command:"/vim",description:"Toggle vim mode"}],v0=[{command:"/bug",description:"File an issue about Gemini CLI"},{command:"/chat",description:"Manage chat checkpoints and exports"},{command:"/clear",description:"Clear the terminal display"},{command:"/compress",description:"Replace chat context with a summary"},{command:"/copy",description:"Copy the last Gemini CLI output"},{command:"/directory",description:"Manage additional workspace directories",aliases:["dir"]},{command:"/editor",description:"Choose the preferred editor"},{command:"/extensions",description:"List active Gemini CLI extensions"},{command:"/help",description:"Show help and command usage",aliases:["?"]},{command:"/mcp",description:"Show MCP servers and tools"},{command:"/memory",description:"Manage loaded GEMINI.md memory"},{command:"/restore",description:"Restore files from a tool checkpoint"},{command:"/settings",description:"Open the Gemini CLI settings editor"},{command:"/stats",description:"Show session statistics and token usage"},{command:"/theme",description:"Change the Gemini CLI theme"},{command:"/auth",description:"Change the authentication method"},{command:"/about",description:"Show version information"},{command:"/tools",description:"List currently available tools"},{command:"/privacy",description:"Review privacy and data collection settings"},{command:"/quit",description:"Exit Gemini CLI",aliases:["exit"]},{command:"/vim",description:"Toggle vim mode"},{command:"/init",description:"Generate a tailored GEMINI.md file"}],x0=[{command:"/model",description:"Change the active model"},{command:"/plan",description:"Create or reopen a plan"},{command:"/ask",description:"Toggle ask mode (read-only Q&A)"},{command:"/debug",description:"Toggle debug mode"},{command:"/clear",description:"Start a new chat session",aliases:["new","new-chat","newchat"]},{command:"/compress",description:"Summarize the conversation to reduce context"},{command:"/vim",description:"Toggle vim mode"},{command:"/shell",description:"Enter shell mode"},{command:"/about",description:"Show CLI, system, and account information"},{command:"/setup-terminal",description:"Configure terminal newline shortcuts"},{command:"/feedback",description:"Share feedback with the Cursor team"},{command:"/open",description:"Open the repository git root in Cursor"},{command:"/cursor",description:"Alias for /open",aliases:["open"]},{command:"/resume-chat",description:"Resume a previous chat by folder name",aliases:["resume"]},{command:"/copy-request-id",description:"Copy the last request ID"},{command:"/copy-conversation-id",description:"Copy the current conversation ID"},{command:"/logout",description:"Sign out from Cursor"},{command:"/quit",description:"Exit Cursor Agent",aliases:["exit"]},{command:"/mcp",description:"Manage MCP servers"}],_0={[Bt.CODEX]:p0,[Bt.CLAUDE_CODE]:g0,[Bt.GEMINI_CLI]:v0,[Bt.CURSOR_AGENT]:x0};function hc(e){return e.trim().toLowerCase().replace(/^\//,"")}function b0(e){return e?(_0[e]??[]).map(s=>({...s,kind:s.kind??"builtin"})):[]}function y0(e){const s=e.match(/^\s*\/([^\s]*)$/);return s?hc(s[1]):null}function S0(e,s){return uc(e,hc(s))}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 fc({agentType:e,workingDir:s,input:r,setInput:o,textareaRef:p,minHeight:m,maxHeight:v}){const[i,n]=C.useState(0),{data:l=[]}=u0({agentType:e,workingDir:s}),u=C.useMemo(()=>h0(b0(e),l),[e,l]),c=C.useMemo(()=>y0(r),[r]),g=C.useMemo(()=>c===null?[]:S0(u,c),[u,c]),_=C.useCallback(()=>{const a=p.current;a&&(a.style.height="auto",a.style.height=`${Math.max(m,Math.min(a.scrollHeight,v))}px`)},[v,m,p]);C.useEffect(()=>{n(0)},[e,c]),C.useEffect(()=>{i<g.length||n(0)},[g.length,i]);const y=C.useCallback(a=>{const d=`${r.match(/^(\s*)\/[^\s]*$/)?.[1]??""}${a.command} `;o(d),requestAnimationFrame(()=>{const f=p.current;f&&(_(),f.focus(),f.setSelectionRange(d.length,d.length))})},[r,_,o,p]),x=C.useCallback(a=>c===null||g.length===0?!1:a.key==="ArrowDown"?(a.preventDefault(),n(h=>(h+1)%g.length),!0):a.key==="ArrowUp"?(a.preventDefault(),n(h=>(h-1+g.length)%g.length),!0):w0(a)?(a.preventDefault(),y(g[i]??g[0]),!0):!1,[y,g,c,i]);return{allCommands:u,query:c,filteredCommands:g,selectedIndex:i,setSelectedIndex:n,applyCommand:y,handleKeyDown:x}}function C0({agentType:e,workingDir:s}){return Tt({queryKey:ne.system.skillCatalog(e,s),queryFn:async()=>(await ge.get("/system/skill-catalog",{params:{agentType:String(e),...s?{workingDir:s}:{}}})).commands,enabled:e===Bt.CODEX,staleTime:3e4})}function k0(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 mc({agentType:e,workingDir:s,input:r,setInput:o,textareaRef:p,minHeight:m,maxHeight:v}){const[i,n]=C.useState(0),{data:l=[]}=C0({agentType:e,workingDir:s}),c=C.useMemo(()=>e===Bt.CODEX?ta(r):null,[e,r])?.query??null,g=C.useMemo(()=>c===null?[]:uc(l,c),[c,l]),_=C.useCallback(()=>{const a=p.current;a&&(a.style.height="auto",a.style.height=`${Math.max(m,Math.min(a.scrollHeight,v))}px`)},[v,m,p]);C.useEffect(()=>{n(0)},[e,c]),C.useEffect(()=>{i<g.length||n(0)},[g.length,i]);const y=C.useCallback(a=>{const h=ta(r);if(!h)return;const d=`${r.slice(0,h.replaceStart)}${a.command} `;o(d),requestAnimationFrame(()=>{const f=p.current;f&&(_(),f.focus(),f.setSelectionRange(d.length,d.length))})},[r,_,o,p]),x=C.useCallback(a=>c===null||g.length===0?!1:a.key==="ArrowDown"?(a.preventDefault(),n(h=>(h+1)%g.length),!0):a.key==="ArrowUp"?(a.preventDefault(),n(h=>(h-1+g.length)%g.length),!0):k0(a)?(a.preventDefault(),y(g[i]??g[0]),!0):!1,[y,g,c,i]);return{allSkills:l,query:c,filteredSkills:g,selectedIndex:i,setSelectedIndex:n,applySkill:y,handleKeyDown:x}}const E0="/api",j0=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${E0}/attachments/by-path?path=${encodeURIComponent(e)}`:e,Cs=520,Li=48,N0=4,R0=420;function A0(){const{t:e}=ce();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 sa=[{status:pe.Review,className:"bg-warning/10 text-warning",hoverClass:"hover:bg-warning/15",icon:t.jsx(ja,{className:"w-3 h-3"})},{status:pe.Running,className:"bg-info/10 text-info",hoverClass:"hover:bg-info/15",icon:t.jsx(Ea,{className:"w-3 h-3"})},{status:pe.Pending,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-muted",icon:t.jsx(ka,{className:"w-3 h-3"})},{status:pe.Done,className:"bg-success/10 text-success",hoverClass:"hover:bg-success/15",icon:t.jsx(Ca,{className:"w-3 h-3"})},{status:pe.Cancelled,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-border",icon:t.jsx(wa,{className:"w-3 h-3"})}];function M0({status:e,onChangeStatus:s}){const{t:r}=ce(),[o,p]=C.useState(!1),m=C.useRef(null);C.useEffect(()=>{if(!o)return;const i=n=>{m.current&&!m.current.contains(n.target)&&p(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[o]);const v=sa.find(i=>i.status===e);return t.jsxs("div",{className:"relative",ref:m,children:[t.jsxs("button",{onClick:()=>s&&p(i=>!i),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:sa.filter(i=>i.status!==e).map(i=>t.jsxs("button",{onClick:()=>{s?.(i.status),p(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-xs font-medium transition-colors ${i.hoverClass}`,children:[t.jsx("span",{className:i.className.split(" ").find(n=>n.startsWith("text-")),children:i.icon}),t.jsx("span",{className:"text-foreground/80",children:r(i.status)})]},i.status))})]})}function ra({state:e,onRetry:s}){const{t:r}=ce(),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(Re,{size:"sm",variant:"outline",className:"mt-3",onClick:s,children:[t.jsx(Ut,{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 T0({task:e,onDeleteTask:s,isDeleting:r,onTaskStatusChange:o,autoStartState:p,onAutoStartRecovered:m}){const{t:v}=ce(),[i,n]=C.useState(""),[l,u]=C.useState(!1),[c,g]=C.useState(!1),[_,y]=C.useState(!1),[x,a]=C.useState(!1),[h,d]=C.useState(!1),[f,b]=C.useState(!1),[w,k]=C.useState(null),j=C.useRef(null),[S,E]=C.useState(!1),[R,L]=C.useState(null),[T,A]=C.useState(void 0),[B,D]=C.useState(!1),z=C.useRef(null),H=C.useRef(null),M=C.useRef(null),O=C.useRef(null),{scrollRef:P,contentRef:I,isAtBottom:$,scrollToBottom:Y}=dn({resize:"smooth",initial:"instant"}),[q,V]=C.useState(!1),[F,N]=C.useState(Cs),[W,X]=C.useState(!1),K=C.useRef(0),ie=C.useRef(Cs),Z=C.useRef(null),{data:re,isLoading:he}=En(e?.id??""),fe=e0(e?.id),{data:Be}=ba(e?.id??""),{data:le}=ya(Be?.id??""),Ge=rn(Be?.id??""),we=Be??null,qe=!!we,Fe=e?.isGitRepo!==!1,De=Be===null&&Fe,ze=!!(e?.id&&Be===null),{data:Ae,isLoading:Ke}=Sa(e?.id??"",ze);C.useEffect(()=>{D(!1),L(null),A(void 0)},[e?.id]);const Ee=C.useMemo(()=>gl(re,we,T),[T,we,re]);C.useEffect(()=>{T&&!re?.some(J=>J.id===T)&&A(void 0)},[T,re]);const Ce=C.useMemo(()=>re?.find(J=>J.id===Ee),[Ee,re]),ke=Ce?.status===Rt.ACTIVE?Ce.id:void 0,st=Fe&&vl(Ce,we);C.useEffect(()=>{if(!B||!re)return;re.some(oe=>oe.status==="ACTIVE"&&oe.sessions&&oe.sessions.length>0)&&D(!1)},[re,B]);const je=C.useMemo(()=>{if(B||!re)return null;const J=ft=>{const gi=ft.createdAt,Ws=ft.endedAt??ft.startedAt??gi;if(!Ws)return 0;const ys=Date.parse(Ws);return Number.isNaN(ys)?0:ys},oe=(ft,gi)=>{const Ws=ft.filter(ys=>gi.includes(ys.status));return Ws.length===0?null:Ws.sort((ys,Wc)=>J(Wc)-J(ys))[0]??null},Ve=re.filter(ft=>ft.status==="ACTIVE"&&Array.isArray(ft.sessions)).flatMap(ft=>ft.sessions??[]),Ct=oe(Ve,[it.RUNNING])??oe(Ve,[it.PENDING])??oe(Ve,[it.COMPLETED,it.FAILED,it.CANCELLED]);if(Ct)return Ct;const _t=re.filter(ft=>(ft.status==="MERGED"||ft.status==="ABANDONED"||ft.status==="HIBERNATED")&&Array.isArray(ft.sessions)).flatMap(ft=>ft.sessions??[]);return oe(_t,[it.COMPLETED,it.FAILED,it.CANCELLED])},[re,B]),We=je?.id??"",ue=qe?R??"":We,dt=C.useMemo(()=>{if(!R||!re)return null;for(const J of re){const oe=J.sessions?.find(Ve=>Ve.id===R);if(oe)return oe}return null},[R,re]),wt=C.useMemo(()=>{if(!R||!we?.invocations)return null;const J=we.invocations.filter(oe=>oe.sessionId===R);return J.length===0?null:J.sort((oe,Ve)=>{const Ct=Date.parse(oe.updatedAt??oe.createdAt??""),_t=Date.parse(Ve.updatedAt??Ve.createdAt??"");return(Number.isNaN(_t)?0:_t)-(Number.isNaN(Ct)?0:Ct)})[0]??null},[R,we?.invocations]),G=C.useMemo(()=>!wt?.memberId||!we?.members?null:we.members.find(J=>J.id===wt.memberId)??null,[wt?.memberId,we?.members]),U=R?dt:je??null,Q=U?.status===it.RUNNING||U?.status===it.PENDING,se=!!e?.projectArchivedAt,de=!!e?.projectRepoDeletedAt,Ne=v(de?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),{data:ve}=Ds(),[be,me]=C.useState(null);C.useEffect(()=>{me(je?.providerId??null)},[je?.providerId]);const Me=C.useMemo(()=>!je||!re?!1:!re.some(oe=>oe.status==="ACTIVE"&&oe.sessions?.some(Ve=>Ve.id===je.id)),[je,re]),Se=C.useMemo(()=>{if(!(!re||B)){if(Ce)return ss(Ce);for(const J of re)if(J.status==="ACTIVE"&&ss(J))return ss(J);return ss(re[0])}},[B,Ce,re]),Pe=fc({agentType:je?.agentType,workingDir:Se,input:i,setInput:n,textareaRef:M,minHeight:60,maxHeight:300}),He=mc({agentType:je?.agentType,workingDir:Se,input:i,setInput:n,textareaRef:M,minHeight:60,maxHeight:300}),ut=sn(J=>J.setVisibleContext),Je=!!(st&&ke&&Se&&!se),{data:xe,isLoading:ht}=Nn(ke??"",{enabled:Je}),{data:Qe}=ni(Se,{enabled:Je});C.useEffect(()=>{if(!(q||!Je||!ke||!Se))return ut({workspaceId:ke,workingDir:Se,tab:"changes"}),()=>{ut(null)}},[q,ke,ut,Je,Se]);const et=Ce?.sessions??[],mt=fs(Ce),gt=Ce?.commitMessage,vt=C.useMemo(()=>xl(Ce,re,e?.mainBranch??""),[Ce,e?.mainBranch,re]),Xe=C.useMemo(()=>xe?.conflictOp&&xe.conflictedFiles.length>0?{conflictOp:xe.conflictOp,conflictedFiles:xe.conflictedFiles}:w,[xe?.conflictOp,xe?.conflictedFiles,w]),Xt=Xe?.targetWorkspaceId??ke,ps=Xe?.targetWorktreePath??Ce?.worktreePath,gs=Xe?.sourceBranch??mt,ai=Xe?.targetBranch??vt,tt=ot(),vs=C.useCallback(async()=>e?.id?tt.fetchQuery({queryKey:ne.tasks.body(e.id),queryFn:()=>ge.get(`/tasks/${e.id}/body`)}):null,[tt,e?.id]),Is=C.useCallback(()=>e?.id?tt.invalidateQueries({queryKey:ne.workspaces.list(e.id)}):Promise.resolve(),[e?.id,tt]);C.useEffect(()=>{if(!S)return;const J=oe=>{H.current&&!H.current.contains(oe.target)&&E(!1)};return document.addEventListener("mousedown",J),()=>document.removeEventListener("mousedown",J)},[S]);const Bs=zn(),Vt=jn(),ls=dd(),hr=ll(e?.id??""),Fs=Fn(),xs=nf(),zt=C.useMemo(()=>!re||re.some(oe=>oe.status==="ACTIVE")?null:re.find(oe=>oe.status==="HIBERNATED")??null,[re]),_s=C.useRef(null);C.useEffect(()=>{zt&&_s.current!==zt.id&&(xs.isPending||(_s.current=zt.id,xs.mutate(zt.id,{onSettled:()=>{_s.current=null}})))},[zt,xs]);const li=C.useCallback(async()=>{if(!e?.id)return;const J=je?.providerId??ve?.find(oe=>oe.availability.type!=="NOT_FOUND")?.provider.id;if(J){a(!1),d(!0);try{const Ve=(await vs())?.prompt??e.title;await ls.mutateAsync(e.id),D(!0);const Ct=await hr.mutateAsync({workspaceKind:Fe?void 0:jt.MAIN_DIRECTORY}),_t=await ge.post(`/workspaces/${Ct.id}/sessions`,{providerId:J,prompt:Ve});await Fs.mutateAsync(_t.id),await tt.invalidateQueries({queryKey:ne.workspaces.list(e.id)})}catch(oe){console.error("[retry] failed:",oe),D(!1)}finally{d(!1)}}},[e?.id,e?.title,Fe,je?.providerId,ve,vs,ls,hr,Fs,tt]),zs=C.useCallback(async()=>{e?.id&&(await vs(),u(!0))},[vs,e?.id]),fr=C.useCallback(()=>{Ce?.id&&Vt.mutate({workspaceId:Ce.id})},[Vt,Ce?.id]),ci=C.useCallback(()=>{!e?.id||!s||(s(e.id),y(!1))},[e?.id,s]),mr=C.useCallback(J=>{L(J),requestAnimationFrame(()=>{Y()})},[Y]),pr=C.useCallback(()=>{L(null)},[]),bs=C.useCallback(J=>{k(J??null),b(!0)},[]),di=C.useCallback(J=>Ge.mutateAsync(J),[Ge]),Yt=C.useCallback(()=>{tt.invalidateQueries({queryKey:ud.all})},[tt]),{isConnected:gr,isLoadingSnapshot:Gt,logs:ee,entries:_e,attach:Oe}=La({sessionId:ue,sessionStatus:U?.status,onExit:C.useCallback(()=>{tt.invalidateQueries({queryKey:["workspaces"]})},[tt])});C.useEffect(()=>{if(!e?.id)return;const J=Jt.connect();J.emit(ks.SUBSCRIBE,{topic:"task",id:e.id});const oe=_t=>{_t.taskId===e.id&&(tt.invalidateQueries({queryKey:["tasks"]}),Yt())},Ve=_t=>{_t.taskId===e.id&&(tt.invalidateQueries({queryKey:ne.workspaces.list(e.id)}),Yt())},Ct=_t=>{_t.taskId===e.id&&(tt.invalidateQueries({queryKey:ne.workspaces.list(e.id)}),Yt())};return J.on(at.TASK_UPDATED,oe),J.on(at.WORKSPACE_COMMIT_MESSAGE_UPDATED,Ve),J.on(at.WORKSPACE_HIBERNATED,Ct),()=>{J.off(at.TASK_UPDATED,oe),J.off(at.WORKSPACE_COMMIT_MESSAGE_UPDATED,Ve),J.off(at.WORKSPACE_HIBERNATED,Ct),J.emit(ks.UNSUBSCRIBE,{topic:"task",id:e.id})}},[e?.id,tt,Yt]),C.useEffect(()=>{if(!ue)return;const J=Jt.connect(),oe=Ve=>{Ve.sessionId===ue&&(tt.invalidateQueries({queryKey:["workspaces"]}),Yt())};return J.on(at.SESSION_COMPLETED,oe),()=>{J.off(at.SESSION_COMPLETED,oe)}},[ue,tt,Yt]);const{todos:Le}=Pa(_e),{files:Et,addFiles:xt,removeFile:Ie,clear:Wt,buildMarkdownLinks:Ht,hasFiles:Pt,isUploading:vr}=cn(),Mc=C.useMemo(()=>nc(U),[U?.tokenUsage]),Hn=Ta(ee,Mc);C.useEffect(()=>{ue&&gr&&Oe()},[ue,gr,Oe]);const $n=C.useRef(e?.id);C.useEffect(()=>{if($n.current!==e?.id&&P.current){const J=P.current;requestAnimationFrame(()=>{J.scrollTop=J.scrollHeight})}$n.current=e?.id},[e?.id,P]);const ui=rc(),hi=C.useRef(!1),Un=C.useCallback(async()=>{if(!i.trim()&&!Pt||!ue||hi.current||vr)return;hi.current=!0;const J=Ht(),oe=[i.trim(),J].filter(Boolean).join(`
|
|
79
|
-
|
|
80
|
-
`);n(""),Wt(),M.current&&(M.current.style.height="60px"),Bs.mutate({id:ue,message:oe,providerId:be??void 0},{onSuccess:()=>{Oe()},onSettled:()=>{hi.current=!1}})},[i,ue,Bs,Oe,Pt,vr,Ht,Wt,be]),Tc=C.useCallback(async()=>{ue&&(await ui.mutateAsync(ue),tt.invalidateQueries({queryKey:["workspaces"]}))},[ue,ui,tt]),Dc=C.useCallback(J=>{const oe=J.target.files;oe&&oe.length>0&&xt(Array.from(oe)),J.target.value=""},[xt]),Lc=C.useCallback(J=>{const oe=J.clipboardData.items,Ve=[];for(const Ct of oe)if(Ct.kind==="file"){const _t=Ct.getAsFile();_t&&Ve.push(_t)}Ve.length>0&&(J.preventDefault(),xt(Ve))},[xt]),[qn,fi]=C.useState(!1),Pc=C.useCallback(J=>{J.preventDefault(),fi(!0)},[]),Oc=C.useCallback(J=>{J.preventDefault(),fi(!1)},[]),Ic=C.useCallback(J=>{J.preventDefault(),fi(!1);const oe=J.dataTransfer.files;oe.length>0&&xt(Array.from(oe))},[xt]),$t=C.useCallback(J=>{const oe=Z.current?.getBoundingClientRect().width??(typeof window<"u"?window.innerWidth:void 0),Ve=oe?Math.max(Cs,oe-Li-N0-R0):Cs;return Math.max(Cs,Math.min(Math.round(J),Ve))},[]),mi=C.useCallback(J=>{const oe=J.clientX-K.current;N($t(ie.current-oe))},[$t]),pi=C.useCallback(()=>{X(!1),document.body.style.cursor="",document.body.style.userSelect=""},[]);C.useEffect(()=>{if(W)return document.addEventListener("mousemove",mi),document.addEventListener("mouseup",pi),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",mi),document.removeEventListener("mouseup",pi),document.body.style.cursor="",document.body.style.userSelect=""}},[pi,mi,W]);const Bc=C.useCallback(J=>{J.preventDefault(),K.current=J.clientX,ie.current=F,X(!0)},[F]);C.useEffect(()=>{!q||W||N(J=>$t(J))},[$t,q,W]),C.useEffect(()=>{if(!q)return;const J=()=>{N(oe=>$t(oe))};return window.addEventListener("resize",J),()=>window.removeEventListener("resize",J)},[$t,q]);const Fc=C.useCallback(()=>{N(J=>$t(J)),V(!0),requestAnimationFrame(()=>{j.current?.setTab("review")})},[$t]),zc=C.useCallback(J=>{n(J.target.value);const oe=J.target;oe.style.height="auto";const Ve=oe.scrollHeight;oe.style.height=`${Math.max(60,Math.min(Ve,300))}px`},[]),Kn=Je&&ke?t.jsx(dc,{workspaceId:ke,branchName:mt,targetBranch:vt,commitMessage:gt,changes:Qe,gitStatus:xe,isGitStatusLoading:ht,canRunGitOperations:st,onOpenChanges:Fc,onRefreshCommitMessage:Is,onConflict:bs,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(M0,{status:e.status,onChangeStatus:!se&&o?J=>o(e.id,J):void 0}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:fr,disabled:!Se||se,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(Xr,{size:16})}),(s||De)&&!se&&t.jsxs("div",{className:"relative",ref:H,children:[t.jsx("button",{onClick:()=>E(J=>!J),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(Fa,{size:16})}),S&&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:[De&&t.jsxs("button",{onClick:()=>{g(!0),E(!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(ts,{size:15}),t.jsx("span",{children:v("创建 TeamRun")})]}),t.jsxs("button",{onClick:()=>{a(!0),E(!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(Nd,{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:()=>{y(!0),E(!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(pn,{size:15}),t.jsx("span",{children:v("删除任务")})]})]})]})]})]})]})]}),st&&ke&&xe&&t.jsx(i0,{workspaceId:ke,gitStatus:xe,onResolve:()=>bs()}),t.jsxs("div",{ref:Z,className:"flex-1 flex overflow-hidden",children:[t.jsx("div",{className:"flex min-w-0 flex-1 flex-col bg-background relative",children:qe&&we?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(oc,{session:U,providers:ve,usage:Hn,providerIdFallback:G?.providerId,agentTypeFallback:U?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Re,{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:pr,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:P,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsx("div",{ref:I,className:"w-full max-w-4xl mx-auto",children:Gt?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...")})]}):ee.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:v(Q?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(Nr,{logs:ee})})}),!$&&t.jsxs("button",{onClick:()=>Y(),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(Qs,{size:14}),t.jsx("span",{children:v("回到底部")})]})]}),Le.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(Rr,{todos:Le})})})]}):t.jsx(pl,{teamRun:we,messages:le??we.messages??[],readOnly:se,readOnlyMessage:Ne,onSendMessage:di,onViewInvocationSession:mr,changeSummaryBar:Kn,centered:!0}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:P,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsxs("div",{ref:I,className:"w-full min-w-0 max-w-4xl mx-auto",children:[(Ke||Ae?.body)&&t.jsx("div",{className:"mb-4 pb-4 border-b border-border/60 min-w-0",children:Ke?t.jsx("p",{className:"text-sm text-muted-foreground/70 italic",children:v("Loading...")}):Ae?.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(nn,{urlTransform:j0,components:on,children:Ae.body})}):null}),fe&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-muted-foreground/70 text-sm",children:[fe.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:fe.currentIndex,total:fe.totalCommands,command:fe.currentCommand})})]}),fe.status==="completed"&&t.jsx("span",{className:"text-success",children:v("Setup 完成")}),fe.status==="failed"&&t.jsx("span",{className:"text-destructive/80",children:v("Setup 失败: {error}",{error:fe.error})})]}),!se&&p&&(he||We)?t.jsx("div",{className:"flex justify-center py-3",children:t.jsx(ra,{state:p,onRetry:p.status==="failed"?zs:void 0})}):null,he?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...")})]}):We?Gt?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...")})]}):ee.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:v(Q?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(Nr,{logs:ee}):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(Ut,{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(se?"项目为只读历史":"尚未启动 Agent")}),t.jsx("p",{className:"text-sm text-muted-foreground mb-6 max-w-xs",children:se?Ne:v("选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。")}),!se&&p?t.jsx(ra,{state:p}):null,!se&&t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[t.jsxs(Re,{onClick:zs,disabled:!!(p&&p.status!=="failed"),children:[t.jsx(Ut,{size:16,className:"mr-1.5"}),p?.status==="failed"?v("重试启动 Agent"):v("启动 Agent")]}),De&&t.jsxs(Re,{variant:"outline",onClick:()=>g(!0),children:[t.jsx(ts,{size:16,className:"mr-1.5"}),v("创建 TeamRun")]})]})]})]})}),!$&&t.jsxs("button",{onClick:()=>Y(),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(Qs,{size:14}),t.jsx("span",{children:v("回到底部")})]})]}),Le.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(Rr,{todos:Le})})}),se?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:Ne})})}):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.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(Re,{size:"sm",onClick:zs,children:[t.jsx(Ut,{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:Pc,onDragLeave:Oc,onDrop:Ic,children:[t.jsxs("div",{className:"max-w-4xl mx-auto",children:[Kn,t.jsxs("div",{ref:z,className:`relative bg-background rounded-xl border hover:border-ring/40 focus-within:border-ring/60 transition-colors duration-200 ${qn?"border-info bg-info/5":"border-border"}`,children:[t.jsx(un,{files:Et,onRemove:Ie}),t.jsx("textarea",{ref:M,value:i,onChange:zc,onPaste:Lc,onKeyDown:J=>{He.handleKeyDown(J)||Pe.handleKeyDown(J)||J.key==="Enter"&&!J.shiftKey&&!J.repeat&&!J.nativeEvent.isComposing&&J.nativeEvent.keyCode!==229&&(J.preventDefault(),Un())},rows:1,placeholder:v(qn?"Drop files here...":We&&!Q?"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:O,type:"file",multiple:!0,className:"hidden",onChange:Dc}),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:()=>O.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(mn,{size:18})})}),t.jsxs("div",{className:"flex items-center gap-2",children:[je&&ve&&t.jsx(Da,{providers:ve,currentProviderId:be,agentType:je.agentType,onSelect:me}),t.jsx(fn,{usage:Hn}),Q&&!i.trim()&&!Pt?t.jsx("button",{onClick:Tc,disabled:ui.isPending,className:"p-2 rounded-lg transition-all duration-200 bg-destructive text-white hover:bg-destructive/90 disabled:opacity-50",children:t.jsx(Ms,{size:14})}):t.jsx("button",{onClick:Un,disabled:!i.trim()&&!Pt||vr,className:`p-2 rounded-lg transition-all duration-200 ${(i.trim()||Pt)&&!vr?"bg-primary text-primary-foreground hover:bg-primary/90":"bg-transparent text-muted-foreground/50 cursor-not-allowed"}`,children:t.jsx(hn,{size:18})})]})]})]})]}),t.jsx(Hr,{open:Pe.query!==null,anchorRef:z,commands:Pe.filteredCommands,selectedIndex:Pe.selectedIndex,query:Pe.query??"",hasCatalog:Pe.allCommands.length>0,onSelect:Pe.applyCommand}),t.jsx(Hr,{open:He.query!==null,anchorRef:z,commands:He.filteredSkills,selectedIndex:He.selectedIndex,query:He.query??"",hasCatalog:He.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",onSelect:He.applySkill})]})]})}),q&&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:Bc,role:"separator","aria-orientation":"vertical","aria-label":v("调整工作区宽度")}),t.jsx("div",{className:"flex h-full flex-shrink-0 bg-background",style:{width:q?Li+F:Li},children:t.jsx(sc,{sessionId:We||void 0,workspaceId:Ee,workingDir:Se,projectId:e.projectId,readOnly:se,repoDeleted:de,teamRun:we,teamStatus:we?t.jsx(yl,{teamRun:we,workspaces:re,selectedWorkspaceId:Ee,onSelectWorkspace:A,onViewInvocationSession:mr}):void 0,workspaces:re,selectedWorkspaceId:Ee,onSelectWorkspace:A,variant:"rail",expanded:q,onExpandedChange:J=>{J&&N(oe=>$t(oe)),V(J)},minContentWidth:Cs,tabRef:j,gitAvailable:Fe,gitProps:st&&ke?{branchName:mt,targetBranch:vt,commitMessage:gt,canRunGitOperations:!0,onRefreshCommitMessage:Is,onConflict:bs,onResolveConflicts:()=>bs()}:void 0})})]}),!se&&t.jsx(ic,{isOpen:l,onClose:()=>u(!1),taskId:e.id,taskTitle:Ae?.title??e.title,taskDescription:Ae?.body??"",taskPrompt:Ae?.prompt,projectIsGitRepo:Fe,onStarted:()=>m?.(e.id)}),De&&!se&&t.jsx(s0,{isOpen:c,onClose:()=>g(!1),taskId:e.id}),st&&Xt&&Xe&&t.jsx(cc,{open:f,onOpenChange:J=>{b(J),J||k(null)},workspaceId:Xt,conflictOp:Xe.conflictOp,conflictedFiles:Xe.conflictedFiles,sourceBranch:gs,targetBranch:ai,operation:xe?.operation,worktreePath:ps,mergeAborted:Xe.mergeAborted,mergeStrategy:Xe.mergeStrategy,sourceWorkspaceId:Xe.sourceWorkspaceId,targetWorkspaceId:Xe.targetWorkspaceId,sourceWorktreePath:Xe.sourceWorktreePath,targetWorktreePath:Xe.targetWorktreePath,sessions:et,currentSessionId:qe?void 0:We,teamRunId:we?.id}),t.jsx(an,{isOpen:x,onClose:()=>a(!1),onConfirm:li,title:v("重新开始任务"),description:t.jsx("p",{children:v("将归档当前工作区并自动在新 Worktree 中重新启动 Agent,旧工作区内容保留供参考。")}),confirmText:v("确认重试"),variant:"default",isLoading:h}),t.jsx(An,{isOpen:_,onClose:()=>y(!1),onConfirm:ci,taskId:e.id,taskTitle:e.title,workspaces:re,isLoading:r})]}):t.jsx(A0,{})}function Wn(e){switch(e){case It.TODO:return pe.Pending;case It.IN_PROGRESS:return pe.Running;case It.IN_REVIEW:return pe.Review;case It.DONE:return pe.Done;case It.CANCELLED:return pe.Cancelled}}function D0(e){switch(e){case pe.Pending:return It.TODO;case pe.Running:return It.IN_PROGRESS;case pe.Review:return It.IN_REVIEW;case pe.Done:return It.DONE;case pe.Cancelled:return It.CANCELLED}}function L0(e){switch(e){case Bt.CLAUDE_CODE:return"Claude Code";case Bt.GEMINI_CLI:return"Gemini CLI";case Bt.CURSOR_AGENT:return"Cursor Agent";case Bt.CODEX:return"Codex"}}const $r=["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 pc(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 gc(e,s){return s??e?.find(r=>r.status==="ACTIVE")??e?.[0]}function vc(e){return e?e.workspaceKind===jt.MAIN_DIRECTORY?"Project directory":e.branchName:"—"}function P0(e){return{id:e.id,name:e.name,color:e.color||$r[pc(e.name,$r.length)],isGitRepo:e.isGitRepo,archivedAt:e.archivedAt??null,repoDeletedAt:e.repoDeletedAt??null}}function O0(e){const s=gc(e);if(!s)return{agent:"—",branch:"—"};const r=vc(s),o=s.sessions;if(o&&o.length>0){const p=o[o.length-1];return{agent:L0(p.agentType),branch:r}}return{agent:"—",branch:r}}function I0(e){const{agent:s,branch:r}=O0(e.workspaces),o=e.project;return{id:e.id,projectId:e.projectId,title:e.titlePreview??e.title,status:Wn(e.status),agent:s,branch:r,description:e.contentPreview??e.description??"",updatedAt:e.updatedAt,isGitRepo:o?.isGitRepo,projectArchivedAt:o?.archivedAt??null,projectRepoDeletedAt:o?.repoDeletedAt??null}}function B0(e,s,r){const o=gc(e.workspaces,r),p=vc(o);return{id:e.id,projectId:s.id,projectName:s.name,projectColor:s.color||$r[pc(s.name,$r.length)],title:e.titlePreview??e.title,status:Wn(e.status),branch:p,mainBranch:o?.baseBranch??s.mainBranch??"main",description:e.description??"",isGitRepo:s.isGitRepo,projectArchivedAt:s.archivedAt??null,projectRepoDeletedAt:s.repoDeletedAt??null}}const ia={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 F0(e){const s=e.split("/");return s[s.length-1]||e}function z0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function W0({workingDir:e,filePath:s,type:r}){const{t:o}=ce(),{data:p,isLoading:m,isError:v}=Xl(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(Ye,{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 i=p?.diff||"";if(!i.trim())return t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:o("No diff content available.")});const n=i.split(`
|
|
81
|
-
`);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:n.map((l,u)=>{let c="",g="text-neutral-400";return l.startsWith("+")&&!l.startsWith("+++")?(c="bg-emerald-950/40",g="text-emerald-400"):l.startsWith("-")&&!l.startsWith("---")?(c="bg-red-950/40",g="text-red-400"):l.startsWith("@@")&&(c="bg-blue-950/30",g="text-blue-400"),t.jsx("div",{className:te("px-3 whitespace-pre",c,g),children:l},u)})})}function H0({entry:e,type:s,workingDir:r}){const[o,p]=C.useState(!1),m=ia[e.status]||ia.M,v=z0(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(i=>!i),className:te("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:te("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:F0(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(yt,{size:14}):t.jsx(Mt,{size:14})})]}),o&&t.jsx(W0,{workingDir:r,filePath:e.path,type:s})]})}function na({title:e,entries:s,type:r,workingDir:o,defaultOpen:p}){const{t:m}=ce(),[v,i]=C.useState(p);return s.length===0?null:t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>i(n=>!n),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(yt,{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(n=>t.jsx(H0,{entry:n,type:r,workingDir:o},`${r}:${n.path}`))})]})}function $0({workingDir:e}){const{t:s}=ce(),{data:r,isLoading:o,isError:p}=ni(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(Ye,{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(Ls,{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(na,{title:"Uncommitted",entries:m,type:"uncommitted",workingDir:e,defaultOpen:!0}),t.jsx(na,{title:"Committed",entries:v,type:"committed",workingDir:e,defaultOpen:!1})]})}const Pi=50,oa={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 U0(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?pt("{count}s ago",{count:r}):r<3600?pt("{count}m ago",{count:Math.floor(r/60)}):r<86400?pt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?pt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function q0(e){const s=e.split("/");return s[s.length-1]||e}function K0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function X0({workingDir:e,hash:s,filePath:r}){const{t:o}=ce(),{data:p,isLoading:m,isError:v}=Bn(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(Ye,{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 i=p?.diff||"";if(!i.trim())return t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:o("No diff content available.")});const n=i.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:n.map((l,u)=>{let c="",g="text-neutral-400";return l.startsWith("+")&&!l.startsWith("+++")?(c="bg-emerald-950/40",g="text-emerald-400"):l.startsWith("-")&&!l.startsWith("---")?(c="bg-red-950/40",g="text-red-400"):l.startsWith("@@")&&(c="bg-blue-950/30",g="text-blue-400"),t.jsx("div",{className:te("px-3 whitespace-pre",c,g),children:l},u)})})}function V0({entry:e,workingDir:s,hash:r}){const[o,p]=C.useState(!1),m=oa[e.status]||oa.M,v=K0(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(i=>!i),className:te("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:te("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:q0(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(yt,{size:14}):t.jsx(Mt,{size:14})})]}),o&&t.jsx(X0,{workingDir:s,hash:r,filePath:e.path})]})}function Y0({commit:e,workingDir:s}){const{t:r}=ce(),[o,p]=C.useState(!1),{data:m,isLoading:v}=In(s,o?e.hash:null),i=m?.files||[];return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(n=>!n),className:te("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:te("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:U0(e.timestamp)})]})]}),t.jsx("span",{className:"text-neutral-400 shrink-0 pt-0.5",children:o?t.jsx(yt,{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(Ye,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:r("Loading files...")})]}):i.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:i.map(n=>t.jsx(V0,{entry:n,workingDir:s,hash:e.hash},n.path))})]})]})}function G0({workingDir:e}){const{t:s}=ce(),{data:r,isLoading:o,isError:p,fetchNextPage:m,hasNextPage:v,isFetchingNextPage:i}=gn({queryKey:ne.git.log(e||""),queryFn:({pageParam:l=0})=>ge.get("/git/log",{params:{workingDir:e||"",limit:String(Pi),skip:String(l)}}),initialPageParam:0,getNextPageParam:(l,u)=>l.commits.length<Pi?void 0:u.length*Pi,enabled:!!e}),n=r?.pages.flatMap(l=>l.commits)||[];return e?o?t.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[t.jsx(Ye,{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.")}):n.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[t.jsx(Ts,{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:n.map(l=>t.jsx(Y0,{commit:l,workingDir:e},l.hash))}),v&&t.jsx("button",{type:"button",onClick:()=>m(),disabled:i,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:i?t.jsxs(t.Fragment,{children:[t.jsx(Ye,{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 Q0="/api",Z0=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${Q0}/attachments/by-path?path=${encodeURIComponent(e)}`:e;function J0({status:e}){const s={[pe.Running]:"bg-blue-500",[pe.Review]:"bg-amber-500",[pe.Pending]:"bg-neutral-400",[pe.Done]:"bg-emerald-500",[pe.Cancelled]:"bg-neutral-400"};return t.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${s[e]}`})}const ex=[{key:"chat",label:"Chat",icon:qr},{key:"changes",label:"Changes",icon:Ls},{key:"history",label:"History",icon:Ts},{key:"workspace",label:"Workspace",icon:Vr}],tx=[{key:"chat",label:"Team room",icon:qr},{key:"team-status",label:"Team Status",icon:us},{key:"changes",label:"Changes",icon:Ls},{key:"workspace",label:"Workspace",icon:Vr}];function aa({state:e,onRetry:s}){const{t:r}=ce(),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(Re,{size:"sm",variant:"outline",className:"mt-3",onClick:s,children:[t.jsx(Ut,{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 sx({task:e,onBack:s,onDeleteTask:r,isDeleting:o,autoStartState:p,onAutoStartRecovered:m}){const{t:v}=ce(),i=sn(ee=>ee.setVisibleContext),[n,l]=C.useState("chat"),[u,c]=C.useState(""),[g,_]=C.useState(!1),[y,x]=C.useState(!1),[a,h]=C.useState(!1),[d,f]=C.useState(null),[b,w]=C.useState(void 0),k=C.useRef(null),j=C.useRef(null),S=C.useRef(null),E=C.useRef(null),{scrollRef:R,contentRef:L,isAtBottom:T,scrollToBottom:A}=dn({resize:"smooth",initial:"instant"}),B=ot();C.useEffect(()=>{if(!a)return;const ee=_e=>{j.current&&!j.current.contains(_e.target)&&h(!1)};return document.addEventListener("mousedown",ee),()=>document.removeEventListener("mousedown",ee)},[a]);const{data:D,isLoading:z}=En(e.id),{data:H}=ba(e.id),{data:M}=ya(H?.id??""),O=rn(H?.id??""),P=H??null,I=e.isGitRepo!==!1,$=C.useMemo(()=>(P?tx:ex).filter(ee=>I||ee.key!=="changes"&&ee.key!=="history"),[I,P]),Y=H===null,{data:q,isLoading:V}=Sa(e.id,Y),F=!!e.projectArchivedAt,N=!!e.projectRepoDeletedAt,W=v(N?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。");C.useEffect(()=>{w(void 0),f(null)},[e.id]),C.useEffect(()=>{P&&n==="history"&&l("chat"),!P&&n==="team-status"&&l("chat"),$.some(ee=>ee.key===n)||l("chat")},[n,$,P]);const X=C.useMemo(()=>gl(D,P,b),[b,P,D]);C.useEffect(()=>{b&&!D?.some(ee=>ee.id===b)&&w(void 0)},[b,D]);const K=C.useMemo(()=>D?.find(ee=>ee.id===X),[X,D]),ie=C.useMemo(()=>{if(D){if(K)return ss(K);for(const ee of D)if(ee.status==="ACTIVE"&&ss(ee))return ss(ee);return ss(D[0])}},[K,D]),Z=K?.status===Rt.ACTIVE?K.id:void 0,re=I&&vl(K,P),he=K?.branchName??"",fe=K?.commitMessage,Be=C.useMemo(()=>xl(K,D,e?.mainBranch??""),[K,e?.mainBranch,D]),le=!!(re&&Z&&ie&&!F),{data:Ge,isLoading:we}=Nn(Z??"",{enabled:le}),{data:qe}=ni(ie,{enabled:le}),Fe=qe?.committed?.length,[De,ze]=C.useState(!1),[Ae,Ke]=C.useState(null);C.useEffect(()=>{const ee=I&&(n==="changes"||n==="chat"&&le)?"changes":I&&n==="history"?"history":null;if(!Z||!ie||!ee){i(null);return}return i({workspaceId:Z,workingDir:ie,tab:ee}),()=>{i(null)}},[n,I,Z,i,le,ie]);const Ee=C.useMemo(()=>Ge?.conflictOp&&Ge.conflictedFiles.length>0?{conflictOp:Ge.conflictOp,conflictedFiles:Ge.conflictedFiles}:Ae,[Ge?.conflictOp,Ge?.conflictedFiles,Ae]),Ce=Ee?.targetWorkspaceId??Z,ke=Ee?.targetWorktreePath??K?.worktreePath,st=Ee?.sourceBranch??he,je=Ee?.targetBranch??Be,We=K?.sessions??[],ue=C.useCallback(ee=>{Ke(ee??null),ze(!0)},[]),dt=C.useCallback(()=>e?.id?B.invalidateQueries({queryKey:ne.workspaces.list(e.id)}):Promise.resolve(),[e?.id,B]),wt=C.useCallback(async()=>B.fetchQuery({queryKey:ne.tasks.body(e.id),queryFn:()=>ge.get(`/tasks/${e.id}/body`)}),[B,e.id]),G=C.useMemo(()=>{if(!D)return null;const ee=D.filter(Ie=>Ie.status==="ACTIVE"&&Array.isArray(Ie.sessions)).flatMap(Ie=>Ie.sessions??[]),_e=Ie=>{const Wt=Ie.createdAt,Ht=Ie.endedAt??Ie.startedAt??Wt;if(!Ht)return 0;const Pt=Date.parse(Ht);return Number.isNaN(Pt)?0:Pt},Oe=Ie=>{const Wt=ee.filter(Ht=>Ie.includes(Ht.status));return Wt.length===0?null:Wt.sort((Ht,Pt)=>_e(Pt)-_e(Ht))[0]??null},Le=Oe([it.RUNNING])??Oe([it.PENDING])??Oe([it.COMPLETED,it.FAILED,it.CANCELLED]);if(Le)return Le;const xt=D.filter(Ie=>(Ie.status==="ABANDONED"||Ie.status==="MERGED"||Ie.status==="HIBERNATED")&&Array.isArray(Ie.sessions)).flatMap(Ie=>Ie.sessions??[]).filter(Ie=>[it.COMPLETED,it.FAILED,it.CANCELLED].includes(Ie.status));return xt.length===0?null:xt.sort((Ie,Wt)=>_e(Wt)-_e(Ie))[0]??null},[D]),U=G?.id??"",Q=P?d??"":U,se=C.useMemo(()=>{if(!d||!D)return null;for(const ee of D){const _e=ee.sessions?.find(Oe=>Oe.id===d);if(_e)return _e}return null},[d,D]),de=C.useMemo(()=>{if(!d||!P?.invocations)return null;const ee=P.invocations.filter(_e=>_e.sessionId===d);return ee.length===0?null:ee.sort((_e,Oe)=>{const Le=Date.parse(_e.updatedAt??_e.createdAt??""),Et=Date.parse(Oe.updatedAt??Oe.createdAt??"");return(Number.isNaN(Et)?0:Et)-(Number.isNaN(Le)?0:Le)})[0]??null},[d,P?.invocations]),Ne=C.useMemo(()=>!de?.memberId||!P?.members?null:P.members.find(ee=>ee.id===de.memberId)??null,[de?.memberId,P?.members]),ve=d?se:G??null,be=ve?.status===it.RUNNING||ve?.status===it.PENDING,me=C.useMemo(()=>!G||!D?!1:!D.some(_e=>_e.status==="ACTIVE"&&_e.sessions?.some(Oe=>Oe.id===G.id)),[G,D]),{data:Me}=Ds(),[Se,Pe]=C.useState(null),He=Se?.sessionId===U?Se.providerId:G?.providerId??null,ut=C.useCallback(ee=>{Pe({sessionId:U,providerId:ee})},[U]),Je=fc({agentType:G?.agentType,workingDir:ie,input:u,setInput:c,textareaRef:S,minHeight:40,maxHeight:140}),xe=mc({agentType:G?.agentType,workingDir:ie,input:u,setInput:c,textareaRef:S,minHeight:40,maxHeight:140}),ht=ie&&K?K.id:void 0,Qe=zn(),et=jn(),mt=rc(),{isConnected:gt,isLoadingSnapshot:vt,logs:Xe,entries:Xt,attach:ps}=La({sessionId:Q,sessionStatus:ve?.status,onExit:C.useCallback(()=>{B.invalidateQueries({queryKey:["workspaces"]})},[B])}),{todos:gs}=Pa(Xt),{files:ai,addFiles:tt,removeFile:vs,clear:Is,buildMarkdownLinks:Bs,hasFiles:Vt,isUploading:ls}=cn(),hr=C.useMemo(()=>nc(ve),[ve?.tokenUsage]),Fs=Ta(Xe,hr);C.useEffect(()=>{Q&>&&ps()},[Q,gt,ps]);const xs=C.useRef(null);C.useEffect(()=>{if(xs.current!==e.id&&R.current){const ee=R.current;requestAnimationFrame(()=>{ee.scrollTop=ee.scrollHeight})}xs.current=e.id},[e.id,R]);const zt=C.useRef(!1),_s=C.useCallback(async()=>{if(!u.trim()&&!Vt||!U||zt.current||ls)return;zt.current=!0;const ee=Bs(),_e=[u.trim(),ee].filter(Boolean).join(`
|
|
83
|
-
|
|
84
|
-
`);c(""),Is(),S.current&&(S.current.style.height="40px"),Qe.mutate({id:U,message:_e,providerId:He??void 0},{onSuccess:()=>ps(),onSettled:()=>{zt.current=!1}})},[u,U,Qe,ps,Vt,ls,Bs,Is,He]),li=C.useCallback(async()=>{U&&(await mt.mutateAsync(U),B.invalidateQueries({queryKey:["workspaces"]}))},[U,mt,B]),zs=C.useCallback(ee=>O.mutateAsync(ee),[O]),fr=C.useCallback(ee=>{f(ee),l("chat"),requestAnimationFrame(()=>{A()})},[A]),ci=C.useCallback(()=>{f(null)},[]),mr=C.useCallback(()=>{l("changes")},[]),pr=le&&Z?t.jsx(dc,{workspaceId:Z,branchName:he,targetBranch:Be,commitMessage:fe,changes:qe,gitStatus:Ge,isGitStatusLoading:we,canRunGitOperations:re,onOpenChanges:mr,onRefreshCommitMessage:dt,onConflict:ue,className:"mb-2"}):null,bs=C.useCallback(ee=>{const _e=ee.target.files;_e&&_e.length>0&&tt(Array.from(_e)),ee.target.value=""},[tt]),di=C.useCallback(ee=>{const _e=ee.clipboardData.items,Oe=[];for(const Le of _e)if(Le.kind==="file"){const Et=Le.getAsFile();Et&&Oe.push(Et)}Oe.length>0&&(ee.preventDefault(),tt(Oe))},[tt]),Yt=C.useCallback(ee=>{c(ee.target.value);const _e=ee.target;_e.style.height="auto",_e.style.height=`${Math.max(40,Math.min(_e.scrollHeight,140))}px`},[]),gr=C.useCallback(()=>{ht&&et.mutate({workspaceId:ht})},[et,ht]),Gt=C.useRef(null);return C.useEffect(()=>{const ee=window.visualViewport;if(!ee)return;let _e=!1;const Oe=()=>{Gt.current&&(Gt.current.style.height=`${ee.height}px`,Gt.current.style.top=`${ee.offsetTop}px`)},Le=()=>Oe(),Et=()=>{_e||Oe()},xt=()=>{_e=!0},Ie=()=>{_e=!1,requestAnimationFrame(Oe)};return ee.addEventListener("resize",Le),ee.addEventListener("scroll",Et),document.addEventListener("touchstart",xt,{passive:!0}),document.addEventListener("touchend",Ie,{passive:!0}),document.addEventListener("touchcancel",Ie,{passive:!0}),()=>{ee.removeEventListener("resize",Le),ee.removeEventListener("scroll",Et),document.removeEventListener("touchstart",xt),document.removeEventListener("touchend",Ie),document.removeEventListener("touchcancel",Ie)}},[]),C.useEffect(()=>{const ee=Gt.current;if(!ee)return;const _e=Oe=>{let Le=Oe.target;for(;Le&&Le!==ee;){if(Le.tagName==="TEXTAREA"){if(Le.scrollHeight>Le.clientHeight)return;Le=Le.parentElement;continue}const xt=window.getComputedStyle(Le).overflowY;if((xt==="auto"||xt==="scroll")&&Le.scrollHeight>Le.clientHeight)return;Le=Le.parentElement}Oe.preventDefault()};return ee.addEventListener("touchmove",_e,{passive:!1}),()=>ee.removeEventListener("touchmove",_e)},[]),t.jsxs("div",{ref:Gt,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(J0,{status:e.status}),t.jsx("button",{onClick:gr,disabled:!ht||F,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:t.jsx(Xr,{size:16})}),r&&!F&&t.jsxs("div",{className:"relative",ref:j,children:[t.jsx("button",{onClick:()=>h(ee=>!ee),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:t.jsx(Fa,{size:16})}),a&&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:()=>{x(!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(pn,{size:15}),t.jsx("span",{children:v("删除任务")})]})})]})]}),t.jsx("div",{className:"flex border-t border-neutral-100",children:$.map(({key:ee,label:_e,icon:Oe})=>t.jsxs("button",{onClick:()=>l(ee),className:`flex min-w-0 flex-1 items-center justify-center gap-1 px-1 py-2 text-[11px] font-medium transition-colors ${n===ee?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[t.jsx(Oe,{size:13,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:v(_e)})]},ee))})]}),n==="chat"&&(P?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(oc,{session:ve,providers:Me,usage:Fs,compact:!0,providerIdFallback:Ne?.providerId,agentTypeFallback:ve?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Re,{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:ci,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:R,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:L,children:vt?t.jsx(Oi,{label:v("Loading logs...")}):Xe.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:v(be?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(Nr,{logs:Xe})})}),!T&&t.jsxs("button",{onClick:()=>A(),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(Qs,{size:12}),t.jsx("span",{children:v("回到底部")})]})]}),gs.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(Rr,{todos:gs,compact:!0})})]}):t.jsx(pl,{teamRun:P,messages:M??P.messages??[],readOnly:F,readOnlyMessage:W,onSendMessage:zs,onViewInvocationSession:fr,changeSummaryBar:pr,compactComposer:!0})}):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:R,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:L,children:[t.jsx("div",{className:"mb-3 pb-2 border-b border-neutral-100",children:V?t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:v("Loading...")}):q?.body?t.jsx("div",{className:"text-[13px] text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:t.jsx(nn,{urlTransform:Z0,components:on,children:q.body})}):t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),!F&&p&&(z||U)?t.jsx("div",{className:"flex justify-center py-2",children:t.jsx(aa,{state:p,onRetry:p.status==="failed"?async()=>{await wt(),_(!0)}:void 0})}):null,z?t.jsx(Oi,{label:"Loading..."}):U?vt?t.jsx(Oi,{label:"Loading logs..."}):Xe.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:be?"Waiting for agent output...":"No logs recorded."}):t.jsx(Nr,{logs:Xe}):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(Ut,{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:F?W:v("选择一个 Agent 来执行此任务")}),!F&&p?t.jsx(aa,{state:p}):null,!F&&t.jsxs(Re,{onClick:async()=>{await wt(),_(!0)},disabled:!!(p&&p.status!=="failed"),children:[t.jsx(Ut,{size:16,className:"mr-1.5"}),p?.status==="failed"?v("重试启动 Agent"):v("启动 Agent")]})]})]})}),!T&&t.jsxs("button",{onClick:()=>A(),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(Qs,{size:12}),t.jsx("span",{children:v("回到底部")})]})]}),gs.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(Rr,{todos:gs,compact:!0})}),F?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:W})}):me?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(Re,{size:"sm",onClick:async()=>{await wt(),_(!0)},children:[t.jsx(Ut,{size:14,className:"mr-1.5"}),v("启动新 Agent")]})]})}):U&&t.jsxs("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:[pr,t.jsxs("div",{ref:k,className:"relative bg-white rounded-xl border border-neutral-200 shadow-sm focus-within:border-neutral-300",children:[t.jsx(un,{files:ai,onRemove:vs}),t.jsx("textarea",{ref:S,value:u,onChange:Yt,onPaste:di,onKeyDown:ee=>{xe.handleKeyDown(ee)||Je.handleKeyDown(ee)||ee.key==="Enter"&&!ee.shiftKey&&!ee.repeat&&!ee.nativeEvent.isComposing&&ee.nativeEvent.keyCode!==229&&(ee.preventDefault(),_s())},rows:1,placeholder:be?"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:E,type:"file",multiple:!0,className:"hidden",onChange:bs}),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:()=>E.current?.click(),className:"p-1 text-neutral-400 active:text-neutral-600 rounded-lg",children:t.jsx(mn,{size:15})})}),t.jsxs("div",{className:"flex items-center gap-1",children:[G&&Me&&t.jsx(Da,{providers:Me,currentProviderId:He,agentType:G.agentType,onSelect:ut}),t.jsx(fn,{usage:Fs}),be&&!u.trim()&&!Vt?t.jsx("button",{onClick:li,disabled:mt.isPending,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:t.jsx(Ms,{size:12})}):t.jsx("button",{onClick:_s,disabled:!u.trim()&&!Vt||ls,className:`p-1.5 rounded-lg transition-colors ${(u.trim()||Vt)&&!ls?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:t.jsx(hn,{size:15})})]})]})]}),t.jsx(Hr,{open:Je.query!==null,anchorRef:k,commands:Je.filteredCommands,selectedIndex:Je.selectedIndex,query:Je.query??"",hasCatalog:Je.allCommands.length>0,compact:!0,onSelect:Je.applyCommand}),t.jsx(Hr,{open:xe.query!==null,anchorRef:k,commands:xe.filteredSkills,selectedIndex:xe.selectedIndex,query:xe.query??"",hasCatalog:xe.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",compact:!0,onSelect:xe.applySkill})]})]})),n==="team-status"&&P&&t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:t.jsx(yl,{teamRun:P,workspaces:D,selectedWorkspaceId:X,onSelectWorkspace:w,onViewInvocationSession:fr})}),n==="changes"&&I&&t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[D&&D.length>1&&t.jsx("div",{className:"shrink-0 border-b border-neutral-100 bg-white px-3 py-2",children:t.jsx(tc,{workspaces:D,teamRun:P,selectedWorkspaceId:X,onSelectWorkspace:w,className:"w-full",buttonClassName:"w-full max-w-none min-w-0 justify-start"})}),re&&Z&&t.jsx("div",{className:"shrink-0",children:t.jsx(Gl,{workspaceId:Z,branchName:he,targetBranch:Be,commitMessage:fe,committedFileCount:Fe,onRefreshCommitMessage:dt,onConflict:ue,onResolveConflicts:()=>ue()})}),t.jsx($0,{workingDir:ie})]}),n==="history"&&t.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:t.jsx(G0,{workingDir:ie})}),n==="workspace"&&t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(sc,{sessionId:U||void 0,workspaceId:X,workingDir:ie,projectId:e.projectId,className:"h-full",hideChanges:!0,gitAvailable:I,readOnly:F,repoDeleted:N})}),!F&&t.jsx(ic,{isOpen:g,onClose:()=>_(!1),taskId:e.id,taskTitle:q?.title??e.title,taskDescription:q?.body??"",taskPrompt:q?.prompt,projectIsGitRepo:I,onStarted:()=>m?.(e.id)}),t.jsx(An,{isOpen:y,onClose:()=>x(!1),onConfirm:()=>{r?.(e.id),x(!1)},taskId:e.id,taskTitle:e.title,workspaces:D,isLoading:o}),De&&Ee&&Ce&&t.jsx(cc,{open:De,onOpenChange:ee=>{ze(ee),ee||Ke(null)},workspaceId:Ce,conflictOp:Ee.conflictOp,conflictedFiles:Ee.conflictedFiles,sourceBranch:st,targetBranch:je,operation:Ge?.operation,worktreePath:ke,mergeAborted:Ee.mergeAborted,mergeStrategy:Ee.mergeStrategy,sourceWorkspaceId:Ee.sourceWorkspaceId,targetWorkspaceId:Ee.targetWorkspaceId,sourceWorktreePath:Ee.sourceWorktreePath,targetWorktreePath:Ee.targetWorktreePath,sessions:We,currentSessionId:P?void 0:U,teamRunId:P?.id})]})}function Oi({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 rx=Object.defineProperty,Ur=Object.getOwnPropertySymbols,xc=Object.prototype.hasOwnProperty,_c=Object.prototype.propertyIsEnumerable,la=(e,s,r)=>s in e?rx(e,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[s]=r,Ji=(e,s)=>{for(var r in s||(s={}))xc.call(s,r)&&la(e,r,s[r]);if(Ur)for(var r of Ur(s))_c.call(s,r)&&la(e,r,s[r]);return e},en=(e,s)=>{var r={};for(var o in e)xc.call(e,o)&&s.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&Ur)for(var o of Ur(e))s.indexOf(o)<0&&_c.call(e,o)&&(r[o]=e[o]);return r};var ms;(e=>{const s=class ye{constructor(n,l,u,c){if(this.version=n,this.errorCorrectionLevel=l,this.modules=[],this.isFunction=[],n<ye.MIN_VERSION||n>ye.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=n*4+17;let g=[];for(let y=0;y<this.size;y++)g.push(!1);for(let y=0;y<this.size;y++)this.modules.push(g.slice()),this.isFunction.push(g.slice());this.drawFunctionPatterns();const _=this.addEccAndInterleave(u);if(this.drawCodewords(_),c==-1){let y=1e9;for(let x=0;x<8;x++){this.applyMask(x),this.drawFormatBits(x);const a=this.getPenaltyScore();a<y&&(c=x,y=a),this.applyMask(x)}}p(0<=c&&c<=7),this.mask=c,this.applyMask(c),this.drawFormatBits(c),this.isFunction=[]}static encodeText(n,l){const u=e.QrSegment.makeSegments(n);return ye.encodeSegments(u,l)}static encodeBinary(n,l){const u=e.QrSegment.makeBytes(n);return ye.encodeSegments([u],l)}static encodeSegments(n,l,u=1,c=40,g=-1,_=!0){if(!(ye.MIN_VERSION<=u&&u<=c&&c<=ye.MAX_VERSION)||g<-1||g>7)throw new RangeError("Invalid value");let y,x;for(y=u;;y++){const f=ye.getNumDataCodewords(y,l)*8,b=v.getTotalBits(n,y);if(b<=f){x=b;break}if(y>=c)throw new RangeError("Data too long")}for(const f of[ye.Ecc.MEDIUM,ye.Ecc.QUARTILE,ye.Ecc.HIGH])_&&x<=ye.getNumDataCodewords(y,f)*8&&(l=f);let a=[];for(const f of n){r(f.mode.modeBits,4,a),r(f.numChars,f.mode.numCharCountBits(y),a);for(const b of f.getData())a.push(b)}p(a.length==x);const h=ye.getNumDataCodewords(y,l)*8;p(a.length<=h),r(0,Math.min(4,h-a.length),a),r(0,(8-a.length%8)%8,a),p(a.length%8==0);for(let f=236;a.length<h;f^=253)r(f,8,a);let d=[];for(;d.length*8<a.length;)d.push(0);return a.forEach((f,b)=>d[b>>>3]|=f<<7-(b&7)),new ye(y,l,d,g)}getModule(n,l){return 0<=n&&n<this.size&&0<=l&&l<this.size&&this.modules[l][n]}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 n=this.getAlignmentPatternPositions(),l=n.length;for(let u=0;u<l;u++)for(let c=0;c<l;c++)u==0&&c==0||u==0&&c==l-1||u==l-1&&c==0||this.drawAlignmentPattern(n[u],n[c]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(n){const l=this.errorCorrectionLevel.formatBits<<3|n;let u=l;for(let g=0;g<10;g++)u=u<<1^(u>>>9)*1335;const c=(l<<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 n=this.version;for(let u=0;u<12;u++)n=n<<1^(n>>>11)*7973;const l=this.version<<12|n;p(l>>>18==0);for(let u=0;u<18;u++){const c=o(l,u),g=this.size-11+u%3,_=Math.floor(u/3);this.setFunctionModule(g,_,c),this.setFunctionModule(_,g,c)}}drawFinderPattern(n,l){for(let u=-4;u<=4;u++)for(let c=-4;c<=4;c++){const g=Math.max(Math.abs(c),Math.abs(u)),_=n+c,y=l+u;0<=_&&_<this.size&&0<=y&&y<this.size&&this.setFunctionModule(_,y,g!=2&&g!=4)}}drawAlignmentPattern(n,l){for(let u=-2;u<=2;u++)for(let c=-2;c<=2;c++)this.setFunctionModule(n+c,l+u,Math.max(Math.abs(c),Math.abs(u))!=1)}setFunctionModule(n,l,u){this.modules[l][n]=u,this.isFunction[l][n]=!0}addEccAndInterleave(n){const l=this.version,u=this.errorCorrectionLevel;if(n.length!=ye.getNumDataCodewords(l,u))throw new RangeError("Invalid argument");const c=ye.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][l],g=ye.ECC_CODEWORDS_PER_BLOCK[u.ordinal][l],_=Math.floor(ye.getNumRawDataModules(l)/8),y=c-_%c,x=Math.floor(_/c);let a=[];const h=ye.reedSolomonComputeDivisor(g);for(let f=0,b=0;f<c;f++){let w=n.slice(b,b+x-g+(f<y?0:1));b+=w.length;const k=ye.reedSolomonComputeRemainder(w,h);f<y&&w.push(0),a.push(w.concat(k))}let d=[];for(let f=0;f<a[0].length;f++)a.forEach((b,w)=>{(f!=x-g||w>=y)&&d.push(b[f])});return p(d.length==_),d}drawCodewords(n){if(n.length!=Math.floor(ye.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let l=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 _=u-g,x=(u+1&2)==0?this.size-1-c:c;!this.isFunction[x][_]&&l<n.length*8&&(this.modules[x][_]=o(n[l>>>3],7-(l&7)),l++)}}p(l==n.length*8)}applyMask(n){if(n<0||n>7)throw new RangeError("Mask value out of range");for(let l=0;l<this.size;l++)for(let u=0;u<this.size;u++){let c;switch(n){case 0:c=(u+l)%2==0;break;case 1:c=l%2==0;break;case 2:c=u%3==0;break;case 3:c=(u+l)%3==0;break;case 4:c=(Math.floor(u/3)+Math.floor(l/2))%2==0;break;case 5:c=u*l%2+u*l%3==0;break;case 6:c=(u*l%2+u*l%3)%2==0;break;case 7:c=((u+l)%2+u*l%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[l][u]&&c&&(this.modules[l][u]=!this.modules[l][u])}}getPenaltyScore(){let n=0;for(let g=0;g<this.size;g++){let _=!1,y=0,x=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[g][a]==_?(y++,y==5?n+=ye.PENALTY_N1:y>5&&n++):(this.finderPenaltyAddHistory(y,x),_||(n+=this.finderPenaltyCountPatterns(x)*ye.PENALTY_N3),_=this.modules[g][a],y=1);n+=this.finderPenaltyTerminateAndCount(_,y,x)*ye.PENALTY_N3}for(let g=0;g<this.size;g++){let _=!1,y=0,x=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][g]==_?(y++,y==5?n+=ye.PENALTY_N1:y>5&&n++):(this.finderPenaltyAddHistory(y,x),_||(n+=this.finderPenaltyCountPatterns(x)*ye.PENALTY_N3),_=this.modules[a][g],y=1);n+=this.finderPenaltyTerminateAndCount(_,y,x)*ye.PENALTY_N3}for(let g=0;g<this.size-1;g++)for(let _=0;_<this.size-1;_++){const y=this.modules[g][_];y==this.modules[g][_+1]&&y==this.modules[g+1][_]&&y==this.modules[g+1][_+1]&&(n+=ye.PENALTY_N2)}let l=0;for(const g of this.modules)l=g.reduce((_,y)=>_+(y?1:0),l);const u=this.size*this.size,c=Math.ceil(Math.abs(l*20-u*10)/u)-1;return p(0<=c&&c<=9),n+=c*ye.PENALTY_N4,p(0<=n&&n<=2568888),n}getAlignmentPatternPositions(){if(this.version==1)return[];{const n=Math.floor(this.version/7)+2,l=this.version==32?26:Math.ceil((this.version*4+4)/(n*2-2))*2;let u=[6];for(let c=this.size-7;u.length<n;c-=l)u.splice(1,0,c);return u}}static getNumRawDataModules(n){if(n<ye.MIN_VERSION||n>ye.MAX_VERSION)throw new RangeError("Version number out of range");let l=(16*n+128)*n+64;if(n>=2){const u=Math.floor(n/7)+2;l-=(25*u-10)*u-55,n>=7&&(l-=36)}return p(208<=l&&l<=29648),l}static getNumDataCodewords(n,l){return Math.floor(ye.getNumRawDataModules(n)/8)-ye.ECC_CODEWORDS_PER_BLOCK[l.ordinal][n]*ye.NUM_ERROR_CORRECTION_BLOCKS[l.ordinal][n]}static reedSolomonComputeDivisor(n){if(n<1||n>255)throw new RangeError("Degree out of range");let l=[];for(let c=0;c<n-1;c++)l.push(0);l.push(1);let u=1;for(let c=0;c<n;c++){for(let g=0;g<l.length;g++)l[g]=ye.reedSolomonMultiply(l[g],u),g+1<l.length&&(l[g]^=l[g+1]);u=ye.reedSolomonMultiply(u,2)}return l}static reedSolomonComputeRemainder(n,l){let u=l.map(c=>0);for(const c of n){const g=c^u.shift();u.push(0),l.forEach((_,y)=>u[y]^=ye.reedSolomonMultiply(_,g))}return u}static reedSolomonMultiply(n,l){if(n>>>8||l>>>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^=(l>>>c&1)*n;return p(u>>>8==0),u}finderPenaltyCountPatterns(n){const l=n[1];p(l<=this.size*3);const u=l>0&&n[2]==l&&n[3]==l*3&&n[4]==l&&n[5]==l;return(u&&n[0]>=l*4&&n[6]>=l?1:0)+(u&&n[6]>=l*4&&n[0]>=l?1:0)}finderPenaltyTerminateAndCount(n,l,u){return n&&(this.finderPenaltyAddHistory(l,u),l=0),l+=this.size,this.finderPenaltyAddHistory(l,u),this.finderPenaltyCountPatterns(u)}finderPenaltyAddHistory(n,l){l[0]==0&&(n+=this.size),l.pop(),l.unshift(n)}};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(i,n,l){if(n<0||n>31||i>>>n)throw new RangeError("Value out of range");for(let u=n-1;u>=0;u--)l.push(i>>>u&1)}function o(i,n){return(i>>>n&1)!=0}function p(i){if(!i)throw new Error("Assertion error")}const m=class rt{constructor(n,l,u){if(this.mode=n,this.numChars=l,this.bitData=u,l<0)throw new RangeError("Invalid argument");this.bitData=u.slice()}static makeBytes(n){let l=[];for(const u of n)r(u,8,l);return new rt(rt.Mode.BYTE,n.length,l)}static makeNumeric(n){if(!rt.isNumeric(n))throw new RangeError("String contains non-numeric characters");let l=[];for(let u=0;u<n.length;){const c=Math.min(n.length-u,3);r(parseInt(n.substring(u,u+c),10),c*3+1,l),u+=c}return new rt(rt.Mode.NUMERIC,n.length,l)}static makeAlphanumeric(n){if(!rt.isAlphanumeric(n))throw new RangeError("String contains unencodable characters in alphanumeric mode");let l=[],u;for(u=0;u+2<=n.length;u+=2){let c=rt.ALPHANUMERIC_CHARSET.indexOf(n.charAt(u))*45;c+=rt.ALPHANUMERIC_CHARSET.indexOf(n.charAt(u+1)),r(c,11,l)}return u<n.length&&r(rt.ALPHANUMERIC_CHARSET.indexOf(n.charAt(u)),6,l),new rt(rt.Mode.ALPHANUMERIC,n.length,l)}static makeSegments(n){return n==""?[]:rt.isNumeric(n)?[rt.makeNumeric(n)]:rt.isAlphanumeric(n)?[rt.makeAlphanumeric(n)]:[rt.makeBytes(rt.toUtf8ByteArray(n))]}static makeEci(n){let l=[];if(n<0)throw new RangeError("ECI assignment value out of range");if(n<128)r(n,8,l);else if(n<16384)r(2,2,l),r(n,14,l);else if(n<1e6)r(6,3,l),r(n,21,l);else throw new RangeError("ECI assignment value out of range");return new rt(rt.Mode.ECI,0,l)}static isNumeric(n){return rt.NUMERIC_REGEX.test(n)}static isAlphanumeric(n){return rt.ALPHANUMERIC_REGEX.test(n)}getData(){return this.bitData.slice()}static getTotalBits(n,l){let u=0;for(const c of n){const g=c.mode.numCharCountBits(l);if(c.numChars>=1<<g)return 1/0;u+=4+g+c.bitData.length}return u}static toUtf8ByteArray(n){n=encodeURI(n);let l=[];for(let u=0;u<n.length;u++)n.charAt(u)!="%"?l.push(n.charCodeAt(u)):(l.push(parseInt(n.substring(u+1,u+3),16)),u+=2);return l}};m.NUMERIC_REGEX=/^[0-9]*$/,m.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,m.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let v=m;e.QrSegment=m})(ms||(ms={}));(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={}))})(ms||(ms={}));(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={}))})(ms||(ms={}));var Ns=ms;var ix={L:Ns.QrCode.Ecc.LOW,M:Ns.QrCode.Ecc.MEDIUM,Q:Ns.QrCode.Ecc.QUARTILE,H:Ns.QrCode.Ecc.HIGH},bc=128,yc="L",Sc="#FFFFFF",wc="#000000",Cc=!1,kc=1,nx=4,ox=0,ax=.1;function Ec(e,s=0){const r=[];return e.forEach(function(o,p){let m=null;o.forEach(function(v,i){if(!v&&m!==null){r.push(`M${m+s} ${p+s}h${i-m}v1H${m+s}z`),m=null;return}if(i===o.length-1){if(!v)return;m===null?r.push(`M${i+s},${p+s} h1v1H${i+s}z`):r.push(`M${m+s},${p+s} h${i+1-m}v1H${m+s}z`);return}v&&m===null&&(m=i)})}),r.join("")}function jc(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 lx(e,s,r,o){if(o==null)return null;const p=e.length+r*2,m=Math.floor(s*ax),v=p/s,i=(o.width||m)*v,n=(o.height||m)*v,l=o.x==null?e.length/2-i/2:o.x*v,u=o.y==null?e.length/2-n/2:o.y*v,c=o.opacity==null?1:o.opacity;let g=null;if(o.excavate){let y=Math.floor(l),x=Math.floor(u),a=Math.ceil(i+l-y),h=Math.ceil(n+u-x);g={x:y,y:x,w:a,h}}const _=o.crossOrigin;return{x:l,y:u,h:n,w:i,excavation:g,opacity:c,crossOrigin:_}}function cx(e,s){return s!=null?Math.max(Math.floor(s),0):e?nx:ox}function Nc({value:e,level:s,minVersion:r,includeMargin:o,marginSize:p,imageSettings:m,size:v,boostLevel:i}){let n=ae.useMemo(()=>{const y=(Array.isArray(e)?e:[e]).reduce((x,a)=>(x.push(...Ns.QrSegment.makeSegments(a)),x),[]);return Ns.QrCode.encodeSegments(y,ix[s],r,void 0,void 0,i)},[e,s,r,i]);const{cells:l,margin:u,numCells:c,calculatedImageSettings:g}=ae.useMemo(()=>{let _=n.getModules();const y=cx(o,p),x=_.length+y*2,a=lx(_,v,y,m);return{cells:_,margin:y,numCells:x,calculatedImageSettings:a}},[n,v,m,o,p]);return{qrcode:n,margin:u,cells:l,numCells:c,calculatedImageSettings:g}}var dx=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),ux=ae.forwardRef(function(s,r){const o=s,{value:p,size:m=bc,level:v=yc,bgColor:i=Sc,fgColor:n=wc,includeMargin:l=Cc,minVersion:u=kc,boostLevel:c,marginSize:g,imageSettings:_}=o,x=en(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:a}=x,h=en(x,["style"]),d=_?.src,f=ae.useRef(null),b=ae.useRef(null),w=ae.useCallback(B=>{f.current=B,typeof r=="function"?r(B):r&&(r.current=B)},[r]),[k,j]=ae.useState(!1),{margin:S,cells:E,numCells:R,calculatedImageSettings:L}=Nc({value:p,level:v,minVersion:u,boostLevel:c,includeMargin:l,marginSize:g,imageSettings:_,size:m});ae.useEffect(()=>{if(f.current!=null){const B=f.current,D=B.getContext("2d");if(!D)return;let z=E;const H=b.current,M=L!=null&&H!==null&&H.complete&&H.naturalHeight!==0&&H.naturalWidth!==0;M&&L.excavation!=null&&(z=jc(E,L.excavation));const O=window.devicePixelRatio||1;B.height=B.width=m*O;const P=m/R*O;D.scale(P,P),D.fillStyle=i,D.fillRect(0,0,R,R),D.fillStyle=n,dx?D.fill(new Path2D(Ec(z,S))):E.forEach(function(I,$){I.forEach(function(Y,q){Y&&D.fillRect(q+S,$+S,1,1)})}),L&&(D.globalAlpha=L.opacity),M&&D.drawImage(H,L.x+S,L.y+S,L.w,L.h)}}),ae.useEffect(()=>{j(!1)},[d]);const T=Ji({height:m,width:m},a);let A=null;return d!=null&&(A=ae.createElement("img",{src:d,key:d,style:{display:"none"},onLoad:()=>{j(!0)},ref:b,crossOrigin:L?.crossOrigin})),ae.createElement(ae.Fragment,null,ae.createElement("canvas",Ji({style:T,height:m,width:m,ref:w,role:"img"},h)),A)});ux.displayName="QRCodeCanvas";var Rc=ae.forwardRef(function(s,r){const o=s,{value:p,size:m=bc,level:v=yc,bgColor:i=Sc,fgColor:n=wc,includeMargin:l=Cc,minVersion:u=kc,boostLevel:c,title:g,marginSize:_,imageSettings:y}=o,x=en(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:a,cells:h,numCells:d,calculatedImageSettings:f}=Nc({value:p,level:v,minVersion:u,boostLevel:c,includeMargin:l,marginSize:_,imageSettings:y,size:m});let b=h,w=null;y!=null&&f!=null&&(f.excavation!=null&&(b=jc(h,f.excavation)),w=ae.createElement("image",{href:y.src,height:f.h,width:f.w,x:f.x+a,y:f.y+a,preserveAspectRatio:"none",opacity:f.opacity,crossOrigin:f.crossOrigin}));const k=Ec(b,a);return ae.createElement("svg",Ji({height:m,width:m,viewBox:`0 0 ${d} ${d}`,ref:r,role:"img"},x),!!g&&ae.createElement("title",null,g),ae.createElement("path",{fill:i,d:`M0,0 h${d}v${d}H0z`,shapeRendering:"crispEdges"}),ae.createElement("path",{fill:n,d:k,shapeRendering:"crispEdges"}),w)});Rc.displayName="QRCodeSVG";function Ac(){return parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10)}function hx(){return Tt({queryKey:ne.tunnel.status,queryFn:()=>ge.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?5e3:!1})}function fx(){const e=ot();return St({mutationFn:()=>ge.post("/tunnel/start",{port:Ac()}),onSuccess:()=>{e.invalidateQueries({queryKey:ne.tunnel.status})}})}function mx(){const e=ot();return St({mutationFn:()=>ge.post("/tunnel/regenerate",{port:Ac()}),onSuccess:()=>{e.invalidateQueries({queryKey:ne.tunnel.status})}})}function px(){const e=ot();return St({mutationFn:()=>ge.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:ne.tunnel.status})}})}function gx(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 vx(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 xx(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 ca(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 Us(e){const s=e?.trim();return s||null}function _x(e){if(!e)return"";const s=[Us(e.lastLocalError),Us(e.lastRemoteError),Us(e.lastError)].filter(p=>p!==null),r=Us(e.lastProcessOutput),o=!!r&&(e.status==="error"||e.status==="exited"||!!Us(e.lastError));return r&&o&&s.push(r),s.join(`
|
|
85
|
-
`)}function da(){const{t:e}=ce(),{data:s}=hx(),r=fx(),o=px(),p=mx(),[m,v]=C.useState(!1),[i,n]=C.useState(null),l=C.useRef(null),[u,c]=C.useState({top:0,right:0}),[g,_]=C.useState(!1),[y,x]=C.useState(!1),a=s?.status!==void 0&&s.status!=="stopped",h=r.isPending||s?.status==="starting",d=p.isPending,f=s?.shareableUrl,b=s?.token,w=gx(s),k=vx(s),j=_x(s);C.useEffect(()=>{if(m&&l.current){const B=l.current.getBoundingClientRect();c({top:B.bottom+8,right:window.innerWidth-B.right})}},[m]);const S=C.useCallback(()=>{v(!0)},[a]),E=C.useCallback(()=>{r.mutate(void 0,{onSuccess:()=>v(!0)})},[r]),R=C.useCallback(()=>{f&&(navigator.clipboard.writeText(f),n("url"),setTimeout(()=>n(null),2e3))},[f]),L=C.useCallback(()=>{b&&(navigator.clipboard.writeText(b),n("token"),setTimeout(()=>n(null),2e3))},[b]),T=C.useCallback(()=>{o.mutate(),v(!1),_(!1),x(!1)},[o]),A=C.useCallback(()=>{p.mutate(void 0,{onSuccess:()=>{x(!1),v(!0)}})},[p]);return t.jsxs("div",{className:"relative",children:[t.jsx("button",{ref:l,onClick:S,disabled:h,className:`p-1.5 rounded-md transition-colors ${w.button}`,title:e(w.label),children:h?t.jsx(Ye,{size:16,className:"animate-spin"}):w.icon==="warn"?t.jsx(rr,{size:16}):t.jsx(no,{size:16})}),a&&!h&&t.jsx("span",{className:`absolute top-0.5 right-0.5 w-2 h-2 ${w.dot} rounded-full`}),m&&!a&&es.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(no,{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(ns,{size:14})})]}),t.jsxs("button",{onClick:E,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(Ye,{size:13,className:"animate-spin"}),e(h?"Starting tunnel...":"Enable phone access")]})]})]}),document.body),m&&a&&es.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 ${w.dot} rounded-full inline-block`}),e(k)]}),t.jsx("p",{className:"mt-1 text-xs text-neutral-500 leading-relaxed",children:e(xx(s))})]}),t.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(ns,{size:14})})]}),b&&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(bd,{size:12}),t.jsx("span",{children:e("Token protected")})]}),f&&t.jsx("div",{className:"flex justify-center py-3",children:t.jsx(Rc,{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:B=>B.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:i==="url"?t.jsx(qt,{size:14,className:"text-emerald-500"}):t.jsx(so,{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:ca(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:ca(s?.lastHealthyAt)})]})]}),j&&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:j}),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.")}),b&&t.jsxs("div",{className:"mt-2",children:[t.jsx("button",{onClick:()=>_(!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:b}),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:i==="token"?t.jsx(qt,{size:14,className:"text-emerald-500"}):t.jsx(so,{size:14})})]})]}),y&&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:()=>x(!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:A,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")})]})]}),!y&&t.jsxs("button",{onClick:()=>x(!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(ir,{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 Ii({isOpen:e,onClose:s}){const{t:r}=ce(),o=Cd(),[p,m]=C.useState(""),[v,i]=C.useState(""),[n,l]=C.useState(null),[u,c]=C.useState(!1),[g,_]=C.useState(!1),y=p.trim(),x=v.trim(),a=u||o.isPending,h=C.useMemo(()=>!!(y&&x&&!a),[y,x,a]),d=C.useCallback(()=>{m(""),i(""),l(null),_(!1)},[]),f=C.useCallback(()=>{a||(d(),s())},[a,s,d]);C.useEffect(()=>{e||d()},[e,d]);const b=C.useCallback(async S=>{try{await o.mutateAsync({name:y,repoPath:x,initEmptyRepo:S}),d(),s()}catch(E){const R=E instanceof Error?E.message:r("Failed to create project");l(R),ct.error(R)}},[o,s,d,r,y,x]),w=C.useCallback(async()=>{if(!(!y||!x||a)){l(null),c(!0);try{const S=await ge.get("/filesystem/validate",{params:{path:x}});if(!S.valid){l(S.error??r("Selected path is not a valid directory"));return}if(S.isGitRepo){await b(!1);return}if(S.reason==="no_git"&&S.isEmpty){_(!0);return}if(S.reason==="no_git"){await b(!1);return}await b(!1)}catch(S){l(S instanceof Error?S.message:r("Could not check project path"))}finally{c(!1)}}},[b,a,r,y,x]),k=C.useCallback(()=>{_(!1),b(!1)},[b]),j=C.useCallback(()=>{_(!1),b(!0)},[b]);return t.jsxs(t.Fragment,{children:[t.jsx(hs,{isOpen:e,onClose:f,title:r("Create New Project"),action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:f,disabled:a,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:w,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:S=>m(S.target.value),placeholder:r("e.g., Agent Tower"),disabled:a,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(kd,{value:v,onChange:i,validationMode:"directory"})]}),n&&t.jsx("p",{className:"text-xs text-red-500 leading-relaxed",children:n})]})}),t.jsx(hs,{isOpen:g,onClose:()=>{o.isPending||_(!1)},title:r("Initialize Git repository?"),action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>_(!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:j,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 ua({projects:e,filterProjectId:s,setFilterProjectId:r,onCreateProject:o,className:p}){const{t:m}=ce(),[v,i]=C.useState(!1),n=e.filter(u=>!u.archivedAt),l=s?e.find(u=>u.id===s)??null:null;return t.jsxs("div",{className:te("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:()=>i(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:[l?t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${l.color.replace("text-","bg-")}`}):t.jsx(As,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"truncate max-w-[200px] font-medium",children:l?l.name:m("All Projects")}),t.jsx(yt,{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:()=>i(!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),i(!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(As,{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(qt,{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:n.map(u=>{const c=s===u.id;return t.jsxs("button",{onClick:()=>{r(u.id),i(!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(qt,{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:()=>{i(!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(ts,{size:13}),t.jsx("span",{children:m("Create New Project...")})]})]})]}):null]})}function ha(){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 bx=260,yx=600,fa=400,Sx=100,kr=1e3;function wx(e,s){return e&&(e.data.findIndex(o=>o.id===s.id)>=0?{...e,data:e.data.map(o=>o.id===s.id?{...o,...s}:o)}:{...e,data:[s,...e.data],total:e.total+1})}function Cx(e,s){const r=s.find(o=>o?.id===e.projectId);return r?{...e,project:r}:e}function Jx(){const{t:e,locale:s}=ce(),[r,o]=C.useState(null),[p,m]=C.useState(null),[v,i]=C.useState(fa),[n,l]=C.useState(!1),[u,c]=C.useState("idle"),[g,_]=C.useState({}),y=C.useRef(!1),x=C.useRef(0),a=C.useRef(fa),h=C.useRef(null),d=ot(),{data:f,isLoading:b}=Ds(),{data:w,isLoading:k}=Ed({limit:Sx}),j=C.useMemo(()=>w?.data??[],[w?.data]),S=C.useMemo(()=>j.map(P0),[j]),E=p&&j.some(U=>U.id===p)?p:null,{data:R,isLoading:L}=hd(E??"",{limit:kr}),T=Td({queries:E?[]:j.map(U=>({queryKey:ne.tasks.list(U.id,{limit:kr}),queryFn:()=>ge.get(`/projects/${U.id}/tasks`,{params:{limit:String(kr)}})}))}),A=!E&&T.some(U=>U.isLoading),B=C.useMemo(()=>{if(E)return R?.data??[];const U=[];for(const Q of T)Q.data?.data&&U.push(...Q.data.data);return U},[E,R,T]),[D,z]=C.useState([]),H=C.useMemo(()=>{if(D.length===0)return B;const U=new Set(B.map(Q=>Q.id));return[...D.filter(Q=>!U.has(Q.id)),...B]},[B,D]),[M,O]=C.useState(null),P=C.useMemo(()=>r&&H.some(U=>U.id===r)?r:M&&r===M?M:null,[r,H,M]);C.useEffect(()=>{M&&H.some(U=>U.id===M)&&O(null)},[M,H]),C.useEffect(()=>{if(D.length===0)return;const U=new Set(B.map(Q=>Q.id));D.some(Q=>U.has(Q.id))&&z(Q=>Q.filter(se=>!U.has(se.id)))},[B,D]);const I=C.useMemo(()=>{const U=new Map;for(const Q of H){const se=Q.createdAt?new Date(Q.createdAt).getTime():0,de=U.get(Q.projectId)??0;se>de&&U.set(Q.projectId,se)}return[...j].sort((Q,se)=>{const de=U.get(Q.id)??(Q.createdAt?new Date(Q.createdAt).getTime():0);return(U.get(se.id)??(se.createdAt?new Date(se.createdAt).getTime():0))-de})},[j,H]),$=C.useMemo(()=>I.filter(U=>!U.archivedAt),[I]),Y=C.useMemo(()=>{if(!f)return[];const U=localStorage.getItem("providerUsageCount"),Q=U?JSON.parse(U):{};return[...f].sort((se,de)=>{const Ne=se.availability.type!=="NOT_FOUND",ve=de.availability.type!=="NOT_FOUND";if(Ne!==ve)return Ne?-1:1;const be=Q[se.provider.id]??0;return(Q[de.provider.id]??0)-be})},[f]),q=C.useMemo(()=>H.map(I0),[H]),V=C.useMemo(()=>new Set,[]),F=C.useMemo(()=>{if(!P)return null;const U=H.find(se=>se.id===P);if(!U)return null;const Q=j.find(se=>se.id===U.projectId);if(!Q){const se=fs(U.workspaces?.find(de=>de.status==="ACTIVE")??U.workspaces?.[0]);return{id:U.id,projectId:U.projectId,projectName:"Unknown",projectColor:"text-muted-foreground",title:U.title,status:Wn(U.status),branch:se,mainBranch:"main",description:U.description??"",isGitRepo:!1,projectArchivedAt:null,projectRepoDeletedAt:null}}return B0(U,Q)},[P,H,j]),N=_a(),W=fd(),X=md(),K=Fn(),ie=C.useCallback(U=>{z(Q=>Q.some(se=>se.id===U.id)?Q.map(se=>se.id===U.id?{...se,...U}:se):[U,...Q]),d.setQueryData(ne.tasks.list(U.projectId,{limit:kr}),Q=>wx(Q,U)),d.setQueryData(ne.tasks.detail(U.id),U),O(U.id),o(U.id)},[d]),Z=C.useCallback((U,Q,se)=>{const de=U.id,Ne=[U.title,U.description].filter(Boolean).join(`
|
|
86
|
-
|
|
87
|
-
`);_(ve=>({...ve,[de]:{status:"creating-workspace"}})),(async()=>{try{const ve=await ge.post(`/tasks/${de}/workspaces`,{workspaceKind:se});_(me=>({...me,[de]:{status:"creating-session"}}));const be=await ge.post(`/workspaces/${ve.id}/sessions`,{providerId:Q,prompt:Ne});_(me=>({...me,[de]:{status:"starting-session"}})),await K.mutateAsync(be.id),await d.invalidateQueries({queryKey:ne.workspaces.list(de)}),await d.invalidateQueries({queryKey:ne.tasks.all}),_(me=>{const{[de]:Me,...Se}=me;return Se})}catch(ve){const be=ve instanceof Error?ve.message:e("启动 Agent 失败");_(me=>({...me,[de]:{status:"failed",error:be}})),ct.error(e("任务已创建,但启动 Agent 失败,可在详情中重试")),d.invalidateQueries({queryKey:ne.workspaces.list(de)}),d.invalidateQueries({queryKey:ne.tasks.all})}})()},[d,K,e]),re=C.useCallback(U=>{_(Q=>{const{[U]:se,...de}=Q;return de}),d.invalidateQueries({queryKey:ne.workspaces.list(U)}),d.invalidateQueries({queryKey:ne.tasks.all})},[d]),he=C.useCallback(U=>{W.mutate(U,{onSuccess:()=>{P===U&&o(null),_(Q=>{const{[U]:se,...de}=Q;return de}),z(Q=>Q.filter(se=>se.id!==U)),d.invalidateQueries({queryKey:ne.tasks.all})},onError:()=>{ct.error(e("删除任务失败"))}})},[W,P,d,e]),fe=C.useCallback((U,Q)=>{X.mutate({id:U,status:D0(Q)},{onError:()=>{ct.error(e("状态变更失败,该操作不被允许"))}})},[X,e]),Be=C.useCallback(U=>{U.preventDefault(),y.current=!0,x.current=U.clientX,a.current=v,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[v]);C.useEffect(()=>{const U=se=>{if(!y.current)return;const de=se.clientX-x.current,Ne=Math.max(bx,Math.min(yx,a.current+de));i(Ne)},Q=()=>{y.current&&(y.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",U),document.addEventListener("mouseup",Q),()=>{document.removeEventListener("mousemove",U),document.removeEventListener("mouseup",Q)}},[]);const le=C.useCallback(()=>{l(!0)},[]),Ge=C.useCallback(()=>{if($.length===0){ct.error(e("没有可用项目,请先创建或恢复项目"));return}o(null)},[$,e]),we=C.useCallback(()=>{l(!1)},[]),qe=C.useCallback(async U=>{const{title:Q,description:se,projectId:de,providerId:Ne,mode:ve,workspaceMode:be,teamRunMode:me,teamTemplateId:Me,memberPresetIds:Se,attachmentLinks:Pe}=U,He=[se,Pe].filter(Boolean).join(`
|
|
88
|
-
|
|
89
|
-
`),Je=$.find(et=>et.id===de)?.isGitRepo!==!1,xe=Je?ve:"SOLO",ht=Je?be:jt.MAIN_DIRECTORY;let Qe=null;try{c("creating-task");const et=await ge.post(`/projects/${de}/tasks`,{title:Q,description:He||void 0});if(Qe=Cx(et,$),localStorage.setItem("lastSelectedProjectId",de),xe==="SOLO"&&Ne){localStorage.setItem("lastSelectedProviderId",Ne);const mt=localStorage.getItem("providerUsageCount"),gt=mt?JSON.parse(mt):{};gt[Ne]=(gt[Ne]??0)+1,localStorage.setItem("providerUsageCount",JSON.stringify(gt))}xe==="TEAM"?(c("creating-teamrun"),await N.mutateAsync({taskId:Qe.id,mode:me,...Me?{teamTemplateId:Me}:{},...Se.length>0?{memberPresetIds:Se}:{}})):Ne&&Z(Qe,Ne,ht),E&&de!==E&&m(null),ie(Qe),c("idle"),d.invalidateQueries({queryKey:ne.tasks.all}),d.invalidateQueries({queryKey:ne.projects.all})}catch(et){if(c("idle"),Qe&&xe==="TEAM"){try{await W.mutateAsync(Qe.id)}catch{}throw ct.error(e("TeamRun 创建失败,请检查团队配置后重试")),et}else if(Qe)E&&de!==E&&m(null),ie(Qe),d.invalidateQueries({queryKey:ne.tasks.all}),d.invalidateQueries({queryKey:ne.projects.all});else throw ct.error(et instanceof Error?et.message:e("Failed to create task")),et}},[$,N,Z,W,d,e,E,ie]),Fe=k||L||A,De=C.useMemo(()=>$.map(U=>({id:U.id,name:U.name,color:S.find(Q=>Q.id===U.id)?.color,isGitRepo:U.isGitRepo})),[$,S]),ze=C.useMemo(()=>Y.map(({provider:U,availability:Q})=>({id:U.id,name:U.name,agentType:U.agentType,available:Q.type!=="NOT_FOUND"})),[Y]),Ae=C.useMemo(()=>{if(E&&$.find(Q=>Q.id===E))return E;const U=localStorage.getItem("lastSelectedProjectId");return U&&$.find(Q=>Q.id===U)?U:$[0]?.id??""},[$,E]),[Ke,Ee]=C.useState(Ae);C.useEffect(()=>{Ee(Ae)},[Ae]);const Ce=C.useMemo(()=>$.find(U=>U.id===Ke)?.name??$.find(U=>U.id===Ae)?.name??e("Project"),[$,Ke,Ae,e]),ke=s==="zh-CN"?`你需要在 ${Ce} 中做点什么?`:`What do you need to do in ${Ce}?`,st=C.useMemo(()=>{const U=localStorage.getItem("lastSelectedProviderId");return U&&Y.find(se=>se.provider.id===U&&se.availability.type!=="NOT_FOUND")?U:Y.find(se=>se.availability.type!=="NOT_FOUND")?.provider.id??""},[Y]),je=al(),[We,ue]=C.useState(!1),{usesIntegratedTitlebar:dt}=ma(),wt=C.useCallback(()=>{if($.length===0){ct.error(e("没有可用项目,请先创建或恢复项目"));return}ue(!0)},[$,e]),G=C.useCallback(async U=>{await qe(U),ue(!1)},[qe]);return je?We?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:()=>ue(!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(Jn,{projects:De,providers:ze,isProvidersLoading:b,onSubmit:G,defaultProjectId:Ae,defaultProviderId:st,onProjectChange:Ee,createStep:u})]})]}):P&&F?t.jsxs(t.Fragment,{children:[t.jsx(sx,{task:F,onBack:()=>o(null),onDeleteTask:F.projectArchivedAt?void 0:he,isDeleting:W.isPending,autoStartState:g[F.id]??null,onAutoStartRecovered:re}),t.jsx(Ii,{isOpen:n,onClose:we})]}):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(eo,{}),t.jsx(to,{}),t.jsx(ua,{projects:S,filterProjectId:E,setFilterProjectId:m,onCreateProject:le})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(da,{}),t.jsx("button",{onClick:()=>Qn.getState().openSettings(),className:"p-1.5 text-muted-foreground/70 active:text-foreground rounded-md",children:t.jsx(Gn,{size:16})})]})]}),Fe&&q.length===0?t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(ha,{})}):t.jsx(_o,{tasks:q,projects:S,selectedTaskId:null,onSelectTask:o,filterProjectId:E,setFilterProjectId:m,width:"100%",onCreateTask:wt,onCreateProject:le,activeTaskIds:V,onTaskStatusChange:fe})]}),t.jsx(Ii,{isOpen:n,onClose:we})]}):t.jsxs("div",{ref:h,className:"flex flex-col h-screen bg-sidebar overflow-hidden text-sm",children:[t.jsxs("header",{className:te("h-12 bg-sidebar flex items-center px-4 justify-between flex-shrink-0 z-20 relative",dt&&"app-region-drag"),children:[t.jsxs("div",{className:te("flex items-center gap-2 min-w-0",dt&&"pl-[72px]"),children:[t.jsx(eo,{}),t.jsx(to,{}),t.jsx(ua,{projects:S,filterProjectId:E,setFilterProjectId:m,onCreateProject:le,className:dt?"app-region-no-drag":void 0})]}),t.jsxs("div",{className:te("flex items-center gap-1",dt&&"app-region-no-drag"),children:[t.jsx("div",{className:dt?"app-region-no-drag":void 0,children:t.jsx(da,{})}),t.jsx("button",{onClick:()=>Qn.getState().openSettings(),className:te("p-1.5 text-muted-foreground/70 hover:text-foreground hover:bg-accent rounded-md transition-colors",dt&&"app-region-no-drag"),children:t.jsx(Gn,{size:16})})]})]}),t.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[Fe&&q.length===0?t.jsx("div",{className:"h-full overflow-hidden flex-shrink-0",style:{width:v},children:t.jsx(ha,{})}):t.jsx(_o,{tasks:q,projects:S,selectedTaskId:P,onSelectTask:o,filterProjectId:E,setFilterProjectId:m,width:v,onCreateTask:Ge,onCreateProject:le,isCreateActive:!P,activeTaskIds:V,onTaskStatusChange:fe,onDeleteTask:he}),t.jsx("div",{onMouseDown:Be,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:P&&F?t.jsx(T0,{task:F,onDeleteTask:F.projectArchivedAt?void 0:he,isDeleting:W.isPending,onTaskStatusChange:F.projectArchivedAt?void 0:fe,autoStartState:g[F.id]??null,onAutoStartRecovered:re}):P&&!F?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(Jn,{projects:De,providers:ze,isProvidersLoading:b,onSubmit:qe,defaultProjectId:Ae,defaultProviderId:st,onProjectChange:Ee,createStep:u})]})})})]}),t.jsx(Ii,{isOpen:n,onClose:we})]})}export{Jx as ProjectKanbanPage};
|