agent-tower 0.5.3-beta.7 → 0.5.3-beta.9
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/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 +9 -11
- package/dist/executors/__tests__/base.executor.test.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/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__/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/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/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/utils/process-launch.d.ts.map +1 -1
- package/dist/utils/process-launch.js +7 -1
- package/dist/utils/process-launch.js.map +1 -1
- package/dist/utils/process-launch.test.js +21 -3
- package/dist/utils/process-launch.test.js.map +1 -1
- package/dist/web/assets/{AgentDemoPage-C3_t3lf0.js → AgentDemoPage-DMLw4xpg.js} +1 -1
- package/dist/web/assets/AgentEnvironmentSettingsPage-NgRdouLu.js +1 -0
- package/dist/web/assets/AgentLogo-ThhvSi7G.js +1 -0
- package/dist/web/assets/{ConversationPage-D3BaVRNK.js → ConversationPage-B1ZcyF_h.js} +2 -2
- package/dist/web/assets/CreateTaskInput-Cb3aRHr3.js +1 -0
- package/dist/web/assets/{DemoPage-BGdrlCk3.js → DemoPage-CN2OBKzu.js} +3 -3
- package/dist/web/assets/{GeneralSettingsPage-DRP9x8ha.js → GeneralSettingsPage-CE7P3t_v.js} +1 -1
- package/dist/web/assets/{Icons-U8HyAFg8.js → Icons-DIZBOtuC.js} +1 -1
- package/dist/web/assets/{LoadingPreviewPage-BR3n6lWz.js → LoadingPreviewPage-CRBcypeY.js} +1 -1
- package/dist/web/assets/McpSettingsPage-gp1XDMUd.js +1 -0
- package/dist/web/assets/{MemberAvatar-BjHhs0Hs.js → MemberAvatar-Y_pJlw-N.js} +1 -1
- package/dist/web/assets/NotificationSettingsPage-BhZeHEef.js +1 -0
- package/dist/web/assets/{ProfileSettingsPage-CvVvZlDS.js → ProfileSettingsPage-D_y3ePFs.js} +1 -1
- package/dist/web/assets/{ProjectKanbanPage-DpWuiq4x.js → ProjectKanbanPage-CBfocvKp.js} +30 -30
- package/dist/web/assets/ProjectSettingsPage-V38j8T61.js +2 -0
- package/dist/web/assets/{ProviderSettingsPage-CXq-sGzZ.js → ProviderSettingsPage-D-1Fyh5B.js} +13 -13
- package/dist/web/assets/{SettingsMasterDetail-BOKbstXF.js → SettingsMasterDetail-CZfVaFo2.js} +1 -1
- package/dist/web/assets/TeamSettingsPage-DysTmOGE.js +1 -0
- package/dist/web/assets/{arc-D4qG1SmX.js → arc-CgLBAHTH.js} +1 -1
- package/dist/web/assets/architectureDiagram-3BPJPVTR-CP9eQfdk.js +36 -0
- package/dist/web/assets/{arrow-left-DKU68PPE.js → arrow-left-y1LwO7sB.js} +1 -1
- package/dist/web/assets/{blockDiagram-GPEHLZMM-CHBz_0R-.js → blockDiagram-GPEHLZMM-BURZnUwn.js} +1 -1
- package/dist/web/assets/{c4Diagram-AAUBKEIU-spmGspVf.js → c4Diagram-AAUBKEIU-Dzgp3z3S.js} +1 -1
- package/dist/web/assets/channel-CWEYGfCJ.js +1 -0
- package/dist/web/assets/check-D2WWIhwV.js +1 -0
- package/dist/web/assets/{chevron-down-Bqq-PI_B.js → chevron-down--B7iZqBL.js} +1 -1
- package/dist/web/assets/chevron-right-7PShDIwg.js +1 -0
- package/dist/web/assets/{chevron-up-Rnt9gnA4.js → chevron-up-3n_vHdrD.js} +1 -1
- package/dist/web/assets/{chunk-2J33WTMH-BoBYuHA8.js → chunk-2J33WTMH-CIpasa01.js} +1 -1
- package/dist/web/assets/{chunk-4BX2VUAB-Bmb_y0KF.js → chunk-4BX2VUAB-DeSe2m1y.js} +1 -1
- package/dist/web/assets/{chunk-55IACEB6-B_KS5xlb.js → chunk-55IACEB6-BkJ6ogdn.js} +1 -1
- package/dist/web/assets/{chunk-727SXJPM-DI9KppWM.js → chunk-727SXJPM-Bkbv-knP.js} +1 -1
- package/dist/web/assets/{chunk-AQP2D5EJ-C3F0DJdJ.js → chunk-AQP2D5EJ-BG9wGFIo.js} +1 -1
- package/dist/web/assets/{chunk-FMBD7UC4-C6-Jfc2f.js → chunk-FMBD7UC4-Cvl_2za9.js} +1 -1
- package/dist/web/assets/{chunk-ND2GUHAM-Crt5iCMS.js → chunk-ND2GUHAM-B_zdzkWX.js} +1 -1
- package/dist/web/assets/{chunk-QZHKN3VN-CSYfO5_E.js → chunk-QZHKN3VN-Ch6dvKNw.js} +1 -1
- package/dist/web/assets/{circle-alert-BA6H1Efg.js → circle-alert-W13JkYj3.js} +1 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-CcU8zfK8.js +1 -0
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-CcU8zfK8.js +1 -0
- package/dist/web/assets/{code-block-OCS4YCEC-BNCfYHwe.js → code-block-OCS4YCEC-CYhJ9OPu.js} +1 -1
- package/dist/web/assets/confirm-dialog-BAqfLDT8.js +1 -0
- package/dist/web/assets/copy-bJ2sut_L.js +1 -0
- package/dist/web/assets/cose-bilkent-S5V4N54A-DWlnxyfH.js +1 -0
- package/dist/web/assets/{dagre-BM42HDAG-a0_McFXq.js → dagre-BM42HDAG-Bt3QI02a.js} +1 -1
- package/dist/web/assets/{diagram-2AECGRRQ-Dc-ZrrCl.js → diagram-2AECGRRQ-EaJBYSnS.js} +1 -1
- package/dist/web/assets/{diagram-5GNKFQAL-CVTae_wQ.js → diagram-5GNKFQAL-BGyRb-_h.js} +1 -1
- package/dist/web/assets/{diagram-KO2AKTUF-DkfB2YqP.js → diagram-KO2AKTUF-CZhDTMfm.js} +1 -1
- package/dist/web/assets/{diagram-LMA3HP47-k45WlYTa.js → diagram-LMA3HP47-Be8BAxmL.js} +1 -1
- package/dist/web/assets/{diagram-OG6HWLK6-D6oP9231.js → diagram-OG6HWLK6-DEdQ7Cml.js} +1 -1
- package/dist/web/assets/{erDiagram-TEJ5UH35-DCsStITe.js → erDiagram-TEJ5UH35-CG9SNlbz.js} +1 -1
- package/dist/web/assets/{flowDiagram-I6XJVG4X-BpnMpo54.js → flowDiagram-I6XJVG4X-BUpx5PVX.js} +1 -1
- package/dist/web/assets/folder-picker-DFB9_pv4.js +1 -0
- package/dist/web/assets/{folder-aqzIYw0B.js → folder-u7fKAtz_.js} +1 -1
- package/dist/web/assets/ganttDiagram-6RSMTGT7-D7vRxMpE.js +292 -0
- package/dist/web/assets/{gitGraphDiagram-PVQCEYII-AlRFGn3n.js → gitGraphDiagram-PVQCEYII-3lhH-RcD.js} +1 -1
- package/dist/web/assets/index-7nw4fV42.js +122 -0
- package/dist/web/assets/{index-BvCxcy2E.js → index-CGMjRoF7.js} +4 -4
- package/dist/web/assets/index-YCjjSSLC.css +1 -0
- package/dist/web/assets/{infoDiagram-5YYISTIA-DYmUMa5y.js → infoDiagram-5YYISTIA-C5SNbJpO.js} +1 -1
- package/dist/web/assets/{input-BOQDrqKN.js → input-CKwRYuUJ.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-BbR4k44d.js → ishikawaDiagram-YF4QCWOH-Ca7tX9_0.js} +1 -1
- package/dist/web/assets/{journeyDiagram-JHISSGLW-B3BgsbGr.js → journeyDiagram-JHISSGLW-B2oo6nxY.js} +1 -1
- package/dist/web/assets/{kanban-definition-UN3LZRKU-CAw6dg5S.js → kanban-definition-UN3LZRKU-D1CzIzX9.js} +1 -1
- package/dist/web/assets/{layers-CHCOcaOD.js → layers-BbLzQqyy.js} +1 -1
- package/dist/web/assets/{linear-DuhwDM_T.js → linear-BWowtcGw.js} +1 -1
- package/dist/web/assets/mermaid-NOHMQCX5-B42ziicV.js +123 -0
- package/dist/web/assets/{message-square-8nr39Elw.js → message-square-Bd_m34OX.js} +1 -1
- package/dist/web/assets/{mindmap-definition-RKZ34NQL-Dn4_OJVF.js → mindmap-definition-RKZ34NQL-CYbO6QCk.js} +1 -1
- package/dist/web/assets/modal-CxOKWOjZ.js +1 -0
- package/dist/web/assets/{pencil-CHhoqtja.js → pencil-h5kxwbcu.js} +1 -1
- package/dist/web/assets/{pieDiagram-4H26LBE5-BazLj2iZ.js → pieDiagram-4H26LBE5-DXQghKRy.js} +1 -1
- package/dist/web/assets/{quadrantDiagram-W4KKPZXB-By8b3yLK.js → quadrantDiagram-W4KKPZXB-C6lAMMQB.js} +1 -1
- package/dist/web/assets/{requirementDiagram-4Y6WPE33-Y8tQe-HW.js → requirementDiagram-4Y6WPE33-Di9Le7Wy.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-5OEKKPKP-CsWPn5i_.js → sankeyDiagram-5OEKKPKP-BGpnptvR.js} +1 -1
- package/dist/web/assets/{select-BAGWw5mB.js → select-DFuN9DX8.js} +1 -1
- package/dist/web/assets/{sequenceDiagram-3UESZ5HK-CRYTLL5B.js → sequenceDiagram-3UESZ5HK-DjfkfaQL.js} +1 -1
- package/dist/web/assets/{stateDiagram-AJRCARHV-CRAWuvD-.js → stateDiagram-AJRCARHV-DsELotm9.js} +1 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-CudtEyHd.js +1 -0
- package/dist/web/assets/switch-gL7lBFj6.js +1 -0
- package/dist/web/assets/{textarea-Bwf5qeVw.js → textarea-Lr4GZaYW.js} +1 -1
- package/dist/web/assets/{timeline-definition-PNZ67QCA-CNyG_LiR.js → timeline-definition-PNZ67QCA-Cq1BWC0T.js} +1 -1
- package/dist/web/assets/{trash-2-CAJaQyy-.js → trash-2-B7GFt5Wl.js} +1 -1
- package/dist/web/assets/upload-L8hpDFoO.js +1 -0
- package/dist/web/assets/{use-profiles-CXwrOP0r.js → use-profiles-zIsoigD8.js} +1 -1
- package/dist/web/assets/{use-providers-cM1M1P2G.js → use-providers-erJ2iHLz.js} +1 -1
- package/dist/web/assets/useNormalizedLogs-CXAn7xj_.js +1 -0
- package/dist/web/assets/{vennDiagram-CIIHVFJN-Ccs0W2eH.js → vennDiagram-CIIHVFJN-DdOfNtRo.js} +1 -1
- package/dist/web/assets/{wardley-L42UT6IY-DZ98ClK4.js → wardley-L42UT6IY-BeKcEIgK.js} +1 -1
- package/dist/web/assets/{wardleyDiagram-YWT4CUSO-CFZaMuWx.js → wardleyDiagram-YWT4CUSO-DPKOxABd.js} +1 -1
- package/dist/web/assets/{xychartDiagram-2RQKCTM6-DupmVBai.js → xychartDiagram-2RQKCTM6-olIy_aaY.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 +3 -4
- package/node_modules/@prisma/client/.prisma/client/index.js +3 -4
- package/package.json +1 -1
- package/dist/web/assets/AgentLogo-BiGSdOLM.js +0 -1
- package/dist/web/assets/CreateTaskInput-C6ZA8Cnu.js +0 -2
- package/dist/web/assets/McpSettingsPage-BQ4HNeR-.js +0 -1
- package/dist/web/assets/NotificationSettingsPage-nAYf_v-C.js +0 -1
- package/dist/web/assets/ProjectSettingsPage-B1V5vUQk.js +0 -2
- package/dist/web/assets/TeamSettingsPage-DFx7ZKTf.js +0 -1
- package/dist/web/assets/architectureDiagram-3BPJPVTR-C1KQ-nPu.js +0 -36
- package/dist/web/assets/channel-BzXNFc3j.js +0 -1
- package/dist/web/assets/check-ugjfD3Li.js +0 -1
- package/dist/web/assets/chevron-right-K0xCrJxO.js +0 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-DWVhCasm.js +0 -1
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-DWVhCasm.js +0 -1
- package/dist/web/assets/confirm-dialog-xFGalfma.js +0 -1
- package/dist/web/assets/cose-bilkent-S5V4N54A-CsfM-xa6.js +0 -1
- package/dist/web/assets/folder-picker-CFznZBP-.js +0 -1
- package/dist/web/assets/ganttDiagram-6RSMTGT7-CzoF4UuV.js +0 -292
- package/dist/web/assets/index-BMsh00ht.js +0 -120
- package/dist/web/assets/index-CMlcurFO.css +0 -1
- package/dist/web/assets/loader-circle-ZTtR7VFf.js +0 -1
- package/dist/web/assets/mermaid-NOHMQCX5-BfcG134x.js +0 -122
- package/dist/web/assets/modal-Ct5Hq4HV.js +0 -1
- package/dist/web/assets/rotate-ccw-DacB7Wa2.js +0 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-DLPzRpsU.js +0 -1
- package/dist/web/assets/switch-DEDPfm5p.js +0 -1
- package/dist/web/assets/terminal-D9ZyN65O.js +0 -1
- package/dist/web/assets/upload-CvRhSiH5.js +0 -1
- package/dist/web/assets/useNormalizedLogs-Bpa12fkI.js +0 -1
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
import{a3 as tn,a4 as Xn,a5 as Wc,a6 as $c,a7 as Uc,a8 as Bi,a9 as qc,aa as Kc,k as at,ab as Xc,ac as Yc,r as C,ad as Vc,ae as Gc,af as Qc,ag as Zc,ah as Yn,ai as Vn,aj as Jc,ak as ed,al as td,h as Oe,am as ce,H as ts,i as Tt,l as St,m as xe,q as oe,u as ue,j as t,Z as gt,M as ma,N as sd,g as ee,B as Me,an as pa,ao as ga,ap as va,a2 as us,X as os,aq as rd,ar as id,s as nd,as as od,at as ad,au as ld,t as ht,I as Jt,J as dt,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-BMsh00ht.js";import{S as rt,Q as nn,h as pd,i as on,W as Dt,j as Rt,C as Gs,A as Ft,b as Nr,T as Bt}from"./mermaid-NOHMQCX5-BfcG134x.js";import{C as an}from"./confirm-dialog-xFGalfma.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-U8HyAFg8.js";import{C as yt}from"./chevron-down-Bqq-PI_B.js";import{C as Mt}from"./chevron-right-K0xCrJxO.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,h as _d,i as bd,T as fn,j as yd,a as Ta,P as Da,k as Sd,C as Jn,B as eo,e as to}from"./CreateTaskInput-C6ZA8Cnu.js";import{a as wd,F as Cd,f as kd,g as Ed,e as jd,u as Nd}from"./folder-picker-CFznZBP-.js";import{M as qr}from"./message-square-8nr39Elw.js";import{L as As}from"./layers-CHCOcaOD.js";import{S as Ms,P as mn,u as La,a as Pa,T as Rr}from"./useNormalizedLogs-Bpa12fkI.js";import{u as Ds}from"./use-providers-cM1M1P2G.js";import{A as Kr}from"./AgentLogo-BiGSdOLM.js";import{M as zt}from"./MemberAvatar-BjHhs0Hs.js";import{C as Oa}from"./chevron-up-Rnt9gnA4.js";import{C as Kt}from"./check-ugjfD3Li.js";import{M as hs,T as rr}from"./modal-Ct5Hq4HV.js";import{S as es}from"./select-BAGWw5mB.js";import{P as ss,T as pn}from"./trash-2-CAJaQyy-.js";import{T as Ar,C as so}from"./terminal-D9ZyN65O.js";import{F as Ia}from"./folder-aqzIYw0B.js";import{L as Ve}from"./loader-circle-ZTtR7VFf.js";import{U as Mr,C as Rd}from"./upload-CvRhSiH5.js";import{A as Zs}from"./arrow-left-DKU68PPE.js";import{R as Ad}from"./rotate-ccw-DacB7Wa2.js";import"./circle-alert-BA6H1Efg.js";var Md=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:Wc(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 Td(e,s,r){const o=e.slice(0);return o[s]=r,o}var Dd=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=Td(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 Ld({queries:e,...s},r){const o=at(),p=Xc(),m=Yc(),v=C.useMemo(()=>e.map(_=>{const a=o.defaultQueryOptions(_);return a._optimisticResults=p?"isRestoring":"optimistic",a}),[e,o,p]);v.forEach(_=>{Vc(_);const a=o.getQueryCache().get(_.queryHash);Gc(_,m,a)}),Qc(m);const[i]=C.useState(()=>new Dd(o,v,s)),[n,l,u]=i.getOptimisticResult(v,s.combine),c=!p&&s.subscribed!==!1;C.useSyncExternalStore(C.useCallback(_=>c?i.subscribe(Bi.batchCalls(_)):Zc,[i,c]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),C.useEffect(()=>{i.setQueries(v,s)},[v,s,i]);const x=n.some((_,a)=>Yn(v[a],_))?n.flatMap((_,a)=>{const h=v[a];if(h){const d=new tn(o,h);if(Yn(h,_))return Vn(h,d,m);Jc(_,p)&&Vn(h,d,m)}return[]}):[];if(x.length>0)throw Promise.all(x);const y=n.find((_,a)=>{const h=v[a];return h&&ed({result:_,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,Md)}const Pd=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Od=Oe("arrow-right",Pd);const Id=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ba=Oe("ban",Id);const Bd=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Fd=Oe("chevron-left",Bd);const zd=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Es=Oe("clock-3",zd);const Hd=[["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=Oe("code-xml",Hd);const Wd=[["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=Oe("copy-plus",Wd);const $d=[["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=Oe("ellipsis-vertical",$d);const Ud=[["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=Oe("external-link",Ud);const qd=[["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"}]],Kd=Oe("file-braces-corner",qd);const Xd=[["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=Oe("file-code-corner",Xd);const Yd=[["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"}]],Vd=Oe("file-exclamation-point",Yd);const Gd=[["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"}]],Yr=Oe("folder-open",Gd);const Qd=[["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=Oe("git-graph",Qd);const Zd=[["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=Oe("history",Zd);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=Oe("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=Oe("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=Oe("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=Oe("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=Oe("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=Oe("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=Oe("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"}]],qt=Oe("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=Oe("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=Oe("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=Oe("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=Oe("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=Oe("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=Oe("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=Oe("zoom-out",yu),Vr=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 Ha(e){return e instanceof bt(e).SVGElement}function Os(e){return e?Ps(e)?e.document:xn(e)?_n(e)?e:nr(e)||Ha(e)?e.ownerDocument:document:document:document}const Xt=Vr?C.useLayoutEffect:C.useEffect;function Gr(e){const s=C.useRef(e);return Xt(()=>{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 Xt(()=>{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 Wa(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=Wa(1),Pr=Wa(-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 ce.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 ce.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:`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CGMjRoF7.js","assets/index-7nw4fV42.js","assets/index-YCjjSSLC.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{ae as sn,af as Yn,ag as Uc,ah as qc,ai as Kc,aj as Fi,ak as Xc,al as Yc,k as at,am as Vc,an as Gc,r as C,ao as Qc,ap as Zc,aq as Jc,ar as ed,as as Vn,at as Gn,au as td,av as sd,aw as rd,g as Ue,ax as ce,w as ts,i as Tt,l as St,m as xe,q as oe,u as ue,j as t,a5 as gt,O as ga,P as id,h as ee,U as As,B as Me,ay as va,az as xa,aA as _a,ac as us,X as os,aB as rn,J as rr,aC as nd,aD as od,x as ad,aE as ld,aF as cd,aG as dd,T as ir,t as ht,K as Jt,M as dt,N as ks,a1 as Rr,aH as nr,$ as Ve,aI as ba,ad as ud,a9 as hd,aJ as nn,aa as fd,aK as ya,aL as on,aM as Sa,aN as wa,aO as Ca,aP as md,aQ as pd,Y as gd,aR as vd,aS as xd,aT as _d,Q as Qn,a4 as Zn}from"./index-7nw4fV42.js";import{S as rt,u as an,A as ln,j as bd,F as ka,Q as cn,k as yd,l as dn,W as Dt,m as Rt,o as Ea,C as Gs,i as Ft,b as Ar,T as Bt}from"./mermaid-NOHMQCX5-B42ziicV.js";import{C as un}from"./confirm-dialog-BAqfLDT8.js";import{c as ja,a as Na,b as Ra,I as Aa,d as Ma,A as Jn,G as Ta}from"./Icons-DIZBOtuC.js";import{C as yt}from"./chevron-down--B7iZqBL.js";import{C as Mt}from"./chevron-right-7PShDIwg.js";import{d as hn,S as Sd,u as fn,A as Qs,b as mn,G as Da,Z as wd,e as Cd,T as pn,f as kd,a as La,P as Pa,g as Ed,C as eo,B as to,c as so}from"./CreateTaskInput-Cb3aRHr3.js";import{a as jd,F as Nd,f as Rd,g as Ad,e as Md,u as Td}from"./folder-picker-DFB9_pv4.js";import{M as Kr}from"./message-square-Bd_m34OX.js";import{L as Ms}from"./layers-BbLzQqyy.js";import{P as gn,u as Oa,a as Ia,T as Mr}from"./useNormalizedLogs-CXAn7xj_.js";import{u as Ds}from"./use-providers-erJ2iHLz.js";import{A as Xr}from"./AgentLogo-ThhvSi7G.js";import{M as zt}from"./MemberAvatar-Y_pJlw-N.js";import{C as Ba}from"./chevron-up-3n_vHdrD.js";import{C as Kt}from"./check-D2WWIhwV.js";import{M as hs}from"./modal-CxOKWOjZ.js";import{S as es}from"./select-DFuN9DX8.js";import{P as ss,T as vn}from"./trash-2-B7GFt5Wl.js";import{F as Fa}from"./folder-u7fKAtz_.js";import{U as Tr}from"./upload-L8hpDFoO.js";import{A as Zs}from"./arrow-left-y1LwO7sB.js";import{C as ro}from"./copy-bJ2sut_L.js";import"./circle-alert-W13JkYj3.js";var Dd=class extends sn{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:Yn()})}getOptimisticResult(e){return e.behavior=Yn(),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:qc(s,r.data),hasPreviousPage:Uc(s,r.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:c,isFetchingPreviousPage:g,isRefetchError:i&&!l&&!c,isRefetching:m&&!u&&!g}}};function io(e,s){const r=new Set(s);return e.filter(o=>!r.has(o))}function Ld(e,s,r){const o=e.slice(0);return o[s]=r,o}var Pd=class extends Kc{#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,Fi.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||!Xc(u,g)});!n&&!l||(n&&(this.#c=o,this.#t=p),this.#e=m,this.hasListeners()&&(n&&(io(r,p).forEach(u=>{u.destroy()}),io(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=Yc(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 sn(this.#r,p);r.push({defaultedQueryOptions:p,observer:v})}),r}#f(e,s){const r=this.#t.indexOf(e);r!==-1&&(this.#e=Ld(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&&Fi.batch(()=>{this.listeners.forEach(o=>{o(this.#e)})})}}};function Od({queries:e,...s},r){const o=at(),p=Vc(),m=Gc(),v=C.useMemo(()=>e.map(_=>{const a=o.defaultQueryOptions(_);return a._optimisticResults=p?"isRestoring":"optimistic",a}),[e,o,p]);v.forEach(_=>{Qc(_);const a=o.getQueryCache().get(_.queryHash);Zc(_,m,a)}),Jc(m);const[i]=C.useState(()=>new Pd(o,v,s)),[n,l,u]=i.getOptimisticResult(v,s.combine),c=!p&&s.subscribed!==!1;C.useSyncExternalStore(C.useCallback(_=>c?i.subscribe(Fi.batchCalls(_)):ed,[i,c]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),C.useEffect(()=>{i.setQueries(v,s)},[v,s,i]);const x=n.some((_,a)=>Vn(v[a],_))?n.flatMap((_,a)=>{const h=v[a];if(h){const d=new sn(o,h);if(Vn(h,_))return Gn(h,d,m);td(_,p)&&Gn(h,d,m)}return[]}):[];if(x.length>0)throw Promise.all(x);const y=n.find((_,a)=>{const h=v[a];return h&&sd({result:_,errorResetBoundary:m,throwOnError:h.throwOnError,query:o.getQueryCache().get(h.queryHash),suspense:h.suspense})});if(y?.error)throw y.error;return l(u())}function xn(e,s){return rd(e,Dd)}const Id=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Bd=Ue("arrow-right",Id);const Fd=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],za=Ue("ban",Fd);const zd=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Wd=Ue("chevron-left",zd);const Hd=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Es=Ue("clock-3",Hd);const $d=[["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"}]],Yr=Ue("code-xml",$d);const Ud=[["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"}]],no=Ue("copy-plus",Ud);const qd=[["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"}]],Wa=Ue("ellipsis-vertical",qd);const Kd=[["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"}]],Xd=Ue("file-braces-corner",Kd);const Yd=[["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"}]],Dr=Ue("file-code-corner",Yd);const Vd=[["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"}]],Gd=Ue("file-exclamation-point",Vd);const Qd=[["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=Ue("folder-open",Qd);const Zd=[["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=Ue("git-graph",Zd);const Jd=[["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=Ue("history",Jd);const eu=[["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"}]],tu=Ue("lock-keyhole",eu);const su=[["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"}]],ru=Ue("maximize",su);const iu=[["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"}]],nu=Ue("panel-left-close",iu);const ou=[["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"}]],au=Ue("panel-left-open",ou);const lu=[["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"}]],cu=Ue("panel-right-close",lu);const du=[["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"}]],zi=Ue("panel-right-open",du);const uu=[["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"}]],hu=Ue("pen-line",uu);const fu=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],qt=Ue("play",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=Ue("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"}]],Ha=Ue("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"}]],oo=Ue("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"}]],_r=Ue("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=Ue("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=Ue("zoom-out",yu),Gr=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 _n(e){return"nodeType"in e}function bt(e){var s,r;return e?Ps(e)?e:_n(e)&&(s=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function bn(e){const{Document:s}=bt(e);return e instanceof s}function or(e){return Ps(e)?!1:e instanceof bt(e).HTMLElement}function $a(e){return e instanceof bt(e).SVGElement}function Os(e){return e?Ps(e)?e.document:_n(e)?bn(e)?e:or(e)||$a(e)?e.ownerDocument:document:document:document}const Xt=Gr?C.useLayoutEffect:C.useEffect;function Qr(e){const s=C.useRef(e);return Xt(()=>{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 Xt(()=>{r.current!==e&&(r.current=e)},s),r}function ar(e,s){const r=C.useRef();return C.useMemo(()=>{const o=e(r.current);return r.current=o,o},[...s])}function Lr(e){const s=Qr(e),r=C.useRef(null),o=C.useCallback(p=>{p!==r.current&&s?.(p,r.current),r.current=p},[]);return[r,o]}function Pr(e){const s=C.useRef();return C.useEffect(()=>{s.current=e},[e]),s.current}let xi={};function Zr(e,s){return C.useMemo(()=>{if(s)return s;const r=xi[e]==null?0:xi[e]+1;return xi[e]=r,e+"-"+r},[e,s])}function Ua(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=Ua(1),Or=Ua(-1);function Cu(e){return"clientX"in e&&"clientY"in e}function yn(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 Ir(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}}}),ao="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(ao)?e:e.querySelector(ao)}const ju={display:"none"};function Nu(e){let{id:s,value:r}=e;return ce.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 ce.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 qa=C.createContext(null);function Mu(e){const s=C.useContext(qa);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
3
|
To pick up a draggable item, press the space bar.
|
|
4
4
|
While dragging, use the arrow keys to move the item.
|
|
5
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:x}=c;s.onDragMove&&m(s.onDragMove({active:g,over:x}))},onDragOver(c){let{active:g,over:x}=c;m(s.onDragOver({active:g,over:x}))},onDragEnd(c){let{active:g,over:x}=c;m(s.onDragEnd({active:g,over:x}))},onDragCancel(c){let{active:g,over:x}=c;m(s.onDragCancel({active:g,over:x}))}}),[m,s])),!n)return null;const u=ce.createElement(ce.Fragment,null,ce.createElement(Nu,{id:o,value:p.draggable}),ce.createElement(Ru,{id:i,announcement:v}));return r?ts.createPortal(u,r):u}var ot;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(ot||(ot={}));function 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 Pt=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 Hu(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 Wu=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=Hu(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}:Pt}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 Yu(e){const s=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function Vu(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)||Ha(p)||r.includes(p))return r;const m=bt(e).getComputedStyle(p);return p!==e&&Gu(p,m)&&r.push(p),Vu(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!Vr||!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 Ya(e){return Ps(e)?e.scrollY:e.scrollTop}function zi(e){return{x:Xa(e),y:Ya(e)}}var ut;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(ut||(ut={}));function Va(e){return!Vr||!e?!1:e===document.scrollingElement}function Ga(e){const s={x:0,y:0},r=Va(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={x:0,y:0},y={x:0,y:0},_={height:s.height*p.y,width:s.width*p.x};return!l&&m<=s.top+_.height?(x.y=ut.Backward,y.y=o*Math.abs((s.top+_.height-m)/_.height)):!u&&n>=s.bottom-_.height&&(x.y=ut.Forward,y.y=o*Math.abs((s.bottom-_.height-n)/_.height)),!g&&i>=s.right-_.width?(x.x=ut.Forward,y.x=o*Math.abs((s.right-_.width-i)/_.width)):!c&&v<=s.left+_.width&&(x.x=ut.Backward,y.x=o*Math.abs((s.left+_.width-v)/_.width)),{direction:x,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)),Pt)}function eh(e){return e.reduce((s,r)=>s+Xa(r),0)}function th(e){return e.reduce((s,r)=>s+Ya(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 Ue;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(Ue||(Ue={}));const Ja={start:[Ue.Space,Ue.Enter],cancel:[Ue.Esc],end:[Ue.Space,Ue.Enter,Ue.Tab]},nh=(e,s)=>{let{currentCoordinates:r}=s;switch(e.code){case Ue.Right:return{...r,x:r.x+25};case Ue.Left:return{...r,x:r.x-25};case Ue.Down:return{...r,y:r.y+25};case Ue.Up:return{...r,y:r.y-25}}};class 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(Pt)}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}:Pt;this.referenceCoordinates||(this.referenceCoordinates=u);const c=v(s,{active:r,context:o.current,currentCoordinates:u});if(c){const g=Pr(c,u),x={x:0,y:0},{scrollableAncestors:y}=o.current;for(const _ of y){const a=s.code,{isTop:h,isRight:d,isLeft:f,isBottom:b,maxScroll:w,minScroll:k}=Ga(_),j=Ju(_),S={x:Math.min(a===Ue.Right?j.right-j.width/2:j.right,Math.max(a===Ue.Right?j.left:j.left+j.width/2,c.x)),y:Math.min(a===Ue.Down?j.bottom-j.height/2:j.bottom,Math.max(a===Ue.Down?j.top:j.top+j.height/2,c.y))},E=a===Ue.Right&&!d||a===Ue.Left&&!f,R=a===Ue.Down&&!b||a===Ue.Up&&!h;if(E&&S.x!==c.x){const L=_.scrollLeft+g.x,T=a===Ue.Right&&L<=w.x||a===Ue.Left&&L>=k.x;if(T&&!g.y){_.scrollTo({left:L,behavior:i});return}T?x.x=_.scrollLeft-L:x.x=a===Ue.Right?_.scrollLeft-w.x:_.scrollLeft-k.x,x.x&&_.scrollBy({left:-x.x,behavior:i});break}else if(R&&S.y!==c.y){const L=_.scrollTop+g.y,T=a===Ue.Down&&L<=w.y||a===Ue.Up&&L>=k.y;if(T&&!g.x){_.scrollTo({top:L,behavior:i});return}T?x.y=_.scrollTop-L:x.y=a===Ue.Down?_.scrollTop-w.y:_.scrollTop-k.y,x.y&&_.scrollBy({top:-x.y,behavior:i});break}}this.handleMove(s,Rs(Pr(c,this.referenceCoordinates),x))}}}handleMove(s,r){const{onMove:o}=this.props;s.preventDefault(),o(r)}handleEnd(s){const{onEnd:r}=this.props;s.preventDefault(),this.detach(),r()}handleCancel(s){const{onCancel:r}=this.props;s.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}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:Pt,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:Pt,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===Ue.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 Hi;(function(e){e[e.RightClick=2]="RightClick"})(Hi||(Hi={}));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===Hi.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 x=hh({delta:c,disabled:!m}),[y,_]=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){_();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"])x[L][E[L]]||(R[L]=0,E[L]=0);if(R.x>0||R.y>0){_(),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},_()},[s,b,o,_,m,v,JSON.stringify(d),JSON.stringify(x),y,l,w,u,JSON.stringify(g)])}const uh={x:{[ut.Backward]:!1,[ut.Forward]:!1},y:{[ut.Backward]:!1,[ut.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:{[ut.Backward]:p.x[ut.Backward]||m.x===-1,[ut.Forward]:p.x[ut.Forward]||m.x===1},y:{[ut.Backward]:p.y[ut.Backward]||m.y===-1,[ut.Forward]:p.y[ut.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 Wi;(function(e){e.Optimized="optimized"})(Wi||(Wi={}));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),x=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),_=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||x()},[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(()=>{x(),y.current=null},i))},[i,c,x,...o]),{droppableRects:_,measureDroppableContainers:x,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 Xt(()=>{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),Pt):Qa(e):Pt,[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!==Pt;o&&!r.current&&(r.current=e),!o&&r.current&&(r.current=null)},[e]),r.current?Pr(e,r.current):Pt}function Sh(e){C.useEffect(()=>{if(!Vr)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?Yu(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=>Va(n)?o:new Sn(s(n),n)):go)}const i=Zr({callback:v});return Xt(()=>{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:Wi.Optimized},dragOverlay:{measure:ar}};class Ys 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 Ys,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 Ys}}}function Ah(e,s){switch(s.type){case ot.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case ot.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:s.coordinates.x-e.draggable.initialCoordinates.x,y:s.coordinates.y-e.draggable.initialCoordinates.y}}};case ot.DragEnd:case ot.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ot.RegisterDroppable:{const{element:r}=s,{id:o}=r,p=new Ys(e.droppable.containers);return p.set(o,r),{...e,droppable:{...e.droppable,containers:p}}}case ot.SetDroppableDisabled:{const{id:r,key:o,disabled:p}=s,m=e.droppable.containers.get(r);if(!m||o!==m.key)return e;const v=new Ys(e.droppable.containers);return v.set(r,{...m,disabled:p}),{...e,droppable:{...e.droppable,containers:v}}}case ot.UnregisterDroppable:{const{id:r,key:o}=s,p=e.droppable.containers.get(r);if(!p||o!==p.key)return e;const m=new Ys(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;Xt(()=>{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({...Pt,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=Wu,measuring:g,modifiers:x,...y}=s;const _=C.useReducer(Ah,void 0,Rh),[a,h]=_,[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}),M=C.useMemo(()=>{var ae;return j!=null?{id:j,data:(ae=L?.data)!=null?ae:jh,rect:T}:null},[j,L]),B=C.useRef(null),[D,F]=C.useState(null),[W,A]=C.useState(null),O=Js(y,Object.values(y)),P=Qr("DndDescribedBy",v),I=C.useMemo(()=>R.getEnabled(),[R]),$=Th(g),{droppableRects:Y,measureDroppableContainers:U,measuringScheduled:X}=ph(I,{dragging:k,dependencies:[E.x,E.y],config:$.droppable}),z=fh(S,j),N=C.useMemo(()=>W?Or(W):null,[W]),H=ne(),K=gh(z,$.draggable.measure);Dh({activeNode:j!=null?S.get(j):null,config:H.layoutShiftCompensation,initialRect:K,measure:$.draggable.measure});const q=fo(z,$.draggable.measure,K),ie=fo(z?z.parentElement:null),Q=C.useRef({activatorEvent:null,active:null,activeNode:z,collisionRect:null,collisions:null,droppableRects:Y,draggableNodes:S,draggingNode:null,draggingNodeRect:null,droppableContainers:R,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),se=R.getNodeFor((r=Q.current.over)==null?void 0:r.id),pe=kh({measure:$.dragOverlay.measure}),ge=(o=pe.nodeRef.current)!=null?o:z,ze=k?(p=pe.rect)!=null?p:q:null,de=!!(pe.nodeRef.current&&pe.rect),Ge=_h(de?null:q),Ee=tl(ge?bt(ge):null),Ke=bh(k?se??z:null),He=Ch(Ke),De=nl(x,{transform:{x:E.x-Ge.x,y:E.y-Ge.y,scaleX:1,scaleY:1},activatorEvent:W,active:M,activeNodeRect:q,containerNodeRect:ie,draggingNodeRect:ze,over:Q.current.over,overlayNodeRect:pe.rect,scrollableAncestors:Ke,scrollableAncestorRects:He,windowRect:Ee}),We=N?Rs(N,E):null,Te=yh(Ke),Xe=po(Te),Re=po(Te,[q]),je=Rs(De,Xe),Ne=ze?qu(ze,De):null,et=M&&Ne?c({active:M,collisionRect:Ne,droppableRects:Y,droppableContainers:I,pointerCoordinates:We}):null,Ae=zu(et,"id"),[$e,he]=C.useState(null),ft=de?De:Rs(De,Re),wt=$u(ft,(m=$e?.rect)!=null?m:null,q),G=C.useRef(null),te=C.useCallback((ae,me)=>{let{sensor:we,options:ye}=me;if(B.current==null)return;const Ce=S.get(B.current);if(!Ce)return;const Le=ae.nativeEvent,it=new we({active:B.current,activeNode:Ce,event:Le,options:ye,context:Q,onAbort(Se){if(!S.get(Se))return;const{onDragAbort:lt}=O.current,ct={id:Se};lt?.(ct),d({type:"onDragAbort",event:ct})},onPending(Se,pt,lt,ct){if(!S.get(Se))return;const{onDragPending:nt}=O.current,Qe={id:Se,constraint:pt,initialCoordinates:lt,offset:ct};nt?.(Qe),d({type:"onDragPending",event:Qe})},onStart(Se){const pt=B.current;if(pt==null)return;const lt=S.get(pt);if(!lt)return;const{onDragStart:ct}=O.current,vt={activatorEvent:Le,active:{id:pt,data:lt.data,rect:T}};ts.unstable_batchedUpdates(()=>{ct?.(vt),w(Zt.Initializing),h({type:ot.DragStart,initialCoordinates:Se,active:pt}),d({type:"onDragStart",event:vt}),F(G.current),A(Le)})},onMove(Se){h({type:ot.DragMove,coordinates:Se})},onEnd:tt(ot.DragEnd),onCancel:tt(ot.DragCancel)});G.current=it;function tt(Se){return async function(){const{active:lt,collisions:ct,over:vt,scrollAdjustedTranslate:nt}=Q.current;let Qe=null;if(lt&&nt){const{cancelDrop:Ie}=O.current;Qe={activatorEvent:Le,active:lt,collisions:ct,delta:nt,over:vt},Se===ot.DragEnd&&typeof Ie=="function"&&await Promise.resolve(Ie(Qe))&&(Se=ot.DragCancel)}B.current=null,ts.unstable_batchedUpdates(()=>{h({type:Se}),w(Zt.Uninitialized),he(null),F(null),A(null),G.current=null;const Ie=Se===ot.DragEnd?"onDragEnd":"onDragCancel";if(Qe){const Et=O.current[Ie];Et?.(Qe),d({type:Ie,event:Qe})}})}}},[S]),fe=C.useCallback((ae,me)=>(we,ye)=>{const Ce=we.nativeEvent,Le=S.get(ye);if(B.current!==null||!Le||Ce.dndKit||Ce.defaultPrevented)return;const it={active:Le};ae(we,me.options,it)===!0&&(Ce.dndKit={capturedBy:me.sensor},B.current=ye,te(we,me))},[S,te]),_e=mh(u,fe);Sh(u),Xt(()=>{q&&b===Zt.Initializing&&w(Zt.Initialized)},[q,b]),C.useEffect(()=>{const{onDragMove:ae}=O.current,{active:me,activatorEvent:we,collisions:ye,over:Ce}=Q.current;if(!me||!we)return;const Le={active:me,activatorEvent:we,collisions:ye,delta:{x:je.x,y:je.y},over:Ce};ts.unstable_batchedUpdates(()=>{ae?.(Le),d({type:"onDragMove",event:Le})})},[je.x,je.y]),C.useEffect(()=>{const{active:ae,activatorEvent:me,collisions:we,droppableContainers:ye,scrollAdjustedTranslate:Ce}=Q.current;if(!ae||B.current==null||!me||!Ce)return;const{onDragOver:Le}=O.current,it=ye.get(Ae),tt=it&&it.rect.current?{id:it.id,rect:it.rect.current,data:it.data,disabled:it.disabled}:null,Se={active:ae,activatorEvent:me,collisions:we,delta:{x:Ce.x,y:Ce.y},over:tt};ts.unstable_batchedUpdates(()=>{he(tt),Le?.(Se),d({type:"onDragOver",event:Se})})},[Ae]),Xt(()=>{Q.current={activatorEvent:W,active:M,activeNode:z,collisionRect:Ne,collisions:et,droppableRects:Y,draggableNodes:S,draggingNode:ge,draggingNodeRect:ze,droppableContainers:R,over:$e,scrollableAncestors:Ke,scrollAdjustedTranslate:je},T.current={initial:ze,translated:Ne}},[M,z,et,Ne,S,ge,ze,Y,R,$e,Ke,je]),dh({...H,delta:E,draggingRect:Ne,pointerCoordinates:We,scrollableAncestors:Ke,scrollableAncestorRects:He});const V=C.useMemo(()=>({active:M,activeNode:z,activeNodeRect:q,activatorEvent:W,collisions:et,containerNodeRect:ie,dragOverlay:pe,draggableNodes:S,droppableContainers:R,droppableRects:Y,over:$e,measureDroppableContainers:U,scrollableAncestors:Ke,scrollableAncestorRects:He,measuringConfiguration:$,measuringScheduled:X,windowRect:Ee}),[M,z,q,W,et,ie,pe,S,R,Y,$e,U,Ke,He,$,X,Ee]),re=C.useMemo(()=>({activatorEvent:W,activators:_e,active:M,activeNodeRect:q,ariaDescribedById:{draggable:P},dispatch:h,draggableNodes:S,over:$e,measureDroppableContainers:U}),[W,_e,M,q,h,P,S,$e,U]);return ce.createElement($a.Provider,{value:f},ce.createElement(lr.Provider,{value:re},ce.createElement(il.Provider,{value:V},ce.createElement(Jr.Provider,{value:wt},l)),ce.createElement(Mh,{disabled:i?.restoreFocus===!1})),ce.createElement(Pu,{...i,hiddenTextDescribedById:P}));function ne(){const ae=D?.autoScrollEnabled===!1,me=typeof n=="object"?n.enabled===!1:n===!1,we=k&&!ae&&!me;return typeof n=="object"?{...n,enabled:we}:{enabled:we}}}),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:x=vo,roleDescription:y="draggable",tabIndex:_=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);Xt(()=>(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:x,tabIndex:_,"aria-disabled":o,"aria-pressed":a&&x===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 Hh(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),x=C.useRef(null),{disabled:y,updateMeasurementsFor:_,timeout:a}={...zh,...p},h=Js(_??o),d=C.useCallback(()=>{if(!c.current){c.current=!0;return}x.current!=null&&clearTimeout(x.current),x.current=setTimeout(()=>{l(Array.isArray(h.current)?h.current:[h.current]),x.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:ot.RegisterDroppable,element:{id:o,key:m,disabled:r,node:w,rect:g,data:j}}),()=>i({type:ot.UnregisterDroppable,key:m,id:o})),[o]),C.useEffect(()=>{r!==u.current.disabled&&(i({type:ot.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 Wh(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),Xt(()=>{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]),ce.createElement(ce.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 ce.createElement(lr.Provider,{value:rl},ce.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 ce.createElement(r,{className:v,style:g,ref:s},m)}),Yh=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)}},Vh=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:Vh,sideEffects:Yh({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},x=p({...l,active:v,dragOverlay:i,transform:{initial:n,final:g}}),[y]=x,_=x[x.length-1];if(JSON.stringify(y)===JSON.stringify(_))return;const a=o?.({active:v,dragOverlay:i,...l}),h=i.node.animate(x,{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=ce.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:x,draggableNodes:y,droppableContainers:_,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:x,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:_,measuringConfiguration:d}),L=E?a.setRef:void 0;return ce.createElement(Uh,null,ce.createElement(Wh,{animation:R},c&&j?ce.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:oe.workspaces.list(e),queryFn:()=>xe.get(`/tasks/${e}/workspaces`),enabled:!!e})}function ll(e){const s=at();return St({mutationFn:r=>xe.post(`/tasks/${e}/workspaces`,r),onSuccess:()=>{s.invalidateQueries({queryKey:oe.workspaces.list(e)}),s.invalidateQueries({queryKey:oe.tasks.all})}})}function cl(){const e=at();return St({mutationFn:({id:s,commitMessage:r})=>xe.post(`/workspaces/${s}/merge`,{commitMessage:r}),onSuccess:()=>{e.invalidateQueries({queryKey:oe.workspaces.all}),e.invalidateQueries({queryKey:oe.tasks.all}),e.invalidateQueries({queryKey:oe.git.all})},onError:()=>{e.invalidateQueries({queryKey:oe.git.all})}})}function nf(){const e=at();return St({mutationFn:s=>xe.post(`/workspaces/${s}/reactivate`),onSuccess:()=>{e.invalidateQueries({queryKey:oe.workspaces.all}),e.invalidateQueries({queryKey:oe.tasks.all})}})}function jn(){return St({mutationFn:({workspaceId:e,editorType:s})=>xe.post(`/workspaces/${e}/open-editor`,{editorType:s})})}function Nn(e,s={}){return Tt({queryKey:oe.workspaces.gitStatus(e),queryFn:()=>xe.get(`/workspaces/${e}/git-status`),enabled:!!e&&(s.enabled??!0)})}function dl(){const e=at();return St({mutationFn:s=>xe.post(`/workspaces/${s}/rebase`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:oe.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:oe.git.all})},onError:(s,r)=>{e.invalidateQueries({queryKey:oe.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:oe.git.all})}})}function Rn(){const e=at();return St({mutationFn:s=>xe.post(`/workspaces/${s}/abort-operation`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:oe.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:oe.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===rt.RUNNING||v.status===rt.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}=ue(),{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((x,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:x})]},y))}):null]}),confirmText:i("删除"),variant:"danger",isLoading:v||c})}const ve={Review:"Review",Running:"Running",Pending:"Pending",Done:"Done",Cancelled:"Cancelled"},$i={[ve.Review]:{label:"Review",icon:ja,iconClass:"text-warning",accentClass:"text-warning"},[ve.Running]:{label:"Running",icon:Ea,iconClass:"text-info",accentClass:"text-info"},[ve.Pending]:{label:"Pending",icon:ka,iconClass:"text-muted-foreground",accentClass:"text-muted-foreground"},[ve.Done]:{label:"Done",icon:Ca,iconClass:"text-success/80",accentClass:"text-success"},[ve.Cancelled]:{label:"Cancelled",icon:wa,iconClass:"text-muted-foreground/70",accentClass:"text-muted-foreground/70"}},af=[ve.Review,ve.Running,ve.Pending,ve.Done,ve.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?gt("{count}s ago",{count:s}):s<3600?gt("{count}m ago",{count:Math.floor(s/60)}):s<86400?gt("{count}h ago",{count:Math.floor(s/3600)}):gt("{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}=ue(),u=C.useContext(ul),c=C.useRef(null),g=!!e.projectArchivedAt,x=g||!!n,{attributes:y,listeners:_,setNodeRef:a,isDragging:h}=Ih({id:e.id,data:{task:e,fromStatus:s},disabled:x}),d=C.useCallback(M=>{c.current=M,a(M),u&&(M?u.registry.set(e.id,M):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(M=>{g||!v&&!i||(M.preventDefault(),b({x:M.clientX,y:M.clientY}))},[g,v,i]),R=C.useCallback(()=>{S.current&&(clearTimeout(S.current),S.current=null)},[]),L=C.useCallback(M=>{if(!n||g||!v&&!i)return;const B=M.touches[0];if(!B)return;const{clientX:D,clientY:F}=B;S.current=setTimeout(()=>{S.current=null,b({x:D,y:F})},500)},[n,g,v,i]);C.useEffect(()=>{if(!f)return;const M=B=>{j.current&&!j.current.contains(B.target)&&b(null)};return document.addEventListener("mousedown",M),document.addEventListener("touchstart",M),()=>{document.removeEventListener("mousedown",M),document.removeEventListener("touchstart",M)}},[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
|
|
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=Zr("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:x}=c;s.onDragMove&&m(s.onDragMove({active:g,over:x}))},onDragOver(c){let{active:g,over:x}=c;m(s.onDragOver({active:g,over:x}))},onDragEnd(c){let{active:g,over:x}=c;m(s.onDragEnd({active:g,over:x}))},onDragCancel(c){let{active:g,over:x}=c;m(s.onDragCancel({active:g,over:x}))}}),[m,s])),!n)return null;const u=ce.createElement(ce.Fragment,null,ce.createElement(Nu,{id:o,value:p.draggable}),ce.createElement(Ru,{id:i,announcement:v}));return r?ts.createPortal(u,r):u}var ot;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(ot||(ot={}));function Br(){}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 Pt=Object.freeze({x:0,y:0});function Bu(e,s){const r=Ir(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 Ka(e,s){return e&&s?{x:e.left-s.left,y:e.top-s.top}:Pt}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 Xa(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=Xa(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 lr(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 lo(e){return lr(e,{ignoreTransform:!0})}function Yu(e){const s=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function Vu(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 Sn(e,s){const r=[];function o(p){if(s!=null&&r.length>=s||!p)return r;if(bn(p)&&p.scrollingElement!=null&&!r.includes(p.scrollingElement))return r.push(p.scrollingElement),r;if(!or(p)||$a(p)||r.includes(p))return r;const m=bt(e).getComputedStyle(p);return p!==e&&Gu(p,m)&&r.push(p),Vu(p,m)?r:o(p.parentNode)}return e?o(e):r}function Ya(e){const[s]=Sn(e,1);return s??null}function _i(e){return!Gr||!e?null:Ps(e)?e:_n(e)?bn(e)||e===Os(e).scrollingElement?window:or(e)?e:null:null}function Va(e){return Ps(e)?e.scrollX:e.scrollLeft}function Ga(e){return Ps(e)?e.scrollY:e.scrollTop}function Wi(e){return{x:Va(e),y:Ga(e)}}var ut;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(ut||(ut={}));function Qa(e){return!Gr||!e?!1:e===document.scrollingElement}function Za(e){const s={x:0,y:0},r=Qa(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}=Za(e),x={x:0,y:0},y={x:0,y:0},_={height:s.height*p.y,width:s.width*p.x};return!l&&m<=s.top+_.height?(x.y=ut.Backward,y.y=o*Math.abs((s.top+_.height-m)/_.height)):!u&&n>=s.bottom-_.height&&(x.y=ut.Forward,y.y=o*Math.abs((s.bottom-_.height-n)/_.height)),!g&&i>=s.right-_.width?(x.x=ut.Forward,y.x=o*Math.abs((s.right-_.width-i)/_.width)):!c&&v<=s.left+_.width&&(x.x=ut.Backward,y.x=o*Math.abs((s.left+_.width-v)/_.width)),{direction:x,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 Ja(e){return e.reduce((s,r)=>Rs(s,Wi(r)),Pt)}function eh(e){return e.reduce((s,r)=>s+Va(r),0)}function th(e){return e.reduce((s,r)=>s+Ga(r),0)}function el(e,s){if(s===void 0&&(s=lr),!e)return;const{top:r,left:o,bottom:p,right:m}=s(e);Ya(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 wn{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=Sn(r),p=Ja(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 bi(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 co(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 tl={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 sl{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&&el(o),r(Pt)}handleKeyDown(s){if(yn(s)){const{active:r,context:o,options:p}=this.props,{keyboardCodes:m=tl,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}:Pt;this.referenceCoordinates||(this.referenceCoordinates=u);const c=v(s,{active:r,context:o.current,currentCoordinates:u});if(c){const g=Or(c,u),x={x:0,y:0},{scrollableAncestors:y}=o.current;for(const _ of y){const a=s.code,{isTop:h,isRight:d,isLeft:f,isBottom:b,maxScroll:w,minScroll:k}=Za(_),j=Ju(_),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=_.scrollLeft+g.x,T=a===$e.Right&&L<=w.x||a===$e.Left&&L>=k.x;if(T&&!g.y){_.scrollTo({left:L,behavior:i});return}T?x.x=_.scrollLeft-L:x.x=a===$e.Right?_.scrollLeft-w.x:_.scrollLeft-k.x,x.x&&_.scrollBy({left:-x.x,behavior:i});break}else if(R&&S.y!==c.y){const L=_.scrollTop+g.y,T=a===$e.Down&&L<=w.y||a===$e.Up&&L>=k.y;if(T&&!g.x){_.scrollTo({top:L,behavior:i});return}T?x.y=_.scrollTop-L:x.y=a===$e.Down?_.scrollTop-w.y:_.scrollTop-k.y,x.y&&_.scrollBy({top:-x.y,behavior:i});break}}this.handleMove(s,Rs(Or(c,this.referenceCoordinates),x))}}}handleMove(s,r){const{onMove:o}=this.props;s.preventDefault(),o(r)}handleEnd(s){const{onEnd:r}=this.props;s.preventDefault(),this.detach(),r()}handleCancel(s){const{onCancel:r}=this.props;s.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}sl.activators=[{eventName:"onKeyDown",handler:(e,s,r)=>{let{keyboardCodes:o=tl,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 uo(e){return!!(e&&"distance"in e)}function ho(e){return!!(e&&"delay"in e)}class Cn{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=Ir(m))!=null?p:Pt,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,co),this.windowListeners.add(Nt.VisibilityChange,this.handleCancel),this.windowListeners.add(Nt.ContextMenu,co),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(ho(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(uo(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=Ir(s))!=null?r:Pt,l=Or(p,n);if(!o&&i){if(uo(i)){if(i.tolerance!=null&&bi(l,i.tolerance))return this.handleCancel();if(bi(l,i.distance))return this.handleStart()}if(ho(i)&&bi(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 kn extends Cn{constructor(s){const{event:r}=s,o=Os(r.target);super(s,oh,o)}}kn.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 Hi;(function(e){e[e.RightClick=2]="RightClick"})(Hi||(Hi={}));class lh extends Cn{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===Hi.RightClick?!1:(o?.({event:r}),!0)}}];const yi={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class ch extends Cn{constructor(s){super(s,yi)}static setup(){return window.addEventListener(yi.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(yi.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 Fr;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Fr||(Fr={}));function dh(e){let{acceleration:s,activator:r=Xs.Pointer,canScroll:o,draggingRect:p,enabled:m,interval:v=5,order:i=Fr.TreeOrder,pointerCoordinates:n,scrollableAncestors:l,scrollableAncestorRects:u,delta:c,threshold:g}=e;const x=hh({delta:c,disabled:!m}),[y,_]=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===Fr.TreeOrder?[...l].reverse():l,[i,l]);C.useEffect(()=>{if(!m||!l.length||!d){_();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"])x[L][E[L]]||(R[L]=0,E[L]=0);if(R.x>0||R.y>0){_(),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},_()},[s,b,o,_,m,v,JSON.stringify(d),JSON.stringify(x),y,l,w,u,JSON.stringify(g)])}const uh={x:{[ut.Backward]:!1,[ut.Forward]:!1},y:{[ut.Backward]:!1,[ut.Forward]:!1}};function hh(e){let{delta:s,disabled:r}=e;const o=Pr(s);return ar(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:{[ut.Backward]:p.x[ut.Backward]||m.x===-1,[ut.Forward]:p.x[ut.Forward]||m.x===1},y:{[ut.Backward]:p.y[ut.Backward]||m.y===-1,[ut.Forward]:p.y[ut.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 ar(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 $i;(function(e){e.Optimized="optimized"})($i||($i={}));const fo=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),x=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),_=ar(h=>{if(c&&!r)return fo;if(!h||h===fo||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 wn(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||x()},[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(()=>{x(),y.current=null},i))},[i,c,x,...o]),{droppableRects:_,measureDroppableContainers:x,measuringScheduled:m!=null};function a(){switch(l){case tr.Always:return!1;case tr.BeforeDragging:return r;default:return!r}}}function En(e,s){return ar(r=>e?r||(typeof s=="function"?s(e):e):null,[s,e])}function gh(e,s){return En(e,s)}function vh(e){let{callback:s,disabled:r}=e;const o=Qr(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 Jr(e){let{callback:s,disabled:r}=e;const o=Qr(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 wn(lr(e),e)}function mo(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=Jr({callback:m});return Xt(()=>{m(),e?(i?.observe(e),v?.observe(document.body,{childList:!0,subtree:!0})):(i?.disconnect(),v?.disconnect())},[e]),o}function _h(e){const s=En(e);return Ka(e,s)}const po=[];function bh(e){const s=C.useRef(e),r=ar(o=>e?o&&o!==po&&e&&s.current&&e.parentNode===s.current.parentNode?o:Sn(e):po,[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=_i(m.target);v&&r(i=>i?(i.set(v,Wi(v)),new Map(i)):null)},[]);return C.useEffect(()=>{const m=o.current;if(e!==m){v(m);const i=e.map(n=>{const l=_i(n);return l?(l.addEventListener("scroll",p,{passive:!0}),[l,Wi(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=_i(n);l?.removeEventListener("scroll",p)})}},[p,e]),C.useMemo(()=>e.length?s?Array.from(s.values()).reduce((m,v)=>Rs(m,v),Pt):Ja(e):Pt,[e,s])}function go(e,s){s===void 0&&(s=[]);const r=C.useRef(null);return C.useEffect(()=>{r.current=null},s),C.useEffect(()=>{const o=e!==Pt;o&&!r.current&&(r.current=e),!o&&r.current&&(r.current=null)},[e]),r.current?Or(e,r.current):Pt}function Sh(e){C.useEffect(()=>{if(!Gr)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 rl(e){return C.useMemo(()=>e?Yu(e):null,[e])}const vo=[];function Ch(e,s){s===void 0&&(s=lr);const[r]=e,o=rl(r?bt(r):null),[p,m]=C.useState(vo);function v(){m(()=>e.length?e.map(n=>Qa(n)?o:new wn(s(n),n)):vo)}const i=Jr({callback:v});return Xt(()=>{i?.disconnect(),v(),e.forEach(n=>i?.observe(n))},[e]),p}function il(e){if(!e)return null;if(e.children.length>1)return e;const s=e.children[0];return or(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(or(u)){o(c=>{const g=s(u);return c?{...c,width:g.width,height:g.height}:g});break}},[s]),m=Jr({callback:p}),v=C.useCallback(l=>{const u=il(l);m?.disconnect(),u&&m?.observe(u),o(u?s(u):null)},[s,m]),[i,n]=Lr(v);return C.useMemo(()=>({nodeRef:i,rect:r,setRef:n}),[r,i,n])}const Eh=[{sensor:kn,options:{}},{sensor:sl,options:{}}],jh={current:{}},jr={draggable:{measure:lo},droppable:{measure:lo,strategy:tr.WhileDragging,frequency:$i.Optimized},dragOverlay:{measure:lr}};class Ys 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 Ys,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Br},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:jr,measureDroppableContainers:Br,windowRect:null,measuringScheduled:!1},nl={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Br,draggableNodes:new Map,over:null,measureDroppableContainers:Br},cr=C.createContext(nl),ol=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 Ys}}}function Ah(e,s){switch(s.type){case ot.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case ot.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:s.coordinates.x-e.draggable.initialCoordinates.x,y:s.coordinates.y-e.draggable.initialCoordinates.y}}};case ot.DragEnd:case ot.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ot.RegisterDroppable:{const{element:r}=s,{id:o}=r,p=new Ys(e.droppable.containers);return p.set(o,r),{...e,droppable:{...e.droppable,containers:p}}}case ot.SetDroppableDisabled:{const{id:r,key:o,disabled:p}=s,m=e.droppable.containers.get(r);if(!m||o!==m.key)return e;const v=new Ys(e.droppable.containers);return v.set(r,{...m,disabled:p}),{...e,droppable:{...e.droppable,containers:v}}}case ot.UnregisterDroppable:{const{id:r,key:o}=s,p=e.droppable.containers.get(r);if(!p||o!==p.key)return e;const m=new Ys(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(cr),m=Pr(o),v=Pr(r?.id);return C.useEffect(()=>{if(!s&&!o&&m&&v!=null){if(!yn(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 al(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:{...jr.draggable,...e?.draggable},droppable:{...jr.droppable,...e?.droppable},dragOverlay:{...jr.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;Xt(()=>{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=Ka(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=Ya(l);g&&g.scrollBy({top:c.y,left:c.x})}},[s,v,i,o,r])}const ei=C.createContext({...Pt,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:x,...y}=s;const _=C.useReducer(Ah,void 0,Rh),[a,h]=_,[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}),M=C.useMemo(()=>{var ae;return j!=null?{id:j,data:(ae=L?.data)!=null?ae:jh,rect:T}:null},[j,L]),B=C.useRef(null),[D,F]=C.useState(null),[H,A]=C.useState(null),O=Js(y,Object.values(y)),P=Zr("DndDescribedBy",v),I=C.useMemo(()=>R.getEnabled(),[R]),$=Th(g),{droppableRects:Y,measureDroppableContainers:U,measuringScheduled:X}=ph(I,{dragging:k,dependencies:[E.x,E.y],config:$.droppable}),z=fh(S,j),N=C.useMemo(()=>H?Ir(H):null,[H]),W=ne(),K=gh(z,$.draggable.measure);Dh({activeNode:j!=null?S.get(j):null,config:W.layoutShiftCompensation,initialRect:K,measure:$.draggable.measure});const q=mo(z,$.draggable.measure,K),ie=mo(z?z.parentElement:null),Q=C.useRef({activatorEvent:null,active:null,activeNode:z,collisionRect:null,collisions:null,droppableRects:Y,draggableNodes:S,draggingNode:null,draggingNodeRect:null,droppableContainers:R,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),se=R.getNodeFor((r=Q.current.over)==null?void 0:r.id),pe=kh({measure:$.dragOverlay.measure}),ge=(o=pe.nodeRef.current)!=null?o:z,Fe=k?(p=pe.rect)!=null?p:q:null,de=!!(pe.nodeRef.current&&pe.rect),Ge=_h(de?null:q),Ee=rl(ge?bt(ge):null),Ke=bh(k?se??z:null),ze=Ch(Ke),De=al(x,{transform:{x:E.x-Ge.x,y:E.y-Ge.y,scaleX:1,scaleY:1},activatorEvent:H,active:M,activeNodeRect:q,containerNodeRect:ie,draggingNodeRect:Fe,over:Q.current.over,overlayNodeRect:pe.rect,scrollableAncestors:Ke,scrollableAncestorRects:ze,windowRect:Ee}),We=N?Rs(N,E):null,Te=yh(Ke),Xe=go(Te),Re=go(Te,[q]),je=Rs(De,Xe),Ne=Fe?qu(Fe,De):null,et=M&&Ne?c({active:M,collisionRect:Ne,droppableRects:Y,droppableContainers:I,pointerCoordinates:We}):null,Ae=zu(et,"id"),[He,he]=C.useState(null),ft=de?De:Rs(De,Re),wt=$u(ft,(m=He?.rect)!=null?m:null,q),G=C.useRef(null),te=C.useCallback((ae,me)=>{let{sensor:we,options:ye}=me;if(B.current==null)return;const Ce=S.get(B.current);if(!Ce)return;const Le=ae.nativeEvent,it=new we({active:B.current,activeNode:Ce,event:Le,options:ye,context:Q,onAbort(Se){if(!S.get(Se))return;const{onDragAbort:lt}=O.current,ct={id:Se};lt?.(ct),d({type:"onDragAbort",event:ct})},onPending(Se,pt,lt,ct){if(!S.get(Se))return;const{onDragPending:nt}=O.current,Qe={id:Se,constraint:pt,initialCoordinates:lt,offset:ct};nt?.(Qe),d({type:"onDragPending",event:Qe})},onStart(Se){const pt=B.current;if(pt==null)return;const lt=S.get(pt);if(!lt)return;const{onDragStart:ct}=O.current,vt={activatorEvent:Le,active:{id:pt,data:lt.data,rect:T}};ts.unstable_batchedUpdates(()=>{ct?.(vt),w(Zt.Initializing),h({type:ot.DragStart,initialCoordinates:Se,active:pt}),d({type:"onDragStart",event:vt}),F(G.current),A(Le)})},onMove(Se){h({type:ot.DragMove,coordinates:Se})},onEnd:tt(ot.DragEnd),onCancel:tt(ot.DragCancel)});G.current=it;function tt(Se){return async function(){const{active:lt,collisions:ct,over:vt,scrollAdjustedTranslate:nt}=Q.current;let Qe=null;if(lt&&nt){const{cancelDrop:Oe}=O.current;Qe={activatorEvent:Le,active:lt,collisions:ct,delta:nt,over:vt},Se===ot.DragEnd&&typeof Oe=="function"&&await Promise.resolve(Oe(Qe))&&(Se=ot.DragCancel)}B.current=null,ts.unstable_batchedUpdates(()=>{h({type:Se}),w(Zt.Uninitialized),he(null),F(null),A(null),G.current=null;const Oe=Se===ot.DragEnd?"onDragEnd":"onDragCancel";if(Qe){const Et=O.current[Oe];Et?.(Qe),d({type:Oe,event:Qe})}})}}},[S]),fe=C.useCallback((ae,me)=>(we,ye)=>{const Ce=we.nativeEvent,Le=S.get(ye);if(B.current!==null||!Le||Ce.dndKit||Ce.defaultPrevented)return;const it={active:Le};ae(we,me.options,it)===!0&&(Ce.dndKit={capturedBy:me.sensor},B.current=ye,te(we,me))},[S,te]),_e=mh(u,fe);Sh(u),Xt(()=>{q&&b===Zt.Initializing&&w(Zt.Initialized)},[q,b]),C.useEffect(()=>{const{onDragMove:ae}=O.current,{active:me,activatorEvent:we,collisions:ye,over:Ce}=Q.current;if(!me||!we)return;const Le={active:me,activatorEvent:we,collisions:ye,delta:{x:je.x,y:je.y},over:Ce};ts.unstable_batchedUpdates(()=>{ae?.(Le),d({type:"onDragMove",event:Le})})},[je.x,je.y]),C.useEffect(()=>{const{active:ae,activatorEvent:me,collisions:we,droppableContainers:ye,scrollAdjustedTranslate:Ce}=Q.current;if(!ae||B.current==null||!me||!Ce)return;const{onDragOver:Le}=O.current,it=ye.get(Ae),tt=it&&it.rect.current?{id:it.id,rect:it.rect.current,data:it.data,disabled:it.disabled}:null,Se={active:ae,activatorEvent:me,collisions:we,delta:{x:Ce.x,y:Ce.y},over:tt};ts.unstable_batchedUpdates(()=>{he(tt),Le?.(Se),d({type:"onDragOver",event:Se})})},[Ae]),Xt(()=>{Q.current={activatorEvent:H,active:M,activeNode:z,collisionRect:Ne,collisions:et,droppableRects:Y,draggableNodes:S,draggingNode:ge,draggingNodeRect:Fe,droppableContainers:R,over:He,scrollableAncestors:Ke,scrollAdjustedTranslate:je},T.current={initial:Fe,translated:Ne}},[M,z,et,Ne,S,ge,Fe,Y,R,He,Ke,je]),dh({...W,delta:E,draggingRect:Ne,pointerCoordinates:We,scrollableAncestors:Ke,scrollableAncestorRects:ze});const V=C.useMemo(()=>({active:M,activeNode:z,activeNodeRect:q,activatorEvent:H,collisions:et,containerNodeRect:ie,dragOverlay:pe,draggableNodes:S,droppableContainers:R,droppableRects:Y,over:He,measureDroppableContainers:U,scrollableAncestors:Ke,scrollableAncestorRects:ze,measuringConfiguration:$,measuringScheduled:X,windowRect:Ee}),[M,z,q,H,et,ie,pe,S,R,Y,He,U,Ke,ze,$,X,Ee]),re=C.useMemo(()=>({activatorEvent:H,activators:_e,active:M,activeNodeRect:q,ariaDescribedById:{draggable:P},dispatch:h,draggableNodes:S,over:He,measureDroppableContainers:U}),[H,_e,M,q,h,P,S,He,U]);return ce.createElement(qa.Provider,{value:f},ce.createElement(cr.Provider,{value:re},ce.createElement(ol.Provider,{value:V},ce.createElement(ei.Provider,{value:wt},l)),ce.createElement(Mh,{disabled:i?.restoreFocus===!1})),ce.createElement(Pu,{...i,hiddenTextDescribedById:P}));function ne(){const ae=D?.autoScrollEnabled===!1,me=typeof n=="object"?n.enabled===!1:n===!1,we=k&&!ae&&!me;return typeof n=="object"?{...n,enabled:we}:{enabled:we}}}),Ph=C.createContext(null),xo="button",Oh="Draggable";function Ih(e){let{id:s,data:r,disabled:o=!1,attributes:p}=e;const m=Zr(Oh),{activators:v,activatorEvent:i,active:n,activeNodeRect:l,ariaDescribedById:u,draggableNodes:c,over:g}=C.useContext(cr),{role:x=xo,roleDescription:y="draggable",tabIndex:_=0}=p??{},a=n?.id===s,h=C.useContext(a?ei:Ph),[d,f]=Lr(),[b,w]=Lr(),k=wh(v,s),j=Js(r);Xt(()=>(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:x,tabIndex:_,"aria-disabled":o,"aria-pressed":a&&x===xo?!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(ol)}const Fh="Droppable",zh={timeout:25};function Wh(e){let{data:s,disabled:r=!1,id:o,resizeObserverConfig:p}=e;const m=Zr(Fh),{active:v,dispatch:i,over:n,measureDroppableContainers:l}=C.useContext(cr),u=C.useRef({disabled:r}),c=C.useRef(!1),g=C.useRef(null),x=C.useRef(null),{disabled:y,updateMeasurementsFor:_,timeout:a}={...zh,...p},h=Js(_??o),d=C.useCallback(()=>{if(!c.current){c.current=!0;return}x.current!=null&&clearTimeout(x.current),x.current=setTimeout(()=>{l(Array.isArray(h.current)?h.current:[h.current]),x.current=null},a)},[a]),f=Jr({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]=Lr(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:ot.RegisterDroppable,element:{id:o,key:m,disabled:r,node:w,rect:g,data:j}}),()=>i({type:ot.UnregisterDroppable,key:m,id:o})),[o]),C.useEffect(()=>{r!==u.current.disabled&&(i({type:ot.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=Pr(r);return!r&&!o&&i&&p(i),Xt(()=>{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]),ce.createElement(ce.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 ce.createElement(cr.Provider,{value:nl},ce.createElement(ei.Provider,{value:$h},s))}const qh={position:"fixed",touchAction:"none"},Kh=e=>yn(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 ce.createElement(r,{className:v,style:g,ref:s},m)}),Yh=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)}},Vh=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:Vh,sideEffects:Yh({styles:{active:{opacity:"0"}}})};function Qh(e){let{config:s,draggableNodes:r,droppableContainers:o,measuringConfiguration:p}=e;return Qr((m,v)=>{if(s===null)return;const i=r.get(m);if(!i)return;const n=i.node.current;if(!n)return;const l=il(v);if(!l)return;const{transform:u}=bt(v).getComputedStyle(v),c=Xa(u);if(!c)return;const g=typeof s=="function"?s:Zh(s);return el(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},x=p({...l,active:v,dragOverlay:i,transform:{initial:n,final:g}}),[y]=x,_=x[x.length-1];if(JSON.stringify(y)===JSON.stringify(_))return;const a=o?.({active:v,dragOverlay:i,...l}),h=i.node.animate(x,{duration:s,easing:r,fill:"forwards"});return new Promise(d=>{h.onfinish=()=>{a?.(),d()}})}}let _o=0;function Jh(e){return C.useMemo(()=>{if(e!=null)return _o++,_o},[e])}const ef=ce.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:x,draggableNodes:y,droppableContainers:_,dragOverlay:a,over:h,measuringConfiguration:d,scrollableAncestors:f,scrollableAncestorRects:b,windowRect:w}=Bh(),k=C.useContext(ei),j=Jh(c?.id),S=al(v,{activatorEvent:u,active:c,activeNodeRect:g,containerNodeRect:x,draggingNodeRect:a.rect,over:h,overlayNodeRect:a.rect,scrollableAncestors:f,scrollableAncestorRects:b,transform:k,windowRect:w}),E=En(g),R=Qh({config:o,draggableNodes:y,droppableContainers:_,measuringConfiguration:d}),L=E?a.setRef:void 0;return ce.createElement(Uh,null,ce.createElement(Hh,{animation:R},c&&j?ce.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))}),ll=768;function tf(e){const s=window.matchMedia(`(max-width: ${ll-1}px)`);return s.addEventListener("change",e),()=>s.removeEventListener("change",e)}function sf(){return window.innerWidth<ll}function rf(){return!1}function cl(){return C.useSyncExternalStore(tf,sf,rf)}function jn(e){return Tt({queryKey:oe.workspaces.list(e),queryFn:()=>xe.get(`/tasks/${e}/workspaces`),enabled:!!e})}function dl(e){const s=at();return St({mutationFn:r=>xe.post(`/tasks/${e}/workspaces`,r),onSuccess:()=>{s.invalidateQueries({queryKey:oe.workspaces.list(e)}),s.invalidateQueries({queryKey:oe.tasks.all})}})}function ul(){const e=at();return St({mutationFn:({id:s,commitMessage:r})=>xe.post(`/workspaces/${s}/merge`,{commitMessage:r}),onSuccess:()=>{e.invalidateQueries({queryKey:oe.workspaces.all}),e.invalidateQueries({queryKey:oe.tasks.all}),e.invalidateQueries({queryKey:oe.git.all})},onError:()=>{e.invalidateQueries({queryKey:oe.git.all})}})}function nf(){const e=at();return St({mutationFn:s=>xe.post(`/workspaces/${s}/reactivate`),onSuccess:()=>{e.invalidateQueries({queryKey:oe.workspaces.all}),e.invalidateQueries({queryKey:oe.tasks.all})}})}function Nn(){return St({mutationFn:({workspaceId:e,editorType:s})=>xe.post(`/workspaces/${e}/open-editor`,{editorType:s})})}function Rn(e,s={}){return Tt({queryKey:oe.workspaces.gitStatus(e),queryFn:()=>xe.get(`/workspaces/${e}/git-status`),enabled:!!e&&(s.enabled??!0)})}function hl(){const e=at();return St({mutationFn:s=>xe.post(`/workspaces/${s}/rebase`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:oe.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:oe.git.all})},onError:(s,r)=>{e.invalidateQueries({queryKey:oe.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:oe.git.all})}})}function An(){const e=at();return St({mutationFn:s=>xe.post(`/workspaces/${s}/abort-operation`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:oe.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:oe.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===rt.RUNNING||v.status===rt.PENDING))&&r.push(s("正在运行的 Agent 将被停止")),o&&(r.push(s("分支上未合并的变更将丢失")),r.push(s("关联的工作目录(worktree)将被清理"))),r}function Mn({isOpen:e,onClose:s,onConfirm:r,taskId:o,taskTitle:p,workspaces:m,isLoading:v}){const{t:i}=ue(),{data:n,isLoading:l}=jn(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(un,{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((x,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:x})]},y))}):null]}),confirmText:i("删除"),variant:"danger",isLoading:v||c})}const ve={Review:"Review",Running:"Running",Pending:"Pending",Done:"Done",Cancelled:"Cancelled"},Ui={[ve.Review]:{label:"Review",icon:Ma,iconClass:"text-warning",accentClass:"text-warning"},[ve.Running]:{label:"Running",icon:Aa,iconClass:"text-info",accentClass:"text-info"},[ve.Pending]:{label:"Pending",icon:Ra,iconClass:"text-muted-foreground",accentClass:"text-muted-foreground"},[ve.Done]:{label:"Done",icon:Na,iconClass:"text-success/80",accentClass:"text-success"},[ve.Cancelled]:{label:"Cancelled",icon:ja,iconClass:"text-muted-foreground/70",accentClass:"text-muted-foreground/70"}},af=[ve.Review,ve.Running,ve.Pending,ve.Done,ve.Cancelled],fl=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?gt("{count}s ago",{count:s}):s<3600?gt("{count}m ago",{count:Math.floor(s/60)}):s<86400?gt("{count}h ago",{count:Math.floor(s/3600)}):gt("{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}=ue(),u=C.useContext(fl),c=C.useRef(null),g=!!e.projectArchivedAt,x=g||!!n,{attributes:y,listeners:_,setNodeRef:a,isDragging:h}=Ih({id:e.id,data:{task:e,fromStatus:s},disabled:x}),d=C.useCallback(M=>{c.current=M,a(M),u&&(M?u.registry.set(e.id,M):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(M=>{g||!v&&!i||(M.preventDefault(),b({x:M.clientX,y:M.clientY}))},[g,v,i]),R=C.useCallback(()=>{S.current&&(clearTimeout(S.current),S.current=null)},[]),L=C.useCallback(M=>{if(!n||g||!v&&!i)return;const B=M.touches[0];if(!B)return;const{clientX:D,clientY:F}=B;S.current=setTimeout(()=>{S.current=null,b({x:D,y:F})},500)},[n,g,v,i]);C.useEffect(()=>{if(!f)return;const M=B=>{j.current&&!j.current.contains(B.target)&&b(null)};return document.addEventListener("mousedown",M),document.addEventListener("touchstart",M),()=>{document.removeEventListener("mousedown",M),document.removeEventListener("touchstart",M)}},[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
7
|
${h?"opacity-30":""}
|
|
8
|
-
${r?"bg-accent":"hover:bg-accent/50"}`,...x?{}:_,...x?{}:y,children:[t.jsx("span",{className:"shrink-0 flex items-center",children:(()=>{const{icon:M,iconClass:B}
|
|
8
|
+
${r?"bg-accent":"hover:bg-accent/50"}`,...x?{}:_,...x?{}:y,children:[t.jsx("span",{className:"shrink-0 flex items-center",children:(()=>{const{icon:M,iconClass:B}=Ui[s];return t.jsx(M,{className:`${B} ${s===ve.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(M=>M!==s).map(M=>{const{icon:B,label:D,accentClass:F}=Ui[M];return t.jsxs("button",{onClick:()=>{v(e.id,M),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 ${F}`}),t.jsx("span",{className:"text-foreground/80",children:l(D)})]},M)})]}),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(Mn,{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:x}){const{t:y}=ue(),[_,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===ve.Review,j=y(s),S=l?d&&(_||!0):_;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
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
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(M=>M.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:x},E.id)})})]})}),ff=12,mf=50;function pf({isOpen:e,onClose:s,tasks:r,projects:o,onSelectTask:p}){const{t:m}=ue(),[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(_=>_.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]),x=C.useCallback(y=>{if(y.key==="Escape")y.preventDefault(),s();else if(y.key==="ArrowDown")y.preventDefault(),l(_=>Math.min(_+1,c.length-1));else if(y.key==="ArrowUp")y.preventDefault(),l(_=>Math.max(_-1,0));else if(y.key==="Enter"&&!y.nativeEvent.isComposing){y.preventDefault();const _=c[n];_&&g(_.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(
|
|
12
|
-
${_===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={[ve.Review]:[],[ve.Running]:[],[ve.Pending]:[],[ve.Done]:[],[ve.Cancelled]:[]};for(const r of e)s[r.status].push(r);return s}const _f=[{status:ve.Review,title:"Review",defaultOpen:!0},{status:ve.Running,title:"Running",defaultOpen:!0},{status:ve.Pending,title:"Pending",defaultOpen:!1},{status:ve.Done,title:"Done",defaultOpen:!1},{status:ve.Cancelled,title:"Cancelled",defaultOpen:!1}];function
|
|
13
|
-
${l?"bg-accent text-foreground":"text-foreground/80 hover:bg-accent/50"}`,title:x(O?"New Task":"Deleted projects are read-only"),children:[t.jsx(
|
|
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(M=>M.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:x},E.id)})})]})}),ff=12,mf=50;function pf({isOpen:e,onClose:s,tasks:r,projects:o,onSelectTask:p}){const{t:m}=ue(),[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(_=>_.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]),x=C.useCallback(y=>{if(y.key==="Escape")y.preventDefault(),s();else if(y.key==="ArrowDown")y.preventDefault(),l(_=>Math.min(_+1,c.length-1));else if(y.key==="ArrowUp")y.preventDefault(),l(_=>Math.max(_-1,0));else if(y.key==="Enter"&&!y.nativeEvent.isComposing){y.preventDefault();const _=c[n];_&&g(_.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(hn,{size:15,className:"text-muted-foreground/70 shrink-0"}),t.jsx("input",{value:v,onChange:y=>i(y.target.value),onKeyDown:x,placeholder:m("Search tasks..."),"aria-label":m("Search tasks..."),autoFocus:!0,className:"flex-1 py-3 bg-transparent border-none focus:outline-none text-sm text-foreground placeholder-muted-foreground/60"})]}),c.length>0?t.jsxs(t.Fragment,{children:[!v.trim()&&t.jsx("div",{className:"px-4 pt-2.5 pb-1 text-[11px] font-medium text-muted-foreground/70",children:m("Recent tasks")}),t.jsx("div",{ref:u,className:"max-h-[46vh] overflow-y-auto scrollbar-app-thin pb-1.5 pt-0.5",children:c.map((y,_)=>{const a=o.find(f=>f.id===y.projectId),{icon:h,iconClass:d}=Ui[y.status];return t.jsxs("button",{onClick:()=>g(y.id),onMouseEnter:()=>l(_),className:`w-full flex items-center gap-2.5 px-4 py-2 text-left transition-colors
|
|
12
|
+
${_===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={[ve.Review]:[],[ve.Running]:[],[ve.Pending]:[],[ve.Done]:[],[ve.Cancelled]:[]};for(const r of e)s[r.status].push(r);return s}const _f=[{status:ve.Review,title:"Review",defaultOpen:!0},{status:ve.Running,title:"Running",defaultOpen:!0},{status:ve.Pending,title:"Pending",defaultOpen:!1},{status:ve.Done,title:"Done",defaultOpen:!1},{status:ve.Cancelled,title:"Cancelled",defaultOpen:!1}];function bo({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:x}=ue(),{preserveDesktopSearch:y}=ga(),_=cl(),[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 X=(Y.querySelector("button")??Y).getBoundingClientRect();return X.width===0||X.height===0?null:new DOMRect(X.left+8,X.bottom+4,$.width,$.height)},[]),M=C.useCallback((I,$,Y,U=!1)=>{const X=document.createElement("div");X.setAttribute("aria-hidden","true"),X.innerHTML=Y;const z=X.firstElementChild;z&&(z.style.cssText="",z.className=z.className.replace(/\bopacity-\S*/g,"").replace(/\banimate-task-enter\b/g,""),z.style.pointerEvents="none",z.style.width=`${I.width}px`,z.style.height=`${I.height}px`,z.style.margin="0",z.style.backgroundColor="var(--sidebar-accent)",z.style.borderRadius="0.375rem",z.style.boxShadow="0 6px 16px rgba(15, 23, 42, 0.10), 0 1px 3px rgba(15, 23, 42, 0.08)",z.style.opacity="0.96",z.style.transition="none",z.setAttribute("tabindex","-1")),Object.assign(X.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(X),j.current.add(X);const N=$.left-I.left,W=$.top-I.top;X.animate([{transform:"translate(0, 0)",opacity:.96,offset:0},{transform:`translate(${N}px, ${W}px)`,opacity:U?.12:.96,offset:1}],{duration:U?vf:gf,easing:"cubic-bezier(0.2, 0, 0, 1)",fill:"forwards"}).finished.then(()=>R(X),()=>R(X))},[R]);C.useLayoutEffect(()=>{const I=window.matchMedia("(prefers-reduced-motion: reduce)").matches,$=new Map;for(const Y of L){const U=k.current.get(Y.id);if(!U)continue;const X={status:Y.status,rect:U.getBoundingClientRect(),html:U.outerHTML};if($.set(Y.id,X),I)continue;const z=S.current.get(Y.id);if(!z||z.status===Y.status)continue;const N=X.rect.left-z.rect.left,W=X.rect.top-z.rect.top;Math.abs(N)<1&&Math.abs(W)<1||M(z.rect,X.rect,z.html)}if(!I)for(const[Y,U]of S.current){if($.has(Y))continue;const X=L.find(N=>N.id===Y);if(!X||X.status===U.status)continue;const z=T(X.status,U.rect);z&&M(U.rect,z,U.html,!0)}S.current=$},[L,M,T]),C.useEffect(()=>()=>{for(const I of j.current)I.remove();j.current.clear()},[]);const B=Iu(Ou(kn,{activationConstraint:{distance:8}})),D=C.useCallback(I=>{const $=I.active.data.current?.task,Y=I.active.data.current?.fromStatus;$&&h($),Y&&f(Y)},[]),F=C.useCallback(I=>{h(null),f(null);const{active:$,over:Y}=I;if(!Y)return;const U=$.data.current?.task,X=$.data.current?.fromStatus,z=Y.data.current?.status;!U||!X||!z||U.projectArchivedAt||X!==z&&c?.(U.id,z)},[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:x("New Project"),children:[t.jsx(jd,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:x("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:x(O?"New Task":"Deleted projects are read-only"),children:[t.jsx(Sd,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:x("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:x("Search"),children:[t.jsx(hn,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:x("Search")})]}),t.jsxs(id,{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:x("对话"),children:[t.jsx(Kr,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:x("对话")})]})]}),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(Ms,{size:36,className:"text-muted-foreground/40 mb-3",strokeWidth:1.5}),t.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:x("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:x("New Task")}):null]}):t.jsx(fl.Provider,{value:E,children:t.jsxs(Lh,{sensors:B,onDragStart:D,onDragEnd:F,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:_},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:x("{count} tasks",{count:L.length})}),p?t.jsx("button",{onClick:()=>m(null),className:"hover:text-foreground underline decoration-border underline-offset-2",children:x("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:x("{count} tasks",{count:0})})}),t.jsx(pf,{isOpen:b,onClose:()=>w(!1),tasks:L,projects:s,onSelectTask:o})]})}const bf=10,yf=24,ml=bf*yf,Sf=8;function wf(e,s=ml){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 ti=new Set(["RUNNING","WAITING_ROOM_REPLY","QUEUED","SESSION_ENDED"]);function yo(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=>ti.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=yo(m.sortTime)-yo(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}=ue();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}=ue(),[u,c]=C.useState(Mf),g=C.useMemo(()=>e.filter(y=>ti.has(y.status)).sort((y,_)=>Date.parse(_.updatedAt??_.createdAt??"")-Date.parse(y.updatedAt??y.createdAt??"")),[e]);if(g.length===0)return null;const x=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:x})]}),u?t.jsx(yt,{size:15,className:"shrink-0 text-neutral-400"}):t.jsx(Ba,{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 _=s.get(y.memberId),a=r.get(y.workRequestId),h=!!(y.sessionId&&o),d=!!_,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:ee("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(zt,{name:_?.name??l("Agent"),avatar:_?.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:_?.name??l("Agent")}),t.jsx("span",{className:ee("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")} ${_?.name??l("Agent")}`,children:t.jsx(zi,{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")} ${_?.name??l("Agent")}`,children:t.jsx(As,{size:12})})]}),d&&f&&_&&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(Me,{type:"button",size:"xs",variant:"outline",disabled:b,onClick:()=>p(_.id,!1),children:[t.jsx(As,{size:11}),t.jsx("span",{children:l(b?"Stopping":"Stop only")})]}),t.jsxs(Me,{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(_.id,!0),children:[t.jsx(za,{size:11}),t.jsx("span",{children:l(b?"Stopping":"Stop + clear queue")})]})]})]},y.id)})})]})}const zr=rr(),Lf=240,Pf=/(^|\n)(```|~~~)[^\S\r\n]*mermaid(?:[\s\r\n]|$)/i;let qi=null;function Of(e){return Pf.test(e)}function If(){return qi??=od(async()=>{const{mermaid:e}=await import("./index-CGMjRoF7.js").then(s=>s.bm);return{mermaid:e}},__vite__mapDeps([0,1,2])).then(({mermaid:e})=>({mermaid:e})),qi}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(()=>{qi=null,p&&o(void 0)}),()=>{p=!1}},[s]),s?r:void 0}let So=0;function Ff(e,s){return So+=1,{id:`pending-room-message-${Date.now()}-${So}`,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 pl(e){return"pendingStatus"in e}const zf=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${zr}/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 Ki(e,s){if(s.length===0)return e;const r=new Set(s.map(Hf));return e.split(`
|
|
14
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
15
|
`).replace(/\n{3,}/g,`
|
|
16
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
|
|
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 Xi(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 wo(e){return e.membershipStatus!=="REMOVED"}function Xf(e,s){return e.label??s.get(e.memberId)?.name??e.memberId}function Yf(e,s){return(e.recipientMemberIds??[]).map(r=>s.get(r)?.name??r)}function Vf(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:ee("team-room-message-markdown prose prose-sm max-w-none break-words [overflow-wrap:anywhere]","prose-p:my-2 prose-p:first:mt-0 prose-p:last:mb-0 prose-p:leading-6","prose-ul:my-2 prose-ol:my-2 prose-li:my-1 prose-li:pl-0 prose-li:leading-6 prose-li:marker:text-neutral-400","prose-blockquote:my-2 prose-blockquote:border-l-2 prose-blockquote:border-neutral-300 prose-blockquote:pl-3 prose-blockquote:text-neutral-600","prose-pre:my-3 prose-pre:max-w-full prose-pre:overflow-x-auto prose-pre:rounded-md prose-pre:border prose-pre:border-neutral-800 prose-pre:bg-neutral-950 prose-pre:p-3 prose-pre:text-xs prose-pre:leading-relaxed prose-pre:shadow-inner","prose-code:break-words prose-code:rounded prose-code:bg-neutral-100 prose-code:px-1 prose-code:py-0.5 prose-code:text-[0.9em] prose-code:font-medium prose-code:text-neutral-800","prose-pre:prose-code:bg-transparent prose-pre:prose-code:p-0 prose-pre:prose-code:text-neutral-100","prose-headings:mb-2 prose-headings:mt-3 prose-headings:font-semibold prose-headings:leading-snug","prose-a:text-blue-600 prose-a:underline-offset-2 hover:prose-a:text-blue-700","prose-hr:my-3 prose-hr:border-neutral-200",s?["text-white prose-strong:text-white prose-headings:text-white prose-blockquote:border-white/30 prose-blockquote:text-neutral-200","prose-code:bg-white/15 prose-code:text-white prose-pre:border-neutral-700 prose-a:text-blue-200 hover:prose-a:text-blue-100 prose-hr:border-white/15"]:"text-neutral-800 prose-strong:text-neutral-900"),children:t.jsx(cn,{urlTransform:zf,components:dn,plugins:r,controls:r?yd: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=`${zr}${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(ka,{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(rn,{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}=bd(v),l=i.length>0?Ki(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(os,{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(Wd,{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:`${zr}${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:`${zr}${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(rn,{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
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}=ue(),v=C.useId(),i=C.useRef(null),[n,l]=C.useState(null),[u,c]=C.useState(!1),[g,x]=C.useState(null),y=rd(e.teamRunId,e.id,!1),_=y.data?.content,a=_?qi(_,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(x(null),b){l({messageId:e.id,content:d,expanded:!1});return}if(f&&!_){const R=await y.refetch();if(R.error){x(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,_,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:ee("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:ee("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:ee("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:ee("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:ee("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(zt,{name:e,avatar:s??null,className:"mt-0.5 h-8 w-8 text-[11px]"}),t.jsxs("div",{className:ee("flex min-w-0 max-w-[min(86%,46rem)] flex-col",o?"items-end":"items-start"),children:[t.jsxs("div",{className:ee("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:ee("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(zt,{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}=ue(),n=e.senderType==="user",l=e.senderType==="system",u=fl(e)?e.pendingStatus:null,c=e.mentions??[],g=e.workRequestIds?.length??0,x=e.visibility==="PRIVATE",y=x?Yf(e,p):[],_=t.jsxs(t.Fragment,{children:[!n&&!l&&o&&t.jsx(rm,{provider:o}),x&&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:_,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}=ue();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(Me,{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(Kt,{size:12}),t.jsx("span",{children:i(m?"Approving":"Approve")})]}),t.jsxs(Me,{type:"button",size:"xs",variant:"outline",disabled:p,onClick:o,children:[t.jsx(os,{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}=ue(),u=pa(e.id),c=ga(e.id),g=va(e.id),[x,y]=C.useState(""),[_,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([]),[M,B]=C.useState(null),D=C.useRef(null),F=C.useRef(null),{files:W,addFiles:A,removeFile:O,clear:P,restoreFiles:I,buildMarkdownLinks:$,getDoneAttachments:Y,isUploading:U}=cn(),X=W.some(G=>G.status==="done"&&G.attachment),[z,N]=C.useState(null),{scrollRef:H,contentRef:K,isAtBottom:q,scrollToBottom:ie}=dn({resize:"smooth",initial:"instant"}),{data:Q}=Ds(),se=C.useMemo(()=>{const G=new Map;for(const te of Q??[])G.set(te.provider.id,te.provider);return G},[Q]),pe=C.useMemo(()=>new Map((e.members??[]).map(G=>[G.id,G])),[e.members]),ge=C.useMemo(()=>(e.members??[]).filter(So),[e.members]),ze=C.useMemo(()=>new Map((e.invocations??[]).map(G=>[G.id,G])),[e.invocations]),de=C.useMemo(()=>{const G=new Set(s.map(fe=>fe.id)),te=L.filter(fe=>!G.has(fe.id));return[...s,...te].sort((fe,_e)=>{const V=Date.parse(fe.createdAt??""),re=Date.parse(_e.createdAt??"");return(Number.isNaN(V)?0:V)-(Number.isNaN(re)?0:re)})},[s,L]),Ge=C.useMemo(()=>new Map((e.workRequests??[]).map(G=>[G.id,G])),[e.workRequests]),Ee=C.useMemo(()=>jf(de,e.workRequests??[],e.invocations??[]),[de,e.invocations,e.workRequests]),Ke=C.useMemo(()=>(e.invocations??[]).filter(G=>ei.has(G.status)),[e.invocations]),He=C.useMemo(()=>w.map(G=>pe.get(G)).filter(G=>!!G).filter(So),[pe,w]),De=C.useMemo(()=>{const G=h?.query??"";return ge.filter(te=>Kf(te,G)).sort((te,fe)=>{const _e=w.includes(te.id),V=w.includes(fe.id);return _e!==V?_e?1:-1:te.name.localeCompare(fe.name)})},[ge,h?.query,w]),We=!r&&(_||!!h)&&De.length>0,Te=C.useCallback((G,te)=>{if(te==null){d(null);return}d(qf(G,te)),b(0)},[]),Xe=C.useCallback(G=>{k(re=>Cf(re,G.id));const te=`@${G.name} `;if(h){const re=`${x.slice(0,h.start)}${te}${x.slice(h.end)}`,ne=h.start+te.length;y(re),d(null),a(!1),requestAnimationFrame(()=>{D.current?.focus(),D.current?.setSelectionRange(ne,ne)});return}const fe=x.length===0||/\s$/.test(x)?"":" ",_e=`${x}${fe}${te}`,V=_e.length;y(_e),a(!1),requestAnimationFrame(()=>{D.current?.focus(),D.current?.setSelectionRange(V,V)})},[x,h]),Re=C.useCallback(G=>{k(te=>kf(te,G))},[]),je=C.useCallback(G=>{const te=G.target.value;y(te),R(null);const fe=G.target;fe.style.height="auto",fe.style.height=`${Math.max(i?40:72,Math.min(fe.scrollHeight,i?140:240))}px`,a(!1),Te(te,fe.selectionStart)},[i,Te]),Ne=C.useCallback(G=>{const te=G.target.files;te&&te.length>0&&(A(Array.from(te)),R(null)),G.target.value=""},[A]),et=C.useCallback(G=>{const te=[];for(const fe of G.clipboardData.items)if(fe.kind==="file"){const _e=fe.getAsFile();_e&&te.push(_e)}te.length>0&&(G.preventDefault(),A(te),R(null))},[A]),Ae=C.useCallback(async()=>{if(r||j||U)return;const G=$(),te=Y().map(me=>me.id),fe=Ef(w,ge),_e=tm({draft:x,attachmentMarkdown:G,attachmentIds:te,mentions:fe});if(!_e||!x.trim()&&!X)return;const V=Ff(e.id,_e),re=x,ne=w,ae=W;T(me=>[...me,V]),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(_e);T(we=>we.filter(ye=>ye.id!==V.id)),me&&typeof me=="object"&&"id"in me&&requestAnimationFrame(()=>ie())}catch(me){const we=me instanceof Error?me.message:"Failed to send room message";T(ye=>ye.map(Ce=>Ce.id===V.id?{...Ce,pendingStatus:"failed",error:we}:Ce)),y(ye=>ye.length===0?re:ye),k(ye=>ye.length===0?ne:ye),I(ae),R(we),requestAnimationFrame(()=>ie())}finally{S(!1)}},[ge,W,$,P,i,x,Y,X,j,U,p,r,I,ie,w,e.id]),$e=C.useCallback(G=>{const te=G.nativeEvent.isComposing||G.nativeEvent.keyCode===229;if(We){if(G.key==="ArrowDown"){G.preventDefault(),b(fe=>(fe+1)%De.length);return}if(G.key==="ArrowUp"){G.preventDefault(),b(fe=>(fe-1+De.length)%De.length);return}if(G.key==="Enter"&&!te||G.key==="Tab"){G.preventDefault();const fe=De[f]??De[0];fe&&Xe(fe);return}if(G.key==="Escape"){G.preventDefault(),d(null),a(!1);return}}G.key==="Enter"&&!G.shiftKey&&!G.repeat&&!te&&(G.preventDefault(),Ae())},[Xe,Ae,f,De,We]);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 he=u.isError?u.error:c.isError?c.error:null,ft=u.isPending||c.isPending,wt=C.useCallback((G,te)=>{g.mutate({memberId:G,cancelQueued:te},{onSuccess:()=>B(null)})},[g]);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[z&&t.jsx(em,{images:z.images,index:z.index,onClose:()=>N(null),onSelect:G=>N(te=>te&&{...te,index:G})}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:H,className:ee("h-full overflow-y-auto scrollbar-app-thin bg-white",i?"px-3 py-3":"px-4 py-4"),children:t.jsxs("div",{ref:K,className:ee(i?"space-y-2.5":"space-y-3",n&&"max-w-4xl mx-auto"),children:[Ee.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")})]}):Ee.map(G=>{if(G.kind==="pendingApproval"){const ne=G.request,ae=pe.get(ne.targetMemberId),me=u.isPending&&u.variables===ne.id,we=c.isPending&&c.variables===ne.id;return t.jsx(nm,{request:ne,member:ae,onApprove:()=>u.mutate(ne.id),onReject:()=>c.mutate(ne.id),isActionPending:ft,isApprovePending:me,isRejectPending:we},G.key)}const te=G.message,fe=Gf(te,pe,ze),_e=te.senderType==="user"?l("你"):te.senderType==="system"?l("System"):fe?.name??l("Agent"),V=Vf(te,pe),re=fe?.providerId?se.get(fe.providerId)??null:null;return t.jsx(im,{message:te,senderName:_e,senderMember:fe,senderProvider:re,memberById:pe,displayContent:V,onOpenImage:(ne,ae)=>N({images:ne,index:ae})},G.key)}),he&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Ki(he,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"))})]})}),!q&&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:ee("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:ee(n&&"max-w-4xl mx-auto"),children:[t.jsx(Df,{invocations:Ke,memberById:pe,workRequestById:Ge,onViewInvocationSession:m,onStopMember:wt,isStopPending:g.isPending,stoppingMemberId:g.variables?.memberId??null,stopPromptInvocationId:M,onToggleStopConfirm:G=>B(te=>te===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:[We&&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,te)=>{const fe=w.includes(G.id),_e=te===f;return t.jsxs("button",{type:"button",onMouseEnter:()=>b(te),onMouseDown:V=>{V.preventDefault(),Xe(G)},className:ee("flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors",_e?"bg-neutral-100":"hover:bg-neutral-50"),children:[t.jsx(zt,{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}),fe&&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)})})]}),He.length>0&&t.jsx("div",{className:"flex flex-wrap items-center gap-1.5 border-b border-neutral-100 px-3 py-2",children:He.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:()=>Re(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(os,{size:12})})]},G.id))}),t.jsx(un,{files:W,onRemove:O}),t.jsx("textarea",{ref:D,value:x,rows:i?1:void 0,onChange:je,onKeyDown:$e,onPaste:et,onClick:G=>Te(x,G.currentTarget.selectionStart),onSelect:G=>Te(x,G.currentTarget.selectionStart),placeholder:l("Message the team room..."),className:ee("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:ee("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:F,type:"file",multiple:!0,className:"hidden",onChange:Ne}),t.jsx("button",{type:"button",onClick:()=>F.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:He.length===0&&ge.length===0,title:l("Mention members"),"aria-label":l("Mention members"),className:ee("rounded-lg transition-colors",i?"p-1.5":"p-2",_?"bg-neutral-100 text-neutral-700":"text-neutral-400 hover:bg-neutral-100 hover:text-neutral-600",He.length===0&&ge.length===0?"cursor-not-allowed opacity-50":""),children:t.jsx(Zn,{size:i?15:18})}),He.length>0&&t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[He.length," ",l("selected")]})]}),t.jsx("button",{type:"button",onClick:()=>{Ae()},disabled:r||j||U||!x.trim()&&!X,title:l(U?"Uploading...":j?"发送中...":"发送"),"aria-label":l(U?"Uploading...":j?"发送中...":"发送"),className:ee("rounded-lg transition-all duration-200",i?"p-1.5":"p-2",(x.trim()||X)&&!r&&!j&&!U?"bg-neutral-900 text-white shadow-md hover:bg-black":"cursor-not-allowed bg-transparent text-neutral-300",j||U?"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===Dt.MAIN_DIRECTORY}function fs(e){return e?Mn(e)?"Project directory":e.branchName:"—"}function rs(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 Ws(){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 It({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}=ue(),{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,x]=C.useState(null),[y,_]=C.useState(""),[a,h]=C.useState(Ws()),[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(z=>z.id===b.id)?[...j,b]:j,[b,j]),E=g?j.find(z=>z.id===g)??null:null,R=b?.id===g?b:E,L=y?p.find(z=>z.id===y)??null:null,T=v.isPending||i.isPending||n.isPending,M=S.filter(Xi).length,B=C.useMemo(()=>{const z=m.map(({provider:N,availability:H})=>({value:N.id,label:N.name+(H.type==="NOT_FOUND"?o(" (不可用)"):""),icon:t.jsx(Kr,{agentType:N.agentType,className:"size-4"}),disabled:H.type==="NOT_FOUND"}));return a.providerId&&!z.some(N=>N.value===a.providerId)&&z.unshift({value:a.providerId,label:`${a.providerId}${o(" (不可用)")}`,disabled:!0}),z},[a.providerId,m,o]);C.useEffect(()=>{if(!e){l.current=!1,w(null);return}if(l.current)return;l.current=!0;const z=S[0]??null;c(z?"edit":"add-preset"),x(z?.id??null),_(""),h(z?Ss(z):Ws()),f(null)},[S,e]),C.useEffect(()=>{b&&j.some(z=>z.id===b.id)&&w(null)},[b,j]),C.useEffect(()=>{u==="add-preset"&&L&&h(yi(L))},[u,L]);const D=(z,N)=>{h(H=>({...H,[z]:N}))},F=(z,N)=>{h(H=>({...H,capabilities:{...H.capabilities,[z]:N}}))},W=z=>{c("edit"),x(z.id),_(""),h(Ss(z))},A=()=>{c("add-preset"),x(null);const z=L??p[0]??null;_(z?.id??""),h(z?yi(z):Ws())},O=()=>{c("add-custom"),x(null),_(""),h(Ws())},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});ht.success(o("Member added")),w(N),c("edit"),x(N.id),_(""),h(Ss(N));return}const z=um(a);if(!z.name||!z.providerId||!z.rolePrompt){ht.error(o("Name, provider, and role prompt are required"));return}if(u==="add-custom"){const N=await v.mutateAsync({member:z});ht.success(o("Member added")),w(N),c("edit"),x(N.id),h(Ss(N));return}if(R){const N=await i.mutateAsync({memberId:R.id,data:z});ht.success(o("Member updated")),w(H=>H?.id===N.id?N:H),x(N.id),h(Ss(N))}}catch(z){ht.error(Co(z,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 z=S.find(N=>N.id!==d.id)??null;x(z?.id??null),c(z?"edit":"add-preset"),h(z?Ss(z):Ws())}w(z=>z?.id===d.id?null:z),f(null),ht.success(o("Member removed"))}catch(z){ht.error(Co(z,o("Failed to remove member")))}},U=()=>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(Me,{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(Me,{type:"button",variant:"outline",size:"sm",onClick:O,disabled:T,children:[t.jsx(ss,{size:13}),o("Custom member")]})}):t.jsx("div",{className:"grid grid-cols-1 gap-2 xl:grid-cols-2",children:p.map(z=>{const N=y===z.id;return t.jsxs("button",{type:"button",onClick:()=>{_(z.id),h(yi(z))},className:ee("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(zt,{name:z.name,avatar:z.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:z.name}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:z.providerId}),t.jsxs("span",{className:"mt-1 block truncate text-[10px] text-neutral-400",children:[o(jo(z.workspacePolicy))," · ",o(hm(z.sessionPolicy))]})]}),N?t.jsx(Kt,{size:16,className:"shrink-0 text-neutral-900"}):null]},z.id)})})})]}),X=()=>{const z=u==="edit";return z&&!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(Me,{type:"button",variant:"outline",size:"sm",onClick:A,disabled:T,children:[t.jsx(ss,{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:[z?t.jsx(za,{size:15,className:"text-neutral-500"}):t.jsx(ss,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o(z?"Edit member":"Custom member")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:o(z?"Provider, role, workspace, and session changes apply to future work only.":"Create a one-off member snapshot for this TeamRun.")})]}),z&&R?t.jsxs(Me,{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(Me,{type:"button",variant:"outline",size:"sm",onClick:A,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:[z&&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(zt,{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:ee("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(It,{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(It,{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(It,{children:o("Provider")}),t.jsx(es,{value:a.providerId,onChange:N=>D("providerId",N),options:B})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(It,{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(It,{children:o("Workspace policy")}),t.jsx(es,{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(It,{children:o("Trigger policy")}),t.jsx(es,{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(It,{children:o("Session policy")}),t.jsx(es,{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(It,{children:o("Queue policy")}),t.jsx(es,{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(It,{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(It,{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:H=>F(N.key,H.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(Me,{type:"button",variant:"outline",onClick:s,disabled:T,children:o("Close")}),t.jsx(Me,{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")," · ",M," ",o("working")]})]}),t.jsx(Me,{type:"button",size:"icon-sm",variant:"outline",onClick:A,disabled:T,title:o("Add member"),children:t.jsx(ss,{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(z=>{const N=u==="edit"&&g===z.id;return t.jsxs("button",{type:"button",onClick:()=>W(z),className:ee("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(zt,{name:z.name,avatar:z.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:ee("h-1.5 w-1.5 shrink-0 rounded-full",Eo(z))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:z.name})]}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:z.providerId})]}),t.jsx(uu,{size:13,className:ee("shrink-0 text-neutral-300 transition-opacity",N?"opacity-100":"opacity-0 group-hover:opacity-100")})]},z.id)})})}),t.jsx("div",{className:"border-t border-neutral-200 p-2",children:t.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[t.jsxs("button",{type:"button",onClick:A,disabled:T,className:ee("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:ee("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"?U():X()})]})}),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}=ue(),v=pa(e.id),i=ga(e.id),n=va(e.id),[l,u]=C.useState(null),[c,g]=C.useState(null),[x,y]=C.useState(!1),[_,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,F)=>Date.parse(F.updatedAt??F.createdAt??"")-Date.parse(D.updatedAt??D.createdAt??"")),[f]),S=C.useMemo(()=>[...f].filter(D=>D.status==="QUEUED").sort((D,F)=>Date.parse(F.updatedAt??F.createdAt??"")-Date.parse(D.updatedAt??D.createdAt??"")),[f]),E=C.useMemo(()=>[...h].map(D=>({member:D,status:xm(D.status)})).sort((D,F)=>Ro[D.status]-Ro[F.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),M=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:_,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:M.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 F=h.find(O=>O.id===D.targetMemberId),W=v.isPending&&v.variables===D.id,A=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(zt,{name:F?.name??"Agent",avatar:F?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:F?.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(Kt,{size:11}),t.jsx("span",{className:"truncate",children:m(W?"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(os,{size:11}),t.jsx("span",{className:"truncate",children:m(A?"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:F})=>{const W=Nm(D,b),A=jm(b.filter(X=>X.memberId===D.id)),O=W?k.get(W.workRequestId):void 0,P=c===D.id,I=F==="running"||F==="waiting room reply",$=I&&!!W,Y=l===D.id,U=n.isPending&&n.variables?.memberId===D.id;return t.jsxs("div",{className:ee("bg-white",P&&"bg-neutral-50/50"),children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[t.jsx(zt,{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:ee("h-1.5 w-1.5 shrink-0 rounded-full",Sm(F))}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:D.name}),t.jsx("span",{className:ee("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",ym(F)),children:m(bm(F))})]}),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})}),W?.sessionId&&p&&t.jsx("button",{type:"button",onClick:()=>p(W.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:U&&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:U&&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:A.length})]}),A.length===0?t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:m("No invocations yet")}):t.jsx("div",{className:"space-y-1",children:A.map(X=>{const z=k.get(X.workRequestId),N=!!(X.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:ee("rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Cm(X.status)),children:X.status}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:Si(X.updatedAt??X.createdAt)})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:_r(z)||X.workRequestId})]}),N&&t.jsxs("button",{type:"button",onClick:()=>X.sessionId&&p?.(X.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")})]})]})},X.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 F=h.find(W=>W.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(zt,{name:F?.name??"Agent",avatar:F?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:F?.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":x,"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}),x?t.jsx(yt,{size:13,className:"text-neutral-400"}):t.jsx(Mt,{size:13,className:"text-neutral-400"})]})]}),x&&t.jsx("div",{className:"space-y-1.5",children:w.map(D=>{const F=r===D.workspace.id;return t.jsx("div",{className:ee("rounded-md border bg-white px-3 py-2",F?"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:ee("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:ee("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||F,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:[F?t.jsx(Kt,{size:11}):t.jsx(Aa,{size:11}),t.jsx("span",{children:m(F?"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),x=n(9924),y=n(844),_=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 x.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((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(`
|
|
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}=ue(),v=C.useId(),i=C.useRef(null),[n,l]=C.useState(null),[u,c]=C.useState(!1),[g,x]=C.useState(null),y=nd(e.teamRunId,e.id,!1),_=y.data?.content,a=_?Ki(_,r):void 0,d=!!(a&&a!==s)?a:s,f=!!(e.isTruncated&&!pl(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(x(null),b){l({messageId:e.id,content:d,expanded:!1});return}if(f&&!_){const R=await y.refetch();if(R.error){x(Xi(R.error,m("Failed to load full message")));return}const L=R.data?.content?Ki(R.data.content,r):d;l({messageId:e.id,content:L,expanded:!0});return}l({messageId:e.id,content:d,expanded:!0})},[r,f,_,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:ee("relative transition-[max-height] duration-200 ease-out",j?"overflow-hidden":""),style:j?{maxHeight:ml}:void 0,children:[t.jsx(Qf,{content:d,isUser:o}),j&&t.jsx("div",{className:ee("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:ee("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(Ba,{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:ee("mt-1 text-xs",p==="user"?"text-red-200":"text-red-600"),children:g})]})}function gl({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:ee("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(zt,{name:e,avatar:s??null,className:"mt-0.5 h-8 w-8 text-[11px]"}),t.jsxs("div",{className:ee("flex min-w-0 max-w-[min(86%,46rem)] flex-col",o?"items-end":"items-start"),children:[t.jsxs("div",{className:ee("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:ee("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(zt,{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(Xr,{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}=ue(),n=e.senderType==="user",l=e.senderType==="system",u=pl(e)?e.pendingStatus:null,c=e.mentions??[],g=e.workRequestIds?.length??0,x=e.visibility==="PRIVATE",y=x?Yf(e,p):[],_=t.jsxs(t.Fragment,{children:[!n&&!l&&o&&t.jsx(rm,{provider:o}),x&&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(tu,{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(gl,{senderName:s,avatar:r?.avatar??null,createdAt:e.createdAt,isUser:n,isSystem:l,headerAddon:_,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}=ue();return t.jsx(gl,{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(Me,{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(Kt,{size:12}),t.jsx("span",{children:i(m?"Approving":"Approve")})]}),t.jsxs(Me,{type:"button",size:"xs",variant:"outline",disabled:p,onClick:o,children:[t.jsx(os,{size:12}),t.jsx("span",{children:i(v?"Rejecting":"Reject")})]})]})]})})}function vl({teamRun:e,messages:s,readOnly:r,readOnlyMessage:o,onSendMessage:p,onViewInvocationSession:m,changeSummaryBar:v,compactComposer:i,centered:n}){const{t:l}=ue(),u=va(e.id),c=xa(e.id),g=_a(e.id),[x,y]=C.useState(""),[_,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([]),[M,B]=C.useState(null),D=C.useRef(null),F=C.useRef(null),{files:H,addFiles:A,removeFile:O,clear:P,restoreFiles:I,buildMarkdownLinks:$,getDoneAttachments:Y,isUploading:U}=an(),X=H.some(G=>G.status==="done"&&G.attachment),[z,N]=C.useState(null),{scrollRef:W,contentRef:K,isAtBottom:q,scrollToBottom:ie}=fn({resize:"smooth",initial:"instant"}),{data:Q}=Ds(),se=C.useMemo(()=>{const G=new Map;for(const te of Q??[])G.set(te.provider.id,te.provider);return G},[Q]),pe=C.useMemo(()=>new Map((e.members??[]).map(G=>[G.id,G])),[e.members]),ge=C.useMemo(()=>(e.members??[]).filter(wo),[e.members]),Fe=C.useMemo(()=>new Map((e.invocations??[]).map(G=>[G.id,G])),[e.invocations]),de=C.useMemo(()=>{const G=new Set(s.map(fe=>fe.id)),te=L.filter(fe=>!G.has(fe.id));return[...s,...te].sort((fe,_e)=>{const V=Date.parse(fe.createdAt??""),re=Date.parse(_e.createdAt??"");return(Number.isNaN(V)?0:V)-(Number.isNaN(re)?0:re)})},[s,L]),Ge=C.useMemo(()=>new Map((e.workRequests??[]).map(G=>[G.id,G])),[e.workRequests]),Ee=C.useMemo(()=>jf(de,e.workRequests??[],e.invocations??[]),[de,e.invocations,e.workRequests]),Ke=C.useMemo(()=>(e.invocations??[]).filter(G=>ti.has(G.status)),[e.invocations]),ze=C.useMemo(()=>w.map(G=>pe.get(G)).filter(G=>!!G).filter(wo),[pe,w]),De=C.useMemo(()=>{const G=h?.query??"";return ge.filter(te=>Kf(te,G)).sort((te,fe)=>{const _e=w.includes(te.id),V=w.includes(fe.id);return _e!==V?_e?1:-1:te.name.localeCompare(fe.name)})},[ge,h?.query,w]),We=!r&&(_||!!h)&&De.length>0,Te=C.useCallback((G,te)=>{if(te==null){d(null);return}d(qf(G,te)),b(0)},[]),Xe=C.useCallback(G=>{k(re=>Cf(re,G.id));const te=`@${G.name} `;if(h){const re=`${x.slice(0,h.start)}${te}${x.slice(h.end)}`,ne=h.start+te.length;y(re),d(null),a(!1),requestAnimationFrame(()=>{D.current?.focus(),D.current?.setSelectionRange(ne,ne)});return}const fe=x.length===0||/\s$/.test(x)?"":" ",_e=`${x}${fe}${te}`,V=_e.length;y(_e),a(!1),requestAnimationFrame(()=>{D.current?.focus(),D.current?.setSelectionRange(V,V)})},[x,h]),Re=C.useCallback(G=>{k(te=>kf(te,G))},[]),je=C.useCallback(G=>{const te=G.target.value;y(te),R(null);const fe=G.target;fe.style.height="auto",fe.style.height=`${Math.max(i?40:72,Math.min(fe.scrollHeight,i?140:240))}px`,a(!1),Te(te,fe.selectionStart)},[i,Te]),Ne=C.useCallback(G=>{const te=G.target.files;te&&te.length>0&&(A(Array.from(te)),R(null)),G.target.value=""},[A]),et=C.useCallback(G=>{const te=[];for(const fe of G.clipboardData.items)if(fe.kind==="file"){const _e=fe.getAsFile();_e&&te.push(_e)}te.length>0&&(G.preventDefault(),A(te),R(null))},[A]),Ae=C.useCallback(async()=>{if(r||j||U)return;const G=$(),te=Y().map(me=>me.id),fe=Ef(w,ge),_e=tm({draft:x,attachmentMarkdown:G,attachmentIds:te,mentions:fe});if(!_e||!x.trim()&&!X)return;const V=Ff(e.id,_e),re=x,ne=w,ae=H;T(me=>[...me,V]),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(_e);T(we=>we.filter(ye=>ye.id!==V.id)),me&&typeof me=="object"&&"id"in me&&requestAnimationFrame(()=>ie())}catch(me){const we=me instanceof Error?me.message:"Failed to send room message";T(ye=>ye.map(Ce=>Ce.id===V.id?{...Ce,pendingStatus:"failed",error:we}:Ce)),y(ye=>ye.length===0?re:ye),k(ye=>ye.length===0?ne:ye),I(ae),R(we),requestAnimationFrame(()=>ie())}finally{S(!1)}},[ge,H,$,P,i,x,Y,X,j,U,p,r,I,ie,w,e.id]),He=C.useCallback(G=>{const te=G.nativeEvent.isComposing||G.nativeEvent.keyCode===229;if(We){if(G.key==="ArrowDown"){G.preventDefault(),b(fe=>(fe+1)%De.length);return}if(G.key==="ArrowUp"){G.preventDefault(),b(fe=>(fe-1+De.length)%De.length);return}if(G.key==="Enter"&&!te||G.key==="Tab"){G.preventDefault();const fe=De[f]??De[0];fe&&Xe(fe);return}if(G.key==="Escape"){G.preventDefault(),d(null),a(!1);return}}G.key==="Enter"&&!G.shiftKey&&!G.repeat&&!te&&(G.preventDefault(),Ae())},[Xe,Ae,f,De,We]);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 he=u.isError?u.error:c.isError?c.error:null,ft=u.isPending||c.isPending,wt=C.useCallback((G,te)=>{g.mutate({memberId:G,cancelQueued:te},{onSuccess:()=>B(null)})},[g]);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[z&&t.jsx(em,{images:z.images,index:z.index,onClose:()=>N(null),onSelect:G=>N(te=>te&&{...te,index:G})}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:W,className:ee("h-full overflow-y-auto scrollbar-app-thin bg-white",i?"px-3 py-3":"px-4 py-4"),children:t.jsxs("div",{ref:K,className:ee(i?"space-y-2.5":"space-y-3",n&&"max-w-4xl mx-auto"),children:[Ee.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")})]}):Ee.map(G=>{if(G.kind==="pendingApproval"){const ne=G.request,ae=pe.get(ne.targetMemberId),me=u.isPending&&u.variables===ne.id,we=c.isPending&&c.variables===ne.id;return t.jsx(nm,{request:ne,member:ae,onApprove:()=>u.mutate(ne.id),onReject:()=>c.mutate(ne.id),isActionPending:ft,isApprovePending:me,isRejectPending:we},G.key)}const te=G.message,fe=Gf(te,pe,Fe),_e=te.senderType==="user"?l("你"):te.senderType==="system"?l("System"):fe?.name??l("Agent"),V=Vf(te,pe),re=fe?.providerId?se.get(fe.providerId)??null:null;return t.jsx(im,{message:te,senderName:_e,senderMember:fe,senderProvider:re,memberById:pe,displayContent:V,onOpenImage:(ne,ae)=>N({images:ne,index:ae})},G.key)}),he&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Xi(he,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:Xi(g.error,l("Failed to stop member work"))})]})}),!q&&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:ee("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:ee(n&&"max-w-4xl mx-auto"),children:[t.jsx(Df,{invocations:Ke,memberById:pe,workRequestById:Ge,onViewInvocationSession:m,onStopMember:wt,isStopPending:g.isPending,stoppingMemberId:g.variables?.memberId??null,stopPromptInvocationId:M,onToggleStopConfirm:G=>B(te=>te===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:[We&&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,te)=>{const fe=w.includes(G.id),_e=te===f;return t.jsxs("button",{type:"button",onMouseEnter:()=>b(te),onMouseDown:V=>{V.preventDefault(),Xe(G)},className:ee("flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors",_e?"bg-neutral-100":"hover:bg-neutral-50"),children:[t.jsx(zt,{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}),fe&&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(Jn,{size:15,className:"text-neutral-400"})]},G.id)})})]}),ze.length>0&&t.jsx("div",{className:"flex flex-wrap items-center gap-1.5 border-b border-neutral-100 px-3 py-2",children:ze.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:()=>Re(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(os,{size:12})})]},G.id))}),t.jsx(ln,{files:H,onRemove:O}),t.jsx("textarea",{ref:D,value:x,rows:i?1:void 0,onChange:je,onKeyDown:He,onPaste:et,onClick:G=>Te(x,G.currentTarget.selectionStart),onSelect:G=>Te(x,G.currentTarget.selectionStart),placeholder:l("Message the team room..."),className:ee("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:ee("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:F,type:"file",multiple:!0,className:"hidden",onChange:Ne}),t.jsx("button",{type:"button",onClick:()=>F.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(gn,{size:18})}),t.jsx("button",{type:"button",onClick:()=>{a(G=>!G),d(null),requestAnimationFrame(()=>D.current?.focus())},disabled:ze.length===0&&ge.length===0,title:l("Mention members"),"aria-label":l("Mention members"),className:ee("rounded-lg transition-colors",i?"p-1.5":"p-2",_?"bg-neutral-100 text-neutral-700":"text-neutral-400 hover:bg-neutral-100 hover:text-neutral-600",ze.length===0&&ge.length===0?"cursor-not-allowed opacity-50":""),children:t.jsx(Jn,{size:i?15:18})}),ze.length>0&&t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[ze.length," ",l("selected")]})]}),t.jsx("button",{type:"button",onClick:()=>{Ae()},disabled:r||j||U||!x.trim()&&!X,title:l(U?"Uploading...":j?"发送中...":"发送"),"aria-label":l(U?"Uploading...":j?"发送中...":"发送"),className:ee("rounded-lg transition-all duration-200",i?"p-1.5":"p-2",(x.trim()||X)&&!r&&!j&&!U?"bg-neutral-900 text-white shadow-md hover:bg-black":"cursor-not-allowed bg-transparent text-neutral-300",j||U?"opacity-70":""),children:t.jsx(mn,{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 Co(e){const s=e?Date.parse(e):0;return Number.isNaN(s)?0:s}function Tn(e){return e?.workspaceKind===Dt.MAIN_DIRECTORY}function fs(e){return e?Tn(e)?"Project directory":e.branchName:"—"}function rs(e){return e?.workingDir||e?.worktreePath||void 0}function Dn(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=Tn(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:Co(m.workspace.createdAt)-Co(v.workspace.createdAt)})}function xl(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 _l(e,s){return!e||e.status!==Rt.ACTIVE||Tn(e)?!1:!s||e.parentWorkspaceId?!0:!!(s.mainWorkspaceId&&e.id===s.mainWorkspaceId)}function bl(e,s,r){return e?.parentWorkspaceId?s?.find(p=>p.id===e.parentWorkspaceId)?.branchName??e.baseBranch??r:r}const Ln={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:"合并工作区"}],yl=[{value:"none",label:"无"},{value:"shared",label:"共享"},{value:"dedicated",label:"独占"}],lm=[{value:"MENTION_ONLY",label:"仅提及"},{value:"USER_MESSAGES",label:"所有用户消息"}],Sl=[{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:{...Ln},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:{...Ln,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function Si(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...Ln,...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 ko(e,s){return e instanceof Error?e.message:s}function Eo(e){return e.membershipStatus!=="REMOVED"}function Yi(e){return e.status==="RUNNING"||e.status==="WAITING_ROOM_REPLY"||e.status==="SESSION_ENDED"||e.status==="QUEUED"}function jo(e){return Yi(e)?"bg-emerald-500":e.status==="FAILED"?"bg-red-500":"bg-neutral-300"}function No(e){return yl.find(s=>s.value===e)?.label??e}function hm(e){return Sl.find(s=>s.value===e)?.label??e}function It({children:e}){return t.jsx("span",{className:"text-xs font-medium text-neutral-600",children:e})}function Ro({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}=ue(),{data:p=[]}=ad(),{data:m=[]}=Ds(),v=ld(r.id),i=cd(r.id),n=dd(r.id),l=C.useRef(!1),[u,c]=C.useState("edit"),[g,x]=C.useState(null),[y,_]=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(Eo),[k]),S=C.useMemo(()=>b&&Eo(b)&&!j.some(z=>z.id===b.id)?[...j,b]:j,[b,j]),E=g?j.find(z=>z.id===g)??null:null,R=b?.id===g?b:E,L=y?p.find(z=>z.id===y)??null:null,T=v.isPending||i.isPending||n.isPending,M=S.filter(Yi).length,B=C.useMemo(()=>{const z=m.map(({provider:N,availability:W})=>({value:N.id,label:N.name+(W.type==="NOT_FOUND"?o(" (不可用)"):""),icon:t.jsx(Xr,{agentType:N.agentType,className:"size-4"}),disabled:W.type==="NOT_FOUND"}));return a.providerId&&!z.some(N=>N.value===a.providerId)&&z.unshift({value:a.providerId,label:`${a.providerId}${o(" (不可用)")}`,disabled:!0}),z},[a.providerId,m,o]);C.useEffect(()=>{if(!e){l.current=!1,w(null);return}if(l.current)return;l.current=!0;const z=S[0]??null;c(z?"edit":"add-preset"),x(z?.id??null),_(""),h(z?Ss(z):Hs()),f(null)},[S,e]),C.useEffect(()=>{b&&j.some(z=>z.id===b.id)&&w(null)},[b,j]),C.useEffect(()=>{u==="add-preset"&&L&&h(Si(L))},[u,L]);const D=(z,N)=>{h(W=>({...W,[z]:N}))},F=(z,N)=>{h(W=>({...W,capabilities:{...W.capabilities,[z]:N}}))},H=z=>{c("edit"),x(z.id),_(""),h(Ss(z))},A=()=>{c("add-preset"),x(null);const z=L??p[0]??null;_(z?.id??""),h(z?Si(z):Hs())},O=()=>{c("add-custom"),x(null),_(""),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});ht.success(o("Member added")),w(N),c("edit"),x(N.id),_(""),h(Ss(N));return}const z=um(a);if(!z.name||!z.providerId||!z.rolePrompt){ht.error(o("Name, provider, and role prompt are required"));return}if(u==="add-custom"){const N=await v.mutateAsync({member:z});ht.success(o("Member added")),w(N),c("edit"),x(N.id),h(Ss(N));return}if(R){const N=await i.mutateAsync({memberId:R.id,data:z});ht.success(o("Member updated")),w(W=>W?.id===N.id?N:W),x(N.id),h(Ss(N))}}catch(z){ht.error(ko(z,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 z=S.find(N=>N.id!==d.id)??null;x(z?.id??null),c(z?"edit":"add-preset"),h(z?Ss(z):Hs())}w(z=>z?.id===d.id?null:z),f(null),ht.success(o("Member removed"))}catch(z){ht.error(ko(z,o("Failed to remove member")))}},U=()=>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(_r,{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(Me,{type:"button",variant:"outline",size:"sm",onClick:O,disabled:T,children:[t.jsx(no,{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(Ro,{icon:t.jsx(_r,{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(Me,{type:"button",variant:"outline",size:"sm",onClick:O,disabled:T,children:[t.jsx(ss,{size:13}),o("Custom member")]})}):t.jsx("div",{className:"grid grid-cols-1 gap-2 xl:grid-cols-2",children:p.map(z=>{const N=y===z.id;return t.jsxs("button",{type:"button",onClick:()=>{_(z.id),h(Si(z))},className:ee("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(zt,{name:z.name,avatar:z.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:z.name}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:z.providerId}),t.jsxs("span",{className:"mt-1 block truncate text-[10px] text-neutral-400",children:[o(No(z.workspacePolicy))," · ",o(hm(z.sessionPolicy))]})]}),N?t.jsx(Kt,{size:16,className:"shrink-0 text-neutral-900"}):null]},z.id)})})})]}),X=()=>{const z=u==="edit";return z&&!R?t.jsx("div",{className:"p-5",children:t.jsx(Ro,{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(Me,{type:"button",variant:"outline",size:"sm",onClick:A,disabled:T,children:[t.jsx(ss,{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:[z?t.jsx(Ha,{size:15,className:"text-neutral-500"}):t.jsx(ss,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o(z?"Edit member":"Custom member")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:o(z?"Provider, role, workspace, and session changes apply to future work only.":"Create a one-off member snapshot for this TeamRun.")})]}),z&&R?t.jsxs(Me,{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(vn,{size:13}),o("Remove")]}):t.jsxs(Me,{type:"button",variant:"outline",size:"sm",onClick:A,disabled:T,children:[t.jsx(_r,{size:13}),o("Use preset")]})]})}),t.jsxs("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:[z&&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(zt,{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:ee("h-2 w-2 shrink-0 rounded-full",jo(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(No(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(It,{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(It,{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(It,{children:o("Provider")}),t.jsx(es,{value:a.providerId,onChange:N=>D("providerId",N),options:B})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(It,{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(It,{children:o("Workspace policy")}),t.jsx(es,{value:a.workspacePolicy,onChange:N=>D("workspacePolicy",N),options:yl.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(It,{children:o("Trigger policy")}),t.jsx(es,{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(It,{children:o("Session policy")}),t.jsx(es,{value:a.sessionPolicy,onChange:N=>D("sessionPolicy",N),options:Sl.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(It,{children:o("Queue policy")}),t.jsx(es,{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(It,{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(It,{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=>F(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(Me,{type:"button",variant:"outline",onClick:s,disabled:T,children:o("Close")}),t.jsx(Me,{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")," · ",M," ",o("working")]})]}),t.jsx(Me,{type:"button",size:"icon-sm",variant:"outline",onClick:A,disabled:T,title:o("Add member"),children:t.jsx(ss,{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(z=>{const N=u==="edit"&&g===z.id;return t.jsxs("button",{type:"button",onClick:()=>H(z),className:ee("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(zt,{name:z.name,avatar:z.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:ee("h-1.5 w-1.5 shrink-0 rounded-full",jo(z))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:z.name})]}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:z.providerId})]}),t.jsx(hu,{size:13,className:ee("shrink-0 text-neutral-300 transition-opacity",N?"opacity-100":"opacity-0 group-hover:opacity-100")})]},z.id)})})}),t.jsx("div",{className:"border-t border-neutral-200 p-2",children:t.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[t.jsxs("button",{type:"button",onClick:A,disabled:T,className:ee("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(_r,{size:12}),o("Preset")]}),t.jsxs("button",{type:"button",onClick:O,disabled:T,className:ee("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(no,{size:12}),o("Custom")]})]})})]}),t.jsx("section",{className:"flex min-h-0 min-w-0 flex-col",children:u==="add-preset"?U():X()})]})}),t.jsx(un,{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&&Yi(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(ir,{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 Ao={running:0,"waiting room reply":1,queued:2,"session ended":3,"pending approval":4,idle:5,removed:6};function wi(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 Mo(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 br(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&&ti.has(r.status))}function wl({teamRun:e,workspaces:s,selectedWorkspaceId:r,onSelectWorkspace:o,onViewInvocationSession:p}){const{t:m}=ue(),v=va(e.id),i=xa(e.id),n=_a(e.id),[l,u]=C.useState(null),[c,g]=C.useState(null),[x,y]=C.useState(!1),[_,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(()=>Dn(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,F)=>Date.parse(F.updatedAt??F.createdAt??"")-Date.parse(D.updatedAt??D.createdAt??"")),[f]),S=C.useMemo(()=>[...f].filter(D=>D.status==="QUEUED").sort((D,F)=>Date.parse(F.updatedAt??F.createdAt??"")-Date.parse(D.updatedAt??D.createdAt??"")),[f]),E=C.useMemo(()=>[...h].map(D=>({member:D,status:xm(D.status)})).sort((D,F)=>Ao[D.status]-Ao[F.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),M=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:_,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(Ms,{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(Kr,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:M.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 F=h.find(O=>O.id===D.targetMemberId),H=v.isPending&&v.variables===D.id,A=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(zt,{name:F?.name??"Agent",avatar:F?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:F?.name??D.targetMemberId})]}),t.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-neutral-600 line-clamp-2",children:br(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:wi(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(Kt,{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(os,{size:11}),t.jsx("span",{className:"truncate",children:m(A?"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:Mo(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(Ha,{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:F})=>{const H=Nm(D,b),A=jm(b.filter(X=>X.memberId===D.id)),O=H?k.get(H.workRequestId):void 0,P=c===D.id,I=F==="running"||F==="waiting room reply",$=I&&!!H,Y=l===D.id,U=n.isPending&&n.variables?.memberId===D.id;return t.jsxs("div",{className:ee("bg-white",P&&"bg-neutral-50/50"),children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[t.jsx(zt,{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:ee("h-1.5 w-1.5 shrink-0 rounded-full",Sm(F))}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:D.name}),t.jsx("span",{className:ee("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",ym(F)),children:m(bm(F))})]}),I&&O?.instruction&&t.jsx("div",{className:"mt-0.5 truncate pl-3 text-[10px] text-neutral-500",children:br(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(As,{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(zi,{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(As,{size:10}),t.jsx("span",{children:U&&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(za,{size:10}),t.jsx("span",{children:U&&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:A.length})]}),A.length===0?t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:m("No invocations yet")}):t.jsx("div",{className:"space-y-1",children:A.map(X=>{const z=k.get(X.workRequestId),N=!!(X.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:ee("rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Cm(X.status)),children:X.status}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:wi(X.updatedAt??X.createdAt)})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:br(z)||X.workRequestId})]}),N&&t.jsxs("button",{type:"button",onClick:()=>X.sessionId&&p?.(X.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(zi,{size:10}),t.jsx("span",{children:m("Log")})]})]})},X.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:Mo(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 F=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(zt,{name:F?.name??"Agent",avatar:F?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:F?.name??D.targetMemberId})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:br(D)})]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:wi(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":x,"aria-label":m("Workspaces"),children:[t.jsx(Ms,{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}),x?t.jsx(yt,{size:13,className:"text-neutral-400"}):t.jsx(Mt,{size:13,className:"text-neutral-400"})]})]}),x&&t.jsx("div",{className:"space-y-1.5",children:w.map(D=>{const F=r===D.workspace.id;return t.jsx("div",{className:ee("rounded-md border bg-white px-3 py-2",F?"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:ee("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:ee("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||F,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:[F?t.jsx(Kt,{size:11}):t.jsx(Da,{size:11}),t.jsx("span",{children:m(F?"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 Ci={exports:{}},To;function Rm(){return To||(To=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),x=n(9924),y=n(844),_=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 x.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((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
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 _.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
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,x){return x?"\x1B[200~"+g+"\x1B[201~":g}function u(g,x,y,_){g=l(g=n(g),y.decPrivateModes.bracketedPasteMode&&_.rawOptions.ignoreBracketedPasteMode!==!0),y.triggerDataEvent(g,!0),x.value=""}function c(g,x,y){const _=y.getBoundingClientRect(),a=g.clientX-_.left-10,h=g.clientY-_.top-10;x.style.width="20px",x.style.height="20px",x.style.left=`${a}px`,x.style.top=`${h}px`,x.style.zIndex="1000",x.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,x){g.clipboardData&&g.clipboardData.setData("text/plain",x.selectionText),g.preventDefault()},i.handlePasteEvent=function(g,x,y,_){g.stopPropagation(),g.clipboardData&&u(g.clipboardData.getData("text/plain"),x,y,_)},i.paste=u,i.moveTextAreaUnderMouseCursor=c,i.rightClickHandler=function(g,x,y,_,a){c(g,x,y),a&&_.rightClickSelect(g),x.value=_.selectionText,x.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),x=n(844),y=n(2585);let _=i.Linkifier2=class extends x.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,x.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,x.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,x.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=_=l([u(0,y.IBufferService)],_)},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(_,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(_,a,h,d);else for(var k=_.length-1;k>=0;k--)(f=_[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(_,a){return function(h,d){a(h,d,_)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OscLinkProvider=void 0;const c=n(511),g=n(2585);let x=i.OscLinkProvider=class{constructor(_,a,h){this._bufferService=_,this._optionsService=a,this._oscLinkService=h}provideLinks(_,a){var h;const d=this._bufferService.buffer.lines.get(_-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:_},end:{x:R+(E||R!==k-1?0:1),y:_}};let M=!1;if(!b?.allowNonHttpProtocols)try{const B=new URL(L);["http:","https:"].includes(B.protocol)||(M=!0)}catch{M=!0}M||f.push({text:L,range:T,activate:(B,D)=>b?b.activate(B,D,T):y(0,D),hover:(B,D)=>{var F;return(F=b?.hover)===null||F===void 0?void 0:F.call(b,B,D,T)},leave:(B,D)=>{var F;return(F=b?.leave)===null||F===void 0?void 0:F.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(_,a){if(confirm(`Do you want to navigate to ${a}?
|
|
22
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=x=l([u(0,g.IBufferService),u(1,g.IOptionsService),u(2,g.IOscLinkService)],x)},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),x=n(3730),y=n(1680),_=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),M=n(8460),B=n(844),D=n(6114),F=n(8437),W=n(2584),A=n(7399),O=n(5941),P=n(9074),I=n(2585),$=n(5435),Y=n(4567),U=typeof window<"u"?window.document:null;class X 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 M.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new M.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new M.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new M.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new M.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new M.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new M.EventEmitter),this._onBlur=this.register(new M.EventEmitter),this._onA11yCharEmitter=this.register(new M.EventEmitter),this._onA11yTabEmitter=this.register(new M.EventEmitter),this._onWillOpen=this.register(new M.EventEmitter),this._setup(),this.linkifier2=this.register(this._instantiationService.createInstance(c.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(x.OscLinkProvider)),this._decorationService=this._instantiationService.createInstance(P.DecorationService),this._instantiationService.setService(I.IDecorationService,this._decorationService),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((H,K)=>this.refresh(H,K)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((H=>this._reportWindowsOptions(H)))),this.register(this._inputHandler.onColor((H=>this._handleColorEvent(H)))),this.register((0,M.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,M.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,M.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,M.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((H=>this._afterResize(H.cols,H.rows)))),this.register((0,B.toDisposable)((()=>{var H,K;this._customKeyEventHandler=void 0,(K=(H=this.element)===null||H===void 0?void 0:H.parentNode)===null||K===void 0||K.removeChild(this.element)})))}_handleColorEvent(N){if(this._themeService)for(const H of N){let K,q="";switch(H.index){case 256:K="foreground",q="10";break;case 257:K="background",q="11";break;case 258:K="cursor",q="12";break;default:K="ansi",q="4;"+H.index}switch(H.type){case 0:const ie=L.color.toColorRGB(K==="ansi"?this._themeService.colors.ansi[H.index]:this._themeService.colors[K]);this.coreService.triggerDataEvent(`${W.C0.ESC}]${q};${(0,O.toRgbString)(ie)}${W.C1_ESCAPED.ST}`);break;case 1:if(K==="ansi")this._themeService.modifyColors((Q=>Q.ansi[H.index]=L.rgba.toColor(...H.color)));else{const Q=K;this._themeService.modifyColors((se=>se[Q]=L.rgba.toColor(...H.color)))}break;case 2:this._themeService.restoreColor(H.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(W.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(W.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,H=this.buffer.lines.get(N);if(!H)return;const K=Math.min(this.buffer.x,this.cols-1),q=this._renderService.dimensions.css.cell.height,ie=H.getWidth(K),Q=this._renderService.dimensions.css.cell.width*ie,se=this.buffer.y*this._renderService.dimensions.css.cell.height,pe=K*this._renderService.dimensions.css.cell.width;this.textarea.style.left=pe+"px",this.textarea.style.top=se+"px",this.textarea.style.width=Q+"px",this.textarea.style.height=q+"px",this.textarea.style.lineHeight=q+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,u.addDisposableDomListener)(this.element,"copy",(H=>{this.hasSelection()&&(0,l.copyHandler)(H,this._selectionService)})));const N=H=>(0,l.handlePasteEvent)(H,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",(H=>{H.button===2&&(0,l.rightClickHandler)(H,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,u.addDisposableDomListener)(this.element,"contextmenu",(H=>{(0,l.rightClickHandler)(H,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),D.isLinux&&this.register((0,u.addDisposableDomListener)(this.element,"auxclick",(H=>{H.button===1&&(0,l.moveTextAreaUnderMouseCursor)(H,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 H;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 K=U.createDocumentFragment();this._viewportElement=U.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),K.appendChild(this._viewportElement),this._viewportScrollArea=U.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=U.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=U.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),K.appendChild(this.screenElement),this.textarea=U.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,(H=this._document.defaultView)!==null&&H!==void 0?H:window),this._instantiationService.setService(E.ICoreBrowserService,this._coreBrowserService),this.register((0,u.addDisposableDomListener)(this.textarea,"focus",(q=>this._handleTextAreaFocus(q)))),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((q=>this._onRender.fire(q)))),this.onResize((q=>this._renderService.resize(q.cols,q.rows))),this._compositionView=U.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(K);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._mouseService=this._instantiationService.createInstance(k.MouseService),this._instantiationService.setService(E.IMouseService,this._mouseService),this.viewport=this._instantiationService.createInstance(y.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((q=>this.scrollLines(q.amount,q.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((q=>this.scrollLines(q.amount,q.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((q=>this._renderService.handleSelectionChanged(q.start,q.end,q.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((q=>{this.textarea.value=q,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((q=>{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(_.BufferDecorationRenderer,this.screenElement)),this.register((0,u.addDisposableDomListener)(this.element,"mousedown",(q=>this._selectionService.handleMouseDown(q)))),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",(q=>this._handleScreenReaderModeOptionChange(q)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(a.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(q=>{!this._overviewRulerRenderer&&q&&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,H=this.element;function K(Q){const se=N._mouseService.getMouseReportCoords(Q,N.screenElement);if(!se)return!1;let pe,ge;switch(Q.overrideType||Q.type){case"mousemove":ge=32,Q.buttons===void 0?(pe=3,Q.button!==void 0&&(pe=Q.button<3?Q.button:3)):pe=1&Q.buttons?0:4&Q.buttons?1:2&Q.buttons?2:3;break;case"mouseup":ge=0,pe=Q.button<3?Q.button:3;break;case"mousedown":ge=1,pe=Q.button<3?Q.button:3;break;case"wheel":if(N.viewport.getLinesScrolled(Q)===0)return!1;ge=Q.deltaY<0?0:1,pe=4;break;default:return!1}return!(ge===void 0||pe===void 0||pe>4)&&N.coreMouseService.triggerMouseEvent({col:se.col,row:se.row,x:se.x,y:se.y,button:pe,action:ge,ctrl:Q.ctrlKey,alt:Q.altKey,shift:Q.shiftKey})}const q={mouseup:null,wheel:null,mousedrag:null,mousemove:null},ie={mouseup:Q=>(K(Q),Q.buttons||(this._document.removeEventListener("mouseup",q.mouseup),q.mousedrag&&this._document.removeEventListener("mousemove",q.mousedrag)),this.cancel(Q)),wheel:Q=>(K(Q),this.cancel(Q,!0)),mousedrag:Q=>{Q.buttons&&K(Q)},mousemove:Q=>{Q.buttons||K(Q)}};this.register(this.coreMouseService.onProtocolChange((Q=>{Q?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(Q)),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&Q?q.mousemove||(H.addEventListener("mousemove",ie.mousemove),q.mousemove=ie.mousemove):(H.removeEventListener("mousemove",q.mousemove),q.mousemove=null),16&Q?q.wheel||(H.addEventListener("wheel",ie.wheel,{passive:!1}),q.wheel=ie.wheel):(H.removeEventListener("wheel",q.wheel),q.wheel=null),2&Q?q.mouseup||(H.addEventListener("mouseup",ie.mouseup),q.mouseup=ie.mouseup):(this._document.removeEventListener("mouseup",q.mouseup),H.removeEventListener("mouseup",q.mouseup),q.mouseup=null),4&Q?q.mousedrag||(q.mousedrag=ie.mousedrag):(this._document.removeEventListener("mousemove",q.mousedrag),q.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,u.addDisposableDomListener)(H,"mousedown",(Q=>{if(Q.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(Q))return K(Q),q.mouseup&&this._document.addEventListener("mouseup",q.mouseup),q.mousedrag&&this._document.addEventListener("mousemove",q.mousedrag),this.cancel(Q)}))),this.register((0,u.addDisposableDomListener)(H,"wheel",(Q=>{if(!q.wheel){if(!this.buffer.hasScrollback){const se=this.viewport.getLinesScrolled(Q);if(se===0)return;const pe=W.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(Q.deltaY<0?"A":"B");let ge="";for(let ze=0;ze<Math.abs(se);ze++)ge+=pe;return this.coreService.triggerDataEvent(ge,!0),this.cancel(Q,!0)}return this.viewport.handleWheel(Q)?this.cancel(Q):void 0}}),{passive:!1})),this.register((0,u.addDisposableDomListener)(H,"touchstart",(Q=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(Q),this.cancel(Q)}),{passive:!0})),this.register((0,u.addDisposableDomListener)(H,"touchmove",(Q=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(Q)?void 0:this.cancel(Q)}),{passive:!1}))}refresh(N,H){var K;(K=this._renderService)===null||K===void 0||K.refreshRows(N,H)}updateCursorStyle(N){var H;!((H=this._selectionService)===null||H===void 0)&&H.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,H,K=0){var q;K===1?(super.scrollLines(N,H,K),this.refresh(0,this.rows-1)):(q=this.viewport)===null||q===void 0||q.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 H=this._characterJoinerService.register(N);return this.refresh(0,this.rows-1),H}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,H,K){this._selectionService.setSelection(N,H,K)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var N;(N=this._selectionService)===null||N===void 0||N.clearSelection()}selectAll(){var N;(N=this._selectionService)===null||N===void 0||N.selectAll()}selectLines(N,H){var K;(K=this._selectionService)===null||K===void 0||K.selectLines(N,H)}_keyDown(N){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1)return!1;const H=this.browser.isMac&&this.options.macOptionIsMeta&&N.altKey;if(!H&&!this._compositionHelper.keydown(N))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;H||N.key!=="Dead"&&N.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const K=(0,A.evaluateKeyboardEvent)(N,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(N),K.type===3||K.type===2){const q=this.rows-1;return this.scrollLines(K.type===2?-q:q),this.cancel(N,!0)}return K.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,N)||(K.cancel&&this.cancel(N,!0),!K.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):(K.key!==W.C0.ETX&&K.key!==W.C0.CR||(this.textarea.value=""),this._onKey.fire({key:K.key,domEvent:N}),this._showCursor(),this.coreService.triggerDataEvent(K.key,!0),!this.optionsService.rawOptions.screenReaderMode||N.altKey||N.ctrlKey?this.cancel(N,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(N,H){const K=N.isMac&&!this.options.macOptionIsMeta&&H.altKey&&!H.ctrlKey&&!H.metaKey||N.isWindows&&H.altKey&&H.ctrlKey&&!H.metaKey||N.isWindows&&H.getModifierState("AltGraph");return H.type==="keypress"?K:K&&(!H.keyCode||H.keyCode>47)}_keyUp(N){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1||((function(H){return H.keyCode===16||H.keyCode===17||H.keyCode===18})(N)||this.focus(),this.updateCursorStyle(N),this._keyPressHandled=!1)}_keyPress(N){let H;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1)return!1;if(this.cancel(N),N.charCode)H=N.charCode;else if(N.which===null||N.which===void 0)H=N.keyCode;else{if(N.which===0||N.charCode===0)return!1;H=N.which}return!(!H||(N.altKey||N.ctrlKey||N.metaKey)&&!this._isThirdLevelShift(this.browser,N)||(H=String.fromCharCode(H),this._onKey.fire({key:H,domEvent:N}),this._showCursor(),this.coreService.triggerDataEvent(H,!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 H=N.data;return this.coreService.triggerDataEvent(H,!0),this.cancel(N),!0}return!1}resize(N,H){N!==this.cols||H!==this.rows?super.resize(N,H):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(N,H){var K,q;(K=this._charSizeService)===null||K===void 0||K.measure(),(q=this.viewport)===null||q===void 0||q.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 H=1;H<this.rows;H++)this.buffer.lines.push(this.buffer.getBlankLine(F.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,H;this.options.rows=this.rows,this.options.cols=this.cols;const K=this._customKeyEventHandler;this._setup(),super.reset(),(N=this._selectionService)===null||N===void 0||N.reset(),this._decorationService.reset(),(H=this.viewport)===null||H===void 0||H.reset(),this._customKeyEventHandler=K,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(W.C0.ESC+"[I"):this.coreService.triggerDataEvent(W.C0.ESC+"[O")}_reportWindowsOptions(N){if(this._renderService)switch(N){case $.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const H=this._renderService.dimensions.css.canvas.width.toFixed(0),K=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${W.C0.ESC}[4;${K};${H}t`);break;case $.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const q=this._renderService.dimensions.css.cell.width.toFixed(0),ie=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${W.C0.ESC}[6;${ie};${q}t`)}}cancel(N,H){if(this.options.cancelEvents||H)return N.preventDefault(),N.stopPropagation(),!1}}i.Terminal=X},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,x=this._debounceThresholdMS-g;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),x)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const 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),x=n(8460),y=n(844),_=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 x.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,c.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((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,_.IBufferService),u(3,_.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),x=n(844),y=n(2585);let _=i.BufferDecorationRenderer=class extends x.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,x.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(const 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=_=l([u(1,y.IBufferService),u(2,y.IDecorationService),u(3,g.IRenderService)],_)},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),x=n(4725),y=n(844),_=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 M;(M=this._canvas)===null||M===void 0||M.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,_.IBufferService),u(3,_.IDecorationService),u(4,x.IRenderService),u(5,_.IOptionsService),u(6,x.ICoreBrowserService)],f)},2950:function(v,i,n){var l=this&&this.__decorate||function(_,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(_,a,h,d);else for(var k=_.length-1;k>=0;k--)(f=_[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(_,a){return function(h,d){a(h,d,_)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CompositionHelper=void 0;const c=n(4725),g=n(2585),x=n(2584);let y=i.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(_,a,h,d,f,b){this._textarea=_,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(_){this._compositionView.textContent=_.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(_){if(this._isComposing||this._isSendingComposition){if(_.keyCode===229||_.keyCode===16||_.keyCode===17||_.keyCode===18)return!1;this._finalizeComposition(!1)}return _.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(_){if(this._compositionView.classList.remove("active"),this._isComposing=!1,_){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 _=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const a=this._textarea.value,h=a.replace(_,"");this._dataAlreadySent=h,a.length>_.length?this._coreService.triggerDataEvent(h,!0):a.length<_.length?this._coreService.triggerDataEvent(`${x.C0.DEL}`,!0):a.length===_.length&&a!==_&&this._coreService.triggerDataEvent(a,!0)}}),0)}updateCompositionElements(_){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"}_||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(),x=l.getComputedStyle(c),y=parseInt(x.getPropertyValue("padding-left")),_=parseInt(x.getPropertyValue("padding-top"));return[u.clientX-g.left-y,u.clientY-g.top-_]}Object.defineProperty(i,"__esModule",{value:!0}),i.getCoords=i.getCoordsRelativeToElement=void 0,i.getCoordsRelativeToElement=n,i.getCoords=function(l,u,c,g,x,y,_,a,h){if(!y)return;const d=n(l,u,c);return d?(d[0]=Math.ceil((d[0]+(h?_/2:0))/_),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),x),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 M=0;M<Math.abs(L-T);M++){const B=g(j,S)==="A"?-1:1,D=E.buffer.lines.get(L+B*M);D?.isWrapped&&R++}return R})(a,h,d);return _(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 x(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 _(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,M){return u(E,L,T,M).length===0?"":_(x(S,E,S,E-c(E,T),!1,T).length,y("D",M))})(b,w,0,h,d,f)+u(w,h,d,f)+(function(S,E,R,L,T,M){let B;B=u(E,L,T,M).length>0?L-c(L,T):E;const D=L,F=(function(W,A,O,P,I,$){let Y;return Y=u(O,P,I,$).length>0?P-c(P,I):A,W<O&&Y<=P||W>=O&&Y<P?"C":"D"})(S,E,R,L,T,M);return _(x(S,B,R,D,F==="C",T).length,y(F,M))})(b,w,a,h,d,f);let k;if(w===h)return k=b>a?"D":"C",_(Math.abs(b-a),y(k,f));k=w>h?"D":"C";const j=Math.abs(w-h);return _((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,M,B,D){var F,W=arguments.length,A=W<3?M:D===null?D=Object.getOwnPropertyDescriptor(M,B):D;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(T,M,B,D);else for(var O=T.length-1;O>=0;O--)(F=T[O])&&(A=(W<3?F(A):W>3?F(M,B,A):F(M,B))||A);return W>3&&A&&Object.defineProperty(M,B,A),A},u=this&&this.__param||function(T,M){return function(B,D){M(B,D,T)}};Object.defineProperty(i,"__esModule",{value:!0}),i.DomRenderer=void 0;const c=n(3787),g=n(2550),x=n(2223),y=n(6171),_=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,M,B,D,F,W,A,O,P,I){super(),this._element=T,this._screenElement=M,this._viewportElement=B,this._linkifier2=D,this._charSizeService=W,this._optionsService=A,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=F.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 M=`${this._terminalSelector} .${w} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=M,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 M=`${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}`;M+=`${this._terminalSelector} .${w} .xterm-dim { color: ${a.color.multiplyOpacity(T.foreground,.5).css};}`,M+=`${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;}`,M+="@keyframes blink_box_shadow_"+this._terminalClass+" { 50% { border-bottom-style: hidden; }}",M+="@keyframes blink_block_"+this._terminalClass+` { 0% { background-color: ${T.cursor.css}; color: ${T.cursorAccent.css}; } 50% { background-color: inherit; color: ${T.cursor.css}; }}`,M+=`${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);}`,M+=`${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())M+=`${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}; }`;M+=`${this._terminalSelector} .${k}${x.INVERTED_DEFAULT_COLOR} { color: ${a.color.opaque(T.background).css}; }${this._terminalSelector} .${k}${x.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${a.color.multiplyOpacity(a.color.opaque(T.background),.5).css}; }${this._terminalSelector} .${j}${x.INVERTED_DEFAULT_COLOR} { background-color: ${T.foreground.css}; }`,this._themeStyleElement.textContent=M}_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,M){for(let B=this._rowElements.length;B<=M;B++){const D=document.createElement("div");this._rowContainer.appendChild(D),this._rowElements.push(D)}for(;this._rowElements.length>M;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(T,M){this._refreshRowElements(T,M),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,M,B){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(T,M,B),this.renderRows(0,this._bufferService.rows-1),!T||!M)return;const D=T[1]-this._bufferService.buffer.ydisp,F=M[1]-this._bufferService.buffer.ydisp,W=Math.max(D,0),A=Math.min(F,this._bufferService.rows-1);if(W>=this._bufferService.rows||A<0)return;const O=document.createDocumentFragment();if(B){const P=T[0]>M[0];O.appendChild(this._createSelectionElement(W,P?M[0]:T[0],P?T[0]:M[0],A-W+1))}else{const P=D===W?T[0]:0,I=W===F?M[0]:this._bufferService.cols;O.appendChild(this._createSelectionElement(W,P,I));const $=A-W-1;if(O.appendChild(this._createSelectionElement(W+1,0,this._bufferService.cols,$)),W!==A){const Y=F===A?M[0]:this._bufferService.cols;O.appendChild(this._createSelectionElement(A,0,Y))}}this._selectionContainer.appendChild(O)}_createSelectionElement(T,M,B,D=1){const F=document.createElement("div");return F.style.height=D*this.dimensions.css.cell.height+"px",F.style.top=T*this.dimensions.css.cell.height+"px",F.style.left=M*this.dimensions.css.cell.width+"px",F.style.width=this.dimensions.css.cell.width*(B-M)+"px",F}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,M){const B=this._bufferService.buffer,D=B.ybase+B.y,F=Math.min(B.x,this._bufferService.cols-1),W=this._optionsService.rawOptions.cursorBlink,A=this._optionsService.rawOptions.cursorStyle,O=this._optionsService.rawOptions.cursorInactiveStyle;for(let P=T;P<=M;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,A,O,F,W,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,M,B,D,F,W){B<0&&(T=0),D<0&&(M=0);const A=this._bufferService.rows-1;B=Math.max(Math.min(B,A),0),D=Math.max(Math.min(D,A),0),F=Math.min(F,this._bufferService.cols);const O=this._bufferService.buffer,P=O.ybase+O.y,I=Math.min(O.x,F-1),$=this._optionsService.rawOptions.cursorBlink,Y=this._optionsService.rawOptions.cursorStyle,U=this._optionsService.rawOptions.cursorInactiveStyle;for(let X=B;X<=D;++X){const z=X+O.ydisp,N=this._rowElements[X],H=O.lines.get(z);if(!N||!H)break;N.replaceChildren(...this._rowFactory.createRow(H,z,z===P,Y,U,I,$,this.dimensions.css.cell.width,this._widthCache,W?X===B?T:0:-1,W?(X===D?M:F)-1:-1))}}};i.DomRenderer=L=l([u(4,f.IInstantiationService),u(5,_.ICharSizeService),u(6,f.IOptionsService),u(7,f.IBufferService),u(8,_.ICoreBrowserService),u(9,_.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 M=k.length-1;M>=0;M--)(R=k[M])&&(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),x=n(511),y=n(2585),_=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 x.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,M,B,D,F){const W=[],A=this._characterJoinerService.getJoinedCharacters(j),O=this._themeService.colors;let P,I=k.getNoBgTrimmedLength();S&&I<L+1&&(I=L+1);let $=0,Y="",U=0,X=0,z=0,N=!1,H=0,K=!1,q=0;const ie=[],Q=D!==-1&&F!==-1;for(let se=0;se<I;se++){k.loadCell(se,this._workCell);let pe=this._workCell.getWidth();if(pe===0)continue;let ge=!1,ze=se,de=this._workCell;if(A.length>0&&se===A[0][0]){ge=!0;const he=A.shift();de=new h.JoinedCellData(this._workCell,k.translateToString(!0,he[0],he[1]),he[1]-he[0]),ze=he[1]-1,pe=de.getWidth()}const Ge=this._isCellInSelection(se,j),Ee=S&&se===L,Ke=Q&&se>=D&&se<=F;let He=!1;this._decorationService.forEachDecorationAtCell(se,j,void 0,(he=>{He=!0}));let De=de.getChars()||g.WHITESPACE_CELL_CHAR;if(De===" "&&(de.isUnderline()||de.isOverline())&&(De=" "),q=pe*M-B.get(De,de.isBold(),de.isItalic()),P){if($&&(Ge&&K||!Ge&&!K&&de.bg===U)&&(Ge&&K&&O.selectionForeground||de.fg===X)&&de.extended.ext===z&&Ke===N&&q===H&&!Ee&&!ge&&!He){Y+=De,$++;continue}$&&(P.textContent=Y),P=this._document.createElement("span"),$=0,Y=""}else P=this._document.createElement("span");if(U=de.bg,X=de.fg,z=de.extended.ext,N=Ke,H=q,K=Ge,ge&&L>=se&&L<=ze&&(L=se),!this._coreService.isCursorHidden&&Ee){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(de.isBold()&&ie.push("xterm-bold"),de.isItalic()&&ie.push("xterm-italic"),de.isDim()&&ie.push("xterm-dim"),Y=de.isInvisible()?g.WHITESPACE_CELL_CHAR:de.getChars()||g.WHITESPACE_CELL_CHAR,de.isUnderline()&&(ie.push(`xterm-underline-${de.extended.underlineStyle}`),Y===" "&&(Y=" "),!de.isUnderlineColorDefault()))if(de.isUnderlineColorRGB())P.style.textDecorationColor=`rgb(${f.AttributeData.toColorRGB(de.getUnderlineColor()).join(",")})`;else{let he=de.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&de.isBold()&&he<8&&(he+=8),P.style.textDecorationColor=O.ansi[he].css}de.isOverline()&&(ie.push("xterm-overline"),Y===" "&&(Y=" ")),de.isStrikethrough()&&ie.push("xterm-strikethrough"),Ke&&(P.style.textDecoration="underline");let We=de.getFgColor(),Te=de.getFgColorMode(),Xe=de.getBgColor(),Re=de.getBgColorMode();const je=!!de.isInverse();if(je){const he=We;We=Xe,Xe=he;const ft=Te;Te=Re,Re=ft}let Ne,et,Ae,$e=!1;switch(this._decorationService.forEachDecorationAtCell(se,j,void 0,(he=>{he.options.layer!=="top"&&$e||(he.backgroundColorRGB&&(Re=50331648,Xe=he.backgroundColorRGB.rgba>>8&16777215,Ne=he.backgroundColorRGB),he.foregroundColorRGB&&(Te=50331648,We=he.foregroundColorRGB.rgba>>8&16777215,et=he.foregroundColorRGB),$e=he.options.layer==="top")})),!$e&&Ge&&(Ne=this._coreBrowserService.isFocused?O.selectionBackgroundOpaque:O.selectionInactiveBackgroundOpaque,Xe=Ne.rgba>>8&16777215,Re=50331648,$e=!0,O.selectionForeground&&(Te=50331648,We=O.selectionForeground.rgba>>8&16777215,et=O.selectionForeground)),$e&&ie.push("xterm-decoration-top"),Re){case 16777216:case 33554432:Ae=O.ansi[Xe],ie.push(`xterm-bg-${Xe}`);break;case 50331648:Ae=_.rgba.toColor(Xe>>16,Xe>>8&255,255&Xe),this._addStyle(P,`background-color:#${w((Xe>>>0).toString(16),"0",6)}`);break;default:je?(Ae=O.foreground,ie.push(`xterm-bg-${c.INVERTED_DEFAULT_COLOR}`)):Ae=O.background}switch(Ne||de.isDim()&&(Ne=_.color.multiplyOpacity(Ae,.5)),Te){case 16777216:case 33554432:de.isBold()&&We<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(We+=8),this._applyMinimumContrast(P,Ae,O.ansi[We],de,Ne,void 0)||ie.push(`xterm-fg-${We}`);break;case 50331648:const he=_.rgba.toColor(We>>16&255,We>>8&255,255&We);this._applyMinimumContrast(P,Ae,he,de,Ne,et)||this._addStyle(P,`color:#${w(We.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(P,Ae,O.foreground,de,Ne,void 0)||je&&ie.push(`xterm-fg-${c.INVERTED_DEFAULT_COLOR}`)}ie.length&&(P.className=ie.join(" "),ie.length=0),Ee||ge||He?P.textContent=Y:$++,q!==this.defaultSpacing&&(P.style.letterSpacing=`${q}px`),W.push(P),se=ze}return P&&$&&(P.textContent=Y),W}_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 M;if(R||L||(M=T.getColor(j.rgba,S.rgba)),M===void 0){const B=this._optionsService.rawOptions.minimumContrastRatio/(E.isDim()?2:1);M=_.color.ensureContrastRatio(R||j,L||S,B),T.setColor((R||j).rgba,(L||S).rgba,M??null)}return!!M&&(this._addStyle(k,`color:${M.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 x=this._holey.get(g);if(x===void 0){let y=0;l&&(y|=1),u&&(y|=2),x=this._measure(n,y),this._holey.set(g,x)}return x}_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),x=n(844);let y=i.CharSizeService=class extends x.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 _(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 _{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),x=n(511),y=n(2585);class _ 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=_;let a=i.CharacterJoinerService=class Sl{constructor(d){this._bufferService=d,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new x.CellData}register(d){const f={id:this._nextCharacterJoinerId++,handler:d};return this._characterJoiners.push(f),f.id}deregister(d){for(let f=0;f<this._characterJoiners.length;f++)if(this._characterJoiners[f].id===d)return this._characterJoiners.splice(f,1),!0;return!1}getJoinedCharacters(d){if(this._characterJoiners.length===0)return[];const f=this._bufferService.buffer.lines.get(d);if(!f||f.length===0)return[];const 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 M=0;M<T.length;M++)b.push(T[M])}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,_,a,h){var d,f=arguments.length,b=f<3?_:h===null?h=Object.getOwnPropertyDescriptor(_,a):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(y,_,a,h);else for(var w=y.length-1;w>=0;w--)(d=y[w])&&(b=(f<3?d(b):f>3?d(_,a,b):d(_,a))||b);return f>3&&b&&Object.defineProperty(_,a,b),b},u=this&&this.__param||function(y,_){return function(a,h){_(a,h,y)}};Object.defineProperty(i,"__esModule",{value:!0}),i.MouseService=void 0;const c=n(4725),g=n(9806);let x=i.MouseService=class{constructor(y,_){this._renderService=y,this._charSizeService=_}getCoords(y,_,a,h,d){return(0,g.getCoords)(window,y,_,a,h,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,d)}getMouseReportCoords(y,_){const a=(0,g.getCoordsRelativeToElement)(window,y,_);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=x=l([u(0,c.IRenderService),u(1,c.ICharSizeService)],x)},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),x=n(5596),y=n(4725),_=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 _.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new _.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new _.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new _.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new g.RenderDebouncer(R.window,((T,M)=>this._renderRows(T,M))),this.register(this._renderDebouncer),this._screenDprMonitor=new x.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((M=>this._handleIntersectionChange(M[M.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,M=arguments.length,B=M<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=(M<3?T(B):M>3?T(E,R,B):T(E,R))||B);return M>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),x=n(456),y=n(4725),_=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,M,B,D,F){super(),this._element=S,this._screenElement=E,this._linkifier=R,this._bufferService=L,this._coreService=T,this._mouseService=M,this._optionsService=B,this._renderService=D,this._coreBrowserService=F,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 _.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new _.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new _.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new _.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=W=>this._handleMouseMove(W),this._mouseUpListener=W=>this._handleMouseUp(W),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((W=>this._handleTrim(W))),this.register(this._bufferService.buffers.onBufferActivate((W=>this._handleBufferActivate(W)))),this.enable(),this._model=new x.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],M=S[0]<E[0]?E[0]:S[0];for(let B=S[1];B<=E[1];B++){const D=R.translateBufferLineToString(B,!0,T,M);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 M=S[1]+1;M<=E[1]-1;M++){const B=R.lines.get(M),D=R.translateBufferLineToString(M,!0);B?.isWrapped?L[L.length-1]+=D:L.push(D)}if(S[1]!==E[1]){const M=R.lines.get(E[1]),B=R.translateBufferLineToString(E[1],!0,0,E[0]);M&&M.isWrapped?L[L.length-1]+=B:L.push(B)}}return L.map((T=>T.replace(k," "))).join(h.isWindows?`\r
|
|
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=x=l([u(0,g.IBufferService),u(1,g.IOptionsService),u(2,g.IOscLinkService)],x)},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),x=n(3730),y=n(1680),_=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),M=n(8460),B=n(844),D=n(6114),F=n(8437),H=n(2584),A=n(7399),O=n(5941),P=n(9074),I=n(2585),$=n(5435),Y=n(4567),U=typeof window<"u"?window.document:null;class X 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 M.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new M.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new M.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new M.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new M.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new M.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new M.EventEmitter),this._onBlur=this.register(new M.EventEmitter),this._onA11yCharEmitter=this.register(new M.EventEmitter),this._onA11yTabEmitter=this.register(new M.EventEmitter),this._onWillOpen=this.register(new M.EventEmitter),this._setup(),this.linkifier2=this.register(this._instantiationService.createInstance(c.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(x.OscLinkProvider)),this._decorationService=this._instantiationService.createInstance(P.DecorationService),this._instantiationService.setService(I.IDecorationService,this._decorationService),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((W,K)=>this.refresh(W,K)))),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,M.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,M.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,M.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,M.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,K;this._customKeyEventHandler=void 0,(K=(W=this.element)===null||W===void 0?void 0:W.parentNode)===null||K===void 0||K.removeChild(this.element)})))}_handleColorEvent(N){if(this._themeService)for(const W of N){let K,q="";switch(W.index){case 256:K="foreground",q="10";break;case 257:K="background",q="11";break;case 258:K="cursor",q="12";break;default:K="ansi",q="4;"+W.index}switch(W.type){case 0:const ie=L.color.toColorRGB(K==="ansi"?this._themeService.colors.ansi[W.index]:this._themeService.colors[K]);this.coreService.triggerDataEvent(`${H.C0.ESC}]${q};${(0,O.toRgbString)(ie)}${H.C1_ESCAPED.ST}`);break;case 1:if(K==="ansi")this._themeService.modifyColors((Q=>Q.ansi[W.index]=L.rgba.toColor(...W.color)));else{const Q=K;this._themeService.modifyColors((se=>se[Q]=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 K=Math.min(this.buffer.x,this.cols-1),q=this._renderService.dimensions.css.cell.height,ie=W.getWidth(K),Q=this._renderService.dimensions.css.cell.width*ie,se=this.buffer.y*this._renderService.dimensions.css.cell.height,pe=K*this._renderService.dimensions.css.cell.width;this.textarea.style.left=pe+"px",this.textarea.style.top=se+"px",this.textarea.style.width=Q+"px",this.textarea.style.height=q+"px",this.textarea.style.lineHeight=q+"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 K=U.createDocumentFragment();this._viewportElement=U.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),K.appendChild(this._viewportElement),this._viewportScrollArea=U.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=U.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=U.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),K.appendChild(this.screenElement),this.textarea=U.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",(q=>this._handleTextAreaFocus(q)))),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((q=>this._onRender.fire(q)))),this.onResize((q=>this._renderService.resize(q.cols,q.rows))),this._compositionView=U.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(K);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._mouseService=this._instantiationService.createInstance(k.MouseService),this._instantiationService.setService(E.IMouseService,this._mouseService),this.viewport=this._instantiationService.createInstance(y.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((q=>this.scrollLines(q.amount,q.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((q=>this.scrollLines(q.amount,q.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((q=>this._renderService.handleSelectionChanged(q.start,q.end,q.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((q=>{this.textarea.value=q,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((q=>{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(_.BufferDecorationRenderer,this.screenElement)),this.register((0,u.addDisposableDomListener)(this.element,"mousedown",(q=>this._selectionService.handleMouseDown(q)))),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",(q=>this._handleScreenReaderModeOptionChange(q)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(a.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(q=>{!this._overviewRulerRenderer&&q&&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 K(Q){const se=N._mouseService.getMouseReportCoords(Q,N.screenElement);if(!se)return!1;let pe,ge;switch(Q.overrideType||Q.type){case"mousemove":ge=32,Q.buttons===void 0?(pe=3,Q.button!==void 0&&(pe=Q.button<3?Q.button:3)):pe=1&Q.buttons?0:4&Q.buttons?1:2&Q.buttons?2:3;break;case"mouseup":ge=0,pe=Q.button<3?Q.button:3;break;case"mousedown":ge=1,pe=Q.button<3?Q.button:3;break;case"wheel":if(N.viewport.getLinesScrolled(Q)===0)return!1;ge=Q.deltaY<0?0:1,pe=4;break;default:return!1}return!(ge===void 0||pe===void 0||pe>4)&&N.coreMouseService.triggerMouseEvent({col:se.col,row:se.row,x:se.x,y:se.y,button:pe,action:ge,ctrl:Q.ctrlKey,alt:Q.altKey,shift:Q.shiftKey})}const q={mouseup:null,wheel:null,mousedrag:null,mousemove:null},ie={mouseup:Q=>(K(Q),Q.buttons||(this._document.removeEventListener("mouseup",q.mouseup),q.mousedrag&&this._document.removeEventListener("mousemove",q.mousedrag)),this.cancel(Q)),wheel:Q=>(K(Q),this.cancel(Q,!0)),mousedrag:Q=>{Q.buttons&&K(Q)},mousemove:Q=>{Q.buttons||K(Q)}};this.register(this.coreMouseService.onProtocolChange((Q=>{Q?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(Q)),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&Q?q.mousemove||(W.addEventListener("mousemove",ie.mousemove),q.mousemove=ie.mousemove):(W.removeEventListener("mousemove",q.mousemove),q.mousemove=null),16&Q?q.wheel||(W.addEventListener("wheel",ie.wheel,{passive:!1}),q.wheel=ie.wheel):(W.removeEventListener("wheel",q.wheel),q.wheel=null),2&Q?q.mouseup||(W.addEventListener("mouseup",ie.mouseup),q.mouseup=ie.mouseup):(this._document.removeEventListener("mouseup",q.mouseup),W.removeEventListener("mouseup",q.mouseup),q.mouseup=null),4&Q?q.mousedrag||(q.mousedrag=ie.mousedrag):(this._document.removeEventListener("mousemove",q.mousedrag),q.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,u.addDisposableDomListener)(W,"mousedown",(Q=>{if(Q.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(Q))return K(Q),q.mouseup&&this._document.addEventListener("mouseup",q.mouseup),q.mousedrag&&this._document.addEventListener("mousemove",q.mousedrag),this.cancel(Q)}))),this.register((0,u.addDisposableDomListener)(W,"wheel",(Q=>{if(!q.wheel){if(!this.buffer.hasScrollback){const se=this.viewport.getLinesScrolled(Q);if(se===0)return;const pe=H.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(Q.deltaY<0?"A":"B");let ge="";for(let Fe=0;Fe<Math.abs(se);Fe++)ge+=pe;return this.coreService.triggerDataEvent(ge,!0),this.cancel(Q,!0)}return this.viewport.handleWheel(Q)?this.cancel(Q):void 0}}),{passive:!1})),this.register((0,u.addDisposableDomListener)(W,"touchstart",(Q=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(Q),this.cancel(Q)}),{passive:!0})),this.register((0,u.addDisposableDomListener)(W,"touchmove",(Q=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(Q)?void 0:this.cancel(Q)}),{passive:!1}))}refresh(N,W){var K;(K=this._renderService)===null||K===void 0||K.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,K=0){var q;K===1?(super.scrollLines(N,W,K),this.refresh(0,this.rows-1)):(q=this.viewport)===null||q===void 0||q.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,K){this._selectionService.setSelection(N,W,K)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var 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 K;(K=this._selectionService)===null||K===void 0||K.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 K=(0,A.evaluateKeyboardEvent)(N,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(N),K.type===3||K.type===2){const q=this.rows-1;return this.scrollLines(K.type===2?-q:q),this.cancel(N,!0)}return K.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,N)||(K.cancel&&this.cancel(N,!0),!K.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):(K.key!==H.C0.ETX&&K.key!==H.C0.CR||(this.textarea.value=""),this._onKey.fire({key:K.key,domEvent:N}),this._showCursor(),this.coreService.triggerDataEvent(K.key,!0),!this.optionsService.rawOptions.screenReaderMode||N.altKey||N.ctrlKey?this.cancel(N,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(N,W){const K=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"?K:K&&(!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 K,q;(K=this._charSizeService)===null||K===void 0||K.measure(),(q=this.viewport)===null||q===void 0||q.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(F.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 K=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=K,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),K=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${H.C0.ESC}[4;${K};${W}t`);break;case $.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const q=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};${q}t`)}}cancel(N,W){if(this.options.cancelEvents||W)return N.preventDefault(),N.stopPropagation(),!1}}i.Terminal=X},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,x=this._debounceThresholdMS-g;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),x)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const 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),x=n(8460),y=n(844),_=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 x.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,c.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((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,_.IBufferService),u(3,_.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),x=n(844),y=n(2585);let _=i.BufferDecorationRenderer=class extends x.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,x.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(const 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=_=l([u(1,y.IBufferService),u(2,y.IDecorationService),u(3,g.IRenderService)],_)},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),x=n(4725),y=n(844),_=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 M;(M=this._canvas)===null||M===void 0||M.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,_.IBufferService),u(3,_.IDecorationService),u(4,x.IRenderService),u(5,_.IOptionsService),u(6,x.ICoreBrowserService)],f)},2950:function(v,i,n){var l=this&&this.__decorate||function(_,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(_,a,h,d);else for(var k=_.length-1;k>=0;k--)(f=_[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(_,a){return function(h,d){a(h,d,_)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CompositionHelper=void 0;const c=n(4725),g=n(2585),x=n(2584);let y=i.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(_,a,h,d,f,b){this._textarea=_,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(_){this._compositionView.textContent=_.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(_){if(this._isComposing||this._isSendingComposition){if(_.keyCode===229||_.keyCode===16||_.keyCode===17||_.keyCode===18)return!1;this._finalizeComposition(!1)}return _.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(_){if(this._compositionView.classList.remove("active"),this._isComposing=!1,_){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 _=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const a=this._textarea.value,h=a.replace(_,"");this._dataAlreadySent=h,a.length>_.length?this._coreService.triggerDataEvent(h,!0):a.length<_.length?this._coreService.triggerDataEvent(`${x.C0.DEL}`,!0):a.length===_.length&&a!==_&&this._coreService.triggerDataEvent(a,!0)}}),0)}updateCompositionElements(_){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"}_||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(),x=l.getComputedStyle(c),y=parseInt(x.getPropertyValue("padding-left")),_=parseInt(x.getPropertyValue("padding-top"));return[u.clientX-g.left-y,u.clientY-g.top-_]}Object.defineProperty(i,"__esModule",{value:!0}),i.getCoords=i.getCoordsRelativeToElement=void 0,i.getCoordsRelativeToElement=n,i.getCoords=function(l,u,c,g,x,y,_,a,h){if(!y)return;const d=n(l,u,c);return d?(d[0]=Math.ceil((d[0]+(h?_/2:0))/_),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),x),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 M=0;M<Math.abs(L-T);M++){const B=g(j,S)==="A"?-1:1,D=E.buffer.lines.get(L+B*M);D?.isWrapped&&R++}return R})(a,h,d);return _(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 x(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 _(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,M){return u(E,L,T,M).length===0?"":_(x(S,E,S,E-c(E,T),!1,T).length,y("D",M))})(b,w,0,h,d,f)+u(w,h,d,f)+(function(S,E,R,L,T,M){let B;B=u(E,L,T,M).length>0?L-c(L,T):E;const D=L,F=(function(H,A,O,P,I,$){let Y;return Y=u(O,P,I,$).length>0?P-c(P,I):A,H<O&&Y<=P||H>=O&&Y<P?"C":"D"})(S,E,R,L,T,M);return _(x(S,B,R,D,F==="C",T).length,y(F,M))})(b,w,a,h,d,f);let k;if(w===h)return k=b>a?"D":"C",_(Math.abs(b-a),y(k,f));k=w>h?"D":"C";const j=Math.abs(w-h);return _((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,M,B,D){var F,H=arguments.length,A=H<3?M:D===null?D=Object.getOwnPropertyDescriptor(M,B):D;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(T,M,B,D);else for(var O=T.length-1;O>=0;O--)(F=T[O])&&(A=(H<3?F(A):H>3?F(M,B,A):F(M,B))||A);return H>3&&A&&Object.defineProperty(M,B,A),A},u=this&&this.__param||function(T,M){return function(B,D){M(B,D,T)}};Object.defineProperty(i,"__esModule",{value:!0}),i.DomRenderer=void 0;const c=n(3787),g=n(2550),x=n(2223),y=n(6171),_=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,M,B,D,F,H,A,O,P,I){super(),this._element=T,this._screenElement=M,this._viewportElement=B,this._linkifier2=D,this._charSizeService=H,this._optionsService=A,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=F.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 M=`${this._terminalSelector} .${w} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=M,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 M=`${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}`;M+=`${this._terminalSelector} .${w} .xterm-dim { color: ${a.color.multiplyOpacity(T.foreground,.5).css};}`,M+=`${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;}`,M+="@keyframes blink_box_shadow_"+this._terminalClass+" { 50% { border-bottom-style: hidden; }}",M+="@keyframes blink_block_"+this._terminalClass+` { 0% { background-color: ${T.cursor.css}; color: ${T.cursorAccent.css}; } 50% { background-color: inherit; color: ${T.cursor.css}; }}`,M+=`${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);}`,M+=`${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())M+=`${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}; }`;M+=`${this._terminalSelector} .${k}${x.INVERTED_DEFAULT_COLOR} { color: ${a.color.opaque(T.background).css}; }${this._terminalSelector} .${k}${x.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${a.color.multiplyOpacity(a.color.opaque(T.background),.5).css}; }${this._terminalSelector} .${j}${x.INVERTED_DEFAULT_COLOR} { background-color: ${T.foreground.css}; }`,this._themeStyleElement.textContent=M}_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,M){for(let B=this._rowElements.length;B<=M;B++){const D=document.createElement("div");this._rowContainer.appendChild(D),this._rowElements.push(D)}for(;this._rowElements.length>M;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(T,M){this._refreshRowElements(T,M),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,M,B){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(T,M,B),this.renderRows(0,this._bufferService.rows-1),!T||!M)return;const D=T[1]-this._bufferService.buffer.ydisp,F=M[1]-this._bufferService.buffer.ydisp,H=Math.max(D,0),A=Math.min(F,this._bufferService.rows-1);if(H>=this._bufferService.rows||A<0)return;const O=document.createDocumentFragment();if(B){const P=T[0]>M[0];O.appendChild(this._createSelectionElement(H,P?M[0]:T[0],P?T[0]:M[0],A-H+1))}else{const P=D===H?T[0]:0,I=H===F?M[0]:this._bufferService.cols;O.appendChild(this._createSelectionElement(H,P,I));const $=A-H-1;if(O.appendChild(this._createSelectionElement(H+1,0,this._bufferService.cols,$)),H!==A){const Y=F===A?M[0]:this._bufferService.cols;O.appendChild(this._createSelectionElement(A,0,Y))}}this._selectionContainer.appendChild(O)}_createSelectionElement(T,M,B,D=1){const F=document.createElement("div");return F.style.height=D*this.dimensions.css.cell.height+"px",F.style.top=T*this.dimensions.css.cell.height+"px",F.style.left=M*this.dimensions.css.cell.width+"px",F.style.width=this.dimensions.css.cell.width*(B-M)+"px",F}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,M){const B=this._bufferService.buffer,D=B.ybase+B.y,F=Math.min(B.x,this._bufferService.cols-1),H=this._optionsService.rawOptions.cursorBlink,A=this._optionsService.rawOptions.cursorStyle,O=this._optionsService.rawOptions.cursorInactiveStyle;for(let P=T;P<=M;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,A,O,F,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,M,B,D,F,H){B<0&&(T=0),D<0&&(M=0);const A=this._bufferService.rows-1;B=Math.max(Math.min(B,A),0),D=Math.max(Math.min(D,A),0),F=Math.min(F,this._bufferService.cols);const O=this._bufferService.buffer,P=O.ybase+O.y,I=Math.min(O.x,F-1),$=this._optionsService.rawOptions.cursorBlink,Y=this._optionsService.rawOptions.cursorStyle,U=this._optionsService.rawOptions.cursorInactiveStyle;for(let X=B;X<=D;++X){const z=X+O.ydisp,N=this._rowElements[X],W=O.lines.get(z);if(!N||!W)break;N.replaceChildren(...this._rowFactory.createRow(W,z,z===P,Y,U,I,$,this.dimensions.css.cell.width,this._widthCache,H?X===B?T:0:-1,H?(X===D?M:F)-1:-1))}}};i.DomRenderer=L=l([u(4,f.IInstantiationService),u(5,_.ICharSizeService),u(6,f.IOptionsService),u(7,f.IBufferService),u(8,_.ICoreBrowserService),u(9,_.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 M=k.length-1;M>=0;M--)(R=k[M])&&(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),x=n(511),y=n(2585),_=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 x.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,M,B,D,F){const H=[],A=this._characterJoinerService.getJoinedCharacters(j),O=this._themeService.colors;let P,I=k.getNoBgTrimmedLength();S&&I<L+1&&(I=L+1);let $=0,Y="",U=0,X=0,z=0,N=!1,W=0,K=!1,q=0;const ie=[],Q=D!==-1&&F!==-1;for(let se=0;se<I;se++){k.loadCell(se,this._workCell);let pe=this._workCell.getWidth();if(pe===0)continue;let ge=!1,Fe=se,de=this._workCell;if(A.length>0&&se===A[0][0]){ge=!0;const he=A.shift();de=new h.JoinedCellData(this._workCell,k.translateToString(!0,he[0],he[1]),he[1]-he[0]),Fe=he[1]-1,pe=de.getWidth()}const Ge=this._isCellInSelection(se,j),Ee=S&&se===L,Ke=Q&&se>=D&&se<=F;let ze=!1;this._decorationService.forEachDecorationAtCell(se,j,void 0,(he=>{ze=!0}));let De=de.getChars()||g.WHITESPACE_CELL_CHAR;if(De===" "&&(de.isUnderline()||de.isOverline())&&(De=" "),q=pe*M-B.get(De,de.isBold(),de.isItalic()),P){if($&&(Ge&&K||!Ge&&!K&&de.bg===U)&&(Ge&&K&&O.selectionForeground||de.fg===X)&&de.extended.ext===z&&Ke===N&&q===W&&!Ee&&!ge&&!ze){Y+=De,$++;continue}$&&(P.textContent=Y),P=this._document.createElement("span"),$=0,Y=""}else P=this._document.createElement("span");if(U=de.bg,X=de.fg,z=de.extended.ext,N=Ke,W=q,K=Ge,ge&&L>=se&&L<=Fe&&(L=se),!this._coreService.isCursorHidden&&Ee){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(de.isBold()&&ie.push("xterm-bold"),de.isItalic()&&ie.push("xterm-italic"),de.isDim()&&ie.push("xterm-dim"),Y=de.isInvisible()?g.WHITESPACE_CELL_CHAR:de.getChars()||g.WHITESPACE_CELL_CHAR,de.isUnderline()&&(ie.push(`xterm-underline-${de.extended.underlineStyle}`),Y===" "&&(Y=" "),!de.isUnderlineColorDefault()))if(de.isUnderlineColorRGB())P.style.textDecorationColor=`rgb(${f.AttributeData.toColorRGB(de.getUnderlineColor()).join(",")})`;else{let he=de.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&de.isBold()&&he<8&&(he+=8),P.style.textDecorationColor=O.ansi[he].css}de.isOverline()&&(ie.push("xterm-overline"),Y===" "&&(Y=" ")),de.isStrikethrough()&&ie.push("xterm-strikethrough"),Ke&&(P.style.textDecoration="underline");let We=de.getFgColor(),Te=de.getFgColorMode(),Xe=de.getBgColor(),Re=de.getBgColorMode();const je=!!de.isInverse();if(je){const he=We;We=Xe,Xe=he;const ft=Te;Te=Re,Re=ft}let Ne,et,Ae,He=!1;switch(this._decorationService.forEachDecorationAtCell(se,j,void 0,(he=>{he.options.layer!=="top"&&He||(he.backgroundColorRGB&&(Re=50331648,Xe=he.backgroundColorRGB.rgba>>8&16777215,Ne=he.backgroundColorRGB),he.foregroundColorRGB&&(Te=50331648,We=he.foregroundColorRGB.rgba>>8&16777215,et=he.foregroundColorRGB),He=he.options.layer==="top")})),!He&&Ge&&(Ne=this._coreBrowserService.isFocused?O.selectionBackgroundOpaque:O.selectionInactiveBackgroundOpaque,Xe=Ne.rgba>>8&16777215,Re=50331648,He=!0,O.selectionForeground&&(Te=50331648,We=O.selectionForeground.rgba>>8&16777215,et=O.selectionForeground)),He&&ie.push("xterm-decoration-top"),Re){case 16777216:case 33554432:Ae=O.ansi[Xe],ie.push(`xterm-bg-${Xe}`);break;case 50331648:Ae=_.rgba.toColor(Xe>>16,Xe>>8&255,255&Xe),this._addStyle(P,`background-color:#${w((Xe>>>0).toString(16),"0",6)}`);break;default:je?(Ae=O.foreground,ie.push(`xterm-bg-${c.INVERTED_DEFAULT_COLOR}`)):Ae=O.background}switch(Ne||de.isDim()&&(Ne=_.color.multiplyOpacity(Ae,.5)),Te){case 16777216:case 33554432:de.isBold()&&We<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(We+=8),this._applyMinimumContrast(P,Ae,O.ansi[We],de,Ne,void 0)||ie.push(`xterm-fg-${We}`);break;case 50331648:const he=_.rgba.toColor(We>>16&255,We>>8&255,255&We);this._applyMinimumContrast(P,Ae,he,de,Ne,et)||this._addStyle(P,`color:#${w(We.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(P,Ae,O.foreground,de,Ne,void 0)||je&&ie.push(`xterm-fg-${c.INVERTED_DEFAULT_COLOR}`)}ie.length&&(P.className=ie.join(" "),ie.length=0),Ee||ge||ze?P.textContent=Y:$++,q!==this.defaultSpacing&&(P.style.letterSpacing=`${q}px`),H.push(P),se=Fe}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 M;if(R||L||(M=T.getColor(j.rgba,S.rgba)),M===void 0){const B=this._optionsService.rawOptions.minimumContrastRatio/(E.isDim()?2:1);M=_.color.ensureContrastRatio(R||j,L||S,B),T.setColor((R||j).rgba,(L||S).rgba,M??null)}return!!M&&(this._addStyle(k,`color:${M.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 x=this._holey.get(g);if(x===void 0){let y=0;l&&(y|=1),u&&(y|=2),x=this._measure(n,y),this._holey.set(g,x)}return x}_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),x=n(844);let y=i.CharSizeService=class extends x.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 _(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 _{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),x=n(511),y=n(2585);class _ 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=_;let a=i.CharacterJoinerService=class Cl{constructor(d){this._bufferService=d,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new x.CellData}register(d){const f={id:this._nextCharacterJoinerId++,handler:d};return this._characterJoiners.push(f),f.id}deregister(d){for(let f=0;f<this._characterJoiners.length;f++)if(this._characterJoiners[f].id===d)return this._characterJoiners.splice(f,1),!0;return!1}getJoinedCharacters(d){if(this._characterJoiners.length===0)return[];const f=this._bufferService.buffer.lines.get(d);if(!f||f.length===0)return[];const 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 M=0;M<T.length;M++)b.push(T[M])}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++)Cl._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,_,a,h){var d,f=arguments.length,b=f<3?_:h===null?h=Object.getOwnPropertyDescriptor(_,a):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(y,_,a,h);else for(var w=y.length-1;w>=0;w--)(d=y[w])&&(b=(f<3?d(b):f>3?d(_,a,b):d(_,a))||b);return f>3&&b&&Object.defineProperty(_,a,b),b},u=this&&this.__param||function(y,_){return function(a,h){_(a,h,y)}};Object.defineProperty(i,"__esModule",{value:!0}),i.MouseService=void 0;const c=n(4725),g=n(9806);let x=i.MouseService=class{constructor(y,_){this._renderService=y,this._charSizeService=_}getCoords(y,_,a,h,d){return(0,g.getCoords)(window,y,_,a,h,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,d)}getMouseReportCoords(y,_){const a=(0,g.getCoordsRelativeToElement)(window,y,_);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=x=l([u(0,c.IRenderService),u(1,c.ICharSizeService)],x)},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),x=n(5596),y=n(4725),_=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 _.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new _.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new _.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new _.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new g.RenderDebouncer(R.window,((T,M)=>this._renderRows(T,M))),this.register(this._renderDebouncer),this._screenDprMonitor=new x.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((M=>this._handleIntersectionChange(M[M.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,M=arguments.length,B=M<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=(M<3?T(B):M>3?T(E,R,B):T(E,R))||B);return M>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),x=n(456),y=n(4725),_=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,M,B,D,F){super(),this._element=S,this._screenElement=E,this._linkifier=R,this._bufferService=L,this._coreService=T,this._mouseService=M,this._optionsService=B,this._renderService=D,this._coreBrowserService=F,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 _.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new _.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new _.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new _.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 x.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],M=S[0]<E[0]?E[0]:S[0];for(let B=S[1];B<=E[1];B++){const D=R.translateBufferLineToString(B,!0,T,M);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 M=S[1]+1;M<=E[1]-1;M++){const B=R.lines.get(M),D=R.translateBufferLineToString(M,!0);B?.isWrapped?L[L.length-1]+=D:L.push(D)}if(S[1]!==E[1]){const M=R.lines.get(E[1]),B=R.translateBufferLineToString(E[1],!0,0,E[0]);M&&M.isWrapped?L[L.length-1]+=B:L.push(B)}}return L.map((T=>T.replace(k," "))).join(h.isWindows?`\r
|
|
24
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 M=this._getMouseBufferCoords(S);return!!M&&(this._selectWordAt(M,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,M=T.lines.get(S[1]);if(!M)return;const B=T.translateBufferLineToString(S[1],!1);let D=this._convertViewportColToCharacterIndex(M,S[0]),F=D;const W=S[0]-D;let A=0,O=0,P=0,I=0;if(B.charAt(D)===" "){for(;D>0&&B.charAt(D-1)===" ";)D--;for(;F<B.length&&B.charAt(F+1)===" ";)F++}else{let U=S[0],X=S[0];M.getWidth(U)===0&&(A++,U--),M.getWidth(X)===2&&(O++,X++);const z=M.getString(X).length;for(z>1&&(I+=z-1,F+=z-1);U>0&&D>0&&!this._isCharWordSeparator(M.loadCell(U-1,this._workCell));){M.loadCell(U-1,this._workCell);const N=this._workCell.getChars().length;this._workCell.getWidth()===0?(A++,U--):N>1&&(P+=N-1,D-=N-1),D--,U--}for(;X<M.length&&F+1<B.length&&!this._isCharWordSeparator(M.loadCell(X+1,this._workCell));){M.loadCell(X+1,this._workCell);const N=this._workCell.getChars().length;this._workCell.getWidth()===2?(O++,X++):N>1&&(I+=N-1,F+=N-1),F++,X++}}F++;let $=D+W-A+P,Y=Math.min(this._bufferService.cols,F-D+A+O-P-I);if(E||B.slice(D,F).trim()!==""){if(R&&$===0&&M.getCodePoint(0)!==32){const U=T.lines.get(S[1]-1);if(U&&M.isWrapped&&U.getCodePoint(this._bufferService.cols-1)!==32){const X=this._getWordAt([this._bufferService.cols-1,S[1]-1],!1,!0,!1);if(X){const z=this._bufferService.cols-X.start;$-=z,Y+=z}}}if(L&&$+Y===this._bufferService.cols&&M.getCodePoint(this._bufferService.cols-1)!==32){const U=T.lines.get(S[1]+1);if(U?.isWrapped&&U.getCodePoint(0)!==32){const X=this._getWordAt([0,S[1]+1],!1,!1,!0);X&&(Y+=X.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,M=T<3?S:R===null?R=Object.getOwnPropertyDescriptor(S,E):R;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")M=Reflect.decorate(j,S,E,R);else for(var B=j.length-1;B>=0;B--)(L=j[B])&&(M=(T<3?L(M):T>3?L(S,E,M):L(S,E))||M);return T>3&&M&&Object.defineProperty(S,E,M),M},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),x=n(8460),y=n(844),_=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 x.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,_.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(x){super(),this._maxLength=x,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(x){if(this._maxLength===x)return;const y=new Array(x);for(let _=0;_<Math.min(x,this.length);_++)y[_]=this._array[this._getCyclicIndex(_)];this._array=y,this._maxLength=x,this._startIndex=0}get length(){return this._length}set length(x){if(x>this._length)for(let y=this._length;y<x;y++)this._array[y]=void 0;this._length=x}get(x){return this._array[this._getCyclicIndex(x)]}set(x,y){this._array[this._getCyclicIndex(x)]=y}push(x){this._array[this._getCyclicIndex(this._length)]=x,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(x,y,..._){if(y){for(let a=x;a<this._length-y;a++)this._array[this._getCyclicIndex(a)]=this._array[this._getCyclicIndex(a+y)];this._length-=y,this.onDeleteEmitter.fire({index:x,amount:y})}for(let a=this._length-1;a>=x;a--)this._array[this._getCyclicIndex(a+_.length)]=this._array[this._getCyclicIndex(a)];for(let a=0;a<_.length;a++)this._array[this._getCyclicIndex(x+a)]=_[a];if(_.length&&this.onInsertEmitter.fire({index:x,amount:_.length}),this._length+_.length>this._maxLength){const a=this._length+_.length-this._maxLength;this._startIndex+=a,this._length=this._maxLength,this.onTrimEmitter.fire(a)}else this._length+=_.length}trimStart(x){x>this._length&&(x=this._length),this._startIndex+=x,this._length-=x,this.onTrimEmitter.fire(x)}shiftElements(x,y,_){if(!(y<=0)){if(x<0||x>=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(_>0){for(let h=y-1;h>=0;h--)this.set(x+h+_,this.get(x+h));const a=x+y+_-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(x+a+_,this.get(x+a))}}_getCyclicIndex(x){return(this._startIndex+x)%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,x=0;var y,_,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 x=Math.round(255*S),[u,c,g]=d.toChannels(j.rgba),{css:y.toCss(u,c,g,x),rgba:y.toRgba(u,c,g,x)}}w.blend=function(j,S){if(x=(255&S.rgba)/255,x===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,M=j.rgba>>16&255,B=j.rgba>>8&255;return u=T+Math.round((E-T)*x),c=M+Math.round((R-M)*x),g=B+Math.round((L-B)*x),{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 x=255&j.rgba,k(j,x*S/255)},w.toColorRGB=function(j){return[j.rgba>>24&255,j.rgba>>16&255,j.rgba>>8&255]}})(_||(i.color=_={})),(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),x=parseInt(S.slice(4,5).repeat(2),16),d.toColor(u,c,g,x);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]),x=Math.round(255*(E[5]===void 0?1:parseFloat(E[5]))),d.toColor(u,c,g,x);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,x]=k.getImageData(0,0,1,1).data,x!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:y.toRgba(u,c,g,x),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,M=S>>8&255;let B=E>>24&255,D=E>>16&255,F=E>>8&255,W=b(h.relativeLuminance2(B,D,F),h.relativeLuminance2(L,T,M));for(;W<R&&(B>0||D>0||F>0);)B-=Math.max(0,Math.ceil(.1*B)),D-=Math.max(0,Math.ceil(.1*D)),F-=Math.max(0,Math.ceil(.1*F)),W=b(h.relativeLuminance2(B,D,F),h.relativeLuminance2(L,T,M));return(B<<24|D<<16|F<<8|255)>>>0}function j(S,E,R){const L=S>>24&255,T=S>>16&255,M=S>>8&255;let B=E>>24&255,D=E>>16&255,F=E>>8&255,W=b(h.relativeLuminance2(B,D,F),h.relativeLuminance2(L,T,M));for(;W<R&&(B<255||D<255||F<255);)B=Math.min(255,B+Math.ceil(.1*(255-B))),D=Math.min(255,D+Math.ceil(.1*(255-D))),F=Math.min(255,F+Math.ceil(.1*(255-F))),W=b(h.relativeLuminance2(B,D,F),h.relativeLuminance2(L,T,M));return(B<<24|D<<16|F<<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),F=b(L,h.relativeLuminance(D>>8));if(F<R){const W=j(S,E,R);return F>b(L,h.relativeLuminance(W>>8))?D:W}return D}const M=j(S,E,R),B=b(L,h.relativeLuminance(M>>8));if(B<R){const D=k(S,E,R);return B>b(L,h.relativeLuminance(D>>8))?M:D}return M}},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),x=n(744),y=n(7302),_=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(x.BufferService)),this._instantiationService.setService(u.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(g.LogService)),this._instantiationService.setService(u.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(_.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,M)=>this._inputHandler.parse(T,M)))),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,x.MINIMUM_COLS),T=Math.max(T,x.MINIMUM_ROWS),this._bufferService.resize(L,T))}scroll(L,T=!1){this._bufferService.scroll(L,T)}scrollLines(L,T,M){this._bufferService.scrollLines(L,T,M)}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(W,A,O,P){var I,$=arguments.length,Y=$<3?A:P===null?P=Object.getOwnPropertyDescriptor(A,O):P;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")Y=Reflect.decorate(W,A,O,P);else for(var U=W.length-1;U>=0;U--)(I=W[U])&&(Y=($<3?I(Y):$>3?I(A,O,Y):I(A,O))||Y);return $>3&&Y&&Object.defineProperty(A,O,Y),Y},u=this&&this.__param||function(W,A){return function(O,P){A(O,P,W)}};Object.defineProperty(i,"__esModule",{value:!0}),i.InputHandler=i.WindowsOptionsReportType=void 0;const c=n(2584),g=n(7116),x=n(2015),y=n(844),_=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(W,A){if(W>24)return A.setWinLines||!1;switch(W){case 1:return!!A.restoreWin;case 2:return!!A.minimizeWin;case 3:return!!A.setWinPosition;case 4:return!!A.setWinSizePixels;case 5:return!!A.raiseWin;case 6:return!!A.lowerWin;case 7:return!!A.refreshWin;case 8:return!!A.setWinSizeChars;case 9:return!!A.maximizeWin;case 10:return!!A.fullscreenWin;case 11:return!!A.getWinState;case 13:return!!A.getWinPosition;case 14:return!!A.getWinSizePixels;case 15:return!!A.getScreenSizePixels;case 16:return!!A.getCellSizePixels;case 18:return!!A.getWinSizeChars;case 19:return!!A.getScreenSizeChars;case 20:return!!A.getIconTitle;case 21:return!!A.getWinTitle;case 22:return!!A.pushTitle;case 23:return!!A.popTitle;case 24:return!!A.setWinLines}return!1}var T;(function(W){W[W.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",W[W.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(T||(i.WindowsOptionsReportType=T={}));let M=0;class B extends y.Disposable{getAttrData(){return this._curAttrData}constructor(A,O,P,I,$,Y,U,X,z=new x.EscapeSequenceParser){super(),this._bufferService=A,this._charsetService=O,this._coreService=P,this._logService=I,this._optionsService=$,this._oscLinkService=Y,this._coreMouseService=U,this._unicodeService=X,this._parser=z,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new _.StringToUtf32,this._utf8Decoder=new _.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,H)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(N),params:H.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,H,K)=>{this._logService.debug("Unknown OSC code: ",{identifier:N,action:H,data:K})})),this._parser.setDcsHandlerFallback(((N,H,K)=>{H==="HOOK"&&(K=K.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(N),action:H,payload:K})})),this._parser.setPrintHandler(((N,H,K)=>this.print(N,H,K))),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,H)=>this.requestStatusString(N,H))))}_preserveStack(A,O,P,I){this._parseStack.paused=!0,this._parseStack.cursorStartX=A,this._parseStack.cursorStartY=O,this._parseStack.decodedLength=P,this._parseStack.position=I}_logSlowResolvingAsync(A){this._logService.logLevel<=w.LogLevelEnum.WARN&&Promise.race([A,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(A,O){let P,I=this._activeBuffer.x,$=this._activeBuffer.y,Y=0;const U=this._parseStack.paused;if(U){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,A.length>R&&(Y=this._parseStack.position+R)}if(this._logService.logLevel<=w.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof A=="string"?` "${A}"`:` "${Array.prototype.map.call(A,(X=>String.fromCharCode(X))).join("")}"`),typeof A=="string"?A.split("").map((X=>X.charCodeAt(0))):A),this._parseBuffer.length<A.length&&this._parseBuffer.length<R&&(this._parseBuffer=new Uint32Array(Math.min(A.length,R))),U||this._dirtyRowTracker.clearRange(),A.length>R)for(let X=Y;X<A.length;X+=R){const z=X+R<A.length?X+R:A.length,N=typeof A=="string"?this._stringDecoder.decode(A.substring(X,z),this._parseBuffer):this._utf8Decoder.decode(A.subarray(X,z),this._parseBuffer);if(P=this._parser.parse(this._parseBuffer,N))return this._preserveStack(I,$,N,X),this._logSlowResolvingAsync(P),P}else if(!U){const X=typeof A=="string"?this._stringDecoder.decode(A,this._parseBuffer):this._utf8Decoder.decode(A,this._parseBuffer);if(P=this._parser.parse(this._parseBuffer,X))return this._preserveStack(I,$,X,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(A,O,P){let I,$;const Y=this._charsetService.charset,U=this._optionsService.rawOptions.screenReaderMode,X=this._bufferService.cols,z=this._coreService.decPrivateModes.wraparound,N=this._coreService.modes.insertMode,H=this._curAttrData;let K=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&P-O>0&&K.getWidth(this._activeBuffer.x-1)===2&&K.setCellFromCodePoint(this._activeBuffer.x-1,0,1,H.fg,H.bg,H.extended);for(let q=O;q<P;++q){if(I=A[q],$=this._unicodeService.wcwidth(I),I<127&&Y){const ie=Y[String.fromCharCode(I)];ie&&(I=ie.charCodeAt(0))}if(U&&this._onA11yChar.fire((0,_.stringFromCodePoint)(I)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),$||!this._activeBuffer.x){if(this._activeBuffer.x+$-1>=X){if(z){for(;this._activeBuffer.x<X;)K.setCellFromCodePoint(this._activeBuffer.x++,0,1,H.fg,H.bg,H.extended);this._activeBuffer.x=0,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),K=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)}else if(this._activeBuffer.x=X-1,$===2)continue}if(N&&(K.insertCells(this._activeBuffer.x,$,this._activeBuffer.getNullCell(H),H),K.getWidth(X-1)===2&&K.setCellFromCodePoint(X-1,d.NULL_CELL_CODE,d.NULL_CELL_WIDTH,H.fg,H.bg,H.extended)),K.setCellFromCodePoint(this._activeBuffer.x++,I,$,H.fg,H.bg,H.extended),$>0)for(;--$;)K.setCellFromCodePoint(this._activeBuffer.x++,0,0,H.fg,H.bg,H.extended)}else K.getWidth(this._activeBuffer.x-1)?K.addCodepointToCell(this._activeBuffer.x-1,I):K.addCodepointToCell(this._activeBuffer.x-2,I)}P-O>0&&(K.loadCell(this._activeBuffer.x-1,this._workCell),this._workCell.getWidth()===2||this._workCell.getCode()>65535?this._parser.precedingCodepoint=0:this._workCell.isCombined()?this._parser.precedingCodepoint=this._workCell.getChars().charCodeAt(0):this._parser.precedingCodepoint=this._workCell.content),this._activeBuffer.x<X&&P-O>0&&K.getWidth(this._activeBuffer.x)===0&&!K.hasContent(this._activeBuffer.x)&&K.setCellFromCodePoint(this._activeBuffer.x,0,1,H.fg,H.bg,H.extended),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(A,O){return A.final!=="t"||A.prefix||A.intermediates?this._parser.registerCsiHandler(A,O):this._parser.registerCsiHandler(A,(P=>!L(P.params[0],this._optionsService.rawOptions.windowOptions)||O(P)))}registerDcsHandler(A,O){return this._parser.registerDcsHandler(A,new j.DcsHandler(O))}registerEscHandler(A,O){return this._parser.registerEscHandler(A,O)}registerOscHandler(A,O){return this._parser.registerOscHandler(A,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 A;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&(!((A=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))===null||A===void 0)&&A.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const 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 A=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-A),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(A=this._bufferService.cols-1){this._activeBuffer.x=Math.min(A,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(A,O){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=A,this._activeBuffer.y=this._activeBuffer.scrollTop+O):(this._activeBuffer.x=A,this._activeBuffer.y=O),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(A,O){this._restrictCursor(),this._setCursor(this._activeBuffer.x+A,this._activeBuffer.y+O)}cursorUp(A){const O=this._activeBuffer.y-this._activeBuffer.scrollTop;return O>=0?this._moveCursor(0,-Math.min(O,A.params[0]||1)):this._moveCursor(0,-(A.params[0]||1)),!0}cursorDown(A){const O=this._activeBuffer.scrollBottom-this._activeBuffer.y;return O>=0?this._moveCursor(0,Math.min(O,A.params[0]||1)):this._moveCursor(0,A.params[0]||1),!0}cursorForward(A){return this._moveCursor(A.params[0]||1,0),!0}cursorBackward(A){return this._moveCursor(-(A.params[0]||1),0),!0}cursorNextLine(A){return this.cursorDown(A),this._activeBuffer.x=0,!0}cursorPrecedingLine(A){return this.cursorUp(A),this._activeBuffer.x=0,!0}cursorCharAbsolute(A){return this._setCursor((A.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(A){return this._setCursor(A.length>=2?(A.params[1]||1)-1:0,(A.params[0]||1)-1),!0}charPosAbsolute(A){return this._setCursor((A.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(A){return this._moveCursor(A.params[0]||1,0),!0}linePosAbsolute(A){return this._setCursor(this._activeBuffer.x,(A.params[0]||1)-1),!0}vPositionRelative(A){return this._moveCursor(0,A.params[0]||1),!0}hVPosition(A){return this.cursorPosition(A),!0}tabClear(A){const O=A.params[0];return O===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:O===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(A){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let O=A.params[0]||1;for(;O--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(A){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let O=A.params[0]||1;for(;O--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(A){const O=A.params[0];return O===1&&(this._curAttrData.bg|=536870912),O!==2&&O!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(A,O,P,I=!1,$=!1){const Y=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);Y.replaceCells(O,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),$),I&&(Y.isWrapped=!1)}_resetBufferLine(A,O=!1){const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);P&&(P.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),O),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+A),P.isWrapped=!1)}eraseInDisplay(A,O=!1){let P;switch(this._restrictCursor(this._bufferService.cols),A.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(A,O=!1){switch(this._restrictCursor(this._bufferService.cols),A.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,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(A){this._restrictCursor();let O=A.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(A){this._restrictCursor();let O=A.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(A){this._restrictCursor();const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return O&&(O.insertCells(this._activeBuffer.x,A.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(A){this._restrictCursor();const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return O&&(O.deleteCells(this._activeBuffer.x,A.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(A){let O=A.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(A){let O=A.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(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=A.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(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=A.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(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=A.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(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=A.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(A){this._restrictCursor();const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return O&&(O.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(A.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(A){if(!this._parser.precedingCodepoint)return!0;const O=A.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(A){return A.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(c.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(c.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(A){return A.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(c.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(c.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(A.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(c.C0.ESC+"[>83;40003;0c")),!0}_is(A){return(this._optionsService.rawOptions.termName+"").indexOf(A)===0}setMode(A){for(let O=0;O<A.length;O++)switch(A.params[O]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(A){for(let O=0;O<A.length;O++)switch(A.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(A){for(let O=0;O<A.length;O++)switch(A.params[O]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(A){for(let O=0;O<A.length;O++)switch(A.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(),A.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(A,O){const P=this._coreService.decPrivateModes,{activeProtocol:I,activeEncoding:$}=this._coreMouseService,Y=this._coreService,{buffers:U,cols:X}=this._bufferService,{active:z,alt:N}=U,H=this._optionsService.rawOptions,K=se=>se?1:2,q=A.params[0];return ie=q,Q=O?q===2?4:q===4?K(Y.modes.insertMode):q===12?3:q===20?K(H.convertEol):0:q===1?K(P.applicationCursorKeys):q===3?H.windowOptions.setWinLines?X===80?2:X===132?1:0:0:q===6?K(P.origin):q===7?K(P.wraparound):q===8?3:q===9?K(I==="X10"):q===12?K(H.cursorBlink):q===25?K(!Y.isCursorHidden):q===45?K(P.reverseWraparound):q===66?K(P.applicationKeypad):q===67?4:q===1e3?K(I==="VT200"):q===1002?K(I==="DRAG"):q===1003?K(I==="ANY"):q===1004?K(P.sendFocus):q===1005?4:q===1006?K($==="SGR"):q===1015?4:q===1016?K($==="SGR_PIXELS"):q===1048?1:q===47||q===1047||q===1049?K(z===N):q===2004?K(P.bracketedPasteMode):0,Y.triggerDataEvent(`${c.C0.ESC}[${O?"":"?"}${ie};${Q}$y`),!0;var ie,Q}_updateAttrColor(A,O,P,I,$){return O===2?(A|=50331648,A&=-16777216,A|=b.AttributeData.fromColorRGB([P,I,$])):O===5&&(A&=-50331904,A|=33554432|255&P),A}_extractColor(A,O,P){const I=[0,0,-1,0,0,0];let $=0,Y=0;do{if(I[Y+$]=A.params[O+Y],A.hasSubParams(O+Y)){const U=A.getSubParams(O+Y);let X=0;do I[1]===5&&($=1),I[Y+X+1+$]=U[X];while(++X<U.length&&X+Y+1+$<I.length);break}if(I[1]===5&&Y+$>=2||I[1]===2&&Y+$>=5)break;I[1]&&($=1)}while(++Y+O<A.length&&Y+$<I.length);for(let U=2;U<I.length;++U)I[U]===-1&&(I[U]=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(A,O){O.extended=O.extended.clone(),(!~A||A>5)&&(A=1),O.extended.underlineStyle=A,O.fg|=268435456,A===0&&(O.fg&=-268435457),O.updateExtended()}_processSGR0(A){A.fg=a.DEFAULT_ATTR_DATA.fg,A.bg=a.DEFAULT_ATTR_DATA.bg,A.extended=A.extended.clone(),A.extended.underlineStyle=0,A.extended.underlineColor&=-67108864,A.updateExtended()}charAttributes(A){if(A.length===1&&A.params[0]===0)return this._processSGR0(this._curAttrData),!0;const O=A.length;let P;const I=this._curAttrData;for(let $=0;$<O;$++)P=A.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(A.hasSubParams($)?A.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(A,$,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(A){switch(A.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(A){if(A.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(A){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(A){const O=A.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(A){const O=A.params[0]||1;let P;return(A.length<2||(P=A.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(A){if(!L(A.params[0],this._optionsService.rawOptions.windowOptions))return!0;const O=A.length>1?A.params[1]:0;switch(A.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(A){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(A){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(A){return this._windowTitle=A,this._onTitleChange.fire(A),!0}setIconName(A){return this._iconName=A,!0}setOrReportIndexedColor(A){const O=[],P=A.split(";");for(;P.length>1;){const I=P.shift(),$=P.shift();if(/^\d+$/.exec(I)){const Y=parseInt(I);if(F(Y))if($==="?")O.push({type:0,index:Y});else{const U=(0,S.parseColor)($);U&&O.push({type:1,index:Y,color:U})}}}return O.length&&this._onColor.fire(O),!0}setHyperlink(A){const O=A.split(";");return!(O.length<2)&&(O[1]?this._createHyperlink(O[0],O[1]):!O[0]&&this._finishHyperlink())}_createHyperlink(A,O){this._getCurrentLinkId()&&this._finishHyperlink();const P=A.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(A,O){const P=A.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(A){return this._setOrReportSpecialColor(A,0)}setOrReportBgColor(A){return this._setOrReportSpecialColor(A,1)}setOrReportCursorColor(A){return this._setOrReportSpecialColor(A,2)}restoreIndexedColor(A){if(!A)return this._onColor.fire([{type:2}]),!0;const O=[],P=A.split(";");for(let I=0;I<P.length;++I)if(/^\d+$/.exec(P[I])){const $=parseInt(P[I]);F($)&&O.push({type:2,index:$})}return O.length&&this._onColor.fire(O),!0}restoreFgColor(A){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(A){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(A){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,g.DEFAULT_CHARSET),!0}selectCharset(A){return A.length!==2?(this.selectDefaultCharset(),!0):(A[0]==="/"||this._charsetService.setgCharset(E[A[0]],g.CHARSETS[A[1]]||g.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){const A=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,A,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=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(A){return this._charsetService.setgLevel(A),!0}screenAlignmentPattern(){const A=new f.CellData;A.content=4194373,A.fg=this._curAttrData.fg,A.bg=this._curAttrData.bg,this._setCursor(0,0);for(let 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(A),I.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(A,O){const P=this._bufferService.buffer,I=this._optionsService.rawOptions;return($=>(this._coreService.triggerDataEvent(`${c.C0.ESC}${$}${c.C0.ESC}\\`),!0))(A==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:A==='"p'?'P1$r61;1"p':A==="r"?`P1$r${P.scrollTop+1};${P.scrollBottom+1}r`:A==="m"?"P1$r0m":A===" q"?`P1$r${{block:2,underline:4,bar:6}[I.cursorStyle]-(I.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(A,O){this._dirtyRowTracker.markRangeDirty(A,O)}}i.InputHandler=B;let D=class{constructor(W){this._bufferService=W,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(W){W<this.start?this.start=W:W>this.end&&(this.end=W)}markRangeDirty(W,A){W>A&&(M=W,W=A,A=M),W<this.start&&(this.start=W),A>this.end&&(this.end=A)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function F(W){return 0<=W&&W<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,x){this._data.get(l,u)||this._data.set(l,u,new n),this._data.get(l,u).set(c,g,x)}get(l,u,c,g){var x;return(x=this._data.get(l,u))===null||x===void 0?void 0:x.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 x=this._getKey(this._array[g]);if(x>l)c=g-1;else{if(!(x<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(x){this._tasks.push(x),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(x){this._idleCallback=void 0;let y=0,_=0,a=x.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),_=Math.max(y,_),h=x.timeRemaining(),1.5*_>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(x){return setTimeout((()=>x(this._createDeadline(16))))}_cancelCallback(x){clearTimeout(x)}_createDeadline(x){const y=Date.now()+x;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),x=u.buffer.lines.get(u.buffer.ybase+u.buffer.y);x&&g&&(x.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),x=n(4634),y=n(511),_=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,_.NULL_CELL_CHAR,_.NULL_CELL_WIDTH,_.NULL_CELL_CODE]),this._whitespaceCell=y.CellData.fromCharData([0,_.WHITESPACE_CELL_CHAR,_.WHITESPACE_CELL_WIDTH,_.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,x.reflowLargerGetLinesToRemove)(this.lines,this._cols,d,this.ybase+this.y,this.getNullCell(g.DEFAULT_ATTR_DATA));if(b.length>0){const w=(0,x.reflowLargerCreateNewLayout)(this.lines,b);(0,x.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,x.reflowSmallerGetNewLineLengths)(E,this._cols,d),M=T.length-E.length;let B;B=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+M):Math.max(0,this.lines.length-this.lines.maxLength+M);const D=[];for(let I=0;I<M;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 F=T.length-1,W=T[F];W===0&&(F--,W=T[F]);let A=E.length-M-1,O=L;for(;A>=0;){const I=Math.min(O,W);if(E[F]===void 0)break;if(E[F].copyCellsFrom(E[A],O-I,W-I,I,!0),W-=I,W===0&&(F--,W=T[F]),O-=I,O===0){A--;const $=Math.max(A,0);O=(0,x.getWrappedLineTrimmedLength)(E,$,this._cols)}}for(let I=0;I<E.length;I++)T[I]<d&&E[I].setCell(T[I],b);let P=M-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+M,this.ybase+f-1)}if(w.length>0){const j=[],S=[];for(let F=0;F<this.lines.length;F++)S.push(this.lines.get(F));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 M=0;for(let F=Math.min(this.lines.maxLength-1,E+k-1);F>=0;F--)if(T&&T.start>R+M){for(let W=T.newLines.length-1;W>=0;W--)this.lines.set(F--,T.newLines[W]);F++,j.push({index:R+1,amount:T.newLines.length}),M+=T.newLines.length,T=w[++L]}else this.lines.set(F,S[R--]);let B=0;for(let F=j.length-1;F>=0;F--)j[F].index+=B,this.lines.onInsertEmitter.fire(j[F]),B+=j[F].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 x=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 x=3*a,h.content=this._data[x+0],h.fg=this._data[x+1],h.bg=this._data[x+2],2097152&h.content&&(h.combinedData=this._combined[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,x=l[u+1].getWidth(0)===2;return g&&x?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,x){const y=[];for(let _=0;_<l.length-1;_++){let a=_,h=l.get(++a);if(!h.isWrapped)continue;const d=[l.get(_)];for(;a<l.length&&h.isWrapped;)d.push(h),h=l.get(++a);if(g>=_&&g<a){_+=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,x))}d[f].replaceCells(b,c,x);let j=0;for(let S=d.length-1;S>0&&(S>f||d[S].getTrimmedLength()===0);S--)j++;j>0&&(y.push(_+d.length-j),y.push(j)),_+=d.length-1}return y},i.reflowLargerCreateNewLayout=function(l,u){const c=[];let g=0,x=u[g],y=0;for(let _=0;_<l.length;_++)if(x===_){const a=u[++g];l.onDeleteEmitter.fire({index:_-y,amount:a}),_+=a-1,y+=a,x=u[++g]}else c.push(_);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=[],x=l.map(((h,d)=>n(l,d,u))).reduce(((h,d)=>h+d));let y=0,_=0,a=0;for(;a<x;){if(x-a<c){g.push(x-a);break}y+=c;const h=n(l,_,u);y>h&&(y-=h,_++);const d=l[_].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,_){super(),this._optionsService=y,this._bufferService=_,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,_){this._normal.resize(y,_),this._alt.resize(y,_),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 _=new g;return _.setFromCharData(y),_}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 _=!1;if(y[u.CHAR_DATA_CHAR_INDEX].length>2)_=!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:_=!0}else _=!0}else this.content=y[u.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|y[u.CHAR_DATA_WIDTH_INDEX]<<22;_&&(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(x){this.line=x,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(x){return this._disposables.push(x),x}}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=`
|
|
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 M=this._getMouseBufferCoords(S);return!!M&&(this._selectWordAt(M,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,M=T.lines.get(S[1]);if(!M)return;const B=T.translateBufferLineToString(S[1],!1);let D=this._convertViewportColToCharacterIndex(M,S[0]),F=D;const H=S[0]-D;let A=0,O=0,P=0,I=0;if(B.charAt(D)===" "){for(;D>0&&B.charAt(D-1)===" ";)D--;for(;F<B.length&&B.charAt(F+1)===" ";)F++}else{let U=S[0],X=S[0];M.getWidth(U)===0&&(A++,U--),M.getWidth(X)===2&&(O++,X++);const z=M.getString(X).length;for(z>1&&(I+=z-1,F+=z-1);U>0&&D>0&&!this._isCharWordSeparator(M.loadCell(U-1,this._workCell));){M.loadCell(U-1,this._workCell);const N=this._workCell.getChars().length;this._workCell.getWidth()===0?(A++,U--):N>1&&(P+=N-1,D-=N-1),D--,U--}for(;X<M.length&&F+1<B.length&&!this._isCharWordSeparator(M.loadCell(X+1,this._workCell));){M.loadCell(X+1,this._workCell);const N=this._workCell.getChars().length;this._workCell.getWidth()===2?(O++,X++):N>1&&(I+=N-1,F+=N-1),F++,X++}}F++;let $=D+H-A+P,Y=Math.min(this._bufferService.cols,F-D+A+O-P-I);if(E||B.slice(D,F).trim()!==""){if(R&&$===0&&M.getCodePoint(0)!==32){const U=T.lines.get(S[1]-1);if(U&&M.isWrapped&&U.getCodePoint(this._bufferService.cols-1)!==32){const X=this._getWordAt([this._bufferService.cols-1,S[1]-1],!1,!0,!1);if(X){const z=this._bufferService.cols-X.start;$-=z,Y+=z}}}if(L&&$+Y===this._bufferService.cols&&M.getCodePoint(this._bufferService.cols-1)!==32){const U=T.lines.get(S[1]+1);if(U?.isWrapped&&U.getCodePoint(0)!==32){const X=this._getWordAt([0,S[1]+1],!1,!1,!0);X&&(Y+=X.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,M=T<3?S:R===null?R=Object.getOwnPropertyDescriptor(S,E):R;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")M=Reflect.decorate(j,S,E,R);else for(var B=j.length-1;B>=0;B--)(L=j[B])&&(M=(T<3?L(M):T>3?L(S,E,M):L(S,E))||M);return T>3&&M&&Object.defineProperty(S,E,M),M},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),x=n(8460),y=n(844),_=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 x.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,_.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(x){super(),this._maxLength=x,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(x){if(this._maxLength===x)return;const y=new Array(x);for(let _=0;_<Math.min(x,this.length);_++)y[_]=this._array[this._getCyclicIndex(_)];this._array=y,this._maxLength=x,this._startIndex=0}get length(){return this._length}set length(x){if(x>this._length)for(let y=this._length;y<x;y++)this._array[y]=void 0;this._length=x}get(x){return this._array[this._getCyclicIndex(x)]}set(x,y){this._array[this._getCyclicIndex(x)]=y}push(x){this._array[this._getCyclicIndex(this._length)]=x,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(x,y,..._){if(y){for(let a=x;a<this._length-y;a++)this._array[this._getCyclicIndex(a)]=this._array[this._getCyclicIndex(a+y)];this._length-=y,this.onDeleteEmitter.fire({index:x,amount:y})}for(let a=this._length-1;a>=x;a--)this._array[this._getCyclicIndex(a+_.length)]=this._array[this._getCyclicIndex(a)];for(let a=0;a<_.length;a++)this._array[this._getCyclicIndex(x+a)]=_[a];if(_.length&&this.onInsertEmitter.fire({index:x,amount:_.length}),this._length+_.length>this._maxLength){const a=this._length+_.length-this._maxLength;this._startIndex+=a,this._length=this._maxLength,this.onTrimEmitter.fire(a)}else this._length+=_.length}trimStart(x){x>this._length&&(x=this._length),this._startIndex+=x,this._length-=x,this.onTrimEmitter.fire(x)}shiftElements(x,y,_){if(!(y<=0)){if(x<0||x>=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(_>0){for(let h=y-1;h>=0;h--)this.set(x+h+_,this.get(x+h));const a=x+y+_-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(x+a+_,this.get(x+a))}}_getCyclicIndex(x){return(this._startIndex+x)%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,x=0;var y,_,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 x=Math.round(255*S),[u,c,g]=d.toChannels(j.rgba),{css:y.toCss(u,c,g,x),rgba:y.toRgba(u,c,g,x)}}w.blend=function(j,S){if(x=(255&S.rgba)/255,x===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,M=j.rgba>>16&255,B=j.rgba>>8&255;return u=T+Math.round((E-T)*x),c=M+Math.round((R-M)*x),g=B+Math.round((L-B)*x),{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 x=255&j.rgba,k(j,x*S/255)},w.toColorRGB=function(j){return[j.rgba>>24&255,j.rgba>>16&255,j.rgba>>8&255]}})(_||(i.color=_={})),(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),x=parseInt(S.slice(4,5).repeat(2),16),d.toColor(u,c,g,x);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]),x=Math.round(255*(E[5]===void 0?1:parseFloat(E[5]))),d.toColor(u,c,g,x);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,x]=k.getImageData(0,0,1,1).data,x!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:y.toRgba(u,c,g,x),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,M=S>>8&255;let B=E>>24&255,D=E>>16&255,F=E>>8&255,H=b(h.relativeLuminance2(B,D,F),h.relativeLuminance2(L,T,M));for(;H<R&&(B>0||D>0||F>0);)B-=Math.max(0,Math.ceil(.1*B)),D-=Math.max(0,Math.ceil(.1*D)),F-=Math.max(0,Math.ceil(.1*F)),H=b(h.relativeLuminance2(B,D,F),h.relativeLuminance2(L,T,M));return(B<<24|D<<16|F<<8|255)>>>0}function j(S,E,R){const L=S>>24&255,T=S>>16&255,M=S>>8&255;let B=E>>24&255,D=E>>16&255,F=E>>8&255,H=b(h.relativeLuminance2(B,D,F),h.relativeLuminance2(L,T,M));for(;H<R&&(B<255||D<255||F<255);)B=Math.min(255,B+Math.ceil(.1*(255-B))),D=Math.min(255,D+Math.ceil(.1*(255-D))),F=Math.min(255,F+Math.ceil(.1*(255-F))),H=b(h.relativeLuminance2(B,D,F),h.relativeLuminance2(L,T,M));return(B<<24|D<<16|F<<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),F=b(L,h.relativeLuminance(D>>8));if(F<R){const H=j(S,E,R);return F>b(L,h.relativeLuminance(H>>8))?D:H}return D}const M=j(S,E,R),B=b(L,h.relativeLuminance(M>>8));if(B<R){const D=k(S,E,R);return B>b(L,h.relativeLuminance(D>>8))?M:D}return M}},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),x=n(744),y=n(7302),_=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(x.BufferService)),this._instantiationService.setService(u.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(g.LogService)),this._instantiationService.setService(u.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(_.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,M)=>this._inputHandler.parse(T,M)))),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,x.MINIMUM_COLS),T=Math.max(T,x.MINIMUM_ROWS),this._bufferService.resize(L,T))}scroll(L,T=!1){this._bufferService.scroll(L,T)}scrollLines(L,T,M){this._bufferService.scrollLines(L,T,M)}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,A,O,P){var I,$=arguments.length,Y=$<3?A:P===null?P=Object.getOwnPropertyDescriptor(A,O):P;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")Y=Reflect.decorate(H,A,O,P);else for(var U=H.length-1;U>=0;U--)(I=H[U])&&(Y=($<3?I(Y):$>3?I(A,O,Y):I(A,O))||Y);return $>3&&Y&&Object.defineProperty(A,O,Y),Y},u=this&&this.__param||function(H,A){return function(O,P){A(O,P,H)}};Object.defineProperty(i,"__esModule",{value:!0}),i.InputHandler=i.WindowsOptionsReportType=void 0;const c=n(2584),g=n(7116),x=n(2015),y=n(844),_=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,A){if(H>24)return A.setWinLines||!1;switch(H){case 1:return!!A.restoreWin;case 2:return!!A.minimizeWin;case 3:return!!A.setWinPosition;case 4:return!!A.setWinSizePixels;case 5:return!!A.raiseWin;case 6:return!!A.lowerWin;case 7:return!!A.refreshWin;case 8:return!!A.setWinSizeChars;case 9:return!!A.maximizeWin;case 10:return!!A.fullscreenWin;case 11:return!!A.getWinState;case 13:return!!A.getWinPosition;case 14:return!!A.getWinSizePixels;case 15:return!!A.getScreenSizePixels;case 16:return!!A.getCellSizePixels;case 18:return!!A.getWinSizeChars;case 19:return!!A.getScreenSizeChars;case 20:return!!A.getIconTitle;case 21:return!!A.getWinTitle;case 22:return!!A.pushTitle;case 23:return!!A.popTitle;case 24:return!!A.setWinLines}return!1}var T;(function(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 M=0;class B extends y.Disposable{getAttrData(){return this._curAttrData}constructor(A,O,P,I,$,Y,U,X,z=new x.EscapeSequenceParser){super(),this._bufferService=A,this._charsetService=O,this._coreService=P,this._logService=I,this._optionsService=$,this._oscLinkService=Y,this._coreMouseService=U,this._unicodeService=X,this._parser=z,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new _.StringToUtf32,this._utf8Decoder=new _.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,K)=>{this._logService.debug("Unknown OSC code: ",{identifier:N,action:W,data:K})})),this._parser.setDcsHandlerFallback(((N,W,K)=>{W==="HOOK"&&(K=K.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(N),action:W,payload:K})})),this._parser.setPrintHandler(((N,W,K)=>this.print(N,W,K))),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(A,O,P,I){this._parseStack.paused=!0,this._parseStack.cursorStartX=A,this._parseStack.cursorStartY=O,this._parseStack.decodedLength=P,this._parseStack.position=I}_logSlowResolvingAsync(A){this._logService.logLevel<=w.LogLevelEnum.WARN&&Promise.race([A,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(A,O){let P,I=this._activeBuffer.x,$=this._activeBuffer.y,Y=0;const U=this._parseStack.paused;if(U){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,A.length>R&&(Y=this._parseStack.position+R)}if(this._logService.logLevel<=w.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof A=="string"?` "${A}"`:` "${Array.prototype.map.call(A,(X=>String.fromCharCode(X))).join("")}"`),typeof A=="string"?A.split("").map((X=>X.charCodeAt(0))):A),this._parseBuffer.length<A.length&&this._parseBuffer.length<R&&(this._parseBuffer=new Uint32Array(Math.min(A.length,R))),U||this._dirtyRowTracker.clearRange(),A.length>R)for(let X=Y;X<A.length;X+=R){const z=X+R<A.length?X+R:A.length,N=typeof A=="string"?this._stringDecoder.decode(A.substring(X,z),this._parseBuffer):this._utf8Decoder.decode(A.subarray(X,z),this._parseBuffer);if(P=this._parser.parse(this._parseBuffer,N))return this._preserveStack(I,$,N,X),this._logSlowResolvingAsync(P),P}else if(!U){const X=typeof A=="string"?this._stringDecoder.decode(A,this._parseBuffer):this._utf8Decoder.decode(A,this._parseBuffer);if(P=this._parser.parse(this._parseBuffer,X))return this._preserveStack(I,$,X,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(A,O,P){let I,$;const Y=this._charsetService.charset,U=this._optionsService.rawOptions.screenReaderMode,X=this._bufferService.cols,z=this._coreService.decPrivateModes.wraparound,N=this._coreService.modes.insertMode,W=this._curAttrData;let K=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&P-O>0&&K.getWidth(this._activeBuffer.x-1)===2&&K.setCellFromCodePoint(this._activeBuffer.x-1,0,1,W.fg,W.bg,W.extended);for(let q=O;q<P;++q){if(I=A[q],$=this._unicodeService.wcwidth(I),I<127&&Y){const ie=Y[String.fromCharCode(I)];ie&&(I=ie.charCodeAt(0))}if(U&&this._onA11yChar.fire((0,_.stringFromCodePoint)(I)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),$||!this._activeBuffer.x){if(this._activeBuffer.x+$-1>=X){if(z){for(;this._activeBuffer.x<X;)K.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),K=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)}else if(this._activeBuffer.x=X-1,$===2)continue}if(N&&(K.insertCells(this._activeBuffer.x,$,this._activeBuffer.getNullCell(W),W),K.getWidth(X-1)===2&&K.setCellFromCodePoint(X-1,d.NULL_CELL_CODE,d.NULL_CELL_WIDTH,W.fg,W.bg,W.extended)),K.setCellFromCodePoint(this._activeBuffer.x++,I,$,W.fg,W.bg,W.extended),$>0)for(;--$;)K.setCellFromCodePoint(this._activeBuffer.x++,0,0,W.fg,W.bg,W.extended)}else K.getWidth(this._activeBuffer.x-1)?K.addCodepointToCell(this._activeBuffer.x-1,I):K.addCodepointToCell(this._activeBuffer.x-2,I)}P-O>0&&(K.loadCell(this._activeBuffer.x-1,this._workCell),this._workCell.getWidth()===2||this._workCell.getCode()>65535?this._parser.precedingCodepoint=0:this._workCell.isCombined()?this._parser.precedingCodepoint=this._workCell.getChars().charCodeAt(0):this._parser.precedingCodepoint=this._workCell.content),this._activeBuffer.x<X&&P-O>0&&K.getWidth(this._activeBuffer.x)===0&&!K.hasContent(this._activeBuffer.x)&&K.setCellFromCodePoint(this._activeBuffer.x,0,1,W.fg,W.bg,W.extended),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(A,O){return A.final!=="t"||A.prefix||A.intermediates?this._parser.registerCsiHandler(A,O):this._parser.registerCsiHandler(A,(P=>!L(P.params[0],this._optionsService.rawOptions.windowOptions)||O(P)))}registerDcsHandler(A,O){return this._parser.registerDcsHandler(A,new j.DcsHandler(O))}registerEscHandler(A,O){return this._parser.registerEscHandler(A,O)}registerOscHandler(A,O){return this._parser.registerOscHandler(A,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 A;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&(!((A=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))===null||A===void 0)&&A.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const 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 A=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-A),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(A=this._bufferService.cols-1){this._activeBuffer.x=Math.min(A,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(A,O){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=A,this._activeBuffer.y=this._activeBuffer.scrollTop+O):(this._activeBuffer.x=A,this._activeBuffer.y=O),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(A,O){this._restrictCursor(),this._setCursor(this._activeBuffer.x+A,this._activeBuffer.y+O)}cursorUp(A){const O=this._activeBuffer.y-this._activeBuffer.scrollTop;return O>=0?this._moveCursor(0,-Math.min(O,A.params[0]||1)):this._moveCursor(0,-(A.params[0]||1)),!0}cursorDown(A){const O=this._activeBuffer.scrollBottom-this._activeBuffer.y;return O>=0?this._moveCursor(0,Math.min(O,A.params[0]||1)):this._moveCursor(0,A.params[0]||1),!0}cursorForward(A){return this._moveCursor(A.params[0]||1,0),!0}cursorBackward(A){return this._moveCursor(-(A.params[0]||1),0),!0}cursorNextLine(A){return this.cursorDown(A),this._activeBuffer.x=0,!0}cursorPrecedingLine(A){return this.cursorUp(A),this._activeBuffer.x=0,!0}cursorCharAbsolute(A){return this._setCursor((A.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(A){return this._setCursor(A.length>=2?(A.params[1]||1)-1:0,(A.params[0]||1)-1),!0}charPosAbsolute(A){return this._setCursor((A.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(A){return this._moveCursor(A.params[0]||1,0),!0}linePosAbsolute(A){return this._setCursor(this._activeBuffer.x,(A.params[0]||1)-1),!0}vPositionRelative(A){return this._moveCursor(0,A.params[0]||1),!0}hVPosition(A){return this.cursorPosition(A),!0}tabClear(A){const O=A.params[0];return O===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:O===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(A){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let O=A.params[0]||1;for(;O--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(A){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let O=A.params[0]||1;for(;O--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(A){const O=A.params[0];return O===1&&(this._curAttrData.bg|=536870912),O!==2&&O!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(A,O,P,I=!1,$=!1){const Y=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);Y.replaceCells(O,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),$),I&&(Y.isWrapped=!1)}_resetBufferLine(A,O=!1){const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);P&&(P.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),O),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+A),P.isWrapped=!1)}eraseInDisplay(A,O=!1){let P;switch(this._restrictCursor(this._bufferService.cols),A.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(A,O=!1){switch(this._restrictCursor(this._bufferService.cols),A.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,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(A){this._restrictCursor();let O=A.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(A){this._restrictCursor();let O=A.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(A){this._restrictCursor();const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return O&&(O.insertCells(this._activeBuffer.x,A.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(A){this._restrictCursor();const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return O&&(O.deleteCells(this._activeBuffer.x,A.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(A){let O=A.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(A){let O=A.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(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=A.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(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=A.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(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=A.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(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=A.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(A){this._restrictCursor();const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return O&&(O.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(A.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(A){if(!this._parser.precedingCodepoint)return!0;const O=A.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(A){return A.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(c.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(c.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(A){return A.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(c.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(c.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(A.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(c.C0.ESC+"[>83;40003;0c")),!0}_is(A){return(this._optionsService.rawOptions.termName+"").indexOf(A)===0}setMode(A){for(let O=0;O<A.length;O++)switch(A.params[O]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(A){for(let O=0;O<A.length;O++)switch(A.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(A){for(let O=0;O<A.length;O++)switch(A.params[O]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(A){for(let O=0;O<A.length;O++)switch(A.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(),A.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(A,O){const P=this._coreService.decPrivateModes,{activeProtocol:I,activeEncoding:$}=this._coreMouseService,Y=this._coreService,{buffers:U,cols:X}=this._bufferService,{active:z,alt:N}=U,W=this._optionsService.rawOptions,K=se=>se?1:2,q=A.params[0];return ie=q,Q=O?q===2?4:q===4?K(Y.modes.insertMode):q===12?3:q===20?K(W.convertEol):0:q===1?K(P.applicationCursorKeys):q===3?W.windowOptions.setWinLines?X===80?2:X===132?1:0:0:q===6?K(P.origin):q===7?K(P.wraparound):q===8?3:q===9?K(I==="X10"):q===12?K(W.cursorBlink):q===25?K(!Y.isCursorHidden):q===45?K(P.reverseWraparound):q===66?K(P.applicationKeypad):q===67?4:q===1e3?K(I==="VT200"):q===1002?K(I==="DRAG"):q===1003?K(I==="ANY"):q===1004?K(P.sendFocus):q===1005?4:q===1006?K($==="SGR"):q===1015?4:q===1016?K($==="SGR_PIXELS"):q===1048?1:q===47||q===1047||q===1049?K(z===N):q===2004?K(P.bracketedPasteMode):0,Y.triggerDataEvent(`${c.C0.ESC}[${O?"":"?"}${ie};${Q}$y`),!0;var ie,Q}_updateAttrColor(A,O,P,I,$){return O===2?(A|=50331648,A&=-16777216,A|=b.AttributeData.fromColorRGB([P,I,$])):O===5&&(A&=-50331904,A|=33554432|255&P),A}_extractColor(A,O,P){const I=[0,0,-1,0,0,0];let $=0,Y=0;do{if(I[Y+$]=A.params[O+Y],A.hasSubParams(O+Y)){const U=A.getSubParams(O+Y);let X=0;do I[1]===5&&($=1),I[Y+X+1+$]=U[X];while(++X<U.length&&X+Y+1+$<I.length);break}if(I[1]===5&&Y+$>=2||I[1]===2&&Y+$>=5)break;I[1]&&($=1)}while(++Y+O<A.length&&Y+$<I.length);for(let U=2;U<I.length;++U)I[U]===-1&&(I[U]=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(A,O){O.extended=O.extended.clone(),(!~A||A>5)&&(A=1),O.extended.underlineStyle=A,O.fg|=268435456,A===0&&(O.fg&=-268435457),O.updateExtended()}_processSGR0(A){A.fg=a.DEFAULT_ATTR_DATA.fg,A.bg=a.DEFAULT_ATTR_DATA.bg,A.extended=A.extended.clone(),A.extended.underlineStyle=0,A.extended.underlineColor&=-67108864,A.updateExtended()}charAttributes(A){if(A.length===1&&A.params[0]===0)return this._processSGR0(this._curAttrData),!0;const O=A.length;let P;const I=this._curAttrData;for(let $=0;$<O;$++)P=A.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(A.hasSubParams($)?A.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(A,$,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(A){switch(A.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(A){if(A.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(A){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(A){const O=A.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(A){const O=A.params[0]||1;let P;return(A.length<2||(P=A.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(A){if(!L(A.params[0],this._optionsService.rawOptions.windowOptions))return!0;const O=A.length>1?A.params[1]:0;switch(A.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(A){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(A){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(A){return this._windowTitle=A,this._onTitleChange.fire(A),!0}setIconName(A){return this._iconName=A,!0}setOrReportIndexedColor(A){const O=[],P=A.split(";");for(;P.length>1;){const I=P.shift(),$=P.shift();if(/^\d+$/.exec(I)){const Y=parseInt(I);if(F(Y))if($==="?")O.push({type:0,index:Y});else{const U=(0,S.parseColor)($);U&&O.push({type:1,index:Y,color:U})}}}return O.length&&this._onColor.fire(O),!0}setHyperlink(A){const O=A.split(";");return!(O.length<2)&&(O[1]?this._createHyperlink(O[0],O[1]):!O[0]&&this._finishHyperlink())}_createHyperlink(A,O){this._getCurrentLinkId()&&this._finishHyperlink();const P=A.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(A,O){const P=A.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(A){return this._setOrReportSpecialColor(A,0)}setOrReportBgColor(A){return this._setOrReportSpecialColor(A,1)}setOrReportCursorColor(A){return this._setOrReportSpecialColor(A,2)}restoreIndexedColor(A){if(!A)return this._onColor.fire([{type:2}]),!0;const O=[],P=A.split(";");for(let I=0;I<P.length;++I)if(/^\d+$/.exec(P[I])){const $=parseInt(P[I]);F($)&&O.push({type:2,index:$})}return O.length&&this._onColor.fire(O),!0}restoreFgColor(A){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(A){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(A){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,g.DEFAULT_CHARSET),!0}selectCharset(A){return A.length!==2?(this.selectDefaultCharset(),!0):(A[0]==="/"||this._charsetService.setgCharset(E[A[0]],g.CHARSETS[A[1]]||g.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){const A=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,A,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=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(A){return this._charsetService.setgLevel(A),!0}screenAlignmentPattern(){const A=new f.CellData;A.content=4194373,A.fg=this._curAttrData.fg,A.bg=this._curAttrData.bg,this._setCursor(0,0);for(let 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(A),I.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(A,O){const P=this._bufferService.buffer,I=this._optionsService.rawOptions;return($=>(this._coreService.triggerDataEvent(`${c.C0.ESC}${$}${c.C0.ESC}\\`),!0))(A==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:A==='"p'?'P1$r61;1"p':A==="r"?`P1$r${P.scrollTop+1};${P.scrollBottom+1}r`:A==="m"?"P1$r0m":A===" q"?`P1$r${{block:2,underline:4,bar:6}[I.cursorStyle]-(I.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(A,O){this._dirtyRowTracker.markRangeDirty(A,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,A){H>A&&(M=H,H=A,A=M),H<this.start&&(this.start=H),A>this.end&&(this.end=A)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function F(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,x){this._data.get(l,u)||this._data.set(l,u,new n),this._data.get(l,u).set(c,g,x)}get(l,u,c,g){var x;return(x=this._data.get(l,u))===null||x===void 0?void 0:x.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 x=this._getKey(this._array[g]);if(x>l)c=g-1;else{if(!(x<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(x){this._tasks.push(x),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(x){this._idleCallback=void 0;let y=0,_=0,a=x.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),_=Math.max(y,_),h=x.timeRemaining(),1.5*_>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(x){return setTimeout((()=>x(this._createDeadline(16))))}_cancelCallback(x){clearTimeout(x)}_createDeadline(x){const y=Date.now()+x;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),x=u.buffer.lines.get(u.buffer.ybase+u.buffer.y);x&&g&&(x.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),x=n(4634),y=n(511),_=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,_.NULL_CELL_CHAR,_.NULL_CELL_WIDTH,_.NULL_CELL_CODE]),this._whitespaceCell=y.CellData.fromCharData([0,_.WHITESPACE_CELL_CHAR,_.WHITESPACE_CELL_WIDTH,_.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,x.reflowLargerGetLinesToRemove)(this.lines,this._cols,d,this.ybase+this.y,this.getNullCell(g.DEFAULT_ATTR_DATA));if(b.length>0){const w=(0,x.reflowLargerCreateNewLayout)(this.lines,b);(0,x.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,x.reflowSmallerGetNewLineLengths)(E,this._cols,d),M=T.length-E.length;let B;B=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+M):Math.max(0,this.lines.length-this.lines.maxLength+M);const D=[];for(let I=0;I<M;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 F=T.length-1,H=T[F];H===0&&(F--,H=T[F]);let A=E.length-M-1,O=L;for(;A>=0;){const I=Math.min(O,H);if(E[F]===void 0)break;if(E[F].copyCellsFrom(E[A],O-I,H-I,I,!0),H-=I,H===0&&(F--,H=T[F]),O-=I,O===0){A--;const $=Math.max(A,0);O=(0,x.getWrappedLineTrimmedLength)(E,$,this._cols)}}for(let I=0;I<E.length;I++)T[I]<d&&E[I].setCell(T[I],b);let P=M-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+M,this.ybase+f-1)}if(w.length>0){const j=[],S=[];for(let F=0;F<this.lines.length;F++)S.push(this.lines.get(F));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 M=0;for(let F=Math.min(this.lines.maxLength-1,E+k-1);F>=0;F--)if(T&&T.start>R+M){for(let H=T.newLines.length-1;H>=0;H--)this.lines.set(F--,T.newLines[H]);F++,j.push({index:R+1,amount:T.newLines.length}),M+=T.newLines.length,T=w[++L]}else this.lines.set(F,S[R--]);let B=0;for(let F=j.length-1;F>=0;F--)j[F].index+=B,this.lines.onInsertEmitter.fire(j[F]),B+=j[F].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 x=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 x=3*a,h.content=this._data[x+0],h.fg=this._data[x+1],h.bg=this._data[x+2],2097152&h.content&&(h.combinedData=this._combined[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,x=l[u+1].getWidth(0)===2;return g&&x?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,x){const y=[];for(let _=0;_<l.length-1;_++){let a=_,h=l.get(++a);if(!h.isWrapped)continue;const d=[l.get(_)];for(;a<l.length&&h.isWrapped;)d.push(h),h=l.get(++a);if(g>=_&&g<a){_+=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,x))}d[f].replaceCells(b,c,x);let j=0;for(let S=d.length-1;S>0&&(S>f||d[S].getTrimmedLength()===0);S--)j++;j>0&&(y.push(_+d.length-j),y.push(j)),_+=d.length-1}return y},i.reflowLargerCreateNewLayout=function(l,u){const c=[];let g=0,x=u[g],y=0;for(let _=0;_<l.length;_++)if(x===_){const a=u[++g];l.onDeleteEmitter.fire({index:_-y,amount:a}),_+=a-1,y+=a,x=u[++g]}else c.push(_);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=[],x=l.map(((h,d)=>n(l,d,u))).reduce(((h,d)=>h+d));let y=0,_=0,a=0;for(;a<x;){if(x-a<c){g.push(x-a);break}y+=c;const h=n(l,_,u);y>h&&(y-=h,_++);const d=l[_].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,_){super(),this._optionsService=y,this._bufferService=_,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,_){this._normal.resize(y,_),this._alt.resize(y,_),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 _=new g;return _.setFromCharData(y),_}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 _=!1;if(y[u.CHAR_DATA_CHAR_INDEX].length>2)_=!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:_=!0}else _=!0}else this.content=y[u.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|y[u.CHAR_DATA_WIDTH_INDEX]<<22;_&&(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(x){this.line=x,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(x){return this._disposables.push(x),x}}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
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,x,y){const _={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"?_.key=g?l.C0.ESC+"OA":l.C0.ESC+"[A":c.key==="UIKeyInputLeftArrow"?_.key=g?l.C0.ESC+"OD":l.C0.ESC+"[D":c.key==="UIKeyInputRightArrow"?_.key=g?l.C0.ESC+"OC":l.C0.ESC+"[C":c.key==="UIKeyInputDownArrow"&&(_.key=g?l.C0.ESC+"OB":l.C0.ESC+"[B");break;case 8:if(c.altKey){_.key=l.C0.ESC+l.C0.DEL;break}_.key=l.C0.DEL;break;case 9:if(c.shiftKey){_.key=l.C0.ESC+"[Z";break}_.key=l.C0.HT,_.cancel=!0;break;case 13:_.key=c.altKey?l.C0.ESC+l.C0.CR:l.C0.CR,_.cancel=!0;break;case 27:_.key=l.C0.ESC,c.altKey&&(_.key=l.C0.ESC+l.C0.ESC),_.cancel=!0;break;case 37:if(c.metaKey)break;a?(_.key=l.C0.ESC+"[1;"+(a+1)+"D",_.key===l.C0.ESC+"[1;3D"&&(_.key=l.C0.ESC+(x?"b":"[1;5D"))):_.key=g?l.C0.ESC+"OD":l.C0.ESC+"[D";break;case 39:if(c.metaKey)break;a?(_.key=l.C0.ESC+"[1;"+(a+1)+"C",_.key===l.C0.ESC+"[1;3C"&&(_.key=l.C0.ESC+(x?"f":"[1;5C"))):_.key=g?l.C0.ESC+"OC":l.C0.ESC+"[C";break;case 38:if(c.metaKey)break;a?(_.key=l.C0.ESC+"[1;"+(a+1)+"A",x||_.key!==l.C0.ESC+"[1;3A"||(_.key=l.C0.ESC+"[1;5A")):_.key=g?l.C0.ESC+"OA":l.C0.ESC+"[A";break;case 40:if(c.metaKey)break;a?(_.key=l.C0.ESC+"[1;"+(a+1)+"B",x||_.key!==l.C0.ESC+"[1;3B"||(_.key=l.C0.ESC+"[1;5B")):_.key=g?l.C0.ESC+"OB":l.C0.ESC+"[B";break;case 45:c.shiftKey||c.ctrlKey||(_.key=l.C0.ESC+"[2~");break;case 46:_.key=a?l.C0.ESC+"[3;"+(a+1)+"~":l.C0.ESC+"[3~";break;case 36:_.key=a?l.C0.ESC+"[1;"+(a+1)+"H":g?l.C0.ESC+"OH":l.C0.ESC+"[H";break;case 35:_.key=a?l.C0.ESC+"[1;"+(a+1)+"F":g?l.C0.ESC+"OF":l.C0.ESC+"[F";break;case 33:c.shiftKey?_.type=2:c.ctrlKey?_.key=l.C0.ESC+"[5;"+(a+1)+"~":_.key=l.C0.ESC+"[5~";break;case 34:c.shiftKey?_.type=3:c.ctrlKey?_.key=l.C0.ESC+"[6;"+(a+1)+"~":_.key=l.C0.ESC+"[6~";break;case 112:_.key=a?l.C0.ESC+"[1;"+(a+1)+"P":l.C0.ESC+"OP";break;case 113:_.key=a?l.C0.ESC+"[1;"+(a+1)+"Q":l.C0.ESC+"OQ";break;case 114:_.key=a?l.C0.ESC+"[1;"+(a+1)+"R":l.C0.ESC+"OR";break;case 115:_.key=a?l.C0.ESC+"[1;"+(a+1)+"S":l.C0.ESC+"OS";break;case 116:_.key=a?l.C0.ESC+"[15;"+(a+1)+"~":l.C0.ESC+"[15~";break;case 117:_.key=a?l.C0.ESC+"[17;"+(a+1)+"~":l.C0.ESC+"[17~";break;case 118:_.key=a?l.C0.ESC+"[18;"+(a+1)+"~":l.C0.ESC+"[18~";break;case 119:_.key=a?l.C0.ESC+"[19;"+(a+1)+"~":l.C0.ESC+"[19~";break;case 120:_.key=a?l.C0.ESC+"[20;"+(a+1)+"~":l.C0.ESC+"[20~";break;case 121:_.key=a?l.C0.ESC+"[21;"+(a+1)+"~":l.C0.ESC+"[21~";break;case 122:_.key=a?l.C0.ESC+"[23;"+(a+1)+"~":l.C0.ESC+"[23~";break;case 123:_.key=a?l.C0.ESC+"[24;"+(a+1)+"~":l.C0.ESC+"[24~";break;default:if(!c.ctrlKey||c.shiftKey||c.altKey||c.metaKey)if(x&&!y||!c.altKey||c.metaKey)!x||c.altKey||c.ctrlKey||c.shiftKey||!c.metaKey?c.key&&!c.ctrlKey&&!c.altKey&&!c.metaKey&&c.keyCode>=48&&c.key.length===1?_.key=c.key:c.key&&c.ctrlKey&&(c.key==="_"&&(_.key=l.C0.US),c.key==="@"&&(_.key=l.C0.NUL)):c.keyCode===65&&(_.type=1);else{const h=u[c.keyCode],d=h?.[c.shiftKey?1:0];if(d)_.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()),_.key=l.C0.ESC+b}else if(c.keyCode===32)_.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()),_.key=l.C0.ESC+f,_.cancel=!0}}else c.keyCode>=65&&c.keyCode<=90?_.key=String.fromCharCode(c.keyCode-64):c.keyCode===32?_.key=l.C0.NUL:c.keyCode>=51&&c.keyCode<=55?_.key=String.fromCharCode(c.keyCode-51+27):c.keyCode===56?_.key=l.C0.DEL:c.keyCode===219?_.key=l.C0.ESC:c.keyCode===220?_.key=l.C0.FS:c.keyCode===221&&(_.key=l.C0.GS)}return _}},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 x=n[g];x>65535?(x-=65536,c+=String.fromCharCode(55296+(x>>10))+String.fromCharCode(x%1024+56320)):c+=String.fromCharCode(x)}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 x=n.charCodeAt(g++);56320<=x&&x<=57343?l[c++]=1024*(this._interim-55296)+x-56320+65536:(l[c++]=this._interim,l[c++]=x),this._interim=0}for(let x=g;x<u;++x){const y=n.charCodeAt(x);if(55296<=y&&y<=56319){if(++x>=u)return this._interim=y,c;const _=n.charCodeAt(x);56320<=_&&_<=57343?l[c++]=1024*(y-55296)+_-56320+65536:(l[c++]=y,l[c++]=_)}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,x,y,_=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[_++]=w:S===3?w<2048||w>=55296&&w<=57343||w===65279||(l[_++]=w):w<65536||w>1114111||(l[_++]=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&(x=n[f+2])||128&(y=n[f+3]));)l[_++]=c,l[_++]=g,l[_++]=x,l[_++]=y,f+=4;if(c=n[f++],c<128)l[_++]=c;else if((224&c)==192){if(f>=u)return this.interim[0]=c,_;if(g=n[f++],(192&g)!=128){f--;continue}if(a=(31&c)<<6|63&g,a<128){f--;continue}l[_++]=a}else if((240&c)==224){if(f>=u)return this.interim[0]=c,_;if(g=n[f++],(192&g)!=128){f--;continue}if(f>=u)return this.interim[0]=c,this.interim[1]=g,_;if(x=n[f++],(192&x)!=128){f--;continue}if(a=(15&c)<<12|(63&g)<<6|63&x,a<2048||a>=55296&&a<=57343||a===65279)continue;l[_++]=a}else if((248&c)==240){if(f>=u)return this.interim[0]=c,_;if(g=n[f++],(192&g)!=128){f--;continue}if(f>=u)return this.interim[0]=c,this.interim[1]=g,_;if(x=n[f++],(192&x)!=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&x)<<6|63&y,a<65536||a>1114111)continue;l[_++]=a}}return _}}},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,x){let y,_=0,a=x.length-1;if(g<x[0][0]||g>x[a][1])return!1;for(;a>=_;)if(y=_+a>>1,g>x[y][1])_=y+1;else{if(!(g<x[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(x){super(),this._action=x,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new l.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(x,y){if(y!==void 0&&this._syncCalls>y)return void(this._syncCalls=0);if(this._pendingData+=x.length,this._writeBuffer.push(x),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let _;for(this._isSyncWriting=!0;_=this._writeBuffer.shift();){this._action(_);const a=this._callbacks.shift();a&&a()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(x,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+=x.length,this._writeBuffer.push(x),this._callbacks.push(y),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=x.length,this._writeBuffer.push(x),this._callbacks.push(y)}_innerWrite(x=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()-_>=12?setTimeout((()=>this._innerWrite(0,b))):this._innerWrite(_,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()-_>=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 x=c.toString(16),y=x.length<2?"0"+x:x;switch(g){case 4:return x[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 x=n.exec(g);if(x){const y=x[1]?15:x[4]?255:x[7]?4095:65535;return[Math.round(parseInt(x[1]||x[4]||x[7]||x[10],16)/y*255),Math.round(parseInt(x[2]||x[5]||x[8]||x[11],16)/y*255),Math.round(parseInt(x[3]||x[6]||x[9]||x[12],16)/y*255)]}}else if(g.indexOf("#")===0&&(g=g.slice(1),l.exec(g)&&[3,6,9,12].includes(g.length))){const x=g.length/3,y=[0,0,0];for(let _=0;_<3;++_){const a=parseInt(g.slice(x*_,x*_+x),16);y[_]=x===1?a<<4:x===2?a:x===3?a>>4:a>>8}return y}},i.toRgbString=function(c,g=16){const[x,y,_]=c;return`rgb:${u(x,g)}/${u(y,g)}/${u(_,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,_){this._handlers[y]===void 0&&(this._handlers[y]=[]);const a=this._handlers[y];return a.push(_),{dispose:()=>{const h=a.indexOf(_);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,_){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(_);else this._handlerFb(this._ident,"HOOK",_)}put(y,_,a){if(this._active.length)for(let h=this._active.length-1;h>=0;h--)this._active[h].put(y,_,a);else this._handlerFb(this._ident,"PUT",(0,l.utf32ToString)(y,_,a))}unhook(y,_=!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=_,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 x=new u.Params;x.addParam(0),i.DcsHandler=class{constructor(y){this._handler=y,this._data="",this._params=x,this._hitLimit=!1}hook(y){this._params=y.length>1||y.params[0]?y.clone():x,this._data="",this._hitLimit=!1}put(y,_,a){this._hitLimit||(this._data+=(0,l.utf32ToString)(y,_,a),this._data.length>c.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(y){let _=!1;if(this._hitLimit)_=!1;else if(y&&(_=this._handler(this._data,this._params),_ instanceof Promise))return _.then((a=>(this._params=x,this._data="",this._hitLimit=!1,a)));return this._params=x,this._data="",this._hitLimit=!1,_}}},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 x{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=x;const y=160;i.VT500_TRANSITION_TABLE=(function(){const a=new x(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 _ 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 M=S+1;;++M){if(M>=d||(w=h[M])<32||w>126&&w<y){this._printHandler(h,S,M),S=M-1;break}if(++M>=d||(w=h[M])<32||w>126&&w<y){this._printHandler(h,S,M),S=M-1;break}if(++M>=d||(w=h[M])<32||w>126&&w<y){this._printHandler(h,S,M),S=M-1;break}if(++M>=d||(w=h[M])<32||w>126&&w<y){this._printHandler(h,S,M),S=M-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 M=S+1;;++M)if(M>=d||(w=h[M])===24||w===26||w===27||w>127&&w<y){this._dcsParser.put(h,S,M),S=M-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 M=S+1;;M++)if(M>=d||(w=h[M])<32||w>127&&w<y){this._oscParser.put(h,S,M),S=M-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=_},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,x){this._handlers[g]===void 0&&(this._handlers[g]=[]);const y=this._handlers[g];return y.push(x),{dispose:()=>{const _=y.indexOf(x);_!==-1&&y.splice(_,1)}}}clearHandler(g){this._handlers[g]&&delete this._handlers[g]}setHandlerFallback(g){this._handlerFb=g}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=c}reset(){if(this._state===2)for(let g=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;g>=0;--g)this._active[g].end(!1);this._stack.paused=!1,this._active=c,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||c,this._active.length)for(let g=this._active.length-1;g>=0;g--)this._active[g].start();else this._handlerFb(this._id,"START")}_put(g,x,y){if(this._active.length)for(let _=this._active.length-1;_>=0;_--)this._active[_].put(g,x,y);else this._handlerFb(this._id,"PUT",(0,u.utf32ToString)(g,x,y))}start(){this.reset(),this._state=1}put(g,x,y){if(this._state!==3){if(this._state===1)for(;x<y;){const _=g[x++];if(_===59){this._state=2,this._start();break}if(_<48||57<_)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+_-48}this._state===2&&y-x>0&&this._put(g,x,y)}}end(g,x=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let y=!1,_=this._active.length-1,a=!1;if(this._stack.paused&&(_=this._stack.loopPosition-1,y=x,a=this._stack.fallThrough,this._stack.paused=!1),!a&&y===!1){for(;_>=0&&(y=this._active[_].end(g),y!==!0);_--)if(y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=_,this._stack.fallThrough=!1,y;_--}for(;_>=0;_--)if(y=this._active[_].end(!1),y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=_,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,x,y){this._hitLimit||(this._data+=(0,u.utf32ToString)(g,x,y),this._data.length>l.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(g){let x=!1;if(this._hitLimit)x=!1;else if(g&&(x=this._handler(this._data),x instanceof Promise))return x.then((y=>(this._data="",this._hitLimit=!1,y)));return this._data="",this._hitLimit=!1,x}}},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 x=Array.isArray(c[0])?1:0;x<c.length;++x){const y=c[x];if(Array.isArray(y))for(let _=0;_<y.length;++_)g.addSubParam(y[_]);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 x=this._subParamsIdx[g]>>8,y=255&this._subParamsIdx[g];y-x>0&&c.push(Array.prototype.slice.call(this._subParams,x,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,x=255&this._subParamsIdx[c];return x-g>0?this._subParams.subarray(g,x):null}getSubParamsAll(){const c={};for(let g=0;g<this.length;++g){const x=this._subParamsIdx[g]>>8,y=255&this._subParamsIdx[g];y-x>0&&(c[g]=this._subParams.slice(x,y))}return c}addDigit(c){let g;if(this._rejectDigits||!(g=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const x=this._digitIsSub?this._subParams:this.params,y=x[g-1];x[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),x=n(5295),y=n(2585);i.MINIMUM_COLS=2,i.MINIMUM_ROWS=1;let _=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 x.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=_=l([u(0,y.IOptionsService)],_)},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),x=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 _(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=[_(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[<${_(f,!0)};${f.col};${f.row}${b}`},SGR_PIXELS:f=>{const b=f.action===0&&f.button!==4?"m":"M";return`\x1B[<${_(f,!0)};${f.x};${f.y}${b}`}};let d=i.CoreMouseService=class extends x.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),x=n(844),y=n(2585),_=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 x.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)(_),this.decPrivateModes=(0,c.clone)(a)}reset(){this.modes=(0,c.clone)(_),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 x=0,y=0;class _ 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;x=(j=k.options.x)!==null&&j!==void 0?j:0,y=x+((S=k.options.width)!==null&&S!==void 0?S:1),d>=x&&d<y&&(!b||((E=k.options.layer)!==null&&E!==void 0?E:"bottom")===b)&&w(k)}))}}i.DecorationService=_;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(...x){this._entries=new Map;for(const[y,_]of x)this.set(y,_)}set(x,y){const _=this._entries.get(x);return this._entries.set(x,y),_}forEach(x){for(const[y,_]of this._entries.entries())x(y,_)}has(x){return this._entries.has(x)}get(x){return this._entries.get(x)}}i.ServiceCollection=c,i.InstantiationService=class{constructor(){this._services=new c,this._services.set(l.IInstantiationService,this)}setService(g,x){this._services.set(g,x)}getService(g){return this._services.get(g)}createInstance(g,...x){const y=(0,u.getServiceDependencies)(g).sort(((h,d)=>h.index-d.index)),_=[];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}.`);_.push(d)}const a=y.length>0?y[0].index:x.length;if(x.length!==a)throw new Error(`[createInstance] First service dependency of ${g.name} at position ${a+1} conflicts with ${x.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),x={trace:g.LogLevelEnum.TRACE,debug:g.LogLevelEnum.DEBUG,info:g.LogLevelEnum.INFO,warn:g.LogLevelEnum.WARN,error:g.LogLevelEnum.ERROR,off:g.LogLevelEnum.OFF};let y,_=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=x[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=_=l([u(0,g.IOptionsService)],_),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 x extends u.Disposable{constructor(_){super(),this._onOptionChange=this.register(new l.EventEmitter),this.onOptionChange=this._onOptionChange.event;const a=Object.assign({},i.DEFAULT_OPTIONS);for(const h in _)if(h in a)try{const d=_[h];a[h]=this._sanitizeAndValidateOption(h,d)}catch(d){console.error(d)}this.rawOptions=a,this.options=Object.assign({},a),this._setupOptions()}onSpecificOptionChange(_,a){return this.onOptionChange((h=>{h===_&&a(this.rawOptions[_])}))}onMultipleOptionChange(_,a){return this.onOptionChange((h=>{_.indexOf(h)!==-1&&a()}))}_setupOptions(){const _=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:_.bind(this,h),set:a.bind(this,h)};Object.defineProperty(this.options,h,d)}}_sanitizeAndValidateOption(_,a){switch(_){case"cursorStyle":if(a||(a=i.DEFAULT_OPTIONS[_]),!(function(h){return h==="block"||h==="underline"||h==="bar"})(a))throw new Error(`"${a}" is not a valid value for ${_}`);break;case"wordSeparator":a||(a=i.DEFAULT_OPTIONS[_]);break;case"fontWeight":case"fontWeightBold":if(typeof a=="number"&&1<=a&&a<=1e3)break;a=g.includes(a)?a:i.DEFAULT_OPTIONS[_];break;case"cursorWidth":a=Math.floor(a);case"lineHeight":case"tabStopWidth":if(a<1)throw new Error(`${_} 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(`${_} cannot be less than 0, value: ${a}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(a<=0)throw new Error(`${_} cannot be less than or equal to 0, value: ${a}`);break;case"rows":case"cols":if(!a&&a!==0)throw new Error(`${_} must be numeric, value: ${a}`);break;case"windowsPty":a=a??{}}return a}}i.OptionsService=x},2660:function(v,i,n){var l=this&&this.__decorate||function(x,y,_,a){var h,d=arguments.length,f=d<3?y:a===null?a=Object.getOwnPropertyDescriptor(y,_):a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")f=Reflect.decorate(x,y,_,a);else for(var b=x.length-1;b>=0;b--)(h=x[b])&&(f=(d<3?h(f):d>3?h(y,_,f):h(y,_))||f);return d>3&&f&&Object.defineProperty(y,_,f),f},u=this&&this.__param||function(x,y){return function(_,a){y(_,a,x)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OscLinkService=void 0;const c=n(2585);let g=i.OscLinkService=class{constructor(x){this._bufferService=x,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(x){const y=this._bufferService.buffer;if(x.id===void 0){const b=y.addMarker(y.ybase+y.y),w={data:x,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(_),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(_),data:_,lines:[d]};return d.onDispose((()=>this._removeMarkerFromLink(f,d))),this._entriesWithId.set(f.key,f),this._dataByLinkId.set(f.id,f),f.id}addLineToLink(x,y){const _=this._dataByLinkId.get(x);if(_&&_.lines.every((a=>a.line!==y))){const a=this._bufferService.buffer.addMarker(y);_.lines.push(a),a.onDispose((()=>this._removeMarkerFromLink(_,a)))}}getLinkData(x){var y;return(y=this._dataByLinkId.get(x))===null||y===void 0?void 0:y.data}_getEntryIdKey(x){return`${x.id};;${x.uri}`}_removeMarkerFromLink(x,y){const _=x.lines.indexOf(y);_!==-1&&(x.lines.splice(_,1),x.lines.length===0&&(x.data.id!==void 0&&this._entriesWithId.delete(x.key),this._dataByLinkId.delete(x.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,x,y){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(_,a,h){a[n]===a?a[l].push({id:_,index:h}):(a[l]=[{id:_,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 x=c.length;for(let y=0;y<x;++y){let _=c.charCodeAt(y);if(55296<=_&&_<=56319){if(++y>=x)return g+this.wcwidth(_);const a=c.charCodeAt(y);56320<=a&&a<=57343?_=1024*(_-55296)+a-56320+65536:g+=this.wcwidth(a)}g+=this.wcwidth(_)}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),x=p(7090),y=["cols","rows"];class _ 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 x.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this.register(new c.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const h=this._core.coreService.decPrivateModes;let d="none";switch(this._core.coreMouseService.activeProtocol){case"X10":d="x10";break;case"VT200":d="vt200";break;case"DRAG":d="drag";break;case"ANY":d="any"}return{applicationCursorKeysMode:h.applicationCursorKeys,applicationKeypadMode:h.applicationKeypad,bracketedPasteMode:h.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:d,originMode:h.origin,reverseWraparoundMode:h.reverseWraparound,sendFocusMode:h.sendFocus,wraparoundMode:h.wraparound}}get options(){return this._publicOptions}set options(h){for(const d in h)this._publicOptions[d]=h[d]}blur(){this._core.blur()}focus(){this._core.focus()}resize(h,d){this._verifyIntegers(h,d),this._core.resize(h,d)}open(h){this._core.open(h)}attachCustomKeyEventHandler(h){this._core.attachCustomKeyEventHandler(h)}registerLinkProvider(h){return this._core.registerLinkProvider(h)}registerCharacterJoiner(h){return this._checkProposedApi(),this._core.registerCharacterJoiner(h)}deregisterCharacterJoiner(h){this._checkProposedApi(),this._core.deregisterCharacterJoiner(h)}registerMarker(h=0){return this._verifyIntegers(h),this._core.registerMarker(h)}registerDecoration(h){var d,f,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=_})(),m})()))})(
|
|
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=_})(),m})()))})(Ci)),Ci.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,x]=C.useState(!1),[y,_]=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),_(!0)},S=()=>{l(!1),c(!1)},E=M=>{M.terminalId===v&&a.current.onOutput?.(M.data)},R=M=>{M.terminalId===v&&(c(!1),a.current.onExit?.(M.exitCode),i(null))},L=M=>{M.terminalId===v&&c(!0)},T=M=>{M.terminalId===v&&c(!1)};return k.on("connect",j),k.on("disconnect",S),k.on(dt.TERMINAL_STDOUT,E),k.on(dt.TERMINAL_EXIT,R),k.on(dt.TERMINAL_SUBSCRIBED,L),k.on(dt.TERMINAL_UNSUBSCRIBED,T),l(k.connected),k.connected&&k.emit(ks.SUBSCRIBE,{topic:"terminal",id:v},M=>{M.success&&c(!0)}),()=>{k.off("connect",j),k.off("disconnect",S),k.off(dt.TERMINAL_STDOUT,E),k.off(dt.TERMINAL_EXIT,R),k.off(dt.TERMINAL_SUBSCRIBED,L),k.off(dt.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;x(!0);try{const j=await xe.post("/terminals",{socketId:k.id,cwd:s,cols:r,rows:o});return i(j.terminalId),_(!1),j.terminalId}catch(j){return console.error("[useStandaloneTerminal] Failed to create terminal:",j),null}finally{x(!1)}},[s,r,o]),f=C.useCallback(async()=>{const k=h.current;if(k){try{await xe.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&&xe.delete(`/terminals/${k}`).catch(()=>{})},[]),{terminalId:v,isConnected:n,isAttached:u,isCreating:g,needsRecreate:y,create:d,destroy:f,sendInput:b,resize:w}}function Pm({terminalRef:e,xtermRef:s,fitAddonRef:r,isVisible:o=!0,onResize:p}){const m=C.useRef(null),v=C.useRef(null),i=C.useRef(0),n=C.useCallback(()=>{m.current!=null&&(window.clearTimeout(m.current),m.current=null),v.current!=null&&(window.cancelAnimationFrame(v.current),v.current=null)},[]),l=C.useCallback(()=>{const g=r.current,x=s.current,y=e.current;if(!g||!x||!y||y.clientWidth<=0||y.clientHeight<=0)return!1;try{return g.fit(),x.cols>0&&x.rows>0&&p(x.cols,x.rows),!0}catch{return!1}},[r,p,e,s]),u=C.useCallback((g=6)=>{n();const x=i.current+1;i.current=x;let y=0;const _=()=>{i.current===x&&(v.current=window.requestAnimationFrame(()=>{if(v.current=null,i.current!==x)return;const a=l(),h=y<2;y<g&&(!a||h)&&(y+=1,m.current=window.setTimeout(_,50))}))};_()},[n,l]),c=C.useCallback(()=>{i.current+=1,n()},[n]);return C.useEffect(()=>c,[c]),C.useEffect(()=>{o&&u(8)},[o,u]),C.useEffect(()=>{const g=e.current;if(!g)return;if(typeof ResizeObserver>"u"){u(8);return}const x=new ResizeObserver(()=>{u(4)});return x.observe(g),g.parentElement&&x.observe(g.parentElement),u(8),()=>{x.disconnect()}},[u,e]),{fitNow:l,scheduleFit:u}}const Om={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"},Im=ce.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:x,resize:y}=Lm({cwd:s,onOutput:C.useCallback(a=>{v.current?.write(a)},[]),onExit:C.useCallback(a=>{v.current?.writeln(`\r
|
|
28
28
|
\x1B[90m[Process exited with code ${a}]\x1B[0m`),o?.(a)},[o])}),{scheduleFit:_}=Pm({terminalRef:m,xtermRef:v,fitAddonRef:i,isVisible:r,onResize:y});return C.useEffect(()=>{r||v.current?.blur()},[r]),C.useEffect(()=>{if(!c)return;const a=v.current;a&&a.writeln(`\r
|
|
29
|
-
\x1B[33m[Terminal disconnected — reconnecting...]\x1B[0m`),g()},[c,g]),C.useLayoutEffect(()=>{if(!m.current)return;const a=new Am.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, 'Courier New', monospace",lineHeight:1.4,theme:Om,scrollback:5e3,convertEol:!0}),h=new Dm;return a.loadAddon(h),a.open(m.current),v.current=a,i.current=h,_(8),()=>{a.dispose(),v.current=null,i.current=null}},[_]),C.useEffect(()=>{n.current||(n.current=!0,g())},[g]),C.useEffect(()=>{const a=v.current;if(!a||!u)return;const h=a.onData(d=>{x(d)});return()=>h.dispose()},[x,u]),C.useEffect(()=>{u&&(_(4),p?.({sendInput:x}))},[u,p,_,x]),t.jsxs("div",{className:"relative flex h-full w-full min-h-0 min-w-0 flex-col overflow-hidden 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:"terminal-xterm-host flex-1 min-h-0 min-w-0 w-full overflow-hidden"})]})}),Bm=ce.memo(function({commands:s,onSelect:r}){const{t:o}=ue(),[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(
|
|
30
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function
|
|
29
|
+
\x1B[33m[Terminal disconnected — reconnecting...]\x1B[0m`),g()},[c,g]),C.useLayoutEffect(()=>{if(!m.current)return;const a=new Am.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, 'Courier New', monospace",lineHeight:1.4,theme:Om,scrollback:5e3,convertEol:!0}),h=new Dm;return a.loadAddon(h),a.open(m.current),v.current=a,i.current=h,_(8),()=>{a.dispose(),v.current=null,i.current=null}},[_]),C.useEffect(()=>{n.current||(n.current=!0,g())},[g]),C.useEffect(()=>{const a=v.current;if(!a||!u)return;const h=a.onData(d=>{x(d)});return()=>h.dispose()},[x,u]),C.useEffect(()=>{u&&(_(4),p?.({sendInput:x}))},[u,p,_,x]),t.jsxs("div",{className:"relative flex h-full w-full min-h-0 min-w-0 flex-col overflow-hidden 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:"terminal-xterm-host flex-1 min-h-0 min-w-0 w-full overflow-hidden"})]})}),Bm=ce.memo(function({commands:s,onSelect:r}){const{t:o}=ue(),[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(wd,{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(qt,{size:12,className:"text-green-500 mt-0.5 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-[12px] font-medium text-neutral-200",children:n.name}),t.jsx("div",{className:"text-[11px] font-mono text-neutral-500 truncate",children:n.command})]})]},l))})})]})]})});let ki=0;function Do(){return ki+=1,{id:`shell-${ki}`,order:ki}}const Fm=ce.memo(function({cwd:s,isVisible:r=!0,quickCommands:o=[]}){const{t:p}=ue(),[m,v]=C.useState(()=>[Do()]),[i,n]=C.useState(()=>m[0].id),l=C.useRef(new Map),u=C.useCallback(()=>{const _=Do();v(a=>[...a,_]),n(_.id)},[]),c=C.useCallback((_,a)=>{a.stopPropagation(),l.current.delete(_),v(h=>{const d=h.filter(f=>f.id!==_);return _===i&&d.length>0&&n(d[d.length-1].id),d})},[i]),g=C.useCallback(_=>{l.current.delete(_),v(a=>{const h=a.filter(d=>d.id!==_);return _===i&&h.length>0&&n(h[h.length-1].id),h})},[i]),x=C.useCallback((_,a)=>{l.current.set(_,a.sendInput)},[]),y=C.useCallback(_=>{const a=l.current.get(i);a&&a(_+"\r")},[i]);return t.jsxs("div",{className:"flex h-full w-full min-h-0 min-w-0 flex-col overflow-hidden 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 scrollbar-app-thin flex-1 min-w-0",children:m.map(_=>t.jsxs("button",{onClick:()=>n(_.id),className:ee("flex items-center gap-1.5 px-3 py-1.5 text-[11px] border-r border-[#333] whitespace-nowrap group transition-colors",_.id===i?"bg-[#1e1e1e] text-neutral-200":"bg-[#2d2d2d] text-neutral-500 hover:text-neutral-300"),children:[t.jsx(Rr,{size:11,className:"shrink-0"}),t.jsx("span",{children:p("Shell {count}",{count:_.order})}),m.length>1&&t.jsx("span",{onClick:a=>c(_.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(os,{size:10})})]},_.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(ss,{size:14})}),o.length>0&&t.jsx(Bm,{commands:o,onSelect:y})]}),t.jsx("div",{className:"flex-1 min-h-0 min-w-0 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(Rr,{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(_=>t.jsx("div",{"aria-hidden":_.id!==i,className:ee("absolute inset-0 h-full w-full min-h-0 min-w-0 overflow-hidden",_.id===i?"visible pointer-events-auto":"invisible pointer-events-none"),children:t.jsx(Im,{cwd:s,isVisible:r&&_.id===i,onExit:()=>g(_.id),onReady:a=>x(_.id,a)})},_.id))})]})});function Lo(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 zm(e){if(Array.isArray(e))return e}function Wm(e,s,r){return(s=Ym(s))in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function Hm(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 $m(){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 Po(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 Oo(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Po(Object(r),!0).forEach(function(o){Wm(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Po(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function Um(e,s){if(e==null)return{};var r,o,p=qm(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 qm(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 Km(e,s){return zm(e)||Hm(e,s)||Vm(e,s)||$m()}function Xm(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 Ym(e){var s=Xm(e,"string");return typeof s=="symbol"?s:s+""}function Vm(e,s){if(e){if(typeof e=="string")return Lo(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)?Lo(e,s):void 0}}function Gm(e,s,r){return s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function Io(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 Bo(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Io(Object(r),!0).forEach(function(o){Gm(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Io(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function Qm(){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 Wr(e){return{}.toString.call(e).includes("Object")}function Zm(e){return!Object.keys(e).length}function sr(e){return typeof e=="function"}function Jm(e,s){return Object.prototype.hasOwnProperty.call(e,s)}function ep(e,s){return Wr(s)||is("changeType"),Object.keys(s).some(function(r){return!Jm(e,r)})&&is("changeField"),s}function tp(e){sr(e)||is("selectorType")}function sp(e){sr(e)||Wr(e)||is("handlerType"),Wr(e)&&Object.values(e).some(function(s){return!sr(s)})&&is("handlersType")}function rp(e){e||is("initialIsRequired"),Wr(e)||is("initialType"),Zm(e)&&is("initialContent")}function ip(e,s){throw new Error(e[s]||e.default)}var np={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"},is=qs(ip)(np),yr={changes:ep,selector:tp,handler:sp,initial:rp};function op(e){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};yr.initial(e),yr.handler(s);var r={current:e},o=qs(cp)(r,s),p=qs(lp)(r),m=qs(yr.changes)(e),v=qs(ap)(r);function i(){var l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(u){return u};return yr.selector(l),l(r.current)}function n(l){Qm(o,p,m,v)(l)}return[i,n]}function ap(e,s){return sr(s)?s(e.current):s}function lp(e,s){return e.current=Bo(Bo({},e.current),s),s}function cp(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 dp={create:op},up={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function hp(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 fp(e){return{}.toString.call(e).includes("Object")}function mp(e){return e||Fo("configIsRequired"),fp(e)||Fo("configType"),e.urls?(pp(),{paths:{vs:e.urls.monacoBase}}):e}function pp(){console.warn(kl.deprecation)}function gp(e,s){throw new Error(e[s]||e.default)}var kl={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
31
|
You are using deprecated way of configuration.
|
|
32
32
|
|
|
33
33
|
Instead of using
|
|
@@ -36,7 +36,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
36
36
|
monaco.config({ paths: { vs: '...' } })
|
|
37
37
|
|
|
38
38
|
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
39
|
-
`},Bo=hp(gp)(wl),vp={config:mp},xp=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 _p={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(_p):o(m)}),e.catch(p)});return r.cancel=function(){return s=!0},r}var bp=["monaco"],yp=dp.create({config:up,isInitialized:!1,resolve:null,reject:null,monaco:null}),kl=Km(yp,2),cr=kl[0],ti=kl[1];function Sp(e){var s=vp.config(e),r=s.monaco,o=Um(s,bp);ti(function(p){return{config:Cl(p.config,o),monaco:r}})}function wp(){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);xp(Cp,Ep)(jp)}return ki(Ei)}function Cp(e){return document.body.appendChild(e)}function kp(e){var s=document.createElement("script");return e&&(s.src=e),s}function Ep(e){var s=cr(function(o){var p=o.config,m=o.reject;return{config:p,reject:m}}),r=kp("".concat(s.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=s.reject,r}function jp(){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 Np(){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:Sp,init:wp,__getMonacoInstance:Np},Rp={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},ji=Rp,Ap={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Mp=Ap;function Tp({children:e}){return ce.createElement("div",{style:Mp.container},e)}var Dp=Tp,Lp=Dp;function Pp({width:e,height:s,isEditorReady:r,loading:o,_ref:p,className:m,wrapperProps:v}){return ce.createElement("section",{style:{...ji.wrapper,width:e,height:s},...v},!r&&ce.createElement(Lp,null,o),ce.createElement("div",{ref:p,style:{...ji.fullWidth,...!r&&ji.hide},className:m}))}var Op=Pp,Nl=C.memo(Op);function Ip(e){C.useEffect(e,[])}var Rl=Ip;function Bp(e,s,r=!0){let o=C.useRef(!0);C.useEffect(o.current||!r?()=>{o.current=!1}:e,s)}var kt=Bp;function Vs(){}function js(e,s,r,o){return Fp(e,o)||zp(e,s,r,o)}function Fp(e,s){return e.editor.getModel(Al(e,s))}function zp(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 Hp({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:x="100%",className:y,wrapperProps:_={},beforeMount:a=Vs,onMount:h=Vs}){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(F=>(j.current=F)&&w(!1)).catch(F=>F?.type!=="cancelation"&&console.error("Monaco initialization: error:",F)),()=>k.current?B():D.cancel()}),kt(()=>{if(k.current&&j.current){let D=k.current.getOriginalEditor(),F=js(j.current,e||"",o||r||"text",m||"");F!==D.getModel()&&D.setModel(F)}},[m],d),kt(()=>{if(k.current&&j.current){let D=k.current.getModifiedEditor(),F=js(j.current,s||"",p||r||"text",v||"");F!==D.getModel()&&D.setModel(F)}},[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:F}=k.current.getModel();j.current.editor.setModelLanguage(D,o||r||"text"),j.current.editor.setModelLanguage(F,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||""),F=js(j.current,s||"",p||r||"text",v||"");k.current?.setModel({original:D,modified:F})},[r,s,p,e,o,m,v]),M=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&&M()},[b,d,M]);function B(){let D=k.current?.getModel();i||D?.original?.dispose(),n||D?.modified?.dispose(),k.current?.dispose()}return ce.createElement(Nl,{width:x,height:g,isEditorReady:d,loading:u,_ref:S,className:y,wrapperProps:_})}var Wp=Hp;C.memo(Wp);function $p(e){let s=C.useRef();return C.useEffect(()=>{s.current=e},[e]),s.current}var Up=$p,yr=new Map;function qp({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:x="100%",height:y="100%",className:_,wrapperProps:a={},beforeMount:h=Vs,onMount:d=Vs,onChange:f,onValidate:b=Vs}){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),M=C.useRef(h),B=C.useRef(),D=C.useRef(o),F=Up(m),W=C.useRef(!1),A=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(F,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()&&(A.current=!0,R.current.executeEdits("",[{range:R.current.getModel().getFullModelRange(),text:o,forceMoveMarkers:!0}]),R.current.pushUndoStop(),A.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)&&!W.current){M.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),W.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=>{A.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(U=>U.path===Y.path)){let U=E.current.editor.getModelMarkers({resource:Y});b?.(U)}});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 ce.createElement(Nl,{width:x,height:y,isEditorReady:w,loading:n,_ref:L,className:_,wrapperProps:a})}var Kp=qp,Xp=C.memo(Kp),Yp=Xp,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)},Gp=function(e){return-Math.cos(e*Math.PI)/2+.5},Qp=function(e){return e},Zp=function(e){return e*e},Jp=function(e){return e*(2-e)},eg=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},tg=function(e){return e*e*e},sg=function(e){return--e*e*e+1},rg=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},ig=function(e){return e*e*e*e},ng=function(e){return 1- --e*e*e*e},og=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},ag=function(e){return e*e*e*e*e},lg=function(e){return 1+--e*e*e*e*e},cg=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},Ml={easeOut:Gp,linear:Qp,easeInQuad:Zp,easeOutQuad:Jp,easeInOutQuad:eg,easeInCubic:tg,easeOutCubic:sg,easeInOutCubic:rg,easeInQuart:ig,easeOutQuart:ng,easeInOutQuart:og,easeInQuint:ag,easeOutQuint:lg,easeInOutQuint:cg},Tl=function(e){typeof e=="number"&&cancelAnimationFrame(e)},Lt=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;Lt(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 dg(e){var s=e.scale,r=e.positionX,o=e.positionY;return!(Number.isNaN(s)||Number.isNaN(r)||Number.isNaN(o))}function ls(e,s,r,o){var p=dg(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(x){var y=i+u*x,_=n+c*x,a=l+g*x;m(y,_,a)})}}function ug(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 hg=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=ug(r,o,s),v=m.wrapperWidth,i=m.wrapperHeight,n=m.newContentWidth,l=m.newDiffWidth,u=m.newContentHeight,c=m.newDiffHeight,g=hg(v,n,l,i,u,c,!!p);return g},Yi=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 x=Yi(e,i-c,l+c,o),y=Yi(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,x=dr(c,g,p,m,0,0,null);return x}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},fg=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}},mg=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 pg(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,x=u.maxPositionY,y=u.minPositionY,_=r>c||r<g,a=o>x||o<y,h=r>c?l.offsetWidth:e.setup.minPositionX||0,d=o>x?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:_?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),x=g.x,y=g.y;e.setTransformState(l,x,y)}}var gg=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,x=i?l:c;return{x:g,y:x}},as=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},vg=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},xg=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 _g(e,s){var r=e.setup.velocityAnimation,o=r.equalToMove,p=r.animationTime,m=r.sensitivity;return o?p*s*m:p}function Ho(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:Yi(e,m,v,p)}function bg(e,s){var r=1;return s?Math.min(r,e.offsetWidth/window.innerWidth):r}function yg(e,s){var r=vg(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=bg(v,i),u=s.x-o.x,c=s.y-o.y,g=u/l,x=c/l,y=n-p,_=u*u+c*c,a=Math.sqrt(_)/y;e.velocity={velocityX:g,velocityY:x,total:a}}e.lastMousePosition=s,e.velocityTime=n}}function Sg(e){var s=e.velocity,r=e.bounds,o=e.setup,p=e.wrapperComponent,m=xg(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,x=o.limitToBounds,y=o.alignmentAnimation,_=o.zoomAnimation,a=o.panning,h=a.lockAxisY,d=a.lockAxisX,f=_.animationType,b=y.sizeX,w=y.sizeY,k=y.velocityAlignmentTime,j=k,S=_g(e,n),E=Math.max(S,j),R=as(e,b),L=as(e,w),T=R*p.offsetWidth/100,M=L*p.offsetHeight/100,B=l+T,D=u-T,F=c+M,W=g-M,A=e.transformState,O=new Date().getTime();Dl(e,f,E,function(P){var I=e.transformState,$=I.scale,Y=I.positionX,U=I.positionY,X=new Date().getTime()-O,z=X/j,N=Ml[y.animationType],H=1-N(Math.min(1,z)),K=1-P,q=Y+v*K,ie=U+i*K,Q=Ho(q,A.positionX,Y,d,x,u,l,D,B,H),se=Ho(ie,A.positionY,U,h,x,g,c,W,F,H);(Y!==q||U!==ie)&&e.setTransformState($,Q,se)})}}function Wo(e,s){var r=e.transformState.scale;Lt(e),ds(e,r),window.TouchEvent!==void 0&&s instanceof TouchEvent?mg(e,s):fg(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=pg(e);g&&ls(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=gg(e,s,r),l=n.x,u=n.y,c=as(e,v),g=as(e,i);yg(e,{x:l,y:u}),Ll(e,l,u,c,g)}}function wg(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?Sg(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 x=s||p.offsetWidth/2,y=r||p.offsetHeight/2,_=On(e,v,x,y);_&&ls(e,_,u,c)}}var ns=function(){return ns=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},ns.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}},Vi={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=ns({},$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]=ns(ns({},$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,x=(c/2-l)/i,y=Il(e,s,r),_=On(e,y,g,x);if(!_)return console.error("Error during zoom event. New transformation state was not calculated.");ls(e,_,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),x=dr(i.positionX,i.positionY,g,v,0,0,m),y={scale:i.scale,positionX:x.x,positionY:x.y};l===i.scale&&u===i.positionX&&c===i.positionY||(o?.(),ls(e,y,s,r))}}function Cg(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 kg(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=Cg(s,o,p,m),x=g.x,y=g.y,_=c.width/m.scale,a=c.height/m.scale,h=o.offsetWidth/_,d=o.offsetHeight/a,f=ur(r||Math.min(h,d),n,l,0,!1),b=(u.width-_*f)/2,w=(u.height-a*f)/2,k=(u.left-x)*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 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){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),Bl(e,-1,s,r,o)}},Ng=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 x={positionX:Number.isNaN(s)?i:s,positionY:Number.isNaN(r)?n:r,scale:Number.isNaN(o)?l:o};ls(e,x,p,m)}}},Rg=function(e){return function(s,r){s===void 0&&(s=200),r===void 0&&(r="easeOut"),Fl(e,s,r)}},Ag=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);ls(e,i,r,o)}}},Mg=function(e){return function(s,r,o,p){o===void 0&&(o=600),p===void 0&&(p="easeOut"),Lt(e);var m=e.wrapperComponent,v=typeof s=="string"?document.getElementById(s):s;if(m&&v&&m.contains(v)){var i=kg(e,v,r);ls(e,i,o,p)}}},Hr=function(e){return{instance:e,zoomIn:Eg(e),zoomOut:jg(e),setTransform:Ng(e),resetTransform:Rg(e),centerView:Ag(e),zoomToElement:Mg(e)}},Gi=function(e){return{instance:e,state:e.transformState}},qe=function(e){var s={};return Object.assign(s,Gi(e)),Object.assign(s,Hr(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(Vi.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)},Tg=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 Dg(e){return function(s){e.forEach(function(r){typeof r=="function"?r(s):r!=null&&(r.current=s)})}}var Lg=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},Pg=function(e){return e?e.deltaY<0?1:-1:0};function Og(e,s){var r=Pg(e),o=Vp(s,r);return o}function Hl(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 Ig=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,x=u.disabled;if(!v)throw new Error("Wrapper is not mounted");var y=m+s*r,_=o?!1:!x,a=ur(At(y,3),l,n,g,_&&!c);return a},Bg=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},Fg=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},zg=function(e){var s=e.setup.pinch.disabled,r=e.isInitialized,o=e.pinchStartDistance,p=r&&!s&&o;return!!p},Hg=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}},Wl=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)},$g=160,Ug=100,qg=function(e,s){var r=e.props,o=r.onWheelStart,p=r.onZoomStart;e.wheelStopEventTimer||(Lt(e),Ze(qe(e),s,o),Ze(qe(e),s,p))},Kg=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,x=v.disablePadding,y=v.smooth,_=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=Og(s,null),b=y?d*Math.abs(s.deltaY):h,w=Ig(e,f,b,!s.ctrlKey);if(n!==w){var k=ds(e,w),j=Hl(s,m,n),S=a||_===0||u||x,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(qe(e),s,o),Ze(qe(e),s,p)}},Xg=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)},Ug);var m=Bg(e,s);m&&(Qi(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,Ze(qe(e),s,o),Ze(qe(e),s,p))},$g))},$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}},Yg=function(e,s){var r=Wl(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,Lt(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 x=Hg(s,m,r);if(!(!Number.isFinite(x.x)||!Number.isFinite(x.y))){var y=Wl(s),_=Wg(e,y),a=$l(s),h=a.x-(e.pinchLastCenterX||0),d=a.y-(e.pinchLastCenterY||0);if(!(_===m&&h===0&&d===0)){e.pinchLastCenterX=a.x,e.pinchLastCenterY=a.y;var f=ds(e,_),b=c||g===0||n,w=i&&b,k=si(e,x.x,x.y,_,f,w),j=k.x,S=k.y;e.pinchMidpoint=x,e.lastDistance=y;var E=u.sizeX,R=u.sizeY,L=as(e,E),T=as(e,R),M=j+h,B=S+d,D=dr(M,B,f,i,L,T,p),F=D.x,W=D.y;e.setTransformState(_,F,W)}}}},Gg=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(qe(e),s,r)},o)},Qg=function(e,s){var r=e.props,o=r.onZoomStart,p=r.onZoom,m=e.setup.doubleClick,v=m.animationTime,i=m.animationType;Ze(qe(e),s,o),Fl(e,v,i,function(){return Ze(qe(e),s,p)}),Ul(e,s)};function Zg(e,s){return e==="toggle"?s===1?1:-1:e==="zoomOut"?-1:1}function Jg(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,x=u.step,y=u.animationTime,_=u.animationType;if(!c&&!o){if(g==="reset")return Qg(e,s);if(!m)return console.error("No ContentComponent found");var a=Zg(g,e.transformState.scale),h=Il(e,a,x);if(v!==h){Ze(qe(e),s,n);var d=Hl(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(qe(e),s,l),ls(e,f,y,_),Ul(e,s)}}}var ev=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},tv=(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),Lt(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(qe(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 Lt(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=Lg(r,o);if(m){var v=r.isPressingKeys(r.setup.wheel.activationKeys);v&&(qg(r,o),Kg(r,o),Xg(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,x=i.lockAxisX?l:c,y=i.lockAxisY?u:g,_=r.setup.alignmentAnimation,a=_.sizeX,h=_.sizeY,d=as(r,a),f=as(r,h);x===l&&y===u||Ll(r,x,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(),Lt(r),Wo(r,o),Ze(qe(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(qe(r),o,m))}}},this.onPanningStop=function(o){var p=r.props.onPanningStop;r.isPanning&&(wg(r),Ze(qe(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=Fg(r,o);n&&(Yg(r,o),Lt(r),Ze(qe(r),o,v),Ze(qe(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=zg(r);n&&(o.preventDefault(),o.stopPropagation(),Vg(r,o),Ze(qe(r),o,v),Ze(qe(r),o,i))}},this.onPinchStop=function(o){var p=r.props,m=p.onPinchingStop,v=p.onZoomStop;r.pinchStartScale&&(Gg(r),Ze(qe(r),o,m),Ze(qe(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,Lt(r);var n=o.touches,l=n.length===1,u=n.length===2;l&&(Lt(r),Wo(r,o),Ze(qe(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(qe(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=ev(r,o);m&&Jg(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=qe(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):Tg(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 qe(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=qe(r);Ze(m,void 0,r.props.onInit)},this.props=s,this.setup=qo(this.props),this.transformState=Ol(this.props)}return e})(),ii=ce.createContext(null),sv=function(e,s){return typeof e=="function"?e(s):e},rv=ce.forwardRef(function(e,s){var r=C.useRef(new tv(e)).current,o=sv(e.children,Hr(r));return C.useImperativeHandle(s,function(){return Hr(r)},[r]),C.useEffect(function(){r.update(e)},[r,e]),ce.createElement(ii.Provider,{value:r},o)});ce.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]),ce.createElement("div",ns({},e,{ref:Dg([r,s])}))});function iv(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 nv=`.transform-component-module_wrapper__SPB86 {
|
|
39
|
+
`},Fo=hp(gp)(kl),vp={config:mp},xp=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 El(e,s){return Object.keys(s).forEach(function(r){s[r]instanceof Object&&e[r]&&Object.assign(s[r],El(e[r],s[r]))}),Oo(Oo({},e),s)}var _p={type:"cancelation",msg:"operation is manually canceled"};function Ei(e){var s=!1,r=new Promise(function(o,p){e.then(function(m){return s?p(_p):o(m)}),e.catch(p)});return r.cancel=function(){return s=!0},r}var bp=["monaco"],yp=dp.create({config:up,isInitialized:!1,resolve:null,reject:null,monaco:null}),jl=Km(yp,2),dr=jl[0],si=jl[1];function Sp(e){var s=vp.config(e),r=s.monaco,o=Um(s,bp);si(function(p){return{config:El(p.config,o),monaco:r}})}function wp(){var e=dr(function(s){var r=s.monaco,o=s.isInitialized,p=s.resolve;return{monaco:r,isInitialized:o,resolve:p}});if(!e.isInitialized){if(si({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),Ei(ji);if(window.monaco&&window.monaco.editor)return Nl(window.monaco),e.resolve(window.monaco),Ei(ji);xp(Cp,Ep)(jp)}return Ei(ji)}function Cp(e){return document.body.appendChild(e)}function kp(e){var s=document.createElement("script");return e&&(s.src=e),s}function Ep(e){var s=dr(function(o){var p=o.config,m=o.reject;return{config:p,reject:m}}),r=kp("".concat(s.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=s.reject,r}function jp(){var e=dr(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;Nl(o),e.resolve(o)},function(r){e.reject(r)})}function Nl(e){dr().monaco||si({monaco:e})}function Np(){return dr(function(e){var s=e.monaco;return s})}var ji=new Promise(function(e,s){return si({resolve:e,reject:s})}),Rl={config:Sp,init:wp,__getMonacoInstance:Np},Rp={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},Ni=Rp,Ap={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Mp=Ap;function Tp({children:e}){return ce.createElement("div",{style:Mp.container},e)}var Dp=Tp,Lp=Dp;function Pp({width:e,height:s,isEditorReady:r,loading:o,_ref:p,className:m,wrapperProps:v}){return ce.createElement("section",{style:{...Ni.wrapper,width:e,height:s},...v},!r&&ce.createElement(Lp,null,o),ce.createElement("div",{ref:p,style:{...Ni.fullWidth,...!r&&Ni.hide},className:m}))}var Op=Pp,Al=C.memo(Op);function Ip(e){C.useEffect(e,[])}var Ml=Ip;function Bp(e,s,r=!0){let o=C.useRef(!0);C.useEffect(o.current||!r?()=>{o.current=!1}:e,s)}var kt=Bp;function Vs(){}function js(e,s,r,o){return Fp(e,o)||zp(e,s,r,o)}function Fp(e,s){return e.editor.getModel(Tl(e,s))}function zp(e,s,r,o){return e.editor.createModel(s,r,o?Tl(e,o):void 0)}function Tl(e,s){return e.Uri.parse(s)}function Wp({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:x="100%",className:y,wrapperProps:_={},beforeMount:a=Vs,onMount:h=Vs}){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);Ml(()=>{let D=Rl.init();return D.then(F=>(j.current=F)&&w(!1)).catch(F=>F?.type!=="cancelation"&&console.error("Monaco initialization: error:",F)),()=>k.current?B():D.cancel()}),kt(()=>{if(k.current&&j.current){let D=k.current.getOriginalEditor(),F=js(j.current,e||"",o||r||"text",m||"");F!==D.getModel()&&D.setModel(F)}},[m],d),kt(()=>{if(k.current&&j.current){let D=k.current.getModifiedEditor(),F=js(j.current,s||"",p||r||"text",v||"");F!==D.getModel()&&D.setModel(F)}},[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:F}=k.current.getModel();j.current.editor.setModelLanguage(D,o||r||"text"),j.current.editor.setModelLanguage(F,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||""),F=js(j.current,s||"",p||r||"text",v||"");k.current?.setModel({original:D,modified:F})},[r,s,p,e,o,m,v]),M=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&&M()},[b,d,M]);function B(){let D=k.current?.getModel();i||D?.original?.dispose(),n||D?.modified?.dispose(),k.current?.dispose()}return ce.createElement(Al,{width:x,height:g,isEditorReady:d,loading:u,_ref:S,className:y,wrapperProps:_})}var Hp=Wp;C.memo(Hp);function $p(e){let s=C.useRef();return C.useEffect(()=>{s.current=e},[e]),s.current}var Up=$p,Sr=new Map;function qp({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:x="100%",height:y="100%",className:_,wrapperProps:a={},beforeMount:h=Vs,onMount:d=Vs,onChange:f,onValidate:b=Vs}){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),M=C.useRef(h),B=C.useRef(),D=C.useRef(o),F=Up(m),H=C.useRef(!1),A=C.useRef(!1);Ml(()=>{let I=Rl.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&&Sr.set(F,R.current?.saveViewState()),R.current?.setModel(I),c&&R.current?.restoreViewState(Sr.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()&&(A.current=!0,R.current.executeEdits("",[{range:R.current.getModel().getFullModelRange(),text:o,forceMoveMarkers:!0}]),R.current.pushUndoStop(),A.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){M.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(Sr.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=>{A.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(U=>U.path===Y.path)){let U=E.current.editor.getModelMarkers({resource:Y});b?.(U)}});return()=>{I?.dispose()}}return()=>{}},[w,b]);function P(){B.current?.dispose(),g?c&&Sr.set(m,R.current.saveViewState()):R.current.getModel()?.dispose(),R.current.dispose()}return ce.createElement(Al,{width:x,height:y,isEditorReady:w,loading:n,_ref:L,className:_,wrapperProps:a})}var Kp=qp,Xp=C.memo(Kp),Yp=Xp,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)},Gp=function(e){return-Math.cos(e*Math.PI)/2+.5},Qp=function(e){return e},Zp=function(e){return e*e},Jp=function(e){return e*(2-e)},eg=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},tg=function(e){return e*e*e},sg=function(e){return--e*e*e+1},rg=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},ig=function(e){return e*e*e*e},ng=function(e){return 1- --e*e*e*e},og=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},ag=function(e){return e*e*e*e*e},lg=function(e){return 1+--e*e*e*e*e},cg=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},Dl={easeOut:Gp,linear:Qp,easeInQuad:Zp,easeOutQuad:Jp,easeInOutQuad:eg,easeInCubic:tg,easeOutCubic:sg,easeInOutCubic:rg,easeInQuart:ig,easeOutQuart:ng,easeInOutQuart:og,easeInQuint:ag,easeOutQuint:lg,easeInOutQuint:cg},Ll=function(e){typeof e=="number"&&cancelAnimationFrame(e)},Lt=function(e){e.mounted&&(Ll(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function Pl(e,s,r,o){if(e.mounted){var p=new Date().getTime(),m=1;Lt(e),e.animation=function(){if(!e.mounted)return Ll(e.animation);var v=new Date().getTime()-p,i=v/r,n=Dl[s],l=n(i);v>=r?(o(m),e.animation=null):e.animation&&(o(l),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function dg(e){var s=e.scale,r=e.positionX,o=e.positionY;return!(Number.isNaN(s)||Number.isNaN(r)||Number.isNaN(o))}function ls(e,s,r,o){var p=dg(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):Pl(e,o,r,function(x){var y=i+u*x,_=n+c*x,a=l+g*x;m(y,_,a)})}}function ug(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 hg=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}},Pn=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=ug(r,o,s),v=m.wrapperWidth,i=m.wrapperHeight,n=m.newContentWidth,l=m.newDiffWidth,u=m.newContentHeight,c=m.newDiffHeight,g=hg(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=Pn(e,s);return e.bounds=r,r};function ur(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 x=Vi(e,i-c,l+c,o),y=Vi(s,n-g,u+g,o);return{x,y}}function ri(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,x=ur(c,g,p,m,0,0,null);return x}function hr(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 zo=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=ii(m,r);return!l},Wo=function(e){var s=e.isInitialized,r=e.isPanning,o=e.setup,p=o.panning.disabled,m=s&&r&&!p;return!!m},fg=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}},mg=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 pg(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,x=u.maxPositionY,y=u.minPositionY,_=r>c||r<g,a=o>x||o<y,h=r>c?l.offsetWidth:e.setup.minPositionX||0,d=o>x?l.offsetHeight:e.setup.minPositionY||0,f=ri(e,h,d,p,e.bounds,i||n),b=f.x,w=f.y;return{scale:p,positionX:_?b:r,positionY:a?w:o}}}function Ol(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=ur(s,r,i,m,o,p,v),x=g.x,y=g.y;e.setTransformState(l,x,y)}}var gg=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,x=i?l:c;return{x:g,y:x}},as=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},vg=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},xg=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 _g(e,s){var r=e.setup.velocityAnimation,o=r.equalToMove,p=r.animationTime,m=r.sensitivity;return o?p*s*m:p}function Ho(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 bg(e,s){var r=1;return s?Math.min(r,e.offsetWidth/window.innerWidth):r}function yg(e,s){var r=vg(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=bg(v,i),u=s.x-o.x,c=s.y-o.y,g=u/l,x=c/l,y=n-p,_=u*u+c*c,a=Math.sqrt(_)/y;e.velocity={velocityX:g,velocityY:x,total:a}}e.lastMousePosition=s,e.velocityTime=n}}function Sg(e){var s=e.velocity,r=e.bounds,o=e.setup,p=e.wrapperComponent,m=xg(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,x=o.limitToBounds,y=o.alignmentAnimation,_=o.zoomAnimation,a=o.panning,h=a.lockAxisY,d=a.lockAxisX,f=_.animationType,b=y.sizeX,w=y.sizeY,k=y.velocityAlignmentTime,j=k,S=_g(e,n),E=Math.max(S,j),R=as(e,b),L=as(e,w),T=R*p.offsetWidth/100,M=L*p.offsetHeight/100,B=l+T,D=u-T,F=c+M,H=g-M,A=e.transformState,O=new Date().getTime();Pl(e,f,E,function(P){var I=e.transformState,$=I.scale,Y=I.positionX,U=I.positionY,X=new Date().getTime()-O,z=X/j,N=Dl[y.animationType],W=1-N(Math.min(1,z)),K=1-P,q=Y+v*K,ie=U+i*K,Q=Ho(q,A.positionX,Y,d,x,u,l,D,B,W),se=Ho(ie,A.positionY,U,h,x,g,c,H,F,W);(Y!==q||U!==ie)&&e.setTransformState($,Q,se)})}}function $o(e,s){var r=e.transformState.scale;Lt(e),ds(e,r),window.TouchEvent!==void 0&&s instanceof TouchEvent?mg(e,s):fg(e,s)}function On(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=pg(e);g&&ls(e,g,s??l,u)}}function Uo(e,s,r){var o=e.startCoords,p=e.setup,m=p.alignmentAnimation,v=m.sizeX,i=m.sizeY;if(o){var n=gg(e,s,r),l=n.x,u=n.y,c=as(e,v),g=as(e,i);yg(e,{x:l,y:u}),Ol(e,l,u,c,g)}}function wg(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?Sg(e):On(e)}}function In(e,s,r,o){var p=e.setup,m=p.minScale,v=p.maxScale,i=p.limitToBounds,n=hr(At(s,2),m,v,0,!1),l=ds(e,n),u=ri(e,r,o,n,l,i),c=u.x,g=u.y;return{scale:n,positionX:c,positionY:g}}function Il(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)&&On(e),!(g||!p||!e.mounted)){var x=s||p.offsetWidth/2,y=r||p.offsetHeight/2,_=In(e,v,x,y);_&&ls(e,_,u,c)}}var ns=function(){return ns=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},ns.apply(this,arguments)};function qo(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 wr={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}},Gi={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},Bl=function(e){var s,r,o,p;return{previousScale:(s=e.initialScale)!==null&&s!==void 0?s:wr.scale,scale:(r=e.initialScale)!==null&&r!==void 0?r:wr.scale,positionX:(o=e.initialPositionX)!==null&&o!==void 0?o:wr.positionX,positionY:(p=e.initialPositionY)!==null&&p!==void 0?p:wr.positionY}},Ko=function(e){var s=ns({},$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]=ns(ns({},$s[r]),e[r]):i?s[r]=qo(qo([],$s[r],!0),e[r]):s[r]=e[r]}}),s},Fl=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=hr(At(c,3),i,v,u,!1);return g};function zl(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,x=(c/2-l)/i,y=Fl(e,s,r),_=In(e,y,g,x);if(!_)return console.error("Error during zoom event. New transformation state was not calculated.");ls(e,_,o,p)}function Wl(e,s,r,o){var p=e.setup,m=e.wrapperComponent,v=p.limitToBounds,i=Bl(e.props),n=e.transformState,l=n.scale,u=n.positionX,c=n.positionY;if(m){var g=Pn(e,i.scale),x=ur(i.positionX,i.positionY,g,v,0,0,m),y={scale:i.scale,positionX:x.x,positionY:x.y};l===i.scale&&u===i.positionX&&c===i.positionY||(o?.(),ls(e,y,s,r))}}function Cg(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 kg(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=Cg(s,o,p,m),x=g.x,y=g.y,_=c.width/m.scale,a=c.height/m.scale,h=o.offsetWidth/_,d=o.offsetHeight/a,f=hr(r||Math.min(h,d),n,l,0,!1),b=(u.width-_*f)/2,w=(u.height-a*f)/2,k=(u.left-x)*f+b,j=(u.top-y)*f+w,S=Pn(e,f),E=ur(k,j,S,i,0,0,o),R=E.x,L=E.y;return{positionX:R,positionY:L,scale:f}}var Eg=function(e){return function(s,r,o){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),zl(e,1,s,r,o)}},jg=function(e){return function(s,r,o){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),zl(e,-1,s,r,o)}},Ng=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 x={positionX:Number.isNaN(s)?i:s,positionY:Number.isNaN(r)?n:r,scale:Number.isNaN(o)?l:o};ls(e,x,p,m)}}},Rg=function(e){return function(s,r){s===void 0&&(s=200),r===void 0&&(r="easeOut"),Wl(e,s,r)}},Ag=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=Hl(s||p.scale,m,v);ls(e,i,r,o)}}},Mg=function(e){return function(s,r,o,p){o===void 0&&(o=600),p===void 0&&(p="easeOut"),Lt(e);var m=e.wrapperComponent,v=typeof s=="string"?document.getElementById(s):s;if(m&&v&&m.contains(v)){var i=kg(e,v,r);ls(e,i,o,p)}}},Hr=function(e){return{instance:e,zoomIn:Eg(e),zoomOut:jg(e),setTransform:Ng(e),resetTransform:Rg(e),centerView:Ag(e),zoomToElement:Mg(e)}},Qi=function(e){return{instance:e,state:e.transformState}},qe=function(e){var s={};return Object.assign(s,Qi(e)),Object.assign(s,Hr(e)),s},Ri=!1;function Ai(){try{var e={get passive(){return Ri=!0,!1}};return e}catch{return Ri=!1,Ri}}var Cr=".".concat(Gi.wrapperClass),ii=function(e,s){return s.some(function(r){return e.matches("".concat(Cr," ").concat(r,", ").concat(Cr," .").concat(r,", ").concat(Cr," ").concat(r," *, ").concat(Cr," .").concat(r," *"))})},Zi=function(e){e&&clearTimeout(e)},Tg=function(e,s,r){return"translate(".concat(e,"px, ").concat(s,"px) scale(").concat(r,")")},Hl=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 Dg(e){return function(s){e.forEach(function(r){typeof r=="function"?r(s):r!=null&&(r.current=s)})}}var Lg=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=ii(l,v);return!c},Pg=function(e){return e?e.deltaY<0?1:-1:0};function Og(e,s){var r=Pg(e),o=Vp(s,r);return o}function $l(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 Ig=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,x=u.disabled;if(!v)throw new Error("Wrapper is not mounted");var y=m+s*r,_=o?!1:!x,a=hr(At(y,3),l,n,g,_&&!c);return a},Bg=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},Fg=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=ii(v,p);return!n},zg=function(e){var s=e.setup.pinch.disabled,r=e.isInitialized,o=e.pinchStartDistance,p=r&&!s&&o;return!!p},Wg=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}},Ul=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))},Hg=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 hr(At(g,2),v,m,l,!u&&!n)},$g=160,Ug=100,qg=function(e,s){var r=e.props,o=r.onWheelStart,p=r.onZoomStart;e.wheelStopEventTimer||(Lt(e),Ze(qe(e),s,o),Ze(qe(e),s,p))},Kg=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,x=v.disablePadding,y=v.smooth,_=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=Og(s,null),b=y?d*Math.abs(s.deltaY):h,w=Ig(e,f,b,!s.ctrlKey);if(n!==w){var k=ds(e,w),j=$l(s,m,n),S=a||_===0||u||x,E=l&&S,R=ri(e,j.x,j.y,w,k,E),L=R.x,T=R.y;e.previousWheelEvent=s,e.setTransformState(w,L,T),Ze(qe(e),s,o),Ze(qe(e),s,p)}},Xg=function(e,s){var r=e.props,o=r.onWheelStop,p=r.onZoomStop;Zi(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(Il(e,s.x,s.y),e.wheelAnimationTimer=null)},Ug);var m=Bg(e,s);m&&(Zi(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,Ze(qe(e),s,o),Ze(qe(e),s,p))},$g))},ql=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}},Yg=function(e,s){var r=Ul(s);e.pinchStartDistance=r,e.lastDistance=r,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var o=ql(s);e.pinchLastCenterX=o.x,e.pinchLastCenterY=o.y,Lt(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 x=Wg(s,m,r);if(!(!Number.isFinite(x.x)||!Number.isFinite(x.y))){var y=Ul(s),_=Hg(e,y),a=ql(s),h=a.x-(e.pinchLastCenterX||0),d=a.y-(e.pinchLastCenterY||0);if(!(_===m&&h===0&&d===0)){e.pinchLastCenterX=a.x,e.pinchLastCenterY=a.y;var f=ds(e,_),b=c||g===0||n,w=i&&b,k=ri(e,x.x,x.y,_,f,w),j=k.x,S=k.y;e.pinchMidpoint=x,e.lastDistance=y;var E=u.sizeX,R=u.sizeY,L=as(e,E),T=as(e,R),M=j+h,B=S+d,D=ur(M,B,f,i,L,T,p),F=D.x,H=D.y;e.setTransformState(_,F,H)}}}},Gg=function(e){var s=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,Il(e,s?.x,s?.y)},Kl=function(e,s){var r=e.props.onZoomStop,o=e.setup.doubleClick.animationTime;Zi(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,Ze(qe(e),s,r)},o)},Qg=function(e,s){var r=e.props,o=r.onZoomStart,p=r.onZoom,m=e.setup.doubleClick,v=m.animationTime,i=m.animationType;Ze(qe(e),s,o),Wl(e,v,i,function(){return Ze(qe(e),s,p)}),Kl(e,s)};function Zg(e,s){return e==="toggle"?s===1?1:-1:e==="zoomOut"?-1:1}function Jg(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,x=u.step,y=u.animationTime,_=u.animationType;if(!c&&!o){if(g==="reset")return Qg(e,s);if(!m)return console.error("No ContentComponent found");var a=Zg(g,e.transformState.scale),h=Fl(e,a,x);if(v!==h){Ze(qe(e),s,n);var d=$l(s,m,v),f=In(e,h,d.x,d.y);if(!f)return console.error("Error during zoom event. New transformation state was not calculated.");Ze(qe(e),s,l),ls(e,f,y,_),Kl(e,s)}}}var ev=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=ii(n,i);return!c},tv=(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=Ko(o)},this.initializeWindowEvents=function(){var o,p,m=Ai(),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=Ai(),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),Lt(r),(p=r.observer)===null||p===void 0||p.disconnect()},this.handleInitializeWrapperEvents=function(o){var p=Ai();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(qe(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 Lt(r),ds(r,r.transformState.scale),On(r,0)}),r.observer.observe(o),r.observer.observe(p)},this.onWheelZoom=function(o){var p=r.setup.disabled;if(!p){var m=Lg(r,o);if(m){var v=r.isPressingKeys(r.setup.wheel.activationKeys);v&&(qg(r,o),Kg(r,o),Xg(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,x=i.lockAxisX?l:c,y=i.lockAxisY?u:g,_=r.setup.alignmentAnimation,a=_.sizeX,h=_.sizeY,d=as(r,a),f=as(r,h);x===l&&y===u||Ol(r,x,y,d,f)}},this.onPanningStart=function(o){var p=r.setup.disabled,m=r.props.onPanningStart;if(!p){var v=zo(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(),Lt(r),$o(r,o),Ze(qe(r),o,m)))}}},this.onPanning=function(o){var p=r.setup.disabled,m=r.props.onPanning;if(!p){var v=Wo(r);if(v){var i=r.isPressingKeys(r.setup.panning.activationKeys);i&&(o.preventDefault(),o.stopPropagation(),Uo(r,o.clientX,o.clientY),Ze(qe(r),o,m))}}},this.onPanningStop=function(o){var p=r.props.onPanningStop;r.isPanning&&(wg(r),Ze(qe(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=Fg(r,o);n&&(Yg(r,o),Lt(r),Ze(qe(r),o,v),Ze(qe(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=zg(r);n&&(o.preventDefault(),o.stopPropagation(),Vg(r,o),Ze(qe(r),o,v),Ze(qe(r),o,i))}},this.onPinchStop=function(o){var p=r.props,m=p.onPinchingStop,v=p.onZoomStop;r.pinchStartScale&&(Gg(r),Ze(qe(r),o,m),Ze(qe(r),o,v))},this.onTouchPanningStart=function(o){var p=r.setup.disabled,m=r.props.onPanningStart;if(!p){var v=zo(r,o);if(v){var i=r.lastTouch&&+new Date-r.lastTouch<200&&o.touches.length===1;if(!i){r.lastTouch=+new Date,Lt(r);var n=o.touches,l=n.length===1,u=n.length===2;l&&(Lt(r),$o(r,o),Ze(qe(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=Wo(r);if(!v)return;o.preventDefault(),o.stopPropagation();var i=o.touches[0];Uo(r,i.clientX,i.clientY),Ze(qe(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=ev(r,o);m&&Jg(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=qe(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=Hl(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):Tg(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 qe(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=qe(r);Ze(m,void 0,r.props.onInit)},this.props=s,this.setup=Ko(this.props),this.transformState=Bl(this.props)}return e})(),ni=ce.createContext(null),sv=function(e,s){return typeof e=="function"?e(s):e},rv=ce.forwardRef(function(e,s){var r=C.useRef(new tv(e)).current,o=sv(e.children,Hr(r));return C.useImperativeHandle(s,function(){return Hr(r)},[r]),C.useEffect(function(){r.update(e)},[r,e]),ce.createElement(ni.Provider,{value:r},o)});ce.forwardRef(function(e,s){var r=C.useRef(null),o=C.useContext(ni);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]),ce.createElement("div",ns({},e,{ref:Dg([r,s])}))});function iv(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 nv=`.transform-component-module_wrapper__SPB86 {
|
|
40
40
|
position: relative;
|
|
41
41
|
width: -moz-fit-content;
|
|
42
42
|
width: fit-content;
|
|
@@ -67,23 +67,23 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
67
67
|
.transform-component-module_content__FBWxo img {
|
|
68
68
|
pointer-events: none;
|
|
69
69
|
}
|
|
70
|
-
`,Ko={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};iv(nv);var ov=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),x=g.init,y=g.cleanupWindowEvents,_=C.useRef(null),a=C.useRef(null);return C.useEffect(function(){var h=_.current,d=a.current;return h!==null&&d!==null&&x&&x?.(h,d),function(){y?.()}},[]),ce.createElement("div",ns({},l,{ref:_,className:"".concat(Vi.wrapperClass," ").concat(Ko.wrapper," ").concat(o),style:v}),ce.createElement("div",ns({},c,{ref:a,className:"".concat(Vi.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},av=function(){var e=ql();return Hr(e)};function lv(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 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"}}function dv(e,s){return Tt({queryKey:oe.files.tree(e||"",s),queryFn:()=>xe.get("/files/tree",{params:{workingDir:e||"",path:s}}),enabled:!!e})}function uv(e,s){return Tt({queryKey:oe.files.content(e||"",s||""),queryFn:()=>xe.get("/files/read",{params:{workingDir:e||"",path:s||""}}),enabled:!!e&&!!s})}function hv(e){const s=at();return C.useCallback(()=>{e&&s.invalidateQueries({queryKey:["files","tree",e]})},[s,e])}function fv(){const e=at();return St({mutationFn:s=>xe.post("/files/write",s),onSuccess:(s,r)=>{const o=oe.files.content(r.workingDir,r.path),p=e.getQueryData(o);e.setQueryData(o,{content:r.content,language:p?.language||cv(r.path)})}})}function mv(e,s){return e==="/"?`/${s}`:`${e}/${s}`}function pv(e,s){return e==="/"?s:`${e.slice(1)}/${s}`}const gv=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function vv(e){if(e.type==="directory")return null;const s=e.name.split(".").pop()?.toLowerCase();return s&&gv.has(s)?Ma:s==="ts"||s==="tsx"||s==="js"||s==="jsx"?Tr:s==="json"?Kd:s==="md"||s==="mdx"||s==="txt"?Ra:Cd}const Xo=({depth:e,active:s,onClick:r,leftIcon:o,rightIcon:p,label:m})=>t.jsxs("button",{type:"button",onClick:r,className:ee("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}=ue(),{data:n,isLoading:l,isError:u}=dv(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=mv(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(Yr,{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 x=pv(s,g.name),y=vv(g),_=v===x,a=y===Ma;return t.jsx(Xo,{depth:r,active:_,onClick:()=>m(x),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},x)})})},xv=({workingDir:e,className:s,onFileSelect:r,selectedFilePath:o,onCollapse:p})=>{const{t:m}=ue(),[v,i]=C.useState(()=>new Set),n=hv(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:ee("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.")})})]})},_v=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function bv(e){const s=e.split(".").pop()?.toLowerCase();return s?_v.has(s):!1}function yv(e,s){const r="/api",o=new URLSearchParams({workingDir:e,path:s});return`${r}/files/image?${o.toString()}`}const Sv=({filePath:e})=>{const{t:s}=ue(),{zoomIn:r,zoomOut:o,centerView:p}=av(),m=lv(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})]})},wv=({workingDir:e,filePath:s})=>{const{t:r}=ue(),[o,p]=C.useState(!1),m=yv(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(rv,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx(Sv,{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(ov,{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 Cv(e){const s=e.split("/");return s[s.length-1]||e}function kv(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 Ev=({active:e,name:s,isDirty:r,onClick:o,onClose:p})=>{const{t:m}=ue();return t.jsxs("button",{type:"button",onClick:o,className:ee("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:ee("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(os,{size:12})})]})},jv=({workingDir:e,className:s,readOnly:r=!1})=>{const{t:o}=ue(),[p,m]=C.useState([]),[v,i]=C.useState(null),n=fv(),[l,u]=C.useState(280),[c,g]=C.useState(!1),[x,y]=C.useState(!1),_=C.useRef(280),a=C.useCallback(()=>{g(M=>(M?u(_.current):_.current=l,!M))},[l]),h=C.useCallback(M=>{M.preventDefault(),y(!0);const B=M.clientX,D=l,F=A=>{const O=A.clientX-B,P=Math.min(480,Math.max(160,D+O));u(P)},W=()=>{y(!1),document.removeEventListener("mousemove",F),document.removeEventListener("mouseup",W)};document.addEventListener("mousemove",F),document.addEventListener("mouseup",W)},[l]);C.useEffect(()=>{m([]),i(null)},[e]);const d=C.useMemo(()=>p.find(M=>M.path===v)||null,[p,v]),{data:f,isFetching:b,isError:w,error:k}=uv(e,d?.isImage?null:v);C.useEffect(()=>{!v||!f||m(M=>M.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(M=>{m(B=>{if(B.find(W=>W.path===M))return B;const F=bv(M);return[...B,{path:M,name:Cv(M),language:kv(M),content:"",savedContent:"",isDirty:!1,loaded:F,isImage:F}]}),i(M)},[]),S=C.useCallback(M=>{m(B=>{const D=B.filter(F=>F.path!==M);return i(F=>F!==M?F:D.length?D[D.length-1].path:null),D})},[]),E=C.useCallback(M=>{m(B=>B.map(D=>{if(D.path!==v)return D;const F=M!==D.savedContent;return{...D,content:M,isDirty:F}}))},[v]),R=C.useCallback(async()=>{r||!e||!d||(await n.mutateAsync({workingDir:e,path:d.path,content:d.content}),m(M=>M.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 M=B=>{r||(B.metaKey||B.ctrlKey)&&B.key.toLowerCase()==="s"&&(B.preventDefault(),L.current())};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[r]);const T=C.useCallback((M,B)=>{M.addCommand(B.KeyMod.CtrlCmd|B.KeyCode.KeyS,()=>{L.current()})},[]);return t.jsxs("div",{className:ee("flex h-full overflow-hidden bg-white",s),style:x?{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:x?"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(xv,{workingDir:e,onFileSelect:j,selectedFilePath:d?.path||null,onCollapse:a},e||"no-working-dir")})}),!c&&t.jsx("div",{onMouseDown:h,className:ee("w-1 shrink-0 cursor-col-resize transition-colors",x?"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(M=>t.jsx(Ev,{active:M.path===v,name:M.name,isDirty:M.isDirty,onClick:()=>i(M.path),onClose:B=>{B.stopPropagation(),S(M.path)}},M.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(Ve,{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(wv,{workingDir:e,filePath:d.path}):t.jsxs(t.Fragment,{children:[t.jsx(Yp,{path:d.path,value:d.content,language:d.language,theme:"vs-light",height:"100%",onChange:r?void 0:M=>E(M??""),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(Ve,{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:oe.git.changes(e||""),queryFn:()=>xe.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e&&(s.enabled??!0)})}function Xl(e,s,r){return Tt({queryKey:oe.git.diff(e||"",s||"",r),queryFn:()=>xe.get("/git/diff",{params:{workingDir:e||"",path:s||"",type:r}}),enabled:!!e&&!!s})}function In(e,s){return Tt({queryKey:oe.git.commitFiles(e||"",s||""),queryFn:()=>xe.get("/git/commit-files",{params:{workingDir:e||"",hash:s||""}}),enabled:!!e&&!!s})}function Bn(e,s,r){return Tt({queryKey:oe.git.commitDiff(e||"",s||"",r||""),queryFn:()=>xe.get("/git/commit-diff",{params:{workingDir:e||"",hash:s||"",path:r||""}}),enabled:!!e&&!!s&&!!r})}function Yl({isOpen:e,onClose:s,branchName:r,targetBranch:o,commitMessage:p,isPending:m,error:v,onConfirm:i}){const{t:n}=ue(),[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 x=()=>{m||s()};return t.jsx(hs,{isOpen:e,onClose:x,title:n("提交变更"),className:"max-w-md",action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:x,disabled:m,className:"px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children: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(Ve,{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(Od,{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 Vl(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 Yo(e,s,r,o){const p=Vl(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}=ue(),{data:l,isLoading:u}=Nn(e),c=dl(),g=cl(),x=Rn(),[y,_]=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(Ve,{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=>{Yo(T,n("更新失败,请稍后重试"),M=>v(M),h)}})},E=()=>{h(null),_(!0)},R=T=>{h(null),g.mutate({id:e,commitMessage:T},{onSuccess:()=>_(!1),onError:M=>{Yo(M,n("提交失败,请稍后重试"),B=>{_(!1),v(B)},h)}})},L=()=>{g.isPending||(_(!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(_d,{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(Vd,{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:()=>x.mutate(e),disabled:x.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs text-muted-foreground hover:bg-muted border border-border transition-colors disabled:opacity-50",children:x.isPending?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(Ve,{size:13,className:"animate-spin shrink-0"}),t.jsx("span",{children:l.operation==="rebase"?n("正在同步源分支更新..."):n("正在提交变更...")})]}),t.jsxs("button",{onClick:()=>x.mutate(e),disabled:x.isPending,className:"flex items-center gap-1.5 ml-auto px-2.5 py-1 rounded-md text-xs text-muted-foreground hover:bg-muted border border-border transition-colors disabled:opacity-50",children:[t.jsx(Rd,{size:12}),x.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(Yl,{isOpen:y,onClose:L,branchName:s,targetBranch:r,commitMessage:o,isPending:g.isPending,error:a,onConfirm:R})]})}const Ai=50,Mi=400,Vo={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 Nv(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function Rv(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?gt("{count}s ago",{count:r}):r<3600?gt("{count}m ago",{count:Math.floor(r/60)}):r<86400?gt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?gt("{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:ee("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"})]}),Av=({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:ee("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:ee("pl-2 whitespace-pre",o),children:e})]})},Zl=({diff:e})=>{const{t:s}=ue(),[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(Av,{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})})]})},Mv=({workingDir:e,path:s,diffType:r,enabled:o})=>{const{t:p}=ue(),{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(Ve,{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||""})},Tv=({workingDir:e,hash:s,path:r,enabled:o})=>{const{t:p}=ue(),{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(Ve,{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 x=l.current;if(!x||i)return;const y=new IntersectionObserver(_=>{_.some(a=>a.isIntersecting)&&(n(!0),y.disconnect())},{rootMargin:"300px 0px"});return y.observe(x),()=>y.disconnect()},[i]);const c=Vo[e.status]||Vo.M,g=Nv(e.path);return t.jsxs("div",{ref:l,"data-card-key":u,className:ee("rounded-md border border-border bg-background overflow-hidden transition-shadow",o&&"ring-2 ring-info/40"),children:[t.jsxs("button",{type:"button",onClick:()=>v(x=>!x),className:"w-full flex items-center gap-2 px-3 py-2 bg-muted/40 hover:bg-muted/70 transition-colors text-left",children:[m?t.jsx(Mt,{size:13,className:"text-muted-foreground/70 shrink-0"}):t.jsx(yt,{size:13,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:ee("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(Mv,{workingDir:r,path:e.path,diffType:s.diffType,enabled:i}):t.jsx(Tv,{workingDir:r,hash:s.hash,path:e.path,enabled:i})})]})};function Dv(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 Lv=({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(Yr,{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(Lv,{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:ee("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:ee("w-1.5 h-1.5 rounded-full shrink-0",Go[p.status]||Go.M)}),t.jsx("span",{className:ee("text-xs truncate",m?"text-foreground font-medium":"text-foreground/90"),children:Ql(p.path)})]},p.cardKey)})]}),Pv=({workingDir:e,selectedHash:s,onSelectCommit:r})=>{const{t:o}=ue(),{data:p,isLoading:m,fetchNextPage:v,hasNextPage:i,isFetchingNextPage:n}=gn({queryKey:oe.git.log(e),queryFn:({pageParam:u=0})=>xe.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(Ve,{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:ee("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:ee("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:ee("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," · ",Rv(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(Ve,{size:11,className:"animate-spin"})," ",o("正在加载...")]}):o("加载更多提交")})]})},Ov=({workingDir:e,workspaceId:s,branchName:r,targetBranch:o,commitMessage:p,canRunGitOperations:m,onRefreshCommitMessage:v,onConflict:i,onResolveConflicts:n})=>{const{t:l}=ue(),[u,c]=C.useState({kind:"overview"}),[g,x]=C.useState(""),[y,_]=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((U,X)=>{X?S.current.set(U,X):S.current.delete(U)},[]),{uncommitted:T,committed:M,commitFiles:B}=C.useMemo(()=>{const U=N=>!g.trim()||N.path.toLowerCase().includes(g.trim().toLowerCase());if(u.kind==="commit"){const N={kind:"commit",hash:u.commit.hash},H=(k?.files||[]).filter(U).map(K=>({...K,cardKey:jr(N,K.path)}));return{uncommitted:[],committed:[],commitFiles:H}}const X=(d?.uncommitted||[]).filter(U).map(N=>({...N,cardKey:jr({kind:"working",diffType:"uncommitted"},N.path)})),z=(d?.committed||[]).filter(U).map(N=>({...N,cardKey:jr({kind:"working",diffType:"committed"},N.path)}));return{uncommitted:X,committed:z,commitFiles:[]}},[u,d,k,g]),D=u.kind==="commit"?B:[...T,...M],F=C.useMemo(()=>Dv(D),[D]),W=C.useMemo(()=>{let U=0,X=0;for(const z of D)U+=z.additions??0,X+=z.deletions??0;return{additions:U,deletions:X,files:D.length}},[D]),A=C.useCallback(()=>{const U=E.current;if(!U)return;const X=U.getBoundingClientRect().top;let z=null,N=Number.NEGATIVE_INFINITY;for(const[H,K]of S.current){const q=K.getBoundingClientRect().top-X;q<=48&&q>N&&(N=q,z=H)}if(!z){let H=null,K=Number.POSITIVE_INFINITY;for(const[q,ie]of S.current){const Q=ie.getBoundingClientRect().top-X;Q<K&&(K=Q,H=q)}z=H}_(z)},[]);C.useEffect(()=>{const U=E.current;if(!U)return;let X=0;const z=()=>{cancelAnimationFrame(X),X=requestAnimationFrame(A)};return U.addEventListener("scroll",z,{passive:!0}),()=>{U.removeEventListener("scroll",z),cancelAnimationFrame(X)}},[A]);const O=C.useCallback(U=>{const X=S.current.get(U.cardKey);X&&(X.scrollIntoView({behavior:"smooth",block:"start"}),_(U.cardKey),h(U.cardKey),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>h(null),1200))},[]),P=C.useCallback(U=>{c(X=>X.kind==="commit"&&X.commit.hash===U.hash?{kind:"overview"}:{kind:"commit",commit:U}),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:W.files})}),t.jsx(Zi,{additions:W.additions,deletions:W.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:W.additions,deletions:W.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(U=>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"})]})]},U))}):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(U=>t.jsx(Ti,{entry:U,source:{kind:"commit",hash:u.commit.hash},workingDir:e,flash:a===U.cardKey,registerNode:L},U.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(U=>t.jsx(Ti,{entry:U,source:{kind:"working",diffType:"uncommitted"},workingDir:e,flash:a===U.cardKey,registerNode:L},U.cardKey))})]}),M.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:M.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:M.map(U=>t.jsx(Ti,{entry:U,source:{kind:"working",diffType:"committed"},workingDir:e,flash:a===U.cardKey,registerNode:L},U.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:U=>x(U.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:F,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(Pv,{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 Iv(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?gt("{count}s ago",{count:r}):r<3600?gt("{count}m ago",{count:Math.floor(r/60)}):r<86400?gt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?gt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function Bv(e){const s=e.split("/");return s[s.length-1]||e}function Fv(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}const zv=({line:e,lineNum:s})=>{let r="",o="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?r="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?r="bg-destructive/10":e.startsWith("@@")?(r="bg-info/5",o="text-info"):(e.startsWith("diff ")||e.startsWith("index "))&&(o="text-muted-foreground/70"),t.jsxs("div",{className:ee("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:ee("pl-2 whitespace-pre",o),children:e})]})},Hv=({workingDir:e,hash:s,filePath:r})=>{const{t:o}=ue(),{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(Ve,{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(zv,{line:l,lineNum:u+1},u))})},Wv=({workingDir:e,hash:s,selectedPath:r,onSelectFile:o})=>{const{t:p}=ue(),{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(Ve,{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=Fv(n.path);return t.jsxs("button",{type:"button",onClick:c=>{c.stopPropagation(),o(n.path)},className:ee("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:ee("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:Bv(n.path)}),u&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate ml-auto shrink-0",children:u})]},n.path)})})},$v=({workingDir:e})=>{const{t:s}=ue(),{data:r,isLoading:o,isError:p,fetchNextPage:m,hasNextPage:v,isFetchingNextPage:i}=gn({queryKey:oe.git.log(e||""),queryFn:({pageParam:w=0})=>xe.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),[x,y]=C.useState(280),[_,a]=C.useState(!1),h=C.useCallback(w=>{w.preventDefault(),a(!0);const k=w.clientX,j=x,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)},[x]),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(Ve,{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:_?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsxs("div",{className:"border-r border-border flex flex-col shrink-0",style:{width:x},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:ee("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:ee("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:ee("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:Iv(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(Ve,{size:12,className:"animate-spin"})," ",s("Loading...")]}):s("Load more")})]})]}),t.jsx("div",{onMouseDown:h,className:ee("w-1 shrink-0 cursor-col-resize transition-colors",_?"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(Hv,{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 Uv(e){return Tt({queryKey:oe.previews.status(e??""),queryFn:async()=>{const s=await xe.get(`/previews/${e}/status`);return{...s,viewUrl:s.viewUrl?s.viewUrl:null}},enabled:!!e,refetchOnWindowFocus:!1})}function qv(e){const s=at();return St({mutationFn:r=>xe.put(`/previews/${e}/config`,{target:r}),onSuccess:()=>{e&&(s.invalidateQueries({queryKey:oe.previews.status(e)}),s.invalidateQueries({queryKey:oe.workspaces.all}))}})}function Kv(){return"3000, localhost:3000, http://127.0.0.1:5173"}function Xv({workspaceId:e,readOnly:s}){const{t:r}=ue(),{data:o,isLoading:p,refetch:m,isFetching:v}=Uv(e),i=qv(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]),x=async()=>{if(e)try{await i.mutateAsync(n.trim()||null),c(_=>_+1),ht.success(r("Preview target saved"))}catch(_){const a=_ instanceof Error?_.message:r("Failed to save preview target");ht.error(a)}},y=async()=>{await m(),c(_=>_+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:_=>l(_.target.value),onKeyDown:_=>{_.key==="Enter"&&!_.nativeEvent.isComposing&&(_.preventDefault(),x())},disabled:s||i.isPending,placeholder:Kv(),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(Me,{type:"button",size:"sm",variant:"outline",onClick:x,disabled:s||i.isPending,title:r("Save preview target"),children:[i.isPending?t.jsx(Ve,{className:"animate-spin"}):t.jsx(pu,{}),t.jsx("span",{className:"hidden xl:inline",children:r("Save")})]}),t.jsxs(Me,{type:"button",size:"sm",variant:"outline",onClick:y,disabled:v,title:r("Refresh preview"),children:[v?t.jsx(Ve,{className:"animate-spin"}):t.jsx(ir,{}),t.jsx("span",{className:"hidden xl:inline",children:r("Refresh")})]}),o?.ready&&o.viewUrl&&t.jsx(Me,{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 Yv(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}=ue(),[n,l]=C.useState(!1),u=C.useRef(null),c=C.useMemo(()=>Tn(e,s),[e,s]),g=c.find(x=>x.workspace.id===r)??c[0];return C.useEffect(()=>{if(!n)return;const x=y=>{u.current&&!u.current.contains(y.target)&&l(!1)};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[n]),c.length<=1?null:t.jsxs("div",{ref:u,className:ee("relative",m),children:[t.jsxs("button",{type:"button",onClick:()=>l(x=>!x),disabled:p,className:ee("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:ee("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:ee("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(x=>{const y=x.workspace.id===g.workspace.id;return t.jsxs("button",{type:"button",onClick:()=>{o(x.workspace.id),l(!1)},className:ee("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(Kt,{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(x.displayName)}),t.jsx("span",{className:ee("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",Zo(x.roleLabel)),children:i(x.roleLabel)}),t.jsx("span",{className:ee("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",Yv(x.workspace.status)),children:x.workspace.status})]}),t.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-neutral-500",children:fs(x.workspace)}),t.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[x.ownerName&&t.jsxs("span",{children:[i("Owner"),": ",x.ownerName]}),x.parentBranchName&&t.jsxs("span",{children:[i("Parent"),": ",x.parentBranchName]}),t.jsx("span",{children:x.workspace.id.slice(0,8)})]})]})]},x.workspace.id)})})]})}const Gv=[{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})}],Qv=[{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})}],Zv=({active:e,onClick:s,icon:r,label:o})=>t.jsxs("button",{type:"button",onClick:s,className:ee("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})]}),Jv=({active:e,onClick:s,icon:r,label:o})=>t.jsx("button",{type:"button",onClick:s,title:o,"aria-label":o,"aria-pressed":e,className:ee("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=ce.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:x,selectedWorkspaceId:y,onSelectWorkspace:_,variant:a="tabs",expanded:h,onExpandedChange:d,minContentWidth:f=520,tabRef:b}){const{t:w}=ue(),k=sn(z=>z.setVisibleContext),j=a==="rail",[S,E]=C.useState(!1),R=j?h??S:!0,L=C.useCallback(z=>{h===void 0&&E(z),d?.(z)},[h,d]),T=C.useMemo(()=>{const z=v?Qv:Gv,N=i?z:z.filter(K=>K.key!=="review"&&K.key!=="history"),H=n?N.filter(K=>K.key!=="terminal"):N;return u?[{key:"team-status",label:"Team Status",icon:t.jsx(us,{size:14})},...H]:H},[i,v,n,u]),[M,B]=C.useState(i?v?"history":"review":"editor"),D=C.useCallback(z=>{B(z),j&&L(!0)},[j,L]);C.useImperativeHandle(b,()=>({setTab:z=>D(z)}),[D]);const{data:F}=kd(m??""),W=C.useMemo(()=>{if(!F?.quickCommands)return[];try{return JSON.parse(F.quickCommands)}catch{return[]}},[F?.quickCommands]),[A,O]=C.useState([]),P=C.useRef(void 0);C.useEffect(()=>{p&&p!==P.current&&(P.current=p,O(z=>z.includes(p)?z:[...z,p]))},[p]),C.useEffect(()=>{T.some(z=>z.key===M)||B(T[0]?.key??"editor")},[M,T]),C.useEffect(()=>{if(j&&!R)return;const z=M==="review"?"changes":M==="history"?"history":null;if(!o||!p||!z){k(null);return}return k({workspaceId:o,workingDir:p,tab:z}),()=>{k(null)}},[M,R,j,k,p,o]);const I=!!_&&Tn(x,u).length>1,$=T.find(z=>z.key===M)??T[0],Y=$?w($.label):"",U=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,X=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:x,teamRun:u,selectedWorkspaceId:y,onSelectWorkspace:_,buttonClassName:"h-7 text-[11px]"})}),t.jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[M==="team-status"&&u&&c,M==="editor"&&t.jsx(jv,{workingDir:p,readOnly:n}),A.map(z=>{const N=M==="terminal"&&p===z;return t.jsx("div",{"aria-hidden":!N,className:"absolute inset-0 h-full w-full min-h-0 min-w-0 overflow-hidden",style:{display:N?"block":"none"},children:t.jsx(Fm,{cwd:z,isVisible:N,quickCommands:W})},z)}),M==="preview"&&t.jsx(Xv,{workspaceId:o,readOnly:n}),M==="review"&&t.jsx(Ov,{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}),M==="history"&&t.jsx($v,{workingDir:p})]})]});return j?t.jsxs("div",{className:ee("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(z=>t.jsx(Jv,{active:R&&M===z.key,onClick:()=>D(z.key),icon:z.icon,label:w(z.label)},z.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:[U,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})})]}),X]})]}):t.jsxs("div",{className:ee("flex h-full w-full min-w-0 flex-col bg-white",s),children:[n&&U,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(z=>t.jsx(Zv,{active:M===z.key,onClick:()=>D(z.key),icon:z.icon,label:w(z.label)},z.key))}),X]})}),Jo=1500,e0=3e3;function t0(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),e0)},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,x=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)):x>0?(p.current=c,v(),m.current=setTimeout(()=>n(c),x)):n(c)};return i.on(dt.WORKSPACE_SETUP_PROGRESS,l),()=>{i.off(dt.WORKSPACE_SETUP_PROGRESS,l),v(),o.current=0,p.current=null}},[e]),s}function Fn(){const e=at();return St({mutationFn:s=>xe.post(`/sessions/${s}/start`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:oe.sessions.detail(r)}),e.invalidateQueries({queryKey:oe.tasks.all})}})}function rc(){const e=at();return St({mutationFn:s=>xe.post(`/sessions/${s}/stop`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:oe.sessions.detail(r)})}})}function zn(){const e=at();return St({mutationFn:({id:s,message:r,providerId:o})=>xe.post(`/sessions/${s}/message`,{message:r,providerId:o}),onSuccess:()=>{e.invalidateQueries({queryKey:oe.workspaces.all}),e.invalidateQueries({queryKey:oe.tasks.all})}})}function ic({isOpen:e,onClose:s,onStarted:r,taskId:o,taskTitle:p,taskDescription:m,taskPrompt:v,projectIsGitRepo:i=!0}){const{t:n}=ue(),[l,u]=C.useState(""),[c,g]=C.useState(""),[x,y]=C.useState(Dt.WORKTREE),[_,a]=C.useState("idle"),[h,d]=C.useState(null),f=at(),b=ll(o),w=Fn(),{data:k,isLoading:j}=Ds();C.useEffect(()=>{if(!e||!k)return;const F=k.find(W=>W.availability.type!=="NOT_FOUND");F&&u(F.provider.id)},[e,k]),C.useEffect(()=>{if(e){const F=[p];m&&F.push(m),g(v?.trim()||F.join(`
|
|
70
|
+
`,Xo={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};iv(nv);var ov=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(ni),x=g.init,y=g.cleanupWindowEvents,_=C.useRef(null),a=C.useRef(null);return C.useEffect(function(){var h=_.current,d=a.current;return h!==null&&d!==null&&x&&x?.(h,d),function(){y?.()}},[]),ce.createElement("div",ns({},l,{ref:_,className:"".concat(Gi.wrapperClass," ").concat(Xo.wrapper," ").concat(o),style:v}),ce.createElement("div",ns({},c,{ref:a,className:"".concat(Gi.contentClass," ").concat(Xo.content," ").concat(m),style:i}),s))},Xl=function(){var e=C.useContext(ni);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},av=function(){var e=Xl();return Hr(e)};function lv(e){var s=Xl(),r=C.useState(e(Qi(s))),o=r[0],p=r[1];return C.useEffect(function(){var m=!0,v=s.onChange(function(i){m&&p(e(Qi(i.instance)))});return function(){v(),m=!1}},[e,s]),o}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"}}function dv(e,s){return Tt({queryKey:oe.files.tree(e||"",s),queryFn:()=>xe.get("/files/tree",{params:{workingDir:e||"",path:s}}),enabled:!!e})}function uv(e,s){return Tt({queryKey:oe.files.content(e||"",s||""),queryFn:()=>xe.get("/files/read",{params:{workingDir:e||"",path:s||""}}),enabled:!!e&&!!s})}function hv(e){const s=at();return C.useCallback(()=>{e&&s.invalidateQueries({queryKey:["files","tree",e]})},[s,e])}function fv(){const e=at();return St({mutationFn:s=>xe.post("/files/write",s),onSuccess:(s,r)=>{const o=oe.files.content(r.workingDir,r.path),p=e.getQueryData(o);e.setQueryData(o,{content:r.content,language:p?.language||cv(r.path)})}})}function mv(e,s){return e==="/"?`/${s}`:`${e}/${s}`}function pv(e,s){return e==="/"?s:`${e.slice(1)}/${s}`}const gv=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function vv(e){if(e.type==="directory")return null;const s=e.name.split(".").pop()?.toLowerCase();return s&&gv.has(s)?Ea:s==="ts"||s==="tsx"||s==="js"||s==="jsx"?Dr:s==="json"?Xd:s==="md"||s==="mdx"||s==="txt"?ka:Nd}const Yo=({depth:e,active:s,onClick:r,leftIcon:o,rightIcon:p,label:m})=>t.jsxs("button",{type:"button",onClick:r,className:ee("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})]}),Yl=({workingDir:e,path:s,depth:r,expanded:o,toggleDir:p,onFileSelect:m,selectedFilePath:v})=>{const{t:i}=ue(),{data:n,isLoading:l,isError:u}=dv(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=mv(s,g.name),d=o.has(h);return t.jsxs("div",{children:[t.jsx(Yo,{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(Fa,{size:14,className:"text-amber-500"}),label:g.name}),d&&t.jsx(Yl,{workingDir:e,path:h,depth:r+1,expanded:o,toggleDir:p,onFileSelect:m,selectedFilePath:v})]},h)}const x=pv(s,g.name),y=vv(g),_=v===x,a=y===Ea;return t.jsx(Yo,{depth:r,active:_,onClick:()=>m(x),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},x)})})},xv=({workingDir:e,className:s,onFileSelect:r,selectedFilePath:o,onCollapse:p})=>{const{t:m}=ue(),[v,i]=C.useState(()=>new Set),n=hv(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:ee("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(nr,{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(nu,{size:13})})]})]}),t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin p-2",children:e?t.jsx(Yl,{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.")})})]})},_v=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function bv(e){const s=e.split(".").pop()?.toLowerCase();return s?_v.has(s):!1}function yv(e,s){const r=rr(),o=new URLSearchParams({workingDir:e,path:s});return`${r}/files/image?${o.toString()}`}const Sv=({filePath:e})=>{const{t:s}=ue(),{zoomIn:r,zoomOut:o,centerView:p}=av(),m=lv(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(ru,{size:13})}),t.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},wv=({workingDir:e,filePath:s})=>{const{t:r}=ue(),[o,p]=C.useState(!1),m=yv(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(rv,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx(Sv,{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(ov,{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 Cv(e){const s=e.split("/");return s[s.length-1]||e}function kv(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 Ev=({active:e,name:s,isDirty:r,onClick:o,onClose:p})=>{const{t:m}=ue();return t.jsxs("button",{type:"button",onClick:o,className:ee("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:ee("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(os,{size:12})})]})},jv=({workingDir:e,className:s,readOnly:r=!1})=>{const{t:o}=ue(),[p,m]=C.useState([]),[v,i]=C.useState(null),n=fv(),[l,u]=C.useState(280),[c,g]=C.useState(!1),[x,y]=C.useState(!1),_=C.useRef(280),a=C.useCallback(()=>{g(M=>(M?u(_.current):_.current=l,!M))},[l]),h=C.useCallback(M=>{M.preventDefault(),y(!0);const B=M.clientX,D=l,F=A=>{const O=A.clientX-B,P=Math.min(480,Math.max(160,D+O));u(P)},H=()=>{y(!1),document.removeEventListener("mousemove",F),document.removeEventListener("mouseup",H)};document.addEventListener("mousemove",F),document.addEventListener("mouseup",H)},[l]);C.useEffect(()=>{m([]),i(null)},[e]);const d=C.useMemo(()=>p.find(M=>M.path===v)||null,[p,v]),{data:f,isFetching:b,isError:w,error:k}=uv(e,d?.isImage?null:v);C.useEffect(()=>{!v||!f||m(M=>M.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(M=>{m(B=>{if(B.find(H=>H.path===M))return B;const F=bv(M);return[...B,{path:M,name:Cv(M),language:kv(M),content:"",savedContent:"",isDirty:!1,loaded:F,isImage:F}]}),i(M)},[]),S=C.useCallback(M=>{m(B=>{const D=B.filter(F=>F.path!==M);return i(F=>F!==M?F:D.length?D[D.length-1].path:null),D})},[]),E=C.useCallback(M=>{m(B=>B.map(D=>{if(D.path!==v)return D;const F=M!==D.savedContent;return{...D,content:M,isDirty:F}}))},[v]),R=C.useCallback(async()=>{r||!e||!d||(await n.mutateAsync({workingDir:e,path:d.path,content:d.content}),m(M=>M.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 M=B=>{r||(B.metaKey||B.ctrlKey)&&B.key.toLowerCase()==="s"&&(B.preventDefault(),L.current())};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[r]);const T=C.useCallback((M,B)=>{M.addCommand(B.KeyMod.CtrlCmd|B.KeyCode.KeyS,()=>{L.current()})},[]);return t.jsxs("div",{className:ee("flex h-full overflow-hidden bg-white",s),style:x?{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:x?"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(au,{size:16})})}):t.jsx(t.Fragment,{children:t.jsx(xv,{workingDir:e,onFileSelect:j,selectedFilePath:d?.path||null,onCollapse:a},e||"no-working-dir")})}),!c&&t.jsx("div",{onMouseDown:h,className:ee("w-1 shrink-0 cursor-col-resize transition-colors",x?"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(M=>t.jsx(Ev,{active:M.path===v,name:M.name,isDirty:M.isDirty,onClick:()=>i(M.path),onClose:B=>{B.stopPropagation(),S(M.path)}},M.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(Ve,{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(wv,{workingDir:e,filePath:d.path}):t.jsxs(t.Fragment,{children:[t.jsx(Yp,{path:d.path,value:d.content,language:d.language,theme:"vs-light",height:"100%",onChange:r?void 0:M=>E(M??""),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(Ve,{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 oi(e,s={}){return Tt({queryKey:oe.git.changes(e||""),queryFn:()=>xe.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e&&(s.enabled??!0)})}function Vl(e,s,r){return Tt({queryKey:oe.git.diff(e||"",s||"",r),queryFn:()=>xe.get("/git/diff",{params:{workingDir:e||"",path:s||"",type:r}}),enabled:!!e&&!!s})}function Bn(e,s){return Tt({queryKey:oe.git.commitFiles(e||"",s||""),queryFn:()=>xe.get("/git/commit-files",{params:{workingDir:e||"",hash:s||""}}),enabled:!!e&&!!s})}function Fn(e,s,r){return Tt({queryKey:oe.git.commitDiff(e||"",s||"",r||""),queryFn:()=>xe.get("/git/commit-diff",{params:{workingDir:e||"",hash:s||"",path:r||""}}),enabled:!!e&&!!s&&!!r})}function Gl({isOpen:e,onClose:s,branchName:r,targetBranch:o,commitMessage:p,isPending:m,error:v,onConfirm:i}){const{t:n}=ue(),[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 x=()=>{m||s()};return t.jsx(hs,{isOpen:e,onClose:x,title:n("提交变更"),className:"max-w-md",action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:x,disabled:m,className:"px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children: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(Ve,{size:14,className:"animate-spin"}),n("正在提交...")]}):t.jsxs(t.Fragment,{children:[t.jsx(Tr,{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(Bd,{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 Ql(e){if(!(e instanceof ba)||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=Ql(e);if(p){r(p);return}o(e instanceof Error?e.message:s)}function Zl({workspaceId:e,branchName:s,targetBranch:r,commitMessage:o,committedFileCount:p,onRefreshCommitMessage:m,onConflict:v,onResolveConflicts:i}){const{t:n}=ue(),{data:l,isLoading:u}=Rn(e),c=hl(),g=ul(),x=An(),[y,_]=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(Ve,{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("更新失败,请稍后重试"),M=>v(M),h)}})},E=()=>{h(null),_(!0)},R=T=>{h(null),g.mutate({id:e,commitMessage:T},{onSuccess:()=>_(!1),onError:M=>{Vo(M,n("提交失败,请稍后重试"),B=>{_(!1),v(B)},h)}})},L=()=>{g.isPending||(_(!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(ud,{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(Gd,{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(ir,{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:()=>x.mutate(e),disabled:x.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs text-muted-foreground hover:bg-muted border border-border transition-colors disabled:opacity-50",children:x.isPending?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(Ve,{size:13,className:"animate-spin shrink-0"}),t.jsx("span",{children:l.operation==="rebase"?n("正在同步源分支更新..."):n("正在提交变更...")})]}),t.jsxs("button",{onClick:()=>x.mutate(e),disabled:x.isPending,className:"flex items-center gap-1.5 ml-auto px-2.5 py-1 rounded-md text-xs text-muted-foreground hover:bg-muted border border-border transition-colors disabled:opacity-50",children:[t.jsx(hd,{size:12}),x.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(nr,{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(Tr,{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(Tr,{size:12}),n("提交变更")]})]})]})]})}),t.jsx(Gl,{isOpen:y,onClose:L,branchName:s,targetBranch:r,commitMessage:o,isPending:g.isPending,error:a,onConfirm:R})]})}const Mi=50,Ti=400,Go={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"},Qo={M:"bg-amber-500",A:"bg-emerald-500",D:"bg-red-500",R:"bg-blue-500"};function Jl(e){const s=e.split("/");return s[s.length-1]||e}function Nv(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function Rv(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?gt("{count}s ago",{count:r}):r<3600?gt("{count}m ago",{count:Math.floor(r/60)}):r<86400?gt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?gt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function Nr(e,s){return e.kind==="working"?`${e.diffType}:${s}`:`${e.hash}:${s}`}const Ji=({additions:e,deletions:s,className:r})=>e===void 0&&s===void 0?null:t.jsxs("span",{className:ee("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"})]}),Av=({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:ee("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:ee("pl-2 whitespace-pre",o),children:e})]})},ec=({diff:e})=>{const{t:s}=ue(),[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>Ti,v=m?p.slice(0,Ti):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(Av,{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-Ti})})]})},Mv=({workingDir:e,path:s,diffType:r,enabled:o})=>{const{t:p}=ue(),{data:m,isLoading:v,isError:i}=Vl(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(Ve,{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(ec,{diff:m?.diff||""})},Tv=({workingDir:e,hash:s,path:r,enabled:o})=>{const{t:p}=ue(),{data:m,isLoading:v,isError:i}=Fn(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(Ve,{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(ec,{diff:m?.diff||""})},Di=({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=Nr(s,e.path);C.useEffect(()=>(p(u,l.current),()=>p(u,null)),[u,p]),C.useEffect(()=>{const x=l.current;if(!x||i)return;const y=new IntersectionObserver(_=>{_.some(a=>a.isIntersecting)&&(n(!0),y.disconnect())},{rootMargin:"300px 0px"});return y.observe(x),()=>y.disconnect()},[i]);const c=Go[e.status]||Go.M,g=Nv(e.path);return t.jsxs("div",{ref:l,"data-card-key":u,className:ee("rounded-md border border-border bg-background overflow-hidden transition-shadow",o&&"ring-2 ring-info/40"),children:[t.jsxs("button",{type:"button",onClick:()=>v(x=>!x),className:"w-full flex items-center gap-2 px-3 py-2 bg-muted/40 hover:bg-muted/70 transition-colors text-left",children:[m?t.jsx(Mt,{size:13,className:"text-muted-foreground/70 shrink-0"}):t.jsx(yt,{size:13,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:ee("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:Jl(e.path)}),g&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate",children:g}),t.jsx("span",{className:"ml-auto"}),t.jsx(Ji,{additions:e.additions,deletions:e.deletions})]}),!m&&t.jsx("div",{className:"border-t border-border/60",children:s.kind==="working"?t.jsx(Mv,{workingDir:r,path:e.path,diffType:s.diffType,enabled:i}):t.jsx(Tv,{workingDir:r,hash:s.hash,path:e.path,enabled:i})})]})};function Dv(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 tc(s)}function tc(e){const s=new Map;for(const r of e.dirs.values()){let o=tc(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 Lv=({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(Fa,{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(sc,{node:e,depth:s+1,activeKey:r,onSelect:o})]})},sc=({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(Lv,{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:ee("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:ee("w-1.5 h-1.5 rounded-full shrink-0",Qo[p.status]||Qo.M)}),t.jsx("span",{className:ee("text-xs truncate",m?"text-foreground font-medium":"text-foreground/90"),children:Jl(p.path)})]},p.cardKey)})]}),Pv=({workingDir:e,selectedHash:s,onSelectCommit:r})=>{const{t:o}=ue(),{data:p,isLoading:m,fetchNextPage:v,hasNextPage:i,isFetchingNextPage:n}=xn({queryKey:oe.git.log(e),queryFn:({pageParam:u=0})=>xe.get("/git/log",{params:{workingDir:e,limit:String(Mi),skip:String(u)}}),initialPageParam:0,getNextPageParam:(u,c)=>u.commits.length<Mi?void 0:c.length*Mi}),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(Ve,{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:ee("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:ee("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:ee("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," · ",Rv(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(Ve,{size:11,className:"animate-spin"})," ",o("正在加载...")]}):o("加载更多提交")})]})},Ov=({workingDir:e,workspaceId:s,branchName:r,targetBranch:o,commitMessage:p,canRunGitOperations:m,onRefreshCommitMessage:v,onConflict:i,onResolveConflicts:n})=>{const{t:l}=ue(),[u,c]=C.useState({kind:"overview"}),[g,x]=C.useState(""),[y,_]=C.useState(null),[a,h]=C.useState(null),{data:d,isLoading:f,isError:b}=oi(e),w=u.kind==="commit"?u.commit.hash:null,{data:k,isLoading:j}=Bn(e,w),S=C.useRef(new Map),E=C.useRef(null),R=C.useRef(null),L=C.useCallback((U,X)=>{X?S.current.set(U,X):S.current.delete(U)},[]),{uncommitted:T,committed:M,commitFiles:B}=C.useMemo(()=>{const U=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(U).map(K=>({...K,cardKey:Nr(N,K.path)}));return{uncommitted:[],committed:[],commitFiles:W}}const X=(d?.uncommitted||[]).filter(U).map(N=>({...N,cardKey:Nr({kind:"working",diffType:"uncommitted"},N.path)})),z=(d?.committed||[]).filter(U).map(N=>({...N,cardKey:Nr({kind:"working",diffType:"committed"},N.path)}));return{uncommitted:X,committed:z,commitFiles:[]}},[u,d,k,g]),D=u.kind==="commit"?B:[...T,...M],F=C.useMemo(()=>Dv(D),[D]),H=C.useMemo(()=>{let U=0,X=0;for(const z of D)U+=z.additions??0,X+=z.deletions??0;return{additions:U,deletions:X,files:D.length}},[D]),A=C.useCallback(()=>{const U=E.current;if(!U)return;const X=U.getBoundingClientRect().top;let z=null,N=Number.NEGATIVE_INFINITY;for(const[W,K]of S.current){const q=K.getBoundingClientRect().top-X;q<=48&&q>N&&(N=q,z=W)}if(!z){let W=null,K=Number.POSITIVE_INFINITY;for(const[q,ie]of S.current){const Q=ie.getBoundingClientRect().top-X;Q<K&&(K=Q,W=q)}z=W}_(z)},[]);C.useEffect(()=>{const U=E.current;if(!U)return;let X=0;const z=()=>{cancelAnimationFrame(X),X=requestAnimationFrame(A)};return U.addEventListener("scroll",z,{passive:!0}),()=>{U.removeEventListener("scroll",z),cancelAnimationFrame(X)}},[A]);const O=C.useCallback(U=>{const X=S.current.get(U.cardKey);X&&(X.scrollIntoView({behavior:"smooth",block:"start"}),_(U.cardKey),h(U.cardKey),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>h(null),1200))},[]),P=C.useCallback(U=>{c(X=>X.kind==="commit"&&X.commit.hash===U.hash?{kind:"overview"}:{kind:"commit",commit:U}),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(Zl,{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(Ji,{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(Ji,{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(U=>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"})]})]},U))}):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(Dr,{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(U=>t.jsx(Di,{entry:U,source:{kind:"commit",hash:u.commit.hash},workingDir:e,flash:a===U.cardKey,registerNode:L},U.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(U=>t.jsx(Di,{entry:U,source:{kind:"working",diffType:"uncommitted"},workingDir:e,flash:a===U.cardKey,registerNode:L},U.cardKey))})]}),M.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:M.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:M.map(U=>t.jsx(Di,{entry:U,source:{kind:"working",diffType:"committed"},workingDir:e,flash:a===U.cardKey,registerNode:L},U.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(hn,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground/60"}),t.jsx("input",{value:g,onChange:U=>x(U.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(sc,{node:F,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(Pv,{workingDir:e,selectedHash:w,onSelectCommit:P})})]})]})]})]})},Li=50,Zo={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 Iv(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?gt("{count}s ago",{count:r}):r<3600?gt("{count}m ago",{count:Math.floor(r/60)}):r<86400?gt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?gt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function Bv(e){const s=e.split("/");return s[s.length-1]||e}function Fv(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}const zv=({line:e,lineNum:s})=>{let r="",o="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?r="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?r="bg-destructive/10":e.startsWith("@@")?(r="bg-info/5",o="text-info"):(e.startsWith("diff ")||e.startsWith("index "))&&(o="text-muted-foreground/70"),t.jsxs("div",{className:ee("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:ee("pl-2 whitespace-pre",o),children:e})]})},Wv=({workingDir:e,hash:s,filePath:r})=>{const{t:o}=ue(),{data:p,isLoading:m,isError:v}=Fn(e,s,r);if(m)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:[t.jsx(Ve,{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(zv,{line:l,lineNum:u+1},u))})},Hv=({workingDir:e,hash:s,selectedPath:r,onSelectFile:o})=>{const{t:p}=ue(),{data:m,isLoading:v}=Bn(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(Ve,{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=Zo[n.status]||Zo.M,u=Fv(n.path);return t.jsxs("button",{type:"button",onClick:c=>{c.stopPropagation(),o(n.path)},className:ee("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:ee("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:Bv(n.path)}),u&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate ml-auto shrink-0",children:u})]},n.path)})})},$v=({workingDir:e})=>{const{t:s}=ue(),{data:r,isLoading:o,isError:p,fetchNextPage:m,hasNextPage:v,isFetchingNextPage:i}=xn({queryKey:oe.git.log(e||""),queryFn:({pageParam:w=0})=>xe.get("/git/log",{params:{workingDir:e||"",limit:String(Li),skip:String(w)}}),initialPageParam:0,getNextPageParam:(w,k)=>w.commits.length<Li?void 0:k.length*Li,enabled:!!e}),n=r?.pages.flatMap(w=>w.commits)||[],[l,u]=C.useState(null),[c,g]=C.useState(null),[x,y]=C.useState(280),[_,a]=C.useState(!1),h=C.useCallback(w=>{w.preventDefault(),a(!0);const k=w.clientX,j=x,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)},[x]),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(Ve,{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:_?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsxs("div",{className:"border-r border-border flex flex-col shrink-0",style:{width:x},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:ee("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:ee("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:ee("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:Iv(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(Hv,{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(Ve,{size:12,className:"animate-spin"})," ",s("Loading...")]}):s("Load more")})]})]}),t.jsx("div",{onMouseDown:h,className:ee("w-1 shrink-0 cursor-col-resize transition-colors",_?"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(Dr,{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(Wv,{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(Dr,{size:28}),t.jsx("span",{className:"text-xs",children:s(l?"Select a file to view diff":"Select a commit to view changes")})]})})})]})},Jo=rr();function Uv(e){if(!Jo)return e;try{const s=new URL(Jo);return new URL(e,s.origin).toString()}catch{return e}}function qv(e){return Tt({queryKey:oe.previews.status(e??""),queryFn:async()=>{const s=await xe.get(`/previews/${e}/status`);return{...s,viewUrl:s.viewUrl?Uv(s.viewUrl):null}},enabled:!!e,refetchOnWindowFocus:!1})}function Kv(e){const s=at();return St({mutationFn:r=>xe.put(`/previews/${e}/config`,{target:r}),onSuccess:()=>{e&&(s.invalidateQueries({queryKey:oe.previews.status(e)}),s.invalidateQueries({queryKey:oe.workspaces.all}))}})}function Xv(){return"3000, localhost:3000, http://127.0.0.1:5173"}function Yv({workspaceId:e,readOnly:s}){const{t:r}=ue(),{data:o,isLoading:p,refetch:m,isFetching:v}=qv(e),i=Kv(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]),x=async()=>{if(e)try{await i.mutateAsync(n.trim()||null),c(_=>_+1),ht.success(r("Preview target saved"))}catch(_){const a=_ instanceof Error?_.message:r("Failed to save preview target");ht.error(a)}},y=async()=>{await m(),c(_=>_+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:_=>l(_.target.value),onKeyDown:_=>{_.key==="Enter"&&!_.nativeEvent.isComposing&&(_.preventDefault(),x())},disabled:s||i.isPending,placeholder:Xv(),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(Me,{type:"button",size:"sm",variant:"outline",onClick:x,disabled:s||i.isPending,title:r("Save preview target"),children:[i.isPending?t.jsx(Ve,{className:"animate-spin"}):t.jsx(pu,{}),t.jsx("span",{className:"hidden xl:inline",children:r("Save")})]}),t.jsxs(Me,{type:"button",size:"sm",variant:"outline",onClick:y,disabled:v,title:r("Refresh preview"),children:[v?t.jsx(Ve,{className:"animate-spin"}):t.jsx(nr,{}),t.jsx("span",{className:"hidden xl:inline",children:r("Refresh")})]}),o?.ready&&o.viewUrl&&t.jsx(Me,{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(rn,{})})})]}),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 Vv(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 ea(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 Gv(e){return e.length<=34?e:`...${e.slice(-31)}`}function rc({workspaces:e,teamRun:s,selectedWorkspaceId:r,onSelectWorkspace:o,disabled:p,className:m,buttonClassName:v}){const{t:i}=ue(),[n,l]=C.useState(!1),u=C.useRef(null),c=C.useMemo(()=>Dn(e,s),[e,s]),g=c.find(x=>x.workspace.id===r)??c[0];return C.useEffect(()=>{if(!n)return;const x=y=>{u.current&&!u.current.contains(y.target)&&l(!1)};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[n]),c.length<=1?null:t.jsxs("div",{ref:u,className:ee("relative",m),children:[t.jsxs("button",{type:"button",onClick:()=>l(x=>!x),disabled:p,className:ee("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(Ms,{size:14,className:"shrink-0 text-neutral-500"}),t.jsx("span",{className:ee("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",ea(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:Gv(fs(g.workspace))}),t.jsx(yt,{size:13,className:ee("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(x=>{const y=x.workspace.id===g.workspace.id;return t.jsxs("button",{type:"button",onClick:()=>{o(x.workspace.id),l(!1)},className:ee("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(Kt,{size:13}):t.jsx(Da,{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(x.displayName)}),t.jsx("span",{className:ee("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",ea(x.roleLabel)),children:i(x.roleLabel)}),t.jsx("span",{className:ee("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",Vv(x.workspace.status)),children:x.workspace.status})]}),t.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-neutral-500",children:fs(x.workspace)}),t.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[x.ownerName&&t.jsxs("span",{children:[i("Owner"),": ",x.ownerName]}),x.parentBranchName&&t.jsxs("span",{children:[i("Parent"),": ",x.parentBranchName]}),t.jsx("span",{children:x.workspace.id.slice(0,8)})]})]})]},x.workspace.id)})})]})}const Qv=[{key:"review",label:"Changes",icon:t.jsx(Ls,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(Yr,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(Rr,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(Ta,{size:14})}],Zv=[{key:"history",label:"History",icon:t.jsx(Ts,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(Yr,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(Rr,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(Ta,{size:14})}],Jv=({active:e,onClick:s,icon:r,label:o})=>t.jsxs("button",{type:"button",onClick:s,className:ee("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})]}),e0=({active:e,onClick:s,icon:r,label:o})=>t.jsx("button",{type:"button",onClick:s,title:o,"aria-label":o,"aria-pressed":e,className:ee("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}),ic=ce.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:x,selectedWorkspaceId:y,onSelectWorkspace:_,variant:a="tabs",expanded:h,onExpandedChange:d,minContentWidth:f=520,tabRef:b}){const{t:w}=ue(),k=nn(z=>z.setVisibleContext),j=a==="rail",[S,E]=C.useState(!1),R=j?h??S:!0,L=C.useCallback(z=>{h===void 0&&E(z),d?.(z)},[h,d]),T=C.useMemo(()=>{const z=v?Zv:Qv,N=i?z:z.filter(K=>K.key!=="review"&&K.key!=="history"),W=n?N.filter(K=>K.key!=="terminal"):N;return u?[{key:"team-status",label:"Team Status",icon:t.jsx(us,{size:14})},...W]:W},[i,v,n,u]),[M,B]=C.useState(i?v?"history":"review":"editor"),D=C.useCallback(z=>{B(z),j&&L(!0)},[j,L]);C.useImperativeHandle(b,()=>({setTab:z=>D(z)}),[D]);const{data:F}=Rd(m??""),H=C.useMemo(()=>{if(!F?.quickCommands)return[];try{return JSON.parse(F.quickCommands)}catch{return[]}},[F?.quickCommands]),[A,O]=C.useState([]),P=C.useRef(void 0);C.useEffect(()=>{p&&p!==P.current&&(P.current=p,O(z=>z.includes(p)?z:[...z,p]))},[p]),C.useEffect(()=>{T.some(z=>z.key===M)||B(T[0]?.key??"editor")},[M,T]),C.useEffect(()=>{if(j&&!R)return;const z=M==="review"?"changes":M==="history"?"history":null;if(!o||!p||!z){k(null);return}return k({workspaceId:o,workingDir:p,tab:z}),()=>{k(null)}},[M,R,j,k,p,o]);const I=!!_&&Dn(x,u).length>1,$=T.find(z=>z.key===M)??T[0],Y=$?w($.label):"",U=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,X=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(rc,{workspaces:x,teamRun:u,selectedWorkspaceId:y,onSelectWorkspace:_,buttonClassName:"h-7 text-[11px]"})}),t.jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[M==="team-status"&&u&&c,M==="editor"&&t.jsx(jv,{workingDir:p,readOnly:n}),A.map(z=>{const N=M==="terminal"&&p===z;return t.jsx("div",{"aria-hidden":!N,className:"absolute inset-0 h-full w-full min-h-0 min-w-0 overflow-hidden",style:{display:N?"block":"none"},children:t.jsx(Fm,{cwd:z,isVisible:N,quickCommands:H})},z)}),M==="preview"&&t.jsx(Yv,{workspaceId:o,readOnly:n}),M==="review"&&t.jsx(Ov,{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}),M==="history"&&t.jsx($v,{workingDir:p})]})]});return j?t.jsxs("div",{className:ee("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(z=>t.jsx(e0,{active:R&&M===z.key,onClick:()=>D(z.key),icon:z.icon,label:w(z.label)},z.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:[U,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(cu,{size:15})})]}),X]})]}):t.jsxs("div",{className:ee("flex h-full w-full min-w-0 flex-col bg-white",s),children:[n&&U,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(z=>t.jsx(Jv,{active:M===z.key,onClick:()=>D(z.key),icon:z.icon,label:w(z.label)},z.key))}),X]})}),ta=1500,t0=3e3;function s0(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),t0)},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,x=ta-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),ta)):x>0?(p.current=c,v(),m.current=setTimeout(()=>n(c),x)):n(c)};return i.on(dt.WORKSPACE_SETUP_PROGRESS,l),()=>{i.off(dt.WORKSPACE_SETUP_PROGRESS,l),v(),o.current=0,p.current=null}},[e]),s}function zn(){const e=at();return St({mutationFn:s=>xe.post(`/sessions/${s}/start`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:oe.sessions.detail(r)}),e.invalidateQueries({queryKey:oe.tasks.all})}})}function nc(){const e=at();return St({mutationFn:s=>xe.post(`/sessions/${s}/stop`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:oe.sessions.detail(r)})}})}function Wn(){const e=at();return St({mutationFn:({id:s,message:r,providerId:o})=>xe.post(`/sessions/${s}/message`,{message:r,providerId:o}),onSuccess:()=>{e.invalidateQueries({queryKey:oe.workspaces.all}),e.invalidateQueries({queryKey:oe.tasks.all})}})}function oc({isOpen:e,onClose:s,onStarted:r,taskId:o,taskTitle:p,taskDescription:m,taskPrompt:v,projectIsGitRepo:i=!0}){const{t:n}=ue(),[l,u]=C.useState(""),[c,g]=C.useState(""),[x,y]=C.useState(Dt.WORKTREE),[_,a]=C.useState("idle"),[h,d]=C.useState(null),f=at(),b=dl(o),w=zn(),{data:k,isLoading:j}=Ds();C.useEffect(()=>{if(!e||!k)return;const F=k.find(H=>H.availability.type!=="NOT_FOUND");F&&u(F.provider.id)},[e,k]),C.useEffect(()=>{if(e){const F=[p];m&&F.push(m),g(v?.trim()||F.join(`
|
|
73
73
|
|
|
74
|
-
`)),y(i?Dt.WORKTREE:Dt.MAIN_DIRECTORY),a("idle"),d(null)}},[e,i,p,m,v]),C.useEffect(()=>{i||y(Dt.MAIN_DIRECTORY)},[i]);const S=_!=="idle",E=async()=>{if(!(!l||!c.trim())){d(null);try{a("creating-workspace");const F=await b.mutateAsync({workspaceKind:i?x:Dt.MAIN_DIRECTORY});a("creating-session");const
|
|
75
|
-
`):"- 未获取到冲突文件列表"}function
|
|
76
|
-
`):["## Merge 冲突解决","",`在将分支 \`${e}\` 合并到 \`${s}\` 时发生了冲突。`,...v.length>0?["","### 上下文",...v]:[],"","### 冲突文件",m,"","### 解决步骤",...
|
|
77
|
-
`)}function
|
|
78
|
-
`)}function d0(e){if(e.teamRunId)return{type:"team_room",message:c0(e)};const s=e.currentSessionId||e.selectedSessionId;return s?{type:"session",sessionId:s,message:l0(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:x,targetWorktreePath:y,sessions:_,currentSessionId:a,teamRunId:h}){const{t:d}=ue(),[f,b]=C.useState(""),w=zn(),k=rn(h??""),j=jn(),S=!!h,E=a||f,R=S?k.isPending:w.isPending,L=()=>{const F=d0({workspaceId:r,worktreePath:n,operation:i,mergeAborted:l,mergeStrategy:u,sourceWorkspaceId:c,targetWorkspaceId:g,sourceWorktreePath:x,targetWorktreePath:y,sourceBranch:m,targetBranch:v,conflictedFiles:p,conflictOp:o,teamRunId:h,currentSessionId:a,selectedSessionId:f});if(F.type==="team_room"){k.mutate({content:F.message,kind:"chat"},{onSuccess:()=>{ht.success(d("已发送到 Team Room")),s(!1)}});return}F.type==="session"&&w.mutate({id:F.sessionId,message:F.message},{onSuccess:()=>s(!1)})},T=()=>{j.mutate({workspaceId:r},{onSuccess:()=>s(!1)})},M=o==="REBASE"?"Rebase":"Merge",B=!S&&!a&&_.length>0,D=S||!!E;return t.jsx(hs,{isOpen:e,onClose:()=>s(!1),title:d("解决 {opLabel} 冲突",{opLabel:M}),action:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Me,{variant:"outline",onClick:T,children:d("在 IDE 中打开")}),t.jsx(Me,{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(F=>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:F},F))})]}),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:F=>b(F.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...")}),_.map(F=>t.jsxs("option",{value:F.id,children:[F.agentType," — ",F.status]},F.id))]})]}),!S&&!E&&_.length===0&&t.jsx("p",{className:"text-sm text-neutral-500",children:d("没有可用的 Session,请在 IDE 中手动解决冲突。")})]})})}function u0(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=Vl(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}=ue(),x=dl(),y=cl(),_=Rn(),[a,h]=C.useState(!1),[d,f]=C.useState(null),b=C.useMemo(()=>u0(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,M=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 F=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?"可合并":"已是最新"),W=g("{files} 个文件 · {lines} 行",{files:b.files,lines:w}),A=()=>{B&&(f(null),x.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("提交失败,请稍后重试"),U=>{h(!1),u(U)},f)}})},I=()=>{y.isPending||(h(!1),f(null))};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:ee("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:W}),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:F})]}),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:()=>_.mutate(e),disabled:_.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:_.isPending?g("正在撤销..."):g("撤销操作")}),t.jsxs("button",{type:"button",onClick:A,disabled:!B||x.isPending||M,className:"inline-flex h-7 items-center gap-1.5 rounded-md border border-border/70 bg-background px-2 text-xs font-medium text-foreground/80 transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-45",title:g(L?"同步更新":"已是最新"),children:[x.isPending?t.jsx(Ve,{size:12,className:"animate-spin"}):t.jsx(ir,{size:12}),t.jsx("span",{children:x.isPending?g("正在同步..."):g("更新")})]}),t.jsxs("button",{type:"button",onClick:O,disabled:!D||y.isPending||M,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(Ve,{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(Yl,{isOpen:a,onClose:I,branchName:s,targetBranch:r,commitMessage:o,isPending:y.isPending,error:d,onConfirm:P})]})}function h0({agentType:e,workingDir:s}){return Tt({queryKey:oe.system.slashCommandCatalog(e,s),queryFn:async()=>(await xe.get("/system/slash-command-catalog",{params:{agentType:String(e),...s?{workingDir:s}:{}}})).commands,enabled:!!e,staleTime:3e4})}function f0(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 m0(e){return oi(e.command)}function p0(e,s){if(!s)return 1e3;const r=m0(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:p0(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 g0=[{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"}],v0=[{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"}],x0=[{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"}],_0=[{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"}],b0={[Ft.CODEX]:g0,[Ft.CLAUDE_CODE]:v0,[Ft.GEMINI_CLI]:x0,[Ft.CURSOR_AGENT]:_0};function hc(e){return e.trim().toLowerCase().replace(/^\//,"")}function y0(e){return e?(b0[e]??[]).map(s=>({...s,kind:s.kind??"builtin"})):[]}function S0(e){const s=e.match(/^\s*\/([^\s]*)$/);return s?hc(s[1]):null}function w0(e,s){return uc(e,hc(s))}function C0(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=[]}=h0({agentType:e,workingDir:s}),u=C.useMemo(()=>f0(y0(e),l),[e,l]),c=C.useMemo(()=>S0(r),[r]),g=C.useMemo(()=>c===null?[]:w0(u,c),[u,c]),x=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&&(x(),f.focus(),f.setSelectionRange(d.length,d.length))})},[r,x,o,p]),_=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):C0(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:_}}function k0({agentType:e,workingDir:s}){return Tt({queryKey:oe.system.skillCatalog(e,s),queryFn:async()=>(await xe.get("/system/skill-catalog",{params:{agentType:String(e),...s?{workingDir:s}:{}}})).commands,enabled:e===Ft.CODEX,staleTime:3e4})}function E0(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=[]}=k0({agentType:e,workingDir:s}),c=C.useMemo(()=>e===Ft.CODEX?ta(r):null,[e,r])?.query??null,g=C.useMemo(()=>c===null?[]:uc(l,c),[c,l]),x=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&&(x(),f.focus(),f.setSelectionRange(d.length,d.length))})},[r,x,o,p]),_=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):E0(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:_}}const j0="/api",N0=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${j0}/attachments/by-path?path=${encodeURIComponent(e)}`:e,Cs=520,Li=48,R0=4,A0=420;function M0(){const{t:e}=ue();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:ve.Review,className:"bg-warning/10 text-warning",hoverClass:"hover:bg-warning/15",icon:t.jsx(ja,{className:"w-3 h-3"})},{status:ve.Running,className:"bg-info/10 text-info",hoverClass:"hover:bg-info/15",icon:t.jsx(Ea,{className:"w-3 h-3"})},{status:ve.Pending,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-muted",icon:t.jsx(ka,{className:"w-3 h-3"})},{status:ve.Done,className:"bg-success/10 text-success",hoverClass:"hover:bg-success/15",icon:t.jsx(Ca,{className:"w-3 h-3"})},{status:ve.Cancelled,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-border",icon:t.jsx(wa,{className:"w-3 h-3"})}];function T0({status:e,onChangeStatus:s}){const{t:r}=ue(),[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}=ue(),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(Me,{size:"sm",variant:"outline",className:"mt-3",onClick:s,children:[t.jsx(qt,{size:14,className:"mr-1.5"}),r("重试启动 Agent")]}):null]}):t.jsxs("div",{className:"mb-6 flex items-center gap-2 rounded-full border border-border bg-muted/30 px-3 py-1.5 text-sm text-muted-foreground",children:[t.jsxs("svg",{className:"h-3.5 w-3.5 animate-spin shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:o})]})}function D0({task:e,onDeleteTask:s,isDeleting:r,onTaskStatusChange:o,autoStartState:p,onAutoStartRecovered:m}){const{t:v}=ue(),[i,n]=C.useState(""),[l,u]=C.useState(!1),[c,g]=C.useState(!1),[x,y]=C.useState(!1),[_,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,M]=C.useState(void 0),[B,D]=C.useState(!1),F=C.useRef(null),W=C.useRef(null),A=C.useRef(null),O=C.useRef(null),{scrollRef:P,contentRef:I,isAtBottom:$,scrollToBottom:Y}=dn({resize:"smooth",initial:"instant"}),[U,X]=C.useState(!1),[z,N]=C.useState(Cs),[H,K]=C.useState(!1),q=C.useRef(0),ie=C.useRef(Cs),Q=C.useRef(null),{data:se,isLoading:pe}=En(e?.id??""),ge=t0(e?.id),{data:ze}=ba(e?.id??""),{data:de}=ya(ze?.id??""),Ge=rn(ze?.id??""),Ee=ze??null,Ke=!!Ee,He=e?.isGitRepo!==!1,De=ze===null&&He,We=!!(e?.id&&ze===null),{data:Te,isLoading:Xe}=Sa(e?.id??"",We);C.useEffect(()=>{D(!1),L(null),M(void 0)},[e?.id]);const Re=C.useMemo(()=>gl(se,Ee,T),[T,Ee,se]);C.useEffect(()=>{T&&!se?.some(Z=>Z.id===T)&&M(void 0)},[T,se]);const je=C.useMemo(()=>se?.find(Z=>Z.id===Re),[Re,se]),Ne=je?.status===Rt.ACTIVE?je.id:void 0,et=He&&vl(je,Ee);C.useEffect(()=>{if(!B||!se)return;se.some(le=>le.status==="ACTIVE"&&le.sessions&&le.sessions.length>0)&&D(!1)},[se,B]);const Ae=C.useMemo(()=>{if(B||!se)return null;const Z=mt=>{const gi=mt.createdAt,Hs=mt.endedAt??mt.startedAt??gi;if(!Hs)return 0;const ys=Date.parse(Hs);return Number.isNaN(ys)?0:ys},le=(mt,gi)=>{const Hs=mt.filter(ys=>gi.includes(ys.status));return Hs.length===0?null:Hs.sort((ys,Hc)=>Z(Hc)-Z(ys))[0]??null},Ye=se.filter(mt=>mt.status==="ACTIVE"&&Array.isArray(mt.sessions)).flatMap(mt=>mt.sessions??[]),Ct=le(Ye,[rt.RUNNING])??le(Ye,[rt.PENDING])??le(Ye,[rt.COMPLETED,rt.FAILED,rt.CANCELLED]);if(Ct)return Ct;const _t=se.filter(mt=>(mt.status==="MERGED"||mt.status==="ABANDONED"||mt.status==="HIBERNATED")&&Array.isArray(mt.sessions)).flatMap(mt=>mt.sessions??[]);return le(_t,[rt.COMPLETED,rt.FAILED,rt.CANCELLED])},[se,B]),$e=Ae?.id??"",he=Ke?R??"":$e,ft=C.useMemo(()=>{if(!R||!se)return null;for(const Z of se){const le=Z.sessions?.find(Ye=>Ye.id===R);if(le)return le}return null},[R,se]),wt=C.useMemo(()=>{if(!R||!Ee?.invocations)return null;const Z=Ee.invocations.filter(le=>le.sessionId===R);return Z.length===0?null:Z.sort((le,Ye)=>{const Ct=Date.parse(le.updatedAt??le.createdAt??""),_t=Date.parse(Ye.updatedAt??Ye.createdAt??"");return(Number.isNaN(_t)?0:_t)-(Number.isNaN(Ct)?0:Ct)})[0]??null},[R,Ee?.invocations]),G=C.useMemo(()=>!wt?.memberId||!Ee?.members?null:Ee.members.find(Z=>Z.id===wt.memberId)??null,[wt?.memberId,Ee?.members]),te=R?ft:Ae??null,fe=te?.status===rt.RUNNING||te?.status===rt.PENDING,_e=!!e?.projectArchivedAt,V=!!e?.projectRepoDeletedAt,re=v(V?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),{data:ne}=Ds(),[ae,me]=C.useState(null);C.useEffect(()=>{me(Ae?.providerId??null)},[Ae?.providerId]);const we=C.useMemo(()=>!Ae||!se?!1:!se.some(le=>le.status==="ACTIVE"&&le.sessions?.some(Ye=>Ye.id===Ae.id)),[Ae,se]),ye=C.useMemo(()=>{if(!(!se||B)){if(je)return rs(je);for(const Z of se)if(Z.status==="ACTIVE"&&rs(Z))return rs(Z);return rs(se[0])}},[B,je,se]),Ce=fc({agentType:Ae?.agentType,workingDir:ye,input:i,setInput:n,textareaRef:A,minHeight:60,maxHeight:300}),Le=mc({agentType:Ae?.agentType,workingDir:ye,input:i,setInput:n,textareaRef:A,minHeight:60,maxHeight:300}),it=sn(Z=>Z.setVisibleContext),tt=!!(et&&Ne&&ye&&!_e),{data:Se,isLoading:pt}=Nn(Ne??"",{enabled:tt}),{data:lt}=ni(ye,{enabled:tt});C.useEffect(()=>{if(!(U||!tt||!Ne||!ye))return it({workspaceId:Ne,workingDir:ye,tab:"changes"}),()=>{it(null)}},[U,Ne,it,tt,ye]);const ct=je?.sessions??[],vt=fs(je),nt=je?.commitMessage,Qe=C.useMemo(()=>xl(je,se,e?.mainBranch??""),[je,e?.mainBranch,se]),Ie=C.useMemo(()=>Se?.conflictOp&&Se.conflictedFiles.length>0?{conflictOp:Se.conflictOp,conflictedFiles:Se.conflictedFiles}:w,[Se?.conflictOp,Se?.conflictedFiles,w]),Et=Ie?.targetWorkspaceId??Ne,ps=Ie?.targetWorktreePath??je?.worktreePath,gs=Ie?.sourceBranch??vt,ai=Ie?.targetBranch??Qe,Je=at(),vs=C.useCallback(async()=>e?.id?Je.fetchQuery({queryKey:oe.tasks.body(e.id),queryFn:()=>xe.get(`/tasks/${e.id}/body`)}):null,[Je,e?.id]),Is=C.useCallback(()=>e?.id?Je.invalidateQueries({queryKey:oe.workspaces.list(e.id)}):Promise.resolve(),[e?.id,Je]);C.useEffect(()=>{if(!S)return;const Z=le=>{W.current&&!W.current.contains(le.target)&&E(!1)};return document.addEventListener("mousedown",Z),()=>document.removeEventListener("mousedown",Z)},[S]);const Bs=zn(),Yt=jn(),cs=dd(),hr=ll(e?.id??""),Fs=Fn(),xs=nf(),Ht=C.useMemo(()=>!se||se.some(le=>le.status==="ACTIVE")?null:se.find(le=>le.status==="HIBERNATED")??null,[se]),_s=C.useRef(null);C.useEffect(()=>{Ht&&_s.current!==Ht.id&&(xs.isPending||(_s.current=Ht.id,xs.mutate(Ht.id,{onSettled:()=>{_s.current=null}})))},[Ht,xs]);const li=C.useCallback(async()=>{if(!e?.id)return;const Z=Ae?.providerId??ne?.find(le=>le.availability.type!=="NOT_FOUND")?.provider.id;if(Z){a(!1),d(!0);try{const Ye=(await vs())?.prompt??e.title;await cs.mutateAsync(e.id),D(!0);const Ct=await hr.mutateAsync({workspaceKind:He?void 0:Dt.MAIN_DIRECTORY}),_t=await xe.post(`/workspaces/${Ct.id}/sessions`,{providerId:Z,prompt:Ye});await Fs.mutateAsync(_t.id),await Je.invalidateQueries({queryKey:oe.workspaces.list(e.id)})}catch(le){console.error("[retry] failed:",le),D(!1)}finally{d(!1)}}},[e?.id,e?.title,He,Ae?.providerId,ne,vs,cs,hr,Fs,Je]),zs=C.useCallback(async()=>{e?.id&&(await vs(),u(!0))},[vs,e?.id]),fr=C.useCallback(()=>{je?.id&&Yt.mutate({workspaceId:je.id})},[Yt,je?.id]),ci=C.useCallback(()=>{!e?.id||!s||(s(e.id),y(!1))},[e?.id,s]),mr=C.useCallback(Z=>{L(Z),requestAnimationFrame(()=>{Y()})},[Y]),pr=C.useCallback(()=>{L(null)},[]),bs=C.useCallback(Z=>{k(Z??null),b(!0)},[]),di=C.useCallback(Z=>Ge.mutateAsync(Z),[Ge]),Vt=C.useCallback(()=>{Je.invalidateQueries({queryKey:ud.all})},[Je]),{isConnected:gr,isLoadingSnapshot:Gt,logs:J,entries:be,attach:Be}=La({sessionId:he,sessionStatus:te?.status,onExit:C.useCallback(()=>{Je.invalidateQueries({queryKey:["workspaces"]})},[Je])});C.useEffect(()=>{if(!e?.id)return;const Z=Jt.connect();Z.emit(ks.SUBSCRIBE,{topic:"task",id:e.id});const le=_t=>{_t.taskId===e.id&&(Je.invalidateQueries({queryKey:["tasks"]}),Vt())},Ye=_t=>{_t.taskId===e.id&&(Je.invalidateQueries({queryKey:oe.workspaces.list(e.id)}),Vt())},Ct=_t=>{_t.taskId===e.id&&(Je.invalidateQueries({queryKey:oe.workspaces.list(e.id)}),Vt())};return Z.on(dt.TASK_UPDATED,le),Z.on(dt.WORKSPACE_COMMIT_MESSAGE_UPDATED,Ye),Z.on(dt.WORKSPACE_HIBERNATED,Ct),()=>{Z.off(dt.TASK_UPDATED,le),Z.off(dt.WORKSPACE_COMMIT_MESSAGE_UPDATED,Ye),Z.off(dt.WORKSPACE_HIBERNATED,Ct),Z.emit(ks.UNSUBSCRIBE,{topic:"task",id:e.id})}},[e?.id,Je,Vt]),C.useEffect(()=>{if(!he)return;const Z=Jt.connect(),le=Ye=>{Ye.sessionId===he&&(Je.invalidateQueries({queryKey:["workspaces"]}),Vt())};return Z.on(dt.SESSION_COMPLETED,le),()=>{Z.off(dt.SESSION_COMPLETED,le)}},[he,Je,Vt]);const{todos:Pe}=Pa(be),{files:jt,addFiles:xt,removeFile:Fe,clear:Wt,buildMarkdownLinks:$t,hasFiles:Ot,isUploading:vr}=cn(),Mc=C.useMemo(()=>nc(te),[te?.tokenUsage]),Wn=Ta(J,Mc);C.useEffect(()=>{he&&gr&&Be()},[he,gr,Be]);const $n=C.useRef(e?.id);C.useEffect(()=>{if($n.current!==e?.id&&P.current){const Z=P.current;requestAnimationFrame(()=>{Z.scrollTop=Z.scrollHeight})}$n.current=e?.id},[e?.id,P]);const ui=rc(),hi=C.useRef(!1),Un=C.useCallback(async()=>{if(!i.trim()&&!Ot||!he||hi.current||vr)return;hi.current=!0;const Z=$t(),le=[i.trim(),Z].filter(Boolean).join(`
|
|
74
|
+
`)),y(i?Dt.WORKTREE:Dt.MAIN_DIRECTORY),a("idle"),d(null)}},[e,i,p,m,v]),C.useEffect(()=>{i||y(Dt.MAIN_DIRECTORY)},[i]);const S=_!=="idle",E=async()=>{if(!(!l||!c.trim())){d(null);try{a("creating-workspace");const F=await b.mutateAsync({workspaceKind:i?x:Dt.MAIN_DIRECTORY});a("creating-session");const H=await xe.post(`/workspaces/${F.id}/sessions`,{providerId:l,prompt:c.trim()});a("starting-session"),await w.mutateAsync(H.id),await f.invalidateQueries({queryKey:oe.workspaces.list(o)}),a("idle"),r?.(),s()}catch(F){a("idle"),d(F instanceof Error?F.message:n("启动失败,请重试"))}}},R={idle:n("启动"),"creating-workspace":n("创建工作空间..."),"creating-session":n("创建会话..."),"starting-session":n("启动 Agent...")},L=(k??[]).map(({provider:F,availability:H})=>{const A=H.type!=="NOT_FOUND";return{value:F.id,label:A?F.name:`${F.name}${n(" (不可用)")}`,icon:t.jsx(Xr,{agentType:F.agentType,className:"size-4"}),disabled:!A}}),T=n("工作树隔离改动,支持 TeamRun、Merge、Rebase 和冲突解决。"),M=n("本地模式会直接修改项目主目录,不会自动提交,也不能使用 Merge、Rebase 或冲突解决。"),B=n("非 Git 项目只能使用本地模式。"),D=[{value:Dt.WORKTREE,label:n("工作树模式"),description:T,disabled:!i},{value:Dt.MAIN_DIRECTORY,label:n("本地模式"),description:M}];return t.jsx(hs,{isOpen:e,onClose:S?()=>{}:s,title:n("启动 Agent"),action:t.jsxs(t.Fragment,{children:[t.jsx(Me,{variant:"outline",onClick:s,disabled:S,children:n("取消")}),t.jsx(Me,{onClick:E,disabled:S||!l||!c.trim(),children:R[_]})]}),children:t.jsxs("div",{className:"space-y-5",children:[t.jsx("div",{children:t.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:n("Agent")}),t.jsx(es,{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("模式")}),i?t.jsx(es,{value:x,onChange:F=>y(F),options:D,disabled:S}):t.jsx(Cd,{side:"bottom",className:"w-full",content:B,children:t.jsx("div",{tabIndex:0,"aria-label":B,className:"rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:t.jsx(es,{value:x,onChange:F=>y(F),options:D,disabled:!0})})})]})]})}),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:F=>g(F.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 ac(e){const s=e?.tokenUsage;if(!(!s||typeof s.totalTokens!="number"))return s}function r0(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 lc({session:e,providers:s,usage:r,compact:o=!1,providerIdFallback:p,agentTypeFallback:m,tokenTooltipSide:v="top"}){const{t:i}=ue(),n=r0(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(Xr,{agentType:n.agentType,className:o?"size-3":"size-3.5"}),t.jsx("span",{className:"min-w-0 truncate",children:fd(n.label,o?12:18)})]}),t.jsx(pn,{usage:r,tooltipSide:v})]})}function i0({isOpen:e,onClose:s,taskId:r}){const{t:o}=ue(),[p,m]=C.useState("AUTO"),[v,i]=C.useState(null),[n,l]=C.useState([]),[u,c]=C.useState(null),g=ya();C.useEffect(()=>{e&&(m("AUTO"),i(null),l([]),c(null))},[e]);const x=g.isPending,y=!!v||n.length>0,_=async()=>{if(!x){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 ba&&h.status===409){c(o("该任务已经存在 TeamRun。请刷新后再试。"));return}c(h instanceof Error?h.message:o("创建 TeamRun 失败"))}}},a=x||!y;return t.jsxs(hs,{isOpen:e,onClose:x?()=>{}:s,title:o("创建 TeamRun"),className:"max-w-5xl",action:t.jsxs(t.Fragment,{children:[t.jsx(Me,{type:"button",variant:"outline",onClick:s,disabled:x,children:o("取消")}),t.jsx(Me,{type:"button",onClick:_,disabled:a,children:o(x?"处理中...":"创建 TeamRun")})]}),children:[t.jsx(kd,{mode:p,setMode:m,selectedTemplateId:v,setSelectedTemplateId:i,selectedMemberPresetIds:n,setSelectedMemberPresetIds:l,disabled:x}),u&&t.jsx("div",{role:"alert",className:"rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700",children:u})]})}function n0({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",x=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} ${x} overflow-y-auto`,children:e.map((y,_)=>t.jsxs("button",{type:"button",onMouseDown:a=>a.preventDefault(),onClick:()=>u(y),className:`w-full rounded-lg border text-left transition-colors ${_===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,kr=8;function $r({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 x=C.useRef(null),[y,_]=C.useState(null);return C.useLayoutEffect(()=>{if(!e){_(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)),M=S-k.bottom-kr-Qt,B=k.top-kr-Qt,D=x.current?.offsetHeight??(c?220:280),F=c?240:320,H=M<180&&B>M,O=Math.max(120,Math.min(F,H?B:M)),P=H?Math.max(Qt,k.top-kr-Math.min(D,O)):Math.min(S-Qt-Math.min(D,O),k.bottom+kr);_({top:P,left:T,width:L,maxHeight:O})},f=()=>{cancelAnimationFrame(h),h=requestAnimationFrame(d)};f();const b=new ResizeObserver(f);return b.observe(a),x.current&&b.observe(x.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:ts.createPortal(t.jsx("div",{className:"pointer-events-none fixed inset-0 z-[120]",children:t.jsx("div",{ref:x,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(n0,{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 o0({workspaceId:e,gitStatus:s,onResolve:r}){const{t:o}=ue(),p=An();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(ir,{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(Me,{variant:"ghost",size:"sm",onClick:()=>p.mutate(e),disabled:p.isPending,className:"text-muted-foreground hover:text-foreground",children:o("中止操作")}),t.jsx(Me,{size:"sm",onClick:r,children:o("解决冲突")})]})]})}function cc(e){return e.length>0?e.map(s=>`- ${s}`).join(`
|
|
75
|
+
`):"- 未获取到冲突文件列表"}function dc(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 a0(e,s){if(!s?.mergeAborted)return["1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git commit` 完成合并"];const r=s.mergeStrategy==="squash"?`git merge --squash --no-commit ${e}`:`git merge --no-ff ${e}`,o=s.mergeStrategy==="squash"?"`git commit`":"`git merge --continue` 或 `git commit`";return["1. 注意:Agent Tower 检测到 merge 冲突后已经执行 abort,当前不要假设存在冲突标记或 `MERGE_HEAD`","2. 切换到 Target worktree / Target branch 上下文,确认工作区干净",`3. 重新执行 \`${r}\` 复现冲突`,"4. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","5. 对每个已解决的文件执行 `git add <file>`",`6. 执行 ${o} 完成合并`]}function l0(e){if(!e.mergeAborted)return"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 merge 提交,然后说明处理结果。";const s=e.targetWorktreePath?`目标 worktree \`${e.targetWorktreePath}\``:`目标分支 \`${e.targetBranch}\``,r=e.mergeStrategy==="squash"?`git merge --squash --no-commit ${e.sourceBranch}`:`git merge --no-ff ${e.sourceBranch}`;return`Agent Tower 已在检测到冲突后 abort 了 merge;请在${s}中确认工作区干净,重新执行 \`${r}\` 复现冲突,解决后完成提交并汇报验证结果。`}function c0(e,s,r,o,p){const m=cc(r),v=dc(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,"","### 解决步骤",...a0(e,p)].join(`
|
|
77
|
+
`)}function d0(e){const s=e.conflictOp===Gs.REBASE?"Rebase":"Merge",r=cc(e.conflictedFiles),o=[...dc(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`,然后说明处理结果。":l0(e)].join(`
|
|
78
|
+
`)}function u0(e){if(e.teamRunId)return{type:"team_room",message:d0(e)};const s=e.currentSessionId||e.selectedSessionId;return s?{type:"session",sessionId:s,message:c0(e.sourceBranch,e.targetBranch,e.conflictedFiles,e.conflictOp,e)}:{type:"none"}}function uc({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:x,targetWorktreePath:y,sessions:_,currentSessionId:a,teamRunId:h}){const{t:d}=ue(),[f,b]=C.useState(""),w=Wn(),k=on(h??""),j=Nn(),S=!!h,E=a||f,R=S?k.isPending:w.isPending,L=()=>{const F=u0({workspaceId:r,worktreePath:n,operation:i,mergeAborted:l,mergeStrategy:u,sourceWorkspaceId:c,targetWorkspaceId:g,sourceWorktreePath:x,targetWorktreePath:y,sourceBranch:m,targetBranch:v,conflictedFiles:p,conflictOp:o,teamRunId:h,currentSessionId:a,selectedSessionId:f});if(F.type==="team_room"){k.mutate({content:F.message,kind:"chat"},{onSuccess:()=>{ht.success(d("已发送到 Team Room")),s(!1)}});return}F.type==="session"&&w.mutate({id:F.sessionId,message:F.message},{onSuccess:()=>s(!1)})},T=()=>{j.mutate({workspaceId:r},{onSuccess:()=>s(!1)})},M=o==="REBASE"?"Rebase":"Merge",B=!S&&!a&&_.length>0,D=S||!!E;return t.jsx(hs,{isOpen:e,onClose:()=>s(!1),title:d("解决 {opLabel} 冲突",{opLabel:M}),action:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Me,{variant:"outline",onClick:T,children:d("在 IDE 中打开")}),t.jsx(Me,{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(F=>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:F},F))})]}),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:F=>b(F.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...")}),_.map(F=>t.jsxs("option",{value:F.id,children:[F.agentType," — ",F.status]},F.id))]})]}),!S&&!E&&_.length===0&&t.jsx("p",{className:"text-sm text-neutral-500",children:d("没有可用的 Session,请在 IDE 中手动解决冲突。")})]})})}function h0(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 sa(e,s,r,o){const p=Ql(e);if(p){r(p);return}o(e instanceof Error?e.message:s)}function hc({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}=ue(),x=hl(),y=ul(),_=An(),[a,h]=C.useState(!1),[d,f]=C.useState(null),b=C.useMemo(()=>h0(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,M=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 F=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}),A=()=>{B&&(f(null),x.mutate(e,{onError:$=>{sa($,g("更新失败,请稍后重试"),Y=>u(Y),f)}}))},O=()=>{D&&(f(null),h(!0))},P=$=>{f(null),y.mutate({id:e,commitMessage:$},{onSuccess:()=>h(!1),onError:Y=>{sa(Y,g("提交失败,请稍后重试"),U=>{h(!1),u(U)},f)}})},I=()=>{y.isPending||(h(!1),f(null))};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:ee("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(ir,{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:F})]}),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:()=>_.mutate(e),disabled:_.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:_.isPending?g("正在撤销..."):g("撤销操作")}),t.jsxs("button",{type:"button",onClick:A,disabled:!B||x.isPending||M,className:"inline-flex h-7 items-center gap-1.5 rounded-md border border-border/70 bg-background px-2 text-xs font-medium text-foreground/80 transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-45",title:g(L?"同步更新":"已是最新"),children:[x.isPending?t.jsx(Ve,{size:12,className:"animate-spin"}):t.jsx(nr,{size:12}),t.jsx("span",{children:x.isPending?g("正在同步..."):g("更新")})]}),t.jsxs("button",{type:"button",onClick:O,disabled:!D||y.isPending||M,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(Ve,{size:12,className:"animate-spin"}):t.jsx(Tr,{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(Gl,{isOpen:a,onClose:I,branchName:s,targetBranch:r,commitMessage:o,isPending:y.isPending,error:d,onConfirm:P})]})}function f0({agentType:e,workingDir:s}){return Tt({queryKey:oe.system.slashCommandCatalog(e,s),queryFn:async()=>(await xe.get("/system/slash-command-catalog",{params:{agentType:String(e),...s?{workingDir:s}:{}}})).commands,enabled:!!e,staleTime:3e4})}function m0(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 ai(e){return e.trim().toLowerCase().replace(/^[/$]/,"")}function p0(e){return ai(e.command)}function g0(e,s){if(!s)return 1e3;const r=p0(e),o=e.aliases?.map(ai)??[],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 ra(e){const s=/(^|[\s])\$([^\s]*)$/.exec(e);if(!s||s.index===void 0)return null;const r=s.index+s[1].length;return{query:ai(s[2]),replaceStart:r}}function fc(e,s){const r=ai(s);return r?e.map((o,p)=>({command:o,index:p,score:g0(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 v0=[{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"}],x0=[{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"}],_0=[{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"}],b0=[{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"}],y0={[Ft.CODEX]:v0,[Ft.CLAUDE_CODE]:x0,[Ft.GEMINI_CLI]:_0,[Ft.CURSOR_AGENT]:b0};function mc(e){return e.trim().toLowerCase().replace(/^\//,"")}function S0(e){return e?(y0[e]??[]).map(s=>({...s,kind:s.kind??"builtin"})):[]}function w0(e){const s=e.match(/^\s*\/([^\s]*)$/);return s?mc(s[1]):null}function C0(e,s){return fc(e,mc(s))}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 pc({agentType:e,workingDir:s,input:r,setInput:o,textareaRef:p,minHeight:m,maxHeight:v}){const[i,n]=C.useState(0),{data:l=[]}=f0({agentType:e,workingDir:s}),u=C.useMemo(()=>m0(S0(e),l),[e,l]),c=C.useMemo(()=>w0(r),[r]),g=C.useMemo(()=>c===null?[]:C0(u,c),[u,c]),x=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&&(x(),f.focus(),f.setSelectionRange(d.length,d.length))})},[r,x,o,p]),_=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{allCommands:u,query:c,filteredCommands:g,selectedIndex:i,setSelectedIndex:n,applyCommand:y,handleKeyDown:_}}function E0({agentType:e,workingDir:s}){return Tt({queryKey:oe.system.skillCatalog(e,s),queryFn:async()=>(await xe.get("/system/skill-catalog",{params:{agentType:String(e),...s?{workingDir:s}:{}}})).commands,enabled:e===Ft.CODEX,staleTime:3e4})}function j0(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 gc({agentType:e,workingDir:s,input:r,setInput:o,textareaRef:p,minHeight:m,maxHeight:v}){const[i,n]=C.useState(0),{data:l=[]}=E0({agentType:e,workingDir:s}),c=C.useMemo(()=>e===Ft.CODEX?ra(r):null,[e,r])?.query??null,g=C.useMemo(()=>c===null?[]:fc(l,c),[c,l]),x=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=ra(r);if(!h)return;const d=`${r.slice(0,h.replaceStart)}${a.command} `;o(d),requestAnimationFrame(()=>{const f=p.current;f&&(x(),f.focus(),f.setSelectionRange(d.length,d.length))})},[r,x,o,p]),_=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):j0(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:_}}const N0=rr(),R0=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${N0}/attachments/by-path?path=${encodeURIComponent(e)}`:e,Cs=520,Pi=48,A0=4,M0=420;function T0(){const{t:e}=ue();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 ia=[{status:ve.Review,className:"bg-warning/10 text-warning",hoverClass:"hover:bg-warning/15",icon:t.jsx(Ma,{className:"w-3 h-3"})},{status:ve.Running,className:"bg-info/10 text-info",hoverClass:"hover:bg-info/15",icon:t.jsx(Aa,{className:"w-3 h-3"})},{status:ve.Pending,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-muted",icon:t.jsx(Ra,{className:"w-3 h-3"})},{status:ve.Done,className:"bg-success/10 text-success",hoverClass:"hover:bg-success/15",icon:t.jsx(Na,{className:"w-3 h-3"})},{status:ve.Cancelled,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-border",icon:t.jsx(ja,{className:"w-3 h-3"})}];function D0({status:e,onChangeStatus:s}){const{t:r}=ue(),[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=ia.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:ia.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 na({state:e,onRetry:s}){const{t:r}=ue(),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(Me,{size:"sm",variant:"outline",className:"mt-3",onClick:s,children:[t.jsx(qt,{size:14,className:"mr-1.5"}),r("重试启动 Agent")]}):null]}):t.jsxs("div",{className:"mb-6 flex items-center gap-2 rounded-full border border-border bg-muted/30 px-3 py-1.5 text-sm text-muted-foreground",children:[t.jsxs("svg",{className:"h-3.5 w-3.5 animate-spin shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:o})]})}function L0({task:e,onDeleteTask:s,isDeleting:r,onTaskStatusChange:o,autoStartState:p,onAutoStartRecovered:m}){const{t:v}=ue(),[i,n]=C.useState(""),[l,u]=C.useState(!1),[c,g]=C.useState(!1),[x,y]=C.useState(!1),[_,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,M]=C.useState(void 0),[B,D]=C.useState(!1),F=C.useRef(null),H=C.useRef(null),A=C.useRef(null),O=C.useRef(null),{scrollRef:P,contentRef:I,isAtBottom:$,scrollToBottom:Y}=fn({resize:"smooth",initial:"instant"}),[U,X]=C.useState(!1),[z,N]=C.useState(Cs),[W,K]=C.useState(!1),q=C.useRef(0),ie=C.useRef(Cs),Q=C.useRef(null),{data:se,isLoading:pe}=jn(e?.id??""),ge=s0(e?.id),{data:Fe}=Sa(e?.id??""),{data:de}=wa(Fe?.id??""),Ge=on(Fe?.id??""),Ee=Fe??null,Ke=!!Ee,ze=e?.isGitRepo!==!1,De=Fe===null&&ze,We=!!(e?.id&&Fe===null),{data:Te,isLoading:Xe}=Ca(e?.id??"",We);C.useEffect(()=>{D(!1),L(null),M(void 0)},[e?.id]);const Re=C.useMemo(()=>xl(se,Ee,T),[T,Ee,se]);C.useEffect(()=>{T&&!se?.some(Z=>Z.id===T)&&M(void 0)},[T,se]);const je=C.useMemo(()=>se?.find(Z=>Z.id===Re),[Re,se]),Ne=je?.status===Rt.ACTIVE?je.id:void 0,et=ze&&_l(je,Ee);C.useEffect(()=>{if(!B||!se)return;se.some(le=>le.status==="ACTIVE"&&le.sessions&&le.sessions.length>0)&&D(!1)},[se,B]);const Ae=C.useMemo(()=>{if(B||!se)return null;const Z=mt=>{const vi=mt.createdAt,Ws=mt.endedAt??mt.startedAt??vi;if(!Ws)return 0;const ys=Date.parse(Ws);return Number.isNaN(ys)?0:ys},le=(mt,vi)=>{const Ws=mt.filter(ys=>vi.includes(ys.status));return Ws.length===0?null:Ws.sort((ys,$c)=>Z($c)-Z(ys))[0]??null},Ye=se.filter(mt=>mt.status==="ACTIVE"&&Array.isArray(mt.sessions)).flatMap(mt=>mt.sessions??[]),Ct=le(Ye,[rt.RUNNING])??le(Ye,[rt.PENDING])??le(Ye,[rt.COMPLETED,rt.FAILED,rt.CANCELLED]);if(Ct)return Ct;const _t=se.filter(mt=>(mt.status==="MERGED"||mt.status==="ABANDONED"||mt.status==="HIBERNATED")&&Array.isArray(mt.sessions)).flatMap(mt=>mt.sessions??[]);return le(_t,[rt.COMPLETED,rt.FAILED,rt.CANCELLED])},[se,B]),He=Ae?.id??"",he=Ke?R??"":He,ft=C.useMemo(()=>{if(!R||!se)return null;for(const Z of se){const le=Z.sessions?.find(Ye=>Ye.id===R);if(le)return le}return null},[R,se]),wt=C.useMemo(()=>{if(!R||!Ee?.invocations)return null;const Z=Ee.invocations.filter(le=>le.sessionId===R);return Z.length===0?null:Z.sort((le,Ye)=>{const Ct=Date.parse(le.updatedAt??le.createdAt??""),_t=Date.parse(Ye.updatedAt??Ye.createdAt??"");return(Number.isNaN(_t)?0:_t)-(Number.isNaN(Ct)?0:Ct)})[0]??null},[R,Ee?.invocations]),G=C.useMemo(()=>!wt?.memberId||!Ee?.members?null:Ee.members.find(Z=>Z.id===wt.memberId)??null,[wt?.memberId,Ee?.members]),te=R?ft:Ae??null,fe=te?.status===rt.RUNNING||te?.status===rt.PENDING,_e=!!e?.projectArchivedAt,V=!!e?.projectRepoDeletedAt,re=v(V?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),{data:ne}=Ds(),[ae,me]=C.useState(null);C.useEffect(()=>{me(Ae?.providerId??null)},[Ae?.providerId]);const we=C.useMemo(()=>!Ae||!se?!1:!se.some(le=>le.status==="ACTIVE"&&le.sessions?.some(Ye=>Ye.id===Ae.id)),[Ae,se]),ye=C.useMemo(()=>{if(!(!se||B)){if(je)return rs(je);for(const Z of se)if(Z.status==="ACTIVE"&&rs(Z))return rs(Z);return rs(se[0])}},[B,je,se]),Ce=pc({agentType:Ae?.agentType,workingDir:ye,input:i,setInput:n,textareaRef:A,minHeight:60,maxHeight:300}),Le=gc({agentType:Ae?.agentType,workingDir:ye,input:i,setInput:n,textareaRef:A,minHeight:60,maxHeight:300}),it=nn(Z=>Z.setVisibleContext),tt=!!(et&&Ne&&ye&&!_e),{data:Se,isLoading:pt}=Rn(Ne??"",{enabled:tt}),{data:lt}=oi(ye,{enabled:tt});C.useEffect(()=>{if(!(U||!tt||!Ne||!ye))return it({workspaceId:Ne,workingDir:ye,tab:"changes"}),()=>{it(null)}},[U,Ne,it,tt,ye]);const ct=je?.sessions??[],vt=fs(je),nt=je?.commitMessage,Qe=C.useMemo(()=>bl(je,se,e?.mainBranch??""),[je,e?.mainBranch,se]),Oe=C.useMemo(()=>Se?.conflictOp&&Se.conflictedFiles.length>0?{conflictOp:Se.conflictOp,conflictedFiles:Se.conflictedFiles}:w,[Se?.conflictOp,Se?.conflictedFiles,w]),Et=Oe?.targetWorkspaceId??Ne,ps=Oe?.targetWorktreePath??je?.worktreePath,gs=Oe?.sourceBranch??vt,li=Oe?.targetBranch??Qe,Je=at(),vs=C.useCallback(async()=>e?.id?Je.fetchQuery({queryKey:oe.tasks.body(e.id),queryFn:()=>xe.get(`/tasks/${e.id}/body`)}):null,[Je,e?.id]),Is=C.useCallback(()=>e?.id?Je.invalidateQueries({queryKey:oe.workspaces.list(e.id)}):Promise.resolve(),[e?.id,Je]);C.useEffect(()=>{if(!S)return;const Z=le=>{H.current&&!H.current.contains(le.target)&&E(!1)};return document.addEventListener("mousedown",Z),()=>document.removeEventListener("mousedown",Z)},[S]);const Bs=Wn(),Yt=Nn(),cs=md(),fr=dl(e?.id??""),Fs=zn(),xs=nf(),Wt=C.useMemo(()=>!se||se.some(le=>le.status==="ACTIVE")?null:se.find(le=>le.status==="HIBERNATED")??null,[se]),_s=C.useRef(null);C.useEffect(()=>{Wt&&_s.current!==Wt.id&&(xs.isPending||(_s.current=Wt.id,xs.mutate(Wt.id,{onSettled:()=>{_s.current=null}})))},[Wt,xs]);const ci=C.useCallback(async()=>{if(!e?.id)return;const Z=Ae?.providerId??ne?.find(le=>le.availability.type!=="NOT_FOUND")?.provider.id;if(Z){a(!1),d(!0);try{const Ye=(await vs())?.prompt??e.title;await cs.mutateAsync(e.id),D(!0);const Ct=await fr.mutateAsync({workspaceKind:ze?void 0:Dt.MAIN_DIRECTORY}),_t=await xe.post(`/workspaces/${Ct.id}/sessions`,{providerId:Z,prompt:Ye});await Fs.mutateAsync(_t.id),await Je.invalidateQueries({queryKey:oe.workspaces.list(e.id)})}catch(le){console.error("[retry] failed:",le),D(!1)}finally{d(!1)}}},[e?.id,e?.title,ze,Ae?.providerId,ne,vs,cs,fr,Fs,Je]),zs=C.useCallback(async()=>{e?.id&&(await vs(),u(!0))},[vs,e?.id]),mr=C.useCallback(()=>{je?.id&&Yt.mutate({workspaceId:je.id})},[Yt,je?.id]),di=C.useCallback(()=>{!e?.id||!s||(s(e.id),y(!1))},[e?.id,s]),pr=C.useCallback(Z=>{L(Z),requestAnimationFrame(()=>{Y()})},[Y]),gr=C.useCallback(()=>{L(null)},[]),bs=C.useCallback(Z=>{k(Z??null),b(!0)},[]),ui=C.useCallback(Z=>Ge.mutateAsync(Z),[Ge]),Vt=C.useCallback(()=>{Je.invalidateQueries({queryKey:pd.all})},[Je]),{isConnected:vr,isLoadingSnapshot:Gt,logs:J,entries:be,attach:Ie}=Oa({sessionId:he,sessionStatus:te?.status,onExit:C.useCallback(()=>{Je.invalidateQueries({queryKey:["workspaces"]})},[Je])});C.useEffect(()=>{if(!e?.id)return;const Z=Jt.connect();Z.emit(ks.SUBSCRIBE,{topic:"task",id:e.id});const le=_t=>{_t.taskId===e.id&&(Je.invalidateQueries({queryKey:["tasks"]}),Vt())},Ye=_t=>{_t.taskId===e.id&&(Je.invalidateQueries({queryKey:oe.workspaces.list(e.id)}),Vt())},Ct=_t=>{_t.taskId===e.id&&(Je.invalidateQueries({queryKey:oe.workspaces.list(e.id)}),Vt())};return Z.on(dt.TASK_UPDATED,le),Z.on(dt.WORKSPACE_COMMIT_MESSAGE_UPDATED,Ye),Z.on(dt.WORKSPACE_HIBERNATED,Ct),()=>{Z.off(dt.TASK_UPDATED,le),Z.off(dt.WORKSPACE_COMMIT_MESSAGE_UPDATED,Ye),Z.off(dt.WORKSPACE_HIBERNATED,Ct),Z.emit(ks.UNSUBSCRIBE,{topic:"task",id:e.id})}},[e?.id,Je,Vt]),C.useEffect(()=>{if(!he)return;const Z=Jt.connect(),le=Ye=>{Ye.sessionId===he&&(Je.invalidateQueries({queryKey:["workspaces"]}),Vt())};return Z.on(dt.SESSION_COMPLETED,le),()=>{Z.off(dt.SESSION_COMPLETED,le)}},[he,Je,Vt]);const{todos:Pe}=Ia(be),{files:jt,addFiles:xt,removeFile:Be,clear:Ht,buildMarkdownLinks:$t,hasFiles:Ot,isUploading:xr}=an(),Dc=C.useMemo(()=>ac(te),[te?.tokenUsage]),$n=La(J,Dc);C.useEffect(()=>{he&&vr&&Ie()},[he,vr,Ie]);const Un=C.useRef(e?.id);C.useEffect(()=>{if(Un.current!==e?.id&&P.current){const Z=P.current;requestAnimationFrame(()=>{Z.scrollTop=Z.scrollHeight})}Un.current=e?.id},[e?.id,P]);const hi=nc(),fi=C.useRef(!1),qn=C.useCallback(async()=>{if(!i.trim()&&!Ot||!he||fi.current||xr)return;fi.current=!0;const Z=$t(),le=[i.trim(),Z].filter(Boolean).join(`
|
|
79
79
|
|
|
80
|
-
`);n(""),Wt(),A.current&&(A.current.style.height="60px"),Bs.mutate({id:he,message:le,providerId:ae??void 0},{onSuccess:()=>{Be()},onSettled:()=>{hi.current=!1}})},[i,he,Bs,Be,Ot,vr,$t,Wt,ae]),Tc=C.useCallback(async()=>{he&&(await ui.mutateAsync(he),Je.invalidateQueries({queryKey:["workspaces"]}))},[he,ui,Je]),Dc=C.useCallback(Z=>{const le=Z.target.files;le&&le.length>0&&xt(Array.from(le)),Z.target.value=""},[xt]),Lc=C.useCallback(Z=>{const le=Z.clipboardData.items,Ye=[];for(const Ct of le)if(Ct.kind==="file"){const _t=Ct.getAsFile();_t&&Ye.push(_t)}Ye.length>0&&(Z.preventDefault(),xt(Ye))},[xt]),[qn,fi]=C.useState(!1),Pc=C.useCallback(Z=>{Z.preventDefault(),fi(!0)},[]),Oc=C.useCallback(Z=>{Z.preventDefault(),fi(!1)},[]),Ic=C.useCallback(Z=>{Z.preventDefault(),fi(!1);const le=Z.dataTransfer.files;le.length>0&&xt(Array.from(le))},[xt]),Ut=C.useCallback(Z=>{const le=Q.current?.getBoundingClientRect().width??(typeof window<"u"?window.innerWidth:void 0),Ye=le?Math.max(Cs,le-Li-R0-A0):Cs;return Math.max(Cs,Math.min(Math.round(Z),Ye))},[]),mi=C.useCallback(Z=>{const le=Z.clientX-q.current;N(Ut(ie.current-le))},[Ut]),pi=C.useCallback(()=>{K(!1),document.body.style.cursor="",document.body.style.userSelect=""},[]);C.useEffect(()=>{if(H)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,H]);const Bc=C.useCallback(Z=>{Z.preventDefault(),q.current=Z.clientX,ie.current=z,K(!0)},[z]);C.useEffect(()=>{!U||H||N(Z=>Ut(Z))},[Ut,U,H]),C.useEffect(()=>{if(!U)return;const Z=()=>{N(le=>Ut(le))};return window.addEventListener("resize",Z),()=>window.removeEventListener("resize",Z)},[Ut,U]);const Fc=C.useCallback(()=>{N(Z=>Ut(Z)),X(!0),requestAnimationFrame(()=>{j.current?.setTab("review")})},[Ut]),zc=C.useCallback(Z=>{n(Z.target.value);const le=Z.target;le.style.height="auto";const Ye=le.scrollHeight;le.style.height=`${Math.max(60,Math.min(Ye,300))}px`},[]),Kn=tt&&Ne?t.jsx(dc,{workspaceId:Ne,branchName:vt,targetBranch:Qe,commitMessage:nt,changes:lt,gitStatus:Se,isGitStatusLoading:pt,canRunGitOperations:et,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(T0,{status:e.status,onChangeStatus:!_e&&o?Z=>o(e.id,Z):void 0}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:fr,disabled:!ye||_e,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)&&!_e&&t.jsxs("div",{className:"relative",ref:W,children:[t.jsx("button",{onClick:()=>E(Z=>!Z),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(ss,{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(Ad,{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("删除任务")})]})]})]})]})]})]})]}),et&&Ne&&Se&&t.jsx(n0,{workspaceId:Ne,gitStatus:Se,onResolve:()=>bs()}),t.jsxs("div",{ref:Q,className:"flex-1 flex overflow-hidden",children:[t.jsx("div",{className:"flex min-w-0 flex-1 flex-col bg-background relative",children:Ke&&Ee?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:te,providers:ne,usage:Wn,providerIdFallback:G?.providerId,agentTypeFallback:te?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Me,{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...")})]}):J.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:v(fe?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(Nr,{logs:J})})}),!$&&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("回到底部")})]})]}),Pe.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:Pe})})})]}):t.jsx(pl,{teamRun:Ee,messages:de??Ee.messages??[],readOnly:_e,readOnlyMessage:re,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:[(Xe||Te?.body)&&t.jsx("div",{className:"mb-4 pb-4 border-b border-border/60 min-w-0",children:Xe?t.jsx("p",{className:"text-sm text-muted-foreground/70 italic",children:v("Loading...")}):Te?.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:N0,components:on,children:Te.body})}):null}),ge&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-muted-foreground/70 text-sm",children:[ge.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:ge.currentIndex,total:ge.totalCommands,command:ge.currentCommand})})]}),ge.status==="completed"&&t.jsx("span",{className:"text-success",children:v("Setup 完成")}),ge.status==="failed"&&t.jsx("span",{className:"text-destructive/80",children:v("Setup 失败: {error}",{error:ge.error})})]}),!_e&&p&&(pe||$e)?t.jsx("div",{className:"flex justify-center py-3",children:t.jsx(ra,{state:p,onRetry:p.status==="failed"?zs:void 0})}):null,pe?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...")})]}):$e?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...")})]}):J.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:v(fe?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(Nr,{logs:J}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[t.jsx("div",{className:"w-14 h-14 bg-muted/50 rounded-2xl border border-border/60 flex items-center justify-center mb-5",children:t.jsx(qt,{size:24,className:"text-muted-foreground/70 ml-0.5"})}),t.jsx("h3",{className:"text-base font-medium text-foreground mb-1.5",children:v(_e?"项目为只读历史":"尚未启动 Agent")}),t.jsx("p",{className:"text-sm text-muted-foreground mb-6 max-w-xs",children:_e?re:v("选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。")}),!_e&&p?t.jsx(ra,{state:p}):null,!_e&&t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[t.jsxs(Me,{onClick:zs,disabled:!!(p&&p.status!=="failed"),children:[t.jsx(qt,{size:16,className:"mr-1.5"}),p?.status==="failed"?v("重试启动 Agent"):v("启动 Agent")]}),De&&t.jsxs(Me,{variant:"outline",onClick:()=>g(!0),children:[t.jsx(ss,{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("回到底部")})]})]}),Pe.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:Pe})})}),_e?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:re})})}):we?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(Me,{size:"sm",onClick:zs,children:[t.jsx(qt,{size:14,className:"mr-1.5"}),v("启动新 Agent")]})]})})}):t.jsxs("div",{className:"p-6 pt-2 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-transparent",onDragOver:Pc,onDragLeave:Oc,onDrop:Ic,children:[t.jsxs("div",{className:"max-w-4xl mx-auto",children:[Kn,t.jsxs("div",{ref:F,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:jt,onRemove:Fe}),t.jsx("textarea",{ref:A,value:i,onChange:zc,onPaste:Lc,onKeyDown:Z=>{Le.handleKeyDown(Z)||Ce.handleKeyDown(Z)||Z.key==="Enter"&&!Z.shiftKey&&!Z.repeat&&!Z.nativeEvent.isComposing&&Z.nativeEvent.keyCode!==229&&(Z.preventDefault(),Un())},rows:1,placeholder:v(qn?"Drop files here...":$e&&!fe?"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:[Ae&&ne&&t.jsx(Da,{providers:ne,currentProviderId:ae,agentType:Ae.agentType,onSelect:me}),t.jsx(fn,{usage:Wn}),fe&&!i.trim()&&!Ot?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()&&!Ot||vr,className:`p-2 rounded-lg transition-all duration-200 ${(i.trim()||Ot)&&!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(Wr,{open:Ce.query!==null,anchorRef:F,commands:Ce.filteredCommands,selectedIndex:Ce.selectedIndex,query:Ce.query??"",hasCatalog:Ce.allCommands.length>0,onSelect:Ce.applyCommand}),t.jsx(Wr,{open:Le.query!==null,anchorRef:F,commands:Le.filteredSkills,selectedIndex:Le.selectedIndex,query:Le.query??"",hasCatalog:Le.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",onSelect:Le.applySkill})]})]})}),U&&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:U?Li+z:Li},children:t.jsx(sc,{sessionId:$e||void 0,workspaceId:Re,workingDir:ye,projectId:e.projectId,readOnly:_e,repoDeleted:V,teamRun:Ee,teamStatus:Ee?t.jsx(yl,{teamRun:Ee,workspaces:se,selectedWorkspaceId:Re,onSelectWorkspace:M,onViewInvocationSession:mr}):void 0,workspaces:se,selectedWorkspaceId:Re,onSelectWorkspace:M,variant:"rail",expanded:U,onExpandedChange:Z=>{Z&&N(le=>Ut(le)),X(Z)},minContentWidth:Cs,tabRef:j,gitAvailable:He,gitProps:et&&Ne?{branchName:vt,targetBranch:Qe,commitMessage:nt,canRunGitOperations:!0,onRefreshCommitMessage:Is,onConflict:bs,onResolveConflicts:()=>bs()}:void 0})})]}),!_e&&t.jsx(ic,{isOpen:l,onClose:()=>u(!1),taskId:e.id,taskTitle:Te?.title??e.title,taskDescription:Te?.body??"",taskPrompt:Te?.prompt,projectIsGitRepo:He,onStarted:()=>m?.(e.id)}),De&&!_e&&t.jsx(r0,{isOpen:c,onClose:()=>g(!1),taskId:e.id}),et&&Et&&Ie&&t.jsx(cc,{open:f,onOpenChange:Z=>{b(Z),Z||k(null)},workspaceId:Et,conflictOp:Ie.conflictOp,conflictedFiles:Ie.conflictedFiles,sourceBranch:gs,targetBranch:ai,operation:Se?.operation,worktreePath:ps,mergeAborted:Ie.mergeAborted,mergeStrategy:Ie.mergeStrategy,sourceWorkspaceId:Ie.sourceWorkspaceId,targetWorkspaceId:Ie.targetWorkspaceId,sourceWorktreePath:Ie.sourceWorktreePath,targetWorktreePath:Ie.targetWorktreePath,sessions:ct,currentSessionId:Ke?void 0:$e,teamRunId:Ee?.id}),t.jsx(an,{isOpen:_,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:x,onClose:()=>y(!1),onConfirm:ci,taskId:e.id,taskTitle:e.title,workspaces:se,isLoading:r})]}):t.jsx(M0,{})}function Hn(e){switch(e){case Bt.TODO:return ve.Pending;case Bt.IN_PROGRESS:return ve.Running;case Bt.IN_REVIEW:return ve.Review;case Bt.DONE:return ve.Done;case Bt.CANCELLED:return ve.Cancelled}}function L0(e){switch(e){case ve.Pending:return Bt.TODO;case ve.Running:return Bt.IN_PROGRESS;case ve.Review:return Bt.IN_REVIEW;case ve.Done:return Bt.DONE;case ve.Cancelled:return Bt.CANCELLED}}function P0(e){switch(e){case Ft.CLAUDE_CODE:return"Claude Code";case Ft.GEMINI_CLI:return"Gemini CLI";case Ft.CURSOR_AGENT:return"Cursor Agent";case Ft.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===Dt.MAIN_DIRECTORY?"Project directory":e.branchName:"—"}function O0(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 I0(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:P0(p.agentType),branch:r}}return{agent:"—",branch:r}}function B0(e){const{agent:s,branch:r}=I0(e.workspaces),o=e.project;return{id:e.id,projectId:e.projectId,title:e.titlePreview??e.title,status:Hn(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 F0(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:Hn(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 z0(e){const s=e.split("/");return s[s.length-1]||e}function H0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function W0({workingDir:e,filePath:s,type:r}){const{t:o}=ue(),{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(Ve,{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:ee("px-3 whitespace-pre",c,g),children:l},u)})})}function
|
|
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:ee("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=X0(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(i=>!i),className:ee("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:ee("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:K0(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(Y0,{workingDir:s,hash:r,filePath:e.path})]})}function G0({commit:e,workingDir:s}){const{t:r}=ue(),[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:ee("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:ee("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:q0(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(Ve,{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 Q0({workingDir:e}){const{t:s}=ue(),{data:r,isLoading:o,isError:p,fetchNextPage:m,hasNextPage:v,isFetchingNextPage:i}=gn({queryKey:oe.git.log(e||""),queryFn:({pageParam:l=0})=>xe.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(Ve,{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(G0,{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(Ve,{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 Z0="/api",J0=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${Z0}/attachments/by-path?path=${encodeURIComponent(e)}`:e;function ex({status:e}){const s={[ve.Running]:"bg-blue-500",[ve.Review]:"bg-amber-500",[ve.Pending]:"bg-neutral-400",[ve.Done]:"bg-emerald-500",[ve.Cancelled]:"bg-neutral-400"};return t.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${s[e]}`})}const tx=[{key:"chat",label:"Chat",icon:qr},{key:"changes",label:"Changes",icon:Ls},{key:"history",label:"History",icon:Ts},{key:"workspace",label:"Workspace",icon:Yr}],sx=[{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:Yr}];function aa({state:e,onRetry:s}){const{t:r}=ue(),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(Me,{size:"sm",variant:"outline",className:"mt-3",onClick:s,children:[t.jsx(qt,{size:14,className:"mr-1.5"}),r("重试启动 Agent")]}):null]}):t.jsxs("div",{className:"mb-5 flex items-center gap-2 rounded-full border border-neutral-200 bg-neutral-50 px-3 py-1.5 text-xs text-neutral-500",children:[t.jsxs("svg",{className:"h-3.5 w-3.5 animate-spin shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:o})]})}function rx({task:e,onBack:s,onDeleteTask:r,isDeleting:o,autoStartState:p,onAutoStartRecovered:m}){const{t:v}=ue(),i=sn(J=>J.setVisibleContext),[n,l]=C.useState("chat"),[u,c]=C.useState(""),[g,x]=C.useState(!1),[y,_]=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:M}=dn({resize:"smooth",initial:"instant"}),B=at();C.useEffect(()=>{if(!a)return;const J=be=>{j.current&&!j.current.contains(be.target)&&h(!1)};return document.addEventListener("mousedown",J),()=>document.removeEventListener("mousedown",J)},[a]);const{data:D,isLoading:F}=En(e.id),{data:W}=ba(e.id),{data:A}=ya(W?.id??""),O=rn(W?.id??""),P=W??null,I=e.isGitRepo!==!1,$=C.useMemo(()=>(P?sx:tx).filter(J=>I||J.key!=="changes"&&J.key!=="history"),[I,P]),Y=W===null,{data:U,isLoading:X}=Sa(e.id,Y),z=!!e.projectArchivedAt,N=!!e.projectRepoDeletedAt,H=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(J=>J.key===n)||l("chat")},[n,$,P]);const K=C.useMemo(()=>gl(D,P,b),[b,P,D]);C.useEffect(()=>{b&&!D?.some(J=>J.id===b)&&w(void 0)},[b,D]);const q=C.useMemo(()=>D?.find(J=>J.id===K),[K,D]),ie=C.useMemo(()=>{if(D){if(q)return rs(q);for(const J of D)if(J.status==="ACTIVE"&&rs(J))return rs(J);return rs(D[0])}},[q,D]),Q=q?.status===Rt.ACTIVE?q.id:void 0,se=I&&vl(q,P),pe=q?.branchName??"",ge=q?.commitMessage,ze=C.useMemo(()=>xl(q,D,e?.mainBranch??""),[q,e?.mainBranch,D]),de=!!(se&&Q&&ie&&!z),{data:Ge,isLoading:Ee}=Nn(Q??"",{enabled:de}),{data:Ke}=ni(ie,{enabled:de}),He=Ke?.committed?.length,[De,We]=C.useState(!1),[Te,Xe]=C.useState(null);C.useEffect(()=>{const J=I&&(n==="changes"||n==="chat"&&de)?"changes":I&&n==="history"?"history":null;if(!Q||!ie||!J){i(null);return}return i({workspaceId:Q,workingDir:ie,tab:J}),()=>{i(null)}},[n,I,Q,i,de,ie]);const Re=C.useMemo(()=>Ge?.conflictOp&&Ge.conflictedFiles.length>0?{conflictOp:Ge.conflictOp,conflictedFiles:Ge.conflictedFiles}:Te,[Ge?.conflictOp,Ge?.conflictedFiles,Te]),je=Re?.targetWorkspaceId??Q,Ne=Re?.targetWorktreePath??q?.worktreePath,et=Re?.sourceBranch??pe,Ae=Re?.targetBranch??ze,$e=q?.sessions??[],he=C.useCallback(J=>{Xe(J??null),We(!0)},[]),ft=C.useCallback(()=>e?.id?B.invalidateQueries({queryKey:oe.workspaces.list(e.id)}):Promise.resolve(),[e?.id,B]),wt=C.useCallback(async()=>B.fetchQuery({queryKey:oe.tasks.body(e.id),queryFn:()=>xe.get(`/tasks/${e.id}/body`)}),[B,e.id]),G=C.useMemo(()=>{if(!D)return null;const J=D.filter(Fe=>Fe.status==="ACTIVE"&&Array.isArray(Fe.sessions)).flatMap(Fe=>Fe.sessions??[]),be=Fe=>{const Wt=Fe.createdAt,$t=Fe.endedAt??Fe.startedAt??Wt;if(!$t)return 0;const Ot=Date.parse($t);return Number.isNaN(Ot)?0:Ot},Be=Fe=>{const Wt=J.filter($t=>Fe.includes($t.status));return Wt.length===0?null:Wt.sort(($t,Ot)=>be(Ot)-be($t))[0]??null},Pe=Be([rt.RUNNING])??Be([rt.PENDING])??Be([rt.COMPLETED,rt.FAILED,rt.CANCELLED]);if(Pe)return Pe;const xt=D.filter(Fe=>(Fe.status==="ABANDONED"||Fe.status==="MERGED"||Fe.status==="HIBERNATED")&&Array.isArray(Fe.sessions)).flatMap(Fe=>Fe.sessions??[]).filter(Fe=>[rt.COMPLETED,rt.FAILED,rt.CANCELLED].includes(Fe.status));return xt.length===0?null:xt.sort((Fe,Wt)=>be(Wt)-be(Fe))[0]??null},[D]),te=G?.id??"",fe=P?d??"":te,_e=C.useMemo(()=>{if(!d||!D)return null;for(const J of D){const be=J.sessions?.find(Be=>Be.id===d);if(be)return be}return null},[d,D]),V=C.useMemo(()=>{if(!d||!P?.invocations)return null;const J=P.invocations.filter(be=>be.sessionId===d);return J.length===0?null:J.sort((be,Be)=>{const Pe=Date.parse(be.updatedAt??be.createdAt??""),jt=Date.parse(Be.updatedAt??Be.createdAt??"");return(Number.isNaN(jt)?0:jt)-(Number.isNaN(Pe)?0:Pe)})[0]??null},[d,P?.invocations]),re=C.useMemo(()=>!V?.memberId||!P?.members?null:P.members.find(J=>J.id===V.memberId)??null,[V?.memberId,P?.members]),ne=d?_e:G??null,ae=ne?.status===rt.RUNNING||ne?.status===rt.PENDING,me=C.useMemo(()=>!G||!D?!1:!D.some(be=>be.status==="ACTIVE"&&be.sessions?.some(Be=>Be.id===G.id)),[G,D]),{data:we}=Ds(),[ye,Ce]=C.useState(null),Le=ye?.sessionId===te?ye.providerId:G?.providerId??null,it=C.useCallback(J=>{Ce({sessionId:te,providerId:J})},[te]),tt=fc({agentType:G?.agentType,workingDir:ie,input:u,setInput:c,textareaRef:S,minHeight:40,maxHeight:140}),Se=mc({agentType:G?.agentType,workingDir:ie,input:u,setInput:c,textareaRef:S,minHeight:40,maxHeight:140}),pt=ie&&q?q.id:void 0,lt=zn(),ct=jn(),vt=rc(),{isConnected:nt,isLoadingSnapshot:Qe,logs:Ie,entries:Et,attach:ps}=La({sessionId:fe,sessionStatus:ne?.status,onExit:C.useCallback(()=>{B.invalidateQueries({queryKey:["workspaces"]})},[B])}),{todos:gs}=Pa(Et),{files:ai,addFiles:Je,removeFile:vs,clear:Is,buildMarkdownLinks:Bs,hasFiles:Yt,isUploading:cs}=cn(),hr=C.useMemo(()=>nc(ne),[ne?.tokenUsage]),Fs=Ta(Ie,hr);C.useEffect(()=>{fe&&nt&&ps()},[fe,nt,ps]);const xs=C.useRef(null);C.useEffect(()=>{if(xs.current!==e.id&&R.current){const J=R.current;requestAnimationFrame(()=>{J.scrollTop=J.scrollHeight})}xs.current=e.id},[e.id,R]);const Ht=C.useRef(!1),_s=C.useCallback(async()=>{if(!u.trim()&&!Yt||!te||Ht.current||cs)return;Ht.current=!0;const J=Bs(),be=[u.trim(),J].filter(Boolean).join(`
|
|
80
|
+
`);n(""),Ht(),A.current&&(A.current.style.height="60px"),Bs.mutate({id:he,message:le,providerId:ae??void 0},{onSuccess:()=>{Ie()},onSettled:()=>{fi.current=!1}})},[i,he,Bs,Ie,Ot,xr,$t,Ht,ae]),Lc=C.useCallback(async()=>{he&&(await hi.mutateAsync(he),Je.invalidateQueries({queryKey:["workspaces"]}))},[he,hi,Je]),Pc=C.useCallback(Z=>{const le=Z.target.files;le&&le.length>0&&xt(Array.from(le)),Z.target.value=""},[xt]),Oc=C.useCallback(Z=>{const le=Z.clipboardData.items,Ye=[];for(const Ct of le)if(Ct.kind==="file"){const _t=Ct.getAsFile();_t&&Ye.push(_t)}Ye.length>0&&(Z.preventDefault(),xt(Ye))},[xt]),[Kn,mi]=C.useState(!1),Ic=C.useCallback(Z=>{Z.preventDefault(),mi(!0)},[]),Bc=C.useCallback(Z=>{Z.preventDefault(),mi(!1)},[]),Fc=C.useCallback(Z=>{Z.preventDefault(),mi(!1);const le=Z.dataTransfer.files;le.length>0&&xt(Array.from(le))},[xt]),Ut=C.useCallback(Z=>{const le=Q.current?.getBoundingClientRect().width??(typeof window<"u"?window.innerWidth:void 0),Ye=le?Math.max(Cs,le-Pi-A0-M0):Cs;return Math.max(Cs,Math.min(Math.round(Z),Ye))},[]),pi=C.useCallback(Z=>{const le=Z.clientX-q.current;N(Ut(ie.current-le))},[Ut]),gi=C.useCallback(()=>{K(!1),document.body.style.cursor="",document.body.style.userSelect=""},[]);C.useEffect(()=>{if(W)return document.addEventListener("mousemove",pi),document.addEventListener("mouseup",gi),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",pi),document.removeEventListener("mouseup",gi),document.body.style.cursor="",document.body.style.userSelect=""}},[gi,pi,W]);const zc=C.useCallback(Z=>{Z.preventDefault(),q.current=Z.clientX,ie.current=z,K(!0)},[z]);C.useEffect(()=>{!U||W||N(Z=>Ut(Z))},[Ut,U,W]),C.useEffect(()=>{if(!U)return;const Z=()=>{N(le=>Ut(le))};return window.addEventListener("resize",Z),()=>window.removeEventListener("resize",Z)},[Ut,U]);const Wc=C.useCallback(()=>{N(Z=>Ut(Z)),X(!0),requestAnimationFrame(()=>{j.current?.setTab("review")})},[Ut]),Hc=C.useCallback(Z=>{n(Z.target.value);const le=Z.target;le.style.height="auto";const Ye=le.scrollHeight;le.style.height=`${Math.max(60,Math.min(Ye,300))}px`},[]),Xn=tt&&Ne?t.jsx(hc,{workspaceId:Ne,branchName:vt,targetBranch:Qe,commitMessage:nt,changes:lt,gitStatus:Se,isGitStatusLoading:pt,canRunGitOperations:et,onOpenChanges:Wc,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(D0,{status:e.status,onChangeStatus:!_e&&o?Z=>o(e.id,Z):void 0}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:mr,disabled:!ye||_e,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(Yr,{size:16})}),(s||De)&&!_e&&t.jsxs("div",{className:"relative",ref:H,children:[t.jsx("button",{onClick:()=>E(Z=>!Z),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(Wa,{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(ss,{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(gd,{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(vn,{size:15}),t.jsx("span",{children:v("删除任务")})]})]})]})]})]})]})]}),et&&Ne&&Se&&t.jsx(o0,{workspaceId:Ne,gitStatus:Se,onResolve:()=>bs()}),t.jsxs("div",{ref:Q,className:"flex-1 flex overflow-hidden",children:[t.jsx("div",{className:"flex min-w-0 flex-1 flex-col bg-background relative",children:Ke&&Ee?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(lc,{session:te,providers:ne,usage:$n,providerIdFallback:G?.providerId,agentTypeFallback:te?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Me,{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:gr,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...")})]}):J.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:v(fe?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(Ar,{logs:J})})}),!$&&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("回到底部")})]})]}),Pe.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(Mr,{todos:Pe})})})]}):t.jsx(vl,{teamRun:Ee,messages:de??Ee.messages??[],readOnly:_e,readOnlyMessage:re,onSendMessage:ui,onViewInvocationSession:pr,changeSummaryBar:Xn,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:[(Xe||Te?.body)&&t.jsx("div",{className:"mb-4 pb-4 border-b border-border/60 min-w-0",children:Xe?t.jsx("p",{className:"text-sm text-muted-foreground/70 italic",children:v("Loading...")}):Te?.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(cn,{urlTransform:R0,components:dn,children:Te.body})}):null}),ge&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-muted-foreground/70 text-sm",children:[ge.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:ge.currentIndex,total:ge.totalCommands,command:ge.currentCommand})})]}),ge.status==="completed"&&t.jsx("span",{className:"text-success",children:v("Setup 完成")}),ge.status==="failed"&&t.jsx("span",{className:"text-destructive/80",children:v("Setup 失败: {error}",{error:ge.error})})]}),!_e&&p&&(pe||He)?t.jsx("div",{className:"flex justify-center py-3",children:t.jsx(na,{state:p,onRetry:p.status==="failed"?zs:void 0})}):null,pe?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...")})]}):He?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...")})]}):J.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:v(fe?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(Ar,{logs:J}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[t.jsx("div",{className:"w-14 h-14 bg-muted/50 rounded-2xl border border-border/60 flex items-center justify-center mb-5",children:t.jsx(qt,{size:24,className:"text-muted-foreground/70 ml-0.5"})}),t.jsx("h3",{className:"text-base font-medium text-foreground mb-1.5",children:v(_e?"项目为只读历史":"尚未启动 Agent")}),t.jsx("p",{className:"text-sm text-muted-foreground mb-6 max-w-xs",children:_e?re:v("选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。")}),!_e&&p?t.jsx(na,{state:p}):null,!_e&&t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[t.jsxs(Me,{onClick:zs,disabled:!!(p&&p.status!=="failed"),children:[t.jsx(qt,{size:16,className:"mr-1.5"}),p?.status==="failed"?v("重试启动 Agent"):v("启动 Agent")]}),De&&t.jsxs(Me,{variant:"outline",onClick:()=>g(!0),children:[t.jsx(ss,{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("回到底部")})]})]}),Pe.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(Mr,{todos:Pe})})}),_e?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:re})})}):we?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(Me,{size:"sm",onClick:zs,children:[t.jsx(qt,{size:14,className:"mr-1.5"}),v("启动新 Agent")]})]})})}):t.jsxs("div",{className:"p-6 pt-2 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-transparent",onDragOver:Ic,onDragLeave:Bc,onDrop:Fc,children:[t.jsxs("div",{className:"max-w-4xl mx-auto",children:[Xn,t.jsxs("div",{ref:F,className:`relative bg-background rounded-xl border hover:border-ring/40 focus-within:border-ring/60 transition-colors duration-200 ${Kn?"border-info bg-info/5":"border-border"}`,children:[t.jsx(ln,{files:jt,onRemove:Be}),t.jsx("textarea",{ref:A,value:i,onChange:Hc,onPaste:Oc,onKeyDown:Z=>{Le.handleKeyDown(Z)||Ce.handleKeyDown(Z)||Z.key==="Enter"&&!Z.shiftKey&&!Z.repeat&&!Z.nativeEvent.isComposing&&Z.nativeEvent.keyCode!==229&&(Z.preventDefault(),qn())},rows:1,placeholder:v(Kn?"Drop files here...":He&&!fe?"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:Pc}),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(gn,{size:18})})}),t.jsxs("div",{className:"flex items-center gap-2",children:[Ae&&ne&&t.jsx(Pa,{providers:ne,currentProviderId:ae,agentType:Ae.agentType,onSelect:me}),t.jsx(pn,{usage:$n}),fe&&!i.trim()&&!Ot?t.jsx("button",{onClick:Lc,disabled:hi.isPending,className:"p-2 rounded-lg transition-all duration-200 bg-destructive text-white hover:bg-destructive/90 disabled:opacity-50",children:t.jsx(As,{size:14})}):t.jsx("button",{onClick:qn,disabled:!i.trim()&&!Ot||xr,className:`p-2 rounded-lg transition-all duration-200 ${(i.trim()||Ot)&&!xr?"bg-primary text-primary-foreground hover:bg-primary/90":"bg-transparent text-muted-foreground/50 cursor-not-allowed"}`,children:t.jsx(mn,{size:18})})]})]})]})]}),t.jsx($r,{open:Ce.query!==null,anchorRef:F,commands:Ce.filteredCommands,selectedIndex:Ce.selectedIndex,query:Ce.query??"",hasCatalog:Ce.allCommands.length>0,onSelect:Ce.applyCommand}),t.jsx($r,{open:Le.query!==null,anchorRef:F,commands:Le.filteredSkills,selectedIndex:Le.selectedIndex,query:Le.query??"",hasCatalog:Le.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",onSelect:Le.applySkill})]})]})}),U&&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:zc,role:"separator","aria-orientation":"vertical","aria-label":v("调整工作区宽度")}),t.jsx("div",{className:"flex h-full flex-shrink-0 bg-background",style:{width:U?Pi+z:Pi},children:t.jsx(ic,{sessionId:He||void 0,workspaceId:Re,workingDir:ye,projectId:e.projectId,readOnly:_e,repoDeleted:V,teamRun:Ee,teamStatus:Ee?t.jsx(wl,{teamRun:Ee,workspaces:se,selectedWorkspaceId:Re,onSelectWorkspace:M,onViewInvocationSession:pr}):void 0,workspaces:se,selectedWorkspaceId:Re,onSelectWorkspace:M,variant:"rail",expanded:U,onExpandedChange:Z=>{Z&&N(le=>Ut(le)),X(Z)},minContentWidth:Cs,tabRef:j,gitAvailable:ze,gitProps:et&&Ne?{branchName:vt,targetBranch:Qe,commitMessage:nt,canRunGitOperations:!0,onRefreshCommitMessage:Is,onConflict:bs,onResolveConflicts:()=>bs()}:void 0})})]}),!_e&&t.jsx(oc,{isOpen:l,onClose:()=>u(!1),taskId:e.id,taskTitle:Te?.title??e.title,taskDescription:Te?.body??"",taskPrompt:Te?.prompt,projectIsGitRepo:ze,onStarted:()=>m?.(e.id)}),De&&!_e&&t.jsx(i0,{isOpen:c,onClose:()=>g(!1),taskId:e.id}),et&&Et&&Oe&&t.jsx(uc,{open:f,onOpenChange:Z=>{b(Z),Z||k(null)},workspaceId:Et,conflictOp:Oe.conflictOp,conflictedFiles:Oe.conflictedFiles,sourceBranch:gs,targetBranch:li,operation:Se?.operation,worktreePath:ps,mergeAborted:Oe.mergeAborted,mergeStrategy:Oe.mergeStrategy,sourceWorkspaceId:Oe.sourceWorkspaceId,targetWorkspaceId:Oe.targetWorkspaceId,sourceWorktreePath:Oe.sourceWorktreePath,targetWorktreePath:Oe.targetWorktreePath,sessions:ct,currentSessionId:Ke?void 0:He,teamRunId:Ee?.id}),t.jsx(un,{isOpen:_,onClose:()=>a(!1),onConfirm:ci,title:v("重新开始任务"),description:t.jsx("p",{children:v("将归档当前工作区并自动在新 Worktree 中重新启动 Agent,旧工作区内容保留供参考。")}),confirmText:v("确认重试"),variant:"default",isLoading:h}),t.jsx(Mn,{isOpen:x,onClose:()=>y(!1),onConfirm:di,taskId:e.id,taskTitle:e.title,workspaces:se,isLoading:r})]}):t.jsx(T0,{})}function Hn(e){switch(e){case Bt.TODO:return ve.Pending;case Bt.IN_PROGRESS:return ve.Running;case Bt.IN_REVIEW:return ve.Review;case Bt.DONE:return ve.Done;case Bt.CANCELLED:return ve.Cancelled}}function P0(e){switch(e){case ve.Pending:return Bt.TODO;case ve.Running:return Bt.IN_PROGRESS;case ve.Review:return Bt.IN_REVIEW;case ve.Done:return Bt.DONE;case ve.Cancelled:return Bt.CANCELLED}}function O0(e){switch(e){case Ft.CLAUDE_CODE:return"Claude Code";case Ft.GEMINI_CLI:return"Gemini CLI";case Ft.CURSOR_AGENT:return"Cursor Agent";case Ft.CODEX:return"Codex"}}const Ur=["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 vc(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 xc(e,s){return s??e?.find(r=>r.status==="ACTIVE")??e?.[0]}function _c(e){return e?e.workspaceKind===Dt.MAIN_DIRECTORY?"Project directory":e.branchName:"—"}function I0(e){return{id:e.id,name:e.name,color:e.color||Ur[vc(e.name,Ur.length)],isGitRepo:e.isGitRepo,archivedAt:e.archivedAt??null,repoDeletedAt:e.repoDeletedAt??null}}function B0(e){const s=xc(e);if(!s)return{agent:"—",branch:"—"};const r=_c(s),o=s.sessions;if(o&&o.length>0){const p=o[o.length-1];return{agent:O0(p.agentType),branch:r}}return{agent:"—",branch:r}}function F0(e){const{agent:s,branch:r}=B0(e.workspaces),o=e.project;return{id:e.id,projectId:e.projectId,title:e.titlePreview??e.title,status:Hn(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 z0(e,s,r){const o=xc(e.workspaces,r),p=_c(o);return{id:e.id,projectId:s.id,projectName:s.name,projectColor:s.color||Ur[vc(s.name,Ur.length)],title:e.titlePreview??e.title,status:Hn(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 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 W0(e){const s=e.split("/");return s[s.length-1]||e}function H0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function $0({workingDir:e,filePath:s,type:r}){const{t:o}=ue(),{data:p,isLoading:m,isError:v}=Vl(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(Ve,{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:ee("px-3 whitespace-pre",c,g),children:l},u)})})}function U0({entry:e,type:s,workingDir:r}){const[o,p]=C.useState(!1),m=oa[e.status]||oa.M,v=H0(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(i=>!i),className:ee("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:ee("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:W0(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($0,{workingDir:r,filePath:e.path,type:s})]})}function aa({title:e,entries:s,type:r,workingDir:o,defaultOpen:p}){const{t:m}=ue(),[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(U0,{entry:n,type:r,workingDir:o},`${r}:${n.path}`))})]})}function q0({workingDir:e}){const{t:s}=ue(),{data:r,isLoading:o,isError:p}=oi(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(Ve,{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(aa,{title:"Uncommitted",entries:m,type:"uncommitted",workingDir:e,defaultOpen:!0}),t.jsx(aa,{title:"Committed",entries:v,type:"committed",workingDir:e,defaultOpen:!1})]})}const Oi=50,la={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 K0(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?gt("{count}s ago",{count:r}):r<3600?gt("{count}m ago",{count:Math.floor(r/60)}):r<86400?gt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?gt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function X0(e){const s=e.split("/");return s[s.length-1]||e}function Y0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function V0({workingDir:e,hash:s,filePath:r}){const{t:o}=ue(),{data:p,isLoading:m,isError:v}=Fn(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(Ve,{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:ee("px-3 whitespace-pre",c,g),children:l},u)})})}function G0({entry:e,workingDir:s,hash:r}){const[o,p]=C.useState(!1),m=la[e.status]||la.M,v=Y0(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(i=>!i),className:ee("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:ee("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:X0(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(V0,{workingDir:s,hash:r,filePath:e.path})]})}function Q0({commit:e,workingDir:s}){const{t:r}=ue(),[o,p]=C.useState(!1),{data:m,isLoading:v}=Bn(s,o?e.hash:null),i=m?.files||[];return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(n=>!n),className:ee("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:ee("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:K0(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(Ve,{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(G0,{entry:n,workingDir:s,hash:e.hash},n.path))})]})]})}function Z0({workingDir:e}){const{t:s}=ue(),{data:r,isLoading:o,isError:p,fetchNextPage:m,hasNextPage:v,isFetchingNextPage:i}=xn({queryKey:oe.git.log(e||""),queryFn:({pageParam:l=0})=>xe.get("/git/log",{params:{workingDir:e||"",limit:String(Oi),skip:String(l)}}),initialPageParam:0,getNextPageParam:(l,u)=>l.commits.length<Oi?void 0:u.length*Oi,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(Ve,{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(Q0,{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(Ve,{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 J0=rr(),ex=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${J0}/attachments/by-path?path=${encodeURIComponent(e)}`:e;function tx({status:e}){const s={[ve.Running]:"bg-blue-500",[ve.Review]:"bg-amber-500",[ve.Pending]:"bg-neutral-400",[ve.Done]:"bg-emerald-500",[ve.Cancelled]:"bg-neutral-400"};return t.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${s[e]}`})}const sx=[{key:"chat",label:"Chat",icon:Kr},{key:"changes",label:"Changes",icon:Ls},{key:"history",label:"History",icon:Ts},{key:"workspace",label:"Workspace",icon:Vr}],rx=[{key:"chat",label:"Team room",icon:Kr},{key:"team-status",label:"Team Status",icon:us},{key:"changes",label:"Changes",icon:Ls},{key:"workspace",label:"Workspace",icon:Vr}];function ca({state:e,onRetry:s}){const{t:r}=ue(),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(Me,{size:"sm",variant:"outline",className:"mt-3",onClick:s,children:[t.jsx(qt,{size:14,className:"mr-1.5"}),r("重试启动 Agent")]}):null]}):t.jsxs("div",{className:"mb-5 flex items-center gap-2 rounded-full border border-neutral-200 bg-neutral-50 px-3 py-1.5 text-xs text-neutral-500",children:[t.jsxs("svg",{className:"h-3.5 w-3.5 animate-spin shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:o})]})}function ix({task:e,onBack:s,onDeleteTask:r,isDeleting:o,autoStartState:p,onAutoStartRecovered:m}){const{t:v}=ue(),i=nn(J=>J.setVisibleContext),[n,l]=C.useState("chat"),[u,c]=C.useState(""),[g,x]=C.useState(!1),[y,_]=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:M}=fn({resize:"smooth",initial:"instant"}),B=at();C.useEffect(()=>{if(!a)return;const J=be=>{j.current&&!j.current.contains(be.target)&&h(!1)};return document.addEventListener("mousedown",J),()=>document.removeEventListener("mousedown",J)},[a]);const{data:D,isLoading:F}=jn(e.id),{data:H}=Sa(e.id),{data:A}=wa(H?.id??""),O=on(H?.id??""),P=H??null,I=e.isGitRepo!==!1,$=C.useMemo(()=>(P?rx:sx).filter(J=>I||J.key!=="changes"&&J.key!=="history"),[I,P]),Y=H===null,{data:U,isLoading:X}=Ca(e.id,Y),z=!!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(J=>J.key===n)||l("chat")},[n,$,P]);const K=C.useMemo(()=>xl(D,P,b),[b,P,D]);C.useEffect(()=>{b&&!D?.some(J=>J.id===b)&&w(void 0)},[b,D]);const q=C.useMemo(()=>D?.find(J=>J.id===K),[K,D]),ie=C.useMemo(()=>{if(D){if(q)return rs(q);for(const J of D)if(J.status==="ACTIVE"&&rs(J))return rs(J);return rs(D[0])}},[q,D]),Q=q?.status===Rt.ACTIVE?q.id:void 0,se=I&&_l(q,P),pe=q?.branchName??"",ge=q?.commitMessage,Fe=C.useMemo(()=>bl(q,D,e?.mainBranch??""),[q,e?.mainBranch,D]),de=!!(se&&Q&&ie&&!z),{data:Ge,isLoading:Ee}=Rn(Q??"",{enabled:de}),{data:Ke}=oi(ie,{enabled:de}),ze=Ke?.committed?.length,[De,We]=C.useState(!1),[Te,Xe]=C.useState(null);C.useEffect(()=>{const J=I&&(n==="changes"||n==="chat"&&de)?"changes":I&&n==="history"?"history":null;if(!Q||!ie||!J){i(null);return}return i({workspaceId:Q,workingDir:ie,tab:J}),()=>{i(null)}},[n,I,Q,i,de,ie]);const Re=C.useMemo(()=>Ge?.conflictOp&&Ge.conflictedFiles.length>0?{conflictOp:Ge.conflictOp,conflictedFiles:Ge.conflictedFiles}:Te,[Ge?.conflictOp,Ge?.conflictedFiles,Te]),je=Re?.targetWorkspaceId??Q,Ne=Re?.targetWorktreePath??q?.worktreePath,et=Re?.sourceBranch??pe,Ae=Re?.targetBranch??Fe,He=q?.sessions??[],he=C.useCallback(J=>{Xe(J??null),We(!0)},[]),ft=C.useCallback(()=>e?.id?B.invalidateQueries({queryKey:oe.workspaces.list(e.id)}):Promise.resolve(),[e?.id,B]),wt=C.useCallback(async()=>B.fetchQuery({queryKey:oe.tasks.body(e.id),queryFn:()=>xe.get(`/tasks/${e.id}/body`)}),[B,e.id]),G=C.useMemo(()=>{if(!D)return null;const J=D.filter(Be=>Be.status==="ACTIVE"&&Array.isArray(Be.sessions)).flatMap(Be=>Be.sessions??[]),be=Be=>{const Ht=Be.createdAt,$t=Be.endedAt??Be.startedAt??Ht;if(!$t)return 0;const Ot=Date.parse($t);return Number.isNaN(Ot)?0:Ot},Ie=Be=>{const Ht=J.filter($t=>Be.includes($t.status));return Ht.length===0?null:Ht.sort(($t,Ot)=>be(Ot)-be($t))[0]??null},Pe=Ie([rt.RUNNING])??Ie([rt.PENDING])??Ie([rt.COMPLETED,rt.FAILED,rt.CANCELLED]);if(Pe)return Pe;const xt=D.filter(Be=>(Be.status==="ABANDONED"||Be.status==="MERGED"||Be.status==="HIBERNATED")&&Array.isArray(Be.sessions)).flatMap(Be=>Be.sessions??[]).filter(Be=>[rt.COMPLETED,rt.FAILED,rt.CANCELLED].includes(Be.status));return xt.length===0?null:xt.sort((Be,Ht)=>be(Ht)-be(Be))[0]??null},[D]),te=G?.id??"",fe=P?d??"":te,_e=C.useMemo(()=>{if(!d||!D)return null;for(const J of D){const be=J.sessions?.find(Ie=>Ie.id===d);if(be)return be}return null},[d,D]),V=C.useMemo(()=>{if(!d||!P?.invocations)return null;const J=P.invocations.filter(be=>be.sessionId===d);return J.length===0?null:J.sort((be,Ie)=>{const Pe=Date.parse(be.updatedAt??be.createdAt??""),jt=Date.parse(Ie.updatedAt??Ie.createdAt??"");return(Number.isNaN(jt)?0:jt)-(Number.isNaN(Pe)?0:Pe)})[0]??null},[d,P?.invocations]),re=C.useMemo(()=>!V?.memberId||!P?.members?null:P.members.find(J=>J.id===V.memberId)??null,[V?.memberId,P?.members]),ne=d?_e:G??null,ae=ne?.status===rt.RUNNING||ne?.status===rt.PENDING,me=C.useMemo(()=>!G||!D?!1:!D.some(be=>be.status==="ACTIVE"&&be.sessions?.some(Ie=>Ie.id===G.id)),[G,D]),{data:we}=Ds(),[ye,Ce]=C.useState(null),Le=ye?.sessionId===te?ye.providerId:G?.providerId??null,it=C.useCallback(J=>{Ce({sessionId:te,providerId:J})},[te]),tt=pc({agentType:G?.agentType,workingDir:ie,input:u,setInput:c,textareaRef:S,minHeight:40,maxHeight:140}),Se=gc({agentType:G?.agentType,workingDir:ie,input:u,setInput:c,textareaRef:S,minHeight:40,maxHeight:140}),pt=ie&&q?q.id:void 0,lt=Wn(),ct=Nn(),vt=nc(),{isConnected:nt,isLoadingSnapshot:Qe,logs:Oe,entries:Et,attach:ps}=Oa({sessionId:fe,sessionStatus:ne?.status,onExit:C.useCallback(()=>{B.invalidateQueries({queryKey:["workspaces"]})},[B])}),{todos:gs}=Ia(Et),{files:li,addFiles:Je,removeFile:vs,clear:Is,buildMarkdownLinks:Bs,hasFiles:Yt,isUploading:cs}=an(),fr=C.useMemo(()=>ac(ne),[ne?.tokenUsage]),Fs=La(Oe,fr);C.useEffect(()=>{fe&&nt&&ps()},[fe,nt,ps]);const xs=C.useRef(null);C.useEffect(()=>{if(xs.current!==e.id&&R.current){const J=R.current;requestAnimationFrame(()=>{J.scrollTop=J.scrollHeight})}xs.current=e.id},[e.id,R]);const Wt=C.useRef(!1),_s=C.useCallback(async()=>{if(!u.trim()&&!Yt||!te||Wt.current||cs)return;Wt.current=!0;const J=Bs(),be=[u.trim(),J].filter(Boolean).join(`
|
|
83
83
|
|
|
84
|
-
`);c(""),Is(),S.current&&(S.current.style.height="40px"),lt.mutate({id:te,message:be,providerId:Le??void 0},{onSuccess:()=>ps(),onSettled:()=>{Ht.current=!1}})},[u,te,lt,ps,Yt,cs,Bs,Is,Le]),li=C.useCallback(async()=>{te&&(await vt.mutateAsync(te),B.invalidateQueries({queryKey:["workspaces"]}))},[te,vt,B]),zs=C.useCallback(J=>O.mutateAsync(J),[O]),fr=C.useCallback(J=>{f(J),l("chat"),requestAnimationFrame(()=>{M()})},[M]),ci=C.useCallback(()=>{f(null)},[]),mr=C.useCallback(()=>{l("changes")},[]),pr=de&&Q?t.jsx(dc,{workspaceId:Q,branchName:pe,targetBranch:ze,commitMessage:ge,changes:Ke,gitStatus:Ge,isGitStatusLoading:Ee,canRunGitOperations:se,onOpenChanges:mr,onRefreshCommitMessage:ft,onConflict:he,className:"mb-2"}):null,bs=C.useCallback(J=>{const be=J.target.files;be&&be.length>0&&Je(Array.from(be)),J.target.value=""},[Je]),di=C.useCallback(J=>{const be=J.clipboardData.items,Be=[];for(const Pe of be)if(Pe.kind==="file"){const jt=Pe.getAsFile();jt&&Be.push(jt)}Be.length>0&&(J.preventDefault(),Je(Be))},[Je]),Vt=C.useCallback(J=>{c(J.target.value);const be=J.target;be.style.height="auto",be.style.height=`${Math.max(40,Math.min(be.scrollHeight,140))}px`},[]),gr=C.useCallback(()=>{pt&&ct.mutate({workspaceId:pt})},[ct,pt]),Gt=C.useRef(null);return C.useEffect(()=>{const J=window.visualViewport;if(!J)return;let be=!1;const Be=()=>{Gt.current&&(Gt.current.style.height=`${J.height}px`,Gt.current.style.top=`${J.offsetTop}px`)},Pe=()=>Be(),jt=()=>{be||Be()},xt=()=>{be=!0},Fe=()=>{be=!1,requestAnimationFrame(Be)};return J.addEventListener("resize",Pe),J.addEventListener("scroll",jt),document.addEventListener("touchstart",xt,{passive:!0}),document.addEventListener("touchend",Fe,{passive:!0}),document.addEventListener("touchcancel",Fe,{passive:!0}),()=>{J.removeEventListener("resize",Pe),J.removeEventListener("scroll",jt),document.removeEventListener("touchstart",xt),document.removeEventListener("touchend",Fe),document.removeEventListener("touchcancel",Fe)}},[]),C.useEffect(()=>{const J=Gt.current;if(!J)return;const be=Be=>{let Pe=Be.target;for(;Pe&&Pe!==J;){if(Pe.tagName==="TEXTAREA"){if(Pe.scrollHeight>Pe.clientHeight)return;Pe=Pe.parentElement;continue}const xt=window.getComputedStyle(Pe).overflowY;if((xt==="auto"||xt==="scroll")&&Pe.scrollHeight>Pe.clientHeight)return;Pe=Pe.parentElement}Be.preventDefault()};return J.addEventListener("touchmove",be,{passive:!1}),()=>J.removeEventListener("touchmove",be)},[]),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(ex,{status:e.status}),t.jsx("button",{onClick:gr,disabled:!pt||z,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:t.jsx(Xr,{size:16})}),r&&!z&&t.jsxs("div",{className:"relative",ref:j,children:[t.jsx("button",{onClick:()=>h(J=>!J),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:()=>{_(!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:J,label:be,icon:Be})=>t.jsxs("button",{onClick:()=>l(J),className:`flex min-w-0 flex-1 items-center justify-center gap-1 px-1 py-2 text-[11px] font-medium transition-colors ${n===J?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[t.jsx(Be,{size:13,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:v(be)})]},J))})]}),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:ne,providers:we,usage:Fs,compact:!0,providerIdFallback:re?.providerId,agentTypeFallback:ne?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Me,{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:Qe?t.jsx(Oi,{label:v("Loading logs...")}):Ie.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:v(ae?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(Nr,{logs:Ie})})}),!T&&t.jsxs("button",{onClick:()=>M(),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:A??P.messages??[],readOnly:z,readOnlyMessage:H,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:X?t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:v("Loading...")}):U?.body?t.jsx("div",{className:"text-[13px] text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:t.jsx(nn,{urlTransform:J0,components:on,children:U.body})}):t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),!z&&p&&(F||te)?t.jsx("div",{className:"flex justify-center py-2",children:t.jsx(aa,{state:p,onRetry:p.status==="failed"?async()=>{await wt(),x(!0)}:void 0})}):null,F?t.jsx(Oi,{label:"Loading..."}):te?Qe?t.jsx(Oi,{label:"Loading logs..."}):Ie.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:ae?"Waiting for agent output...":"No logs recorded."}):t.jsx(Nr,{logs:Ie}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[t.jsx("div",{className:"w-12 h-12 bg-neutral-50 rounded-xl border border-neutral-100 flex items-center justify-center mb-4",children:t.jsx(qt,{size:20,className:"text-neutral-400 ml-0.5"})}),t.jsx("h3",{className:"text-sm font-medium text-neutral-900 mb-1",children:v("尚未启动 Agent")}),t.jsx("p",{className:"text-xs text-neutral-500 mb-5 max-w-[240px]",children:z?H:v("选择一个 Agent 来执行此任务")}),!z&&p?t.jsx(aa,{state:p}):null,!z&&t.jsxs(Me,{onClick:async()=>{await wt(),x(!0)},disabled:!!(p&&p.status!=="failed"),children:[t.jsx(qt,{size:16,className:"mr-1.5"}),p?.status==="failed"?v("重试启动 Agent"):v("启动 Agent")]})]})]})}),!T&&t.jsxs("button",{onClick:()=>M(),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})}),z?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:H})}):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(Me,{size:"sm",onClick:async()=>{await wt(),x(!0)},children:[t.jsx(qt,{size:14,className:"mr-1.5"}),v("启动新 Agent")]})]})}):te&&t.jsxs("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:[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:Vt,onPaste:di,onKeyDown:J=>{Se.handleKeyDown(J)||tt.handleKeyDown(J)||J.key==="Enter"&&!J.shiftKey&&!J.repeat&&!J.nativeEvent.isComposing&&J.nativeEvent.keyCode!==229&&(J.preventDefault(),_s())},rows:1,placeholder:ae?"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&&we&&t.jsx(Da,{providers:we,currentProviderId:Le,agentType:G.agentType,onSelect:it}),t.jsx(fn,{usage:Fs}),ae&&!u.trim()&&!Yt?t.jsx("button",{onClick:li,disabled:vt.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()&&!Yt||cs,className:`p-1.5 rounded-lg transition-colors ${(u.trim()||Yt)&&!cs?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:t.jsx(hn,{size:15})})]})]})]}),t.jsx(Wr,{open:tt.query!==null,anchorRef:k,commands:tt.filteredCommands,selectedIndex:tt.selectedIndex,query:tt.query??"",hasCatalog:tt.allCommands.length>0,compact:!0,onSelect:tt.applyCommand}),t.jsx(Wr,{open:Se.query!==null,anchorRef:k,commands:Se.filteredSkills,selectedIndex:Se.selectedIndex,query:Se.query??"",hasCatalog:Se.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",compact:!0,onSelect:Se.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:K,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:K,onSelectWorkspace:w,className:"w-full",buttonClassName:"w-full max-w-none min-w-0 justify-start"})}),se&&Q&&t.jsx("div",{className:"shrink-0",children:t.jsx(Gl,{workspaceId:Q,branchName:pe,targetBranch:ze,commitMessage:ge,committedFileCount:He,onRefreshCommitMessage:ft,onConflict:he,onResolveConflicts:()=>he()})}),t.jsx(U0,{workingDir:ie})]}),n==="history"&&t.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:t.jsx(Q0,{workingDir:ie})}),n==="workspace"&&t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(sc,{sessionId:te||void 0,workspaceId:K,workingDir:ie,projectId:e.projectId,className:"h-full",hideChanges:!0,gitAvailable:I,readOnly:z,repoDeleted:N})}),!z&&t.jsx(ic,{isOpen:g,onClose:()=>x(!1),taskId:e.id,taskTitle:U?.title??e.title,taskDescription:U?.body??"",taskPrompt:U?.prompt,projectIsGitRepo:I,onStarted:()=>m?.(e.id)}),t.jsx(An,{isOpen:y,onClose:()=>_(!1),onConfirm:()=>{r?.(e.id),_(!1)},taskId:e.id,taskTitle:e.title,workspaces:D,isLoading:o}),De&&Re&&je&&t.jsx(cc,{open:De,onOpenChange:J=>{We(J),J||Xe(null)},workspaceId:je,conflictOp:Re.conflictOp,conflictedFiles:Re.conflictedFiles,sourceBranch:et,targetBranch:Ae,operation:Ge?.operation,worktreePath:Ne,mergeAborted:Re.mergeAborted,mergeStrategy:Re.mergeStrategy,sourceWorkspaceId:Re.sourceWorkspaceId,targetWorkspaceId:Re.targetWorkspaceId,sourceWorktreePath:Re.sourceWorktreePath,targetWorktreePath:Re.targetWorktreePath,sessions:$e,currentSessionId:P?void 0:te,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 ix=Object.defineProperty,Ur=Object.getOwnPropertySymbols,xc=Object.prototype.hasOwnProperty,_c=Object.prototype.propertyIsEnumerable,la=(e,s,r)=>s in e?ix(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 ke{constructor(n,l,u,c){if(this.version=n,this.errorCorrectionLevel=l,this.modules=[],this.isFunction=[],n<ke.MIN_VERSION||n>ke.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 x=this.addEccAndInterleave(u);if(this.drawCodewords(x),c==-1){let y=1e9;for(let _=0;_<8;_++){this.applyMask(_),this.drawFormatBits(_);const a=this.getPenaltyScore();a<y&&(c=_,y=a),this.applyMask(_)}}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 ke.encodeSegments(u,l)}static encodeBinary(n,l){const u=e.QrSegment.makeBytes(n);return ke.encodeSegments([u],l)}static encodeSegments(n,l,u=1,c=40,g=-1,x=!0){if(!(ke.MIN_VERSION<=u&&u<=c&&c<=ke.MAX_VERSION)||g<-1||g>7)throw new RangeError("Invalid value");let y,_;for(y=u;;y++){const f=ke.getNumDataCodewords(y,l)*8,b=v.getTotalBits(n,y);if(b<=f){_=b;break}if(y>=c)throw new RangeError("Data too long")}for(const f of[ke.Ecc.MEDIUM,ke.Ecc.QUARTILE,ke.Ecc.HIGH])x&&_<=ke.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==_);const h=ke.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 ke(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,x=Math.floor(u/3);this.setFunctionModule(g,x,c),this.setFunctionModule(x,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)),x=n+c,y=l+u;0<=x&&x<this.size&&0<=y&&y<this.size&&this.setFunctionModule(x,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!=ke.getNumDataCodewords(l,u))throw new RangeError("Invalid argument");const c=ke.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][l],g=ke.ECC_CODEWORDS_PER_BLOCK[u.ordinal][l],x=Math.floor(ke.getNumRawDataModules(l)/8),y=c-x%c,_=Math.floor(x/c);let a=[];const h=ke.reedSolomonComputeDivisor(g);for(let f=0,b=0;f<c;f++){let w=n.slice(b,b+_-g+(f<y?0:1));b+=w.length;const k=ke.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!=_-g||w>=y)&&d.push(b[f])});return p(d.length==x),d}drawCodewords(n){if(n.length!=Math.floor(ke.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 x=u-g,_=(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 x=!1,y=0,_=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[g][a]==x?(y++,y==5?n+=ke.PENALTY_N1:y>5&&n++):(this.finderPenaltyAddHistory(y,_),x||(n+=this.finderPenaltyCountPatterns(_)*ke.PENALTY_N3),x=this.modules[g][a],y=1);n+=this.finderPenaltyTerminateAndCount(x,y,_)*ke.PENALTY_N3}for(let g=0;g<this.size;g++){let x=!1,y=0,_=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][g]==x?(y++,y==5?n+=ke.PENALTY_N1:y>5&&n++):(this.finderPenaltyAddHistory(y,_),x||(n+=this.finderPenaltyCountPatterns(_)*ke.PENALTY_N3),x=this.modules[a][g],y=1);n+=this.finderPenaltyTerminateAndCount(x,y,_)*ke.PENALTY_N3}for(let g=0;g<this.size-1;g++)for(let x=0;x<this.size-1;x++){const y=this.modules[g][x];y==this.modules[g][x+1]&&y==this.modules[g+1][x]&&y==this.modules[g+1][x+1]&&(n+=ke.PENALTY_N2)}let l=0;for(const g of this.modules)l=g.reduce((x,y)=>x+(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*ke.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<ke.MIN_VERSION||n>ke.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(ke.getNumRawDataModules(n)/8)-ke.ECC_CODEWORDS_PER_BLOCK[l.ordinal][n]*ke.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]=ke.reedSolomonMultiply(l[g],u),g+1<l.length&&(l[g]^=l[g+1]);u=ke.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((x,y)=>u[y]^=ke.reedSolomonMultiply(x,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 st{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 st(st.Mode.BYTE,n.length,l)}static makeNumeric(n){if(!st.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 st(st.Mode.NUMERIC,n.length,l)}static makeAlphanumeric(n){if(!st.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=st.ALPHANUMERIC_CHARSET.indexOf(n.charAt(u))*45;c+=st.ALPHANUMERIC_CHARSET.indexOf(n.charAt(u+1)),r(c,11,l)}return u<n.length&&r(st.ALPHANUMERIC_CHARSET.indexOf(n.charAt(u)),6,l),new st(st.Mode.ALPHANUMERIC,n.length,l)}static makeSegments(n){return n==""?[]:st.isNumeric(n)?[st.makeNumeric(n)]:st.isAlphanumeric(n)?[st.makeAlphanumeric(n)]:[st.makeBytes(st.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 st(st.Mode.ECI,0,l)}static isNumeric(n){return st.NUMERIC_REGEX.test(n)}static isAlphanumeric(n){return st.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 nx={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,ox=4,ax=0,lx=.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 cx(e,s,r,o){if(o==null)return null;const p=e.length+r*2,m=Math.floor(s*lx),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),_=Math.floor(u),a=Math.ceil(i+l-y),h=Math.ceil(n+u-_);g={x:y,y:_,w:a,h}}const x=o.crossOrigin;return{x:l,y:u,h:n,w:i,excavation:g,opacity:c,crossOrigin:x}}function dx(e,s){return s!=null?Math.max(Math.floor(s),0):e?ox:ax}function Nc({value:e,level:s,minVersion:r,includeMargin:o,marginSize:p,imageSettings:m,size:v,boostLevel:i}){let n=ce.useMemo(()=>{const y=(Array.isArray(e)?e:[e]).reduce((_,a)=>(_.push(...Ns.QrSegment.makeSegments(a)),_),[]);return Ns.QrCode.encodeSegments(y,nx[s],r,void 0,void 0,i)},[e,s,r,i]);const{cells:l,margin:u,numCells:c,calculatedImageSettings:g}=ce.useMemo(()=>{let x=n.getModules();const y=dx(o,p),_=x.length+y*2,a=cx(x,v,y,m);return{cells:x,margin:y,numCells:_,calculatedImageSettings:a}},[n,v,m,o,p]);return{qrcode:n,margin:u,cells:l,numCells:c,calculatedImageSettings:g}}var ux=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),hx=ce.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:x}=o,_=en(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:a}=_,h=en(_,["style"]),d=x?.src,f=ce.useRef(null),b=ce.useRef(null),w=ce.useCallback(B=>{f.current=B,typeof r=="function"?r(B):r&&(r.current=B)},[r]),[k,j]=ce.useState(!1),{margin:S,cells:E,numCells:R,calculatedImageSettings:L}=Nc({value:p,level:v,minVersion:u,boostLevel:c,includeMargin:l,marginSize:g,imageSettings:x,size:m});ce.useEffect(()=>{if(f.current!=null){const B=f.current,D=B.getContext("2d");if(!D)return;let F=E;const W=b.current,A=L!=null&&W!==null&&W.complete&&W.naturalHeight!==0&&W.naturalWidth!==0;A&&L.excavation!=null&&(F=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,ux?D.fill(new Path2D(Ec(F,S))):E.forEach(function(I,$){I.forEach(function(Y,U){Y&&D.fillRect(U+S,$+S,1,1)})}),L&&(D.globalAlpha=L.opacity),A&&D.drawImage(W,L.x+S,L.y+S,L.w,L.h)}}),ce.useEffect(()=>{j(!1)},[d]);const T=Ji({height:m,width:m},a);let M=null;return d!=null&&(M=ce.createElement("img",{src:d,key:d,style:{display:"none"},onLoad:()=>{j(!0)},ref:b,crossOrigin:L?.crossOrigin})),ce.createElement(ce.Fragment,null,ce.createElement("canvas",Ji({style:T,height:m,width:m,ref:w,role:"img"},h)),M)});hx.displayName="QRCodeCanvas";var Rc=ce.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:x,imageSettings:y}=o,_=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:x,imageSettings:y,size:m});let b=h,w=null;y!=null&&f!=null&&(f.excavation!=null&&(b=jc(h,f.excavation)),w=ce.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 ce.createElement("svg",Ji({height:m,width:m,viewBox:`0 0 ${d} ${d}`,ref:r,role:"img"},_),!!g&&ce.createElement("title",null,g),ce.createElement("path",{fill:i,d:`M0,0 h${d}v${d}H0z`,shapeRendering:"crispEdges"}),ce.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 fx(){return Tt({queryKey:oe.tunnel.status,queryFn:()=>xe.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?5e3:!1})}function mx(){const e=at();return St({mutationFn:()=>xe.post("/tunnel/start",{port:Ac()}),onSuccess:()=>{e.invalidateQueries({queryKey:oe.tunnel.status})}})}function px(){const e=at();return St({mutationFn:()=>xe.post("/tunnel/regenerate",{port:Ac()}),onSuccess:()=>{e.invalidateQueries({queryKey:oe.tunnel.status})}})}function gx(){const e=at();return St({mutationFn:()=>xe.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:oe.tunnel.status})}})}function vx(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 xx(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 _x(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 bx(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}=ue(),{data:s}=fx(),r=mx(),o=gx(),p=px(),[m,v]=C.useState(!1),[i,n]=C.useState(null),l=C.useRef(null),[u,c]=C.useState({top:0,right:0}),[g,x]=C.useState(!1),[y,_]=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=vx(s),k=xx(s),j=bx(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),x(!1),_(!1)},[o]),M=C.useCallback(()=>{p.mutate(void 0,{onSuccess:()=>{_(!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(Ve,{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&&ts.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(os,{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(Ve,{size:13,className:"animate-spin"}),e(h?"Starting tunnel...":"Enable phone access")]})]})]}),document.body),m&&a&&ts.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(_x(s))})]}),t.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(os,{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(Sd,{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(Kt,{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:()=>x(!g),className:"text-xs text-neutral-500 hover:text-neutral-700 transition-colors",children:e(g?"Hide token":"Show token")}),g&&t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.jsx("code",{className:"flex-1 min-w-0 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-600 break-all",children: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(Kt,{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:()=>_(!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:M,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:()=>_(!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}=ue(),o=Ed(),[p,m]=C.useState(""),[v,i]=C.useState(""),[n,l]=C.useState(null),[u,c]=C.useState(!1),[g,x]=C.useState(!1),y=p.trim(),_=v.trim(),a=u||o.isPending,h=C.useMemo(()=>!!(y&&_&&!a),[y,_,a]),d=C.useCallback(()=>{m(""),i(""),l(null),x(!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:_,initEmptyRepo:S}),d(),s()}catch(E){const R=E instanceof Error?E.message:r("Failed to create project");l(R),ht.error(R)}},[o,s,d,r,y,_]),w=C.useCallback(async()=>{if(!(!y||!_||a)){l(null),c(!0);try{const S=await xe.get("/filesystem/validate",{params:{path:_}});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){x(!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,_]),k=C.useCallback(()=>{x(!1),b(!1)},[b]),j=C.useCallback(()=>{x(!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(jd,{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||x(!1)},title:r("Initialize Git repository?"),action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>x(!1),disabled:o.isPending,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:r("Cancel")}),t.jsx("button",{onClick:k,disabled:o.isPending,className:"px-4 py-2 text-sm font-medium rounded-lg border border-neutral-200 text-neutral-700 hover:bg-neutral-50 transition-colors disabled:opacity-50",children:r("Create Local Project")}),t.jsx("button",{onClick: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}=ue(),[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:ee("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(Kt,{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(Kt,{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(ss,{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 yx=260,Sx=600,fa=400,wx=100,kr=1e3;function Cx(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 kx(e,s){const r=s.find(o=>o?.id===e.projectId);return r?{...e,project:r}:e}function e_(){const{t:e,locale:s}=ue(),[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,x]=C.useState({}),y=C.useRef(!1),_=C.useRef(0),a=C.useRef(fa),h=C.useRef(null),d=at(),{data:f,isLoading:b}=Ds(),{data:w,isLoading:k}=Nd({limit:wx}),j=C.useMemo(()=>w?.data??[],[w?.data]),S=C.useMemo(()=>j.map(O0),[j]),E=p&&j.some(V=>V.id===p)?p:null,{data:R,isLoading:L}=hd(E??"",{limit:kr}),T=Ld({queries:E?[]:j.map(V=>({queryKey:oe.tasks.list(V.id,{limit:kr}),queryFn:()=>xe.get(`/projects/${V.id}/tasks`,{params:{limit:String(kr)}})}))}),M=!E&&T.some(V=>V.isLoading),B=C.useMemo(()=>{if(E)return R?.data??[];const V=[];for(const re of T)re.data?.data&&V.push(...re.data.data);return V},[E,R,T]),[D,F]=C.useState([]),W=C.useMemo(()=>{if(D.length===0)return B;const V=new Set(B.map(re=>re.id));return[...D.filter(re=>!V.has(re.id)),...B]},[B,D]),[A,O]=C.useState(null),P=C.useMemo(()=>r&&W.some(V=>V.id===r)?r:A&&r===A?A:null,[r,W,A]);C.useEffect(()=>{A&&W.some(V=>V.id===A)&&O(null)},[A,W]),C.useEffect(()=>{if(D.length===0)return;const V=new Set(B.map(re=>re.id));D.some(re=>V.has(re.id))&&F(re=>re.filter(ne=>!V.has(ne.id)))},[B,D]);const I=C.useMemo(()=>{const V=new Map;for(const re of W){const ne=re.createdAt?new Date(re.createdAt).getTime():0,ae=V.get(re.projectId)??0;ne>ae&&V.set(re.projectId,ne)}return[...j].sort((re,ne)=>{const ae=V.get(re.id)??(re.createdAt?new Date(re.createdAt).getTime():0);return(V.get(ne.id)??(ne.createdAt?new Date(ne.createdAt).getTime():0))-ae})},[j,W]),$=C.useMemo(()=>I.filter(V=>!V.archivedAt),[I]),Y=C.useMemo(()=>{if(!f)return[];const V=localStorage.getItem("providerUsageCount"),re=V?JSON.parse(V):{};return[...f].sort((ne,ae)=>{const me=ne.availability.type!=="NOT_FOUND",we=ae.availability.type!=="NOT_FOUND";if(me!==we)return me?-1:1;const ye=re[ne.provider.id]??0;return(re[ae.provider.id]??0)-ye})},[f]),U=C.useMemo(()=>W.map(B0),[W]),X=C.useMemo(()=>new Set,[]),z=C.useMemo(()=>{if(!P)return null;const V=W.find(ne=>ne.id===P);if(!V)return null;const re=j.find(ne=>ne.id===V.projectId);if(!re){const ne=fs(V.workspaces?.find(ae=>ae.status==="ACTIVE")??V.workspaces?.[0]);return{id:V.id,projectId:V.projectId,projectName:"Unknown",projectColor:"text-muted-foreground",title:V.title,status:Hn(V.status),branch:ne,mainBranch:"main",description:V.description??"",isGitRepo:!1,projectArchivedAt:null,projectRepoDeletedAt:null}}return F0(V,re)},[P,W,j]),N=_a(),H=fd(),K=md(),q=Fn(),ie=C.useCallback(V=>{F(re=>re.some(ne=>ne.id===V.id)?re.map(ne=>ne.id===V.id?{...ne,...V}:ne):[V,...re]),d.setQueryData(oe.tasks.list(V.projectId,{limit:kr}),re=>Cx(re,V)),d.setQueryData(oe.tasks.detail(V.id),V),O(V.id),o(V.id)},[d]),Q=C.useCallback((V,re,ne)=>{const ae=V.id,me=[V.title,V.description].filter(Boolean).join(`
|
|
84
|
+
`);c(""),Is(),S.current&&(S.current.style.height="40px"),lt.mutate({id:te,message:be,providerId:Le??void 0},{onSuccess:()=>ps(),onSettled:()=>{Wt.current=!1}})},[u,te,lt,ps,Yt,cs,Bs,Is,Le]),ci=C.useCallback(async()=>{te&&(await vt.mutateAsync(te),B.invalidateQueries({queryKey:["workspaces"]}))},[te,vt,B]),zs=C.useCallback(J=>O.mutateAsync(J),[O]),mr=C.useCallback(J=>{f(J),l("chat"),requestAnimationFrame(()=>{M()})},[M]),di=C.useCallback(()=>{f(null)},[]),pr=C.useCallback(()=>{l("changes")},[]),gr=de&&Q?t.jsx(hc,{workspaceId:Q,branchName:pe,targetBranch:Fe,commitMessage:ge,changes:Ke,gitStatus:Ge,isGitStatusLoading:Ee,canRunGitOperations:se,onOpenChanges:pr,onRefreshCommitMessage:ft,onConflict:he,className:"mb-2"}):null,bs=C.useCallback(J=>{const be=J.target.files;be&&be.length>0&&Je(Array.from(be)),J.target.value=""},[Je]),ui=C.useCallback(J=>{const be=J.clipboardData.items,Ie=[];for(const Pe of be)if(Pe.kind==="file"){const jt=Pe.getAsFile();jt&&Ie.push(jt)}Ie.length>0&&(J.preventDefault(),Je(Ie))},[Je]),Vt=C.useCallback(J=>{c(J.target.value);const be=J.target;be.style.height="auto",be.style.height=`${Math.max(40,Math.min(be.scrollHeight,140))}px`},[]),vr=C.useCallback(()=>{pt&&ct.mutate({workspaceId:pt})},[ct,pt]),Gt=C.useRef(null);return C.useEffect(()=>{const J=window.visualViewport;if(!J)return;let be=!1;const Ie=()=>{Gt.current&&(Gt.current.style.height=`${J.height}px`,Gt.current.style.top=`${J.offsetTop}px`)},Pe=()=>Ie(),jt=()=>{be||Ie()},xt=()=>{be=!0},Be=()=>{be=!1,requestAnimationFrame(Ie)};return J.addEventListener("resize",Pe),J.addEventListener("scroll",jt),document.addEventListener("touchstart",xt,{passive:!0}),document.addEventListener("touchend",Be,{passive:!0}),document.addEventListener("touchcancel",Be,{passive:!0}),()=>{J.removeEventListener("resize",Pe),J.removeEventListener("scroll",jt),document.removeEventListener("touchstart",xt),document.removeEventListener("touchend",Be),document.removeEventListener("touchcancel",Be)}},[]),C.useEffect(()=>{const J=Gt.current;if(!J)return;const be=Ie=>{let Pe=Ie.target;for(;Pe&&Pe!==J;){if(Pe.tagName==="TEXTAREA"){if(Pe.scrollHeight>Pe.clientHeight)return;Pe=Pe.parentElement;continue}const xt=window.getComputedStyle(Pe).overflowY;if((xt==="auto"||xt==="scroll")&&Pe.scrollHeight>Pe.clientHeight)return;Pe=Pe.parentElement}Ie.preventDefault()};return J.addEventListener("touchmove",be,{passive:!1}),()=>J.removeEventListener("touchmove",be)},[]),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(tx,{status:e.status}),t.jsx("button",{onClick:vr,disabled:!pt||z,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:t.jsx(Yr,{size:16})}),r&&!z&&t.jsxs("div",{className:"relative",ref:j,children:[t.jsx("button",{onClick:()=>h(J=>!J),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:t.jsx(Wa,{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:()=>{_(!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(vn,{size:15}),t.jsx("span",{children:v("删除任务")})]})})]})]}),t.jsx("div",{className:"flex border-t border-neutral-100",children:$.map(({key:J,label:be,icon:Ie})=>t.jsxs("button",{onClick:()=>l(J),className:`flex min-w-0 flex-1 items-center justify-center gap-1 px-1 py-2 text-[11px] font-medium transition-colors ${n===J?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[t.jsx(Ie,{size:13,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:v(be)})]},J))})]}),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(lc,{session:ne,providers:we,usage:Fs,compact:!0,providerIdFallback:re?.providerId,agentTypeFallback:ne?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Me,{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:di,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:Qe?t.jsx(Ii,{label:v("Loading logs...")}):Oe.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:v(ae?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(Ar,{logs:Oe})})}),!T&&t.jsxs("button",{onClick:()=>M(),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(Mr,{todos:gs,compact:!0})})]}):t.jsx(vl,{teamRun:P,messages:A??P.messages??[],readOnly:z,readOnlyMessage:W,onSendMessage:zs,onViewInvocationSession:mr,changeSummaryBar:gr,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:X?t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:v("Loading...")}):U?.body?t.jsx("div",{className:"text-[13px] text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:t.jsx(cn,{urlTransform:ex,components:dn,children:U.body})}):t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),!z&&p&&(F||te)?t.jsx("div",{className:"flex justify-center py-2",children:t.jsx(ca,{state:p,onRetry:p.status==="failed"?async()=>{await wt(),x(!0)}:void 0})}):null,F?t.jsx(Ii,{label:"Loading..."}):te?Qe?t.jsx(Ii,{label:"Loading logs..."}):Oe.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:ae?"Waiting for agent output...":"No logs recorded."}):t.jsx(Ar,{logs:Oe}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[t.jsx("div",{className:"w-12 h-12 bg-neutral-50 rounded-xl border border-neutral-100 flex items-center justify-center mb-4",children:t.jsx(qt,{size:20,className:"text-neutral-400 ml-0.5"})}),t.jsx("h3",{className:"text-sm font-medium text-neutral-900 mb-1",children:v("尚未启动 Agent")}),t.jsx("p",{className:"text-xs text-neutral-500 mb-5 max-w-[240px]",children:z?W:v("选择一个 Agent 来执行此任务")}),!z&&p?t.jsx(ca,{state:p}):null,!z&&t.jsxs(Me,{onClick:async()=>{await wt(),x(!0)},disabled:!!(p&&p.status!=="failed"),children:[t.jsx(qt,{size:16,className:"mr-1.5"}),p?.status==="failed"?v("重试启动 Agent"):v("启动 Agent")]})]})]})}),!T&&t.jsxs("button",{onClick:()=>M(),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(Mr,{todos:gs,compact:!0})}),z?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(Me,{size:"sm",onClick:async()=>{await wt(),x(!0)},children:[t.jsx(qt,{size:14,className:"mr-1.5"}),v("启动新 Agent")]})]})}):te&&t.jsxs("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:[gr,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(ln,{files:li,onRemove:vs}),t.jsx("textarea",{ref:S,value:u,onChange:Vt,onPaste:ui,onKeyDown:J=>{Se.handleKeyDown(J)||tt.handleKeyDown(J)||J.key==="Enter"&&!J.shiftKey&&!J.repeat&&!J.nativeEvent.isComposing&&J.nativeEvent.keyCode!==229&&(J.preventDefault(),_s())},rows:1,placeholder:ae?"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(gn,{size:15})})}),t.jsxs("div",{className:"flex items-center gap-1",children:[G&&we&&t.jsx(Pa,{providers:we,currentProviderId:Le,agentType:G.agentType,onSelect:it}),t.jsx(pn,{usage:Fs}),ae&&!u.trim()&&!Yt?t.jsx("button",{onClick:ci,disabled:vt.isPending,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:t.jsx(As,{size:12})}):t.jsx("button",{onClick:_s,disabled:!u.trim()&&!Yt||cs,className:`p-1.5 rounded-lg transition-colors ${(u.trim()||Yt)&&!cs?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:t.jsx(mn,{size:15})})]})]})]}),t.jsx($r,{open:tt.query!==null,anchorRef:k,commands:tt.filteredCommands,selectedIndex:tt.selectedIndex,query:tt.query??"",hasCatalog:tt.allCommands.length>0,compact:!0,onSelect:tt.applyCommand}),t.jsx($r,{open:Se.query!==null,anchorRef:k,commands:Se.filteredSkills,selectedIndex:Se.selectedIndex,query:Se.query??"",hasCatalog:Se.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",compact:!0,onSelect:Se.applySkill})]})]})),n==="team-status"&&P&&t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:t.jsx(wl,{teamRun:P,workspaces:D,selectedWorkspaceId:K,onSelectWorkspace:w,onViewInvocationSession:mr})}),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(rc,{workspaces:D,teamRun:P,selectedWorkspaceId:K,onSelectWorkspace:w,className:"w-full",buttonClassName:"w-full max-w-none min-w-0 justify-start"})}),se&&Q&&t.jsx("div",{className:"shrink-0",children:t.jsx(Zl,{workspaceId:Q,branchName:pe,targetBranch:Fe,commitMessage:ge,committedFileCount:ze,onRefreshCommitMessage:ft,onConflict:he,onResolveConflicts:()=>he()})}),t.jsx(q0,{workingDir:ie})]}),n==="history"&&t.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:t.jsx(Z0,{workingDir:ie})}),n==="workspace"&&t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(ic,{sessionId:te||void 0,workspaceId:K,workingDir:ie,projectId:e.projectId,className:"h-full",hideChanges:!0,gitAvailable:I,readOnly:z,repoDeleted:N})}),!z&&t.jsx(oc,{isOpen:g,onClose:()=>x(!1),taskId:e.id,taskTitle:U?.title??e.title,taskDescription:U?.body??"",taskPrompt:U?.prompt,projectIsGitRepo:I,onStarted:()=>m?.(e.id)}),t.jsx(Mn,{isOpen:y,onClose:()=>_(!1),onConfirm:()=>{r?.(e.id),_(!1)},taskId:e.id,taskTitle:e.title,workspaces:D,isLoading:o}),De&&Re&&je&&t.jsx(uc,{open:De,onOpenChange:J=>{We(J),J||Xe(null)},workspaceId:je,conflictOp:Re.conflictOp,conflictedFiles:Re.conflictedFiles,sourceBranch:et,targetBranch:Ae,operation:Ge?.operation,worktreePath:Ne,mergeAborted:Re.mergeAborted,mergeStrategy:Re.mergeStrategy,sourceWorkspaceId:Re.sourceWorkspaceId,targetWorkspaceId:Re.targetWorkspaceId,sourceWorktreePath:Re.sourceWorktreePath,targetWorktreePath:Re.targetWorktreePath,sessions:He,currentSessionId:P?void 0:te,teamRunId:P?.id})]})}function Ii({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 nx=Object.defineProperty,qr=Object.getOwnPropertySymbols,bc=Object.prototype.hasOwnProperty,yc=Object.prototype.propertyIsEnumerable,da=(e,s,r)=>s in e?nx(e,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[s]=r,en=(e,s)=>{for(var r in s||(s={}))bc.call(s,r)&&da(e,r,s[r]);if(qr)for(var r of qr(s))yc.call(s,r)&&da(e,r,s[r]);return e},tn=(e,s)=>{var r={};for(var o in e)bc.call(e,o)&&s.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&qr)for(var o of qr(e))s.indexOf(o)<0&&yc.call(e,o)&&(r[o]=e[o]);return r};var ms;(e=>{const s=class ke{constructor(n,l,u,c){if(this.version=n,this.errorCorrectionLevel=l,this.modules=[],this.isFunction=[],n<ke.MIN_VERSION||n>ke.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 x=this.addEccAndInterleave(u);if(this.drawCodewords(x),c==-1){let y=1e9;for(let _=0;_<8;_++){this.applyMask(_),this.drawFormatBits(_);const a=this.getPenaltyScore();a<y&&(c=_,y=a),this.applyMask(_)}}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 ke.encodeSegments(u,l)}static encodeBinary(n,l){const u=e.QrSegment.makeBytes(n);return ke.encodeSegments([u],l)}static encodeSegments(n,l,u=1,c=40,g=-1,x=!0){if(!(ke.MIN_VERSION<=u&&u<=c&&c<=ke.MAX_VERSION)||g<-1||g>7)throw new RangeError("Invalid value");let y,_;for(y=u;;y++){const f=ke.getNumDataCodewords(y,l)*8,b=v.getTotalBits(n,y);if(b<=f){_=b;break}if(y>=c)throw new RangeError("Data too long")}for(const f of[ke.Ecc.MEDIUM,ke.Ecc.QUARTILE,ke.Ecc.HIGH])x&&_<=ke.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==_);const h=ke.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 ke(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,x=Math.floor(u/3);this.setFunctionModule(g,x,c),this.setFunctionModule(x,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)),x=n+c,y=l+u;0<=x&&x<this.size&&0<=y&&y<this.size&&this.setFunctionModule(x,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!=ke.getNumDataCodewords(l,u))throw new RangeError("Invalid argument");const c=ke.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][l],g=ke.ECC_CODEWORDS_PER_BLOCK[u.ordinal][l],x=Math.floor(ke.getNumRawDataModules(l)/8),y=c-x%c,_=Math.floor(x/c);let a=[];const h=ke.reedSolomonComputeDivisor(g);for(let f=0,b=0;f<c;f++){let w=n.slice(b,b+_-g+(f<y?0:1));b+=w.length;const k=ke.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!=_-g||w>=y)&&d.push(b[f])});return p(d.length==x),d}drawCodewords(n){if(n.length!=Math.floor(ke.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 x=u-g,_=(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 x=!1,y=0,_=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[g][a]==x?(y++,y==5?n+=ke.PENALTY_N1:y>5&&n++):(this.finderPenaltyAddHistory(y,_),x||(n+=this.finderPenaltyCountPatterns(_)*ke.PENALTY_N3),x=this.modules[g][a],y=1);n+=this.finderPenaltyTerminateAndCount(x,y,_)*ke.PENALTY_N3}for(let g=0;g<this.size;g++){let x=!1,y=0,_=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][g]==x?(y++,y==5?n+=ke.PENALTY_N1:y>5&&n++):(this.finderPenaltyAddHistory(y,_),x||(n+=this.finderPenaltyCountPatterns(_)*ke.PENALTY_N3),x=this.modules[a][g],y=1);n+=this.finderPenaltyTerminateAndCount(x,y,_)*ke.PENALTY_N3}for(let g=0;g<this.size-1;g++)for(let x=0;x<this.size-1;x++){const y=this.modules[g][x];y==this.modules[g][x+1]&&y==this.modules[g+1][x]&&y==this.modules[g+1][x+1]&&(n+=ke.PENALTY_N2)}let l=0;for(const g of this.modules)l=g.reduce((x,y)=>x+(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*ke.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<ke.MIN_VERSION||n>ke.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(ke.getNumRawDataModules(n)/8)-ke.ECC_CODEWORDS_PER_BLOCK[l.ordinal][n]*ke.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]=ke.reedSolomonMultiply(l[g],u),g+1<l.length&&(l[g]^=l[g+1]);u=ke.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((x,y)=>u[y]^=ke.reedSolomonMultiply(x,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 st{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 st(st.Mode.BYTE,n.length,l)}static makeNumeric(n){if(!st.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 st(st.Mode.NUMERIC,n.length,l)}static makeAlphanumeric(n){if(!st.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=st.ALPHANUMERIC_CHARSET.indexOf(n.charAt(u))*45;c+=st.ALPHANUMERIC_CHARSET.indexOf(n.charAt(u+1)),r(c,11,l)}return u<n.length&&r(st.ALPHANUMERIC_CHARSET.indexOf(n.charAt(u)),6,l),new st(st.Mode.ALPHANUMERIC,n.length,l)}static makeSegments(n){return n==""?[]:st.isNumeric(n)?[st.makeNumeric(n)]:st.isAlphanumeric(n)?[st.makeAlphanumeric(n)]:[st.makeBytes(st.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 st(st.Mode.ECI,0,l)}static isNumeric(n){return st.NUMERIC_REGEX.test(n)}static isAlphanumeric(n){return st.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 ox={L:Ns.QrCode.Ecc.LOW,M:Ns.QrCode.Ecc.MEDIUM,Q:Ns.QrCode.Ecc.QUARTILE,H:Ns.QrCode.Ecc.HIGH},Sc=128,wc="L",Cc="#FFFFFF",kc="#000000",Ec=!1,jc=1,ax=4,lx=0,cx=.1;function Nc(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 Rc(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 dx(e,s,r,o){if(o==null)return null;const p=e.length+r*2,m=Math.floor(s*cx),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),_=Math.floor(u),a=Math.ceil(i+l-y),h=Math.ceil(n+u-_);g={x:y,y:_,w:a,h}}const x=o.crossOrigin;return{x:l,y:u,h:n,w:i,excavation:g,opacity:c,crossOrigin:x}}function ux(e,s){return s!=null?Math.max(Math.floor(s),0):e?ax:lx}function Ac({value:e,level:s,minVersion:r,includeMargin:o,marginSize:p,imageSettings:m,size:v,boostLevel:i}){let n=ce.useMemo(()=>{const y=(Array.isArray(e)?e:[e]).reduce((_,a)=>(_.push(...Ns.QrSegment.makeSegments(a)),_),[]);return Ns.QrCode.encodeSegments(y,ox[s],r,void 0,void 0,i)},[e,s,r,i]);const{cells:l,margin:u,numCells:c,calculatedImageSettings:g}=ce.useMemo(()=>{let x=n.getModules();const y=ux(o,p),_=x.length+y*2,a=dx(x,v,y,m);return{cells:x,margin:y,numCells:_,calculatedImageSettings:a}},[n,v,m,o,p]);return{qrcode:n,margin:u,cells:l,numCells:c,calculatedImageSettings:g}}var hx=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),fx=ce.forwardRef(function(s,r){const o=s,{value:p,size:m=Sc,level:v=wc,bgColor:i=Cc,fgColor:n=kc,includeMargin:l=Ec,minVersion:u=jc,boostLevel:c,marginSize:g,imageSettings:x}=o,_=tn(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:a}=_,h=tn(_,["style"]),d=x?.src,f=ce.useRef(null),b=ce.useRef(null),w=ce.useCallback(B=>{f.current=B,typeof r=="function"?r(B):r&&(r.current=B)},[r]),[k,j]=ce.useState(!1),{margin:S,cells:E,numCells:R,calculatedImageSettings:L}=Ac({value:p,level:v,minVersion:u,boostLevel:c,includeMargin:l,marginSize:g,imageSettings:x,size:m});ce.useEffect(()=>{if(f.current!=null){const B=f.current,D=B.getContext("2d");if(!D)return;let F=E;const H=b.current,A=L!=null&&H!==null&&H.complete&&H.naturalHeight!==0&&H.naturalWidth!==0;A&&L.excavation!=null&&(F=Rc(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,hx?D.fill(new Path2D(Nc(F,S))):E.forEach(function(I,$){I.forEach(function(Y,U){Y&&D.fillRect(U+S,$+S,1,1)})}),L&&(D.globalAlpha=L.opacity),A&&D.drawImage(H,L.x+S,L.y+S,L.w,L.h)}}),ce.useEffect(()=>{j(!1)},[d]);const T=en({height:m,width:m},a);let M=null;return d!=null&&(M=ce.createElement("img",{src:d,key:d,style:{display:"none"},onLoad:()=>{j(!0)},ref:b,crossOrigin:L?.crossOrigin})),ce.createElement(ce.Fragment,null,ce.createElement("canvas",en({style:T,height:m,width:m,ref:w,role:"img"},h)),M)});fx.displayName="QRCodeCanvas";var Mc=ce.forwardRef(function(s,r){const o=s,{value:p,size:m=Sc,level:v=wc,bgColor:i=Cc,fgColor:n=kc,includeMargin:l=Ec,minVersion:u=jc,boostLevel:c,title:g,marginSize:x,imageSettings:y}=o,_=tn(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:a,cells:h,numCells:d,calculatedImageSettings:f}=Ac({value:p,level:v,minVersion:u,boostLevel:c,includeMargin:l,marginSize:x,imageSettings:y,size:m});let b=h,w=null;y!=null&&f!=null&&(f.excavation!=null&&(b=Rc(h,f.excavation)),w=ce.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=Nc(b,a);return ce.createElement("svg",en({height:m,width:m,viewBox:`0 0 ${d} ${d}`,ref:r,role:"img"},_),!!g&&ce.createElement("title",null,g),ce.createElement("path",{fill:i,d:`M0,0 h${d}v${d}H0z`,shapeRendering:"crispEdges"}),ce.createElement("path",{fill:n,d:k,shapeRendering:"crispEdges"}),w)});Mc.displayName="QRCodeSVG";function Tc(){return parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10)}function mx(){return Tt({queryKey:oe.tunnel.status,queryFn:()=>xe.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?5e3:!1})}function px(){const e=at();return St({mutationFn:()=>xe.post("/tunnel/start",{port:Tc()}),onSuccess:()=>{e.invalidateQueries({queryKey:oe.tunnel.status})}})}function gx(){const e=at();return St({mutationFn:()=>xe.post("/tunnel/regenerate",{port:Tc()}),onSuccess:()=>{e.invalidateQueries({queryKey:oe.tunnel.status})}})}function vx(){const e=at();return St({mutationFn:()=>xe.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:oe.tunnel.status})}})}function xx(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 _x(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 bx(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 ua(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 yx(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 ha(){const{t:e}=ue(),{data:s}=mx(),r=px(),o=vx(),p=gx(),[m,v]=C.useState(!1),[i,n]=C.useState(null),l=C.useRef(null),[u,c]=C.useState({top:0,right:0}),[g,x]=C.useState(!1),[y,_]=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=xx(s),k=_x(s),j=yx(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),x(!1),_(!1)},[o]),M=C.useCallback(()=>{p.mutate(void 0,{onSuccess:()=>{_(!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(Ve,{size:16,className:"animate-spin"}):w.icon==="warn"?t.jsx(ir,{size:16}):t.jsx(oo,{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&&ts.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(oo,{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(os,{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(Ve,{size:13,className:"animate-spin"}),e(h?"Starting tunnel...":"Enable phone access")]})]})]}),document.body),m&&a&&ts.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(bx(s))})]}),t.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(os,{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(Ed,{size:12}),t.jsx("span",{children:e("Token protected")})]}),f&&t.jsx("div",{className:"flex justify-center py-3",children:t.jsx(Mc,{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(Kt,{size:14,className:"text-emerald-500"}):t.jsx(ro,{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:ua(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:ua(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:()=>x(!g),className:"text-xs text-neutral-500 hover:text-neutral-700 transition-colors",children:e(g?"Hide token":"Show token")}),g&&t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.jsx("code",{className:"flex-1 min-w-0 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-600 break-all",children: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(Kt,{size:14,className:"text-emerald-500"}):t.jsx(ro,{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:()=>_(!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:M,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:()=>_(!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(nr,{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 Bi({isOpen:e,onClose:s}){const{t:r}=ue(),o=Ad(),[p,m]=C.useState(""),[v,i]=C.useState(""),[n,l]=C.useState(null),[u,c]=C.useState(!1),[g,x]=C.useState(!1),y=p.trim(),_=v.trim(),a=u||o.isPending,h=C.useMemo(()=>!!(y&&_&&!a),[y,_,a]),d=C.useCallback(()=>{m(""),i(""),l(null),x(!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:_,initEmptyRepo:S}),d(),s()}catch(E){const R=E instanceof Error?E.message:r("Failed to create project");l(R),ht.error(R)}},[o,s,d,r,y,_]),w=C.useCallback(async()=>{if(!(!y||!_||a)){l(null),c(!0);try{const S=await xe.get("/filesystem/validate",{params:{path:_}});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){x(!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,_]),k=C.useCallback(()=>{x(!1),b(!1)},[b]),j=C.useCallback(()=>{x(!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(Md,{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||x(!1)},title:r("Initialize Git repository?"),action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>x(!1),disabled:o.isPending,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:r("Cancel")}),t.jsx("button",{onClick:k,disabled:o.isPending,className:"px-4 py-2 text-sm font-medium rounded-lg border border-neutral-200 text-neutral-700 hover:bg-neutral-50 transition-colors disabled:opacity-50",children:r("Create Local Project")}),t.jsx("button",{onClick: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 fa({projects:e,filterProjectId:s,setFilterProjectId:r,onCreateProject:o,className:p}){const{t:m}=ue(),[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:ee("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(Ms,{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(Ms,{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(Kt,{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(Kt,{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(ss,{size:13}),t.jsx("span",{children:m("Create New Project...")})]})]})]}):null]})}function ma(){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 Sx=260,wx=600,pa=400,Cx=100,Er=1e3;function kx(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 Ex(e,s){const r=s.find(o=>o?.id===e.projectId);return r?{...e,project:r}:e}function Jx(){const{t:e,locale:s}=ue(),[r,o]=C.useState(null),[p,m]=C.useState(null),[v,i]=C.useState(pa),[n,l]=C.useState(!1),[u,c]=C.useState("idle"),[g,x]=C.useState({}),y=C.useRef(!1),_=C.useRef(0),a=C.useRef(pa),h=C.useRef(null),d=at(),{data:f,isLoading:b}=Ds(),{data:w,isLoading:k}=Td({limit:Cx}),j=C.useMemo(()=>w?.data??[],[w?.data]),S=C.useMemo(()=>j.map(I0),[j]),E=p&&j.some(V=>V.id===p)?p:null,{data:R,isLoading:L}=vd(E??"",{limit:Er}),T=Od({queries:E?[]:j.map(V=>({queryKey:oe.tasks.list(V.id,{limit:Er}),queryFn:()=>xe.get(`/projects/${V.id}/tasks`,{params:{limit:String(Er)}})}))}),M=!E&&T.some(V=>V.isLoading),B=C.useMemo(()=>{if(E)return R?.data??[];const V=[];for(const re of T)re.data?.data&&V.push(...re.data.data);return V},[E,R,T]),[D,F]=C.useState([]),H=C.useMemo(()=>{if(D.length===0)return B;const V=new Set(B.map(re=>re.id));return[...D.filter(re=>!V.has(re.id)),...B]},[B,D]),[A,O]=C.useState(null),P=C.useMemo(()=>r&&H.some(V=>V.id===r)?r:A&&r===A?A:null,[r,H,A]);C.useEffect(()=>{A&&H.some(V=>V.id===A)&&O(null)},[A,H]),C.useEffect(()=>{if(D.length===0)return;const V=new Set(B.map(re=>re.id));D.some(re=>V.has(re.id))&&F(re=>re.filter(ne=>!V.has(ne.id)))},[B,D]);const I=C.useMemo(()=>{const V=new Map;for(const re of H){const ne=re.createdAt?new Date(re.createdAt).getTime():0,ae=V.get(re.projectId)??0;ne>ae&&V.set(re.projectId,ne)}return[...j].sort((re,ne)=>{const ae=V.get(re.id)??(re.createdAt?new Date(re.createdAt).getTime():0);return(V.get(ne.id)??(ne.createdAt?new Date(ne.createdAt).getTime():0))-ae})},[j,H]),$=C.useMemo(()=>I.filter(V=>!V.archivedAt),[I]),Y=C.useMemo(()=>{if(!f)return[];const V=localStorage.getItem("providerUsageCount"),re=V?JSON.parse(V):{};return[...f].sort((ne,ae)=>{const me=ne.availability.type!=="NOT_FOUND",we=ae.availability.type!=="NOT_FOUND";if(me!==we)return me?-1:1;const ye=re[ne.provider.id]??0;return(re[ae.provider.id]??0)-ye})},[f]),U=C.useMemo(()=>H.map(F0),[H]),X=C.useMemo(()=>new Set,[]),z=C.useMemo(()=>{if(!P)return null;const V=H.find(ne=>ne.id===P);if(!V)return null;const re=j.find(ne=>ne.id===V.projectId);if(!re){const ne=fs(V.workspaces?.find(ae=>ae.status==="ACTIVE")??V.workspaces?.[0]);return{id:V.id,projectId:V.projectId,projectName:"Unknown",projectColor:"text-muted-foreground",title:V.title,status:Hn(V.status),branch:ne,mainBranch:"main",description:V.description??"",isGitRepo:!1,projectArchivedAt:null,projectRepoDeletedAt:null}}return z0(V,re)},[P,H,j]),N=ya(),W=xd(),K=_d(),q=zn(),ie=C.useCallback(V=>{F(re=>re.some(ne=>ne.id===V.id)?re.map(ne=>ne.id===V.id?{...ne,...V}:ne):[V,...re]),d.setQueryData(oe.tasks.list(V.projectId,{limit:Er}),re=>kx(re,V)),d.setQueryData(oe.tasks.detail(V.id),V),O(V.id),o(V.id)},[d]),Q=C.useCallback((V,re,ne)=>{const ae=V.id,me=[V.title,V.description].filter(Boolean).join(`
|
|
86
86
|
|
|
87
|
-
`);x(we=>({...we,[ae]:{status:"creating-workspace"}})),(async()=>{try{const we=await xe.post(`/tasks/${ae}/workspaces`,{workspaceKind:ne});x(Ce=>({...Ce,[ae]:{status:"creating-session"}}));const ye=await xe.post(`/workspaces/${we.id}/sessions`,{providerId:re,prompt:me});x(Ce=>({...Ce,[ae]:{status:"starting-session"}})),await q.mutateAsync(ye.id),await d.invalidateQueries({queryKey:oe.workspaces.list(ae)}),await d.invalidateQueries({queryKey:oe.tasks.all}),x(Ce=>{const{[ae]:Le,...it}=Ce;return it})}catch(we){const ye=we instanceof Error?we.message:e("启动 Agent 失败");x(Ce=>({...Ce,[ae]:{status:"failed",error:ye}})),ht.error(e("任务已创建,但启动 Agent 失败,可在详情中重试")),d.invalidateQueries({queryKey:oe.workspaces.list(ae)}),d.invalidateQueries({queryKey:oe.tasks.all})}})()},[d,q,e]),se=C.useCallback(V=>{x(re=>{const{[V]:ne,...ae}=re;return ae}),d.invalidateQueries({queryKey:oe.workspaces.list(V)}),d.invalidateQueries({queryKey:oe.tasks.all})},[d]),pe=C.useCallback(V=>{
|
|
87
|
+
`);x(we=>({...we,[ae]:{status:"creating-workspace"}})),(async()=>{try{const we=await xe.post(`/tasks/${ae}/workspaces`,{workspaceKind:ne});x(Ce=>({...Ce,[ae]:{status:"creating-session"}}));const ye=await xe.post(`/workspaces/${we.id}/sessions`,{providerId:re,prompt:me});x(Ce=>({...Ce,[ae]:{status:"starting-session"}})),await q.mutateAsync(ye.id),await d.invalidateQueries({queryKey:oe.workspaces.list(ae)}),await d.invalidateQueries({queryKey:oe.tasks.all}),x(Ce=>{const{[ae]:Le,...it}=Ce;return it})}catch(we){const ye=we instanceof Error?we.message:e("启动 Agent 失败");x(Ce=>({...Ce,[ae]:{status:"failed",error:ye}})),ht.error(e("任务已创建,但启动 Agent 失败,可在详情中重试")),d.invalidateQueries({queryKey:oe.workspaces.list(ae)}),d.invalidateQueries({queryKey:oe.tasks.all})}})()},[d,q,e]),se=C.useCallback(V=>{x(re=>{const{[V]:ne,...ae}=re;return ae}),d.invalidateQueries({queryKey:oe.workspaces.list(V)}),d.invalidateQueries({queryKey:oe.tasks.all})},[d]),pe=C.useCallback(V=>{W.mutate(V,{onSuccess:()=>{P===V&&o(null),x(re=>{const{[V]:ne,...ae}=re;return ae}),F(re=>re.filter(ne=>ne.id!==V)),d.invalidateQueries({queryKey:oe.tasks.all})},onError:()=>{ht.error(e("删除任务失败"))}})},[W,P,d,e]),ge=C.useCallback((V,re)=>{K.mutate({id:V,status:P0(re)},{onError:()=>{ht.error(e("状态变更失败,该操作不被允许"))}})},[K,e]),Fe=C.useCallback(V=>{V.preventDefault(),y.current=!0,_.current=V.clientX,a.current=v,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[v]);C.useEffect(()=>{const V=ne=>{if(!y.current)return;const ae=ne.clientX-_.current,me=Math.max(Sx,Math.min(wx,a.current+ae));i(me)},re=()=>{y.current&&(y.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",V),document.addEventListener("mouseup",re),()=>{document.removeEventListener("mousemove",V),document.removeEventListener("mouseup",re)}},[]);const de=C.useCallback(()=>{l(!0)},[]),Ge=C.useCallback(()=>{if($.length===0){ht.error(e("没有可用项目,请先创建或恢复项目"));return}o(null)},[$,e]),Ee=C.useCallback(()=>{l(!1)},[]),Ke=C.useCallback(async V=>{const{title:re,description:ne,projectId:ae,providerId:me,mode:we,workspaceMode:ye,teamRunMode:Ce,teamTemplateId:Le,memberPresetIds:it,attachmentLinks:tt}=V,Se=[ne,tt].filter(Boolean).join(`
|
|
88
88
|
|
|
89
|
-
`),lt=$.find(Qe=>Qe.id===ae)?.isGitRepo!==!1,ct=lt?we:"SOLO",vt=lt?ye:Dt.MAIN_DIRECTORY;let nt=null;try{c("creating-task");const Qe=await xe.post(`/projects/${ae}/tasks`,{title:re,description:Se||void 0});if(nt=
|
|
89
|
+
`),lt=$.find(Qe=>Qe.id===ae)?.isGitRepo!==!1,ct=lt?we:"SOLO",vt=lt?ye:Dt.MAIN_DIRECTORY;let nt=null;try{c("creating-task");const Qe=await xe.post(`/projects/${ae}/tasks`,{title:re,description:Se||void 0});if(nt=Ex(Qe,$),localStorage.setItem("lastSelectedProjectId",ae),ct==="SOLO"&&me){localStorage.setItem("lastSelectedProviderId",me);const Oe=localStorage.getItem("providerUsageCount"),Et=Oe?JSON.parse(Oe):{};Et[me]=(Et[me]??0)+1,localStorage.setItem("providerUsageCount",JSON.stringify(Et))}ct==="TEAM"?(c("creating-teamrun"),await N.mutateAsync({taskId:nt.id,mode:Ce,...Le?{teamTemplateId:Le}:{},...it.length>0?{memberPresetIds:it}:{}})):me&&Q(nt,me,vt),E&&ae!==E&&m(null),ie(nt),c("idle"),d.invalidateQueries({queryKey:oe.tasks.all}),d.invalidateQueries({queryKey:oe.projects.all})}catch(Qe){if(c("idle"),nt&&ct==="TEAM"){try{await W.mutateAsync(nt.id)}catch{}throw ht.error(e("TeamRun 创建失败,请检查团队配置后重试")),Qe}else if(nt)E&&ae!==E&&m(null),ie(nt),d.invalidateQueries({queryKey:oe.tasks.all}),d.invalidateQueries({queryKey:oe.projects.all});else throw ht.error(Qe instanceof Error?Qe.message:e("Failed to create task")),Qe}},[$,N,Q,W,d,e,E,ie]),ze=k||L||M,De=C.useMemo(()=>$.map(V=>({id:V.id,name:V.name,color:S.find(re=>re.id===V.id)?.color,isGitRepo:V.isGitRepo})),[$,S]),We=C.useMemo(()=>Y.map(({provider:V,availability:re})=>({id:V.id,name:V.name,agentType:V.agentType,available:re.type!=="NOT_FOUND"})),[Y]),Te=C.useMemo(()=>{if(E&&$.find(re=>re.id===E))return E;const V=localStorage.getItem("lastSelectedProjectId");return V&&$.find(re=>re.id===V)?V:$[0]?.id??""},[$,E]),[Xe,Re]=C.useState(Te);C.useEffect(()=>{Re(Te)},[Te]);const je=C.useMemo(()=>$.find(V=>V.id===Xe)?.name??$.find(V=>V.id===Te)?.name??e("Project"),[$,Xe,Te,e]),Ne=s==="zh-CN"?`你需要在 ${je} 中做点什么?`:`What do you need to do in ${je}?`,et=C.useMemo(()=>{const V=localStorage.getItem("lastSelectedProviderId");return V&&Y.find(ne=>ne.provider.id===V&&ne.availability.type!=="NOT_FOUND")?V:Y.find(ne=>ne.availability.type!=="NOT_FOUND")?.provider.id??""},[Y]),Ae=cl(),[He,he]=C.useState(!1),{usesIntegratedTitlebar:ft,desktopPlatform:wt,hasMacTrafficLights:G}=ga(),te=ft&&wt==="win32",fe=C.useCallback(()=>{if($.length===0){ht.error(e("没有可用项目,请先创建或恢复项目"));return}he(!0)},[$,e]),_e=C.useCallback(async V=>{await Ke(V),he(!1)},[Ke]);return Ae?He?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:()=>he(!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:Ne}),t.jsx(eo,{projects:De,providers:We,isProvidersLoading:b,onSubmit:_e,defaultProjectId:Te,defaultProviderId:et,onProjectChange:Re,createStep:u})]})]}):P&&z?t.jsxs(t.Fragment,{children:[t.jsx(ix,{task:z,onBack:()=>o(null),onDeleteTask:z.projectArchivedAt?void 0:pe,isDeleting:W.isPending,autoStartState:g[z.id]??null,onAutoStartRecovered:se}),t.jsx(Bi,{isOpen:n,onClose:Ee})]}):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(to,{}),t.jsx(so,{}),t.jsx(fa,{projects:S,filterProjectId:E,setFilterProjectId:m,onCreateProject:de})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(ha,{}),t.jsx("button",{onClick:()=>Zn.getState().openSettings(),className:"p-1.5 text-muted-foreground/70 active:text-foreground rounded-md",children:t.jsx(Qn,{size:16})})]})]}),ze&&U.length===0?t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(ma,{})}):t.jsx(bo,{tasks:U,projects:S,selectedTaskId:null,onSelectTask:o,filterProjectId:E,setFilterProjectId:m,width:"100%",onCreateTask:fe,onCreateProject:de,activeTaskIds:X,onTaskStatusChange:ge})]}),t.jsx(Bi,{isOpen:n,onClose:Ee})]}):t.jsxs("div",{ref:h,className:"flex flex-col h-screen bg-sidebar overflow-hidden text-sm",children:[t.jsxs("header",{className:ee("h-12 bg-sidebar flex items-center px-4 justify-between flex-shrink-0 z-20 relative",ft&&"app-region-drag",te&&"pr-[150px]"),children:[t.jsxs("div",{className:ee("flex items-center gap-2 min-w-0",G&&"pl-[72px]"),children:[t.jsx(to,{}),t.jsx(so,{}),t.jsx(fa,{projects:S,filterProjectId:E,setFilterProjectId:m,onCreateProject:de,className:ft?"app-region-no-drag":void 0})]}),t.jsxs("div",{className:ee("flex items-center gap-1",ft&&"app-region-no-drag"),children:[t.jsx("div",{className:ft?"app-region-no-drag":void 0,children:t.jsx(ha,{})}),t.jsx("button",{onClick:()=>Zn.getState().openSettings(),className:ee("p-1.5 text-muted-foreground/70 hover:text-foreground hover:bg-accent rounded-md transition-colors",ft&&"app-region-no-drag"),children:t.jsx(Qn,{size:16})})]})]}),t.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[ze&&U.length===0?t.jsx("div",{className:"h-full overflow-hidden flex-shrink-0",style:{width:v},children:t.jsx(ma,{})}):t.jsx(bo,{tasks:U,projects:S,selectedTaskId:P,onSelectTask:o,filterProjectId:E,setFilterProjectId:m,width:v,onCreateTask:Ge,onCreateProject:de,isCreateActive:!P,activeTaskIds:X,onTaskStatusChange:ge,onDeleteTask:pe}),t.jsx("div",{onMouseDown:Fe,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&&z?t.jsx(L0,{task:z,onDeleteTask:z.projectArchivedAt?void 0:pe,isDeleting:W.isPending,onTaskStatusChange:z.projectArchivedAt?void 0:ge,autoStartState:g[z.id]??null,onAutoStartRecovered:se}):P&&!z?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:Ne}),t.jsx(eo,{projects:De,providers:We,isProvidersLoading:b,onSubmit:Ke,defaultProjectId:Te,defaultProviderId:et,onProjectChange:Re,createStep:u})]})})})]}),t.jsx(Bi,{isOpen:n,onClose:Ee})]})}export{Jx as ProjectKanbanPage};
|