agent-tower 0.7.4-beta.1 → 0.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/dist/mcp/tools/tasks.js +1 -1
  2. package/dist/mcp/tools/tasks.js.map +1 -1
  3. package/dist/mcp/types.js +1 -1
  4. package/dist/mcp/types.js.map +1 -1
  5. package/dist/services/__tests__/task.service.test.js +69 -7
  6. package/dist/services/__tests__/task.service.test.js.map +1 -1
  7. package/dist/services/task-display-state.d.ts +10 -0
  8. package/dist/services/task-display-state.d.ts.map +1 -0
  9. package/dist/services/task-display-state.js +45 -0
  10. package/dist/services/task-display-state.js.map +1 -0
  11. package/dist/services/task.service.d.ts +14 -6
  12. package/dist/services/task.service.d.ts.map +1 -1
  13. package/dist/services/task.service.js +70 -83
  14. package/dist/services/task.service.js.map +1 -1
  15. package/dist/web/assets/{AgentDemoPage-DiHEh1iv.js → AgentDemoPage-D9bIiALx.js} +1 -1
  16. package/dist/web/assets/{AgentEnvironmentSettingsPage-B_Xk7Bef.js → AgentEnvironmentSettingsPage-BE0RC6fR.js} +1 -1
  17. package/dist/web/assets/{AttachmentPreview-BngGSahV.js → AttachmentPreview-TPd4gdfb.js} +1 -1
  18. package/dist/web/assets/{BranchSelect-BgVKUnxj.js → BranchSelect-Kv3M1YhZ.js} +1 -1
  19. package/dist/web/assets/{BrandLogo-CBahjTd7.js → BrandLogo-fR2lCwEo.js} +1 -1
  20. package/dist/web/assets/{ConversationPage-kgJIlyS5.js → ConversationPage-BZiMHI9T.js} +1 -1
  21. package/dist/web/assets/{CreateTaskInput-Cllw4abW.js → CreateTaskInput-TcZpjBe-.js} +1 -1
  22. package/dist/web/assets/{DemoPage-CkS__9CE.js → DemoPage-DwpThe16.js} +1 -1
  23. package/dist/web/assets/{DesignSystemPage-BklN99GA.js → DesignSystemPage-DH9_cygJ.js} +1 -1
  24. package/dist/web/assets/{ExecutionPermissionSelector-Bsi1aa7q.js → ExecutionPermissionSelector-C-akTOVg.js} +1 -1
  25. package/dist/web/assets/{GeneralSettingsPage-BC9TUWiu.js → GeneralSettingsPage-v2w1eofz.js} +1 -1
  26. package/dist/web/assets/{LoadingPreviewPage-Dx8Si6-g.js → LoadingPreviewPage-pgk3PWM9.js} +1 -1
  27. package/dist/web/assets/{McpSettingsPage-fqXRGtFu.js → McpSettingsPage-w1DOlY5V.js} +1 -1
  28. package/dist/web/assets/{MemberAvatar-CZ3F53Ep.js → MemberAvatar-CJtylxwu.js} +1 -1
  29. package/dist/web/assets/MobileTaskDetail-D5Czlr2O.js +3 -0
  30. package/dist/web/assets/{NotificationSettingsPage-D9KGIFVA.js → NotificationSettingsPage-CkLg4WvT.js} +1 -1
  31. package/dist/web/assets/{ProfileSettingsPage-D_Hw5lpd.js → ProfileSettingsPage-B3yzbY1V.js} +1 -1
  32. package/dist/web/assets/ProjectKanbanPage-CuGSLvrU.js +14 -0
  33. package/dist/web/assets/{ProjectSettingsPage-CJANCPJX.js → ProjectSettingsPage-DoklOfna.js} +1 -1
  34. package/dist/web/assets/{ProviderSettingsPage-B6Ro5PQa.js → ProviderSettingsPage-Cm0hbX5n.js} +1 -1
  35. package/dist/web/assets/{SettingsMasterDetail-Q-049Dvh.js → SettingsMasterDetail-CGCUalkW.js} +1 -1
  36. package/dist/web/assets/TaskDetail-BiZbuXcE.js +1 -0
  37. package/dist/web/assets/{TaskHandoffPanel-BpGiZ5eT.js → TaskHandoffPanel-CJahUKNo.js} +24 -24
  38. package/dist/web/assets/{TeamSettingsPage-DbKgqEO_.js → TeamSettingsPage-CyppRTaY.js} +1 -1
  39. package/dist/web/assets/{TranslationSettingsPage-Ba-iypOV.js → TranslationSettingsPage-BoQXEZmn.js} +1 -1
  40. package/dist/web/assets/{arc-SOqs3Svk.js → arc-5NPBSbiL.js} +1 -1
  41. package/dist/web/assets/{architectureDiagram-3BPJPVTR-BH25ukq_.js → architectureDiagram-3BPJPVTR-CqPT-IsX.js} +1 -1
  42. package/dist/web/assets/{at-sign-CEsum1vJ.js → at-sign-Cf39WHCg.js} +1 -1
  43. package/dist/web/assets/{blockDiagram-GPEHLZMM-CKA17iNP.js → blockDiagram-GPEHLZMM-BN-1z9KN.js} +1 -1
  44. package/dist/web/assets/{c4Diagram-AAUBKEIU-DnZ_8oOf.js → c4Diagram-AAUBKEIU-CkeLbmQp.js} +1 -1
  45. package/dist/web/assets/channel-CDkuQ_7m.js +1 -0
  46. package/dist/web/assets/check-yNWhPvMH.js +1 -0
  47. package/dist/web/assets/{chevron-down-Bmwy-nvS.js → chevron-down-Ct7FZbKm.js} +1 -1
  48. package/dist/web/assets/{chevron-up-CClL6-SF.js → chevron-up-ARFlXMyO.js} +1 -1
  49. package/dist/web/assets/{chip-BSMT2uT1.js → chip-BV_1-tIb.js} +1 -1
  50. package/dist/web/assets/{chunk-2J33WTMH-BrtUyBDF.js → chunk-2J33WTMH-CWR7tRuT.js} +1 -1
  51. package/dist/web/assets/{chunk-4BX2VUAB-DZDNetDC.js → chunk-4BX2VUAB-CAulp4D5.js} +1 -1
  52. package/dist/web/assets/{chunk-55IACEB6-xVa3bJqv.js → chunk-55IACEB6-DqkKXsbD.js} +1 -1
  53. package/dist/web/assets/{chunk-727SXJPM-B7n9vxY4.js → chunk-727SXJPM-B19m45Sq.js} +1 -1
  54. package/dist/web/assets/{chunk-AQP2D5EJ-DQd4G76y.js → chunk-AQP2D5EJ-CuODwkza.js} +1 -1
  55. package/dist/web/assets/{chunk-FMBD7UC4-CXyP08kl.js → chunk-FMBD7UC4-CbUAjtCT.js} +1 -1
  56. package/dist/web/assets/{chunk-ND2GUHAM-BtnIS-HK.js → chunk-ND2GUHAM-C54VxArl.js} +1 -1
  57. package/dist/web/assets/{chunk-QZHKN3VN-D4D-V_ex.js → chunk-QZHKN3VN-D54Uw5fD.js} +1 -1
  58. package/dist/web/assets/classDiagram-4FO5ZUOK-eHY73FGu.js +1 -0
  59. package/dist/web/assets/classDiagram-v2-Q7XG4LA2-eHY73FGu.js +1 -0
  60. package/dist/web/assets/{code-block-OCS4YCEC-DfERo9L1.js → code-block-OCS4YCEC-CtAySD1h.js} +1 -1
  61. package/dist/web/assets/{confirm-dialog-8ItnHBi0.js → confirm-dialog-CCjHVFTv.js} +1 -1
  62. package/dist/web/assets/{content-DrW8KnXu.js → content-DZozZbBD.js} +1 -1
  63. package/dist/web/assets/{copy-prrQrInw.js → copy-C-jvx2et.js} +1 -1
  64. package/dist/web/assets/{cose-bilkent-S5V4N54A-CXdH8Idq.js → cose-bilkent-S5V4N54A-BaB2EVcU.js} +1 -1
  65. package/dist/web/assets/{cssMode-CJ6_f10q.js → cssMode-wd7JR1S4.js} +1 -1
  66. package/dist/web/assets/{dagre-BM42HDAG-XZydDwXe.js → dagre-BM42HDAG-C2j1Y8pO.js} +1 -1
  67. package/dist/web/assets/{diagram-2AECGRRQ-CofEe0Fr.js → diagram-2AECGRRQ-CF-EvpV9.js} +1 -1
  68. package/dist/web/assets/{diagram-5GNKFQAL-BbTtW5WH.js → diagram-5GNKFQAL-rBNso835.js} +1 -1
  69. package/dist/web/assets/{diagram-KO2AKTUF-BJHZXpUM.js → diagram-KO2AKTUF-6NW-oos1.js} +1 -1
  70. package/dist/web/assets/{diagram-LMA3HP47-DN7A27YU.js → diagram-LMA3HP47-DTfRxRLT.js} +1 -1
  71. package/dist/web/assets/{diagram-OG6HWLK6-4IdYadiw.js → diagram-OG6HWLK6-CS4Ae-hD.js} +1 -1
  72. package/dist/web/assets/{dialog-BUsI4h2U.js → dialog-DV4wfpNU.js} +1 -1
  73. package/dist/web/assets/{erDiagram-TEJ5UH35-BFijhCWv.js → erDiagram-TEJ5UH35-Dw9QQctN.js} +1 -1
  74. package/dist/web/assets/{file-C6QMUr5_.js → file-Btui_I8Z.js} +1 -1
  75. package/dist/web/assets/{flowDiagram-I6XJVG4X-D9MxC-El.js → flowDiagram-I6XJVG4X-BGZ9q86S.js} +1 -1
  76. package/dist/web/assets/{folder-picker-CBdw-4v3.js → folder-picker-DiR-8Qdl.js} +1 -1
  77. package/dist/web/assets/{freemarker2-CJVobC22.js → freemarker2-yVWXzD3l.js} +1 -1
  78. package/dist/web/assets/{ganttDiagram-6RSMTGT7-BijCAyPQ.js → ganttDiagram-6RSMTGT7-CkGun0no.js} +1 -1
  79. package/dist/web/assets/{gitGraphDiagram-PVQCEYII-AvI5QqxQ.js → gitGraphDiagram-PVQCEYII-Bz3oiYvi.js} +1 -1
  80. package/dist/web/assets/{globe-BOfcTsvL.js → globe-DAFqpAcW.js} +1 -1
  81. package/dist/web/assets/{handlebars-DTqWmI25.js → handlebars-BPf0z6eN.js} +1 -1
  82. package/dist/web/assets/{html-Bx7L8DX_.js → html-HCTCjfUg.js} +1 -1
  83. package/dist/web/assets/{htmlMode-D_S0NjZc.js → htmlMode-BDkbsknt.js} +1 -1
  84. package/dist/web/assets/index-408ws6FY.css +1 -0
  85. package/dist/web/assets/{index-DUmVscrR.js → index-B8xoIIa6.js} +4 -4
  86. package/dist/web/assets/{index-JXcQeorP.js → index-BMcLxIvZ.js} +1 -1
  87. package/dist/web/assets/{index-BFcDmhr0.js → index-BPqjxXmH.js} +1 -1
  88. package/dist/web/assets/index-BszkzNS4.js +122 -0
  89. package/dist/web/assets/{index-COigMgrJ.js → index-DgUtx9rV.js} +1 -1
  90. package/dist/web/assets/{index-Cdmj8aPv.js → index-DkSPjZm4.js} +1 -1
  91. package/dist/web/assets/{index-Bg8TlDo_.js → index-DuM6iAxG.js} +1 -1
  92. package/dist/web/assets/{index-CtOu4p9B.js → index-GuczxPxb.js} +1 -1
  93. package/dist/web/assets/{index-BClyhWqz.js → index-lZLy5rkr.js} +1 -1
  94. package/dist/web/assets/{infoDiagram-5YYISTIA-76JLqjJ0.js → infoDiagram-5YYISTIA-DYFufUYC.js} +1 -1
  95. package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-CXHFTVly.js → ishikawaDiagram-YF4QCWOH-IOkrKRwu.js} +1 -1
  96. package/dist/web/assets/javascript-DKmxrNeR.js +1 -0
  97. package/dist/web/assets/{journeyDiagram-JHISSGLW-6SDJs9C5.js → journeyDiagram-JHISSGLW-Btl3yxne.js} +1 -1
  98. package/dist/web/assets/{jsonMode-BGg9MhFR.js → jsonMode-DJPdvFcw.js} +1 -1
  99. package/dist/web/assets/{kanban-definition-UN3LZRKU-C0Y3zy1P.js → kanban-definition-UN3LZRKU-CDryhPbA.js} +1 -1
  100. package/dist/web/assets/{kbd-D4KIW7lm.js → kbd-8RRRm9jd.js} +1 -1
  101. package/dist/web/assets/{key-round-C4vhwqUu.js → key-round-wojrCrDP.js} +1 -1
  102. package/dist/web/assets/{layers-BBHgMnhN.js → layers-BH_LL4b8.js} +1 -1
  103. package/dist/web/assets/{linear-CjeIgBwO.js → linear-BLuwKHze.js} +1 -1
  104. package/dist/web/assets/{link-C-Jq7dnc.js → link-jWQOSQOQ.js} +1 -1
  105. package/dist/web/assets/{liquid-guocpCJB.js → liquid-1y-xg637.js} +1 -1
  106. package/dist/web/assets/{lspLanguageFeatures-CPXERxVW.js → lspLanguageFeatures-cYkILdCn.js} +1 -1
  107. package/dist/web/assets/{mdx-DA4ymd3l.js → mdx-CRg4Q6aP.js} +1 -1
  108. package/dist/web/assets/{menu-BgtmXAzT.js → menu-CMqbaDni.js} +1 -1
  109. package/dist/web/assets/{mermaid-NOHMQCX5-XQbfQDGS.js → mermaid-NOHMQCX5-CYeAhOl-.js} +4 -4
  110. package/dist/web/assets/{message-square-DIFv9yrO.js → message-square-DykJ2lWP.js} +1 -1
  111. package/dist/web/assets/{mindmap-definition-RKZ34NQL-6ucD61UV.js → mindmap-definition-RKZ34NQL-B5wtw1Rv.js} +1 -1
  112. package/dist/web/assets/{modal-Dx4N46s5.js → modal-BwOwTzij.js} +1 -1
  113. package/dist/web/assets/{monaco-Mn1xgio_.js → monaco-CcHqpOKe.js} +3 -3
  114. package/dist/web/assets/{nav-row-DwEkbw3N.js → nav-row-BmtdNLxR.js} +1 -1
  115. package/dist/web/assets/{paperclip-CdQvl5ee.js → paperclip-C4t49vX2.js} +1 -1
  116. package/dist/web/assets/{pencil-ChX7G9j9.js → pencil-BQ5_raiB.js} +1 -1
  117. package/dist/web/assets/{people-D_VwidfV.js → people-Dr0v8HK0.js} +1 -1
  118. package/dist/web/assets/{pieDiagram-4H26LBE5-KVvAyrIn.js → pieDiagram-4H26LBE5-BZ3VoaNI.js} +1 -1
  119. package/dist/web/assets/{popover-CGEFZKuu.js → popover-CTqvKqTR.js} +1 -1
  120. package/dist/web/assets/{python-BzNNRn8W.js → python-Huq_acyd.js} +1 -1
  121. package/dist/web/assets/{quadrantDiagram-W4KKPZXB-ClVzvpE7.js → quadrantDiagram-W4KKPZXB-C6ArHmnG.js} +1 -1
  122. package/dist/web/assets/{razor-DF2ZxqCE.js → razor-Clc87Ivb.js} +1 -1
  123. package/dist/web/assets/{requirementDiagram-4Y6WPE33-uXN6Uoln.js → requirementDiagram-4Y6WPE33-DiLzBRQP.js} +1 -1
  124. package/dist/web/assets/{sankeyDiagram-5OEKKPKP-Bi3Tc0wR.js → sankeyDiagram-5OEKKPKP-QlYYd7IZ.js} +1 -1
  125. package/dist/web/assets/{search--FRFbCre.js → search-CMIAPUEt.js} +1 -1
  126. package/dist/web/assets/{select-D0sHgfcU.js → select-Bg7NI8i0.js} +1 -1
  127. package/dist/web/assets/{select-c5IIpQj0.js → select-DqB7YF38.js} +1 -1
  128. package/dist/web/assets/{sequenceDiagram-3UESZ5HK-CLdrO2PY.js → sequenceDiagram-3UESZ5HK-COKEtqc0.js} +1 -1
  129. package/dist/web/assets/{server-Dr_6KJFM.js → server-D7knl8H9.js} +1 -1
  130. package/dist/web/assets/{stateDiagram-AJRCARHV-BGInldGc.js → stateDiagram-AJRCARHV-1RZZZdOe.js} +1 -1
  131. package/dist/web/assets/stateDiagram-v2-BHNVJYJU-CCLmVs34.js +1 -0
  132. package/dist/web/assets/{textarea-W-xQPto3.js → textarea-BCY2J2ca.js} +1 -1
  133. package/dist/web/assets/{timeline-definition-PNZ67QCA-BUp6Qykc.js → timeline-definition-PNZ67QCA-IJl1LY6J.js} +1 -1
  134. package/dist/web/assets/{toggles-Bgp7vdwg.js → toggles-C4LmZwyo.js} +1 -1
  135. package/dist/web/assets/{tooltip-DZcaSN1F.js → tooltip-Cirpotu3.js} +1 -1
  136. package/dist/web/assets/{track-Cj1Ogapu.js → track-Cv7h6oaE.js} +1 -1
  137. package/dist/web/assets/{trash-2-DmFXzIhh.js → trash-2-BEOQ1ICJ.js} +1 -1
  138. package/dist/web/assets/{tsMode-CSHMQttX.js → tsMode-CHIbCBQc.js} +1 -1
  139. package/dist/web/assets/{typescript-CyQKmnN-.js → typescript-CScj0bbb.js} +1 -1
  140. package/dist/web/assets/{upload-C-4QDrwN.js → upload-tLVD0xMT.js} +1 -1
  141. package/dist/web/assets/{use-profiles-D5mIgeQU.js → use-profiles-TkoP4Yw9.js} +1 -1
  142. package/dist/web/assets/{use-providers-BViTes-6.js → use-providers-Bz6YNiYj.js} +1 -1
  143. package/dist/web/assets/{use-translation-settings-Dgw0oKP1.js → use-translation-settings-CCpQNS30.js} +1 -1
  144. package/dist/web/assets/{useNormalizedLogs-BX7pMg0-.js → useNormalizedLogs-Bstb98cF.js} +1 -1
  145. package/dist/web/assets/{useTokenUsage-T03faPfn.js → useTokenUsage-D7SEwXb0.js} +1 -1
  146. package/dist/web/assets/{vennDiagram-CIIHVFJN-iQYnP9Ux.js → vennDiagram-CIIHVFJN-DzVayy4U.js} +1 -1
  147. package/dist/web/assets/{wardley-L42UT6IY-J7vXwA5J.js → wardley-L42UT6IY-CULSKh55.js} +1 -1
  148. package/dist/web/assets/{wardleyDiagram-YWT4CUSO-CdtM5GJv.js → wardleyDiagram-YWT4CUSO-C5_h3lAA.js} +1 -1
  149. package/dist/web/assets/{xml-C79KdvcD.js → xml-XuycSwh6.js} +1 -1
  150. package/dist/web/assets/{xychartDiagram-2RQKCTM6-B3gcBChQ.js → xychartDiagram-2RQKCTM6-F65naXcR.js} +1 -1
  151. package/dist/web/assets/{yaml-C1WLpuVe.js → yaml-BWm159lw.js} +1 -1
  152. package/dist/web/index.html +2 -2
  153. package/node_modules/@agent-tower/shared/dist/types.d.ts +12 -2
  154. package/node_modules/@agent-tower/shared/dist/types.d.ts.map +1 -1
  155. package/node_modules/@agent-tower/shared/dist/types.js.map +1 -1
  156. package/package.json +1 -1
  157. package/dist/web/assets/MobileTaskDetail-B68iYPOI.js +0 -3
  158. package/dist/web/assets/ProjectKanbanPage-CUX0Kh-t.js +0 -12
  159. package/dist/web/assets/TaskDetail-DBtWf0YV.js +0 -1
  160. package/dist/web/assets/channel-xU45IQlP.js +0 -1
  161. package/dist/web/assets/check-DUA2DjGH.js +0 -1
  162. package/dist/web/assets/classDiagram-4FO5ZUOK-pvRulc6s.js +0 -1
  163. package/dist/web/assets/classDiagram-v2-Q7XG4LA2-pvRulc6s.js +0 -1
  164. package/dist/web/assets/index-BDON669P.css +0 -1
  165. package/dist/web/assets/index-BRu1Yhrx.js +0 -122
  166. package/dist/web/assets/javascript-80FDzX3y.js +0 -1
  167. package/dist/web/assets/stateDiagram-v2-BHNVJYJU-D44x8SXb.js +0 -1
@@ -1,23 +1,23 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/monaco-Mn1xgio_.js","assets/index-BRu1Yhrx.js","assets/index-BDON669P.css","assets/monaco-Dvl_Svmm.css"])))=>i.map(i=>d[i]);
2
- import{o as De,r as A,cp as Tn,cq as An,c as pe,u as re,bw as Rn,bp as Ln,au as as,j as t,a5 as ce,aA as Mn,l as Q,aC as Is,n as Ct,p as oe,ai as Dn,cr as er,q as ie,m as Ee,cs as ot,af as be,ag as Le,ah as mt,J as Ze,ax as qt,B as ge,ct as Kr,cu as Pn,aY as Xr,cv as Bn,aw as On,X as tt,a3 as Fs,ay as In,cn as Hs,a2 as Je,cw as Yr,cx as Vr,aE as vt,a0 as zs,cy as Fn,_ as Gt,cz as Gr,ao as We,as as He,O as Hn,cA as zn,cB as Wn,cC as $n,ae as Tt,t as ke,aW as Qr,ab as _e,aB as xe,aU as _t,ac as yt,bB as Un,aj as Oe,aq as Qt,cD as kt,bF as qn,bc as Zr,s as ks,bl as Jr,bH as Kn,aD as Ye,a6 as Wt,bf as Xn,am as Yn,aX as ei,cE as ti,cF as si,cG as tr,cH as ri,cI as sr,ar as rr,a9 as Vn,b5 as ii,bz as Gn}from"./index-BRu1Yhrx.js";import{L as ni,m as Qn,t as Zn}from"./ProjectKanbanPage-CUX0Kh-t.js";import{P as pt,T as Jn}from"./trash-2-DmFXzIhh.js";import{e as Es,M as eo,f as oi,h as to,i as so,j as ro,k as io,l as ai,m as no,p as oo,o as ao,q as lo,Q as li,t as co,v as Dt,w as ho,x as uo,y as fo,T as mo,s as po}from"./mermaid-NOHMQCX5-XQbfQDGS.js";import{a as go,u as vo,A as _o,c as bo,p as ci,d as xo,e as So}from"./AttachmentPreview-BngGSahV.js";import{u as di}from"./use-translation-settings-Dgw0oKP1.js";import{u as Ws}from"./use-providers-BViTes-6.js";import{M as Ue}from"./MemberAvatar-CZ3F53Ep.js";import{C as Ke}from"./chevron-down-Bmwy-nvS.js";import{C as hi}from"./chevron-up-CClL6-SF.js";import{A as ir}from"./at-sign-CEsum1vJ.js";import{P as yo}from"./paperclip-CdQvl5ee.js";import{C as Et}from"./check-DUA2DjGH.js";import{F as wo}from"./tooltip-DZcaSN1F.js";import{u as Co,T as ko}from"./useTokenUsage-T03faPfn.js";import{a as Eo,I as $e}from"./BrandLogo-CBahjTd7.js";import{C as jo}from"./confirm-dialog-8ItnHBi0.js";import{M as At}from"./modal-Dx4N46s5.js";import{S as Xe}from"./select-c5IIpQj0.js";import{i as ui}from"./provider-selection-DSu7SCI7.js";import{L as js}from"./layers-BBHgMnhN.js";import{M as No}from"./message-square-DIFv9yrO.js";import{T as To}from"./textarea-W-xQPto3.js";import{r as Ao,P as Ro,a as fi,h as Lo,f as mi,k as pi,H as Kt,F as gi,l as Mo,C as vi,d as Do}from"./content-DrW8KnXu.js";import{M as _i,a as bi,b as xi,p as Po,d as Bo,e as Oo}from"./menu-BgtmXAzT.js";import{Z as Io,c as Fo,b as Ho,l as nr,m as zo}from"./CreateTaskInput-Cllw4abW.js";import{S as Ns}from"./server-Dr_6KJFM.js";import{F as $s,S as Wo,I as $o}from"./popover-CGEFZKuu.js";import{m as Si,f as Uo,n as qo,B as Ko,b as Xo,o as yi,p as wi,u as Ci,q as Yo,r as Vo,d as Go,l as Qo,c as Zo}from"./BranchSelect-BgVKUnxj.js";import{U as Us}from"./upload-C-4QDrwN.js";import{G as ki}from"./globe-BOfcTsvL.js";import{a as ht,l as Jo}from"./ExecutionPermissionSelector-Bsi1aa7q.js";import{S as ea}from"./select-D0sHgfcU.js";import{P as ta}from"./pencil-ChX7G9j9.js";function Ei(e,r){const s=De(r);return sa({filters:{...e,status:"pending"}},s).length}function or(e,r){return e.findAll(r.filters).map(s=>r.select?r.select(s):s.state)}function sa(e={},r){const s=De(r).getMutationCache(),l=A.useRef(e),g=A.useRef(null);return g.current===null&&(g.current=or(s,e)),A.useEffect(()=>{l.current=e}),A.useSyncExternalStore(A.useCallback(v=>s.subscribe(()=>{const w=Tn(g.current,or(s,l.current));g.current!==w&&(g.current=w,An.schedule(v))}),[s]),()=>g.current,()=>g.current)}const ra=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],ji=pe("arrow-right",ra);const ia=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ni=pe("ban",ia);const na=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],oa=pe("chevron-left",na);const aa=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],la=pe("circle",aa);const ca=[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]],da=pe("clipboard-paste",ca);const ha=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ve=pe("clock-3",ha);const ua=[["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"}]],ar=pe("copy-plus",ua);const fa=[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],ma=pe("earth",fa);const pa=[["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"}]],Ff=pe("ellipsis-vertical",pa);const ga=[["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"}]],Ts=pe("file-code-corner",ga);const va=[["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"}]],_a=pe("file-exclamation-point",va);const ba=[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v6",key:"158jrl"}],["circle",{cx:"5",cy:"18",r:"3",key:"104gr9"}],["path",{d:"M12 3v18",key:"108xh3"}],["circle",{cx:"19",cy:"6",r:"3",key:"108a5v"}],["path",{d:"M16 15.7A9 9 0 0 0 19 9",key:"1e3vqb"}]],qs=pe("git-graph",ba);const xa=[["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"}]],Sa=pe("maximize",xa);const ya=[["path",{d:"M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4",key:"re6nr2"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"pqwjuv"}]],wa=pe("notebook-pen",ya);const Ca=[["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"}]],ka=pe("panel-left-close",Ca);const Ea=[["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"}]],ja=pe("panel-left-open",Ea);const Na=[["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"}]],Ta=pe("panel-right-close",Na);const Aa=[["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"}]],As=pe("panel-right-open",Aa);const Ra=[["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"}]],La=pe("pen-line",Ra);const Ma=[["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"}]],Ti=pe("settings-2",Ma);const Da=[["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"}]],Pt=pe("user-plus",Da);const Pa=[["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"}]],Ba=pe("zoom-in",Pa);const Oa=[["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"}]],Ia=pe("zoom-out",Oa),Fa=32768;function Hf({task:e,onSelectTask:r,onCreateSubtask:s}){const{t:l}=re(),g=Rn(e.parentTaskId??""),v=Ln(e.id,as(e)),w=v.data?.pages[0]?.total??e.subtaskCount??0;return t.jsxs("section",{className:"flex h-full min-h-0 flex-col","aria-label":l("Subtasks"),children:[e.parentTaskId&&t.jsx("div",{className:"shrink-0 border-b border-border/60 px-3 py-2",children:t.jsxs(ce,{variant:"link",size:"sm",className:"max-w-full",onClick:()=>r?.(e.parentTaskId),children:[t.jsx(ni,{size:14,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:l("Parent task: {title}",{title:g.data?.titlePreview??g.data?.title??l("Loading...")})})]})}),t.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3 py-2",children:[t.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:l("{count} subtasks",{count:w})}),s&&as(e)&&!e.projectArchivedAt&&t.jsxs(ce,{variant:"ghost",size:"sm",onClick:()=>s(e.id),children:[t.jsx(pt,{size:14}),l("Create subtask")]})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-2 py-2",children:[!as(e)&&t.jsx("p",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:l("Tasks support at most three levels")}),v.isLoading&&t.jsx("p",{className:"px-2 py-1 text-xs text-muted-foreground",children:l("Loading...")}),v.isError&&t.jsx(ce,{variant:"ghost",size:"sm",onClick:()=>v.refetch(),children:l("Could not load subtasks. Retry")}),v.data?.pages.flatMap(i=>i.data).map(i=>{const o=Mn[Qn(i.status)];return t.jsxs(ce,{variant:"ghost",size:"sm",className:"w-full justify-start",title:i.title,onClick:()=>r?.(i.id),children:[t.jsx(o.icon,{className:Q("size-3.5 shrink-0",o.accentClass)}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:i.title}),t.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:l(o.label)})]},i.id)}),v.data&&w===0&&t.jsx("p",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:l("No subtasks yet")}),v.hasNextPage&&t.jsx(ce,{variant:"ghost",size:"sm",disabled:v.isFetchingNextPage,onClick:()=>v.fetchNextPage(),children:l("Load more")})]})]})}function Ai({taskId:e,teamRunId:r,enabled:s=!0,showDeliveries:l=!0}){const{t:g}=re(),v=De(),w=di(),i=Es(s?`task:${e}`:"","pending","TEAM_TASK"),o=Is({queryKey:["team-task-inputs",r],initialPageParam:void 0,queryFn:({pageParam:a})=>oe.get(`/team-runs/${r}/task-inputs${a?`?cursor=${encodeURIComponent(a)}`:""}`),getNextPageParam:a=>a.nextCursor??void 0,enabled:s&&!!r,refetchInterval:2e3}),u=Ct({mutationFn:({input:a,action:p})=>go(`task-input:${a.id}`,{action:p,expectedRevision:a.revision},m=>{const{clientSubmissionId:y,...b}=m;return oe.post(`/team-runs/${r}/task-inputs/${a.id}/actions`,{...b,actionId:y})}),onSettled:()=>{v.invalidateQueries({queryKey:["team-task-inputs",r]}),v.invalidateQueries({queryKey:["message-deliveries",`task:${e}`]})}}),f=Ct({mutationFn:a=>oe.get(`/team-runs/${r}/task-inputs/${a}`)});return s?t.jsxs("div",{className:"space-y-2 text-xs","aria-live":"polite",children:[l&&i.data?.pages.flatMap(a=>a.items).filter(a=>!["SENT","CANCELLED"].includes(a.state)).map(a=>t.jsx("div",{className:"flex justify-end","data-operation-id":a.id,children:t.jsxs("div",{className:"flex max-w-[85%] min-w-0 flex-col items-end",children:[a.origin==="TEAM_INITIAL"&&t.jsx("p",{className:"mb-1 px-0.5 text-xs text-muted-foreground",children:g("Team creation pending")}),t.jsxs("div",{className:"max-w-full rounded-2xl rounded-tr-sm bg-foreground/[0.08] px-5 py-3.5 text-sm",children:[t.jsx("p",{className:"whitespace-pre-wrap break-words",children:a.originalText}),t.jsx(eo,{delivery:a})]}),t.jsx("div",{className:"mt-1 max-w-full px-0.5","data-message-feedback":!0,children:t.jsx(oi,{delivery:a})})]})},a.id)),o.data?.pages.flatMap(a=>a.items).filter(a=>a.state==="PENDING"&&a.consumerCount>0).map(a=>t.jsxs("div",{className:"ml-auto max-w-[85%] space-y-1 px-0.5 text-muted-foreground",children:[t.jsxs("p",{children:[g("Task input"),": ",a.translationState??"PENDING"," ",a.errorCode??""]}),t.jsxs("div",{className:"flex flex-wrap gap-3",children:[t.jsx("button",{type:"button",className:"underline",disabled:f.isPending,onClick:()=>f.mutate(a.id),children:g("查看原文")}),t.jsx("button",{type:"button",className:"underline",disabled:u.isPending,onClick:()=>u.mutate({input:a,action:"send_original"}),children:g("Send original")}),w.data?.enabled===!0&&["FAILED","CANCELLED","QUEUE_FULL","PAUSED_DISABLED","INTERRUPTED"].includes(a.translationState??"")&&t.jsx("button",{type:"button",className:"underline",disabled:u.isPending,onClick:()=>u.mutate({input:a,action:"retry_translation"}),children:g("Retry translation")})]}),f.data?.id===a.id&&t.jsx("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap",children:f.data.originalText})]},a.id)),o.hasNextPage&&t.jsx("button",{type:"button",className:"underline",onClick:()=>{o.fetchNextPage()},children:g("Load more task inputs")}),i.hasNextPage&&t.jsx("button",{type:"button",className:"underline",onClick:()=>{i.fetchNextPage()},children:g("Load more")}),(u.error||f.error)&&t.jsx("p",{role:"alert",children:g("Delivery action failed. Refresh and try again.")}),(i.error||o.error)&&t.jsx("p",{role:"alert",children:g("Failed to restore pending messages")})]}):null}function zf({taskId:e}){const{t:r}=re(),s=De(),l=Dn(),[g,v]=A.useState(null);let w=!1,i=null;try{w=!!er(e)}catch(f){i=f.message}const o=i??g,u=async()=>{try{const f=er(e);f&&await l.mutateAsync({taskId:e,...f}),v(null),s.invalidateQueries({queryKey:["message-deliveries",`task:${e}`]})}catch(f){v(f.message)}};return t.jsxs("div",{className:"space-y-2 py-2","data-team-creation-status":!0,children:[w&&t.jsxs("div",{className:"rounded border p-2 text-xs",children:[t.jsx("p",{children:r("Team creation result unknown. Check the original request.")}),t.jsx("button",{type:"button",className:"underline",disabled:l.isPending,onClick:()=>{u()},children:r("Check team creation")})]}),o&&t.jsx("p",{role:"alert",className:"text-xs text-destructive",children:o}),t.jsx(Ai,{taskId:e,teamRunId:""})]})}function Ha(e){return`${e.mimeType.startsWith("image/")?"!":""}[${e.originalName}](${e.storagePath})`}function $t(e,r){if(r.length===0)return e;const s=new Set(r.map(Ha));return e.split(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/monaco-CcHqpOKe.js","assets/index-BszkzNS4.js","assets/index-408ws6FY.css","assets/monaco-Dvl_Svmm.css"])))=>i.map(i=>d[i]);
2
+ import{o as De,r as A,cp as Tn,cq as An,c as pe,u as re,bw as Rn,bp as Ln,au as as,j as t,a5 as ce,aA as Mn,l as Q,aC as Is,n as Ct,p as oe,ai as Dn,cr as er,q as ie,m as Ee,cs as ot,af as be,ag as Le,ah as mt,J as Ze,ax as qt,B as ge,ct as Kr,cu as Pn,aY as Xr,cv as Bn,aw as On,X as tt,a3 as Fs,ay as In,cn as Hs,a2 as Je,cw as Yr,cx as Vr,aE as vt,a0 as zs,cy as Fn,_ as Gt,cz as Gr,ao as We,as as He,O as Hn,cA as zn,cB as Wn,cC as $n,ae as Tt,t as ke,aW as Qr,ab as _e,aB as xe,aU as _t,ac as yt,bB as Un,aj as Oe,aq as Qt,cD as kt,bF as qn,bc as Zr,s as ks,bl as Jr,bH as Kn,aD as Ye,a6 as Wt,bf as Xn,am as Yn,aX as ei,cE as ti,cF as si,cG as tr,cH as ri,cI as sr,ar as rr,a9 as Vn,b5 as ii,bz as Gn}from"./index-BszkzNS4.js";import{L as ni,m as Qn,t as Zn}from"./ProjectKanbanPage-CuGSLvrU.js";import{P as pt,T as Jn}from"./trash-2-BEOQ1ICJ.js";import{e as Es,M as eo,f as oi,h as to,i as so,j as ro,k as io,l as ai,m as no,p as oo,o as ao,q as lo,Q as li,t as co,v as Dt,w as ho,x as uo,y as fo,T as mo,s as po}from"./mermaid-NOHMQCX5-CYeAhOl-.js";import{a as go,u as vo,A as _o,c as bo,p as ci,d as xo,e as So}from"./AttachmentPreview-TPd4gdfb.js";import{u as di}from"./use-translation-settings-CCpQNS30.js";import{u as Ws}from"./use-providers-Bz6YNiYj.js";import{M as Ue}from"./MemberAvatar-CJtylxwu.js";import{C as Ke}from"./chevron-down-Ct7FZbKm.js";import{C as hi}from"./chevron-up-ARFlXMyO.js";import{A as ir}from"./at-sign-Cf39WHCg.js";import{P as yo}from"./paperclip-C4t49vX2.js";import{C as Et}from"./check-yNWhPvMH.js";import{F as wo}from"./tooltip-Cirpotu3.js";import{u as Co,T as ko}from"./useTokenUsage-D7SEwXb0.js";import{a as Eo,I as $e}from"./BrandLogo-fR2lCwEo.js";import{C as jo}from"./confirm-dialog-CCjHVFTv.js";import{M as At}from"./modal-BwOwTzij.js";import{S as Xe}from"./select-DqB7YF38.js";import{i as ui}from"./provider-selection-DSu7SCI7.js";import{L as js}from"./layers-BH_LL4b8.js";import{M as No}from"./message-square-DykJ2lWP.js";import{T as To}from"./textarea-BCY2J2ca.js";import{r as Ao,P as Ro,a as fi,h as Lo,f as mi,k as pi,H as Kt,F as gi,l as Mo,C as vi,d as Do}from"./content-DZozZbBD.js";import{M as _i,a as bi,b as xi,p as Po,d as Bo,e as Oo}from"./menu-CMqbaDni.js";import{Z as Io,c as Fo,b as Ho,l as nr,m as zo}from"./CreateTaskInput-TcZpjBe-.js";import{S as Ns}from"./server-D7knl8H9.js";import{F as $s,S as Wo,I as $o}from"./popover-CTqvKqTR.js";import{m as Si,f as Uo,n as qo,B as Ko,b as Xo,o as yi,p as wi,u as Ci,q as Yo,r as Vo,d as Go,l as Qo,c as Zo}from"./BranchSelect-Kv3M1YhZ.js";import{U as Us}from"./upload-tLVD0xMT.js";import{G as ki}from"./globe-DAFqpAcW.js";import{a as ht,l as Jo}from"./ExecutionPermissionSelector-C-akTOVg.js";import{S as ea}from"./select-Bg7NI8i0.js";import{P as ta}from"./pencil-BQ5_raiB.js";function Ei(e,i){const s=De(i);return sa({filters:{...e,status:"pending"}},s).length}function or(e,i){return e.findAll(i.filters).map(s=>i.select?i.select(s):s.state)}function sa(e={},i){const s=De(i).getMutationCache(),l=A.useRef(e),g=A.useRef(null);return g.current===null&&(g.current=or(s,e)),A.useEffect(()=>{l.current=e}),A.useSyncExternalStore(A.useCallback(v=>s.subscribe(()=>{const w=Tn(g.current,or(s,l.current));g.current!==w&&(g.current=w,An.schedule(v))}),[s]),()=>g.current,()=>g.current)}const ra=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],ji=pe("arrow-right",ra);const ia=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ni=pe("ban",ia);const na=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],oa=pe("chevron-left",na);const aa=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],la=pe("circle",aa);const ca=[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]],da=pe("clipboard-paste",ca);const ha=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ve=pe("clock-3",ha);const ua=[["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"}]],ar=pe("copy-plus",ua);const fa=[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],ma=pe("earth",fa);const pa=[["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"}]],Ff=pe("ellipsis-vertical",pa);const ga=[["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"}]],Ts=pe("file-code-corner",ga);const va=[["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"}]],_a=pe("file-exclamation-point",va);const ba=[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v6",key:"158jrl"}],["circle",{cx:"5",cy:"18",r:"3",key:"104gr9"}],["path",{d:"M12 3v18",key:"108xh3"}],["circle",{cx:"19",cy:"6",r:"3",key:"108a5v"}],["path",{d:"M16 15.7A9 9 0 0 0 19 9",key:"1e3vqb"}]],qs=pe("git-graph",ba);const xa=[["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"}]],Sa=pe("maximize",xa);const ya=[["path",{d:"M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4",key:"re6nr2"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"pqwjuv"}]],wa=pe("notebook-pen",ya);const Ca=[["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"}]],ka=pe("panel-left-close",Ca);const Ea=[["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"}]],ja=pe("panel-left-open",Ea);const Na=[["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"}]],Ta=pe("panel-right-close",Na);const Aa=[["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"}]],As=pe("panel-right-open",Aa);const Ra=[["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"}]],La=pe("pen-line",Ra);const Ma=[["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"}]],Ti=pe("settings-2",Ma);const Da=[["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"}]],Pt=pe("user-plus",Da);const Pa=[["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"}]],Ba=pe("zoom-in",Pa);const Oa=[["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"}]],Ia=pe("zoom-out",Oa),Fa=32768;function Hf({task:e,onSelectTask:i,onCreateSubtask:s}){const{t:l}=re(),g=Rn(e.parentTaskId??""),v=Ln(e.id,as(e)),w=v.data?.pages[0]?.total??e.subtaskCount??0;return t.jsxs("section",{className:"flex h-full min-h-0 flex-col","aria-label":l("Subtasks"),children:[e.parentTaskId&&t.jsx("div",{className:"shrink-0 border-b border-border/60 px-3 py-2",children:t.jsxs(ce,{variant:"link",size:"sm",className:"max-w-full",onClick:()=>i?.(e.parentTaskId),children:[t.jsx(ni,{size:14,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:l("Parent task: {title}",{title:g.data?.titlePreview??g.data?.title??l("Loading...")})})]})}),t.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3 py-2",children:[t.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:l("{count} subtasks",{count:w})}),s&&as(e)&&!e.projectArchivedAt&&t.jsxs(ce,{variant:"ghost",size:"sm",onClick:()=>s(e.id),children:[t.jsx(pt,{size:14}),l("Create subtask")]})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-2 py-2",children:[!as(e)&&t.jsx("p",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:l("Tasks support at most three levels")}),v.isLoading&&t.jsx("p",{className:"px-2 py-1 text-xs text-muted-foreground",children:l("Loading...")}),v.isError&&t.jsx(ce,{variant:"ghost",size:"sm",onClick:()=>v.refetch(),children:l("Could not load subtasks. Retry")}),v.data?.pages.flatMap(r=>r.data).map(r=>{const o=Mn[Qn(r.displayStatus??r.status)];return t.jsxs(ce,{variant:"ghost",size:"sm",className:"w-full justify-start",title:r.title,onClick:()=>i?.(r.id),children:[t.jsx(o.icon,{className:Q("size-3.5 shrink-0",o.accentClass)}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:r.title}),t.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:l(o.label)})]},r.id)}),v.data&&w===0&&t.jsx("p",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:l("No subtasks yet")}),v.hasNextPage&&t.jsx(ce,{variant:"ghost",size:"sm",disabled:v.isFetchingNextPage,onClick:()=>v.fetchNextPage(),children:l("Load more")})]})]})}function Ai({taskId:e,teamRunId:i,enabled:s=!0,showDeliveries:l=!0}){const{t:g}=re(),v=De(),w=di(),r=Es(s?`task:${e}`:"","pending","TEAM_TASK"),o=Is({queryKey:["team-task-inputs",i],initialPageParam:void 0,queryFn:({pageParam:a})=>oe.get(`/team-runs/${i}/task-inputs${a?`?cursor=${encodeURIComponent(a)}`:""}`),getNextPageParam:a=>a.nextCursor??void 0,enabled:s&&!!i,refetchInterval:2e3}),u=Ct({mutationFn:({input:a,action:p})=>go(`task-input:${a.id}`,{action:p,expectedRevision:a.revision},m=>{const{clientSubmissionId:y,...b}=m;return oe.post(`/team-runs/${i}/task-inputs/${a.id}/actions`,{...b,actionId:y})}),onSettled:()=>{v.invalidateQueries({queryKey:["team-task-inputs",i]}),v.invalidateQueries({queryKey:["message-deliveries",`task:${e}`]})}}),f=Ct({mutationFn:a=>oe.get(`/team-runs/${i}/task-inputs/${a}`)});return s?t.jsxs("div",{className:"space-y-2 text-xs","aria-live":"polite",children:[l&&r.data?.pages.flatMap(a=>a.items).filter(a=>!["SENT","CANCELLED"].includes(a.state)).map(a=>t.jsx("div",{className:"flex justify-end","data-operation-id":a.id,children:t.jsxs("div",{className:"flex max-w-[85%] min-w-0 flex-col items-end",children:[a.origin==="TEAM_INITIAL"&&t.jsx("p",{className:"mb-1 px-0.5 text-xs text-muted-foreground",children:g("Team creation pending")}),t.jsxs("div",{className:"max-w-full rounded-2xl rounded-tr-sm bg-foreground/[0.08] px-5 py-3.5 text-sm",children:[t.jsx("p",{className:"whitespace-pre-wrap break-words",children:a.originalText}),t.jsx(eo,{delivery:a})]}),t.jsx("div",{className:"mt-1 max-w-full px-0.5","data-message-feedback":!0,children:t.jsx(oi,{delivery:a})})]})},a.id)),o.data?.pages.flatMap(a=>a.items).filter(a=>a.state==="PENDING"&&a.consumerCount>0).map(a=>t.jsxs("div",{className:"ml-auto max-w-[85%] space-y-1 px-0.5 text-muted-foreground",children:[t.jsxs("p",{children:[g("Task input"),": ",a.translationState??"PENDING"," ",a.errorCode??""]}),t.jsxs("div",{className:"flex flex-wrap gap-3",children:[t.jsx("button",{type:"button",className:"underline",disabled:f.isPending,onClick:()=>f.mutate(a.id),children:g("查看原文")}),t.jsx("button",{type:"button",className:"underline",disabled:u.isPending,onClick:()=>u.mutate({input:a,action:"send_original"}),children:g("Send original")}),w.data?.enabled===!0&&["FAILED","CANCELLED","QUEUE_FULL","PAUSED_DISABLED","INTERRUPTED"].includes(a.translationState??"")&&t.jsx("button",{type:"button",className:"underline",disabled:u.isPending,onClick:()=>u.mutate({input:a,action:"retry_translation"}),children:g("Retry translation")})]}),f.data?.id===a.id&&t.jsx("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap",children:f.data.originalText})]},a.id)),o.hasNextPage&&t.jsx("button",{type:"button",className:"underline",onClick:()=>{o.fetchNextPage()},children:g("Load more task inputs")}),r.hasNextPage&&t.jsx("button",{type:"button",className:"underline",onClick:()=>{r.fetchNextPage()},children:g("Load more")}),(u.error||f.error)&&t.jsx("p",{role:"alert",children:g("Delivery action failed. Refresh and try again.")}),(r.error||o.error)&&t.jsx("p",{role:"alert",children:g("Failed to restore pending messages")})]}):null}function zf({taskId:e}){const{t:i}=re(),s=De(),l=Dn(),[g,v]=A.useState(null);let w=!1,r=null;try{w=!!er(e)}catch(f){r=f.message}const o=r??g,u=async()=>{try{const f=er(e);f&&await l.mutateAsync({taskId:e,...f}),v(null),s.invalidateQueries({queryKey:["message-deliveries",`task:${e}`]})}catch(f){v(f.message)}};return t.jsxs("div",{className:"space-y-2 py-2","data-team-creation-status":!0,children:[w&&t.jsxs("div",{className:"rounded border p-2 text-xs",children:[t.jsx("p",{children:i("Team creation result unknown. Check the original request.")}),t.jsx("button",{type:"button",className:"underline",disabled:l.isPending,onClick:()=>{u()},children:i("Check team creation")})]}),o&&t.jsx("p",{role:"alert",className:"text-xs text-destructive",children:o}),t.jsx(Ai,{taskId:e,teamRunId:""})]})}function Ha(e){return`${e.mimeType.startsWith("image/")?"!":""}[${e.originalName}](${e.storagePath})`}function $t(e,i){if(i.length===0)return e;const s=new Set(i.map(Ha));return e.split(`
3
3
  `).map(l=>{const g=l.match(/^\s*/)?.[0]??"",v=l.trimStart();for(const w of s){if(v===w)return null;if(v.startsWith(`${w} `)||v.startsWith(`${w} `))return`${g}${v.slice(w.length).trimStart()}`}return l}).filter(l=>l!=null).join(`
4
4
  `).replace(/\n{3,}/g,`
5
5
 
6
- `).trim()}function za({draft:e,attachmentMarkdown:r,attachmentIds:s,mentions:l}){const v=[e.trim(),r].filter(Boolean).join(`
6
+ `).trim()}function za({draft:e,attachmentMarkdown:i,attachmentIds:s,mentions:l}){const v=[e.trim(),i].filter(Boolean).join(`
7
7
 
8
- `);return v?{content:v,mentions:l,senderType:"user",...s.length>0?{attachmentIds:s}:{}}:null}function Wa({items:e,renderItem:r,scrollElementRef:s,compact:l}){const[g,v]=A.useState(null),[w,i]=A.useState(0),[o,u]=A.useState(!1),f=A.useCallback(m=>{if(!m)return;const y=s.current??m.closest("[data-room-scroll]");v(y),i(y?.clientHeight??0),u(!0)},[s]);A.useEffect(()=>{if(!g)return;const m=()=>i(g.clientHeight);if(m(),typeof ResizeObserver>"u")return;const y=new ResizeObserver(m);return y.observe(g),()=>y.disconnect()},[g]);const a=l?12:16,p=to({count:e.length,getScrollElement:()=>g,getItemKey:A.useCallback(m=>e[m].key,[e]),estimateSize:()=>160,overscan:6,scrollMargin:a,measureElement:m=>m.getBoundingClientRect().height});return p.shouldAdjustScrollPositionOnItemSizeChange=so,o?t.jsx("div",{ref:f,children:w>0?t.jsx("div",{style:{position:"relative",height:p.getTotalSize(),width:"100%"},children:p.getVirtualItems().map(m=>t.jsx("div",{"data-index":m.index,"data-room-row":m.key,ref:p.measureElement,style:{position:"absolute",top:m.start-a,left:0,width:"100%",paddingBottom:l?10:12},children:r(e[m.index])},m.key))},"virtual"):t.jsx("div",{className:l?"space-y-2.5":"space-y-3",children:e.slice(-20).map(m=>t.jsx("div",{"data-room-row":m.key,children:r(m)},m.key))},"unmeasured")}):t.jsx("div",{ref:f})}const ze=new WeakMap,lt=()=>new DOMException("Aborted","AbortError"),ls=e=>e instanceof Ze&&[401,403,404].includes(e.status);function $a(e,r,s){let l=ze.get(e);l||(l=new Map,ze.set(e,l));let g=l.get(r);if(g)g.owners.add(s),s.permission(g.denied);else{const v=new Set;let w=0,i=!1;const o=()=>{g.epoch++,!i&&(i=!0,queueMicrotask(()=>{if(i=!1,l.get(r)===g)for(const p of v)p.refresh()}))},u=()=>{const p=++w;e.emit(mt.SUBSCRIBE,{topic:"team-run",id:r},m=>{if(!(p!==w||l.get(r)!==g)){g.denied=!m.success;for(const y of v)y.permission(!m.success);o()}}),o()},f=p=>{p.teamRunId===r&&o()},a=p=>{if(p==="io server disconnect"){w++,g.denied=!0,g.epoch++;for(const m of v)m.permission(!0)}};g={owners:v,epoch:0,itemGenerations:new Map,denied:!1,dispose:()=>{w++,e.off("connect",u),e.off("disconnect",a),e.off(Le.TRANSLATION_INVALIDATED,f),e.emit(mt.UNSUBSCRIBE,{topic:"team-run",id:r})}},l.set(r,g),e.on("connect",u),e.on("disconnect",a),e.on(Le.TRANSLATION_INVALIDATED,f),v.add(s),e.connected&&u()}return()=>{g.owners.delete(s),g.owners.size||(g.dispose(),l.delete(r))}}function Bt(e,r){return ze.get(e)?.get(r)?.epoch??0}function ut(e,r,s){return ze.get(e)?.get(r)?.itemGenerations.get(s)??0}function Ua(e,r){const s=new Map(e?.map(l=>[l.sourceId,l]));return r.map(l=>{const g=s.get(l.sourceId);return g&&(g.sourceRevision>l.sourceRevision||g.sourceRevision===l.sourceRevision&&g.overlayRevision>l.overlayRevision)?g:l})}async function qa(e,r,s){const l=[];for(let g=0;g<r.length;g+=100){if(s.aborted)throw lt();const v=await oe.get(`/team-runs/${encodeURIComponent(e)}/translations`,{signal:s,params:{messageIds:r.slice(g,g+100).join(",")}});l.push(...v.items)}return l}function Ka(e,r){const s=De(),l=Ei({mutationKey:ie.accessAuth.identityChange})>0,g=ot(),[v,w]=A.useState(!1),[,i]=A.useState(0),o=A.useMemo(()=>r.filter(C=>C.teamRunId===e&&C.senderType==="agent"&&C.visibility==="PUBLIC"&&!C.id.startsWith("pending-")),[r,e]),u=A.useMemo(()=>[...new Set(o.map(C=>C.id))].sort(),[o]),f=A.useMemo(()=>o.map(C=>[C.id,C.content,C.contentPreview,C.isTruncated,C.senderId,C.senderInvocationId]),[o]),a=A.useMemo(()=>({teamRunId:e,accessGeneration:g,active:!0,allowed:!1,generation:0,summaries:new Map}),[e,g]),p=A.useRef(new Set(u)),m=A.useRef(new Set(u));p.current=new Set(u);const y=()=>{s.cancelQueries({queryKey:ie.roomTranslations.scope(e)}),s.removeQueries({queryKey:ie.roomTranslations.scope(e)})},b=()=>{if(g!==ot())return;const C=ze.get(be.getSocket())?.get(e);if(C){C.denied=!0;for(const T of C.owners)T.permission(!0)}else a.allowed=!1,a.generation++,w(!0);y()},n=Ee({queryKey:[...ie.roomTranslations.summaries(e),g,u,f],enabled:u.length>0&&!v&&!l,queryFn:async({signal:C})=>{const T=be.getSocket();try{for(let L=0;L<3;L++){const R=Bt(T,e),M=Object.fromEntries(u.map(B=>[B,ut(T,e,B)])),I=await qa(e,u,C);if(C.aborted||ze.get(T)?.get(e)?.denied||g!==ot())throw lt();if(R===Bt(T,e)&&u.every(B=>M[B]===ut(T,e,B)))return{items:I.filter(B=>B.teamRunId===e&&u.includes(B.messageId)),generations:M}}throw new Error("Translation snapshot changed while reading")}catch(L){throw ls(L)&&b(),L}},structuralSharing:(C,T)=>{const L=C,R=T;return{...R,items:Ua(L?.items.filter(M=>L.generations[M.messageId]===R.generations[M.messageId]),R.items)}},refetchOnMount:"always",refetchOnWindowFocus:!0,refetchInterval:5e3,retry:!1,gcTime:0});a.allowed=!v&&!l&&!n.isError&&n.isFetchedAfterMount&&g===ot();const d=n.data?.generations,c=A.useMemo(()=>a.allowed?n.data?.items??[]:[],[a.allowed,n.data]);a.summaries=new Map(c.filter(C=>p.current.has(C.messageId)&&d?.[C.messageId]===ut(be.getSocket(),e,C.messageId)).map(C=>[C.messageId,C])),A.useEffect(()=>{a.active=!0;const C=be.connect(),T=$a(C,e,{client:s,candidates:()=>p.current,withdraw:L=>{a.summaries.delete(L),i(R=>R+1)},refresh:()=>{s.invalidateQueries({queryKey:ie.roomTranslations.scope(e)},{cancelRefetch:!1})},permission:L=>{L&&(a.allowed=!1,a.generation++,a.summaries.clear(),y()),w(L)}});return()=>{a.active=!1,a.allowed=!1,a.generation++,T(),ze.get(C)?.has(e)||y()}},[s,e,a]),A.useLayoutEffect(()=>{const C=ze.get(be.getSocket())?.get(e),T=[...m.current].filter(L=>!p.current.has(L)&&![...C?.owners??[]].some(R=>R.candidates().has(L)));m.current=new Set(u);for(const L of T){const R=[...ie.roomTranslations.details(e),L];s.cancelQueries({queryKey:R}),s.removeQueries({queryKey:R})}},[s,e,u]),A.useEffect(()=>{if(!n.isSuccess||!n.isFetchedAfterMount)return;const C=new Set(c.map(L=>L.messageId)),T=s.getQueryCache().findAll({queryKey:ie.roomTranslations.details(e)}).filter(L=>u.includes(L.queryKey[3])&&!C.has(L.queryKey[3]));for(const L of T)s.cancelQueries({queryKey:L.queryKey,exact:!0}),s.removeQueries({queryKey:L.queryKey,exact:!0})},[s,e,c,u,n.isSuccess,n.isFetchedAfterMount]);const h=C=>{const T=a.summaries.get(C.messageId);return a.active&&a.allowed&&g===ot()&&p.current.has(C.messageId)&&d?.[C.messageId]===ut(be.getSocket(),e,C.messageId)&&T?.sourceId===C.sourceId&&T.sourceRevision===C.sourceRevision&&T.overlayRevision===C.overlayRevision},_=async C=>{if(!h(C))throw lt();const T=a.generation,L=ut(be.getSocket(),e,C.messageId),R=await s.fetchQuery({queryKey:ie.roomTranslations.full(e,C.messageId,C.sourceId,C.sourceRevision,C.overlayRevision),staleTime:0,gcTime:0,retry:!1,queryFn:async({signal:M})=>{try{for(let I=0;I<3;I++){const B=Bt(be.getSocket(),e),H=await oe.get(`/team-runs/${encodeURIComponent(e)}/messages/${encodeURIComponent(C.messageId)}/translation`,{signal:M}),$=ze.get(be.getSocket())?.get(e);if(M.aborted||g!==ot()||!$||$.denied||L!==ut(be.getSocket(),e,C.messageId)||![...$.owners].some(N=>N.candidates().has(C.messageId))||H.teamRunId!==e||H.messageId!==C.messageId||H.sourceId!==C.sourceId||H.sourceRevision!==C.sourceRevision)throw lt();if(H.overlayRevision>=C.overlayRevision&&B===Bt(be.getSocket(),e))return H}throw new Error("Translation detail changed while reading")}catch(I){throw I instanceof Ze&&I.status===404?S(C):ls(I)&&b(),I}}});if(T!==a.generation||!h(C))throw lt();return R},S=C=>{if(g!==ot())return;const T=ze.get(be.getSocket())?.get(e);if(T){T.itemGenerations.set(C.messageId,(T.itemGenerations.get(C.messageId)??0)+1);for(const L of T.owners)L.withdraw(C.messageId);for(const L of new Set([s,...[...T.owners].map(R=>R.client)])){const R=[...ie.roomTranslations.details(e),C.messageId];L.cancelQueries({queryKey:R}),L.removeQueries({queryKey:R});const M=ie.roomTranslations.summaries(e);L.cancelQueries({queryKey:M}),L.setQueriesData({queryKey:M},I=>I&&{...I,items:I.items.filter(B=>B.messageId!==C.messageId)}),L.invalidateQueries({queryKey:M},{cancelRefetch:!1})}}},k=async C=>{if(!h(C))throw lt();try{await oe.post(`/team-runs/${encodeURIComponent(e)}/translations/${encodeURIComponent(C.sourceId)}/retry`,{expectedRevision:C.sourceRevision})}catch(T){throw T instanceof Ze&&T.status===404?S(C):ls(T)&&b(),T}finally{s.invalidateQueries({queryKey:ie.roomTranslations.summaries(e)},{cancelRefetch:!1})}},E=[...a.summaries.values()],x=ro(`${e}:${g}`,o.map(C=>({id:C.id,revision:0})),E.map(C=>({id:C.messageId,version:`${C.sourceId}:${C.sourceRevision}`,state:C.state})),r.length>0);return{overlays:E,loadFull:_,isCurrent:h,retry:k,claimReveal:x}}const Xa=10,Ya=24,Ri=Xa*Ya,Va=8;function Ga(e,r=Ri){return e>r+Va}function Qa(e,r){return e.includes(r)?e:[...e,r]}function Za(e,r){return e.filter(s=>s!==r)}function Ja(e,r){const s=new Map(r.map(l=>[l.id,l]));return e.map(l=>s.get(l)).filter(l=>!!l).map(l=>({memberId:l.id,label:l.name}))}const Zt=new Set(["RUNNING","WAITING_ROOM_REPLY","QUEUED","SESSION_ENDED"]);function lr(e){if(!e)return 0;const r=Date.parse(e);return Number.isNaN(r)?0:r}function el(e,r=[],s=[]){const l=new Set(s.filter(v=>Zt.has(v.status)).map(v=>v.workRequestId));return[...e.map(v=>({kind:"message",key:`message:${v.id}`,sortTime:v.createdAt,order:0,message:v})),...r.filter(v=>v.status==="PENDING_APPROVAL").filter(v=>!l.has(v.id)).map(v=>({kind:"pendingApproval",key:`pending-approval:${v.id}`,sortTime:v.updatedAt??v.createdAt,order:1,request:v}))].sort((v,w)=>{const i=lr(v.sortTime)-lr(w.sortTime);return i!==0?i:v.order!==w.order?v.order-w.order:v.key.localeCompare(w.key)})}function tl(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 sl(e){switch(e){case"FAILED":return"text-destructive-ink";case"RUNNING":case"WAITING_ROOM_REPLY":case"QUEUED":case"SESSION_ENDED":return"text-muted-foreground";default:return"text-muted-foreground"}}function rl(e,r){const s=e.reduce((g,v)=>(g[v.status]=(g[v.status]??0)+1,g),{});return[["RUNNING","running"],["QUEUED","queued"],["WAITING_ROOM_REPLY","waiting"],["SESSION_ENDED","ended"]].map(([g,v])=>{const w=s[g];return w?`${w} ${r(v)}`:null}).filter(g=>!!g).join(" · ")}function il(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(min-width: 768px)").matches}function nl({status:e}){const{t:r}=re();return e==="RUNNING"?t.jsxs(t.Fragment,{children:[r("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:r(tl(e))})}function ol({invocations:e,memberById:r,workRequestById:s,onViewInvocationSession:l,onStopMember:g,isStopPending:v,stoppingMemberId:w,stopPromptInvocationId:i,onToggleStopConfirm:o}){const{t:u}=re(),[f,a]=A.useState(il),p=A.useMemo(()=>e.filter(y=>Zt.has(y.status)).sort((y,b)=>Date.parse(b.updatedAt??b.createdAt??"")-Date.parse(y.updatedAt??y.createdAt??"")),[e]);if(p.length===0)return null;const m=rl(p,u);return t.jsxs("div",{className:"border-t border-border bg-muted/40",children:[t.jsxs("button",{type:"button",onClick:()=>a(y=>!y),"aria-expanded":f,className:"flex h-8 w-full items-center justify-between gap-3 px-3 text-left text-xs text-foreground/70 transition-colors hover:bg-accent",children:[t.jsxs("span",{className:"min-w-0 truncate",children:[t.jsx("span",{className:"font-medium text-foreground",children:u("Active work")}),t.jsx("span",{className:"mx-1.5 text-muted-foreground",children:"·"}),t.jsx("span",{children:m})]}),f?t.jsx(Ke,{size:15,className:"shrink-0 text-muted-foreground/70"}):t.jsx(hi,{size:15,className:"shrink-0 text-muted-foreground/70"})]}),f&&t.jsx("div",{className:"max-h-32 overflow-y-auto border-t border-border",children:p.map(y=>{const b=r.get(y.memberId),n=s.get(y.workRequestId),d=!!(y.sessionId&&l),c=!!b,h=i===y.id,_=v&&w===y.memberId,S=n?.instruction??y.workRequestId;return t.jsxs("div",{className:"border-t border-border/60 first:border-t-0",children:[t.jsxs("div",{title:S,className:Q("group flex h-8 items-center gap-2 px-3 text-xs text-foreground/80",d?"cursor-pointer hover:bg-background":"cursor-default"),role:d?"button":void 0,tabIndex:d?0:void 0,onClick:()=>y.sessionId&&l?.(y.sessionId),onKeyDown:k=>{!d||!y.sessionId||(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),l?.(y.sessionId))},children:[t.jsx(Ue,{name:b?.name??u("Agent"),avatar:b?.avatar??null,size:"xs",className:"size-4"}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[t.jsx("span",{className:"truncate font-medium text-foreground",children:b?.name??u("Agent")}),t.jsx("span",{className:Q("shrink-0",sl(y.status)),children:t.jsx(nl,{status:y.status})})]}),d&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),y.sessionId&&l?.(y.sessionId)},onKeyDown:k=>k.stopPropagation(),className:"hidden shrink-0 rounded-md p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground/80 group-hover:inline-flex",title:u("View log"),"aria-label":`${u("View log")} ${b?.name??u("Agent")}`,children:t.jsx(As,{size:13})}),c&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),o(y.id)},onKeyDown:k=>k.stopPropagation(),disabled:_,className:"shrink-0 rounded-md p-1 text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive-ink disabled:cursor-not-allowed disabled:opacity-50",title:u("Stop"),"aria-label":`${u("Stop")} ${b?.name??u("Agent")}`,children:t.jsx(qt,{size:12})})]}),c&&h&&b&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 border-t border-border/60 bg-background px-3 py-2",children:[t.jsx("span",{className:"mr-1 text-xs text-foreground/70",children:u("Stop running work?")}),t.jsxs(ge,{type:"button",size:"xs",variant:"outline",disabled:_,onClick:()=>g(b.id,!1),children:[t.jsx(qt,{size:11}),t.jsx("span",{children:u(_?"Stopping":"Stop only")})]}),t.jsxs(ge,{type:"button",size:"xs",variant:"outline",disabled:_,className:"border-destructive/25 bg-destructive/10 text-destructive-ink hover:bg-destructive/15 hover:text-destructive-ink",onClick:()=>g(b.id,!0),children:[t.jsx(Ni,{size:11}),t.jsx("span",{children:u(_?"Stopping":"Stop + clear queue")})]})]})]},y.id)})})]})}const Rs=zs(),al=240;function cs(e,r){return{id:r.clientSubmissionId??Xr(),submissionInput:r,teamRunId:e,senderType:r.senderType??"user",senderId:r.senderId??null,senderInvocationId:r.senderInvocationId??null,kind:r.kind??((r.mentions?.length??0)>0?"work_request":"chat"),visibility:"PUBLIC",content:r.content,mentions:r.mentions??[],workRequestIds:[],artifactRefs:r.artifactRefs??[],attachmentIds:r.attachmentIds??[],createdAt:new Date().toISOString(),pendingStatus:"sending"}}function Xt(e){return"pendingStatus"in e}function ll(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function cl(e){if(!e)return"";const r=new Date(e);return Number.isNaN(r.getTime())?"":r.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Ks(e,r){return e instanceof Error?e.message:r}function dl(e,r=al){const s=(e??"").replace(/\s+/g," ").trim();return s.length<=r?s:`${s.slice(0,r-3).trimEnd()}...`}function hl(e,r){const l=e.slice(0,r).match(/(^|\s)@([^\s@]*)$/);return!l||l.index==null?null:{start:l.index+l[1].length,end:r,query:l[2]??""}}function ul(e,r){const s=r.trim().toLowerCase();return s?[e.name,e.providerId,...e.aliases??[]].some(g=>g.toLowerCase().includes(s)):!0}function cr(e){return e.membershipStatus!=="REMOVED"}function fl(e,r){return e.label??r.get(e.memberId)?.name??e.memberId}function ml(e,r){return(e.recipientMemberIds??[]).map(s=>r.get(s)?.name??s)}function pl(e,r){const s=e.mentions??[],l=e.contentPreview??e.content;if(s.length===0)return l;const g=s.map(w=>fl(w,r)).filter(w=>w&&!l.includes(`@${w}`));if(g.length===0)return l;const v=g.map(w=>`@${w}`).join(" ");return l.trimEnd()?`${l.trimEnd()} ${v}`:v}function gl(e,r,s){if(e.senderType!=="agent")return null;if(e.senderId&&r.has(e.senderId))return r.get(e.senderId)??null;if(e.senderInvocationId){const l=s.get(e.senderInvocationId);if(l?.memberId&&r.has(l.memberId))return r.get(l.memberId)??null}return null}function Li({content:e,workingDir:r,onOpenWorkspaceFile:s,onOpenPreviewUrl:l,onOpenVisualization:g,downloadSessionId:v}){const w=A.useMemo(()=>g||v?oo(e):e,[e,v,g]),i=ao(w),o=A.useMemo(()=>lo({workingDir:r,onOpenWorkspaceFile:s,onOpenPreviewUrl:l,onOpenVisualization:g,downloadSessionId:v}),[v,l,g,s,r]);return t.jsx("div",{className:Q("team-room-message-markdown prose prose-sm max-w-none break-words [overflow-wrap:anywhere]","prose-p:my-2 prose-p:first:mt-0 prose-p:last:mb-0 prose-p:leading-6","prose-ul:my-2 prose-ol:my-2 prose-li:my-1 prose-li:pl-0 prose-li:leading-6 prose-li:marker:text-muted-foreground","prose-blockquote:my-2 prose-blockquote:border-l-2 prose-blockquote:border-border prose-blockquote:pl-3 prose-blockquote:text-foreground/70","prose-pre:my-3 prose-pre:max-w-full prose-pre:overflow-x-auto prose-pre:rounded-md prose-pre:border prose-pre:border-border/60 prose-pre:bg-foreground/[0.025] prose-pre:p-3 prose-pre:text-xs prose-pre:leading-relaxed","prose-code:break-words prose-code:rounded prose-code:bg-muted prose-code:px-1 prose-code:py-0.5 prose-code:text-[0.9em] prose-code:font-medium prose-code:text-foreground","prose-pre:prose-code:bg-transparent prose-pre:prose-code:p-0 prose-pre:prose-code:text-foreground","prose-headings:mb-2 prose-headings:mt-3 prose-headings:font-semibold prose-headings:leading-snug","prose-hr:my-3 prose-hr:border-border","text-foreground prose-strong:text-foreground"),children:t.jsx(li,{components:o,plugins:i,controls:i?co:void 0,children:w})})}function vl({hasAttachmentIds:e,attachments:r,isLoading:s,onOpenImage:l}){if(!e)return null;if(s&&r.length===0)return t.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"Loading attachments..."});if(r.length===0)return null;const g=r.filter(w=>w.mimeType.startsWith("image/")),v=new Map(g.map((w,i)=>[w.id,i]));return t.jsx("div",{className:"mt-3 flex flex-wrap gap-2 text-foreground/80",children:r.map(w=>{const i=`${Rs}${w.url}`;if(w.mimeType.startsWith("image/")){const u=v.get(w.id)??0;return t.jsxs("button",{type:"button",onClick:()=>l(g,u),className:"group relative h-24 w-24 overflow-hidden rounded-lg border border-border bg-muted/50 shadow-raised transition-opacity hover:opacity-90",title:w.originalName,children:[t.jsx("img",{src:i,alt:w.originalName,className:"h-full w-full object-cover",loading:"lazy"}),t.jsx("span",{className:"absolute inset-x-0 bottom-0 truncate bg-inverse/60 px-1.5 py-1 text-left text-[11px] text-inverse-foreground",children:w.originalName})]},w.id)}return t.jsxs("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"flex max-w-[220px] items-center gap-2 rounded-lg border border-border bg-background px-3 py-2 text-xs text-foreground/80 shadow-raised hover:bg-accent",title:w.originalName,children:[t.jsx(wo,{size:16,className:"shrink-0 text-muted-foreground/70","aria-hidden":!0}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate font-medium",children:w.originalName}),t.jsx("span",{className:"text-muted-foreground",children:ll(w.sizeBytes)})]}),t.jsx(Hs,{size:13,className:"shrink-0 text-muted-foreground/70","aria-hidden":!0})]},w.id)})})}function Mi({message:e,content:r,attachmentIds:s,isUser:l,tone:g,onOpenImage:v,workingDir:w,onOpenWorkspaceFile:i,onOpenPreviewUrl:o,onOpenVisualization:u,downloadSessionId:f,textVersion:a}){const p=A.useMemo(()=>Array.from(new Set(s??[])),[s]),{data:m=[],isLoading:y}=bo(p),b=m.length>0?$t(r,m):r;return t.jsxs(t.Fragment,{children:[b.trim()&&t.jsx(bl,{message:e,content:b,attachments:m,isUser:l,tone:g,workingDir:w,onOpenWorkspaceFile:i,onOpenPreviewUrl:o,onOpenVisualization:u,downloadSessionId:f,textVersion:a}),t.jsx(vl,{hasAttachmentIds:p.length>0,attachments:m,isLoading:y,onOpenImage:v})]})}function _l({images:e,index:r,onClose:s,onSelect:l}){const g=e[r];if(!g)return null;const v=r>0,w=r<e.length-1;return t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-inverse/90 p-4",role:"dialog","aria-modal":"true",children:[t.jsx("button",{type:"button",onClick:s,className:"absolute right-4 top-4 rounded-full bg-inverse-foreground/10 p-2 text-inverse-foreground transition-colors hover:bg-inverse-foreground/20","aria-label":"Close image preview",children:t.jsx(tt,{size:20})}),v&&t.jsx("button",{type:"button",onClick:()=>l(r-1),className:"absolute left-4 top-1/2 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-inverse-foreground/10 text-inverse-foreground transition-colors hover:bg-inverse-foreground/20","aria-label":"Previous image",children:t.jsx(oa,{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:`${Rs}${g.url}`,alt:g.originalName,className:"max-h-[82vh] max-w-[92vw] rounded-lg object-contain"}),t.jsxs("div",{className:"flex items-center gap-3 text-sm text-inverse-foreground",children:[t.jsx("span",{className:"max-w-[70vw] truncate",children:g.originalName}),t.jsxs("a",{href:`${Rs}${g.url}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-md bg-inverse-foreground/10 px-2 py-1 text-xs hover:bg-inverse-foreground/20",children:[t.jsx(Hs,{size:13,"aria-hidden":!0}),"Open"]})]})]}),w&&t.jsx("button",{type:"button",onClick:()=>l(r+1),className:"absolute right-4 top-1/2 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-inverse-foreground/10 text-inverse-foreground transition-colors hover:bg-inverse-foreground/20","aria-label":"Next image",children:t.jsx(Je,{size:24,"aria-hidden":!0})})]})}const Di=A.createContext(null);function bl({message:e,content:r,attachments:s,isUser:l,tone:g=l?"user":"agent",workingDir:v,onOpenWorkspaceFile:w,onOpenPreviewUrl:i,onOpenVisualization:o,downloadSessionId:u,textVersion:f}){const{t:a}=re(),p=A.useId(),m=A.useRef(null),y=A.useContext(Di),[b,n]=A.useState(()=>y?.get(e.id)??null),d=A.useCallback(N=>{N.expanded?y?.set(e.id,N):y?.delete(e.id),n(N)},[y,e.id]),[c,h]=A.useState(!1),[_,S]=A.useState(null),k=Gr(e.teamRunId,e.id,!1),E=f?f.full:k.data?.content,x=E?$t(E,s):void 0,T=!!(x&&x!==r)?x:r,L=!!((f?f.truncated:e.isTruncated)&&!Xt(e)),R=b?.messageId===e.id&&b.content===T&&b.expanded,M=A.useCallback(()=>{const N=m.current;N&&h(Ga(N.scrollHeight))},[]);A.useLayoutEffect(()=>{M();const N=m.current;if(!N)return;const P=window.requestAnimationFrame(M),D=typeof ResizeObserver>"u"?null:new ResizeObserver(M);return D?.observe(N),window.addEventListener("resize",M),()=>{window.cancelAnimationFrame(P),D?.disconnect(),window.removeEventListener("resize",M)}},[T,M]);const I=A.useCallback(async()=>{if(S(null),R){d({messageId:e.id,content:T,expanded:!1});return}if(L&&!E){if(f){try{const D=await f.load();d({messageId:e.id,content:$t(D,s),expanded:!0})}catch{S(a("Failed to load full message"))}return}const N=await k.refetch();if(N.error){S(Ks(N.error,a("Failed to load full message")));return}const P=N.data?.content?$t(N.data.content,s):T;d({messageId:e.id,content:P,expanded:!0});return}d({messageId:e.id,content:T,expanded:!0})},[s,L,E,k,R,e.id,T,d,a,f]),B=(c||L)&&!R,H=c||L,$=f?f.loading:k.isFetching;return t.jsxs("div",{className:"relative",children:[t.jsxs("div",{id:p,ref:m,onLoadCapture:M,className:Q("relative transition-[max-height] duration-200 ease-out",B?"overflow-hidden":""),style:B?{maxHeight:Ri}:void 0,children:[t.jsx(Li,{content:T,isUser:l,workingDir:v,onOpenWorkspaceFile:w,onOpenPreviewUrl:i,onOpenVisualization:o,downloadSessionId:u}),B&&t.jsx("div",{className:Q("pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-gradient-to-b from-transparent",g==="system"?"to-[color-mix(in_oklab,var(--color-warning)_8%,var(--color-background))]":g==="user"?"to-[color-mix(in_oklab,var(--color-foreground)_8%,var(--color-background))]":"to-background")})]}),H&&t.jsxs("button",{type:"button","aria-expanded":R,"aria-controls":p,"aria-label":a(R?"Collapse message":"Expand full message"),disabled:$,onClick:()=>{I()},className:Q("mt-2 inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",g==="system"?"bg-warning/10 text-warning-ink hover:bg-warning/20":g==="user"?"bg-background/70 text-foreground/70 hover:bg-background hover:text-foreground":"bg-muted text-foreground/70 hover:bg-foreground/10 hover:text-foreground",$?"cursor-wait opacity-70":""),children:[R?t.jsx(hi,{size:13}):t.jsx(Ke,{size:13}),t.jsx("span",{children:a($?"Loading":R?"Collapse message":"Expand full message")})]}),_&&t.jsx("div",{className:Q("mt-1 text-xs","text-destructive-ink"),children:_})]})}function Pi({senderName:e,avatar:r,createdAt:s,isUser:l,isSystem:g,children:v,headerAddon:w,footer:i,bubbleClassName:o,isPending:u}){return g?t.jsx("div",{className:"flex justify-center",children:t.jsx("div",{className:"max-w-[min(100%,42rem)] rounded-lg border border-warning/25 bg-warning/10 px-3 py-2 text-xs text-warning-ink shadow-raised",children:v})}):t.jsxs("div",{className:Q("group flex items-start gap-3",l?"justify-end pl-8 sm:pl-14":"justify-start pr-8 sm:pr-14"),children:[!l&&t.jsx(Ue,{name:e,avatar:r??null,className:"mt-0.5 h-8 w-8 text-[11px]"}),t.jsxs("div",{className:Q("flex min-w-0 max-w-[min(86%,46rem)] flex-col",l?"items-end":"items-start"),children:[t.jsxs("div",{className:Q("mb-1.5 flex max-w-full items-center gap-1.5 px-0.5 text-xs text-muted-foreground",l?"justify-end":"justify-start"),children:[t.jsx("span",{className:"truncate font-semibold text-foreground/80",children:e}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-foreground/15","aria-hidden":!0}),t.jsx(Ve,{size:11,className:"text-muted-foreground/70"}),t.jsx("span",{className:"shrink-0",children:cl(s)}),w]}),t.jsx("div",{className:Q("max-w-full rounded-lg px-3.5 py-3 text-sm leading-6 transition-colors",l?"rounded-tr-[4px] bg-foreground/[0.08] text-foreground":"rounded-tl-[4px] border border-border/70 bg-background text-foreground",o,u?"opacity-70":""),children:v}),i&&t.jsx("div",{className:"mt-1 max-w-full px-0.5","data-message-feedback":!0,children:i})]}),l&&t.jsx(Ue,{name:e,avatar:null,className:"mt-0.5 h-8 w-8 text-[11px]"})]})}function xl({provider:e}){return t.jsxs("span",{className:"ml-0.5 inline-flex max-w-[10rem] shrink items-center gap-1 rounded-full bg-foreground/5 px-1.5 py-0.5 text-xs font-medium leading-none text-muted-foreground",children:[t.jsx(Gt,{agentType:e.agentType,className:"size-2.5"}),t.jsx("span",{className:"truncate",children:e.name})]})}function Sl({overlay:e,translations:r,enabled:s,body:l}){const{t:g}=re(),[v,w]=A.useState(null),[i,o]=A.useState(!1),[u,f]=A.useState(null),a=A.useRef(null),p=A.useRef(!0);A.useEffect(()=>(p.current=!0,()=>{p.current=!1}),[]);const m=()=>p.current&&r.isCurrent(e),y=async()=>{if(!m())throw new DOMException("Aborted","AbortError");return v||(a.current||(o(!0),f(null),a.current=r.loadFull(e).then(_=>{if(!m())throw new DOMException("Aborted","AbortError");if(!l.message.isTruncated&&l.message.contentMode==="full"&&l.message.content!==_.originalText)throw new Error("Message changed");return w(_),_}).catch(_=>{throw m()&&f(g("Failed to load full message")),_}).finally(()=>{a.current=null,p.current&&o(!1)})),a.current)},b=e.state==="SUCCESS"&&e.translatedTextPreview!==null,n=v?.originalText??e.originalTextPreview,d=v?.translatedText??e.translatedTextPreview??"",c=async()=>e.originalTextTruncated?(await y()).originalText:n,h=async()=>b?e.translatedTextTruncated?(await y()).translatedText??"":d:c();return t.jsxs("div",{className:`relative ${e.state==="NOT_REQUIRED"?"":"pr-8"}`,children:[t.jsx(Mi,{...l,content:b?d:l.content,textVersion:b?{kind:"translated",truncated:e.translatedTextTruncated,full:v?.translatedText??void 0,loading:i,load:h}:void 0}),e.state!=="NOT_REQUIRED"&&t.jsx("div",{className:"absolute bottom-0 right-0",children:t.jsxs(ai,{original:n,getOriginal:c,canCopy:m,onOpen:()=>{e.originalTextTruncated&&y().catch(()=>{})},loading:i,error:u,children:[t.jsx(Li,{content:n,workingDir:l.workingDir,onOpenWorkspaceFile:l.onOpenWorkspaceFile,onOpenPreviewUrl:l.onOpenPreviewUrl,onOpenVisualization:l.onOpenVisualization,downloadSessionId:l.downloadSessionId}),t.jsx(no,{state:e.state,errorCode:e.errorCode,enabled:s,onRetry:()=>r.retry(e)})]})})]})}function yl({message:e,senderName:r,senderMember:s,senderProvider:l,memberById:g,displayContent:v,onOpenImage:w,workingDir:i,onOpenWorkspaceFile:o,onOpenPreviewUrl:u,onOpenVisualization:f,previewWorkspaceId:a,previewSessionId:p,overlay:m,translations:y,translationEnabled:b,delivery:n,onRetrySubmission:d}){const{t:c}=re(),h=e.senderType==="user",_=e.senderType==="system",S=!n&&Xt(e)?e.pendingStatus:null,k=e.mentions??[],E=e.workRequestIds?.length??0,x=e.visibility==="PRIVATE",C=A.useCallback(I=>{u?.(I,a)},[u,a]),T=A.useCallback(I=>{p&&f?.(p,I,a)},[f,p,a]),L=x?ml(e,g):[],R={message:e,content:v,attachmentIds:e.attachmentIds,isUser:h&&S!=="failed",tone:_?"system":void 0,onOpenImage:w,workingDir:i,onOpenWorkspaceFile:o,onOpenPreviewUrl:u?C:void 0,onOpenVisualization:f&&p?T:void 0,downloadSessionId:p},M=t.jsxs(t.Fragment,{children:[!h&&!_&&l&&t.jsx(xl,{provider:l}),x&&t.jsxs("span",{className:"ml-0.5 inline-flex max-w-[18rem] shrink items-center gap-1 rounded-full bg-foreground/[0.06] px-1.5 py-0.5 text-xs font-medium leading-none text-foreground/70",title:L.join(", "),children:[t.jsx(Fn,{size:10}),t.jsxs("span",{className:"truncate",children:[c("Private"),L.length>0?`: ${L.join(", ")}`:""]})]}),!_&&E>0&&k.length===0&&t.jsxs("span",{className:"ml-0.5 shrink-0 rounded-full bg-foreground/[0.08] px-1.5 py-0.5 text-xs font-medium leading-none text-foreground/70",children:[c("Work requests"),": ",E]}),S==="failed"&&t.jsx("span",{className:"ml-0.5 shrink-0 rounded-full bg-destructive/10 px-1.5 py-0.5 text-xs font-medium leading-none text-destructive-ink",children:c("Acceptance unknown")})]});return t.jsx(Pi,{senderName:r,avatar:s?.avatar??null,createdAt:e.createdAt,isUser:h,isSystem:_,headerAddon:M,bubbleClassName:h&&S==="failed"?"border border-destructive/25 bg-destructive/10 text-destructive-ink":void 0,isPending:S==="sending",footer:n||e.userDelivery||S==="failed"?t.jsxs(t.Fragment,{children:[n&&t.jsx(oi,{delivery:n}),e.userDelivery&&!n&&t.jsx(wl,{message:e}),S==="failed"&&!n&&t.jsxs("div",{className:"text-xs",children:[t.jsx("p",{children:c("Acceptance unknown; check or retry the same submission.")}),Xt(e)&&e.error&&t.jsx("p",{children:e.error}),t.jsx("button",{type:"button",className:"underline",onClick:d,children:c("Retry original submission")})]})]}):void 0,children:t.jsx(io,{claim:y.claimReveal,version:m?.state==="SUCCESS"?`${m.sourceId}:${m.sourceRevision}`:null,children:m?t.jsx(Sl,{overlay:m,translations:y,enabled:b,body:R},`${m.sourceId}:${m.sourceRevision}:${m.overlayRevision}`):t.jsx(Mi,{...R})})})}function wl({message:e}){const r=Gr(e.teamRunId,e.id,!1),s=e.userDelivery;if(s.sentMode!=="TRANSLATED")return null;const l=r.data?.userDelivery?.actualSentText??s.actualSentText??"",g=async()=>{if(!s.isTruncated)return l;const v=await r.refetch();if(v.error||!v.data?.userDelivery)throw new Error("Failed to load sent text");return v.data.userDelivery.actualSentText??""};return t.jsx(ai,{label:"Actual sent text",original:l,getOriginal:g,onOpen:()=>{s.isTruncated&&r.refetch()},loading:r.isFetching,error:r.error?.message,children:t.jsx("pre",{className:"whitespace-pre-wrap",children:l})})}function Cl({request:e,member:r,onApprove:s,onReject:l,isActionPending:g,isApprovePending:v,isRejectPending:w}){const{t:i}=re();return t.jsx(Pi,{senderName:r?.name??i("Agent"),avatar:r?.avatar??null,createdAt:e.createdAt,bubbleClassName:"border border-warning/25 bg-warning/8",children:t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-warning/25 bg-warning/10 px-2 py-0.5 text-xs font-medium text-warning-ink",children:[t.jsx(Ve,{size:11}),i("Pending approval")]}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:[i("Requester"),": ",i(e.requesterType==="user"?"User":e.requesterType==="system"?"System":"Agent")]})]}),t.jsx("div",{className:"text-sm leading-6 text-foreground [overflow-wrap:anywhere]",children:e.instructionPreview??dl(e.instruction)}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs(ge,{type:"button",size:"xs",variant:"outline",disabled:g,className:"border-success/25 bg-success/10 text-success-ink hover:bg-success/15 hover:text-success-ink",onClick:s,children:[t.jsx(Et,{size:12}),t.jsx("span",{children:i(v?"Approving":"Approve")})]}),t.jsxs(ge,{type:"button",size:"xs",variant:"outline",disabled:g,onClick:l,children:[t.jsx(tt,{size:12}),t.jsx("span",{children:i(w?"Rejecting":"Reject")})]})]})]})})}const kl=A.memo(function({teamRun:r,messages:s,timelineItems:l,recovered:g,scrollElementRef:v,compact:w,onRetrySubmission:i,onOpenImage:o,workingDir:u,onOpenWorkspaceFile:f,onOpenPreviewUrl:a,onOpenVisualization:p}){const{t:m}=re(),y=Yr(r.id),b=Ka(r.id,s),{data:n}=di(),d=new Map(b.overlays.map(L=>[L.messageId,L])),c=Vr(r.id),{data:h}=Ws(),_=A.useMemo(()=>{const L=new Map;for(const R of h??[])L.set(R.provider.id,R.provider);return L},[h]),S=A.useMemo(()=>new Map((r.members??[]).map(L=>[L.id,L])),[r.members]),k=A.useMemo(()=>new Map((r.invocations??[]).map(L=>[L.id,L])),[r.invocations]),E=y.isError?y.error:c.isError?c.error:null,x=y.isPending||c.isPending,[C]=A.useState(()=>new Map);A.useEffect(()=>{const L=new Set(s.map(R=>R.id));for(const R of C.keys())L.has(R)||C.delete(R)},[C,s]);const T=L=>{if(L.kind==="pendingApproval"){const D=L.request,O=S.get(D.targetMemberId),q=y.isPending&&y.variables===D.id,K=c.isPending&&c.variables===D.id;return t.jsx(Cl,{request:D,member:O,onApprove:()=>y.mutate(D.id),onReject:()=>c.mutate(D.id),isActionPending:x,isApprovePending:q,isRejectPending:K},L.key)}const R=L.message,M=gl(R,S,k),I=R.senderType==="user"?m("你"):R.senderType==="system"?m("System"):M?.name??m("Agent"),B=pl(R,S),H=M?.providerId?_.get(M.providerId)??null:null,$=R.senderInvocationId?k.get(R.senderInvocationId):void 0,N=$?.workspaceId??void 0,P=$?.sessionId??void 0;return t.jsx(yl,{message:R,senderName:I,senderMember:M,senderProvider:H,memberById:S,displayContent:B,overlay:d.get(R.id),translations:b,translationEnabled:n?.enabled===!0,delivery:g.get(R.userDelivery?.clientSubmissionId??R.id),onRetrySubmission:Xt(R)?()=>i(R):void 0,onOpenImage:o,workingDir:u,onOpenWorkspaceFile:f,onOpenPreviewUrl:a,onOpenVisualization:p,previewWorkspaceId:N,previewSessionId:P},L.key)};return t.jsxs(Di.Provider,{value:C,children:[l.length===0?t.jsxs("div",{className:"flex min-h-[180px] flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-border bg-background text-muted-foreground",children:[t.jsx(vt,{size:24,className:"text-muted-foreground/70"}),t.jsx("span",{className:"text-sm",children:m("No room messages yet")})]}):t.jsx(Wa,{items:l,renderItem:T,scrollElementRef:v,compact:w}),E&&t.jsx("div",{className:"rounded-md border border-destructive/25 bg-destructive/10 px-3 py-2 text-xs text-destructive-ink",children:Ks(E,m("Failed to update work request"))})]})});function Wf({teamRun:e,messages:r,readOnly:s,readOnlyMessage:l,onSendMessage:g,onViewInvocationSession:v,changeSummaryBar:w,compactComposer:i,centered:o,workingDir:u,onOpenWorkspaceFile:f,onOpenPreviewUrl:a,onOpenVisualization:p}){const{t:m}=re(),y=Kr(e.id),[b,n]=A.useState(""),[d,c]=A.useState(!1),[h,_]=A.useState(null),[S,k]=A.useState(0),[E,x]=A.useState([]),[C,T]=A.useState(!1),L=Es(s?"":`task:${e.taskId}`,"pending","TEAM_TASK"),R=Es(s?"":`task:${e.taskId}`,"sent","TEAM_TASK"),M=A.useMemo(()=>new Map([...L.data?.pages.flatMap(V=>V.items)??[],...R.data?.pages.flatMap(V=>V.items)??[]].filter(V=>V.destination.kind==="TEAM_ROOM"&&V.destination.teamRunId===e.id).sort((V,J)=>V.revision-J.revision).map(V=>[V.clientSubmissionId,V])),[L.data,R.data,e.id]),[I,B]=A.useState([]),[H,$]=A.useState(null),N=A.useRef(null),P=A.useRef(null),{files:D,addFiles:O,removeFile:q,clear:K,buildMarkdownLinks:U,getDoneAttachments:z,isUploading:W}=vo(),j=D.some(V=>V.status==="done"&&V.attachment),[F,X]=A.useState(null),{scrollRef:Y,contentRef:ee,isAtBottom:G,scrollToBottom:Z}=Co({resize:"instant",initial:"instant"}),ae=A.useRef(!1),he=A.useRef(null),je=A.useRef(e.id),se=A.useCallback(()=>(ae.current=!1,Z({animation:"instant",ignoreEscapes:!0})),[Z]);A.useEffect(()=>{if(je.current===e.id)return;je.current=e.id;const V=requestAnimationFrame(()=>{se()});return()=>cancelAnimationFrame(V)},[se,e.id]),A.useEffect(()=>{const V=Y.current;if(!V)return;const J=ne=>{if(ne.deltaY<0){ae.current=!0;return}ne.deltaY>0&&V.scrollHeight-V.scrollTop-V.clientHeight<=70&&(ae.current=!1)};return V.addEventListener("wheel",J,{passive:!0}),()=>V.removeEventListener("wheel",J)},[Y]);const Ae=A.useMemo(()=>new Map((e.members??[]).map(V=>[V.id,V])),[e.members]),te=A.useMemo(()=>(e.members??[]).filter(cr),[e.members]),me=A.useMemo(()=>new Set([...r.flatMap(V=>V.userDelivery?[V.userDelivery.clientSubmissionId]:[]),...L.data?.pages.flatMap(V=>V.items.map(J=>J.clientSubmissionId))??[]]),[r,L.data]);A.useEffect(()=>{for(const V of me)Pn(e.id,V);B(V=>V.some(J=>me.has(J.id))?V.filter(J=>!me.has(J.id)):V)},[me,e.id]);const Pe=A.useMemo(()=>{const V=new Set(r.map(le=>le.id)),J=new Set(r.flatMap(le=>le.userDelivery?[le.userDelivery.clientSubmissionId]:[])),ne=[...M.values()].filter(le=>le.state!=="CANCELLED"&&!J.has(le.clientSubmissionId)).map(le=>({...cs(e.id,{content:le.originalText,clientSubmissionId:le.clientSubmissionId,attachmentIds:le.attachmentIds}),pendingStatus:"sending",createdAt:le.createdAt})),ye=I.filter(le=>!V.has(le.id)&&!J.has(le.id)&&!M.has(le.id));return[...r,...ne,...ye].sort((le,we)=>Date.parse(le.createdAt??"")-Date.parse(we.createdAt??""))},[r,I,M,e.id]),qe=A.useMemo(()=>new Map((e.workRequests??[]).map(V=>[V.id,V])),[e.workRequests]),ve=A.useMemo(()=>el(Pe,e.workRequests??[],e.invocations??[]),[Pe,e.invocations,e.workRequests]);A.useEffect(()=>{const V=ve.at(-1)?.key??null,J=he.current;if(he.current=V,J==null||V==null||V===J||ae.current)return;const ne=requestAnimationFrame(()=>{Z({animation:"instant",preserveScrollPosition:!0})});return()=>cancelAnimationFrame(ne)},[Z,ve]);const Re=A.useMemo(()=>(e.invocations??[]).filter(V=>Zt.has(V.status)),[e.invocations]),Se=A.useMemo(()=>E.map(V=>Ae.get(V)).filter(V=>!!V).filter(cr),[Ae,E]),Ce=A.useMemo(()=>{const V=h?.query??"";return te.filter(J=>ul(J,V)).sort((J,ne)=>{const ye=E.includes(J.id),le=E.includes(ne.id);return ye!==le?ye?1:-1:J.name.localeCompare(ne.name)})},[te,h?.query,E]),rt=!s&&(d||!!h)&&Ce.length>0,Ne=A.useCallback((V,J)=>{if(J==null){_(null);return}_(hl(V,J)),k(0)},[]),it=A.useCallback(V=>{x(we=>Qa(we,V.id));const J=`@${V.name} `;if(h){const we=`${b.slice(0,h.start)}${J}${b.slice(h.end)}`,dt=h.start+J.length;n(we),_(null),c(!1),requestAnimationFrame(()=>{N.current?.focus(),N.current?.setSelectionRange(dt,dt)});return}const ne=b.length===0||/\s$/.test(b)?"":" ",ye=`${b}${ne}${J}`,le=ye.length;n(ye),c(!1),requestAnimationFrame(()=>{N.current?.focus(),N.current?.setSelectionRange(le,le)})},[b,h]),Ie=A.useCallback(V=>{x(J=>Za(J,V))},[]),nt=A.useCallback(V=>{const J=V.target.value;n(J);const ne=V.target;ne.style.height="auto",ne.style.height=`${Math.max(i?40:72,Math.min(ne.scrollHeight,i?140:240))}px`,c(!1),Ne(J,ne.selectionStart)},[i,Ne]),ue=A.useCallback(V=>{const J=V.target.files;J&&J.length>0&&O(Array.from(J)),V.target.value=""},[O]),rs=A.useCallback(V=>{const J=[];for(const ne of V.clipboardData.items)if(ne.kind==="file"){const ye=ne.getAsFile();ye&&J.push(ye)}J.length>0&&(V.preventDefault(),O(J))},[O]),is=A.useCallback(async()=>{if(s||C||W)return;const V=U(),J=z().map(we=>we.id),ne=Ja(E,te),ye=za({draft:b,attachmentMarkdown:V,attachmentIds:J,mentions:ne});if(!ye||!b.trim()&&!j)return;ye.clientSubmissionId=Xr();const le=cs(e.id,ye);B(we=>[...we,le]),n(""),x([]),c(!1),_(null),K(),N.current&&(N.current.style.height=i?"40px":"72px"),requestAnimationFrame(()=>se()),T(!0);try{const we=await g(ye);B(dt=>dt.filter(ns=>ns.id!==le.id)),we&&typeof we=="object"&&"id"in we&&requestAnimationFrame(()=>se())}catch(we){const dt=we instanceof Error?we.message:"Failed to send room message";B(ns=>ns.map(os=>os.id===le.id?{...os,pendingStatus:"failed",error:dt}:os)),requestAnimationFrame(()=>se())}finally{T(!1)}},[te,U,K,i,b,z,j,C,W,se,g,s,E,e.id]),kn=A.useCallback(V=>{const J=V.nativeEvent.isComposing||V.nativeEvent.keyCode===229;if(rt){if(V.key==="ArrowDown"){V.preventDefault(),k(ne=>(ne+1)%Ce.length);return}if(V.key==="ArrowUp"){V.preventDefault(),k(ne=>(ne-1+Ce.length)%Ce.length);return}if(V.key==="Enter"&&!J||V.key==="Tab"){V.preventDefault();const ne=Ce[S]??Ce[0];ne&&it(ne);return}if(V.key==="Escape"){V.preventDefault(),_(null),c(!1);return}}V.key==="Enter"&&!V.shiftKey&&!V.repeat&&!J&&(V.preventDefault(),is())},[it,is,S,Ce,rt]);A.useEffect(()=>{n(""),x([]),c(!1),_(null),B(Bn(e.id).map(V=>({...cs(e.id,V),pendingStatus:"failed",error:"Acceptance unknown; check or retry the same submission."}))),K(),ae.current=!1,he.current=null,$(null),N.current&&(N.current.style.height=i?"40px":"72px")},[K,i,e.id]);const En=A.useCallback((V,J)=>{X({images:V,index:J})},[]),jn=A.useCallback(V=>{C||(T(!0),g(V.submissionInput).then(()=>B(J=>J.filter(ne=>ne.id!==V.id))).finally(()=>T(!1)).catch(()=>{}))},[C,g]),Nn=A.useCallback((V,J)=>{y.mutate({memberId:V,cancelQueued:J},{onSuccess:()=>$(null)})},[y]);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background",children:[F&&t.jsx(_l,{images:F.images,index:F.index,onClose:()=>X(null),onSelect:V=>X(J=>J&&{...J,index:V})}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:Y,"data-room-scroll":!0,className:Q("h-full overflow-y-auto scrollbar-app-thin bg-background",i?"px-3 py-3":"px-4 py-4"),children:t.jsxs("div",{ref:ee,className:Q(i?"space-y-2.5":"space-y-3",o&&"max-w-4xl mx-auto"),children:[t.jsx(kl,{teamRun:e,messages:r,timelineItems:ve,recovered:M,scrollElementRef:Y,compact:i,onRetrySubmission:jn,onOpenImage:En,workingDir:u,onOpenWorkspaceFile:f,onOpenPreviewUrl:a,onOpenVisualization:p},e.id),t.jsx(Ai,{taskId:e.taskId,teamRunId:e.id,enabled:!s,showDeliveries:!1}),y.isError&&t.jsx("div",{className:"rounded-md border border-destructive/25 bg-destructive/10 px-3 py-2 text-xs text-destructive-ink",children:Ks(y.error,m("Failed to stop member work"))})]})}),!G&&t.jsxs("button",{type:"button",onClick:()=>se(),className:"absolute bottom-3 left-1/2 z-10 flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-border bg-background/90 px-3 py-1.5 text-xs text-foreground/70 shadow-raised backdrop-blur-sm hover:bg-background hover:text-foreground transition-colors",children:[t.jsx(On,{size:14}),t.jsx("span",{children:m("Back to bottom")})]})]}),t.jsx("div",{className:Q("shrink-0 border-t border-transparent bg-background",i?"px-3 pb-2 pt-1.5":"px-6 pb-6 pt-2"),children:t.jsxs("div",{className:Q(o&&"max-w-4xl mx-auto"),children:[t.jsx(ol,{invocations:Re,memberById:Ae,workRequestById:qe,onViewInvocationSession:v,onStopMember:Nn,isStopPending:y.isPending,stoppingMemberId:y.variables?.memberId??null,stopPromptInvocationId:H,onToggleStopConfirm:V=>$(J=>J===V?null:V)}),!s&&w,s?t.jsx("div",{className:"rounded-xl border border-border bg-muted/50 px-4 py-3 text-sm text-muted-foreground",children:l??m("This project is read-only")}):t.jsxs("div",{className:"relative rounded-xl border border-border bg-background shadow-raised transition-all duration-200 hover:shadow-raised focus-within:border-ring focus-within:shadow-raised",children:[rt&&t.jsxs("div",{className:"absolute bottom-full left-3 z-20 mb-2 w-[min(24rem,calc(100vw-3rem))] overflow-hidden rounded-xl border border-border bg-background shadow-popover",children:[t.jsx("div",{className:"border-b border-border/60 px-3 py-2 text-xs font-medium text-muted-foreground",children:m(h?"Mention members":"Team members")}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:Ce.map((V,J)=>{const ne=E.includes(V.id),ye=J===S;return t.jsxs("button",{type:"button",onMouseEnter:()=>k(J),onMouseDown:le=>{le.preventDefault(),it(V)},className:Q("flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors",ye?"bg-muted":"hover:bg-accent"),children:[t.jsx(Ue,{name:V.name,avatar:V.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:V.name}),ne&&t.jsx("span",{className:"rounded-full bg-primary px-1.5 py-0.5 text-xs font-medium text-primary-foreground",children:m("selected")})]}),t.jsx("div",{className:"truncate text-xs text-muted-foreground",children:[V.providerId,V.id.slice(0,8)].filter(Boolean).join(" · ")})]}),t.jsx(ir,{size:15,className:"text-muted-foreground/70"})]},V.id)})})]}),Se.length>0&&t.jsx("div",{className:"flex flex-wrap items-center gap-1.5 border-b border-border/60 px-3 py-2",children:Se.map(V=>t.jsxs("span",{className:"inline-flex max-w-full items-center gap-1.5 rounded-full border border-border bg-muted/50 px-2 py-1 text-xs text-foreground/80",children:[t.jsxs("span",{className:"truncate font-medium",children:["@",V.name]}),t.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:V.id.slice(0,8)}),t.jsx("button",{type:"button",onClick:()=>Ie(V.id),className:"shrink-0 rounded-full p-0.5 text-muted-foreground transition-colors hover:bg-foreground/10 hover:text-foreground/80",title:m("Remove mention"),"aria-label":`${m("Remove mention")} ${V.name}`,children:t.jsx(tt,{size:12})})]},V.id))}),t.jsx(_o,{files:D,onRemove:q}),t.jsx("textarea",{ref:N,value:b,rows:i?1:void 0,onChange:nt,onKeyDown:kn,onPaste:rs,onClick:V=>Ne(b,V.currentTarget.selectionStart),onSelect:V=>Ne(b,V.currentTarget.selectionStart),placeholder:m("Message the team room..."),className:Q("w-full resize-none border-none bg-transparent text-foreground placeholder:text-muted-foreground/70 focus:outline-none",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:Q("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:P,type:"file",multiple:!0,className:"hidden",onChange:ue}),t.jsx("button",{type:"button",onClick:()=>P.current?.click(),title:m("Upload file"),"aria-label":m("Upload file"),className:"rounded-lg p-2 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground/70",children:t.jsx(yo,{size:18})}),t.jsx("button",{type:"button",onClick:()=>{c(V=>!V),_(null),requestAnimationFrame(()=>N.current?.focus())},disabled:Se.length===0&&te.length===0,title:m("Mention members"),"aria-label":m("Mention members"),className:Q("rounded-lg transition-colors",i?"p-1.5":"p-2",d?"bg-muted text-foreground/80":"text-muted-foreground hover:bg-accent hover:text-foreground/70",Se.length===0&&te.length===0?"cursor-not-allowed opacity-50":""),children:t.jsx(ir,{size:i?15:18})}),Se.length>0&&t.jsxs("span",{className:"text-xs text-muted-foreground",children:[Se.length," ",m("selected")]})]}),t.jsx("button",{type:"button",onClick:()=>{is()},disabled:s||C||W||!b.trim()&&!j,"aria-busy":C,title:m(W?"Uploading...":C?"发送中...":"发送"),"aria-label":m(W?"Uploading...":C?"发送中...":"发送"),className:Q("rounded-lg transition-all duration-200",i?"p-1.5":"p-2",(b.trim()||j)&&!s&&!C&&!W?"bg-primary text-primary-foreground shadow-raised hover:bg-primary":"cursor-not-allowed bg-transparent text-muted-foreground",C||W?"opacity-70":""),children:C?t.jsx(Fs,{size:i?15:18,className:"animate-spin"}):t.jsx(In,{size:i?15:18})})]})]})]})})]})}function El(e){return e?e.slice(0,8):""}function dr(e){const r=e?Date.parse(e):0;return Number.isNaN(r)?0:r}function Xs(e){return e?.workspaceKind===He.MAIN_DIRECTORY}function jt(e){return e?Xs(e)?"Project directory":e.branchName:"—"}function $f(e){return e?.workingDir||e?.worktreePath||void 0}function Ys(e,r){if(!e?.length)return[];const s=new Map((r?.members??[]).map(v=>[v.id,v])),l=new Map(e.map(v=>[v.id,v])),g=r?.mainWorkspaceId??null;return e.map(v=>{const w=v.parentWorkspaceId?l.get(v.parentWorkspaceId):void 0,i=v.ownerMemberId?s.get(v.ownerMemberId):void 0,o=!!(g&&v.id===g),u=o?"main":v.parentWorkspaceId?"child":"root",f=i?.name??(v.ownerMemberId?`Member ${El(v.ownerMemberId)}`:void 0),a=Xs(v)?"Project directory":o?"Main workspace":u==="child"?f?`${f} workspace`:"Child workspace":r?"Root workspace":"Workspace";return{workspace:v,kind:u,roleLabel:o?"Main":u==="child"?"Child":"Root",displayName:a,ownerName:f,parentBranchName:w?jt(w):void 0,isMain:o}}).sort((v,w)=>{const i=u=>u.kind==="main"?0:u.kind==="child"?1:2,o=i(v)-i(w);return o!==0?o:dr(v.workspace.createdAt)-dr(w.workspace.createdAt)})}function Uf(e,r,s){if(e?.length)return s&&e.some(l=>l.id===s)?s:r?.mainWorkspaceId&&e.some(l=>l.id===r.mainWorkspaceId)?r.mainWorkspaceId:e.find(l=>l.status===We.ACTIVE)?.id??e[0]?.id}function qf(e,r){return!e||e.status!==We.ACTIVE||Xs(e)?!1:!r||e.parentWorkspaceId?!0:!!(r.mainWorkspaceId&&e.id===r.mainWorkspaceId)}function Kf(e,r,s){return e?.parentWorkspaceId?r?.find(g=>g.id===e.parentWorkspaceId)?.branchName??e.baseBranch??s:e?.baseBranch||s}const Vs={readRoom:!1,postRoomMessage:!1,mentionMembers:!1,stopMemberWork:!1,markReadyForReview:!1,readFiles:!1,writeFiles:!1,runCommands:!1,readDiff:!1,mergeWorkspace:!1},jl=[{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:"合并工作区"}],Bi=[{value:"none",label:"无"},{value:"shared",label:"共享"},{value:"dedicated",label:"独占"}],Nl=[{value:"MENTION_ONLY",label:"仅提及"},{value:"USER_MESSAGES",label:"所有用户消息"}],Oi=[{value:"new_per_request",label:"每次新会话"},{value:"resume_last",label:"复用上次会话"}],Tl=[{value:"own_only",label:"仅自己队列"},{value:"team_pending",label:"全队列待处理"}];function bt(){return{name:"",aliasesText:"",providerId:"",rolePrompt:"",capabilities:{...Vs},workspacePolicy:"none",triggerPolicy:"MENTION_ONLY",sessionPolicy:"new_per_request",queueManagementPolicy:"own_only",avatar:""}}function ft(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...Vs,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function ds(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...Vs,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function Al(e){return Array.from(new Set(e.split(/[\n,]/).map(r=>r.trim()).filter(Boolean)))}function Rl(e){return{name:e.name.trim(),aliases:Al(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 hr(e,r){return e instanceof Error?e.message:r}function ur(e){return e.membershipStatus!=="REMOVED"}function Ls(e){return e.status==="RUNNING"||e.status==="WAITING_ROOM_REPLY"||e.status==="SESSION_ENDED"||e.status==="QUEUED"}function fr(e){return Ls(e)?"bg-success":e.status==="FAILED"?"bg-destructive":"bg-foreground/15"}function mr(e){return Bi.find(r=>r.value===e)?.label??e}function Ll(e){return Oi.find(r=>r.value===e)?.label??e}function Fe({children:e}){return t.jsx("span",{className:"text-xs font-medium text-foreground/70",children:e})}function pr({icon:e,title:r,description:s,action:l}){return t.jsxs("div",{className:"flex min-h-[18rem] flex-col items-center justify-center rounded-lg border border-dashed border-border bg-background px-6 py-8 text-center",children:[t.jsx("div",{className:"mb-3 flex h-10 w-10 items-center justify-center rounded-full bg-muted text-muted-foreground",children:e}),t.jsx("div",{className:"text-sm font-medium text-foreground",children:r}),s?t.jsx("div",{className:"mt-1 max-w-sm text-xs leading-relaxed text-muted-foreground",children:s}):null,l?t.jsx("div",{className:"mt-4",children:l}):null]})}function Ml({isOpen:e,onClose:r,teamRun:s}){const{t:l}=re(),{data:g=[]}=Hn(),{data:v=[]}=Ws(),w=zn(s.id),i=Wn(s.id),o=$n(s.id),u=A.useRef(!1),[f,a]=A.useState("edit"),[p,m]=A.useState(null),[y,b]=A.useState(""),[n,d]=A.useState(bt()),[c,h]=A.useState(null),[_,S]=A.useState(null),k=s.members??[],E=A.useMemo(()=>k.filter(ur),[k]),x=A.useMemo(()=>_&&ur(_)&&!E.some(W=>W.id===_.id)?[...E,_]:E,[_,E]),C=p?E.find(W=>W.id===p)??null:null,T=_?.id===p?_:C,L=y?g.find(W=>W.id===y)??null:null,R=w.isPending||i.isPending||o.isPending,M=x.filter(Ls).length,I=A.useMemo(()=>{const W=v.filter(ui).map(({provider:j,availability:F})=>({value:j.id,label:j.name+(F.type==="NOT_FOUND"?l(" (不可用)"):""),icon:t.jsx(Gt,{agentType:j.agentType,className:"size-4"}),disabled:F.type==="NOT_FOUND"}));return n.providerId&&!v.some(j=>j.provider.id===n.providerId)&&!W.some(j=>j.value===n.providerId)&&W.unshift({value:n.providerId,label:`${n.providerId}${l(" (不可用)")}`,disabled:!0}),W},[n.providerId,v,l]);A.useEffect(()=>{if(!e){u.current=!1,S(null);return}if(u.current)return;u.current=!0;const W=x[0]??null;a(W?"edit":"add-preset"),m(W?.id??null),b(""),d(W?ft(W):bt()),h(null)},[x,e]),A.useEffect(()=>{_&&E.some(W=>W.id===_.id)&&S(null)},[_,E]),A.useEffect(()=>{f==="add-preset"&&L&&d(ds(L))},[f,L]);const B=(W,j)=>{d(F=>({...F,[W]:j}))},H=(W,j)=>{d(F=>({...F,capabilities:{...F.capabilities,[W]:j}}))},$=W=>{a("edit"),m(W.id),b(""),d(ft(W))},N=()=>{a("add-preset"),m(null);const W=L??g[0]??null;b(W?.id??""),d(W?ds(W):bt())},P=()=>{a("add-custom"),m(null),b(""),d(bt())},D=!!(n.name.trim()&&n.providerId.trim()&&n.rolePrompt.trim()),O=f==="add-preset"?!!y:f==="edit"?!!(T&&D):D,q=async()=>{try{if(f==="add-preset"){if(!y)return;const j=await w.mutateAsync({memberPresetId:y});ke.success(l("Member added")),S(j),a("edit"),m(j.id),b(""),d(ft(j));return}const W=Rl(n);if(!W.name||!W.providerId||!W.rolePrompt){ke.error(l("Name, provider, and role prompt are required"));return}if(f==="add-custom"){const j=await w.mutateAsync({member:W});ke.success(l("Member added")),S(j),a("edit"),m(j.id),d(ft(j));return}if(T){const j=await i.mutateAsync({memberId:T.id,data:W});ke.success(l("Member updated")),S(F=>F?.id===j.id?j:F),m(j.id),d(ft(j))}}catch(W){ke.error(hr(W,l("Failed to save member")))}},K=async()=>{if(c)try{if(await o.mutateAsync({memberId:c.id,stopActive:!0,cancelQueued:!0}),p===c.id){const W=x.find(j=>j.id!==c.id)??null;m(W?.id??null),a(W?"edit":"add-preset"),d(W?ft(W):bt())}S(W=>W?.id===c.id?null:W),h(null),ke.success(l("Member removed"))}catch(W){ke.error(hr(W,l("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-border/60 px-5 py-4",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-foreground",children:[t.jsx(Pt,{size:15,className:"text-muted-foreground"}),t.jsx("span",{children:l("Add member from preset")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:l("Choose a saved preset to add a ready-to-run member snapshot.")})]}),t.jsxs(ge,{type:"button",variant:"outline",size:"sm",onClick:P,disabled:R,children:[t.jsx(ar,{size:13}),l("Custom member")]})]})}),t.jsx("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:g.length===0?t.jsx(pr,{icon:t.jsx(Pt,{size:18}),title:l("No member presets"),description:l("Create a custom member for this TeamRun, or add presets from Team Collaboration Settings."),action:t.jsxs(ge,{type:"button",variant:"outline",size:"sm",onClick:P,disabled:R,children:[t.jsx(pt,{size:13}),l("Custom member")]})}):t.jsx("div",{className:"grid grid-cols-1 gap-2 xl:grid-cols-2",children:g.map(W=>{const j=y===W.id;return t.jsxs("button",{type:"button",onClick:()=>{b(W.id),d(ds(W))},className:Q("flex min-h-[4.25rem] items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors",j?"border-foreground bg-muted/50 shadow-raised":"border-border bg-background hover:border-foreground/20 hover:bg-accent"),children:[t.jsx(Ue,{name:W.name,avatar:W.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-medium text-foreground",children:W.name}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-muted-foreground",children:W.providerId}),t.jsxs("span",{className:"mt-1 block truncate text-xs text-muted-foreground",children:[l(mr(W.workspacePolicy))," · ",l(Ll(W.sessionPolicy))]})]}),j?t.jsx(Et,{size:16,className:"shrink-0 text-foreground"}):null]},W.id)})})})]}),z=()=>{const W=f==="edit";return W&&!T?t.jsx("div",{className:"p-5",children:t.jsx(pr,{icon:t.jsx(vt,{size:18}),title:l("Select a member"),description:l("Choose a member on the left to edit its future TeamRun configuration."),action:t.jsxs(ge,{type:"button",variant:"outline",size:"sm",onClick:N,disabled:R,children:[t.jsx(pt,{size:13}),l("Add member")]})})}):t.jsxs("div",{className:"flex min-h-0 flex-col lg:flex-1",children:[t.jsx("div",{className:"border-b border-border/60 px-5 py-4",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-foreground",children:[W?t.jsx(Ti,{size:15,className:"text-muted-foreground"}):t.jsx(pt,{size:15,className:"text-muted-foreground"}),t.jsx("span",{children:l(W?"Edit member":"Custom member")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:l(W?"Provider, role, workspace, and session changes apply to future work only.":"Create a one-off member snapshot for this TeamRun.")})]}),W&&T?t.jsxs(ge,{type:"button",variant:"outline",size:"sm",onClick:()=>h(T),disabled:R,className:"border-destructive/25 text-destructive-ink hover:bg-destructive/10 hover:text-destructive-ink",children:[t.jsx(Jn,{size:13}),l("Remove")]}):t.jsxs(ge,{type:"button",variant:"outline",size:"sm",onClick:N,disabled:R,children:[t.jsx(Pt,{size:13}),l("Use preset")]})]})}),t.jsxs("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:[W&&T?t.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg border border-border bg-muted/50 px-3 py-2.5",children:[t.jsx(Ue,{name:T.name,avatar:T.avatar,className:"h-9 w-9 text-xs"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:Q("h-2 w-2 shrink-0 rounded-full",fr(T))}),t.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:T.name})]}),t.jsxs("div",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:[T.providerId," · ",l(mr(T.workspacePolicy))]})]})]}):null,t.jsxs("div",{className:"space-y-5",children:[t.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Fe,{children:l("Name")}),t.jsx("input",{value:n.name,onChange:j=>B("name",j.target.value),className:"h-9 w-full rounded-lg border border-border px-3 text-sm outline-none transition-colors focus:border-ring"})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Fe,{children:l("Aliases")}),t.jsx("input",{value:n.aliasesText,onChange:j=>B("aliasesText",j.target.value),placeholder:l("Comma separated"),className:"h-9 w-full rounded-lg border border-border px-3 text-sm outline-none transition-colors focus:border-ring"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Fe,{children:l("Provider")}),t.jsx(Xe,{value:n.providerId,onChange:j=>B("providerId",j),options:I,placeholder:v.find(j=>j.provider.id===n.providerId)?.provider.name})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Fe,{children:l("Avatar")}),t.jsx("input",{value:n.avatar,onChange:j=>B("avatar",j.target.value),className:"h-9 w-full rounded-lg border border-border px-3 text-sm outline-none transition-colors focus:border-ring"})]})]}),t.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Fe,{children:l("Workspace policy")}),t.jsx(Xe,{value:n.workspacePolicy,onChange:j=>B("workspacePolicy",j),options:Bi.map(j=>({value:j.value,label:l(j.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Fe,{children:l("Trigger policy")}),t.jsx(Xe,{value:n.triggerPolicy,onChange:j=>B("triggerPolicy",j),options:Nl.map(j=>({value:j.value,label:l(j.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Fe,{children:l("Session policy")}),t.jsx(Xe,{value:n.sessionPolicy,onChange:j=>B("sessionPolicy",j),options:Oi.map(j=>({value:j.value,label:l(j.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Fe,{children:l("Queue policy")}),t.jsx(Xe,{value:n.queueManagementPolicy,onChange:j=>B("queueManagementPolicy",j),options:Tl.map(j=>({value:j.value,label:l(j.label)}))})]})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Fe,{children:l("Role prompt")}),t.jsx("textarea",{value:n.rolePrompt,onChange:j=>B("rolePrompt",j.target.value),rows:7,className:"w-full resize-y rounded-lg border border-border px-3 py-2 text-sm leading-relaxed outline-none transition-colors focus:border-ring"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Fe,{children:l("Capabilities")}),t.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-3",children:jl.map(j=>t.jsxs("label",{className:"flex min-h-9 items-center gap-2 rounded-md border border-border bg-background px-2.5 py-2 text-xs text-foreground/80",children:[t.jsx("input",{type:"checkbox",checked:!!n.capabilities[j.key],onChange:F=>H(j.key,F.target.checked)}),t.jsx("span",{className:"min-w-0 truncate",children:l(j.label)})]},j.key))})]})]})]})]})};return t.jsxs(t.Fragment,{children:[t.jsx(At,{isOpen:e,onClose:R?()=>{}:r,title:l("Manage Team Members"),className:"max-w-6xl",action:t.jsxs(t.Fragment,{children:[t.jsx(ge,{type:"button",variant:"outline",onClick:r,disabled:R,children:l("Close")}),t.jsx(ge,{type:"button",onClick:q,disabled:R||!O,children:l(R?"Processing...":f==="edit"?"Save member":"Add member")})]}),children:t.jsxs("div",{className:"grid min-h-0 grid-cols-1 overflow-visible rounded-lg border border-border bg-background lg:h-[min(42rem,calc(100vh-13rem))] lg:min-h-[34rem] lg:grid-cols-[20rem_minmax(0,1fr)] lg:overflow-hidden",children:[t.jsxs("aside",{className:"flex min-h-0 flex-col border-b border-border bg-muted/35 lg:border-b-0 lg:border-r",children:[t.jsx("div",{className:"border-b border-border px-4 py-4",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-foreground",children:[t.jsx(vt,{size:15,className:"text-muted-foreground"}),t.jsx("span",{children:l("Members")})]}),t.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[x.length," ",l("active")," · ",M," ",l("working")]})]}),t.jsx(ge,{type:"button",size:"icon-sm",variant:"outline",onClick:N,disabled:R,title:l("Add member"),children:t.jsx(pt,{size:14})})]})}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-2 lg:min-h-0 lg:max-h-none lg:flex-1",children:x.length===0?t.jsx("div",{className:"rounded-lg border border-dashed border-border bg-background px-3 py-5 text-center text-xs text-muted-foreground",children:l("No active members")}):t.jsx("div",{className:"space-y-1",children:x.map(W=>{const j=f==="edit"&&p===W.id;return t.jsxs("button",{type:"button",onClick:()=>$(W),className:Q("group flex w-full items-center gap-2 rounded-lg border px-2.5 py-2 text-left transition-colors",j?"border-border bg-background shadow-raised":"border-transparent hover:border-border hover:bg-background"),children:[t.jsx(Ue,{name:W.name,avatar:W.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:Q("h-1.5 w-1.5 shrink-0 rounded-full",fr(W))}),t.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:W.name})]}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-muted-foreground",children:W.providerId})]}),t.jsx(La,{size:13,className:Q("shrink-0 text-muted-foreground transition-opacity",j?"opacity-100":"opacity-0 group-hover:opacity-100")})]},W.id)})})}),t.jsx("div",{className:"border-t border-border p-2",children:t.jsx(Eo,{block:!0,"aria-label":l("Add member"),value:f,onValueChange:W=>W==="add-preset"?N():P(),options:[{value:"add-preset",label:l("Preset"),icon:t.jsx(Pt,{}),disabled:R},{value:"add-custom",label:l("Custom"),icon:t.jsx(ar,{}),disabled:R}]})})]}),t.jsx("section",{className:"flex min-h-0 min-w-0 flex-col",children:f==="add-preset"?U():z()})]})}),t.jsx(jo,{isOpen:!!c,onClose:()=>h(null),onConfirm:K,title:l("Remove member"),variant:"danger",isLoading:o.isPending,confirmText:l("Remove"),description:t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{children:c?l("Remove this member from future TeamRun work?"):""}),c&&Ls(c)?t.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-destructive/25 bg-destructive/10 px-3 py-2 text-left text-destructive-ink",children:[t.jsx(Tt,{size:15,className:"mt-0.5 shrink-0"}),t.jsx("span",{className:"text-sm font-medium",children:l("确认后会停止当前工作并取消队列")})]}):null]})})]})}const Dl=[],Pl=[],Bl=[],Ol=240;function Il(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 gr={running:0,"waiting room reply":1,queued:2,"session ended":3,"pending approval":4,idle:5,removed:6};function hs(e){if(!e)return"";const r=new Date(e);return Number.isNaN(r.getTime())?"":r.toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function vr(e,r){return e instanceof Error?e.message:r}function Fl(e,r=Ol){const s=(e??"").replace(/\s+/g," ").trim();return s.length<=r?s:`${s.slice(0,r-3).trimEnd()}...`}function Ot(e){return e?e.instructionPreview??Fl(e.instruction):""}function Hl(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 zl(e){switch(e){case"running":return"border-success/25 bg-success/10 text-success-ink";case"waiting room reply":return"border-warning/25 bg-warning/10 text-warning-ink";case"queued":case"session ended":return"border-info/25 bg-info/10 text-info-ink";case"pending approval":return"border-border bg-muted/50 text-foreground/70";case"removed":return"border-border bg-muted/50 text-muted-foreground";case"idle":return"border-border bg-background text-muted-foreground"}}function Wl(e){switch(e){case"running":return"bg-success";case"waiting room reply":return"bg-warning";case"queued":case"session ended":return"bg-info";case"pending approval":return"bg-muted-foreground/60";case"removed":return"bg-foreground/15";case"idle":return"bg-foreground/15"}}function $l(e){switch(e){case"user":return"User";case"agent":return"Agent";case"system":return"System"}}function Ul(e){switch(e){case"RUNNING":return"border-success/25 bg-success/10 text-success-ink";case"WAITING_ROOM_REPLY":return"border-warning/25 bg-warning/10 text-warning-ink";case"QUEUED":case"SESSION_ENDED":return"border-info/25 bg-info/10 text-info-ink";case"COMPLETED":return"border-border bg-muted/50 text-foreground/80";case"FAILED":return"border-destructive/25 bg-destructive/10 text-destructive-ink";case"CANCELLED":return"border-border bg-background text-muted-foreground"}}function ql(e){switch(e){case We.ACTIVE:return"border-success/25 bg-success/10 text-success-ink";case We.MERGED:return"border-info/25 bg-info/10 text-info-ink";case We.HIBERNATED:return"border-warning/25 bg-warning/10 text-warning-ink";case We.ABANDONED:return"border-border bg-muted/50 text-muted-foreground"}}function Kl(e){switch(e){case"Main":return"border-border bg-muted/50 text-foreground/80";case"Child":return"border-border bg-muted/50 text-foreground/80";default:return"border-border bg-muted/50 text-foreground/70"}}function Xl(e){return[...e].sort((r,s)=>Date.parse(s.updatedAt??s.createdAt??"")-Date.parse(r.updatedAt??r.createdAt??""))}function Yl(e,r){return r.find(s=>s.memberId===e.id&&Zt.has(s.status))}function Xf({teamRun:e,workspaces:r,selectedWorkspaceId:s,onSelectWorkspace:l,onViewInvocationSession:g}){const{t:v}=re(),w=Yr(e.id),i=Vr(e.id),o=Kr(e.id),[u,f]=A.useState(null),[a,p]=A.useState(null),[m,y]=A.useState(!1),[b,n]=A.useState(!1),d=e.members??Dl,c=A.useMemo(()=>d.filter(B=>B.membershipStatus!=="REMOVED"),[d]),h=e.workRequests??Pl,_=e.invocations??Bl,S=A.useMemo(()=>Ys(r,e),[e,r]),k=A.useMemo(()=>new Map(h.map(B=>[B.id,B])),[h]),E=A.useMemo(()=>[...h].filter(B=>B.status==="PENDING_APPROVAL").sort((B,H)=>Date.parse(H.updatedAt??H.createdAt??"")-Date.parse(B.updatedAt??B.createdAt??"")),[h]),x=A.useMemo(()=>[...h].filter(B=>B.status==="QUEUED").sort((B,H)=>Date.parse(H.updatedAt??H.createdAt??"")-Date.parse(B.updatedAt??B.createdAt??"")),[h]),C=A.useMemo(()=>[...d].map(B=>({member:B,status:Il(B.status)})).sort((B,H)=>gr[B.status]-gr[H.status]),[d]),T=w.isError?w.error:i.isError?i.error:null,L=w.isPending||i.isPending,R=S.find(B=>B.workspace.id===s),M=e.messages??[],I=C.filter(({status:B})=>B==="running"||B==="waiting room reply").length;return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background",children:[t.jsx(Ml,{isOpen:b,onClose:()=>n(!1),teamRun:e}),t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border px-4 py-3 shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(js,{size:14,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:v("Team Status")})]}),t.jsxs("div",{className:"flex items-center gap-1.5 rounded-full border border-border bg-muted/50 px-2 py-0.5 text-xs font-medium text-muted-foreground",children:[t.jsx("span",{children:v("Team mode")}),t.jsx("span",{className:"text-foreground/80",children:e.mode})]})]}),t.jsxs("div",{className:"flex items-center gap-3 border-b border-border/60 px-4 py-1.5 shrink-0 text-xs text-muted-foreground",children:[t.jsxs("span",{className:"inline-flex items-center gap-1",title:v("Messages"),children:[t.jsx(No,{size:11,className:"text-muted-foreground/70"}),t.jsx("span",{className:"tabular-nums",children:M.length})]}),t.jsxs("span",{className:"inline-flex items-center gap-1",title:v("Members"),children:[t.jsx(vt,{size:11,className:"text-muted-foreground/70"}),t.jsx("span",{className:"tabular-nums",children:I>0?`${I}/${c.length}`:c.length}),I>0&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-success"})]}),x.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1",title:v("Queue"),children:[t.jsx(Ve,{size:11,className:"text-muted-foreground/70"}),t.jsx("span",{className:"tabular-nums",children:x.length})]}),E.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-warning-ink",title:v("Pending approval"),children:[t.jsx(Ve,{size:11}),t.jsx("span",{className:"tabular-nums",children:E.length})]})]}),t.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-app-thin px-4 py-3 space-y-3",children:[E.length>0&&t.jsxs("section",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-warning-ink",children:[t.jsx(Ve,{size:13}),t.jsx("span",{children:v("Pending approval")}),t.jsx("span",{className:"ml-auto rounded-full bg-warning/10 px-1.5 py-0.5 text-[11px] font-semibold text-warning-ink",children:E.length})]}),t.jsx("div",{className:"space-y-1.5",children:E.map(B=>{const H=d.find(P=>P.id===B.targetMemberId),$=w.isPending&&w.variables===B.id,N=i.isPending&&i.variables===B.id;return t.jsxs("div",{className:"rounded-md border border-warning/25 bg-warning/5 px-3 py-2",children:[t.jsx("div",{className:"flex items-start justify-between gap-2",children:t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(Ue,{name:H?.name??"Agent",avatar:H?.avatar??null,size:"xs",className:"size-4"}),t.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:H?.name??B.targetMemberId})]}),t.jsx("div",{className:"mt-1 text-xs leading-relaxed text-foreground/70 line-clamp-2",children:Ot(B)})]})}),t.jsxs("div",{className:"mt-1.5 flex items-center gap-x-2 text-xs text-muted-foreground",children:[t.jsx("span",{children:v($l(B.requesterType))}),t.jsx("span",{children:hs(B.createdAt)})]}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>w.mutate(B.id),disabled:L,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-success/25 bg-success/10 px-2 text-xs font-medium text-success-ink transition-colors hover:bg-success/15 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Et,{size:11}),t.jsx("span",{className:"truncate",children:v($?"Approving":"Approve")})]}),t.jsxs("button",{type:"button",onClick:()=>i.mutate(B.id),disabled:L,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-border bg-muted/50 px-2 text-xs font-medium text-foreground/80 transition-colors hover:bg-accent disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(tt,{size:11}),t.jsx("span",{className:"truncate",children:v(N?"Rejecting":"Reject")})]})]})]},B.id)})}),T&&t.jsx("div",{className:"rounded-md border border-destructive/25 bg-destructive/10 px-3 py-2 text-xs text-destructive-ink",children:vr(T,v("Failed to update work request"))})]}),t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground",children:[t.jsx(vt,{size:13}),t.jsx("span",{children:v("Members")}),t.jsx("span",{className:"ml-auto text-[11px] font-normal text-muted-foreground",children:c.length}),t.jsx("button",{type:"button",onClick:()=>n(!0),className:"rounded-md p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground/80",title:v("Manage Team Members"),"aria-label":v("Manage Team Members"),children:t.jsx(Ti,{size:13})})]}),d.length===0?t.jsx("div",{className:"py-3 text-center text-xs text-muted-foreground",children:v("No members")}):t.jsx("div",{className:"space-y-px rounded-md border border-border overflow-hidden",children:C.map(({member:B,status:H})=>{const $=Yl(B,_),N=Xl(_.filter(z=>z.memberId===B.id)),P=$?k.get($.workRequestId):void 0,D=a===B.id,O=H==="running"||H==="waiting room reply",q=O&&!!$,K=u===B.id,U=o.isPending&&o.variables?.memberId===B.id;return t.jsxs("div",{className:Q("bg-background",D&&"bg-muted/25"),children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[t.jsx(Ue,{name:B.name,avatar:B.avatar,className:"h-6 w-6 text-[10px] shrink-0"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:Q("h-1.5 w-1.5 shrink-0 rounded-full",Wl(H))}),t.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:B.name}),t.jsx("span",{className:Q("shrink-0 rounded-full border px-1.5 py-px text-xs font-medium leading-tight",zl(H)),children:v(Hl(H))})]}),O&&P?.instruction&&t.jsx("div",{className:"mt-0.5 truncate pl-3 text-xs text-muted-foreground",children:Ot(P)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[q&&t.jsx("button",{type:"button",onClick:()=>f(K?null:B.id),disabled:o.isPending,className:"rounded-md p-1 text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive-ink disabled:cursor-not-allowed disabled:opacity-50",title:v("Stop"),"aria-label":v("Stop"),children:t.jsx(qt,{size:12})}),$?.sessionId&&g&&t.jsx("button",{type:"button",onClick:()=>g($.sessionId),className:"rounded-md p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground/80",title:v("View log"),"aria-label":v("View log"),children:t.jsx(As,{size:12})}),t.jsx("button",{type:"button",onClick:()=>p(D?null:B.id),className:"rounded-md p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground/70",title:v("Details"),"aria-label":v("Details"),"aria-expanded":D,children:D?t.jsx(Ke,{size:13}):t.jsx(Je,{size:13})})]})]}),q&&K&&t.jsxs("div",{className:"mx-3 mb-2 rounded-md border border-border bg-muted/50 p-2",children:[t.jsx("div",{className:"mb-1.5 text-xs text-foreground/70",children:v("Stop running work?")}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{o.mutate({memberId:B.id,cancelQueued:!1},{onSuccess:()=>f(null)})},disabled:o.isPending,className:"inline-flex h-6 items-center gap-1 rounded-md border border-border bg-background px-2 text-xs font-medium text-foreground/80 transition-colors hover:bg-accent disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(qt,{size:10}),t.jsx("span",{children:U&&o.variables?.cancelQueued===!1?v("Stopping"):v("Stop only")})]}),t.jsxs("button",{type:"button",onClick:()=>{o.mutate({memberId:B.id,cancelQueued:!0},{onSuccess:()=>f(null)})},disabled:o.isPending,className:"inline-flex h-6 items-center gap-1 rounded-md border border-destructive/25 bg-destructive/10 px-2 text-xs font-medium text-destructive-ink transition-colors hover:bg-destructive/15 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Ni,{size:10}),t.jsx("span",{children:U&&o.variables?.cancelQueued===!0?v("Stopping"):v("Stop + clear queue")})]})]})]}),D&&t.jsxs("div",{className:"border-t border-border/60 px-3 py-2",children:[t.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[t.jsx("span",{children:B.providerId}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-foreground/15"}),t.jsx("span",{children:B.workspacePolicy}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-foreground/15"}),t.jsx("span",{children:B.sessionPolicy==="resume_last"?v("Resume last session"):v("New session per request")})]}),t.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:v("Invocation history")}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:N.length})]}),N.length===0?t.jsx("div",{className:"py-2 text-center text-xs text-muted-foreground",children:v("No invocations yet")}):t.jsx("div",{className:"space-y-1",children:N.map(z=>{const W=k.get(z.workRequestId),j=!!(z.sessionId&&g);return t.jsx("div",{className:"rounded-md border border-border/60 bg-background px-2.5 py-1.5",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:Q("rounded-full border px-1.5 py-px text-[10px] font-medium leading-tight",Ul(z.status)),children:z.status}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:hs(z.updatedAt??z.createdAt)})]}),t.jsx("div",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:Ot(W)||z.workRequestId})]}),j&&t.jsxs("button",{type:"button",onClick:()=>z.sessionId&&g?.(z.sessionId),className:"inline-flex h-5 shrink-0 items-center gap-1 rounded border border-border bg-background px-1.5 text-xs font-medium text-foreground/70 transition-colors hover:bg-accent",title:v("View log"),"aria-label":v("View log"),children:[t.jsx(As,{size:10}),t.jsx("span",{children:v("Log")})]})]})},z.id)})})]}),C[C.length-1]?.member.id!==B.id&&!D&&t.jsx("div",{className:"mx-3 border-b border-border/60"})]},B.id)})}),o.isError&&t.jsx("div",{className:"rounded-md border border-destructive/25 bg-destructive/10 px-3 py-2 text-xs text-destructive-ink",children:vr(o.error,v("Failed to stop member work"))})]}),x.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground",children:[t.jsx(Ve,{size:13}),t.jsx("span",{children:v("Queue")}),t.jsx("span",{className:"ml-auto rounded-full bg-muted px-1.5 py-0.5 text-[11px] font-semibold text-foreground/70",children:x.length})]}),t.jsx("div",{className:"space-y-1",children:x.map(B=>{const H=d.find($=>$.id===B.targetMemberId);return t.jsx("div",{className:"rounded-md border border-border bg-background px-3 py-2",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(Ue,{name:H?.name??"Agent",avatar:H?.avatar??null,size:"xs",className:"size-4"}),t.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:H?.name??B.targetMemberId})]}),t.jsx("div",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:Ot(B)})]}),t.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:hs(B.createdAt)})]})},B.id)})})]}),S.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>y(B=>!B),className:"flex w-full items-center gap-2 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground/80","aria-expanded":m,"aria-label":v("Workspaces"),children:[t.jsx(js,{size:13}),t.jsx("span",{children:v("Workspaces")}),t.jsxs("span",{className:"ml-auto flex items-center gap-1.5",children:[R&&t.jsx("span",{className:"max-w-[120px] truncate font-mono text-[11px] font-normal text-muted-foreground",children:jt(R.workspace)}),t.jsx("span",{className:"rounded-full bg-muted px-1.5 py-0.5 text-[11px] font-semibold text-foreground/70",children:S.length}),m?t.jsx(Ke,{size:13,className:"text-muted-foreground/70"}):t.jsx(Je,{size:13,className:"text-muted-foreground/70"})]})]}),m&&t.jsx("div",{className:"space-y-1.5",children:S.map(B=>{const H=s===B.workspace.id;return t.jsx("div",{className:Q("rounded-md border bg-background px-3 py-2",H?"border-foreground/25 shadow-raised":"border-border"),children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:v(B.displayName)}),t.jsx("span",{className:Q("shrink-0 rounded-full border px-1.5 py-px text-[11px] font-medium leading-tight",Kl(B.roleLabel)),children:v(B.roleLabel)}),t.jsx("span",{className:Q("shrink-0 rounded-full border px-1.5 py-px text-[11px] font-medium leading-tight",ql(B.workspace.status)),children:B.workspace.status})]}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-[11px] text-muted-foreground",children:jt(B.workspace)}),t.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground",children:[B.ownerName&&t.jsxs("span",{children:[v("Owner"),": ",B.ownerName]}),B.parentBranchName&&t.jsxs("span",{children:[v("Parent"),": ",B.parentBranchName]})]})]}),t.jsxs("button",{type:"button",onClick:()=>l?.(B.workspace.id),disabled:!l||H,className:"inline-flex h-6 shrink-0 items-center gap-1 rounded-md border border-border bg-muted/50 px-2 text-xs font-medium text-foreground/80 transition-colors hover:bg-accent disabled:cursor-not-allowed disabled:opacity-50",title:v("View workspace"),children:[H?t.jsx(Et,{size:11}):t.jsx(Qr,{size:11}),t.jsx("span",{children:v(H?"Selected":"Select")})]})]})},B.workspace.id)})})]}),E.length===0&&x.length===0&&C.every(({status:B})=>B==="idle")&&t.jsx("div",{className:"py-2 text-center text-xs text-muted-foreground",children:v("All members idle")})]})]})}var us={exports:{}},_r;function Vl(){return _r||(_r=1,(function(e,r){(function(s,l){e.exports=l()})(self,(()=>(()=>{var s={4567:function(w,i,o){var u=this&&this.__decorate||function(h,_,S,k){var E,x=arguments.length,C=x<3?_:k===null?k=Object.getOwnPropertyDescriptor(_,S):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(h,_,S,k);else for(var T=h.length-1;T>=0;T--)(E=h[T])&&(C=(x<3?E(C):x>3?E(_,S,C):E(_,S))||C);return x>3&&C&&Object.defineProperty(_,S,C),C},f=this&&this.__param||function(h,_){return function(S,k){_(S,k,h)}};Object.defineProperty(i,"__esModule",{value:!0}),i.AccessibilityManager=void 0;const a=o(9042),p=o(6114),m=o(9924),y=o(844),b=o(5596),n=o(4725),d=o(3656);let c=i.AccessibilityManager=class extends y.Disposable{constructor(h,_){super(),this._terminal=h,this._renderService=_,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=document.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=document.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let S=0;S<this._terminal.rows;S++)this._rowElements[S]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[S]);if(this._topBoundaryFocusListener=S=>this._handleBoundaryFocus(S,0),this._bottomBoundaryFocusListener=S=>this._handleBoundaryFocus(S,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=document.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new m.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((S=>this._handleResize(S.rows)))),this.register(this._terminal.onRender((S=>this._refreshRows(S.start,S.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((S=>this._handleChar(S)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
8
+ `);return v?{content:v,mentions:l,senderType:"user",...s.length>0?{attachmentIds:s}:{}}:null}function Wa({items:e,renderItem:i,scrollElementRef:s,compact:l}){const[g,v]=A.useState(null),[w,r]=A.useState(0),[o,u]=A.useState(!1),f=A.useCallback(m=>{if(!m)return;const y=s.current??m.closest("[data-room-scroll]");v(y),r(y?.clientHeight??0),u(!0)},[s]);A.useEffect(()=>{if(!g)return;const m=()=>r(g.clientHeight);if(m(),typeof ResizeObserver>"u")return;const y=new ResizeObserver(m);return y.observe(g),()=>y.disconnect()},[g]);const a=l?12:16,p=to({count:e.length,getScrollElement:()=>g,getItemKey:A.useCallback(m=>e[m].key,[e]),estimateSize:()=>160,overscan:6,scrollMargin:a,measureElement:m=>m.getBoundingClientRect().height});return p.shouldAdjustScrollPositionOnItemSizeChange=so,o?t.jsx("div",{ref:f,children:w>0?t.jsx("div",{style:{position:"relative",height:p.getTotalSize(),width:"100%"},children:p.getVirtualItems().map(m=>t.jsx("div",{"data-index":m.index,"data-room-row":m.key,ref:p.measureElement,style:{position:"absolute",top:m.start-a,left:0,width:"100%",paddingBottom:l?10:12},children:i(e[m.index])},m.key))},"virtual"):t.jsx("div",{className:l?"space-y-2.5":"space-y-3",children:e.slice(-20).map(m=>t.jsx("div",{"data-room-row":m.key,children:i(m)},m.key))},"unmeasured")}):t.jsx("div",{ref:f})}const ze=new WeakMap,lt=()=>new DOMException("Aborted","AbortError"),ls=e=>e instanceof Ze&&[401,403,404].includes(e.status);function $a(e,i,s){let l=ze.get(e);l||(l=new Map,ze.set(e,l));let g=l.get(i);if(g)g.owners.add(s),s.permission(g.denied);else{const v=new Set;let w=0,r=!1;const o=()=>{g.epoch++,!r&&(r=!0,queueMicrotask(()=>{if(r=!1,l.get(i)===g)for(const p of v)p.refresh()}))},u=()=>{const p=++w;e.emit(mt.SUBSCRIBE,{topic:"team-run",id:i},m=>{if(!(p!==w||l.get(i)!==g)){g.denied=!m.success;for(const y of v)y.permission(!m.success);o()}}),o()},f=p=>{p.teamRunId===i&&o()},a=p=>{if(p==="io server disconnect"){w++,g.denied=!0,g.epoch++;for(const m of v)m.permission(!0)}};g={owners:v,epoch:0,itemGenerations:new Map,denied:!1,dispose:()=>{w++,e.off("connect",u),e.off("disconnect",a),e.off(Le.TRANSLATION_INVALIDATED,f),e.emit(mt.UNSUBSCRIBE,{topic:"team-run",id:i})}},l.set(i,g),e.on("connect",u),e.on("disconnect",a),e.on(Le.TRANSLATION_INVALIDATED,f),v.add(s),e.connected&&u()}return()=>{g.owners.delete(s),g.owners.size||(g.dispose(),l.delete(i))}}function Bt(e,i){return ze.get(e)?.get(i)?.epoch??0}function ut(e,i,s){return ze.get(e)?.get(i)?.itemGenerations.get(s)??0}function Ua(e,i){const s=new Map(e?.map(l=>[l.sourceId,l]));return i.map(l=>{const g=s.get(l.sourceId);return g&&(g.sourceRevision>l.sourceRevision||g.sourceRevision===l.sourceRevision&&g.overlayRevision>l.overlayRevision)?g:l})}async function qa(e,i,s){const l=[];for(let g=0;g<i.length;g+=100){if(s.aborted)throw lt();const v=await oe.get(`/team-runs/${encodeURIComponent(e)}/translations`,{signal:s,params:{messageIds:i.slice(g,g+100).join(",")}});l.push(...v.items)}return l}function Ka(e,i){const s=De(),l=Ei({mutationKey:ie.accessAuth.identityChange})>0,g=ot(),[v,w]=A.useState(!1),[,r]=A.useState(0),o=A.useMemo(()=>i.filter(C=>C.teamRunId===e&&C.senderType==="agent"&&C.visibility==="PUBLIC"&&!C.id.startsWith("pending-")),[i,e]),u=A.useMemo(()=>[...new Set(o.map(C=>C.id))].sort(),[o]),f=A.useMemo(()=>o.map(C=>[C.id,C.content,C.contentPreview,C.isTruncated,C.senderId,C.senderInvocationId]),[o]),a=A.useMemo(()=>({teamRunId:e,accessGeneration:g,active:!0,allowed:!1,generation:0,summaries:new Map}),[e,g]),p=A.useRef(new Set(u)),m=A.useRef(new Set(u));p.current=new Set(u);const y=()=>{s.cancelQueries({queryKey:ie.roomTranslations.scope(e)}),s.removeQueries({queryKey:ie.roomTranslations.scope(e)})},b=()=>{if(g!==ot())return;const C=ze.get(be.getSocket())?.get(e);if(C){C.denied=!0;for(const T of C.owners)T.permission(!0)}else a.allowed=!1,a.generation++,w(!0);y()},n=Ee({queryKey:[...ie.roomTranslations.summaries(e),g,u,f],enabled:u.length>0&&!v&&!l,queryFn:async({signal:C})=>{const T=be.getSocket();try{for(let L=0;L<3;L++){const R=Bt(T,e),M=Object.fromEntries(u.map(B=>[B,ut(T,e,B)])),I=await qa(e,u,C);if(C.aborted||ze.get(T)?.get(e)?.denied||g!==ot())throw lt();if(R===Bt(T,e)&&u.every(B=>M[B]===ut(T,e,B)))return{items:I.filter(B=>B.teamRunId===e&&u.includes(B.messageId)),generations:M}}throw new Error("Translation snapshot changed while reading")}catch(L){throw ls(L)&&b(),L}},structuralSharing:(C,T)=>{const L=C,R=T;return{...R,items:Ua(L?.items.filter(M=>L.generations[M.messageId]===R.generations[M.messageId]),R.items)}},refetchOnMount:"always",refetchOnWindowFocus:!0,refetchInterval:5e3,retry:!1,gcTime:0});a.allowed=!v&&!l&&!n.isError&&n.isFetchedAfterMount&&g===ot();const d=n.data?.generations,c=A.useMemo(()=>a.allowed?n.data?.items??[]:[],[a.allowed,n.data]);a.summaries=new Map(c.filter(C=>p.current.has(C.messageId)&&d?.[C.messageId]===ut(be.getSocket(),e,C.messageId)).map(C=>[C.messageId,C])),A.useEffect(()=>{a.active=!0;const C=be.connect(),T=$a(C,e,{client:s,candidates:()=>p.current,withdraw:L=>{a.summaries.delete(L),r(R=>R+1)},refresh:()=>{s.invalidateQueries({queryKey:ie.roomTranslations.scope(e)},{cancelRefetch:!1})},permission:L=>{L&&(a.allowed=!1,a.generation++,a.summaries.clear(),y()),w(L)}});return()=>{a.active=!1,a.allowed=!1,a.generation++,T(),ze.get(C)?.has(e)||y()}},[s,e,a]),A.useLayoutEffect(()=>{const C=ze.get(be.getSocket())?.get(e),T=[...m.current].filter(L=>!p.current.has(L)&&![...C?.owners??[]].some(R=>R.candidates().has(L)));m.current=new Set(u);for(const L of T){const R=[...ie.roomTranslations.details(e),L];s.cancelQueries({queryKey:R}),s.removeQueries({queryKey:R})}},[s,e,u]),A.useEffect(()=>{if(!n.isSuccess||!n.isFetchedAfterMount)return;const C=new Set(c.map(L=>L.messageId)),T=s.getQueryCache().findAll({queryKey:ie.roomTranslations.details(e)}).filter(L=>u.includes(L.queryKey[3])&&!C.has(L.queryKey[3]));for(const L of T)s.cancelQueries({queryKey:L.queryKey,exact:!0}),s.removeQueries({queryKey:L.queryKey,exact:!0})},[s,e,c,u,n.isSuccess,n.isFetchedAfterMount]);const h=C=>{const T=a.summaries.get(C.messageId);return a.active&&a.allowed&&g===ot()&&p.current.has(C.messageId)&&d?.[C.messageId]===ut(be.getSocket(),e,C.messageId)&&T?.sourceId===C.sourceId&&T.sourceRevision===C.sourceRevision&&T.overlayRevision===C.overlayRevision},_=async C=>{if(!h(C))throw lt();const T=a.generation,L=ut(be.getSocket(),e,C.messageId),R=await s.fetchQuery({queryKey:ie.roomTranslations.full(e,C.messageId,C.sourceId,C.sourceRevision,C.overlayRevision),staleTime:0,gcTime:0,retry:!1,queryFn:async({signal:M})=>{try{for(let I=0;I<3;I++){const B=Bt(be.getSocket(),e),H=await oe.get(`/team-runs/${encodeURIComponent(e)}/messages/${encodeURIComponent(C.messageId)}/translation`,{signal:M}),$=ze.get(be.getSocket())?.get(e);if(M.aborted||g!==ot()||!$||$.denied||L!==ut(be.getSocket(),e,C.messageId)||![...$.owners].some(N=>N.candidates().has(C.messageId))||H.teamRunId!==e||H.messageId!==C.messageId||H.sourceId!==C.sourceId||H.sourceRevision!==C.sourceRevision)throw lt();if(H.overlayRevision>=C.overlayRevision&&B===Bt(be.getSocket(),e))return H}throw new Error("Translation detail changed while reading")}catch(I){throw I instanceof Ze&&I.status===404?S(C):ls(I)&&b(),I}}});if(T!==a.generation||!h(C))throw lt();return R},S=C=>{if(g!==ot())return;const T=ze.get(be.getSocket())?.get(e);if(T){T.itemGenerations.set(C.messageId,(T.itemGenerations.get(C.messageId)??0)+1);for(const L of T.owners)L.withdraw(C.messageId);for(const L of new Set([s,...[...T.owners].map(R=>R.client)])){const R=[...ie.roomTranslations.details(e),C.messageId];L.cancelQueries({queryKey:R}),L.removeQueries({queryKey:R});const M=ie.roomTranslations.summaries(e);L.cancelQueries({queryKey:M}),L.setQueriesData({queryKey:M},I=>I&&{...I,items:I.items.filter(B=>B.messageId!==C.messageId)}),L.invalidateQueries({queryKey:M},{cancelRefetch:!1})}}},k=async C=>{if(!h(C))throw lt();try{await oe.post(`/team-runs/${encodeURIComponent(e)}/translations/${encodeURIComponent(C.sourceId)}/retry`,{expectedRevision:C.sourceRevision})}catch(T){throw T instanceof Ze&&T.status===404?S(C):ls(T)&&b(),T}finally{s.invalidateQueries({queryKey:ie.roomTranslations.summaries(e)},{cancelRefetch:!1})}},E=[...a.summaries.values()],x=ro(`${e}:${g}`,o.map(C=>({id:C.id,revision:0})),E.map(C=>({id:C.messageId,version:`${C.sourceId}:${C.sourceRevision}`,state:C.state})),i.length>0);return{overlays:E,loadFull:_,isCurrent:h,retry:k,claimReveal:x}}const Xa=10,Ya=24,Ri=Xa*Ya,Va=8;function Ga(e,i=Ri){return e>i+Va}function Qa(e,i){return e.includes(i)?e:[...e,i]}function Za(e,i){return e.filter(s=>s!==i)}function Ja(e,i){const s=new Map(i.map(l=>[l.id,l]));return e.map(l=>s.get(l)).filter(l=>!!l).map(l=>({memberId:l.id,label:l.name}))}const Zt=new Set(["RUNNING","WAITING_ROOM_REPLY","QUEUED","SESSION_ENDED"]);function lr(e){if(!e)return 0;const i=Date.parse(e);return Number.isNaN(i)?0:i}function el(e,i=[],s=[]){const l=new Set(s.filter(v=>Zt.has(v.status)).map(v=>v.workRequestId));return[...e.map(v=>({kind:"message",key:`message:${v.id}`,sortTime:v.createdAt,order:0,message:v})),...i.filter(v=>v.status==="PENDING_APPROVAL").filter(v=>!l.has(v.id)).map(v=>({kind:"pendingApproval",key:`pending-approval:${v.id}`,sortTime:v.updatedAt??v.createdAt,order:1,request:v}))].sort((v,w)=>{const r=lr(v.sortTime)-lr(w.sortTime);return r!==0?r:v.order!==w.order?v.order-w.order:v.key.localeCompare(w.key)})}function tl(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 sl(e){switch(e){case"FAILED":return"text-destructive-ink";case"RUNNING":case"WAITING_ROOM_REPLY":case"QUEUED":case"SESSION_ENDED":return"text-muted-foreground";default:return"text-muted-foreground"}}function rl(e,i){const s=e.reduce((g,v)=>(g[v.status]=(g[v.status]??0)+1,g),{});return[["RUNNING","running"],["QUEUED","queued"],["WAITING_ROOM_REPLY","waiting"],["SESSION_ENDED","ended"]].map(([g,v])=>{const w=s[g];return w?`${w} ${i(v)}`:null}).filter(g=>!!g).join(" · ")}function il(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(min-width: 768px)").matches}function nl({status:e}){const{t:i}=re();return e==="RUNNING"?t.jsxs(t.Fragment,{children:[i("Working"),t.jsxs("span",{className:"active-work-dots","aria-hidden":"true",children:[t.jsx("span",{children:"."}),t.jsx("span",{className:"active-work-dots__second",children:"."}),t.jsx("span",{className:"active-work-dots__third",children:"."})]})]}):t.jsx(t.Fragment,{children:i(tl(e))})}function ol({invocations:e,memberById:i,workRequestById:s,onViewInvocationSession:l,onStopMember:g,isStopPending:v,stoppingMemberId:w,stopPromptInvocationId:r,onToggleStopConfirm:o}){const{t:u}=re(),[f,a]=A.useState(il),p=A.useMemo(()=>e.filter(y=>Zt.has(y.status)).sort((y,b)=>Date.parse(b.updatedAt??b.createdAt??"")-Date.parse(y.updatedAt??y.createdAt??"")),[e]);if(p.length===0)return null;const m=rl(p,u);return t.jsxs("div",{className:"border-t border-border bg-muted/40",children:[t.jsxs("button",{type:"button",onClick:()=>a(y=>!y),"aria-expanded":f,className:"flex h-8 w-full items-center justify-between gap-3 px-3 text-left text-xs text-foreground/70 transition-colors hover:bg-accent",children:[t.jsxs("span",{className:"min-w-0 truncate",children:[t.jsx("span",{className:"font-medium text-foreground",children:u("Active work")}),t.jsx("span",{className:"mx-1.5 text-muted-foreground",children:"·"}),t.jsx("span",{children:m})]}),f?t.jsx(Ke,{size:15,className:"shrink-0 text-muted-foreground/70"}):t.jsx(hi,{size:15,className:"shrink-0 text-muted-foreground/70"})]}),f&&t.jsx("div",{className:"max-h-32 overflow-y-auto border-t border-border",children:p.map(y=>{const b=i.get(y.memberId),n=s.get(y.workRequestId),d=!!(y.sessionId&&l),c=!!b,h=r===y.id,_=v&&w===y.memberId,S=n?.instruction??y.workRequestId;return t.jsxs("div",{className:"border-t border-border/60 first:border-t-0",children:[t.jsxs("div",{title:S,className:Q("group flex h-8 items-center gap-2 px-3 text-xs text-foreground/80",d?"cursor-pointer hover:bg-background":"cursor-default"),role:d?"button":void 0,tabIndex:d?0:void 0,onClick:()=>y.sessionId&&l?.(y.sessionId),onKeyDown:k=>{!d||!y.sessionId||(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),l?.(y.sessionId))},children:[t.jsx(Ue,{name:b?.name??u("Agent"),avatar:b?.avatar??null,size:"xs",className:"size-4"}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[t.jsx("span",{className:"truncate font-medium text-foreground",children:b?.name??u("Agent")}),t.jsx("span",{className:Q("shrink-0",sl(y.status)),children:t.jsx(nl,{status:y.status})})]}),d&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),y.sessionId&&l?.(y.sessionId)},onKeyDown:k=>k.stopPropagation(),className:"hidden shrink-0 rounded-md p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground/80 group-hover:inline-flex",title:u("View log"),"aria-label":`${u("View log")} ${b?.name??u("Agent")}`,children:t.jsx(As,{size:13})}),c&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),o(y.id)},onKeyDown:k=>k.stopPropagation(),disabled:_,className:"shrink-0 rounded-md p-1 text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive-ink disabled:cursor-not-allowed disabled:opacity-50",title:u("Stop"),"aria-label":`${u("Stop")} ${b?.name??u("Agent")}`,children:t.jsx(qt,{size:12})})]}),c&&h&&b&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 border-t border-border/60 bg-background px-3 py-2",children:[t.jsx("span",{className:"mr-1 text-xs text-foreground/70",children:u("Stop running work?")}),t.jsxs(ge,{type:"button",size:"xs",variant:"outline",disabled:_,onClick:()=>g(b.id,!1),children:[t.jsx(qt,{size:11}),t.jsx("span",{children:u(_?"Stopping":"Stop only")})]}),t.jsxs(ge,{type:"button",size:"xs",variant:"outline",disabled:_,className:"border-destructive/25 bg-destructive/10 text-destructive-ink hover:bg-destructive/15 hover:text-destructive-ink",onClick:()=>g(b.id,!0),children:[t.jsx(Ni,{size:11}),t.jsx("span",{children:u(_?"Stopping":"Stop + clear queue")})]})]})]},y.id)})})]})}const Rs=zs(),al=240;function cs(e,i){return{id:i.clientSubmissionId??Xr(),submissionInput:i,teamRunId:e,senderType:i.senderType??"user",senderId:i.senderId??null,senderInvocationId:i.senderInvocationId??null,kind:i.kind??((i.mentions?.length??0)>0?"work_request":"chat"),visibility:"PUBLIC",content:i.content,mentions:i.mentions??[],workRequestIds:[],artifactRefs:i.artifactRefs??[],attachmentIds:i.attachmentIds??[],createdAt:new Date().toISOString(),pendingStatus:"sending"}}function Xt(e){return"pendingStatus"in e}function ll(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function cl(e){if(!e)return"";const i=new Date(e);return Number.isNaN(i.getTime())?"":i.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Ks(e,i){return e instanceof Error?e.message:i}function dl(e,i=al){const s=(e??"").replace(/\s+/g," ").trim();return s.length<=i?s:`${s.slice(0,i-3).trimEnd()}...`}function hl(e,i){const l=e.slice(0,i).match(/(^|\s)@([^\s@]*)$/);return!l||l.index==null?null:{start:l.index+l[1].length,end:i,query:l[2]??""}}function ul(e,i){const s=i.trim().toLowerCase();return s?[e.name,e.providerId,...e.aliases??[]].some(g=>g.toLowerCase().includes(s)):!0}function cr(e){return e.membershipStatus!=="REMOVED"}function fl(e,i){return e.label??i.get(e.memberId)?.name??e.memberId}function ml(e,i){return(e.recipientMemberIds??[]).map(s=>i.get(s)?.name??s)}function pl(e,i){const s=e.mentions??[],l=e.contentPreview??e.content;if(s.length===0)return l;const g=s.map(w=>fl(w,i)).filter(w=>w&&!l.includes(`@${w}`));if(g.length===0)return l;const v=g.map(w=>`@${w}`).join(" ");return l.trimEnd()?`${l.trimEnd()} ${v}`:v}function gl(e,i,s){if(e.senderType!=="agent")return null;if(e.senderId&&i.has(e.senderId))return i.get(e.senderId)??null;if(e.senderInvocationId){const l=s.get(e.senderInvocationId);if(l?.memberId&&i.has(l.memberId))return i.get(l.memberId)??null}return null}function Li({content:e,workingDir:i,onOpenWorkspaceFile:s,onOpenPreviewUrl:l,onOpenVisualization:g,downloadSessionId:v}){const w=A.useMemo(()=>g||v?oo(e):e,[e,v,g]),r=ao(w),o=A.useMemo(()=>lo({workingDir:i,onOpenWorkspaceFile:s,onOpenPreviewUrl:l,onOpenVisualization:g,downloadSessionId:v}),[v,l,g,s,i]);return t.jsx("div",{className:Q("team-room-message-markdown prose prose-sm max-w-none break-words [overflow-wrap:anywhere]","prose-p:my-2 prose-p:first:mt-0 prose-p:last:mb-0 prose-p:leading-6","prose-ul:my-2 prose-ol:my-2 prose-li:my-1 prose-li:pl-0 prose-li:leading-6 prose-li:marker:text-muted-foreground","prose-blockquote:my-2 prose-blockquote:border-l-2 prose-blockquote:border-border prose-blockquote:pl-3 prose-blockquote:text-foreground/70","prose-pre:my-3 prose-pre:max-w-full prose-pre:overflow-x-auto prose-pre:rounded-md prose-pre:border prose-pre:border-border/60 prose-pre:bg-foreground/[0.025] prose-pre:p-3 prose-pre:text-xs prose-pre:leading-relaxed","prose-code:break-words prose-code:rounded prose-code:bg-muted prose-code:px-1 prose-code:py-0.5 prose-code:text-[0.9em] prose-code:font-medium prose-code:text-foreground","prose-pre:prose-code:bg-transparent prose-pre:prose-code:p-0 prose-pre:prose-code:text-foreground","prose-headings:mb-2 prose-headings:mt-3 prose-headings:font-semibold prose-headings:leading-snug","prose-hr:my-3 prose-hr:border-border","text-foreground prose-strong:text-foreground"),children:t.jsx(li,{components:o,plugins:r,controls:r?co:void 0,children:w})})}function vl({hasAttachmentIds:e,attachments:i,isLoading:s,onOpenImage:l}){if(!e)return null;if(s&&i.length===0)return t.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"Loading attachments..."});if(i.length===0)return null;const g=i.filter(w=>w.mimeType.startsWith("image/")),v=new Map(g.map((w,r)=>[w.id,r]));return t.jsx("div",{className:"mt-3 flex flex-wrap gap-2 text-foreground/80",children:i.map(w=>{const r=`${Rs}${w.url}`;if(w.mimeType.startsWith("image/")){const u=v.get(w.id)??0;return t.jsxs("button",{type:"button",onClick:()=>l(g,u),className:"group relative h-24 w-24 overflow-hidden rounded-lg border border-border bg-muted/50 shadow-raised transition-opacity hover:opacity-90",title:w.originalName,children:[t.jsx("img",{src:r,alt:w.originalName,className:"h-full w-full object-cover",loading:"lazy"}),t.jsx("span",{className:"absolute inset-x-0 bottom-0 truncate bg-inverse/60 px-1.5 py-1 text-left text-[11px] text-inverse-foreground",children:w.originalName})]},w.id)}return t.jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"flex max-w-[220px] items-center gap-2 rounded-lg border border-border bg-background px-3 py-2 text-xs text-foreground/80 shadow-raised hover:bg-accent",title:w.originalName,children:[t.jsx(wo,{size:16,className:"shrink-0 text-muted-foreground/70","aria-hidden":!0}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate font-medium",children:w.originalName}),t.jsx("span",{className:"text-muted-foreground",children:ll(w.sizeBytes)})]}),t.jsx(Hs,{size:13,className:"shrink-0 text-muted-foreground/70","aria-hidden":!0})]},w.id)})})}function Mi({message:e,content:i,attachmentIds:s,isUser:l,tone:g,onOpenImage:v,workingDir:w,onOpenWorkspaceFile:r,onOpenPreviewUrl:o,onOpenVisualization:u,downloadSessionId:f,textVersion:a}){const p=A.useMemo(()=>Array.from(new Set(s??[])),[s]),{data:m=[],isLoading:y}=bo(p),b=m.length>0?$t(i,m):i;return t.jsxs(t.Fragment,{children:[b.trim()&&t.jsx(bl,{message:e,content:b,attachments:m,isUser:l,tone:g,workingDir:w,onOpenWorkspaceFile:r,onOpenPreviewUrl:o,onOpenVisualization:u,downloadSessionId:f,textVersion:a}),t.jsx(vl,{hasAttachmentIds:p.length>0,attachments:m,isLoading:y,onOpenImage:v})]})}function _l({images:e,index:i,onClose:s,onSelect:l}){const g=e[i];if(!g)return null;const v=i>0,w=i<e.length-1;return t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-inverse/90 p-4",role:"dialog","aria-modal":"true",children:[t.jsx("button",{type:"button",onClick:s,className:"absolute right-4 top-4 rounded-full bg-inverse-foreground/10 p-2 text-inverse-foreground transition-colors hover:bg-inverse-foreground/20","aria-label":"Close image preview",children:t.jsx(tt,{size:20})}),v&&t.jsx("button",{type:"button",onClick:()=>l(i-1),className:"absolute left-4 top-1/2 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-inverse-foreground/10 text-inverse-foreground transition-colors hover:bg-inverse-foreground/20","aria-label":"Previous image",children:t.jsx(oa,{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:`${Rs}${g.url}`,alt:g.originalName,className:"max-h-[82vh] max-w-[92vw] rounded-lg object-contain"}),t.jsxs("div",{className:"flex items-center gap-3 text-sm text-inverse-foreground",children:[t.jsx("span",{className:"max-w-[70vw] truncate",children:g.originalName}),t.jsxs("a",{href:`${Rs}${g.url}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-md bg-inverse-foreground/10 px-2 py-1 text-xs hover:bg-inverse-foreground/20",children:[t.jsx(Hs,{size:13,"aria-hidden":!0}),"Open"]})]})]}),w&&t.jsx("button",{type:"button",onClick:()=>l(i+1),className:"absolute right-4 top-1/2 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-inverse-foreground/10 text-inverse-foreground transition-colors hover:bg-inverse-foreground/20","aria-label":"Next image",children:t.jsx(Je,{size:24,"aria-hidden":!0})})]})}const Di=A.createContext(null);function bl({message:e,content:i,attachments:s,isUser:l,tone:g=l?"user":"agent",workingDir:v,onOpenWorkspaceFile:w,onOpenPreviewUrl:r,onOpenVisualization:o,downloadSessionId:u,textVersion:f}){const{t:a}=re(),p=A.useId(),m=A.useRef(null),y=A.useContext(Di),[b,n]=A.useState(()=>y?.get(e.id)??null),d=A.useCallback(N=>{N.expanded?y?.set(e.id,N):y?.delete(e.id),n(N)},[y,e.id]),[c,h]=A.useState(!1),[_,S]=A.useState(null),k=Gr(e.teamRunId,e.id,!1),E=f?f.full:k.data?.content,x=E?$t(E,s):void 0,T=!!(x&&x!==i)?x:i,L=!!((f?f.truncated:e.isTruncated)&&!Xt(e)),R=b?.messageId===e.id&&b.content===T&&b.expanded,M=A.useCallback(()=>{const N=m.current;N&&h(Ga(N.scrollHeight))},[]);A.useLayoutEffect(()=>{M();const N=m.current;if(!N)return;const P=window.requestAnimationFrame(M),D=typeof ResizeObserver>"u"?null:new ResizeObserver(M);return D?.observe(N),window.addEventListener("resize",M),()=>{window.cancelAnimationFrame(P),D?.disconnect(),window.removeEventListener("resize",M)}},[T,M]);const I=A.useCallback(async()=>{if(S(null),R){d({messageId:e.id,content:T,expanded:!1});return}if(L&&!E){if(f){try{const D=await f.load();d({messageId:e.id,content:$t(D,s),expanded:!0})}catch{S(a("Failed to load full message"))}return}const N=await k.refetch();if(N.error){S(Ks(N.error,a("Failed to load full message")));return}const P=N.data?.content?$t(N.data.content,s):T;d({messageId:e.id,content:P,expanded:!0});return}d({messageId:e.id,content:T,expanded:!0})},[s,L,E,k,R,e.id,T,d,a,f]),B=(c||L)&&!R,H=c||L,$=f?f.loading:k.isFetching;return t.jsxs("div",{className:"relative",children:[t.jsxs("div",{id:p,ref:m,onLoadCapture:M,className:Q("relative transition-[max-height] duration-200 ease-out",B?"overflow-hidden":""),style:B?{maxHeight:Ri}:void 0,children:[t.jsx(Li,{content:T,isUser:l,workingDir:v,onOpenWorkspaceFile:w,onOpenPreviewUrl:r,onOpenVisualization:o,downloadSessionId:u}),B&&t.jsx("div",{className:Q("pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-gradient-to-b from-transparent",g==="system"?"to-[color-mix(in_oklab,var(--color-warning)_8%,var(--color-background))]":g==="user"?"to-[color-mix(in_oklab,var(--color-foreground)_8%,var(--color-background))]":"to-background")})]}),H&&t.jsxs("button",{type:"button","aria-expanded":R,"aria-controls":p,"aria-label":a(R?"Collapse message":"Expand full message"),disabled:$,onClick:()=>{I()},className:Q("mt-2 inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",g==="system"?"bg-warning/10 text-warning-ink hover:bg-warning/20":g==="user"?"bg-background/70 text-foreground/70 hover:bg-background hover:text-foreground":"bg-muted text-foreground/70 hover:bg-foreground/10 hover:text-foreground",$?"cursor-wait opacity-70":""),children:[R?t.jsx(hi,{size:13}):t.jsx(Ke,{size:13}),t.jsx("span",{children:a($?"Loading":R?"Collapse message":"Expand full message")})]}),_&&t.jsx("div",{className:Q("mt-1 text-xs","text-destructive-ink"),children:_})]})}function Pi({senderName:e,avatar:i,createdAt:s,isUser:l,isSystem:g,children:v,headerAddon:w,footer:r,bubbleClassName:o,isPending:u}){return g?t.jsx("div",{className:"flex justify-center",children:t.jsx("div",{className:"max-w-[min(100%,42rem)] rounded-lg border border-warning/25 bg-warning/10 px-3 py-2 text-xs text-warning-ink shadow-raised",children:v})}):t.jsxs("div",{className:Q("group flex items-start gap-3",l?"justify-end pl-8 sm:pl-14":"justify-start pr-8 sm:pr-14"),children:[!l&&t.jsx(Ue,{name:e,avatar:i??null,className:"mt-0.5 h-8 w-8 text-[11px]"}),t.jsxs("div",{className:Q("flex min-w-0 max-w-[min(86%,46rem)] flex-col",l?"items-end":"items-start"),children:[t.jsxs("div",{className:Q("mb-1.5 flex max-w-full items-center gap-1.5 px-0.5 text-xs text-muted-foreground",l?"justify-end":"justify-start"),children:[t.jsx("span",{className:"truncate font-semibold text-foreground/80",children:e}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-foreground/15","aria-hidden":!0}),t.jsx(Ve,{size:11,className:"text-muted-foreground/70"}),t.jsx("span",{className:"shrink-0",children:cl(s)}),w]}),t.jsx("div",{className:Q("max-w-full rounded-lg px-3.5 py-3 text-sm leading-6 transition-colors",l?"rounded-tr-[4px] bg-foreground/[0.08] text-foreground":"rounded-tl-[4px] border border-border/70 bg-background text-foreground",o,u?"opacity-70":""),children:v}),r&&t.jsx("div",{className:"mt-1 max-w-full px-0.5","data-message-feedback":!0,children:r})]}),l&&t.jsx(Ue,{name:e,avatar:null,className:"mt-0.5 h-8 w-8 text-[11px]"})]})}function xl({provider:e}){return t.jsxs("span",{className:"ml-0.5 inline-flex max-w-[10rem] shrink items-center gap-1 rounded-full bg-foreground/5 px-1.5 py-0.5 text-xs font-medium leading-none text-muted-foreground",children:[t.jsx(Gt,{agentType:e.agentType,className:"size-2.5"}),t.jsx("span",{className:"truncate",children:e.name})]})}function Sl({overlay:e,translations:i,enabled:s,body:l}){const{t:g}=re(),[v,w]=A.useState(null),[r,o]=A.useState(!1),[u,f]=A.useState(null),a=A.useRef(null),p=A.useRef(!0);A.useEffect(()=>(p.current=!0,()=>{p.current=!1}),[]);const m=()=>p.current&&i.isCurrent(e),y=async()=>{if(!m())throw new DOMException("Aborted","AbortError");return v||(a.current||(o(!0),f(null),a.current=i.loadFull(e).then(_=>{if(!m())throw new DOMException("Aborted","AbortError");if(!l.message.isTruncated&&l.message.contentMode==="full"&&l.message.content!==_.originalText)throw new Error("Message changed");return w(_),_}).catch(_=>{throw m()&&f(g("Failed to load full message")),_}).finally(()=>{a.current=null,p.current&&o(!1)})),a.current)},b=e.state==="SUCCESS"&&e.translatedTextPreview!==null,n=v?.originalText??e.originalTextPreview,d=v?.translatedText??e.translatedTextPreview??"",c=async()=>e.originalTextTruncated?(await y()).originalText:n,h=async()=>b?e.translatedTextTruncated?(await y()).translatedText??"":d:c();return t.jsxs("div",{className:`relative ${e.state==="NOT_REQUIRED"?"":"pr-8"}`,children:[t.jsx(Mi,{...l,content:b?d:l.content,textVersion:b?{kind:"translated",truncated:e.translatedTextTruncated,full:v?.translatedText??void 0,loading:r,load:h}:void 0}),e.state!=="NOT_REQUIRED"&&t.jsx("div",{className:"absolute bottom-0 right-0",children:t.jsxs(ai,{original:n,getOriginal:c,canCopy:m,onOpen:()=>{e.originalTextTruncated&&y().catch(()=>{})},loading:r,error:u,children:[t.jsx(Li,{content:n,workingDir:l.workingDir,onOpenWorkspaceFile:l.onOpenWorkspaceFile,onOpenPreviewUrl:l.onOpenPreviewUrl,onOpenVisualization:l.onOpenVisualization,downloadSessionId:l.downloadSessionId}),t.jsx(no,{state:e.state,errorCode:e.errorCode,enabled:s,onRetry:()=>i.retry(e)})]})})]})}function yl({message:e,senderName:i,senderMember:s,senderProvider:l,memberById:g,displayContent:v,onOpenImage:w,workingDir:r,onOpenWorkspaceFile:o,onOpenPreviewUrl:u,onOpenVisualization:f,previewWorkspaceId:a,previewSessionId:p,overlay:m,translations:y,translationEnabled:b,delivery:n,onRetrySubmission:d}){const{t:c}=re(),h=e.senderType==="user",_=e.senderType==="system",S=!n&&Xt(e)?e.pendingStatus:null,k=e.mentions??[],E=e.workRequestIds?.length??0,x=e.visibility==="PRIVATE",C=A.useCallback(I=>{u?.(I,a)},[u,a]),T=A.useCallback(I=>{p&&f?.(p,I,a)},[f,p,a]),L=x?ml(e,g):[],R={message:e,content:v,attachmentIds:e.attachmentIds,isUser:h&&S!=="failed",tone:_?"system":void 0,onOpenImage:w,workingDir:r,onOpenWorkspaceFile:o,onOpenPreviewUrl:u?C:void 0,onOpenVisualization:f&&p?T:void 0,downloadSessionId:p},M=t.jsxs(t.Fragment,{children:[!h&&!_&&l&&t.jsx(xl,{provider:l}),x&&t.jsxs("span",{className:"ml-0.5 inline-flex max-w-[18rem] shrink items-center gap-1 rounded-full bg-foreground/[0.06] px-1.5 py-0.5 text-xs font-medium leading-none text-foreground/70",title:L.join(", "),children:[t.jsx(Fn,{size:10}),t.jsxs("span",{className:"truncate",children:[c("Private"),L.length>0?`: ${L.join(", ")}`:""]})]}),!_&&E>0&&k.length===0&&t.jsxs("span",{className:"ml-0.5 shrink-0 rounded-full bg-foreground/[0.08] px-1.5 py-0.5 text-xs font-medium leading-none text-foreground/70",children:[c("Work requests"),": ",E]}),S==="failed"&&t.jsx("span",{className:"ml-0.5 shrink-0 rounded-full bg-destructive/10 px-1.5 py-0.5 text-xs font-medium leading-none text-destructive-ink",children:c("Acceptance unknown")})]});return t.jsx(Pi,{senderName:i,avatar:s?.avatar??null,createdAt:e.createdAt,isUser:h,isSystem:_,headerAddon:M,bubbleClassName:h&&S==="failed"?"border border-destructive/25 bg-destructive/10 text-destructive-ink":void 0,isPending:S==="sending",footer:n||e.userDelivery||S==="failed"?t.jsxs(t.Fragment,{children:[n&&t.jsx(oi,{delivery:n}),e.userDelivery&&!n&&t.jsx(wl,{message:e}),S==="failed"&&!n&&t.jsxs("div",{className:"text-xs",children:[t.jsx("p",{children:c("Acceptance unknown; check or retry the same submission.")}),Xt(e)&&e.error&&t.jsx("p",{children:e.error}),t.jsx("button",{type:"button",className:"underline",onClick:d,children:c("Retry original submission")})]})]}):void 0,children:t.jsx(io,{claim:y.claimReveal,version:m?.state==="SUCCESS"?`${m.sourceId}:${m.sourceRevision}`:null,children:m?t.jsx(Sl,{overlay:m,translations:y,enabled:b,body:R},`${m.sourceId}:${m.sourceRevision}:${m.overlayRevision}`):t.jsx(Mi,{...R})})})}function wl({message:e}){const i=Gr(e.teamRunId,e.id,!1),s=e.userDelivery;if(s.sentMode!=="TRANSLATED")return null;const l=i.data?.userDelivery?.actualSentText??s.actualSentText??"",g=async()=>{if(!s.isTruncated)return l;const v=await i.refetch();if(v.error||!v.data?.userDelivery)throw new Error("Failed to load sent text");return v.data.userDelivery.actualSentText??""};return t.jsx(ai,{label:"Actual sent text",original:l,getOriginal:g,onOpen:()=>{s.isTruncated&&i.refetch()},loading:i.isFetching,error:i.error?.message,children:t.jsx("pre",{className:"whitespace-pre-wrap",children:l})})}function Cl({request:e,member:i,onApprove:s,onReject:l,isActionPending:g,isApprovePending:v,isRejectPending:w}){const{t:r}=re();return t.jsx(Pi,{senderName:i?.name??r("Agent"),avatar:i?.avatar??null,createdAt:e.createdAt,bubbleClassName:"border border-warning/25 bg-warning/8",children:t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-warning/25 bg-warning/10 px-2 py-0.5 text-xs font-medium text-warning-ink",children:[t.jsx(Ve,{size:11}),r("Pending approval")]}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:[r("Requester"),": ",r(e.requesterType==="user"?"User":e.requesterType==="system"?"System":"Agent")]})]}),t.jsx("div",{className:"text-sm leading-6 text-foreground [overflow-wrap:anywhere]",children:e.instructionPreview??dl(e.instruction)}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs(ge,{type:"button",size:"xs",variant:"outline",disabled:g,className:"border-success/25 bg-success/10 text-success-ink hover:bg-success/15 hover:text-success-ink",onClick:s,children:[t.jsx(Et,{size:12}),t.jsx("span",{children:r(v?"Approving":"Approve")})]}),t.jsxs(ge,{type:"button",size:"xs",variant:"outline",disabled:g,onClick:l,children:[t.jsx(tt,{size:12}),t.jsx("span",{children:r(w?"Rejecting":"Reject")})]})]})]})})}const kl=A.memo(function({teamRun:i,messages:s,timelineItems:l,recovered:g,scrollElementRef:v,compact:w,onRetrySubmission:r,onOpenImage:o,workingDir:u,onOpenWorkspaceFile:f,onOpenPreviewUrl:a,onOpenVisualization:p}){const{t:m}=re(),y=Yr(i.id),b=Ka(i.id,s),{data:n}=di(),d=new Map(b.overlays.map(L=>[L.messageId,L])),c=Vr(i.id),{data:h}=Ws(),_=A.useMemo(()=>{const L=new Map;for(const R of h??[])L.set(R.provider.id,R.provider);return L},[h]),S=A.useMemo(()=>new Map((i.members??[]).map(L=>[L.id,L])),[i.members]),k=A.useMemo(()=>new Map((i.invocations??[]).map(L=>[L.id,L])),[i.invocations]),E=y.isError?y.error:c.isError?c.error:null,x=y.isPending||c.isPending,[C]=A.useState(()=>new Map);A.useEffect(()=>{const L=new Set(s.map(R=>R.id));for(const R of C.keys())L.has(R)||C.delete(R)},[C,s]);const T=L=>{if(L.kind==="pendingApproval"){const D=L.request,O=S.get(D.targetMemberId),q=y.isPending&&y.variables===D.id,K=c.isPending&&c.variables===D.id;return t.jsx(Cl,{request:D,member:O,onApprove:()=>y.mutate(D.id),onReject:()=>c.mutate(D.id),isActionPending:x,isApprovePending:q,isRejectPending:K},L.key)}const R=L.message,M=gl(R,S,k),I=R.senderType==="user"?m("你"):R.senderType==="system"?m("System"):M?.name??m("Agent"),B=pl(R,S),H=M?.providerId?_.get(M.providerId)??null:null,$=R.senderInvocationId?k.get(R.senderInvocationId):void 0,N=$?.workspaceId??void 0,P=$?.sessionId??void 0;return t.jsx(yl,{message:R,senderName:I,senderMember:M,senderProvider:H,memberById:S,displayContent:B,overlay:d.get(R.id),translations:b,translationEnabled:n?.enabled===!0,delivery:g.get(R.userDelivery?.clientSubmissionId??R.id),onRetrySubmission:Xt(R)?()=>r(R):void 0,onOpenImage:o,workingDir:u,onOpenWorkspaceFile:f,onOpenPreviewUrl:a,onOpenVisualization:p,previewWorkspaceId:N,previewSessionId:P},L.key)};return t.jsxs(Di.Provider,{value:C,children:[l.length===0?t.jsxs("div",{className:"flex min-h-[180px] flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-border bg-background text-muted-foreground",children:[t.jsx(vt,{size:24,className:"text-muted-foreground/70"}),t.jsx("span",{className:"text-sm",children:m("No room messages yet")})]}):t.jsx(Wa,{items:l,renderItem:T,scrollElementRef:v,compact:w}),E&&t.jsx("div",{className:"rounded-md border border-destructive/25 bg-destructive/10 px-3 py-2 text-xs text-destructive-ink",children:Ks(E,m("Failed to update work request"))})]})});function Wf({teamRun:e,messages:i,readOnly:s,readOnlyMessage:l,onSendMessage:g,onViewInvocationSession:v,changeSummaryBar:w,compactComposer:r,centered:o,workingDir:u,onOpenWorkspaceFile:f,onOpenPreviewUrl:a,onOpenVisualization:p}){const{t:m}=re(),y=Kr(e.id),[b,n]=A.useState(""),[d,c]=A.useState(!1),[h,_]=A.useState(null),[S,k]=A.useState(0),[E,x]=A.useState([]),[C,T]=A.useState(!1),L=Es(s?"":`task:${e.taskId}`,"pending","TEAM_TASK"),R=Es(s?"":`task:${e.taskId}`,"sent","TEAM_TASK"),M=A.useMemo(()=>new Map([...L.data?.pages.flatMap(V=>V.items)??[],...R.data?.pages.flatMap(V=>V.items)??[]].filter(V=>V.destination.kind==="TEAM_ROOM"&&V.destination.teamRunId===e.id).sort((V,J)=>V.revision-J.revision).map(V=>[V.clientSubmissionId,V])),[L.data,R.data,e.id]),[I,B]=A.useState([]),[H,$]=A.useState(null),N=A.useRef(null),P=A.useRef(null),{files:D,addFiles:O,removeFile:q,clear:K,buildMarkdownLinks:U,getDoneAttachments:z,isUploading:W}=vo(),j=D.some(V=>V.status==="done"&&V.attachment),[F,X]=A.useState(null),{scrollRef:Y,contentRef:ee,isAtBottom:G,scrollToBottom:Z}=Co({resize:"instant",initial:"instant"}),ae=A.useRef(!1),he=A.useRef(null),je=A.useRef(e.id),se=A.useCallback(()=>(ae.current=!1,Z({animation:"instant",ignoreEscapes:!0})),[Z]);A.useEffect(()=>{if(je.current===e.id)return;je.current=e.id;const V=requestAnimationFrame(()=>{se()});return()=>cancelAnimationFrame(V)},[se,e.id]),A.useEffect(()=>{const V=Y.current;if(!V)return;const J=ne=>{if(ne.deltaY<0){ae.current=!0;return}ne.deltaY>0&&V.scrollHeight-V.scrollTop-V.clientHeight<=70&&(ae.current=!1)};return V.addEventListener("wheel",J,{passive:!0}),()=>V.removeEventListener("wheel",J)},[Y]);const Ae=A.useMemo(()=>new Map((e.members??[]).map(V=>[V.id,V])),[e.members]),te=A.useMemo(()=>(e.members??[]).filter(cr),[e.members]),me=A.useMemo(()=>new Set([...i.flatMap(V=>V.userDelivery?[V.userDelivery.clientSubmissionId]:[]),...L.data?.pages.flatMap(V=>V.items.map(J=>J.clientSubmissionId))??[]]),[i,L.data]);A.useEffect(()=>{for(const V of me)Pn(e.id,V);B(V=>V.some(J=>me.has(J.id))?V.filter(J=>!me.has(J.id)):V)},[me,e.id]);const Pe=A.useMemo(()=>{const V=new Set(i.map(le=>le.id)),J=new Set(i.flatMap(le=>le.userDelivery?[le.userDelivery.clientSubmissionId]:[])),ne=[...M.values()].filter(le=>le.state!=="CANCELLED"&&!J.has(le.clientSubmissionId)).map(le=>({...cs(e.id,{content:le.originalText,clientSubmissionId:le.clientSubmissionId,attachmentIds:le.attachmentIds}),pendingStatus:"sending",createdAt:le.createdAt})),ye=I.filter(le=>!V.has(le.id)&&!J.has(le.id)&&!M.has(le.id));return[...i,...ne,...ye].sort((le,we)=>Date.parse(le.createdAt??"")-Date.parse(we.createdAt??""))},[i,I,M,e.id]),qe=A.useMemo(()=>new Map((e.workRequests??[]).map(V=>[V.id,V])),[e.workRequests]),ve=A.useMemo(()=>el(Pe,e.workRequests??[],e.invocations??[]),[Pe,e.invocations,e.workRequests]);A.useEffect(()=>{const V=ve.at(-1)?.key??null,J=he.current;if(he.current=V,J==null||V==null||V===J||ae.current)return;const ne=requestAnimationFrame(()=>{Z({animation:"instant",preserveScrollPosition:!0})});return()=>cancelAnimationFrame(ne)},[Z,ve]);const Re=A.useMemo(()=>(e.invocations??[]).filter(V=>Zt.has(V.status)),[e.invocations]),Se=A.useMemo(()=>E.map(V=>Ae.get(V)).filter(V=>!!V).filter(cr),[Ae,E]),Ce=A.useMemo(()=>{const V=h?.query??"";return te.filter(J=>ul(J,V)).sort((J,ne)=>{const ye=E.includes(J.id),le=E.includes(ne.id);return ye!==le?ye?1:-1:J.name.localeCompare(ne.name)})},[te,h?.query,E]),rt=!s&&(d||!!h)&&Ce.length>0,Ne=A.useCallback((V,J)=>{if(J==null){_(null);return}_(hl(V,J)),k(0)},[]),it=A.useCallback(V=>{x(we=>Qa(we,V.id));const J=`@${V.name} `;if(h){const we=`${b.slice(0,h.start)}${J}${b.slice(h.end)}`,dt=h.start+J.length;n(we),_(null),c(!1),requestAnimationFrame(()=>{N.current?.focus(),N.current?.setSelectionRange(dt,dt)});return}const ne=b.length===0||/\s$/.test(b)?"":" ",ye=`${b}${ne}${J}`,le=ye.length;n(ye),c(!1),requestAnimationFrame(()=>{N.current?.focus(),N.current?.setSelectionRange(le,le)})},[b,h]),Ie=A.useCallback(V=>{x(J=>Za(J,V))},[]),nt=A.useCallback(V=>{const J=V.target.value;n(J);const ne=V.target;ne.style.height="auto",ne.style.height=`${Math.max(r?40:72,Math.min(ne.scrollHeight,r?140:240))}px`,c(!1),Ne(J,ne.selectionStart)},[r,Ne]),ue=A.useCallback(V=>{const J=V.target.files;J&&J.length>0&&O(Array.from(J)),V.target.value=""},[O]),rs=A.useCallback(V=>{const J=[];for(const ne of V.clipboardData.items)if(ne.kind==="file"){const ye=ne.getAsFile();ye&&J.push(ye)}J.length>0&&(V.preventDefault(),O(J))},[O]),is=A.useCallback(async()=>{if(s||C||W)return;const V=U(),J=z().map(we=>we.id),ne=Ja(E,te),ye=za({draft:b,attachmentMarkdown:V,attachmentIds:J,mentions:ne});if(!ye||!b.trim()&&!j)return;ye.clientSubmissionId=Xr();const le=cs(e.id,ye);B(we=>[...we,le]),n(""),x([]),c(!1),_(null),K(),N.current&&(N.current.style.height=r?"40px":"72px"),requestAnimationFrame(()=>se()),T(!0);try{const we=await g(ye);B(dt=>dt.filter(ns=>ns.id!==le.id)),we&&typeof we=="object"&&"id"in we&&requestAnimationFrame(()=>se())}catch(we){const dt=we instanceof Error?we.message:"Failed to send room message";B(ns=>ns.map(os=>os.id===le.id?{...os,pendingStatus:"failed",error:dt}:os)),requestAnimationFrame(()=>se())}finally{T(!1)}},[te,U,K,r,b,z,j,C,W,se,g,s,E,e.id]),kn=A.useCallback(V=>{const J=V.nativeEvent.isComposing||V.nativeEvent.keyCode===229;if(rt){if(V.key==="ArrowDown"){V.preventDefault(),k(ne=>(ne+1)%Ce.length);return}if(V.key==="ArrowUp"){V.preventDefault(),k(ne=>(ne-1+Ce.length)%Ce.length);return}if(V.key==="Enter"&&!J||V.key==="Tab"){V.preventDefault();const ne=Ce[S]??Ce[0];ne&&it(ne);return}if(V.key==="Escape"){V.preventDefault(),_(null),c(!1);return}}V.key==="Enter"&&!V.shiftKey&&!V.repeat&&!J&&(V.preventDefault(),is())},[it,is,S,Ce,rt]);A.useEffect(()=>{n(""),x([]),c(!1),_(null),B(Bn(e.id).map(V=>({...cs(e.id,V),pendingStatus:"failed",error:"Acceptance unknown; check or retry the same submission."}))),K(),ae.current=!1,he.current=null,$(null),N.current&&(N.current.style.height=r?"40px":"72px")},[K,r,e.id]);const En=A.useCallback((V,J)=>{X({images:V,index:J})},[]),jn=A.useCallback(V=>{C||(T(!0),g(V.submissionInput).then(()=>B(J=>J.filter(ne=>ne.id!==V.id))).finally(()=>T(!1)).catch(()=>{}))},[C,g]),Nn=A.useCallback((V,J)=>{y.mutate({memberId:V,cancelQueued:J},{onSuccess:()=>$(null)})},[y]);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background",children:[F&&t.jsx(_l,{images:F.images,index:F.index,onClose:()=>X(null),onSelect:V=>X(J=>J&&{...J,index:V})}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:Y,"data-room-scroll":!0,className:Q("h-full overflow-y-auto scrollbar-app-thin bg-background",r?"px-3 py-3":"px-4 py-4"),children:t.jsxs("div",{ref:ee,className:Q(r?"space-y-2.5":"space-y-3",o&&"max-w-4xl mx-auto"),children:[t.jsx(kl,{teamRun:e,messages:i,timelineItems:ve,recovered:M,scrollElementRef:Y,compact:r,onRetrySubmission:jn,onOpenImage:En,workingDir:u,onOpenWorkspaceFile:f,onOpenPreviewUrl:a,onOpenVisualization:p},e.id),t.jsx(Ai,{taskId:e.taskId,teamRunId:e.id,enabled:!s,showDeliveries:!1}),y.isError&&t.jsx("div",{className:"rounded-md border border-destructive/25 bg-destructive/10 px-3 py-2 text-xs text-destructive-ink",children:Ks(y.error,m("Failed to stop member work"))})]})}),!G&&t.jsxs("button",{type:"button",onClick:()=>se(),className:"absolute bottom-3 left-1/2 z-10 flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-border bg-background/90 px-3 py-1.5 text-xs text-foreground/70 shadow-raised backdrop-blur-sm hover:bg-background hover:text-foreground transition-colors",children:[t.jsx(On,{size:14}),t.jsx("span",{children:m("Back to bottom")})]})]}),t.jsx("div",{className:Q("shrink-0 border-t border-transparent bg-background",r?"px-3 pb-2 pt-1.5":"px-6 pb-6 pt-2"),children:t.jsxs("div",{className:Q(o&&"max-w-4xl mx-auto"),children:[t.jsx(ol,{invocations:Re,memberById:Ae,workRequestById:qe,onViewInvocationSession:v,onStopMember:Nn,isStopPending:y.isPending,stoppingMemberId:y.variables?.memberId??null,stopPromptInvocationId:H,onToggleStopConfirm:V=>$(J=>J===V?null:V)}),!s&&w,s?t.jsx("div",{className:"rounded-xl border border-border bg-muted/50 px-4 py-3 text-sm text-muted-foreground",children:l??m("This project is read-only")}):t.jsxs("div",{className:"relative rounded-xl border border-border bg-background shadow-raised transition-all duration-200 hover:shadow-raised focus-within:border-ring focus-within:shadow-raised",children:[rt&&t.jsxs("div",{className:"absolute bottom-full left-3 z-20 mb-2 w-[min(24rem,calc(100vw-3rem))] overflow-hidden rounded-xl border border-border bg-background shadow-popover",children:[t.jsx("div",{className:"border-b border-border/60 px-3 py-2 text-xs font-medium text-muted-foreground",children:m(h?"Mention members":"Team members")}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:Ce.map((V,J)=>{const ne=E.includes(V.id),ye=J===S;return t.jsxs("button",{type:"button",onMouseEnter:()=>k(J),onMouseDown:le=>{le.preventDefault(),it(V)},className:Q("flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors",ye?"bg-muted":"hover:bg-accent"),children:[t.jsx(Ue,{name:V.name,avatar:V.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:V.name}),ne&&t.jsx("span",{className:"rounded-full bg-primary px-1.5 py-0.5 text-xs font-medium text-primary-foreground",children:m("selected")})]}),t.jsx("div",{className:"truncate text-xs text-muted-foreground",children:[V.providerId,V.id.slice(0,8)].filter(Boolean).join(" · ")})]}),t.jsx(ir,{size:15,className:"text-muted-foreground/70"})]},V.id)})})]}),Se.length>0&&t.jsx("div",{className:"flex flex-wrap items-center gap-1.5 border-b border-border/60 px-3 py-2",children:Se.map(V=>t.jsxs("span",{className:"inline-flex max-w-full items-center gap-1.5 rounded-full border border-border bg-muted/50 px-2 py-1 text-xs text-foreground/80",children:[t.jsxs("span",{className:"truncate font-medium",children:["@",V.name]}),t.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:V.id.slice(0,8)}),t.jsx("button",{type:"button",onClick:()=>Ie(V.id),className:"shrink-0 rounded-full p-0.5 text-muted-foreground transition-colors hover:bg-foreground/10 hover:text-foreground/80",title:m("Remove mention"),"aria-label":`${m("Remove mention")} ${V.name}`,children:t.jsx(tt,{size:12})})]},V.id))}),t.jsx(_o,{files:D,onRemove:q}),t.jsx("textarea",{ref:N,value:b,rows:r?1:void 0,onChange:nt,onKeyDown:kn,onPaste:rs,onClick:V=>Ne(b,V.currentTarget.selectionStart),onSelect:V=>Ne(b,V.currentTarget.selectionStart),placeholder:m("Message the team room..."),className:Q("w-full resize-none border-none bg-transparent text-foreground placeholder:text-muted-foreground/70 focus:outline-none",r?"px-3 pb-1 pt-2.5 text-[15px] leading-5":"px-4 pb-2 pt-4 text-sm leading-relaxed"),style:r?{minHeight:40,maxHeight:140}:{minHeight:60,maxHeight:220}}),t.jsxs("div",{className:Q("flex items-center justify-between",r?"px-2 pb-1.5 pt-0.5":"px-2 pb-2 pt-1"),children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{ref:P,type:"file",multiple:!0,className:"hidden",onChange:ue}),t.jsx("button",{type:"button",onClick:()=>P.current?.click(),title:m("Upload file"),"aria-label":m("Upload file"),className:"rounded-lg p-2 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground/70",children:t.jsx(yo,{size:18})}),t.jsx("button",{type:"button",onClick:()=>{c(V=>!V),_(null),requestAnimationFrame(()=>N.current?.focus())},disabled:Se.length===0&&te.length===0,title:m("Mention members"),"aria-label":m("Mention members"),className:Q("rounded-lg transition-colors",r?"p-1.5":"p-2",d?"bg-muted text-foreground/80":"text-muted-foreground hover:bg-accent hover:text-foreground/70",Se.length===0&&te.length===0?"cursor-not-allowed opacity-50":""),children:t.jsx(ir,{size:r?15:18})}),Se.length>0&&t.jsxs("span",{className:"text-xs text-muted-foreground",children:[Se.length," ",m("selected")]})]}),t.jsx("button",{type:"button",onClick:()=>{is()},disabled:s||C||W||!b.trim()&&!j,"aria-busy":C,title:m(W?"Uploading...":C?"发送中...":"发送"),"aria-label":m(W?"Uploading...":C?"发送中...":"发送"),className:Q("rounded-lg transition-all duration-200",r?"p-1.5":"p-2",(b.trim()||j)&&!s&&!C&&!W?"bg-primary text-primary-foreground shadow-raised hover:bg-primary":"cursor-not-allowed bg-transparent text-muted-foreground",C||W?"opacity-70":""),children:C?t.jsx(Fs,{size:r?15:18,className:"animate-spin"}):t.jsx(In,{size:r?15:18})})]})]})]})})]})}function El(e){return e?e.slice(0,8):""}function dr(e){const i=e?Date.parse(e):0;return Number.isNaN(i)?0:i}function Xs(e){return e?.workspaceKind===He.MAIN_DIRECTORY}function jt(e){return e?Xs(e)?"Project directory":e.branchName:"—"}function $f(e){return e?.workingDir||e?.worktreePath||void 0}function Ys(e,i){if(!e?.length)return[];const s=new Map((i?.members??[]).map(v=>[v.id,v])),l=new Map(e.map(v=>[v.id,v])),g=i?.mainWorkspaceId??null;return e.map(v=>{const w=v.parentWorkspaceId?l.get(v.parentWorkspaceId):void 0,r=v.ownerMemberId?s.get(v.ownerMemberId):void 0,o=!!(g&&v.id===g),u=o?"main":v.parentWorkspaceId?"child":"root",f=r?.name??(v.ownerMemberId?`Member ${El(v.ownerMemberId)}`:void 0),a=Xs(v)?"Project directory":o?"Main workspace":u==="child"?f?`${f} workspace`:"Child workspace":i?"Root workspace":"Workspace";return{workspace:v,kind:u,roleLabel:o?"Main":u==="child"?"Child":"Root",displayName:a,ownerName:f,parentBranchName:w?jt(w):void 0,isMain:o}}).sort((v,w)=>{const r=u=>u.kind==="main"?0:u.kind==="child"?1:2,o=r(v)-r(w);return o!==0?o:dr(v.workspace.createdAt)-dr(w.workspace.createdAt)})}function Uf(e,i,s){if(e?.length)return s&&e.some(l=>l.id===s)?s:i?.mainWorkspaceId&&e.some(l=>l.id===i.mainWorkspaceId)?i.mainWorkspaceId:e.find(l=>l.status===We.ACTIVE)?.id??e[0]?.id}function qf(e,i){return!e||e.status!==We.ACTIVE||Xs(e)?!1:!i||e.parentWorkspaceId?!0:!!(i.mainWorkspaceId&&e.id===i.mainWorkspaceId)}function Kf(e,i,s){return e?.parentWorkspaceId?i?.find(g=>g.id===e.parentWorkspaceId)?.branchName??e.baseBranch??s:e?.baseBranch||s}const Vs={readRoom:!1,postRoomMessage:!1,mentionMembers:!1,stopMemberWork:!1,markReadyForReview:!1,readFiles:!1,writeFiles:!1,runCommands:!1,readDiff:!1,mergeWorkspace:!1},jl=[{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:"合并工作区"}],Bi=[{value:"none",label:"无"},{value:"shared",label:"共享"},{value:"dedicated",label:"独占"}],Nl=[{value:"MENTION_ONLY",label:"仅提及"},{value:"USER_MESSAGES",label:"所有用户消息"}],Oi=[{value:"new_per_request",label:"每次新会话"},{value:"resume_last",label:"复用上次会话"}],Tl=[{value:"own_only",label:"仅自己队列"},{value:"team_pending",label:"全队列待处理"}];function bt(){return{name:"",aliasesText:"",providerId:"",rolePrompt:"",capabilities:{...Vs},workspacePolicy:"none",triggerPolicy:"MENTION_ONLY",sessionPolicy:"new_per_request",queueManagementPolicy:"own_only",avatar:""}}function ft(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...Vs,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function ds(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...Vs,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function Al(e){return Array.from(new Set(e.split(/[\n,]/).map(i=>i.trim()).filter(Boolean)))}function Rl(e){return{name:e.name.trim(),aliases:Al(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 hr(e,i){return e instanceof Error?e.message:i}function ur(e){return e.membershipStatus!=="REMOVED"}function Ls(e){return e.status==="RUNNING"||e.status==="WAITING_ROOM_REPLY"||e.status==="SESSION_ENDED"||e.status==="QUEUED"}function fr(e){return Ls(e)?"bg-success":e.status==="FAILED"?"bg-destructive":"bg-foreground/15"}function mr(e){return Bi.find(i=>i.value===e)?.label??e}function Ll(e){return Oi.find(i=>i.value===e)?.label??e}function Fe({children:e}){return t.jsx("span",{className:"text-xs font-medium text-foreground/70",children:e})}function pr({icon:e,title:i,description:s,action:l}){return t.jsxs("div",{className:"flex min-h-[18rem] flex-col items-center justify-center rounded-lg border border-dashed border-border bg-background px-6 py-8 text-center",children:[t.jsx("div",{className:"mb-3 flex h-10 w-10 items-center justify-center rounded-full bg-muted text-muted-foreground",children:e}),t.jsx("div",{className:"text-sm font-medium text-foreground",children:i}),s?t.jsx("div",{className:"mt-1 max-w-sm text-xs leading-relaxed text-muted-foreground",children:s}):null,l?t.jsx("div",{className:"mt-4",children:l}):null]})}function Ml({isOpen:e,onClose:i,teamRun:s}){const{t:l}=re(),{data:g=[]}=Hn(),{data:v=[]}=Ws(),w=zn(s.id),r=Wn(s.id),o=$n(s.id),u=A.useRef(!1),[f,a]=A.useState("edit"),[p,m]=A.useState(null),[y,b]=A.useState(""),[n,d]=A.useState(bt()),[c,h]=A.useState(null),[_,S]=A.useState(null),k=s.members??[],E=A.useMemo(()=>k.filter(ur),[k]),x=A.useMemo(()=>_&&ur(_)&&!E.some(W=>W.id===_.id)?[...E,_]:E,[_,E]),C=p?E.find(W=>W.id===p)??null:null,T=_?.id===p?_:C,L=y?g.find(W=>W.id===y)??null:null,R=w.isPending||r.isPending||o.isPending,M=x.filter(Ls).length,I=A.useMemo(()=>{const W=v.filter(ui).map(({provider:j,availability:F})=>({value:j.id,label:j.name+(F.type==="NOT_FOUND"?l(" (不可用)"):""),icon:t.jsx(Gt,{agentType:j.agentType,className:"size-4"}),disabled:F.type==="NOT_FOUND"}));return n.providerId&&!v.some(j=>j.provider.id===n.providerId)&&!W.some(j=>j.value===n.providerId)&&W.unshift({value:n.providerId,label:`${n.providerId}${l(" (不可用)")}`,disabled:!0}),W},[n.providerId,v,l]);A.useEffect(()=>{if(!e){u.current=!1,S(null);return}if(u.current)return;u.current=!0;const W=x[0]??null;a(W?"edit":"add-preset"),m(W?.id??null),b(""),d(W?ft(W):bt()),h(null)},[x,e]),A.useEffect(()=>{_&&E.some(W=>W.id===_.id)&&S(null)},[_,E]),A.useEffect(()=>{f==="add-preset"&&L&&d(ds(L))},[f,L]);const B=(W,j)=>{d(F=>({...F,[W]:j}))},H=(W,j)=>{d(F=>({...F,capabilities:{...F.capabilities,[W]:j}}))},$=W=>{a("edit"),m(W.id),b(""),d(ft(W))},N=()=>{a("add-preset"),m(null);const W=L??g[0]??null;b(W?.id??""),d(W?ds(W):bt())},P=()=>{a("add-custom"),m(null),b(""),d(bt())},D=!!(n.name.trim()&&n.providerId.trim()&&n.rolePrompt.trim()),O=f==="add-preset"?!!y:f==="edit"?!!(T&&D):D,q=async()=>{try{if(f==="add-preset"){if(!y)return;const j=await w.mutateAsync({memberPresetId:y});ke.success(l("Member added")),S(j),a("edit"),m(j.id),b(""),d(ft(j));return}const W=Rl(n);if(!W.name||!W.providerId||!W.rolePrompt){ke.error(l("Name, provider, and role prompt are required"));return}if(f==="add-custom"){const j=await w.mutateAsync({member:W});ke.success(l("Member added")),S(j),a("edit"),m(j.id),d(ft(j));return}if(T){const j=await r.mutateAsync({memberId:T.id,data:W});ke.success(l("Member updated")),S(F=>F?.id===j.id?j:F),m(j.id),d(ft(j))}}catch(W){ke.error(hr(W,l("Failed to save member")))}},K=async()=>{if(c)try{if(await o.mutateAsync({memberId:c.id,stopActive:!0,cancelQueued:!0}),p===c.id){const W=x.find(j=>j.id!==c.id)??null;m(W?.id??null),a(W?"edit":"add-preset"),d(W?ft(W):bt())}S(W=>W?.id===c.id?null:W),h(null),ke.success(l("Member removed"))}catch(W){ke.error(hr(W,l("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-border/60 px-5 py-4",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-foreground",children:[t.jsx(Pt,{size:15,className:"text-muted-foreground"}),t.jsx("span",{children:l("Add member from preset")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:l("Choose a saved preset to add a ready-to-run member snapshot.")})]}),t.jsxs(ge,{type:"button",variant:"outline",size:"sm",onClick:P,disabled:R,children:[t.jsx(ar,{size:13}),l("Custom member")]})]})}),t.jsx("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:g.length===0?t.jsx(pr,{icon:t.jsx(Pt,{size:18}),title:l("No member presets"),description:l("Create a custom member for this TeamRun, or add presets from Team Collaboration Settings."),action:t.jsxs(ge,{type:"button",variant:"outline",size:"sm",onClick:P,disabled:R,children:[t.jsx(pt,{size:13}),l("Custom member")]})}):t.jsx("div",{className:"grid grid-cols-1 gap-2 xl:grid-cols-2",children:g.map(W=>{const j=y===W.id;return t.jsxs("button",{type:"button",onClick:()=>{b(W.id),d(ds(W))},className:Q("flex min-h-[4.25rem] items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors",j?"border-foreground bg-muted/50 shadow-raised":"border-border bg-background hover:border-foreground/20 hover:bg-accent"),children:[t.jsx(Ue,{name:W.name,avatar:W.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-medium text-foreground",children:W.name}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-muted-foreground",children:W.providerId}),t.jsxs("span",{className:"mt-1 block truncate text-xs text-muted-foreground",children:[l(mr(W.workspacePolicy))," · ",l(Ll(W.sessionPolicy))]})]}),j?t.jsx(Et,{size:16,className:"shrink-0 text-foreground"}):null]},W.id)})})})]}),z=()=>{const W=f==="edit";return W&&!T?t.jsx("div",{className:"p-5",children:t.jsx(pr,{icon:t.jsx(vt,{size:18}),title:l("Select a member"),description:l("Choose a member on the left to edit its future TeamRun configuration."),action:t.jsxs(ge,{type:"button",variant:"outline",size:"sm",onClick:N,disabled:R,children:[t.jsx(pt,{size:13}),l("Add member")]})})}):t.jsxs("div",{className:"flex min-h-0 flex-col lg:flex-1",children:[t.jsx("div",{className:"border-b border-border/60 px-5 py-4",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-foreground",children:[W?t.jsx(Ti,{size:15,className:"text-muted-foreground"}):t.jsx(pt,{size:15,className:"text-muted-foreground"}),t.jsx("span",{children:l(W?"Edit member":"Custom member")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:l(W?"Provider, role, workspace, and session changes apply to future work only.":"Create a one-off member snapshot for this TeamRun.")})]}),W&&T?t.jsxs(ge,{type:"button",variant:"outline",size:"sm",onClick:()=>h(T),disabled:R,className:"border-destructive/25 text-destructive-ink hover:bg-destructive/10 hover:text-destructive-ink",children:[t.jsx(Jn,{size:13}),l("Remove")]}):t.jsxs(ge,{type:"button",variant:"outline",size:"sm",onClick:N,disabled:R,children:[t.jsx(Pt,{size:13}),l("Use preset")]})]})}),t.jsxs("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:[W&&T?t.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg border border-border bg-muted/50 px-3 py-2.5",children:[t.jsx(Ue,{name:T.name,avatar:T.avatar,className:"h-9 w-9 text-xs"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:Q("h-2 w-2 shrink-0 rounded-full",fr(T))}),t.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:T.name})]}),t.jsxs("div",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:[T.providerId," · ",l(mr(T.workspacePolicy))]})]})]}):null,t.jsxs("div",{className:"space-y-5",children:[t.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Fe,{children:l("Name")}),t.jsx("input",{value:n.name,onChange:j=>B("name",j.target.value),className:"h-9 w-full rounded-lg border border-border px-3 text-sm outline-none transition-colors focus:border-ring"})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Fe,{children:l("Aliases")}),t.jsx("input",{value:n.aliasesText,onChange:j=>B("aliasesText",j.target.value),placeholder:l("Comma separated"),className:"h-9 w-full rounded-lg border border-border px-3 text-sm outline-none transition-colors focus:border-ring"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Fe,{children:l("Provider")}),t.jsx(Xe,{value:n.providerId,onChange:j=>B("providerId",j),options:I,placeholder:v.find(j=>j.provider.id===n.providerId)?.provider.name})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Fe,{children:l("Avatar")}),t.jsx("input",{value:n.avatar,onChange:j=>B("avatar",j.target.value),className:"h-9 w-full rounded-lg border border-border px-3 text-sm outline-none transition-colors focus:border-ring"})]})]}),t.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Fe,{children:l("Workspace policy")}),t.jsx(Xe,{value:n.workspacePolicy,onChange:j=>B("workspacePolicy",j),options:Bi.map(j=>({value:j.value,label:l(j.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Fe,{children:l("Trigger policy")}),t.jsx(Xe,{value:n.triggerPolicy,onChange:j=>B("triggerPolicy",j),options:Nl.map(j=>({value:j.value,label:l(j.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Fe,{children:l("Session policy")}),t.jsx(Xe,{value:n.sessionPolicy,onChange:j=>B("sessionPolicy",j),options:Oi.map(j=>({value:j.value,label:l(j.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Fe,{children:l("Queue policy")}),t.jsx(Xe,{value:n.queueManagementPolicy,onChange:j=>B("queueManagementPolicy",j),options:Tl.map(j=>({value:j.value,label:l(j.label)}))})]})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Fe,{children:l("Role prompt")}),t.jsx("textarea",{value:n.rolePrompt,onChange:j=>B("rolePrompt",j.target.value),rows:7,className:"w-full resize-y rounded-lg border border-border px-3 py-2 text-sm leading-relaxed outline-none transition-colors focus:border-ring"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Fe,{children:l("Capabilities")}),t.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-3",children:jl.map(j=>t.jsxs("label",{className:"flex min-h-9 items-center gap-2 rounded-md border border-border bg-background px-2.5 py-2 text-xs text-foreground/80",children:[t.jsx("input",{type:"checkbox",checked:!!n.capabilities[j.key],onChange:F=>H(j.key,F.target.checked)}),t.jsx("span",{className:"min-w-0 truncate",children:l(j.label)})]},j.key))})]})]})]})]})};return t.jsxs(t.Fragment,{children:[t.jsx(At,{isOpen:e,onClose:R?()=>{}:i,title:l("Manage Team Members"),className:"max-w-6xl",action:t.jsxs(t.Fragment,{children:[t.jsx(ge,{type:"button",variant:"outline",onClick:i,disabled:R,children:l("Close")}),t.jsx(ge,{type:"button",onClick:q,disabled:R||!O,children:l(R?"Processing...":f==="edit"?"Save member":"Add member")})]}),children:t.jsxs("div",{className:"grid min-h-0 grid-cols-1 overflow-visible rounded-lg border border-border bg-background lg:h-[min(42rem,calc(100vh-13rem))] lg:min-h-[34rem] lg:grid-cols-[20rem_minmax(0,1fr)] lg:overflow-hidden",children:[t.jsxs("aside",{className:"flex min-h-0 flex-col border-b border-border bg-muted/35 lg:border-b-0 lg:border-r",children:[t.jsx("div",{className:"border-b border-border px-4 py-4",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-foreground",children:[t.jsx(vt,{size:15,className:"text-muted-foreground"}),t.jsx("span",{children:l("Members")})]}),t.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[x.length," ",l("active")," · ",M," ",l("working")]})]}),t.jsx(ge,{type:"button",size:"icon-sm",variant:"outline",onClick:N,disabled:R,title:l("Add member"),children:t.jsx(pt,{size:14})})]})}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-2 lg:min-h-0 lg:max-h-none lg:flex-1",children:x.length===0?t.jsx("div",{className:"rounded-lg border border-dashed border-border bg-background px-3 py-5 text-center text-xs text-muted-foreground",children:l("No active members")}):t.jsx("div",{className:"space-y-1",children:x.map(W=>{const j=f==="edit"&&p===W.id;return t.jsxs("button",{type:"button",onClick:()=>$(W),className:Q("group flex w-full items-center gap-2 rounded-lg border px-2.5 py-2 text-left transition-colors",j?"border-border bg-background shadow-raised":"border-transparent hover:border-border hover:bg-background"),children:[t.jsx(Ue,{name:W.name,avatar:W.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:Q("h-1.5 w-1.5 shrink-0 rounded-full",fr(W))}),t.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:W.name})]}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-muted-foreground",children:W.providerId})]}),t.jsx(La,{size:13,className:Q("shrink-0 text-muted-foreground transition-opacity",j?"opacity-100":"opacity-0 group-hover:opacity-100")})]},W.id)})})}),t.jsx("div",{className:"border-t border-border p-2",children:t.jsx(Eo,{block:!0,"aria-label":l("Add member"),value:f,onValueChange:W=>W==="add-preset"?N():P(),options:[{value:"add-preset",label:l("Preset"),icon:t.jsx(Pt,{}),disabled:R},{value:"add-custom",label:l("Custom"),icon:t.jsx(ar,{}),disabled:R}]})})]}),t.jsx("section",{className:"flex min-h-0 min-w-0 flex-col",children:f==="add-preset"?U():z()})]})}),t.jsx(jo,{isOpen:!!c,onClose:()=>h(null),onConfirm:K,title:l("Remove member"),variant:"danger",isLoading:o.isPending,confirmText:l("Remove"),description:t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{children:c?l("Remove this member from future TeamRun work?"):""}),c&&Ls(c)?t.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-destructive/25 bg-destructive/10 px-3 py-2 text-left text-destructive-ink",children:[t.jsx(Tt,{size:15,className:"mt-0.5 shrink-0"}),t.jsx("span",{className:"text-sm font-medium",children:l("确认后会停止当前工作并取消队列")})]}):null]})})]})}const Dl=[],Pl=[],Bl=[],Ol=240;function Il(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 gr={running:0,"waiting room reply":1,queued:2,"session ended":3,"pending approval":4,idle:5,removed:6};function hs(e){if(!e)return"";const i=new Date(e);return Number.isNaN(i.getTime())?"":i.toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function vr(e,i){return e instanceof Error?e.message:i}function Fl(e,i=Ol){const s=(e??"").replace(/\s+/g," ").trim();return s.length<=i?s:`${s.slice(0,i-3).trimEnd()}...`}function Ot(e){return e?e.instructionPreview??Fl(e.instruction):""}function Hl(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 zl(e){switch(e){case"running":return"border-success/25 bg-success/10 text-success-ink";case"waiting room reply":return"border-warning/25 bg-warning/10 text-warning-ink";case"queued":case"session ended":return"border-info/25 bg-info/10 text-info-ink";case"pending approval":return"border-border bg-muted/50 text-foreground/70";case"removed":return"border-border bg-muted/50 text-muted-foreground";case"idle":return"border-border bg-background text-muted-foreground"}}function Wl(e){switch(e){case"running":return"bg-success";case"waiting room reply":return"bg-warning";case"queued":case"session ended":return"bg-info";case"pending approval":return"bg-muted-foreground/60";case"removed":return"bg-foreground/15";case"idle":return"bg-foreground/15"}}function $l(e){switch(e){case"user":return"User";case"agent":return"Agent";case"system":return"System"}}function Ul(e){switch(e){case"RUNNING":return"border-success/25 bg-success/10 text-success-ink";case"WAITING_ROOM_REPLY":return"border-warning/25 bg-warning/10 text-warning-ink";case"QUEUED":case"SESSION_ENDED":return"border-info/25 bg-info/10 text-info-ink";case"COMPLETED":return"border-border bg-muted/50 text-foreground/80";case"FAILED":return"border-destructive/25 bg-destructive/10 text-destructive-ink";case"CANCELLED":return"border-border bg-background text-muted-foreground"}}function ql(e){switch(e){case We.ACTIVE:return"border-success/25 bg-success/10 text-success-ink";case We.MERGED:return"border-info/25 bg-info/10 text-info-ink";case We.HIBERNATED:return"border-warning/25 bg-warning/10 text-warning-ink";case We.ABANDONED:return"border-border bg-muted/50 text-muted-foreground"}}function Kl(e){switch(e){case"Main":return"border-border bg-muted/50 text-foreground/80";case"Child":return"border-border bg-muted/50 text-foreground/80";default:return"border-border bg-muted/50 text-foreground/70"}}function Xl(e){return[...e].sort((i,s)=>Date.parse(s.updatedAt??s.createdAt??"")-Date.parse(i.updatedAt??i.createdAt??""))}function Yl(e,i){return i.find(s=>s.memberId===e.id&&Zt.has(s.status))}function Xf({teamRun:e,workspaces:i,selectedWorkspaceId:s,onSelectWorkspace:l,onViewInvocationSession:g}){const{t:v}=re(),w=Yr(e.id),r=Vr(e.id),o=Kr(e.id),[u,f]=A.useState(null),[a,p]=A.useState(null),[m,y]=A.useState(!1),[b,n]=A.useState(!1),d=e.members??Dl,c=A.useMemo(()=>d.filter(B=>B.membershipStatus!=="REMOVED"),[d]),h=e.workRequests??Pl,_=e.invocations??Bl,S=A.useMemo(()=>Ys(i,e),[e,i]),k=A.useMemo(()=>new Map(h.map(B=>[B.id,B])),[h]),E=A.useMemo(()=>[...h].filter(B=>B.status==="PENDING_APPROVAL").sort((B,H)=>Date.parse(H.updatedAt??H.createdAt??"")-Date.parse(B.updatedAt??B.createdAt??"")),[h]),x=A.useMemo(()=>[...h].filter(B=>B.status==="QUEUED").sort((B,H)=>Date.parse(H.updatedAt??H.createdAt??"")-Date.parse(B.updatedAt??B.createdAt??"")),[h]),C=A.useMemo(()=>[...d].map(B=>({member:B,status:Il(B.status)})).sort((B,H)=>gr[B.status]-gr[H.status]),[d]),T=w.isError?w.error:r.isError?r.error:null,L=w.isPending||r.isPending,R=S.find(B=>B.workspace.id===s),M=e.messages??[],I=C.filter(({status:B})=>B==="running"||B==="waiting room reply").length;return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background",children:[t.jsx(Ml,{isOpen:b,onClose:()=>n(!1),teamRun:e}),t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border px-4 py-3 shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(js,{size:14,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:v("Team Status")})]}),t.jsxs("div",{className:"flex items-center gap-1.5 rounded-full border border-border bg-muted/50 px-2 py-0.5 text-xs font-medium text-muted-foreground",children:[t.jsx("span",{children:v("Team mode")}),t.jsx("span",{className:"text-foreground/80",children:e.mode})]})]}),t.jsxs("div",{className:"flex items-center gap-3 border-b border-border/60 px-4 py-1.5 shrink-0 text-xs text-muted-foreground",children:[t.jsxs("span",{className:"inline-flex items-center gap-1",title:v("Messages"),children:[t.jsx(No,{size:11,className:"text-muted-foreground/70"}),t.jsx("span",{className:"tabular-nums",children:M.length})]}),t.jsxs("span",{className:"inline-flex items-center gap-1",title:v("Members"),children:[t.jsx(vt,{size:11,className:"text-muted-foreground/70"}),t.jsx("span",{className:"tabular-nums",children:I>0?`${I}/${c.length}`:c.length}),I>0&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-success"})]}),x.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1",title:v("Queue"),children:[t.jsx(Ve,{size:11,className:"text-muted-foreground/70"}),t.jsx("span",{className:"tabular-nums",children:x.length})]}),E.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-warning-ink",title:v("Pending approval"),children:[t.jsx(Ve,{size:11}),t.jsx("span",{className:"tabular-nums",children:E.length})]})]}),t.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-app-thin px-4 py-3 space-y-3",children:[E.length>0&&t.jsxs("section",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-warning-ink",children:[t.jsx(Ve,{size:13}),t.jsx("span",{children:v("Pending approval")}),t.jsx("span",{className:"ml-auto rounded-full bg-warning/10 px-1.5 py-0.5 text-[11px] font-semibold text-warning-ink",children:E.length})]}),t.jsx("div",{className:"space-y-1.5",children:E.map(B=>{const H=d.find(P=>P.id===B.targetMemberId),$=w.isPending&&w.variables===B.id,N=r.isPending&&r.variables===B.id;return t.jsxs("div",{className:"rounded-md border border-warning/25 bg-warning/5 px-3 py-2",children:[t.jsx("div",{className:"flex items-start justify-between gap-2",children:t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(Ue,{name:H?.name??"Agent",avatar:H?.avatar??null,size:"xs",className:"size-4"}),t.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:H?.name??B.targetMemberId})]}),t.jsx("div",{className:"mt-1 text-xs leading-relaxed text-foreground/70 line-clamp-2",children:Ot(B)})]})}),t.jsxs("div",{className:"mt-1.5 flex items-center gap-x-2 text-xs text-muted-foreground",children:[t.jsx("span",{children:v($l(B.requesterType))}),t.jsx("span",{children:hs(B.createdAt)})]}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>w.mutate(B.id),disabled:L,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-success/25 bg-success/10 px-2 text-xs font-medium text-success-ink transition-colors hover:bg-success/15 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Et,{size:11}),t.jsx("span",{className:"truncate",children:v($?"Approving":"Approve")})]}),t.jsxs("button",{type:"button",onClick:()=>r.mutate(B.id),disabled:L,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-border bg-muted/50 px-2 text-xs font-medium text-foreground/80 transition-colors hover:bg-accent disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(tt,{size:11}),t.jsx("span",{className:"truncate",children:v(N?"Rejecting":"Reject")})]})]})]},B.id)})}),T&&t.jsx("div",{className:"rounded-md border border-destructive/25 bg-destructive/10 px-3 py-2 text-xs text-destructive-ink",children:vr(T,v("Failed to update work request"))})]}),t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground",children:[t.jsx(vt,{size:13}),t.jsx("span",{children:v("Members")}),t.jsx("span",{className:"ml-auto text-[11px] font-normal text-muted-foreground",children:c.length}),t.jsx("button",{type:"button",onClick:()=>n(!0),className:"rounded-md p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground/80",title:v("Manage Team Members"),"aria-label":v("Manage Team Members"),children:t.jsx(Ti,{size:13})})]}),d.length===0?t.jsx("div",{className:"py-3 text-center text-xs text-muted-foreground",children:v("No members")}):t.jsx("div",{className:"space-y-px rounded-md border border-border overflow-hidden",children:C.map(({member:B,status:H})=>{const $=Yl(B,_),N=Xl(_.filter(z=>z.memberId===B.id)),P=$?k.get($.workRequestId):void 0,D=a===B.id,O=H==="running"||H==="waiting room reply",q=O&&!!$,K=u===B.id,U=o.isPending&&o.variables?.memberId===B.id;return t.jsxs("div",{className:Q("bg-background",D&&"bg-muted/25"),children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[t.jsx(Ue,{name:B.name,avatar:B.avatar,className:"h-6 w-6 text-[10px] shrink-0"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:Q("h-1.5 w-1.5 shrink-0 rounded-full",Wl(H))}),t.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:B.name}),t.jsx("span",{className:Q("shrink-0 rounded-full border px-1.5 py-px text-xs font-medium leading-tight",zl(H)),children:v(Hl(H))})]}),O&&P?.instruction&&t.jsx("div",{className:"mt-0.5 truncate pl-3 text-xs text-muted-foreground",children:Ot(P)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[q&&t.jsx("button",{type:"button",onClick:()=>f(K?null:B.id),disabled:o.isPending,className:"rounded-md p-1 text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive-ink disabled:cursor-not-allowed disabled:opacity-50",title:v("Stop"),"aria-label":v("Stop"),children:t.jsx(qt,{size:12})}),$?.sessionId&&g&&t.jsx("button",{type:"button",onClick:()=>g($.sessionId),className:"rounded-md p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground/80",title:v("View log"),"aria-label":v("View log"),children:t.jsx(As,{size:12})}),t.jsx("button",{type:"button",onClick:()=>p(D?null:B.id),className:"rounded-md p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground/70",title:v("Details"),"aria-label":v("Details"),"aria-expanded":D,children:D?t.jsx(Ke,{size:13}):t.jsx(Je,{size:13})})]})]}),q&&K&&t.jsxs("div",{className:"mx-3 mb-2 rounded-md border border-border bg-muted/50 p-2",children:[t.jsx("div",{className:"mb-1.5 text-xs text-foreground/70",children:v("Stop running work?")}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{o.mutate({memberId:B.id,cancelQueued:!1},{onSuccess:()=>f(null)})},disabled:o.isPending,className:"inline-flex h-6 items-center gap-1 rounded-md border border-border bg-background px-2 text-xs font-medium text-foreground/80 transition-colors hover:bg-accent disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(qt,{size:10}),t.jsx("span",{children:U&&o.variables?.cancelQueued===!1?v("Stopping"):v("Stop only")})]}),t.jsxs("button",{type:"button",onClick:()=>{o.mutate({memberId:B.id,cancelQueued:!0},{onSuccess:()=>f(null)})},disabled:o.isPending,className:"inline-flex h-6 items-center gap-1 rounded-md border border-destructive/25 bg-destructive/10 px-2 text-xs font-medium text-destructive-ink transition-colors hover:bg-destructive/15 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Ni,{size:10}),t.jsx("span",{children:U&&o.variables?.cancelQueued===!0?v("Stopping"):v("Stop + clear queue")})]})]})]}),D&&t.jsxs("div",{className:"border-t border-border/60 px-3 py-2",children:[t.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[t.jsx("span",{children:B.providerId}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-foreground/15"}),t.jsx("span",{children:B.workspacePolicy}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-foreground/15"}),t.jsx("span",{children:B.sessionPolicy==="resume_last"?v("Resume last session"):v("New session per request")})]}),t.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:v("Invocation history")}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:N.length})]}),N.length===0?t.jsx("div",{className:"py-2 text-center text-xs text-muted-foreground",children:v("No invocations yet")}):t.jsx("div",{className:"space-y-1",children:N.map(z=>{const W=k.get(z.workRequestId),j=!!(z.sessionId&&g);return t.jsx("div",{className:"rounded-md border border-border/60 bg-background px-2.5 py-1.5",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:Q("rounded-full border px-1.5 py-px text-[10px] font-medium leading-tight",Ul(z.status)),children:z.status}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:hs(z.updatedAt??z.createdAt)})]}),t.jsx("div",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:Ot(W)||z.workRequestId})]}),j&&t.jsxs("button",{type:"button",onClick:()=>z.sessionId&&g?.(z.sessionId),className:"inline-flex h-5 shrink-0 items-center gap-1 rounded border border-border bg-background px-1.5 text-xs font-medium text-foreground/70 transition-colors hover:bg-accent",title:v("View log"),"aria-label":v("View log"),children:[t.jsx(As,{size:10}),t.jsx("span",{children:v("Log")})]})]})},z.id)})})]}),C[C.length-1]?.member.id!==B.id&&!D&&t.jsx("div",{className:"mx-3 border-b border-border/60"})]},B.id)})}),o.isError&&t.jsx("div",{className:"rounded-md border border-destructive/25 bg-destructive/10 px-3 py-2 text-xs text-destructive-ink",children:vr(o.error,v("Failed to stop member work"))})]}),x.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground",children:[t.jsx(Ve,{size:13}),t.jsx("span",{children:v("Queue")}),t.jsx("span",{className:"ml-auto rounded-full bg-muted px-1.5 py-0.5 text-[11px] font-semibold text-foreground/70",children:x.length})]}),t.jsx("div",{className:"space-y-1",children:x.map(B=>{const H=d.find($=>$.id===B.targetMemberId);return t.jsx("div",{className:"rounded-md border border-border bg-background px-3 py-2",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(Ue,{name:H?.name??"Agent",avatar:H?.avatar??null,size:"xs",className:"size-4"}),t.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:H?.name??B.targetMemberId})]}),t.jsx("div",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:Ot(B)})]}),t.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:hs(B.createdAt)})]})},B.id)})})]}),S.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>y(B=>!B),className:"flex w-full items-center gap-2 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground/80","aria-expanded":m,"aria-label":v("Workspaces"),children:[t.jsx(js,{size:13}),t.jsx("span",{children:v("Workspaces")}),t.jsxs("span",{className:"ml-auto flex items-center gap-1.5",children:[R&&t.jsx("span",{className:"max-w-[120px] truncate font-mono text-[11px] font-normal text-muted-foreground",children:jt(R.workspace)}),t.jsx("span",{className:"rounded-full bg-muted px-1.5 py-0.5 text-[11px] font-semibold text-foreground/70",children:S.length}),m?t.jsx(Ke,{size:13,className:"text-muted-foreground/70"}):t.jsx(Je,{size:13,className:"text-muted-foreground/70"})]})]}),m&&t.jsx("div",{className:"space-y-1.5",children:S.map(B=>{const H=s===B.workspace.id;return t.jsx("div",{className:Q("rounded-md border bg-background px-3 py-2",H?"border-foreground/25 shadow-raised":"border-border"),children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:v(B.displayName)}),t.jsx("span",{className:Q("shrink-0 rounded-full border px-1.5 py-px text-[11px] font-medium leading-tight",Kl(B.roleLabel)),children:v(B.roleLabel)}),t.jsx("span",{className:Q("shrink-0 rounded-full border px-1.5 py-px text-[11px] font-medium leading-tight",ql(B.workspace.status)),children:B.workspace.status})]}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-[11px] text-muted-foreground",children:jt(B.workspace)}),t.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground",children:[B.ownerName&&t.jsxs("span",{children:[v("Owner"),": ",B.ownerName]}),B.parentBranchName&&t.jsxs("span",{children:[v("Parent"),": ",B.parentBranchName]})]})]}),t.jsxs("button",{type:"button",onClick:()=>l?.(B.workspace.id),disabled:!l||H,className:"inline-flex h-6 shrink-0 items-center gap-1 rounded-md border border-border bg-muted/50 px-2 text-xs font-medium text-foreground/80 transition-colors hover:bg-accent disabled:cursor-not-allowed disabled:opacity-50",title:v("View workspace"),children:[H?t.jsx(Et,{size:11}):t.jsx(Qr,{size:11}),t.jsx("span",{children:v(H?"Selected":"Select")})]})]})},B.workspace.id)})})]}),E.length===0&&x.length===0&&C.every(({status:B})=>B==="idle")&&t.jsx("div",{className:"py-2 text-center text-xs text-muted-foreground",children:v("All members idle")})]})]})}var us={exports:{}},_r;function Vl(){return _r||(_r=1,(function(e,i){(function(s,l){e.exports=l()})(self,(()=>(()=>{var s={4567:function(w,r,o){var u=this&&this.__decorate||function(h,_,S,k){var E,x=arguments.length,C=x<3?_:k===null?k=Object.getOwnPropertyDescriptor(_,S):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(h,_,S,k);else for(var T=h.length-1;T>=0;T--)(E=h[T])&&(C=(x<3?E(C):x>3?E(_,S,C):E(_,S))||C);return x>3&&C&&Object.defineProperty(_,S,C),C},f=this&&this.__param||function(h,_){return function(S,k){_(S,k,h)}};Object.defineProperty(r,"__esModule",{value:!0}),r.AccessibilityManager=void 0;const a=o(9042),p=o(6114),m=o(9924),y=o(844),b=o(5596),n=o(4725),d=o(3656);let c=r.AccessibilityManager=class extends y.Disposable{constructor(h,_){super(),this._terminal=h,this._renderService=_,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=document.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=document.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let S=0;S<this._terminal.rows;S++)this._rowElements[S]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[S]);if(this._topBoundaryFocusListener=S=>this._handleBoundaryFocus(S,0),this._bottomBoundaryFocusListener=S=>this._handleBoundaryFocus(S,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=document.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new m.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((S=>this._handleResize(S.rows)))),this.register(this._terminal.onRender((S=>this._refreshRows(S.start,S.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((S=>this._handleChar(S)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
9
9
  `)))),this.register(this._terminal.onA11yTab((S=>this._handleTab(S)))),this.register(this._terminal.onKey((S=>this._handleKey(S.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this._screenDprMonitor=new b.ScreenDprMonitor(window),this.register(this._screenDprMonitor),this._screenDprMonitor.setListener((()=>this._refreshRowsDimensions())),this.register((0,d.addDisposableDomListener)(window,"resize",(()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,y.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(h){for(let _=0;_<h;_++)this._handleChar(" ")}_handleChar(h){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==h&&(this._charsToAnnounce+=h):this._charsToAnnounce+=h,h===`
10
- `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=a.tooMuchOutput)),p.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,p.isMac&&this._liveRegion.remove()}_handleKey(h){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(h)||this._charsToConsume.push(h)}_refreshRows(h,_){this._liveRegionDebouncer.refresh(h,_,this._terminal.rows)}_renderRows(h,_){const S=this._terminal.buffer,k=S.lines.length.toString();for(let E=h;E<=_;E++){const x=S.translateBufferLineToString(S.ydisp+E,!0),C=(S.ydisp+E+1).toString(),T=this._rowElements[E];T&&(x.length===0?T.innerText=" ":T.textContent=x,T.setAttribute("aria-posinset",C),T.setAttribute("aria-setsize",k))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(h,_){const S=h.target,k=this._rowElements[_===0?1:this._rowElements.length-2];if(S.getAttribute("aria-posinset")===(_===0?"1":`${this._terminal.buffer.lines.length}`)||h.relatedTarget!==k)return;let E,x;if(_===0?(E=S,x=this._rowElements.pop(),this._rowContainer.removeChild(x)):(E=this._rowElements.shift(),x=S,this._rowContainer.removeChild(E)),E.removeEventListener("focus",this._topBoundaryFocusListener),x.removeEventListener("focus",this._bottomBoundaryFocusListener),_===0){const C=this._createAccessibilityTreeNode();this._rowElements.unshift(C),this._rowContainer.insertAdjacentElement("afterbegin",C)}else{const C=this._createAccessibilityTreeNode();this._rowElements.push(C),this._rowContainer.appendChild(C)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(_===0?-1:1),this._rowElements[_===0?1:this._rowElements.length-2].focus(),h.preventDefault(),h.stopImmediatePropagation()}_handleResize(h){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let _=this._rowContainer.children.length;_<this._terminal.rows;_++)this._rowElements[_]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[_]);for(;this._rowElements.length>h;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const h=document.createElement("div");return h.setAttribute("role","listitem"),h.tabIndex=-1,this._refreshRowDimensions(h),h}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let h=0;h<this._terminal.rows;h++)this._refreshRowDimensions(this._rowElements[h])}}_refreshRowDimensions(h){h.style.height=`${this._renderService.dimensions.css.cell.height}px`}};i.AccessibilityManager=c=u([f(1,n.IRenderService)],c)},3614:(w,i)=>{function o(p){return p.replace(/\r?\n/g,"\r")}function u(p,m){return m?"\x1B[200~"+p+"\x1B[201~":p}function f(p,m,y,b){p=u(p=o(p),y.decPrivateModes.bracketedPasteMode&&b.rawOptions.ignoreBracketedPasteMode!==!0),y.triggerDataEvent(p,!0),m.value=""}function a(p,m,y){const b=y.getBoundingClientRect(),n=p.clientX-b.left-10,d=p.clientY-b.top-10;m.style.width="20px",m.style.height="20px",m.style.left=`${n}px`,m.style.top=`${d}px`,m.style.zIndex="1000",m.focus()}Object.defineProperty(i,"__esModule",{value:!0}),i.rightClickHandler=i.moveTextAreaUnderMouseCursor=i.paste=i.handlePasteEvent=i.copyHandler=i.bracketTextForPaste=i.prepareTextForTerminal=void 0,i.prepareTextForTerminal=o,i.bracketTextForPaste=u,i.copyHandler=function(p,m){p.clipboardData&&p.clipboardData.setData("text/plain",m.selectionText),p.preventDefault()},i.handlePasteEvent=function(p,m,y,b){p.stopPropagation(),p.clipboardData&&f(p.clipboardData.getData("text/plain"),m,y,b)},i.paste=f,i.moveTextAreaUnderMouseCursor=a,i.rightClickHandler=function(p,m,y,b,n){a(p,m,y),n&&b.rightClickSelect(p),m.value=b.selectionText,m.select()}},7239:(w,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ColorContrastCache=void 0;const u=o(1505);i.ColorContrastCache=class{constructor(){this._color=new u.TwoKeyMap,this._css=new u.TwoKeyMap}setCss(f,a,p){this._css.set(f,a,p)}getCss(f,a){return this._css.get(f,a)}setColor(f,a,p){this._color.set(f,a,p)}getColor(f,a){return this._color.get(f,a)}clear(){this._color.clear(),this._css.clear()}}},3656:(w,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.addDisposableDomListener=void 0,i.addDisposableDomListener=function(o,u,f,a){o.addEventListener(u,f,a);let p=!1;return{dispose:()=>{p||(p=!0,o.removeEventListener(u,f,a))}}}},6465:function(w,i,o){var u=this&&this.__decorate||function(n,d,c,h){var _,S=arguments.length,k=S<3?d:h===null?h=Object.getOwnPropertyDescriptor(d,c):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(n,d,c,h);else for(var E=n.length-1;E>=0;E--)(_=n[E])&&(k=(S<3?_(k):S>3?_(d,c,k):_(d,c))||k);return S>3&&k&&Object.defineProperty(d,c,k),k},f=this&&this.__param||function(n,d){return function(c,h){d(c,h,n)}};Object.defineProperty(i,"__esModule",{value:!0}),i.Linkifier2=void 0;const a=o(3656),p=o(8460),m=o(844),y=o(2585);let b=i.Linkifier2=class extends m.Disposable{get currentLink(){return this._currentLink}constructor(n){super(),this._bufferService=n,this._linkProviders=[],this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new p.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new p.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,m.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,m.toDisposable)((()=>{this._lastMouseEvent=void 0}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0})))}registerLinkProvider(n){return this._linkProviders.push(n),{dispose:()=>{const d=this._linkProviders.indexOf(n);d!==-1&&this._linkProviders.splice(d,1)}}}attachToDom(n,d,c){this._element=n,this._mouseService=d,this._renderService=c,this.register((0,a.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,a.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,a.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,a.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(n){if(this._lastMouseEvent=n,!this._element||!this._mouseService)return;const d=this._positionFromMouseEvent(n,this._element,this._mouseService);if(!d)return;this._isMouseOut=!1;const c=n.composedPath();for(let h=0;h<c.length;h++){const _=c[h];if(_.classList.contains("xterm"))break;if(_.classList.contains("xterm-hover"))return}this._lastBufferCell&&d.x===this._lastBufferCell.x&&d.y===this._lastBufferCell.y||(this._handleHover(d),this._lastBufferCell=d)}_handleHover(n){if(this._activeLine!==n.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(n,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,n)||(this._clearCurrentLink(),this._askForLink(n,!0))}_askForLink(n,d){var c,h;this._activeProviderReplies&&d||((c=this._activeProviderReplies)===null||c===void 0||c.forEach((S=>{S?.forEach((k=>{k.link.dispose&&k.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=n.y);let _=!1;for(const[S,k]of this._linkProviders.entries())d?!((h=this._activeProviderReplies)===null||h===void 0)&&h.get(S)&&(_=this._checkLinkProviderResult(S,n,_)):k.provideLinks(n.y,(E=>{var x,C;if(this._isMouseOut)return;const T=E?.map((L=>({link:L})));(x=this._activeProviderReplies)===null||x===void 0||x.set(S,T),_=this._checkLinkProviderResult(S,n,_),((C=this._activeProviderReplies)===null||C===void 0?void 0:C.size)===this._linkProviders.length&&this._removeIntersectingLinks(n.y,this._activeProviderReplies)}))}_removeIntersectingLinks(n,d){const c=new Set;for(let h=0;h<d.size;h++){const _=d.get(h);if(_)for(let S=0;S<_.length;S++){const k=_[S],E=k.link.range.start.y<n?0:k.link.range.start.x,x=k.link.range.end.y>n?this._bufferService.cols:k.link.range.end.x;for(let C=E;C<=x;C++){if(c.has(C)){_.splice(S--,1);break}c.add(C)}}}}_checkLinkProviderResult(n,d,c){var h;if(!this._activeProviderReplies)return c;const _=this._activeProviderReplies.get(n);let S=!1;for(let k=0;k<n;k++)this._activeProviderReplies.has(k)&&!this._activeProviderReplies.get(k)||(S=!0);if(!S&&_){const k=_.find((E=>this._linkAtPosition(E.link,d)));k&&(c=!0,this._handleNewLink(k))}if(this._activeProviderReplies.size===this._linkProviders.length&&!c)for(let k=0;k<this._activeProviderReplies.size;k++){const E=(h=this._activeProviderReplies.get(k))===null||h===void 0?void 0:h.find((x=>this._linkAtPosition(x.link,d)));if(E){c=!0,this._handleNewLink(E);break}}return c}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(n){if(!this._element||!this._mouseService||!this._currentLink)return;const d=this._positionFromMouseEvent(n,this._element,this._mouseService);d&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,d)&&this._currentLink.link.activate(n,this._currentLink.link.text)}_clearCurrentLink(n,d){this._element&&this._currentLink&&this._lastMouseEvent&&(!n||!d||this._currentLink.link.range.start.y>=n&&this._currentLink.link.range.end.y<=d)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,m.disposeArray)(this._linkCacheDisposables))}_handleNewLink(n){if(!this._element||!this._lastMouseEvent||!this._mouseService)return;const d=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);d&&this._linkAtPosition(n.link,d)&&(this._currentLink=n,this._currentLink.state={decorations:{underline:n.link.decorations===void 0||n.link.decorations.underline,pointerCursor:n.link.decorations===void 0||n.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,n.link,this._lastMouseEvent),n.link.decorations={},Object.defineProperties(n.link.decorations,{pointerCursor:{get:()=>{var c,h;return(h=(c=this._currentLink)===null||c===void 0?void 0:c.state)===null||h===void 0?void 0:h.decorations.pointerCursor},set:c=>{var h,_;!((h=this._currentLink)===null||h===void 0)&&h.state&&this._currentLink.state.decorations.pointerCursor!==c&&(this._currentLink.state.decorations.pointerCursor=c,this._currentLink.state.isHovered&&((_=this._element)===null||_===void 0||_.classList.toggle("xterm-cursor-pointer",c)))}},underline:{get:()=>{var c,h;return(h=(c=this._currentLink)===null||c===void 0?void 0:c.state)===null||h===void 0?void 0:h.decorations.underline},set:c=>{var h,_,S;!((h=this._currentLink)===null||h===void 0)&&h.state&&((S=(_=this._currentLink)===null||_===void 0?void 0:_.state)===null||S===void 0?void 0:S.decorations.underline)!==c&&(this._currentLink.state.decorations.underline=c,this._currentLink.state.isHovered&&this._fireUnderlineEvent(n.link,c))}}}),this._renderService&&this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((c=>{if(!this._currentLink)return;const h=c.start===0?0:c.start+1+this._bufferService.buffer.ydisp,_=this._bufferService.buffer.ydisp+1+c.end;if(this._currentLink.link.range.start.y>=h&&this._currentLink.link.range.end.y<=_&&(this._clearCurrentLink(h,_),this._lastMouseEvent&&this._element)){const S=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);S&&this._askForLink(S,!1)}}))))}_linkHover(n,d,c){var h;!((h=this._currentLink)===null||h===void 0)&&h.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(d,!0),this._currentLink.state.decorations.pointerCursor&&n.classList.add("xterm-cursor-pointer")),d.hover&&d.hover(c,d.text)}_fireUnderlineEvent(n,d){const c=n.range,h=this._bufferService.buffer.ydisp,_=this._createLinkUnderlineEvent(c.start.x-1,c.start.y-h-1,c.end.x,c.end.y-h-1,void 0);(d?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(_)}_linkLeave(n,d,c){var h;!((h=this._currentLink)===null||h===void 0)&&h.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(d,!1),this._currentLink.state.decorations.pointerCursor&&n.classList.remove("xterm-cursor-pointer")),d.leave&&d.leave(c,d.text)}_linkAtPosition(n,d){const c=n.range.start.y*this._bufferService.cols+n.range.start.x,h=n.range.end.y*this._bufferService.cols+n.range.end.x,_=d.y*this._bufferService.cols+d.x;return c<=_&&_<=h}_positionFromMouseEvent(n,d,c){const h=c.getCoords(n,d,this._bufferService.cols,this._bufferService.rows);if(h)return{x:h[0],y:h[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(n,d,c,h,_){return{x1:n,y1:d,x2:c,y2:h,cols:this._bufferService.cols,fg:_}}};i.Linkifier2=b=u([f(0,y.IBufferService)],b)},9042:(w,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(w,i,o){var u=this&&this.__decorate||function(b,n,d,c){var h,_=arguments.length,S=_<3?n:c===null?c=Object.getOwnPropertyDescriptor(n,d):c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(b,n,d,c);else for(var k=b.length-1;k>=0;k--)(h=b[k])&&(S=(_<3?h(S):_>3?h(n,d,S):h(n,d))||S);return _>3&&S&&Object.defineProperty(n,d,S),S},f=this&&this.__param||function(b,n){return function(d,c){n(d,c,b)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OscLinkProvider=void 0;const a=o(511),p=o(2585);let m=i.OscLinkProvider=class{constructor(b,n,d){this._bufferService=b,this._optionsService=n,this._oscLinkService=d}provideLinks(b,n){var d;const c=this._bufferService.buffer.lines.get(b-1);if(!c)return void n(void 0);const h=[],_=this._optionsService.rawOptions.linkHandler,S=new a.CellData,k=c.getTrimmedLength();let E=-1,x=-1,C=!1;for(let T=0;T<k;T++)if(x!==-1||c.hasContent(T)){if(c.loadCell(T,S),S.hasExtendedAttrs()&&S.extended.urlId){if(x===-1){x=T,E=S.extended.urlId;continue}C=S.extended.urlId!==E}else x!==-1&&(C=!0);if(C||x!==-1&&T===k-1){const L=(d=this._oscLinkService.getLinkData(E))===null||d===void 0?void 0:d.uri;if(L){const R={start:{x:x+1,y:b},end:{x:T+(C||T!==k-1?0:1),y:b}};let M=!1;if(!_?.allowNonHttpProtocols)try{const I=new URL(L);["http:","https:"].includes(I.protocol)||(M=!0)}catch{M=!0}M||h.push({text:L,range:R,activate:(I,B)=>_?_.activate(I,B,R):y(0,B),hover:(I,B)=>{var H;return(H=_?.hover)===null||H===void 0?void 0:H.call(_,I,B,R)},leave:(I,B)=>{var H;return(H=_?.leave)===null||H===void 0?void 0:H.call(_,I,B,R)}})}C=!1,S.hasExtendedAttrs()&&S.extended.urlId?(x=T,E=S.extended.urlId):(x=-1,E=-1)}}n(h)}};function y(b,n){if(confirm(`Do you want to navigate to ${n}?
10
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=a.tooMuchOutput)),p.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,p.isMac&&this._liveRegion.remove()}_handleKey(h){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(h)||this._charsToConsume.push(h)}_refreshRows(h,_){this._liveRegionDebouncer.refresh(h,_,this._terminal.rows)}_renderRows(h,_){const S=this._terminal.buffer,k=S.lines.length.toString();for(let E=h;E<=_;E++){const x=S.translateBufferLineToString(S.ydisp+E,!0),C=(S.ydisp+E+1).toString(),T=this._rowElements[E];T&&(x.length===0?T.innerText=" ":T.textContent=x,T.setAttribute("aria-posinset",C),T.setAttribute("aria-setsize",k))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(h,_){const S=h.target,k=this._rowElements[_===0?1:this._rowElements.length-2];if(S.getAttribute("aria-posinset")===(_===0?"1":`${this._terminal.buffer.lines.length}`)||h.relatedTarget!==k)return;let E,x;if(_===0?(E=S,x=this._rowElements.pop(),this._rowContainer.removeChild(x)):(E=this._rowElements.shift(),x=S,this._rowContainer.removeChild(E)),E.removeEventListener("focus",this._topBoundaryFocusListener),x.removeEventListener("focus",this._bottomBoundaryFocusListener),_===0){const C=this._createAccessibilityTreeNode();this._rowElements.unshift(C),this._rowContainer.insertAdjacentElement("afterbegin",C)}else{const C=this._createAccessibilityTreeNode();this._rowElements.push(C),this._rowContainer.appendChild(C)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(_===0?-1:1),this._rowElements[_===0?1:this._rowElements.length-2].focus(),h.preventDefault(),h.stopImmediatePropagation()}_handleResize(h){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let _=this._rowContainer.children.length;_<this._terminal.rows;_++)this._rowElements[_]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[_]);for(;this._rowElements.length>h;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const h=document.createElement("div");return h.setAttribute("role","listitem"),h.tabIndex=-1,this._refreshRowDimensions(h),h}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let h=0;h<this._terminal.rows;h++)this._refreshRowDimensions(this._rowElements[h])}}_refreshRowDimensions(h){h.style.height=`${this._renderService.dimensions.css.cell.height}px`}};r.AccessibilityManager=c=u([f(1,n.IRenderService)],c)},3614:(w,r)=>{function o(p){return p.replace(/\r?\n/g,"\r")}function u(p,m){return m?"\x1B[200~"+p+"\x1B[201~":p}function f(p,m,y,b){p=u(p=o(p),y.decPrivateModes.bracketedPasteMode&&b.rawOptions.ignoreBracketedPasteMode!==!0),y.triggerDataEvent(p,!0),m.value=""}function a(p,m,y){const b=y.getBoundingClientRect(),n=p.clientX-b.left-10,d=p.clientY-b.top-10;m.style.width="20px",m.style.height="20px",m.style.left=`${n}px`,m.style.top=`${d}px`,m.style.zIndex="1000",m.focus()}Object.defineProperty(r,"__esModule",{value:!0}),r.rightClickHandler=r.moveTextAreaUnderMouseCursor=r.paste=r.handlePasteEvent=r.copyHandler=r.bracketTextForPaste=r.prepareTextForTerminal=void 0,r.prepareTextForTerminal=o,r.bracketTextForPaste=u,r.copyHandler=function(p,m){p.clipboardData&&p.clipboardData.setData("text/plain",m.selectionText),p.preventDefault()},r.handlePasteEvent=function(p,m,y,b){p.stopPropagation(),p.clipboardData&&f(p.clipboardData.getData("text/plain"),m,y,b)},r.paste=f,r.moveTextAreaUnderMouseCursor=a,r.rightClickHandler=function(p,m,y,b,n){a(p,m,y),n&&b.rightClickSelect(p),m.value=b.selectionText,m.select()}},7239:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ColorContrastCache=void 0;const u=o(1505);r.ColorContrastCache=class{constructor(){this._color=new u.TwoKeyMap,this._css=new u.TwoKeyMap}setCss(f,a,p){this._css.set(f,a,p)}getCss(f,a){return this._css.get(f,a)}setColor(f,a,p){this._color.set(f,a,p)}getColor(f,a){return this._color.get(f,a)}clear(){this._color.clear(),this._css.clear()}}},3656:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.addDisposableDomListener=void 0,r.addDisposableDomListener=function(o,u,f,a){o.addEventListener(u,f,a);let p=!1;return{dispose:()=>{p||(p=!0,o.removeEventListener(u,f,a))}}}},6465:function(w,r,o){var u=this&&this.__decorate||function(n,d,c,h){var _,S=arguments.length,k=S<3?d:h===null?h=Object.getOwnPropertyDescriptor(d,c):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(n,d,c,h);else for(var E=n.length-1;E>=0;E--)(_=n[E])&&(k=(S<3?_(k):S>3?_(d,c,k):_(d,c))||k);return S>3&&k&&Object.defineProperty(d,c,k),k},f=this&&this.__param||function(n,d){return function(c,h){d(c,h,n)}};Object.defineProperty(r,"__esModule",{value:!0}),r.Linkifier2=void 0;const a=o(3656),p=o(8460),m=o(844),y=o(2585);let b=r.Linkifier2=class extends m.Disposable{get currentLink(){return this._currentLink}constructor(n){super(),this._bufferService=n,this._linkProviders=[],this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new p.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new p.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,m.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,m.toDisposable)((()=>{this._lastMouseEvent=void 0}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0})))}registerLinkProvider(n){return this._linkProviders.push(n),{dispose:()=>{const d=this._linkProviders.indexOf(n);d!==-1&&this._linkProviders.splice(d,1)}}}attachToDom(n,d,c){this._element=n,this._mouseService=d,this._renderService=c,this.register((0,a.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,a.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,a.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,a.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(n){if(this._lastMouseEvent=n,!this._element||!this._mouseService)return;const d=this._positionFromMouseEvent(n,this._element,this._mouseService);if(!d)return;this._isMouseOut=!1;const c=n.composedPath();for(let h=0;h<c.length;h++){const _=c[h];if(_.classList.contains("xterm"))break;if(_.classList.contains("xterm-hover"))return}this._lastBufferCell&&d.x===this._lastBufferCell.x&&d.y===this._lastBufferCell.y||(this._handleHover(d),this._lastBufferCell=d)}_handleHover(n){if(this._activeLine!==n.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(n,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,n)||(this._clearCurrentLink(),this._askForLink(n,!0))}_askForLink(n,d){var c,h;this._activeProviderReplies&&d||((c=this._activeProviderReplies)===null||c===void 0||c.forEach((S=>{S?.forEach((k=>{k.link.dispose&&k.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=n.y);let _=!1;for(const[S,k]of this._linkProviders.entries())d?!((h=this._activeProviderReplies)===null||h===void 0)&&h.get(S)&&(_=this._checkLinkProviderResult(S,n,_)):k.provideLinks(n.y,(E=>{var x,C;if(this._isMouseOut)return;const T=E?.map((L=>({link:L})));(x=this._activeProviderReplies)===null||x===void 0||x.set(S,T),_=this._checkLinkProviderResult(S,n,_),((C=this._activeProviderReplies)===null||C===void 0?void 0:C.size)===this._linkProviders.length&&this._removeIntersectingLinks(n.y,this._activeProviderReplies)}))}_removeIntersectingLinks(n,d){const c=new Set;for(let h=0;h<d.size;h++){const _=d.get(h);if(_)for(let S=0;S<_.length;S++){const k=_[S],E=k.link.range.start.y<n?0:k.link.range.start.x,x=k.link.range.end.y>n?this._bufferService.cols:k.link.range.end.x;for(let C=E;C<=x;C++){if(c.has(C)){_.splice(S--,1);break}c.add(C)}}}}_checkLinkProviderResult(n,d,c){var h;if(!this._activeProviderReplies)return c;const _=this._activeProviderReplies.get(n);let S=!1;for(let k=0;k<n;k++)this._activeProviderReplies.has(k)&&!this._activeProviderReplies.get(k)||(S=!0);if(!S&&_){const k=_.find((E=>this._linkAtPosition(E.link,d)));k&&(c=!0,this._handleNewLink(k))}if(this._activeProviderReplies.size===this._linkProviders.length&&!c)for(let k=0;k<this._activeProviderReplies.size;k++){const E=(h=this._activeProviderReplies.get(k))===null||h===void 0?void 0:h.find((x=>this._linkAtPosition(x.link,d)));if(E){c=!0,this._handleNewLink(E);break}}return c}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(n){if(!this._element||!this._mouseService||!this._currentLink)return;const d=this._positionFromMouseEvent(n,this._element,this._mouseService);d&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,d)&&this._currentLink.link.activate(n,this._currentLink.link.text)}_clearCurrentLink(n,d){this._element&&this._currentLink&&this._lastMouseEvent&&(!n||!d||this._currentLink.link.range.start.y>=n&&this._currentLink.link.range.end.y<=d)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,m.disposeArray)(this._linkCacheDisposables))}_handleNewLink(n){if(!this._element||!this._lastMouseEvent||!this._mouseService)return;const d=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);d&&this._linkAtPosition(n.link,d)&&(this._currentLink=n,this._currentLink.state={decorations:{underline:n.link.decorations===void 0||n.link.decorations.underline,pointerCursor:n.link.decorations===void 0||n.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,n.link,this._lastMouseEvent),n.link.decorations={},Object.defineProperties(n.link.decorations,{pointerCursor:{get:()=>{var c,h;return(h=(c=this._currentLink)===null||c===void 0?void 0:c.state)===null||h===void 0?void 0:h.decorations.pointerCursor},set:c=>{var h,_;!((h=this._currentLink)===null||h===void 0)&&h.state&&this._currentLink.state.decorations.pointerCursor!==c&&(this._currentLink.state.decorations.pointerCursor=c,this._currentLink.state.isHovered&&((_=this._element)===null||_===void 0||_.classList.toggle("xterm-cursor-pointer",c)))}},underline:{get:()=>{var c,h;return(h=(c=this._currentLink)===null||c===void 0?void 0:c.state)===null||h===void 0?void 0:h.decorations.underline},set:c=>{var h,_,S;!((h=this._currentLink)===null||h===void 0)&&h.state&&((S=(_=this._currentLink)===null||_===void 0?void 0:_.state)===null||S===void 0?void 0:S.decorations.underline)!==c&&(this._currentLink.state.decorations.underline=c,this._currentLink.state.isHovered&&this._fireUnderlineEvent(n.link,c))}}}),this._renderService&&this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((c=>{if(!this._currentLink)return;const h=c.start===0?0:c.start+1+this._bufferService.buffer.ydisp,_=this._bufferService.buffer.ydisp+1+c.end;if(this._currentLink.link.range.start.y>=h&&this._currentLink.link.range.end.y<=_&&(this._clearCurrentLink(h,_),this._lastMouseEvent&&this._element)){const S=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);S&&this._askForLink(S,!1)}}))))}_linkHover(n,d,c){var h;!((h=this._currentLink)===null||h===void 0)&&h.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(d,!0),this._currentLink.state.decorations.pointerCursor&&n.classList.add("xterm-cursor-pointer")),d.hover&&d.hover(c,d.text)}_fireUnderlineEvent(n,d){const c=n.range,h=this._bufferService.buffer.ydisp,_=this._createLinkUnderlineEvent(c.start.x-1,c.start.y-h-1,c.end.x,c.end.y-h-1,void 0);(d?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(_)}_linkLeave(n,d,c){var h;!((h=this._currentLink)===null||h===void 0)&&h.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(d,!1),this._currentLink.state.decorations.pointerCursor&&n.classList.remove("xterm-cursor-pointer")),d.leave&&d.leave(c,d.text)}_linkAtPosition(n,d){const c=n.range.start.y*this._bufferService.cols+n.range.start.x,h=n.range.end.y*this._bufferService.cols+n.range.end.x,_=d.y*this._bufferService.cols+d.x;return c<=_&&_<=h}_positionFromMouseEvent(n,d,c){const h=c.getCoords(n,d,this._bufferService.cols,this._bufferService.rows);if(h)return{x:h[0],y:h[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(n,d,c,h,_){return{x1:n,y1:d,x2:c,y2:h,cols:this._bufferService.cols,fg:_}}};r.Linkifier2=b=u([f(0,y.IBufferService)],b)},9042:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.tooMuchOutput=r.promptLabel=void 0,r.promptLabel="Terminal input",r.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(w,r,o){var u=this&&this.__decorate||function(b,n,d,c){var h,_=arguments.length,S=_<3?n:c===null?c=Object.getOwnPropertyDescriptor(n,d):c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(b,n,d,c);else for(var k=b.length-1;k>=0;k--)(h=b[k])&&(S=(_<3?h(S):_>3?h(n,d,S):h(n,d))||S);return _>3&&S&&Object.defineProperty(n,d,S),S},f=this&&this.__param||function(b,n){return function(d,c){n(d,c,b)}};Object.defineProperty(r,"__esModule",{value:!0}),r.OscLinkProvider=void 0;const a=o(511),p=o(2585);let m=r.OscLinkProvider=class{constructor(b,n,d){this._bufferService=b,this._optionsService=n,this._oscLinkService=d}provideLinks(b,n){var d;const c=this._bufferService.buffer.lines.get(b-1);if(!c)return void n(void 0);const h=[],_=this._optionsService.rawOptions.linkHandler,S=new a.CellData,k=c.getTrimmedLength();let E=-1,x=-1,C=!1;for(let T=0;T<k;T++)if(x!==-1||c.hasContent(T)){if(c.loadCell(T,S),S.hasExtendedAttrs()&&S.extended.urlId){if(x===-1){x=T,E=S.extended.urlId;continue}C=S.extended.urlId!==E}else x!==-1&&(C=!0);if(C||x!==-1&&T===k-1){const L=(d=this._oscLinkService.getLinkData(E))===null||d===void 0?void 0:d.uri;if(L){const R={start:{x:x+1,y:b},end:{x:T+(C||T!==k-1?0:1),y:b}};let M=!1;if(!_?.allowNonHttpProtocols)try{const I=new URL(L);["http:","https:"].includes(I.protocol)||(M=!0)}catch{M=!0}M||h.push({text:L,range:R,activate:(I,B)=>_?_.activate(I,B,R):y(0,B),hover:(I,B)=>{var H;return(H=_?.hover)===null||H===void 0?void 0:H.call(_,I,B,R)},leave:(I,B)=>{var H;return(H=_?.leave)===null||H===void 0?void 0:H.call(_,I,B,R)}})}C=!1,S.hasExtendedAttrs()&&S.extended.urlId?(x=T,E=S.extended.urlId):(x=-1,E=-1)}}n(h)}};function y(b,n){if(confirm(`Do you want to navigate to ${n}?
11
11
 
12
- WARNING: This link could potentially be dangerous`)){const d=window.open();if(d){try{d.opener=null}catch{}d.location.href=n}else console.warn("Opening link blocked as opener could not be cleared")}}i.OscLinkProvider=m=u([f(0,p.IBufferService),f(1,p.IOptionsService),f(2,p.IOscLinkService)],m)},6193:(w,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.RenderDebouncer=void 0,i.RenderDebouncer=class{constructor(o,u){this._parentWindow=o,this._renderCallback=u,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._parentWindow.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(o){return this._refreshCallbacks.push(o),this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(o,u,f){this._rowCount=f,o=o!==void 0?o:0,u=u!==void 0?u:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,o):o,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,u):u,this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return void this._runRefreshCallbacks();const o=Math.max(this._rowStart,0),u=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(o,u),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const o of this._refreshCallbacks)o(0);this._refreshCallbacks=[]}}},5596:(w,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ScreenDprMonitor=void 0;const u=o(844);class f extends u.Disposable{constructor(p){super(),this._parentWindow=p,this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this.register((0,u.toDisposable)((()=>{this.clearListener()})))}setListener(p){this._listener&&this.clearListener(),this._listener=p,this._outerListener=()=>{this._listener&&(this._listener(this._parentWindow.devicePixelRatio,this._currentDevicePixelRatio),this._updateDpr())},this._updateDpr()}_updateDpr(){var p;this._outerListener&&((p=this._resolutionMediaMatchList)===null||p===void 0||p.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=f},3236:(w,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Terminal=void 0;const u=o(3614),f=o(3656),a=o(6465),p=o(9042),m=o(3730),y=o(1680),b=o(3107),n=o(5744),d=o(2950),c=o(1296),h=o(428),_=o(4269),S=o(5114),k=o(8934),E=o(3230),x=o(9312),C=o(4725),T=o(6731),L=o(8055),R=o(8969),M=o(8460),I=o(844),B=o(6114),H=o(8437),$=o(2584),N=o(7399),P=o(5941),D=o(9074),O=o(2585),q=o(5435),K=o(4567),U=typeof window<"u"?window.document:null;class z extends R.CoreTerminal{get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}constructor(j={}){super(j),this.browser=B,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new I.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(a.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(m.OscLinkProvider)),this._decorationService=this._instantiationService.createInstance(D.DecorationService),this._instantiationService.setService(O.IDecorationService,this._decorationService),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((F,X)=>this.refresh(F,X)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((F=>this._reportWindowsOptions(F)))),this.register(this._inputHandler.onColor((F=>this._handleColorEvent(F)))),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((F=>this._afterResize(F.cols,F.rows)))),this.register((0,I.toDisposable)((()=>{var F,X;this._customKeyEventHandler=void 0,(X=(F=this.element)===null||F===void 0?void 0:F.parentNode)===null||X===void 0||X.removeChild(this.element)})))}_handleColorEvent(j){if(this._themeService)for(const F of j){let X,Y="";switch(F.index){case 256:X="foreground",Y="10";break;case 257:X="background",Y="11";break;case 258:X="cursor",Y="12";break;default:X="ansi",Y="4;"+F.index}switch(F.type){case 0:const ee=L.color.toColorRGB(X==="ansi"?this._themeService.colors.ansi[F.index]:this._themeService.colors[X]);this.coreService.triggerDataEvent(`${$.C0.ESC}]${Y};${(0,P.toRgbString)(ee)}${$.C1_ESCAPED.ST}`);break;case 1:if(X==="ansi")this._themeService.modifyColors((G=>G.ansi[F.index]=L.rgba.toColor(...F.color)));else{const G=X;this._themeService.modifyColors((Z=>Z[G]=L.rgba.toColor(...F.color)))}break;case 2:this._themeService.restoreColor(F.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(j){j?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(K.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(j){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.C0.ESC+"[I"),this.updateCursorStyle(j),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var j;return(j=this.textarea)===null||j===void 0?void 0:j.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;const j=this.buffer.ybase+this.buffer.y,F=this.buffer.lines.get(j);if(!F)return;const X=Math.min(this.buffer.x,this.cols-1),Y=this._renderService.dimensions.css.cell.height,ee=F.getWidth(X),G=this._renderService.dimensions.css.cell.width*ee,Z=this.buffer.y*this._renderService.dimensions.css.cell.height,ae=X*this._renderService.dimensions.css.cell.width;this.textarea.style.left=ae+"px",this.textarea.style.top=Z+"px",this.textarea.style.width=G+"px",this.textarea.style.height=Y+"px",this.textarea.style.lineHeight=Y+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,f.addDisposableDomListener)(this.element,"copy",(F=>{this.hasSelection()&&(0,u.copyHandler)(F,this._selectionService)})));const j=F=>(0,u.handlePasteEvent)(F,this.textarea,this.coreService,this.optionsService);this.register((0,f.addDisposableDomListener)(this.textarea,"paste",j)),this.register((0,f.addDisposableDomListener)(this.element,"paste",j)),B.isFirefox?this.register((0,f.addDisposableDomListener)(this.element,"mousedown",(F=>{F.button===2&&(0,u.rightClickHandler)(F,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,f.addDisposableDomListener)(this.element,"contextmenu",(F=>{(0,u.rightClickHandler)(F,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),B.isLinux&&this.register((0,f.addDisposableDomListener)(this.element,"auxclick",(F=>{F.button===1&&(0,u.moveTextAreaUnderMouseCursor)(F,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,f.addDisposableDomListener)(this.textarea,"keyup",(j=>this._keyUp(j)),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"keydown",(j=>this._keyDown(j)),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"keypress",(j=>this._keyPress(j)),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionupdate",(j=>this._compositionHelper.compositionupdate(j)))),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,f.addDisposableDomListener)(this.textarea,"input",(j=>this._inputEvent(j)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(j){var F;if(!j)throw new Error("Terminal requires a parent element.");j.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this._document=j.ownerDocument,this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),j.appendChild(this.element);const X=U.createDocumentFragment();this._viewportElement=U.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),X.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),X.appendChild(this.screenElement),this.textarea=U.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",p.promptLabel),B.isChromeOS||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._coreBrowserService=this._instantiationService.createInstance(S.CoreBrowserService,this.textarea,(F=this._document.defaultView)!==null&&F!==void 0?F:window),this._instantiationService.setService(C.ICoreBrowserService,this._coreBrowserService),this.register((0,f.addDisposableDomListener)(this.textarea,"focus",(Y=>this._handleTextAreaFocus(Y)))),this.register((0,f.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(h.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(C.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(T.ThemeService),this._instantiationService.setService(C.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(_.CharacterJoinerService),this._instantiationService.setService(C.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(E.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(C.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((Y=>this._onRender.fire(Y)))),this.onResize((Y=>this._renderService.resize(Y.cols,Y.rows))),this._compositionView=U.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(d.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this.element.appendChild(X);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._mouseService=this._instantiationService.createInstance(k.MouseService),this._instantiationService.setService(C.IMouseService,this._mouseService),this.viewport=this._instantiationService.createInstance(y.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((Y=>this.scrollLines(Y.amount,Y.suppressScrollEvent,1))),this.register(this._inputHandler.onRequestSyncScrollBar((()=>this.viewport.syncScrollArea()))),this.register(this.viewport),this.register(this.onCursorMove((()=>{this._renderService.handleCursorMove(),this._syncTextArea()}))),this.register(this.onResize((()=>this._renderService.handleResize(this.cols,this.rows)))),this.register(this.onBlur((()=>this._renderService.handleBlur()))),this.register(this.onFocus((()=>this._renderService.handleFocus()))),this.register(this._renderService.onDimensionsChange((()=>this.viewport.syncScrollArea()))),this._selectionService=this.register(this._instantiationService.createInstance(x.SelectionService,this.element,this.screenElement,this.linkifier2)),this._instantiationService.setService(C.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((Y=>this.scrollLines(Y.amount,Y.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((Y=>this._renderService.handleSelectionChanged(Y.start,Y.end,Y.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((Y=>{this.textarea.value=Y,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((Y=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,f.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.linkifier2.attachToDom(this.screenElement,this._mouseService,this._renderService),this.register(this._instantiationService.createInstance(b.BufferDecorationRenderer,this.screenElement)),this.register((0,f.addDisposableDomListener)(this.element,"mousedown",(Y=>this._selectionService.handleMouseDown(Y)))),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(K.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(Y=>this._handleScreenReaderModeOptionChange(Y)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(n.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(Y=>{!this._overviewRulerRenderer&&Y&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(n.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(c.DomRenderer,this.element,this.screenElement,this._viewportElement,this.linkifier2)}bindMouse(){const j=this,F=this.element;function X(G){const Z=j._mouseService.getMouseReportCoords(G,j.screenElement);if(!Z)return!1;let ae,he;switch(G.overrideType||G.type){case"mousemove":he=32,G.buttons===void 0?(ae=3,G.button!==void 0&&(ae=G.button<3?G.button:3)):ae=1&G.buttons?0:4&G.buttons?1:2&G.buttons?2:3;break;case"mouseup":he=0,ae=G.button<3?G.button:3;break;case"mousedown":he=1,ae=G.button<3?G.button:3;break;case"wheel":if(j.viewport.getLinesScrolled(G)===0)return!1;he=G.deltaY<0?0:1,ae=4;break;default:return!1}return!(he===void 0||ae===void 0||ae>4)&&j.coreMouseService.triggerMouseEvent({col:Z.col,row:Z.row,x:Z.x,y:Z.y,button:ae,action:he,ctrl:G.ctrlKey,alt:G.altKey,shift:G.shiftKey})}const Y={mouseup:null,wheel:null,mousedrag:null,mousemove:null},ee={mouseup:G=>(X(G),G.buttons||(this._document.removeEventListener("mouseup",Y.mouseup),Y.mousedrag&&this._document.removeEventListener("mousemove",Y.mousedrag)),this.cancel(G)),wheel:G=>(X(G),this.cancel(G,!0)),mousedrag:G=>{G.buttons&&X(G)},mousemove:G=>{G.buttons||X(G)}};this.register(this.coreMouseService.onProtocolChange((G=>{G?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(G)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),8&G?Y.mousemove||(F.addEventListener("mousemove",ee.mousemove),Y.mousemove=ee.mousemove):(F.removeEventListener("mousemove",Y.mousemove),Y.mousemove=null),16&G?Y.wheel||(F.addEventListener("wheel",ee.wheel,{passive:!1}),Y.wheel=ee.wheel):(F.removeEventListener("wheel",Y.wheel),Y.wheel=null),2&G?Y.mouseup||(F.addEventListener("mouseup",ee.mouseup),Y.mouseup=ee.mouseup):(this._document.removeEventListener("mouseup",Y.mouseup),F.removeEventListener("mouseup",Y.mouseup),Y.mouseup=null),4&G?Y.mousedrag||(Y.mousedrag=ee.mousedrag):(this._document.removeEventListener("mousemove",Y.mousedrag),Y.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,f.addDisposableDomListener)(F,"mousedown",(G=>{if(G.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(G))return X(G),Y.mouseup&&this._document.addEventListener("mouseup",Y.mouseup),Y.mousedrag&&this._document.addEventListener("mousemove",Y.mousedrag),this.cancel(G)}))),this.register((0,f.addDisposableDomListener)(F,"wheel",(G=>{if(!Y.wheel){if(!this.buffer.hasScrollback){const Z=this.viewport.getLinesScrolled(G);if(Z===0)return;const ae=$.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(G.deltaY<0?"A":"B");let he="";for(let je=0;je<Math.abs(Z);je++)he+=ae;return this.coreService.triggerDataEvent(he,!0),this.cancel(G,!0)}return this.viewport.handleWheel(G)?this.cancel(G):void 0}}),{passive:!1})),this.register((0,f.addDisposableDomListener)(F,"touchstart",(G=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(G),this.cancel(G)}),{passive:!0})),this.register((0,f.addDisposableDomListener)(F,"touchmove",(G=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(G)?void 0:this.cancel(G)}),{passive:!1}))}refresh(j,F){var X;(X=this._renderService)===null||X===void 0||X.refreshRows(j,F)}updateCursorStyle(j){var F;!((F=this._selectionService)===null||F===void 0)&&F.shouldColumnSelect(j)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(j,F,X=0){var Y;X===1?(super.scrollLines(j,F,X),this.refresh(0,this.rows-1)):(Y=this.viewport)===null||Y===void 0||Y.scrollLines(j)}paste(j){(0,u.paste)(j,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(j){this._customKeyEventHandler=j}registerLinkProvider(j){return this.linkifier2.registerLinkProvider(j)}registerCharacterJoiner(j){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const F=this._characterJoinerService.register(j);return this.refresh(0,this.rows-1),F}deregisterCharacterJoiner(j){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(j)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(j){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+j)}registerDecoration(j){return this._decorationService.registerDecoration(j)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(j,F,X){this._selectionService.setSelection(j,F,X)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var j;(j=this._selectionService)===null||j===void 0||j.clearSelection()}selectAll(){var j;(j=this._selectionService)===null||j===void 0||j.selectAll()}selectLines(j,F){var X;(X=this._selectionService)===null||X===void 0||X.selectLines(j,F)}_keyDown(j){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(j)===!1)return!1;const F=this.browser.isMac&&this.options.macOptionIsMeta&&j.altKey;if(!F&&!this._compositionHelper.keydown(j))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;F||j.key!=="Dead"&&j.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const X=(0,N.evaluateKeyboardEvent)(j,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(j),X.type===3||X.type===2){const Y=this.rows-1;return this.scrollLines(X.type===2?-Y:Y),this.cancel(j,!0)}return X.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,j)||(X.cancel&&this.cancel(j,!0),!X.key||!!(j.key&&!j.ctrlKey&&!j.altKey&&!j.metaKey&&j.key.length===1&&j.key.charCodeAt(0)>=65&&j.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(X.key!==$.C0.ETX&&X.key!==$.C0.CR||(this.textarea.value=""),this._onKey.fire({key:X.key,domEvent:j}),this._showCursor(),this.coreService.triggerDataEvent(X.key,!0),!this.optionsService.rawOptions.screenReaderMode||j.altKey||j.ctrlKey?this.cancel(j,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(j,F){const X=j.isMac&&!this.options.macOptionIsMeta&&F.altKey&&!F.ctrlKey&&!F.metaKey||j.isWindows&&F.altKey&&F.ctrlKey&&!F.metaKey||j.isWindows&&F.getModifierState("AltGraph");return F.type==="keypress"?X:X&&(!F.keyCode||F.keyCode>47)}_keyUp(j){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(j)===!1||((function(F){return F.keyCode===16||F.keyCode===17||F.keyCode===18})(j)||this.focus(),this.updateCursorStyle(j),this._keyPressHandled=!1)}_keyPress(j){let F;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(j)===!1)return!1;if(this.cancel(j),j.charCode)F=j.charCode;else if(j.which===null||j.which===void 0)F=j.keyCode;else{if(j.which===0||j.charCode===0)return!1;F=j.which}return!(!F||(j.altKey||j.ctrlKey||j.metaKey)&&!this._isThirdLevelShift(this.browser,j)||(F=String.fromCharCode(F),this._onKey.fire({key:F,domEvent:j}),this._showCursor(),this.coreService.triggerDataEvent(F,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(j){if(j.data&&j.inputType==="insertText"&&(!j.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const F=j.data;return this.coreService.triggerDataEvent(F,!0),this.cancel(j),!0}return!1}resize(j,F){j!==this.cols||F!==this.rows?super.resize(j,F):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(j,F){var X,Y;(X=this._charSizeService)===null||X===void 0||X.measure(),(Y=this.viewport)===null||Y===void 0||Y.syncScrollArea(!0)}clear(){var j;if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let F=1;F<this.rows;F++)this.buffer.lines.push(this.buffer.getBlankLine(H.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(j=this.viewport)===null||j===void 0||j.reset(),this.refresh(0,this.rows-1)}}reset(){var j,F;this.options.rows=this.rows,this.options.cols=this.cols;const X=this._customKeyEventHandler;this._setup(),super.reset(),(j=this._selectionService)===null||j===void 0||j.reset(),this._decorationService.reset(),(F=this.viewport)===null||F===void 0||F.reset(),this._customKeyEventHandler=X,this.refresh(0,this.rows-1)}clearTextureAtlas(){var j;(j=this._renderService)===null||j===void 0||j.clearTextureAtlas()}_reportFocus(){var j;!((j=this.element)===null||j===void 0)&&j.classList.contains("focus")?this.coreService.triggerDataEvent($.C0.ESC+"[I"):this.coreService.triggerDataEvent($.C0.ESC+"[O")}_reportWindowsOptions(j){if(this._renderService)switch(j){case q.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const F=this._renderService.dimensions.css.canvas.width.toFixed(0),X=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${$.C0.ESC}[4;${X};${F}t`);break;case q.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const Y=this._renderService.dimensions.css.cell.width.toFixed(0),ee=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${$.C0.ESC}[6;${ee};${Y}t`)}}cancel(j,F){if(this.options.cancelEvents||F)return j.preventDefault(),j.stopPropagation(),!1}}i.Terminal=z},9924:(w,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.TimeBasedDebouncer=void 0,i.TimeBasedDebouncer=class{constructor(o,u=1e3){this._renderCallback=o,this._debounceThresholdMS=u,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(o,u,f){this._rowCount=f,o=o!==void 0?o:0,u=u!==void 0?u:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,o):o,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,u):u;const a=Date.now();if(a-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=a,this._innerRefresh();else if(!this._additionalRefreshRequested){const p=a-this._lastRefreshMs,m=this._debounceThresholdMS-p;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),m)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const o=Math.max(this._rowStart,0),u=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(o,u)}}},1680:function(w,i,o){var u=this&&this.__decorate||function(d,c,h,_){var S,k=arguments.length,E=k<3?c:_===null?_=Object.getOwnPropertyDescriptor(c,h):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(d,c,h,_);else for(var x=d.length-1;x>=0;x--)(S=d[x])&&(E=(k<3?S(E):k>3?S(c,h,E):S(c,h))||E);return k>3&&E&&Object.defineProperty(c,h,E),E},f=this&&this.__param||function(d,c){return function(h,_){c(h,_,d)}};Object.defineProperty(i,"__esModule",{value:!0}),i.Viewport=void 0;const a=o(3656),p=o(4725),m=o(8460),y=o(844),b=o(2585);let n=i.Viewport=class extends y.Disposable{constructor(d,c,h,_,S,k,E,x){super(),this._viewportElement=d,this._scrollArea=c,this._bufferService=h,this._optionsService=_,this._charSizeService=S,this._renderService=k,this._coreBrowserService=E,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new m.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,a.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((C=>this._activeBuffer=C.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((C=>this._renderDimensions=C))),this._handleThemeChange(x.colors),this.register(x.onChangeColors((C=>this._handleThemeChange(C)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(d){this._viewportElement.style.backgroundColor=d.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame((()=>this.syncScrollArea()))}_refresh(d){if(d)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderService.dimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderService.dimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;const c=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderService.dimensions.css.canvas.height);this._lastRecordedBufferHeight!==c&&(this._lastRecordedBufferHeight=c,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const d=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==d&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=d),this._refreshAnimationFrame=null}syncScrollArea(d=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(d);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(d)}_handleScroll(d){if(this._lastScrollTop=this._viewportElement.scrollTop,!this._viewportElement.offsetParent)return;if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._onRequestScrollLines.fire({amount:0,suppressScrollEvent:!0});const c=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:c,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const d=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(d*(this._smoothScrollState.target-this._smoothScrollState.origin)),d<1?this._coreBrowserService.window.requestAnimationFrame((()=>this._smoothScroll())):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(d,c){const h=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(c<0&&this._viewportElement.scrollTop!==0||c>0&&h<this._lastRecordedBufferHeight)||(d.cancelable&&d.preventDefault(),!1)}handleWheel(d){const c=this._getPixelsScrolled(d);return c!==0&&(this._optionsService.rawOptions.smoothScrollDuration?(this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target===-1?this._smoothScrollState.target=this._viewportElement.scrollTop+c:this._smoothScrollState.target+=c,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=c,this._bubbleScroll(d,c))}scrollLines(d){if(d!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const c=d*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+c,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:d,suppressScrollEvent:!1})}_getPixelsScrolled(d){if(d.deltaY===0||d.shiftKey)return 0;let c=this._applyScrollModifier(d.deltaY,d);return d.deltaMode===WheelEvent.DOM_DELTA_LINE?c*=this._currentRowHeight:d.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(c*=this._currentRowHeight*this._bufferService.rows),c}getBufferElements(d,c){var h;let _,S="";const k=[],E=c??this._bufferService.buffer.lines.length,x=this._bufferService.buffer.lines;for(let C=d;C<E;C++){const T=x.get(C);if(!T)continue;const L=(h=x.get(C+1))===null||h===void 0?void 0:h.isWrapped;if(S+=T.translateToString(!L),!L||C===x.length-1){const R=document.createElement("div");R.textContent=S,k.push(R),S.length>0&&(_=R),S=""}}return{bufferElements:k,cursorElement:_}}getLinesScrolled(d){if(d.deltaY===0||d.shiftKey)return 0;let c=this._applyScrollModifier(d.deltaY,d);return d.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(c/=this._currentRowHeight+0,this._wheelPartialScroll+=c,c=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):d.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(c*=this._bufferService.rows),c}_applyScrollModifier(d,c){const h=this._optionsService.rawOptions.fastScrollModifier;return h==="alt"&&c.altKey||h==="ctrl"&&c.ctrlKey||h==="shift"&&c.shiftKey?d*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:d*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(d){this._lastTouchY=d.touches[0].pageY}handleTouchMove(d){const c=this._lastTouchY-d.touches[0].pageY;return this._lastTouchY=d.touches[0].pageY,c!==0&&(this._viewportElement.scrollTop+=c,this._bubbleScroll(d,c))}};i.Viewport=n=u([f(2,b.IBufferService),f(3,b.IOptionsService),f(4,p.ICharSizeService),f(5,p.IRenderService),f(6,p.ICoreBrowserService),f(7,p.IThemeService)],n)},3107:function(w,i,o){var u=this&&this.__decorate||function(n,d,c,h){var _,S=arguments.length,k=S<3?d:h===null?h=Object.getOwnPropertyDescriptor(d,c):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(n,d,c,h);else for(var E=n.length-1;E>=0;E--)(_=n[E])&&(k=(S<3?_(k):S>3?_(d,c,k):_(d,c))||k);return S>3&&k&&Object.defineProperty(d,c,k),k},f=this&&this.__param||function(n,d){return function(c,h){d(c,h,n)}};Object.defineProperty(i,"__esModule",{value:!0}),i.BufferDecorationRenderer=void 0;const a=o(3656),p=o(4725),m=o(844),y=o(2585);let b=i.BufferDecorationRenderer=class extends m.Disposable{constructor(n,d,c,h){super(),this._screenElement=n,this._bufferService=d,this._decorationService=c,this._renderService=h,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this.register(this._renderService.onRenderedViewportChange((()=>this._doRefreshDecorations()))),this.register(this._renderService.onDimensionsChange((()=>{this._dimensionsChanged=!0,this._queueRefresh()}))),this.register((0,a.addDisposableDomListener)(window,"resize",(()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt}))),this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh()))),this.register(this._decorationService.onDecorationRemoved((_=>this._removeDecoration(_)))),this.register((0,m.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(const n of this._decorationService.decorations)this._renderDecoration(n);this._dimensionsChanged=!1}_renderDecoration(n){this._refreshStyle(n),this._dimensionsChanged&&this._refreshXPosition(n)}_createElement(n){var d,c;const h=document.createElement("div");h.classList.add("xterm-decoration"),h.classList.toggle("xterm-decoration-top-layer",((d=n?.options)===null||d===void 0?void 0:d.layer)==="top"),h.style.width=`${Math.round((n.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,h.style.height=(n.options.height||1)*this._renderService.dimensions.css.cell.height+"px",h.style.top=(n.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",h.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const _=(c=n.options.x)!==null&&c!==void 0?c:0;return _&&_>this._bufferService.cols&&(h.style.display="none"),this._refreshXPosition(n,h),h}_refreshStyle(n){const d=n.marker.line-this._bufferService.buffers.active.ydisp;if(d<0||d>=this._bufferService.rows)n.element&&(n.element.style.display="none",n.onRenderEmitter.fire(n.element));else{let c=this._decorationElements.get(n);c||(c=this._createElement(n),n.element=c,this._decorationElements.set(n,c),this._container.appendChild(c),n.onDispose((()=>{this._decorationElements.delete(n),c.remove()}))),c.style.top=d*this._renderService.dimensions.css.cell.height+"px",c.style.display=this._altBufferIsActive?"none":"block",n.onRenderEmitter.fire(c)}}_refreshXPosition(n,d=n.element){var c;if(!d)return;const h=(c=n.options.x)!==null&&c!==void 0?c:0;(n.options.anchor||"left")==="right"?d.style.right=h?h*this._renderService.dimensions.css.cell.width+"px":"":d.style.left=h?h*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(n){var d;(d=this._decorationElements.get(n))===null||d===void 0||d.remove(),this._decorationElements.delete(n),n.dispose()}};i.BufferDecorationRenderer=b=u([f(1,y.IBufferService),f(2,y.IDecorationService),f(3,p.IRenderService)],b)},5871:(w,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(o){if(o.options.overviewRulerOptions){for(const u of this._zones)if(u.color===o.options.overviewRulerOptions.color&&u.position===o.options.overviewRulerOptions.position){if(this._lineIntersectsZone(u,o.marker.line))return;if(this._lineAdjacentToZone(u,o.marker.line,o.options.overviewRulerOptions.position))return void this._addLineToZone(u,o.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=o.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=o.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=o.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=o.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:o.options.overviewRulerOptions.color,position:o.options.overviewRulerOptions.position,startBufferLine:o.marker.line,endBufferLine:o.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(o){this._linePadding=o}_lineIntersectsZone(o,u){return u>=o.startBufferLine&&u<=o.endBufferLine}_lineAdjacentToZone(o,u,f){return u>=o.startBufferLine-this._linePadding[f||"full"]&&u<=o.endBufferLine+this._linePadding[f||"full"]}_addLineToZone(o,u){o.startBufferLine=Math.min(o.startBufferLine,u),o.endBufferLine=Math.max(o.endBufferLine,u)}}},5744:function(w,i,o){var u=this&&this.__decorate||function(_,S,k,E){var x,C=arguments.length,T=C<3?S:E===null?E=Object.getOwnPropertyDescriptor(S,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(_,S,k,E);else for(var L=_.length-1;L>=0;L--)(x=_[L])&&(T=(C<3?x(T):C>3?x(S,k,T):x(S,k))||T);return C>3&&T&&Object.defineProperty(S,k,T),T},f=this&&this.__param||function(_,S){return function(k,E){S(k,E,_)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OverviewRulerRenderer=void 0;const a=o(5871),p=o(3656),m=o(4725),y=o(844),b=o(2585),n={full:0,left:0,center:0,right:0},d={full:0,left:0,center:0,right:0},c={full:0,left:0,center:0,right:0};let h=i.OverviewRulerRenderer=class extends y.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(_,S,k,E,x,C,T){var L;super(),this._viewportElement=_,this._screenElement=S,this._bufferService=k,this._decorationService=E,this._renderService=x,this._optionsService=C,this._coreBrowseService=T,this._colorZoneStore=new a.ColorZoneStore,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=document.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(L=this._viewportElement.parentElement)===null||L===void 0||L.insertBefore(this._canvas,this._viewportElement);const R=this._canvas.getContext("2d");if(!R)throw new Error("Ctx cannot be null");this._ctx=R,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,y.toDisposable)((()=>{var 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,p.addDisposableDomListener)(this._coreBrowseService.window,"resize",(()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){const _=Math.floor(this._canvas.width/3),S=Math.ceil(this._canvas.width/3);d.full=this._canvas.width,d.left=_,d.center=S,d.right=_,this._refreshDrawHeightConstants(),c.full=0,c.left=0,c.center=d.left,c.right=d.left+d.center}_refreshDrawHeightConstants(){n.full=Math.round(2*this._coreBrowseService.dpr);const _=this._canvas.height/this._bufferService.buffer.lines.length,S=Math.round(Math.max(Math.min(_,12),6)*this._coreBrowseService.dpr);n.left=S,n.center=S,n.right=S}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*n.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*n.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*n.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*n.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowseService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowseService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(const S of this._decorationService.decorations)this._colorZoneStore.addDecoration(S);this._ctx.lineWidth=1;const _=this._colorZoneStore.zones;for(const S of _)S.position!=="full"&&this._renderColorZone(S);for(const S of _)S.position==="full"&&this._renderColorZone(S);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(_){this._ctx.fillStyle=_.color,this._ctx.fillRect(c[_.position||"full"],Math.round((this._canvas.height-1)*(_.startBufferLine/this._bufferService.buffers.active.lines.length)-n[_.position||"full"]/2),d[_.position||"full"],Math.round((this._canvas.height-1)*((_.endBufferLine-_.startBufferLine)/this._bufferService.buffers.active.lines.length)+n[_.position||"full"]))}_queueRefresh(_,S){this._shouldUpdateDimensions=_||this._shouldUpdateDimensions,this._shouldUpdateAnchor=S||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowseService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};i.OverviewRulerRenderer=h=u([f(2,b.IBufferService),f(3,b.IDecorationService),f(4,m.IRenderService),f(5,b.IOptionsService),f(6,m.ICoreBrowserService)],h)},2950:function(w,i,o){var u=this&&this.__decorate||function(b,n,d,c){var h,_=arguments.length,S=_<3?n:c===null?c=Object.getOwnPropertyDescriptor(n,d):c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(b,n,d,c);else for(var k=b.length-1;k>=0;k--)(h=b[k])&&(S=(_<3?h(S):_>3?h(n,d,S):h(n,d))||S);return _>3&&S&&Object.defineProperty(n,d,S),S},f=this&&this.__param||function(b,n){return function(d,c){n(d,c,b)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CompositionHelper=void 0;const a=o(4725),p=o(2585),m=o(2584);let y=i.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(b,n,d,c,h,_){this._textarea=b,this._compositionView=n,this._bufferService=d,this._optionsService=c,this._coreService=h,this._renderService=_,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(b){this._compositionView.textContent=b.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(b){if(this._isComposing||this._isSendingComposition){if(b.keyCode===229||b.keyCode===16||b.keyCode===17||b.keyCode===18)return!1;this._finalizeComposition(!1)}return b.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(b){if(this._compositionView.classList.remove("active"),this._isComposing=!1,b){const n={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let d;this._isSendingComposition=!1,n.start+=this._dataAlreadySent.length,d=this._isComposing?this._textarea.value.substring(n.start,n.end):this._textarea.value.substring(n.start),d.length>0&&this._coreService.triggerDataEvent(d,!0)}}),0)}else{this._isSendingComposition=!1;const n=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(n,!0)}}_handleAnyTextareaChanges(){const b=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const n=this._textarea.value,d=n.replace(b,"");this._dataAlreadySent=d,n.length>b.length?this._coreService.triggerDataEvent(d,!0):n.length<b.length?this._coreService.triggerDataEvent(`${m.C0.DEL}`,!0):n.length===b.length&&n!==b&&this._coreService.triggerDataEvent(n,!0)}}),0)}updateCompositionElements(b){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const n=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),d=this._renderService.dimensions.css.cell.height,c=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,h=n*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=h+"px",this._compositionView.style.top=c+"px",this._compositionView.style.height=d+"px",this._compositionView.style.lineHeight=d+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const _=this._compositionView.getBoundingClientRect();this._textarea.style.left=h+"px",this._textarea.style.top=c+"px",this._textarea.style.width=Math.max(_.width,1)+"px",this._textarea.style.height=Math.max(_.height,1)+"px",this._textarea.style.lineHeight=_.height+"px"}b||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};i.CompositionHelper=y=u([f(2,p.IBufferService),f(3,p.IOptionsService),f(4,p.ICoreService),f(5,a.IRenderService)],y)},9806:(w,i)=>{function o(u,f,a){const p=a.getBoundingClientRect(),m=u.getComputedStyle(a),y=parseInt(m.getPropertyValue("padding-left")),b=parseInt(m.getPropertyValue("padding-top"));return[f.clientX-p.left-y,f.clientY-p.top-b]}Object.defineProperty(i,"__esModule",{value:!0}),i.getCoords=i.getCoordsRelativeToElement=void 0,i.getCoordsRelativeToElement=o,i.getCoords=function(u,f,a,p,m,y,b,n,d){if(!y)return;const c=o(u,f,a);return c?(c[0]=Math.ceil((c[0]+(d?b/2:0))/b),c[1]=Math.ceil(c[1]/n),c[0]=Math.min(Math.max(c[0],1),p+(d?1:0)),c[1]=Math.min(Math.max(c[1],1),m),c):void 0}},9504:(w,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.moveToCellSequence=void 0;const u=o(2584);function f(n,d,c,h){const _=n-a(n,c),S=d-a(d,c),k=Math.abs(_-S)-(function(E,x,C){let T=0;const L=E-a(E,C),R=x-a(x,C);for(let M=0;M<Math.abs(L-R);M++){const I=p(E,x)==="A"?-1:1,B=C.buffer.lines.get(L+I*M);B?.isWrapped&&T++}return T})(n,d,c);return b(k,y(p(n,d),h))}function a(n,d){let c=0,h=d.buffer.lines.get(n),_=h?.isWrapped;for(;_&&n>=0&&n<d.rows;)c++,h=d.buffer.lines.get(--n),_=h?.isWrapped;return c}function p(n,d){return n>d?"A":"B"}function m(n,d,c,h,_,S){let k=n,E=d,x="";for(;k!==c||E!==h;)k+=_?1:-1,_&&k>S.cols-1?(x+=S.buffer.translateBufferLineToString(E,!1,n,k),k=0,n=0,E++):!_&&k<0&&(x+=S.buffer.translateBufferLineToString(E,!1,0,n+1),k=S.cols-1,n=k,E--);return x+S.buffer.translateBufferLineToString(E,!1,n,k)}function y(n,d){const c=d?"O":"[";return u.C0.ESC+c+n}function b(n,d){n=Math.floor(n);let c="";for(let h=0;h<n;h++)c+=d;return c}i.moveToCellSequence=function(n,d,c,h){const _=c.buffer.x,S=c.buffer.y;if(!c.buffer.hasScrollback)return(function(x,C,T,L,R,M){return f(C,L,R,M).length===0?"":b(m(x,C,x,C-a(C,R),!1,R).length,y("D",M))})(_,S,0,d,c,h)+f(S,d,c,h)+(function(x,C,T,L,R,M){let I;I=f(C,L,R,M).length>0?L-a(L,R):C;const B=L,H=(function($,N,P,D,O,q){let K;return K=f(P,D,O,q).length>0?D-a(D,O):N,$<P&&K<=D||$>=P&&K<D?"C":"D"})(x,C,T,L,R,M);return b(m(x,I,T,B,H==="C",R).length,y(H,M))})(_,S,n,d,c,h);let k;if(S===d)return k=_>n?"D":"C",b(Math.abs(_-n),y(k,h));k=S>d?"D":"C";const E=Math.abs(S-d);return b((function(x,C){return C.cols-x})(S>d?n:_,c)+(E-1)*c.cols+1+((S>d?_:n)-1),y(k,h))}},1296:function(w,i,o){var u=this&&this.__decorate||function(R,M,I,B){var H,$=arguments.length,N=$<3?M:B===null?B=Object.getOwnPropertyDescriptor(M,I):B;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(R,M,I,B);else for(var P=R.length-1;P>=0;P--)(H=R[P])&&(N=($<3?H(N):$>3?H(M,I,N):H(M,I))||N);return $>3&&N&&Object.defineProperty(M,I,N),N},f=this&&this.__param||function(R,M){return function(I,B){M(I,B,R)}};Object.defineProperty(i,"__esModule",{value:!0}),i.DomRenderer=void 0;const a=o(3787),p=o(2550),m=o(2223),y=o(6171),b=o(4725),n=o(8055),d=o(8460),c=o(844),h=o(2585),_="xterm-dom-renderer-owner-",S="xterm-rows",k="xterm-fg-",E="xterm-bg-",x="xterm-focus",C="xterm-selection";let T=1,L=i.DomRenderer=class extends c.Disposable{constructor(R,M,I,B,H,$,N,P,D,O){super(),this._element=R,this._screenElement=M,this._viewportElement=I,this._linkifier2=B,this._charSizeService=$,this._optionsService=N,this._bufferService=P,this._coreBrowserService=D,this._themeService=O,this._terminalClass=T++,this._rowElements=[],this.onRequestRedraw=this.register(new d.EventEmitter).event,this._rowContainer=document.createElement("div"),this._rowContainer.classList.add(S),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=document.createElement("div"),this._selectionContainer.classList.add(C),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,y.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((q=>this._injectCss(q)))),this._injectCss(this._themeService.colors),this._rowFactory=H.createInstance(a.DomRendererRowFactory,document),this._element.classList.add(_+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((q=>this._handleLinkHover(q)))),this.register(this._linkifier2.onHideLinkUnderline((q=>this._handleLinkLeave(q)))),this.register((0,c.toDisposable)((()=>{this._element.classList.remove(_+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new p.WidthCache(document),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){const R=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*R,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*R),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/R),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/R),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(const I of this._rowElements)I.style.width=`${this.dimensions.css.canvas.width}px`,I.style.height=`${this.dimensions.css.cell.height}px`,I.style.lineHeight=`${this.dimensions.css.cell.height}px`,I.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const M=`${this._terminalSelector} .${S} 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(R){this._themeStyleElement||(this._themeStyleElement=document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let M=`${this._terminalSelector} .${S} { color: ${R.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;M+=`${this._terminalSelector} .${S} .xterm-dim { color: ${n.color.multiplyOpacity(R.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: ${R.cursor.css}; color: ${R.cursorAccent.css}; } 50% { background-color: inherit; color: ${R.cursor.css}; }}`,M+=`${this._terminalSelector} .${S}.${x} .xterm-cursor.xterm-cursor-blink:not(.xterm-cursor-block) { animation: blink_box_shadow_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${S}.${x} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: blink_block_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-block { background-color: ${R.cursor.css}; color: ${R.cursorAccent.css};}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${R.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${R.cursor.css} inset;}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${R.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,M+=`${this._terminalSelector} .${C} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${C} div { position: absolute; background-color: ${R.selectionBackgroundOpaque.css};}${this._terminalSelector} .${C} div { position: absolute; background-color: ${R.selectionInactiveBackgroundOpaque.css};}`;for(const[I,B]of R.ansi.entries())M+=`${this._terminalSelector} .${k}${I} { color: ${B.css}; }${this._terminalSelector} .${k}${I}.xterm-dim { color: ${n.color.multiplyOpacity(B,.5).css}; }${this._terminalSelector} .${E}${I} { background-color: ${B.css}; }`;M+=`${this._terminalSelector} .${k}${m.INVERTED_DEFAULT_COLOR} { color: ${n.color.opaque(R.background).css}; }${this._terminalSelector} .${k}${m.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${n.color.multiplyOpacity(n.color.opaque(R.background),.5).css}; }${this._terminalSelector} .${E}${m.INVERTED_DEFAULT_COLOR} { background-color: ${R.foreground.css}; }`,this._themeStyleElement.textContent=M}_setDefaultSpacing(){const R=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${R}px`,this._rowFactory.defaultSpacing=R}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(R,M){for(let I=this._rowElements.length;I<=M;I++){const B=document.createElement("div");this._rowContainer.appendChild(B),this._rowElements.push(B)}for(;this._rowElements.length>M;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(R,M){this._refreshRowElements(R,M),this._updateDimensions()}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(x)}handleFocus(){this._rowContainer.classList.add(x),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(R,M,I){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(R,M,I),this.renderRows(0,this._bufferService.rows-1),!R||!M)return;const B=R[1]-this._bufferService.buffer.ydisp,H=M[1]-this._bufferService.buffer.ydisp,$=Math.max(B,0),N=Math.min(H,this._bufferService.rows-1);if($>=this._bufferService.rows||N<0)return;const P=document.createDocumentFragment();if(I){const D=R[0]>M[0];P.appendChild(this._createSelectionElement($,D?M[0]:R[0],D?R[0]:M[0],N-$+1))}else{const D=B===$?R[0]:0,O=$===H?M[0]:this._bufferService.cols;P.appendChild(this._createSelectionElement($,D,O));const q=N-$-1;if(P.appendChild(this._createSelectionElement($+1,0,this._bufferService.cols,q)),$!==N){const K=H===N?M[0]:this._bufferService.cols;P.appendChild(this._createSelectionElement(N,0,K))}}this._selectionContainer.appendChild(P)}_createSelectionElement(R,M,I,B=1){const H=document.createElement("div");return H.style.height=B*this.dimensions.css.cell.height+"px",H.style.top=R*this.dimensions.css.cell.height+"px",H.style.left=M*this.dimensions.css.cell.width+"px",H.style.width=this.dimensions.css.cell.width*(I-M)+"px",H}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(const R of this._rowElements)R.replaceChildren()}renderRows(R,M){const I=this._bufferService.buffer,B=I.ybase+I.y,H=Math.min(I.x,this._bufferService.cols-1),$=this._optionsService.rawOptions.cursorBlink,N=this._optionsService.rawOptions.cursorStyle,P=this._optionsService.rawOptions.cursorInactiveStyle;for(let D=R;D<=M;D++){const O=D+I.ydisp,q=this._rowElements[D],K=I.lines.get(O);if(!q||!K)break;q.replaceChildren(...this._rowFactory.createRow(K,O,O===B,N,P,H,$,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${_}${this._terminalClass}`}_handleLinkHover(R){this._setCellUnderline(R.x1,R.x2,R.y1,R.y2,R.cols,!0)}_handleLinkLeave(R){this._setCellUnderline(R.x1,R.x2,R.y1,R.y2,R.cols,!1)}_setCellUnderline(R,M,I,B,H,$){I<0&&(R=0),B<0&&(M=0);const N=this._bufferService.rows-1;I=Math.max(Math.min(I,N),0),B=Math.max(Math.min(B,N),0),H=Math.min(H,this._bufferService.cols);const P=this._bufferService.buffer,D=P.ybase+P.y,O=Math.min(P.x,H-1),q=this._optionsService.rawOptions.cursorBlink,K=this._optionsService.rawOptions.cursorStyle,U=this._optionsService.rawOptions.cursorInactiveStyle;for(let z=I;z<=B;++z){const W=z+P.ydisp,j=this._rowElements[z],F=P.lines.get(W);if(!j||!F)break;j.replaceChildren(...this._rowFactory.createRow(F,W,W===D,K,U,O,q,this.dimensions.css.cell.width,this._widthCache,$?z===I?R:0:-1,$?(z===B?M:H)-1:-1))}}};i.DomRenderer=L=u([f(4,h.IInstantiationService),f(5,b.ICharSizeService),f(6,h.IOptionsService),f(7,h.IBufferService),f(8,b.ICoreBrowserService),f(9,b.IThemeService)],L)},3787:function(w,i,o){var u=this&&this.__decorate||function(k,E,x,C){var T,L=arguments.length,R=L<3?E:C===null?C=Object.getOwnPropertyDescriptor(E,x):C;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(k,E,x,C);else for(var M=k.length-1;M>=0;M--)(T=k[M])&&(R=(L<3?T(R):L>3?T(E,x,R):T(E,x))||R);return L>3&&R&&Object.defineProperty(E,x,R),R},f=this&&this.__param||function(k,E){return function(x,C){E(x,C,k)}};Object.defineProperty(i,"__esModule",{value:!0}),i.DomRendererRowFactory=void 0;const a=o(2223),p=o(643),m=o(511),y=o(2585),b=o(8055),n=o(4725),d=o(4269),c=o(6171),h=o(3734);let _=i.DomRendererRowFactory=class{constructor(k,E,x,C,T,L,R){this._document=k,this._characterJoinerService=E,this._optionsService=x,this._coreBrowserService=C,this._coreService=T,this._decorationService=L,this._themeService=R,this._workCell=new m.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(k,E,x){this._selectionStart=k,this._selectionEnd=E,this._columnSelectMode=x}createRow(k,E,x,C,T,L,R,M,I,B,H){const $=[],N=this._characterJoinerService.getJoinedCharacters(E),P=this._themeService.colors;let D,O=k.getNoBgTrimmedLength();x&&O<L+1&&(O=L+1);let q=0,K="",U=0,z=0,W=0,j=!1,F=0,X=!1,Y=0;const ee=[],G=B!==-1&&H!==-1;for(let Z=0;Z<O;Z++){k.loadCell(Z,this._workCell);let ae=this._workCell.getWidth();if(ae===0)continue;let he=!1,je=Z,se=this._workCell;if(N.length>0&&Z===N[0][0]){he=!0;const ue=N.shift();se=new d.JoinedCellData(this._workCell,k.translateToString(!0,ue[0],ue[1]),ue[1]-ue[0]),je=ue[1]-1,ae=se.getWidth()}const Ae=this._isCellInSelection(Z,E),te=x&&Z===L,me=G&&Z>=B&&Z<=H;let Pe=!1;this._decorationService.forEachDecorationAtCell(Z,E,void 0,(ue=>{Pe=!0}));let qe=se.getChars()||p.WHITESPACE_CELL_CHAR;if(qe===" "&&(se.isUnderline()||se.isOverline())&&(qe=" "),Y=ae*M-I.get(qe,se.isBold(),se.isItalic()),D){if(q&&(Ae&&X||!Ae&&!X&&se.bg===U)&&(Ae&&X&&P.selectionForeground||se.fg===z)&&se.extended.ext===W&&me===j&&Y===F&&!te&&!he&&!Pe){K+=qe,q++;continue}q&&(D.textContent=K),D=this._document.createElement("span"),q=0,K=""}else D=this._document.createElement("span");if(U=se.bg,z=se.fg,W=se.extended.ext,j=me,F=Y,X=Ae,he&&L>=Z&&L<=je&&(L=Z),!this._coreService.isCursorHidden&&te){if(ee.push("xterm-cursor"),this._coreBrowserService.isFocused)R&&ee.push("xterm-cursor-blink"),ee.push(C==="bar"?"xterm-cursor-bar":C==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(T)switch(T){case"outline":ee.push("xterm-cursor-outline");break;case"block":ee.push("xterm-cursor-block");break;case"bar":ee.push("xterm-cursor-bar");break;case"underline":ee.push("xterm-cursor-underline")}}if(se.isBold()&&ee.push("xterm-bold"),se.isItalic()&&ee.push("xterm-italic"),se.isDim()&&ee.push("xterm-dim"),K=se.isInvisible()?p.WHITESPACE_CELL_CHAR:se.getChars()||p.WHITESPACE_CELL_CHAR,se.isUnderline()&&(ee.push(`xterm-underline-${se.extended.underlineStyle}`),K===" "&&(K=" "),!se.isUnderlineColorDefault()))if(se.isUnderlineColorRGB())D.style.textDecorationColor=`rgb(${h.AttributeData.toColorRGB(se.getUnderlineColor()).join(",")})`;else{let ue=se.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&se.isBold()&&ue<8&&(ue+=8),D.style.textDecorationColor=P.ansi[ue].css}se.isOverline()&&(ee.push("xterm-overline"),K===" "&&(K=" ")),se.isStrikethrough()&&ee.push("xterm-strikethrough"),me&&(D.style.textDecoration="underline");let ve=se.getFgColor(),Re=se.getFgColorMode(),Se=se.getBgColor(),Ce=se.getBgColorMode();const rt=!!se.isInverse();if(rt){const ue=ve;ve=Se,Se=ue;const rs=Re;Re=Ce,Ce=rs}let Ne,it,Ie,nt=!1;switch(this._decorationService.forEachDecorationAtCell(Z,E,void 0,(ue=>{ue.options.layer!=="top"&&nt||(ue.backgroundColorRGB&&(Ce=50331648,Se=ue.backgroundColorRGB.rgba>>8&16777215,Ne=ue.backgroundColorRGB),ue.foregroundColorRGB&&(Re=50331648,ve=ue.foregroundColorRGB.rgba>>8&16777215,it=ue.foregroundColorRGB),nt=ue.options.layer==="top")})),!nt&&Ae&&(Ne=this._coreBrowserService.isFocused?P.selectionBackgroundOpaque:P.selectionInactiveBackgroundOpaque,Se=Ne.rgba>>8&16777215,Ce=50331648,nt=!0,P.selectionForeground&&(Re=50331648,ve=P.selectionForeground.rgba>>8&16777215,it=P.selectionForeground)),nt&&ee.push("xterm-decoration-top"),Ce){case 16777216:case 33554432:Ie=P.ansi[Se],ee.push(`xterm-bg-${Se}`);break;case 50331648:Ie=b.rgba.toColor(Se>>16,Se>>8&255,255&Se),this._addStyle(D,`background-color:#${S((Se>>>0).toString(16),"0",6)}`);break;default:rt?(Ie=P.foreground,ee.push(`xterm-bg-${a.INVERTED_DEFAULT_COLOR}`)):Ie=P.background}switch(Ne||se.isDim()&&(Ne=b.color.multiplyOpacity(Ie,.5)),Re){case 16777216:case 33554432:se.isBold()&&ve<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ve+=8),this._applyMinimumContrast(D,Ie,P.ansi[ve],se,Ne,void 0)||ee.push(`xterm-fg-${ve}`);break;case 50331648:const ue=b.rgba.toColor(ve>>16&255,ve>>8&255,255&ve);this._applyMinimumContrast(D,Ie,ue,se,Ne,it)||this._addStyle(D,`color:#${S(ve.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(D,Ie,P.foreground,se,Ne,void 0)||rt&&ee.push(`xterm-fg-${a.INVERTED_DEFAULT_COLOR}`)}ee.length&&(D.className=ee.join(" "),ee.length=0),te||he||Pe?D.textContent=K:q++,Y!==this.defaultSpacing&&(D.style.letterSpacing=`${Y}px`),$.push(D),Z=je}return D&&q&&(D.textContent=K),$}_applyMinimumContrast(k,E,x,C,T,L){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,c.excludeFromContrastRatioDemands)(C.getCode()))return!1;const R=this._getContrastCache(C);let M;if(T||L||(M=R.getColor(E.rgba,x.rgba)),M===void 0){const I=this._optionsService.rawOptions.minimumContrastRatio/(C.isDim()?2:1);M=b.color.ensureContrastRatio(T||E,L||x,I),R.setColor((T||E).rgba,(L||x).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,E){k.setAttribute("style",`${k.getAttribute("style")||""}${E};`)}_isCellInSelection(k,E){const x=this._selectionStart,C=this._selectionEnd;return!(!x||!C)&&(this._columnSelectMode?x[0]<=C[0]?k>=x[0]&&E>=x[1]&&k<C[0]&&E<=C[1]:k<x[0]&&E>=x[1]&&k>=C[0]&&E<=C[1]:E>x[1]&&E<C[1]||x[1]===C[1]&&E===x[1]&&k>=x[0]&&k<C[0]||x[1]<C[1]&&E===C[1]&&k<C[0]||x[1]<C[1]&&E===x[1]&&k>=x[0])}};function S(k,E,x){for(;k.length<x;)k=E+k;return k}i.DomRendererRowFactory=_=u([f(1,n.ICharacterJoinerService),f(2,y.IOptionsService),f(3,n.ICoreBrowserService),f(4,y.ICoreService),f(5,y.IDecorationService),f(6,n.IThemeService)],_)},2550:(w,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WidthCache=void 0,i.WidthCache=class{constructor(o){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=o.createElement("div"),this._container.style.position="absolute",this._container.style.top="-50000px",this._container.style.width="50000px",this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";const u=o.createElement("span"),f=o.createElement("span");f.style.fontWeight="bold";const a=o.createElement("span");a.style.fontStyle="italic";const p=o.createElement("span");p.style.fontWeight="bold",p.style.fontStyle="italic",this._measureElements=[u,f,a,p],this._container.appendChild(u),this._container.appendChild(f),this._container.appendChild(a),this._container.appendChild(p),o.body.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(o,u,f,a){o===this._font&&u===this._fontSize&&f===this._weight&&a===this._weightBold||(this._font=o,this._fontSize=u,this._weight=f,this._weightBold=a,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${f}`,this._measureElements[1].style.fontWeight=`${a}`,this._measureElements[2].style.fontWeight=`${f}`,this._measureElements[3].style.fontWeight=`${a}`,this.clear())}get(o,u,f){let a=0;if(!u&&!f&&o.length===1&&(a=o.charCodeAt(0))<256)return this._flat[a]!==-9999?this._flat[a]:this._flat[a]=this._measure(o,0);let p=o;u&&(p+="B"),f&&(p+="I");let m=this._holey.get(p);if(m===void 0){let y=0;u&&(y|=1),f&&(y|=2),m=this._measure(o,y),this._holey.set(p,m)}return m}_measure(o,u){const f=this._measureElements[u];return f.textContent=o.repeat(32),f.offsetWidth/32}}},2223:(w,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.TEXT_BASELINE=i.DIM_OPACITY=i.INVERTED_DEFAULT_COLOR=void 0;const u=o(6114);i.INVERTED_DEFAULT_COLOR=257,i.DIM_OPACITY=.5,i.TEXT_BASELINE=u.isFirefox||u.isLegacyEdge?"bottom":"ideographic"},6171:(w,i)=>{function o(u){return 57508<=u&&u<=57558}Object.defineProperty(i,"__esModule",{value:!0}),i.createRenderDimensions=i.excludeFromContrastRatioDemands=i.isRestrictedPowerlineGlyph=i.isPowerlineGlyph=i.throwIfFalsy=void 0,i.throwIfFalsy=function(u){if(!u)throw new Error("value must not be falsy");return u},i.isPowerlineGlyph=o,i.isRestrictedPowerlineGlyph=function(u){return 57520<=u&&u<=57527},i.excludeFromContrastRatioDemands=function(u){return o(u)||(function(f){return 9472<=f&&f<=9631})(u)},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:(w,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.SelectionModel=void 0,i.SelectionModel=class{constructor(o){this._bufferService=o,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){const o=this.selectionStart[0]+this.selectionStartLength;return o>this._bufferService.cols?o%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(o/this._bufferService.cols)-1]:[o%this._bufferService.cols,this.selectionStart[1]+Math.floor(o/this._bufferService.cols)]:[o,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const o=this.selectionStart[0]+this.selectionStartLength;return o>this._bufferService.cols?[o%this._bufferService.cols,this.selectionStart[1]+Math.floor(o/this._bufferService.cols)]:[Math.max(o,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const o=this.selectionStart,u=this.selectionEnd;return!(!o||!u)&&(o[1]>u[1]||o[1]===u[1]&&o[0]>u[0])}handleTrim(o){return this.selectionStart&&(this.selectionStart[1]-=o),this.selectionEnd&&(this.selectionEnd[1]-=o),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(w,i,o){var u=this&&this.__decorate||function(n,d,c,h){var _,S=arguments.length,k=S<3?d:h===null?h=Object.getOwnPropertyDescriptor(d,c):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(n,d,c,h);else for(var E=n.length-1;E>=0;E--)(_=n[E])&&(k=(S<3?_(k):S>3?_(d,c,k):_(d,c))||k);return S>3&&k&&Object.defineProperty(d,c,k),k},f=this&&this.__param||function(n,d){return function(c,h){d(c,h,n)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CharSizeService=void 0;const a=o(2585),p=o(8460),m=o(844);let y=i.CharSizeService=class extends m.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(n,d,c){super(),this._optionsService=c,this.width=0,this.height=0,this._onCharSizeChange=this.register(new p.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event,this._measureStrategy=new b(n,d,this._optionsService),this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const n=this._measureStrategy.measure();n.width===this.width&&n.height===this.height||(this.width=n.width,this.height=n.height,this._onCharSizeChange.fire())}};i.CharSizeService=y=u([f(2,a.IOptionsService)],y);class b{constructor(d,c,h){this._document=d,this._parentElement=c,this._optionsService=h,this._result={width:0,height:0},this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`;const d={height:Number(this._measureElement.offsetHeight),width:Number(this._measureElement.offsetWidth)};return d.width!==0&&d.height!==0&&(this._result.width=d.width/32,this._result.height=Math.ceil(d.height)),this._result}}},4269:function(w,i,o){var u=this&&this.__decorate||function(d,c,h,_){var S,k=arguments.length,E=k<3?c:_===null?_=Object.getOwnPropertyDescriptor(c,h):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(d,c,h,_);else for(var x=d.length-1;x>=0;x--)(S=d[x])&&(E=(k<3?S(E):k>3?S(c,h,E):S(c,h))||E);return k>3&&E&&Object.defineProperty(c,h,E),E},f=this&&this.__param||function(d,c){return function(h,_){c(h,_,d)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CharacterJoinerService=i.JoinedCellData=void 0;const a=o(3734),p=o(643),m=o(511),y=o(2585);class b extends a.AttributeData{constructor(c,h,_){super(),this.content=0,this.combinedData="",this.fg=c.fg,this.bg=c.bg,this.combinedData=h,this._width=_}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(c){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}i.JoinedCellData=b;let n=i.CharacterJoinerService=class Ii{constructor(c){this._bufferService=c,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new m.CellData}register(c){const h={id:this._nextCharacterJoinerId++,handler:c};return this._characterJoiners.push(h),h.id}deregister(c){for(let h=0;h<this._characterJoiners.length;h++)if(this._characterJoiners[h].id===c)return this._characterJoiners.splice(h,1),!0;return!1}getJoinedCharacters(c){if(this._characterJoiners.length===0)return[];const h=this._bufferService.buffer.lines.get(c);if(!h||h.length===0)return[];const _=[],S=h.translateToString(!0);let k=0,E=0,x=0,C=h.getFg(0),T=h.getBg(0);for(let L=0;L<h.getTrimmedLength();L++)if(h.loadCell(L,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==C||this._workCell.bg!==T){if(L-k>1){const R=this._getJoinedRanges(S,x,E,h,k);for(let M=0;M<R.length;M++)_.push(R[M])}k=L,x=E,C=this._workCell.fg,T=this._workCell.bg}E+=this._workCell.getChars().length||p.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-k>1){const L=this._getJoinedRanges(S,x,E,h,k);for(let R=0;R<L.length;R++)_.push(L[R])}return _}_getJoinedRanges(c,h,_,S,k){const E=c.substring(h,_);let x=[];try{x=this._characterJoiners[0].handler(E)}catch(C){console.error(C)}for(let C=1;C<this._characterJoiners.length;C++)try{const T=this._characterJoiners[C].handler(E);for(let L=0;L<T.length;L++)Ii._mergeRanges(x,T[L])}catch(T){console.error(T)}return this._stringRangesToCellRanges(x,S,k),x}_stringRangesToCellRanges(c,h,_){let S=0,k=!1,E=0,x=c[S];if(x){for(let C=_;C<this._bufferService.cols;C++){const T=h.getWidth(C),L=h.getString(C).length||p.WHITESPACE_CELL_CHAR.length;if(T!==0){if(!k&&x[0]<=E&&(x[0]=C,k=!0),x[1]<=E){if(x[1]=C,x=c[++S],!x)break;x[0]<=E?(x[0]=C,k=!0):k=!1}E+=L}}x&&(x[1]=this._bufferService.cols)}}static _mergeRanges(c,h){let _=!1;for(let S=0;S<c.length;S++){const k=c[S];if(_){if(h[1]<=k[0])return c[S-1][1]=h[1],c;if(h[1]<=k[1])return c[S-1][1]=Math.max(h[1],k[1]),c.splice(S,1),c;c.splice(S,1),S--}else{if(h[1]<=k[0])return c.splice(S,0,h),c;if(h[1]<=k[1])return k[0]=Math.min(h[0],k[0]),c;h[0]<k[1]&&(k[0]=Math.min(h[0],k[0]),_=!0)}}return _?c[c.length-1][1]=h[1]:c.push(h),c}};i.CharacterJoinerService=n=u([f(0,y.IBufferService)],n)},5114:(w,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CoreBrowserService=void 0,i.CoreBrowserService=class{constructor(o,u){this._textarea=o,this.window=u,this._isFocused=!1,this._cachedIsFocused=void 0,this._textarea.addEventListener("focus",(()=>this._isFocused=!0)),this._textarea.addEventListener("blur",(()=>this._isFocused=!1))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask((()=>this._cachedIsFocused=void 0))),this._cachedIsFocused}}},8934:function(w,i,o){var u=this&&this.__decorate||function(y,b,n,d){var c,h=arguments.length,_=h<3?b:d===null?d=Object.getOwnPropertyDescriptor(b,n):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")_=Reflect.decorate(y,b,n,d);else for(var S=y.length-1;S>=0;S--)(c=y[S])&&(_=(h<3?c(_):h>3?c(b,n,_):c(b,n))||_);return h>3&&_&&Object.defineProperty(b,n,_),_},f=this&&this.__param||function(y,b){return function(n,d){b(n,d,y)}};Object.defineProperty(i,"__esModule",{value:!0}),i.MouseService=void 0;const a=o(4725),p=o(9806);let m=i.MouseService=class{constructor(y,b){this._renderService=y,this._charSizeService=b}getCoords(y,b,n,d,c){return(0,p.getCoords)(window,y,b,n,d,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,c)}getMouseReportCoords(y,b){const n=(0,p.getCoordsRelativeToElement)(window,y,b);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};i.MouseService=m=u([f(0,a.IRenderService),f(1,a.ICharSizeService)],m)},3230:function(w,i,o){var u=this&&this.__decorate||function(_,S,k,E){var x,C=arguments.length,T=C<3?S:E===null?E=Object.getOwnPropertyDescriptor(S,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(_,S,k,E);else for(var L=_.length-1;L>=0;L--)(x=_[L])&&(T=(C<3?x(T):C>3?x(S,k,T):x(S,k))||T);return C>3&&T&&Object.defineProperty(S,k,T),T},f=this&&this.__param||function(_,S){return function(k,E){S(k,E,_)}};Object.defineProperty(i,"__esModule",{value:!0}),i.RenderService=void 0;const a=o(3656),p=o(6193),m=o(5596),y=o(4725),b=o(8460),n=o(844),d=o(7226),c=o(2585);let h=i.RenderService=class extends n.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(_,S,k,E,x,C,T,L){if(super(),this._rowCount=_,this._charSizeService=E,this._renderer=this.register(new n.MutableDisposable),this._pausedResizeTask=new d.DebouncedIdleTask,this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this.register(new b.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new b.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new b.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new b.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new p.RenderDebouncer(T.window,((R,M)=>this._renderRows(R,M))),this.register(this._renderDebouncer),this._screenDprMonitor=new m.ScreenDprMonitor(T.window),this._screenDprMonitor.setListener((()=>this.handleDevicePixelRatioChange())),this.register(this._screenDprMonitor),this.register(C.onResize((()=>this._fullRefresh()))),this.register(C.buffers.onBufferActivate((()=>{var R;return(R=this._renderer.value)===null||R===void 0?void 0:R.clear()}))),this.register(k.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(x.onDecorationRegistered((()=>this._fullRefresh()))),this.register(x.onDecorationRemoved((()=>this._fullRefresh()))),this.register(k.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio"],(()=>{this.clear(),this.handleResize(C.cols,C.rows),this._fullRefresh()}))),this.register(k.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(C.buffer.y,C.buffer.y,!0)))),this.register((0,a.addDisposableDomListener)(T.window,"resize",(()=>this.handleDevicePixelRatioChange()))),this.register(L.onChangeColors((()=>this._fullRefresh()))),"IntersectionObserver"in T.window){const R=new T.window.IntersectionObserver((M=>this._handleIntersectionChange(M[M.length-1])),{threshold:0});R.observe(S),this.register({dispose:()=>R.disconnect()})}}_handleIntersectionChange(_){this._isPaused=_.isIntersecting===void 0?_.intersectionRatio===0:!_.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(_,S,k=!1){this._isPaused?this._needsFullRefresh=!0:(k||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(_,S,this._rowCount))}_renderRows(_,S){this._renderer.value&&(_=Math.min(_,this._rowCount-1),S=Math.min(S,this._rowCount-1),this._renderer.value.renderRows(_,S),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:_,end:S}),this._onRender.fire({start:_,end:S}),this._isNextRenderRedrawOnly=!0)}resize(_,S){this._rowCount=S,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(_){this._renderer.value=_,this._renderer.value.onRequestRedraw((S=>this.refreshRows(S.start,S.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh()}addRefreshCallback(_){return this._renderDebouncer.addRefreshCallback(_)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var _,S;this._renderer.value&&((S=(_=this._renderer.value).clearTextureAtlas)===null||S===void 0||S.call(_),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(_,S){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value.handleResize(_,S))):this._renderer.value.handleResize(_,S),this._fullRefresh())}handleCharSizeChanged(){var _;(_=this._renderer.value)===null||_===void 0||_.handleCharSizeChanged()}handleBlur(){var _;(_=this._renderer.value)===null||_===void 0||_.handleBlur()}handleFocus(){var _;(_=this._renderer.value)===null||_===void 0||_.handleFocus()}handleSelectionChanged(_,S,k){var E;this._selectionState.start=_,this._selectionState.end=S,this._selectionState.columnSelectMode=k,(E=this._renderer.value)===null||E===void 0||E.handleSelectionChanged(_,S,k)}handleCursorMove(){var _;(_=this._renderer.value)===null||_===void 0||_.handleCursorMove()}clear(){var _;(_=this._renderer.value)===null||_===void 0||_.clear()}};i.RenderService=h=u([f(2,c.IOptionsService),f(3,y.ICharSizeService),f(4,c.IDecorationService),f(5,c.IBufferService),f(6,y.ICoreBrowserService),f(7,y.IThemeService)],h)},9312:function(w,i,o){var u=this&&this.__decorate||function(x,C,T,L){var R,M=arguments.length,I=M<3?C:L===null?L=Object.getOwnPropertyDescriptor(C,T):L;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")I=Reflect.decorate(x,C,T,L);else for(var B=x.length-1;B>=0;B--)(R=x[B])&&(I=(M<3?R(I):M>3?R(C,T,I):R(C,T))||I);return M>3&&I&&Object.defineProperty(C,T,I),I},f=this&&this.__param||function(x,C){return function(T,L){C(T,L,x)}};Object.defineProperty(i,"__esModule",{value:!0}),i.SelectionService=void 0;const a=o(9806),p=o(9504),m=o(456),y=o(4725),b=o(8460),n=o(844),d=o(6114),c=o(4841),h=o(511),_=o(2585),S=" ",k=new RegExp(S,"g");let E=i.SelectionService=class extends n.Disposable{constructor(x,C,T,L,R,M,I,B,H){super(),this._element=x,this._screenElement=C,this._linkifier=T,this._bufferService=L,this._coreService=R,this._mouseService=M,this._optionsService=I,this._renderService=B,this._coreBrowserService=H,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new h.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new b.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new b.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new b.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new b.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=$=>this._handleMouseMove($),this._mouseUpListener=$=>this._handleMouseUp($),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim(($=>this._handleTrim($))),this.register(this._bufferService.buffers.onBufferActivate(($=>this._handleBufferActivate($)))),this.enable(),this._model=new m.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,n.toDisposable)((()=>{this._removeMouseDownListeners()})))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){const x=this._model.finalSelectionStart,C=this._model.finalSelectionEnd;return!(!x||!C||x[0]===C[0]&&x[1]===C[1])}get selectionText(){const x=this._model.finalSelectionStart,C=this._model.finalSelectionEnd;if(!x||!C)return"";const T=this._bufferService.buffer,L=[];if(this._activeSelectionMode===3){if(x[0]===C[0])return"";const R=x[0]<C[0]?x[0]:C[0],M=x[0]<C[0]?C[0]:x[0];for(let I=x[1];I<=C[1];I++){const B=T.translateBufferLineToString(I,!0,R,M);L.push(B)}}else{const R=x[1]===C[1]?C[0]:void 0;L.push(T.translateBufferLineToString(x[1],!0,x[0],R));for(let M=x[1]+1;M<=C[1]-1;M++){const I=T.lines.get(M),B=T.translateBufferLineToString(M,!0);I?.isWrapped?L[L.length-1]+=B:L.push(B)}if(x[1]!==C[1]){const M=T.lines.get(C[1]),I=T.translateBufferLineToString(C[1],!0,0,C[0]);M&&M.isWrapped?L[L.length-1]+=I:L.push(I)}}return L.map((R=>R.replace(k," "))).join(d.isWindows?`\r
12
+ WARNING: This link could potentially be dangerous`)){const d=window.open();if(d){try{d.opener=null}catch{}d.location.href=n}else console.warn("Opening link blocked as opener could not be cleared")}}r.OscLinkProvider=m=u([f(0,p.IBufferService),f(1,p.IOptionsService),f(2,p.IOscLinkService)],m)},6193:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.RenderDebouncer=void 0,r.RenderDebouncer=class{constructor(o,u){this._parentWindow=o,this._renderCallback=u,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._parentWindow.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(o){return this._refreshCallbacks.push(o),this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(o,u,f){this._rowCount=f,o=o!==void 0?o:0,u=u!==void 0?u:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,o):o,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,u):u,this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return void this._runRefreshCallbacks();const o=Math.max(this._rowStart,0),u=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(o,u),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const o of this._refreshCallbacks)o(0);this._refreshCallbacks=[]}}},5596:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ScreenDprMonitor=void 0;const u=o(844);class f extends u.Disposable{constructor(p){super(),this._parentWindow=p,this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this.register((0,u.toDisposable)((()=>{this.clearListener()})))}setListener(p){this._listener&&this.clearListener(),this._listener=p,this._outerListener=()=>{this._listener&&(this._listener(this._parentWindow.devicePixelRatio,this._currentDevicePixelRatio),this._updateDpr())},this._updateDpr()}_updateDpr(){var p;this._outerListener&&((p=this._resolutionMediaMatchList)===null||p===void 0||p.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._listener&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._listener=void 0,this._outerListener=void 0)}}r.ScreenDprMonitor=f},3236:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Terminal=void 0;const u=o(3614),f=o(3656),a=o(6465),p=o(9042),m=o(3730),y=o(1680),b=o(3107),n=o(5744),d=o(2950),c=o(1296),h=o(428),_=o(4269),S=o(5114),k=o(8934),E=o(3230),x=o(9312),C=o(4725),T=o(6731),L=o(8055),R=o(8969),M=o(8460),I=o(844),B=o(6114),H=o(8437),$=o(2584),N=o(7399),P=o(5941),D=o(9074),O=o(2585),q=o(5435),K=o(4567),U=typeof window<"u"?window.document:null;class z extends R.CoreTerminal{get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}constructor(j={}){super(j),this.browser=B,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new I.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(a.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(m.OscLinkProvider)),this._decorationService=this._instantiationService.createInstance(D.DecorationService),this._instantiationService.setService(O.IDecorationService,this._decorationService),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((F,X)=>this.refresh(F,X)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((F=>this._reportWindowsOptions(F)))),this.register(this._inputHandler.onColor((F=>this._handleColorEvent(F)))),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((F=>this._afterResize(F.cols,F.rows)))),this.register((0,I.toDisposable)((()=>{var F,X;this._customKeyEventHandler=void 0,(X=(F=this.element)===null||F===void 0?void 0:F.parentNode)===null||X===void 0||X.removeChild(this.element)})))}_handleColorEvent(j){if(this._themeService)for(const F of j){let X,Y="";switch(F.index){case 256:X="foreground",Y="10";break;case 257:X="background",Y="11";break;case 258:X="cursor",Y="12";break;default:X="ansi",Y="4;"+F.index}switch(F.type){case 0:const ee=L.color.toColorRGB(X==="ansi"?this._themeService.colors.ansi[F.index]:this._themeService.colors[X]);this.coreService.triggerDataEvent(`${$.C0.ESC}]${Y};${(0,P.toRgbString)(ee)}${$.C1_ESCAPED.ST}`);break;case 1:if(X==="ansi")this._themeService.modifyColors((G=>G.ansi[F.index]=L.rgba.toColor(...F.color)));else{const G=X;this._themeService.modifyColors((Z=>Z[G]=L.rgba.toColor(...F.color)))}break;case 2:this._themeService.restoreColor(F.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(j){j?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(K.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(j){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.C0.ESC+"[I"),this.updateCursorStyle(j),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var j;return(j=this.textarea)===null||j===void 0?void 0:j.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;const j=this.buffer.ybase+this.buffer.y,F=this.buffer.lines.get(j);if(!F)return;const X=Math.min(this.buffer.x,this.cols-1),Y=this._renderService.dimensions.css.cell.height,ee=F.getWidth(X),G=this._renderService.dimensions.css.cell.width*ee,Z=this.buffer.y*this._renderService.dimensions.css.cell.height,ae=X*this._renderService.dimensions.css.cell.width;this.textarea.style.left=ae+"px",this.textarea.style.top=Z+"px",this.textarea.style.width=G+"px",this.textarea.style.height=Y+"px",this.textarea.style.lineHeight=Y+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,f.addDisposableDomListener)(this.element,"copy",(F=>{this.hasSelection()&&(0,u.copyHandler)(F,this._selectionService)})));const j=F=>(0,u.handlePasteEvent)(F,this.textarea,this.coreService,this.optionsService);this.register((0,f.addDisposableDomListener)(this.textarea,"paste",j)),this.register((0,f.addDisposableDomListener)(this.element,"paste",j)),B.isFirefox?this.register((0,f.addDisposableDomListener)(this.element,"mousedown",(F=>{F.button===2&&(0,u.rightClickHandler)(F,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,f.addDisposableDomListener)(this.element,"contextmenu",(F=>{(0,u.rightClickHandler)(F,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),B.isLinux&&this.register((0,f.addDisposableDomListener)(this.element,"auxclick",(F=>{F.button===1&&(0,u.moveTextAreaUnderMouseCursor)(F,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,f.addDisposableDomListener)(this.textarea,"keyup",(j=>this._keyUp(j)),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"keydown",(j=>this._keyDown(j)),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"keypress",(j=>this._keyPress(j)),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionupdate",(j=>this._compositionHelper.compositionupdate(j)))),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,f.addDisposableDomListener)(this.textarea,"input",(j=>this._inputEvent(j)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(j){var F;if(!j)throw new Error("Terminal requires a parent element.");j.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this._document=j.ownerDocument,this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),j.appendChild(this.element);const X=U.createDocumentFragment();this._viewportElement=U.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),X.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),X.appendChild(this.screenElement),this.textarea=U.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",p.promptLabel),B.isChromeOS||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._coreBrowserService=this._instantiationService.createInstance(S.CoreBrowserService,this.textarea,(F=this._document.defaultView)!==null&&F!==void 0?F:window),this._instantiationService.setService(C.ICoreBrowserService,this._coreBrowserService),this.register((0,f.addDisposableDomListener)(this.textarea,"focus",(Y=>this._handleTextAreaFocus(Y)))),this.register((0,f.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(h.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(C.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(T.ThemeService),this._instantiationService.setService(C.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(_.CharacterJoinerService),this._instantiationService.setService(C.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(E.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(C.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((Y=>this._onRender.fire(Y)))),this.onResize((Y=>this._renderService.resize(Y.cols,Y.rows))),this._compositionView=U.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(d.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this.element.appendChild(X);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._mouseService=this._instantiationService.createInstance(k.MouseService),this._instantiationService.setService(C.IMouseService,this._mouseService),this.viewport=this._instantiationService.createInstance(y.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((Y=>this.scrollLines(Y.amount,Y.suppressScrollEvent,1))),this.register(this._inputHandler.onRequestSyncScrollBar((()=>this.viewport.syncScrollArea()))),this.register(this.viewport),this.register(this.onCursorMove((()=>{this._renderService.handleCursorMove(),this._syncTextArea()}))),this.register(this.onResize((()=>this._renderService.handleResize(this.cols,this.rows)))),this.register(this.onBlur((()=>this._renderService.handleBlur()))),this.register(this.onFocus((()=>this._renderService.handleFocus()))),this.register(this._renderService.onDimensionsChange((()=>this.viewport.syncScrollArea()))),this._selectionService=this.register(this._instantiationService.createInstance(x.SelectionService,this.element,this.screenElement,this.linkifier2)),this._instantiationService.setService(C.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((Y=>this.scrollLines(Y.amount,Y.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((Y=>this._renderService.handleSelectionChanged(Y.start,Y.end,Y.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((Y=>{this.textarea.value=Y,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((Y=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,f.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.linkifier2.attachToDom(this.screenElement,this._mouseService,this._renderService),this.register(this._instantiationService.createInstance(b.BufferDecorationRenderer,this.screenElement)),this.register((0,f.addDisposableDomListener)(this.element,"mousedown",(Y=>this._selectionService.handleMouseDown(Y)))),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(K.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(Y=>this._handleScreenReaderModeOptionChange(Y)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(n.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(Y=>{!this._overviewRulerRenderer&&Y&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(n.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(c.DomRenderer,this.element,this.screenElement,this._viewportElement,this.linkifier2)}bindMouse(){const j=this,F=this.element;function X(G){const Z=j._mouseService.getMouseReportCoords(G,j.screenElement);if(!Z)return!1;let ae,he;switch(G.overrideType||G.type){case"mousemove":he=32,G.buttons===void 0?(ae=3,G.button!==void 0&&(ae=G.button<3?G.button:3)):ae=1&G.buttons?0:4&G.buttons?1:2&G.buttons?2:3;break;case"mouseup":he=0,ae=G.button<3?G.button:3;break;case"mousedown":he=1,ae=G.button<3?G.button:3;break;case"wheel":if(j.viewport.getLinesScrolled(G)===0)return!1;he=G.deltaY<0?0:1,ae=4;break;default:return!1}return!(he===void 0||ae===void 0||ae>4)&&j.coreMouseService.triggerMouseEvent({col:Z.col,row:Z.row,x:Z.x,y:Z.y,button:ae,action:he,ctrl:G.ctrlKey,alt:G.altKey,shift:G.shiftKey})}const Y={mouseup:null,wheel:null,mousedrag:null,mousemove:null},ee={mouseup:G=>(X(G),G.buttons||(this._document.removeEventListener("mouseup",Y.mouseup),Y.mousedrag&&this._document.removeEventListener("mousemove",Y.mousedrag)),this.cancel(G)),wheel:G=>(X(G),this.cancel(G,!0)),mousedrag:G=>{G.buttons&&X(G)},mousemove:G=>{G.buttons||X(G)}};this.register(this.coreMouseService.onProtocolChange((G=>{G?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(G)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),8&G?Y.mousemove||(F.addEventListener("mousemove",ee.mousemove),Y.mousemove=ee.mousemove):(F.removeEventListener("mousemove",Y.mousemove),Y.mousemove=null),16&G?Y.wheel||(F.addEventListener("wheel",ee.wheel,{passive:!1}),Y.wheel=ee.wheel):(F.removeEventListener("wheel",Y.wheel),Y.wheel=null),2&G?Y.mouseup||(F.addEventListener("mouseup",ee.mouseup),Y.mouseup=ee.mouseup):(this._document.removeEventListener("mouseup",Y.mouseup),F.removeEventListener("mouseup",Y.mouseup),Y.mouseup=null),4&G?Y.mousedrag||(Y.mousedrag=ee.mousedrag):(this._document.removeEventListener("mousemove",Y.mousedrag),Y.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,f.addDisposableDomListener)(F,"mousedown",(G=>{if(G.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(G))return X(G),Y.mouseup&&this._document.addEventListener("mouseup",Y.mouseup),Y.mousedrag&&this._document.addEventListener("mousemove",Y.mousedrag),this.cancel(G)}))),this.register((0,f.addDisposableDomListener)(F,"wheel",(G=>{if(!Y.wheel){if(!this.buffer.hasScrollback){const Z=this.viewport.getLinesScrolled(G);if(Z===0)return;const ae=$.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(G.deltaY<0?"A":"B");let he="";for(let je=0;je<Math.abs(Z);je++)he+=ae;return this.coreService.triggerDataEvent(he,!0),this.cancel(G,!0)}return this.viewport.handleWheel(G)?this.cancel(G):void 0}}),{passive:!1})),this.register((0,f.addDisposableDomListener)(F,"touchstart",(G=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(G),this.cancel(G)}),{passive:!0})),this.register((0,f.addDisposableDomListener)(F,"touchmove",(G=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(G)?void 0:this.cancel(G)}),{passive:!1}))}refresh(j,F){var X;(X=this._renderService)===null||X===void 0||X.refreshRows(j,F)}updateCursorStyle(j){var F;!((F=this._selectionService)===null||F===void 0)&&F.shouldColumnSelect(j)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(j,F,X=0){var Y;X===1?(super.scrollLines(j,F,X),this.refresh(0,this.rows-1)):(Y=this.viewport)===null||Y===void 0||Y.scrollLines(j)}paste(j){(0,u.paste)(j,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(j){this._customKeyEventHandler=j}registerLinkProvider(j){return this.linkifier2.registerLinkProvider(j)}registerCharacterJoiner(j){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const F=this._characterJoinerService.register(j);return this.refresh(0,this.rows-1),F}deregisterCharacterJoiner(j){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(j)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(j){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+j)}registerDecoration(j){return this._decorationService.registerDecoration(j)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(j,F,X){this._selectionService.setSelection(j,F,X)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var j;(j=this._selectionService)===null||j===void 0||j.clearSelection()}selectAll(){var j;(j=this._selectionService)===null||j===void 0||j.selectAll()}selectLines(j,F){var X;(X=this._selectionService)===null||X===void 0||X.selectLines(j,F)}_keyDown(j){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(j)===!1)return!1;const F=this.browser.isMac&&this.options.macOptionIsMeta&&j.altKey;if(!F&&!this._compositionHelper.keydown(j))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;F||j.key!=="Dead"&&j.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const X=(0,N.evaluateKeyboardEvent)(j,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(j),X.type===3||X.type===2){const Y=this.rows-1;return this.scrollLines(X.type===2?-Y:Y),this.cancel(j,!0)}return X.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,j)||(X.cancel&&this.cancel(j,!0),!X.key||!!(j.key&&!j.ctrlKey&&!j.altKey&&!j.metaKey&&j.key.length===1&&j.key.charCodeAt(0)>=65&&j.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(X.key!==$.C0.ETX&&X.key!==$.C0.CR||(this.textarea.value=""),this._onKey.fire({key:X.key,domEvent:j}),this._showCursor(),this.coreService.triggerDataEvent(X.key,!0),!this.optionsService.rawOptions.screenReaderMode||j.altKey||j.ctrlKey?this.cancel(j,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(j,F){const X=j.isMac&&!this.options.macOptionIsMeta&&F.altKey&&!F.ctrlKey&&!F.metaKey||j.isWindows&&F.altKey&&F.ctrlKey&&!F.metaKey||j.isWindows&&F.getModifierState("AltGraph");return F.type==="keypress"?X:X&&(!F.keyCode||F.keyCode>47)}_keyUp(j){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(j)===!1||((function(F){return F.keyCode===16||F.keyCode===17||F.keyCode===18})(j)||this.focus(),this.updateCursorStyle(j),this._keyPressHandled=!1)}_keyPress(j){let F;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(j)===!1)return!1;if(this.cancel(j),j.charCode)F=j.charCode;else if(j.which===null||j.which===void 0)F=j.keyCode;else{if(j.which===0||j.charCode===0)return!1;F=j.which}return!(!F||(j.altKey||j.ctrlKey||j.metaKey)&&!this._isThirdLevelShift(this.browser,j)||(F=String.fromCharCode(F),this._onKey.fire({key:F,domEvent:j}),this._showCursor(),this.coreService.triggerDataEvent(F,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(j){if(j.data&&j.inputType==="insertText"&&(!j.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const F=j.data;return this.coreService.triggerDataEvent(F,!0),this.cancel(j),!0}return!1}resize(j,F){j!==this.cols||F!==this.rows?super.resize(j,F):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(j,F){var X,Y;(X=this._charSizeService)===null||X===void 0||X.measure(),(Y=this.viewport)===null||Y===void 0||Y.syncScrollArea(!0)}clear(){var j;if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let F=1;F<this.rows;F++)this.buffer.lines.push(this.buffer.getBlankLine(H.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(j=this.viewport)===null||j===void 0||j.reset(),this.refresh(0,this.rows-1)}}reset(){var j,F;this.options.rows=this.rows,this.options.cols=this.cols;const X=this._customKeyEventHandler;this._setup(),super.reset(),(j=this._selectionService)===null||j===void 0||j.reset(),this._decorationService.reset(),(F=this.viewport)===null||F===void 0||F.reset(),this._customKeyEventHandler=X,this.refresh(0,this.rows-1)}clearTextureAtlas(){var j;(j=this._renderService)===null||j===void 0||j.clearTextureAtlas()}_reportFocus(){var j;!((j=this.element)===null||j===void 0)&&j.classList.contains("focus")?this.coreService.triggerDataEvent($.C0.ESC+"[I"):this.coreService.triggerDataEvent($.C0.ESC+"[O")}_reportWindowsOptions(j){if(this._renderService)switch(j){case q.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const F=this._renderService.dimensions.css.canvas.width.toFixed(0),X=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${$.C0.ESC}[4;${X};${F}t`);break;case q.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const Y=this._renderService.dimensions.css.cell.width.toFixed(0),ee=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${$.C0.ESC}[6;${ee};${Y}t`)}}cancel(j,F){if(this.options.cancelEvents||F)return j.preventDefault(),j.stopPropagation(),!1}}r.Terminal=z},9924:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.TimeBasedDebouncer=void 0,r.TimeBasedDebouncer=class{constructor(o,u=1e3){this._renderCallback=o,this._debounceThresholdMS=u,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(o,u,f){this._rowCount=f,o=o!==void 0?o:0,u=u!==void 0?u:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,o):o,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,u):u;const a=Date.now();if(a-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=a,this._innerRefresh();else if(!this._additionalRefreshRequested){const p=a-this._lastRefreshMs,m=this._debounceThresholdMS-p;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),m)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const o=Math.max(this._rowStart,0),u=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(o,u)}}},1680:function(w,r,o){var u=this&&this.__decorate||function(d,c,h,_){var S,k=arguments.length,E=k<3?c:_===null?_=Object.getOwnPropertyDescriptor(c,h):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(d,c,h,_);else for(var x=d.length-1;x>=0;x--)(S=d[x])&&(E=(k<3?S(E):k>3?S(c,h,E):S(c,h))||E);return k>3&&E&&Object.defineProperty(c,h,E),E},f=this&&this.__param||function(d,c){return function(h,_){c(h,_,d)}};Object.defineProperty(r,"__esModule",{value:!0}),r.Viewport=void 0;const a=o(3656),p=o(4725),m=o(8460),y=o(844),b=o(2585);let n=r.Viewport=class extends y.Disposable{constructor(d,c,h,_,S,k,E,x){super(),this._viewportElement=d,this._scrollArea=c,this._bufferService=h,this._optionsService=_,this._charSizeService=S,this._renderService=k,this._coreBrowserService=E,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new m.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,a.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((C=>this._activeBuffer=C.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((C=>this._renderDimensions=C))),this._handleThemeChange(x.colors),this.register(x.onChangeColors((C=>this._handleThemeChange(C)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(d){this._viewportElement.style.backgroundColor=d.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame((()=>this.syncScrollArea()))}_refresh(d){if(d)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderService.dimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderService.dimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;const c=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderService.dimensions.css.canvas.height);this._lastRecordedBufferHeight!==c&&(this._lastRecordedBufferHeight=c,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const d=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==d&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=d),this._refreshAnimationFrame=null}syncScrollArea(d=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(d);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(d)}_handleScroll(d){if(this._lastScrollTop=this._viewportElement.scrollTop,!this._viewportElement.offsetParent)return;if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._onRequestScrollLines.fire({amount:0,suppressScrollEvent:!0});const c=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:c,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const d=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(d*(this._smoothScrollState.target-this._smoothScrollState.origin)),d<1?this._coreBrowserService.window.requestAnimationFrame((()=>this._smoothScroll())):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(d,c){const h=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(c<0&&this._viewportElement.scrollTop!==0||c>0&&h<this._lastRecordedBufferHeight)||(d.cancelable&&d.preventDefault(),!1)}handleWheel(d){const c=this._getPixelsScrolled(d);return c!==0&&(this._optionsService.rawOptions.smoothScrollDuration?(this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target===-1?this._smoothScrollState.target=this._viewportElement.scrollTop+c:this._smoothScrollState.target+=c,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=c,this._bubbleScroll(d,c))}scrollLines(d){if(d!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const c=d*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+c,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:d,suppressScrollEvent:!1})}_getPixelsScrolled(d){if(d.deltaY===0||d.shiftKey)return 0;let c=this._applyScrollModifier(d.deltaY,d);return d.deltaMode===WheelEvent.DOM_DELTA_LINE?c*=this._currentRowHeight:d.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(c*=this._currentRowHeight*this._bufferService.rows),c}getBufferElements(d,c){var h;let _,S="";const k=[],E=c??this._bufferService.buffer.lines.length,x=this._bufferService.buffer.lines;for(let C=d;C<E;C++){const T=x.get(C);if(!T)continue;const L=(h=x.get(C+1))===null||h===void 0?void 0:h.isWrapped;if(S+=T.translateToString(!L),!L||C===x.length-1){const R=document.createElement("div");R.textContent=S,k.push(R),S.length>0&&(_=R),S=""}}return{bufferElements:k,cursorElement:_}}getLinesScrolled(d){if(d.deltaY===0||d.shiftKey)return 0;let c=this._applyScrollModifier(d.deltaY,d);return d.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(c/=this._currentRowHeight+0,this._wheelPartialScroll+=c,c=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):d.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(c*=this._bufferService.rows),c}_applyScrollModifier(d,c){const h=this._optionsService.rawOptions.fastScrollModifier;return h==="alt"&&c.altKey||h==="ctrl"&&c.ctrlKey||h==="shift"&&c.shiftKey?d*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:d*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(d){this._lastTouchY=d.touches[0].pageY}handleTouchMove(d){const c=this._lastTouchY-d.touches[0].pageY;return this._lastTouchY=d.touches[0].pageY,c!==0&&(this._viewportElement.scrollTop+=c,this._bubbleScroll(d,c))}};r.Viewport=n=u([f(2,b.IBufferService),f(3,b.IOptionsService),f(4,p.ICharSizeService),f(5,p.IRenderService),f(6,p.ICoreBrowserService),f(7,p.IThemeService)],n)},3107:function(w,r,o){var u=this&&this.__decorate||function(n,d,c,h){var _,S=arguments.length,k=S<3?d:h===null?h=Object.getOwnPropertyDescriptor(d,c):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(n,d,c,h);else for(var E=n.length-1;E>=0;E--)(_=n[E])&&(k=(S<3?_(k):S>3?_(d,c,k):_(d,c))||k);return S>3&&k&&Object.defineProperty(d,c,k),k},f=this&&this.__param||function(n,d){return function(c,h){d(c,h,n)}};Object.defineProperty(r,"__esModule",{value:!0}),r.BufferDecorationRenderer=void 0;const a=o(3656),p=o(4725),m=o(844),y=o(2585);let b=r.BufferDecorationRenderer=class extends m.Disposable{constructor(n,d,c,h){super(),this._screenElement=n,this._bufferService=d,this._decorationService=c,this._renderService=h,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this.register(this._renderService.onRenderedViewportChange((()=>this._doRefreshDecorations()))),this.register(this._renderService.onDimensionsChange((()=>{this._dimensionsChanged=!0,this._queueRefresh()}))),this.register((0,a.addDisposableDomListener)(window,"resize",(()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt}))),this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh()))),this.register(this._decorationService.onDecorationRemoved((_=>this._removeDecoration(_)))),this.register((0,m.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(const n of this._decorationService.decorations)this._renderDecoration(n);this._dimensionsChanged=!1}_renderDecoration(n){this._refreshStyle(n),this._dimensionsChanged&&this._refreshXPosition(n)}_createElement(n){var d,c;const h=document.createElement("div");h.classList.add("xterm-decoration"),h.classList.toggle("xterm-decoration-top-layer",((d=n?.options)===null||d===void 0?void 0:d.layer)==="top"),h.style.width=`${Math.round((n.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,h.style.height=(n.options.height||1)*this._renderService.dimensions.css.cell.height+"px",h.style.top=(n.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",h.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const _=(c=n.options.x)!==null&&c!==void 0?c:0;return _&&_>this._bufferService.cols&&(h.style.display="none"),this._refreshXPosition(n,h),h}_refreshStyle(n){const d=n.marker.line-this._bufferService.buffers.active.ydisp;if(d<0||d>=this._bufferService.rows)n.element&&(n.element.style.display="none",n.onRenderEmitter.fire(n.element));else{let c=this._decorationElements.get(n);c||(c=this._createElement(n),n.element=c,this._decorationElements.set(n,c),this._container.appendChild(c),n.onDispose((()=>{this._decorationElements.delete(n),c.remove()}))),c.style.top=d*this._renderService.dimensions.css.cell.height+"px",c.style.display=this._altBufferIsActive?"none":"block",n.onRenderEmitter.fire(c)}}_refreshXPosition(n,d=n.element){var c;if(!d)return;const h=(c=n.options.x)!==null&&c!==void 0?c:0;(n.options.anchor||"left")==="right"?d.style.right=h?h*this._renderService.dimensions.css.cell.width+"px":"":d.style.left=h?h*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(n){var d;(d=this._decorationElements.get(n))===null||d===void 0||d.remove(),this._decorationElements.delete(n),n.dispose()}};r.BufferDecorationRenderer=b=u([f(1,y.IBufferService),f(2,y.IDecorationService),f(3,p.IRenderService)],b)},5871:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ColorZoneStore=void 0,r.ColorZoneStore=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(o){if(o.options.overviewRulerOptions){for(const u of this._zones)if(u.color===o.options.overviewRulerOptions.color&&u.position===o.options.overviewRulerOptions.position){if(this._lineIntersectsZone(u,o.marker.line))return;if(this._lineAdjacentToZone(u,o.marker.line,o.options.overviewRulerOptions.position))return void this._addLineToZone(u,o.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=o.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=o.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=o.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=o.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:o.options.overviewRulerOptions.color,position:o.options.overviewRulerOptions.position,startBufferLine:o.marker.line,endBufferLine:o.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(o){this._linePadding=o}_lineIntersectsZone(o,u){return u>=o.startBufferLine&&u<=o.endBufferLine}_lineAdjacentToZone(o,u,f){return u>=o.startBufferLine-this._linePadding[f||"full"]&&u<=o.endBufferLine+this._linePadding[f||"full"]}_addLineToZone(o,u){o.startBufferLine=Math.min(o.startBufferLine,u),o.endBufferLine=Math.max(o.endBufferLine,u)}}},5744:function(w,r,o){var u=this&&this.__decorate||function(_,S,k,E){var x,C=arguments.length,T=C<3?S:E===null?E=Object.getOwnPropertyDescriptor(S,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(_,S,k,E);else for(var L=_.length-1;L>=0;L--)(x=_[L])&&(T=(C<3?x(T):C>3?x(S,k,T):x(S,k))||T);return C>3&&T&&Object.defineProperty(S,k,T),T},f=this&&this.__param||function(_,S){return function(k,E){S(k,E,_)}};Object.defineProperty(r,"__esModule",{value:!0}),r.OverviewRulerRenderer=void 0;const a=o(5871),p=o(3656),m=o(4725),y=o(844),b=o(2585),n={full:0,left:0,center:0,right:0},d={full:0,left:0,center:0,right:0},c={full:0,left:0,center:0,right:0};let h=r.OverviewRulerRenderer=class extends y.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(_,S,k,E,x,C,T){var L;super(),this._viewportElement=_,this._screenElement=S,this._bufferService=k,this._decorationService=E,this._renderService=x,this._optionsService=C,this._coreBrowseService=T,this._colorZoneStore=new a.ColorZoneStore,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=document.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(L=this._viewportElement.parentElement)===null||L===void 0||L.insertBefore(this._canvas,this._viewportElement);const R=this._canvas.getContext("2d");if(!R)throw new Error("Ctx cannot be null");this._ctx=R,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,y.toDisposable)((()=>{var 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,p.addDisposableDomListener)(this._coreBrowseService.window,"resize",(()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){const _=Math.floor(this._canvas.width/3),S=Math.ceil(this._canvas.width/3);d.full=this._canvas.width,d.left=_,d.center=S,d.right=_,this._refreshDrawHeightConstants(),c.full=0,c.left=0,c.center=d.left,c.right=d.left+d.center}_refreshDrawHeightConstants(){n.full=Math.round(2*this._coreBrowseService.dpr);const _=this._canvas.height/this._bufferService.buffer.lines.length,S=Math.round(Math.max(Math.min(_,12),6)*this._coreBrowseService.dpr);n.left=S,n.center=S,n.right=S}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*n.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*n.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*n.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*n.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowseService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowseService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(const S of this._decorationService.decorations)this._colorZoneStore.addDecoration(S);this._ctx.lineWidth=1;const _=this._colorZoneStore.zones;for(const S of _)S.position!=="full"&&this._renderColorZone(S);for(const S of _)S.position==="full"&&this._renderColorZone(S);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(_){this._ctx.fillStyle=_.color,this._ctx.fillRect(c[_.position||"full"],Math.round((this._canvas.height-1)*(_.startBufferLine/this._bufferService.buffers.active.lines.length)-n[_.position||"full"]/2),d[_.position||"full"],Math.round((this._canvas.height-1)*((_.endBufferLine-_.startBufferLine)/this._bufferService.buffers.active.lines.length)+n[_.position||"full"]))}_queueRefresh(_,S){this._shouldUpdateDimensions=_||this._shouldUpdateDimensions,this._shouldUpdateAnchor=S||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowseService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};r.OverviewRulerRenderer=h=u([f(2,b.IBufferService),f(3,b.IDecorationService),f(4,m.IRenderService),f(5,b.IOptionsService),f(6,m.ICoreBrowserService)],h)},2950:function(w,r,o){var u=this&&this.__decorate||function(b,n,d,c){var h,_=arguments.length,S=_<3?n:c===null?c=Object.getOwnPropertyDescriptor(n,d):c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(b,n,d,c);else for(var k=b.length-1;k>=0;k--)(h=b[k])&&(S=(_<3?h(S):_>3?h(n,d,S):h(n,d))||S);return _>3&&S&&Object.defineProperty(n,d,S),S},f=this&&this.__param||function(b,n){return function(d,c){n(d,c,b)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CompositionHelper=void 0;const a=o(4725),p=o(2585),m=o(2584);let y=r.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(b,n,d,c,h,_){this._textarea=b,this._compositionView=n,this._bufferService=d,this._optionsService=c,this._coreService=h,this._renderService=_,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(b){this._compositionView.textContent=b.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(b){if(this._isComposing||this._isSendingComposition){if(b.keyCode===229||b.keyCode===16||b.keyCode===17||b.keyCode===18)return!1;this._finalizeComposition(!1)}return b.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(b){if(this._compositionView.classList.remove("active"),this._isComposing=!1,b){const n={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let d;this._isSendingComposition=!1,n.start+=this._dataAlreadySent.length,d=this._isComposing?this._textarea.value.substring(n.start,n.end):this._textarea.value.substring(n.start),d.length>0&&this._coreService.triggerDataEvent(d,!0)}}),0)}else{this._isSendingComposition=!1;const n=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(n,!0)}}_handleAnyTextareaChanges(){const b=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const n=this._textarea.value,d=n.replace(b,"");this._dataAlreadySent=d,n.length>b.length?this._coreService.triggerDataEvent(d,!0):n.length<b.length?this._coreService.triggerDataEvent(`${m.C0.DEL}`,!0):n.length===b.length&&n!==b&&this._coreService.triggerDataEvent(n,!0)}}),0)}updateCompositionElements(b){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const n=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),d=this._renderService.dimensions.css.cell.height,c=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,h=n*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=h+"px",this._compositionView.style.top=c+"px",this._compositionView.style.height=d+"px",this._compositionView.style.lineHeight=d+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const _=this._compositionView.getBoundingClientRect();this._textarea.style.left=h+"px",this._textarea.style.top=c+"px",this._textarea.style.width=Math.max(_.width,1)+"px",this._textarea.style.height=Math.max(_.height,1)+"px",this._textarea.style.lineHeight=_.height+"px"}b||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};r.CompositionHelper=y=u([f(2,p.IBufferService),f(3,p.IOptionsService),f(4,p.ICoreService),f(5,a.IRenderService)],y)},9806:(w,r)=>{function o(u,f,a){const p=a.getBoundingClientRect(),m=u.getComputedStyle(a),y=parseInt(m.getPropertyValue("padding-left")),b=parseInt(m.getPropertyValue("padding-top"));return[f.clientX-p.left-y,f.clientY-p.top-b]}Object.defineProperty(r,"__esModule",{value:!0}),r.getCoords=r.getCoordsRelativeToElement=void 0,r.getCoordsRelativeToElement=o,r.getCoords=function(u,f,a,p,m,y,b,n,d){if(!y)return;const c=o(u,f,a);return c?(c[0]=Math.ceil((c[0]+(d?b/2:0))/b),c[1]=Math.ceil(c[1]/n),c[0]=Math.min(Math.max(c[0],1),p+(d?1:0)),c[1]=Math.min(Math.max(c[1],1),m),c):void 0}},9504:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.moveToCellSequence=void 0;const u=o(2584);function f(n,d,c,h){const _=n-a(n,c),S=d-a(d,c),k=Math.abs(_-S)-(function(E,x,C){let T=0;const L=E-a(E,C),R=x-a(x,C);for(let M=0;M<Math.abs(L-R);M++){const I=p(E,x)==="A"?-1:1,B=C.buffer.lines.get(L+I*M);B?.isWrapped&&T++}return T})(n,d,c);return b(k,y(p(n,d),h))}function a(n,d){let c=0,h=d.buffer.lines.get(n),_=h?.isWrapped;for(;_&&n>=0&&n<d.rows;)c++,h=d.buffer.lines.get(--n),_=h?.isWrapped;return c}function p(n,d){return n>d?"A":"B"}function m(n,d,c,h,_,S){let k=n,E=d,x="";for(;k!==c||E!==h;)k+=_?1:-1,_&&k>S.cols-1?(x+=S.buffer.translateBufferLineToString(E,!1,n,k),k=0,n=0,E++):!_&&k<0&&(x+=S.buffer.translateBufferLineToString(E,!1,0,n+1),k=S.cols-1,n=k,E--);return x+S.buffer.translateBufferLineToString(E,!1,n,k)}function y(n,d){const c=d?"O":"[";return u.C0.ESC+c+n}function b(n,d){n=Math.floor(n);let c="";for(let h=0;h<n;h++)c+=d;return c}r.moveToCellSequence=function(n,d,c,h){const _=c.buffer.x,S=c.buffer.y;if(!c.buffer.hasScrollback)return(function(x,C,T,L,R,M){return f(C,L,R,M).length===0?"":b(m(x,C,x,C-a(C,R),!1,R).length,y("D",M))})(_,S,0,d,c,h)+f(S,d,c,h)+(function(x,C,T,L,R,M){let I;I=f(C,L,R,M).length>0?L-a(L,R):C;const B=L,H=(function($,N,P,D,O,q){let K;return K=f(P,D,O,q).length>0?D-a(D,O):N,$<P&&K<=D||$>=P&&K<D?"C":"D"})(x,C,T,L,R,M);return b(m(x,I,T,B,H==="C",R).length,y(H,M))})(_,S,n,d,c,h);let k;if(S===d)return k=_>n?"D":"C",b(Math.abs(_-n),y(k,h));k=S>d?"D":"C";const E=Math.abs(S-d);return b((function(x,C){return C.cols-x})(S>d?n:_,c)+(E-1)*c.cols+1+((S>d?_:n)-1),y(k,h))}},1296:function(w,r,o){var u=this&&this.__decorate||function(R,M,I,B){var H,$=arguments.length,N=$<3?M:B===null?B=Object.getOwnPropertyDescriptor(M,I):B;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(R,M,I,B);else for(var P=R.length-1;P>=0;P--)(H=R[P])&&(N=($<3?H(N):$>3?H(M,I,N):H(M,I))||N);return $>3&&N&&Object.defineProperty(M,I,N),N},f=this&&this.__param||function(R,M){return function(I,B){M(I,B,R)}};Object.defineProperty(r,"__esModule",{value:!0}),r.DomRenderer=void 0;const a=o(3787),p=o(2550),m=o(2223),y=o(6171),b=o(4725),n=o(8055),d=o(8460),c=o(844),h=o(2585),_="xterm-dom-renderer-owner-",S="xterm-rows",k="xterm-fg-",E="xterm-bg-",x="xterm-focus",C="xterm-selection";let T=1,L=r.DomRenderer=class extends c.Disposable{constructor(R,M,I,B,H,$,N,P,D,O){super(),this._element=R,this._screenElement=M,this._viewportElement=I,this._linkifier2=B,this._charSizeService=$,this._optionsService=N,this._bufferService=P,this._coreBrowserService=D,this._themeService=O,this._terminalClass=T++,this._rowElements=[],this.onRequestRedraw=this.register(new d.EventEmitter).event,this._rowContainer=document.createElement("div"),this._rowContainer.classList.add(S),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=document.createElement("div"),this._selectionContainer.classList.add(C),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,y.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((q=>this._injectCss(q)))),this._injectCss(this._themeService.colors),this._rowFactory=H.createInstance(a.DomRendererRowFactory,document),this._element.classList.add(_+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((q=>this._handleLinkHover(q)))),this.register(this._linkifier2.onHideLinkUnderline((q=>this._handleLinkLeave(q)))),this.register((0,c.toDisposable)((()=>{this._element.classList.remove(_+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new p.WidthCache(document),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){const R=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*R,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*R),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/R),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/R),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(const I of this._rowElements)I.style.width=`${this.dimensions.css.canvas.width}px`,I.style.height=`${this.dimensions.css.cell.height}px`,I.style.lineHeight=`${this.dimensions.css.cell.height}px`,I.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const M=`${this._terminalSelector} .${S} 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(R){this._themeStyleElement||(this._themeStyleElement=document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let M=`${this._terminalSelector} .${S} { color: ${R.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;M+=`${this._terminalSelector} .${S} .xterm-dim { color: ${n.color.multiplyOpacity(R.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: ${R.cursor.css}; color: ${R.cursorAccent.css}; } 50% { background-color: inherit; color: ${R.cursor.css}; }}`,M+=`${this._terminalSelector} .${S}.${x} .xterm-cursor.xterm-cursor-blink:not(.xterm-cursor-block) { animation: blink_box_shadow_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${S}.${x} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: blink_block_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-block { background-color: ${R.cursor.css}; color: ${R.cursorAccent.css};}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${R.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${R.cursor.css} inset;}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${R.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,M+=`${this._terminalSelector} .${C} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${C} div { position: absolute; background-color: ${R.selectionBackgroundOpaque.css};}${this._terminalSelector} .${C} div { position: absolute; background-color: ${R.selectionInactiveBackgroundOpaque.css};}`;for(const[I,B]of R.ansi.entries())M+=`${this._terminalSelector} .${k}${I} { color: ${B.css}; }${this._terminalSelector} .${k}${I}.xterm-dim { color: ${n.color.multiplyOpacity(B,.5).css}; }${this._terminalSelector} .${E}${I} { background-color: ${B.css}; }`;M+=`${this._terminalSelector} .${k}${m.INVERTED_DEFAULT_COLOR} { color: ${n.color.opaque(R.background).css}; }${this._terminalSelector} .${k}${m.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${n.color.multiplyOpacity(n.color.opaque(R.background),.5).css}; }${this._terminalSelector} .${E}${m.INVERTED_DEFAULT_COLOR} { background-color: ${R.foreground.css}; }`,this._themeStyleElement.textContent=M}_setDefaultSpacing(){const R=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${R}px`,this._rowFactory.defaultSpacing=R}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(R,M){for(let I=this._rowElements.length;I<=M;I++){const B=document.createElement("div");this._rowContainer.appendChild(B),this._rowElements.push(B)}for(;this._rowElements.length>M;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(R,M){this._refreshRowElements(R,M),this._updateDimensions()}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(x)}handleFocus(){this._rowContainer.classList.add(x),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(R,M,I){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(R,M,I),this.renderRows(0,this._bufferService.rows-1),!R||!M)return;const B=R[1]-this._bufferService.buffer.ydisp,H=M[1]-this._bufferService.buffer.ydisp,$=Math.max(B,0),N=Math.min(H,this._bufferService.rows-1);if($>=this._bufferService.rows||N<0)return;const P=document.createDocumentFragment();if(I){const D=R[0]>M[0];P.appendChild(this._createSelectionElement($,D?M[0]:R[0],D?R[0]:M[0],N-$+1))}else{const D=B===$?R[0]:0,O=$===H?M[0]:this._bufferService.cols;P.appendChild(this._createSelectionElement($,D,O));const q=N-$-1;if(P.appendChild(this._createSelectionElement($+1,0,this._bufferService.cols,q)),$!==N){const K=H===N?M[0]:this._bufferService.cols;P.appendChild(this._createSelectionElement(N,0,K))}}this._selectionContainer.appendChild(P)}_createSelectionElement(R,M,I,B=1){const H=document.createElement("div");return H.style.height=B*this.dimensions.css.cell.height+"px",H.style.top=R*this.dimensions.css.cell.height+"px",H.style.left=M*this.dimensions.css.cell.width+"px",H.style.width=this.dimensions.css.cell.width*(I-M)+"px",H}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(const R of this._rowElements)R.replaceChildren()}renderRows(R,M){const I=this._bufferService.buffer,B=I.ybase+I.y,H=Math.min(I.x,this._bufferService.cols-1),$=this._optionsService.rawOptions.cursorBlink,N=this._optionsService.rawOptions.cursorStyle,P=this._optionsService.rawOptions.cursorInactiveStyle;for(let D=R;D<=M;D++){const O=D+I.ydisp,q=this._rowElements[D],K=I.lines.get(O);if(!q||!K)break;q.replaceChildren(...this._rowFactory.createRow(K,O,O===B,N,P,H,$,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${_}${this._terminalClass}`}_handleLinkHover(R){this._setCellUnderline(R.x1,R.x2,R.y1,R.y2,R.cols,!0)}_handleLinkLeave(R){this._setCellUnderline(R.x1,R.x2,R.y1,R.y2,R.cols,!1)}_setCellUnderline(R,M,I,B,H,$){I<0&&(R=0),B<0&&(M=0);const N=this._bufferService.rows-1;I=Math.max(Math.min(I,N),0),B=Math.max(Math.min(B,N),0),H=Math.min(H,this._bufferService.cols);const P=this._bufferService.buffer,D=P.ybase+P.y,O=Math.min(P.x,H-1),q=this._optionsService.rawOptions.cursorBlink,K=this._optionsService.rawOptions.cursorStyle,U=this._optionsService.rawOptions.cursorInactiveStyle;for(let z=I;z<=B;++z){const W=z+P.ydisp,j=this._rowElements[z],F=P.lines.get(W);if(!j||!F)break;j.replaceChildren(...this._rowFactory.createRow(F,W,W===D,K,U,O,q,this.dimensions.css.cell.width,this._widthCache,$?z===I?R:0:-1,$?(z===B?M:H)-1:-1))}}};r.DomRenderer=L=u([f(4,h.IInstantiationService),f(5,b.ICharSizeService),f(6,h.IOptionsService),f(7,h.IBufferService),f(8,b.ICoreBrowserService),f(9,b.IThemeService)],L)},3787:function(w,r,o){var u=this&&this.__decorate||function(k,E,x,C){var T,L=arguments.length,R=L<3?E:C===null?C=Object.getOwnPropertyDescriptor(E,x):C;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(k,E,x,C);else for(var M=k.length-1;M>=0;M--)(T=k[M])&&(R=(L<3?T(R):L>3?T(E,x,R):T(E,x))||R);return L>3&&R&&Object.defineProperty(E,x,R),R},f=this&&this.__param||function(k,E){return function(x,C){E(x,C,k)}};Object.defineProperty(r,"__esModule",{value:!0}),r.DomRendererRowFactory=void 0;const a=o(2223),p=o(643),m=o(511),y=o(2585),b=o(8055),n=o(4725),d=o(4269),c=o(6171),h=o(3734);let _=r.DomRendererRowFactory=class{constructor(k,E,x,C,T,L,R){this._document=k,this._characterJoinerService=E,this._optionsService=x,this._coreBrowserService=C,this._coreService=T,this._decorationService=L,this._themeService=R,this._workCell=new m.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(k,E,x){this._selectionStart=k,this._selectionEnd=E,this._columnSelectMode=x}createRow(k,E,x,C,T,L,R,M,I,B,H){const $=[],N=this._characterJoinerService.getJoinedCharacters(E),P=this._themeService.colors;let D,O=k.getNoBgTrimmedLength();x&&O<L+1&&(O=L+1);let q=0,K="",U=0,z=0,W=0,j=!1,F=0,X=!1,Y=0;const ee=[],G=B!==-1&&H!==-1;for(let Z=0;Z<O;Z++){k.loadCell(Z,this._workCell);let ae=this._workCell.getWidth();if(ae===0)continue;let he=!1,je=Z,se=this._workCell;if(N.length>0&&Z===N[0][0]){he=!0;const ue=N.shift();se=new d.JoinedCellData(this._workCell,k.translateToString(!0,ue[0],ue[1]),ue[1]-ue[0]),je=ue[1]-1,ae=se.getWidth()}const Ae=this._isCellInSelection(Z,E),te=x&&Z===L,me=G&&Z>=B&&Z<=H;let Pe=!1;this._decorationService.forEachDecorationAtCell(Z,E,void 0,(ue=>{Pe=!0}));let qe=se.getChars()||p.WHITESPACE_CELL_CHAR;if(qe===" "&&(se.isUnderline()||se.isOverline())&&(qe=" "),Y=ae*M-I.get(qe,se.isBold(),se.isItalic()),D){if(q&&(Ae&&X||!Ae&&!X&&se.bg===U)&&(Ae&&X&&P.selectionForeground||se.fg===z)&&se.extended.ext===W&&me===j&&Y===F&&!te&&!he&&!Pe){K+=qe,q++;continue}q&&(D.textContent=K),D=this._document.createElement("span"),q=0,K=""}else D=this._document.createElement("span");if(U=se.bg,z=se.fg,W=se.extended.ext,j=me,F=Y,X=Ae,he&&L>=Z&&L<=je&&(L=Z),!this._coreService.isCursorHidden&&te){if(ee.push("xterm-cursor"),this._coreBrowserService.isFocused)R&&ee.push("xterm-cursor-blink"),ee.push(C==="bar"?"xterm-cursor-bar":C==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(T)switch(T){case"outline":ee.push("xterm-cursor-outline");break;case"block":ee.push("xterm-cursor-block");break;case"bar":ee.push("xterm-cursor-bar");break;case"underline":ee.push("xterm-cursor-underline")}}if(se.isBold()&&ee.push("xterm-bold"),se.isItalic()&&ee.push("xterm-italic"),se.isDim()&&ee.push("xterm-dim"),K=se.isInvisible()?p.WHITESPACE_CELL_CHAR:se.getChars()||p.WHITESPACE_CELL_CHAR,se.isUnderline()&&(ee.push(`xterm-underline-${se.extended.underlineStyle}`),K===" "&&(K=" "),!se.isUnderlineColorDefault()))if(se.isUnderlineColorRGB())D.style.textDecorationColor=`rgb(${h.AttributeData.toColorRGB(se.getUnderlineColor()).join(",")})`;else{let ue=se.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&se.isBold()&&ue<8&&(ue+=8),D.style.textDecorationColor=P.ansi[ue].css}se.isOverline()&&(ee.push("xterm-overline"),K===" "&&(K=" ")),se.isStrikethrough()&&ee.push("xterm-strikethrough"),me&&(D.style.textDecoration="underline");let ve=se.getFgColor(),Re=se.getFgColorMode(),Se=se.getBgColor(),Ce=se.getBgColorMode();const rt=!!se.isInverse();if(rt){const ue=ve;ve=Se,Se=ue;const rs=Re;Re=Ce,Ce=rs}let Ne,it,Ie,nt=!1;switch(this._decorationService.forEachDecorationAtCell(Z,E,void 0,(ue=>{ue.options.layer!=="top"&&nt||(ue.backgroundColorRGB&&(Ce=50331648,Se=ue.backgroundColorRGB.rgba>>8&16777215,Ne=ue.backgroundColorRGB),ue.foregroundColorRGB&&(Re=50331648,ve=ue.foregroundColorRGB.rgba>>8&16777215,it=ue.foregroundColorRGB),nt=ue.options.layer==="top")})),!nt&&Ae&&(Ne=this._coreBrowserService.isFocused?P.selectionBackgroundOpaque:P.selectionInactiveBackgroundOpaque,Se=Ne.rgba>>8&16777215,Ce=50331648,nt=!0,P.selectionForeground&&(Re=50331648,ve=P.selectionForeground.rgba>>8&16777215,it=P.selectionForeground)),nt&&ee.push("xterm-decoration-top"),Ce){case 16777216:case 33554432:Ie=P.ansi[Se],ee.push(`xterm-bg-${Se}`);break;case 50331648:Ie=b.rgba.toColor(Se>>16,Se>>8&255,255&Se),this._addStyle(D,`background-color:#${S((Se>>>0).toString(16),"0",6)}`);break;default:rt?(Ie=P.foreground,ee.push(`xterm-bg-${a.INVERTED_DEFAULT_COLOR}`)):Ie=P.background}switch(Ne||se.isDim()&&(Ne=b.color.multiplyOpacity(Ie,.5)),Re){case 16777216:case 33554432:se.isBold()&&ve<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ve+=8),this._applyMinimumContrast(D,Ie,P.ansi[ve],se,Ne,void 0)||ee.push(`xterm-fg-${ve}`);break;case 50331648:const ue=b.rgba.toColor(ve>>16&255,ve>>8&255,255&ve);this._applyMinimumContrast(D,Ie,ue,se,Ne,it)||this._addStyle(D,`color:#${S(ve.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(D,Ie,P.foreground,se,Ne,void 0)||rt&&ee.push(`xterm-fg-${a.INVERTED_DEFAULT_COLOR}`)}ee.length&&(D.className=ee.join(" "),ee.length=0),te||he||Pe?D.textContent=K:q++,Y!==this.defaultSpacing&&(D.style.letterSpacing=`${Y}px`),$.push(D),Z=je}return D&&q&&(D.textContent=K),$}_applyMinimumContrast(k,E,x,C,T,L){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,c.excludeFromContrastRatioDemands)(C.getCode()))return!1;const R=this._getContrastCache(C);let M;if(T||L||(M=R.getColor(E.rgba,x.rgba)),M===void 0){const I=this._optionsService.rawOptions.minimumContrastRatio/(C.isDim()?2:1);M=b.color.ensureContrastRatio(T||E,L||x,I),R.setColor((T||E).rgba,(L||x).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,E){k.setAttribute("style",`${k.getAttribute("style")||""}${E};`)}_isCellInSelection(k,E){const x=this._selectionStart,C=this._selectionEnd;return!(!x||!C)&&(this._columnSelectMode?x[0]<=C[0]?k>=x[0]&&E>=x[1]&&k<C[0]&&E<=C[1]:k<x[0]&&E>=x[1]&&k>=C[0]&&E<=C[1]:E>x[1]&&E<C[1]||x[1]===C[1]&&E===x[1]&&k>=x[0]&&k<C[0]||x[1]<C[1]&&E===C[1]&&k<C[0]||x[1]<C[1]&&E===x[1]&&k>=x[0])}};function S(k,E,x){for(;k.length<x;)k=E+k;return k}r.DomRendererRowFactory=_=u([f(1,n.ICharacterJoinerService),f(2,y.IOptionsService),f(3,n.ICoreBrowserService),f(4,y.ICoreService),f(5,y.IDecorationService),f(6,n.IThemeService)],_)},2550:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.WidthCache=void 0,r.WidthCache=class{constructor(o){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=o.createElement("div"),this._container.style.position="absolute",this._container.style.top="-50000px",this._container.style.width="50000px",this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";const u=o.createElement("span"),f=o.createElement("span");f.style.fontWeight="bold";const a=o.createElement("span");a.style.fontStyle="italic";const p=o.createElement("span");p.style.fontWeight="bold",p.style.fontStyle="italic",this._measureElements=[u,f,a,p],this._container.appendChild(u),this._container.appendChild(f),this._container.appendChild(a),this._container.appendChild(p),o.body.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(o,u,f,a){o===this._font&&u===this._fontSize&&f===this._weight&&a===this._weightBold||(this._font=o,this._fontSize=u,this._weight=f,this._weightBold=a,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${f}`,this._measureElements[1].style.fontWeight=`${a}`,this._measureElements[2].style.fontWeight=`${f}`,this._measureElements[3].style.fontWeight=`${a}`,this.clear())}get(o,u,f){let a=0;if(!u&&!f&&o.length===1&&(a=o.charCodeAt(0))<256)return this._flat[a]!==-9999?this._flat[a]:this._flat[a]=this._measure(o,0);let p=o;u&&(p+="B"),f&&(p+="I");let m=this._holey.get(p);if(m===void 0){let y=0;u&&(y|=1),f&&(y|=2),m=this._measure(o,y),this._holey.set(p,m)}return m}_measure(o,u){const f=this._measureElements[u];return f.textContent=o.repeat(32),f.offsetWidth/32}}},2223:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.TEXT_BASELINE=r.DIM_OPACITY=r.INVERTED_DEFAULT_COLOR=void 0;const u=o(6114);r.INVERTED_DEFAULT_COLOR=257,r.DIM_OPACITY=.5,r.TEXT_BASELINE=u.isFirefox||u.isLegacyEdge?"bottom":"ideographic"},6171:(w,r)=>{function o(u){return 57508<=u&&u<=57558}Object.defineProperty(r,"__esModule",{value:!0}),r.createRenderDimensions=r.excludeFromContrastRatioDemands=r.isRestrictedPowerlineGlyph=r.isPowerlineGlyph=r.throwIfFalsy=void 0,r.throwIfFalsy=function(u){if(!u)throw new Error("value must not be falsy");return u},r.isPowerlineGlyph=o,r.isRestrictedPowerlineGlyph=function(u){return 57520<=u&&u<=57527},r.excludeFromContrastRatioDemands=function(u){return o(u)||(function(f){return 9472<=f&&f<=9631})(u)},r.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}}},456:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.SelectionModel=void 0,r.SelectionModel=class{constructor(o){this._bufferService=o,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){const o=this.selectionStart[0]+this.selectionStartLength;return o>this._bufferService.cols?o%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(o/this._bufferService.cols)-1]:[o%this._bufferService.cols,this.selectionStart[1]+Math.floor(o/this._bufferService.cols)]:[o,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const o=this.selectionStart[0]+this.selectionStartLength;return o>this._bufferService.cols?[o%this._bufferService.cols,this.selectionStart[1]+Math.floor(o/this._bufferService.cols)]:[Math.max(o,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const o=this.selectionStart,u=this.selectionEnd;return!(!o||!u)&&(o[1]>u[1]||o[1]===u[1]&&o[0]>u[0])}handleTrim(o){return this.selectionStart&&(this.selectionStart[1]-=o),this.selectionEnd&&(this.selectionEnd[1]-=o),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(w,r,o){var u=this&&this.__decorate||function(n,d,c,h){var _,S=arguments.length,k=S<3?d:h===null?h=Object.getOwnPropertyDescriptor(d,c):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(n,d,c,h);else for(var E=n.length-1;E>=0;E--)(_=n[E])&&(k=(S<3?_(k):S>3?_(d,c,k):_(d,c))||k);return S>3&&k&&Object.defineProperty(d,c,k),k},f=this&&this.__param||function(n,d){return function(c,h){d(c,h,n)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CharSizeService=void 0;const a=o(2585),p=o(8460),m=o(844);let y=r.CharSizeService=class extends m.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(n,d,c){super(),this._optionsService=c,this.width=0,this.height=0,this._onCharSizeChange=this.register(new p.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event,this._measureStrategy=new b(n,d,this._optionsService),this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const n=this._measureStrategy.measure();n.width===this.width&&n.height===this.height||(this.width=n.width,this.height=n.height,this._onCharSizeChange.fire())}};r.CharSizeService=y=u([f(2,a.IOptionsService)],y);class b{constructor(d,c,h){this._document=d,this._parentElement=c,this._optionsService=h,this._result={width:0,height:0},this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`;const d={height:Number(this._measureElement.offsetHeight),width:Number(this._measureElement.offsetWidth)};return d.width!==0&&d.height!==0&&(this._result.width=d.width/32,this._result.height=Math.ceil(d.height)),this._result}}},4269:function(w,r,o){var u=this&&this.__decorate||function(d,c,h,_){var S,k=arguments.length,E=k<3?c:_===null?_=Object.getOwnPropertyDescriptor(c,h):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(d,c,h,_);else for(var x=d.length-1;x>=0;x--)(S=d[x])&&(E=(k<3?S(E):k>3?S(c,h,E):S(c,h))||E);return k>3&&E&&Object.defineProperty(c,h,E),E},f=this&&this.__param||function(d,c){return function(h,_){c(h,_,d)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CharacterJoinerService=r.JoinedCellData=void 0;const a=o(3734),p=o(643),m=o(511),y=o(2585);class b extends a.AttributeData{constructor(c,h,_){super(),this.content=0,this.combinedData="",this.fg=c.fg,this.bg=c.bg,this.combinedData=h,this._width=_}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(c){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}r.JoinedCellData=b;let n=r.CharacterJoinerService=class Ii{constructor(c){this._bufferService=c,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new m.CellData}register(c){const h={id:this._nextCharacterJoinerId++,handler:c};return this._characterJoiners.push(h),h.id}deregister(c){for(let h=0;h<this._characterJoiners.length;h++)if(this._characterJoiners[h].id===c)return this._characterJoiners.splice(h,1),!0;return!1}getJoinedCharacters(c){if(this._characterJoiners.length===0)return[];const h=this._bufferService.buffer.lines.get(c);if(!h||h.length===0)return[];const _=[],S=h.translateToString(!0);let k=0,E=0,x=0,C=h.getFg(0),T=h.getBg(0);for(let L=0;L<h.getTrimmedLength();L++)if(h.loadCell(L,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==C||this._workCell.bg!==T){if(L-k>1){const R=this._getJoinedRanges(S,x,E,h,k);for(let M=0;M<R.length;M++)_.push(R[M])}k=L,x=E,C=this._workCell.fg,T=this._workCell.bg}E+=this._workCell.getChars().length||p.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-k>1){const L=this._getJoinedRanges(S,x,E,h,k);for(let R=0;R<L.length;R++)_.push(L[R])}return _}_getJoinedRanges(c,h,_,S,k){const E=c.substring(h,_);let x=[];try{x=this._characterJoiners[0].handler(E)}catch(C){console.error(C)}for(let C=1;C<this._characterJoiners.length;C++)try{const T=this._characterJoiners[C].handler(E);for(let L=0;L<T.length;L++)Ii._mergeRanges(x,T[L])}catch(T){console.error(T)}return this._stringRangesToCellRanges(x,S,k),x}_stringRangesToCellRanges(c,h,_){let S=0,k=!1,E=0,x=c[S];if(x){for(let C=_;C<this._bufferService.cols;C++){const T=h.getWidth(C),L=h.getString(C).length||p.WHITESPACE_CELL_CHAR.length;if(T!==0){if(!k&&x[0]<=E&&(x[0]=C,k=!0),x[1]<=E){if(x[1]=C,x=c[++S],!x)break;x[0]<=E?(x[0]=C,k=!0):k=!1}E+=L}}x&&(x[1]=this._bufferService.cols)}}static _mergeRanges(c,h){let _=!1;for(let S=0;S<c.length;S++){const k=c[S];if(_){if(h[1]<=k[0])return c[S-1][1]=h[1],c;if(h[1]<=k[1])return c[S-1][1]=Math.max(h[1],k[1]),c.splice(S,1),c;c.splice(S,1),S--}else{if(h[1]<=k[0])return c.splice(S,0,h),c;if(h[1]<=k[1])return k[0]=Math.min(h[0],k[0]),c;h[0]<k[1]&&(k[0]=Math.min(h[0],k[0]),_=!0)}}return _?c[c.length-1][1]=h[1]:c.push(h),c}};r.CharacterJoinerService=n=u([f(0,y.IBufferService)],n)},5114:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CoreBrowserService=void 0,r.CoreBrowserService=class{constructor(o,u){this._textarea=o,this.window=u,this._isFocused=!1,this._cachedIsFocused=void 0,this._textarea.addEventListener("focus",(()=>this._isFocused=!0)),this._textarea.addEventListener("blur",(()=>this._isFocused=!1))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask((()=>this._cachedIsFocused=void 0))),this._cachedIsFocused}}},8934:function(w,r,o){var u=this&&this.__decorate||function(y,b,n,d){var c,h=arguments.length,_=h<3?b:d===null?d=Object.getOwnPropertyDescriptor(b,n):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")_=Reflect.decorate(y,b,n,d);else for(var S=y.length-1;S>=0;S--)(c=y[S])&&(_=(h<3?c(_):h>3?c(b,n,_):c(b,n))||_);return h>3&&_&&Object.defineProperty(b,n,_),_},f=this&&this.__param||function(y,b){return function(n,d){b(n,d,y)}};Object.defineProperty(r,"__esModule",{value:!0}),r.MouseService=void 0;const a=o(4725),p=o(9806);let m=r.MouseService=class{constructor(y,b){this._renderService=y,this._charSizeService=b}getCoords(y,b,n,d,c){return(0,p.getCoords)(window,y,b,n,d,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,c)}getMouseReportCoords(y,b){const n=(0,p.getCoordsRelativeToElement)(window,y,b);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};r.MouseService=m=u([f(0,a.IRenderService),f(1,a.ICharSizeService)],m)},3230:function(w,r,o){var u=this&&this.__decorate||function(_,S,k,E){var x,C=arguments.length,T=C<3?S:E===null?E=Object.getOwnPropertyDescriptor(S,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(_,S,k,E);else for(var L=_.length-1;L>=0;L--)(x=_[L])&&(T=(C<3?x(T):C>3?x(S,k,T):x(S,k))||T);return C>3&&T&&Object.defineProperty(S,k,T),T},f=this&&this.__param||function(_,S){return function(k,E){S(k,E,_)}};Object.defineProperty(r,"__esModule",{value:!0}),r.RenderService=void 0;const a=o(3656),p=o(6193),m=o(5596),y=o(4725),b=o(8460),n=o(844),d=o(7226),c=o(2585);let h=r.RenderService=class extends n.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(_,S,k,E,x,C,T,L){if(super(),this._rowCount=_,this._charSizeService=E,this._renderer=this.register(new n.MutableDisposable),this._pausedResizeTask=new d.DebouncedIdleTask,this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this.register(new b.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new b.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new b.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new b.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new p.RenderDebouncer(T.window,((R,M)=>this._renderRows(R,M))),this.register(this._renderDebouncer),this._screenDprMonitor=new m.ScreenDprMonitor(T.window),this._screenDprMonitor.setListener((()=>this.handleDevicePixelRatioChange())),this.register(this._screenDprMonitor),this.register(C.onResize((()=>this._fullRefresh()))),this.register(C.buffers.onBufferActivate((()=>{var R;return(R=this._renderer.value)===null||R===void 0?void 0:R.clear()}))),this.register(k.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(x.onDecorationRegistered((()=>this._fullRefresh()))),this.register(x.onDecorationRemoved((()=>this._fullRefresh()))),this.register(k.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio"],(()=>{this.clear(),this.handleResize(C.cols,C.rows),this._fullRefresh()}))),this.register(k.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(C.buffer.y,C.buffer.y,!0)))),this.register((0,a.addDisposableDomListener)(T.window,"resize",(()=>this.handleDevicePixelRatioChange()))),this.register(L.onChangeColors((()=>this._fullRefresh()))),"IntersectionObserver"in T.window){const R=new T.window.IntersectionObserver((M=>this._handleIntersectionChange(M[M.length-1])),{threshold:0});R.observe(S),this.register({dispose:()=>R.disconnect()})}}_handleIntersectionChange(_){this._isPaused=_.isIntersecting===void 0?_.intersectionRatio===0:!_.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(_,S,k=!1){this._isPaused?this._needsFullRefresh=!0:(k||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(_,S,this._rowCount))}_renderRows(_,S){this._renderer.value&&(_=Math.min(_,this._rowCount-1),S=Math.min(S,this._rowCount-1),this._renderer.value.renderRows(_,S),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:_,end:S}),this._onRender.fire({start:_,end:S}),this._isNextRenderRedrawOnly=!0)}resize(_,S){this._rowCount=S,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(_){this._renderer.value=_,this._renderer.value.onRequestRedraw((S=>this.refreshRows(S.start,S.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh()}addRefreshCallback(_){return this._renderDebouncer.addRefreshCallback(_)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var _,S;this._renderer.value&&((S=(_=this._renderer.value).clearTextureAtlas)===null||S===void 0||S.call(_),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(_,S){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value.handleResize(_,S))):this._renderer.value.handleResize(_,S),this._fullRefresh())}handleCharSizeChanged(){var _;(_=this._renderer.value)===null||_===void 0||_.handleCharSizeChanged()}handleBlur(){var _;(_=this._renderer.value)===null||_===void 0||_.handleBlur()}handleFocus(){var _;(_=this._renderer.value)===null||_===void 0||_.handleFocus()}handleSelectionChanged(_,S,k){var E;this._selectionState.start=_,this._selectionState.end=S,this._selectionState.columnSelectMode=k,(E=this._renderer.value)===null||E===void 0||E.handleSelectionChanged(_,S,k)}handleCursorMove(){var _;(_=this._renderer.value)===null||_===void 0||_.handleCursorMove()}clear(){var _;(_=this._renderer.value)===null||_===void 0||_.clear()}};r.RenderService=h=u([f(2,c.IOptionsService),f(3,y.ICharSizeService),f(4,c.IDecorationService),f(5,c.IBufferService),f(6,y.ICoreBrowserService),f(7,y.IThemeService)],h)},9312:function(w,r,o){var u=this&&this.__decorate||function(x,C,T,L){var R,M=arguments.length,I=M<3?C:L===null?L=Object.getOwnPropertyDescriptor(C,T):L;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")I=Reflect.decorate(x,C,T,L);else for(var B=x.length-1;B>=0;B--)(R=x[B])&&(I=(M<3?R(I):M>3?R(C,T,I):R(C,T))||I);return M>3&&I&&Object.defineProperty(C,T,I),I},f=this&&this.__param||function(x,C){return function(T,L){C(T,L,x)}};Object.defineProperty(r,"__esModule",{value:!0}),r.SelectionService=void 0;const a=o(9806),p=o(9504),m=o(456),y=o(4725),b=o(8460),n=o(844),d=o(6114),c=o(4841),h=o(511),_=o(2585),S=" ",k=new RegExp(S,"g");let E=r.SelectionService=class extends n.Disposable{constructor(x,C,T,L,R,M,I,B,H){super(),this._element=x,this._screenElement=C,this._linkifier=T,this._bufferService=L,this._coreService=R,this._mouseService=M,this._optionsService=I,this._renderService=B,this._coreBrowserService=H,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new h.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new b.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new b.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new b.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new b.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=$=>this._handleMouseMove($),this._mouseUpListener=$=>this._handleMouseUp($),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim(($=>this._handleTrim($))),this.register(this._bufferService.buffers.onBufferActivate(($=>this._handleBufferActivate($)))),this.enable(),this._model=new m.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,n.toDisposable)((()=>{this._removeMouseDownListeners()})))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){const x=this._model.finalSelectionStart,C=this._model.finalSelectionEnd;return!(!x||!C||x[0]===C[0]&&x[1]===C[1])}get selectionText(){const x=this._model.finalSelectionStart,C=this._model.finalSelectionEnd;if(!x||!C)return"";const T=this._bufferService.buffer,L=[];if(this._activeSelectionMode===3){if(x[0]===C[0])return"";const R=x[0]<C[0]?x[0]:C[0],M=x[0]<C[0]?C[0]:x[0];for(let I=x[1];I<=C[1];I++){const B=T.translateBufferLineToString(I,!0,R,M);L.push(B)}}else{const R=x[1]===C[1]?C[0]:void 0;L.push(T.translateBufferLineToString(x[1],!0,x[0],R));for(let M=x[1]+1;M<=C[1]-1;M++){const I=T.lines.get(M),B=T.translateBufferLineToString(M,!0);I?.isWrapped?L[L.length-1]+=B:L.push(B)}if(x[1]!==C[1]){const M=T.lines.get(C[1]),I=T.translateBufferLineToString(C[1],!0,0,C[0]);M&&M.isWrapped?L[L.length-1]+=I:L.push(I)}}return L.map((R=>R.replace(k," "))).join(d.isWindows?`\r
13
13
  `:`
14
- `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(x){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),d.isLinux&&x&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(x){const C=this._getMouseBufferCoords(x),T=this._model.finalSelectionStart,L=this._model.finalSelectionEnd;return!!(T&&L&&C)&&this._areCoordsInSelection(C,T,L)}isCellInSelection(x,C){const T=this._model.finalSelectionStart,L=this._model.finalSelectionEnd;return!(!T||!L)&&this._areCoordsInSelection([x,C],T,L)}_areCoordsInSelection(x,C,T){return x[1]>C[1]&&x[1]<T[1]||C[1]===T[1]&&x[1]===C[1]&&x[0]>=C[0]&&x[0]<T[0]||C[1]<T[1]&&x[1]===T[1]&&x[0]<T[0]||C[1]<T[1]&&x[1]===C[1]&&x[0]>=C[0]}_selectWordAtCursor(x,C){var T,L;const R=(L=(T=this._linkifier.currentLink)===null||T===void 0?void 0:T.link)===null||L===void 0?void 0:L.range;if(R)return this._model.selectionStart=[R.start.x-1,R.start.y-1],this._model.selectionStartLength=(0,c.getRangeLength)(R,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const M=this._getMouseBufferCoords(x);return!!M&&(this._selectWordAt(M,C),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(x,C){this._model.clearSelection(),x=Math.max(x,0),C=Math.min(C,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,x],this._model.selectionEnd=[this._bufferService.cols,C],this.refresh(),this._onSelectionChange.fire()}_handleTrim(x){this._model.handleTrim(x)&&this.refresh()}_getMouseBufferCoords(x){const C=this._mouseService.getCoords(x,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(C)return C[0]--,C[1]--,C[1]+=this._bufferService.buffer.ydisp,C}_getMouseEventScrollAmount(x){let C=(0,a.getCoordsRelativeToElement)(this._coreBrowserService.window,x,this._screenElement)[1];const T=this._renderService.dimensions.css.canvas.height;return C>=0&&C<=T?0:(C>T&&(C-=T),C=Math.min(Math.max(C,-50),50),C/=50,C/Math.abs(C)+Math.round(14*C))}shouldForceSelection(x){return d.isMac?x.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:x.shiftKey}handleMouseDown(x){if(this._mouseDownTimeStamp=x.timeStamp,(x.button!==2||!this.hasSelection)&&x.button===0){if(!this._enabled){if(!this.shouldForceSelection(x))return;x.stopPropagation()}x.preventDefault(),this._dragScrollAmount=0,this._enabled&&x.shiftKey?this._handleIncrementalClick(x):x.detail===1?this._handleSingleClick(x):x.detail===2?this._handleDoubleClick(x):x.detail===3&&this._handleTripleClick(x),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval((()=>this._dragScroll()),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(x){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(x))}_handleSingleClick(x){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(x)?3:0,this._model.selectionStart=this._getMouseBufferCoords(x),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const C=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);C&&C.length!==this._model.selectionStart[0]&&C.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(x){this._selectWordAtCursor(x,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(x){const C=this._getMouseBufferCoords(x);C&&(this._activeSelectionMode=2,this._selectLineAt(C[1]))}shouldColumnSelect(x){return x.altKey&&!(d.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(x){if(x.stopImmediatePropagation(),!this._model.selectionStart)return;const C=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(x),!this._model.selectionEnd)return void this.refresh(!0);this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(x),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const T=this._bufferService.buffer;if(this._model.selectionEnd[1]<T.lines.length){const L=T.lines.get(this._model.selectionEnd[1]);L&&L.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]++}C&&C[0]===this._model.selectionEnd[0]&&C[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});const x=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(x.ydisp+this._bufferService.rows,x.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=x.ydisp),this.refresh()}}_handleMouseUp(x){const C=x.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&C<500&&x.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const T=this._mouseService.getCoords(x,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(T&&T[0]!==void 0&&T[1]!==void 0){const L=(0,p.moveToCellSequence)(T[0]-1,T[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(L,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const x=this._model.finalSelectionStart,C=this._model.finalSelectionEnd,T=!(!x||!C||x[0]===C[0]&&x[1]===C[1]);T?x&&C&&(this._oldSelectionStart&&this._oldSelectionEnd&&x[0]===this._oldSelectionStart[0]&&x[1]===this._oldSelectionStart[1]&&C[0]===this._oldSelectionEnd[0]&&C[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(x,C,T)):this._oldHasSelection&&this._fireOnSelectionChange(x,C,T)}_fireOnSelectionChange(x,C,T){this._oldSelectionStart=x,this._oldSelectionEnd=C,this._oldHasSelection=T,this._onSelectionChange.fire()}_handleBufferActivate(x){this.clearSelection(),this._trimListener.dispose(),this._trimListener=x.activeBuffer.lines.onTrim((C=>this._handleTrim(C)))}_convertViewportColToCharacterIndex(x,C){let T=C;for(let L=0;C>=L;L++){const R=x.loadCell(L,this._workCell).getChars().length;this._workCell.getWidth()===0?T--:R>1&&C!==L&&(T+=R-1)}return T}setSelection(x,C,T){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[x,C],this._model.selectionStartLength=T,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(x){this._isClickInSelection(x)||(this._selectWordAtCursor(x,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(x,C,T=!0,L=!0){if(x[0]>=this._bufferService.cols)return;const R=this._bufferService.buffer,M=R.lines.get(x[1]);if(!M)return;const I=R.translateBufferLineToString(x[1],!1);let B=this._convertViewportColToCharacterIndex(M,x[0]),H=B;const $=x[0]-B;let N=0,P=0,D=0,O=0;if(I.charAt(B)===" "){for(;B>0&&I.charAt(B-1)===" ";)B--;for(;H<I.length&&I.charAt(H+1)===" ";)H++}else{let U=x[0],z=x[0];M.getWidth(U)===0&&(N++,U--),M.getWidth(z)===2&&(P++,z++);const W=M.getString(z).length;for(W>1&&(O+=W-1,H+=W-1);U>0&&B>0&&!this._isCharWordSeparator(M.loadCell(U-1,this._workCell));){M.loadCell(U-1,this._workCell);const j=this._workCell.getChars().length;this._workCell.getWidth()===0?(N++,U--):j>1&&(D+=j-1,B-=j-1),B--,U--}for(;z<M.length&&H+1<I.length&&!this._isCharWordSeparator(M.loadCell(z+1,this._workCell));){M.loadCell(z+1,this._workCell);const j=this._workCell.getChars().length;this._workCell.getWidth()===2?(P++,z++):j>1&&(O+=j-1,H+=j-1),H++,z++}}H++;let q=B+$-N+D,K=Math.min(this._bufferService.cols,H-B+N+P-D-O);if(C||I.slice(B,H).trim()!==""){if(T&&q===0&&M.getCodePoint(0)!==32){const U=R.lines.get(x[1]-1);if(U&&M.isWrapped&&U.getCodePoint(this._bufferService.cols-1)!==32){const z=this._getWordAt([this._bufferService.cols-1,x[1]-1],!1,!0,!1);if(z){const W=this._bufferService.cols-z.start;q-=W,K+=W}}}if(L&&q+K===this._bufferService.cols&&M.getCodePoint(this._bufferService.cols-1)!==32){const U=R.lines.get(x[1]+1);if(U?.isWrapped&&U.getCodePoint(0)!==32){const z=this._getWordAt([0,x[1]+1],!1,!1,!0);z&&(K+=z.length)}}return{start:q,length:K}}}_selectWordAt(x,C){const T=this._getWordAt(x,C);if(T){for(;T.start<0;)T.start+=this._bufferService.cols,x[1]--;this._model.selectionStart=[T.start,x[1]],this._model.selectionStartLength=T.length}}_selectToWordAt(x){const C=this._getWordAt(x,!0);if(C){let T=x[1];for(;C.start<0;)C.start+=this._bufferService.cols,T--;if(!this._model.areSelectionValuesReversed())for(;C.start+C.length>this._bufferService.cols;)C.length-=this._bufferService.cols,T++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?C.start:C.start+C.length,T]}}_isCharWordSeparator(x){return x.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(x.getChars())>=0}_selectLineAt(x){const C=this._bufferService.buffer.getWrappedRangeForLine(x),T={start:{x:0,y:C.first},end:{x:this._bufferService.cols-1,y:C.last}};this._model.selectionStart=[0,C.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,c.getRangeLength)(T,this._bufferService.cols)}};i.SelectionService=E=u([f(3,_.IBufferService),f(4,_.ICoreService),f(5,y.IMouseService),f(6,_.IOptionsService),f(7,y.IRenderService),f(8,y.ICoreBrowserService)],E)},4725:(w,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.IThemeService=i.ICharacterJoinerService=i.ISelectionService=i.IRenderService=i.IMouseService=i.ICoreBrowserService=i.ICharSizeService=void 0;const u=o(8343);i.ICharSizeService=(0,u.createDecorator)("CharSizeService"),i.ICoreBrowserService=(0,u.createDecorator)("CoreBrowserService"),i.IMouseService=(0,u.createDecorator)("MouseService"),i.IRenderService=(0,u.createDecorator)("RenderService"),i.ISelectionService=(0,u.createDecorator)("SelectionService"),i.ICharacterJoinerService=(0,u.createDecorator)("CharacterJoinerService"),i.IThemeService=(0,u.createDecorator)("ThemeService")},6731:function(w,i,o){var u=this&&this.__decorate||function(E,x,C,T){var L,R=arguments.length,M=R<3?x:T===null?T=Object.getOwnPropertyDescriptor(x,C):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")M=Reflect.decorate(E,x,C,T);else for(var I=E.length-1;I>=0;I--)(L=E[I])&&(M=(R<3?L(M):R>3?L(x,C,M):L(x,C))||M);return R>3&&M&&Object.defineProperty(x,C,M),M},f=this&&this.__param||function(E,x){return function(C,T){x(C,T,E)}};Object.defineProperty(i,"__esModule",{value:!0}),i.ThemeService=i.DEFAULT_ANSI_COLORS=void 0;const a=o(7239),p=o(8055),m=o(8460),y=o(844),b=o(2585),n=p.css.toColor("#ffffff"),d=p.css.toColor("#000000"),c=p.css.toColor("#ffffff"),h=p.css.toColor("#000000"),_={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};i.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const E=[p.css.toColor("#2e3436"),p.css.toColor("#cc0000"),p.css.toColor("#4e9a06"),p.css.toColor("#c4a000"),p.css.toColor("#3465a4"),p.css.toColor("#75507b"),p.css.toColor("#06989a"),p.css.toColor("#d3d7cf"),p.css.toColor("#555753"),p.css.toColor("#ef2929"),p.css.toColor("#8ae234"),p.css.toColor("#fce94f"),p.css.toColor("#729fcf"),p.css.toColor("#ad7fa8"),p.css.toColor("#34e2e2"),p.css.toColor("#eeeeec")],x=[0,95,135,175,215,255];for(let C=0;C<216;C++){const T=x[C/36%6|0],L=x[C/6%6|0],R=x[C%6];E.push({css:p.channels.toCss(T,L,R),rgba:p.channels.toRgba(T,L,R)})}for(let C=0;C<24;C++){const T=8+10*C;E.push({css:p.channels.toCss(T,T,T),rgba:p.channels.toRgba(T,T,T)})}return E})());let S=i.ThemeService=class extends y.Disposable{get colors(){return this._colors}constructor(E){super(),this._optionsService=E,this._contrastCache=new a.ColorContrastCache,this._halfContrastCache=new a.ColorContrastCache,this._onChangeColors=this.register(new m.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:n,background:d,cursor:c,cursorAccent:h,selectionForeground:void 0,selectionBackgroundTransparent:_,selectionBackgroundOpaque:p.color.blend(d,_),selectionInactiveBackgroundTransparent:_,selectionInactiveBackgroundOpaque:p.color.blend(d,_),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(E={}){const x=this._colors;if(x.foreground=k(E.foreground,n),x.background=k(E.background,d),x.cursor=k(E.cursor,c),x.cursorAccent=k(E.cursorAccent,h),x.selectionBackgroundTransparent=k(E.selectionBackground,_),x.selectionBackgroundOpaque=p.color.blend(x.background,x.selectionBackgroundTransparent),x.selectionInactiveBackgroundTransparent=k(E.selectionInactiveBackground,x.selectionBackgroundTransparent),x.selectionInactiveBackgroundOpaque=p.color.blend(x.background,x.selectionInactiveBackgroundTransparent),x.selectionForeground=E.selectionForeground?k(E.selectionForeground,p.NULL_COLOR):void 0,x.selectionForeground===p.NULL_COLOR&&(x.selectionForeground=void 0),p.color.isOpaque(x.selectionBackgroundTransparent)&&(x.selectionBackgroundTransparent=p.color.opacity(x.selectionBackgroundTransparent,.3)),p.color.isOpaque(x.selectionInactiveBackgroundTransparent)&&(x.selectionInactiveBackgroundTransparent=p.color.opacity(x.selectionInactiveBackgroundTransparent,.3)),x.ansi=i.DEFAULT_ANSI_COLORS.slice(),x.ansi[0]=k(E.black,i.DEFAULT_ANSI_COLORS[0]),x.ansi[1]=k(E.red,i.DEFAULT_ANSI_COLORS[1]),x.ansi[2]=k(E.green,i.DEFAULT_ANSI_COLORS[2]),x.ansi[3]=k(E.yellow,i.DEFAULT_ANSI_COLORS[3]),x.ansi[4]=k(E.blue,i.DEFAULT_ANSI_COLORS[4]),x.ansi[5]=k(E.magenta,i.DEFAULT_ANSI_COLORS[5]),x.ansi[6]=k(E.cyan,i.DEFAULT_ANSI_COLORS[6]),x.ansi[7]=k(E.white,i.DEFAULT_ANSI_COLORS[7]),x.ansi[8]=k(E.brightBlack,i.DEFAULT_ANSI_COLORS[8]),x.ansi[9]=k(E.brightRed,i.DEFAULT_ANSI_COLORS[9]),x.ansi[10]=k(E.brightGreen,i.DEFAULT_ANSI_COLORS[10]),x.ansi[11]=k(E.brightYellow,i.DEFAULT_ANSI_COLORS[11]),x.ansi[12]=k(E.brightBlue,i.DEFAULT_ANSI_COLORS[12]),x.ansi[13]=k(E.brightMagenta,i.DEFAULT_ANSI_COLORS[13]),x.ansi[14]=k(E.brightCyan,i.DEFAULT_ANSI_COLORS[14]),x.ansi[15]=k(E.brightWhite,i.DEFAULT_ANSI_COLORS[15]),E.extendedAnsi){const C=Math.min(x.ansi.length-16,E.extendedAnsi.length);for(let T=0;T<C;T++)x.ansi[T+16]=k(E.extendedAnsi[T],i.DEFAULT_ANSI_COLORS[T+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(E){this._restoreColor(E),this._onChangeColors.fire(this.colors)}_restoreColor(E){if(E!==void 0)switch(E){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[E]=this._restoreColors.ansi[E]}else for(let x=0;x<this._restoreColors.ansi.length;++x)this._colors.ansi[x]=this._restoreColors.ansi[x]}modifyColors(E){E(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function k(E,x){if(E!==void 0)try{return p.css.toColor(E)}catch{}return x}i.ThemeService=S=u([f(0,b.IOptionsService)],S)},6349:(w,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CircularList=void 0;const u=o(8460),f=o(844);class a extends f.Disposable{constructor(m){super(),this._maxLength=m,this.onDeleteEmitter=this.register(new u.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new u.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new u.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(m){if(this._maxLength===m)return;const y=new Array(m);for(let b=0;b<Math.min(m,this.length);b++)y[b]=this._array[this._getCyclicIndex(b)];this._array=y,this._maxLength=m,this._startIndex=0}get length(){return this._length}set length(m){if(m>this._length)for(let y=this._length;y<m;y++)this._array[y]=void 0;this._length=m}get(m){return this._array[this._getCyclicIndex(m)]}set(m,y){this._array[this._getCyclicIndex(m)]=y}push(m){this._array[this._getCyclicIndex(this._length)]=m,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(m,y,...b){if(y){for(let n=m;n<this._length-y;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+y)];this._length-=y,this.onDeleteEmitter.fire({index:m,amount:y})}for(let n=this._length-1;n>=m;n--)this._array[this._getCyclicIndex(n+b.length)]=this._array[this._getCyclicIndex(n)];for(let n=0;n<b.length;n++)this._array[this._getCyclicIndex(m+n)]=b[n];if(b.length&&this.onInsertEmitter.fire({index:m,amount:b.length}),this._length+b.length>this._maxLength){const n=this._length+b.length-this._maxLength;this._startIndex+=n,this._length=this._maxLength,this.onTrimEmitter.fire(n)}else this._length+=b.length}trimStart(m){m>this._length&&(m=this._length),this._startIndex+=m,this._length-=m,this.onTrimEmitter.fire(m)}shiftElements(m,y,b){if(!(y<=0)){if(m<0||m>=this._length)throw new Error("start argument out of range");if(m+b<0)throw new Error("Cannot shift elements in list beyond index 0");if(b>0){for(let d=y-1;d>=0;d--)this.set(m+d+b,this.get(m+d));const n=m+y+b-this._length;if(n>0)for(this._length+=n;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let n=0;n<y;n++)this.set(m+n+b,this.get(m+n))}}_getCyclicIndex(m){return(this._startIndex+m)%this._maxLength}}i.CircularList=a},1439:(w,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.clone=void 0,i.clone=function o(u,f=5){if(typeof u!="object")return u;const a=Array.isArray(u)?[]:{};for(const p in u)a[p]=f<=1?u[p]:u[p]&&o(u[p],f-1);return a}},8055:(w,i,o)=>{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 u=o(6114);let f=0,a=0,p=0,m=0;var y,b,n,d,c;function h(S){const k=S.toString(16);return k.length<2?"0"+k:k}function _(S,k){return S<k?(k+.05)/(S+.05):(S+.05)/(k+.05)}i.NULL_COLOR={css:"#00000000",rgba:0},(function(S){S.toCss=function(k,E,x,C){return C!==void 0?`#${h(k)}${h(E)}${h(x)}${h(C)}`:`#${h(k)}${h(E)}${h(x)}`},S.toRgba=function(k,E,x,C=255){return(k<<24|E<<16|x<<8|C)>>>0}})(y||(i.channels=y={})),(function(S){function k(E,x){return m=Math.round(255*x),[f,a,p]=c.toChannels(E.rgba),{css:y.toCss(f,a,p,m),rgba:y.toRgba(f,a,p,m)}}S.blend=function(E,x){if(m=(255&x.rgba)/255,m===1)return{css:x.css,rgba:x.rgba};const C=x.rgba>>24&255,T=x.rgba>>16&255,L=x.rgba>>8&255,R=E.rgba>>24&255,M=E.rgba>>16&255,I=E.rgba>>8&255;return f=R+Math.round((C-R)*m),a=M+Math.round((T-M)*m),p=I+Math.round((L-I)*m),{css:y.toCss(f,a,p),rgba:y.toRgba(f,a,p)}},S.isOpaque=function(E){return(255&E.rgba)==255},S.ensureContrastRatio=function(E,x,C){const T=c.ensureContrastRatio(E.rgba,x.rgba,C);if(T)return c.toColor(T>>24&255,T>>16&255,T>>8&255)},S.opaque=function(E){const x=(255|E.rgba)>>>0;return[f,a,p]=c.toChannels(x),{css:y.toCss(f,a,p),rgba:x}},S.opacity=k,S.multiplyOpacity=function(E,x){return m=255&E.rgba,k(E,m*x/255)},S.toColorRGB=function(E){return[E.rgba>>24&255,E.rgba>>16&255,E.rgba>>8&255]}})(b||(i.color=b={})),(function(S){let k,E;if(!u.isNode){const x=document.createElement("canvas");x.width=1,x.height=1;const C=x.getContext("2d",{willReadFrequently:!0});C&&(k=C,k.globalCompositeOperation="copy",E=k.createLinearGradient(0,0,1,1))}S.toColor=function(x){if(x.match(/#[\da-f]{3,8}/i))switch(x.length){case 4:return f=parseInt(x.slice(1,2).repeat(2),16),a=parseInt(x.slice(2,3).repeat(2),16),p=parseInt(x.slice(3,4).repeat(2),16),c.toColor(f,a,p);case 5:return f=parseInt(x.slice(1,2).repeat(2),16),a=parseInt(x.slice(2,3).repeat(2),16),p=parseInt(x.slice(3,4).repeat(2),16),m=parseInt(x.slice(4,5).repeat(2),16),c.toColor(f,a,p,m);case 7:return{css:x,rgba:(parseInt(x.slice(1),16)<<8|255)>>>0};case 9:return{css:x,rgba:parseInt(x.slice(1),16)>>>0}}const C=x.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(C)return f=parseInt(C[1]),a=parseInt(C[2]),p=parseInt(C[3]),m=Math.round(255*(C[5]===void 0?1:parseFloat(C[5]))),c.toColor(f,a,p,m);if(!k||!E)throw new Error("css.toColor: Unsupported css format");if(k.fillStyle=E,k.fillStyle=x,typeof k.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(k.fillRect(0,0,1,1),[f,a,p,m]=k.getImageData(0,0,1,1).data,m!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:y.toRgba(f,a,p,m),css:x}}})(n||(i.css=n={})),(function(S){function k(E,x,C){const T=E/255,L=x/255,R=C/255;return .2126*(T<=.03928?T/12.92:Math.pow((T+.055)/1.055,2.4))+.7152*(L<=.03928?L/12.92:Math.pow((L+.055)/1.055,2.4))+.0722*(R<=.03928?R/12.92:Math.pow((R+.055)/1.055,2.4))}S.relativeLuminance=function(E){return k(E>>16&255,E>>8&255,255&E)},S.relativeLuminance2=k})(d||(i.rgb=d={})),(function(S){function k(x,C,T){const L=x>>24&255,R=x>>16&255,M=x>>8&255;let I=C>>24&255,B=C>>16&255,H=C>>8&255,$=_(d.relativeLuminance2(I,B,H),d.relativeLuminance2(L,R,M));for(;$<T&&(I>0||B>0||H>0);)I-=Math.max(0,Math.ceil(.1*I)),B-=Math.max(0,Math.ceil(.1*B)),H-=Math.max(0,Math.ceil(.1*H)),$=_(d.relativeLuminance2(I,B,H),d.relativeLuminance2(L,R,M));return(I<<24|B<<16|H<<8|255)>>>0}function E(x,C,T){const L=x>>24&255,R=x>>16&255,M=x>>8&255;let I=C>>24&255,B=C>>16&255,H=C>>8&255,$=_(d.relativeLuminance2(I,B,H),d.relativeLuminance2(L,R,M));for(;$<T&&(I<255||B<255||H<255);)I=Math.min(255,I+Math.ceil(.1*(255-I))),B=Math.min(255,B+Math.ceil(.1*(255-B))),H=Math.min(255,H+Math.ceil(.1*(255-H))),$=_(d.relativeLuminance2(I,B,H),d.relativeLuminance2(L,R,M));return(I<<24|B<<16|H<<8|255)>>>0}S.ensureContrastRatio=function(x,C,T){const L=d.relativeLuminance(x>>8),R=d.relativeLuminance(C>>8);if(_(L,R)<T){if(R<L){const B=k(x,C,T),H=_(L,d.relativeLuminance(B>>8));if(H<T){const $=E(x,C,T);return H>_(L,d.relativeLuminance($>>8))?B:$}return B}const M=E(x,C,T),I=_(L,d.relativeLuminance(M>>8));if(I<T){const B=k(x,C,T);return I>_(L,d.relativeLuminance(B>>8))?M:B}return M}},S.reduceLuminance=k,S.increaseLuminance=E,S.toChannels=function(x){return[x>>24&255,x>>16&255,x>>8&255,255&x]},S.toColor=function(x,C,T,L){return{css:y.toCss(x,C,T,L),rgba:y.toRgba(x,C,T,L)}}})(c||(i.rgba=c={})),i.toPaddedHex=h,i.contrastRatio=_},8969:(w,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CoreTerminal=void 0;const u=o(844),f=o(2585),a=o(4348),p=o(7866),m=o(744),y=o(7302),b=o(6975),n=o(8460),d=o(1753),c=o(1480),h=o(7994),_=o(9282),S=o(5435),k=o(5981),E=o(2660);let x=!1;class C extends u.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new n.EventEmitter),this._onScroll.event((L=>{var R;(R=this._onScrollApi)===null||R===void 0||R.fire(L.position)}))),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(L){for(const R in L)this.optionsService.options[R]=L[R]}constructor(L){super(),this._windowsWrappingHeuristics=this.register(new u.MutableDisposable),this._onBinary=this.register(new n.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new n.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new n.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new n.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new n.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new n.EventEmitter),this._instantiationService=new a.InstantiationService,this.optionsService=this.register(new y.OptionsService(L)),this._instantiationService.setService(f.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(m.BufferService)),this._instantiationService.setService(f.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(p.LogService)),this._instantiationService.setService(f.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(b.CoreService)),this._instantiationService.setService(f.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(d.CoreMouseService)),this._instantiationService.setService(f.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(c.UnicodeService)),this._instantiationService.setService(f.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(h.CharsetService),this._instantiationService.setService(f.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(E.OscLinkService),this._instantiationService.setService(f.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new S.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,n.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,n.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,n.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,n.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom((()=>this.scrollToBottom()))),this.register(this.coreService.onUserInput((()=>this._writeBuffer.handleUserInput()))),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],(()=>this._handleWindowsPtyOptionChange()))),this.register(this._bufferService.onScroll((R=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this.register(this._inputHandler.onScroll((R=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new k.WriteBuffer(((R,M)=>this._inputHandler.parse(R,M)))),this.register((0,n.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(L,R){this._writeBuffer.write(L,R)}writeSync(L,R){this._logService.logLevel<=f.LogLevelEnum.WARN&&!x&&(this._logService.warn("writeSync is unreliable and will be removed soon."),x=!0),this._writeBuffer.writeSync(L,R)}resize(L,R){isNaN(L)||isNaN(R)||(L=Math.max(L,m.MINIMUM_COLS),R=Math.max(R,m.MINIMUM_ROWS),this._bufferService.resize(L,R))}scroll(L,R=!1){this._bufferService.scroll(L,R)}scrollLines(L,R,M){this._bufferService.scrollLines(L,R,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 R=L-this._bufferService.buffer.ydisp;R!==0&&this.scrollLines(R)}registerEscHandler(L,R){return this._inputHandler.registerEscHandler(L,R)}registerDcsHandler(L,R){return this._inputHandler.registerDcsHandler(L,R)}registerCsiHandler(L,R){return this._inputHandler.registerCsiHandler(L,R)}registerOscHandler(L,R){return this._inputHandler.registerOscHandler(L,R)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let L=!1;const R=this.optionsService.rawOptions.windowsPty;R&&R.buildNumber!==void 0&&R.buildNumber!==void 0?L=R.backend==="conpty"&&R.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(L=!0),L?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const L=[];L.push(this.onLineFeed(_.updateWindowsModeWrappedState.bind(null,this._bufferService))),L.push(this.registerCsiHandler({final:"H"},(()=>((0,_.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,u.toDisposable)((()=>{for(const R of L)R.dispose()}))}}}i.CoreTerminal=C},8460:(w,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=o=>(this._listeners.push(o),{dispose:()=>{if(!this._disposed){for(let u=0;u<this._listeners.length;u++)if(this._listeners[u]===o)return void this._listeners.splice(u,1)}}})),this._event}fire(o,u){const f=[];for(let a=0;a<this._listeners.length;a++)f.push(this._listeners[a]);for(let a=0;a<f.length;a++)f[a].call(void 0,o,u)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},i.forwardEvent=function(o,u){return o((f=>u.fire(f)))}},5435:function(w,i,o){var u=this&&this.__decorate||function($,N,P,D){var O,q=arguments.length,K=q<3?N:D===null?D=Object.getOwnPropertyDescriptor(N,P):D;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")K=Reflect.decorate($,N,P,D);else for(var U=$.length-1;U>=0;U--)(O=$[U])&&(K=(q<3?O(K):q>3?O(N,P,K):O(N,P))||K);return q>3&&K&&Object.defineProperty(N,P,K),K},f=this&&this.__param||function($,N){return function(P,D){N(P,D,$)}};Object.defineProperty(i,"__esModule",{value:!0}),i.InputHandler=i.WindowsOptionsReportType=void 0;const a=o(2584),p=o(7116),m=o(2015),y=o(844),b=o(482),n=o(8437),d=o(8460),c=o(643),h=o(511),_=o(3734),S=o(2585),k=o(6242),E=o(6351),x=o(5941),C={"(":0,")":1,"*":2,"+":3,"-":1,".":2},T=131072;function L($,N){if($>24)return N.setWinLines||!1;switch($){case 1:return!!N.restoreWin;case 2:return!!N.minimizeWin;case 3:return!!N.setWinPosition;case 4:return!!N.setWinSizePixels;case 5:return!!N.raiseWin;case 6:return!!N.lowerWin;case 7:return!!N.refreshWin;case 8:return!!N.setWinSizeChars;case 9:return!!N.maximizeWin;case 10:return!!N.fullscreenWin;case 11:return!!N.getWinState;case 13:return!!N.getWinPosition;case 14:return!!N.getWinSizePixels;case 15:return!!N.getScreenSizePixels;case 16:return!!N.getCellSizePixels;case 18:return!!N.getWinSizeChars;case 19:return!!N.getScreenSizeChars;case 20:return!!N.getIconTitle;case 21:return!!N.getWinTitle;case 22:return!!N.pushTitle;case 23:return!!N.popTitle;case 24:return!!N.setWinLines}return!1}var R;(function($){$[$.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",$[$.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(R||(i.WindowsOptionsReportType=R={}));let M=0;class I extends y.Disposable{getAttrData(){return this._curAttrData}constructor(N,P,D,O,q,K,U,z,W=new m.EscapeSequenceParser){super(),this._bufferService=N,this._charsetService=P,this._coreService=D,this._logService=O,this._optionsService=q,this._oscLinkService=K,this._coreMouseService=U,this._unicodeService=z,this._parser=W,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new b.StringToUtf32,this._utf8Decoder=new b.Utf8ToUtf32,this._workCell=new h.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=n.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=n.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new d.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new d.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new d.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new d.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new d.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new d.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new d.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new d.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new d.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new d.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new d.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new d.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new d.EventEmitter),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this.register(this._parser),this._dirtyRowTracker=new B(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((j=>this._activeBuffer=j.activeBuffer))),this._parser.setCsiHandlerFallback(((j,F)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(j),params:F.toArray()})})),this._parser.setEscHandlerFallback((j=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(j)})})),this._parser.setExecuteHandlerFallback((j=>{this._logService.debug("Unknown EXECUTE code: ",{code:j})})),this._parser.setOscHandlerFallback(((j,F,X)=>{this._logService.debug("Unknown OSC code: ",{identifier:j,action:F,data:X})})),this._parser.setDcsHandlerFallback(((j,F,X)=>{F==="HOOK"&&(X=X.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(j),action:F,payload:X})})),this._parser.setPrintHandler(((j,F,X)=>this.print(j,F,X))),this._parser.registerCsiHandler({final:"@"},(j=>this.insertChars(j))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(j=>this.scrollLeft(j))),this._parser.registerCsiHandler({final:"A"},(j=>this.cursorUp(j))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(j=>this.scrollRight(j))),this._parser.registerCsiHandler({final:"B"},(j=>this.cursorDown(j))),this._parser.registerCsiHandler({final:"C"},(j=>this.cursorForward(j))),this._parser.registerCsiHandler({final:"D"},(j=>this.cursorBackward(j))),this._parser.registerCsiHandler({final:"E"},(j=>this.cursorNextLine(j))),this._parser.registerCsiHandler({final:"F"},(j=>this.cursorPrecedingLine(j))),this._parser.registerCsiHandler({final:"G"},(j=>this.cursorCharAbsolute(j))),this._parser.registerCsiHandler({final:"H"},(j=>this.cursorPosition(j))),this._parser.registerCsiHandler({final:"I"},(j=>this.cursorForwardTab(j))),this._parser.registerCsiHandler({final:"J"},(j=>this.eraseInDisplay(j,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(j=>this.eraseInDisplay(j,!0))),this._parser.registerCsiHandler({final:"K"},(j=>this.eraseInLine(j,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(j=>this.eraseInLine(j,!0))),this._parser.registerCsiHandler({final:"L"},(j=>this.insertLines(j))),this._parser.registerCsiHandler({final:"M"},(j=>this.deleteLines(j))),this._parser.registerCsiHandler({final:"P"},(j=>this.deleteChars(j))),this._parser.registerCsiHandler({final:"S"},(j=>this.scrollUp(j))),this._parser.registerCsiHandler({final:"T"},(j=>this.scrollDown(j))),this._parser.registerCsiHandler({final:"X"},(j=>this.eraseChars(j))),this._parser.registerCsiHandler({final:"Z"},(j=>this.cursorBackwardTab(j))),this._parser.registerCsiHandler({final:"`"},(j=>this.charPosAbsolute(j))),this._parser.registerCsiHandler({final:"a"},(j=>this.hPositionRelative(j))),this._parser.registerCsiHandler({final:"b"},(j=>this.repeatPrecedingCharacter(j))),this._parser.registerCsiHandler({final:"c"},(j=>this.sendDeviceAttributesPrimary(j))),this._parser.registerCsiHandler({prefix:">",final:"c"},(j=>this.sendDeviceAttributesSecondary(j))),this._parser.registerCsiHandler({final:"d"},(j=>this.linePosAbsolute(j))),this._parser.registerCsiHandler({final:"e"},(j=>this.vPositionRelative(j))),this._parser.registerCsiHandler({final:"f"},(j=>this.hVPosition(j))),this._parser.registerCsiHandler({final:"g"},(j=>this.tabClear(j))),this._parser.registerCsiHandler({final:"h"},(j=>this.setMode(j))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(j=>this.setModePrivate(j))),this._parser.registerCsiHandler({final:"l"},(j=>this.resetMode(j))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(j=>this.resetModePrivate(j))),this._parser.registerCsiHandler({final:"m"},(j=>this.charAttributes(j))),this._parser.registerCsiHandler({final:"n"},(j=>this.deviceStatus(j))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(j=>this.deviceStatusPrivate(j))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(j=>this.softReset(j))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(j=>this.setCursorStyle(j))),this._parser.registerCsiHandler({final:"r"},(j=>this.setScrollRegion(j))),this._parser.registerCsiHandler({final:"s"},(j=>this.saveCursor(j))),this._parser.registerCsiHandler({final:"t"},(j=>this.windowOptions(j))),this._parser.registerCsiHandler({final:"u"},(j=>this.restoreCursor(j))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(j=>this.insertColumns(j))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(j=>this.deleteColumns(j))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(j=>this.selectProtected(j))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(j=>this.requestMode(j,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(j=>this.requestMode(j,!1))),this._parser.setExecuteHandler(a.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(a.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(a.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(a.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(a.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(a.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(a.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(a.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(a.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(a.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(a.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(a.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new k.OscHandler((j=>(this.setTitle(j),this.setIconName(j),!0)))),this._parser.registerOscHandler(1,new k.OscHandler((j=>this.setIconName(j)))),this._parser.registerOscHandler(2,new k.OscHandler((j=>this.setTitle(j)))),this._parser.registerOscHandler(4,new k.OscHandler((j=>this.setOrReportIndexedColor(j)))),this._parser.registerOscHandler(8,new k.OscHandler((j=>this.setHyperlink(j)))),this._parser.registerOscHandler(10,new k.OscHandler((j=>this.setOrReportFgColor(j)))),this._parser.registerOscHandler(11,new k.OscHandler((j=>this.setOrReportBgColor(j)))),this._parser.registerOscHandler(12,new k.OscHandler((j=>this.setOrReportCursorColor(j)))),this._parser.registerOscHandler(104,new k.OscHandler((j=>this.restoreIndexedColor(j)))),this._parser.registerOscHandler(110,new k.OscHandler((j=>this.restoreFgColor(j)))),this._parser.registerOscHandler(111,new k.OscHandler((j=>this.restoreBgColor(j)))),this._parser.registerOscHandler(112,new k.OscHandler((j=>this.restoreCursorColor(j)))),this._parser.registerEscHandler({final:"7"},(()=>this.saveCursor())),this._parser.registerEscHandler({final:"8"},(()=>this.restoreCursor())),this._parser.registerEscHandler({final:"D"},(()=>this.index())),this._parser.registerEscHandler({final:"E"},(()=>this.nextLine())),this._parser.registerEscHandler({final:"H"},(()=>this.tabSet())),this._parser.registerEscHandler({final:"M"},(()=>this.reverseIndex())),this._parser.registerEscHandler({final:"="},(()=>this.keypadApplicationMode())),this._parser.registerEscHandler({final:">"},(()=>this.keypadNumericMode())),this._parser.registerEscHandler({final:"c"},(()=>this.fullReset())),this._parser.registerEscHandler({final:"n"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"o"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"|"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"}"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"~"},(()=>this.setgLevel(1))),this._parser.registerEscHandler({intermediates:"%",final:"@"},(()=>this.selectDefaultCharset())),this._parser.registerEscHandler({intermediates:"%",final:"G"},(()=>this.selectDefaultCharset()));for(const j in p.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:j},(()=>this.selectCharset("("+j))),this._parser.registerEscHandler({intermediates:")",final:j},(()=>this.selectCharset(")"+j))),this._parser.registerEscHandler({intermediates:"*",final:j},(()=>this.selectCharset("*"+j))),this._parser.registerEscHandler({intermediates:"+",final:j},(()=>this.selectCharset("+"+j))),this._parser.registerEscHandler({intermediates:"-",final:j},(()=>this.selectCharset("-"+j))),this._parser.registerEscHandler({intermediates:".",final:j},(()=>this.selectCharset("."+j))),this._parser.registerEscHandler({intermediates:"/",final:j},(()=>this.selectCharset("/"+j)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((j=>(this._logService.error("Parsing error: ",j),j))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new E.DcsHandler(((j,F)=>this.requestStatusString(j,F))))}_preserveStack(N,P,D,O){this._parseStack.paused=!0,this._parseStack.cursorStartX=N,this._parseStack.cursorStartY=P,this._parseStack.decodedLength=D,this._parseStack.position=O}_logSlowResolvingAsync(N){this._logService.logLevel<=S.LogLevelEnum.WARN&&Promise.race([N,new Promise(((P,D)=>setTimeout((()=>D("#SLOW_TIMEOUT")),5e3)))]).catch((P=>{if(P!=="#SLOW_TIMEOUT")throw P;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(N,P){let D,O=this._activeBuffer.x,q=this._activeBuffer.y,K=0;const U=this._parseStack.paused;if(U){if(D=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,P))return this._logSlowResolvingAsync(D),D;O=this._parseStack.cursorStartX,q=this._parseStack.cursorStartY,this._parseStack.paused=!1,N.length>T&&(K=this._parseStack.position+T)}if(this._logService.logLevel<=S.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof N=="string"?` "${N}"`:` "${Array.prototype.map.call(N,(z=>String.fromCharCode(z))).join("")}"`),typeof N=="string"?N.split("").map((z=>z.charCodeAt(0))):N),this._parseBuffer.length<N.length&&this._parseBuffer.length<T&&(this._parseBuffer=new Uint32Array(Math.min(N.length,T))),U||this._dirtyRowTracker.clearRange(),N.length>T)for(let z=K;z<N.length;z+=T){const W=z+T<N.length?z+T:N.length,j=typeof N=="string"?this._stringDecoder.decode(N.substring(z,W),this._parseBuffer):this._utf8Decoder.decode(N.subarray(z,W),this._parseBuffer);if(D=this._parser.parse(this._parseBuffer,j))return this._preserveStack(O,q,j,z),this._logSlowResolvingAsync(D),D}else if(!U){const z=typeof N=="string"?this._stringDecoder.decode(N,this._parseBuffer):this._utf8Decoder.decode(N,this._parseBuffer);if(D=this._parser.parse(this._parseBuffer,z))return this._preserveStack(O,q,z,0),this._logSlowResolvingAsync(D),D}this._activeBuffer.x===O&&this._activeBuffer.y===q||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowTracker.start,this._dirtyRowTracker.end)}print(N,P,D){let O,q;const K=this._charsetService.charset,U=this._optionsService.rawOptions.screenReaderMode,z=this._bufferService.cols,W=this._coreService.decPrivateModes.wraparound,j=this._coreService.modes.insertMode,F=this._curAttrData;let X=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&D-P>0&&X.getWidth(this._activeBuffer.x-1)===2&&X.setCellFromCodePoint(this._activeBuffer.x-1,0,1,F.fg,F.bg,F.extended);for(let Y=P;Y<D;++Y){if(O=N[Y],q=this._unicodeService.wcwidth(O),O<127&&K){const ee=K[String.fromCharCode(O)];ee&&(O=ee.charCodeAt(0))}if(U&&this._onA11yChar.fire((0,b.stringFromCodePoint)(O)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),q||!this._activeBuffer.x){if(this._activeBuffer.x+q-1>=z){if(W){for(;this._activeBuffer.x<z;)X.setCellFromCodePoint(this._activeBuffer.x++,0,1,F.fg,F.bg,F.extended);this._activeBuffer.x=0,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),X=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)}else if(this._activeBuffer.x=z-1,q===2)continue}if(j&&(X.insertCells(this._activeBuffer.x,q,this._activeBuffer.getNullCell(F),F),X.getWidth(z-1)===2&&X.setCellFromCodePoint(z-1,c.NULL_CELL_CODE,c.NULL_CELL_WIDTH,F.fg,F.bg,F.extended)),X.setCellFromCodePoint(this._activeBuffer.x++,O,q,F.fg,F.bg,F.extended),q>0)for(;--q;)X.setCellFromCodePoint(this._activeBuffer.x++,0,0,F.fg,F.bg,F.extended)}else X.getWidth(this._activeBuffer.x-1)?X.addCodepointToCell(this._activeBuffer.x-1,O):X.addCodepointToCell(this._activeBuffer.x-2,O)}D-P>0&&(X.loadCell(this._activeBuffer.x-1,this._workCell),this._workCell.getWidth()===2||this._workCell.getCode()>65535?this._parser.precedingCodepoint=0:this._workCell.isCombined()?this._parser.precedingCodepoint=this._workCell.getChars().charCodeAt(0):this._parser.precedingCodepoint=this._workCell.content),this._activeBuffer.x<z&&D-P>0&&X.getWidth(this._activeBuffer.x)===0&&!X.hasContent(this._activeBuffer.x)&&X.setCellFromCodePoint(this._activeBuffer.x,0,1,F.fg,F.bg,F.extended),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(N,P){return N.final!=="t"||N.prefix||N.intermediates?this._parser.registerCsiHandler(N,P):this._parser.registerCsiHandler(N,(D=>!L(D.params[0],this._optionsService.rawOptions.windowOptions)||P(D)))}registerDcsHandler(N,P){return this._parser.registerDcsHandler(N,new E.DcsHandler(P))}registerEscHandler(N,P){return this._parser.registerEscHandler(N,P)}registerOscHandler(N,P){return this._parser.registerOscHandler(N,new k.OscHandler(P))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var N;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&&(!((N=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))===null||N===void 0)&&N.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);P.hasWidth(this._activeBuffer.x)&&!P.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const N=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-N),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(N=this._bufferService.cols-1){this._activeBuffer.x=Math.min(N,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(N,P){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=N,this._activeBuffer.y=this._activeBuffer.scrollTop+P):(this._activeBuffer.x=N,this._activeBuffer.y=P),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(N,P){this._restrictCursor(),this._setCursor(this._activeBuffer.x+N,this._activeBuffer.y+P)}cursorUp(N){const P=this._activeBuffer.y-this._activeBuffer.scrollTop;return P>=0?this._moveCursor(0,-Math.min(P,N.params[0]||1)):this._moveCursor(0,-(N.params[0]||1)),!0}cursorDown(N){const P=this._activeBuffer.scrollBottom-this._activeBuffer.y;return P>=0?this._moveCursor(0,Math.min(P,N.params[0]||1)):this._moveCursor(0,N.params[0]||1),!0}cursorForward(N){return this._moveCursor(N.params[0]||1,0),!0}cursorBackward(N){return this._moveCursor(-(N.params[0]||1),0),!0}cursorNextLine(N){return this.cursorDown(N),this._activeBuffer.x=0,!0}cursorPrecedingLine(N){return this.cursorUp(N),this._activeBuffer.x=0,!0}cursorCharAbsolute(N){return this._setCursor((N.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(N){return this._setCursor(N.length>=2?(N.params[1]||1)-1:0,(N.params[0]||1)-1),!0}charPosAbsolute(N){return this._setCursor((N.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(N){return this._moveCursor(N.params[0]||1,0),!0}linePosAbsolute(N){return this._setCursor(this._activeBuffer.x,(N.params[0]||1)-1),!0}vPositionRelative(N){return this._moveCursor(0,N.params[0]||1),!0}hVPosition(N){return this.cursorPosition(N),!0}tabClear(N){const P=N.params[0];return P===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:P===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(N){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let P=N.params[0]||1;for(;P--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(N){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let P=N.params[0]||1;for(;P--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(N){const P=N.params[0];return P===1&&(this._curAttrData.bg|=536870912),P!==2&&P!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(N,P,D,O=!1,q=!1){const K=this._activeBuffer.lines.get(this._activeBuffer.ybase+N);K.replaceCells(P,D,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),q),O&&(K.isWrapped=!1)}_resetBufferLine(N,P=!1){const D=this._activeBuffer.lines.get(this._activeBuffer.ybase+N);D&&(D.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),P),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+N),D.isWrapped=!1)}eraseInDisplay(N,P=!1){let D;switch(this._restrictCursor(this._bufferService.cols),N.params[0]){case 0:for(D=this._activeBuffer.y,this._dirtyRowTracker.markDirty(D),this._eraseInBufferLine(D++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,P);D<this._bufferService.rows;D++)this._resetBufferLine(D,P);this._dirtyRowTracker.markDirty(D);break;case 1:for(D=this._activeBuffer.y,this._dirtyRowTracker.markDirty(D),this._eraseInBufferLine(D,0,this._activeBuffer.x+1,!0,P),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(D+1).isWrapped=!1);D--;)this._resetBufferLine(D,P);this._dirtyRowTracker.markDirty(0);break;case 2:for(D=this._bufferService.rows,this._dirtyRowTracker.markDirty(D-1);D--;)this._resetBufferLine(D,P);this._dirtyRowTracker.markDirty(0);break;case 3:const O=this._activeBuffer.lines.length-this._bufferService.rows;O>0&&(this._activeBuffer.lines.trimStart(O),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-O,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-O,0),this._onScroll.fire(0))}return!0}eraseInLine(N,P=!1){switch(this._restrictCursor(this._bufferService.cols),N.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,P);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,P);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,P)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(N){this._restrictCursor();let P=N.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const D=this._activeBuffer.ybase+this._activeBuffer.y,O=this._bufferService.rows-1-this._activeBuffer.scrollBottom,q=this._bufferService.rows-1+this._activeBuffer.ybase-O+1;for(;P--;)this._activeBuffer.lines.splice(q-1,1),this._activeBuffer.lines.splice(D,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(N){this._restrictCursor();let P=N.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const D=this._activeBuffer.ybase+this._activeBuffer.y;let O;for(O=this._bufferService.rows-1-this._activeBuffer.scrollBottom,O=this._bufferService.rows-1+this._activeBuffer.ybase-O;P--;)this._activeBuffer.lines.splice(D,1),this._activeBuffer.lines.splice(O,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(N){this._restrictCursor();const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return P&&(P.insertCells(this._activeBuffer.x,N.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(N){this._restrictCursor();const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return P&&(P.deleteCells(this._activeBuffer.x,N.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(N){let P=N.params[0]||1;for(;P--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(N){let P=N.params[0]||1;for(;P--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(n.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(N){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=N.params[0]||1;for(let D=this._activeBuffer.scrollTop;D<=this._activeBuffer.scrollBottom;++D){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+D);O.deleteCells(0,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(N){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=N.params[0]||1;for(let D=this._activeBuffer.scrollTop;D<=this._activeBuffer.scrollBottom;++D){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+D);O.insertCells(0,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(N){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=N.params[0]||1;for(let D=this._activeBuffer.scrollTop;D<=this._activeBuffer.scrollBottom;++D){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+D);O.insertCells(this._activeBuffer.x,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(N){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=N.params[0]||1;for(let D=this._activeBuffer.scrollTop;D<=this._activeBuffer.scrollBottom;++D){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+D);O.deleteCells(this._activeBuffer.x,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(N){this._restrictCursor();const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return P&&(P.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(N.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(N){if(!this._parser.precedingCodepoint)return!0;const P=N.params[0]||1,D=new Uint32Array(P);for(let O=0;O<P;++O)D[O]=this._parser.precedingCodepoint;return this.print(D,0,D.length),!0}sendDeviceAttributesPrimary(N){return N.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(a.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(a.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(N){return N.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(a.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(a.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(N.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(a.C0.ESC+"[>83;40003;0c")),!0}_is(N){return(this._optionsService.rawOptions.termName+"").indexOf(N)===0}setMode(N){for(let P=0;P<N.length;P++)switch(N.params[P]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(N){for(let P=0;P<N.length;P++)switch(N.params[P]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,p.DEFAULT_CHARSET),this._charsetService.setgCharset(1,p.DEFAULT_CHARSET),this._charsetService.setgCharset(2,p.DEFAULT_CHARSET),this._charsetService.setgCharset(3,p.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(N){for(let P=0;P<N.length;P++)switch(N.params[P]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(N){for(let P=0;P<N.length;P++)switch(N.params[P]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),N.params[P]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(N,P){const D=this._coreService.decPrivateModes,{activeProtocol:O,activeEncoding:q}=this._coreMouseService,K=this._coreService,{buffers:U,cols:z}=this._bufferService,{active:W,alt:j}=U,F=this._optionsService.rawOptions,X=Z=>Z?1:2,Y=N.params[0];return ee=Y,G=P?Y===2?4:Y===4?X(K.modes.insertMode):Y===12?3:Y===20?X(F.convertEol):0:Y===1?X(D.applicationCursorKeys):Y===3?F.windowOptions.setWinLines?z===80?2:z===132?1:0:0:Y===6?X(D.origin):Y===7?X(D.wraparound):Y===8?3:Y===9?X(O==="X10"):Y===12?X(F.cursorBlink):Y===25?X(!K.isCursorHidden):Y===45?X(D.reverseWraparound):Y===66?X(D.applicationKeypad):Y===67?4:Y===1e3?X(O==="VT200"):Y===1002?X(O==="DRAG"):Y===1003?X(O==="ANY"):Y===1004?X(D.sendFocus):Y===1005?4:Y===1006?X(q==="SGR"):Y===1015?4:Y===1016?X(q==="SGR_PIXELS"):Y===1048?1:Y===47||Y===1047||Y===1049?X(W===j):Y===2004?X(D.bracketedPasteMode):0,K.triggerDataEvent(`${a.C0.ESC}[${P?"":"?"}${ee};${G}$y`),!0;var ee,G}_updateAttrColor(N,P,D,O,q){return P===2?(N|=50331648,N&=-16777216,N|=_.AttributeData.fromColorRGB([D,O,q])):P===5&&(N&=-50331904,N|=33554432|255&D),N}_extractColor(N,P,D){const O=[0,0,-1,0,0,0];let q=0,K=0;do{if(O[K+q]=N.params[P+K],N.hasSubParams(P+K)){const U=N.getSubParams(P+K);let z=0;do O[1]===5&&(q=1),O[K+z+1+q]=U[z];while(++z<U.length&&z+K+1+q<O.length);break}if(O[1]===5&&K+q>=2||O[1]===2&&K+q>=5)break;O[1]&&(q=1)}while(++K+P<N.length&&K+q<O.length);for(let U=2;U<O.length;++U)O[U]===-1&&(O[U]=0);switch(O[0]){case 38:D.fg=this._updateAttrColor(D.fg,O[1],O[3],O[4],O[5]);break;case 48:D.bg=this._updateAttrColor(D.bg,O[1],O[3],O[4],O[5]);break;case 58:D.extended=D.extended.clone(),D.extended.underlineColor=this._updateAttrColor(D.extended.underlineColor,O[1],O[3],O[4],O[5])}return K}_processUnderline(N,P){P.extended=P.extended.clone(),(!~N||N>5)&&(N=1),P.extended.underlineStyle=N,P.fg|=268435456,N===0&&(P.fg&=-268435457),P.updateExtended()}_processSGR0(N){N.fg=n.DEFAULT_ATTR_DATA.fg,N.bg=n.DEFAULT_ATTR_DATA.bg,N.extended=N.extended.clone(),N.extended.underlineStyle=0,N.extended.underlineColor&=-67108864,N.updateExtended()}charAttributes(N){if(N.length===1&&N.params[0]===0)return this._processSGR0(this._curAttrData),!0;const P=N.length;let D;const O=this._curAttrData;for(let q=0;q<P;q++)D=N.params[q],D>=30&&D<=37?(O.fg&=-50331904,O.fg|=16777216|D-30):D>=40&&D<=47?(O.bg&=-50331904,O.bg|=16777216|D-40):D>=90&&D<=97?(O.fg&=-50331904,O.fg|=16777224|D-90):D>=100&&D<=107?(O.bg&=-50331904,O.bg|=16777224|D-100):D===0?this._processSGR0(O):D===1?O.fg|=134217728:D===3?O.bg|=67108864:D===4?(O.fg|=268435456,this._processUnderline(N.hasSubParams(q)?N.getSubParams(q)[0]:1,O)):D===5?O.fg|=536870912:D===7?O.fg|=67108864:D===8?O.fg|=1073741824:D===9?O.fg|=2147483648:D===2?O.bg|=134217728:D===21?this._processUnderline(2,O):D===22?(O.fg&=-134217729,O.bg&=-134217729):D===23?O.bg&=-67108865:D===24?(O.fg&=-268435457,this._processUnderline(0,O)):D===25?O.fg&=-536870913:D===27?O.fg&=-67108865:D===28?O.fg&=-1073741825:D===29?O.fg&=2147483647:D===39?(O.fg&=-67108864,O.fg|=16777215&n.DEFAULT_ATTR_DATA.fg):D===49?(O.bg&=-67108864,O.bg|=16777215&n.DEFAULT_ATTR_DATA.bg):D===38||D===48||D===58?q+=this._extractColor(N,q,O):D===53?O.bg|=1073741824:D===55?O.bg&=-1073741825:D===59?(O.extended=O.extended.clone(),O.extended.underlineColor=-1,O.updateExtended()):D===100?(O.fg&=-67108864,O.fg|=16777215&n.DEFAULT_ATTR_DATA.fg,O.bg&=-67108864,O.bg|=16777215&n.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",D);return!0}deviceStatus(N){switch(N.params[0]){case 5:this._coreService.triggerDataEvent(`${a.C0.ESC}[0n`);break;case 6:const P=this._activeBuffer.y+1,D=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${a.C0.ESC}[${P};${D}R`)}return!0}deviceStatusPrivate(N){if(N.params[0]===6){const P=this._activeBuffer.y+1,D=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${a.C0.ESC}[?${P};${D}R`)}return!0}softReset(N){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=n.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(N){const P=N.params[0]||1;switch(P){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}const D=P%2==1;return this._optionsService.options.cursorBlink=D,!0}setScrollRegion(N){const P=N.params[0]||1;let D;return(N.length<2||(D=N.params[1])>this._bufferService.rows||D===0)&&(D=this._bufferService.rows),D>P&&(this._activeBuffer.scrollTop=P-1,this._activeBuffer.scrollBottom=D-1,this._setCursor(0,0)),!0}windowOptions(N){if(!L(N.params[0],this._optionsService.rawOptions.windowOptions))return!0;const P=N.length>1?N.params[1]:0;switch(N.params[0]){case 14:P!==2&&this._onRequestWindowsOptionsReport.fire(R.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(R.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${a.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:P!==0&&P!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),P!==0&&P!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:P!==0&&P!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),P!==0&&P!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(N){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(N){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(N){return this._windowTitle=N,this._onTitleChange.fire(N),!0}setIconName(N){return this._iconName=N,!0}setOrReportIndexedColor(N){const P=[],D=N.split(";");for(;D.length>1;){const O=D.shift(),q=D.shift();if(/^\d+$/.exec(O)){const K=parseInt(O);if(H(K))if(q==="?")P.push({type:0,index:K});else{const U=(0,x.parseColor)(q);U&&P.push({type:1,index:K,color:U})}}}return P.length&&this._onColor.fire(P),!0}setHyperlink(N){const P=N.split(";");return!(P.length<2)&&(P[1]?this._createHyperlink(P[0],P[1]):!P[0]&&this._finishHyperlink())}_createHyperlink(N,P){this._getCurrentLinkId()&&this._finishHyperlink();const D=N.split(":");let O;const q=D.findIndex((K=>K.startsWith("id=")));return q!==-1&&(O=D[q].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:O,uri:P}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(N,P){const D=N.split(";");for(let O=0;O<D.length&&!(P>=this._specialColors.length);++O,++P)if(D[O]==="?")this._onColor.fire([{type:0,index:this._specialColors[P]}]);else{const q=(0,x.parseColor)(D[O]);q&&this._onColor.fire([{type:1,index:this._specialColors[P],color:q}])}return!0}setOrReportFgColor(N){return this._setOrReportSpecialColor(N,0)}setOrReportBgColor(N){return this._setOrReportSpecialColor(N,1)}setOrReportCursorColor(N){return this._setOrReportSpecialColor(N,2)}restoreIndexedColor(N){if(!N)return this._onColor.fire([{type:2}]),!0;const P=[],D=N.split(";");for(let O=0;O<D.length;++O)if(/^\d+$/.exec(D[O])){const q=parseInt(D[O]);H(q)&&P.push({type:2,index:q})}return P.length&&this._onColor.fire(P),!0}restoreFgColor(N){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(N){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(N){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,p.DEFAULT_CHARSET),!0}selectCharset(N){return N.length!==2?(this.selectDefaultCharset(),!0):(N[0]==="/"||this._charsetService.setgCharset(C[N[0]],p.CHARSETS[N[1]]||p.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 N=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,N,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=n.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=n.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(N){return this._charsetService.setgLevel(N),!0}screenAlignmentPattern(){const N=new h.CellData;N.content=4194373,N.fg=this._curAttrData.fg,N.bg=this._curAttrData.bg,this._setCursor(0,0);for(let P=0;P<this._bufferService.rows;++P){const D=this._activeBuffer.ybase+this._activeBuffer.y+P,O=this._activeBuffer.lines.get(D);O&&(O.fill(N),O.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(N,P){const D=this._bufferService.buffer,O=this._optionsService.rawOptions;return(q=>(this._coreService.triggerDataEvent(`${a.C0.ESC}${q}${a.C0.ESC}\\`),!0))(N==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:N==='"p'?'P1$r61;1"p':N==="r"?`P1$r${D.scrollTop+1};${D.scrollBottom+1}r`:N==="m"?"P1$r0m":N===" q"?`P1$r${{block:2,underline:4,bar:6}[O.cursorStyle]-(O.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(N,P){this._dirtyRowTracker.markRangeDirty(N,P)}}i.InputHandler=I;let B=class{constructor($){this._bufferService=$,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty($){$<this.start?this.start=$:$>this.end&&(this.end=$)}markRangeDirty($,N){$>N&&(M=$,$=N,N=M),$<this.start&&(this.start=$),N>this.end&&(this.end=N)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function H($){return 0<=$&&$<256}B=u([f(0,S.IBufferService)],B)},844:(w,i)=>{function o(u){for(const f of u)f.dispose();u.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 u of this._disposables)u.dispose();this._disposables.length=0}register(u){return this._disposables.push(u),u}unregister(u){const f=this._disposables.indexOf(u);f!==-1&&this._disposables.splice(f,1)}},i.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(u){var f;this._isDisposed||u===this._value||((f=this._value)===null||f===void 0||f.dispose(),this._value=u)}clear(){this.value=void 0}dispose(){var u;this._isDisposed=!0,(u=this._value)===null||u===void 0||u.dispose(),this._value=void 0}},i.toDisposable=function(u){return{dispose:u}},i.disposeArray=o,i.getDisposeArrayDisposable=function(u){return{dispose:()=>o(u)}}},1505:(w,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.FourKeyMap=i.TwoKeyMap=void 0;class o{constructor(){this._data={}}set(f,a,p){this._data[f]||(this._data[f]={}),this._data[f][a]=p}get(f,a){return this._data[f]?this._data[f][a]:void 0}clear(){this._data={}}}i.TwoKeyMap=o,i.FourKeyMap=class{constructor(){this._data=new o}set(u,f,a,p,m){this._data.get(u,f)||this._data.set(u,f,new o),this._data.get(u,f).set(a,p,m)}get(u,f,a,p){var m;return(m=this._data.get(u,f))===null||m===void 0?void 0:m.get(a,p)}clear(){this._data.clear()}}},6114:(w,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 o=i.isNode?"node":navigator.userAgent,u=i.isNode?"node":navigator.platform;i.isFirefox=o.includes("Firefox"),i.isLegacyEdge=o.includes("Edge"),i.isSafari=/^((?!chrome|android).)*safari/i.test(o),i.getSafariVersion=function(){if(!i.isSafari)return 0;const f=o.match(/Version\/(\d+)/);return f===null||f.length<2?0:parseInt(f[1])},i.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(u),i.isIpad=u==="iPad",i.isIphone=u==="iPhone",i.isWindows=["Windows","Win16","Win32","WinCE"].includes(u),i.isLinux=u.indexOf("Linux")>=0,i.isChromeOS=/\bCrOS\b/.test(o)},6106:(w,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.SortedList=void 0;let o=0;i.SortedList=class{constructor(u){this._getKey=u,this._array=[]}clear(){this._array.length=0}insert(u){this._array.length!==0?(o=this._search(this._getKey(u)),this._array.splice(o,0,u)):this._array.push(u)}delete(u){if(this._array.length===0)return!1;const f=this._getKey(u);if(f===void 0||(o=this._search(f),o===-1)||this._getKey(this._array[o])!==f)return!1;do if(this._array[o]===u)return this._array.splice(o,1),!0;while(++o<this._array.length&&this._getKey(this._array[o])===f);return!1}*getKeyIterator(u){if(this._array.length!==0&&(o=this._search(u),!(o<0||o>=this._array.length)&&this._getKey(this._array[o])===u))do yield this._array[o];while(++o<this._array.length&&this._getKey(this._array[o])===u)}forEachByKey(u,f){if(this._array.length!==0&&(o=this._search(u),!(o<0||o>=this._array.length)&&this._getKey(this._array[o])===u))do f(this._array[o]);while(++o<this._array.length&&this._getKey(this._array[o])===u)}values(){return[...this._array].values()}_search(u){let f=0,a=this._array.length-1;for(;a>=f;){let p=f+a>>1;const m=this._getKey(this._array[p]);if(m>u)a=p-1;else{if(!(m<u)){for(;p>0&&this._getKey(this._array[p-1])===u;)p--;return p}f=p+1}}return f}}},7226:(w,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DebouncedIdleTask=i.IdleTaskQueue=i.PriorityTaskQueue=void 0;const u=o(6114);class f{constructor(){this._tasks=[],this._i=0}enqueue(m){this._tasks.push(m),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(m){this._idleCallback=void 0;let y=0,b=0,n=m.timeRemaining(),d=0;for(;this._i<this._tasks.length;){if(y=Date.now(),this._tasks[this._i]()||this._i++,y=Math.max(1,Date.now()-y),b=Math.max(y,b),d=m.timeRemaining(),1.5*b>d)return n-y<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(n-y))}ms`),void this._start();n=d}this.clear()}}class a extends f{_requestCallback(m){return setTimeout((()=>m(this._createDeadline(16))))}_cancelCallback(m){clearTimeout(m)}_createDeadline(m){const y=Date.now()+m;return{timeRemaining:()=>Math.max(0,y-Date.now())}}}i.PriorityTaskQueue=a,i.IdleTaskQueue=!u.isNode&&"requestIdleCallback"in window?class extends f{_requestCallback(p){return requestIdleCallback(p)}_cancelCallback(p){cancelIdleCallback(p)}}:a,i.DebouncedIdleTask=class{constructor(){this._queue=new i.IdleTaskQueue}set(p){this._queue.clear(),this._queue.enqueue(p)}flush(){this._queue.flush()}}},9282:(w,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.updateWindowsModeWrappedState=void 0;const u=o(643);i.updateWindowsModeWrappedState=function(f){const a=f.buffer.lines.get(f.buffer.ybase+f.buffer.y-1),p=a?.get(f.cols-1),m=f.buffer.lines.get(f.buffer.ybase+f.buffer.y);m&&p&&(m.isWrapped=p[u.CHAR_DATA_CODE_INDEX]!==u.NULL_CELL_CODE&&p[u.CHAR_DATA_CODE_INDEX]!==u.WHITESPACE_CELL_CODE)}},3734:(w,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ExtendedAttrs=i.AttributeData=void 0;class o{constructor(){this.fg=0,this.bg=0,this.extended=new u}static toColorRGB(a){return[a>>>16&255,a>>>8&255,255&a]}static fromColorRGB(a){return(255&a[0])<<16|(255&a[1])<<8|255&a[2]}clone(){const a=new o;return a.fg=this.fg,a.bg=this.bg,a.extended=this.extended.clone(),a}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=o;class u{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(a){this._ext=a}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(a){this._ext&=-469762049,this._ext|=a<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(a){this._ext&=-67108864,this._ext|=67108863&a}get urlId(){return this._urlId}set urlId(a){this._urlId=a}constructor(a=0,p=0){this._ext=0,this._urlId=0,this._ext=a,this._urlId=p}clone(){return new u(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}i.ExtendedAttrs=u},9092:(w,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Buffer=i.MAX_BUFFER_SIZE=void 0;const u=o(6349),f=o(7226),a=o(3734),p=o(8437),m=o(4634),y=o(511),b=o(643),n=o(4863),d=o(7116);i.MAX_BUFFER_SIZE=4294967295,i.Buffer=class{constructor(c,h,_){this._hasScrollback=c,this._optionsService=h,this._bufferService=_,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=p.DEFAULT_ATTR_DATA.clone(),this.savedCharset=d.DEFAULT_CHARSET,this.markers=[],this._nullCell=y.CellData.fromCharData([0,b.NULL_CELL_CHAR,b.NULL_CELL_WIDTH,b.NULL_CELL_CODE]),this._whitespaceCell=y.CellData.fromCharData([0,b.WHITESPACE_CELL_CHAR,b.WHITESPACE_CELL_WIDTH,b.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new f.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new u.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(c){return c?(this._nullCell.fg=c.fg,this._nullCell.bg=c.bg,this._nullCell.extended=c.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new a.ExtendedAttrs),this._nullCell}getWhitespaceCell(c){return c?(this._whitespaceCell.fg=c.fg,this._whitespaceCell.bg=c.bg,this._whitespaceCell.extended=c.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new a.ExtendedAttrs),this._whitespaceCell}getBlankLine(c,h){return new p.BufferLine(this._bufferService.cols,this.getNullCell(c),h)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const c=this.ybase+this.y-this.ydisp;return c>=0&&c<this._rows}_getCorrectBufferLength(c){if(!this._hasScrollback)return c;const h=c+this._optionsService.rawOptions.scrollback;return h>i.MAX_BUFFER_SIZE?i.MAX_BUFFER_SIZE:h}fillViewportRows(c){if(this.lines.length===0){c===void 0&&(c=p.DEFAULT_ATTR_DATA);let h=this._rows;for(;h--;)this.lines.push(this.getBlankLine(c))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new u.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(c,h){const _=this.getNullCell(p.DEFAULT_ATTR_DATA);let S=0;const k=this._getCorrectBufferLength(h);if(k>this.lines.maxLength&&(this.lines.maxLength=k),this.lines.length>0){if(this._cols<c)for(let x=0;x<this.lines.length;x++)S+=+this.lines.get(x).resize(c,_);let E=0;if(this._rows<h)for(let x=this._rows;x<h;x++)this.lines.length<h+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new p.BufferLine(c,_)):this.ybase>0&&this.lines.length<=this.ybase+this.y+E+1?(this.ybase--,E++,this.ydisp>0&&this.ydisp--):this.lines.push(new p.BufferLine(c,_)));else for(let x=this._rows;x>h;x--)this.lines.length>h+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(k<this.lines.maxLength){const x=this.lines.length-k;x>0&&(this.lines.trimStart(x),this.ybase=Math.max(this.ybase-x,0),this.ydisp=Math.max(this.ydisp-x,0),this.savedY=Math.max(this.savedY-x,0)),this.lines.maxLength=k}this.x=Math.min(this.x,c-1),this.y=Math.min(this.y,h-1),E&&(this.y+=E),this.savedX=Math.min(this.savedX,c-1),this.scrollTop=0}if(this.scrollBottom=h-1,this._isReflowEnabled&&(this._reflow(c,h),this._cols>c))for(let E=0;E<this.lines.length;E++)S+=+this.lines.get(E).resize(c,_);this._cols=c,this._rows=h,this._memoryCleanupQueue.clear(),S>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let c=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,c=!1);let h=0;for(;this._memoryCleanupPosition<this.lines.length;)if(h+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),h>100)return!0;return c}get _isReflowEnabled(){const c=this._optionsService.rawOptions.windowsPty;return c&&c.buildNumber?this._hasScrollback&&c.backend==="conpty"&&c.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(c,h){this._cols!==c&&(c>this._cols?this._reflowLarger(c,h):this._reflowSmaller(c,h))}_reflowLarger(c,h){const _=(0,m.reflowLargerGetLinesToRemove)(this.lines,this._cols,c,this.ybase+this.y,this.getNullCell(p.DEFAULT_ATTR_DATA));if(_.length>0){const S=(0,m.reflowLargerCreateNewLayout)(this.lines,_);(0,m.reflowLargerApplyNewLayout)(this.lines,S.layout),this._reflowLargerAdjustViewport(c,h,S.countRemoved)}}_reflowLargerAdjustViewport(c,h,_){const S=this.getNullCell(p.DEFAULT_ATTR_DATA);let k=_;for(;k-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<h&&this.lines.push(new p.BufferLine(c,S))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-_,0)}_reflowSmaller(c,h){const _=this.getNullCell(p.DEFAULT_ATTR_DATA),S=[];let k=0;for(let E=this.lines.length-1;E>=0;E--){let x=this.lines.get(E);if(!x||!x.isWrapped&&x.getTrimmedLength()<=c)continue;const C=[x];for(;x.isWrapped&&E>0;)x=this.lines.get(--E),C.unshift(x);const T=this.ybase+this.y;if(T>=E&&T<E+C.length)continue;const L=C[C.length-1].getTrimmedLength(),R=(0,m.reflowSmallerGetNewLineLengths)(C,this._cols,c),M=R.length-C.length;let I;I=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 B=[];for(let O=0;O<M;O++){const q=this.getBlankLine(p.DEFAULT_ATTR_DATA,!0);B.push(q)}B.length>0&&(S.push({start:E+C.length+k,newLines:B}),k+=B.length),C.push(...B);let H=R.length-1,$=R[H];$===0&&(H--,$=R[H]);let N=C.length-M-1,P=L;for(;N>=0;){const O=Math.min(P,$);if(C[H]===void 0)break;if(C[H].copyCellsFrom(C[N],P-O,$-O,O,!0),$-=O,$===0&&(H--,$=R[H]),P-=O,P===0){N--;const q=Math.max(N,0);P=(0,m.getWrappedLineTrimmedLength)(C,q,this._cols)}}for(let O=0;O<C.length;O++)R[O]<c&&C[O].setCell(R[O],_);let D=M-I;for(;D-- >0;)this.ybase===0?this.y<h-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+k)-h&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+M,this.ybase+h-1)}if(S.length>0){const E=[],x=[];for(let H=0;H<this.lines.length;H++)x.push(this.lines.get(H));const C=this.lines.length;let T=C-1,L=0,R=S[L];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+k);let M=0;for(let H=Math.min(this.lines.maxLength-1,C+k-1);H>=0;H--)if(R&&R.start>T+M){for(let $=R.newLines.length-1;$>=0;$--)this.lines.set(H--,R.newLines[$]);H++,E.push({index:T+1,amount:R.newLines.length}),M+=R.newLines.length,R=S[++L]}else this.lines.set(H,x[T--]);let I=0;for(let H=E.length-1;H>=0;H--)E[H].index+=I,this.lines.onInsertEmitter.fire(E[H]),I+=E[H].amount;const B=Math.max(0,C+k-this.lines.maxLength);B>0&&this.lines.onTrimEmitter.fire(B)}}translateBufferLineToString(c,h,_=0,S){const k=this.lines.get(c);return k?k.translateToString(h,_,S):""}getWrappedRangeForLine(c){let h=c,_=c;for(;h>0&&this.lines.get(h).isWrapped;)h--;for(;_+1<this.lines.length&&this.lines.get(_+1).isWrapped;)_++;return{first:h,last:_}}setupTabStops(c){for(c!=null?this.tabs[c]||(c=this.prevStop(c)):(this.tabs={},c=0);c<this._cols;c+=this._optionsService.rawOptions.tabStopWidth)this.tabs[c]=!0}prevStop(c){for(c==null&&(c=this.x);!this.tabs[--c]&&c>0;);return c>=this._cols?this._cols-1:c<0?0:c}nextStop(c){for(c==null&&(c=this.x);!this.tabs[++c]&&c<this._cols;);return c>=this._cols?this._cols-1:c<0?0:c}clearMarkers(c){this._isClearing=!0;for(let h=0;h<this.markers.length;h++)this.markers[h].line===c&&(this.markers[h].dispose(),this.markers.splice(h--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let c=0;c<this.markers.length;c++)this.markers[c].dispose(),this.markers.splice(c--,1);this._isClearing=!1}addMarker(c){const h=new n.Marker(c);return this.markers.push(h),h.register(this.lines.onTrim((_=>{h.line-=_,h.line<0&&h.dispose()}))),h.register(this.lines.onInsert((_=>{h.line>=_.index&&(h.line+=_.amount)}))),h.register(this.lines.onDelete((_=>{h.line>=_.index&&h.line<_.index+_.amount&&h.dispose(),h.line>_.index&&(h.line-=_.amount)}))),h.register(h.onDispose((()=>this._removeMarker(h)))),h}_removeMarker(c){this._isClearing||this.markers.splice(this.markers.indexOf(c),1)}}},8437:(w,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferLine=i.DEFAULT_ATTR_DATA=void 0;const u=o(3734),f=o(511),a=o(643),p=o(482);i.DEFAULT_ATTR_DATA=Object.freeze(new u.AttributeData);let m=0;class y{constructor(n,d,c=!1){this.isWrapped=c,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*n);const h=d||f.CellData.fromCharData([0,a.NULL_CELL_CHAR,a.NULL_CELL_WIDTH,a.NULL_CELL_CODE]);for(let _=0;_<n;++_)this.setCell(_,h);this.length=n}get(n){const d=this._data[3*n+0],c=2097151&d;return[this._data[3*n+1],2097152&d?this._combined[n]:c?(0,p.stringFromCodePoint)(c):"",d>>22,2097152&d?this._combined[n].charCodeAt(this._combined[n].length-1):c]}set(n,d){this._data[3*n+1]=d[a.CHAR_DATA_ATTR_INDEX],d[a.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[n]=d[1],this._data[3*n+0]=2097152|n|d[a.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*n+0]=d[a.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|d[a.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(n){return this._data[3*n+0]>>22}hasWidth(n){return 12582912&this._data[3*n+0]}getFg(n){return this._data[3*n+1]}getBg(n){return this._data[3*n+2]}hasContent(n){return 4194303&this._data[3*n+0]}getCodePoint(n){const d=this._data[3*n+0];return 2097152&d?this._combined[n].charCodeAt(this._combined[n].length-1):2097151&d}isCombined(n){return 2097152&this._data[3*n+0]}getString(n){const d=this._data[3*n+0];return 2097152&d?this._combined[n]:2097151&d?(0,p.stringFromCodePoint)(2097151&d):""}isProtected(n){return 536870912&this._data[3*n+2]}loadCell(n,d){return m=3*n,d.content=this._data[m+0],d.fg=this._data[m+1],d.bg=this._data[m+2],2097152&d.content&&(d.combinedData=this._combined[n]),268435456&d.bg&&(d.extended=this._extendedAttrs[n]),d}setCell(n,d){2097152&d.content&&(this._combined[n]=d.combinedData),268435456&d.bg&&(this._extendedAttrs[n]=d.extended),this._data[3*n+0]=d.content,this._data[3*n+1]=d.fg,this._data[3*n+2]=d.bg}setCellFromCodePoint(n,d,c,h,_,S){268435456&_&&(this._extendedAttrs[n]=S),this._data[3*n+0]=d|c<<22,this._data[3*n+1]=h,this._data[3*n+2]=_}addCodepointToCell(n,d){let c=this._data[3*n+0];2097152&c?this._combined[n]+=(0,p.stringFromCodePoint)(d):(2097151&c?(this._combined[n]=(0,p.stringFromCodePoint)(2097151&c)+(0,p.stringFromCodePoint)(d),c&=-2097152,c|=2097152):c=d|4194304,this._data[3*n+0]=c)}insertCells(n,d,c,h){if((n%=this.length)&&this.getWidth(n-1)===2&&this.setCellFromCodePoint(n-1,0,1,h?.fg||0,h?.bg||0,h?.extended||new u.ExtendedAttrs),d<this.length-n){const _=new f.CellData;for(let S=this.length-n-d-1;S>=0;--S)this.setCell(n+d+S,this.loadCell(n+S,_));for(let S=0;S<d;++S)this.setCell(n+S,c)}else for(let _=n;_<this.length;++_)this.setCell(_,c);this.getWidth(this.length-1)===2&&this.setCellFromCodePoint(this.length-1,0,1,h?.fg||0,h?.bg||0,h?.extended||new u.ExtendedAttrs)}deleteCells(n,d,c,h){if(n%=this.length,d<this.length-n){const _=new f.CellData;for(let S=0;S<this.length-n-d;++S)this.setCell(n+S,this.loadCell(n+d+S,_));for(let S=this.length-d;S<this.length;++S)this.setCell(S,c)}else for(let _=n;_<this.length;++_)this.setCell(_,c);n&&this.getWidth(n-1)===2&&this.setCellFromCodePoint(n-1,0,1,h?.fg||0,h?.bg||0,h?.extended||new u.ExtendedAttrs),this.getWidth(n)!==0||this.hasContent(n)||this.setCellFromCodePoint(n,0,1,h?.fg||0,h?.bg||0,h?.extended||new u.ExtendedAttrs)}replaceCells(n,d,c,h,_=!1){if(_)for(n&&this.getWidth(n-1)===2&&!this.isProtected(n-1)&&this.setCellFromCodePoint(n-1,0,1,h?.fg||0,h?.bg||0,h?.extended||new u.ExtendedAttrs),d<this.length&&this.getWidth(d-1)===2&&!this.isProtected(d)&&this.setCellFromCodePoint(d,0,1,h?.fg||0,h?.bg||0,h?.extended||new u.ExtendedAttrs);n<d&&n<this.length;)this.isProtected(n)||this.setCell(n,c),n++;else for(n&&this.getWidth(n-1)===2&&this.setCellFromCodePoint(n-1,0,1,h?.fg||0,h?.bg||0,h?.extended||new u.ExtendedAttrs),d<this.length&&this.getWidth(d-1)===2&&this.setCellFromCodePoint(d,0,1,h?.fg||0,h?.bg||0,h?.extended||new u.ExtendedAttrs);n<d&&n<this.length;)this.setCell(n++,c)}resize(n,d){if(n===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const c=3*n;if(n>this.length){if(this._data.buffer.byteLength>=4*c)this._data=new Uint32Array(this._data.buffer,0,c);else{const h=new Uint32Array(c);h.set(this._data),this._data=h}for(let h=this.length;h<n;++h)this.setCell(h,d)}else{this._data=this._data.subarray(0,c);const h=Object.keys(this._combined);for(let S=0;S<h.length;S++){const k=parseInt(h[S],10);k>=n&&delete this._combined[k]}const _=Object.keys(this._extendedAttrs);for(let S=0;S<_.length;S++){const k=parseInt(_[S],10);k>=n&&delete this._extendedAttrs[k]}}return this.length=n,4*c*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const n=new Uint32Array(this._data.length);return n.set(this._data),this._data=n,1}return 0}fill(n,d=!1){if(d)for(let c=0;c<this.length;++c)this.isProtected(c)||this.setCell(c,n);else{this._combined={},this._extendedAttrs={};for(let c=0;c<this.length;++c)this.setCell(c,n)}}copyFrom(n){this.length!==n.length?this._data=new Uint32Array(n._data):this._data.set(n._data),this.length=n.length,this._combined={};for(const d in n._combined)this._combined[d]=n._combined[d];this._extendedAttrs={};for(const d in n._extendedAttrs)this._extendedAttrs[d]=n._extendedAttrs[d];this.isWrapped=n.isWrapped}clone(){const n=new y(0);n._data=new Uint32Array(this._data),n.length=this.length;for(const d in this._combined)n._combined[d]=this._combined[d];for(const d in this._extendedAttrs)n._extendedAttrs[d]=this._extendedAttrs[d];return n.isWrapped=this.isWrapped,n}getTrimmedLength(){for(let n=this.length-1;n>=0;--n)if(4194303&this._data[3*n+0])return n+(this._data[3*n+0]>>22);return 0}getNoBgTrimmedLength(){for(let n=this.length-1;n>=0;--n)if(4194303&this._data[3*n+0]||50331648&this._data[3*n+2])return n+(this._data[3*n+0]>>22);return 0}copyCellsFrom(n,d,c,h,_){const S=n._data;if(_)for(let E=h-1;E>=0;E--){for(let x=0;x<3;x++)this._data[3*(c+E)+x]=S[3*(d+E)+x];268435456&S[3*(d+E)+2]&&(this._extendedAttrs[c+E]=n._extendedAttrs[d+E])}else for(let E=0;E<h;E++){for(let x=0;x<3;x++)this._data[3*(c+E)+x]=S[3*(d+E)+x];268435456&S[3*(d+E)+2]&&(this._extendedAttrs[c+E]=n._extendedAttrs[d+E])}const k=Object.keys(n._combined);for(let E=0;E<k.length;E++){const x=parseInt(k[E],10);x>=d&&(this._combined[x-d+c]=n._combined[x])}}translateToString(n=!1,d=0,c=this.length){n&&(c=Math.min(c,this.getTrimmedLength()));let h="";for(;d<c;){const _=this._data[3*d+0],S=2097151&_;h+=2097152&_?this._combined[d]:S?(0,p.stringFromCodePoint)(S):a.WHITESPACE_CELL_CHAR,d+=_>>22||1}return h}}i.BufferLine=y},4841:(w,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.getRangeLength=void 0,i.getRangeLength=function(o,u){if(o.start.y>o.end.y)throw new Error(`Buffer range end (${o.end.x}, ${o.end.y}) cannot be before start (${o.start.x}, ${o.start.y})`);return u*(o.end.y-o.start.y)+(o.end.x-o.start.x+1)}},4634:(w,i)=>{function o(u,f,a){if(f===u.length-1)return u[f].getTrimmedLength();const p=!u[f].hasContent(a-1)&&u[f].getWidth(a-1)===1,m=u[f+1].getWidth(0)===2;return p&&m?a-1:a}Object.defineProperty(i,"__esModule",{value:!0}),i.getWrappedLineTrimmedLength=i.reflowSmallerGetNewLineLengths=i.reflowLargerApplyNewLayout=i.reflowLargerCreateNewLayout=i.reflowLargerGetLinesToRemove=void 0,i.reflowLargerGetLinesToRemove=function(u,f,a,p,m){const y=[];for(let b=0;b<u.length-1;b++){let n=b,d=u.get(++n);if(!d.isWrapped)continue;const c=[u.get(b)];for(;n<u.length&&d.isWrapped;)c.push(d),d=u.get(++n);if(p>=b&&p<n){b+=c.length-1;continue}let h=0,_=o(c,h,f),S=1,k=0;for(;S<c.length;){const x=o(c,S,f),C=x-k,T=a-_,L=Math.min(C,T);c[h].copyCellsFrom(c[S],k,_,L,!1),_+=L,_===a&&(h++,_=0),k+=L,k===x&&(S++,k=0),_===0&&h!==0&&c[h-1].getWidth(a-1)===2&&(c[h].copyCellsFrom(c[h-1],a-1,_++,1,!1),c[h-1].setCell(a-1,m))}c[h].replaceCells(_,a,m);let E=0;for(let x=c.length-1;x>0&&(x>h||c[x].getTrimmedLength()===0);x--)E++;E>0&&(y.push(b+c.length-E),y.push(E)),b+=c.length-1}return y},i.reflowLargerCreateNewLayout=function(u,f){const a=[];let p=0,m=f[p],y=0;for(let b=0;b<u.length;b++)if(m===b){const n=f[++p];u.onDeleteEmitter.fire({index:b-y,amount:n}),b+=n-1,y+=n,m=f[++p]}else a.push(b);return{layout:a,countRemoved:y}},i.reflowLargerApplyNewLayout=function(u,f){const a=[];for(let p=0;p<f.length;p++)a.push(u.get(f[p]));for(let p=0;p<a.length;p++)u.set(p,a[p]);u.length=f.length},i.reflowSmallerGetNewLineLengths=function(u,f,a){const p=[],m=u.map(((d,c)=>o(u,c,f))).reduce(((d,c)=>d+c));let y=0,b=0,n=0;for(;n<m;){if(m-n<a){p.push(m-n);break}y+=a;const d=o(u,b,f);y>d&&(y-=d,b++);const c=u[b].getWidth(y-1)===2;c&&y--;const h=c?a-1:a;p.push(h),n+=h}return p},i.getWrappedLineTrimmedLength=o},5295:(w,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferSet=void 0;const u=o(8460),f=o(844),a=o(9092);class p extends f.Disposable{constructor(y,b){super(),this._optionsService=y,this._bufferService=b,this._onBufferActivate=this.register(new u.EventEmitter),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.resize(this._bufferService.cols,this._bufferService.rows)))),this.register(this._optionsService.onSpecificOptionChange("tabStopWidth",(()=>this.setupTabStops())))}reset(){this._normal=new a.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new a.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(y){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(y),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(y,b){this._normal.resize(y,b),this._alt.resize(y,b),this.setupTabStops(y)}setupTabStops(y){this._normal.setupTabStops(y),this._alt.setupTabStops(y)}}i.BufferSet=p},511:(w,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CellData=void 0;const u=o(482),f=o(643),a=o(3734);class p extends a.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new a.ExtendedAttrs,this.combinedData=""}static fromCharData(y){const b=new p;return b.setFromCharData(y),b}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,u.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(y){this.fg=y[f.CHAR_DATA_ATTR_INDEX],this.bg=0;let b=!1;if(y[f.CHAR_DATA_CHAR_INDEX].length>2)b=!0;else if(y[f.CHAR_DATA_CHAR_INDEX].length===2){const n=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=n&&n<=56319){const d=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=d&&d<=57343?this.content=1024*(n-55296)+d-56320+65536|y[f.CHAR_DATA_WIDTH_INDEX]<<22:b=!0}else b=!0}else this.content=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|y[f.CHAR_DATA_WIDTH_INDEX]<<22;b&&(this.combinedData=y[f.CHAR_DATA_CHAR_INDEX],this.content=2097152|y[f.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}i.CellData=p},643:(w,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:(w,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Marker=void 0;const u=o(8460),f=o(844);class a{get id(){return this._id}constructor(m){this.line=m,this.isDisposed=!1,this._disposables=[],this._id=a._nextId++,this._onDispose=this.register(new u.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,f.disposeArray)(this._disposables),this._disposables.length=0)}register(m){return this._disposables.push(m),m}}i.Marker=a,a._nextId=1},7116:(w,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:(w,i)=>{var o,u,f;Object.defineProperty(i,"__esModule",{value:!0}),i.C1_ESCAPED=i.C1=i.C0=void 0,(function(a){a.NUL="\0",a.SOH="",a.STX="",a.ETX="",a.EOT="",a.ENQ="",a.ACK="",a.BEL="\x07",a.BS="\b",a.HT=" ",a.LF=`
15
- `,a.VT="\v",a.FF="\f",a.CR="\r",a.SO="",a.SI="",a.DLE="",a.DC1="",a.DC2="",a.DC3="",a.DC4="",a.NAK="",a.SYN="",a.ETB="",a.CAN="",a.EM="",a.SUB="",a.ESC="\x1B",a.FS="",a.GS="",a.RS="",a.US="",a.SP=" ",a.DEL=""})(o||(i.C0=o={})),(function(a){a.PAD="€",a.HOP="",a.BPH="‚",a.NBH="ƒ",a.IND="„",a.NEL="…",a.SSA="†",a.ESA="‡",a.HTS="ˆ",a.HTJ="‰",a.VTS="Š",a.PLD="‹",a.PLU="Œ",a.RI="",a.SS2="Ž",a.SS3="",a.DCS="",a.PU1="‘",a.PU2="’",a.STS="“",a.CCH="”",a.MW="•",a.SPA="–",a.EPA="—",a.SOS="˜",a.SGCI="™",a.SCI="š",a.CSI="›",a.ST="œ",a.OSC="",a.PM="ž",a.APC="Ÿ"})(u||(i.C1=u={})),(function(a){a.ST=`${o.ESC}\\`})(f||(i.C1_ESCAPED=f={}))},7399:(w,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.evaluateKeyboardEvent=void 0;const u=o(2584),f={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};i.evaluateKeyboardEvent=function(a,p,m,y){const b={type:0,cancel:!1,key:void 0},n=(a.shiftKey?1:0)|(a.altKey?2:0)|(a.ctrlKey?4:0)|(a.metaKey?8:0);switch(a.keyCode){case 0:a.key==="UIKeyInputUpArrow"?b.key=p?u.C0.ESC+"OA":u.C0.ESC+"[A":a.key==="UIKeyInputLeftArrow"?b.key=p?u.C0.ESC+"OD":u.C0.ESC+"[D":a.key==="UIKeyInputRightArrow"?b.key=p?u.C0.ESC+"OC":u.C0.ESC+"[C":a.key==="UIKeyInputDownArrow"&&(b.key=p?u.C0.ESC+"OB":u.C0.ESC+"[B");break;case 8:if(a.altKey){b.key=u.C0.ESC+u.C0.DEL;break}b.key=u.C0.DEL;break;case 9:if(a.shiftKey){b.key=u.C0.ESC+"[Z";break}b.key=u.C0.HT,b.cancel=!0;break;case 13:b.key=a.altKey?u.C0.ESC+u.C0.CR:u.C0.CR,b.cancel=!0;break;case 27:b.key=u.C0.ESC,a.altKey&&(b.key=u.C0.ESC+u.C0.ESC),b.cancel=!0;break;case 37:if(a.metaKey)break;n?(b.key=u.C0.ESC+"[1;"+(n+1)+"D",b.key===u.C0.ESC+"[1;3D"&&(b.key=u.C0.ESC+(m?"b":"[1;5D"))):b.key=p?u.C0.ESC+"OD":u.C0.ESC+"[D";break;case 39:if(a.metaKey)break;n?(b.key=u.C0.ESC+"[1;"+(n+1)+"C",b.key===u.C0.ESC+"[1;3C"&&(b.key=u.C0.ESC+(m?"f":"[1;5C"))):b.key=p?u.C0.ESC+"OC":u.C0.ESC+"[C";break;case 38:if(a.metaKey)break;n?(b.key=u.C0.ESC+"[1;"+(n+1)+"A",m||b.key!==u.C0.ESC+"[1;3A"||(b.key=u.C0.ESC+"[1;5A")):b.key=p?u.C0.ESC+"OA":u.C0.ESC+"[A";break;case 40:if(a.metaKey)break;n?(b.key=u.C0.ESC+"[1;"+(n+1)+"B",m||b.key!==u.C0.ESC+"[1;3B"||(b.key=u.C0.ESC+"[1;5B")):b.key=p?u.C0.ESC+"OB":u.C0.ESC+"[B";break;case 45:a.shiftKey||a.ctrlKey||(b.key=u.C0.ESC+"[2~");break;case 46:b.key=n?u.C0.ESC+"[3;"+(n+1)+"~":u.C0.ESC+"[3~";break;case 36:b.key=n?u.C0.ESC+"[1;"+(n+1)+"H":p?u.C0.ESC+"OH":u.C0.ESC+"[H";break;case 35:b.key=n?u.C0.ESC+"[1;"+(n+1)+"F":p?u.C0.ESC+"OF":u.C0.ESC+"[F";break;case 33:a.shiftKey?b.type=2:a.ctrlKey?b.key=u.C0.ESC+"[5;"+(n+1)+"~":b.key=u.C0.ESC+"[5~";break;case 34:a.shiftKey?b.type=3:a.ctrlKey?b.key=u.C0.ESC+"[6;"+(n+1)+"~":b.key=u.C0.ESC+"[6~";break;case 112:b.key=n?u.C0.ESC+"[1;"+(n+1)+"P":u.C0.ESC+"OP";break;case 113:b.key=n?u.C0.ESC+"[1;"+(n+1)+"Q":u.C0.ESC+"OQ";break;case 114:b.key=n?u.C0.ESC+"[1;"+(n+1)+"R":u.C0.ESC+"OR";break;case 115:b.key=n?u.C0.ESC+"[1;"+(n+1)+"S":u.C0.ESC+"OS";break;case 116:b.key=n?u.C0.ESC+"[15;"+(n+1)+"~":u.C0.ESC+"[15~";break;case 117:b.key=n?u.C0.ESC+"[17;"+(n+1)+"~":u.C0.ESC+"[17~";break;case 118:b.key=n?u.C0.ESC+"[18;"+(n+1)+"~":u.C0.ESC+"[18~";break;case 119:b.key=n?u.C0.ESC+"[19;"+(n+1)+"~":u.C0.ESC+"[19~";break;case 120:b.key=n?u.C0.ESC+"[20;"+(n+1)+"~":u.C0.ESC+"[20~";break;case 121:b.key=n?u.C0.ESC+"[21;"+(n+1)+"~":u.C0.ESC+"[21~";break;case 122:b.key=n?u.C0.ESC+"[23;"+(n+1)+"~":u.C0.ESC+"[23~";break;case 123:b.key=n?u.C0.ESC+"[24;"+(n+1)+"~":u.C0.ESC+"[24~";break;default:if(!a.ctrlKey||a.shiftKey||a.altKey||a.metaKey)if(m&&!y||!a.altKey||a.metaKey)!m||a.altKey||a.ctrlKey||a.shiftKey||!a.metaKey?a.key&&!a.ctrlKey&&!a.altKey&&!a.metaKey&&a.keyCode>=48&&a.key.length===1?b.key=a.key:a.key&&a.ctrlKey&&(a.key==="_"&&(b.key=u.C0.US),a.key==="@"&&(b.key=u.C0.NUL)):a.keyCode===65&&(b.type=1);else{const d=f[a.keyCode],c=d?.[a.shiftKey?1:0];if(c)b.key=u.C0.ESC+c;else if(a.keyCode>=65&&a.keyCode<=90){const h=a.ctrlKey?a.keyCode-64:a.keyCode+32;let _=String.fromCharCode(h);a.shiftKey&&(_=_.toUpperCase()),b.key=u.C0.ESC+_}else if(a.keyCode===32)b.key=u.C0.ESC+(a.ctrlKey?u.C0.NUL:" ");else if(a.key==="Dead"&&a.code.startsWith("Key")){let h=a.code.slice(3,4);a.shiftKey||(h=h.toLowerCase()),b.key=u.C0.ESC+h,b.cancel=!0}}else a.keyCode>=65&&a.keyCode<=90?b.key=String.fromCharCode(a.keyCode-64):a.keyCode===32?b.key=u.C0.NUL:a.keyCode>=51&&a.keyCode<=55?b.key=String.fromCharCode(a.keyCode-51+27):a.keyCode===56?b.key=u.C0.DEL:a.keyCode===219?b.key=u.C0.ESC:a.keyCode===220?b.key=u.C0.FS:a.keyCode===221&&(b.key=u.C0.GS)}return b}},482:(w,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Utf8ToUtf32=i.StringToUtf32=i.utf32ToString=i.stringFromCodePoint=void 0,i.stringFromCodePoint=function(o){return o>65535?(o-=65536,String.fromCharCode(55296+(o>>10))+String.fromCharCode(o%1024+56320)):String.fromCharCode(o)},i.utf32ToString=function(o,u=0,f=o.length){let a="";for(let p=u;p<f;++p){let m=o[p];m>65535?(m-=65536,a+=String.fromCharCode(55296+(m>>10))+String.fromCharCode(m%1024+56320)):a+=String.fromCharCode(m)}return a},i.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(o,u){const f=o.length;if(!f)return 0;let a=0,p=0;if(this._interim){const m=o.charCodeAt(p++);56320<=m&&m<=57343?u[a++]=1024*(this._interim-55296)+m-56320+65536:(u[a++]=this._interim,u[a++]=m),this._interim=0}for(let m=p;m<f;++m){const y=o.charCodeAt(m);if(55296<=y&&y<=56319){if(++m>=f)return this._interim=y,a;const b=o.charCodeAt(m);56320<=b&&b<=57343?u[a++]=1024*(y-55296)+b-56320+65536:(u[a++]=y,u[a++]=b)}else y!==65279&&(u[a++]=y)}return a}},i.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(o,u){const f=o.length;if(!f)return 0;let a,p,m,y,b=0,n=0,d=0;if(this.interim[0]){let _=!1,S=this.interim[0];S&=(224&S)==192?31:(240&S)==224?15:7;let k,E=0;for(;(k=63&this.interim[++E])&&E<4;)S<<=6,S|=k;const x=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,C=x-E;for(;d<C;){if(d>=f)return 0;if(k=o[d++],(192&k)!=128){d--,_=!0;break}this.interim[E++]=k,S<<=6,S|=63&k}_||(x===2?S<128?d--:u[b++]=S:x===3?S<2048||S>=55296&&S<=57343||S===65279||(u[b++]=S):S<65536||S>1114111||(u[b++]=S)),this.interim.fill(0)}const c=f-4;let h=d;for(;h<f;){for(;!(!(h<c)||128&(a=o[h])||128&(p=o[h+1])||128&(m=o[h+2])||128&(y=o[h+3]));)u[b++]=a,u[b++]=p,u[b++]=m,u[b++]=y,h+=4;if(a=o[h++],a<128)u[b++]=a;else if((224&a)==192){if(h>=f)return this.interim[0]=a,b;if(p=o[h++],(192&p)!=128){h--;continue}if(n=(31&a)<<6|63&p,n<128){h--;continue}u[b++]=n}else if((240&a)==224){if(h>=f)return this.interim[0]=a,b;if(p=o[h++],(192&p)!=128){h--;continue}if(h>=f)return this.interim[0]=a,this.interim[1]=p,b;if(m=o[h++],(192&m)!=128){h--;continue}if(n=(15&a)<<12|(63&p)<<6|63&m,n<2048||n>=55296&&n<=57343||n===65279)continue;u[b++]=n}else if((248&a)==240){if(h>=f)return this.interim[0]=a,b;if(p=o[h++],(192&p)!=128){h--;continue}if(h>=f)return this.interim[0]=a,this.interim[1]=p,b;if(m=o[h++],(192&m)!=128){h--;continue}if(h>=f)return this.interim[0]=a,this.interim[1]=p,this.interim[2]=m,b;if(y=o[h++],(192&y)!=128){h--;continue}if(n=(7&a)<<18|(63&p)<<12|(63&m)<<6|63&y,n<65536||n>1114111)continue;u[b++]=n}}return b}}},225:(w,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeV6=void 0;const o=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],u=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]];let f;i.UnicodeV6=class{constructor(){if(this.version="6",!f){f=new Uint8Array(65536),f.fill(1),f[0]=0,f.fill(0,1,32),f.fill(0,127,160),f.fill(2,4352,4448),f[9001]=2,f[9002]=2,f.fill(2,11904,42192),f[12351]=1,f.fill(2,44032,55204),f.fill(2,63744,64256),f.fill(2,65040,65050),f.fill(2,65072,65136),f.fill(2,65280,65377),f.fill(2,65504,65511);for(let a=0;a<o.length;++a)f.fill(0,o[a][0],o[a][1]+1)}}wcwidth(a){return a<32?0:a<127?1:a<65536?f[a]:(function(p,m){let y,b=0,n=m.length-1;if(p<m[0][0]||p>m[n][1])return!1;for(;n>=b;)if(y=b+n>>1,p>m[y][1])b=y+1;else{if(!(p<m[y][0]))return!0;n=y-1}return!1})(a,u)?0:a>=131072&&a<=196605||a>=196608&&a<=262141?2:1}}},5981:(w,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WriteBuffer=void 0;const u=o(8460),f=o(844);class a extends f.Disposable{constructor(m){super(),this._action=m,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new u.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(m,y){if(y!==void 0&&this._syncCalls>y)return void(this._syncCalls=0);if(this._pendingData+=m.length,this._writeBuffer.push(m),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let b;for(this._isSyncWriting=!0;b=this._writeBuffer.shift();){this._action(b);const n=this._callbacks.shift();n&&n()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(m,y){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=m.length,this._writeBuffer.push(m),this._callbacks.push(y),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=m.length,this._writeBuffer.push(m),this._callbacks.push(y)}_innerWrite(m=0,y=!0){const b=m||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const n=this._writeBuffer[this._bufferOffset],d=this._action(n,y);if(d){const h=_=>Date.now()-b>=12?setTimeout((()=>this._innerWrite(0,_))):this._innerWrite(b,_);return void d.catch((_=>(queueMicrotask((()=>{throw _})),Promise.resolve(!1)))).then(h)}const c=this._callbacks[this._bufferOffset];if(c&&c(),this._bufferOffset++,this._pendingData-=n.length,Date.now()-b>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((()=>this._innerWrite()))):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}i.WriteBuffer=a},5941:(w,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.toRgbString=i.parseColor=void 0;const o=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,u=/^[\da-f]+$/;function f(a,p){const m=a.toString(16),y=m.length<2?"0"+m:m;switch(p){case 4:return m[0];case 8:return y;case 12:return(y+y).slice(0,3);default:return y+y}}i.parseColor=function(a){if(!a)return;let p=a.toLowerCase();if(p.indexOf("rgb:")===0){p=p.slice(4);const m=o.exec(p);if(m){const y=m[1]?15:m[4]?255:m[7]?4095:65535;return[Math.round(parseInt(m[1]||m[4]||m[7]||m[10],16)/y*255),Math.round(parseInt(m[2]||m[5]||m[8]||m[11],16)/y*255),Math.round(parseInt(m[3]||m[6]||m[9]||m[12],16)/y*255)]}}else if(p.indexOf("#")===0&&(p=p.slice(1),u.exec(p)&&[3,6,9,12].includes(p.length))){const m=p.length/3,y=[0,0,0];for(let b=0;b<3;++b){const n=parseInt(p.slice(m*b,m*b+m),16);y[b]=m===1?n<<4:m===2?n:m===3?n>>4:n>>8}return y}},i.toRgbString=function(a,p=16){const[m,y,b]=a;return`rgb:${f(m,p)}/${f(y,p)}/${f(b,p)}`}},5770:(w,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.PAYLOAD_LIMIT=void 0,i.PAYLOAD_LIMIT=1e7},6351:(w,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DcsHandler=i.DcsParser=void 0;const u=o(482),f=o(8742),a=o(5770),p=[];i.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=p,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=p}registerHandler(y,b){this._handlers[y]===void 0&&(this._handlers[y]=[]);const n=this._handlers[y];return n.push(b),{dispose:()=>{const d=n.indexOf(b);d!==-1&&n.splice(d,1)}}}clearHandler(y){this._handlers[y]&&delete this._handlers[y]}setHandlerFallback(y){this._handlerFb=y}reset(){if(this._active.length)for(let y=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;y>=0;--y)this._active[y].unhook(!1);this._stack.paused=!1,this._active=p,this._ident=0}hook(y,b){if(this.reset(),this._ident=y,this._active=this._handlers[y]||p,this._active.length)for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(b);else this._handlerFb(this._ident,"HOOK",b)}put(y,b,n){if(this._active.length)for(let d=this._active.length-1;d>=0;d--)this._active[d].put(y,b,n);else this._handlerFb(this._ident,"PUT",(0,u.utf32ToString)(y,b,n))}unhook(y,b=!0){if(this._active.length){let n=!1,d=this._active.length-1,c=!1;if(this._stack.paused&&(d=this._stack.loopPosition-1,n=b,c=this._stack.fallThrough,this._stack.paused=!1),!c&&n===!1){for(;d>=0&&(n=this._active[d].unhook(y),n!==!0);d--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=d,this._stack.fallThrough=!1,n;d--}for(;d>=0;d--)if(n=this._active[d].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=d,this._stack.fallThrough=!0,n}else this._handlerFb(this._ident,"UNHOOK",y);this._active=p,this._ident=0}};const m=new f.Params;m.addParam(0),i.DcsHandler=class{constructor(y){this._handler=y,this._data="",this._params=m,this._hitLimit=!1}hook(y){this._params=y.length>1||y.params[0]?y.clone():m,this._data="",this._hitLimit=!1}put(y,b,n){this._hitLimit||(this._data+=(0,u.utf32ToString)(y,b,n),this._data.length>a.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(y){let b=!1;if(this._hitLimit)b=!1;else if(y&&(b=this._handler(this._data,this._params),b instanceof Promise))return b.then((n=>(this._params=m,this._data="",this._hitLimit=!1,n)));return this._params=m,this._data="",this._hitLimit=!1,b}}},2015:(w,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.EscapeSequenceParser=i.VT500_TRANSITION_TABLE=i.TransitionTable=void 0;const u=o(844),f=o(8742),a=o(6242),p=o(6351);class m{constructor(d){this.table=new Uint8Array(d)}setDefault(d,c){this.table.fill(d<<4|c)}add(d,c,h,_){this.table[c<<8|d]=h<<4|_}addMany(d,c,h,_){for(let S=0;S<d.length;S++)this.table[c<<8|d[S]]=h<<4|_}}i.TransitionTable=m;const y=160;i.VT500_TRANSITION_TABLE=(function(){const n=new m(4095),d=Array.apply(null,Array(256)).map(((E,x)=>x)),c=(E,x)=>d.slice(E,x),h=c(32,127),_=c(0,24);_.push(25),_.push.apply(_,c(28,32));const S=c(0,14);let k;for(k in n.setDefault(1,0),n.addMany(h,0,2,0),S)n.addMany([24,26,153,154],k,3,0),n.addMany(c(128,144),k,3,0),n.addMany(c(144,152),k,3,0),n.add(156,k,0,0),n.add(27,k,11,1),n.add(157,k,4,8),n.addMany([152,158,159],k,0,7),n.add(155,k,11,3),n.add(144,k,11,9);return n.addMany(_,0,3,0),n.addMany(_,1,3,1),n.add(127,1,0,1),n.addMany(_,8,0,8),n.addMany(_,3,3,3),n.add(127,3,0,3),n.addMany(_,4,3,4),n.add(127,4,0,4),n.addMany(_,6,3,6),n.addMany(_,5,3,5),n.add(127,5,0,5),n.addMany(_,2,3,2),n.add(127,2,0,2),n.add(93,1,4,8),n.addMany(h,8,5,8),n.add(127,8,5,8),n.addMany([156,27,24,26,7],8,6,0),n.addMany(c(28,32),8,0,8),n.addMany([88,94,95],1,0,7),n.addMany(h,7,0,7),n.addMany(_,7,0,7),n.add(156,7,0,0),n.add(127,7,0,7),n.add(91,1,11,3),n.addMany(c(64,127),3,7,0),n.addMany(c(48,60),3,8,4),n.addMany([60,61,62,63],3,9,4),n.addMany(c(48,60),4,8,4),n.addMany(c(64,127),4,7,0),n.addMany([60,61,62,63],4,0,6),n.addMany(c(32,64),6,0,6),n.add(127,6,0,6),n.addMany(c(64,127),6,0,0),n.addMany(c(32,48),3,9,5),n.addMany(c(32,48),5,9,5),n.addMany(c(48,64),5,0,6),n.addMany(c(64,127),5,7,0),n.addMany(c(32,48),4,9,5),n.addMany(c(32,48),1,9,2),n.addMany(c(32,48),2,9,2),n.addMany(c(48,127),2,10,0),n.addMany(c(48,80),1,10,0),n.addMany(c(81,88),1,10,0),n.addMany([89,90,92],1,10,0),n.addMany(c(96,127),1,10,0),n.add(80,1,11,9),n.addMany(_,9,0,9),n.add(127,9,0,9),n.addMany(c(28,32),9,0,9),n.addMany(c(32,48),9,9,12),n.addMany(c(48,60),9,8,10),n.addMany([60,61,62,63],9,9,10),n.addMany(_,11,0,11),n.addMany(c(32,128),11,0,11),n.addMany(c(28,32),11,0,11),n.addMany(_,10,0,10),n.add(127,10,0,10),n.addMany(c(28,32),10,0,10),n.addMany(c(48,60),10,8,10),n.addMany([60,61,62,63],10,0,11),n.addMany(c(32,48),10,9,12),n.addMany(_,12,0,12),n.add(127,12,0,12),n.addMany(c(28,32),12,0,12),n.addMany(c(32,48),12,9,12),n.addMany(c(48,64),12,0,11),n.addMany(c(64,127),12,12,13),n.addMany(c(64,127),10,12,13),n.addMany(c(64,127),9,12,13),n.addMany(_,13,13,13),n.addMany(h,13,13,13),n.add(127,13,0,13),n.addMany([27,156,24,26],13,14,0),n.add(y,0,2,0),n.add(y,8,5,8),n.add(y,6,0,6),n.add(y,11,0,11),n.add(y,13,13,13),n})();class b extends u.Disposable{constructor(d=i.VT500_TRANSITION_TABLE){super(),this._transitions=d,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new f.Params,this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._printHandlerFb=(c,h,_)=>{},this._executeHandlerFb=c=>{},this._csiHandlerFb=(c,h)=>{},this._escHandlerFb=c=>{},this._errorHandlerFb=c=>c,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,u.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new a.OscParser),this._dcsParser=this.register(new p.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(d,c=[64,126]){let h=0;if(d.prefix){if(d.prefix.length>1)throw new Error("only one byte as prefix supported");if(h=d.prefix.charCodeAt(0),h&&60>h||h>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(d.intermediates){if(d.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let S=0;S<d.intermediates.length;++S){const k=d.intermediates.charCodeAt(S);if(32>k||k>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");h<<=8,h|=k}}if(d.final.length!==1)throw new Error("final must be a single byte");const _=d.final.charCodeAt(0);if(c[0]>_||_>c[1])throw new Error(`final must be in range ${c[0]} .. ${c[1]}`);return h<<=8,h|=_,h}identToString(d){const c=[];for(;d;)c.push(String.fromCharCode(255&d)),d>>=8;return c.reverse().join("")}setPrintHandler(d){this._printHandler=d}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(d,c){const h=this._identifier(d,[48,126]);this._escHandlers[h]===void 0&&(this._escHandlers[h]=[]);const _=this._escHandlers[h];return _.push(c),{dispose:()=>{const S=_.indexOf(c);S!==-1&&_.splice(S,1)}}}clearEscHandler(d){this._escHandlers[this._identifier(d,[48,126])]&&delete this._escHandlers[this._identifier(d,[48,126])]}setEscHandlerFallback(d){this._escHandlerFb=d}setExecuteHandler(d,c){this._executeHandlers[d.charCodeAt(0)]=c}clearExecuteHandler(d){this._executeHandlers[d.charCodeAt(0)]&&delete this._executeHandlers[d.charCodeAt(0)]}setExecuteHandlerFallback(d){this._executeHandlerFb=d}registerCsiHandler(d,c){const h=this._identifier(d);this._csiHandlers[h]===void 0&&(this._csiHandlers[h]=[]);const _=this._csiHandlers[h];return _.push(c),{dispose:()=>{const S=_.indexOf(c);S!==-1&&_.splice(S,1)}}}clearCsiHandler(d){this._csiHandlers[this._identifier(d)]&&delete this._csiHandlers[this._identifier(d)]}setCsiHandlerFallback(d){this._csiHandlerFb=d}registerDcsHandler(d,c){return this._dcsParser.registerHandler(this._identifier(d),c)}clearDcsHandler(d){this._dcsParser.clearHandler(this._identifier(d))}setDcsHandlerFallback(d){this._dcsParser.setHandlerFallback(d)}registerOscHandler(d,c){return this._oscParser.registerHandler(d,c)}clearOscHandler(d){this._oscParser.clearHandler(d)}setOscHandlerFallback(d){this._oscParser.setHandlerFallback(d)}setErrorHandler(d){this._errorHandler=d}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(d,c,h,_,S){this._parseStack.state=d,this._parseStack.handlers=c,this._parseStack.handlerPos=h,this._parseStack.transition=_,this._parseStack.chunkPos=S}parse(d,c,h){let _,S=0,k=0,E=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,E=this._parseStack.chunkPos+1;else{if(h===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const x=this._parseStack.handlers;let C=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(h===!1&&C>-1){for(;C>=0&&(_=x[C](this._params),_!==!0);C--)if(_ instanceof Promise)return this._parseStack.handlerPos=C,_}this._parseStack.handlers=[];break;case 4:if(h===!1&&C>-1){for(;C>=0&&(_=x[C](),_!==!0);C--)if(_ instanceof Promise)return this._parseStack.handlerPos=C,_}this._parseStack.handlers=[];break;case 6:if(S=d[this._parseStack.chunkPos],_=this._dcsParser.unhook(S!==24&&S!==26,h),_)return _;S===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(S=d[this._parseStack.chunkPos],_=this._oscParser.end(S!==24&&S!==26,h),_)return _;S===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,E=this._parseStack.chunkPos+1,this.precedingCodepoint=0,this.currentState=15&this._parseStack.transition}for(let x=E;x<c;++x){switch(S=d[x],k=this._transitions.table[this.currentState<<8|(S<160?S:y)],k>>4){case 2:for(let M=x+1;;++M){if(M>=c||(S=d[M])<32||S>126&&S<y){this._printHandler(d,x,M),x=M-1;break}if(++M>=c||(S=d[M])<32||S>126&&S<y){this._printHandler(d,x,M),x=M-1;break}if(++M>=c||(S=d[M])<32||S>126&&S<y){this._printHandler(d,x,M),x=M-1;break}if(++M>=c||(S=d[M])<32||S>126&&S<y){this._printHandler(d,x,M),x=M-1;break}}break;case 3:this._executeHandlers[S]?this._executeHandlers[S]():this._executeHandlerFb(S),this.precedingCodepoint=0;break;case 0:break;case 1:if(this._errorHandler({position:x,code:S,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const C=this._csiHandlers[this._collect<<8|S];let T=C?C.length-1:-1;for(;T>=0&&(_=C[T](this._params),_!==!0);T--)if(_ instanceof Promise)return this._preserveStack(3,C,T,k,x),_;T<0&&this._csiHandlerFb(this._collect<<8|S,this._params),this.precedingCodepoint=0;break;case 8:do switch(S){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(S-48)}while(++x<c&&(S=d[x])>47&&S<60);x--;break;case 9:this._collect<<=8,this._collect|=S;break;case 10:const L=this._escHandlers[this._collect<<8|S];let R=L?L.length-1:-1;for(;R>=0&&(_=L[R](),_!==!0);R--)if(_ instanceof Promise)return this._preserveStack(4,L,R,k,x),_;R<0&&this._escHandlerFb(this._collect<<8|S),this.precedingCodepoint=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|S,this._params);break;case 13:for(let M=x+1;;++M)if(M>=c||(S=d[M])===24||S===26||S===27||S>127&&S<y){this._dcsParser.put(d,x,M),x=M-1;break}break;case 14:if(_=this._dcsParser.unhook(S!==24&&S!==26),_)return this._preserveStack(6,[],0,k,x),_;S===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0;break;case 4:this._oscParser.start();break;case 5:for(let M=x+1;;M++)if(M>=c||(S=d[M])<32||S>127&&S<y){this._oscParser.put(d,x,M),x=M-1;break}break;case 6:if(_=this._oscParser.end(S!==24&&S!==26),_)return this._preserveStack(5,[],0,k,x),_;S===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0}this.currentState=15&k}}}i.EscapeSequenceParser=b},6242:(w,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.OscHandler=i.OscParser=void 0;const u=o(5770),f=o(482),a=[];i.OscParser=class{constructor(){this._state=0,this._active=a,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(p,m){this._handlers[p]===void 0&&(this._handlers[p]=[]);const y=this._handlers[p];return y.push(m),{dispose:()=>{const b=y.indexOf(m);b!==-1&&y.splice(b,1)}}}clearHandler(p){this._handlers[p]&&delete this._handlers[p]}setHandlerFallback(p){this._handlerFb=p}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=a}reset(){if(this._state===2)for(let p=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;p>=0;--p)this._active[p].end(!1);this._stack.paused=!1,this._active=a,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||a,this._active.length)for(let p=this._active.length-1;p>=0;p--)this._active[p].start();else this._handlerFb(this._id,"START")}_put(p,m,y){if(this._active.length)for(let b=this._active.length-1;b>=0;b--)this._active[b].put(p,m,y);else this._handlerFb(this._id,"PUT",(0,f.utf32ToString)(p,m,y))}start(){this.reset(),this._state=1}put(p,m,y){if(this._state!==3){if(this._state===1)for(;m<y;){const b=p[m++];if(b===59){this._state=2,this._start();break}if(b<48||57<b)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+b-48}this._state===2&&y-m>0&&this._put(p,m,y)}}end(p,m=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let y=!1,b=this._active.length-1,n=!1;if(this._stack.paused&&(b=this._stack.loopPosition-1,y=m,n=this._stack.fallThrough,this._stack.paused=!1),!n&&y===!1){for(;b>=0&&(y=this._active[b].end(p),y!==!0);b--)if(y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=b,this._stack.fallThrough=!1,y;b--}for(;b>=0;b--)if(y=this._active[b].end(!1),y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=b,this._stack.fallThrough=!0,y}else this._handlerFb(this._id,"END",p);this._active=a,this._id=-1,this._state=0}}},i.OscHandler=class{constructor(p){this._handler=p,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(p,m,y){this._hitLimit||(this._data+=(0,f.utf32ToString)(p,m,y),this._data.length>u.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(p){let m=!1;if(this._hitLimit)m=!1;else if(p&&(m=this._handler(this._data),m instanceof Promise))return m.then((y=>(this._data="",this._hitLimit=!1,y)));return this._data="",this._hitLimit=!1,m}}},8742:(w,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Params=void 0;const o=2147483647;class u{static fromArray(a){const p=new u;if(!a.length)return p;for(let m=Array.isArray(a[0])?1:0;m<a.length;++m){const y=a[m];if(Array.isArray(y))for(let b=0;b<y.length;++b)p.addSubParam(y[b]);else p.addParam(y)}return p}constructor(a=32,p=32){if(this.maxLength=a,this.maxSubParamsLength=p,p>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(a),this.length=0,this._subParams=new Int32Array(p),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(a),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const a=new u(this.maxLength,this.maxSubParamsLength);return a.params.set(this.params),a.length=this.length,a._subParams.set(this._subParams),a._subParamsLength=this._subParamsLength,a._subParamsIdx.set(this._subParamsIdx),a._rejectDigits=this._rejectDigits,a._rejectSubDigits=this._rejectSubDigits,a._digitIsSub=this._digitIsSub,a}toArray(){const a=[];for(let p=0;p<this.length;++p){a.push(this.params[p]);const m=this._subParamsIdx[p]>>8,y=255&this._subParamsIdx[p];y-m>0&&a.push(Array.prototype.slice.call(this._subParams,m,y))}return a}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(a){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(a<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=a>o?o:a}}addSubParam(a){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(a<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=a>o?o:a,this._subParamsIdx[this.length-1]++}}hasSubParams(a){return(255&this._subParamsIdx[a])-(this._subParamsIdx[a]>>8)>0}getSubParams(a){const p=this._subParamsIdx[a]>>8,m=255&this._subParamsIdx[a];return m-p>0?this._subParams.subarray(p,m):null}getSubParamsAll(){const a={};for(let p=0;p<this.length;++p){const m=this._subParamsIdx[p]>>8,y=255&this._subParamsIdx[p];y-m>0&&(a[p]=this._subParams.slice(m,y))}return a}addDigit(a){let p;if(this._rejectDigits||!(p=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const m=this._digitIsSub?this._subParams:this.params,y=m[p-1];m[p-1]=~y?Math.min(10*y+a,o):a}}i.Params=u},5741:(w,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.AddonManager=void 0,i.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let o=this._addons.length-1;o>=0;o--)this._addons[o].instance.dispose()}loadAddon(o,u){const f={instance:u,dispose:u.dispose,isDisposed:!1};this._addons.push(f),u.dispose=()=>this._wrappedAddonDispose(f),u.activate(o)}_wrappedAddonDispose(o){if(o.isDisposed)return;let u=-1;for(let f=0;f<this._addons.length;f++)if(this._addons[f]===o){u=f;break}if(u===-1)throw new Error("Could not dispose an addon that has not been loaded");o.isDisposed=!0,o.dispose.apply(o.instance),this._addons.splice(u,1)}}},8771:(w,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferApiView=void 0;const u=o(3785),f=o(511);i.BufferApiView=class{constructor(a,p){this._buffer=a,this.type=p}init(a){return this._buffer=a,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(a){const p=this._buffer.lines.get(a);if(p)return new u.BufferLineApiView(p)}getNullCell(){return new f.CellData}}},3785:(w,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferLineApiView=void 0;const u=o(511);i.BufferLineApiView=class{constructor(f){this._line=f}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(f,a){if(!(f<0||f>=this._line.length))return a?(this._line.loadCell(f,a),a):this._line.loadCell(f,new u.CellData)}translateToString(f,a,p){return this._line.translateToString(f,a,p)}}},8285:(w,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferNamespaceApi=void 0;const u=o(8771),f=o(8460),a=o(844);class p extends a.Disposable{constructor(y){super(),this._core=y,this._onBufferChange=this.register(new f.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new u.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new u.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate((()=>this._onBufferChange.fire(this.active)))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}i.BufferNamespaceApi=p},7975:(w,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ParserApi=void 0,i.ParserApi=class{constructor(o){this._core=o}registerCsiHandler(o,u){return this._core.registerCsiHandler(o,(f=>u(f.toArray())))}addCsiHandler(o,u){return this.registerCsiHandler(o,u)}registerDcsHandler(o,u){return this._core.registerDcsHandler(o,((f,a)=>u(f,a.toArray())))}addDcsHandler(o,u){return this.registerDcsHandler(o,u)}registerEscHandler(o,u){return this._core.registerEscHandler(o,u)}addEscHandler(o,u){return this.registerEscHandler(o,u)}registerOscHandler(o,u){return this._core.registerOscHandler(o,u)}addOscHandler(o,u){return this.registerOscHandler(o,u)}}},7090:(w,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeApi=void 0,i.UnicodeApi=class{constructor(o){this._core=o}register(o){this._core.unicodeService.register(o)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(o){this._core.unicodeService.activeVersion=o}}},744:function(w,i,o){var u=this&&this.__decorate||function(n,d,c,h){var _,S=arguments.length,k=S<3?d:h===null?h=Object.getOwnPropertyDescriptor(d,c):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(n,d,c,h);else for(var E=n.length-1;E>=0;E--)(_=n[E])&&(k=(S<3?_(k):S>3?_(d,c,k):_(d,c))||k);return S>3&&k&&Object.defineProperty(d,c,k),k},f=this&&this.__param||function(n,d){return function(c,h){d(c,h,n)}};Object.defineProperty(i,"__esModule",{value:!0}),i.BufferService=i.MINIMUM_ROWS=i.MINIMUM_COLS=void 0;const a=o(8460),p=o(844),m=o(5295),y=o(2585);i.MINIMUM_COLS=2,i.MINIMUM_ROWS=1;let b=i.BufferService=class extends p.Disposable{get buffer(){return this.buffers.active}constructor(n){super(),this.isUserScrolling=!1,this._onResize=this.register(new a.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new a.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(n.rawOptions.cols||0,i.MINIMUM_COLS),this.rows=Math.max(n.rawOptions.rows||0,i.MINIMUM_ROWS),this.buffers=this.register(new m.BufferSet(n,this))}resize(n,d){this.cols=n,this.rows=d,this.buffers.resize(n,d),this._onResize.fire({cols:n,rows:d})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(n,d=!1){const c=this.buffer;let h;h=this._cachedBlankLine,h&&h.length===this.cols&&h.getFg(0)===n.fg&&h.getBg(0)===n.bg||(h=c.getBlankLine(n,d),this._cachedBlankLine=h),h.isWrapped=d;const _=c.ybase+c.scrollTop,S=c.ybase+c.scrollBottom;if(c.scrollTop===0){const k=c.lines.isFull;S===c.lines.length-1?k?c.lines.recycle().copyFrom(h):c.lines.push(h.clone()):c.lines.splice(S+1,0,h.clone()),k?this.isUserScrolling&&(c.ydisp=Math.max(c.ydisp-1,0)):(c.ybase++,this.isUserScrolling||c.ydisp++)}else{const k=S-_+1;c.lines.shiftElements(_+1,k-1,-1),c.lines.set(S,h.clone())}this.isUserScrolling||(c.ydisp=c.ybase),this._onScroll.fire(c.ydisp)}scrollLines(n,d,c){const h=this.buffer;if(n<0){if(h.ydisp===0)return;this.isUserScrolling=!0}else n+h.ydisp>=h.ybase&&(this.isUserScrolling=!1);const _=h.ydisp;h.ydisp=Math.max(Math.min(h.ydisp+n,h.ybase),0),_!==h.ydisp&&(d||this._onScroll.fire(h.ydisp))}};i.BufferService=b=u([f(0,y.IOptionsService)],b)},7994:(w,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(o){this.glevel=o,this.charset=this._charsets[o]}setgCharset(o,u){this._charsets[o]=u,this.glevel===o&&(this.charset=u)}}},1753:function(w,i,o){var u=this&&this.__decorate||function(h,_,S,k){var E,x=arguments.length,C=x<3?_:k===null?k=Object.getOwnPropertyDescriptor(_,S):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(h,_,S,k);else for(var T=h.length-1;T>=0;T--)(E=h[T])&&(C=(x<3?E(C):x>3?E(_,S,C):E(_,S))||C);return x>3&&C&&Object.defineProperty(_,S,C),C},f=this&&this.__param||function(h,_){return function(S,k){_(S,k,h)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CoreMouseService=void 0;const a=o(2585),p=o(8460),m=o(844),y={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:h=>h.button!==4&&h.action===1&&(h.ctrl=!1,h.alt=!1,h.shift=!1,!0)},VT200:{events:19,restrict:h=>h.action!==32},DRAG:{events:23,restrict:h=>h.action!==32||h.button!==3},ANY:{events:31,restrict:h=>!0}};function b(h,_){let S=(h.ctrl?16:0)|(h.shift?4:0)|(h.alt?8:0);return h.button===4?(S|=64,S|=h.action):(S|=3&h.button,4&h.button&&(S|=64),8&h.button&&(S|=128),h.action===32?S|=32:h.action!==0||_||(S|=3)),S}const n=String.fromCharCode,d={DEFAULT:h=>{const _=[b(h,!1)+32,h.col+32,h.row+32];return _[0]>255||_[1]>255||_[2]>255?"":`\x1B[M${n(_[0])}${n(_[1])}${n(_[2])}`},SGR:h=>{const _=h.action===0&&h.button!==4?"m":"M";return`\x1B[<${b(h,!0)};${h.col};${h.row}${_}`},SGR_PIXELS:h=>{const _=h.action===0&&h.button!==4?"m":"M";return`\x1B[<${b(h,!0)};${h.x};${h.y}${_}`}};let c=i.CoreMouseService=class extends m.Disposable{constructor(h,_){super(),this._bufferService=h,this._coreService=_,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new p.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const S of Object.keys(y))this.addProtocol(S,y[S]);for(const S of Object.keys(d))this.addEncoding(S,d[S]);this.reset()}addProtocol(h,_){this._protocols[h]=_}addEncoding(h,_){this._encodings[h]=_}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(h){if(!this._protocols[h])throw new Error(`unknown protocol "${h}"`);this._activeProtocol=h,this._onProtocolChange.fire(this._protocols[h].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(h){if(!this._encodings[h])throw new Error(`unknown encoding "${h}"`);this._activeEncoding=h}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(h){if(h.col<0||h.col>=this._bufferService.cols||h.row<0||h.row>=this._bufferService.rows||h.button===4&&h.action===32||h.button===3&&h.action!==32||h.button!==4&&(h.action===2||h.action===3)||(h.col++,h.row++,h.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,h,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(h))return!1;const _=this._encodings[this._activeEncoding](h);return _&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(_):this._coreService.triggerDataEvent(_,!0)),this._lastEvent=h,!0}explainEvents(h){return{down:!!(1&h),up:!!(2&h),drag:!!(4&h),move:!!(8&h),wheel:!!(16&h)}}_equalEvents(h,_,S){if(S){if(h.x!==_.x||h.y!==_.y)return!1}else if(h.col!==_.col||h.row!==_.row)return!1;return h.button===_.button&&h.action===_.action&&h.ctrl===_.ctrl&&h.alt===_.alt&&h.shift===_.shift}};i.CoreMouseService=c=u([f(0,a.IBufferService),f(1,a.ICoreService)],c)},6975:function(w,i,o){var u=this&&this.__decorate||function(c,h,_,S){var k,E=arguments.length,x=E<3?h:S===null?S=Object.getOwnPropertyDescriptor(h,_):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")x=Reflect.decorate(c,h,_,S);else for(var C=c.length-1;C>=0;C--)(k=c[C])&&(x=(E<3?k(x):E>3?k(h,_,x):k(h,_))||x);return E>3&&x&&Object.defineProperty(h,_,x),x},f=this&&this.__param||function(c,h){return function(_,S){h(_,S,c)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CoreService=void 0;const a=o(1439),p=o(8460),m=o(844),y=o(2585),b=Object.freeze({insertMode:!1}),n=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let d=i.CoreService=class extends m.Disposable{constructor(c,h,_){super(),this._bufferService=c,this._logService=h,this._optionsService=_,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new p.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new p.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new p.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new p.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,a.clone)(b),this.decPrivateModes=(0,a.clone)(n)}reset(){this.modes=(0,a.clone)(b),this.decPrivateModes=(0,a.clone)(n)}triggerDataEvent(c,h=!1){if(this._optionsService.rawOptions.disableStdin)return;const _=this._bufferService.buffer;h&&this._optionsService.rawOptions.scrollOnUserInput&&_.ybase!==_.ydisp&&this._onRequestScrollToBottom.fire(),h&&this._onUserInput.fire(),this._logService.debug(`sending data "${c}"`,(()=>c.split("").map((S=>S.charCodeAt(0))))),this._onData.fire(c)}triggerBinaryEvent(c){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${c}"`,(()=>c.split("").map((h=>h.charCodeAt(0))))),this._onBinary.fire(c))}};i.CoreService=d=u([f(0,y.IBufferService),f(1,y.ILogService),f(2,y.IOptionsService)],d)},9074:(w,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DecorationService=void 0;const u=o(8055),f=o(8460),a=o(844),p=o(6106);let m=0,y=0;class b extends a.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new p.SortedList((c=>c?.marker.line)),this._onDecorationRegistered=this.register(new f.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new f.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,a.toDisposable)((()=>this.reset())))}registerDecoration(c){if(c.marker.isDisposed)return;const h=new n(c);if(h){const _=h.marker.onDispose((()=>h.dispose()));h.onDispose((()=>{h&&(this._decorations.delete(h)&&this._onDecorationRemoved.fire(h),_.dispose())})),this._decorations.insert(h),this._onDecorationRegistered.fire(h)}return h}reset(){for(const c of this._decorations.values())c.dispose();this._decorations.clear()}*getDecorationsAtCell(c,h,_){var S,k,E;let x=0,C=0;for(const T of this._decorations.getKeyIterator(h))x=(S=T.options.x)!==null&&S!==void 0?S:0,C=x+((k=T.options.width)!==null&&k!==void 0?k:1),c>=x&&c<C&&(!_||((E=T.options.layer)!==null&&E!==void 0?E:"bottom")===_)&&(yield T)}forEachDecorationAtCell(c,h,_,S){this._decorations.forEachByKey(h,(k=>{var E,x,C;m=(E=k.options.x)!==null&&E!==void 0?E:0,y=m+((x=k.options.width)!==null&&x!==void 0?x:1),c>=m&&c<y&&(!_||((C=k.options.layer)!==null&&C!==void 0?C:"bottom")===_)&&S(k)}))}}i.DecorationService=b;class n extends a.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=u.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=u.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(c){super(),this.options=c,this.onRenderEmitter=this.register(new f.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new f.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=c.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(w,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.InstantiationService=i.ServiceCollection=void 0;const u=o(2585),f=o(8343);class a{constructor(...m){this._entries=new Map;for(const[y,b]of m)this.set(y,b)}set(m,y){const b=this._entries.get(m);return this._entries.set(m,y),b}forEach(m){for(const[y,b]of this._entries.entries())m(y,b)}has(m){return this._entries.has(m)}get(m){return this._entries.get(m)}}i.ServiceCollection=a,i.InstantiationService=class{constructor(){this._services=new a,this._services.set(u.IInstantiationService,this)}setService(p,m){this._services.set(p,m)}getService(p){return this._services.get(p)}createInstance(p,...m){const y=(0,f.getServiceDependencies)(p).sort(((d,c)=>d.index-c.index)),b=[];for(const d of y){const c=this._services.get(d.id);if(!c)throw new Error(`[createInstance] ${p.name} depends on UNKNOWN service ${d.id}.`);b.push(c)}const n=y.length>0?y[0].index:m.length;if(m.length!==n)throw new Error(`[createInstance] First service dependency of ${p.name} at position ${n+1} conflicts with ${m.length} static arguments`);return new p(...m,...b)}}},7866:function(w,i,o){var u=this&&this.__decorate||function(n,d,c,h){var _,S=arguments.length,k=S<3?d:h===null?h=Object.getOwnPropertyDescriptor(d,c):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(n,d,c,h);else for(var E=n.length-1;E>=0;E--)(_=n[E])&&(k=(S<3?_(k):S>3?_(d,c,k):_(d,c))||k);return S>3&&k&&Object.defineProperty(d,c,k),k},f=this&&this.__param||function(n,d){return function(c,h){d(c,h,n)}};Object.defineProperty(i,"__esModule",{value:!0}),i.traceCall=i.setTraceLogger=i.LogService=void 0;const a=o(844),p=o(2585),m={trace:p.LogLevelEnum.TRACE,debug:p.LogLevelEnum.DEBUG,info:p.LogLevelEnum.INFO,warn:p.LogLevelEnum.WARN,error:p.LogLevelEnum.ERROR,off:p.LogLevelEnum.OFF};let y,b=i.LogService=class extends a.Disposable{get logLevel(){return this._logLevel}constructor(n){super(),this._optionsService=n,this._logLevel=p.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),y=this}_updateLogLevel(){this._logLevel=m[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(n){for(let d=0;d<n.length;d++)typeof n[d]=="function"&&(n[d]=n[d]())}_log(n,d,c){this._evalLazyOptionalParams(c),n.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+d,...c)}trace(n,...d){var c,h;this._logLevel<=p.LogLevelEnum.TRACE&&this._log((h=(c=this._optionsService.options.logger)===null||c===void 0?void 0:c.trace.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.log,n,d)}debug(n,...d){var c,h;this._logLevel<=p.LogLevelEnum.DEBUG&&this._log((h=(c=this._optionsService.options.logger)===null||c===void 0?void 0:c.debug.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.log,n,d)}info(n,...d){var c,h;this._logLevel<=p.LogLevelEnum.INFO&&this._log((h=(c=this._optionsService.options.logger)===null||c===void 0?void 0:c.info.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.info,n,d)}warn(n,...d){var c,h;this._logLevel<=p.LogLevelEnum.WARN&&this._log((h=(c=this._optionsService.options.logger)===null||c===void 0?void 0:c.warn.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.warn,n,d)}error(n,...d){var c,h;this._logLevel<=p.LogLevelEnum.ERROR&&this._log((h=(c=this._optionsService.options.logger)===null||c===void 0?void 0:c.error.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.error,n,d)}};i.LogService=b=u([f(0,p.IOptionsService)],b),i.setTraceLogger=function(n){y=n},i.traceCall=function(n,d,c){if(typeof c.value!="function")throw new Error("not supported");const h=c.value;c.value=function(..._){if(y.logLevel!==p.LogLevelEnum.TRACE)return h.apply(this,_);y.trace(`GlyphRenderer#${h.name}(${_.map((k=>JSON.stringify(k))).join(", ")})`);const S=h.apply(this,_);return y.trace(`GlyphRenderer#${h.name} return`,S),S}}},7302:(w,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.OptionsService=i.DEFAULT_OPTIONS=void 0;const u=o(8460),f=o(844),a=o(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:a.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const p=["normal","bold","100","200","300","400","500","600","700","800","900"];class m extends f.Disposable{constructor(b){super(),this._onOptionChange=this.register(new u.EventEmitter),this.onOptionChange=this._onOptionChange.event;const n=Object.assign({},i.DEFAULT_OPTIONS);for(const d in b)if(d in n)try{const c=b[d];n[d]=this._sanitizeAndValidateOption(d,c)}catch(c){console.error(c)}this.rawOptions=n,this.options=Object.assign({},n),this._setupOptions()}onSpecificOptionChange(b,n){return this.onOptionChange((d=>{d===b&&n(this.rawOptions[b])}))}onMultipleOptionChange(b,n){return this.onOptionChange((d=>{b.indexOf(d)!==-1&&n()}))}_setupOptions(){const b=d=>{if(!(d in i.DEFAULT_OPTIONS))throw new Error(`No option with key "${d}"`);return this.rawOptions[d]},n=(d,c)=>{if(!(d in i.DEFAULT_OPTIONS))throw new Error(`No option with key "${d}"`);c=this._sanitizeAndValidateOption(d,c),this.rawOptions[d]!==c&&(this.rawOptions[d]=c,this._onOptionChange.fire(d))};for(const d in this.rawOptions){const c={get:b.bind(this,d),set:n.bind(this,d)};Object.defineProperty(this.options,d,c)}}_sanitizeAndValidateOption(b,n){switch(b){case"cursorStyle":if(n||(n=i.DEFAULT_OPTIONS[b]),!(function(d){return d==="block"||d==="underline"||d==="bar"})(n))throw new Error(`"${n}" is not a valid value for ${b}`);break;case"wordSeparator":n||(n=i.DEFAULT_OPTIONS[b]);break;case"fontWeight":case"fontWeightBold":if(typeof n=="number"&&1<=n&&n<=1e3)break;n=p.includes(n)?n:i.DEFAULT_OPTIONS[b];break;case"cursorWidth":n=Math.floor(n);case"lineHeight":case"tabStopWidth":if(n<1)throw new Error(`${b} cannot be less than 1, value: ${n}`);break;case"minimumContrastRatio":n=Math.max(1,Math.min(21,Math.round(10*n)/10));break;case"scrollback":if((n=Math.min(n,4294967295))<0)throw new Error(`${b} cannot be less than 0, value: ${n}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(n<=0)throw new Error(`${b} cannot be less than or equal to 0, value: ${n}`);break;case"rows":case"cols":if(!n&&n!==0)throw new Error(`${b} must be numeric, value: ${n}`);break;case"windowsPty":n=n??{}}return n}}i.OptionsService=m},2660:function(w,i,o){var u=this&&this.__decorate||function(m,y,b,n){var d,c=arguments.length,h=c<3?y:n===null?n=Object.getOwnPropertyDescriptor(y,b):n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")h=Reflect.decorate(m,y,b,n);else for(var _=m.length-1;_>=0;_--)(d=m[_])&&(h=(c<3?d(h):c>3?d(y,b,h):d(y,b))||h);return c>3&&h&&Object.defineProperty(y,b,h),h},f=this&&this.__param||function(m,y){return function(b,n){y(b,n,m)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OscLinkService=void 0;const a=o(2585);let p=i.OscLinkService=class{constructor(m){this._bufferService=m,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(m){const y=this._bufferService.buffer;if(m.id===void 0){const _=y.addMarker(y.ybase+y.y),S={data:m,id:this._nextId++,lines:[_]};return _.onDispose((()=>this._removeMarkerFromLink(S,_))),this._dataByLinkId.set(S.id,S),S.id}const b=m,n=this._getEntryIdKey(b),d=this._entriesWithId.get(n);if(d)return this.addLineToLink(d.id,y.ybase+y.y),d.id;const c=y.addMarker(y.ybase+y.y),h={id:this._nextId++,key:this._getEntryIdKey(b),data:b,lines:[c]};return c.onDispose((()=>this._removeMarkerFromLink(h,c))),this._entriesWithId.set(h.key,h),this._dataByLinkId.set(h.id,h),h.id}addLineToLink(m,y){const b=this._dataByLinkId.get(m);if(b&&b.lines.every((n=>n.line!==y))){const n=this._bufferService.buffer.addMarker(y);b.lines.push(n),n.onDispose((()=>this._removeMarkerFromLink(b,n)))}}getLinkData(m){var y;return(y=this._dataByLinkId.get(m))===null||y===void 0?void 0:y.data}_getEntryIdKey(m){return`${m.id};;${m.uri}`}_removeMarkerFromLink(m,y){const b=m.lines.indexOf(y);b!==-1&&(m.lines.splice(b,1),m.lines.length===0&&(m.data.id!==void 0&&this._entriesWithId.delete(m.key),this._dataByLinkId.delete(m.id)))}};i.OscLinkService=p=u([f(0,a.IBufferService)],p)},8343:(w,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.createDecorator=i.getServiceDependencies=i.serviceRegistry=void 0;const o="di$target",u="di$dependencies";i.serviceRegistry=new Map,i.getServiceDependencies=function(f){return f[u]||[]},i.createDecorator=function(f){if(i.serviceRegistry.has(f))return i.serviceRegistry.get(f);const a=function(p,m,y){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(b,n,d){n[o]===n?n[u].push({id:b,index:d}):(n[u]=[{id:b,index:d}],n[o]=n)})(a,p,y)};return a.toString=()=>f,i.serviceRegistry.set(f,a),a}},2585:(w,i,o)=>{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 u=o(8343);var f;i.IBufferService=(0,u.createDecorator)("BufferService"),i.ICoreMouseService=(0,u.createDecorator)("CoreMouseService"),i.ICoreService=(0,u.createDecorator)("CoreService"),i.ICharsetService=(0,u.createDecorator)("CharsetService"),i.IInstantiationService=(0,u.createDecorator)("InstantiationService"),(function(a){a[a.TRACE=0]="TRACE",a[a.DEBUG=1]="DEBUG",a[a.INFO=2]="INFO",a[a.WARN=3]="WARN",a[a.ERROR=4]="ERROR",a[a.OFF=5]="OFF"})(f||(i.LogLevelEnum=f={})),i.ILogService=(0,u.createDecorator)("LogService"),i.IOptionsService=(0,u.createDecorator)("OptionsService"),i.IOscLinkService=(0,u.createDecorator)("OscLinkService"),i.IUnicodeService=(0,u.createDecorator)("UnicodeService"),i.IDecorationService=(0,u.createDecorator)("DecorationService")},1480:(w,i,o)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeService=void 0;const u=o(8460),f=o(225);i.UnicodeService=class{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new u.EventEmitter,this.onChange=this._onChange.event;const a=new f.UnicodeV6;this.register(a),this._active=a.version,this._activeProvider=a}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(a){if(!this._providers[a])throw new Error(`unknown Unicode version "${a}"`);this._active=a,this._activeProvider=this._providers[a],this._onChange.fire(a)}register(a){this._providers[a.version]=a}wcwidth(a){return this._activeProvider.wcwidth(a)}getStringCellWidth(a){let p=0;const m=a.length;for(let y=0;y<m;++y){let b=a.charCodeAt(y);if(55296<=b&&b<=56319){if(++y>=m)return p+this.wcwidth(b);const n=a.charCodeAt(y);56320<=n&&n<=57343?b=1024*(b-55296)+n-56320+65536:p+=this.wcwidth(n)}p+=this.wcwidth(b)}return p}}}},l={};function g(w){var i=l[w];if(i!==void 0)return i.exports;var o=l[w]={exports:{}};return s[w].call(o.exports,o,o.exports,g),o.exports}var v={};return(()=>{var w=v;Object.defineProperty(w,"__esModule",{value:!0}),w.Terminal=void 0;const i=g(9042),o=g(3236),u=g(844),f=g(5741),a=g(8285),p=g(7975),m=g(7090),y=["cols","rows"];class b extends u.Disposable{constructor(d){super(),this._core=this.register(new o.Terminal(d)),this._addonManager=this.register(new f.AddonManager),this._publicOptions=Object.assign({},this._core.options);const c=_=>this._core.options[_],h=(_,S)=>{this._checkReadonlyOptions(_),this._core.options[_]=S};for(const _ in this._core.options){const S={get:c.bind(this,_),set:h.bind(this,_)};Object.defineProperty(this._publicOptions,_,S)}}_checkReadonlyOptions(d){if(y.includes(d))throw new Error(`Option "${d}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new p.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new m.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this.register(new a.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const d=this._core.coreService.decPrivateModes;let c="none";switch(this._core.coreMouseService.activeProtocol){case"X10":c="x10";break;case"VT200":c="vt200";break;case"DRAG":c="drag";break;case"ANY":c="any"}return{applicationCursorKeysMode:d.applicationCursorKeys,applicationKeypadMode:d.applicationKeypad,bracketedPasteMode:d.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:c,originMode:d.origin,reverseWraparoundMode:d.reverseWraparound,sendFocusMode:d.sendFocus,wraparoundMode:d.wraparound}}get options(){return this._publicOptions}set options(d){for(const c in d)this._publicOptions[c]=d[c]}blur(){this._core.blur()}focus(){this._core.focus()}resize(d,c){this._verifyIntegers(d,c),this._core.resize(d,c)}open(d){this._core.open(d)}attachCustomKeyEventHandler(d){this._core.attachCustomKeyEventHandler(d)}registerLinkProvider(d){return this._core.registerLinkProvider(d)}registerCharacterJoiner(d){return this._checkProposedApi(),this._core.registerCharacterJoiner(d)}deregisterCharacterJoiner(d){this._checkProposedApi(),this._core.deregisterCharacterJoiner(d)}registerMarker(d=0){return this._verifyIntegers(d),this._core.registerMarker(d)}registerDecoration(d){var c,h,_;return this._checkProposedApi(),this._verifyPositiveIntegers((c=d.x)!==null&&c!==void 0?c:0,(h=d.width)!==null&&h!==void 0?h:0,(_=d.height)!==null&&_!==void 0?_:0),this._core.registerDecoration(d)}hasSelection(){return this._core.hasSelection()}select(d,c,h){this._verifyIntegers(d,c,h),this._core.select(d,c,h)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(d,c){this._verifyIntegers(d,c),this._core.selectLines(d,c)}dispose(){super.dispose()}scrollLines(d){this._verifyIntegers(d),this._core.scrollLines(d)}scrollPages(d){this._verifyIntegers(d),this._core.scrollPages(d)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(d){this._verifyIntegers(d),this._core.scrollToLine(d)}clear(){this._core.clear()}write(d,c){this._core.write(d,c)}writeln(d,c){this._core.write(d),this._core.write(`\r
16
- `,c)}paste(d){this._core.paste(d)}refresh(d,c){this._verifyIntegers(d,c),this._core.refresh(d,c)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(d){this._addonManager.loadAddon(this,d)}static get strings(){return i}_verifyIntegers(...d){for(const c of d)if(c===1/0||isNaN(c)||c%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...d){for(const c of d)if(c&&(c===1/0||isNaN(c)||c%1!=0||c<0))throw new Error("This API only accepts positive integers")}}w.Terminal=b})(),v})()))})(us)),us.exports}var Gl=Vl();var Ql=2,Zl=1,Jl=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let r=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(r._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 r=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,s=window.getComputedStyle(this._terminal.element.parentElement),l=parseInt(s.getPropertyValue("height")),g=Math.max(0,parseInt(s.getPropertyValue("width"))),v=window.getComputedStyle(this._terminal.element),w={top:parseInt(v.getPropertyValue("padding-top")),bottom:parseInt(v.getPropertyValue("padding-bottom")),right:parseInt(v.getPropertyValue("padding-right")),left:parseInt(v.getPropertyValue("padding-left"))},i=w.top+w.bottom,o=w.right+w.left,u=l-i,f=g-o-r;return{cols:Math.max(Ql,Math.floor(f/e.css.cell.width)),rows:Math.max(Zl,Math.floor(u/e.css.cell.height))}}};function ec(e={}){const{cwd:r,cols:s,rows:l,onOutput:g,onExit:v}=e,[w,i]=A.useState(null),[o,u]=A.useState(()=>be.isConnected()),[f,a]=A.useState(!1),[p,m]=A.useState(!1),[y,b]=A.useState(!1),n=A.useRef({onOutput:g,onExit:v});n.current={onOutput:g,onExit:v};const d=A.useRef(null);d.current=w,A.useEffect(()=>{if(!w)return;const k=be.getSocket(),E=()=>{u(!0),a(!1),i(null),b(!0)},x=()=>{u(!1),a(!1)},C=M=>{M.terminalId===w&&n.current.onOutput?.(M.data)},T=M=>{M.terminalId===w&&(a(!1),n.current.onExit?.(M.exitCode),i(null))},L=M=>{M.terminalId===w&&a(!0)},R=M=>{M.terminalId===w&&a(!1)};return k.on("connect",E),k.on("disconnect",x),k.on(Le.TERMINAL_STDOUT,C),k.on(Le.TERMINAL_EXIT,T),k.on(Le.TERMINAL_SUBSCRIBED,L),k.on(Le.TERMINAL_UNSUBSCRIBED,R),u(k.connected),k.connected&&k.emit(mt.SUBSCRIBE,{topic:"terminal",id:w},M=>{M.success&&a(!0)}),()=>{k.off("connect",E),k.off("disconnect",x),k.off(Le.TERMINAL_STDOUT,C),k.off(Le.TERMINAL_EXIT,T),k.off(Le.TERMINAL_SUBSCRIBED,L),k.off(Le.TERMINAL_UNSUBSCRIBED,R),k.emit(mt.UNSUBSCRIBE,{topic:"terminal",id:w})}},[w]);const c=A.useCallback(async()=>{const k=be.getSocket();if(!k.connected)return null;m(!0);try{const E=await oe.post("/terminals",{socketId:k.id,cwd:r,cols:s,rows:l});return i(E.terminalId),b(!1),E.terminalId}catch(E){return console.error("[useStandaloneTerminal] Failed to create terminal:",E),null}finally{m(!1)}},[r,s,l]),h=A.useCallback(async()=>{const k=d.current;if(k){try{await oe.delete(`/terminals/${k}`)}catch(E){console.error("[useStandaloneTerminal] Failed to destroy terminal:",E)}i(null),a(!1)}},[]),_=A.useCallback(k=>{const E=d.current;if(!E)return;be.getSocket().emit(mt.TERMINAL_INPUT,{terminalId:E,data:k})},[]),S=A.useCallback((k,E)=>{const x=d.current;if(!x)return;be.getSocket().emit(mt.TERMINAL_RESIZE,{terminalId:x,cols:k,rows:E})},[]);return A.useEffect(()=>()=>{const k=d.current;k&&oe.delete(`/terminals/${k}`).catch(()=>{})},[]),{terminalId:w,isConnected:o,isAttached:f,isCreating:p,needsRecreate:y,create:c,destroy:h,sendInput:_,resize:S}}function tc({terminalRef:e,xtermRef:r,fitAddonRef:s,isVisible:l=!0,onResize:g}){const v=A.useRef(null),w=A.useRef(null),i=A.useRef(0),o=A.useCallback(()=>{v.current!=null&&(window.clearTimeout(v.current),v.current=null),w.current!=null&&(window.cancelAnimationFrame(w.current),w.current=null)},[]),u=A.useCallback(()=>{const p=s.current,m=r.current,y=e.current;if(!p||!m||!y||y.clientWidth<=0||y.clientHeight<=0)return!1;try{return p.fit(),m.cols>0&&m.rows>0&&g(m.cols,m.rows),!0}catch{return!1}},[s,g,e,r]),f=A.useCallback((p=6)=>{o();const m=i.current+1;i.current=m;let y=0;const b=()=>{i.current===m&&(w.current=window.requestAnimationFrame(()=>{if(w.current=null,i.current!==m)return;const n=u(),d=y<2;y<p&&(!n||d)&&(y+=1,v.current=window.setTimeout(b,50))}))};b()},[o,u]),a=A.useCallback(()=>{i.current+=1,o()},[o]);return A.useEffect(()=>a,[a]),A.useEffect(()=>{l&&f(8)},[l,f]),A.useEffect(()=>{const p=e.current;if(!p)return;if(typeof ResizeObserver>"u"){f(8);return}const m=new ResizeObserver(()=>{f(4)});return m.observe(p),p.parentElement&&m.observe(p.parentElement),f(8),()=>{m.disconnect()}},[f,e]),{fitNow:u,scheduleFit:f}}const sc=_e.memo(function({cwd:r,isVisible:s=!0,onExit:l,onReady:g}){const v=A.useRef(null),w=A.useRef(null),i=A.useRef(null),o=A.useRef(!1),{terminalId:u,isAttached:f,needsRecreate:a,create:p,sendInput:m,resize:y}=ec({cwd:r,onOutput:A.useCallback(d=>{w.current?.write(d)},[]),onExit:A.useCallback(d=>{w.current?.writeln(`\r
17
- \x1B[90m[Process exited with code ${d}]\x1B[0m`),l?.(d)},[l])}),{scheduleFit:b}=tc({terminalRef:v,xtermRef:w,fitAddonRef:i,isVisible:s,onResize:y}),n=A.useCallback(d=>{w.current?.paste(d)},[]);return A.useEffect(()=>{s||w.current?.blur()},[s]),A.useEffect(()=>{if(!a)return;const d=w.current;d&&d.writeln(`\r
18
- \x1B[33m[Terminal disconnected — reconnecting...]\x1B[0m`),p()},[a,p]),A.useLayoutEffect(()=>{if(!v.current)return;const d=new Gl.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, 'Courier New', monospace",lineHeight:1.4,theme:Ao(),scrollback:5e3,convertEol:!0}),c=new Jl;return d.loadAddon(c),d.open(v.current),w.current=d,i.current=c,b(8),()=>{d.dispose(),w.current=null,i.current=null}},[b]),A.useEffect(()=>{o.current||(o.current=!0,p())},[p]),A.useEffect(()=>{const d=w.current;if(!d||!f)return;const c=d.onData(h=>{m(h)});return()=>c.dispose()},[m,f]),A.useEffect(()=>{f&&(b(4),g?.({sendInput:m,paste:n}))},[f,g,n,b,m]),t.jsxs("div",{className:"relative flex h-full w-full min-h-0 min-w-0 flex-col overflow-hidden bg-terminal",children:[!u&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-terminal-muted-foreground text-xs z-10 bg-terminal",children:"Starting terminal..."}),t.jsx("div",{ref:v,className:"terminal-xterm-host flex-1 min-h-0 min-w-0 w-full overflow-hidden"})]})}),rc=_e.memo(function({commands:r,onSelect:s}){const{t:l}=re();return r.length===0?null:t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-px h-4 bg-terminal-border mx-1 shrink-0"}),t.jsxs(_i,{children:[t.jsxs(bi,{className:"group mx-1 flex shrink-0 items-center gap-1.5 rounded px-2.5 py-1 text-xs font-medium text-terminal-muted-foreground transition-colors hover:bg-terminal-accent hover:text-terminal-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-terminal-muted-foreground data-[state=open]:bg-terminal-accent data-[state=open]:text-terminal-foreground",children:[t.jsx(Io,{size:12}),t.jsx("span",{children:l("快捷命令")}),t.jsx(Ke,{size:10,className:"transition-transform group-data-[state=open]:rotate-180"})]}),t.jsx(xi,{align:"end",className:"w-72",children:t.jsx("div",{className:"max-h-[240px] overflow-y-auto",children:r.map((g,v)=>t.jsxs(Po,{icon:t.jsx(Ro,{className:"mt-0.5"}),onSelect:()=>s(g.command),className:"items-start",children:[t.jsx("span",{className:"block truncate font-medium text-foreground",children:g.name}),t.jsx("span",{className:"block truncate font-mono text-xs text-muted-foreground",children:g.command})]},v))})})]})]})}),Fi="\x1B",ic="\x07",nc="œ";function oc(e){const r=e.charCodeAt(0);return r>=64&&r<=126}function br(e,r){let s=r;for(;s<e.length;){if(e[s]===ic||e[s]===nc)return s+1;if(e[s]===Fi&&e[s+1]==="\\")return s+2;s+=1}return s}function xr(e,r){let s=r;for(;s<e.length&&!oc(e[s]);)s+=1;return s<e.length?s+1:s}function ac(e){let r="";for(let s=0;s<e.length;){if(e[s]==="›"){s=xr(e,s+1);continue}if(e[s]===""){s=br(e,s+1);continue}if(e[s]!==Fi){r+=e[s],s+=1;continue}const l=e[s+1];if(l==="["){s=xr(e,s+2);continue}if(l==="]"||l==="P"||l==="X"||l==="^"||l==="_"){s=br(e,s+2);continue}for(s+=1;s<e.length;){const g=e.charCodeAt(s);if(g<32||g>47)break;s+=1}s<e.length&&(s+=1)}return r}const lc=200,cc=1e3,dc=512*1024;function hc(e){let r=e.reduce((l,g)=>l+g.data.length,0),s=0;for(;e.length-s>cc||r>dc&&e.length-s>1;)r-=e[s].data.length,s+=1;return{entries:s>0?e.slice(s):e,trimmed:s>0}}function uc(e,r){const s=!!e&&e.runtimeInstanceId!==r.runtimeInstanceId,l=s||r.reset,g=l?[]:e?.entries??[],v=new Set(g.map(o=>o.seq)),w=[...g,...r.entries.filter(o=>!v.has(o.seq))].sort((o,u)=>o.seq-u.seq),i=hc(w);return{...r,entries:i.entries,reset:r.reset||s||!l&&(e?.reset??!1),truncated:r.truncated||!l&&(e?.truncated??!1)||i.trimmed}}function Gs(e,r=!0){return Ee({queryKey:ie.workspaceServices.list(e),queryFn:async()=>(await oe.get(`/workspaces/${encodeURIComponent(e)}/services`)).services,enabled:r&&!!e,refetchInterval:r&&e?3e3:!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:"always",refetchOnReconnect:"always"})}function fc(e,r,s,l=!0){const g=De(),v=ie.workspaceServices.logs(e,r);return Ee({queryKey:v,queryFn:async()=>{const w=g.getQueryData(v),i=w?Math.max(0,w.nextSeq-1):0,o=w===void 0?s:w.runtimeInstanceId,u=new URLSearchParams({limit:String(lc)});o!==null&&u.set("runtimeInstanceId",o),u.set("afterSeq",String(i));const f=await oe.get(`/workspaces/${encodeURIComponent(e)}/services/${encodeURIComponent(r)}/logs?${u}`);return uc(w,f)},enabled:l&&!!e&&!!r,refetchInterval:w=>w.state.data?.hasMore?250:1e3,refetchIntervalInBackground:!1,refetchOnWindowFocus:"always",refetchOnReconnect:"always"})}const mc=[];function fs(e){return JSON.stringify([e.command,...e.args])}function Sr(e,r,s){if(!e)return s;const l=new Date(e);return Number.isNaN(l.getTime())?s:new Intl.DateTimeFormat(r,{dateStyle:"medium",timeStyle:"medium"}).format(l)}function pc(e){switch(e){case"RUNNING":return{label:"Running",dotClassName:"bg-terminal-green"};case"STARTING":return{label:"Starting",dotClassName:"bg-terminal-yellow"};case"STOPPING":return{label:"Stopping",dotClassName:"bg-terminal-yellow"};case"FAILED":return{label:"Failed",dotClassName:"bg-terminal-red"};case"EXITED":return{label:"Exited",dotClassName:"bg-terminal-muted-foreground"};default:return{label:"Stopped",dotClassName:"bg-terminal-bright-black"}}}function yr({state:e}){const{t:r}=re(),s=pc(e);return t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5 text-xs text-terminal-foreground",children:[t.jsx("span",{className:Q("h-1.5 w-1.5 rounded-full",s.dotClassName),"aria-hidden":"true"}),r(s.label)]})}function gc({message:e,onRetry:r}){const{t:s}=re();return t.jsxs("div",{className:"flex min-h-24 items-center justify-center gap-2 px-4 text-xs text-terminal-foreground",role:"alert",children:[t.jsx(Tt,{size:14,className:"shrink-0 text-terminal-red","aria-hidden":"true"}),t.jsx("span",{children:e}),t.jsx("button",{type:"button",onClick:r,className:"flex h-7 w-7 shrink-0 items-center justify-center rounded text-terminal-muted-foreground transition-colors hover:bg-terminal-accent hover:text-terminal-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-terminal-muted-foreground",title:s("Retry"),"aria-label":s("Retry"),children:t.jsx(_t,{size:13})})]})}function vc({workspaceId:e,enabled:r=!0}){const{locale:s,t:l}=re(),g=Gs(e,r),v=g.data??mc,[w,i]=A.useState(null),o=v.find(m=>m.name===w)??v[0]??null,u=fc(e,o?.name??"",o?.runtimeInstanceId??null,r&&!!o),f=A.useMemo(()=>ac(u.data?.entries.map(m=>m.data).join("")??""),[u.data?.entries]),a=A.useRef(null),p=A.useRef(!0);return A.useEffect(()=>{p.current=!0},[o?.id,o?.runtimeInstanceId]),A.useEffect(()=>{const m=a.current;m&&p.current&&(m.scrollTop=m.scrollHeight)},[f]),t.jsxs("div",{className:"flex h-full min-h-0 w-full min-w-0 flex-col bg-terminal text-terminal-foreground md:flex-row",children:[t.jsxs("aside",{className:"flex max-h-[44%] min-h-32 shrink-0 flex-col border-b border-terminal-border bg-terminal-chrome md:max-h-none md:min-h-0 md:w-72 md:border-b-0 md:border-r",children:[t.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between border-b border-terminal-border px-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Ns,{size:13,className:"shrink-0 text-terminal-muted-foreground","aria-hidden":"true"}),t.jsx("h2",{className:"truncate text-xs font-medium",children:l("Background services")})]}),!g.isLoading&&!g.isError&&t.jsx("span",{className:"text-[11px] tabular-nums text-terminal-muted-foreground",children:v.length})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto scrollbar-app-thin",children:g.isLoading?t.jsxs("div",{className:"flex min-h-24 items-center justify-center gap-2 text-xs text-terminal-muted-foreground",children:[t.jsx(xe,{size:"sm"}),l("Loading background services...")]}):g.isError?t.jsx(gc,{message:l("Failed to load background services."),onRetry:()=>{g.refetch()}}):v.length===0?t.jsxs("div",{className:"flex min-h-24 flex-col items-center justify-center gap-2 px-4 text-center text-xs text-terminal-muted-foreground",children:[t.jsx(Ns,{size:22,"aria-hidden":"true"}),t.jsx("span",{children:l("No background services")})]}):v.map(m=>{const y=m.name===o?.name;return t.jsxs("button",{type:"button",onClick:()=>i(m.name),"aria-pressed":y,className:Q("block w-full border-b border-terminal-border px-3 py-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-terminal-muted-foreground",y?"bg-terminal":"hover:bg-terminal-accent"),children:[t.jsxs("span",{className:"flex min-w-0 items-center justify-between gap-2",children:[t.jsx("span",{className:"truncate text-xs font-medium text-terminal-foreground",children:m.name}),t.jsx(yr,{state:m.runtimeState})]}),t.jsx("span",{className:"mt-1 block truncate font-mono text-[11px] text-terminal-muted-foreground",title:fs(m),children:fs(m)}),t.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-1 text-[11px] text-terminal-muted-foreground",children:[t.jsx($s,{size:10,className:"shrink-0","aria-hidden":"true"}),t.jsx("span",{className:"truncate",children:m.relativeCwd||"."})]}),t.jsxs("span",{className:`mt-1 flex min-w-0 items-center gap-1 ${m.startedAt?"text-[11px]":"text-xs"} text-terminal-muted-foreground`,children:[t.jsx(Ve,{size:10,className:"shrink-0","aria-hidden":"true"}),t.jsx("span",{className:"truncate",children:Sr(m.startedAt,s,l("Not started"))})]})]},m.id)})})]}),t.jsx("section",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-terminal","aria-label":l("Background service logs"),children:o?t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:"shrink-0 border-b border-terminal-border bg-terminal-chrome",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 px-3 pt-2",children:[t.jsx("span",{className:"min-w-0 truncate text-xs font-semibold text-terminal-foreground",children:o.name}),t.jsx(yr,{state:o.runtimeState})]}),t.jsxs("div",{className:"max-h-32 overflow-y-auto overscroll-y-contain px-3 pb-2 scrollbar-app-thin focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-terminal-muted-foreground",tabIndex:0,"aria-label":`${o.name} ${l("Details")}`,children:[t.jsxs("dl",{className:"mt-1.5 grid min-w-0 gap-x-4 gap-y-1 text-xs text-terminal-muted-foreground sm:grid-cols-2",children:[t.jsxs("div",{className:"flex min-w-0 gap-1.5",children:[t.jsxs("dt",{className:"shrink-0",children:[l("Command"),":"]}),t.jsx("dd",{className:"min-w-0 break-all font-mono text-terminal-foreground",children:fs(o)})]}),t.jsxs("div",{className:"flex min-w-0 gap-1.5",children:[t.jsxs("dt",{className:"shrink-0",children:[l("Working directory"),":"]}),t.jsx("dd",{className:"min-w-0 break-all font-mono text-terminal-foreground",children:o.relativeCwd||"."})]}),t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 sm:col-span-2",children:[t.jsx(Ve,{size:10,className:"shrink-0","aria-hidden":"true"}),t.jsxs("dt",{className:"shrink-0",children:[l("Started"),":"]}),t.jsx("dd",{className:"truncate text-terminal-foreground",children:Sr(o.startedAt,s,l("Not started"))})]})]}),o.lastError&&t.jsxs("p",{className:"mt-1.5 flex min-w-0 items-start gap-1.5 break-words text-xs text-terminal-foreground",role:"alert",children:[t.jsx(Tt,{size:12,className:"mt-0.5 shrink-0 text-terminal-red","aria-hidden":"true"}),t.jsx("span",{className:"min-w-0",children:o.lastError})]})]})]}),(u.data?.truncated||u.data?.reset)&&t.jsx("div",{className:"shrink-0 border-b border-terminal-yellow/20 bg-terminal-yellow/10 px-3 py-1.5 text-xs text-terminal-foreground",children:l("Earlier log output is unavailable.")}),u.isError&&t.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-terminal-red/20 bg-terminal-red/10 px-3 py-1.5 text-xs text-terminal-foreground",role:"alert",children:[t.jsx("span",{children:l("Failed to refresh service logs.")}),t.jsx("button",{type:"button",onClick:()=>{u.refetch()},className:"flex h-6 w-6 items-center justify-center rounded text-terminal-foreground transition-colors hover:bg-terminal-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-terminal-muted-foreground",title:l("Retry"),"aria-label":l("Retry"),children:t.jsx(_t,{size:11})})]}),t.jsx("div",{ref:a,onScroll:m=>{const y=m.currentTarget;p.current=y.scrollHeight-y.scrollTop-y.clientHeight<32},className:"min-h-0 flex-1 overflow-auto p-3 scrollbar-app-thin",role:"log","aria-live":"off",tabIndex:0,children:u.isLoading&&!u.data?t.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-xs text-terminal-muted-foreground",children:[t.jsx(xe,{size:"sm"}),l("Loading service logs...")]}):f?t.jsx("pre",{className:"m-0 whitespace-pre-wrap break-words font-mono text-xs leading-5 text-terminal-foreground",children:f}):t.jsx("div",{className:"flex h-full items-center justify-center text-xs text-terminal-muted-foreground",children:l("No logs yet")})})]}):t.jsx("div",{className:"flex h-full items-center justify-center px-4 text-center text-xs text-terminal-muted-foreground",children:g.isLoading?l("Loading background services..."):l("Select a background service")})})]})}let ms=0;function wr(){return ms+=1,{id:`shell-${ms}`,order:ms}}const _c=_e.memo(function({cwd:r,isVisible:s=!0,workspaceId:l,quickCommands:g=[]}){const{t:v}=re(),[w,i]=A.useState(()=>[wr()]),[o,u]=A.useState(()=>w[0].id),[f,a]=A.useState(()=>new Set),[p,m]=A.useState(!1),[y,b]=A.useState(!1),[n,d]=A.useState(""),[c,h]=A.useState(null),[_,S]=A.useState("terminals"),k=A.useRef(new Map),E=l?_:"terminals",x=A.useCallback(D=>{k.current.delete(D),a(O=>{if(!O.has(D))return O;const q=new Set(O);return q.delete(D),q})},[]),C=A.useCallback(()=>{const D=wr();i(O=>[...O,D]),u(D.id)},[]),T=A.useCallback((D,O)=>{O.stopPropagation(),x(D),i(q=>{const K=q.filter(U=>U.id!==D);return D===o&&K.length>0&&u(K[K.length-1].id),K})},[o,x]),L=A.useCallback(D=>{x(D),i(O=>{const q=O.filter(K=>K.id!==D);return D===o&&q.length>0&&u(q[q.length-1].id),q})},[o,x]),R=A.useCallback((D,O)=>{k.current.set(D,O),a(q=>{if(q.has(D))return q;const K=new Set(q);return K.add(D),K})},[]),M=A.useCallback(D=>{const O=k.current.get(o);O&&O.sendInput(D+"\r")},[o]),I=A.useCallback((D,O="")=>{h(D),d(O),b(!0)},[]),B=A.useCallback((D,O)=>{const q=k.current.get(D);return q?(q.paste(O),ke.success(v("Pasted into terminal")),!0):(ke.error(v("Terminal is not ready")),!1)},[v]),H=A.useCallback(async()=>{if(!k.current.has(o)){ke.error(v("Terminal is not ready"));return}const D=navigator.clipboard;if(!D?.readText){I(o);return}m(!0);try{const O=await D.readText();if(!O||O.includes(`
19
- `)||O.includes("\r")){I(o,O);return}B(o,O)}catch{I(o)}finally{m(!1)}},[o,I,B,v]),$=A.useCallback(()=>{!n||!c||!B(c,n)||(b(!1),d(""),h(null))},[n,B,c]),N=A.useCallback(()=>{b(!1),d(""),h(null)},[]),P=f.has(o);return t.jsxs("div",{className:"flex h-full w-full min-h-0 min-w-0 flex-col overflow-hidden bg-terminal",children:[l&&t.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 border-b border-terminal-border bg-terminal-chrome px-2 select-none",children:[t.jsxs("button",{type:"button",onClick:()=>S("terminals"),"aria-pressed":E==="terminals",className:Q("flex h-7 items-center gap-1.5 rounded px-2.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-terminal-muted-foreground",E==="terminals"?"bg-terminal text-terminal-foreground":"text-terminal-muted-foreground hover:bg-terminal-accent hover:text-terminal-foreground"),children:[t.jsx(yt,{size:12,"aria-hidden":"true"}),v("Interactive terminals")]}),t.jsxs("button",{type:"button",onClick:()=>S("services"),"aria-pressed":E==="services",className:Q("flex h-7 items-center gap-1.5 rounded px-2.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-terminal-muted-foreground",E==="services"?"bg-terminal text-terminal-foreground":"text-terminal-muted-foreground hover:bg-terminal-accent hover:text-terminal-foreground"),children:[t.jsx(Ns,{size:12,"aria-hidden":"true"}),v("Background services")]})]}),t.jsxs("div",{"aria-hidden":E!=="terminals",className:Q("min-h-0 flex-1 flex-col",E==="terminals"?"flex":"hidden"),children:[t.jsxs("div",{className:"flex items-center bg-terminal-chrome border-b border-terminal-border shrink-0 select-none",children:[t.jsx("div",{className:"flex items-center overflow-x-auto scrollbar-app-thin flex-1 min-w-0",children:w.map(D=>t.jsxs("button",{onClick:()=>u(D.id),className:Q("flex items-center gap-1.5 px-3 py-1.5 text-xs border-r border-terminal-border whitespace-nowrap group transition-colors",D.id===o?"bg-terminal text-terminal-foreground":"text-terminal-muted-foreground hover:bg-terminal-accent hover:text-terminal-foreground"),children:[t.jsx(yt,{size:11,className:"shrink-0"}),t.jsx("span",{children:v("Shell {count}",{count:D.order})}),w.length>1&&t.jsx("span",{onClick:O=>T(D.id,O),className:"ml-1 p-0.5 rounded hover:bg-terminal-accent opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:t.jsx(tt,{size:10})})]},D.id))}),w.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"mx-0.5 block h-5 w-px shrink-0 bg-terminal-border md:hidden","aria-hidden":"true"}),t.jsx("button",{type:"button",onClick:H,disabled:!P||p,className:"flex h-11 w-11 shrink-0 items-center justify-center text-terminal-muted-foreground transition-colors hover:bg-terminal-accent hover:text-terminal-foreground active:bg-terminal-accent disabled:cursor-not-allowed disabled:opacity-40 md:hidden",title:v("Paste into terminal"),"aria-label":v("Paste into terminal"),children:p?t.jsx(xe,{size:"lg",className:"size-[18px]"}):t.jsx(da,{size:18})})]}),t.jsx("button",{type:"button",onClick:C,className:"flex h-11 w-11 shrink-0 items-center justify-center text-terminal-muted-foreground transition-colors hover:bg-terminal-accent hover:text-terminal-foreground active:bg-terminal-accent md:h-auto md:w-auto md:px-2 md:py-1.5",title:v("New Terminal"),"aria-label":v("New Terminal"),children:t.jsx(pt,{size:14})}),g.length>0&&t.jsx(rc,{commands:g,onSelect:M})]}),t.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden relative",children:w.length===0?t.jsx("div",{className:"flex-1 flex items-center justify-center h-full text-terminal-muted-foreground",children:t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(yt,{size:28}),t.jsx("span",{className:"text-xs",children:v("No terminals open")}),t.jsx("button",{onClick:C,className:"mt-1 rounded bg-terminal-chrome px-3 py-1 text-xs text-terminal-foreground ring-1 ring-inset ring-terminal-border transition-colors hover:bg-terminal-accent",children:v("New Terminal")})]})}):w.map(D=>t.jsx("div",{"aria-hidden":D.id!==o,className:Q("absolute inset-0 h-full w-full min-h-0 min-w-0 overflow-hidden",D.id===o?"visible pointer-events-auto":"invisible pointer-events-none"),children:t.jsx(sc,{cwd:r,isVisible:s&&E==="terminals"&&D.id===o,onExit:()=>L(D.id),onReady:O=>R(D.id,O)})},D.id))})]}),l&&E==="services"&&t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(vc,{workspaceId:l,enabled:s})}),t.jsx(At,{isOpen:y,onClose:N,title:v("Paste into terminal"),className:"max-sm:inset-x-0 max-sm:top-auto max-sm:bottom-0 max-sm:max-h-[70dvh] max-sm:w-full max-sm:max-w-none max-sm:translate-x-0 max-sm:translate-y-0 max-sm:rounded-b-none max-sm:rounded-t-lg max-sm:border-x-0 max-sm:border-b-0",action:t.jsxs(t.Fragment,{children:[t.jsx(ce,{variant:"ghost",size:"lg",onClick:N,className:"max-sm:h-11",children:v("Cancel")}),t.jsx(ce,{variant:"primary",size:"lg",onClick:$,disabled:!n,className:"max-sm:h-11",children:v("Paste")})]}),children:t.jsx(To,{autoFocus:!0,value:n,onChange:D=>d(D.target.value),placeholder:v("Paste terminal input here"),"aria-label":v("Terminal paste content"),className:"min-h-32 resize-none bg-background font-mono"})})]})});function Cr(e,r){(r==null||r>e.length)&&(r=e.length);for(var s=0,l=Array(r);s<r;s++)l[s]=e[s];return l}function bc(e){if(Array.isArray(e))return e}function xc(e,r,s){return(r=jc(r))in e?Object.defineProperty(e,r,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[r]=s,e}function Sc(e,r){var s=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(s!=null){var l,g,v,w,i=[],o=!0,u=!1;try{if(v=(s=s.call(e)).next,r!==0)for(;!(o=(l=v.call(s)).done)&&(i.push(l.value),i.length!==r);o=!0);}catch(f){u=!0,g=f}finally{try{if(!o&&s.return!=null&&(w=s.return(),Object(w)!==w))return}finally{if(u)throw g}}return i}}function yc(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
20
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function kr(e,r){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);r&&(l=l.filter(function(g){return Object.getOwnPropertyDescriptor(e,g).enumerable})),s.push.apply(s,l)}return s}function Er(e){for(var r=1;r<arguments.length;r++){var s=arguments[r]!=null?arguments[r]:{};r%2?kr(Object(s),!0).forEach(function(l){xc(e,l,s[l])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):kr(Object(s)).forEach(function(l){Object.defineProperty(e,l,Object.getOwnPropertyDescriptor(s,l))})}return e}function wc(e,r){if(e==null)return{};var s,l,g=Cc(e,r);if(Object.getOwnPropertySymbols){var v=Object.getOwnPropertySymbols(e);for(l=0;l<v.length;l++)s=v[l],r.indexOf(s)===-1&&{}.propertyIsEnumerable.call(e,s)&&(g[s]=e[s])}return g}function Cc(e,r){if(e==null)return{};var s={};for(var l in e)if({}.hasOwnProperty.call(e,l)){if(r.indexOf(l)!==-1)continue;s[l]=e[l]}return s}function kc(e,r){return bc(e)||Sc(e,r)||Nc(e,r)||yc()}function Ec(e,r){if(typeof e!="object"||!e)return e;var s=e[Symbol.toPrimitive];if(s!==void 0){var l=s.call(e,r);if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function jc(e){var r=Ec(e,"string");return typeof r=="symbol"?r:r+""}function Nc(e,r){if(e){if(typeof e=="string")return Cr(e,r);var s={}.toString.call(e).slice(8,-1);return s==="Object"&&e.constructor&&(s=e.constructor.name),s==="Map"||s==="Set"?Array.from(e):s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?Cr(e,r):void 0}}function Tc(e,r,s){return r in e?Object.defineProperty(e,r,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[r]=s,e}function jr(e,r){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);r&&(l=l.filter(function(g){return Object.getOwnPropertyDescriptor(e,g).enumerable})),s.push.apply(s,l)}return s}function Nr(e){for(var r=1;r<arguments.length;r++){var s=arguments[r]!=null?arguments[r]:{};r%2?jr(Object(s),!0).forEach(function(l){Tc(e,l,s[l])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):jr(Object(s)).forEach(function(l){Object.defineProperty(e,l,Object.getOwnPropertyDescriptor(s,l))})}return e}function Ac(){for(var e=arguments.length,r=new Array(e),s=0;s<e;s++)r[s]=arguments[s];return function(l){return r.reduceRight(function(g,v){return v(g)},l)}}function St(e){return function r(){for(var s=this,l=arguments.length,g=new Array(l),v=0;v<l;v++)g[v]=arguments[v];return g.length>=e.length?e.apply(this,g):function(){for(var w=arguments.length,i=new Array(w),o=0;o<w;o++)i[o]=arguments[o];return r.apply(s,[].concat(g,i))}}}function Yt(e){return{}.toString.call(e).includes("Object")}function Rc(e){return!Object.keys(e).length}function Nt(e){return typeof e=="function"}function Lc(e,r){return Object.prototype.hasOwnProperty.call(e,r)}function Mc(e,r){return Yt(r)||Ge("changeType"),Object.keys(r).some(function(s){return!Lc(e,s)})&&Ge("changeField"),r}function Dc(e){Nt(e)||Ge("selectorType")}function Pc(e){Nt(e)||Yt(e)||Ge("handlerType"),Yt(e)&&Object.values(e).some(function(r){return!Nt(r)})&&Ge("handlersType")}function Bc(e){e||Ge("initialIsRequired"),Yt(e)||Ge("initialType"),Rc(e)&&Ge("initialContent")}function Oc(e,r){throw new Error(e[r]||e.default)}var Ic={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},Ge=St(Oc)(Ic),It={changes:Mc,selector:Dc,handler:Pc,initial:Bc};function Fc(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};It.initial(e),It.handler(r);var s={current:e},l=St(Wc)(s,r),g=St(zc)(s),v=St(It.changes)(e),w=St(Hc)(s);function i(){var u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(f){return f};return It.selector(u),u(s.current)}function o(u){Ac(l,g,v,w)(u)}return[i,o]}function Hc(e,r){return Nt(r)?r(e.current):r}function zc(e,r){return e.current=Nr(Nr({},e.current),r),r}function Wc(e,r,s){return Nt(r)?r(e.current):Object.keys(s).forEach(function(l){var g;return(g=r[l])===null||g===void 0?void 0:g.call(r,e.current[l])}),s}var $c={create:Fc},Uc={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function qc(e){return function r(){for(var s=this,l=arguments.length,g=new Array(l),v=0;v<l;v++)g[v]=arguments[v];return g.length>=e.length?e.apply(this,g):function(){for(var w=arguments.length,i=new Array(w),o=0;o<w;o++)i[o]=arguments[o];return r.apply(s,[].concat(g,i))}}}function Kc(e){return{}.toString.call(e).includes("Object")}function Xc(e){return e||Tr("configIsRequired"),Kc(e)||Tr("configType"),e.urls?(Yc(),{paths:{vs:e.urls.monacoBase}}):e}function Yc(){console.warn(Hi.deprecation)}function Vc(e,r){throw new Error(e[r]||e.default)}var Hi={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!
14
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(x){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),d.isLinux&&x&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(x){const C=this._getMouseBufferCoords(x),T=this._model.finalSelectionStart,L=this._model.finalSelectionEnd;return!!(T&&L&&C)&&this._areCoordsInSelection(C,T,L)}isCellInSelection(x,C){const T=this._model.finalSelectionStart,L=this._model.finalSelectionEnd;return!(!T||!L)&&this._areCoordsInSelection([x,C],T,L)}_areCoordsInSelection(x,C,T){return x[1]>C[1]&&x[1]<T[1]||C[1]===T[1]&&x[1]===C[1]&&x[0]>=C[0]&&x[0]<T[0]||C[1]<T[1]&&x[1]===T[1]&&x[0]<T[0]||C[1]<T[1]&&x[1]===C[1]&&x[0]>=C[0]}_selectWordAtCursor(x,C){var T,L;const R=(L=(T=this._linkifier.currentLink)===null||T===void 0?void 0:T.link)===null||L===void 0?void 0:L.range;if(R)return this._model.selectionStart=[R.start.x-1,R.start.y-1],this._model.selectionStartLength=(0,c.getRangeLength)(R,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const M=this._getMouseBufferCoords(x);return!!M&&(this._selectWordAt(M,C),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(x,C){this._model.clearSelection(),x=Math.max(x,0),C=Math.min(C,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,x],this._model.selectionEnd=[this._bufferService.cols,C],this.refresh(),this._onSelectionChange.fire()}_handleTrim(x){this._model.handleTrim(x)&&this.refresh()}_getMouseBufferCoords(x){const C=this._mouseService.getCoords(x,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(C)return C[0]--,C[1]--,C[1]+=this._bufferService.buffer.ydisp,C}_getMouseEventScrollAmount(x){let C=(0,a.getCoordsRelativeToElement)(this._coreBrowserService.window,x,this._screenElement)[1];const T=this._renderService.dimensions.css.canvas.height;return C>=0&&C<=T?0:(C>T&&(C-=T),C=Math.min(Math.max(C,-50),50),C/=50,C/Math.abs(C)+Math.round(14*C))}shouldForceSelection(x){return d.isMac?x.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:x.shiftKey}handleMouseDown(x){if(this._mouseDownTimeStamp=x.timeStamp,(x.button!==2||!this.hasSelection)&&x.button===0){if(!this._enabled){if(!this.shouldForceSelection(x))return;x.stopPropagation()}x.preventDefault(),this._dragScrollAmount=0,this._enabled&&x.shiftKey?this._handleIncrementalClick(x):x.detail===1?this._handleSingleClick(x):x.detail===2?this._handleDoubleClick(x):x.detail===3&&this._handleTripleClick(x),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval((()=>this._dragScroll()),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(x){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(x))}_handleSingleClick(x){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(x)?3:0,this._model.selectionStart=this._getMouseBufferCoords(x),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const C=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);C&&C.length!==this._model.selectionStart[0]&&C.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(x){this._selectWordAtCursor(x,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(x){const C=this._getMouseBufferCoords(x);C&&(this._activeSelectionMode=2,this._selectLineAt(C[1]))}shouldColumnSelect(x){return x.altKey&&!(d.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(x){if(x.stopImmediatePropagation(),!this._model.selectionStart)return;const C=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(x),!this._model.selectionEnd)return void this.refresh(!0);this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(x),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const T=this._bufferService.buffer;if(this._model.selectionEnd[1]<T.lines.length){const L=T.lines.get(this._model.selectionEnd[1]);L&&L.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]++}C&&C[0]===this._model.selectionEnd[0]&&C[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});const x=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(x.ydisp+this._bufferService.rows,x.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=x.ydisp),this.refresh()}}_handleMouseUp(x){const C=x.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&C<500&&x.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const T=this._mouseService.getCoords(x,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(T&&T[0]!==void 0&&T[1]!==void 0){const L=(0,p.moveToCellSequence)(T[0]-1,T[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(L,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const x=this._model.finalSelectionStart,C=this._model.finalSelectionEnd,T=!(!x||!C||x[0]===C[0]&&x[1]===C[1]);T?x&&C&&(this._oldSelectionStart&&this._oldSelectionEnd&&x[0]===this._oldSelectionStart[0]&&x[1]===this._oldSelectionStart[1]&&C[0]===this._oldSelectionEnd[0]&&C[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(x,C,T)):this._oldHasSelection&&this._fireOnSelectionChange(x,C,T)}_fireOnSelectionChange(x,C,T){this._oldSelectionStart=x,this._oldSelectionEnd=C,this._oldHasSelection=T,this._onSelectionChange.fire()}_handleBufferActivate(x){this.clearSelection(),this._trimListener.dispose(),this._trimListener=x.activeBuffer.lines.onTrim((C=>this._handleTrim(C)))}_convertViewportColToCharacterIndex(x,C){let T=C;for(let L=0;C>=L;L++){const R=x.loadCell(L,this._workCell).getChars().length;this._workCell.getWidth()===0?T--:R>1&&C!==L&&(T+=R-1)}return T}setSelection(x,C,T){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[x,C],this._model.selectionStartLength=T,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(x){this._isClickInSelection(x)||(this._selectWordAtCursor(x,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(x,C,T=!0,L=!0){if(x[0]>=this._bufferService.cols)return;const R=this._bufferService.buffer,M=R.lines.get(x[1]);if(!M)return;const I=R.translateBufferLineToString(x[1],!1);let B=this._convertViewportColToCharacterIndex(M,x[0]),H=B;const $=x[0]-B;let N=0,P=0,D=0,O=0;if(I.charAt(B)===" "){for(;B>0&&I.charAt(B-1)===" ";)B--;for(;H<I.length&&I.charAt(H+1)===" ";)H++}else{let U=x[0],z=x[0];M.getWidth(U)===0&&(N++,U--),M.getWidth(z)===2&&(P++,z++);const W=M.getString(z).length;for(W>1&&(O+=W-1,H+=W-1);U>0&&B>0&&!this._isCharWordSeparator(M.loadCell(U-1,this._workCell));){M.loadCell(U-1,this._workCell);const j=this._workCell.getChars().length;this._workCell.getWidth()===0?(N++,U--):j>1&&(D+=j-1,B-=j-1),B--,U--}for(;z<M.length&&H+1<I.length&&!this._isCharWordSeparator(M.loadCell(z+1,this._workCell));){M.loadCell(z+1,this._workCell);const j=this._workCell.getChars().length;this._workCell.getWidth()===2?(P++,z++):j>1&&(O+=j-1,H+=j-1),H++,z++}}H++;let q=B+$-N+D,K=Math.min(this._bufferService.cols,H-B+N+P-D-O);if(C||I.slice(B,H).trim()!==""){if(T&&q===0&&M.getCodePoint(0)!==32){const U=R.lines.get(x[1]-1);if(U&&M.isWrapped&&U.getCodePoint(this._bufferService.cols-1)!==32){const z=this._getWordAt([this._bufferService.cols-1,x[1]-1],!1,!0,!1);if(z){const W=this._bufferService.cols-z.start;q-=W,K+=W}}}if(L&&q+K===this._bufferService.cols&&M.getCodePoint(this._bufferService.cols-1)!==32){const U=R.lines.get(x[1]+1);if(U?.isWrapped&&U.getCodePoint(0)!==32){const z=this._getWordAt([0,x[1]+1],!1,!1,!0);z&&(K+=z.length)}}return{start:q,length:K}}}_selectWordAt(x,C){const T=this._getWordAt(x,C);if(T){for(;T.start<0;)T.start+=this._bufferService.cols,x[1]--;this._model.selectionStart=[T.start,x[1]],this._model.selectionStartLength=T.length}}_selectToWordAt(x){const C=this._getWordAt(x,!0);if(C){let T=x[1];for(;C.start<0;)C.start+=this._bufferService.cols,T--;if(!this._model.areSelectionValuesReversed())for(;C.start+C.length>this._bufferService.cols;)C.length-=this._bufferService.cols,T++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?C.start:C.start+C.length,T]}}_isCharWordSeparator(x){return x.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(x.getChars())>=0}_selectLineAt(x){const C=this._bufferService.buffer.getWrappedRangeForLine(x),T={start:{x:0,y:C.first},end:{x:this._bufferService.cols-1,y:C.last}};this._model.selectionStart=[0,C.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,c.getRangeLength)(T,this._bufferService.cols)}};r.SelectionService=E=u([f(3,_.IBufferService),f(4,_.ICoreService),f(5,y.IMouseService),f(6,_.IOptionsService),f(7,y.IRenderService),f(8,y.ICoreBrowserService)],E)},4725:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.IThemeService=r.ICharacterJoinerService=r.ISelectionService=r.IRenderService=r.IMouseService=r.ICoreBrowserService=r.ICharSizeService=void 0;const u=o(8343);r.ICharSizeService=(0,u.createDecorator)("CharSizeService"),r.ICoreBrowserService=(0,u.createDecorator)("CoreBrowserService"),r.IMouseService=(0,u.createDecorator)("MouseService"),r.IRenderService=(0,u.createDecorator)("RenderService"),r.ISelectionService=(0,u.createDecorator)("SelectionService"),r.ICharacterJoinerService=(0,u.createDecorator)("CharacterJoinerService"),r.IThemeService=(0,u.createDecorator)("ThemeService")},6731:function(w,r,o){var u=this&&this.__decorate||function(E,x,C,T){var L,R=arguments.length,M=R<3?x:T===null?T=Object.getOwnPropertyDescriptor(x,C):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")M=Reflect.decorate(E,x,C,T);else for(var I=E.length-1;I>=0;I--)(L=E[I])&&(M=(R<3?L(M):R>3?L(x,C,M):L(x,C))||M);return R>3&&M&&Object.defineProperty(x,C,M),M},f=this&&this.__param||function(E,x){return function(C,T){x(C,T,E)}};Object.defineProperty(r,"__esModule",{value:!0}),r.ThemeService=r.DEFAULT_ANSI_COLORS=void 0;const a=o(7239),p=o(8055),m=o(8460),y=o(844),b=o(2585),n=p.css.toColor("#ffffff"),d=p.css.toColor("#000000"),c=p.css.toColor("#ffffff"),h=p.css.toColor("#000000"),_={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};r.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const E=[p.css.toColor("#2e3436"),p.css.toColor("#cc0000"),p.css.toColor("#4e9a06"),p.css.toColor("#c4a000"),p.css.toColor("#3465a4"),p.css.toColor("#75507b"),p.css.toColor("#06989a"),p.css.toColor("#d3d7cf"),p.css.toColor("#555753"),p.css.toColor("#ef2929"),p.css.toColor("#8ae234"),p.css.toColor("#fce94f"),p.css.toColor("#729fcf"),p.css.toColor("#ad7fa8"),p.css.toColor("#34e2e2"),p.css.toColor("#eeeeec")],x=[0,95,135,175,215,255];for(let C=0;C<216;C++){const T=x[C/36%6|0],L=x[C/6%6|0],R=x[C%6];E.push({css:p.channels.toCss(T,L,R),rgba:p.channels.toRgba(T,L,R)})}for(let C=0;C<24;C++){const T=8+10*C;E.push({css:p.channels.toCss(T,T,T),rgba:p.channels.toRgba(T,T,T)})}return E})());let S=r.ThemeService=class extends y.Disposable{get colors(){return this._colors}constructor(E){super(),this._optionsService=E,this._contrastCache=new a.ColorContrastCache,this._halfContrastCache=new a.ColorContrastCache,this._onChangeColors=this.register(new m.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:n,background:d,cursor:c,cursorAccent:h,selectionForeground:void 0,selectionBackgroundTransparent:_,selectionBackgroundOpaque:p.color.blend(d,_),selectionInactiveBackgroundTransparent:_,selectionInactiveBackgroundOpaque:p.color.blend(d,_),ansi:r.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this.register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",(()=>this._contrastCache.clear()))),this.register(this._optionsService.onSpecificOptionChange("theme",(()=>this._setTheme(this._optionsService.rawOptions.theme))))}_setTheme(E={}){const x=this._colors;if(x.foreground=k(E.foreground,n),x.background=k(E.background,d),x.cursor=k(E.cursor,c),x.cursorAccent=k(E.cursorAccent,h),x.selectionBackgroundTransparent=k(E.selectionBackground,_),x.selectionBackgroundOpaque=p.color.blend(x.background,x.selectionBackgroundTransparent),x.selectionInactiveBackgroundTransparent=k(E.selectionInactiveBackground,x.selectionBackgroundTransparent),x.selectionInactiveBackgroundOpaque=p.color.blend(x.background,x.selectionInactiveBackgroundTransparent),x.selectionForeground=E.selectionForeground?k(E.selectionForeground,p.NULL_COLOR):void 0,x.selectionForeground===p.NULL_COLOR&&(x.selectionForeground=void 0),p.color.isOpaque(x.selectionBackgroundTransparent)&&(x.selectionBackgroundTransparent=p.color.opacity(x.selectionBackgroundTransparent,.3)),p.color.isOpaque(x.selectionInactiveBackgroundTransparent)&&(x.selectionInactiveBackgroundTransparent=p.color.opacity(x.selectionInactiveBackgroundTransparent,.3)),x.ansi=r.DEFAULT_ANSI_COLORS.slice(),x.ansi[0]=k(E.black,r.DEFAULT_ANSI_COLORS[0]),x.ansi[1]=k(E.red,r.DEFAULT_ANSI_COLORS[1]),x.ansi[2]=k(E.green,r.DEFAULT_ANSI_COLORS[2]),x.ansi[3]=k(E.yellow,r.DEFAULT_ANSI_COLORS[3]),x.ansi[4]=k(E.blue,r.DEFAULT_ANSI_COLORS[4]),x.ansi[5]=k(E.magenta,r.DEFAULT_ANSI_COLORS[5]),x.ansi[6]=k(E.cyan,r.DEFAULT_ANSI_COLORS[6]),x.ansi[7]=k(E.white,r.DEFAULT_ANSI_COLORS[7]),x.ansi[8]=k(E.brightBlack,r.DEFAULT_ANSI_COLORS[8]),x.ansi[9]=k(E.brightRed,r.DEFAULT_ANSI_COLORS[9]),x.ansi[10]=k(E.brightGreen,r.DEFAULT_ANSI_COLORS[10]),x.ansi[11]=k(E.brightYellow,r.DEFAULT_ANSI_COLORS[11]),x.ansi[12]=k(E.brightBlue,r.DEFAULT_ANSI_COLORS[12]),x.ansi[13]=k(E.brightMagenta,r.DEFAULT_ANSI_COLORS[13]),x.ansi[14]=k(E.brightCyan,r.DEFAULT_ANSI_COLORS[14]),x.ansi[15]=k(E.brightWhite,r.DEFAULT_ANSI_COLORS[15]),E.extendedAnsi){const C=Math.min(x.ansi.length-16,E.extendedAnsi.length);for(let T=0;T<C;T++)x.ansi[T+16]=k(E.extendedAnsi[T],r.DEFAULT_ANSI_COLORS[T+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(E){this._restoreColor(E),this._onChangeColors.fire(this.colors)}_restoreColor(E){if(E!==void 0)switch(E){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[E]=this._restoreColors.ansi[E]}else for(let x=0;x<this._restoreColors.ansi.length;++x)this._colors.ansi[x]=this._restoreColors.ansi[x]}modifyColors(E){E(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function k(E,x){if(E!==void 0)try{return p.css.toColor(E)}catch{}return x}r.ThemeService=S=u([f(0,b.IOptionsService)],S)},6349:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CircularList=void 0;const u=o(8460),f=o(844);class a extends f.Disposable{constructor(m){super(),this._maxLength=m,this.onDeleteEmitter=this.register(new u.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new u.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new u.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(m){if(this._maxLength===m)return;const y=new Array(m);for(let b=0;b<Math.min(m,this.length);b++)y[b]=this._array[this._getCyclicIndex(b)];this._array=y,this._maxLength=m,this._startIndex=0}get length(){return this._length}set length(m){if(m>this._length)for(let y=this._length;y<m;y++)this._array[y]=void 0;this._length=m}get(m){return this._array[this._getCyclicIndex(m)]}set(m,y){this._array[this._getCyclicIndex(m)]=y}push(m){this._array[this._getCyclicIndex(this._length)]=m,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(m,y,...b){if(y){for(let n=m;n<this._length-y;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+y)];this._length-=y,this.onDeleteEmitter.fire({index:m,amount:y})}for(let n=this._length-1;n>=m;n--)this._array[this._getCyclicIndex(n+b.length)]=this._array[this._getCyclicIndex(n)];for(let n=0;n<b.length;n++)this._array[this._getCyclicIndex(m+n)]=b[n];if(b.length&&this.onInsertEmitter.fire({index:m,amount:b.length}),this._length+b.length>this._maxLength){const n=this._length+b.length-this._maxLength;this._startIndex+=n,this._length=this._maxLength,this.onTrimEmitter.fire(n)}else this._length+=b.length}trimStart(m){m>this._length&&(m=this._length),this._startIndex+=m,this._length-=m,this.onTrimEmitter.fire(m)}shiftElements(m,y,b){if(!(y<=0)){if(m<0||m>=this._length)throw new Error("start argument out of range");if(m+b<0)throw new Error("Cannot shift elements in list beyond index 0");if(b>0){for(let d=y-1;d>=0;d--)this.set(m+d+b,this.get(m+d));const n=m+y+b-this._length;if(n>0)for(this._length+=n;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let n=0;n<y;n++)this.set(m+n+b,this.get(m+n))}}_getCyclicIndex(m){return(this._startIndex+m)%this._maxLength}}r.CircularList=a},1439:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.clone=void 0,r.clone=function o(u,f=5){if(typeof u!="object")return u;const a=Array.isArray(u)?[]:{};for(const p in u)a[p]=f<=1?u[p]:u[p]&&o(u[p],f-1);return a}},8055:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.contrastRatio=r.toPaddedHex=r.rgba=r.rgb=r.css=r.color=r.channels=r.NULL_COLOR=void 0;const u=o(6114);let f=0,a=0,p=0,m=0;var y,b,n,d,c;function h(S){const k=S.toString(16);return k.length<2?"0"+k:k}function _(S,k){return S<k?(k+.05)/(S+.05):(S+.05)/(k+.05)}r.NULL_COLOR={css:"#00000000",rgba:0},(function(S){S.toCss=function(k,E,x,C){return C!==void 0?`#${h(k)}${h(E)}${h(x)}${h(C)}`:`#${h(k)}${h(E)}${h(x)}`},S.toRgba=function(k,E,x,C=255){return(k<<24|E<<16|x<<8|C)>>>0}})(y||(r.channels=y={})),(function(S){function k(E,x){return m=Math.round(255*x),[f,a,p]=c.toChannels(E.rgba),{css:y.toCss(f,a,p,m),rgba:y.toRgba(f,a,p,m)}}S.blend=function(E,x){if(m=(255&x.rgba)/255,m===1)return{css:x.css,rgba:x.rgba};const C=x.rgba>>24&255,T=x.rgba>>16&255,L=x.rgba>>8&255,R=E.rgba>>24&255,M=E.rgba>>16&255,I=E.rgba>>8&255;return f=R+Math.round((C-R)*m),a=M+Math.round((T-M)*m),p=I+Math.round((L-I)*m),{css:y.toCss(f,a,p),rgba:y.toRgba(f,a,p)}},S.isOpaque=function(E){return(255&E.rgba)==255},S.ensureContrastRatio=function(E,x,C){const T=c.ensureContrastRatio(E.rgba,x.rgba,C);if(T)return c.toColor(T>>24&255,T>>16&255,T>>8&255)},S.opaque=function(E){const x=(255|E.rgba)>>>0;return[f,a,p]=c.toChannels(x),{css:y.toCss(f,a,p),rgba:x}},S.opacity=k,S.multiplyOpacity=function(E,x){return m=255&E.rgba,k(E,m*x/255)},S.toColorRGB=function(E){return[E.rgba>>24&255,E.rgba>>16&255,E.rgba>>8&255]}})(b||(r.color=b={})),(function(S){let k,E;if(!u.isNode){const x=document.createElement("canvas");x.width=1,x.height=1;const C=x.getContext("2d",{willReadFrequently:!0});C&&(k=C,k.globalCompositeOperation="copy",E=k.createLinearGradient(0,0,1,1))}S.toColor=function(x){if(x.match(/#[\da-f]{3,8}/i))switch(x.length){case 4:return f=parseInt(x.slice(1,2).repeat(2),16),a=parseInt(x.slice(2,3).repeat(2),16),p=parseInt(x.slice(3,4).repeat(2),16),c.toColor(f,a,p);case 5:return f=parseInt(x.slice(1,2).repeat(2),16),a=parseInt(x.slice(2,3).repeat(2),16),p=parseInt(x.slice(3,4).repeat(2),16),m=parseInt(x.slice(4,5).repeat(2),16),c.toColor(f,a,p,m);case 7:return{css:x,rgba:(parseInt(x.slice(1),16)<<8|255)>>>0};case 9:return{css:x,rgba:parseInt(x.slice(1),16)>>>0}}const C=x.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(C)return f=parseInt(C[1]),a=parseInt(C[2]),p=parseInt(C[3]),m=Math.round(255*(C[5]===void 0?1:parseFloat(C[5]))),c.toColor(f,a,p,m);if(!k||!E)throw new Error("css.toColor: Unsupported css format");if(k.fillStyle=E,k.fillStyle=x,typeof k.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(k.fillRect(0,0,1,1),[f,a,p,m]=k.getImageData(0,0,1,1).data,m!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:y.toRgba(f,a,p,m),css:x}}})(n||(r.css=n={})),(function(S){function k(E,x,C){const T=E/255,L=x/255,R=C/255;return .2126*(T<=.03928?T/12.92:Math.pow((T+.055)/1.055,2.4))+.7152*(L<=.03928?L/12.92:Math.pow((L+.055)/1.055,2.4))+.0722*(R<=.03928?R/12.92:Math.pow((R+.055)/1.055,2.4))}S.relativeLuminance=function(E){return k(E>>16&255,E>>8&255,255&E)},S.relativeLuminance2=k})(d||(r.rgb=d={})),(function(S){function k(x,C,T){const L=x>>24&255,R=x>>16&255,M=x>>8&255;let I=C>>24&255,B=C>>16&255,H=C>>8&255,$=_(d.relativeLuminance2(I,B,H),d.relativeLuminance2(L,R,M));for(;$<T&&(I>0||B>0||H>0);)I-=Math.max(0,Math.ceil(.1*I)),B-=Math.max(0,Math.ceil(.1*B)),H-=Math.max(0,Math.ceil(.1*H)),$=_(d.relativeLuminance2(I,B,H),d.relativeLuminance2(L,R,M));return(I<<24|B<<16|H<<8|255)>>>0}function E(x,C,T){const L=x>>24&255,R=x>>16&255,M=x>>8&255;let I=C>>24&255,B=C>>16&255,H=C>>8&255,$=_(d.relativeLuminance2(I,B,H),d.relativeLuminance2(L,R,M));for(;$<T&&(I<255||B<255||H<255);)I=Math.min(255,I+Math.ceil(.1*(255-I))),B=Math.min(255,B+Math.ceil(.1*(255-B))),H=Math.min(255,H+Math.ceil(.1*(255-H))),$=_(d.relativeLuminance2(I,B,H),d.relativeLuminance2(L,R,M));return(I<<24|B<<16|H<<8|255)>>>0}S.ensureContrastRatio=function(x,C,T){const L=d.relativeLuminance(x>>8),R=d.relativeLuminance(C>>8);if(_(L,R)<T){if(R<L){const B=k(x,C,T),H=_(L,d.relativeLuminance(B>>8));if(H<T){const $=E(x,C,T);return H>_(L,d.relativeLuminance($>>8))?B:$}return B}const M=E(x,C,T),I=_(L,d.relativeLuminance(M>>8));if(I<T){const B=k(x,C,T);return I>_(L,d.relativeLuminance(B>>8))?M:B}return M}},S.reduceLuminance=k,S.increaseLuminance=E,S.toChannels=function(x){return[x>>24&255,x>>16&255,x>>8&255,255&x]},S.toColor=function(x,C,T,L){return{css:y.toCss(x,C,T,L),rgba:y.toRgba(x,C,T,L)}}})(c||(r.rgba=c={})),r.toPaddedHex=h,r.contrastRatio=_},8969:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CoreTerminal=void 0;const u=o(844),f=o(2585),a=o(4348),p=o(7866),m=o(744),y=o(7302),b=o(6975),n=o(8460),d=o(1753),c=o(1480),h=o(7994),_=o(9282),S=o(5435),k=o(5981),E=o(2660);let x=!1;class C extends u.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new n.EventEmitter),this._onScroll.event((L=>{var R;(R=this._onScrollApi)===null||R===void 0||R.fire(L.position)}))),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(L){for(const R in L)this.optionsService.options[R]=L[R]}constructor(L){super(),this._windowsWrappingHeuristics=this.register(new u.MutableDisposable),this._onBinary=this.register(new n.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new n.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new n.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new n.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new n.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new n.EventEmitter),this._instantiationService=new a.InstantiationService,this.optionsService=this.register(new y.OptionsService(L)),this._instantiationService.setService(f.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(m.BufferService)),this._instantiationService.setService(f.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(p.LogService)),this._instantiationService.setService(f.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(b.CoreService)),this._instantiationService.setService(f.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(d.CoreMouseService)),this._instantiationService.setService(f.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(c.UnicodeService)),this._instantiationService.setService(f.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(h.CharsetService),this._instantiationService.setService(f.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(E.OscLinkService),this._instantiationService.setService(f.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new S.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,n.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,n.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,n.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,n.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom((()=>this.scrollToBottom()))),this.register(this.coreService.onUserInput((()=>this._writeBuffer.handleUserInput()))),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],(()=>this._handleWindowsPtyOptionChange()))),this.register(this._bufferService.onScroll((R=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this.register(this._inputHandler.onScroll((R=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new k.WriteBuffer(((R,M)=>this._inputHandler.parse(R,M)))),this.register((0,n.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(L,R){this._writeBuffer.write(L,R)}writeSync(L,R){this._logService.logLevel<=f.LogLevelEnum.WARN&&!x&&(this._logService.warn("writeSync is unreliable and will be removed soon."),x=!0),this._writeBuffer.writeSync(L,R)}resize(L,R){isNaN(L)||isNaN(R)||(L=Math.max(L,m.MINIMUM_COLS),R=Math.max(R,m.MINIMUM_ROWS),this._bufferService.resize(L,R))}scroll(L,R=!1){this._bufferService.scroll(L,R)}scrollLines(L,R,M){this._bufferService.scrollLines(L,R,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 R=L-this._bufferService.buffer.ydisp;R!==0&&this.scrollLines(R)}registerEscHandler(L,R){return this._inputHandler.registerEscHandler(L,R)}registerDcsHandler(L,R){return this._inputHandler.registerDcsHandler(L,R)}registerCsiHandler(L,R){return this._inputHandler.registerCsiHandler(L,R)}registerOscHandler(L,R){return this._inputHandler.registerOscHandler(L,R)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let L=!1;const R=this.optionsService.rawOptions.windowsPty;R&&R.buildNumber!==void 0&&R.buildNumber!==void 0?L=R.backend==="conpty"&&R.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(L=!0),L?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const L=[];L.push(this.onLineFeed(_.updateWindowsModeWrappedState.bind(null,this._bufferService))),L.push(this.registerCsiHandler({final:"H"},(()=>((0,_.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,u.toDisposable)((()=>{for(const R of L)R.dispose()}))}}}r.CoreTerminal=C},8460:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.forwardEvent=r.EventEmitter=void 0,r.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=o=>(this._listeners.push(o),{dispose:()=>{if(!this._disposed){for(let u=0;u<this._listeners.length;u++)if(this._listeners[u]===o)return void this._listeners.splice(u,1)}}})),this._event}fire(o,u){const f=[];for(let a=0;a<this._listeners.length;a++)f.push(this._listeners[a]);for(let a=0;a<f.length;a++)f[a].call(void 0,o,u)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},r.forwardEvent=function(o,u){return o((f=>u.fire(f)))}},5435:function(w,r,o){var u=this&&this.__decorate||function($,N,P,D){var O,q=arguments.length,K=q<3?N:D===null?D=Object.getOwnPropertyDescriptor(N,P):D;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")K=Reflect.decorate($,N,P,D);else for(var U=$.length-1;U>=0;U--)(O=$[U])&&(K=(q<3?O(K):q>3?O(N,P,K):O(N,P))||K);return q>3&&K&&Object.defineProperty(N,P,K),K},f=this&&this.__param||function($,N){return function(P,D){N(P,D,$)}};Object.defineProperty(r,"__esModule",{value:!0}),r.InputHandler=r.WindowsOptionsReportType=void 0;const a=o(2584),p=o(7116),m=o(2015),y=o(844),b=o(482),n=o(8437),d=o(8460),c=o(643),h=o(511),_=o(3734),S=o(2585),k=o(6242),E=o(6351),x=o(5941),C={"(":0,")":1,"*":2,"+":3,"-":1,".":2},T=131072;function L($,N){if($>24)return N.setWinLines||!1;switch($){case 1:return!!N.restoreWin;case 2:return!!N.minimizeWin;case 3:return!!N.setWinPosition;case 4:return!!N.setWinSizePixels;case 5:return!!N.raiseWin;case 6:return!!N.lowerWin;case 7:return!!N.refreshWin;case 8:return!!N.setWinSizeChars;case 9:return!!N.maximizeWin;case 10:return!!N.fullscreenWin;case 11:return!!N.getWinState;case 13:return!!N.getWinPosition;case 14:return!!N.getWinSizePixels;case 15:return!!N.getScreenSizePixels;case 16:return!!N.getCellSizePixels;case 18:return!!N.getWinSizeChars;case 19:return!!N.getScreenSizeChars;case 20:return!!N.getIconTitle;case 21:return!!N.getWinTitle;case 22:return!!N.pushTitle;case 23:return!!N.popTitle;case 24:return!!N.setWinLines}return!1}var R;(function($){$[$.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",$[$.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(R||(r.WindowsOptionsReportType=R={}));let M=0;class I extends y.Disposable{getAttrData(){return this._curAttrData}constructor(N,P,D,O,q,K,U,z,W=new m.EscapeSequenceParser){super(),this._bufferService=N,this._charsetService=P,this._coreService=D,this._logService=O,this._optionsService=q,this._oscLinkService=K,this._coreMouseService=U,this._unicodeService=z,this._parser=W,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new b.StringToUtf32,this._utf8Decoder=new b.Utf8ToUtf32,this._workCell=new h.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=n.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=n.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new d.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new d.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new d.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new d.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new d.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new d.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new d.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new d.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new d.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new d.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new d.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new d.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new d.EventEmitter),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this.register(this._parser),this._dirtyRowTracker=new B(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((j=>this._activeBuffer=j.activeBuffer))),this._parser.setCsiHandlerFallback(((j,F)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(j),params:F.toArray()})})),this._parser.setEscHandlerFallback((j=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(j)})})),this._parser.setExecuteHandlerFallback((j=>{this._logService.debug("Unknown EXECUTE code: ",{code:j})})),this._parser.setOscHandlerFallback(((j,F,X)=>{this._logService.debug("Unknown OSC code: ",{identifier:j,action:F,data:X})})),this._parser.setDcsHandlerFallback(((j,F,X)=>{F==="HOOK"&&(X=X.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(j),action:F,payload:X})})),this._parser.setPrintHandler(((j,F,X)=>this.print(j,F,X))),this._parser.registerCsiHandler({final:"@"},(j=>this.insertChars(j))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(j=>this.scrollLeft(j))),this._parser.registerCsiHandler({final:"A"},(j=>this.cursorUp(j))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(j=>this.scrollRight(j))),this._parser.registerCsiHandler({final:"B"},(j=>this.cursorDown(j))),this._parser.registerCsiHandler({final:"C"},(j=>this.cursorForward(j))),this._parser.registerCsiHandler({final:"D"},(j=>this.cursorBackward(j))),this._parser.registerCsiHandler({final:"E"},(j=>this.cursorNextLine(j))),this._parser.registerCsiHandler({final:"F"},(j=>this.cursorPrecedingLine(j))),this._parser.registerCsiHandler({final:"G"},(j=>this.cursorCharAbsolute(j))),this._parser.registerCsiHandler({final:"H"},(j=>this.cursorPosition(j))),this._parser.registerCsiHandler({final:"I"},(j=>this.cursorForwardTab(j))),this._parser.registerCsiHandler({final:"J"},(j=>this.eraseInDisplay(j,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(j=>this.eraseInDisplay(j,!0))),this._parser.registerCsiHandler({final:"K"},(j=>this.eraseInLine(j,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(j=>this.eraseInLine(j,!0))),this._parser.registerCsiHandler({final:"L"},(j=>this.insertLines(j))),this._parser.registerCsiHandler({final:"M"},(j=>this.deleteLines(j))),this._parser.registerCsiHandler({final:"P"},(j=>this.deleteChars(j))),this._parser.registerCsiHandler({final:"S"},(j=>this.scrollUp(j))),this._parser.registerCsiHandler({final:"T"},(j=>this.scrollDown(j))),this._parser.registerCsiHandler({final:"X"},(j=>this.eraseChars(j))),this._parser.registerCsiHandler({final:"Z"},(j=>this.cursorBackwardTab(j))),this._parser.registerCsiHandler({final:"`"},(j=>this.charPosAbsolute(j))),this._parser.registerCsiHandler({final:"a"},(j=>this.hPositionRelative(j))),this._parser.registerCsiHandler({final:"b"},(j=>this.repeatPrecedingCharacter(j))),this._parser.registerCsiHandler({final:"c"},(j=>this.sendDeviceAttributesPrimary(j))),this._parser.registerCsiHandler({prefix:">",final:"c"},(j=>this.sendDeviceAttributesSecondary(j))),this._parser.registerCsiHandler({final:"d"},(j=>this.linePosAbsolute(j))),this._parser.registerCsiHandler({final:"e"},(j=>this.vPositionRelative(j))),this._parser.registerCsiHandler({final:"f"},(j=>this.hVPosition(j))),this._parser.registerCsiHandler({final:"g"},(j=>this.tabClear(j))),this._parser.registerCsiHandler({final:"h"},(j=>this.setMode(j))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(j=>this.setModePrivate(j))),this._parser.registerCsiHandler({final:"l"},(j=>this.resetMode(j))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(j=>this.resetModePrivate(j))),this._parser.registerCsiHandler({final:"m"},(j=>this.charAttributes(j))),this._parser.registerCsiHandler({final:"n"},(j=>this.deviceStatus(j))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(j=>this.deviceStatusPrivate(j))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(j=>this.softReset(j))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(j=>this.setCursorStyle(j))),this._parser.registerCsiHandler({final:"r"},(j=>this.setScrollRegion(j))),this._parser.registerCsiHandler({final:"s"},(j=>this.saveCursor(j))),this._parser.registerCsiHandler({final:"t"},(j=>this.windowOptions(j))),this._parser.registerCsiHandler({final:"u"},(j=>this.restoreCursor(j))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(j=>this.insertColumns(j))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(j=>this.deleteColumns(j))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(j=>this.selectProtected(j))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(j=>this.requestMode(j,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(j=>this.requestMode(j,!1))),this._parser.setExecuteHandler(a.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(a.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(a.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(a.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(a.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(a.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(a.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(a.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(a.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(a.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(a.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(a.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new k.OscHandler((j=>(this.setTitle(j),this.setIconName(j),!0)))),this._parser.registerOscHandler(1,new k.OscHandler((j=>this.setIconName(j)))),this._parser.registerOscHandler(2,new k.OscHandler((j=>this.setTitle(j)))),this._parser.registerOscHandler(4,new k.OscHandler((j=>this.setOrReportIndexedColor(j)))),this._parser.registerOscHandler(8,new k.OscHandler((j=>this.setHyperlink(j)))),this._parser.registerOscHandler(10,new k.OscHandler((j=>this.setOrReportFgColor(j)))),this._parser.registerOscHandler(11,new k.OscHandler((j=>this.setOrReportBgColor(j)))),this._parser.registerOscHandler(12,new k.OscHandler((j=>this.setOrReportCursorColor(j)))),this._parser.registerOscHandler(104,new k.OscHandler((j=>this.restoreIndexedColor(j)))),this._parser.registerOscHandler(110,new k.OscHandler((j=>this.restoreFgColor(j)))),this._parser.registerOscHandler(111,new k.OscHandler((j=>this.restoreBgColor(j)))),this._parser.registerOscHandler(112,new k.OscHandler((j=>this.restoreCursorColor(j)))),this._parser.registerEscHandler({final:"7"},(()=>this.saveCursor())),this._parser.registerEscHandler({final:"8"},(()=>this.restoreCursor())),this._parser.registerEscHandler({final:"D"},(()=>this.index())),this._parser.registerEscHandler({final:"E"},(()=>this.nextLine())),this._parser.registerEscHandler({final:"H"},(()=>this.tabSet())),this._parser.registerEscHandler({final:"M"},(()=>this.reverseIndex())),this._parser.registerEscHandler({final:"="},(()=>this.keypadApplicationMode())),this._parser.registerEscHandler({final:">"},(()=>this.keypadNumericMode())),this._parser.registerEscHandler({final:"c"},(()=>this.fullReset())),this._parser.registerEscHandler({final:"n"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"o"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"|"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"}"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"~"},(()=>this.setgLevel(1))),this._parser.registerEscHandler({intermediates:"%",final:"@"},(()=>this.selectDefaultCharset())),this._parser.registerEscHandler({intermediates:"%",final:"G"},(()=>this.selectDefaultCharset()));for(const j in p.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:j},(()=>this.selectCharset("("+j))),this._parser.registerEscHandler({intermediates:")",final:j},(()=>this.selectCharset(")"+j))),this._parser.registerEscHandler({intermediates:"*",final:j},(()=>this.selectCharset("*"+j))),this._parser.registerEscHandler({intermediates:"+",final:j},(()=>this.selectCharset("+"+j))),this._parser.registerEscHandler({intermediates:"-",final:j},(()=>this.selectCharset("-"+j))),this._parser.registerEscHandler({intermediates:".",final:j},(()=>this.selectCharset("."+j))),this._parser.registerEscHandler({intermediates:"/",final:j},(()=>this.selectCharset("/"+j)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((j=>(this._logService.error("Parsing error: ",j),j))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new E.DcsHandler(((j,F)=>this.requestStatusString(j,F))))}_preserveStack(N,P,D,O){this._parseStack.paused=!0,this._parseStack.cursorStartX=N,this._parseStack.cursorStartY=P,this._parseStack.decodedLength=D,this._parseStack.position=O}_logSlowResolvingAsync(N){this._logService.logLevel<=S.LogLevelEnum.WARN&&Promise.race([N,new Promise(((P,D)=>setTimeout((()=>D("#SLOW_TIMEOUT")),5e3)))]).catch((P=>{if(P!=="#SLOW_TIMEOUT")throw P;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(N,P){let D,O=this._activeBuffer.x,q=this._activeBuffer.y,K=0;const U=this._parseStack.paused;if(U){if(D=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,P))return this._logSlowResolvingAsync(D),D;O=this._parseStack.cursorStartX,q=this._parseStack.cursorStartY,this._parseStack.paused=!1,N.length>T&&(K=this._parseStack.position+T)}if(this._logService.logLevel<=S.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof N=="string"?` "${N}"`:` "${Array.prototype.map.call(N,(z=>String.fromCharCode(z))).join("")}"`),typeof N=="string"?N.split("").map((z=>z.charCodeAt(0))):N),this._parseBuffer.length<N.length&&this._parseBuffer.length<T&&(this._parseBuffer=new Uint32Array(Math.min(N.length,T))),U||this._dirtyRowTracker.clearRange(),N.length>T)for(let z=K;z<N.length;z+=T){const W=z+T<N.length?z+T:N.length,j=typeof N=="string"?this._stringDecoder.decode(N.substring(z,W),this._parseBuffer):this._utf8Decoder.decode(N.subarray(z,W),this._parseBuffer);if(D=this._parser.parse(this._parseBuffer,j))return this._preserveStack(O,q,j,z),this._logSlowResolvingAsync(D),D}else if(!U){const z=typeof N=="string"?this._stringDecoder.decode(N,this._parseBuffer):this._utf8Decoder.decode(N,this._parseBuffer);if(D=this._parser.parse(this._parseBuffer,z))return this._preserveStack(O,q,z,0),this._logSlowResolvingAsync(D),D}this._activeBuffer.x===O&&this._activeBuffer.y===q||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowTracker.start,this._dirtyRowTracker.end)}print(N,P,D){let O,q;const K=this._charsetService.charset,U=this._optionsService.rawOptions.screenReaderMode,z=this._bufferService.cols,W=this._coreService.decPrivateModes.wraparound,j=this._coreService.modes.insertMode,F=this._curAttrData;let X=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&D-P>0&&X.getWidth(this._activeBuffer.x-1)===2&&X.setCellFromCodePoint(this._activeBuffer.x-1,0,1,F.fg,F.bg,F.extended);for(let Y=P;Y<D;++Y){if(O=N[Y],q=this._unicodeService.wcwidth(O),O<127&&K){const ee=K[String.fromCharCode(O)];ee&&(O=ee.charCodeAt(0))}if(U&&this._onA11yChar.fire((0,b.stringFromCodePoint)(O)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),q||!this._activeBuffer.x){if(this._activeBuffer.x+q-1>=z){if(W){for(;this._activeBuffer.x<z;)X.setCellFromCodePoint(this._activeBuffer.x++,0,1,F.fg,F.bg,F.extended);this._activeBuffer.x=0,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),X=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)}else if(this._activeBuffer.x=z-1,q===2)continue}if(j&&(X.insertCells(this._activeBuffer.x,q,this._activeBuffer.getNullCell(F),F),X.getWidth(z-1)===2&&X.setCellFromCodePoint(z-1,c.NULL_CELL_CODE,c.NULL_CELL_WIDTH,F.fg,F.bg,F.extended)),X.setCellFromCodePoint(this._activeBuffer.x++,O,q,F.fg,F.bg,F.extended),q>0)for(;--q;)X.setCellFromCodePoint(this._activeBuffer.x++,0,0,F.fg,F.bg,F.extended)}else X.getWidth(this._activeBuffer.x-1)?X.addCodepointToCell(this._activeBuffer.x-1,O):X.addCodepointToCell(this._activeBuffer.x-2,O)}D-P>0&&(X.loadCell(this._activeBuffer.x-1,this._workCell),this._workCell.getWidth()===2||this._workCell.getCode()>65535?this._parser.precedingCodepoint=0:this._workCell.isCombined()?this._parser.precedingCodepoint=this._workCell.getChars().charCodeAt(0):this._parser.precedingCodepoint=this._workCell.content),this._activeBuffer.x<z&&D-P>0&&X.getWidth(this._activeBuffer.x)===0&&!X.hasContent(this._activeBuffer.x)&&X.setCellFromCodePoint(this._activeBuffer.x,0,1,F.fg,F.bg,F.extended),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(N,P){return N.final!=="t"||N.prefix||N.intermediates?this._parser.registerCsiHandler(N,P):this._parser.registerCsiHandler(N,(D=>!L(D.params[0],this._optionsService.rawOptions.windowOptions)||P(D)))}registerDcsHandler(N,P){return this._parser.registerDcsHandler(N,new E.DcsHandler(P))}registerEscHandler(N,P){return this._parser.registerEscHandler(N,P)}registerOscHandler(N,P){return this._parser.registerOscHandler(N,new k.OscHandler(P))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var N;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&&(!((N=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))===null||N===void 0)&&N.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);P.hasWidth(this._activeBuffer.x)&&!P.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const N=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-N),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(N=this._bufferService.cols-1){this._activeBuffer.x=Math.min(N,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(N,P){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=N,this._activeBuffer.y=this._activeBuffer.scrollTop+P):(this._activeBuffer.x=N,this._activeBuffer.y=P),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(N,P){this._restrictCursor(),this._setCursor(this._activeBuffer.x+N,this._activeBuffer.y+P)}cursorUp(N){const P=this._activeBuffer.y-this._activeBuffer.scrollTop;return P>=0?this._moveCursor(0,-Math.min(P,N.params[0]||1)):this._moveCursor(0,-(N.params[0]||1)),!0}cursorDown(N){const P=this._activeBuffer.scrollBottom-this._activeBuffer.y;return P>=0?this._moveCursor(0,Math.min(P,N.params[0]||1)):this._moveCursor(0,N.params[0]||1),!0}cursorForward(N){return this._moveCursor(N.params[0]||1,0),!0}cursorBackward(N){return this._moveCursor(-(N.params[0]||1),0),!0}cursorNextLine(N){return this.cursorDown(N),this._activeBuffer.x=0,!0}cursorPrecedingLine(N){return this.cursorUp(N),this._activeBuffer.x=0,!0}cursorCharAbsolute(N){return this._setCursor((N.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(N){return this._setCursor(N.length>=2?(N.params[1]||1)-1:0,(N.params[0]||1)-1),!0}charPosAbsolute(N){return this._setCursor((N.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(N){return this._moveCursor(N.params[0]||1,0),!0}linePosAbsolute(N){return this._setCursor(this._activeBuffer.x,(N.params[0]||1)-1),!0}vPositionRelative(N){return this._moveCursor(0,N.params[0]||1),!0}hVPosition(N){return this.cursorPosition(N),!0}tabClear(N){const P=N.params[0];return P===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:P===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(N){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let P=N.params[0]||1;for(;P--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(N){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let P=N.params[0]||1;for(;P--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(N){const P=N.params[0];return P===1&&(this._curAttrData.bg|=536870912),P!==2&&P!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(N,P,D,O=!1,q=!1){const K=this._activeBuffer.lines.get(this._activeBuffer.ybase+N);K.replaceCells(P,D,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),q),O&&(K.isWrapped=!1)}_resetBufferLine(N,P=!1){const D=this._activeBuffer.lines.get(this._activeBuffer.ybase+N);D&&(D.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),P),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+N),D.isWrapped=!1)}eraseInDisplay(N,P=!1){let D;switch(this._restrictCursor(this._bufferService.cols),N.params[0]){case 0:for(D=this._activeBuffer.y,this._dirtyRowTracker.markDirty(D),this._eraseInBufferLine(D++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,P);D<this._bufferService.rows;D++)this._resetBufferLine(D,P);this._dirtyRowTracker.markDirty(D);break;case 1:for(D=this._activeBuffer.y,this._dirtyRowTracker.markDirty(D),this._eraseInBufferLine(D,0,this._activeBuffer.x+1,!0,P),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(D+1).isWrapped=!1);D--;)this._resetBufferLine(D,P);this._dirtyRowTracker.markDirty(0);break;case 2:for(D=this._bufferService.rows,this._dirtyRowTracker.markDirty(D-1);D--;)this._resetBufferLine(D,P);this._dirtyRowTracker.markDirty(0);break;case 3:const O=this._activeBuffer.lines.length-this._bufferService.rows;O>0&&(this._activeBuffer.lines.trimStart(O),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-O,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-O,0),this._onScroll.fire(0))}return!0}eraseInLine(N,P=!1){switch(this._restrictCursor(this._bufferService.cols),N.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,P);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,P);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,P)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(N){this._restrictCursor();let P=N.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const D=this._activeBuffer.ybase+this._activeBuffer.y,O=this._bufferService.rows-1-this._activeBuffer.scrollBottom,q=this._bufferService.rows-1+this._activeBuffer.ybase-O+1;for(;P--;)this._activeBuffer.lines.splice(q-1,1),this._activeBuffer.lines.splice(D,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(N){this._restrictCursor();let P=N.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const D=this._activeBuffer.ybase+this._activeBuffer.y;let O;for(O=this._bufferService.rows-1-this._activeBuffer.scrollBottom,O=this._bufferService.rows-1+this._activeBuffer.ybase-O;P--;)this._activeBuffer.lines.splice(D,1),this._activeBuffer.lines.splice(O,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(N){this._restrictCursor();const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return P&&(P.insertCells(this._activeBuffer.x,N.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(N){this._restrictCursor();const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return P&&(P.deleteCells(this._activeBuffer.x,N.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(N){let P=N.params[0]||1;for(;P--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(N){let P=N.params[0]||1;for(;P--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(n.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(N){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=N.params[0]||1;for(let D=this._activeBuffer.scrollTop;D<=this._activeBuffer.scrollBottom;++D){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+D);O.deleteCells(0,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(N){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=N.params[0]||1;for(let D=this._activeBuffer.scrollTop;D<=this._activeBuffer.scrollBottom;++D){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+D);O.insertCells(0,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(N){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=N.params[0]||1;for(let D=this._activeBuffer.scrollTop;D<=this._activeBuffer.scrollBottom;++D){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+D);O.insertCells(this._activeBuffer.x,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(N){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=N.params[0]||1;for(let D=this._activeBuffer.scrollTop;D<=this._activeBuffer.scrollBottom;++D){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+D);O.deleteCells(this._activeBuffer.x,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(N){this._restrictCursor();const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return P&&(P.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(N.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(N){if(!this._parser.precedingCodepoint)return!0;const P=N.params[0]||1,D=new Uint32Array(P);for(let O=0;O<P;++O)D[O]=this._parser.precedingCodepoint;return this.print(D,0,D.length),!0}sendDeviceAttributesPrimary(N){return N.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(a.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(a.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(N){return N.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(a.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(a.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(N.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(a.C0.ESC+"[>83;40003;0c")),!0}_is(N){return(this._optionsService.rawOptions.termName+"").indexOf(N)===0}setMode(N){for(let P=0;P<N.length;P++)switch(N.params[P]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(N){for(let P=0;P<N.length;P++)switch(N.params[P]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,p.DEFAULT_CHARSET),this._charsetService.setgCharset(1,p.DEFAULT_CHARSET),this._charsetService.setgCharset(2,p.DEFAULT_CHARSET),this._charsetService.setgCharset(3,p.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(N){for(let P=0;P<N.length;P++)switch(N.params[P]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(N){for(let P=0;P<N.length;P++)switch(N.params[P]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),N.params[P]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(N,P){const D=this._coreService.decPrivateModes,{activeProtocol:O,activeEncoding:q}=this._coreMouseService,K=this._coreService,{buffers:U,cols:z}=this._bufferService,{active:W,alt:j}=U,F=this._optionsService.rawOptions,X=Z=>Z?1:2,Y=N.params[0];return ee=Y,G=P?Y===2?4:Y===4?X(K.modes.insertMode):Y===12?3:Y===20?X(F.convertEol):0:Y===1?X(D.applicationCursorKeys):Y===3?F.windowOptions.setWinLines?z===80?2:z===132?1:0:0:Y===6?X(D.origin):Y===7?X(D.wraparound):Y===8?3:Y===9?X(O==="X10"):Y===12?X(F.cursorBlink):Y===25?X(!K.isCursorHidden):Y===45?X(D.reverseWraparound):Y===66?X(D.applicationKeypad):Y===67?4:Y===1e3?X(O==="VT200"):Y===1002?X(O==="DRAG"):Y===1003?X(O==="ANY"):Y===1004?X(D.sendFocus):Y===1005?4:Y===1006?X(q==="SGR"):Y===1015?4:Y===1016?X(q==="SGR_PIXELS"):Y===1048?1:Y===47||Y===1047||Y===1049?X(W===j):Y===2004?X(D.bracketedPasteMode):0,K.triggerDataEvent(`${a.C0.ESC}[${P?"":"?"}${ee};${G}$y`),!0;var ee,G}_updateAttrColor(N,P,D,O,q){return P===2?(N|=50331648,N&=-16777216,N|=_.AttributeData.fromColorRGB([D,O,q])):P===5&&(N&=-50331904,N|=33554432|255&D),N}_extractColor(N,P,D){const O=[0,0,-1,0,0,0];let q=0,K=0;do{if(O[K+q]=N.params[P+K],N.hasSubParams(P+K)){const U=N.getSubParams(P+K);let z=0;do O[1]===5&&(q=1),O[K+z+1+q]=U[z];while(++z<U.length&&z+K+1+q<O.length);break}if(O[1]===5&&K+q>=2||O[1]===2&&K+q>=5)break;O[1]&&(q=1)}while(++K+P<N.length&&K+q<O.length);for(let U=2;U<O.length;++U)O[U]===-1&&(O[U]=0);switch(O[0]){case 38:D.fg=this._updateAttrColor(D.fg,O[1],O[3],O[4],O[5]);break;case 48:D.bg=this._updateAttrColor(D.bg,O[1],O[3],O[4],O[5]);break;case 58:D.extended=D.extended.clone(),D.extended.underlineColor=this._updateAttrColor(D.extended.underlineColor,O[1],O[3],O[4],O[5])}return K}_processUnderline(N,P){P.extended=P.extended.clone(),(!~N||N>5)&&(N=1),P.extended.underlineStyle=N,P.fg|=268435456,N===0&&(P.fg&=-268435457),P.updateExtended()}_processSGR0(N){N.fg=n.DEFAULT_ATTR_DATA.fg,N.bg=n.DEFAULT_ATTR_DATA.bg,N.extended=N.extended.clone(),N.extended.underlineStyle=0,N.extended.underlineColor&=-67108864,N.updateExtended()}charAttributes(N){if(N.length===1&&N.params[0]===0)return this._processSGR0(this._curAttrData),!0;const P=N.length;let D;const O=this._curAttrData;for(let q=0;q<P;q++)D=N.params[q],D>=30&&D<=37?(O.fg&=-50331904,O.fg|=16777216|D-30):D>=40&&D<=47?(O.bg&=-50331904,O.bg|=16777216|D-40):D>=90&&D<=97?(O.fg&=-50331904,O.fg|=16777224|D-90):D>=100&&D<=107?(O.bg&=-50331904,O.bg|=16777224|D-100):D===0?this._processSGR0(O):D===1?O.fg|=134217728:D===3?O.bg|=67108864:D===4?(O.fg|=268435456,this._processUnderline(N.hasSubParams(q)?N.getSubParams(q)[0]:1,O)):D===5?O.fg|=536870912:D===7?O.fg|=67108864:D===8?O.fg|=1073741824:D===9?O.fg|=2147483648:D===2?O.bg|=134217728:D===21?this._processUnderline(2,O):D===22?(O.fg&=-134217729,O.bg&=-134217729):D===23?O.bg&=-67108865:D===24?(O.fg&=-268435457,this._processUnderline(0,O)):D===25?O.fg&=-536870913:D===27?O.fg&=-67108865:D===28?O.fg&=-1073741825:D===29?O.fg&=2147483647:D===39?(O.fg&=-67108864,O.fg|=16777215&n.DEFAULT_ATTR_DATA.fg):D===49?(O.bg&=-67108864,O.bg|=16777215&n.DEFAULT_ATTR_DATA.bg):D===38||D===48||D===58?q+=this._extractColor(N,q,O):D===53?O.bg|=1073741824:D===55?O.bg&=-1073741825:D===59?(O.extended=O.extended.clone(),O.extended.underlineColor=-1,O.updateExtended()):D===100?(O.fg&=-67108864,O.fg|=16777215&n.DEFAULT_ATTR_DATA.fg,O.bg&=-67108864,O.bg|=16777215&n.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",D);return!0}deviceStatus(N){switch(N.params[0]){case 5:this._coreService.triggerDataEvent(`${a.C0.ESC}[0n`);break;case 6:const P=this._activeBuffer.y+1,D=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${a.C0.ESC}[${P};${D}R`)}return!0}deviceStatusPrivate(N){if(N.params[0]===6){const P=this._activeBuffer.y+1,D=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${a.C0.ESC}[?${P};${D}R`)}return!0}softReset(N){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=n.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(N){const P=N.params[0]||1;switch(P){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}const D=P%2==1;return this._optionsService.options.cursorBlink=D,!0}setScrollRegion(N){const P=N.params[0]||1;let D;return(N.length<2||(D=N.params[1])>this._bufferService.rows||D===0)&&(D=this._bufferService.rows),D>P&&(this._activeBuffer.scrollTop=P-1,this._activeBuffer.scrollBottom=D-1,this._setCursor(0,0)),!0}windowOptions(N){if(!L(N.params[0],this._optionsService.rawOptions.windowOptions))return!0;const P=N.length>1?N.params[1]:0;switch(N.params[0]){case 14:P!==2&&this._onRequestWindowsOptionsReport.fire(R.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(R.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${a.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:P!==0&&P!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),P!==0&&P!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:P!==0&&P!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),P!==0&&P!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(N){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(N){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(N){return this._windowTitle=N,this._onTitleChange.fire(N),!0}setIconName(N){return this._iconName=N,!0}setOrReportIndexedColor(N){const P=[],D=N.split(";");for(;D.length>1;){const O=D.shift(),q=D.shift();if(/^\d+$/.exec(O)){const K=parseInt(O);if(H(K))if(q==="?")P.push({type:0,index:K});else{const U=(0,x.parseColor)(q);U&&P.push({type:1,index:K,color:U})}}}return P.length&&this._onColor.fire(P),!0}setHyperlink(N){const P=N.split(";");return!(P.length<2)&&(P[1]?this._createHyperlink(P[0],P[1]):!P[0]&&this._finishHyperlink())}_createHyperlink(N,P){this._getCurrentLinkId()&&this._finishHyperlink();const D=N.split(":");let O;const q=D.findIndex((K=>K.startsWith("id=")));return q!==-1&&(O=D[q].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:O,uri:P}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(N,P){const D=N.split(";");for(let O=0;O<D.length&&!(P>=this._specialColors.length);++O,++P)if(D[O]==="?")this._onColor.fire([{type:0,index:this._specialColors[P]}]);else{const q=(0,x.parseColor)(D[O]);q&&this._onColor.fire([{type:1,index:this._specialColors[P],color:q}])}return!0}setOrReportFgColor(N){return this._setOrReportSpecialColor(N,0)}setOrReportBgColor(N){return this._setOrReportSpecialColor(N,1)}setOrReportCursorColor(N){return this._setOrReportSpecialColor(N,2)}restoreIndexedColor(N){if(!N)return this._onColor.fire([{type:2}]),!0;const P=[],D=N.split(";");for(let O=0;O<D.length;++O)if(/^\d+$/.exec(D[O])){const q=parseInt(D[O]);H(q)&&P.push({type:2,index:q})}return P.length&&this._onColor.fire(P),!0}restoreFgColor(N){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(N){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(N){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,p.DEFAULT_CHARSET),!0}selectCharset(N){return N.length!==2?(this.selectDefaultCharset(),!0):(N[0]==="/"||this._charsetService.setgCharset(C[N[0]],p.CHARSETS[N[1]]||p.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 N=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,N,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=n.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=n.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(N){return this._charsetService.setgLevel(N),!0}screenAlignmentPattern(){const N=new h.CellData;N.content=4194373,N.fg=this._curAttrData.fg,N.bg=this._curAttrData.bg,this._setCursor(0,0);for(let P=0;P<this._bufferService.rows;++P){const D=this._activeBuffer.ybase+this._activeBuffer.y+P,O=this._activeBuffer.lines.get(D);O&&(O.fill(N),O.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(N,P){const D=this._bufferService.buffer,O=this._optionsService.rawOptions;return(q=>(this._coreService.triggerDataEvent(`${a.C0.ESC}${q}${a.C0.ESC}\\`),!0))(N==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:N==='"p'?'P1$r61;1"p':N==="r"?`P1$r${D.scrollTop+1};${D.scrollBottom+1}r`:N==="m"?"P1$r0m":N===" q"?`P1$r${{block:2,underline:4,bar:6}[O.cursorStyle]-(O.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(N,P){this._dirtyRowTracker.markRangeDirty(N,P)}}r.InputHandler=I;let B=class{constructor($){this._bufferService=$,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty($){$<this.start?this.start=$:$>this.end&&(this.end=$)}markRangeDirty($,N){$>N&&(M=$,$=N,N=M),$<this.start&&(this.start=$),N>this.end&&(this.end=N)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function H($){return 0<=$&&$<256}B=u([f(0,S.IBufferService)],B)},844:(w,r)=>{function o(u){for(const f of u)f.dispose();u.length=0}Object.defineProperty(r,"__esModule",{value:!0}),r.getDisposeArrayDisposable=r.disposeArray=r.toDisposable=r.MutableDisposable=r.Disposable=void 0,r.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const u of this._disposables)u.dispose();this._disposables.length=0}register(u){return this._disposables.push(u),u}unregister(u){const f=this._disposables.indexOf(u);f!==-1&&this._disposables.splice(f,1)}},r.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(u){var f;this._isDisposed||u===this._value||((f=this._value)===null||f===void 0||f.dispose(),this._value=u)}clear(){this.value=void 0}dispose(){var u;this._isDisposed=!0,(u=this._value)===null||u===void 0||u.dispose(),this._value=void 0}},r.toDisposable=function(u){return{dispose:u}},r.disposeArray=o,r.getDisposeArrayDisposable=function(u){return{dispose:()=>o(u)}}},1505:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.FourKeyMap=r.TwoKeyMap=void 0;class o{constructor(){this._data={}}set(f,a,p){this._data[f]||(this._data[f]={}),this._data[f][a]=p}get(f,a){return this._data[f]?this._data[f][a]:void 0}clear(){this._data={}}}r.TwoKeyMap=o,r.FourKeyMap=class{constructor(){this._data=new o}set(u,f,a,p,m){this._data.get(u,f)||this._data.set(u,f,new o),this._data.get(u,f).set(a,p,m)}get(u,f,a,p){var m;return(m=this._data.get(u,f))===null||m===void 0?void 0:m.get(a,p)}clear(){this._data.clear()}}},6114:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.isChromeOS=r.isLinux=r.isWindows=r.isIphone=r.isIpad=r.isMac=r.getSafariVersion=r.isSafari=r.isLegacyEdge=r.isFirefox=r.isNode=void 0,r.isNode=typeof navigator>"u";const o=r.isNode?"node":navigator.userAgent,u=r.isNode?"node":navigator.platform;r.isFirefox=o.includes("Firefox"),r.isLegacyEdge=o.includes("Edge"),r.isSafari=/^((?!chrome|android).)*safari/i.test(o),r.getSafariVersion=function(){if(!r.isSafari)return 0;const f=o.match(/Version\/(\d+)/);return f===null||f.length<2?0:parseInt(f[1])},r.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(u),r.isIpad=u==="iPad",r.isIphone=u==="iPhone",r.isWindows=["Windows","Win16","Win32","WinCE"].includes(u),r.isLinux=u.indexOf("Linux")>=0,r.isChromeOS=/\bCrOS\b/.test(o)},6106:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.SortedList=void 0;let o=0;r.SortedList=class{constructor(u){this._getKey=u,this._array=[]}clear(){this._array.length=0}insert(u){this._array.length!==0?(o=this._search(this._getKey(u)),this._array.splice(o,0,u)):this._array.push(u)}delete(u){if(this._array.length===0)return!1;const f=this._getKey(u);if(f===void 0||(o=this._search(f),o===-1)||this._getKey(this._array[o])!==f)return!1;do if(this._array[o]===u)return this._array.splice(o,1),!0;while(++o<this._array.length&&this._getKey(this._array[o])===f);return!1}*getKeyIterator(u){if(this._array.length!==0&&(o=this._search(u),!(o<0||o>=this._array.length)&&this._getKey(this._array[o])===u))do yield this._array[o];while(++o<this._array.length&&this._getKey(this._array[o])===u)}forEachByKey(u,f){if(this._array.length!==0&&(o=this._search(u),!(o<0||o>=this._array.length)&&this._getKey(this._array[o])===u))do f(this._array[o]);while(++o<this._array.length&&this._getKey(this._array[o])===u)}values(){return[...this._array].values()}_search(u){let f=0,a=this._array.length-1;for(;a>=f;){let p=f+a>>1;const m=this._getKey(this._array[p]);if(m>u)a=p-1;else{if(!(m<u)){for(;p>0&&this._getKey(this._array[p-1])===u;)p--;return p}f=p+1}}return f}}},7226:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.DebouncedIdleTask=r.IdleTaskQueue=r.PriorityTaskQueue=void 0;const u=o(6114);class f{constructor(){this._tasks=[],this._i=0}enqueue(m){this._tasks.push(m),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(m){this._idleCallback=void 0;let y=0,b=0,n=m.timeRemaining(),d=0;for(;this._i<this._tasks.length;){if(y=Date.now(),this._tasks[this._i]()||this._i++,y=Math.max(1,Date.now()-y),b=Math.max(y,b),d=m.timeRemaining(),1.5*b>d)return n-y<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(n-y))}ms`),void this._start();n=d}this.clear()}}class a extends f{_requestCallback(m){return setTimeout((()=>m(this._createDeadline(16))))}_cancelCallback(m){clearTimeout(m)}_createDeadline(m){const y=Date.now()+m;return{timeRemaining:()=>Math.max(0,y-Date.now())}}}r.PriorityTaskQueue=a,r.IdleTaskQueue=!u.isNode&&"requestIdleCallback"in window?class extends f{_requestCallback(p){return requestIdleCallback(p)}_cancelCallback(p){cancelIdleCallback(p)}}:a,r.DebouncedIdleTask=class{constructor(){this._queue=new r.IdleTaskQueue}set(p){this._queue.clear(),this._queue.enqueue(p)}flush(){this._queue.flush()}}},9282:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.updateWindowsModeWrappedState=void 0;const u=o(643);r.updateWindowsModeWrappedState=function(f){const a=f.buffer.lines.get(f.buffer.ybase+f.buffer.y-1),p=a?.get(f.cols-1),m=f.buffer.lines.get(f.buffer.ybase+f.buffer.y);m&&p&&(m.isWrapped=p[u.CHAR_DATA_CODE_INDEX]!==u.NULL_CELL_CODE&&p[u.CHAR_DATA_CODE_INDEX]!==u.WHITESPACE_CELL_CODE)}},3734:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ExtendedAttrs=r.AttributeData=void 0;class o{constructor(){this.fg=0,this.bg=0,this.extended=new u}static toColorRGB(a){return[a>>>16&255,a>>>8&255,255&a]}static fromColorRGB(a){return(255&a[0])<<16|(255&a[1])<<8|255&a[2]}clone(){const a=new o;return a.fg=this.fg,a.bg=this.bg,a.extended=this.extended.clone(),a}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}}r.AttributeData=o;class u{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(a){this._ext=a}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(a){this._ext&=-469762049,this._ext|=a<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(a){this._ext&=-67108864,this._ext|=67108863&a}get urlId(){return this._urlId}set urlId(a){this._urlId=a}constructor(a=0,p=0){this._ext=0,this._urlId=0,this._ext=a,this._urlId=p}clone(){return new u(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}r.ExtendedAttrs=u},9092:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Buffer=r.MAX_BUFFER_SIZE=void 0;const u=o(6349),f=o(7226),a=o(3734),p=o(8437),m=o(4634),y=o(511),b=o(643),n=o(4863),d=o(7116);r.MAX_BUFFER_SIZE=4294967295,r.Buffer=class{constructor(c,h,_){this._hasScrollback=c,this._optionsService=h,this._bufferService=_,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=p.DEFAULT_ATTR_DATA.clone(),this.savedCharset=d.DEFAULT_CHARSET,this.markers=[],this._nullCell=y.CellData.fromCharData([0,b.NULL_CELL_CHAR,b.NULL_CELL_WIDTH,b.NULL_CELL_CODE]),this._whitespaceCell=y.CellData.fromCharData([0,b.WHITESPACE_CELL_CHAR,b.WHITESPACE_CELL_WIDTH,b.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new f.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new u.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(c){return c?(this._nullCell.fg=c.fg,this._nullCell.bg=c.bg,this._nullCell.extended=c.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new a.ExtendedAttrs),this._nullCell}getWhitespaceCell(c){return c?(this._whitespaceCell.fg=c.fg,this._whitespaceCell.bg=c.bg,this._whitespaceCell.extended=c.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new a.ExtendedAttrs),this._whitespaceCell}getBlankLine(c,h){return new p.BufferLine(this._bufferService.cols,this.getNullCell(c),h)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const c=this.ybase+this.y-this.ydisp;return c>=0&&c<this._rows}_getCorrectBufferLength(c){if(!this._hasScrollback)return c;const h=c+this._optionsService.rawOptions.scrollback;return h>r.MAX_BUFFER_SIZE?r.MAX_BUFFER_SIZE:h}fillViewportRows(c){if(this.lines.length===0){c===void 0&&(c=p.DEFAULT_ATTR_DATA);let h=this._rows;for(;h--;)this.lines.push(this.getBlankLine(c))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new u.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(c,h){const _=this.getNullCell(p.DEFAULT_ATTR_DATA);let S=0;const k=this._getCorrectBufferLength(h);if(k>this.lines.maxLength&&(this.lines.maxLength=k),this.lines.length>0){if(this._cols<c)for(let x=0;x<this.lines.length;x++)S+=+this.lines.get(x).resize(c,_);let E=0;if(this._rows<h)for(let x=this._rows;x<h;x++)this.lines.length<h+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new p.BufferLine(c,_)):this.ybase>0&&this.lines.length<=this.ybase+this.y+E+1?(this.ybase--,E++,this.ydisp>0&&this.ydisp--):this.lines.push(new p.BufferLine(c,_)));else for(let x=this._rows;x>h;x--)this.lines.length>h+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(k<this.lines.maxLength){const x=this.lines.length-k;x>0&&(this.lines.trimStart(x),this.ybase=Math.max(this.ybase-x,0),this.ydisp=Math.max(this.ydisp-x,0),this.savedY=Math.max(this.savedY-x,0)),this.lines.maxLength=k}this.x=Math.min(this.x,c-1),this.y=Math.min(this.y,h-1),E&&(this.y+=E),this.savedX=Math.min(this.savedX,c-1),this.scrollTop=0}if(this.scrollBottom=h-1,this._isReflowEnabled&&(this._reflow(c,h),this._cols>c))for(let E=0;E<this.lines.length;E++)S+=+this.lines.get(E).resize(c,_);this._cols=c,this._rows=h,this._memoryCleanupQueue.clear(),S>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let c=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,c=!1);let h=0;for(;this._memoryCleanupPosition<this.lines.length;)if(h+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),h>100)return!0;return c}get _isReflowEnabled(){const c=this._optionsService.rawOptions.windowsPty;return c&&c.buildNumber?this._hasScrollback&&c.backend==="conpty"&&c.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(c,h){this._cols!==c&&(c>this._cols?this._reflowLarger(c,h):this._reflowSmaller(c,h))}_reflowLarger(c,h){const _=(0,m.reflowLargerGetLinesToRemove)(this.lines,this._cols,c,this.ybase+this.y,this.getNullCell(p.DEFAULT_ATTR_DATA));if(_.length>0){const S=(0,m.reflowLargerCreateNewLayout)(this.lines,_);(0,m.reflowLargerApplyNewLayout)(this.lines,S.layout),this._reflowLargerAdjustViewport(c,h,S.countRemoved)}}_reflowLargerAdjustViewport(c,h,_){const S=this.getNullCell(p.DEFAULT_ATTR_DATA);let k=_;for(;k-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<h&&this.lines.push(new p.BufferLine(c,S))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-_,0)}_reflowSmaller(c,h){const _=this.getNullCell(p.DEFAULT_ATTR_DATA),S=[];let k=0;for(let E=this.lines.length-1;E>=0;E--){let x=this.lines.get(E);if(!x||!x.isWrapped&&x.getTrimmedLength()<=c)continue;const C=[x];for(;x.isWrapped&&E>0;)x=this.lines.get(--E),C.unshift(x);const T=this.ybase+this.y;if(T>=E&&T<E+C.length)continue;const L=C[C.length-1].getTrimmedLength(),R=(0,m.reflowSmallerGetNewLineLengths)(C,this._cols,c),M=R.length-C.length;let I;I=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 B=[];for(let O=0;O<M;O++){const q=this.getBlankLine(p.DEFAULT_ATTR_DATA,!0);B.push(q)}B.length>0&&(S.push({start:E+C.length+k,newLines:B}),k+=B.length),C.push(...B);let H=R.length-1,$=R[H];$===0&&(H--,$=R[H]);let N=C.length-M-1,P=L;for(;N>=0;){const O=Math.min(P,$);if(C[H]===void 0)break;if(C[H].copyCellsFrom(C[N],P-O,$-O,O,!0),$-=O,$===0&&(H--,$=R[H]),P-=O,P===0){N--;const q=Math.max(N,0);P=(0,m.getWrappedLineTrimmedLength)(C,q,this._cols)}}for(let O=0;O<C.length;O++)R[O]<c&&C[O].setCell(R[O],_);let D=M-I;for(;D-- >0;)this.ybase===0?this.y<h-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+k)-h&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+M,this.ybase+h-1)}if(S.length>0){const E=[],x=[];for(let H=0;H<this.lines.length;H++)x.push(this.lines.get(H));const C=this.lines.length;let T=C-1,L=0,R=S[L];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+k);let M=0;for(let H=Math.min(this.lines.maxLength-1,C+k-1);H>=0;H--)if(R&&R.start>T+M){for(let $=R.newLines.length-1;$>=0;$--)this.lines.set(H--,R.newLines[$]);H++,E.push({index:T+1,amount:R.newLines.length}),M+=R.newLines.length,R=S[++L]}else this.lines.set(H,x[T--]);let I=0;for(let H=E.length-1;H>=0;H--)E[H].index+=I,this.lines.onInsertEmitter.fire(E[H]),I+=E[H].amount;const B=Math.max(0,C+k-this.lines.maxLength);B>0&&this.lines.onTrimEmitter.fire(B)}}translateBufferLineToString(c,h,_=0,S){const k=this.lines.get(c);return k?k.translateToString(h,_,S):""}getWrappedRangeForLine(c){let h=c,_=c;for(;h>0&&this.lines.get(h).isWrapped;)h--;for(;_+1<this.lines.length&&this.lines.get(_+1).isWrapped;)_++;return{first:h,last:_}}setupTabStops(c){for(c!=null?this.tabs[c]||(c=this.prevStop(c)):(this.tabs={},c=0);c<this._cols;c+=this._optionsService.rawOptions.tabStopWidth)this.tabs[c]=!0}prevStop(c){for(c==null&&(c=this.x);!this.tabs[--c]&&c>0;);return c>=this._cols?this._cols-1:c<0?0:c}nextStop(c){for(c==null&&(c=this.x);!this.tabs[++c]&&c<this._cols;);return c>=this._cols?this._cols-1:c<0?0:c}clearMarkers(c){this._isClearing=!0;for(let h=0;h<this.markers.length;h++)this.markers[h].line===c&&(this.markers[h].dispose(),this.markers.splice(h--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let c=0;c<this.markers.length;c++)this.markers[c].dispose(),this.markers.splice(c--,1);this._isClearing=!1}addMarker(c){const h=new n.Marker(c);return this.markers.push(h),h.register(this.lines.onTrim((_=>{h.line-=_,h.line<0&&h.dispose()}))),h.register(this.lines.onInsert((_=>{h.line>=_.index&&(h.line+=_.amount)}))),h.register(this.lines.onDelete((_=>{h.line>=_.index&&h.line<_.index+_.amount&&h.dispose(),h.line>_.index&&(h.line-=_.amount)}))),h.register(h.onDispose((()=>this._removeMarker(h)))),h}_removeMarker(c){this._isClearing||this.markers.splice(this.markers.indexOf(c),1)}}},8437:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferLine=r.DEFAULT_ATTR_DATA=void 0;const u=o(3734),f=o(511),a=o(643),p=o(482);r.DEFAULT_ATTR_DATA=Object.freeze(new u.AttributeData);let m=0;class y{constructor(n,d,c=!1){this.isWrapped=c,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*n);const h=d||f.CellData.fromCharData([0,a.NULL_CELL_CHAR,a.NULL_CELL_WIDTH,a.NULL_CELL_CODE]);for(let _=0;_<n;++_)this.setCell(_,h);this.length=n}get(n){const d=this._data[3*n+0],c=2097151&d;return[this._data[3*n+1],2097152&d?this._combined[n]:c?(0,p.stringFromCodePoint)(c):"",d>>22,2097152&d?this._combined[n].charCodeAt(this._combined[n].length-1):c]}set(n,d){this._data[3*n+1]=d[a.CHAR_DATA_ATTR_INDEX],d[a.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[n]=d[1],this._data[3*n+0]=2097152|n|d[a.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*n+0]=d[a.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|d[a.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(n){return this._data[3*n+0]>>22}hasWidth(n){return 12582912&this._data[3*n+0]}getFg(n){return this._data[3*n+1]}getBg(n){return this._data[3*n+2]}hasContent(n){return 4194303&this._data[3*n+0]}getCodePoint(n){const d=this._data[3*n+0];return 2097152&d?this._combined[n].charCodeAt(this._combined[n].length-1):2097151&d}isCombined(n){return 2097152&this._data[3*n+0]}getString(n){const d=this._data[3*n+0];return 2097152&d?this._combined[n]:2097151&d?(0,p.stringFromCodePoint)(2097151&d):""}isProtected(n){return 536870912&this._data[3*n+2]}loadCell(n,d){return m=3*n,d.content=this._data[m+0],d.fg=this._data[m+1],d.bg=this._data[m+2],2097152&d.content&&(d.combinedData=this._combined[n]),268435456&d.bg&&(d.extended=this._extendedAttrs[n]),d}setCell(n,d){2097152&d.content&&(this._combined[n]=d.combinedData),268435456&d.bg&&(this._extendedAttrs[n]=d.extended),this._data[3*n+0]=d.content,this._data[3*n+1]=d.fg,this._data[3*n+2]=d.bg}setCellFromCodePoint(n,d,c,h,_,S){268435456&_&&(this._extendedAttrs[n]=S),this._data[3*n+0]=d|c<<22,this._data[3*n+1]=h,this._data[3*n+2]=_}addCodepointToCell(n,d){let c=this._data[3*n+0];2097152&c?this._combined[n]+=(0,p.stringFromCodePoint)(d):(2097151&c?(this._combined[n]=(0,p.stringFromCodePoint)(2097151&c)+(0,p.stringFromCodePoint)(d),c&=-2097152,c|=2097152):c=d|4194304,this._data[3*n+0]=c)}insertCells(n,d,c,h){if((n%=this.length)&&this.getWidth(n-1)===2&&this.setCellFromCodePoint(n-1,0,1,h?.fg||0,h?.bg||0,h?.extended||new u.ExtendedAttrs),d<this.length-n){const _=new f.CellData;for(let S=this.length-n-d-1;S>=0;--S)this.setCell(n+d+S,this.loadCell(n+S,_));for(let S=0;S<d;++S)this.setCell(n+S,c)}else for(let _=n;_<this.length;++_)this.setCell(_,c);this.getWidth(this.length-1)===2&&this.setCellFromCodePoint(this.length-1,0,1,h?.fg||0,h?.bg||0,h?.extended||new u.ExtendedAttrs)}deleteCells(n,d,c,h){if(n%=this.length,d<this.length-n){const _=new f.CellData;for(let S=0;S<this.length-n-d;++S)this.setCell(n+S,this.loadCell(n+d+S,_));for(let S=this.length-d;S<this.length;++S)this.setCell(S,c)}else for(let _=n;_<this.length;++_)this.setCell(_,c);n&&this.getWidth(n-1)===2&&this.setCellFromCodePoint(n-1,0,1,h?.fg||0,h?.bg||0,h?.extended||new u.ExtendedAttrs),this.getWidth(n)!==0||this.hasContent(n)||this.setCellFromCodePoint(n,0,1,h?.fg||0,h?.bg||0,h?.extended||new u.ExtendedAttrs)}replaceCells(n,d,c,h,_=!1){if(_)for(n&&this.getWidth(n-1)===2&&!this.isProtected(n-1)&&this.setCellFromCodePoint(n-1,0,1,h?.fg||0,h?.bg||0,h?.extended||new u.ExtendedAttrs),d<this.length&&this.getWidth(d-1)===2&&!this.isProtected(d)&&this.setCellFromCodePoint(d,0,1,h?.fg||0,h?.bg||0,h?.extended||new u.ExtendedAttrs);n<d&&n<this.length;)this.isProtected(n)||this.setCell(n,c),n++;else for(n&&this.getWidth(n-1)===2&&this.setCellFromCodePoint(n-1,0,1,h?.fg||0,h?.bg||0,h?.extended||new u.ExtendedAttrs),d<this.length&&this.getWidth(d-1)===2&&this.setCellFromCodePoint(d,0,1,h?.fg||0,h?.bg||0,h?.extended||new u.ExtendedAttrs);n<d&&n<this.length;)this.setCell(n++,c)}resize(n,d){if(n===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const c=3*n;if(n>this.length){if(this._data.buffer.byteLength>=4*c)this._data=new Uint32Array(this._data.buffer,0,c);else{const h=new Uint32Array(c);h.set(this._data),this._data=h}for(let h=this.length;h<n;++h)this.setCell(h,d)}else{this._data=this._data.subarray(0,c);const h=Object.keys(this._combined);for(let S=0;S<h.length;S++){const k=parseInt(h[S],10);k>=n&&delete this._combined[k]}const _=Object.keys(this._extendedAttrs);for(let S=0;S<_.length;S++){const k=parseInt(_[S],10);k>=n&&delete this._extendedAttrs[k]}}return this.length=n,4*c*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const n=new Uint32Array(this._data.length);return n.set(this._data),this._data=n,1}return 0}fill(n,d=!1){if(d)for(let c=0;c<this.length;++c)this.isProtected(c)||this.setCell(c,n);else{this._combined={},this._extendedAttrs={};for(let c=0;c<this.length;++c)this.setCell(c,n)}}copyFrom(n){this.length!==n.length?this._data=new Uint32Array(n._data):this._data.set(n._data),this.length=n.length,this._combined={};for(const d in n._combined)this._combined[d]=n._combined[d];this._extendedAttrs={};for(const d in n._extendedAttrs)this._extendedAttrs[d]=n._extendedAttrs[d];this.isWrapped=n.isWrapped}clone(){const n=new y(0);n._data=new Uint32Array(this._data),n.length=this.length;for(const d in this._combined)n._combined[d]=this._combined[d];for(const d in this._extendedAttrs)n._extendedAttrs[d]=this._extendedAttrs[d];return n.isWrapped=this.isWrapped,n}getTrimmedLength(){for(let n=this.length-1;n>=0;--n)if(4194303&this._data[3*n+0])return n+(this._data[3*n+0]>>22);return 0}getNoBgTrimmedLength(){for(let n=this.length-1;n>=0;--n)if(4194303&this._data[3*n+0]||50331648&this._data[3*n+2])return n+(this._data[3*n+0]>>22);return 0}copyCellsFrom(n,d,c,h,_){const S=n._data;if(_)for(let E=h-1;E>=0;E--){for(let x=0;x<3;x++)this._data[3*(c+E)+x]=S[3*(d+E)+x];268435456&S[3*(d+E)+2]&&(this._extendedAttrs[c+E]=n._extendedAttrs[d+E])}else for(let E=0;E<h;E++){for(let x=0;x<3;x++)this._data[3*(c+E)+x]=S[3*(d+E)+x];268435456&S[3*(d+E)+2]&&(this._extendedAttrs[c+E]=n._extendedAttrs[d+E])}const k=Object.keys(n._combined);for(let E=0;E<k.length;E++){const x=parseInt(k[E],10);x>=d&&(this._combined[x-d+c]=n._combined[x])}}translateToString(n=!1,d=0,c=this.length){n&&(c=Math.min(c,this.getTrimmedLength()));let h="";for(;d<c;){const _=this._data[3*d+0],S=2097151&_;h+=2097152&_?this._combined[d]:S?(0,p.stringFromCodePoint)(S):a.WHITESPACE_CELL_CHAR,d+=_>>22||1}return h}}r.BufferLine=y},4841:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.getRangeLength=void 0,r.getRangeLength=function(o,u){if(o.start.y>o.end.y)throw new Error(`Buffer range end (${o.end.x}, ${o.end.y}) cannot be before start (${o.start.x}, ${o.start.y})`);return u*(o.end.y-o.start.y)+(o.end.x-o.start.x+1)}},4634:(w,r)=>{function o(u,f,a){if(f===u.length-1)return u[f].getTrimmedLength();const p=!u[f].hasContent(a-1)&&u[f].getWidth(a-1)===1,m=u[f+1].getWidth(0)===2;return p&&m?a-1:a}Object.defineProperty(r,"__esModule",{value:!0}),r.getWrappedLineTrimmedLength=r.reflowSmallerGetNewLineLengths=r.reflowLargerApplyNewLayout=r.reflowLargerCreateNewLayout=r.reflowLargerGetLinesToRemove=void 0,r.reflowLargerGetLinesToRemove=function(u,f,a,p,m){const y=[];for(let b=0;b<u.length-1;b++){let n=b,d=u.get(++n);if(!d.isWrapped)continue;const c=[u.get(b)];for(;n<u.length&&d.isWrapped;)c.push(d),d=u.get(++n);if(p>=b&&p<n){b+=c.length-1;continue}let h=0,_=o(c,h,f),S=1,k=0;for(;S<c.length;){const x=o(c,S,f),C=x-k,T=a-_,L=Math.min(C,T);c[h].copyCellsFrom(c[S],k,_,L,!1),_+=L,_===a&&(h++,_=0),k+=L,k===x&&(S++,k=0),_===0&&h!==0&&c[h-1].getWidth(a-1)===2&&(c[h].copyCellsFrom(c[h-1],a-1,_++,1,!1),c[h-1].setCell(a-1,m))}c[h].replaceCells(_,a,m);let E=0;for(let x=c.length-1;x>0&&(x>h||c[x].getTrimmedLength()===0);x--)E++;E>0&&(y.push(b+c.length-E),y.push(E)),b+=c.length-1}return y},r.reflowLargerCreateNewLayout=function(u,f){const a=[];let p=0,m=f[p],y=0;for(let b=0;b<u.length;b++)if(m===b){const n=f[++p];u.onDeleteEmitter.fire({index:b-y,amount:n}),b+=n-1,y+=n,m=f[++p]}else a.push(b);return{layout:a,countRemoved:y}},r.reflowLargerApplyNewLayout=function(u,f){const a=[];for(let p=0;p<f.length;p++)a.push(u.get(f[p]));for(let p=0;p<a.length;p++)u.set(p,a[p]);u.length=f.length},r.reflowSmallerGetNewLineLengths=function(u,f,a){const p=[],m=u.map(((d,c)=>o(u,c,f))).reduce(((d,c)=>d+c));let y=0,b=0,n=0;for(;n<m;){if(m-n<a){p.push(m-n);break}y+=a;const d=o(u,b,f);y>d&&(y-=d,b++);const c=u[b].getWidth(y-1)===2;c&&y--;const h=c?a-1:a;p.push(h),n+=h}return p},r.getWrappedLineTrimmedLength=o},5295:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferSet=void 0;const u=o(8460),f=o(844),a=o(9092);class p extends f.Disposable{constructor(y,b){super(),this._optionsService=y,this._bufferService=b,this._onBufferActivate=this.register(new u.EventEmitter),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.resize(this._bufferService.cols,this._bufferService.rows)))),this.register(this._optionsService.onSpecificOptionChange("tabStopWidth",(()=>this.setupTabStops())))}reset(){this._normal=new a.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new a.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(y){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(y),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(y,b){this._normal.resize(y,b),this._alt.resize(y,b),this.setupTabStops(y)}setupTabStops(y){this._normal.setupTabStops(y),this._alt.setupTabStops(y)}}r.BufferSet=p},511:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CellData=void 0;const u=o(482),f=o(643),a=o(3734);class p extends a.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new a.ExtendedAttrs,this.combinedData=""}static fromCharData(y){const b=new p;return b.setFromCharData(y),b}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,u.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(y){this.fg=y[f.CHAR_DATA_ATTR_INDEX],this.bg=0;let b=!1;if(y[f.CHAR_DATA_CHAR_INDEX].length>2)b=!0;else if(y[f.CHAR_DATA_CHAR_INDEX].length===2){const n=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=n&&n<=56319){const d=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=d&&d<=57343?this.content=1024*(n-55296)+d-56320+65536|y[f.CHAR_DATA_WIDTH_INDEX]<<22:b=!0}else b=!0}else this.content=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|y[f.CHAR_DATA_WIDTH_INDEX]<<22;b&&(this.combinedData=y[f.CHAR_DATA_CHAR_INDEX],this.content=2097152|y[f.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}r.CellData=p},643:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.WHITESPACE_CELL_CODE=r.WHITESPACE_CELL_WIDTH=r.WHITESPACE_CELL_CHAR=r.NULL_CELL_CODE=r.NULL_CELL_WIDTH=r.NULL_CELL_CHAR=r.CHAR_DATA_CODE_INDEX=r.CHAR_DATA_WIDTH_INDEX=r.CHAR_DATA_CHAR_INDEX=r.CHAR_DATA_ATTR_INDEX=r.DEFAULT_EXT=r.DEFAULT_ATTR=r.DEFAULT_COLOR=void 0,r.DEFAULT_COLOR=0,r.DEFAULT_ATTR=256|r.DEFAULT_COLOR<<9,r.DEFAULT_EXT=0,r.CHAR_DATA_ATTR_INDEX=0,r.CHAR_DATA_CHAR_INDEX=1,r.CHAR_DATA_WIDTH_INDEX=2,r.CHAR_DATA_CODE_INDEX=3,r.NULL_CELL_CHAR="",r.NULL_CELL_WIDTH=1,r.NULL_CELL_CODE=0,r.WHITESPACE_CELL_CHAR=" ",r.WHITESPACE_CELL_WIDTH=1,r.WHITESPACE_CELL_CODE=32},4863:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Marker=void 0;const u=o(8460),f=o(844);class a{get id(){return this._id}constructor(m){this.line=m,this.isDisposed=!1,this._disposables=[],this._id=a._nextId++,this._onDispose=this.register(new u.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,f.disposeArray)(this._disposables),this._disposables.length=0)}register(m){return this._disposables.push(m),m}}r.Marker=a,a._nextId=1},7116:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.DEFAULT_CHARSET=r.CHARSETS=void 0,r.CHARSETS={},r.DEFAULT_CHARSET=r.CHARSETS.B,r.CHARSETS[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},r.CHARSETS.A={"#":"£"},r.CHARSETS.B=void 0,r.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},r.CHARSETS.C=r.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},r.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},r.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},r.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},r.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},r.CHARSETS.E=r.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},r.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},r.CHARSETS.H=r.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},r.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(w,r)=>{var o,u,f;Object.defineProperty(r,"__esModule",{value:!0}),r.C1_ESCAPED=r.C1=r.C0=void 0,(function(a){a.NUL="\0",a.SOH="",a.STX="",a.ETX="",a.EOT="",a.ENQ="",a.ACK="",a.BEL="\x07",a.BS="\b",a.HT=" ",a.LF=`
15
+ `,a.VT="\v",a.FF="\f",a.CR="\r",a.SO="",a.SI="",a.DLE="",a.DC1="",a.DC2="",a.DC3="",a.DC4="",a.NAK="",a.SYN="",a.ETB="",a.CAN="",a.EM="",a.SUB="",a.ESC="\x1B",a.FS="",a.GS="",a.RS="",a.US="",a.SP=" ",a.DEL=""})(o||(r.C0=o={})),(function(a){a.PAD="€",a.HOP="",a.BPH="‚",a.NBH="ƒ",a.IND="„",a.NEL="…",a.SSA="†",a.ESA="‡",a.HTS="ˆ",a.HTJ="‰",a.VTS="Š",a.PLD="‹",a.PLU="Œ",a.RI="",a.SS2="Ž",a.SS3="",a.DCS="",a.PU1="‘",a.PU2="’",a.STS="“",a.CCH="”",a.MW="•",a.SPA="–",a.EPA="—",a.SOS="˜",a.SGCI="™",a.SCI="š",a.CSI="›",a.ST="œ",a.OSC="",a.PM="ž",a.APC="Ÿ"})(u||(r.C1=u={})),(function(a){a.ST=`${o.ESC}\\`})(f||(r.C1_ESCAPED=f={}))},7399:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.evaluateKeyboardEvent=void 0;const u=o(2584),f={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};r.evaluateKeyboardEvent=function(a,p,m,y){const b={type:0,cancel:!1,key:void 0},n=(a.shiftKey?1:0)|(a.altKey?2:0)|(a.ctrlKey?4:0)|(a.metaKey?8:0);switch(a.keyCode){case 0:a.key==="UIKeyInputUpArrow"?b.key=p?u.C0.ESC+"OA":u.C0.ESC+"[A":a.key==="UIKeyInputLeftArrow"?b.key=p?u.C0.ESC+"OD":u.C0.ESC+"[D":a.key==="UIKeyInputRightArrow"?b.key=p?u.C0.ESC+"OC":u.C0.ESC+"[C":a.key==="UIKeyInputDownArrow"&&(b.key=p?u.C0.ESC+"OB":u.C0.ESC+"[B");break;case 8:if(a.altKey){b.key=u.C0.ESC+u.C0.DEL;break}b.key=u.C0.DEL;break;case 9:if(a.shiftKey){b.key=u.C0.ESC+"[Z";break}b.key=u.C0.HT,b.cancel=!0;break;case 13:b.key=a.altKey?u.C0.ESC+u.C0.CR:u.C0.CR,b.cancel=!0;break;case 27:b.key=u.C0.ESC,a.altKey&&(b.key=u.C0.ESC+u.C0.ESC),b.cancel=!0;break;case 37:if(a.metaKey)break;n?(b.key=u.C0.ESC+"[1;"+(n+1)+"D",b.key===u.C0.ESC+"[1;3D"&&(b.key=u.C0.ESC+(m?"b":"[1;5D"))):b.key=p?u.C0.ESC+"OD":u.C0.ESC+"[D";break;case 39:if(a.metaKey)break;n?(b.key=u.C0.ESC+"[1;"+(n+1)+"C",b.key===u.C0.ESC+"[1;3C"&&(b.key=u.C0.ESC+(m?"f":"[1;5C"))):b.key=p?u.C0.ESC+"OC":u.C0.ESC+"[C";break;case 38:if(a.metaKey)break;n?(b.key=u.C0.ESC+"[1;"+(n+1)+"A",m||b.key!==u.C0.ESC+"[1;3A"||(b.key=u.C0.ESC+"[1;5A")):b.key=p?u.C0.ESC+"OA":u.C0.ESC+"[A";break;case 40:if(a.metaKey)break;n?(b.key=u.C0.ESC+"[1;"+(n+1)+"B",m||b.key!==u.C0.ESC+"[1;3B"||(b.key=u.C0.ESC+"[1;5B")):b.key=p?u.C0.ESC+"OB":u.C0.ESC+"[B";break;case 45:a.shiftKey||a.ctrlKey||(b.key=u.C0.ESC+"[2~");break;case 46:b.key=n?u.C0.ESC+"[3;"+(n+1)+"~":u.C0.ESC+"[3~";break;case 36:b.key=n?u.C0.ESC+"[1;"+(n+1)+"H":p?u.C0.ESC+"OH":u.C0.ESC+"[H";break;case 35:b.key=n?u.C0.ESC+"[1;"+(n+1)+"F":p?u.C0.ESC+"OF":u.C0.ESC+"[F";break;case 33:a.shiftKey?b.type=2:a.ctrlKey?b.key=u.C0.ESC+"[5;"+(n+1)+"~":b.key=u.C0.ESC+"[5~";break;case 34:a.shiftKey?b.type=3:a.ctrlKey?b.key=u.C0.ESC+"[6;"+(n+1)+"~":b.key=u.C0.ESC+"[6~";break;case 112:b.key=n?u.C0.ESC+"[1;"+(n+1)+"P":u.C0.ESC+"OP";break;case 113:b.key=n?u.C0.ESC+"[1;"+(n+1)+"Q":u.C0.ESC+"OQ";break;case 114:b.key=n?u.C0.ESC+"[1;"+(n+1)+"R":u.C0.ESC+"OR";break;case 115:b.key=n?u.C0.ESC+"[1;"+(n+1)+"S":u.C0.ESC+"OS";break;case 116:b.key=n?u.C0.ESC+"[15;"+(n+1)+"~":u.C0.ESC+"[15~";break;case 117:b.key=n?u.C0.ESC+"[17;"+(n+1)+"~":u.C0.ESC+"[17~";break;case 118:b.key=n?u.C0.ESC+"[18;"+(n+1)+"~":u.C0.ESC+"[18~";break;case 119:b.key=n?u.C0.ESC+"[19;"+(n+1)+"~":u.C0.ESC+"[19~";break;case 120:b.key=n?u.C0.ESC+"[20;"+(n+1)+"~":u.C0.ESC+"[20~";break;case 121:b.key=n?u.C0.ESC+"[21;"+(n+1)+"~":u.C0.ESC+"[21~";break;case 122:b.key=n?u.C0.ESC+"[23;"+(n+1)+"~":u.C0.ESC+"[23~";break;case 123:b.key=n?u.C0.ESC+"[24;"+(n+1)+"~":u.C0.ESC+"[24~";break;default:if(!a.ctrlKey||a.shiftKey||a.altKey||a.metaKey)if(m&&!y||!a.altKey||a.metaKey)!m||a.altKey||a.ctrlKey||a.shiftKey||!a.metaKey?a.key&&!a.ctrlKey&&!a.altKey&&!a.metaKey&&a.keyCode>=48&&a.key.length===1?b.key=a.key:a.key&&a.ctrlKey&&(a.key==="_"&&(b.key=u.C0.US),a.key==="@"&&(b.key=u.C0.NUL)):a.keyCode===65&&(b.type=1);else{const d=f[a.keyCode],c=d?.[a.shiftKey?1:0];if(c)b.key=u.C0.ESC+c;else if(a.keyCode>=65&&a.keyCode<=90){const h=a.ctrlKey?a.keyCode-64:a.keyCode+32;let _=String.fromCharCode(h);a.shiftKey&&(_=_.toUpperCase()),b.key=u.C0.ESC+_}else if(a.keyCode===32)b.key=u.C0.ESC+(a.ctrlKey?u.C0.NUL:" ");else if(a.key==="Dead"&&a.code.startsWith("Key")){let h=a.code.slice(3,4);a.shiftKey||(h=h.toLowerCase()),b.key=u.C0.ESC+h,b.cancel=!0}}else a.keyCode>=65&&a.keyCode<=90?b.key=String.fromCharCode(a.keyCode-64):a.keyCode===32?b.key=u.C0.NUL:a.keyCode>=51&&a.keyCode<=55?b.key=String.fromCharCode(a.keyCode-51+27):a.keyCode===56?b.key=u.C0.DEL:a.keyCode===219?b.key=u.C0.ESC:a.keyCode===220?b.key=u.C0.FS:a.keyCode===221&&(b.key=u.C0.GS)}return b}},482:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Utf8ToUtf32=r.StringToUtf32=r.utf32ToString=r.stringFromCodePoint=void 0,r.stringFromCodePoint=function(o){return o>65535?(o-=65536,String.fromCharCode(55296+(o>>10))+String.fromCharCode(o%1024+56320)):String.fromCharCode(o)},r.utf32ToString=function(o,u=0,f=o.length){let a="";for(let p=u;p<f;++p){let m=o[p];m>65535?(m-=65536,a+=String.fromCharCode(55296+(m>>10))+String.fromCharCode(m%1024+56320)):a+=String.fromCharCode(m)}return a},r.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(o,u){const f=o.length;if(!f)return 0;let a=0,p=0;if(this._interim){const m=o.charCodeAt(p++);56320<=m&&m<=57343?u[a++]=1024*(this._interim-55296)+m-56320+65536:(u[a++]=this._interim,u[a++]=m),this._interim=0}for(let m=p;m<f;++m){const y=o.charCodeAt(m);if(55296<=y&&y<=56319){if(++m>=f)return this._interim=y,a;const b=o.charCodeAt(m);56320<=b&&b<=57343?u[a++]=1024*(y-55296)+b-56320+65536:(u[a++]=y,u[a++]=b)}else y!==65279&&(u[a++]=y)}return a}},r.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(o,u){const f=o.length;if(!f)return 0;let a,p,m,y,b=0,n=0,d=0;if(this.interim[0]){let _=!1,S=this.interim[0];S&=(224&S)==192?31:(240&S)==224?15:7;let k,E=0;for(;(k=63&this.interim[++E])&&E<4;)S<<=6,S|=k;const x=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,C=x-E;for(;d<C;){if(d>=f)return 0;if(k=o[d++],(192&k)!=128){d--,_=!0;break}this.interim[E++]=k,S<<=6,S|=63&k}_||(x===2?S<128?d--:u[b++]=S:x===3?S<2048||S>=55296&&S<=57343||S===65279||(u[b++]=S):S<65536||S>1114111||(u[b++]=S)),this.interim.fill(0)}const c=f-4;let h=d;for(;h<f;){for(;!(!(h<c)||128&(a=o[h])||128&(p=o[h+1])||128&(m=o[h+2])||128&(y=o[h+3]));)u[b++]=a,u[b++]=p,u[b++]=m,u[b++]=y,h+=4;if(a=o[h++],a<128)u[b++]=a;else if((224&a)==192){if(h>=f)return this.interim[0]=a,b;if(p=o[h++],(192&p)!=128){h--;continue}if(n=(31&a)<<6|63&p,n<128){h--;continue}u[b++]=n}else if((240&a)==224){if(h>=f)return this.interim[0]=a,b;if(p=o[h++],(192&p)!=128){h--;continue}if(h>=f)return this.interim[0]=a,this.interim[1]=p,b;if(m=o[h++],(192&m)!=128){h--;continue}if(n=(15&a)<<12|(63&p)<<6|63&m,n<2048||n>=55296&&n<=57343||n===65279)continue;u[b++]=n}else if((248&a)==240){if(h>=f)return this.interim[0]=a,b;if(p=o[h++],(192&p)!=128){h--;continue}if(h>=f)return this.interim[0]=a,this.interim[1]=p,b;if(m=o[h++],(192&m)!=128){h--;continue}if(h>=f)return this.interim[0]=a,this.interim[1]=p,this.interim[2]=m,b;if(y=o[h++],(192&y)!=128){h--;continue}if(n=(7&a)<<18|(63&p)<<12|(63&m)<<6|63&y,n<65536||n>1114111)continue;u[b++]=n}}return b}}},225:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.UnicodeV6=void 0;const o=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],u=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]];let f;r.UnicodeV6=class{constructor(){if(this.version="6",!f){f=new Uint8Array(65536),f.fill(1),f[0]=0,f.fill(0,1,32),f.fill(0,127,160),f.fill(2,4352,4448),f[9001]=2,f[9002]=2,f.fill(2,11904,42192),f[12351]=1,f.fill(2,44032,55204),f.fill(2,63744,64256),f.fill(2,65040,65050),f.fill(2,65072,65136),f.fill(2,65280,65377),f.fill(2,65504,65511);for(let a=0;a<o.length;++a)f.fill(0,o[a][0],o[a][1]+1)}}wcwidth(a){return a<32?0:a<127?1:a<65536?f[a]:(function(p,m){let y,b=0,n=m.length-1;if(p<m[0][0]||p>m[n][1])return!1;for(;n>=b;)if(y=b+n>>1,p>m[y][1])b=y+1;else{if(!(p<m[y][0]))return!0;n=y-1}return!1})(a,u)?0:a>=131072&&a<=196605||a>=196608&&a<=262141?2:1}}},5981:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.WriteBuffer=void 0;const u=o(8460),f=o(844);class a extends f.Disposable{constructor(m){super(),this._action=m,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new u.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(m,y){if(y!==void 0&&this._syncCalls>y)return void(this._syncCalls=0);if(this._pendingData+=m.length,this._writeBuffer.push(m),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let b;for(this._isSyncWriting=!0;b=this._writeBuffer.shift();){this._action(b);const n=this._callbacks.shift();n&&n()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(m,y){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=m.length,this._writeBuffer.push(m),this._callbacks.push(y),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=m.length,this._writeBuffer.push(m),this._callbacks.push(y)}_innerWrite(m=0,y=!0){const b=m||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const n=this._writeBuffer[this._bufferOffset],d=this._action(n,y);if(d){const h=_=>Date.now()-b>=12?setTimeout((()=>this._innerWrite(0,_))):this._innerWrite(b,_);return void d.catch((_=>(queueMicrotask((()=>{throw _})),Promise.resolve(!1)))).then(h)}const c=this._callbacks[this._bufferOffset];if(c&&c(),this._bufferOffset++,this._pendingData-=n.length,Date.now()-b>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((()=>this._innerWrite()))):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}r.WriteBuffer=a},5941:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.toRgbString=r.parseColor=void 0;const o=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,u=/^[\da-f]+$/;function f(a,p){const m=a.toString(16),y=m.length<2?"0"+m:m;switch(p){case 4:return m[0];case 8:return y;case 12:return(y+y).slice(0,3);default:return y+y}}r.parseColor=function(a){if(!a)return;let p=a.toLowerCase();if(p.indexOf("rgb:")===0){p=p.slice(4);const m=o.exec(p);if(m){const y=m[1]?15:m[4]?255:m[7]?4095:65535;return[Math.round(parseInt(m[1]||m[4]||m[7]||m[10],16)/y*255),Math.round(parseInt(m[2]||m[5]||m[8]||m[11],16)/y*255),Math.round(parseInt(m[3]||m[6]||m[9]||m[12],16)/y*255)]}}else if(p.indexOf("#")===0&&(p=p.slice(1),u.exec(p)&&[3,6,9,12].includes(p.length))){const m=p.length/3,y=[0,0,0];for(let b=0;b<3;++b){const n=parseInt(p.slice(m*b,m*b+m),16);y[b]=m===1?n<<4:m===2?n:m===3?n>>4:n>>8}return y}},r.toRgbString=function(a,p=16){const[m,y,b]=a;return`rgb:${f(m,p)}/${f(y,p)}/${f(b,p)}`}},5770:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.PAYLOAD_LIMIT=void 0,r.PAYLOAD_LIMIT=1e7},6351:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.DcsHandler=r.DcsParser=void 0;const u=o(482),f=o(8742),a=o(5770),p=[];r.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=p,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=p}registerHandler(y,b){this._handlers[y]===void 0&&(this._handlers[y]=[]);const n=this._handlers[y];return n.push(b),{dispose:()=>{const d=n.indexOf(b);d!==-1&&n.splice(d,1)}}}clearHandler(y){this._handlers[y]&&delete this._handlers[y]}setHandlerFallback(y){this._handlerFb=y}reset(){if(this._active.length)for(let y=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;y>=0;--y)this._active[y].unhook(!1);this._stack.paused=!1,this._active=p,this._ident=0}hook(y,b){if(this.reset(),this._ident=y,this._active=this._handlers[y]||p,this._active.length)for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(b);else this._handlerFb(this._ident,"HOOK",b)}put(y,b,n){if(this._active.length)for(let d=this._active.length-1;d>=0;d--)this._active[d].put(y,b,n);else this._handlerFb(this._ident,"PUT",(0,u.utf32ToString)(y,b,n))}unhook(y,b=!0){if(this._active.length){let n=!1,d=this._active.length-1,c=!1;if(this._stack.paused&&(d=this._stack.loopPosition-1,n=b,c=this._stack.fallThrough,this._stack.paused=!1),!c&&n===!1){for(;d>=0&&(n=this._active[d].unhook(y),n!==!0);d--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=d,this._stack.fallThrough=!1,n;d--}for(;d>=0;d--)if(n=this._active[d].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=d,this._stack.fallThrough=!0,n}else this._handlerFb(this._ident,"UNHOOK",y);this._active=p,this._ident=0}};const m=new f.Params;m.addParam(0),r.DcsHandler=class{constructor(y){this._handler=y,this._data="",this._params=m,this._hitLimit=!1}hook(y){this._params=y.length>1||y.params[0]?y.clone():m,this._data="",this._hitLimit=!1}put(y,b,n){this._hitLimit||(this._data+=(0,u.utf32ToString)(y,b,n),this._data.length>a.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(y){let b=!1;if(this._hitLimit)b=!1;else if(y&&(b=this._handler(this._data,this._params),b instanceof Promise))return b.then((n=>(this._params=m,this._data="",this._hitLimit=!1,n)));return this._params=m,this._data="",this._hitLimit=!1,b}}},2015:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.EscapeSequenceParser=r.VT500_TRANSITION_TABLE=r.TransitionTable=void 0;const u=o(844),f=o(8742),a=o(6242),p=o(6351);class m{constructor(d){this.table=new Uint8Array(d)}setDefault(d,c){this.table.fill(d<<4|c)}add(d,c,h,_){this.table[c<<8|d]=h<<4|_}addMany(d,c,h,_){for(let S=0;S<d.length;S++)this.table[c<<8|d[S]]=h<<4|_}}r.TransitionTable=m;const y=160;r.VT500_TRANSITION_TABLE=(function(){const n=new m(4095),d=Array.apply(null,Array(256)).map(((E,x)=>x)),c=(E,x)=>d.slice(E,x),h=c(32,127),_=c(0,24);_.push(25),_.push.apply(_,c(28,32));const S=c(0,14);let k;for(k in n.setDefault(1,0),n.addMany(h,0,2,0),S)n.addMany([24,26,153,154],k,3,0),n.addMany(c(128,144),k,3,0),n.addMany(c(144,152),k,3,0),n.add(156,k,0,0),n.add(27,k,11,1),n.add(157,k,4,8),n.addMany([152,158,159],k,0,7),n.add(155,k,11,3),n.add(144,k,11,9);return n.addMany(_,0,3,0),n.addMany(_,1,3,1),n.add(127,1,0,1),n.addMany(_,8,0,8),n.addMany(_,3,3,3),n.add(127,3,0,3),n.addMany(_,4,3,4),n.add(127,4,0,4),n.addMany(_,6,3,6),n.addMany(_,5,3,5),n.add(127,5,0,5),n.addMany(_,2,3,2),n.add(127,2,0,2),n.add(93,1,4,8),n.addMany(h,8,5,8),n.add(127,8,5,8),n.addMany([156,27,24,26,7],8,6,0),n.addMany(c(28,32),8,0,8),n.addMany([88,94,95],1,0,7),n.addMany(h,7,0,7),n.addMany(_,7,0,7),n.add(156,7,0,0),n.add(127,7,0,7),n.add(91,1,11,3),n.addMany(c(64,127),3,7,0),n.addMany(c(48,60),3,8,4),n.addMany([60,61,62,63],3,9,4),n.addMany(c(48,60),4,8,4),n.addMany(c(64,127),4,7,0),n.addMany([60,61,62,63],4,0,6),n.addMany(c(32,64),6,0,6),n.add(127,6,0,6),n.addMany(c(64,127),6,0,0),n.addMany(c(32,48),3,9,5),n.addMany(c(32,48),5,9,5),n.addMany(c(48,64),5,0,6),n.addMany(c(64,127),5,7,0),n.addMany(c(32,48),4,9,5),n.addMany(c(32,48),1,9,2),n.addMany(c(32,48),2,9,2),n.addMany(c(48,127),2,10,0),n.addMany(c(48,80),1,10,0),n.addMany(c(81,88),1,10,0),n.addMany([89,90,92],1,10,0),n.addMany(c(96,127),1,10,0),n.add(80,1,11,9),n.addMany(_,9,0,9),n.add(127,9,0,9),n.addMany(c(28,32),9,0,9),n.addMany(c(32,48),9,9,12),n.addMany(c(48,60),9,8,10),n.addMany([60,61,62,63],9,9,10),n.addMany(_,11,0,11),n.addMany(c(32,128),11,0,11),n.addMany(c(28,32),11,0,11),n.addMany(_,10,0,10),n.add(127,10,0,10),n.addMany(c(28,32),10,0,10),n.addMany(c(48,60),10,8,10),n.addMany([60,61,62,63],10,0,11),n.addMany(c(32,48),10,9,12),n.addMany(_,12,0,12),n.add(127,12,0,12),n.addMany(c(28,32),12,0,12),n.addMany(c(32,48),12,9,12),n.addMany(c(48,64),12,0,11),n.addMany(c(64,127),12,12,13),n.addMany(c(64,127),10,12,13),n.addMany(c(64,127),9,12,13),n.addMany(_,13,13,13),n.addMany(h,13,13,13),n.add(127,13,0,13),n.addMany([27,156,24,26],13,14,0),n.add(y,0,2,0),n.add(y,8,5,8),n.add(y,6,0,6),n.add(y,11,0,11),n.add(y,13,13,13),n})();class b extends u.Disposable{constructor(d=r.VT500_TRANSITION_TABLE){super(),this._transitions=d,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new f.Params,this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._printHandlerFb=(c,h,_)=>{},this._executeHandlerFb=c=>{},this._csiHandlerFb=(c,h)=>{},this._escHandlerFb=c=>{},this._errorHandlerFb=c=>c,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,u.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new a.OscParser),this._dcsParser=this.register(new p.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(d,c=[64,126]){let h=0;if(d.prefix){if(d.prefix.length>1)throw new Error("only one byte as prefix supported");if(h=d.prefix.charCodeAt(0),h&&60>h||h>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(d.intermediates){if(d.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let S=0;S<d.intermediates.length;++S){const k=d.intermediates.charCodeAt(S);if(32>k||k>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");h<<=8,h|=k}}if(d.final.length!==1)throw new Error("final must be a single byte");const _=d.final.charCodeAt(0);if(c[0]>_||_>c[1])throw new Error(`final must be in range ${c[0]} .. ${c[1]}`);return h<<=8,h|=_,h}identToString(d){const c=[];for(;d;)c.push(String.fromCharCode(255&d)),d>>=8;return c.reverse().join("")}setPrintHandler(d){this._printHandler=d}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(d,c){const h=this._identifier(d,[48,126]);this._escHandlers[h]===void 0&&(this._escHandlers[h]=[]);const _=this._escHandlers[h];return _.push(c),{dispose:()=>{const S=_.indexOf(c);S!==-1&&_.splice(S,1)}}}clearEscHandler(d){this._escHandlers[this._identifier(d,[48,126])]&&delete this._escHandlers[this._identifier(d,[48,126])]}setEscHandlerFallback(d){this._escHandlerFb=d}setExecuteHandler(d,c){this._executeHandlers[d.charCodeAt(0)]=c}clearExecuteHandler(d){this._executeHandlers[d.charCodeAt(0)]&&delete this._executeHandlers[d.charCodeAt(0)]}setExecuteHandlerFallback(d){this._executeHandlerFb=d}registerCsiHandler(d,c){const h=this._identifier(d);this._csiHandlers[h]===void 0&&(this._csiHandlers[h]=[]);const _=this._csiHandlers[h];return _.push(c),{dispose:()=>{const S=_.indexOf(c);S!==-1&&_.splice(S,1)}}}clearCsiHandler(d){this._csiHandlers[this._identifier(d)]&&delete this._csiHandlers[this._identifier(d)]}setCsiHandlerFallback(d){this._csiHandlerFb=d}registerDcsHandler(d,c){return this._dcsParser.registerHandler(this._identifier(d),c)}clearDcsHandler(d){this._dcsParser.clearHandler(this._identifier(d))}setDcsHandlerFallback(d){this._dcsParser.setHandlerFallback(d)}registerOscHandler(d,c){return this._oscParser.registerHandler(d,c)}clearOscHandler(d){this._oscParser.clearHandler(d)}setOscHandlerFallback(d){this._oscParser.setHandlerFallback(d)}setErrorHandler(d){this._errorHandler=d}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(d,c,h,_,S){this._parseStack.state=d,this._parseStack.handlers=c,this._parseStack.handlerPos=h,this._parseStack.transition=_,this._parseStack.chunkPos=S}parse(d,c,h){let _,S=0,k=0,E=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,E=this._parseStack.chunkPos+1;else{if(h===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const x=this._parseStack.handlers;let C=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(h===!1&&C>-1){for(;C>=0&&(_=x[C](this._params),_!==!0);C--)if(_ instanceof Promise)return this._parseStack.handlerPos=C,_}this._parseStack.handlers=[];break;case 4:if(h===!1&&C>-1){for(;C>=0&&(_=x[C](),_!==!0);C--)if(_ instanceof Promise)return this._parseStack.handlerPos=C,_}this._parseStack.handlers=[];break;case 6:if(S=d[this._parseStack.chunkPos],_=this._dcsParser.unhook(S!==24&&S!==26,h),_)return _;S===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(S=d[this._parseStack.chunkPos],_=this._oscParser.end(S!==24&&S!==26,h),_)return _;S===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,E=this._parseStack.chunkPos+1,this.precedingCodepoint=0,this.currentState=15&this._parseStack.transition}for(let x=E;x<c;++x){switch(S=d[x],k=this._transitions.table[this.currentState<<8|(S<160?S:y)],k>>4){case 2:for(let M=x+1;;++M){if(M>=c||(S=d[M])<32||S>126&&S<y){this._printHandler(d,x,M),x=M-1;break}if(++M>=c||(S=d[M])<32||S>126&&S<y){this._printHandler(d,x,M),x=M-1;break}if(++M>=c||(S=d[M])<32||S>126&&S<y){this._printHandler(d,x,M),x=M-1;break}if(++M>=c||(S=d[M])<32||S>126&&S<y){this._printHandler(d,x,M),x=M-1;break}}break;case 3:this._executeHandlers[S]?this._executeHandlers[S]():this._executeHandlerFb(S),this.precedingCodepoint=0;break;case 0:break;case 1:if(this._errorHandler({position:x,code:S,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const C=this._csiHandlers[this._collect<<8|S];let T=C?C.length-1:-1;for(;T>=0&&(_=C[T](this._params),_!==!0);T--)if(_ instanceof Promise)return this._preserveStack(3,C,T,k,x),_;T<0&&this._csiHandlerFb(this._collect<<8|S,this._params),this.precedingCodepoint=0;break;case 8:do switch(S){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(S-48)}while(++x<c&&(S=d[x])>47&&S<60);x--;break;case 9:this._collect<<=8,this._collect|=S;break;case 10:const L=this._escHandlers[this._collect<<8|S];let R=L?L.length-1:-1;for(;R>=0&&(_=L[R](),_!==!0);R--)if(_ instanceof Promise)return this._preserveStack(4,L,R,k,x),_;R<0&&this._escHandlerFb(this._collect<<8|S),this.precedingCodepoint=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|S,this._params);break;case 13:for(let M=x+1;;++M)if(M>=c||(S=d[M])===24||S===26||S===27||S>127&&S<y){this._dcsParser.put(d,x,M),x=M-1;break}break;case 14:if(_=this._dcsParser.unhook(S!==24&&S!==26),_)return this._preserveStack(6,[],0,k,x),_;S===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0;break;case 4:this._oscParser.start();break;case 5:for(let M=x+1;;M++)if(M>=c||(S=d[M])<32||S>127&&S<y){this._oscParser.put(d,x,M),x=M-1;break}break;case 6:if(_=this._oscParser.end(S!==24&&S!==26),_)return this._preserveStack(5,[],0,k,x),_;S===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0}this.currentState=15&k}}}r.EscapeSequenceParser=b},6242:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.OscHandler=r.OscParser=void 0;const u=o(5770),f=o(482),a=[];r.OscParser=class{constructor(){this._state=0,this._active=a,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(p,m){this._handlers[p]===void 0&&(this._handlers[p]=[]);const y=this._handlers[p];return y.push(m),{dispose:()=>{const b=y.indexOf(m);b!==-1&&y.splice(b,1)}}}clearHandler(p){this._handlers[p]&&delete this._handlers[p]}setHandlerFallback(p){this._handlerFb=p}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=a}reset(){if(this._state===2)for(let p=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;p>=0;--p)this._active[p].end(!1);this._stack.paused=!1,this._active=a,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||a,this._active.length)for(let p=this._active.length-1;p>=0;p--)this._active[p].start();else this._handlerFb(this._id,"START")}_put(p,m,y){if(this._active.length)for(let b=this._active.length-1;b>=0;b--)this._active[b].put(p,m,y);else this._handlerFb(this._id,"PUT",(0,f.utf32ToString)(p,m,y))}start(){this.reset(),this._state=1}put(p,m,y){if(this._state!==3){if(this._state===1)for(;m<y;){const b=p[m++];if(b===59){this._state=2,this._start();break}if(b<48||57<b)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+b-48}this._state===2&&y-m>0&&this._put(p,m,y)}}end(p,m=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let y=!1,b=this._active.length-1,n=!1;if(this._stack.paused&&(b=this._stack.loopPosition-1,y=m,n=this._stack.fallThrough,this._stack.paused=!1),!n&&y===!1){for(;b>=0&&(y=this._active[b].end(p),y!==!0);b--)if(y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=b,this._stack.fallThrough=!1,y;b--}for(;b>=0;b--)if(y=this._active[b].end(!1),y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=b,this._stack.fallThrough=!0,y}else this._handlerFb(this._id,"END",p);this._active=a,this._id=-1,this._state=0}}},r.OscHandler=class{constructor(p){this._handler=p,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(p,m,y){this._hitLimit||(this._data+=(0,f.utf32ToString)(p,m,y),this._data.length>u.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(p){let m=!1;if(this._hitLimit)m=!1;else if(p&&(m=this._handler(this._data),m instanceof Promise))return m.then((y=>(this._data="",this._hitLimit=!1,y)));return this._data="",this._hitLimit=!1,m}}},8742:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Params=void 0;const o=2147483647;class u{static fromArray(a){const p=new u;if(!a.length)return p;for(let m=Array.isArray(a[0])?1:0;m<a.length;++m){const y=a[m];if(Array.isArray(y))for(let b=0;b<y.length;++b)p.addSubParam(y[b]);else p.addParam(y)}return p}constructor(a=32,p=32){if(this.maxLength=a,this.maxSubParamsLength=p,p>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(a),this.length=0,this._subParams=new Int32Array(p),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(a),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const a=new u(this.maxLength,this.maxSubParamsLength);return a.params.set(this.params),a.length=this.length,a._subParams.set(this._subParams),a._subParamsLength=this._subParamsLength,a._subParamsIdx.set(this._subParamsIdx),a._rejectDigits=this._rejectDigits,a._rejectSubDigits=this._rejectSubDigits,a._digitIsSub=this._digitIsSub,a}toArray(){const a=[];for(let p=0;p<this.length;++p){a.push(this.params[p]);const m=this._subParamsIdx[p]>>8,y=255&this._subParamsIdx[p];y-m>0&&a.push(Array.prototype.slice.call(this._subParams,m,y))}return a}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(a){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(a<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=a>o?o:a}}addSubParam(a){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(a<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=a>o?o:a,this._subParamsIdx[this.length-1]++}}hasSubParams(a){return(255&this._subParamsIdx[a])-(this._subParamsIdx[a]>>8)>0}getSubParams(a){const p=this._subParamsIdx[a]>>8,m=255&this._subParamsIdx[a];return m-p>0?this._subParams.subarray(p,m):null}getSubParamsAll(){const a={};for(let p=0;p<this.length;++p){const m=this._subParamsIdx[p]>>8,y=255&this._subParamsIdx[p];y-m>0&&(a[p]=this._subParams.slice(m,y))}return a}addDigit(a){let p;if(this._rejectDigits||!(p=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const m=this._digitIsSub?this._subParams:this.params,y=m[p-1];m[p-1]=~y?Math.min(10*y+a,o):a}}r.Params=u},5741:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.AddonManager=void 0,r.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let o=this._addons.length-1;o>=0;o--)this._addons[o].instance.dispose()}loadAddon(o,u){const f={instance:u,dispose:u.dispose,isDisposed:!1};this._addons.push(f),u.dispose=()=>this._wrappedAddonDispose(f),u.activate(o)}_wrappedAddonDispose(o){if(o.isDisposed)return;let u=-1;for(let f=0;f<this._addons.length;f++)if(this._addons[f]===o){u=f;break}if(u===-1)throw new Error("Could not dispose an addon that has not been loaded");o.isDisposed=!0,o.dispose.apply(o.instance),this._addons.splice(u,1)}}},8771:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferApiView=void 0;const u=o(3785),f=o(511);r.BufferApiView=class{constructor(a,p){this._buffer=a,this.type=p}init(a){return this._buffer=a,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(a){const p=this._buffer.lines.get(a);if(p)return new u.BufferLineApiView(p)}getNullCell(){return new f.CellData}}},3785:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferLineApiView=void 0;const u=o(511);r.BufferLineApiView=class{constructor(f){this._line=f}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(f,a){if(!(f<0||f>=this._line.length))return a?(this._line.loadCell(f,a),a):this._line.loadCell(f,new u.CellData)}translateToString(f,a,p){return this._line.translateToString(f,a,p)}}},8285:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.BufferNamespaceApi=void 0;const u=o(8771),f=o(8460),a=o(844);class p extends a.Disposable{constructor(y){super(),this._core=y,this._onBufferChange=this.register(new f.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new u.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new u.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate((()=>this._onBufferChange.fire(this.active)))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}r.BufferNamespaceApi=p},7975:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ParserApi=void 0,r.ParserApi=class{constructor(o){this._core=o}registerCsiHandler(o,u){return this._core.registerCsiHandler(o,(f=>u(f.toArray())))}addCsiHandler(o,u){return this.registerCsiHandler(o,u)}registerDcsHandler(o,u){return this._core.registerDcsHandler(o,((f,a)=>u(f,a.toArray())))}addDcsHandler(o,u){return this.registerDcsHandler(o,u)}registerEscHandler(o,u){return this._core.registerEscHandler(o,u)}addEscHandler(o,u){return this.registerEscHandler(o,u)}registerOscHandler(o,u){return this._core.registerOscHandler(o,u)}addOscHandler(o,u){return this.registerOscHandler(o,u)}}},7090:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.UnicodeApi=void 0,r.UnicodeApi=class{constructor(o){this._core=o}register(o){this._core.unicodeService.register(o)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(o){this._core.unicodeService.activeVersion=o}}},744:function(w,r,o){var u=this&&this.__decorate||function(n,d,c,h){var _,S=arguments.length,k=S<3?d:h===null?h=Object.getOwnPropertyDescriptor(d,c):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(n,d,c,h);else for(var E=n.length-1;E>=0;E--)(_=n[E])&&(k=(S<3?_(k):S>3?_(d,c,k):_(d,c))||k);return S>3&&k&&Object.defineProperty(d,c,k),k},f=this&&this.__param||function(n,d){return function(c,h){d(c,h,n)}};Object.defineProperty(r,"__esModule",{value:!0}),r.BufferService=r.MINIMUM_ROWS=r.MINIMUM_COLS=void 0;const a=o(8460),p=o(844),m=o(5295),y=o(2585);r.MINIMUM_COLS=2,r.MINIMUM_ROWS=1;let b=r.BufferService=class extends p.Disposable{get buffer(){return this.buffers.active}constructor(n){super(),this.isUserScrolling=!1,this._onResize=this.register(new a.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new a.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(n.rawOptions.cols||0,r.MINIMUM_COLS),this.rows=Math.max(n.rawOptions.rows||0,r.MINIMUM_ROWS),this.buffers=this.register(new m.BufferSet(n,this))}resize(n,d){this.cols=n,this.rows=d,this.buffers.resize(n,d),this._onResize.fire({cols:n,rows:d})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(n,d=!1){const c=this.buffer;let h;h=this._cachedBlankLine,h&&h.length===this.cols&&h.getFg(0)===n.fg&&h.getBg(0)===n.bg||(h=c.getBlankLine(n,d),this._cachedBlankLine=h),h.isWrapped=d;const _=c.ybase+c.scrollTop,S=c.ybase+c.scrollBottom;if(c.scrollTop===0){const k=c.lines.isFull;S===c.lines.length-1?k?c.lines.recycle().copyFrom(h):c.lines.push(h.clone()):c.lines.splice(S+1,0,h.clone()),k?this.isUserScrolling&&(c.ydisp=Math.max(c.ydisp-1,0)):(c.ybase++,this.isUserScrolling||c.ydisp++)}else{const k=S-_+1;c.lines.shiftElements(_+1,k-1,-1),c.lines.set(S,h.clone())}this.isUserScrolling||(c.ydisp=c.ybase),this._onScroll.fire(c.ydisp)}scrollLines(n,d,c){const h=this.buffer;if(n<0){if(h.ydisp===0)return;this.isUserScrolling=!0}else n+h.ydisp>=h.ybase&&(this.isUserScrolling=!1);const _=h.ydisp;h.ydisp=Math.max(Math.min(h.ydisp+n,h.ybase),0),_!==h.ydisp&&(d||this._onScroll.fire(h.ydisp))}};r.BufferService=b=u([f(0,y.IOptionsService)],b)},7994:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.CharsetService=void 0,r.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(o){this.glevel=o,this.charset=this._charsets[o]}setgCharset(o,u){this._charsets[o]=u,this.glevel===o&&(this.charset=u)}}},1753:function(w,r,o){var u=this&&this.__decorate||function(h,_,S,k){var E,x=arguments.length,C=x<3?_:k===null?k=Object.getOwnPropertyDescriptor(_,S):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(h,_,S,k);else for(var T=h.length-1;T>=0;T--)(E=h[T])&&(C=(x<3?E(C):x>3?E(_,S,C):E(_,S))||C);return x>3&&C&&Object.defineProperty(_,S,C),C},f=this&&this.__param||function(h,_){return function(S,k){_(S,k,h)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CoreMouseService=void 0;const a=o(2585),p=o(8460),m=o(844),y={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:h=>h.button!==4&&h.action===1&&(h.ctrl=!1,h.alt=!1,h.shift=!1,!0)},VT200:{events:19,restrict:h=>h.action!==32},DRAG:{events:23,restrict:h=>h.action!==32||h.button!==3},ANY:{events:31,restrict:h=>!0}};function b(h,_){let S=(h.ctrl?16:0)|(h.shift?4:0)|(h.alt?8:0);return h.button===4?(S|=64,S|=h.action):(S|=3&h.button,4&h.button&&(S|=64),8&h.button&&(S|=128),h.action===32?S|=32:h.action!==0||_||(S|=3)),S}const n=String.fromCharCode,d={DEFAULT:h=>{const _=[b(h,!1)+32,h.col+32,h.row+32];return _[0]>255||_[1]>255||_[2]>255?"":`\x1B[M${n(_[0])}${n(_[1])}${n(_[2])}`},SGR:h=>{const _=h.action===0&&h.button!==4?"m":"M";return`\x1B[<${b(h,!0)};${h.col};${h.row}${_}`},SGR_PIXELS:h=>{const _=h.action===0&&h.button!==4?"m":"M";return`\x1B[<${b(h,!0)};${h.x};${h.y}${_}`}};let c=r.CoreMouseService=class extends m.Disposable{constructor(h,_){super(),this._bufferService=h,this._coreService=_,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new p.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const S of Object.keys(y))this.addProtocol(S,y[S]);for(const S of Object.keys(d))this.addEncoding(S,d[S]);this.reset()}addProtocol(h,_){this._protocols[h]=_}addEncoding(h,_){this._encodings[h]=_}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(h){if(!this._protocols[h])throw new Error(`unknown protocol "${h}"`);this._activeProtocol=h,this._onProtocolChange.fire(this._protocols[h].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(h){if(!this._encodings[h])throw new Error(`unknown encoding "${h}"`);this._activeEncoding=h}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(h){if(h.col<0||h.col>=this._bufferService.cols||h.row<0||h.row>=this._bufferService.rows||h.button===4&&h.action===32||h.button===3&&h.action!==32||h.button!==4&&(h.action===2||h.action===3)||(h.col++,h.row++,h.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,h,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(h))return!1;const _=this._encodings[this._activeEncoding](h);return _&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(_):this._coreService.triggerDataEvent(_,!0)),this._lastEvent=h,!0}explainEvents(h){return{down:!!(1&h),up:!!(2&h),drag:!!(4&h),move:!!(8&h),wheel:!!(16&h)}}_equalEvents(h,_,S){if(S){if(h.x!==_.x||h.y!==_.y)return!1}else if(h.col!==_.col||h.row!==_.row)return!1;return h.button===_.button&&h.action===_.action&&h.ctrl===_.ctrl&&h.alt===_.alt&&h.shift===_.shift}};r.CoreMouseService=c=u([f(0,a.IBufferService),f(1,a.ICoreService)],c)},6975:function(w,r,o){var u=this&&this.__decorate||function(c,h,_,S){var k,E=arguments.length,x=E<3?h:S===null?S=Object.getOwnPropertyDescriptor(h,_):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")x=Reflect.decorate(c,h,_,S);else for(var C=c.length-1;C>=0;C--)(k=c[C])&&(x=(E<3?k(x):E>3?k(h,_,x):k(h,_))||x);return E>3&&x&&Object.defineProperty(h,_,x),x},f=this&&this.__param||function(c,h){return function(_,S){h(_,S,c)}};Object.defineProperty(r,"__esModule",{value:!0}),r.CoreService=void 0;const a=o(1439),p=o(8460),m=o(844),y=o(2585),b=Object.freeze({insertMode:!1}),n=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let d=r.CoreService=class extends m.Disposable{constructor(c,h,_){super(),this._bufferService=c,this._logService=h,this._optionsService=_,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new p.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new p.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new p.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new p.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,a.clone)(b),this.decPrivateModes=(0,a.clone)(n)}reset(){this.modes=(0,a.clone)(b),this.decPrivateModes=(0,a.clone)(n)}triggerDataEvent(c,h=!1){if(this._optionsService.rawOptions.disableStdin)return;const _=this._bufferService.buffer;h&&this._optionsService.rawOptions.scrollOnUserInput&&_.ybase!==_.ydisp&&this._onRequestScrollToBottom.fire(),h&&this._onUserInput.fire(),this._logService.debug(`sending data "${c}"`,(()=>c.split("").map((S=>S.charCodeAt(0))))),this._onData.fire(c)}triggerBinaryEvent(c){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${c}"`,(()=>c.split("").map((h=>h.charCodeAt(0))))),this._onBinary.fire(c))}};r.CoreService=d=u([f(0,y.IBufferService),f(1,y.ILogService),f(2,y.IOptionsService)],d)},9074:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.DecorationService=void 0;const u=o(8055),f=o(8460),a=o(844),p=o(6106);let m=0,y=0;class b extends a.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new p.SortedList((c=>c?.marker.line)),this._onDecorationRegistered=this.register(new f.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new f.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,a.toDisposable)((()=>this.reset())))}registerDecoration(c){if(c.marker.isDisposed)return;const h=new n(c);if(h){const _=h.marker.onDispose((()=>h.dispose()));h.onDispose((()=>{h&&(this._decorations.delete(h)&&this._onDecorationRemoved.fire(h),_.dispose())})),this._decorations.insert(h),this._onDecorationRegistered.fire(h)}return h}reset(){for(const c of this._decorations.values())c.dispose();this._decorations.clear()}*getDecorationsAtCell(c,h,_){var S,k,E;let x=0,C=0;for(const T of this._decorations.getKeyIterator(h))x=(S=T.options.x)!==null&&S!==void 0?S:0,C=x+((k=T.options.width)!==null&&k!==void 0?k:1),c>=x&&c<C&&(!_||((E=T.options.layer)!==null&&E!==void 0?E:"bottom")===_)&&(yield T)}forEachDecorationAtCell(c,h,_,S){this._decorations.forEachByKey(h,(k=>{var E,x,C;m=(E=k.options.x)!==null&&E!==void 0?E:0,y=m+((x=k.options.width)!==null&&x!==void 0?x:1),c>=m&&c<y&&(!_||((C=k.options.layer)!==null&&C!==void 0?C:"bottom")===_)&&S(k)}))}}r.DecorationService=b;class n extends a.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=u.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=u.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(c){super(),this.options=c,this.onRenderEmitter=this.register(new f.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new f.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=c.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.InstantiationService=r.ServiceCollection=void 0;const u=o(2585),f=o(8343);class a{constructor(...m){this._entries=new Map;for(const[y,b]of m)this.set(y,b)}set(m,y){const b=this._entries.get(m);return this._entries.set(m,y),b}forEach(m){for(const[y,b]of this._entries.entries())m(y,b)}has(m){return this._entries.has(m)}get(m){return this._entries.get(m)}}r.ServiceCollection=a,r.InstantiationService=class{constructor(){this._services=new a,this._services.set(u.IInstantiationService,this)}setService(p,m){this._services.set(p,m)}getService(p){return this._services.get(p)}createInstance(p,...m){const y=(0,f.getServiceDependencies)(p).sort(((d,c)=>d.index-c.index)),b=[];for(const d of y){const c=this._services.get(d.id);if(!c)throw new Error(`[createInstance] ${p.name} depends on UNKNOWN service ${d.id}.`);b.push(c)}const n=y.length>0?y[0].index:m.length;if(m.length!==n)throw new Error(`[createInstance] First service dependency of ${p.name} at position ${n+1} conflicts with ${m.length} static arguments`);return new p(...m,...b)}}},7866:function(w,r,o){var u=this&&this.__decorate||function(n,d,c,h){var _,S=arguments.length,k=S<3?d:h===null?h=Object.getOwnPropertyDescriptor(d,c):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(n,d,c,h);else for(var E=n.length-1;E>=0;E--)(_=n[E])&&(k=(S<3?_(k):S>3?_(d,c,k):_(d,c))||k);return S>3&&k&&Object.defineProperty(d,c,k),k},f=this&&this.__param||function(n,d){return function(c,h){d(c,h,n)}};Object.defineProperty(r,"__esModule",{value:!0}),r.traceCall=r.setTraceLogger=r.LogService=void 0;const a=o(844),p=o(2585),m={trace:p.LogLevelEnum.TRACE,debug:p.LogLevelEnum.DEBUG,info:p.LogLevelEnum.INFO,warn:p.LogLevelEnum.WARN,error:p.LogLevelEnum.ERROR,off:p.LogLevelEnum.OFF};let y,b=r.LogService=class extends a.Disposable{get logLevel(){return this._logLevel}constructor(n){super(),this._optionsService=n,this._logLevel=p.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),y=this}_updateLogLevel(){this._logLevel=m[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(n){for(let d=0;d<n.length;d++)typeof n[d]=="function"&&(n[d]=n[d]())}_log(n,d,c){this._evalLazyOptionalParams(c),n.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+d,...c)}trace(n,...d){var c,h;this._logLevel<=p.LogLevelEnum.TRACE&&this._log((h=(c=this._optionsService.options.logger)===null||c===void 0?void 0:c.trace.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.log,n,d)}debug(n,...d){var c,h;this._logLevel<=p.LogLevelEnum.DEBUG&&this._log((h=(c=this._optionsService.options.logger)===null||c===void 0?void 0:c.debug.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.log,n,d)}info(n,...d){var c,h;this._logLevel<=p.LogLevelEnum.INFO&&this._log((h=(c=this._optionsService.options.logger)===null||c===void 0?void 0:c.info.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.info,n,d)}warn(n,...d){var c,h;this._logLevel<=p.LogLevelEnum.WARN&&this._log((h=(c=this._optionsService.options.logger)===null||c===void 0?void 0:c.warn.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.warn,n,d)}error(n,...d){var c,h;this._logLevel<=p.LogLevelEnum.ERROR&&this._log((h=(c=this._optionsService.options.logger)===null||c===void 0?void 0:c.error.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.error,n,d)}};r.LogService=b=u([f(0,p.IOptionsService)],b),r.setTraceLogger=function(n){y=n},r.traceCall=function(n,d,c){if(typeof c.value!="function")throw new Error("not supported");const h=c.value;c.value=function(..._){if(y.logLevel!==p.LogLevelEnum.TRACE)return h.apply(this,_);y.trace(`GlyphRenderer#${h.name}(${_.map((k=>JSON.stringify(k))).join(", ")})`);const S=h.apply(this,_);return y.trace(`GlyphRenderer#${h.name} return`,S),S}}},7302:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.OptionsService=r.DEFAULT_OPTIONS=void 0;const u=o(8460),f=o(844),a=o(6114);r.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rightClickSelectsWord:a.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const p=["normal","bold","100","200","300","400","500","600","700","800","900"];class m extends f.Disposable{constructor(b){super(),this._onOptionChange=this.register(new u.EventEmitter),this.onOptionChange=this._onOptionChange.event;const n=Object.assign({},r.DEFAULT_OPTIONS);for(const d in b)if(d in n)try{const c=b[d];n[d]=this._sanitizeAndValidateOption(d,c)}catch(c){console.error(c)}this.rawOptions=n,this.options=Object.assign({},n),this._setupOptions()}onSpecificOptionChange(b,n){return this.onOptionChange((d=>{d===b&&n(this.rawOptions[b])}))}onMultipleOptionChange(b,n){return this.onOptionChange((d=>{b.indexOf(d)!==-1&&n()}))}_setupOptions(){const b=d=>{if(!(d in r.DEFAULT_OPTIONS))throw new Error(`No option with key "${d}"`);return this.rawOptions[d]},n=(d,c)=>{if(!(d in r.DEFAULT_OPTIONS))throw new Error(`No option with key "${d}"`);c=this._sanitizeAndValidateOption(d,c),this.rawOptions[d]!==c&&(this.rawOptions[d]=c,this._onOptionChange.fire(d))};for(const d in this.rawOptions){const c={get:b.bind(this,d),set:n.bind(this,d)};Object.defineProperty(this.options,d,c)}}_sanitizeAndValidateOption(b,n){switch(b){case"cursorStyle":if(n||(n=r.DEFAULT_OPTIONS[b]),!(function(d){return d==="block"||d==="underline"||d==="bar"})(n))throw new Error(`"${n}" is not a valid value for ${b}`);break;case"wordSeparator":n||(n=r.DEFAULT_OPTIONS[b]);break;case"fontWeight":case"fontWeightBold":if(typeof n=="number"&&1<=n&&n<=1e3)break;n=p.includes(n)?n:r.DEFAULT_OPTIONS[b];break;case"cursorWidth":n=Math.floor(n);case"lineHeight":case"tabStopWidth":if(n<1)throw new Error(`${b} cannot be less than 1, value: ${n}`);break;case"minimumContrastRatio":n=Math.max(1,Math.min(21,Math.round(10*n)/10));break;case"scrollback":if((n=Math.min(n,4294967295))<0)throw new Error(`${b} cannot be less than 0, value: ${n}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(n<=0)throw new Error(`${b} cannot be less than or equal to 0, value: ${n}`);break;case"rows":case"cols":if(!n&&n!==0)throw new Error(`${b} must be numeric, value: ${n}`);break;case"windowsPty":n=n??{}}return n}}r.OptionsService=m},2660:function(w,r,o){var u=this&&this.__decorate||function(m,y,b,n){var d,c=arguments.length,h=c<3?y:n===null?n=Object.getOwnPropertyDescriptor(y,b):n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")h=Reflect.decorate(m,y,b,n);else for(var _=m.length-1;_>=0;_--)(d=m[_])&&(h=(c<3?d(h):c>3?d(y,b,h):d(y,b))||h);return c>3&&h&&Object.defineProperty(y,b,h),h},f=this&&this.__param||function(m,y){return function(b,n){y(b,n,m)}};Object.defineProperty(r,"__esModule",{value:!0}),r.OscLinkService=void 0;const a=o(2585);let p=r.OscLinkService=class{constructor(m){this._bufferService=m,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(m){const y=this._bufferService.buffer;if(m.id===void 0){const _=y.addMarker(y.ybase+y.y),S={data:m,id:this._nextId++,lines:[_]};return _.onDispose((()=>this._removeMarkerFromLink(S,_))),this._dataByLinkId.set(S.id,S),S.id}const b=m,n=this._getEntryIdKey(b),d=this._entriesWithId.get(n);if(d)return this.addLineToLink(d.id,y.ybase+y.y),d.id;const c=y.addMarker(y.ybase+y.y),h={id:this._nextId++,key:this._getEntryIdKey(b),data:b,lines:[c]};return c.onDispose((()=>this._removeMarkerFromLink(h,c))),this._entriesWithId.set(h.key,h),this._dataByLinkId.set(h.id,h),h.id}addLineToLink(m,y){const b=this._dataByLinkId.get(m);if(b&&b.lines.every((n=>n.line!==y))){const n=this._bufferService.buffer.addMarker(y);b.lines.push(n),n.onDispose((()=>this._removeMarkerFromLink(b,n)))}}getLinkData(m){var y;return(y=this._dataByLinkId.get(m))===null||y===void 0?void 0:y.data}_getEntryIdKey(m){return`${m.id};;${m.uri}`}_removeMarkerFromLink(m,y){const b=m.lines.indexOf(y);b!==-1&&(m.lines.splice(b,1),m.lines.length===0&&(m.data.id!==void 0&&this._entriesWithId.delete(m.key),this._dataByLinkId.delete(m.id)))}};r.OscLinkService=p=u([f(0,a.IBufferService)],p)},8343:(w,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.createDecorator=r.getServiceDependencies=r.serviceRegistry=void 0;const o="di$target",u="di$dependencies";r.serviceRegistry=new Map,r.getServiceDependencies=function(f){return f[u]||[]},r.createDecorator=function(f){if(r.serviceRegistry.has(f))return r.serviceRegistry.get(f);const a=function(p,m,y){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(b,n,d){n[o]===n?n[u].push({id:b,index:d}):(n[u]=[{id:b,index:d}],n[o]=n)})(a,p,y)};return a.toString=()=>f,r.serviceRegistry.set(f,a),a}},2585:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.IDecorationService=r.IUnicodeService=r.IOscLinkService=r.IOptionsService=r.ILogService=r.LogLevelEnum=r.IInstantiationService=r.ICharsetService=r.ICoreService=r.ICoreMouseService=r.IBufferService=void 0;const u=o(8343);var f;r.IBufferService=(0,u.createDecorator)("BufferService"),r.ICoreMouseService=(0,u.createDecorator)("CoreMouseService"),r.ICoreService=(0,u.createDecorator)("CoreService"),r.ICharsetService=(0,u.createDecorator)("CharsetService"),r.IInstantiationService=(0,u.createDecorator)("InstantiationService"),(function(a){a[a.TRACE=0]="TRACE",a[a.DEBUG=1]="DEBUG",a[a.INFO=2]="INFO",a[a.WARN=3]="WARN",a[a.ERROR=4]="ERROR",a[a.OFF=5]="OFF"})(f||(r.LogLevelEnum=f={})),r.ILogService=(0,u.createDecorator)("LogService"),r.IOptionsService=(0,u.createDecorator)("OptionsService"),r.IOscLinkService=(0,u.createDecorator)("OscLinkService"),r.IUnicodeService=(0,u.createDecorator)("UnicodeService"),r.IDecorationService=(0,u.createDecorator)("DecorationService")},1480:(w,r,o)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.UnicodeService=void 0;const u=o(8460),f=o(225);r.UnicodeService=class{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new u.EventEmitter,this.onChange=this._onChange.event;const a=new f.UnicodeV6;this.register(a),this._active=a.version,this._activeProvider=a}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(a){if(!this._providers[a])throw new Error(`unknown Unicode version "${a}"`);this._active=a,this._activeProvider=this._providers[a],this._onChange.fire(a)}register(a){this._providers[a.version]=a}wcwidth(a){return this._activeProvider.wcwidth(a)}getStringCellWidth(a){let p=0;const m=a.length;for(let y=0;y<m;++y){let b=a.charCodeAt(y);if(55296<=b&&b<=56319){if(++y>=m)return p+this.wcwidth(b);const n=a.charCodeAt(y);56320<=n&&n<=57343?b=1024*(b-55296)+n-56320+65536:p+=this.wcwidth(n)}p+=this.wcwidth(b)}return p}}}},l={};function g(w){var r=l[w];if(r!==void 0)return r.exports;var o=l[w]={exports:{}};return s[w].call(o.exports,o,o.exports,g),o.exports}var v={};return(()=>{var w=v;Object.defineProperty(w,"__esModule",{value:!0}),w.Terminal=void 0;const r=g(9042),o=g(3236),u=g(844),f=g(5741),a=g(8285),p=g(7975),m=g(7090),y=["cols","rows"];class b extends u.Disposable{constructor(d){super(),this._core=this.register(new o.Terminal(d)),this._addonManager=this.register(new f.AddonManager),this._publicOptions=Object.assign({},this._core.options);const c=_=>this._core.options[_],h=(_,S)=>{this._checkReadonlyOptions(_),this._core.options[_]=S};for(const _ in this._core.options){const S={get:c.bind(this,_),set:h.bind(this,_)};Object.defineProperty(this._publicOptions,_,S)}}_checkReadonlyOptions(d){if(y.includes(d))throw new Error(`Option "${d}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new p.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new m.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this.register(new a.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const d=this._core.coreService.decPrivateModes;let c="none";switch(this._core.coreMouseService.activeProtocol){case"X10":c="x10";break;case"VT200":c="vt200";break;case"DRAG":c="drag";break;case"ANY":c="any"}return{applicationCursorKeysMode:d.applicationCursorKeys,applicationKeypadMode:d.applicationKeypad,bracketedPasteMode:d.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:c,originMode:d.origin,reverseWraparoundMode:d.reverseWraparound,sendFocusMode:d.sendFocus,wraparoundMode:d.wraparound}}get options(){return this._publicOptions}set options(d){for(const c in d)this._publicOptions[c]=d[c]}blur(){this._core.blur()}focus(){this._core.focus()}resize(d,c){this._verifyIntegers(d,c),this._core.resize(d,c)}open(d){this._core.open(d)}attachCustomKeyEventHandler(d){this._core.attachCustomKeyEventHandler(d)}registerLinkProvider(d){return this._core.registerLinkProvider(d)}registerCharacterJoiner(d){return this._checkProposedApi(),this._core.registerCharacterJoiner(d)}deregisterCharacterJoiner(d){this._checkProposedApi(),this._core.deregisterCharacterJoiner(d)}registerMarker(d=0){return this._verifyIntegers(d),this._core.registerMarker(d)}registerDecoration(d){var c,h,_;return this._checkProposedApi(),this._verifyPositiveIntegers((c=d.x)!==null&&c!==void 0?c:0,(h=d.width)!==null&&h!==void 0?h:0,(_=d.height)!==null&&_!==void 0?_:0),this._core.registerDecoration(d)}hasSelection(){return this._core.hasSelection()}select(d,c,h){this._verifyIntegers(d,c,h),this._core.select(d,c,h)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(d,c){this._verifyIntegers(d,c),this._core.selectLines(d,c)}dispose(){super.dispose()}scrollLines(d){this._verifyIntegers(d),this._core.scrollLines(d)}scrollPages(d){this._verifyIntegers(d),this._core.scrollPages(d)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(d){this._verifyIntegers(d),this._core.scrollToLine(d)}clear(){this._core.clear()}write(d,c){this._core.write(d,c)}writeln(d,c){this._core.write(d),this._core.write(`\r
16
+ `,c)}paste(d){this._core.paste(d)}refresh(d,c){this._verifyIntegers(d,c),this._core.refresh(d,c)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(d){this._addonManager.loadAddon(this,d)}static get strings(){return r}_verifyIntegers(...d){for(const c of d)if(c===1/0||isNaN(c)||c%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...d){for(const c of d)if(c&&(c===1/0||isNaN(c)||c%1!=0||c<0))throw new Error("This API only accepts positive integers")}}w.Terminal=b})(),v})()))})(us)),us.exports}var Gl=Vl();var Ql=2,Zl=1,Jl=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let i=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(i._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let i=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,s=window.getComputedStyle(this._terminal.element.parentElement),l=parseInt(s.getPropertyValue("height")),g=Math.max(0,parseInt(s.getPropertyValue("width"))),v=window.getComputedStyle(this._terminal.element),w={top:parseInt(v.getPropertyValue("padding-top")),bottom:parseInt(v.getPropertyValue("padding-bottom")),right:parseInt(v.getPropertyValue("padding-right")),left:parseInt(v.getPropertyValue("padding-left"))},r=w.top+w.bottom,o=w.right+w.left,u=l-r,f=g-o-i;return{cols:Math.max(Ql,Math.floor(f/e.css.cell.width)),rows:Math.max(Zl,Math.floor(u/e.css.cell.height))}}};function ec(e={}){const{cwd:i,cols:s,rows:l,onOutput:g,onExit:v}=e,[w,r]=A.useState(null),[o,u]=A.useState(()=>be.isConnected()),[f,a]=A.useState(!1),[p,m]=A.useState(!1),[y,b]=A.useState(!1),n=A.useRef({onOutput:g,onExit:v});n.current={onOutput:g,onExit:v};const d=A.useRef(null);d.current=w,A.useEffect(()=>{if(!w)return;const k=be.getSocket(),E=()=>{u(!0),a(!1),r(null),b(!0)},x=()=>{u(!1),a(!1)},C=M=>{M.terminalId===w&&n.current.onOutput?.(M.data)},T=M=>{M.terminalId===w&&(a(!1),n.current.onExit?.(M.exitCode),r(null))},L=M=>{M.terminalId===w&&a(!0)},R=M=>{M.terminalId===w&&a(!1)};return k.on("connect",E),k.on("disconnect",x),k.on(Le.TERMINAL_STDOUT,C),k.on(Le.TERMINAL_EXIT,T),k.on(Le.TERMINAL_SUBSCRIBED,L),k.on(Le.TERMINAL_UNSUBSCRIBED,R),u(k.connected),k.connected&&k.emit(mt.SUBSCRIBE,{topic:"terminal",id:w},M=>{M.success&&a(!0)}),()=>{k.off("connect",E),k.off("disconnect",x),k.off(Le.TERMINAL_STDOUT,C),k.off(Le.TERMINAL_EXIT,T),k.off(Le.TERMINAL_SUBSCRIBED,L),k.off(Le.TERMINAL_UNSUBSCRIBED,R),k.emit(mt.UNSUBSCRIBE,{topic:"terminal",id:w})}},[w]);const c=A.useCallback(async()=>{const k=be.getSocket();if(!k.connected)return null;m(!0);try{const E=await oe.post("/terminals",{socketId:k.id,cwd:i,cols:s,rows:l});return r(E.terminalId),b(!1),E.terminalId}catch(E){return console.error("[useStandaloneTerminal] Failed to create terminal:",E),null}finally{m(!1)}},[i,s,l]),h=A.useCallback(async()=>{const k=d.current;if(k){try{await oe.delete(`/terminals/${k}`)}catch(E){console.error("[useStandaloneTerminal] Failed to destroy terminal:",E)}r(null),a(!1)}},[]),_=A.useCallback(k=>{const E=d.current;if(!E)return;be.getSocket().emit(mt.TERMINAL_INPUT,{terminalId:E,data:k})},[]),S=A.useCallback((k,E)=>{const x=d.current;if(!x)return;be.getSocket().emit(mt.TERMINAL_RESIZE,{terminalId:x,cols:k,rows:E})},[]);return A.useEffect(()=>()=>{const k=d.current;k&&oe.delete(`/terminals/${k}`).catch(()=>{})},[]),{terminalId:w,isConnected:o,isAttached:f,isCreating:p,needsRecreate:y,create:c,destroy:h,sendInput:_,resize:S}}function tc({terminalRef:e,xtermRef:i,fitAddonRef:s,isVisible:l=!0,onResize:g}){const v=A.useRef(null),w=A.useRef(null),r=A.useRef(0),o=A.useCallback(()=>{v.current!=null&&(window.clearTimeout(v.current),v.current=null),w.current!=null&&(window.cancelAnimationFrame(w.current),w.current=null)},[]),u=A.useCallback(()=>{const p=s.current,m=i.current,y=e.current;if(!p||!m||!y||y.clientWidth<=0||y.clientHeight<=0)return!1;try{return p.fit(),m.cols>0&&m.rows>0&&g(m.cols,m.rows),!0}catch{return!1}},[s,g,e,i]),f=A.useCallback((p=6)=>{o();const m=r.current+1;r.current=m;let y=0;const b=()=>{r.current===m&&(w.current=window.requestAnimationFrame(()=>{if(w.current=null,r.current!==m)return;const n=u(),d=y<2;y<p&&(!n||d)&&(y+=1,v.current=window.setTimeout(b,50))}))};b()},[o,u]),a=A.useCallback(()=>{r.current+=1,o()},[o]);return A.useEffect(()=>a,[a]),A.useEffect(()=>{l&&f(8)},[l,f]),A.useEffect(()=>{const p=e.current;if(!p)return;if(typeof ResizeObserver>"u"){f(8);return}const m=new ResizeObserver(()=>{f(4)});return m.observe(p),p.parentElement&&m.observe(p.parentElement),f(8),()=>{m.disconnect()}},[f,e]),{fitNow:u,scheduleFit:f}}const sc=_e.memo(function({cwd:i,isVisible:s=!0,onExit:l,onReady:g}){const v=A.useRef(null),w=A.useRef(null),r=A.useRef(null),o=A.useRef(!1),{terminalId:u,isAttached:f,needsRecreate:a,create:p,sendInput:m,resize:y}=ec({cwd:i,onOutput:A.useCallback(d=>{w.current?.write(d)},[]),onExit:A.useCallback(d=>{w.current?.writeln(`\r
17
+ \x1B[90m[Process exited with code ${d}]\x1B[0m`),l?.(d)},[l])}),{scheduleFit:b}=tc({terminalRef:v,xtermRef:w,fitAddonRef:r,isVisible:s,onResize:y}),n=A.useCallback(d=>{w.current?.paste(d)},[]);return A.useEffect(()=>{s||w.current?.blur()},[s]),A.useEffect(()=>{if(!a)return;const d=w.current;d&&d.writeln(`\r
18
+ \x1B[33m[Terminal disconnected — reconnecting...]\x1B[0m`),p()},[a,p]),A.useLayoutEffect(()=>{if(!v.current)return;const d=new Gl.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, 'Courier New', monospace",lineHeight:1.4,theme:Ao(),scrollback:5e3,convertEol:!0}),c=new Jl;return d.loadAddon(c),d.open(v.current),w.current=d,r.current=c,b(8),()=>{d.dispose(),w.current=null,r.current=null}},[b]),A.useEffect(()=>{o.current||(o.current=!0,p())},[p]),A.useEffect(()=>{const d=w.current;if(!d||!f)return;const c=d.onData(h=>{m(h)});return()=>c.dispose()},[m,f]),A.useEffect(()=>{f&&(b(4),g?.({sendInput:m,paste:n}))},[f,g,n,b,m]),t.jsxs("div",{className:"relative flex h-full w-full min-h-0 min-w-0 flex-col overflow-hidden bg-terminal",children:[!u&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-terminal-muted-foreground text-xs z-10 bg-terminal",children:"Starting terminal..."}),t.jsx("div",{ref:v,className:"terminal-xterm-host flex-1 min-h-0 min-w-0 w-full overflow-hidden"})]})}),rc=_e.memo(function({commands:i,onSelect:s}){const{t:l}=re();return i.length===0?null:t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-px h-4 bg-terminal-border mx-1 shrink-0"}),t.jsxs(_i,{children:[t.jsxs(bi,{className:"group mx-1 flex shrink-0 items-center gap-1.5 rounded px-2.5 py-1 text-xs font-medium text-terminal-muted-foreground transition-colors hover:bg-terminal-accent hover:text-terminal-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-terminal-muted-foreground data-[state=open]:bg-terminal-accent data-[state=open]:text-terminal-foreground",children:[t.jsx(Io,{size:12}),t.jsx("span",{children:l("快捷命令")}),t.jsx(Ke,{size:10,className:"transition-transform group-data-[state=open]:rotate-180"})]}),t.jsx(xi,{align:"end",className:"w-72",children:t.jsx("div",{className:"max-h-[240px] overflow-y-auto",children:i.map((g,v)=>t.jsxs(Po,{icon:t.jsx(Ro,{className:"mt-0.5"}),onSelect:()=>s(g.command),className:"items-start",children:[t.jsx("span",{className:"block truncate font-medium text-foreground",children:g.name}),t.jsx("span",{className:"block truncate font-mono text-xs text-muted-foreground",children:g.command})]},v))})})]})]})}),Fi="\x1B",ic="\x07",nc="œ";function oc(e){const i=e.charCodeAt(0);return i>=64&&i<=126}function br(e,i){let s=i;for(;s<e.length;){if(e[s]===ic||e[s]===nc)return s+1;if(e[s]===Fi&&e[s+1]==="\\")return s+2;s+=1}return s}function xr(e,i){let s=i;for(;s<e.length&&!oc(e[s]);)s+=1;return s<e.length?s+1:s}function ac(e){let i="";for(let s=0;s<e.length;){if(e[s]==="›"){s=xr(e,s+1);continue}if(e[s]===""){s=br(e,s+1);continue}if(e[s]!==Fi){i+=e[s],s+=1;continue}const l=e[s+1];if(l==="["){s=xr(e,s+2);continue}if(l==="]"||l==="P"||l==="X"||l==="^"||l==="_"){s=br(e,s+2);continue}for(s+=1;s<e.length;){const g=e.charCodeAt(s);if(g<32||g>47)break;s+=1}s<e.length&&(s+=1)}return i}const lc=200,cc=1e3,dc=512*1024;function hc(e){let i=e.reduce((l,g)=>l+g.data.length,0),s=0;for(;e.length-s>cc||i>dc&&e.length-s>1;)i-=e[s].data.length,s+=1;return{entries:s>0?e.slice(s):e,trimmed:s>0}}function uc(e,i){const s=!!e&&e.runtimeInstanceId!==i.runtimeInstanceId,l=s||i.reset,g=l?[]:e?.entries??[],v=new Set(g.map(o=>o.seq)),w=[...g,...i.entries.filter(o=>!v.has(o.seq))].sort((o,u)=>o.seq-u.seq),r=hc(w);return{...i,entries:r.entries,reset:i.reset||s||!l&&(e?.reset??!1),truncated:i.truncated||!l&&(e?.truncated??!1)||r.trimmed}}function Gs(e,i=!0){return Ee({queryKey:ie.workspaceServices.list(e),queryFn:async()=>(await oe.get(`/workspaces/${encodeURIComponent(e)}/services`)).services,enabled:i&&!!e,refetchInterval:i&&e?3e3:!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:"always",refetchOnReconnect:"always"})}function fc(e,i,s,l=!0){const g=De(),v=ie.workspaceServices.logs(e,i);return Ee({queryKey:v,queryFn:async()=>{const w=g.getQueryData(v),r=w?Math.max(0,w.nextSeq-1):0,o=w===void 0?s:w.runtimeInstanceId,u=new URLSearchParams({limit:String(lc)});o!==null&&u.set("runtimeInstanceId",o),u.set("afterSeq",String(r));const f=await oe.get(`/workspaces/${encodeURIComponent(e)}/services/${encodeURIComponent(i)}/logs?${u}`);return uc(w,f)},enabled:l&&!!e&&!!i,refetchInterval:w=>w.state.data?.hasMore?250:1e3,refetchIntervalInBackground:!1,refetchOnWindowFocus:"always",refetchOnReconnect:"always"})}const mc=[];function fs(e){return JSON.stringify([e.command,...e.args])}function Sr(e,i,s){if(!e)return s;const l=new Date(e);return Number.isNaN(l.getTime())?s:new Intl.DateTimeFormat(i,{dateStyle:"medium",timeStyle:"medium"}).format(l)}function pc(e){switch(e){case"RUNNING":return{label:"Running",dotClassName:"bg-terminal-green"};case"STARTING":return{label:"Starting",dotClassName:"bg-terminal-yellow"};case"STOPPING":return{label:"Stopping",dotClassName:"bg-terminal-yellow"};case"FAILED":return{label:"Failed",dotClassName:"bg-terminal-red"};case"EXITED":return{label:"Exited",dotClassName:"bg-terminal-muted-foreground"};default:return{label:"Stopped",dotClassName:"bg-terminal-bright-black"}}}function yr({state:e}){const{t:i}=re(),s=pc(e);return t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5 text-xs text-terminal-foreground",children:[t.jsx("span",{className:Q("h-1.5 w-1.5 rounded-full",s.dotClassName),"aria-hidden":"true"}),i(s.label)]})}function gc({message:e,onRetry:i}){const{t:s}=re();return t.jsxs("div",{className:"flex min-h-24 items-center justify-center gap-2 px-4 text-xs text-terminal-foreground",role:"alert",children:[t.jsx(Tt,{size:14,className:"shrink-0 text-terminal-red","aria-hidden":"true"}),t.jsx("span",{children:e}),t.jsx("button",{type:"button",onClick:i,className:"flex h-7 w-7 shrink-0 items-center justify-center rounded text-terminal-muted-foreground transition-colors hover:bg-terminal-accent hover:text-terminal-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-terminal-muted-foreground",title:s("Retry"),"aria-label":s("Retry"),children:t.jsx(_t,{size:13})})]})}function vc({workspaceId:e,enabled:i=!0}){const{locale:s,t:l}=re(),g=Gs(e,i),v=g.data??mc,[w,r]=A.useState(null),o=v.find(m=>m.name===w)??v[0]??null,u=fc(e,o?.name??"",o?.runtimeInstanceId??null,i&&!!o),f=A.useMemo(()=>ac(u.data?.entries.map(m=>m.data).join("")??""),[u.data?.entries]),a=A.useRef(null),p=A.useRef(!0);return A.useEffect(()=>{p.current=!0},[o?.id,o?.runtimeInstanceId]),A.useEffect(()=>{const m=a.current;m&&p.current&&(m.scrollTop=m.scrollHeight)},[f]),t.jsxs("div",{className:"flex h-full min-h-0 w-full min-w-0 flex-col bg-terminal text-terminal-foreground md:flex-row",children:[t.jsxs("aside",{className:"flex max-h-[44%] min-h-32 shrink-0 flex-col border-b border-terminal-border bg-terminal-chrome md:max-h-none md:min-h-0 md:w-72 md:border-b-0 md:border-r",children:[t.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between border-b border-terminal-border px-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Ns,{size:13,className:"shrink-0 text-terminal-muted-foreground","aria-hidden":"true"}),t.jsx("h2",{className:"truncate text-xs font-medium",children:l("Background services")})]}),!g.isLoading&&!g.isError&&t.jsx("span",{className:"text-[11px] tabular-nums text-terminal-muted-foreground",children:v.length})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto scrollbar-app-thin",children:g.isLoading?t.jsxs("div",{className:"flex min-h-24 items-center justify-center gap-2 text-xs text-terminal-muted-foreground",children:[t.jsx(xe,{size:"sm"}),l("Loading background services...")]}):g.isError?t.jsx(gc,{message:l("Failed to load background services."),onRetry:()=>{g.refetch()}}):v.length===0?t.jsxs("div",{className:"flex min-h-24 flex-col items-center justify-center gap-2 px-4 text-center text-xs text-terminal-muted-foreground",children:[t.jsx(Ns,{size:22,"aria-hidden":"true"}),t.jsx("span",{children:l("No background services")})]}):v.map(m=>{const y=m.name===o?.name;return t.jsxs("button",{type:"button",onClick:()=>r(m.name),"aria-pressed":y,className:Q("block w-full border-b border-terminal-border px-3 py-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-terminal-muted-foreground",y?"bg-terminal":"hover:bg-terminal-accent"),children:[t.jsxs("span",{className:"flex min-w-0 items-center justify-between gap-2",children:[t.jsx("span",{className:"truncate text-xs font-medium text-terminal-foreground",children:m.name}),t.jsx(yr,{state:m.runtimeState})]}),t.jsx("span",{className:"mt-1 block truncate font-mono text-[11px] text-terminal-muted-foreground",title:fs(m),children:fs(m)}),t.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-1 text-[11px] text-terminal-muted-foreground",children:[t.jsx($s,{size:10,className:"shrink-0","aria-hidden":"true"}),t.jsx("span",{className:"truncate",children:m.relativeCwd||"."})]}),t.jsxs("span",{className:`mt-1 flex min-w-0 items-center gap-1 ${m.startedAt?"text-[11px]":"text-xs"} text-terminal-muted-foreground`,children:[t.jsx(Ve,{size:10,className:"shrink-0","aria-hidden":"true"}),t.jsx("span",{className:"truncate",children:Sr(m.startedAt,s,l("Not started"))})]})]},m.id)})})]}),t.jsx("section",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-terminal","aria-label":l("Background service logs"),children:o?t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:"shrink-0 border-b border-terminal-border bg-terminal-chrome",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 px-3 pt-2",children:[t.jsx("span",{className:"min-w-0 truncate text-xs font-semibold text-terminal-foreground",children:o.name}),t.jsx(yr,{state:o.runtimeState})]}),t.jsxs("div",{className:"max-h-32 overflow-y-auto overscroll-y-contain px-3 pb-2 scrollbar-app-thin focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-terminal-muted-foreground",tabIndex:0,"aria-label":`${o.name} ${l("Details")}`,children:[t.jsxs("dl",{className:"mt-1.5 grid min-w-0 gap-x-4 gap-y-1 text-xs text-terminal-muted-foreground sm:grid-cols-2",children:[t.jsxs("div",{className:"flex min-w-0 gap-1.5",children:[t.jsxs("dt",{className:"shrink-0",children:[l("Command"),":"]}),t.jsx("dd",{className:"min-w-0 break-all font-mono text-terminal-foreground",children:fs(o)})]}),t.jsxs("div",{className:"flex min-w-0 gap-1.5",children:[t.jsxs("dt",{className:"shrink-0",children:[l("Working directory"),":"]}),t.jsx("dd",{className:"min-w-0 break-all font-mono text-terminal-foreground",children:o.relativeCwd||"."})]}),t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 sm:col-span-2",children:[t.jsx(Ve,{size:10,className:"shrink-0","aria-hidden":"true"}),t.jsxs("dt",{className:"shrink-0",children:[l("Started"),":"]}),t.jsx("dd",{className:"truncate text-terminal-foreground",children:Sr(o.startedAt,s,l("Not started"))})]})]}),o.lastError&&t.jsxs("p",{className:"mt-1.5 flex min-w-0 items-start gap-1.5 break-words text-xs text-terminal-foreground",role:"alert",children:[t.jsx(Tt,{size:12,className:"mt-0.5 shrink-0 text-terminal-red","aria-hidden":"true"}),t.jsx("span",{className:"min-w-0",children:o.lastError})]})]})]}),(u.data?.truncated||u.data?.reset)&&t.jsx("div",{className:"shrink-0 border-b border-terminal-yellow/20 bg-terminal-yellow/10 px-3 py-1.5 text-xs text-terminal-foreground",children:l("Earlier log output is unavailable.")}),u.isError&&t.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-terminal-red/20 bg-terminal-red/10 px-3 py-1.5 text-xs text-terminal-foreground",role:"alert",children:[t.jsx("span",{children:l("Failed to refresh service logs.")}),t.jsx("button",{type:"button",onClick:()=>{u.refetch()},className:"flex h-6 w-6 items-center justify-center rounded text-terminal-foreground transition-colors hover:bg-terminal-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-terminal-muted-foreground",title:l("Retry"),"aria-label":l("Retry"),children:t.jsx(_t,{size:11})})]}),t.jsx("div",{ref:a,onScroll:m=>{const y=m.currentTarget;p.current=y.scrollHeight-y.scrollTop-y.clientHeight<32},className:"min-h-0 flex-1 overflow-auto p-3 scrollbar-app-thin",role:"log","aria-live":"off",tabIndex:0,children:u.isLoading&&!u.data?t.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-xs text-terminal-muted-foreground",children:[t.jsx(xe,{size:"sm"}),l("Loading service logs...")]}):f?t.jsx("pre",{className:"m-0 whitespace-pre-wrap break-words font-mono text-xs leading-5 text-terminal-foreground",children:f}):t.jsx("div",{className:"flex h-full items-center justify-center text-xs text-terminal-muted-foreground",children:l("No logs yet")})})]}):t.jsx("div",{className:"flex h-full items-center justify-center px-4 text-center text-xs text-terminal-muted-foreground",children:g.isLoading?l("Loading background services..."):l("Select a background service")})})]})}let ms=0;function wr(){return ms+=1,{id:`shell-${ms}`,order:ms}}const _c=_e.memo(function({cwd:i,isVisible:s=!0,workspaceId:l,quickCommands:g=[]}){const{t:v}=re(),[w,r]=A.useState(()=>[wr()]),[o,u]=A.useState(()=>w[0].id),[f,a]=A.useState(()=>new Set),[p,m]=A.useState(!1),[y,b]=A.useState(!1),[n,d]=A.useState(""),[c,h]=A.useState(null),[_,S]=A.useState("terminals"),k=A.useRef(new Map),E=l?_:"terminals",x=A.useCallback(D=>{k.current.delete(D),a(O=>{if(!O.has(D))return O;const q=new Set(O);return q.delete(D),q})},[]),C=A.useCallback(()=>{const D=wr();r(O=>[...O,D]),u(D.id)},[]),T=A.useCallback((D,O)=>{O.stopPropagation(),x(D),r(q=>{const K=q.filter(U=>U.id!==D);return D===o&&K.length>0&&u(K[K.length-1].id),K})},[o,x]),L=A.useCallback(D=>{x(D),r(O=>{const q=O.filter(K=>K.id!==D);return D===o&&q.length>0&&u(q[q.length-1].id),q})},[o,x]),R=A.useCallback((D,O)=>{k.current.set(D,O),a(q=>{if(q.has(D))return q;const K=new Set(q);return K.add(D),K})},[]),M=A.useCallback(D=>{const O=k.current.get(o);O&&O.sendInput(D+"\r")},[o]),I=A.useCallback((D,O="")=>{h(D),d(O),b(!0)},[]),B=A.useCallback((D,O)=>{const q=k.current.get(D);return q?(q.paste(O),ke.success(v("Pasted into terminal")),!0):(ke.error(v("Terminal is not ready")),!1)},[v]),H=A.useCallback(async()=>{if(!k.current.has(o)){ke.error(v("Terminal is not ready"));return}const D=navigator.clipboard;if(!D?.readText){I(o);return}m(!0);try{const O=await D.readText();if(!O||O.includes(`
19
+ `)||O.includes("\r")){I(o,O);return}B(o,O)}catch{I(o)}finally{m(!1)}},[o,I,B,v]),$=A.useCallback(()=>{!n||!c||!B(c,n)||(b(!1),d(""),h(null))},[n,B,c]),N=A.useCallback(()=>{b(!1),d(""),h(null)},[]),P=f.has(o);return t.jsxs("div",{className:"flex h-full w-full min-h-0 min-w-0 flex-col overflow-hidden bg-terminal",children:[l&&t.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 border-b border-terminal-border bg-terminal-chrome px-2 select-none",children:[t.jsxs("button",{type:"button",onClick:()=>S("terminals"),"aria-pressed":E==="terminals",className:Q("flex h-7 items-center gap-1.5 rounded px-2.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-terminal-muted-foreground",E==="terminals"?"bg-terminal text-terminal-foreground":"text-terminal-muted-foreground hover:bg-terminal-accent hover:text-terminal-foreground"),children:[t.jsx(yt,{size:12,"aria-hidden":"true"}),v("Interactive terminals")]}),t.jsxs("button",{type:"button",onClick:()=>S("services"),"aria-pressed":E==="services",className:Q("flex h-7 items-center gap-1.5 rounded px-2.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-terminal-muted-foreground",E==="services"?"bg-terminal text-terminal-foreground":"text-terminal-muted-foreground hover:bg-terminal-accent hover:text-terminal-foreground"),children:[t.jsx(Ns,{size:12,"aria-hidden":"true"}),v("Background services")]})]}),t.jsxs("div",{"aria-hidden":E!=="terminals",className:Q("min-h-0 flex-1 flex-col",E==="terminals"?"flex":"hidden"),children:[t.jsxs("div",{className:"flex items-center bg-terminal-chrome border-b border-terminal-border shrink-0 select-none",children:[t.jsx("div",{className:"flex items-center overflow-x-auto scrollbar-app-thin flex-1 min-w-0",children:w.map(D=>t.jsxs("button",{onClick:()=>u(D.id),className:Q("flex items-center gap-1.5 px-3 py-1.5 text-xs border-r border-terminal-border whitespace-nowrap group transition-colors",D.id===o?"bg-terminal text-terminal-foreground":"text-terminal-muted-foreground hover:bg-terminal-accent hover:text-terminal-foreground"),children:[t.jsx(yt,{size:11,className:"shrink-0"}),t.jsx("span",{children:v("Shell {count}",{count:D.order})}),w.length>1&&t.jsx("span",{onClick:O=>T(D.id,O),className:"ml-1 p-0.5 rounded hover:bg-terminal-accent opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:t.jsx(tt,{size:10})})]},D.id))}),w.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"mx-0.5 block h-5 w-px shrink-0 bg-terminal-border md:hidden","aria-hidden":"true"}),t.jsx("button",{type:"button",onClick:H,disabled:!P||p,className:"flex h-11 w-11 shrink-0 items-center justify-center text-terminal-muted-foreground transition-colors hover:bg-terminal-accent hover:text-terminal-foreground active:bg-terminal-accent disabled:cursor-not-allowed disabled:opacity-40 md:hidden",title:v("Paste into terminal"),"aria-label":v("Paste into terminal"),children:p?t.jsx(xe,{size:"lg",className:"size-[18px]"}):t.jsx(da,{size:18})})]}),t.jsx("button",{type:"button",onClick:C,className:"flex h-11 w-11 shrink-0 items-center justify-center text-terminal-muted-foreground transition-colors hover:bg-terminal-accent hover:text-terminal-foreground active:bg-terminal-accent md:h-auto md:w-auto md:px-2 md:py-1.5",title:v("New Terminal"),"aria-label":v("New Terminal"),children:t.jsx(pt,{size:14})}),g.length>0&&t.jsx(rc,{commands:g,onSelect:M})]}),t.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden relative",children:w.length===0?t.jsx("div",{className:"flex-1 flex items-center justify-center h-full text-terminal-muted-foreground",children:t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(yt,{size:28}),t.jsx("span",{className:"text-xs",children:v("No terminals open")}),t.jsx("button",{onClick:C,className:"mt-1 rounded bg-terminal-chrome px-3 py-1 text-xs text-terminal-foreground ring-1 ring-inset ring-terminal-border transition-colors hover:bg-terminal-accent",children:v("New Terminal")})]})}):w.map(D=>t.jsx("div",{"aria-hidden":D.id!==o,className:Q("absolute inset-0 h-full w-full min-h-0 min-w-0 overflow-hidden",D.id===o?"visible pointer-events-auto":"invisible pointer-events-none"),children:t.jsx(sc,{cwd:i,isVisible:s&&E==="terminals"&&D.id===o,onExit:()=>L(D.id),onReady:O=>R(D.id,O)})},D.id))})]}),l&&E==="services"&&t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(vc,{workspaceId:l,enabled:s})}),t.jsx(At,{isOpen:y,onClose:N,title:v("Paste into terminal"),className:"max-sm:inset-x-0 max-sm:top-auto max-sm:bottom-0 max-sm:max-h-[70dvh] max-sm:w-full max-sm:max-w-none max-sm:translate-x-0 max-sm:translate-y-0 max-sm:rounded-b-none max-sm:rounded-t-lg max-sm:border-x-0 max-sm:border-b-0",action:t.jsxs(t.Fragment,{children:[t.jsx(ce,{variant:"ghost",size:"lg",onClick:N,className:"max-sm:h-11",children:v("Cancel")}),t.jsx(ce,{variant:"primary",size:"lg",onClick:$,disabled:!n,className:"max-sm:h-11",children:v("Paste")})]}),children:t.jsx(To,{autoFocus:!0,value:n,onChange:D=>d(D.target.value),placeholder:v("Paste terminal input here"),"aria-label":v("Terminal paste content"),className:"min-h-32 resize-none bg-background font-mono"})})]})});function Cr(e,i){(i==null||i>e.length)&&(i=e.length);for(var s=0,l=Array(i);s<i;s++)l[s]=e[s];return l}function bc(e){if(Array.isArray(e))return e}function xc(e,i,s){return(i=jc(i))in e?Object.defineProperty(e,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[i]=s,e}function Sc(e,i){var s=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(s!=null){var l,g,v,w,r=[],o=!0,u=!1;try{if(v=(s=s.call(e)).next,i!==0)for(;!(o=(l=v.call(s)).done)&&(r.push(l.value),r.length!==i);o=!0);}catch(f){u=!0,g=f}finally{try{if(!o&&s.return!=null&&(w=s.return(),Object(w)!==w))return}finally{if(u)throw g}}return r}}function yc(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
20
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function kr(e,i){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);i&&(l=l.filter(function(g){return Object.getOwnPropertyDescriptor(e,g).enumerable})),s.push.apply(s,l)}return s}function Er(e){for(var i=1;i<arguments.length;i++){var s=arguments[i]!=null?arguments[i]:{};i%2?kr(Object(s),!0).forEach(function(l){xc(e,l,s[l])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):kr(Object(s)).forEach(function(l){Object.defineProperty(e,l,Object.getOwnPropertyDescriptor(s,l))})}return e}function wc(e,i){if(e==null)return{};var s,l,g=Cc(e,i);if(Object.getOwnPropertySymbols){var v=Object.getOwnPropertySymbols(e);for(l=0;l<v.length;l++)s=v[l],i.indexOf(s)===-1&&{}.propertyIsEnumerable.call(e,s)&&(g[s]=e[s])}return g}function Cc(e,i){if(e==null)return{};var s={};for(var l in e)if({}.hasOwnProperty.call(e,l)){if(i.indexOf(l)!==-1)continue;s[l]=e[l]}return s}function kc(e,i){return bc(e)||Sc(e,i)||Nc(e,i)||yc()}function Ec(e,i){if(typeof e!="object"||!e)return e;var s=e[Symbol.toPrimitive];if(s!==void 0){var l=s.call(e,i);if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(e)}function jc(e){var i=Ec(e,"string");return typeof i=="symbol"?i:i+""}function Nc(e,i){if(e){if(typeof e=="string")return Cr(e,i);var s={}.toString.call(e).slice(8,-1);return s==="Object"&&e.constructor&&(s=e.constructor.name),s==="Map"||s==="Set"?Array.from(e):s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?Cr(e,i):void 0}}function Tc(e,i,s){return i in e?Object.defineProperty(e,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[i]=s,e}function jr(e,i){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);i&&(l=l.filter(function(g){return Object.getOwnPropertyDescriptor(e,g).enumerable})),s.push.apply(s,l)}return s}function Nr(e){for(var i=1;i<arguments.length;i++){var s=arguments[i]!=null?arguments[i]:{};i%2?jr(Object(s),!0).forEach(function(l){Tc(e,l,s[l])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):jr(Object(s)).forEach(function(l){Object.defineProperty(e,l,Object.getOwnPropertyDescriptor(s,l))})}return e}function Ac(){for(var e=arguments.length,i=new Array(e),s=0;s<e;s++)i[s]=arguments[s];return function(l){return i.reduceRight(function(g,v){return v(g)},l)}}function St(e){return function i(){for(var s=this,l=arguments.length,g=new Array(l),v=0;v<l;v++)g[v]=arguments[v];return g.length>=e.length?e.apply(this,g):function(){for(var w=arguments.length,r=new Array(w),o=0;o<w;o++)r[o]=arguments[o];return i.apply(s,[].concat(g,r))}}}function Yt(e){return{}.toString.call(e).includes("Object")}function Rc(e){return!Object.keys(e).length}function Nt(e){return typeof e=="function"}function Lc(e,i){return Object.prototype.hasOwnProperty.call(e,i)}function Mc(e,i){return Yt(i)||Ge("changeType"),Object.keys(i).some(function(s){return!Lc(e,s)})&&Ge("changeField"),i}function Dc(e){Nt(e)||Ge("selectorType")}function Pc(e){Nt(e)||Yt(e)||Ge("handlerType"),Yt(e)&&Object.values(e).some(function(i){return!Nt(i)})&&Ge("handlersType")}function Bc(e){e||Ge("initialIsRequired"),Yt(e)||Ge("initialType"),Rc(e)&&Ge("initialContent")}function Oc(e,i){throw new Error(e[i]||e.default)}var Ic={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},Ge=St(Oc)(Ic),It={changes:Mc,selector:Dc,handler:Pc,initial:Bc};function Fc(e){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};It.initial(e),It.handler(i);var s={current:e},l=St(Wc)(s,i),g=St(zc)(s),v=St(It.changes)(e),w=St(Hc)(s);function r(){var u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(f){return f};return It.selector(u),u(s.current)}function o(u){Ac(l,g,v,w)(u)}return[r,o]}function Hc(e,i){return Nt(i)?i(e.current):i}function zc(e,i){return e.current=Nr(Nr({},e.current),i),i}function Wc(e,i,s){return Nt(i)?i(e.current):Object.keys(s).forEach(function(l){var g;return(g=i[l])===null||g===void 0?void 0:g.call(i,e.current[l])}),s}var $c={create:Fc},Uc={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function qc(e){return function i(){for(var s=this,l=arguments.length,g=new Array(l),v=0;v<l;v++)g[v]=arguments[v];return g.length>=e.length?e.apply(this,g):function(){for(var w=arguments.length,r=new Array(w),o=0;o<w;o++)r[o]=arguments[o];return i.apply(s,[].concat(g,r))}}}function Kc(e){return{}.toString.call(e).includes("Object")}function Xc(e){return e||Tr("configIsRequired"),Kc(e)||Tr("configType"),e.urls?(Yc(),{paths:{vs:e.urls.monacoBase}}):e}function Yc(){console.warn(Hi.deprecation)}function Vc(e,i){throw new Error(e[i]||e.default)}var Hi={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
21
21
  You are using deprecated way of configuration.
22
22
 
23
23
  Instead of using
@@ -26,7 +26,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
26
26
  monaco.config({ paths: { vs: '...' } })
27
27
 
28
28
  For more please check the link https://github.com/suren-atoyan/monaco-loader#config
29
- `},Tr=qc(Vc)(Hi),Gc={config:Xc},Qc=function(){for(var r=arguments.length,s=new Array(r),l=0;l<r;l++)s[l]=arguments[l];return function(g){return s.reduceRight(function(v,w){return w(v)},g)}};function zi(e,r){return Object.keys(r).forEach(function(s){r[s]instanceof Object&&e[s]&&Object.assign(r[s],zi(e[s],r[s]))}),Er(Er({},e),r)}var Zc={type:"cancelation",msg:"operation is manually canceled"};function ps(e){var r=!1,s=new Promise(function(l,g){e.then(function(v){return r?g(Zc):l(v)}),e.catch(g)});return s.cancel=function(){return r=!0},s}var Jc=["monaco"],ed=$c.create({config:Uc,isInitialized:!1,resolve:null,reject:null,monaco:null}),Wi=kc(ed,2),Rt=Wi[0],Jt=Wi[1];function td(e){var r=Gc.config(e),s=r.monaco,l=wc(r,Jc);Jt(function(g){return{config:zi(g.config,l),monaco:s}})}function sd(){var e=Rt(function(r){var s=r.monaco,l=r.isInitialized,g=r.resolve;return{monaco:s,isInitialized:l,resolve:g}});if(!e.isInitialized){if(Jt({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),ps(gs);if(window.monaco&&window.monaco.editor)return $i(window.monaco),e.resolve(window.monaco),ps(gs);Qc(rd,nd)(od)}return ps(gs)}function rd(e){return document.body.appendChild(e)}function id(e){var r=document.createElement("script");return e&&(r.src=e),r}function nd(e){var r=Rt(function(l){var g=l.config,v=l.reject;return{config:g,reject:v}}),s=id("".concat(r.config.paths.vs,"/loader.js"));return s.onload=function(){return e()},s.onerror=r.reject,s}function od(){var e=Rt(function(s){var l=s.config,g=s.resolve,v=s.reject;return{config:l,resolve:g,reject:v}}),r=window.require;r.config(e.config),r(["vs/editor/editor.main"],function(s){var l=s.m||s;$i(l),e.resolve(l)},function(s){e.reject(s)})}function $i(e){Rt().monaco||Jt({monaco:e})}function ad(){return Rt(function(e){var r=e.monaco;return r})}var gs=new Promise(function(e,r){return Jt({resolve:e,reject:r})}),Ui={config:td,init:sd,__getMonacoInstance:ad},ld={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},vs=ld,cd={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},dd=cd;function hd({children:e}){return _e.createElement("div",{style:dd.container},e)}var ud=hd,fd=ud;function md({width:e,height:r,isEditorReady:s,loading:l,_ref:g,className:v,wrapperProps:w}){return _e.createElement("section",{style:{...vs.wrapper,width:e,height:r},...w},!s&&_e.createElement(fd,null,l),_e.createElement("div",{ref:g,style:{...vs.fullWidth,...!s&&vs.hide},className:v}))}var pd=md,qi=A.memo(pd);function gd(e){A.useEffect(e,[])}var Ki=gd;function vd(e,r,s=!0){let l=A.useRef(!0);A.useEffect(l.current||!s?()=>{l.current=!1}:e,r)}var Te=vd;function wt(){}function gt(e,r,s,l){return _d(e,l)||bd(e,r,s,l)}function _d(e,r){return e.editor.getModel(Xi(e,r))}function bd(e,r,s,l){return e.editor.createModel(r,s,l?Xi(e,l):void 0)}function Xi(e,r){return e.Uri.parse(r)}function xd({original:e,modified:r,language:s,originalLanguage:l,modifiedLanguage:g,originalModelPath:v,modifiedModelPath:w,keepCurrentOriginalModel:i=!1,keepCurrentModifiedModel:o=!1,theme:u="light",loading:f="Loading...",options:a={},height:p="100%",width:m="100%",className:y,wrapperProps:b={},beforeMount:n=wt,onMount:d=wt}){let[c,h]=A.useState(!1),[_,S]=A.useState(!0),k=A.useRef(null),E=A.useRef(null),x=A.useRef(null),C=A.useRef(d),T=A.useRef(n),L=A.useRef(!1);Ki(()=>{let B=Ui.init();return B.then(H=>(E.current=H)&&S(!1)).catch(H=>H?.type!=="cancelation"&&console.error("Monaco initialization: error:",H)),()=>k.current?I():B.cancel()}),Te(()=>{if(k.current&&E.current){let B=k.current.getOriginalEditor(),H=gt(E.current,e||"",l||s||"text",v||"");H!==B.getModel()&&B.setModel(H)}},[v],c),Te(()=>{if(k.current&&E.current){let B=k.current.getModifiedEditor(),H=gt(E.current,r||"",g||s||"text",w||"");H!==B.getModel()&&B.setModel(H)}},[w],c),Te(()=>{let B=k.current.getModifiedEditor();B.getOption(E.current.editor.EditorOption.readOnly)?B.setValue(r||""):r!==B.getValue()&&(B.executeEdits("",[{range:B.getModel().getFullModelRange(),text:r||"",forceMoveMarkers:!0}]),B.pushUndoStop())},[r],c),Te(()=>{k.current?.getModel()?.original.setValue(e||"")},[e],c),Te(()=>{let{original:B,modified:H}=k.current.getModel();E.current.editor.setModelLanguage(B,l||s||"text"),E.current.editor.setModelLanguage(H,g||s||"text")},[s,l,g],c),Te(()=>{E.current?.editor.setTheme(u)},[u],c),Te(()=>{k.current?.updateOptions(a)},[a],c);let R=A.useCallback(()=>{if(!E.current)return;T.current(E.current);let B=gt(E.current,e||"",l||s||"text",v||""),H=gt(E.current,r||"",g||s||"text",w||"");k.current?.setModel({original:B,modified:H})},[s,r,g,e,l,v,w]),M=A.useCallback(()=>{!L.current&&x.current&&(k.current=E.current.editor.createDiffEditor(x.current,{automaticLayout:!0,...a}),R(),E.current?.editor.setTheme(u),h(!0),L.current=!0)},[a,u,R]);A.useEffect(()=>{c&&C.current(k.current,E.current)},[c]),A.useEffect(()=>{!_&&!c&&M()},[_,c,M]);function I(){let B=k.current?.getModel();i||B?.original?.dispose(),o||B?.modified?.dispose(),k.current?.dispose()}return _e.createElement(qi,{width:m,height:p,isEditorReady:c,loading:f,_ref:x,className:y,wrapperProps:b})}var Sd=xd;A.memo(Sd);function yd(e){let r=A.useRef();return A.useEffect(()=>{r.current=e},[e]),r.current}var wd=yd,Ft=new Map;function Cd({defaultValue:e,defaultLanguage:r,defaultPath:s,value:l,language:g,path:v,theme:w="light",line:i,loading:o="Loading...",options:u={},overrideServices:f={},saveViewState:a=!0,keepCurrentModel:p=!1,width:m="100%",height:y="100%",className:b,wrapperProps:n={},beforeMount:d=wt,onMount:c=wt,onChange:h,onValidate:_=wt}){let[S,k]=A.useState(!1),[E,x]=A.useState(!0),C=A.useRef(null),T=A.useRef(null),L=A.useRef(null),R=A.useRef(c),M=A.useRef(d),I=A.useRef(),B=A.useRef(l),H=wd(v),$=A.useRef(!1),N=A.useRef(!1);Ki(()=>{let O=Ui.init();return O.then(q=>(C.current=q)&&x(!1)).catch(q=>q?.type!=="cancelation"&&console.error("Monaco initialization: error:",q)),()=>T.current?D():O.cancel()}),Te(()=>{let O=gt(C.current,e||l||"",r||g||"",v||s||"");O!==T.current?.getModel()&&(a&&Ft.set(H,T.current?.saveViewState()),T.current?.setModel(O),a&&T.current?.restoreViewState(Ft.get(v)))},[v],S),Te(()=>{T.current?.updateOptions(u)},[u],S),Te(()=>{!T.current||l===void 0||(T.current.getOption(C.current.editor.EditorOption.readOnly)?T.current.setValue(l):l!==T.current.getValue()&&(N.current=!0,T.current.executeEdits("",[{range:T.current.getModel().getFullModelRange(),text:l,forceMoveMarkers:!0}]),T.current.pushUndoStop(),N.current=!1))},[l],S),Te(()=>{let O=T.current?.getModel();O&&g&&C.current?.editor.setModelLanguage(O,g)},[g],S),Te(()=>{i!==void 0&&T.current?.revealLine(i)},[i],S),Te(()=>{C.current?.editor.setTheme(w)},[w],S);let P=A.useCallback(()=>{if(!(!L.current||!C.current)&&!$.current){M.current(C.current);let O=v||s,q=gt(C.current,l||e||"",r||g||"",O||"");T.current=C.current?.editor.create(L.current,{model:q,automaticLayout:!0,...u},f),a&&T.current.restoreViewState(Ft.get(O)),C.current.editor.setTheme(w),i!==void 0&&T.current.revealLine(i),k(!0),$.current=!0}},[e,r,s,l,g,v,u,f,a,w,i]);A.useEffect(()=>{S&&R.current(T.current,C.current)},[S]),A.useEffect(()=>{!E&&!S&&P()},[E,S,P]),B.current=l,A.useEffect(()=>{S&&h&&(I.current?.dispose(),I.current=T.current?.onDidChangeModelContent(O=>{N.current||h(T.current.getValue(),O)}))},[S,h]),A.useEffect(()=>{if(S){let O=C.current.editor.onDidChangeMarkers(q=>{let K=T.current.getModel()?.uri;if(K&&q.find(U=>U.path===K.path)){let U=C.current.editor.getModelMarkers({resource:K});_?.(U)}});return()=>{O?.dispose()}}return()=>{}},[S,_]);function D(){I.current?.dispose(),p?a&&Ft.set(v,T.current.saveViewState()):T.current.getModel()?.dispose(),T.current.dispose()}return _e.createElement(qi,{width:m,height:y,isEditorReady:S,loading:o,_ref:L,className:b,wrapperProps:n})}var kd=Cd,Ed=A.memo(kd),jd=Ed,Me=function(e,r){return Number(e.toFixed(r))},Nd=function(e,r){return typeof e=="number"?e:r},fe=function(e,r,s){s&&typeof s=="function"&&s(e,r)},Td=function(e){return-Math.cos(e*Math.PI)/2+.5},Ad=function(e){return e},Rd=function(e){return e*e},Ld=function(e){return e*(2-e)},Md=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},Dd=function(e){return e*e*e},Pd=function(e){return--e*e*e+1},Bd=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},Od=function(e){return e*e*e*e},Id=function(e){return 1- --e*e*e*e},Fd=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},Hd=function(e){return e*e*e*e*e},zd=function(e){return 1+--e*e*e*e*e},Wd=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},Yi={easeOut:Td,linear:Ad,easeInQuad:Rd,easeOutQuad:Ld,easeInOutQuad:Md,easeInCubic:Dd,easeOutCubic:Pd,easeInOutCubic:Bd,easeInQuart:Od,easeOutQuart:Id,easeInOutQuart:Fd,easeInQuint:Hd,easeOutQuint:zd,easeInOutQuint:Wd},Vi=function(e){typeof e=="number"&&cancelAnimationFrame(e)},Be=function(e){e.mounted&&(Vi(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function Gi(e,r,s,l){if(e.mounted){var g=new Date().getTime(),v=1;Be(e),e.animation=function(){if(!e.mounted)return Vi(e.animation);var w=new Date().getTime()-g,i=w/s,o=Yi[r],u=o(i);w>=s?(l(v),e.animation=null):e.animation&&(l(u),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function $d(e){var r=e.scale,s=e.positionX,l=e.positionY;return!(Number.isNaN(r)||Number.isNaN(s)||Number.isNaN(l))}function st(e,r,s,l){var g=$d(r);if(!(!e.mounted||!g)){var v=e.setTransformState,w=e.transformState,i=w.scale,o=w.positionX,u=w.positionY,f=r.scale-i,a=r.positionX-o,p=r.positionY-u;s===0?v(r.scale,r.positionX,r.positionY):Gi(e,l,s,function(m){var y=i+f*m,b=o+a*m,n=u+p*m;v(y,b,n)})}}function Ud(e,r,s){var l=e.offsetWidth,g=e.offsetHeight,v=r.offsetWidth,w=r.offsetHeight,i=v*s,o=w*s,u=l-i,f=g-o;return{wrapperWidth:l,wrapperHeight:g,newContentWidth:i,newDiffWidth:u,newContentHeight:o,newDiffHeight:f}}var qd=function(e,r,s,l,g,v,w){var i=e>r?s*(w?1:.5):0,o=l>g?v*(w?1:.5):0,u=e-r-i,f=i,a=l-g-o,p=o;return{minPositionX:u,maxPositionX:f,minPositionY:a,maxPositionY:p}},Qs=function(e,r){var s=e.wrapperComponent,l=e.contentComponent,g=e.setup.centerZoomedOut;if(!s||!l)throw new Error("Components are not mounted");var v=Ud(s,l,r),w=v.wrapperWidth,i=v.wrapperHeight,o=v.newContentWidth,u=v.newDiffWidth,f=v.newContentHeight,a=v.newDiffHeight,p=qd(w,o,u,i,f,a,!!g);return p},Ms=function(e,r,s,l){return l?e<r?Me(r,2):e>s?Me(s,2):Me(e,2):Me(e,2)},ct=function(e,r){var s=Qs(e,r);return e.bounds=s,s};function Lt(e,r,s,l,g,v,w){var i=s.minPositionX,o=s.minPositionY,u=s.maxPositionX,f=s.maxPositionY,a=0,p=0;w&&(a=g,p=v);var m=Ms(e,i-a,u+a,l),y=Ms(r,o-p,f+p,l);return{x:m,y}}function es(e,r,s,l,g,v){var w=e.transformState,i=w.scale,o=w.positionX,u=w.positionY,f=l-i;if(typeof r!="number"||typeof s!="number")return console.error("Mouse X and Y position were not provided!"),{x:o,y:u};var a=o-r*f,p=u-s*f,m=Lt(a,p,g,v,0,0,null);return m}function Mt(e,r,s,l,g){var v=g?l:0,w=r-v;return!Number.isNaN(s)&&e>=s?s:!Number.isNaN(r)&&e<=w?w:e}var Ar=function(e,r){var s=e.setup.panning.excluded,l=e.isInitialized,g=e.wrapperComponent,v=r.target,w="shadowRoot"in v&&"composedPath"in r,i=w?r.composedPath().some(function(f){return f instanceof Element?g?.contains(f):!1}):g?.contains(v),o=l&&v&&i;if(!o)return!1;var u=ts(v,s);return!u},Rr=function(e){var r=e.isInitialized,s=e.isPanning,l=e.setup,g=l.panning.disabled,v=r&&s&&!g;return!!v},Kd=function(e,r){var s=e.transformState,l=s.positionX,g=s.positionY;e.isPanning=!0;var v=r.clientX,w=r.clientY;e.startCoords={x:v-l,y:w-g}},Xd=function(e,r){var s=r.touches,l=e.transformState,g=l.positionX,v=l.positionY;e.isPanning=!0;var w=s.length===1;if(w){var i=s[0].clientX,o=s[0].clientY;e.startCoords={x:i-g,y:o-v}}};function Yd(e){var r=e.transformState,s=r.positionX,l=r.positionY,g=r.scale,v=e.setup,w=v.disabled,i=v.limitToBounds,o=v.centerZoomedOut,u=e.wrapperComponent;if(!(w||!u||!e.bounds)){var f=e.bounds,a=f.maxPositionX,p=f.minPositionX,m=f.maxPositionY,y=f.minPositionY,b=s>a||s<p,n=l>m||l<y,d=s>a?u.offsetWidth:e.setup.minPositionX||0,c=l>m?u.offsetHeight:e.setup.minPositionY||0,h=es(e,d,c,g,e.bounds,i||o),_=h.x,S=h.y;return{scale:g,positionX:b?_:s,positionY:n?S:l}}}function Qi(e,r,s,l,g){var v=e.setup.limitToBounds,w=e.wrapperComponent,i=e.bounds,o=e.transformState,u=o.scale,f=o.positionX,a=o.positionY;if(!(w===null||i===null||r===f&&s===a)){var p=Lt(r,s,i,v,l,g,w),m=p.x,y=p.y;e.setTransformState(u,m,y)}}var Vd=function(e,r,s){var l=e.startCoords,g=e.transformState,v=e.setup.panning,w=v.lockAxisX,i=v.lockAxisY,o=g.positionX,u=g.positionY;if(!l)return{x:o,y:u};var f=r-l.x,a=s-l.y,p=w?o:f,m=i?u:a;return{x:p,y:m}},et=function(e,r){var s=e.setup,l=e.transformState,g=l.scale,v=s.minScale,w=s.disablePadding;return r>0&&g>=v&&!w?r:0},Gd=function(e){var r=e.mounted,s=e.setup,l=s.disabled,g=s.velocityAnimation,v=e.transformState.scale,w=g.disabled,i=!w||v>1||!l||r;return!!i},Qd=function(e){var r=e.mounted,s=e.velocity,l=e.bounds,g=e.setup,v=g.disabled,w=g.velocityAnimation,i=e.transformState.scale,o=w.disabled,u=!o||i>1||!v||r;return!(!u||!s||!l)};function Zd(e,r){var s=e.setup.velocityAnimation,l=s.equalToMove,g=s.animationTime,v=s.sensitivity;return l?g*r*v:g}function Lr(e,r,s,l,g,v,w,i,o,u){if(g){if(r>w&&s>w){var f=w+(e-w)*u;return f>o?o:f<w?w:f}if(r<v&&s<v){var f=v+(e-v)*u;return f<i?i:f>v?v:f}}return l?r:Ms(e,v,w,g)}function Jd(e,r){var s=1;return r?Math.min(s,e.offsetWidth/window.innerWidth):s}function eh(e,r){var s=Gd(e);if(s){var l=e.lastMousePosition,g=e.velocityTime,v=e.setup,w=e.wrapperComponent,i=v.velocityAnimation.equalToMove,o=Date.now();if(l&&g&&w){var u=Jd(w,i),f=r.x-l.x,a=r.y-l.y,p=f/u,m=a/u,y=o-g,b=f*f+a*a,n=Math.sqrt(b)/y;e.velocity={velocityX:p,velocityY:m,total:n}}e.lastMousePosition=r,e.velocityTime=o}}function th(e){var r=e.velocity,s=e.bounds,l=e.setup,g=e.wrapperComponent,v=Qd(e);if(!(!v||!r||!s||!g)){var w=r.velocityX,i=r.velocityY,o=r.total,u=s.maxPositionX,f=s.minPositionX,a=s.maxPositionY,p=s.minPositionY,m=l.limitToBounds,y=l.alignmentAnimation,b=l.zoomAnimation,n=l.panning,d=n.lockAxisY,c=n.lockAxisX,h=b.animationType,_=y.sizeX,S=y.sizeY,k=y.velocityAlignmentTime,E=k,x=Zd(e,o),C=Math.max(x,E),T=et(e,_),L=et(e,S),R=T*g.offsetWidth/100,M=L*g.offsetHeight/100,I=u+R,B=f-R,H=a+M,$=p-M,N=e.transformState,P=new Date().getTime();Gi(e,h,C,function(D){var O=e.transformState,q=O.scale,K=O.positionX,U=O.positionY,z=new Date().getTime()-P,W=z/E,j=Yi[y.animationType],F=1-j(Math.min(1,W)),X=1-D,Y=K+w*X,ee=U+i*X,G=Lr(Y,N.positionX,K,c,m,f,u,B,I,F),Z=Lr(ee,N.positionY,U,d,m,p,a,$,H,F);(K!==Y||U!==ee)&&e.setTransformState(q,G,Z)})}}function Mr(e,r){var s=e.transformState.scale;Be(e),ct(e,s),window.TouchEvent!==void 0&&r instanceof TouchEvent?Xd(e,r):Kd(e,r)}function Zs(e,r){var s=e.transformState.scale,l=e.setup,g=l.minScale,v=l.alignmentAnimation,w=v.disabled,i=v.sizeX,o=v.sizeY,u=v.animationTime,f=v.animationType,a=w||s<g||!i&&!o;if(!a){var p=Yd(e);p&&st(e,p,r??u,f)}}function Dr(e,r,s){var l=e.startCoords,g=e.setup,v=g.alignmentAnimation,w=v.sizeX,i=v.sizeY;if(l){var o=Vd(e,r,s),u=o.x,f=o.y,a=et(e,w),p=et(e,i);eh(e,{x:u,y:f}),Qi(e,u,f,a,p)}}function sh(e){if(e.isPanning){var r=e.setup.panning.velocityDisabled,s=e.velocity,l=e.wrapperComponent,g=e.contentComponent;e.isPanning=!1,e.animate=!1,e.animation=null;var v=l?.getBoundingClientRect(),w=g?.getBoundingClientRect(),i=v?.width||0,o=v?.height||0,u=w?.width||0,f=w?.height||0,a=i<u||o<f,p=!r&&s&&s?.total>.1&&a;p?th(e):Zs(e)}}function Js(e,r,s,l){var g=e.setup,v=g.minScale,w=g.maxScale,i=g.limitToBounds,o=Mt(Me(r,2),v,w,0,!1),u=ct(e,o),f=es(e,s,l,o,u,i),a=f.x,p=f.y;return{scale:o,positionX:a,positionY:p}}function Zi(e,r,s){var l=e.transformState.scale,g=e.wrapperComponent,v=e.setup,w=v.minScale,i=v.limitToBounds,o=v.zoomAnimation,u=o.disabled,f=o.animationTime,a=o.animationType,p=u||l>=w;if((l>=1||i)&&Zs(e),!(p||!g||!e.mounted)){var m=r||g.offsetWidth/2,y=s||g.offsetHeight/2,b=Js(e,w,m,y);b&&st(e,b,f,a)}}var Qe=function(){return Qe=Object.assign||function(r){for(var s,l=1,g=arguments.length;l<g;l++){s=arguments[l];for(var v in s)Object.prototype.hasOwnProperty.call(s,v)&&(r[v]=s[v])}return r},Qe.apply(this,arguments)};function Pr(e,r,s){for(var l=0,g=r.length,v;l<g;l++)(v||!(l in r))&&(v||(v=Array.prototype.slice.call(r,0,l)),v[l]=r[l]);return e.concat(v||Array.prototype.slice.call(r))}var Ht={scale:1,positionX:0,positionY:0},xt={disabled:!1,minPositionX:null,maxPositionX:null,minPositionY:null,maxPositionY:null,minScale:1,maxScale:8,limitToBounds:!0,centerZoomedOut:!1,centerOnInit:!1,disablePadding:!1,smooth:!0,wheel:{step:.2,disabled:!1,smoothStep:.001,wheelDisabled:!1,touchPadDisabled:!1,activationKeys:[],excluded:[]},panning:{disabled:!1,velocityDisabled:!1,lockAxisX:!1,lockAxisY:!1,allowLeftClickPan:!0,allowMiddleClickPan:!0,allowRightClickPan:!0,wheelPanning:!1,activationKeys:[],excluded:[]},pinch:{step:5,disabled:!1,excluded:[]},doubleClick:{disabled:!1,step:.7,mode:"zoomIn",animationType:"easeOut",animationTime:200,excluded:[]},zoomAnimation:{disabled:!1,size:.4,animationTime:200,animationType:"easeOut"},alignmentAnimation:{disabled:!1,sizeX:100,sizeY:100,animationTime:200,velocityAlignmentTime:400,animationType:"easeOut"},velocityAnimation:{disabled:!1,sensitivity:1,animationTime:400,animationType:"easeOut",equalToMove:!0}},Ds={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},Ji=function(e){var r,s,l,g;return{previousScale:(r=e.initialScale)!==null&&r!==void 0?r:Ht.scale,scale:(s=e.initialScale)!==null&&s!==void 0?s:Ht.scale,positionX:(l=e.initialPositionX)!==null&&l!==void 0?l:Ht.positionX,positionY:(g=e.initialPositionY)!==null&&g!==void 0?g:Ht.positionY}},Br=function(e){var r=Qe({},xt);return Object.keys(e).forEach(function(s){var l=typeof e[s]<"u",g=typeof xt[s]<"u";if(g&&l){var v=Object.prototype.toString.call(xt[s]),w=v==="[object Object]",i=v==="[object Array]";w?r[s]=Qe(Qe({},xt[s]),e[s]):i?r[s]=Pr(Pr([],xt[s],!0),e[s]):r[s]=e[s]}}),r},en=function(e,r,s){var l=e.transformState.scale,g=e.wrapperComponent,v=e.setup,w=v.maxScale,i=v.minScale,o=v.zoomAnimation,u=v.smooth,f=o.size;if(!g)throw new Error("Wrapper is not mounted");var a=u?l*Math.exp(r*s):l+r*s,p=Mt(Me(a,3),i,w,f,!1);return p};function tn(e,r,s,l,g){var v=e.wrapperComponent,w=e.transformState,i=w.scale,o=w.positionX,u=w.positionY;if(!v)return console.error("No WrapperComponent found");var f=v.offsetWidth,a=v.offsetHeight,p=(f/2-o)/i,m=(a/2-u)/i,y=en(e,r,s),b=Js(e,y,p,m);if(!b)return console.error("Error during zoom event. New transformation state was not calculated.");st(e,b,l,g)}function sn(e,r,s,l){var g=e.setup,v=e.wrapperComponent,w=g.limitToBounds,i=Ji(e.props),o=e.transformState,u=o.scale,f=o.positionX,a=o.positionY;if(v){var p=Qs(e,i.scale),m=Lt(i.positionX,i.positionY,p,w,0,0,v),y={scale:i.scale,positionX:m.x,positionY:m.y};u===i.scale&&f===i.positionX&&a===i.positionY||(l?.(),st(e,y,r,s))}}function rh(e,r,s,l){var g=e.getBoundingClientRect(),v=r.getBoundingClientRect(),w=s.getBoundingClientRect(),i=v.x*l.scale,o=v.y*l.scale;return{x:(g.x-w.x+i)/l.scale,y:(g.y-w.y+o)/l.scale}}function ih(e,r,s){var l=e.wrapperComponent,g=e.contentComponent,v=e.transformState,w=e.setup,i=w.limitToBounds,o=w.minScale,u=w.maxScale;if(!l||!g)return v;var f=l.getBoundingClientRect(),a=r.getBoundingClientRect(),p=rh(r,l,g,v),m=p.x,y=p.y,b=a.width/v.scale,n=a.height/v.scale,d=l.offsetWidth/b,c=l.offsetHeight/n,h=Mt(s||Math.min(d,c),o,u,0,!1),_=(f.width-b*h)/2,S=(f.height-n*h)/2,k=(f.left-m)*h+_,E=(f.top-y)*h+S,x=Qs(e,h),C=Lt(k,E,x,i,0,0,l),T=C.x,L=C.y;return{positionX:T,positionY:L,scale:h}}var nh=function(e){return function(r,s,l){r===void 0&&(r=.5),s===void 0&&(s=300),l===void 0&&(l="easeOut"),tn(e,1,r,s,l)}},oh=function(e){return function(r,s,l){r===void 0&&(r=.5),s===void 0&&(s=300),l===void 0&&(l="easeOut"),tn(e,-1,r,s,l)}},ah=function(e){return function(r,s,l,g,v){g===void 0&&(g=300),v===void 0&&(v="easeOut");var w=e.transformState,i=w.positionX,o=w.positionY,u=w.scale,f=e.wrapperComponent,a=e.contentComponent,p=e.setup.disabled;if(!(p||!f||!a)){var m={positionX:Number.isNaN(r)?i:r,positionY:Number.isNaN(s)?o:s,scale:Number.isNaN(l)?u:l};st(e,m,g,v)}}},lh=function(e){return function(r,s){r===void 0&&(r=200),s===void 0&&(s="easeOut"),sn(e,r,s)}},ch=function(e){return function(r,s,l){s===void 0&&(s=200),l===void 0&&(l="easeOut");var g=e.transformState,v=e.wrapperComponent,w=e.contentComponent;if(v&&w){var i=rn(r||g.scale,v,w);st(e,i,s,l)}}},dh=function(e){return function(r,s,l,g){l===void 0&&(l=600),g===void 0&&(g="easeOut"),Be(e);var v=e.wrapperComponent,w=typeof r=="string"?document.getElementById(r):r;if(v&&w&&v.contains(w)){var i=ih(e,w,s);st(e,i,l,g)}}},Vt=function(e){return{instance:e,zoomIn:nh(e),zoomOut:oh(e),setTransform:ah(e),resetTransform:lh(e),centerView:ch(e),zoomToElement:dh(e)}},Ps=function(e){return{instance:e,state:e.transformState}},de=function(e){var r={};return Object.assign(r,Ps(e)),Object.assign(r,Vt(e)),r},_s=!1;function bs(){try{var e={get passive(){return _s=!0,!1}};return e}catch{return _s=!1,_s}}var zt=".".concat(Ds.wrapperClass),ts=function(e,r){return r.some(function(s){return e.matches("".concat(zt," ").concat(s,", ").concat(zt," .").concat(s,", ").concat(zt," ").concat(s," *, ").concat(zt," .").concat(s," *"))})},Bs=function(e){e&&clearTimeout(e)},hh=function(e,r,s){return"translate(".concat(e,"px, ").concat(r,"px) scale(").concat(s,")")},rn=function(e,r,s){var l=s.offsetWidth*e,g=s.offsetHeight*e,v=(r.offsetWidth-l)/2,w=(r.offsetHeight-g)/2;return{scale:e,positionX:v,positionY:w}};function uh(e){return function(r){e.forEach(function(s){typeof s=="function"?s(r):s!=null&&(s.current=r)})}}var fh=function(e,r){var s=e.setup.wheel,l=s.disabled,g=s.wheelDisabled,v=s.touchPadDisabled,w=s.excluded,i=e.isInitialized,o=e.isPanning,u=r.target,f=i&&!o&&!l&&u;if(!f||g&&!r.ctrlKey||v&&r.ctrlKey)return!1;var a=ts(u,w);return!a},mh=function(e){return e?e.deltaY<0?1:-1:0};function ph(e,r){var s=mh(e),l=Nd(r,s);return l}function nn(e,r,s){var l=r.getBoundingClientRect(),g=0,v=0;if("clientX"in e)g=(e.clientX-l.left)/s,v=(e.clientY-l.top)/s;else{var w=e.touches[0];g=(w.clientX-l.left)/s,v=(w.clientY-l.top)/s}return(Number.isNaN(g)||Number.isNaN(v))&&console.error("No mouse or touch offset found"),{x:g,y:v}}var gh=function(e,r,s,l,g){var v=e.transformState.scale,w=e.wrapperComponent,i=e.setup,o=i.maxScale,u=i.minScale,f=i.zoomAnimation,a=i.disablePadding,p=f.size,m=f.disabled;if(!w)throw new Error("Wrapper is not mounted");var y=v+r*s,b=l?!1:!m,n=Mt(Me(y,3),u,o,p,b&&!a);return n},vh=function(e,r){var s=e.previousWheelEvent,l=e.transformState.scale,g=e.setup,v=g.maxScale,w=g.minScale;return s?l<v||l>w||Math.sign(s.deltaY)!==Math.sign(r.deltaY)||s.deltaY>0&&s.deltaY<r.deltaY||s.deltaY<0&&s.deltaY>r.deltaY||Math.sign(s.deltaY)!==Math.sign(r.deltaY):!1},_h=function(e,r){var s=e.setup.pinch,l=s.disabled,g=s.excluded,v=e.isInitialized,w=r.target,i=v&&!l&&w;if(!i)return!1;var o=ts(w,g);return!o},bh=function(e){var r=e.setup.pinch.disabled,s=e.isInitialized,l=e.pinchStartDistance,g=s&&!r&&l;return!!g},xh=function(e,r,s){var l=s.getBoundingClientRect(),g=e.touches,v=Me(g[0].clientX-l.left,5),w=Me(g[0].clientY-l.top,5),i=Me(g[1].clientX-l.left,5),o=Me(g[1].clientY-l.top,5);return{x:(v+i)/2/r,y:(w+o)/2/r}},on=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))},Sh=function(e,r){var s=e.pinchStartScale,l=e.pinchStartDistance,g=e.setup,v=g.maxScale,w=g.minScale,i=g.zoomAnimation,o=g.disablePadding,u=i.size,f=i.disabled;if(!s||l===null||!r)throw new Error("Pinch touches distance was not provided");if(r<0)return e.transformState.scale;var a=r/l,p=a*s;return Mt(Me(p,2),w,v,u,!f&&!o)},yh=160,wh=100,Ch=function(e,r){var s=e.props,l=s.onWheelStart,g=s.onZoomStart;e.wheelStopEventTimer||(Be(e),fe(de(e),r,l),fe(de(e),r,g))},kh=function(e,r){var s=e.props,l=s.onWheel,g=s.onZoom,v=e.contentComponent,w=e.setup,i=e.transformState,o=i.scale,u=w.limitToBounds,f=w.centerZoomedOut,a=w.zoomAnimation,p=w.wheel,m=w.disablePadding,y=w.smooth,b=a.size,n=a.disabled,d=p.step,c=p.smoothStep;if(!v)throw new Error("Component not mounted");r.preventDefault(),r.stopPropagation();var h=ph(r,null),_=y?c*Math.abs(r.deltaY):d,S=gh(e,h,_,!r.ctrlKey);if(o!==S){var k=ct(e,S),E=nn(r,v,o),x=n||b===0||f||m,C=u&&x,T=es(e,E.x,E.y,S,k,C),L=T.x,R=T.y;e.previousWheelEvent=r,e.setTransformState(S,L,R),fe(de(e),r,l),fe(de(e),r,g)}},Eh=function(e,r){var s=e.props,l=s.onWheelStop,g=s.onZoomStop;Bs(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(Zi(e,r.x,r.y),e.wheelAnimationTimer=null)},wh);var v=vh(e,r);v&&(Bs(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,fe(de(e),r,l),fe(de(e),r,g))},yh))},an=function(e){for(var r=0,s=0,l=0;l<2;l+=1)r+=e.touches[l].clientX,s+=e.touches[l].clientY;var g=r/2,v=s/2;return{x:g,y:v}},jh=function(e,r){var s=on(r);e.pinchStartDistance=s,e.lastDistance=s,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var l=an(r);e.pinchLastCenterX=l.x,e.pinchLastCenterY=l.y,Be(e)},Nh=function(e,r){var s=e.contentComponent,l=e.pinchStartDistance,g=e.wrapperComponent,v=e.transformState.scale,w=e.setup,i=w.limitToBounds,o=w.centerZoomedOut,u=w.zoomAnimation,f=w.alignmentAnimation,a=u.disabled,p=u.size;if(!(l===null||!s)){var m=xh(r,v,s);if(!(!Number.isFinite(m.x)||!Number.isFinite(m.y))){var y=on(r),b=Sh(e,y),n=an(r),d=n.x-(e.pinchLastCenterX||0),c=n.y-(e.pinchLastCenterY||0);if(!(b===v&&d===0&&c===0)){e.pinchLastCenterX=n.x,e.pinchLastCenterY=n.y;var h=ct(e,b),_=a||p===0||o,S=i&&_,k=es(e,m.x,m.y,b,h,S),E=k.x,x=k.y;e.pinchMidpoint=m,e.lastDistance=y;var C=f.sizeX,T=f.sizeY,L=et(e,C),R=et(e,T),M=E+d,I=x+c,B=Lt(M,I,h,i,L,R,g),H=B.x,$=B.y;e.setTransformState(b,H,$)}}}},Th=function(e){var r=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,Zi(e,r?.x,r?.y)},ln=function(e,r){var s=e.props.onZoomStop,l=e.setup.doubleClick.animationTime;Bs(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,fe(de(e),r,s)},l)},Ah=function(e,r){var s=e.props,l=s.onZoomStart,g=s.onZoom,v=e.setup.doubleClick,w=v.animationTime,i=v.animationType;fe(de(e),r,l),sn(e,w,i,function(){return fe(de(e),r,g)}),ln(e,r)};function Rh(e,r){return e==="toggle"?r===1?1:-1:e==="zoomOut"?-1:1}function Lh(e,r){var s=e.setup,l=e.doubleClickStopEventTimer,g=e.transformState,v=e.contentComponent,w=g.scale,i=e.props,o=i.onZoomStart,u=i.onZoom,f=s.doubleClick,a=f.disabled,p=f.mode,m=f.step,y=f.animationTime,b=f.animationType;if(!a&&!l){if(p==="reset")return Ah(e,r);if(!v)return console.error("No ContentComponent found");var n=Rh(p,e.transformState.scale),d=en(e,n,m);if(w!==d){fe(de(e),r,o);var c=nn(r,v,w),h=Js(e,d,c.x,c.y);if(!h)return console.error("Error during zoom event. New transformation state was not calculated.");fe(de(e),r,u),st(e,h,y,b),ln(e,r)}}}var Mh=function(e,r){var s=e.isInitialized,l=e.setup,g=e.wrapperComponent,v=l.doubleClick,w=v.disabled,i=v.excluded,o=r.target,u=g?.contains(o),f=s&&o&&u&&!w;if(!f)return!1;var a=ts(o,i);return!a},Dh=(function(){function e(r){var s=this;this.mounted=!0,this.pinchLastCenterX=null,this.pinchLastCenterY=null,this.onChangeCallbacks=new Set,this.onInitCallbacks=new Set,this.wrapperComponent=null,this.contentComponent=null,this.isInitialized=!1,this.bounds=null,this.previousWheelEvent=null,this.wheelStopEventTimer=null,this.wheelAnimationTimer=null,this.isPanning=!1,this.isWheelPanning=!1,this.startCoords=null,this.lastTouch=null,this.distance=null,this.lastDistance=null,this.pinchStartDistance=null,this.pinchStartScale=null,this.pinchMidpoint=null,this.doubleClickStopEventTimer=null,this.velocity=null,this.velocityTime=null,this.lastMousePosition=null,this.animate=!1,this.animation=null,this.maxBounds=null,this.pressedKeys={},this.mount=function(){s.initializeWindowEvents()},this.unmount=function(){s.cleanupWindowEvents()},this.update=function(l){s.props=l,ct(s,s.transformState.scale),s.setup=Br(l)},this.initializeWindowEvents=function(){var l,g,v=bs(),w=(l=s.wrapperComponent)===null||l===void 0?void 0:l.ownerDocument,i=w?.defaultView;(g=s.wrapperComponent)===null||g===void 0||g.addEventListener("wheel",s.onWheelPanning,v),i?.addEventListener("mousedown",s.onPanningStart,v),i?.addEventListener("mousemove",s.onPanning,v),i?.addEventListener("mouseup",s.onPanningStop,v),w?.addEventListener("mouseleave",s.clearPanning,v),i?.addEventListener("keyup",s.setKeyUnPressed,v),i?.addEventListener("keydown",s.setKeyPressed,v)},this.cleanupWindowEvents=function(){var l,g,v=bs(),w=(l=s.wrapperComponent)===null||l===void 0?void 0:l.ownerDocument,i=w?.defaultView;i?.removeEventListener("mousedown",s.onPanningStart,v),i?.removeEventListener("mousemove",s.onPanning,v),i?.removeEventListener("mouseup",s.onPanningStop,v),w?.removeEventListener("mouseleave",s.clearPanning,v),i?.removeEventListener("keyup",s.setKeyUnPressed,v),i?.removeEventListener("keydown",s.setKeyPressed,v),document.removeEventListener("mouseleave",s.clearPanning,v),Be(s),(g=s.observer)===null||g===void 0||g.disconnect()},this.handleInitializeWrapperEvents=function(l){var g=bs();l.addEventListener("wheel",s.onWheelZoom,g),l.addEventListener("dblclick",s.onDoubleClick,g),l.addEventListener("touchstart",s.onTouchPanningStart,g),l.addEventListener("touchmove",s.onTouchPanning,g),l.addEventListener("touchend",s.onTouchPanningStop,g)},this.handleInitialize=function(l,g){var v=!1,w=s.setup.centerOnInit,i=function(o,u){for(var f=0,a=o;f<a.length;f++){var p=a[f];if(p.target===u)return!0}return!1};s.applyTransformation(),s.onInitCallbacks.forEach(function(o){o(de(s))}),s.observer=new ResizeObserver(function(o){if(i(o,l)||i(o,g))if(w&&!v){var u=g.offsetWidth,f=g.offsetHeight;(u>0||f>0)&&(v=!0,s.setCenter())}else Be(s),ct(s,s.transformState.scale),Zs(s,0)}),s.observer.observe(l),s.observer.observe(g)},this.onWheelZoom=function(l){var g=s.setup.disabled;if(!g){var v=fh(s,l);if(v){var w=s.isPressingKeys(s.setup.wheel.activationKeys);w&&(Ch(s,l),kh(s,l),Eh(s,l))}}},this.onWheelPanning=function(l){var g=s.setup,v=g.disabled,w=g.wheel,i=g.panning;if(!(!s.wrapperComponent||!s.contentComponent||v||!w.wheelDisabled||i.disabled||!i.wheelPanning||l.ctrlKey)){l.preventDefault(),l.stopPropagation();var o=s.transformState,u=o.positionX,f=o.positionY,a=u-l.deltaX,p=f-l.deltaY,m=i.lockAxisX?u:a,y=i.lockAxisY?f:p,b=s.setup.alignmentAnimation,n=b.sizeX,d=b.sizeY,c=et(s,n),h=et(s,d);m===u&&y===f||Qi(s,m,y,c,h)}},this.onPanningStart=function(l){var g=s.setup.disabled,v=s.props.onPanningStart;if(!g){var w=Ar(s,l);if(w){var i=s.isPressingKeys(s.setup.panning.activationKeys);i&&(l.button===0&&!s.setup.panning.allowLeftClickPan||l.button===1&&!s.setup.panning.allowMiddleClickPan||l.button===2&&!s.setup.panning.allowRightClickPan||(l.preventDefault(),l.stopPropagation(),Be(s),Mr(s,l),fe(de(s),l,v)))}}},this.onPanning=function(l){var g=s.setup.disabled,v=s.props.onPanning;if(!g){var w=Rr(s);if(w){var i=s.isPressingKeys(s.setup.panning.activationKeys);i&&(l.preventDefault(),l.stopPropagation(),Dr(s,l.clientX,l.clientY),fe(de(s),l,v))}}},this.onPanningStop=function(l){var g=s.props.onPanningStop;s.isPanning&&(sh(s),fe(de(s),l,g))},this.onPinchStart=function(l){var g=s.setup.disabled,v=s.props,w=v.onPinchingStart,i=v.onZoomStart;if(!g){var o=_h(s,l);o&&(jh(s,l),Be(s),fe(de(s),l,w),fe(de(s),l,i))}},this.onPinch=function(l){var g=s.setup.disabled,v=s.props,w=v.onPinching,i=v.onZoom;if(!g){var o=bh(s);o&&(l.preventDefault(),l.stopPropagation(),Nh(s,l),fe(de(s),l,w),fe(de(s),l,i))}},this.onPinchStop=function(l){var g=s.props,v=g.onPinchingStop,w=g.onZoomStop;s.pinchStartScale&&(Th(s),fe(de(s),l,v),fe(de(s),l,w))},this.onTouchPanningStart=function(l){var g=s.setup.disabled,v=s.props.onPanningStart;if(!g){var w=Ar(s,l);if(w){var i=s.lastTouch&&+new Date-s.lastTouch<200&&l.touches.length===1;if(!i){s.lastTouch=+new Date,Be(s);var o=l.touches,u=o.length===1,f=o.length===2;u&&(Be(s),Mr(s,l),fe(de(s),l,v)),f&&s.onPinchStart(l)}}}},this.onTouchPanning=function(l){var g=s.setup.disabled,v=s.props.onPanning;if(s.isPanning&&l.touches.length===1){if(g)return;var w=Rr(s);if(!w)return;l.preventDefault(),l.stopPropagation();var i=l.touches[0];Dr(s,i.clientX,i.clientY),fe(de(s),l,v)}else l.touches.length>1&&s.onPinch(l)},this.onTouchPanningStop=function(l){s.onPanningStop(l),s.onPinchStop(l)},this.onDoubleClick=function(l){var g=s.setup.disabled;if(!g){var v=Mh(s,l);v&&Lh(s,l)}},this.clearPanning=function(l){s.isPanning&&s.onPanningStop(l)},this.setKeyPressed=function(l){s.pressedKeys[l.key]=!0},this.setKeyUnPressed=function(l){s.pressedKeys[l.key]=!1},this.isPressingKeys=function(l){return l.length?!!l.find(function(g){return s.pressedKeys[g]}):!0},this.setTransformState=function(l,g,v){var w=s.props.onTransformed;if(!Number.isNaN(l)&&!Number.isNaN(g)&&!Number.isNaN(v)){l!==s.transformState.scale&&(s.transformState.previousScale=s.transformState.scale,s.transformState.scale=l),s.transformState.positionX=g,s.transformState.positionY=v,s.applyTransformation();var i=de(s);s.onChangeCallbacks.forEach(function(o){return o(i)}),fe(i,{scale:l,positionX:g,positionY:v},w)}else console.error("Detected NaN set state values")},this.setCenter=function(){if(s.wrapperComponent&&s.contentComponent){var l=rn(s.transformState.scale,s.wrapperComponent,s.contentComponent);s.setTransformState(l.scale,l.positionX,l.positionY)}},this.handleTransformStyles=function(l,g,v){return s.props.customTransform?s.props.customTransform(l,g,v):hh(l,g,v)},this.applyTransformation=function(){if(!(!s.mounted||!s.contentComponent)){var l=s.transformState,g=l.scale,v=l.positionX,w=l.positionY,i=s.handleTransformStyles(v,w,g);s.contentComponent.style.transform=i}},this.getContext=function(){return de(s)},this.onChange=function(l){return s.onChangeCallbacks.has(l)||s.onChangeCallbacks.add(l),function(){s.onChangeCallbacks.delete(l)}},this.onInit=function(l){return s.onInitCallbacks.has(l)||s.onInitCallbacks.add(l),function(){s.onInitCallbacks.delete(l)}},this.init=function(l,g){s.cleanupWindowEvents(),s.wrapperComponent=l,s.contentComponent=g,ct(s,s.transformState.scale),s.handleInitializeWrapperEvents(l),s.handleInitialize(l,g),s.initializeWindowEvents(),s.isInitialized=!0;var v=de(s);fe(v,void 0,s.props.onInit)},this.props=r,this.setup=Br(this.props),this.transformState=Ji(this.props)}return e})(),ss=_e.createContext(null),Ph=function(e,r){return typeof e=="function"?e(r):e},Bh=_e.forwardRef(function(e,r){var s=A.useRef(new Dh(e)).current,l=Ph(e.children,Vt(s));return A.useImperativeHandle(r,function(){return Vt(s)},[s]),A.useEffect(function(){s.update(e)},[s,e]),_e.createElement(ss.Provider,{value:s},l)});_e.forwardRef(function(e,r){var s=A.useRef(null),l=A.useContext(ss);return A.useEffect(function(){return l.onChange(function(g){if(s.current){var v=0,w=0;s.current.style.transform=l.handleTransformStyles(v,w,1/g.instance.transformState.scale)}})},[l]),_e.createElement("div",Qe({},e,{ref:uh([s,r])}))});function Oh(e,r){r===void 0&&(r={});var s=r.insertAt;if(!(typeof document>"u")){var l=document.head||document.getElementsByTagName("head")[0],g=document.createElement("style");g.type="text/css",s==="top"&&l.firstChild?l.insertBefore(g,l.firstChild):l.appendChild(g),g.styleSheet?g.styleSheet.cssText=e:g.appendChild(document.createTextNode(e))}}var Ih=`.transform-component-module_wrapper__SPB86 {
29
+ `},Tr=qc(Vc)(Hi),Gc={config:Xc},Qc=function(){for(var i=arguments.length,s=new Array(i),l=0;l<i;l++)s[l]=arguments[l];return function(g){return s.reduceRight(function(v,w){return w(v)},g)}};function zi(e,i){return Object.keys(i).forEach(function(s){i[s]instanceof Object&&e[s]&&Object.assign(i[s],zi(e[s],i[s]))}),Er(Er({},e),i)}var Zc={type:"cancelation",msg:"operation is manually canceled"};function ps(e){var i=!1,s=new Promise(function(l,g){e.then(function(v){return i?g(Zc):l(v)}),e.catch(g)});return s.cancel=function(){return i=!0},s}var Jc=["monaco"],ed=$c.create({config:Uc,isInitialized:!1,resolve:null,reject:null,monaco:null}),Wi=kc(ed,2),Rt=Wi[0],Jt=Wi[1];function td(e){var i=Gc.config(e),s=i.monaco,l=wc(i,Jc);Jt(function(g){return{config:zi(g.config,l),monaco:s}})}function sd(){var e=Rt(function(i){var s=i.monaco,l=i.isInitialized,g=i.resolve;return{monaco:s,isInitialized:l,resolve:g}});if(!e.isInitialized){if(Jt({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),ps(gs);if(window.monaco&&window.monaco.editor)return $i(window.monaco),e.resolve(window.monaco),ps(gs);Qc(rd,nd)(od)}return ps(gs)}function rd(e){return document.body.appendChild(e)}function id(e){var i=document.createElement("script");return e&&(i.src=e),i}function nd(e){var i=Rt(function(l){var g=l.config,v=l.reject;return{config:g,reject:v}}),s=id("".concat(i.config.paths.vs,"/loader.js"));return s.onload=function(){return e()},s.onerror=i.reject,s}function od(){var e=Rt(function(s){var l=s.config,g=s.resolve,v=s.reject;return{config:l,resolve:g,reject:v}}),i=window.require;i.config(e.config),i(["vs/editor/editor.main"],function(s){var l=s.m||s;$i(l),e.resolve(l)},function(s){e.reject(s)})}function $i(e){Rt().monaco||Jt({monaco:e})}function ad(){return Rt(function(e){var i=e.monaco;return i})}var gs=new Promise(function(e,i){return Jt({resolve:e,reject:i})}),Ui={config:td,init:sd,__getMonacoInstance:ad},ld={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},vs=ld,cd={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},dd=cd;function hd({children:e}){return _e.createElement("div",{style:dd.container},e)}var ud=hd,fd=ud;function md({width:e,height:i,isEditorReady:s,loading:l,_ref:g,className:v,wrapperProps:w}){return _e.createElement("section",{style:{...vs.wrapper,width:e,height:i},...w},!s&&_e.createElement(fd,null,l),_e.createElement("div",{ref:g,style:{...vs.fullWidth,...!s&&vs.hide},className:v}))}var pd=md,qi=A.memo(pd);function gd(e){A.useEffect(e,[])}var Ki=gd;function vd(e,i,s=!0){let l=A.useRef(!0);A.useEffect(l.current||!s?()=>{l.current=!1}:e,i)}var Te=vd;function wt(){}function gt(e,i,s,l){return _d(e,l)||bd(e,i,s,l)}function _d(e,i){return e.editor.getModel(Xi(e,i))}function bd(e,i,s,l){return e.editor.createModel(i,s,l?Xi(e,l):void 0)}function Xi(e,i){return e.Uri.parse(i)}function xd({original:e,modified:i,language:s,originalLanguage:l,modifiedLanguage:g,originalModelPath:v,modifiedModelPath:w,keepCurrentOriginalModel:r=!1,keepCurrentModifiedModel:o=!1,theme:u="light",loading:f="Loading...",options:a={},height:p="100%",width:m="100%",className:y,wrapperProps:b={},beforeMount:n=wt,onMount:d=wt}){let[c,h]=A.useState(!1),[_,S]=A.useState(!0),k=A.useRef(null),E=A.useRef(null),x=A.useRef(null),C=A.useRef(d),T=A.useRef(n),L=A.useRef(!1);Ki(()=>{let B=Ui.init();return B.then(H=>(E.current=H)&&S(!1)).catch(H=>H?.type!=="cancelation"&&console.error("Monaco initialization: error:",H)),()=>k.current?I():B.cancel()}),Te(()=>{if(k.current&&E.current){let B=k.current.getOriginalEditor(),H=gt(E.current,e||"",l||s||"text",v||"");H!==B.getModel()&&B.setModel(H)}},[v],c),Te(()=>{if(k.current&&E.current){let B=k.current.getModifiedEditor(),H=gt(E.current,i||"",g||s||"text",w||"");H!==B.getModel()&&B.setModel(H)}},[w],c),Te(()=>{let B=k.current.getModifiedEditor();B.getOption(E.current.editor.EditorOption.readOnly)?B.setValue(i||""):i!==B.getValue()&&(B.executeEdits("",[{range:B.getModel().getFullModelRange(),text:i||"",forceMoveMarkers:!0}]),B.pushUndoStop())},[i],c),Te(()=>{k.current?.getModel()?.original.setValue(e||"")},[e],c),Te(()=>{let{original:B,modified:H}=k.current.getModel();E.current.editor.setModelLanguage(B,l||s||"text"),E.current.editor.setModelLanguage(H,g||s||"text")},[s,l,g],c),Te(()=>{E.current?.editor.setTheme(u)},[u],c),Te(()=>{k.current?.updateOptions(a)},[a],c);let R=A.useCallback(()=>{if(!E.current)return;T.current(E.current);let B=gt(E.current,e||"",l||s||"text",v||""),H=gt(E.current,i||"",g||s||"text",w||"");k.current?.setModel({original:B,modified:H})},[s,i,g,e,l,v,w]),M=A.useCallback(()=>{!L.current&&x.current&&(k.current=E.current.editor.createDiffEditor(x.current,{automaticLayout:!0,...a}),R(),E.current?.editor.setTheme(u),h(!0),L.current=!0)},[a,u,R]);A.useEffect(()=>{c&&C.current(k.current,E.current)},[c]),A.useEffect(()=>{!_&&!c&&M()},[_,c,M]);function I(){let B=k.current?.getModel();r||B?.original?.dispose(),o||B?.modified?.dispose(),k.current?.dispose()}return _e.createElement(qi,{width:m,height:p,isEditorReady:c,loading:f,_ref:x,className:y,wrapperProps:b})}var Sd=xd;A.memo(Sd);function yd(e){let i=A.useRef();return A.useEffect(()=>{i.current=e},[e]),i.current}var wd=yd,Ft=new Map;function Cd({defaultValue:e,defaultLanguage:i,defaultPath:s,value:l,language:g,path:v,theme:w="light",line:r,loading:o="Loading...",options:u={},overrideServices:f={},saveViewState:a=!0,keepCurrentModel:p=!1,width:m="100%",height:y="100%",className:b,wrapperProps:n={},beforeMount:d=wt,onMount:c=wt,onChange:h,onValidate:_=wt}){let[S,k]=A.useState(!1),[E,x]=A.useState(!0),C=A.useRef(null),T=A.useRef(null),L=A.useRef(null),R=A.useRef(c),M=A.useRef(d),I=A.useRef(),B=A.useRef(l),H=wd(v),$=A.useRef(!1),N=A.useRef(!1);Ki(()=>{let O=Ui.init();return O.then(q=>(C.current=q)&&x(!1)).catch(q=>q?.type!=="cancelation"&&console.error("Monaco initialization: error:",q)),()=>T.current?D():O.cancel()}),Te(()=>{let O=gt(C.current,e||l||"",i||g||"",v||s||"");O!==T.current?.getModel()&&(a&&Ft.set(H,T.current?.saveViewState()),T.current?.setModel(O),a&&T.current?.restoreViewState(Ft.get(v)))},[v],S),Te(()=>{T.current?.updateOptions(u)},[u],S),Te(()=>{!T.current||l===void 0||(T.current.getOption(C.current.editor.EditorOption.readOnly)?T.current.setValue(l):l!==T.current.getValue()&&(N.current=!0,T.current.executeEdits("",[{range:T.current.getModel().getFullModelRange(),text:l,forceMoveMarkers:!0}]),T.current.pushUndoStop(),N.current=!1))},[l],S),Te(()=>{let O=T.current?.getModel();O&&g&&C.current?.editor.setModelLanguage(O,g)},[g],S),Te(()=>{r!==void 0&&T.current?.revealLine(r)},[r],S),Te(()=>{C.current?.editor.setTheme(w)},[w],S);let P=A.useCallback(()=>{if(!(!L.current||!C.current)&&!$.current){M.current(C.current);let O=v||s,q=gt(C.current,l||e||"",i||g||"",O||"");T.current=C.current?.editor.create(L.current,{model:q,automaticLayout:!0,...u},f),a&&T.current.restoreViewState(Ft.get(O)),C.current.editor.setTheme(w),r!==void 0&&T.current.revealLine(r),k(!0),$.current=!0}},[e,i,s,l,g,v,u,f,a,w,r]);A.useEffect(()=>{S&&R.current(T.current,C.current)},[S]),A.useEffect(()=>{!E&&!S&&P()},[E,S,P]),B.current=l,A.useEffect(()=>{S&&h&&(I.current?.dispose(),I.current=T.current?.onDidChangeModelContent(O=>{N.current||h(T.current.getValue(),O)}))},[S,h]),A.useEffect(()=>{if(S){let O=C.current.editor.onDidChangeMarkers(q=>{let K=T.current.getModel()?.uri;if(K&&q.find(U=>U.path===K.path)){let U=C.current.editor.getModelMarkers({resource:K});_?.(U)}});return()=>{O?.dispose()}}return()=>{}},[S,_]);function D(){I.current?.dispose(),p?a&&Ft.set(v,T.current.saveViewState()):T.current.getModel()?.dispose(),T.current.dispose()}return _e.createElement(qi,{width:m,height:y,isEditorReady:S,loading:o,_ref:L,className:b,wrapperProps:n})}var kd=Cd,Ed=A.memo(kd),jd=Ed,Me=function(e,i){return Number(e.toFixed(i))},Nd=function(e,i){return typeof e=="number"?e:i},fe=function(e,i,s){s&&typeof s=="function"&&s(e,i)},Td=function(e){return-Math.cos(e*Math.PI)/2+.5},Ad=function(e){return e},Rd=function(e){return e*e},Ld=function(e){return e*(2-e)},Md=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},Dd=function(e){return e*e*e},Pd=function(e){return--e*e*e+1},Bd=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},Od=function(e){return e*e*e*e},Id=function(e){return 1- --e*e*e*e},Fd=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},Hd=function(e){return e*e*e*e*e},zd=function(e){return 1+--e*e*e*e*e},Wd=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},Yi={easeOut:Td,linear:Ad,easeInQuad:Rd,easeOutQuad:Ld,easeInOutQuad:Md,easeInCubic:Dd,easeOutCubic:Pd,easeInOutCubic:Bd,easeInQuart:Od,easeOutQuart:Id,easeInOutQuart:Fd,easeInQuint:Hd,easeOutQuint:zd,easeInOutQuint:Wd},Vi=function(e){typeof e=="number"&&cancelAnimationFrame(e)},Be=function(e){e.mounted&&(Vi(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function Gi(e,i,s,l){if(e.mounted){var g=new Date().getTime(),v=1;Be(e),e.animation=function(){if(!e.mounted)return Vi(e.animation);var w=new Date().getTime()-g,r=w/s,o=Yi[i],u=o(r);w>=s?(l(v),e.animation=null):e.animation&&(l(u),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function $d(e){var i=e.scale,s=e.positionX,l=e.positionY;return!(Number.isNaN(i)||Number.isNaN(s)||Number.isNaN(l))}function st(e,i,s,l){var g=$d(i);if(!(!e.mounted||!g)){var v=e.setTransformState,w=e.transformState,r=w.scale,o=w.positionX,u=w.positionY,f=i.scale-r,a=i.positionX-o,p=i.positionY-u;s===0?v(i.scale,i.positionX,i.positionY):Gi(e,l,s,function(m){var y=r+f*m,b=o+a*m,n=u+p*m;v(y,b,n)})}}function Ud(e,i,s){var l=e.offsetWidth,g=e.offsetHeight,v=i.offsetWidth,w=i.offsetHeight,r=v*s,o=w*s,u=l-r,f=g-o;return{wrapperWidth:l,wrapperHeight:g,newContentWidth:r,newDiffWidth:u,newContentHeight:o,newDiffHeight:f}}var qd=function(e,i,s,l,g,v,w){var r=e>i?s*(w?1:.5):0,o=l>g?v*(w?1:.5):0,u=e-i-r,f=r,a=l-g-o,p=o;return{minPositionX:u,maxPositionX:f,minPositionY:a,maxPositionY:p}},Qs=function(e,i){var s=e.wrapperComponent,l=e.contentComponent,g=e.setup.centerZoomedOut;if(!s||!l)throw new Error("Components are not mounted");var v=Ud(s,l,i),w=v.wrapperWidth,r=v.wrapperHeight,o=v.newContentWidth,u=v.newDiffWidth,f=v.newContentHeight,a=v.newDiffHeight,p=qd(w,o,u,r,f,a,!!g);return p},Ms=function(e,i,s,l){return l?e<i?Me(i,2):e>s?Me(s,2):Me(e,2):Me(e,2)},ct=function(e,i){var s=Qs(e,i);return e.bounds=s,s};function Lt(e,i,s,l,g,v,w){var r=s.minPositionX,o=s.minPositionY,u=s.maxPositionX,f=s.maxPositionY,a=0,p=0;w&&(a=g,p=v);var m=Ms(e,r-a,u+a,l),y=Ms(i,o-p,f+p,l);return{x:m,y}}function es(e,i,s,l,g,v){var w=e.transformState,r=w.scale,o=w.positionX,u=w.positionY,f=l-r;if(typeof i!="number"||typeof s!="number")return console.error("Mouse X and Y position were not provided!"),{x:o,y:u};var a=o-i*f,p=u-s*f,m=Lt(a,p,g,v,0,0,null);return m}function Mt(e,i,s,l,g){var v=g?l:0,w=i-v;return!Number.isNaN(s)&&e>=s?s:!Number.isNaN(i)&&e<=w?w:e}var Ar=function(e,i){var s=e.setup.panning.excluded,l=e.isInitialized,g=e.wrapperComponent,v=i.target,w="shadowRoot"in v&&"composedPath"in i,r=w?i.composedPath().some(function(f){return f instanceof Element?g?.contains(f):!1}):g?.contains(v),o=l&&v&&r;if(!o)return!1;var u=ts(v,s);return!u},Rr=function(e){var i=e.isInitialized,s=e.isPanning,l=e.setup,g=l.panning.disabled,v=i&&s&&!g;return!!v},Kd=function(e,i){var s=e.transformState,l=s.positionX,g=s.positionY;e.isPanning=!0;var v=i.clientX,w=i.clientY;e.startCoords={x:v-l,y:w-g}},Xd=function(e,i){var s=i.touches,l=e.transformState,g=l.positionX,v=l.positionY;e.isPanning=!0;var w=s.length===1;if(w){var r=s[0].clientX,o=s[0].clientY;e.startCoords={x:r-g,y:o-v}}};function Yd(e){var i=e.transformState,s=i.positionX,l=i.positionY,g=i.scale,v=e.setup,w=v.disabled,r=v.limitToBounds,o=v.centerZoomedOut,u=e.wrapperComponent;if(!(w||!u||!e.bounds)){var f=e.bounds,a=f.maxPositionX,p=f.minPositionX,m=f.maxPositionY,y=f.minPositionY,b=s>a||s<p,n=l>m||l<y,d=s>a?u.offsetWidth:e.setup.minPositionX||0,c=l>m?u.offsetHeight:e.setup.minPositionY||0,h=es(e,d,c,g,e.bounds,r||o),_=h.x,S=h.y;return{scale:g,positionX:b?_:s,positionY:n?S:l}}}function Qi(e,i,s,l,g){var v=e.setup.limitToBounds,w=e.wrapperComponent,r=e.bounds,o=e.transformState,u=o.scale,f=o.positionX,a=o.positionY;if(!(w===null||r===null||i===f&&s===a)){var p=Lt(i,s,r,v,l,g,w),m=p.x,y=p.y;e.setTransformState(u,m,y)}}var Vd=function(e,i,s){var l=e.startCoords,g=e.transformState,v=e.setup.panning,w=v.lockAxisX,r=v.lockAxisY,o=g.positionX,u=g.positionY;if(!l)return{x:o,y:u};var f=i-l.x,a=s-l.y,p=w?o:f,m=r?u:a;return{x:p,y:m}},et=function(e,i){var s=e.setup,l=e.transformState,g=l.scale,v=s.minScale,w=s.disablePadding;return i>0&&g>=v&&!w?i:0},Gd=function(e){var i=e.mounted,s=e.setup,l=s.disabled,g=s.velocityAnimation,v=e.transformState.scale,w=g.disabled,r=!w||v>1||!l||i;return!!r},Qd=function(e){var i=e.mounted,s=e.velocity,l=e.bounds,g=e.setup,v=g.disabled,w=g.velocityAnimation,r=e.transformState.scale,o=w.disabled,u=!o||r>1||!v||i;return!(!u||!s||!l)};function Zd(e,i){var s=e.setup.velocityAnimation,l=s.equalToMove,g=s.animationTime,v=s.sensitivity;return l?g*i*v:g}function Lr(e,i,s,l,g,v,w,r,o,u){if(g){if(i>w&&s>w){var f=w+(e-w)*u;return f>o?o:f<w?w:f}if(i<v&&s<v){var f=v+(e-v)*u;return f<r?r:f>v?v:f}}return l?i:Ms(e,v,w,g)}function Jd(e,i){var s=1;return i?Math.min(s,e.offsetWidth/window.innerWidth):s}function eh(e,i){var s=Gd(e);if(s){var l=e.lastMousePosition,g=e.velocityTime,v=e.setup,w=e.wrapperComponent,r=v.velocityAnimation.equalToMove,o=Date.now();if(l&&g&&w){var u=Jd(w,r),f=i.x-l.x,a=i.y-l.y,p=f/u,m=a/u,y=o-g,b=f*f+a*a,n=Math.sqrt(b)/y;e.velocity={velocityX:p,velocityY:m,total:n}}e.lastMousePosition=i,e.velocityTime=o}}function th(e){var i=e.velocity,s=e.bounds,l=e.setup,g=e.wrapperComponent,v=Qd(e);if(!(!v||!i||!s||!g)){var w=i.velocityX,r=i.velocityY,o=i.total,u=s.maxPositionX,f=s.minPositionX,a=s.maxPositionY,p=s.minPositionY,m=l.limitToBounds,y=l.alignmentAnimation,b=l.zoomAnimation,n=l.panning,d=n.lockAxisY,c=n.lockAxisX,h=b.animationType,_=y.sizeX,S=y.sizeY,k=y.velocityAlignmentTime,E=k,x=Zd(e,o),C=Math.max(x,E),T=et(e,_),L=et(e,S),R=T*g.offsetWidth/100,M=L*g.offsetHeight/100,I=u+R,B=f-R,H=a+M,$=p-M,N=e.transformState,P=new Date().getTime();Gi(e,h,C,function(D){var O=e.transformState,q=O.scale,K=O.positionX,U=O.positionY,z=new Date().getTime()-P,W=z/E,j=Yi[y.animationType],F=1-j(Math.min(1,W)),X=1-D,Y=K+w*X,ee=U+r*X,G=Lr(Y,N.positionX,K,c,m,f,u,B,I,F),Z=Lr(ee,N.positionY,U,d,m,p,a,$,H,F);(K!==Y||U!==ee)&&e.setTransformState(q,G,Z)})}}function Mr(e,i){var s=e.transformState.scale;Be(e),ct(e,s),window.TouchEvent!==void 0&&i instanceof TouchEvent?Xd(e,i):Kd(e,i)}function Zs(e,i){var s=e.transformState.scale,l=e.setup,g=l.minScale,v=l.alignmentAnimation,w=v.disabled,r=v.sizeX,o=v.sizeY,u=v.animationTime,f=v.animationType,a=w||s<g||!r&&!o;if(!a){var p=Yd(e);p&&st(e,p,i??u,f)}}function Dr(e,i,s){var l=e.startCoords,g=e.setup,v=g.alignmentAnimation,w=v.sizeX,r=v.sizeY;if(l){var o=Vd(e,i,s),u=o.x,f=o.y,a=et(e,w),p=et(e,r);eh(e,{x:u,y:f}),Qi(e,u,f,a,p)}}function sh(e){if(e.isPanning){var i=e.setup.panning.velocityDisabled,s=e.velocity,l=e.wrapperComponent,g=e.contentComponent;e.isPanning=!1,e.animate=!1,e.animation=null;var v=l?.getBoundingClientRect(),w=g?.getBoundingClientRect(),r=v?.width||0,o=v?.height||0,u=w?.width||0,f=w?.height||0,a=r<u||o<f,p=!i&&s&&s?.total>.1&&a;p?th(e):Zs(e)}}function Js(e,i,s,l){var g=e.setup,v=g.minScale,w=g.maxScale,r=g.limitToBounds,o=Mt(Me(i,2),v,w,0,!1),u=ct(e,o),f=es(e,s,l,o,u,r),a=f.x,p=f.y;return{scale:o,positionX:a,positionY:p}}function Zi(e,i,s){var l=e.transformState.scale,g=e.wrapperComponent,v=e.setup,w=v.minScale,r=v.limitToBounds,o=v.zoomAnimation,u=o.disabled,f=o.animationTime,a=o.animationType,p=u||l>=w;if((l>=1||r)&&Zs(e),!(p||!g||!e.mounted)){var m=i||g.offsetWidth/2,y=s||g.offsetHeight/2,b=Js(e,w,m,y);b&&st(e,b,f,a)}}var Qe=function(){return Qe=Object.assign||function(i){for(var s,l=1,g=arguments.length;l<g;l++){s=arguments[l];for(var v in s)Object.prototype.hasOwnProperty.call(s,v)&&(i[v]=s[v])}return i},Qe.apply(this,arguments)};function Pr(e,i,s){for(var l=0,g=i.length,v;l<g;l++)(v||!(l in i))&&(v||(v=Array.prototype.slice.call(i,0,l)),v[l]=i[l]);return e.concat(v||Array.prototype.slice.call(i))}var Ht={scale:1,positionX:0,positionY:0},xt={disabled:!1,minPositionX:null,maxPositionX:null,minPositionY:null,maxPositionY:null,minScale:1,maxScale:8,limitToBounds:!0,centerZoomedOut:!1,centerOnInit:!1,disablePadding:!1,smooth:!0,wheel:{step:.2,disabled:!1,smoothStep:.001,wheelDisabled:!1,touchPadDisabled:!1,activationKeys:[],excluded:[]},panning:{disabled:!1,velocityDisabled:!1,lockAxisX:!1,lockAxisY:!1,allowLeftClickPan:!0,allowMiddleClickPan:!0,allowRightClickPan:!0,wheelPanning:!1,activationKeys:[],excluded:[]},pinch:{step:5,disabled:!1,excluded:[]},doubleClick:{disabled:!1,step:.7,mode:"zoomIn",animationType:"easeOut",animationTime:200,excluded:[]},zoomAnimation:{disabled:!1,size:.4,animationTime:200,animationType:"easeOut"},alignmentAnimation:{disabled:!1,sizeX:100,sizeY:100,animationTime:200,velocityAlignmentTime:400,animationType:"easeOut"},velocityAnimation:{disabled:!1,sensitivity:1,animationTime:400,animationType:"easeOut",equalToMove:!0}},Ds={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},Ji=function(e){var i,s,l,g;return{previousScale:(i=e.initialScale)!==null&&i!==void 0?i:Ht.scale,scale:(s=e.initialScale)!==null&&s!==void 0?s:Ht.scale,positionX:(l=e.initialPositionX)!==null&&l!==void 0?l:Ht.positionX,positionY:(g=e.initialPositionY)!==null&&g!==void 0?g:Ht.positionY}},Br=function(e){var i=Qe({},xt);return Object.keys(e).forEach(function(s){var l=typeof e[s]<"u",g=typeof xt[s]<"u";if(g&&l){var v=Object.prototype.toString.call(xt[s]),w=v==="[object Object]",r=v==="[object Array]";w?i[s]=Qe(Qe({},xt[s]),e[s]):r?i[s]=Pr(Pr([],xt[s],!0),e[s]):i[s]=e[s]}}),i},en=function(e,i,s){var l=e.transformState.scale,g=e.wrapperComponent,v=e.setup,w=v.maxScale,r=v.minScale,o=v.zoomAnimation,u=v.smooth,f=o.size;if(!g)throw new Error("Wrapper is not mounted");var a=u?l*Math.exp(i*s):l+i*s,p=Mt(Me(a,3),r,w,f,!1);return p};function tn(e,i,s,l,g){var v=e.wrapperComponent,w=e.transformState,r=w.scale,o=w.positionX,u=w.positionY;if(!v)return console.error("No WrapperComponent found");var f=v.offsetWidth,a=v.offsetHeight,p=(f/2-o)/r,m=(a/2-u)/r,y=en(e,i,s),b=Js(e,y,p,m);if(!b)return console.error("Error during zoom event. New transformation state was not calculated.");st(e,b,l,g)}function sn(e,i,s,l){var g=e.setup,v=e.wrapperComponent,w=g.limitToBounds,r=Ji(e.props),o=e.transformState,u=o.scale,f=o.positionX,a=o.positionY;if(v){var p=Qs(e,r.scale),m=Lt(r.positionX,r.positionY,p,w,0,0,v),y={scale:r.scale,positionX:m.x,positionY:m.y};u===r.scale&&f===r.positionX&&a===r.positionY||(l?.(),st(e,y,i,s))}}function rh(e,i,s,l){var g=e.getBoundingClientRect(),v=i.getBoundingClientRect(),w=s.getBoundingClientRect(),r=v.x*l.scale,o=v.y*l.scale;return{x:(g.x-w.x+r)/l.scale,y:(g.y-w.y+o)/l.scale}}function ih(e,i,s){var l=e.wrapperComponent,g=e.contentComponent,v=e.transformState,w=e.setup,r=w.limitToBounds,o=w.minScale,u=w.maxScale;if(!l||!g)return v;var f=l.getBoundingClientRect(),a=i.getBoundingClientRect(),p=rh(i,l,g,v),m=p.x,y=p.y,b=a.width/v.scale,n=a.height/v.scale,d=l.offsetWidth/b,c=l.offsetHeight/n,h=Mt(s||Math.min(d,c),o,u,0,!1),_=(f.width-b*h)/2,S=(f.height-n*h)/2,k=(f.left-m)*h+_,E=(f.top-y)*h+S,x=Qs(e,h),C=Lt(k,E,x,r,0,0,l),T=C.x,L=C.y;return{positionX:T,positionY:L,scale:h}}var nh=function(e){return function(i,s,l){i===void 0&&(i=.5),s===void 0&&(s=300),l===void 0&&(l="easeOut"),tn(e,1,i,s,l)}},oh=function(e){return function(i,s,l){i===void 0&&(i=.5),s===void 0&&(s=300),l===void 0&&(l="easeOut"),tn(e,-1,i,s,l)}},ah=function(e){return function(i,s,l,g,v){g===void 0&&(g=300),v===void 0&&(v="easeOut");var w=e.transformState,r=w.positionX,o=w.positionY,u=w.scale,f=e.wrapperComponent,a=e.contentComponent,p=e.setup.disabled;if(!(p||!f||!a)){var m={positionX:Number.isNaN(i)?r:i,positionY:Number.isNaN(s)?o:s,scale:Number.isNaN(l)?u:l};st(e,m,g,v)}}},lh=function(e){return function(i,s){i===void 0&&(i=200),s===void 0&&(s="easeOut"),sn(e,i,s)}},ch=function(e){return function(i,s,l){s===void 0&&(s=200),l===void 0&&(l="easeOut");var g=e.transformState,v=e.wrapperComponent,w=e.contentComponent;if(v&&w){var r=rn(i||g.scale,v,w);st(e,r,s,l)}}},dh=function(e){return function(i,s,l,g){l===void 0&&(l=600),g===void 0&&(g="easeOut"),Be(e);var v=e.wrapperComponent,w=typeof i=="string"?document.getElementById(i):i;if(v&&w&&v.contains(w)){var r=ih(e,w,s);st(e,r,l,g)}}},Vt=function(e){return{instance:e,zoomIn:nh(e),zoomOut:oh(e),setTransform:ah(e),resetTransform:lh(e),centerView:ch(e),zoomToElement:dh(e)}},Ps=function(e){return{instance:e,state:e.transformState}},de=function(e){var i={};return Object.assign(i,Ps(e)),Object.assign(i,Vt(e)),i},_s=!1;function bs(){try{var e={get passive(){return _s=!0,!1}};return e}catch{return _s=!1,_s}}var zt=".".concat(Ds.wrapperClass),ts=function(e,i){return i.some(function(s){return e.matches("".concat(zt," ").concat(s,", ").concat(zt," .").concat(s,", ").concat(zt," ").concat(s," *, ").concat(zt," .").concat(s," *"))})},Bs=function(e){e&&clearTimeout(e)},hh=function(e,i,s){return"translate(".concat(e,"px, ").concat(i,"px) scale(").concat(s,")")},rn=function(e,i,s){var l=s.offsetWidth*e,g=s.offsetHeight*e,v=(i.offsetWidth-l)/2,w=(i.offsetHeight-g)/2;return{scale:e,positionX:v,positionY:w}};function uh(e){return function(i){e.forEach(function(s){typeof s=="function"?s(i):s!=null&&(s.current=i)})}}var fh=function(e,i){var s=e.setup.wheel,l=s.disabled,g=s.wheelDisabled,v=s.touchPadDisabled,w=s.excluded,r=e.isInitialized,o=e.isPanning,u=i.target,f=r&&!o&&!l&&u;if(!f||g&&!i.ctrlKey||v&&i.ctrlKey)return!1;var a=ts(u,w);return!a},mh=function(e){return e?e.deltaY<0?1:-1:0};function ph(e,i){var s=mh(e),l=Nd(i,s);return l}function nn(e,i,s){var l=i.getBoundingClientRect(),g=0,v=0;if("clientX"in e)g=(e.clientX-l.left)/s,v=(e.clientY-l.top)/s;else{var w=e.touches[0];g=(w.clientX-l.left)/s,v=(w.clientY-l.top)/s}return(Number.isNaN(g)||Number.isNaN(v))&&console.error("No mouse or touch offset found"),{x:g,y:v}}var gh=function(e,i,s,l,g){var v=e.transformState.scale,w=e.wrapperComponent,r=e.setup,o=r.maxScale,u=r.minScale,f=r.zoomAnimation,a=r.disablePadding,p=f.size,m=f.disabled;if(!w)throw new Error("Wrapper is not mounted");var y=v+i*s,b=l?!1:!m,n=Mt(Me(y,3),u,o,p,b&&!a);return n},vh=function(e,i){var s=e.previousWheelEvent,l=e.transformState.scale,g=e.setup,v=g.maxScale,w=g.minScale;return s?l<v||l>w||Math.sign(s.deltaY)!==Math.sign(i.deltaY)||s.deltaY>0&&s.deltaY<i.deltaY||s.deltaY<0&&s.deltaY>i.deltaY||Math.sign(s.deltaY)!==Math.sign(i.deltaY):!1},_h=function(e,i){var s=e.setup.pinch,l=s.disabled,g=s.excluded,v=e.isInitialized,w=i.target,r=v&&!l&&w;if(!r)return!1;var o=ts(w,g);return!o},bh=function(e){var i=e.setup.pinch.disabled,s=e.isInitialized,l=e.pinchStartDistance,g=s&&!i&&l;return!!g},xh=function(e,i,s){var l=s.getBoundingClientRect(),g=e.touches,v=Me(g[0].clientX-l.left,5),w=Me(g[0].clientY-l.top,5),r=Me(g[1].clientX-l.left,5),o=Me(g[1].clientY-l.top,5);return{x:(v+r)/2/i,y:(w+o)/2/i}},on=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))},Sh=function(e,i){var s=e.pinchStartScale,l=e.pinchStartDistance,g=e.setup,v=g.maxScale,w=g.minScale,r=g.zoomAnimation,o=g.disablePadding,u=r.size,f=r.disabled;if(!s||l===null||!i)throw new Error("Pinch touches distance was not provided");if(i<0)return e.transformState.scale;var a=i/l,p=a*s;return Mt(Me(p,2),w,v,u,!f&&!o)},yh=160,wh=100,Ch=function(e,i){var s=e.props,l=s.onWheelStart,g=s.onZoomStart;e.wheelStopEventTimer||(Be(e),fe(de(e),i,l),fe(de(e),i,g))},kh=function(e,i){var s=e.props,l=s.onWheel,g=s.onZoom,v=e.contentComponent,w=e.setup,r=e.transformState,o=r.scale,u=w.limitToBounds,f=w.centerZoomedOut,a=w.zoomAnimation,p=w.wheel,m=w.disablePadding,y=w.smooth,b=a.size,n=a.disabled,d=p.step,c=p.smoothStep;if(!v)throw new Error("Component not mounted");i.preventDefault(),i.stopPropagation();var h=ph(i,null),_=y?c*Math.abs(i.deltaY):d,S=gh(e,h,_,!i.ctrlKey);if(o!==S){var k=ct(e,S),E=nn(i,v,o),x=n||b===0||f||m,C=u&&x,T=es(e,E.x,E.y,S,k,C),L=T.x,R=T.y;e.previousWheelEvent=i,e.setTransformState(S,L,R),fe(de(e),i,l),fe(de(e),i,g)}},Eh=function(e,i){var s=e.props,l=s.onWheelStop,g=s.onZoomStop;Bs(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(Zi(e,i.x,i.y),e.wheelAnimationTimer=null)},wh);var v=vh(e,i);v&&(Bs(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,fe(de(e),i,l),fe(de(e),i,g))},yh))},an=function(e){for(var i=0,s=0,l=0;l<2;l+=1)i+=e.touches[l].clientX,s+=e.touches[l].clientY;var g=i/2,v=s/2;return{x:g,y:v}},jh=function(e,i){var s=on(i);e.pinchStartDistance=s,e.lastDistance=s,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var l=an(i);e.pinchLastCenterX=l.x,e.pinchLastCenterY=l.y,Be(e)},Nh=function(e,i){var s=e.contentComponent,l=e.pinchStartDistance,g=e.wrapperComponent,v=e.transformState.scale,w=e.setup,r=w.limitToBounds,o=w.centerZoomedOut,u=w.zoomAnimation,f=w.alignmentAnimation,a=u.disabled,p=u.size;if(!(l===null||!s)){var m=xh(i,v,s);if(!(!Number.isFinite(m.x)||!Number.isFinite(m.y))){var y=on(i),b=Sh(e,y),n=an(i),d=n.x-(e.pinchLastCenterX||0),c=n.y-(e.pinchLastCenterY||0);if(!(b===v&&d===0&&c===0)){e.pinchLastCenterX=n.x,e.pinchLastCenterY=n.y;var h=ct(e,b),_=a||p===0||o,S=r&&_,k=es(e,m.x,m.y,b,h,S),E=k.x,x=k.y;e.pinchMidpoint=m,e.lastDistance=y;var C=f.sizeX,T=f.sizeY,L=et(e,C),R=et(e,T),M=E+d,I=x+c,B=Lt(M,I,h,r,L,R,g),H=B.x,$=B.y;e.setTransformState(b,H,$)}}}},Th=function(e){var i=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,Zi(e,i?.x,i?.y)},ln=function(e,i){var s=e.props.onZoomStop,l=e.setup.doubleClick.animationTime;Bs(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,fe(de(e),i,s)},l)},Ah=function(e,i){var s=e.props,l=s.onZoomStart,g=s.onZoom,v=e.setup.doubleClick,w=v.animationTime,r=v.animationType;fe(de(e),i,l),sn(e,w,r,function(){return fe(de(e),i,g)}),ln(e,i)};function Rh(e,i){return e==="toggle"?i===1?1:-1:e==="zoomOut"?-1:1}function Lh(e,i){var s=e.setup,l=e.doubleClickStopEventTimer,g=e.transformState,v=e.contentComponent,w=g.scale,r=e.props,o=r.onZoomStart,u=r.onZoom,f=s.doubleClick,a=f.disabled,p=f.mode,m=f.step,y=f.animationTime,b=f.animationType;if(!a&&!l){if(p==="reset")return Ah(e,i);if(!v)return console.error("No ContentComponent found");var n=Rh(p,e.transformState.scale),d=en(e,n,m);if(w!==d){fe(de(e),i,o);var c=nn(i,v,w),h=Js(e,d,c.x,c.y);if(!h)return console.error("Error during zoom event. New transformation state was not calculated.");fe(de(e),i,u),st(e,h,y,b),ln(e,i)}}}var Mh=function(e,i){var s=e.isInitialized,l=e.setup,g=e.wrapperComponent,v=l.doubleClick,w=v.disabled,r=v.excluded,o=i.target,u=g?.contains(o),f=s&&o&&u&&!w;if(!f)return!1;var a=ts(o,r);return!a},Dh=(function(){function e(i){var s=this;this.mounted=!0,this.pinchLastCenterX=null,this.pinchLastCenterY=null,this.onChangeCallbacks=new Set,this.onInitCallbacks=new Set,this.wrapperComponent=null,this.contentComponent=null,this.isInitialized=!1,this.bounds=null,this.previousWheelEvent=null,this.wheelStopEventTimer=null,this.wheelAnimationTimer=null,this.isPanning=!1,this.isWheelPanning=!1,this.startCoords=null,this.lastTouch=null,this.distance=null,this.lastDistance=null,this.pinchStartDistance=null,this.pinchStartScale=null,this.pinchMidpoint=null,this.doubleClickStopEventTimer=null,this.velocity=null,this.velocityTime=null,this.lastMousePosition=null,this.animate=!1,this.animation=null,this.maxBounds=null,this.pressedKeys={},this.mount=function(){s.initializeWindowEvents()},this.unmount=function(){s.cleanupWindowEvents()},this.update=function(l){s.props=l,ct(s,s.transformState.scale),s.setup=Br(l)},this.initializeWindowEvents=function(){var l,g,v=bs(),w=(l=s.wrapperComponent)===null||l===void 0?void 0:l.ownerDocument,r=w?.defaultView;(g=s.wrapperComponent)===null||g===void 0||g.addEventListener("wheel",s.onWheelPanning,v),r?.addEventListener("mousedown",s.onPanningStart,v),r?.addEventListener("mousemove",s.onPanning,v),r?.addEventListener("mouseup",s.onPanningStop,v),w?.addEventListener("mouseleave",s.clearPanning,v),r?.addEventListener("keyup",s.setKeyUnPressed,v),r?.addEventListener("keydown",s.setKeyPressed,v)},this.cleanupWindowEvents=function(){var l,g,v=bs(),w=(l=s.wrapperComponent)===null||l===void 0?void 0:l.ownerDocument,r=w?.defaultView;r?.removeEventListener("mousedown",s.onPanningStart,v),r?.removeEventListener("mousemove",s.onPanning,v),r?.removeEventListener("mouseup",s.onPanningStop,v),w?.removeEventListener("mouseleave",s.clearPanning,v),r?.removeEventListener("keyup",s.setKeyUnPressed,v),r?.removeEventListener("keydown",s.setKeyPressed,v),document.removeEventListener("mouseleave",s.clearPanning,v),Be(s),(g=s.observer)===null||g===void 0||g.disconnect()},this.handleInitializeWrapperEvents=function(l){var g=bs();l.addEventListener("wheel",s.onWheelZoom,g),l.addEventListener("dblclick",s.onDoubleClick,g),l.addEventListener("touchstart",s.onTouchPanningStart,g),l.addEventListener("touchmove",s.onTouchPanning,g),l.addEventListener("touchend",s.onTouchPanningStop,g)},this.handleInitialize=function(l,g){var v=!1,w=s.setup.centerOnInit,r=function(o,u){for(var f=0,a=o;f<a.length;f++){var p=a[f];if(p.target===u)return!0}return!1};s.applyTransformation(),s.onInitCallbacks.forEach(function(o){o(de(s))}),s.observer=new ResizeObserver(function(o){if(r(o,l)||r(o,g))if(w&&!v){var u=g.offsetWidth,f=g.offsetHeight;(u>0||f>0)&&(v=!0,s.setCenter())}else Be(s),ct(s,s.transformState.scale),Zs(s,0)}),s.observer.observe(l),s.observer.observe(g)},this.onWheelZoom=function(l){var g=s.setup.disabled;if(!g){var v=fh(s,l);if(v){var w=s.isPressingKeys(s.setup.wheel.activationKeys);w&&(Ch(s,l),kh(s,l),Eh(s,l))}}},this.onWheelPanning=function(l){var g=s.setup,v=g.disabled,w=g.wheel,r=g.panning;if(!(!s.wrapperComponent||!s.contentComponent||v||!w.wheelDisabled||r.disabled||!r.wheelPanning||l.ctrlKey)){l.preventDefault(),l.stopPropagation();var o=s.transformState,u=o.positionX,f=o.positionY,a=u-l.deltaX,p=f-l.deltaY,m=r.lockAxisX?u:a,y=r.lockAxisY?f:p,b=s.setup.alignmentAnimation,n=b.sizeX,d=b.sizeY,c=et(s,n),h=et(s,d);m===u&&y===f||Qi(s,m,y,c,h)}},this.onPanningStart=function(l){var g=s.setup.disabled,v=s.props.onPanningStart;if(!g){var w=Ar(s,l);if(w){var r=s.isPressingKeys(s.setup.panning.activationKeys);r&&(l.button===0&&!s.setup.panning.allowLeftClickPan||l.button===1&&!s.setup.panning.allowMiddleClickPan||l.button===2&&!s.setup.panning.allowRightClickPan||(l.preventDefault(),l.stopPropagation(),Be(s),Mr(s,l),fe(de(s),l,v)))}}},this.onPanning=function(l){var g=s.setup.disabled,v=s.props.onPanning;if(!g){var w=Rr(s);if(w){var r=s.isPressingKeys(s.setup.panning.activationKeys);r&&(l.preventDefault(),l.stopPropagation(),Dr(s,l.clientX,l.clientY),fe(de(s),l,v))}}},this.onPanningStop=function(l){var g=s.props.onPanningStop;s.isPanning&&(sh(s),fe(de(s),l,g))},this.onPinchStart=function(l){var g=s.setup.disabled,v=s.props,w=v.onPinchingStart,r=v.onZoomStart;if(!g){var o=_h(s,l);o&&(jh(s,l),Be(s),fe(de(s),l,w),fe(de(s),l,r))}},this.onPinch=function(l){var g=s.setup.disabled,v=s.props,w=v.onPinching,r=v.onZoom;if(!g){var o=bh(s);o&&(l.preventDefault(),l.stopPropagation(),Nh(s,l),fe(de(s),l,w),fe(de(s),l,r))}},this.onPinchStop=function(l){var g=s.props,v=g.onPinchingStop,w=g.onZoomStop;s.pinchStartScale&&(Th(s),fe(de(s),l,v),fe(de(s),l,w))},this.onTouchPanningStart=function(l){var g=s.setup.disabled,v=s.props.onPanningStart;if(!g){var w=Ar(s,l);if(w){var r=s.lastTouch&&+new Date-s.lastTouch<200&&l.touches.length===1;if(!r){s.lastTouch=+new Date,Be(s);var o=l.touches,u=o.length===1,f=o.length===2;u&&(Be(s),Mr(s,l),fe(de(s),l,v)),f&&s.onPinchStart(l)}}}},this.onTouchPanning=function(l){var g=s.setup.disabled,v=s.props.onPanning;if(s.isPanning&&l.touches.length===1){if(g)return;var w=Rr(s);if(!w)return;l.preventDefault(),l.stopPropagation();var r=l.touches[0];Dr(s,r.clientX,r.clientY),fe(de(s),l,v)}else l.touches.length>1&&s.onPinch(l)},this.onTouchPanningStop=function(l){s.onPanningStop(l),s.onPinchStop(l)},this.onDoubleClick=function(l){var g=s.setup.disabled;if(!g){var v=Mh(s,l);v&&Lh(s,l)}},this.clearPanning=function(l){s.isPanning&&s.onPanningStop(l)},this.setKeyPressed=function(l){s.pressedKeys[l.key]=!0},this.setKeyUnPressed=function(l){s.pressedKeys[l.key]=!1},this.isPressingKeys=function(l){return l.length?!!l.find(function(g){return s.pressedKeys[g]}):!0},this.setTransformState=function(l,g,v){var w=s.props.onTransformed;if(!Number.isNaN(l)&&!Number.isNaN(g)&&!Number.isNaN(v)){l!==s.transformState.scale&&(s.transformState.previousScale=s.transformState.scale,s.transformState.scale=l),s.transformState.positionX=g,s.transformState.positionY=v,s.applyTransformation();var r=de(s);s.onChangeCallbacks.forEach(function(o){return o(r)}),fe(r,{scale:l,positionX:g,positionY:v},w)}else console.error("Detected NaN set state values")},this.setCenter=function(){if(s.wrapperComponent&&s.contentComponent){var l=rn(s.transformState.scale,s.wrapperComponent,s.contentComponent);s.setTransformState(l.scale,l.positionX,l.positionY)}},this.handleTransformStyles=function(l,g,v){return s.props.customTransform?s.props.customTransform(l,g,v):hh(l,g,v)},this.applyTransformation=function(){if(!(!s.mounted||!s.contentComponent)){var l=s.transformState,g=l.scale,v=l.positionX,w=l.positionY,r=s.handleTransformStyles(v,w,g);s.contentComponent.style.transform=r}},this.getContext=function(){return de(s)},this.onChange=function(l){return s.onChangeCallbacks.has(l)||s.onChangeCallbacks.add(l),function(){s.onChangeCallbacks.delete(l)}},this.onInit=function(l){return s.onInitCallbacks.has(l)||s.onInitCallbacks.add(l),function(){s.onInitCallbacks.delete(l)}},this.init=function(l,g){s.cleanupWindowEvents(),s.wrapperComponent=l,s.contentComponent=g,ct(s,s.transformState.scale),s.handleInitializeWrapperEvents(l),s.handleInitialize(l,g),s.initializeWindowEvents(),s.isInitialized=!0;var v=de(s);fe(v,void 0,s.props.onInit)},this.props=i,this.setup=Br(this.props),this.transformState=Ji(this.props)}return e})(),ss=_e.createContext(null),Ph=function(e,i){return typeof e=="function"?e(i):e},Bh=_e.forwardRef(function(e,i){var s=A.useRef(new Dh(e)).current,l=Ph(e.children,Vt(s));return A.useImperativeHandle(i,function(){return Vt(s)},[s]),A.useEffect(function(){s.update(e)},[s,e]),_e.createElement(ss.Provider,{value:s},l)});_e.forwardRef(function(e,i){var s=A.useRef(null),l=A.useContext(ss);return A.useEffect(function(){return l.onChange(function(g){if(s.current){var v=0,w=0;s.current.style.transform=l.handleTransformStyles(v,w,1/g.instance.transformState.scale)}})},[l]),_e.createElement("div",Qe({},e,{ref:uh([s,i])}))});function Oh(e,i){i===void 0&&(i={});var s=i.insertAt;if(!(typeof document>"u")){var l=document.head||document.getElementsByTagName("head")[0],g=document.createElement("style");g.type="text/css",s==="top"&&l.firstChild?l.insertBefore(g,l.firstChild):l.appendChild(g),g.styleSheet?g.styleSheet.cssText=e:g.appendChild(document.createTextNode(e))}}var Ih=`.transform-component-module_wrapper__SPB86 {
30
30
  position: relative;
31
31
  width: -moz-fit-content;
32
32
  width: fit-content;
@@ -57,14 +57,14 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
57
57
  .transform-component-module_content__FBWxo img {
58
58
  pointer-events: none;
59
59
  }
60
- `,Or={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};Oh(Ih);var Fh=function(e){var r=e.children,s=e.wrapperClass,l=s===void 0?"":s,g=e.contentClass,v=g===void 0?"":g,w=e.wrapperStyle,i=e.contentStyle,o=e.wrapperProps,u=o===void 0?{}:o,f=e.contentProps,a=f===void 0?{}:f,p=A.useContext(ss),m=p.init,y=p.cleanupWindowEvents,b=A.useRef(null),n=A.useRef(null);return A.useEffect(function(){var d=b.current,c=n.current;return d!==null&&c!==null&&m&&m?.(d,c),function(){y?.()}},[]),_e.createElement("div",Qe({},u,{ref:b,className:"".concat(Ds.wrapperClass," ").concat(Or.wrapper," ").concat(l),style:w}),_e.createElement("div",Qe({},a,{ref:n,className:"".concat(Ds.contentClass," ").concat(Or.content," ").concat(v),style:i}),r))},cn=function(){var e=A.useContext(ss);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},Hh=function(){var e=cn();return Vt(e)};function zh(e){var r=cn(),s=A.useState(e(Ps(r))),l=s[0],g=s[1];return A.useEffect(function(){var v=!0,w=r.onChange(function(i){v&&g(e(Ps(i.instance)))});return function(){w(),v=!1}},[e,r]),l}function Wh(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 $h(e,r){return Ee({queryKey:ie.files.tree(e||"",r),queryFn:()=>oe.get("/files/tree",{params:{workingDir:e||"",path:r}}),enabled:!!e})}function Uh(e,r){return Ee({queryKey:ie.files.content(e||"",r||""),queryFn:()=>oe.get("/files/read",{params:{workingDir:e||"",path:r||""}}),enabled:!!e&&!!r})}function qh(e){const r=De();return A.useCallback(()=>{e&&r.invalidateQueries({queryKey:["files","tree",e]})},[r,e])}function Kh(){const e=De();return Ct({mutationFn:r=>oe.post("/files/write",r),onSuccess:(r,s)=>{const l=ie.files.content(s.workingDir,s.path),g=e.getQueryData(l);e.setQueryData(l,{content:s.content,language:g?.language||Wh(s.path)})}})}function Xh(e,r){return e==="/"?`/${r}`:`${e}/${r}`}function Yh(e,r){return e==="/"?r:`${e.slice(1)}/${r}`}const Ir=({depth:e,active:r,onClick:s,leftIcon:l,rightIcon:g,label:v})=>t.jsxs("button",{type:"button",onClick:s,"aria-current":r||void 0,className:Q("w-full flex items-center gap-2 rounded-md px-2 py-1 text-left text-xs transition-colors outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/60",r?"bg-foreground/[0.06] font-medium text-foreground":"text-foreground/90 hover:bg-accent"),style:{paddingLeft:8+e*14},children:[t.jsx("span",{className:"shrink-0",children:g}),t.jsx("span",{className:"shrink-0 text-muted-foreground",children:l}),t.jsx("span",{className:"truncate",children:v})]}),dn=({workingDir:e,path:r,depth:s,expanded:l,toggleDir:g,onFileSelect:v,selectedFilePath:w})=>{const{t:i}=re(),{data:o,isLoading:u,isError:f}=$h(e,r),a=A.useMemo(()=>o?.items??[],[o?.items]);return u?t.jsx("div",{className:"text-xs text-muted-foreground px-2 py-1",style:{paddingLeft:8+s*14},children:i("Loading...")}):f?t.jsx("div",{className:"text-xs text-destructive-ink px-2 py-1",style:{paddingLeft:8+s*14},children:i("Failed to load")}):t.jsx("div",{className:"space-y-0.5",children:a.map(p=>{if(p.type==="directory"){const b=Xh(r,p.name),n=l.has(b);return t.jsxs("div",{children:[t.jsx(Ir,{depth:s,onClick:()=>g(b),rightIcon:n?t.jsx(Ke,{size:14,className:"text-muted-foreground/70"}):t.jsx(Je,{size:14,className:"text-muted-foreground/70"}),leftIcon:n?t.jsx(fi,{size:14}):t.jsx($s,{size:14}),label:p.name}),n&&t.jsx(dn,{workingDir:e,path:b,depth:s+1,expanded:l,toggleDir:g,onFileSelect:v,selectedFilePath:w})]},b)}const m=Yh(r,p.name),y=w===m;return t.jsx(Ir,{depth:s,active:y,onClick:()=>v(m),rightIcon:t.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:t.jsx(Lo,{name:p.name}),label:p.name},m)})})},Vh=({workingDir:e,className:r,onFileSelect:s,selectedFilePath:l,onCollapse:g})=>{const{t:v}=re(),[w,i]=A.useState(()=>new Set),o=qh(e),u=A.useCallback(f=>{i(a=>{const p=new Set(a);return p.has(f)?p.delete(f):p.add(f),p})},[]);return t.jsxs("div",{className:Q("h-full flex flex-col",r),children:[t.jsxs("div",{className:"px-3 py-2 border-b border-border bg-muted/40 flex items-center justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:v("Files")}),e?t.jsx("div",{title:e,className:"truncate font-mono text-[11px] text-muted-foreground",children:e}):t.jsx("div",{className:"truncate text-xs text-muted-foreground",children:v("No working directory")})]}),t.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e&&t.jsx($e,{size:"xs",label:v("Refresh file tree"),onClick:o,children:t.jsx(_t,{})}),g&&t.jsx($e,{size:"xs",label:v("Collapse file tree"),onClick:g,children:t.jsx(ka,{})})]})]}),t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin p-2",children:e?t.jsx(dn,{workingDir:e,path:"/",depth:0,expanded:w,toggleDir:u,onFileSelect:s,selectedFilePath:l}):t.jsx("div",{className:"text-xs text-muted-foreground px-2 py-2",children:v("No workspace selected.")})})]})},Gh=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function Qh(e){const r=e.split(".").pop()?.toLowerCase();return r?Gh.has(r):!1}function Zh(e,r){const s=zs(),l=new URLSearchParams({workingDir:e,path:r});return`${s}/files/image?${l.toString()}`}const Jh=({filePath:e})=>{const{t:r}=re(),{zoomIn:s,zoomOut:l,centerView:g}=Hh(),v=zh(i=>i.state.scale),w=Math.round(v*100);return t.jsxs("div",{className:"flex items-center gap-1 px-3 py-1.5 border-b border-border bg-muted/40 shrink-0",children:[t.jsx($e,{size:"xs",label:r("Zoom out"),onClick:()=>l(.5),children:t.jsx(Ia,{})}),t.jsxs(ce,{variant:"ghost",size:"xs",className:"min-w-10 tabular-nums",onClick:()=>g(1),title:r("Reset zoom"),children:[w,"%"]}),t.jsx($e,{size:"xs",label:r("Zoom in"),onClick:()=>s(.5),children:t.jsx(Ba,{})}),t.jsx($e,{size:"xs",label:r("Fit to view"),className:"ml-1",onClick:()=>g(1),children:t.jsx(Sa,{})}),t.jsx("span",{title:e,className:"ml-2 truncate font-mono text-[11px] text-muted-foreground",children:e})]})},eu=({workingDir:e,filePath:r})=>{const{t:s}=re(),[l,g]=A.useState(!1),v=Zh(e,r);return l?t.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:s("Failed to load image.")}):t.jsx(Bh,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx(Jh,{filePath:r}),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(Fh,{wrapperStyle:{width:"100%",height:"100%"},contentStyle:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx("img",{src:v,alt:r,className:"max-w-full max-h-full object-contain rounded shadow-raised",draggable:!1,onError:()=>g(!0)})})})]})})};function tu(e){const r=e.split("/");return r[r.length-1]||e}function su(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 ru=({active:e,name:r,isDirty:s,onClick:l,onClose:g})=>{const{t:v}=re();return t.jsxs("button",{type:"button",onClick:l,className:Q("group flex items-center gap-2 px-3 py-2 rounded-t-md border-t border-x -mb-px min-w-[120px] max-w-[240px] outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/60",e?"bg-background border-border text-foreground":"bg-foreground/[0.03] border-transparent text-muted-foreground hover:text-foreground hover:bg-foreground/[0.05]"),children:[t.jsx("span",{className:Q("w-2 h-2 rounded-full",s?"bg-warning":"bg-transparent")}),t.jsx("span",{className:"truncate flex-1 text-left text-xs",children:r}),t.jsx("span",{onClick:g,className:"opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100 pointer-coarse:opacity-100 p-0.5 hover:bg-foreground/[0.08] rounded transition-all shrink-0","aria-label":v("Close tab"),title:v("Close"),children:t.jsx(tt,{size:12})})]})},iu=_e.forwardRef(function({workingDir:r,className:s,readOnly:l=!1},g){const{t:v}=re(),[w,i]=A.useState([]),[o,u]=A.useState(null),[f,a]=A.useState(!1),[p,m]=A.useState(!1),[y,b]=A.useState(0),[n,d]=A.useState(null),c=A.useRef(null),h=Kh();A.useEffect(()=>{let U=!1;return Un(async()=>{const{preloadMonaco:z}=await import("./monaco-Mn1xgio_.js").then(W=>W.m);return{preloadMonaco:z}},__vite__mapDeps([0,1,2,3])).then(({preloadMonaco:z})=>z()).then(()=>{U||a(!0)}).catch(()=>{U||m(!0)}),()=>{U=!0}},[]);const[_,S]=A.useState(280),[k,E]=A.useState(!1),[x,C]=A.useState(!1),T=A.useRef(280),L=A.useCallback(()=>{E(U=>(U?S(T.current):T.current=_,!U))},[_]),R=A.useCallback(U=>{U.preventDefault(),C(!0);const z=U.clientX,W=_,j=X=>{const Y=X.clientX-z,ee=Math.min(480,Math.max(160,W+Y));S(ee)},F=()=>{C(!1),document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",F)};document.addEventListener("mousemove",j),document.addEventListener("mouseup",F)},[_]);A.useEffect(()=>{i([]),u(null),d(null)},[r]);const M=A.useMemo(()=>w.find(U=>U.path===o)||null,[w,o]),{data:I,isFetching:B,isError:H,error:$}=Uh(r,M?.isImage?null:o);A.useEffect(()=>{!o||!I||i(U=>U.map(z=>z.path!==o||z.isDirty||z.loaded?z:{...z,language:I.language||z.language,content:I.content,savedContent:I.content,isDirty:!1,loaded:!0}))},[o,I]);const N=A.useCallback((U,z,W)=>{i(j=>{if(j.find(Y=>Y.path===U))return j;const X=Qh(U);return[...j,{path:U,name:tu(U),language:su(U),content:"",savedContent:"",isDirty:!1,loaded:X,isImage:X}]}),u(U),d(z?{path:U,line:z,column:W}:null)},[]);_e.useImperativeHandle(g,()=>({openFile:N}),[N]);const P=A.useCallback(U=>{i(z=>{const W=z.filter(j=>j.path!==U);return u(j=>j!==U?j:W.length?W[W.length-1].path:null),W})},[]),D=A.useCallback(U=>{i(z=>z.map(W=>{if(W.path!==o)return W;const j=U!==W.savedContent;return{...W,content:U,isDirty:j}}))},[o]),O=A.useCallback(async()=>{l||!r||!M||(await h.mutateAsync({workingDir:r,path:M.path,content:M.content}),i(U=>U.map(z=>z.path===M.path?{...z,savedContent:z.content,isDirty:!1,loaded:!0}:z)))},[M,l,h,r]),q=A.useRef(()=>{});A.useEffect(()=>{q.current=()=>{O().catch(()=>{})}},[O]),A.useEffect(()=>{const U=z=>{l||(z.metaKey||z.ctrlKey)&&z.key.toLowerCase()==="s"&&(z.preventDefault(),q.current())};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[l]);const K=A.useCallback((U,z)=>{c.current=U,b(W=>W+1),U.addCommand(z.KeyMod.CtrlCmd|z.KeyCode.KeyS,()=>{q.current()})},[]);return A.useEffect(()=>{if(!n||n.path!==o||!M?.loaded)return;const U=c.current,z=U?.getModel();if(!U||!z)return;const W=Math.min(n.line,z.getLineCount()),j=Math.min(n.column??1,z.getLineMaxColumn(W)),F={lineNumber:W,column:j};U.setPosition(F),U.revealPositionInCenter(F),U.focus(),d(null)},[o,M?.loaded,y,n]),t.jsxs("div",{className:Q("flex h-full overflow-hidden bg-background",s),style:x?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsx("div",{className:"border-r border-border bg-background shrink-0 overflow-hidden relative",style:{width:k?36:_,transition:x?"none":"width 0.15s ease"},children:k?t.jsx("div",{className:"h-full flex items-start pt-2 justify-center",children:t.jsx($e,{size:"sm",label:v("Expand file tree"),onClick:L,children:t.jsx(ja,{className:"size-4"})})}):t.jsx(t.Fragment,{children:t.jsx(Vh,{workingDir:r,onFileSelect:N,selectedFilePath:M?.path||null,onCollapse:L},r||"no-working-dir")})}),!k&&t.jsx("div",{onMouseDown:R,className:Q("w-1 shrink-0 cursor-col-resize transition-colors",x?"bg-ring/40":"bg-transparent hover:bg-border")}),t.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1 px-2 pt-2 border-b border-border bg-muted overflow-x-auto shrink-0",children:[w.length===0?t.jsx("div",{className:"px-2 pb-2 text-xs text-muted-foreground",children:v("No open files")}):w.map(U=>t.jsx(ru,{active:U.path===o,name:U.name,isDirty:U.isDirty,onClick:()=>u(U.path),onClose:z=>{z.stopPropagation(),P(U.path)}},U.path)),t.jsxs("div",{className:"ml-auto flex items-center gap-2 pb-2 pr-1",children:[l&&t.jsx("span",{className:"text-xs text-muted-foreground",children:v("Read-only")}),h.isPending&&t.jsxs("span",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[t.jsx(xe,{}),v("Saving")]}),M?.isDirty&&!h.isPending&&t.jsx("span",{className:"text-xs text-warning-ink",children:v("Unsaved")})]})]}),t.jsx("div",{className:"flex-1 min-h-0 relative",children:r?M?M.isImage?t.jsx(eu,{workingDir:r,filePath:M.path}):p?t.jsx("div",{className:"h-full flex items-center justify-center text-destructive-ink text-sm",children:v("Failed to load editor.")}):f?t.jsxs(t.Fragment,{children:[t.jsx(jd,{path:M.path,value:M.content,language:M.language,theme:"vs-light",height:"100%",onChange:l?void 0:U=>D(U??""),onMount:K,options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",automaticLayout:!0,readOnly:l}}),B&&!M.loaded&&t.jsx("div",{className:"absolute inset-0 bg-background/60 flex items-center justify-center",children:t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[t.jsx(xe,{}),v("Loading file...")]})}),H&&t.jsx("div",{className:"absolute bottom-2 left-2 right-2 rounded-md bg-background shadow-raised",children:t.jsxs(Oe,{tone:"danger",size:"sm",children:[v("Failed to load file"),$ instanceof Error?`: ${$.message}`:""]})})]}):t.jsxs("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:[t.jsx(xe,{className:"mr-2"}),v("Loading editor...")]}):t.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:v("Select a file from the tree to open.")}):t.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:v("No workspace selected.")})})]})]})});function nu(e,r={}){const s=Qt(g=>g.visibleContext),l=Si(e,s);return Ee({queryKey:ie.git.changes(e||""),queryFn:()=>oe.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e&&(r.enabled??!0),refetchInterval:l,refetchIntervalInBackground:!1,refetchOnWindowFocus:l?"always":!1,refetchOnReconnect:l?"always":!1})}function ou(e,r,s){const l=Qt(v=>v.visibleContext),g=Si(e,l);return Ee({queryKey:ie.git.diff(e||"",r||"",s),queryFn:()=>oe.get("/git/diff",{params:{workingDir:e||"",path:r||"",type:s}}),enabled:!!e&&!!r,refetchInterval:g,refetchIntervalInBackground:!1,refetchOnWindowFocus:g?"always":!1,refetchOnReconnect:g?"always":!1})}function hn(e,r){return Ee({queryKey:ie.git.commitFiles(e||"",r||""),queryFn:()=>oe.get("/git/commit-files",{params:{workingDir:e||"",hash:r||""}}),enabled:!!e&&!!r})}function un(e,r,s){return Ee({queryKey:ie.git.commitDiff(e||"",r||"",s||""),queryFn:()=>oe.get("/git/commit-diff",{params:{workingDir:e||"",hash:r||"",path:s||""}}),enabled:!!e&&!!r&&!!s})}const au=new Set(["STARTING","RUNNING","STOPPING"]);function fn(e){return au.has(e.runtimeState)||e.runtimeInstanceId!==null}function mn(e){return e instanceof Ze&&e.status===409&&e.details.code==="WORKSPACE_HAS_ACTIVE_SERVICE"}const Fr="h-6 min-w-0 truncate rounded-md bg-foreground/[0.05] px-2 font-mono text-xs leading-6 text-foreground/85";function lu({from:e,to:r}){return t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{title:e,className:Fr,children:e}),t.jsx(ji,{size:14,className:"shrink-0 text-muted-foreground/70"}),t.jsx("span",{title:r,className:Fr,children:r})]})}function cu({services:e,isLoading:r,isError:s}){const{t:l}=re();return r?t.jsx(xe,{size:"xs",label:l("正在检查后台服务..."),className:"text-xs"}):e.length>0?t.jsxs(Oe,{tone:"warning",title:l("合并前将停止 {count} 个后台服务",{count:e.length}),children:[t.jsx("p",{className:"break-all font-mono text-xs",children:e.map(g=>g.name).join(", ")}),t.jsx("p",{className:"mt-1",children:l("停止后不会自动恢复。")})]}):s?t.jsx("p",{className:"text-xs text-warning-ink",role:"status",children:l("无法检查后台服务状态,提交时会再次确认。")}):null}const du={INVALID_BASE_BRANCH:"Choose an existing local branch different from the workspace branch.",BASE_BRANCH_UNRELATED:"The selected branch has no shared commit history with this workspace.",WORKSPACE_BASE_BRANCH_BUSY:"Wait for the Agent to finish or stop it before changing the base branch.",WORKSPACE_GIT_OPERATION_IN_PROGRESS:"Finish or abort the current Git operation before changing the base branch.",WORKSPACE_BASE_BRANCH_CHANGED:"The workspace changed. Refresh and select the base branch again.",INVALID_WORKSPACE_STATE:"Only active workspaces can change base branch. Refresh the list.",WORKSPACE_BASE_BRANCH_MANAGED:"TeamRun member base branches are managed by their parent workspace."};function pn(e){return e.isOpen?t.jsx(hu,{...e},e.workspaceId):null}function hu({isOpen:e,onClose:r,onBaseBranchSaved:s,projectId:l,workspaceId:g,branchName:v,targetBranch:w,commitMessage:i,isPending:o,canMerge:u,activeServices:f,isCheckingServices:a,serviceCheckFailed:p,error:m,onConfirm:y}){const{t:b}=re(),n=A.useId(),d=Uo(l),c=qo(),h=d.data?.workspaces.find(N=>N.id===g),_=h?.baseBranch||d.data?.mainBranch||w,[S,k]=A.useState(null),E=S??_,x=d.data?.branches.filter(N=>N!==v)??[],C=!!h&&E!==_,T=o||c.isPending,L=d.isPending||d.isFetching||d.isError,R=c.error instanceof Ze?String(c.error.details.code):"",[M,I]=A.useState(null),B=M??i??"",H=()=>{T||r()},$=async()=>{if(!(!h||!C))try{await c.mutateAsync({id:g,baseBranch:E,expectedBaseBranch:h.baseBranch}),ke.success(b("Workspace base branch saved. Review the changes before merging.")),r(),s?.()}catch{}};return t.jsx(At,{isOpen:e,onClose:H,title:b("提交变更"),className:"max-w-md",action:t.jsxs(t.Fragment,{children:[t.jsx(ce,{variant:"ghost",onClick:H,disabled:T,children:b("取消")}),t.jsx(ce,{variant:"primary",onClick:()=>y(B.trim()||void 0,f.length>0),disabled:T||a||L||C||!u,loading:o||a,children:o||a?a?b("正在检查后台服务..."):f.length>0?b("正在停止服务并提交..."):b("正在提交..."):t.jsxs(t.Fragment,{children:[t.jsx(Us,{}),f.length>0?b("停止服务并提交"):b("确认提交")]})})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsx(lu,{from:v,to:h?_:w}),d.isPending?t.jsx("p",{className:"text-xs text-muted-foreground",children:b("Loading...")}):d.isError?t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{role:"alert",className:"text-xs text-destructive-ink",children:b("Could not load branches. Refresh to try again.")}),t.jsx(ce,{size:"sm",onClick:()=>{d.refetch()},children:b("Refresh")})]}):h&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:n,className:"block text-[13px] font-medium text-foreground",children:b("Base branch for this workspace")}),t.jsx(Ko,{id:n,label:b("Base branch for this workspace"),value:E,branches:x,disabled:T,isRefreshing:d.isFetching,onOpen:()=>{d.refetch()},onChange:N=>{k(N),c.reset()}}),t.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:b("Changing this base branch updates the comparison, update and merge target for this workspace only. Save and review the changes before merging.")}),C&&t.jsx(ce,{variant:"primary",size:"sm",onClick:()=>{$()},disabled:T||L||!x.includes(E),children:c.isPending?b("Saving"):b("Save base branch and review changes")}),c.isError&&t.jsx("p",{role:"alert",className:"text-xs text-destructive-ink",children:b(du[R]??"Could not save the base branch. Refresh and try again.")})]}),!u&&t.jsx("p",{className:"text-xs text-muted-foreground",children:b("Review the changes and sync the base branch before submitting.")}),t.jsx(mi,{label:b("提交消息"),description:t.jsxs(t.Fragment,{children:[b("建议以 feat、fix、docs、refactor、chore 开头,保持提交记录清晰。feat 新增功能,fix 修复问题,docs 文档更新,refactor 代码重构,chore 日常维护。"),!B.trim()&&t.jsx("span",{className:"mt-1 block",children:b("留空将使用默认消息")})]}),children:t.jsx(pi,{value:B,onChange:N=>I(N.target.value),placeholder:b("请描述本次修改的内容"),minRows:4,className:"font-mono"})}),t.jsx(cu,{services:f,isLoading:a,isError:p}),m&&t.jsx(Oe,{tone:"danger",children:m})]})})}function at(e,r){const s=e[r];return typeof s=="string"&&s.length>0?s:void 0}function gn(e){if(!(e instanceof Ze)||e.status!==409)return;const r=e.details;if(r.code!=="MERGE_CONFLICT"||r.conflictOp!==kt.REBASE&&r.conflictOp!==kt.MERGE||!Array.isArray(r.conflictedFiles)||!r.conflictedFiles.every(l=>typeof l=="string"))return;const s=r.mergeStrategy==="squash"||r.mergeStrategy==="no_ff"?r.mergeStrategy:void 0;return{conflictOp:r.conflictOp,conflictedFiles:r.conflictedFiles,mergeAborted:typeof r.mergeAborted=="boolean"?r.mergeAborted:void 0,mergeStrategy:s,sourceBranch:at(r,"sourceBranch"),targetBranch:at(r,"targetBranch"),sourceWorktreePath:at(r,"sourceWorktreePath"),targetWorktreePath:at(r,"targetWorktreePath"),sourceWorkspaceId:at(r,"sourceWorkspaceId"),targetWorkspaceId:at(r,"targetWorkspaceId"),resolutionContextToken:at(r,"resolutionContextToken")}}function Hr(e,r,s,l){const g=gn(e);if(g){s(g);return}l(e instanceof Error?e.message:r)}function uu({projectId:e,workspaceId:r,branchName:s,targetBranch:l,commitMessage:g,committedFileCount:v,onRefreshCommitMessage:w,onConflict:i,onResolveConflicts:o}){const{t:u}=re(),{data:f,isLoading:a}=Xo(r),p=yi(),m=wi(),y=Ci(),[b,n]=A.useState(!1),[d,c]=A.useState(null),h=Gs(r,b),_=(h.data??[]).filter(fn);if(A.useEffect(()=>{b&&w?.()},[b,w]),a||!f)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground border-b border-border/60",children:[t.jsx(xe,{}),t.jsx("span",{className:"text-xs",children:u("正在检查工作区状态...")})]});const S=f.conflictedFiles.length>0,k=f.operation!=="idle",E=f.hasUncommittedChanges||f.untrackedCount>0,x=f.uncommittedCount+f.untrackedCount,C=!S&&!k&&!E,T=!E,L=f.operation==="idle"&&f.ahead===0&&f.behind===0&&!E&&!S,R=()=>{c(null),p.mutate(r,{onError:H=>{Hr(H,u("更新失败,请稍后重试"),$=>i($),c)}})},M=()=>{c(null),n(!0)},I=(H,$)=>{c(null),m.mutate({id:r,commitMessage:H,stopActiveServices:$},{onSuccess:()=>n(!1),onError:N=>{if(mn(N)){c(u("后台服务仍在运行,请确认停止服务后再提交。"));return}Hr(N,u("提交失败,请稍后重试"),P=>{n(!1),i(P)},c)}})},B=()=>{m.isPending||(n(!1),c(null))};return L?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground border-b border-border/60",children:[t.jsx(qn,{size:13,className:"shrink-0 text-muted-foreground/70"}),t.jsx("span",{className:"text-xs",children:u("当前分支还没有任何变更")})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"border-b border-border bg-background",children:t.jsxs("div",{className:"px-3 py-2",children:[d&&t.jsx(Oe,{tone:"danger",size:"sm",className:"mb-2",children:d}),E&&t.jsx(Oe,{tone:"warning",size:"sm",icon:t.jsx(_a,{}),className:"mb-2",children:u("{count} 个本地改动未处理,需要先整理后再继续",{count:x})}),S&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-foreground",children:[t.jsx(Tt,{size:13,className:"shrink-0 text-warning"}),t.jsx("span",{children:u("{count} 个文件存在冲突,需要处理后继续",{count:f.conflictedFiles.length})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[t.jsx(ce,{variant:"primary",size:"sm",onClick:o,children:u("处理冲突")}),t.jsx(ce,{variant:"secondary",size:"sm",onClick:()=>y.mutate(r),loading:y.isPending,children:y.isPending?u("正在撤销..."):u("撤销操作")})]})]}),k&&!S&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-foreground",children:[t.jsx(xe,{size:"xs",className:"text-info"}),t.jsx("span",{children:f.operation==="rebase"?u("正在同步源分支更新..."):u("正在提交变更...")})]}),t.jsxs(ce,{variant:"secondary",size:"sm",className:"ml-auto",onClick:()=>y.mutate(r),loading:y.isPending,children:[!y.isPending&&t.jsx(Zr,{}),y.isPending?u("正在撤销..."):u("撤销操作")]})]}),!S&&!k&&(f.behind>0||f.ahead>0)&&t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[f.behind>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:u("源分支 {branch} 有 {count} 个更新",{branch:l,count:f.behind})}),t.jsxs(ce,{variant:"primary",size:"sm",onClick:R,disabled:!C,loading:p.isPending,children:[!p.isPending&&t.jsx(_t,{}),p.isPending?u("正在同步..."):u("同步更新")]})]}),f.ahead>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:u("{count} 个文件变更,可以安全提交",{count:v??f.ahead})}),t.jsx("span",{title:T?void 0:u("需要先处理本地改动"),className:Q("inline-flex",!T&&"cursor-not-allowed"),children:t.jsxs(ce,{variant:"primary",size:"sm",onClick:M,disabled:!T||m.isPending,children:[t.jsx(Us,{}),u("提交变更")]})})]})]})]})}),t.jsx(pn,{projectId:e,workspaceId:r,canMerge:C&&f.ahead>0&&f.behind===0,isOpen:b,onClose:B,branchName:s,targetBranch:l,commitMessage:g,isPending:m.isPending,activeServices:_,isCheckingServices:h.isLoading,serviceCheckFailed:h.isError,error:d,onConfirm:I})]})}const vn=({line:e,lineNum:r})=>{let s="",l="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?s="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?s="bg-destructive/10":e.startsWith("@@")?(s="bg-info/5",l="text-info-ink"):(e.startsWith("diff ")||e.startsWith("index "))&&(l="text-muted-foreground"),t.jsxs("div",{className:Q("flex",s),children:[t.jsx("span",{"aria-hidden":"true",className:"w-10 shrink-0 select-none border-r border-border/60 pr-2 text-right text-muted-foreground/50",children:r}),t.jsx("span",{className:Q("whitespace-pre pl-2",l),children:e})]})},xs=50,Ss=400;function _n(e){const r=e.split("/");return r[r.length-1]||e}function fu(e){const r=e.lastIndexOf("/");return r>0?e.slice(0,r):""}function mu(e){const s=Math.floor(Date.now()/1e3)-e;return s<60?Ye("{count}s ago",{count:s}):s<3600?Ye("{count}m ago",{count:Math.floor(s/60)}):s<86400?Ye("{count}h ago",{count:Math.floor(s/3600)}):s<604800?Ye("{count}d ago",{count:Math.floor(s/86400)}):new Date(e*1e3).toLocaleDateString()}function Ut(e,r){return e.kind==="working"?`${e.diffType}:${r}`:`${e.hash}:${r}`}const Os=({additions:e,deletions:r,className:s})=>e===void 0&&r===void 0?null:t.jsx(Jr,{additions:e,deletions:r,className:s}),bn=({diff:e})=>{const{t:r}=re(),[s,l]=A.useState(!1),g=A.useMemo(()=>e.split(`
61
- `),[e]);if(!e.trim())return t.jsx("div",{className:"py-6 text-center text-muted-foreground text-xs",children:r("没有可显示的差异内容")});const v=!s&&g.length>Ss,w=v?g.slice(0,Ss):g;return t.jsxs("div",{className:"overflow-x-auto scrollbar-app-thin font-mono text-xs leading-5",children:[w.map((i,o)=>t.jsx(vn,{line:i,lineNum:o+1},o)),v&&t.jsx("button",{type:"button",onClick:()=>l(!0),className:"w-full py-2 text-xs text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:r("还有 {count} 行变更被折叠,点击展开全部",{count:g.length-Ss})})]})},pu=({workingDir:e,path:r,diffType:s,enabled:l})=>{const{t:g}=re(),{data:v,isLoading:w,isError:i}=ou(e,l?r:null,s);return!l||w?t.jsxs("div",{className:"flex items-center justify-center gap-2 py-8 text-muted-foreground",children:[t.jsx(xe,{size:"sm"}),t.jsx("span",{className:"text-xs",children:g("正在加载差异...")})]}):i?t.jsx("div",{className:"py-6 text-center text-destructive-ink text-xs",children:g("差异加载失败")}):t.jsx(bn,{diff:v?.diff||""})},gu=({workingDir:e,hash:r,path:s,enabled:l})=>{const{t:g}=re(),{data:v,isLoading:w,isError:i}=un(e,l?r:null,l?s:null);return!l||w?t.jsxs("div",{className:"flex items-center justify-center gap-2 py-8 text-muted-foreground",children:[t.jsx(xe,{size:"sm"}),t.jsx("span",{className:"text-xs",children:g("正在加载差异...")})]}):i?t.jsx("div",{className:"py-6 text-center text-destructive-ink text-xs",children:g("差异加载失败")}):t.jsx(bn,{diff:v?.diff||""})},ys=({entry:e,source:r,workingDir:s,flash:l,registerNode:g})=>{const[v,w]=A.useState(!1),[i,o]=A.useState(!1),u=A.useRef(null),f=Ut(r,e.path);A.useEffect(()=>(g(f,u.current),()=>g(f,null)),[f,g]),A.useEffect(()=>{const p=u.current;if(!p||i)return;const m=new IntersectionObserver(y=>{y.some(b=>b.isIntersecting)&&(o(!0),m.disconnect())},{rootMargin:"300px 0px"});return m.observe(p),()=>m.disconnect()},[i]);const a=fu(e.path);return t.jsxs("div",{ref:u,"data-card-key":f,className:Q("rounded-md border border-border bg-background overflow-hidden transition-shadow",l&&"ring-2 ring-info/40"),children:[t.jsxs("button",{type:"button",onClick:()=>w(p=>!p),className:"w-full flex items-center gap-2 px-3 py-2 bg-muted/40 hover:bg-muted/70 transition-colors text-left",children:[v?t.jsx(Je,{size:13,className:"text-muted-foreground/70 shrink-0"}):t.jsx(Ke,{size:13,className:"text-muted-foreground/70 shrink-0"}),t.jsx(gi,{status:e.status}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:_n(e.path)}),a&&t.jsx("span",{className:"font-mono text-[11px] text-muted-foreground truncate",children:a}),t.jsx("span",{className:"ml-auto"}),t.jsx(Os,{additions:e.additions,deletions:e.deletions})]}),!v&&t.jsx("div",{className:"border-t border-border/60",children:r.kind==="working"?t.jsx(pu,{workingDir:s,path:e.path,diffType:r.diffType,enabled:i}):t.jsx(gu,{workingDir:s,hash:r.hash,path:e.path,enabled:i})})]})};function vu(e){const r={name:"",path:"",dirs:new Map,files:[]};for(const s of e){const l=s.path.split("/");let g=r;for(let v=0;v<l.length-1;v++){const w=l[v];g.dirs.has(w)||g.dirs.set(w,{name:w,path:g.path?`${g.path}/${w}`:w,dirs:new Map,files:[]}),g=g.dirs.get(w)}g.files.push(s)}return xn(r)}function xn(e){const r=new Map;for(const s of e.dirs.values()){let l=xn(s);for(;l.dirs.size===1&&l.files.length===0;){const g=[...l.dirs.values()][0];l={...g,name:`${l.name}/${g.name}`}}r.set(l.name,l)}return{...e,dirs:r}}const _u=({dir:e,depth:r,activeKey:s,onSelect:l})=>{const[g,v]=A.useState(!0);return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>v(w=>!w),className:"flex items-center gap-1.5 w-full px-2 py-1 rounded-sm hover:bg-muted/60 text-left",style:{paddingLeft:8+r*12},children:[g?t.jsx(fi,{size:12,className:"text-muted-foreground/70 shrink-0"}):t.jsx($s,{size:12,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:e.name})]}),g&&t.jsx(Sn,{node:e,depth:r+1,activeKey:s,onSelect:l})]})},Sn=({node:e,depth:r,activeKey:s,onSelect:l})=>t.jsxs(t.Fragment,{children:[[...e.dirs.values()].sort((g,v)=>g.name.localeCompare(v.name)).map(g=>t.jsx(_u,{dir:g,depth:r,activeKey:s,onSelect:l},g.path)),e.files.slice().sort((g,v)=>g.path.localeCompare(v.path)).map(g=>{const v=s===g.cardKey;return t.jsxs("button",{type:"button",onClick:()=>l(g),className:Q("flex items-center gap-1.5 w-full px-2 py-1 rounded-sm text-left",v?"bg-muted":"hover:bg-muted/60"),style:{paddingLeft:8+r*12},title:g.path,children:[t.jsx("span",{className:Q("w-1.5 h-1.5 rounded-full shrink-0",Kn[Mo(g.status)])}),t.jsx("span",{className:Q("text-xs truncate",v?"text-foreground font-medium":"text-foreground/90"),children:_n(g.path)})]},g.cardKey)})]}),bu=({workingDir:e,selectedHash:r,onSelectCommit:s})=>{const{t:l}=re(),{data:g,isLoading:v,fetchNextPage:w,hasNextPage:i,isFetchingNextPage:o}=Is({queryKey:ie.git.log(e),queryFn:({pageParam:f=0})=>oe.get("/git/log",{params:{workingDir:e,limit:String(xs),skip:String(f)}}),initialPageParam:0,getNextPageParam:(f,a)=>f.commits.length<xs?void 0:a.length*xs}),u=g?.pages.flatMap(f=>f.commits)||[];return v?t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 text-muted-foreground text-xs",children:[t.jsx(xe,{size:"xs"}),t.jsx("span",{children:l("正在加载提交记录...")})]}):u.length===0?t.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:l("暂无提交记录")}):t.jsxs("div",{className:"space-y-px px-1.5 pb-1.5",children:[u.map(f=>{const a=r===f.hash;return t.jsxs("button",{type:"button",onClick:()=>s(f),className:Q("flex items-start gap-1.5 w-full px-1.5 py-1 rounded-sm text-left group",a?"bg-muted":"hover:bg-muted/60"),title:f.message,children:[t.jsx("span",{className:Q("w-1.5 h-1.5 rounded-full mt-1.5 shrink-0 transition-colors",a?"bg-primary":"bg-border group-hover:bg-muted-foreground/60")}),t.jsxs("span",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:Q("block text-xs truncate",a?"text-foreground font-medium":"text-foreground/90"),children:f.message}),t.jsxs("span",{className:"block text-[11px] text-muted-foreground truncate",children:[t.jsx("span",{className:"font-mono",children:f.shortHash})," · ",f.author," · ",mu(f.timestamp)]})]})]},f.hash)}),i&&t.jsx("button",{type:"button",onClick:()=>w(),disabled:o,className:"w-full py-1.5 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 rounded-sm transition-colors flex items-center justify-center gap-1.5",children:o?t.jsxs(t.Fragment,{children:[t.jsx(xe,{size:"xs"})," ",l("正在加载...")]}):l("加载更多提交")})]})},xu=({projectId:e,workingDir:r,workspaceId:s,branchName:l,targetBranch:g,commitMessage:v,canRunGitOperations:w,onRefreshCommitMessage:i,onConflict:o,onResolveConflicts:u})=>{const{t:f}=re(),[a,p]=A.useState({kind:"overview"}),[m,y]=A.useState(""),[b,n]=A.useState(null),[d,c]=A.useState(null),{data:h,isLoading:_,isError:S}=nu(r),k=a.kind==="commit"?a.commit.hash:null,{data:E,isLoading:x}=hn(r,k),C=A.useRef(new Map),T=A.useRef(null),L=A.useRef(null),R=A.useCallback((z,W)=>{W?C.current.set(z,W):C.current.delete(z)},[]),{uncommitted:M,committed:I,commitFiles:B}=A.useMemo(()=>{const z=F=>!m.trim()||F.path.toLowerCase().includes(m.trim().toLowerCase());if(a.kind==="commit"){const F={kind:"commit",hash:a.commit.hash},X=(E?.files||[]).filter(z).map(Y=>({...Y,cardKey:Ut(F,Y.path)}));return{uncommitted:[],committed:[],commitFiles:X}}const W=(h?.uncommitted||[]).filter(z).map(F=>({...F,cardKey:Ut({kind:"working",diffType:"uncommitted"},F.path)})),j=(h?.committed||[]).filter(z).map(F=>({...F,cardKey:Ut({kind:"working",diffType:"committed"},F.path)}));return{uncommitted:W,committed:j,commitFiles:[]}},[a,h,E,m]),H=a.kind==="commit"?B:[...M,...I],$=A.useMemo(()=>vu(H),[H]),N=A.useMemo(()=>{let z=0,W=0;for(const j of H)z+=j.additions??0,W+=j.deletions??0;return{additions:z,deletions:W,files:H.length}},[H]),P=A.useCallback(()=>{const z=T.current;if(!z)return;const W=z.getBoundingClientRect().top;let j=null,F=Number.NEGATIVE_INFINITY;for(const[X,Y]of C.current){const ee=Y.getBoundingClientRect().top-W;ee<=48&&ee>F&&(F=ee,j=X)}if(!j){let X=null,Y=Number.POSITIVE_INFINITY;for(const[ee,G]of C.current){const Z=G.getBoundingClientRect().top-W;Z<Y&&(Y=Z,X=ee)}j=X}n(j)},[]);A.useEffect(()=>{const z=T.current;if(!z)return;let W=0;const j=()=>{cancelAnimationFrame(W),W=requestAnimationFrame(P)};return z.addEventListener("scroll",j,{passive:!0}),()=>{z.removeEventListener("scroll",j),cancelAnimationFrame(W)}},[P]);const D=A.useCallback(z=>{const W=C.current.get(z.cardKey);W&&(W.scrollIntoView({behavior:"smooth",block:"start"}),n(z.cardKey),c(z.cardKey),L.current&&clearTimeout(L.current),L.current=setTimeout(()=>c(null),1200))},[]),O=A.useCallback(z=>{p(W=>W.kind==="commit"&&W.commit.hash===z.hash?{kind:"overview"}:{kind:"commit",commit:z}),y(""),n(null),T.current?.scrollTo({top:0})},[]),q=A.useCallback(()=>{p({kind:"overview"}),y(""),n(null),T.current?.scrollTo({top:0})},[]);if(!r)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm bg-background h-full",children:f("未选择工作区")});const K=w&&e&&s&&l&&g,U=a.kind==="commit"?x:_;return t.jsxs("div",{className:"flex h-full w-full min-w-0 flex-col bg-background",children:[K&&o&&u&&t.jsx(uu,{projectId:e,workspaceId:s,branchName:l,targetBranch:g,commitMessage:v,committedFileCount:h?.committed?.length,onRefreshCommitMessage:i,onConflict:o,onResolveConflicts:u}),t.jsx("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border/60 shrink-0 min-h-[37px]",children:a.kind==="overview"?t.jsxs(t.Fragment,{children:[t.jsx(qs,{size:14,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:f("代码审查")}),t.jsx("span",{className:"text-xs text-muted-foreground",children:f("{count} 个文件",{count:N.files})}),t.jsx(Os,{additions:N.additions,deletions:N.deletions}),l&&g&&t.jsxs("span",{className:"ml-auto flex items-center gap-1 text-[11px] text-muted-foreground font-mono truncate",children:[t.jsx("span",{className:"truncate",children:l}),t.jsx(ks,{size:10,className:"rotate-180 shrink-0"}),t.jsx("span",{className:"truncate",children:g})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",onClick:q,className:"flex items-center gap-1 px-1.5 py-0.5 -ml-1.5 rounded-sm text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors shrink-0",children:[t.jsx(ks,{size:12}),f("全部变更")]}),t.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground/50 text-xs",children:"/"}),t.jsx("span",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:a.commit.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate",children:a.commit.message}),t.jsx(Os,{className:"ml-auto",additions:N.additions,deletions:N.deletions})]})}),t.jsxs("div",{className:"flex flex-1 min-h-0",children:[t.jsx("div",{ref:T,className:"flex-1 min-w-0 overflow-y-auto scrollbar-app-thin",children:U?t.jsx("div",{className:"p-3 space-y-3",children:[0,1].map(z=>t.jsxs("div",{className:"rounded-md border border-border overflow-hidden",children:[t.jsx("div",{className:"h-8 bg-muted/60 animate-pulse motion-reduce:animate-none"}),t.jsxs("div",{className:"p-3 space-y-2",children:[t.jsx("div",{className:"h-3 w-2/3 bg-muted animate-pulse motion-reduce:animate-none rounded-sm"}),t.jsx("div",{className:"h-3 w-1/2 bg-muted animate-pulse motion-reduce:animate-none rounded-sm"}),t.jsx("div",{className:"h-3 w-3/4 bg-muted animate-pulse motion-reduce:animate-none rounded-sm"})]})]},z))}):S&&a.kind==="overview"?t.jsx("div",{className:"flex-1 flex items-center justify-center py-16 text-destructive-ink text-sm",children:f("变更加载失败")}):H.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted-foreground",children:[t.jsx(Ts,{size:28,className:"mb-2 text-muted-foreground/70"}),t.jsx("span",{className:"text-xs",children:m.trim()?f("没有匹配筛选条件的文件"):a.kind==="commit"?f("该提交没有文件变更"):f("没有待审查的变更")})]}):a.kind==="commit"?t.jsx("div",{className:"p-3 space-y-3",children:B.map(z=>t.jsx(ys,{entry:z,source:{kind:"commit",hash:a.commit.hash},workingDir:r,flash:d===z.cardKey,registerNode:R},z.cardKey))}):t.jsxs("div",{className:"p-3 space-y-4",children:[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-xs font-medium text-muted-foreground",children:f("未提交")}),t.jsx("span",{className:"ml-2 text-[11px] tabular-nums text-muted-foreground",children:M.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:M.map(z=>t.jsx(ys,{entry:z,source:{kind:"working",diffType:"uncommitted"},workingDir:r,flash:d===z.cardKey,registerNode:R},z.cardKey))})]}),I.length>0&&t.jsxs("section",{children:[t.jsxs("div",{className:"sticky top-0 z-10 -mx-3 px-5 py-1.5 bg-background/95 backdrop-blur-sm",children:[t.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:f("已提交")}),t.jsx("span",{className:"ml-2 text-[11px] tabular-nums text-muted-foreground",children:I.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:I.map(z=>t.jsx(ys,{entry:z,source:{kind:"working",diffType:"committed"},workingDir:r,flash:d===z.cardKey,registerNode:R},z.cardKey))})]})]})}),t.jsxs("aside",{className:"shrink-0 border-l border-border flex flex-col min-h-0",style:{width:"clamp(15rem, 24%, 22rem)"},children:[t.jsx("div",{className:"p-2 shrink-0",children:t.jsx(Wo,{size:"sm",value:m,onValueChange:y,placeholder:f("筛选文件...")})}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin px-1.5 pb-1.5 min-h-0",children:H.length===0?t.jsx("div",{className:"px-2 py-3 text-xs text-muted-foreground",children:m.trim()?f("无匹配文件"):f("暂无变更文件")}):t.jsx(Sn,{node:$,depth:0,activeKey:b,onSelect:D})}),t.jsxs("div",{className:"shrink-0 border-t border-border/60 max-h-[40%] flex flex-col min-h-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 shrink-0",children:[t.jsx(Kt,{size:12,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:f("提交记录")})]}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin min-h-0",children:t.jsx(bu,{workingDir:r,selectedHash:k,onSelectCommit:O})})]})]})]})]})},ws=50;function Su(e){const s=Math.floor(Date.now()/1e3)-e;return s<60?Ye("{count}s ago",{count:s}):s<3600?Ye("{count}m ago",{count:Math.floor(s/60)}):s<86400?Ye("{count}h ago",{count:Math.floor(s/3600)}):s<604800?Ye("{count}d ago",{count:Math.floor(s/86400)}):new Date(e*1e3).toLocaleDateString()}function yu(e){const r=e.split("/");return r[r.length-1]||e}function wu(e){const r=e.lastIndexOf("/");return r>0?e.slice(0,r):""}const Cu=({workingDir:e,hash:r,filePath:s})=>{const{t:l}=re(),{data:g,isLoading:v,isError:w}=un(e,r,s);if(v)return t.jsxs("div",{className:"flex-1 flex items-center justify-center gap-2 text-muted-foreground",children:[t.jsx(xe,{size:"md"}),t.jsx("span",{className:"text-xs",children:l("Loading diff...")})]});if(w)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive-ink text-xs",children:l("Failed to load diff.")});const i=g?.diff||"";if(!i.trim())return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-xs",children:l("No diff content available.")});const o=i.split(`
62
- `);return t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin font-mono text-xs leading-5",children:o.map((u,f)=>t.jsx(vn,{line:u,lineNum:f+1},f))})},ku=({workingDir:e,hash:r,selectedPath:s,onSelectFile:l})=>{const{t:g}=re(),{data:v,isLoading:w}=hn(e,r);if(w)return t.jsxs("div",{className:"pl-7 py-1 text-xs text-muted-foreground flex items-center gap-1",children:[t.jsx(xe,{size:"xs"}),t.jsx("span",{children:g("Loading...")})]});const i=v?.files||[];return i.length===0?t.jsx("div",{className:"pl-7 py-1 text-xs text-muted-foreground",children:g("No files changed")}):t.jsx("div",{className:"pl-7 pb-1 space-y-0.5",children:i.map(o=>{const u=wu(o.path);return t.jsxs("button",{type:"button",onClick:f=>{f.stopPropagation(),l(o.path)},className:Q("flex items-center gap-2 px-1.5 py-1 rounded-sm cursor-pointer w-full text-left",s===o.path?"bg-muted":"hover:bg-muted/60"),children:[t.jsx(gi,{status:o.status}),t.jsx("span",{className:"min-w-0 text-xs text-foreground truncate",children:yu(o.path)}),u&&t.jsx("span",{className:"min-w-0 flex-1 truncate text-right font-mono text-[11px] text-muted-foreground [direction:rtl]",children:t.jsx("span",{dir:"ltr",children:u})})]},o.path)})})},Eu=({workingDir:e})=>{const{t:r}=re(),s=Qt(E=>E.visibleContext),l=Yo(e,s),{data:g,isLoading:v,isError:w,fetchNextPage:i,hasNextPage:o,isFetchingNextPage:u}=Is({queryKey:ie.git.log(e||""),queryFn:({pageParam:E=0})=>oe.get("/git/log",{params:{workingDir:e||"",limit:String(ws),skip:String(E)}}),initialPageParam:0,getNextPageParam:(E,x)=>E.commits.length<ws?void 0:x.length*ws,enabled:!!e,refetchInterval:l,refetchIntervalInBackground:!1,refetchOnWindowFocus:l?"always":!1,refetchOnReconnect:l?"always":!1}),f=g?.pages.flatMap(E=>E.commits)||[],[a,p]=A.useState(null),[m,y]=A.useState(null),[b,n]=A.useState(280),[d,c]=A.useState(!1),h=A.useCallback(E=>{E.preventDefault(),c(!0);const x=E.clientX,C=b,T=R=>{const M=Math.min(480,Math.max(180,C+(R.clientX-x)));n(M)},L=()=>{c(!1),document.removeEventListener("mousemove",T),document.removeEventListener("mouseup",L)};document.addEventListener("mousemove",T),document.addEventListener("mouseup",L)},[b]),_=E=>{a===E?(p(null),y(null)):(p(E),y(null))},S=A.useRef(null);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm bg-background h-full",children:r("No workspace selected.")});if(v)return t.jsxs("div",{className:"flex-1 flex items-center justify-center gap-2 text-muted-foreground bg-background h-full",children:[t.jsx(xe,{size:"md"}),t.jsx("span",{className:"text-sm",children:r("Loading history...")})]});if(w)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive-ink text-sm bg-background h-full",children:r("Failed to load history.")});if(f.length===0)return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-12 text-muted-foreground bg-background h-full",children:[t.jsx(Kt,{size:28,className:"mb-2 text-muted-foreground/70"}),t.jsx("span",{className:"text-xs",children:r("No commit history")})]});const k=f.find(E=>E.hash===a);return t.jsxs("div",{className:"flex h-full bg-background",style:d?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsxs("div",{className:"border-r border-border flex flex-col shrink-0",style:{width:b},children:[t.jsx("div",{className:"px-3 py-2.5 border-b border-border/60 shrink-0",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Kt,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:r("History")}),t.jsx("span",{className:"text-[11px] tabular-nums bg-muted px-1.5 py-0.5 rounded-full text-muted-foreground",children:f.length})]})}),t.jsxs("div",{ref:S,className:"flex-1 overflow-auto scrollbar-app-thin p-1.5",children:[f.map(E=>{const x=a===E.hash;return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>_(E.hash),className:Q("flex items-start gap-2 px-2 py-1.5 rounded-sm cursor-pointer w-full text-left group",x?"bg-muted":"hover:bg-muted/60"),children:[t.jsx("div",{className:"flex flex-col items-center shrink-0 pt-1",children:t.jsx("div",{className:Q("w-2 h-2 rounded-full shrink-0 transition-colors",x?"bg-primary":"bg-border group-hover:bg-muted-foreground/60")})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:E.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate flex-1",children:E.message}),t.jsx(Je,{size:12,className:Q("shrink-0 text-muted-foreground/70 transition-transform",x&&"rotate-90")})]}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.jsx("span",{className:"text-xs text-muted-foreground truncate",children:E.author}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:Su(E.timestamp)})]})]})]}),x&&t.jsxs(t.Fragment,{children:[E.body&&t.jsx("div",{className:"pl-7 pr-2 py-1.5 text-xs text-muted-foreground whitespace-pre-wrap leading-5 border-l-2 border-border ml-3",children:E.body}),t.jsx(ku,{workingDir:e,hash:E.hash,selectedPath:m,onSelectFile:y})]})]},E.hash)}),o&&t.jsx("button",{type:"button",onClick:()=>i(),disabled:u,className:"w-full py-2 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 rounded-sm transition-colors flex items-center justify-center gap-1.5",children:u?t.jsxs(t.Fragment,{children:[t.jsx(xe,{size:"xs"})," ",r("Loading...")]}):r("Load more")})]})]}),t.jsx("div",{onMouseDown:h,className:Q("w-1 shrink-0 cursor-col-resize transition-colors",d?"bg-ring/40":"bg-transparent hover:bg-border")}),t.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:m&&a?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(Ts,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:m}),t.jsxs("span",{className:"font-mono text-[11px] text-muted-foreground",children:["(",k?.shortHash,")"]})]}),t.jsx(Cu,{workingDir:e,hash:a,filePath:m})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(Ts,{size:28,className:"text-muted-foreground/70"}),t.jsx("span",{className:"text-xs",children:r(a?"Select a file to view diff":"Select a commit to view changes")})]})})})]})},zr=zs();function ju(e){if(!zr)return e;try{const r=new URL(zr);return new URL(e,r.origin).toString()}catch{return e}}function yn(e){return{...e,viewUrl:e.viewUrl?ju(e.viewUrl):null}}function Nu(e,r=!0){return Ee({queryKey:ie.previews.status(e??""),queryFn:async()=>{const s=await oe.get(`/previews/${e}/status`);return yn(s)},enabled:!!e&&r,refetchOnWindowFocus:!1})}function Tu(e){const r=De();return Ct({mutationFn:async s=>{const l=await oe.put(`/previews/${e}/config`,{target:s});return yn(l)},onSuccess:s=>{e&&(r.setQueryData(ie.previews.status(e),s),r.invalidateQueries({queryKey:ie.workspaces.all}))}})}function Au(){return window.location.protocol==="https:"?"remote":"local"}function Ru(e,r,s=!0){const[l,g]=A.useState(null),[v,w]=A.useState(!1),[i,o]=A.useState(null),[u,f]=A.useState(0);return A.useEffect(()=>{if(!s||!e||!r?.ready||!r.target){g(null),w(!1),o(null);return}let a=!1,p=null,m=null;g(null);const y=n=>{oe.delete(`/previews/${e}/sessions/${n}`).catch(()=>{})};return(async()=>{w(!0),o(null);try{const n={mode:Au(),localHostname:window.location.hostname},d=await oe.post(`/previews/${e}/sessions`,n);if(a){y(d.id);return}p=d.id,g(d),m=window.setInterval(async()=>{if(p)try{const c=await oe.post(`/previews/${e}/sessions/${p}/heartbeat`);a||(g(c),o(null))}catch(c){!a&&c instanceof Ze&&c.status===404?f(h=>h+1):a||o(c instanceof Error?c:new Error("Preview session heartbeat failed"))}},3e4)}catch(n){a||(g(null),o(n instanceof Error?n:new Error("Failed to open preview session")))}finally{a||w(!1)}})(),()=>{a=!0,m!==null&&window.clearInterval(m),p&&y(p)}},[s,u,r?.ready,r?.target,e]),{session:l,isOpening:v,error:i,retry:()=>f(a=>a+1)}}const Lu="agent-tower-preview",Mu="agent-tower-preview-host";function Du(){return"3000, localhost:3000, http://127.0.0.1:5173"}function Pu(e){if(!e)return null;try{return new URL(e).origin}catch{return null}}function Bu(e){return t.jsx(Ou,{...e},e.workspaceId??"no-workspace")}function Ou({workspaceId:e,readOnly:r,navigationRequest:s,onNavigationRequestHandled:l}){const{t:g}=re(),[v,w]=A.useState(null),o=!(s?.source.kind==="visualization")&&!v,{data:u,isLoading:f,refetch:a,isFetching:p}=Nu(e,o),m=Tu(e),{session:y,isOpening:b,error:n,retry:d}=Ru(e,u,o),c=A.useRef(null),h=A.useRef(null),_=A.useRef(null),S=A.useRef(null),k=A.useRef(null),E=A.useRef(null),[x,C]=A.useState(0),[T,L]=A.useState({target:null,address:"",iframeSrc:null,isFrameLoading:!1}),R=Pu(y?.viewUrl),M=u&&T.target!==u.target?{target:u.target,address:u.target??"",iframeSrc:null,isFrameLoading:!1}:u&&!u.ready&&T.iframeSrc?{...T,iframeSrc:null,isFrameLoading:!1}:T,I=A.useCallback(K=>{L(U=>({...u&&U.target!==u.target?{target:u.target,address:u.target??"",iframeSrc:null,isFrameLoading:!1}:U,...K}))},[u]);A.useEffect(()=>{if(!y||y.target!==u?.target)return;const K=k.current!==R;k.current=R,L(U=>{const z=s?.source.kind==="web"&&E.current!==s.id?Dt(s.source.url,y.target,y.viewUrl):null;if(!K&&U.iframeSrc&&U.target===y.target&&z?.kind!=="proxy")return U;let W=U.iframeSrc;if(z?.kind==="proxy")W=z.url;else if(!W||U.target!==y.target||K){const F=_.current;if(F)W=ho(y.viewUrl,F);else{const X=Dt(U.address||y.target,y.target,y.viewUrl);W=X?.kind==="proxy"?X.url:y.viewUrl}}_.current=null;const j=S.current;return j&&!j.closed&&W&&j.location.replace(W),S.current=null,{target:y.target,address:z?.kind==="proxy"?s?.source.kind==="web"?s.source.url:U.address:U.address||y.target,iframeSrc:W,isFrameLoading:!!W}})},[s,y,R,u?.target]),A.useEffect(()=>()=>{S.current?.close()},[]);const B=A.useCallback(async(K,U=!1)=>{const z=Dt(K,u?.target??null,y?.viewUrl??null);if(!z||!e)return;if(w(null),z.kind==="proxy"){if(U){window.open(z.url,"_blank","noopener,noreferrer");return}L({target:u?.target??null,address:K,iframeSrc:z.url,isFrameLoading:!0});return}if(r)return;const W=U?window.open("about:blank","_blank"):null;W&&(W.opener=null);try{_.current=z.path,S.current=W;const j=await m.mutateAsync(z.target);L({target:j.target,address:K.trim(),iframeSrc:null,isFrameLoading:!!j.ready}),C(F=>F+1),ke.success(g("Preview target saved")),j.ready||(S.current?.close(),S.current=null)}catch(j){S.current?.close(),S.current=null,_.current=null;const F=j instanceof Error?j.message:g("Failed to save preview target");ke.error(F)}},[y?.viewUrl,r,u?.target,g,m,e]);A.useEffect(()=>{if(!s||E.current===s.id||s.source.kind==="web"&&f)return;const K=window.setTimeout(()=>{E.current=s.id,l?.(s.id),s.source.kind==="visualization"?(w({source:s.source,iframeSrc:uo(s.source.sessionId,s.source.file),isFrameLoading:!0}),C(U=>U+1)):(w(null),B(s.source.url))},0);return()=>window.clearTimeout(K)},[f,B,s,l]),A.useEffect(()=>{if(v)return;const K=U=>{if(U.source!==c.current?.contentWindow)return;const z=U.data;if(!(!z||z.source!==Lu)){if(z.type==="location"&&typeof z.href=="string"){const W=fo(u?.target??null,y?.viewUrl??null,z.href,window.location.href);W&&document.activeElement!==h.current&&I({target:u?.target??M.target,address:W,isFrameLoading:!1});return}z.type==="navigate-loopback"&&typeof z.href=="string"&&B(z.href,z.newTab===!0)}};return window.addEventListener("message",K),()=>window.removeEventListener("message",K)},[M.target,B,I,y?.viewUrl,u?.target,v]);const H=K=>{c.current?.contentWindow?.postMessage({source:Mu,action:K},"*")},$=K=>{K.preventDefault(),B(M.address)},N=async()=>{if(v){w(U=>U&&{...U,isFrameLoading:!0}),C(U=>U+1);return}const K=await a();if(!K.data?.ready){I({target:K.data?.target??M.target,iframeSrc:null,isFrameLoading:!1});return}if(!y||!M.iframeSrc){d();return}I({isFrameLoading:!0}),H("reload")},P=()=>{if(v){window.open(v.iframeSrc,"_blank","noopener,noreferrer");return}if(!y?.viewUrl)return;const K=Dt(M.address||y.target,y.target,y.viewUrl),U=K?.kind==="proxy"?K.url:y.viewUrl;window.open(U,"_blank","noopener,noreferrer")};if(!e)return t.jsx("div",{className:"h-full flex items-center justify-center bg-background text-sm text-muted-foreground",children:g("No active workspace.")});const D=v?.iframeSrc??M.iframeSrc,O=!!v,q=!O&&(f||p||m.isPending||b);return t.jsxs("div",{className:"h-full flex flex-col bg-background",children:[t.jsxs("div",{className:"shrink-0 border-b border-border bg-muted/40 px-2 py-2",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx($e,{label:g("Back"),onClick:()=>{O?w(null):H("back")},disabled:!O&&!M.iframeSrc,children:t.jsx(ks,{})}),t.jsx($e,{label:g("Forward"),onClick:()=>H("forward"),disabled:O||!M.iframeSrc,children:t.jsx(ji,{})}),t.jsx($e,{label:!O&&M.isFrameLoading?g("Stop loading"):g("Refresh preview"),onClick:!O&&M.isFrameLoading?()=>{H("stop"),I({isFrameLoading:!1})}:N,disabled:!O&&!M.isFrameLoading&&p,children:!O&&M.isFrameLoading?t.jsx(tt,{}):p?t.jsx(xe,{}):t.jsx(_t,{})}),t.jsx("form",{className:"min-w-0 flex-1",onSubmit:$,children:t.jsx($o,{ref:h,size:"sm",prefix:t.jsx(ma,{}),value:v?.source.file??M.address,onChange:K=>I({address:K.target.value}),onKeyDown:K=>{K.key==="Enter"&&K.nativeEvent.isComposing&&K.preventDefault()},disabled:O||r||m.isPending,placeholder:Du(),"aria-label":g("Preview address")})}),t.jsx($e,{label:g("Open preview in new tab"),onClick:P,disabled:!D,children:t.jsx(Hs,{})})]}),t.jsxs("div",{className:"mt-1 flex min-h-4 items-center justify-between gap-2 px-1 text-xs leading-4",children:[t.jsx("span",{className:"truncate text-muted-foreground",children:O?g("Viewing agent visualization"):q?g("Checking preview target..."):n?n.message:u?.ready?`${g("Proxying")} ${u.target}`:u?.configured?`${g("Preview target is not reachable")}${u.error?`: ${u.error}`:""}`:g("Enter a local preview URL on the Agent Tower machine.")}),t.jsx("span",{className:"shrink-0 text-muted-foreground",children:g(O?"Session file":"Loopback only")})]})]}),t.jsx("div",{className:"relative flex-1 min-h-0 bg-background",children:D?t.jsx("iframe",{ref:c,src:D,title:g("Preview"),className:"absolute inset-0 h-full w-full border-0 bg-white",sandbox:O?"allow-modals allow-pointer-lock allow-presentation allow-scripts":"allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts",allow:"clipboard-read; clipboard-write; fullscreen",onLoad:()=>{O?w(K=>K&&{...K,isFrameLoading:!1}):I({isFrameLoading:!1})}},x):t.jsx("div",{className:"absolute inset-0 flex items-center justify-center px-4 text-center text-sm text-muted-foreground",children:u?.configured?u.ready&&b?g("Checking preview target..."):g("Start the preview server, then refresh."):g("Configure a local preview target to display it here.")})})]})}const Iu={[We.ACTIVE]:"success",[We.MERGED]:"info",[We.HIBERNATED]:"warning",[We.ABANDONED]:"neutral"};function Fu(e){return e.length<=34?e:`...${e.slice(-31)}`}function Hu({workspaces:e,teamRun:r,selectedWorkspaceId:s,onSelectWorkspace:l,disabled:g,className:v,buttonClassName:w}){const{t:i}=re(),o=A.useMemo(()=>Ys(e,r),[e,r]),u=o.find(f=>f.workspace.id===s)??o[0];return o.length<=1?null:t.jsx("div",{className:Q("relative",v),children:t.jsxs(_i,{children:[t.jsxs(bi,{disabled:g,className:Q("group inline-flex h-8 max-w-[340px] items-center gap-2 rounded-md border border-border bg-background px-2.5 text-left text-xs text-foreground/80 outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring/60 disabled:cursor-not-allowed disabled:opacity-40 data-[state=open]:bg-accent",w),title:i("Workspace"),children:[t.jsx(js,{size:14,className:"shrink-0 text-muted-foreground"}),t.jsx(Wt,{size:"sm",shape:"tag",children:i(u.roleLabel)}),t.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",children:i(u.displayName)}),t.jsx("span",{className:"min-w-0 truncate font-mono text-[11px] text-muted-foreground",children:Fu(jt(u.workspace))}),t.jsx(Ke,{size:13,className:"shrink-0 text-muted-foreground/70 transition-transform group-data-[state=open]:rotate-180"})]}),t.jsx(xi,{className:"w-[420px] max-w-[calc(100vw-2rem)]",children:t.jsx(Bo,{value:u.workspace.id,onValueChange:l,children:o.map(f=>t.jsxs(Oo,{value:f.workspace.id,icon:t.jsx(Qr,{className:"mt-0.5 size-3.5"}),className:"items-start",children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{className:"truncate",children:i(f.displayName)}),t.jsx(Wt,{size:"sm",shape:"tag",children:i(f.roleLabel)}),t.jsx(Wt,{size:"sm",tone:Iu[f.workspace.status],children:f.workspace.status})]}),t.jsx("span",{className:"mt-0.5 block truncate font-mono text-[11px] font-normal text-muted-foreground",children:jt(f.workspace)}),t.jsxs("span",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs font-normal text-muted-foreground",children:[f.ownerName&&t.jsxs("span",{children:[i("Owner"),": ",f.ownerName]}),f.parentBranchName&&t.jsxs("span",{children:[i("Parent"),": ",f.parentBranchName]}),t.jsx("span",{className:"font-mono text-[11px]",children:f.workspace.id.slice(0,8)})]})]},f.workspace.id))})})]})})}const zu=[{key:"review",label:"Changes",icon:t.jsx(qs,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(vi,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(yt,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(ki,{size:14})}],Wu=[{key:"history",label:"History",icon:t.jsx(Kt,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(vi,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(yt,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(ki,{size:14})}],$u=({active:e,onClick:r,icon:s,label:l})=>t.jsxs("button",{type:"button",onClick:r,className:Q("flex shrink-0 items-center gap-2 px-4 py-2 text-xs font-medium transition-all rounded-t-md border-t border-x -mb-px whitespace-nowrap outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/60",e?"bg-background border-border text-foreground z-10":"bg-transparent border-transparent text-muted-foreground hover:text-foreground hover:bg-foreground/[0.05]"),children:[s,t.jsx("span",{children:l})]}),Uu=({active:e,onClick:r,icon:s,label:l})=>t.jsx("button",{type:"button",onClick:r,title:l,"aria-label":l,"aria-pressed":e,className:Q("flex h-9 w-9 items-center justify-center rounded-lg transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",e?"bg-background text-foreground shadow-raised ring-1 ring-border/80":"text-muted-foreground hover:bg-foreground/[0.05] hover:text-foreground"),children:s}),Yf=_e.memo(function({className:r,sessionId:s,workspaceId:l,workingDir:g,projectId:v,hideChanges:w,gitAvailable:i=!0,readOnly:o,repoDeleted:u,teamRun:f,teamStatus:a,subtasks:p,handoff:m,gitProps:y,workspaces:b,selectedWorkspaceId:n,onSelectWorkspace:d,variant:c="tabs",expanded:h,onExpandedChange:_,minContentWidth:S=520,tabRef:k,previewRequest:E,onPreviewRequestHandled:x}){const{t:C}=re(),T=Qt(te=>te.setVisibleContext),L=c==="rail",[R,M]=A.useState(!1),I=L?h??R:!0,B=A.useCallback(te=>{h===void 0&&M(te),_?.(te)},[h,_]),H=p!=null,$=m!=null,N=A.useMemo(()=>{const te=w?Wu:zu,me=i?te:te.filter(Re=>Re.key!=="review"&&Re.key!=="history"),Pe=o?me.filter(Re=>Re.key!=="terminal"):me,qe=H?[...Pe,{key:"subtasks",label:"Subtasks",icon:t.jsx(ni,{size:14})}]:Pe,ve=$?[...qe,{key:"handoff",label:"Handoff note",icon:t.jsx(wa,{size:14})}]:qe;return f?[{key:"team-status",label:"Team Status",icon:t.jsx(vt,{size:14})},...ve]:ve},[i,w,o,f,H,$]),[P,D]=A.useState(()=>E?"preview":i?w?"history":"review":"editor"),O=A.useRef(null),q=A.useRef(0),[K,U]=A.useState(),z=A.useCallback(te=>{D(te),L&&B(!0)},[L,B]);A.useImperativeHandle(k,()=>({setTab:te=>z(te),openFile:(te,me,Pe)=>{z("editor"),requestAnimationFrame(()=>O.current?.openFile(te,me,Pe))},openPreview:(te,me)=>{q.current+=1,U({id:q.current,source:te,workspaceId:me}),z("preview")}}),[z]);const W=E??K,j=W?.workspaceId&&W.workspaceId!==l?void 0:W,F=A.useCallback(te=>{U(me=>me?.id===te?void 0:me),x?.(te)},[x]),{data:X}=Vo(v??""),Y=A.useMemo(()=>{if(!X?.quickCommands)return[];try{return JSON.parse(X.quickCommands)}catch{return[]}},[X?.quickCommands]),[ee,G]=A.useState([]),Z=A.useRef(void 0);A.useEffect(()=>{g&&g!==Z.current&&(Z.current=g,G(te=>te.includes(g)?te:[...te,g]))},[g]),A.useEffect(()=>{N.some(te=>te.key===P)||D(N[0]?.key??"editor")},[P,N]),A.useEffect(()=>{if(L&&!I)return;const te=P==="review"?"changes":P==="history"?"history":null;if(!l||!g||!te){T(null);return}return T({workspaceId:l,workingDir:g,tab:te}),()=>{T(null)}},[P,I,L,T,g,l]);const ae=!!d&&Ys(b,f).length>1,he=N.find(te=>te.key===P)??N[0],je=he?C(he.label):"",se=o?t.jsx(Oe,{size:"sm",className:"mx-2 mt-2",children:C(u?"项目已删除且本地仓库文件已清理。这里只保留历史视图。":"项目已删除。Workspace 以只读模式展示历史内容。")}):null,Ae=t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[ae&&P!=="subtasks"&&P!=="handoff"&&t.jsx("div",{className:"shrink-0 px-3 py-1.5 border-b border-border/60 bg-muted/40",children:t.jsx(Hu,{workspaces:b,teamRun:f,selectedWorkspaceId:n,onSelectWorkspace:d,buttonClassName:"h-7"})}),t.jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[P==="team-status"&&f&&a,P==="subtasks"&&p,P==="handoff"&&m,P==="editor"&&t.jsx(iu,{ref:O,workingDir:g,readOnly:o}),ee.map(te=>{const me=P==="terminal"&&g===te;return t.jsx("div",{"aria-hidden":!me,className:"absolute inset-0 h-full w-full min-h-0 min-w-0 overflow-hidden",style:{display:me?"block":"none"},children:t.jsx(_c,{cwd:te,workspaceId:me?l:void 0,isVisible:me,quickCommands:Y})},te)}),P==="preview"&&t.jsx(Bu,{workspaceId:l,readOnly:o,navigationRequest:j,onNavigationRequestHandled:F}),P==="review"&&t.jsx(xu,{projectId:v,workingDir:g,workspaceId:l,branchName:y?.branchName,targetBranch:y?.targetBranch,commitMessage:y?.commitMessage,canRunGitOperations:y?.canRunGitOperations,onRefreshCommitMessage:y?.onRefreshCommitMessage,onConflict:y?.onConflict,onResolveConflicts:y?.onResolveConflicts}),P==="history"&&t.jsx(Eu,{workingDir:g})]})]});return L?t.jsxs("div",{className:Q("flex h-full w-full min-w-0 bg-background",r),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:N.map(te=>t.jsx(Uu,{active:I&&P===te.key,onClick:()=>z(te.key),icon:te.icon,label:C(te.label)},te.key))}),I&&t.jsxs("div",{className:"flex h-full min-w-0 flex-1 flex-col border-l border-border bg-background",style:{minWidth:S},children:[se,t.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between gap-3 border-b border-border bg-background px-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-sm font-semibold text-foreground",children:[t.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-lg border border-border bg-muted/35 text-muted-foreground",children:he?.icon}),t.jsx("span",{className:"truncate",children:je})]}),t.jsx("button",{type:"button",onClick:()=>B(!1),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",title:C("收起"),"aria-label":C("收起"),children:t.jsx(Ta,{size:15})})]}),Ae]})]}):t.jsxs("div",{className:Q("flex h-full w-full min-w-0 flex-col bg-background",r),children:[o&&se,t.jsx("div",{className:"flex items-center overflow-x-auto scrollbar-app-thin px-2 pt-2 border-b border-border bg-muted shrink-0 gap-1 select-none",children:N.map(te=>t.jsx($u,{active:P===te.key,onClick:()=>z(te.key),icon:te.icon,label:C(te.label)},te.key))}),Ae]})}),qu=3e3;function Wr(e,r){const s=new Map(e.map(l=>[l.workspaceId,l]));for(const l of r){const g=s.get(l.workspaceId);(!g||l.updatedAt>=g.updatedAt)&&s.set(l.workspaceId,l)}return[...s.values()]}function Vf(e){const r=De(),s=A.useRef({version:0,values:new Map}),[l,g]=A.useState(0),{data:v=[]}=Ee({queryKey:ie.workspaces.setupProgress(e??""),enabled:!!e,refetchOnMount:"always",refetchInterval:u=>u.state.data?.some(f=>f.status==="running")?3e3:!1,queryFn:async({signal:u})=>{const f=s.current.version,a=await oe.get(`/tasks/${e}/setup-progress`,{signal:u}),p=[...s.current.values.values()].filter(m=>m.version>f&&m.progress.taskId===e).map(m=>m.progress);return Wr(a,p)}});A.useEffect(()=>{if(!e)return;const u=be.connect(),f=ie.workspaces.setupProgress(e),a=m=>{if(m.taskId!==e)return;const y=s.current.values.get(m.workspaceId);y&&y.progress.updatedAt>m.updatedAt||(s.current.values.set(m.workspaceId,{version:++s.current.version,progress:m}),r.setQueryData(f,b=>Wr(b??[],[m])))},p=()=>{r.invalidateQueries({queryKey:f})};return u.on(Le.WORKSPACE_SETUP_PROGRESS,a),u.on("connect",p),()=>{u.off(Le.WORKSPACE_SETUP_PROGRESS,a),u.off("connect",p)}},[e,r]);const w=[...v].sort((u,f)=>f.updatedAt-u.updatedAt),i=w.find(u=>u.status==="running")??w.find(u=>u.status!=="running"&&u.updatedAt>l),o=i?.status!=="running"?i?.updatedAt??null:null;return A.useEffect(()=>{if(o===null)return;const u=setTimeout(()=>g(o),qu);return()=>clearTimeout(u)},[o]),i??null}function Gf({isOpen:e,onClose:r,onStarted:s,taskId:l,projectId:g,taskTitle:v,taskDescription:w,taskPrompt:i,projectIsGitRepo:o=!0,projectWorktreeReady:u=!0,projectGitReason:f}){const{t:a}=re(),[p,m]=A.useState(""),[y,b]=A.useState(""),[n,d]=A.useState(He.WORKTREE),[c,h]=A.useState(null),[_,S]=A.useState("idle"),[k,E]=A.useState(null),x=De(),C=Go(l),T=Fo(),L=Qo(),{data:R,isLoading:M}=Ws(),I=A.useMemo(()=>R?.filter(ui),[R]),B=c?.isGitRepo??o,H=c?.worktreeReady??u,$=c?.reason??f,N=B!==!1&&H!==!1;A.useEffect(()=>{if(!e||!I)return;const G=I.find(Z=>!ht(Z));m(Z=>Z&&I.some(ae=>ae.provider.id===Z)?Z:G?.provider.id??"")},[e,I]),A.useEffect(()=>{if(e){const G=[v];w&&G.push(w),b(i?.trim()||G.join(`
60
+ `,Or={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};Oh(Ih);var Fh=function(e){var i=e.children,s=e.wrapperClass,l=s===void 0?"":s,g=e.contentClass,v=g===void 0?"":g,w=e.wrapperStyle,r=e.contentStyle,o=e.wrapperProps,u=o===void 0?{}:o,f=e.contentProps,a=f===void 0?{}:f,p=A.useContext(ss),m=p.init,y=p.cleanupWindowEvents,b=A.useRef(null),n=A.useRef(null);return A.useEffect(function(){var d=b.current,c=n.current;return d!==null&&c!==null&&m&&m?.(d,c),function(){y?.()}},[]),_e.createElement("div",Qe({},u,{ref:b,className:"".concat(Ds.wrapperClass," ").concat(Or.wrapper," ").concat(l),style:w}),_e.createElement("div",Qe({},a,{ref:n,className:"".concat(Ds.contentClass," ").concat(Or.content," ").concat(v),style:r}),i))},cn=function(){var e=A.useContext(ss);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},Hh=function(){var e=cn();return Vt(e)};function zh(e){var i=cn(),s=A.useState(e(Ps(i))),l=s[0],g=s[1];return A.useEffect(function(){var v=!0,w=i.onChange(function(r){v&&g(e(Ps(r.instance)))});return function(){w(),v=!1}},[e,i]),l}function Wh(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 $h(e,i){return Ee({queryKey:ie.files.tree(e||"",i),queryFn:()=>oe.get("/files/tree",{params:{workingDir:e||"",path:i}}),enabled:!!e})}function Uh(e,i){return Ee({queryKey:ie.files.content(e||"",i||""),queryFn:()=>oe.get("/files/read",{params:{workingDir:e||"",path:i||""}}),enabled:!!e&&!!i})}function qh(e){const i=De();return A.useCallback(()=>{e&&i.invalidateQueries({queryKey:["files","tree",e]})},[i,e])}function Kh(){const e=De();return Ct({mutationFn:i=>oe.post("/files/write",i),onSuccess:(i,s)=>{const l=ie.files.content(s.workingDir,s.path),g=e.getQueryData(l);e.setQueryData(l,{content:s.content,language:g?.language||Wh(s.path)})}})}function Xh(e,i){return e==="/"?`/${i}`:`${e}/${i}`}function Yh(e,i){return e==="/"?i:`${e.slice(1)}/${i}`}const Ir=({depth:e,active:i,onClick:s,leftIcon:l,rightIcon:g,label:v})=>t.jsxs("button",{type:"button",onClick:s,"aria-current":i||void 0,className:Q("w-full flex items-center gap-2 rounded-md px-2 py-1 text-left text-xs transition-colors outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/60",i?"bg-foreground/[0.06] font-medium text-foreground":"text-foreground/90 hover:bg-accent"),style:{paddingLeft:8+e*14},children:[t.jsx("span",{className:"shrink-0",children:g}),t.jsx("span",{className:"shrink-0 text-muted-foreground",children:l}),t.jsx("span",{className:"truncate",children:v})]}),dn=({workingDir:e,path:i,depth:s,expanded:l,toggleDir:g,onFileSelect:v,selectedFilePath:w})=>{const{t:r}=re(),{data:o,isLoading:u,isError:f}=$h(e,i),a=A.useMemo(()=>o?.items??[],[o?.items]);return u?t.jsx("div",{className:"text-xs text-muted-foreground px-2 py-1",style:{paddingLeft:8+s*14},children:r("Loading...")}):f?t.jsx("div",{className:"text-xs text-destructive-ink px-2 py-1",style:{paddingLeft:8+s*14},children:r("Failed to load")}):t.jsx("div",{className:"space-y-0.5",children:a.map(p=>{if(p.type==="directory"){const b=Xh(i,p.name),n=l.has(b);return t.jsxs("div",{children:[t.jsx(Ir,{depth:s,onClick:()=>g(b),rightIcon:n?t.jsx(Ke,{size:14,className:"text-muted-foreground/70"}):t.jsx(Je,{size:14,className:"text-muted-foreground/70"}),leftIcon:n?t.jsx(fi,{size:14}):t.jsx($s,{size:14}),label:p.name}),n&&t.jsx(dn,{workingDir:e,path:b,depth:s+1,expanded:l,toggleDir:g,onFileSelect:v,selectedFilePath:w})]},b)}const m=Yh(i,p.name),y=w===m;return t.jsx(Ir,{depth:s,active:y,onClick:()=>v(m),rightIcon:t.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:t.jsx(Lo,{name:p.name}),label:p.name},m)})})},Vh=({workingDir:e,className:i,onFileSelect:s,selectedFilePath:l,onCollapse:g})=>{const{t:v}=re(),[w,r]=A.useState(()=>new Set),o=qh(e),u=A.useCallback(f=>{r(a=>{const p=new Set(a);return p.has(f)?p.delete(f):p.add(f),p})},[]);return t.jsxs("div",{className:Q("h-full flex flex-col",i),children:[t.jsxs("div",{className:"px-3 py-2 border-b border-border bg-muted/40 flex items-center justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:v("Files")}),e?t.jsx("div",{title:e,className:"truncate font-mono text-[11px] text-muted-foreground",children:e}):t.jsx("div",{className:"truncate text-xs text-muted-foreground",children:v("No working directory")})]}),t.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e&&t.jsx($e,{size:"xs",label:v("Refresh file tree"),onClick:o,children:t.jsx(_t,{})}),g&&t.jsx($e,{size:"xs",label:v("Collapse file tree"),onClick:g,children:t.jsx(ka,{})})]})]}),t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin p-2",children:e?t.jsx(dn,{workingDir:e,path:"/",depth:0,expanded:w,toggleDir:u,onFileSelect:s,selectedFilePath:l}):t.jsx("div",{className:"text-xs text-muted-foreground px-2 py-2",children:v("No workspace selected.")})})]})},Gh=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function Qh(e){const i=e.split(".").pop()?.toLowerCase();return i?Gh.has(i):!1}function Zh(e,i){const s=zs(),l=new URLSearchParams({workingDir:e,path:i});return`${s}/files/image?${l.toString()}`}const Jh=({filePath:e})=>{const{t:i}=re(),{zoomIn:s,zoomOut:l,centerView:g}=Hh(),v=zh(r=>r.state.scale),w=Math.round(v*100);return t.jsxs("div",{className:"flex items-center gap-1 px-3 py-1.5 border-b border-border bg-muted/40 shrink-0",children:[t.jsx($e,{size:"xs",label:i("Zoom out"),onClick:()=>l(.5),children:t.jsx(Ia,{})}),t.jsxs(ce,{variant:"ghost",size:"xs",className:"min-w-10 tabular-nums",onClick:()=>g(1),title:i("Reset zoom"),children:[w,"%"]}),t.jsx($e,{size:"xs",label:i("Zoom in"),onClick:()=>s(.5),children:t.jsx(Ba,{})}),t.jsx($e,{size:"xs",label:i("Fit to view"),className:"ml-1",onClick:()=>g(1),children:t.jsx(Sa,{})}),t.jsx("span",{title:e,className:"ml-2 truncate font-mono text-[11px] text-muted-foreground",children:e})]})},eu=({workingDir:e,filePath:i})=>{const{t:s}=re(),[l,g]=A.useState(!1),v=Zh(e,i);return l?t.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:s("Failed to load image.")}):t.jsx(Bh,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx(Jh,{filePath:i}),t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden bg-[repeating-conic-gradient(#f3f3f3_0%_25%,#fff_0%_50%)] bg-[length:16px_16px]",children:t.jsx(Fh,{wrapperStyle:{width:"100%",height:"100%"},contentStyle:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx("img",{src:v,alt:i,className:"max-w-full max-h-full object-contain rounded shadow-raised",draggable:!1,onError:()=>g(!0)})})})]})})};function tu(e){const i=e.split("/");return i[i.length-1]||e}function su(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 ru=({active:e,name:i,isDirty:s,onClick:l,onClose:g})=>{const{t:v}=re();return t.jsxs("button",{type:"button",onClick:l,className:Q("group flex items-center gap-2 px-3 py-2 rounded-t-md border-t border-x -mb-px min-w-[120px] max-w-[240px] outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/60",e?"bg-background border-border text-foreground":"bg-foreground/[0.03] border-transparent text-muted-foreground hover:text-foreground hover:bg-foreground/[0.05]"),children:[t.jsx("span",{className:Q("w-2 h-2 rounded-full",s?"bg-warning":"bg-transparent")}),t.jsx("span",{className:"truncate flex-1 text-left text-xs",children:i}),t.jsx("span",{onClick:g,className:"opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100 pointer-coarse:opacity-100 p-0.5 hover:bg-foreground/[0.08] rounded transition-all shrink-0","aria-label":v("Close tab"),title:v("Close"),children:t.jsx(tt,{size:12})})]})},iu=_e.forwardRef(function({workingDir:i,className:s,readOnly:l=!1},g){const{t:v}=re(),[w,r]=A.useState([]),[o,u]=A.useState(null),[f,a]=A.useState(!1),[p,m]=A.useState(!1),[y,b]=A.useState(0),[n,d]=A.useState(null),c=A.useRef(null),h=Kh();A.useEffect(()=>{let U=!1;return Un(async()=>{const{preloadMonaco:z}=await import("./monaco-CcHqpOKe.js").then(W=>W.m);return{preloadMonaco:z}},__vite__mapDeps([0,1,2,3])).then(({preloadMonaco:z})=>z()).then(()=>{U||a(!0)}).catch(()=>{U||m(!0)}),()=>{U=!0}},[]);const[_,S]=A.useState(280),[k,E]=A.useState(!1),[x,C]=A.useState(!1),T=A.useRef(280),L=A.useCallback(()=>{E(U=>(U?S(T.current):T.current=_,!U))},[_]),R=A.useCallback(U=>{U.preventDefault(),C(!0);const z=U.clientX,W=_,j=X=>{const Y=X.clientX-z,ee=Math.min(480,Math.max(160,W+Y));S(ee)},F=()=>{C(!1),document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",F)};document.addEventListener("mousemove",j),document.addEventListener("mouseup",F)},[_]);A.useEffect(()=>{r([]),u(null),d(null)},[i]);const M=A.useMemo(()=>w.find(U=>U.path===o)||null,[w,o]),{data:I,isFetching:B,isError:H,error:$}=Uh(i,M?.isImage?null:o);A.useEffect(()=>{!o||!I||r(U=>U.map(z=>z.path!==o||z.isDirty||z.loaded?z:{...z,language:I.language||z.language,content:I.content,savedContent:I.content,isDirty:!1,loaded:!0}))},[o,I]);const N=A.useCallback((U,z,W)=>{r(j=>{if(j.find(Y=>Y.path===U))return j;const X=Qh(U);return[...j,{path:U,name:tu(U),language:su(U),content:"",savedContent:"",isDirty:!1,loaded:X,isImage:X}]}),u(U),d(z?{path:U,line:z,column:W}:null)},[]);_e.useImperativeHandle(g,()=>({openFile:N}),[N]);const P=A.useCallback(U=>{r(z=>{const W=z.filter(j=>j.path!==U);return u(j=>j!==U?j:W.length?W[W.length-1].path:null),W})},[]),D=A.useCallback(U=>{r(z=>z.map(W=>{if(W.path!==o)return W;const j=U!==W.savedContent;return{...W,content:U,isDirty:j}}))},[o]),O=A.useCallback(async()=>{l||!i||!M||(await h.mutateAsync({workingDir:i,path:M.path,content:M.content}),r(U=>U.map(z=>z.path===M.path?{...z,savedContent:z.content,isDirty:!1,loaded:!0}:z)))},[M,l,h,i]),q=A.useRef(()=>{});A.useEffect(()=>{q.current=()=>{O().catch(()=>{})}},[O]),A.useEffect(()=>{const U=z=>{l||(z.metaKey||z.ctrlKey)&&z.key.toLowerCase()==="s"&&(z.preventDefault(),q.current())};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[l]);const K=A.useCallback((U,z)=>{c.current=U,b(W=>W+1),U.addCommand(z.KeyMod.CtrlCmd|z.KeyCode.KeyS,()=>{q.current()})},[]);return A.useEffect(()=>{if(!n||n.path!==o||!M?.loaded)return;const U=c.current,z=U?.getModel();if(!U||!z)return;const W=Math.min(n.line,z.getLineCount()),j=Math.min(n.column??1,z.getLineMaxColumn(W)),F={lineNumber:W,column:j};U.setPosition(F),U.revealPositionInCenter(F),U.focus(),d(null)},[o,M?.loaded,y,n]),t.jsxs("div",{className:Q("flex h-full overflow-hidden bg-background",s),style:x?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsx("div",{className:"border-r border-border bg-background shrink-0 overflow-hidden relative",style:{width:k?36:_,transition:x?"none":"width 0.15s ease"},children:k?t.jsx("div",{className:"h-full flex items-start pt-2 justify-center",children:t.jsx($e,{size:"sm",label:v("Expand file tree"),onClick:L,children:t.jsx(ja,{className:"size-4"})})}):t.jsx(t.Fragment,{children:t.jsx(Vh,{workingDir:i,onFileSelect:N,selectedFilePath:M?.path||null,onCollapse:L},i||"no-working-dir")})}),!k&&t.jsx("div",{onMouseDown:R,className:Q("w-1 shrink-0 cursor-col-resize transition-colors",x?"bg-ring/40":"bg-transparent hover:bg-border")}),t.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1 px-2 pt-2 border-b border-border bg-muted overflow-x-auto shrink-0",children:[w.length===0?t.jsx("div",{className:"px-2 pb-2 text-xs text-muted-foreground",children:v("No open files")}):w.map(U=>t.jsx(ru,{active:U.path===o,name:U.name,isDirty:U.isDirty,onClick:()=>u(U.path),onClose:z=>{z.stopPropagation(),P(U.path)}},U.path)),t.jsxs("div",{className:"ml-auto flex items-center gap-2 pb-2 pr-1",children:[l&&t.jsx("span",{className:"text-xs text-muted-foreground",children:v("Read-only")}),h.isPending&&t.jsxs("span",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[t.jsx(xe,{}),v("Saving")]}),M?.isDirty&&!h.isPending&&t.jsx("span",{className:"text-xs text-warning-ink",children:v("Unsaved")})]})]}),t.jsx("div",{className:"flex-1 min-h-0 relative",children:i?M?M.isImage?t.jsx(eu,{workingDir:i,filePath:M.path}):p?t.jsx("div",{className:"h-full flex items-center justify-center text-destructive-ink text-sm",children:v("Failed to load editor.")}):f?t.jsxs(t.Fragment,{children:[t.jsx(jd,{path:M.path,value:M.content,language:M.language,theme:"vs-light",height:"100%",onChange:l?void 0:U=>D(U??""),onMount:K,options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",automaticLayout:!0,readOnly:l}}),B&&!M.loaded&&t.jsx("div",{className:"absolute inset-0 bg-background/60 flex items-center justify-center",children:t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[t.jsx(xe,{}),v("Loading file...")]})}),H&&t.jsx("div",{className:"absolute bottom-2 left-2 right-2 rounded-md bg-background shadow-raised",children:t.jsxs(Oe,{tone:"danger",size:"sm",children:[v("Failed to load file"),$ instanceof Error?`: ${$.message}`:""]})})]}):t.jsxs("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:[t.jsx(xe,{className:"mr-2"}),v("Loading editor...")]}):t.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:v("Select a file from the tree to open.")}):t.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:v("No workspace selected.")})})]})]})});function nu(e,i={}){const s=Qt(g=>g.visibleContext),l=Si(e,s);return Ee({queryKey:ie.git.changes(e||""),queryFn:()=>oe.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e&&(i.enabled??!0),refetchInterval:l,refetchIntervalInBackground:!1,refetchOnWindowFocus:l?"always":!1,refetchOnReconnect:l?"always":!1})}function ou(e,i,s){const l=Qt(v=>v.visibleContext),g=Si(e,l);return Ee({queryKey:ie.git.diff(e||"",i||"",s),queryFn:()=>oe.get("/git/diff",{params:{workingDir:e||"",path:i||"",type:s}}),enabled:!!e&&!!i,refetchInterval:g,refetchIntervalInBackground:!1,refetchOnWindowFocus:g?"always":!1,refetchOnReconnect:g?"always":!1})}function hn(e,i){return Ee({queryKey:ie.git.commitFiles(e||"",i||""),queryFn:()=>oe.get("/git/commit-files",{params:{workingDir:e||"",hash:i||""}}),enabled:!!e&&!!i})}function un(e,i,s){return Ee({queryKey:ie.git.commitDiff(e||"",i||"",s||""),queryFn:()=>oe.get("/git/commit-diff",{params:{workingDir:e||"",hash:i||"",path:s||""}}),enabled:!!e&&!!i&&!!s})}const au=new Set(["STARTING","RUNNING","STOPPING"]);function fn(e){return au.has(e.runtimeState)||e.runtimeInstanceId!==null}function mn(e){return e instanceof Ze&&e.status===409&&e.details.code==="WORKSPACE_HAS_ACTIVE_SERVICE"}const Fr="h-6 min-w-0 truncate rounded-md bg-foreground/[0.05] px-2 font-mono text-xs leading-6 text-foreground/85";function lu({from:e,to:i}){return t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{title:e,className:Fr,children:e}),t.jsx(ji,{size:14,className:"shrink-0 text-muted-foreground/70"}),t.jsx("span",{title:i,className:Fr,children:i})]})}function cu({services:e,isLoading:i,isError:s}){const{t:l}=re();return i?t.jsx(xe,{size:"xs",label:l("正在检查后台服务..."),className:"text-xs"}):e.length>0?t.jsxs(Oe,{tone:"warning",title:l("合并前将停止 {count} 个后台服务",{count:e.length}),children:[t.jsx("p",{className:"break-all font-mono text-xs",children:e.map(g=>g.name).join(", ")}),t.jsx("p",{className:"mt-1",children:l("停止后不会自动恢复。")})]}):s?t.jsx("p",{className:"text-xs text-warning-ink",role:"status",children:l("无法检查后台服务状态,提交时会再次确认。")}):null}const du={INVALID_BASE_BRANCH:"Choose an existing local branch different from the workspace branch.",BASE_BRANCH_UNRELATED:"The selected branch has no shared commit history with this workspace.",WORKSPACE_BASE_BRANCH_BUSY:"Wait for the Agent to finish or stop it before changing the base branch.",WORKSPACE_GIT_OPERATION_IN_PROGRESS:"Finish or abort the current Git operation before changing the base branch.",WORKSPACE_BASE_BRANCH_CHANGED:"The workspace changed. Refresh and select the base branch again.",INVALID_WORKSPACE_STATE:"Only active workspaces can change base branch. Refresh the list.",WORKSPACE_BASE_BRANCH_MANAGED:"TeamRun member base branches are managed by their parent workspace."};function pn(e){return e.isOpen?t.jsx(hu,{...e},e.workspaceId):null}function hu({isOpen:e,onClose:i,onBaseBranchSaved:s,projectId:l,workspaceId:g,branchName:v,targetBranch:w,commitMessage:r,isPending:o,canMerge:u,activeServices:f,isCheckingServices:a,serviceCheckFailed:p,error:m,onConfirm:y}){const{t:b}=re(),n=A.useId(),d=Uo(l),c=qo(),h=d.data?.workspaces.find(N=>N.id===g),_=h?.baseBranch||d.data?.mainBranch||w,[S,k]=A.useState(null),E=S??_,x=d.data?.branches.filter(N=>N!==v)??[],C=!!h&&E!==_,T=o||c.isPending,L=d.isPending||d.isFetching||d.isError,R=c.error instanceof Ze?String(c.error.details.code):"",[M,I]=A.useState(null),B=M??r??"",H=()=>{T||i()},$=async()=>{if(!(!h||!C))try{await c.mutateAsync({id:g,baseBranch:E,expectedBaseBranch:h.baseBranch}),ke.success(b("Workspace base branch saved. Review the changes before merging.")),i(),s?.()}catch{}};return t.jsx(At,{isOpen:e,onClose:H,title:b("提交变更"),className:"max-w-md",action:t.jsxs(t.Fragment,{children:[t.jsx(ce,{variant:"ghost",onClick:H,disabled:T,children:b("取消")}),t.jsx(ce,{variant:"primary",onClick:()=>y(B.trim()||void 0,f.length>0),disabled:T||a||L||C||!u,loading:o||a,children:o||a?a?b("正在检查后台服务..."):f.length>0?b("正在停止服务并提交..."):b("正在提交..."):t.jsxs(t.Fragment,{children:[t.jsx(Us,{}),f.length>0?b("停止服务并提交"):b("确认提交")]})})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsx(lu,{from:v,to:h?_:w}),d.isPending?t.jsx("p",{className:"text-xs text-muted-foreground",children:b("Loading...")}):d.isError?t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{role:"alert",className:"text-xs text-destructive-ink",children:b("Could not load branches. Refresh to try again.")}),t.jsx(ce,{size:"sm",onClick:()=>{d.refetch()},children:b("Refresh")})]}):h&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:n,className:"block text-[13px] font-medium text-foreground",children:b("Base branch for this workspace")}),t.jsx(Ko,{id:n,label:b("Base branch for this workspace"),value:E,branches:x,disabled:T,isRefreshing:d.isFetching,onOpen:()=>{d.refetch()},onChange:N=>{k(N),c.reset()}}),t.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:b("Changing this base branch updates the comparison, update and merge target for this workspace only. Save and review the changes before merging.")}),C&&t.jsx(ce,{variant:"primary",size:"sm",onClick:()=>{$()},disabled:T||L||!x.includes(E),children:c.isPending?b("Saving"):b("Save base branch and review changes")}),c.isError&&t.jsx("p",{role:"alert",className:"text-xs text-destructive-ink",children:b(du[R]??"Could not save the base branch. Refresh and try again.")})]}),!u&&t.jsx("p",{className:"text-xs text-muted-foreground",children:b("Review the changes and sync the base branch before submitting.")}),t.jsx(mi,{label:b("提交消息"),description:t.jsxs(t.Fragment,{children:[b("建议以 feat、fix、docs、refactor、chore 开头,保持提交记录清晰。feat 新增功能,fix 修复问题,docs 文档更新,refactor 代码重构,chore 日常维护。"),!B.trim()&&t.jsx("span",{className:"mt-1 block",children:b("留空将使用默认消息")})]}),children:t.jsx(pi,{value:B,onChange:N=>I(N.target.value),placeholder:b("请描述本次修改的内容"),minRows:4,className:"font-mono"})}),t.jsx(cu,{services:f,isLoading:a,isError:p}),m&&t.jsx(Oe,{tone:"danger",children:m})]})})}function at(e,i){const s=e[i];return typeof s=="string"&&s.length>0?s:void 0}function gn(e){if(!(e instanceof Ze)||e.status!==409)return;const i=e.details;if(i.code!=="MERGE_CONFLICT"||i.conflictOp!==kt.REBASE&&i.conflictOp!==kt.MERGE||!Array.isArray(i.conflictedFiles)||!i.conflictedFiles.every(l=>typeof l=="string"))return;const s=i.mergeStrategy==="squash"||i.mergeStrategy==="no_ff"?i.mergeStrategy:void 0;return{conflictOp:i.conflictOp,conflictedFiles:i.conflictedFiles,mergeAborted:typeof i.mergeAborted=="boolean"?i.mergeAborted:void 0,mergeStrategy:s,sourceBranch:at(i,"sourceBranch"),targetBranch:at(i,"targetBranch"),sourceWorktreePath:at(i,"sourceWorktreePath"),targetWorktreePath:at(i,"targetWorktreePath"),sourceWorkspaceId:at(i,"sourceWorkspaceId"),targetWorkspaceId:at(i,"targetWorkspaceId"),resolutionContextToken:at(i,"resolutionContextToken")}}function Hr(e,i,s,l){const g=gn(e);if(g){s(g);return}l(e instanceof Error?e.message:i)}function uu({projectId:e,workspaceId:i,branchName:s,targetBranch:l,commitMessage:g,committedFileCount:v,onRefreshCommitMessage:w,onConflict:r,onResolveConflicts:o}){const{t:u}=re(),{data:f,isLoading:a}=Xo(i),p=yi(),m=wi(),y=Ci(),[b,n]=A.useState(!1),[d,c]=A.useState(null),h=Gs(i,b),_=(h.data??[]).filter(fn);if(A.useEffect(()=>{b&&w?.()},[b,w]),a||!f)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground border-b border-border/60",children:[t.jsx(xe,{}),t.jsx("span",{className:"text-xs",children:u("正在检查工作区状态...")})]});const S=f.conflictedFiles.length>0,k=f.operation!=="idle",E=f.hasUncommittedChanges||f.untrackedCount>0,x=f.uncommittedCount+f.untrackedCount,C=!S&&!k&&!E,T=!E,L=f.operation==="idle"&&f.ahead===0&&f.behind===0&&!E&&!S,R=()=>{c(null),p.mutate(i,{onError:H=>{Hr(H,u("更新失败,请稍后重试"),$=>r($),c)}})},M=()=>{c(null),n(!0)},I=(H,$)=>{c(null),m.mutate({id:i,commitMessage:H,stopActiveServices:$},{onSuccess:()=>n(!1),onError:N=>{if(mn(N)){c(u("后台服务仍在运行,请确认停止服务后再提交。"));return}Hr(N,u("提交失败,请稍后重试"),P=>{n(!1),r(P)},c)}})},B=()=>{m.isPending||(n(!1),c(null))};return L?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground border-b border-border/60",children:[t.jsx(qn,{size:13,className:"shrink-0 text-muted-foreground/70"}),t.jsx("span",{className:"text-xs",children:u("当前分支还没有任何变更")})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"border-b border-border bg-background",children:t.jsxs("div",{className:"px-3 py-2",children:[d&&t.jsx(Oe,{tone:"danger",size:"sm",className:"mb-2",children:d}),E&&t.jsx(Oe,{tone:"warning",size:"sm",icon:t.jsx(_a,{}),className:"mb-2",children:u("{count} 个本地改动未处理,需要先整理后再继续",{count:x})}),S&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-foreground",children:[t.jsx(Tt,{size:13,className:"shrink-0 text-warning"}),t.jsx("span",{children:u("{count} 个文件存在冲突,需要处理后继续",{count:f.conflictedFiles.length})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[t.jsx(ce,{variant:"primary",size:"sm",onClick:o,children:u("处理冲突")}),t.jsx(ce,{variant:"secondary",size:"sm",onClick:()=>y.mutate(i),loading:y.isPending,children:y.isPending?u("正在撤销..."):u("撤销操作")})]})]}),k&&!S&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-foreground",children:[t.jsx(xe,{size:"xs",className:"text-info"}),t.jsx("span",{children:f.operation==="rebase"?u("正在同步源分支更新..."):u("正在提交变更...")})]}),t.jsxs(ce,{variant:"secondary",size:"sm",className:"ml-auto",onClick:()=>y.mutate(i),loading:y.isPending,children:[!y.isPending&&t.jsx(Zr,{}),y.isPending?u("正在撤销..."):u("撤销操作")]})]}),!S&&!k&&(f.behind>0||f.ahead>0)&&t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[f.behind>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:u("源分支 {branch} 有 {count} 个更新",{branch:l,count:f.behind})}),t.jsxs(ce,{variant:"primary",size:"sm",onClick:R,disabled:!C,loading:p.isPending,children:[!p.isPending&&t.jsx(_t,{}),p.isPending?u("正在同步..."):u("同步更新")]})]}),f.ahead>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:u("{count} 个文件变更,可以安全提交",{count:v??f.ahead})}),t.jsx("span",{title:T?void 0:u("需要先处理本地改动"),className:Q("inline-flex",!T&&"cursor-not-allowed"),children:t.jsxs(ce,{variant:"primary",size:"sm",onClick:M,disabled:!T||m.isPending,children:[t.jsx(Us,{}),u("提交变更")]})})]})]})]})}),t.jsx(pn,{projectId:e,workspaceId:i,canMerge:C&&f.ahead>0&&f.behind===0,isOpen:b,onClose:B,branchName:s,targetBranch:l,commitMessage:g,isPending:m.isPending,activeServices:_,isCheckingServices:h.isLoading,serviceCheckFailed:h.isError,error:d,onConfirm:I})]})}const vn=({line:e,lineNum:i})=>{let s="",l="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?s="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?s="bg-destructive/10":e.startsWith("@@")?(s="bg-info/5",l="text-info-ink"):(e.startsWith("diff ")||e.startsWith("index "))&&(l="text-muted-foreground"),t.jsxs("div",{className:Q("flex",s),children:[t.jsx("span",{"aria-hidden":"true",className:"w-10 shrink-0 select-none border-r border-border/60 pr-2 text-right text-muted-foreground/50",children:i}),t.jsx("span",{className:Q("whitespace-pre pl-2",l),children:e})]})},xs=50,Ss=400;function _n(e){const i=e.split("/");return i[i.length-1]||e}function fu(e){const i=e.lastIndexOf("/");return i>0?e.slice(0,i):""}function mu(e){const s=Math.floor(Date.now()/1e3)-e;return s<60?Ye("{count}s ago",{count:s}):s<3600?Ye("{count}m ago",{count:Math.floor(s/60)}):s<86400?Ye("{count}h ago",{count:Math.floor(s/3600)}):s<604800?Ye("{count}d ago",{count:Math.floor(s/86400)}):new Date(e*1e3).toLocaleDateString()}function Ut(e,i){return e.kind==="working"?`${e.diffType}:${i}`:`${e.hash}:${i}`}const Os=({additions:e,deletions:i,className:s})=>e===void 0&&i===void 0?null:t.jsx(Jr,{additions:e,deletions:i,className:s}),bn=({diff:e})=>{const{t:i}=re(),[s,l]=A.useState(!1),g=A.useMemo(()=>e.split(`
61
+ `),[e]);if(!e.trim())return t.jsx("div",{className:"py-6 text-center text-muted-foreground text-xs",children:i("没有可显示的差异内容")});const v=!s&&g.length>Ss,w=v?g.slice(0,Ss):g;return t.jsxs("div",{className:"overflow-x-auto scrollbar-app-thin font-mono text-xs leading-5",children:[w.map((r,o)=>t.jsx(vn,{line:r,lineNum:o+1},o)),v&&t.jsx("button",{type:"button",onClick:()=>l(!0),className:"w-full py-2 text-xs text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:i("还有 {count} 行变更被折叠,点击展开全部",{count:g.length-Ss})})]})},pu=({workingDir:e,path:i,diffType:s,enabled:l})=>{const{t:g}=re(),{data:v,isLoading:w,isError:r}=ou(e,l?i:null,s);return!l||w?t.jsxs("div",{className:"flex items-center justify-center gap-2 py-8 text-muted-foreground",children:[t.jsx(xe,{size:"sm"}),t.jsx("span",{className:"text-xs",children:g("正在加载差异...")})]}):r?t.jsx("div",{className:"py-6 text-center text-destructive-ink text-xs",children:g("差异加载失败")}):t.jsx(bn,{diff:v?.diff||""})},gu=({workingDir:e,hash:i,path:s,enabled:l})=>{const{t:g}=re(),{data:v,isLoading:w,isError:r}=un(e,l?i:null,l?s:null);return!l||w?t.jsxs("div",{className:"flex items-center justify-center gap-2 py-8 text-muted-foreground",children:[t.jsx(xe,{size:"sm"}),t.jsx("span",{className:"text-xs",children:g("正在加载差异...")})]}):r?t.jsx("div",{className:"py-6 text-center text-destructive-ink text-xs",children:g("差异加载失败")}):t.jsx(bn,{diff:v?.diff||""})},ys=({entry:e,source:i,workingDir:s,flash:l,registerNode:g})=>{const[v,w]=A.useState(!1),[r,o]=A.useState(!1),u=A.useRef(null),f=Ut(i,e.path);A.useEffect(()=>(g(f,u.current),()=>g(f,null)),[f,g]),A.useEffect(()=>{const p=u.current;if(!p||r)return;const m=new IntersectionObserver(y=>{y.some(b=>b.isIntersecting)&&(o(!0),m.disconnect())},{rootMargin:"300px 0px"});return m.observe(p),()=>m.disconnect()},[r]);const a=fu(e.path);return t.jsxs("div",{ref:u,"data-card-key":f,className:Q("rounded-md border border-border bg-background overflow-hidden transition-shadow",l&&"ring-2 ring-info/40"),children:[t.jsxs("button",{type:"button",onClick:()=>w(p=>!p),className:"w-full flex items-center gap-2 px-3 py-2 bg-muted/40 hover:bg-muted/70 transition-colors text-left",children:[v?t.jsx(Je,{size:13,className:"text-muted-foreground/70 shrink-0"}):t.jsx(Ke,{size:13,className:"text-muted-foreground/70 shrink-0"}),t.jsx(gi,{status:e.status}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:_n(e.path)}),a&&t.jsx("span",{className:"font-mono text-[11px] text-muted-foreground truncate",children:a}),t.jsx("span",{className:"ml-auto"}),t.jsx(Os,{additions:e.additions,deletions:e.deletions})]}),!v&&t.jsx("div",{className:"border-t border-border/60",children:i.kind==="working"?t.jsx(pu,{workingDir:s,path:e.path,diffType:i.diffType,enabled:r}):t.jsx(gu,{workingDir:s,hash:i.hash,path:e.path,enabled:r})})]})};function vu(e){const i={name:"",path:"",dirs:new Map,files:[]};for(const s of e){const l=s.path.split("/");let g=i;for(let v=0;v<l.length-1;v++){const w=l[v];g.dirs.has(w)||g.dirs.set(w,{name:w,path:g.path?`${g.path}/${w}`:w,dirs:new Map,files:[]}),g=g.dirs.get(w)}g.files.push(s)}return xn(i)}function xn(e){const i=new Map;for(const s of e.dirs.values()){let l=xn(s);for(;l.dirs.size===1&&l.files.length===0;){const g=[...l.dirs.values()][0];l={...g,name:`${l.name}/${g.name}`}}i.set(l.name,l)}return{...e,dirs:i}}const _u=({dir:e,depth:i,activeKey:s,onSelect:l})=>{const[g,v]=A.useState(!0);return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>v(w=>!w),className:"flex items-center gap-1.5 w-full px-2 py-1 rounded-sm hover:bg-muted/60 text-left",style:{paddingLeft:8+i*12},children:[g?t.jsx(fi,{size:12,className:"text-muted-foreground/70 shrink-0"}):t.jsx($s,{size:12,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:e.name})]}),g&&t.jsx(Sn,{node:e,depth:i+1,activeKey:s,onSelect:l})]})},Sn=({node:e,depth:i,activeKey:s,onSelect:l})=>t.jsxs(t.Fragment,{children:[[...e.dirs.values()].sort((g,v)=>g.name.localeCompare(v.name)).map(g=>t.jsx(_u,{dir:g,depth:i,activeKey:s,onSelect:l},g.path)),e.files.slice().sort((g,v)=>g.path.localeCompare(v.path)).map(g=>{const v=s===g.cardKey;return t.jsxs("button",{type:"button",onClick:()=>l(g),className:Q("flex items-center gap-1.5 w-full px-2 py-1 rounded-sm text-left",v?"bg-muted":"hover:bg-muted/60"),style:{paddingLeft:8+i*12},title:g.path,children:[t.jsx("span",{className:Q("w-1.5 h-1.5 rounded-full shrink-0",Kn[Mo(g.status)])}),t.jsx("span",{className:Q("text-xs truncate",v?"text-foreground font-medium":"text-foreground/90"),children:_n(g.path)})]},g.cardKey)})]}),bu=({workingDir:e,selectedHash:i,onSelectCommit:s})=>{const{t:l}=re(),{data:g,isLoading:v,fetchNextPage:w,hasNextPage:r,isFetchingNextPage:o}=Is({queryKey:ie.git.log(e),queryFn:({pageParam:f=0})=>oe.get("/git/log",{params:{workingDir:e,limit:String(xs),skip:String(f)}}),initialPageParam:0,getNextPageParam:(f,a)=>f.commits.length<xs?void 0:a.length*xs}),u=g?.pages.flatMap(f=>f.commits)||[];return v?t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 text-muted-foreground text-xs",children:[t.jsx(xe,{size:"xs"}),t.jsx("span",{children:l("正在加载提交记录...")})]}):u.length===0?t.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:l("暂无提交记录")}):t.jsxs("div",{className:"space-y-px px-1.5 pb-1.5",children:[u.map(f=>{const a=i===f.hash;return t.jsxs("button",{type:"button",onClick:()=>s(f),className:Q("flex items-start gap-1.5 w-full px-1.5 py-1 rounded-sm text-left group",a?"bg-muted":"hover:bg-muted/60"),title:f.message,children:[t.jsx("span",{className:Q("w-1.5 h-1.5 rounded-full mt-1.5 shrink-0 transition-colors",a?"bg-primary":"bg-border group-hover:bg-muted-foreground/60")}),t.jsxs("span",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:Q("block text-xs truncate",a?"text-foreground font-medium":"text-foreground/90"),children:f.message}),t.jsxs("span",{className:"block text-[11px] text-muted-foreground truncate",children:[t.jsx("span",{className:"font-mono",children:f.shortHash})," · ",f.author," · ",mu(f.timestamp)]})]})]},f.hash)}),r&&t.jsx("button",{type:"button",onClick:()=>w(),disabled:o,className:"w-full py-1.5 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 rounded-sm transition-colors flex items-center justify-center gap-1.5",children:o?t.jsxs(t.Fragment,{children:[t.jsx(xe,{size:"xs"})," ",l("正在加载...")]}):l("加载更多提交")})]})},xu=({projectId:e,workingDir:i,workspaceId:s,branchName:l,targetBranch:g,commitMessage:v,canRunGitOperations:w,onRefreshCommitMessage:r,onConflict:o,onResolveConflicts:u})=>{const{t:f}=re(),[a,p]=A.useState({kind:"overview"}),[m,y]=A.useState(""),[b,n]=A.useState(null),[d,c]=A.useState(null),{data:h,isLoading:_,isError:S}=nu(i),k=a.kind==="commit"?a.commit.hash:null,{data:E,isLoading:x}=hn(i,k),C=A.useRef(new Map),T=A.useRef(null),L=A.useRef(null),R=A.useCallback((z,W)=>{W?C.current.set(z,W):C.current.delete(z)},[]),{uncommitted:M,committed:I,commitFiles:B}=A.useMemo(()=>{const z=F=>!m.trim()||F.path.toLowerCase().includes(m.trim().toLowerCase());if(a.kind==="commit"){const F={kind:"commit",hash:a.commit.hash},X=(E?.files||[]).filter(z).map(Y=>({...Y,cardKey:Ut(F,Y.path)}));return{uncommitted:[],committed:[],commitFiles:X}}const W=(h?.uncommitted||[]).filter(z).map(F=>({...F,cardKey:Ut({kind:"working",diffType:"uncommitted"},F.path)})),j=(h?.committed||[]).filter(z).map(F=>({...F,cardKey:Ut({kind:"working",diffType:"committed"},F.path)}));return{uncommitted:W,committed:j,commitFiles:[]}},[a,h,E,m]),H=a.kind==="commit"?B:[...M,...I],$=A.useMemo(()=>vu(H),[H]),N=A.useMemo(()=>{let z=0,W=0;for(const j of H)z+=j.additions??0,W+=j.deletions??0;return{additions:z,deletions:W,files:H.length}},[H]),P=A.useCallback(()=>{const z=T.current;if(!z)return;const W=z.getBoundingClientRect().top;let j=null,F=Number.NEGATIVE_INFINITY;for(const[X,Y]of C.current){const ee=Y.getBoundingClientRect().top-W;ee<=48&&ee>F&&(F=ee,j=X)}if(!j){let X=null,Y=Number.POSITIVE_INFINITY;for(const[ee,G]of C.current){const Z=G.getBoundingClientRect().top-W;Z<Y&&(Y=Z,X=ee)}j=X}n(j)},[]);A.useEffect(()=>{const z=T.current;if(!z)return;let W=0;const j=()=>{cancelAnimationFrame(W),W=requestAnimationFrame(P)};return z.addEventListener("scroll",j,{passive:!0}),()=>{z.removeEventListener("scroll",j),cancelAnimationFrame(W)}},[P]);const D=A.useCallback(z=>{const W=C.current.get(z.cardKey);W&&(W.scrollIntoView({behavior:"smooth",block:"start"}),n(z.cardKey),c(z.cardKey),L.current&&clearTimeout(L.current),L.current=setTimeout(()=>c(null),1200))},[]),O=A.useCallback(z=>{p(W=>W.kind==="commit"&&W.commit.hash===z.hash?{kind:"overview"}:{kind:"commit",commit:z}),y(""),n(null),T.current?.scrollTo({top:0})},[]),q=A.useCallback(()=>{p({kind:"overview"}),y(""),n(null),T.current?.scrollTo({top:0})},[]);if(!i)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm bg-background h-full",children:f("未选择工作区")});const K=w&&e&&s&&l&&g,U=a.kind==="commit"?x:_;return t.jsxs("div",{className:"flex h-full w-full min-w-0 flex-col bg-background",children:[K&&o&&u&&t.jsx(uu,{projectId:e,workspaceId:s,branchName:l,targetBranch:g,commitMessage:v,committedFileCount:h?.committed?.length,onRefreshCommitMessage:r,onConflict:o,onResolveConflicts:u}),t.jsx("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border/60 shrink-0 min-h-[37px]",children:a.kind==="overview"?t.jsxs(t.Fragment,{children:[t.jsx(qs,{size:14,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:f("代码审查")}),t.jsx("span",{className:"text-xs text-muted-foreground",children:f("{count} 个文件",{count:N.files})}),t.jsx(Os,{additions:N.additions,deletions:N.deletions}),l&&g&&t.jsxs("span",{className:"ml-auto flex items-center gap-1 text-[11px] text-muted-foreground font-mono truncate",children:[t.jsx("span",{className:"truncate",children:l}),t.jsx(ks,{size:10,className:"rotate-180 shrink-0"}),t.jsx("span",{className:"truncate",children:g})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",onClick:q,className:"flex items-center gap-1 px-1.5 py-0.5 -ml-1.5 rounded-sm text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors shrink-0",children:[t.jsx(ks,{size:12}),f("全部变更")]}),t.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground/50 text-xs",children:"/"}),t.jsx("span",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:a.commit.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate",children:a.commit.message}),t.jsx(Os,{className:"ml-auto",additions:N.additions,deletions:N.deletions})]})}),t.jsxs("div",{className:"flex flex-1 min-h-0",children:[t.jsx("div",{ref:T,className:"flex-1 min-w-0 overflow-y-auto scrollbar-app-thin",children:U?t.jsx("div",{className:"p-3 space-y-3",children:[0,1].map(z=>t.jsxs("div",{className:"rounded-md border border-border overflow-hidden",children:[t.jsx("div",{className:"h-8 bg-muted/60 animate-pulse motion-reduce:animate-none"}),t.jsxs("div",{className:"p-3 space-y-2",children:[t.jsx("div",{className:"h-3 w-2/3 bg-muted animate-pulse motion-reduce:animate-none rounded-sm"}),t.jsx("div",{className:"h-3 w-1/2 bg-muted animate-pulse motion-reduce:animate-none rounded-sm"}),t.jsx("div",{className:"h-3 w-3/4 bg-muted animate-pulse motion-reduce:animate-none rounded-sm"})]})]},z))}):S&&a.kind==="overview"?t.jsx("div",{className:"flex-1 flex items-center justify-center py-16 text-destructive-ink text-sm",children:f("变更加载失败")}):H.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted-foreground",children:[t.jsx(Ts,{size:28,className:"mb-2 text-muted-foreground/70"}),t.jsx("span",{className:"text-xs",children:m.trim()?f("没有匹配筛选条件的文件"):a.kind==="commit"?f("该提交没有文件变更"):f("没有待审查的变更")})]}):a.kind==="commit"?t.jsx("div",{className:"p-3 space-y-3",children:B.map(z=>t.jsx(ys,{entry:z,source:{kind:"commit",hash:a.commit.hash},workingDir:i,flash:d===z.cardKey,registerNode:R},z.cardKey))}):t.jsxs("div",{className:"p-3 space-y-4",children:[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-xs font-medium text-muted-foreground",children:f("未提交")}),t.jsx("span",{className:"ml-2 text-[11px] tabular-nums text-muted-foreground",children:M.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:M.map(z=>t.jsx(ys,{entry:z,source:{kind:"working",diffType:"uncommitted"},workingDir:i,flash:d===z.cardKey,registerNode:R},z.cardKey))})]}),I.length>0&&t.jsxs("section",{children:[t.jsxs("div",{className:"sticky top-0 z-10 -mx-3 px-5 py-1.5 bg-background/95 backdrop-blur-sm",children:[t.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:f("已提交")}),t.jsx("span",{className:"ml-2 text-[11px] tabular-nums text-muted-foreground",children:I.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:I.map(z=>t.jsx(ys,{entry:z,source:{kind:"working",diffType:"committed"},workingDir:i,flash:d===z.cardKey,registerNode:R},z.cardKey))})]})]})}),t.jsxs("aside",{className:"shrink-0 border-l border-border flex flex-col min-h-0",style:{width:"clamp(15rem, 24%, 22rem)"},children:[t.jsx("div",{className:"p-2 shrink-0",children:t.jsx(Wo,{size:"sm",value:m,onValueChange:y,placeholder:f("筛选文件...")})}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin px-1.5 pb-1.5 min-h-0",children:H.length===0?t.jsx("div",{className:"px-2 py-3 text-xs text-muted-foreground",children:m.trim()?f("无匹配文件"):f("暂无变更文件")}):t.jsx(Sn,{node:$,depth:0,activeKey:b,onSelect:D})}),t.jsxs("div",{className:"shrink-0 border-t border-border/60 max-h-[40%] flex flex-col min-h-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 shrink-0",children:[t.jsx(Kt,{size:12,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:f("提交记录")})]}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin min-h-0",children:t.jsx(bu,{workingDir:i,selectedHash:k,onSelectCommit:O})})]})]})]})]})},ws=50;function Su(e){const s=Math.floor(Date.now()/1e3)-e;return s<60?Ye("{count}s ago",{count:s}):s<3600?Ye("{count}m ago",{count:Math.floor(s/60)}):s<86400?Ye("{count}h ago",{count:Math.floor(s/3600)}):s<604800?Ye("{count}d ago",{count:Math.floor(s/86400)}):new Date(e*1e3).toLocaleDateString()}function yu(e){const i=e.split("/");return i[i.length-1]||e}function wu(e){const i=e.lastIndexOf("/");return i>0?e.slice(0,i):""}const Cu=({workingDir:e,hash:i,filePath:s})=>{const{t:l}=re(),{data:g,isLoading:v,isError:w}=un(e,i,s);if(v)return t.jsxs("div",{className:"flex-1 flex items-center justify-center gap-2 text-muted-foreground",children:[t.jsx(xe,{size:"md"}),t.jsx("span",{className:"text-xs",children:l("Loading diff...")})]});if(w)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive-ink text-xs",children:l("Failed to load diff.")});const r=g?.diff||"";if(!r.trim())return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-xs",children:l("No diff content available.")});const o=r.split(`
62
+ `);return t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin font-mono text-xs leading-5",children:o.map((u,f)=>t.jsx(vn,{line:u,lineNum:f+1},f))})},ku=({workingDir:e,hash:i,selectedPath:s,onSelectFile:l})=>{const{t:g}=re(),{data:v,isLoading:w}=hn(e,i);if(w)return t.jsxs("div",{className:"pl-7 py-1 text-xs text-muted-foreground flex items-center gap-1",children:[t.jsx(xe,{size:"xs"}),t.jsx("span",{children:g("Loading...")})]});const r=v?.files||[];return r.length===0?t.jsx("div",{className:"pl-7 py-1 text-xs text-muted-foreground",children:g("No files changed")}):t.jsx("div",{className:"pl-7 pb-1 space-y-0.5",children:r.map(o=>{const u=wu(o.path);return t.jsxs("button",{type:"button",onClick:f=>{f.stopPropagation(),l(o.path)},className:Q("flex items-center gap-2 px-1.5 py-1 rounded-sm cursor-pointer w-full text-left",s===o.path?"bg-muted":"hover:bg-muted/60"),children:[t.jsx(gi,{status:o.status}),t.jsx("span",{className:"min-w-0 text-xs text-foreground truncate",children:yu(o.path)}),u&&t.jsx("span",{className:"min-w-0 flex-1 truncate text-right font-mono text-[11px] text-muted-foreground [direction:rtl]",children:t.jsx("span",{dir:"ltr",children:u})})]},o.path)})})},Eu=({workingDir:e})=>{const{t:i}=re(),s=Qt(E=>E.visibleContext),l=Yo(e,s),{data:g,isLoading:v,isError:w,fetchNextPage:r,hasNextPage:o,isFetchingNextPage:u}=Is({queryKey:ie.git.log(e||""),queryFn:({pageParam:E=0})=>oe.get("/git/log",{params:{workingDir:e||"",limit:String(ws),skip:String(E)}}),initialPageParam:0,getNextPageParam:(E,x)=>E.commits.length<ws?void 0:x.length*ws,enabled:!!e,refetchInterval:l,refetchIntervalInBackground:!1,refetchOnWindowFocus:l?"always":!1,refetchOnReconnect:l?"always":!1}),f=g?.pages.flatMap(E=>E.commits)||[],[a,p]=A.useState(null),[m,y]=A.useState(null),[b,n]=A.useState(280),[d,c]=A.useState(!1),h=A.useCallback(E=>{E.preventDefault(),c(!0);const x=E.clientX,C=b,T=R=>{const M=Math.min(480,Math.max(180,C+(R.clientX-x)));n(M)},L=()=>{c(!1),document.removeEventListener("mousemove",T),document.removeEventListener("mouseup",L)};document.addEventListener("mousemove",T),document.addEventListener("mouseup",L)},[b]),_=E=>{a===E?(p(null),y(null)):(p(E),y(null))},S=A.useRef(null);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm bg-background h-full",children:i("No workspace selected.")});if(v)return t.jsxs("div",{className:"flex-1 flex items-center justify-center gap-2 text-muted-foreground bg-background h-full",children:[t.jsx(xe,{size:"md"}),t.jsx("span",{className:"text-sm",children:i("Loading history...")})]});if(w)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive-ink text-sm bg-background h-full",children:i("Failed to load history.")});if(f.length===0)return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-12 text-muted-foreground bg-background h-full",children:[t.jsx(Kt,{size:28,className:"mb-2 text-muted-foreground/70"}),t.jsx("span",{className:"text-xs",children:i("No commit history")})]});const k=f.find(E=>E.hash===a);return t.jsxs("div",{className:"flex h-full bg-background",style:d?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsxs("div",{className:"border-r border-border flex flex-col shrink-0",style:{width:b},children:[t.jsx("div",{className:"px-3 py-2.5 border-b border-border/60 shrink-0",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Kt,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:i("History")}),t.jsx("span",{className:"text-[11px] tabular-nums bg-muted px-1.5 py-0.5 rounded-full text-muted-foreground",children:f.length})]})}),t.jsxs("div",{ref:S,className:"flex-1 overflow-auto scrollbar-app-thin p-1.5",children:[f.map(E=>{const x=a===E.hash;return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>_(E.hash),className:Q("flex items-start gap-2 px-2 py-1.5 rounded-sm cursor-pointer w-full text-left group",x?"bg-muted":"hover:bg-muted/60"),children:[t.jsx("div",{className:"flex flex-col items-center shrink-0 pt-1",children:t.jsx("div",{className:Q("w-2 h-2 rounded-full shrink-0 transition-colors",x?"bg-primary":"bg-border group-hover:bg-muted-foreground/60")})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:E.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate flex-1",children:E.message}),t.jsx(Je,{size:12,className:Q("shrink-0 text-muted-foreground/70 transition-transform",x&&"rotate-90")})]}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.jsx("span",{className:"text-xs text-muted-foreground truncate",children:E.author}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:Su(E.timestamp)})]})]})]}),x&&t.jsxs(t.Fragment,{children:[E.body&&t.jsx("div",{className:"pl-7 pr-2 py-1.5 text-xs text-muted-foreground whitespace-pre-wrap leading-5 border-l-2 border-border ml-3",children:E.body}),t.jsx(ku,{workingDir:e,hash:E.hash,selectedPath:m,onSelectFile:y})]})]},E.hash)}),o&&t.jsx("button",{type:"button",onClick:()=>r(),disabled:u,className:"w-full py-2 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 rounded-sm transition-colors flex items-center justify-center gap-1.5",children:u?t.jsxs(t.Fragment,{children:[t.jsx(xe,{size:"xs"})," ",i("Loading...")]}):i("Load more")})]})]}),t.jsx("div",{onMouseDown:h,className:Q("w-1 shrink-0 cursor-col-resize transition-colors",d?"bg-ring/40":"bg-transparent hover:bg-border")}),t.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:m&&a?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(Ts,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:m}),t.jsxs("span",{className:"font-mono text-[11px] text-muted-foreground",children:["(",k?.shortHash,")"]})]}),t.jsx(Cu,{workingDir:e,hash:a,filePath:m})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(Ts,{size:28,className:"text-muted-foreground/70"}),t.jsx("span",{className:"text-xs",children:i(a?"Select a file to view diff":"Select a commit to view changes")})]})})})]})},zr=zs();function ju(e){if(!zr)return e;try{const i=new URL(zr);return new URL(e,i.origin).toString()}catch{return e}}function yn(e){return{...e,viewUrl:e.viewUrl?ju(e.viewUrl):null}}function Nu(e,i=!0){return Ee({queryKey:ie.previews.status(e??""),queryFn:async()=>{const s=await oe.get(`/previews/${e}/status`);return yn(s)},enabled:!!e&&i,refetchOnWindowFocus:!1})}function Tu(e){const i=De();return Ct({mutationFn:async s=>{const l=await oe.put(`/previews/${e}/config`,{target:s});return yn(l)},onSuccess:s=>{e&&(i.setQueryData(ie.previews.status(e),s),i.invalidateQueries({queryKey:ie.workspaces.all}))}})}function Au(){return window.location.protocol==="https:"?"remote":"local"}function Ru(e,i,s=!0){const[l,g]=A.useState(null),[v,w]=A.useState(!1),[r,o]=A.useState(null),[u,f]=A.useState(0);return A.useEffect(()=>{if(!s||!e||!i?.ready||!i.target){g(null),w(!1),o(null);return}let a=!1,p=null,m=null;g(null);const y=n=>{oe.delete(`/previews/${e}/sessions/${n}`).catch(()=>{})};return(async()=>{w(!0),o(null);try{const n={mode:Au(),localHostname:window.location.hostname},d=await oe.post(`/previews/${e}/sessions`,n);if(a){y(d.id);return}p=d.id,g(d),m=window.setInterval(async()=>{if(p)try{const c=await oe.post(`/previews/${e}/sessions/${p}/heartbeat`);a||(g(c),o(null))}catch(c){!a&&c instanceof Ze&&c.status===404?f(h=>h+1):a||o(c instanceof Error?c:new Error("Preview session heartbeat failed"))}},3e4)}catch(n){a||(g(null),o(n instanceof Error?n:new Error("Failed to open preview session")))}finally{a||w(!1)}})(),()=>{a=!0,m!==null&&window.clearInterval(m),p&&y(p)}},[s,u,i?.ready,i?.target,e]),{session:l,isOpening:v,error:r,retry:()=>f(a=>a+1)}}const Lu="agent-tower-preview",Mu="agent-tower-preview-host";function Du(){return"3000, localhost:3000, http://127.0.0.1:5173"}function Pu(e){if(!e)return null;try{return new URL(e).origin}catch{return null}}function Bu(e){return t.jsx(Ou,{...e},e.workspaceId??"no-workspace")}function Ou({workspaceId:e,readOnly:i,navigationRequest:s,onNavigationRequestHandled:l}){const{t:g}=re(),[v,w]=A.useState(null),o=!(s?.source.kind==="visualization")&&!v,{data:u,isLoading:f,refetch:a,isFetching:p}=Nu(e,o),m=Tu(e),{session:y,isOpening:b,error:n,retry:d}=Ru(e,u,o),c=A.useRef(null),h=A.useRef(null),_=A.useRef(null),S=A.useRef(null),k=A.useRef(null),E=A.useRef(null),[x,C]=A.useState(0),[T,L]=A.useState({target:null,address:"",iframeSrc:null,isFrameLoading:!1}),R=Pu(y?.viewUrl),M=u&&T.target!==u.target?{target:u.target,address:u.target??"",iframeSrc:null,isFrameLoading:!1}:u&&!u.ready&&T.iframeSrc?{...T,iframeSrc:null,isFrameLoading:!1}:T,I=A.useCallback(K=>{L(U=>({...u&&U.target!==u.target?{target:u.target,address:u.target??"",iframeSrc:null,isFrameLoading:!1}:U,...K}))},[u]);A.useEffect(()=>{if(!y||y.target!==u?.target)return;const K=k.current!==R;k.current=R,L(U=>{const z=s?.source.kind==="web"&&E.current!==s.id?Dt(s.source.url,y.target,y.viewUrl):null;if(!K&&U.iframeSrc&&U.target===y.target&&z?.kind!=="proxy")return U;let W=U.iframeSrc;if(z?.kind==="proxy")W=z.url;else if(!W||U.target!==y.target||K){const F=_.current;if(F)W=ho(y.viewUrl,F);else{const X=Dt(U.address||y.target,y.target,y.viewUrl);W=X?.kind==="proxy"?X.url:y.viewUrl}}_.current=null;const j=S.current;return j&&!j.closed&&W&&j.location.replace(W),S.current=null,{target:y.target,address:z?.kind==="proxy"?s?.source.kind==="web"?s.source.url:U.address:U.address||y.target,iframeSrc:W,isFrameLoading:!!W}})},[s,y,R,u?.target]),A.useEffect(()=>()=>{S.current?.close()},[]);const B=A.useCallback(async(K,U=!1)=>{const z=Dt(K,u?.target??null,y?.viewUrl??null);if(!z||!e)return;if(w(null),z.kind==="proxy"){if(U){window.open(z.url,"_blank","noopener,noreferrer");return}L({target:u?.target??null,address:K,iframeSrc:z.url,isFrameLoading:!0});return}if(i)return;const W=U?window.open("about:blank","_blank"):null;W&&(W.opener=null);try{_.current=z.path,S.current=W;const j=await m.mutateAsync(z.target);L({target:j.target,address:K.trim(),iframeSrc:null,isFrameLoading:!!j.ready}),C(F=>F+1),ke.success(g("Preview target saved")),j.ready||(S.current?.close(),S.current=null)}catch(j){S.current?.close(),S.current=null,_.current=null;const F=j instanceof Error?j.message:g("Failed to save preview target");ke.error(F)}},[y?.viewUrl,i,u?.target,g,m,e]);A.useEffect(()=>{if(!s||E.current===s.id||s.source.kind==="web"&&f)return;const K=window.setTimeout(()=>{E.current=s.id,l?.(s.id),s.source.kind==="visualization"?(w({source:s.source,iframeSrc:uo(s.source.sessionId,s.source.file),isFrameLoading:!0}),C(U=>U+1)):(w(null),B(s.source.url))},0);return()=>window.clearTimeout(K)},[f,B,s,l]),A.useEffect(()=>{if(v)return;const K=U=>{if(U.source!==c.current?.contentWindow)return;const z=U.data;if(!(!z||z.source!==Lu)){if(z.type==="location"&&typeof z.href=="string"){const W=fo(u?.target??null,y?.viewUrl??null,z.href,window.location.href);W&&document.activeElement!==h.current&&I({target:u?.target??M.target,address:W,isFrameLoading:!1});return}z.type==="navigate-loopback"&&typeof z.href=="string"&&B(z.href,z.newTab===!0)}};return window.addEventListener("message",K),()=>window.removeEventListener("message",K)},[M.target,B,I,y?.viewUrl,u?.target,v]);const H=K=>{c.current?.contentWindow?.postMessage({source:Mu,action:K},"*")},$=K=>{K.preventDefault(),B(M.address)},N=async()=>{if(v){w(U=>U&&{...U,isFrameLoading:!0}),C(U=>U+1);return}const K=await a();if(!K.data?.ready){I({target:K.data?.target??M.target,iframeSrc:null,isFrameLoading:!1});return}if(!y||!M.iframeSrc){d();return}I({isFrameLoading:!0}),H("reload")},P=()=>{if(v){window.open(v.iframeSrc,"_blank","noopener,noreferrer");return}if(!y?.viewUrl)return;const K=Dt(M.address||y.target,y.target,y.viewUrl),U=K?.kind==="proxy"?K.url:y.viewUrl;window.open(U,"_blank","noopener,noreferrer")};if(!e)return t.jsx("div",{className:"h-full flex items-center justify-center bg-background text-sm text-muted-foreground",children:g("No active workspace.")});const D=v?.iframeSrc??M.iframeSrc,O=!!v,q=!O&&(f||p||m.isPending||b);return t.jsxs("div",{className:"h-full flex flex-col bg-background",children:[t.jsxs("div",{className:"shrink-0 border-b border-border bg-muted/40 px-2 py-2",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx($e,{label:g("Back"),onClick:()=>{O?w(null):H("back")},disabled:!O&&!M.iframeSrc,children:t.jsx(ks,{})}),t.jsx($e,{label:g("Forward"),onClick:()=>H("forward"),disabled:O||!M.iframeSrc,children:t.jsx(ji,{})}),t.jsx($e,{label:!O&&M.isFrameLoading?g("Stop loading"):g("Refresh preview"),onClick:!O&&M.isFrameLoading?()=>{H("stop"),I({isFrameLoading:!1})}:N,disabled:!O&&!M.isFrameLoading&&p,children:!O&&M.isFrameLoading?t.jsx(tt,{}):p?t.jsx(xe,{}):t.jsx(_t,{})}),t.jsx("form",{className:"min-w-0 flex-1",onSubmit:$,children:t.jsx($o,{ref:h,size:"sm",prefix:t.jsx(ma,{}),value:v?.source.file??M.address,onChange:K=>I({address:K.target.value}),onKeyDown:K=>{K.key==="Enter"&&K.nativeEvent.isComposing&&K.preventDefault()},disabled:O||i||m.isPending,placeholder:Du(),"aria-label":g("Preview address")})}),t.jsx($e,{label:g("Open preview in new tab"),onClick:P,disabled:!D,children:t.jsx(Hs,{})})]}),t.jsxs("div",{className:"mt-1 flex min-h-4 items-center justify-between gap-2 px-1 text-xs leading-4",children:[t.jsx("span",{className:"truncate text-muted-foreground",children:O?g("Viewing agent visualization"):q?g("Checking preview target..."):n?n.message:u?.ready?`${g("Proxying")} ${u.target}`:u?.configured?`${g("Preview target is not reachable")}${u.error?`: ${u.error}`:""}`:g("Enter a local preview URL on the Agent Tower machine.")}),t.jsx("span",{className:"shrink-0 text-muted-foreground",children:g(O?"Session file":"Loopback only")})]})]}),t.jsx("div",{className:"relative flex-1 min-h-0 bg-background",children:D?t.jsx("iframe",{ref:c,src:D,title:g("Preview"),className:"absolute inset-0 h-full w-full border-0 bg-white",sandbox:O?"allow-modals allow-pointer-lock allow-presentation allow-scripts":"allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts",allow:"clipboard-read; clipboard-write; fullscreen",onLoad:()=>{O?w(K=>K&&{...K,isFrameLoading:!1}):I({isFrameLoading:!1})}},x):t.jsx("div",{className:"absolute inset-0 flex items-center justify-center px-4 text-center text-sm text-muted-foreground",children:u?.configured?u.ready&&b?g("Checking preview target..."):g("Start the preview server, then refresh."):g("Configure a local preview target to display it here.")})})]})}const Iu={[We.ACTIVE]:"success",[We.MERGED]:"info",[We.HIBERNATED]:"warning",[We.ABANDONED]:"neutral"};function Fu(e){return e.length<=34?e:`...${e.slice(-31)}`}function Hu({workspaces:e,teamRun:i,selectedWorkspaceId:s,onSelectWorkspace:l,disabled:g,className:v,buttonClassName:w}){const{t:r}=re(),o=A.useMemo(()=>Ys(e,i),[e,i]),u=o.find(f=>f.workspace.id===s)??o[0];return o.length<=1?null:t.jsx("div",{className:Q("relative",v),children:t.jsxs(_i,{children:[t.jsxs(bi,{disabled:g,className:Q("group inline-flex h-8 max-w-[340px] items-center gap-2 rounded-md border border-border bg-background px-2.5 text-left text-xs text-foreground/80 outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring/60 disabled:cursor-not-allowed disabled:opacity-40 data-[state=open]:bg-accent",w),title:r("Workspace"),children:[t.jsx(js,{size:14,className:"shrink-0 text-muted-foreground"}),t.jsx(Wt,{size:"sm",shape:"tag",children:r(u.roleLabel)}),t.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",children:r(u.displayName)}),t.jsx("span",{className:"min-w-0 truncate font-mono text-[11px] text-muted-foreground",children:Fu(jt(u.workspace))}),t.jsx(Ke,{size:13,className:"shrink-0 text-muted-foreground/70 transition-transform group-data-[state=open]:rotate-180"})]}),t.jsx(xi,{className:"w-[420px] max-w-[calc(100vw-2rem)]",children:t.jsx(Bo,{value:u.workspace.id,onValueChange:l,children:o.map(f=>t.jsxs(Oo,{value:f.workspace.id,icon:t.jsx(Qr,{className:"mt-0.5 size-3.5"}),className:"items-start",children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{className:"truncate",children:r(f.displayName)}),t.jsx(Wt,{size:"sm",shape:"tag",children:r(f.roleLabel)}),t.jsx(Wt,{size:"sm",tone:Iu[f.workspace.status],children:f.workspace.status})]}),t.jsx("span",{className:"mt-0.5 block truncate font-mono text-[11px] font-normal text-muted-foreground",children:jt(f.workspace)}),t.jsxs("span",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs font-normal text-muted-foreground",children:[f.ownerName&&t.jsxs("span",{children:[r("Owner"),": ",f.ownerName]}),f.parentBranchName&&t.jsxs("span",{children:[r("Parent"),": ",f.parentBranchName]}),t.jsx("span",{className:"font-mono text-[11px]",children:f.workspace.id.slice(0,8)})]})]},f.workspace.id))})})]})})}const zu=[{key:"review",label:"Changes",icon:t.jsx(qs,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(vi,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(yt,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(ki,{size:14})}],Wu=[{key:"history",label:"History",icon:t.jsx(Kt,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(vi,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(yt,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(ki,{size:14})}],$u=({active:e,onClick:i,icon:s,label:l})=>t.jsxs("button",{type:"button",onClick:i,className:Q("flex shrink-0 items-center gap-2 px-4 py-2 text-xs font-medium transition-all rounded-t-md border-t border-x -mb-px whitespace-nowrap outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/60",e?"bg-background border-border text-foreground z-10":"bg-transparent border-transparent text-muted-foreground hover:text-foreground hover:bg-foreground/[0.05]"),children:[s,t.jsx("span",{children:l})]}),Uu=({active:e,onClick:i,icon:s,label:l})=>t.jsx("button",{type:"button",onClick:i,title:l,"aria-label":l,"aria-pressed":e,className:Q("flex h-9 w-9 items-center justify-center rounded-lg transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",e?"bg-background text-foreground shadow-raised ring-1 ring-border/80":"text-muted-foreground hover:bg-foreground/[0.05] hover:text-foreground"),children:s}),Yf=_e.memo(function({className:i,sessionId:s,workspaceId:l,workingDir:g,projectId:v,hideChanges:w,gitAvailable:r=!0,readOnly:o,repoDeleted:u,teamRun:f,teamStatus:a,subtasks:p,handoff:m,gitProps:y,workspaces:b,selectedWorkspaceId:n,onSelectWorkspace:d,variant:c="tabs",expanded:h,onExpandedChange:_,minContentWidth:S=520,tabRef:k,previewRequest:E,onPreviewRequestHandled:x}){const{t:C}=re(),T=Qt(te=>te.setVisibleContext),L=c==="rail",[R,M]=A.useState(!1),I=L?h??R:!0,B=A.useCallback(te=>{h===void 0&&M(te),_?.(te)},[h,_]),H=p!=null,$=m!=null,N=A.useMemo(()=>{const te=w?Wu:zu,me=r?te:te.filter(Re=>Re.key!=="review"&&Re.key!=="history"),Pe=o?me.filter(Re=>Re.key!=="terminal"):me,qe=H?[...Pe,{key:"subtasks",label:"Subtasks",icon:t.jsx(ni,{size:14})}]:Pe,ve=$?[...qe,{key:"handoff",label:"Handoff note",icon:t.jsx(wa,{size:14})}]:qe;return f?[{key:"team-status",label:"Team Status",icon:t.jsx(vt,{size:14})},...ve]:ve},[r,w,o,f,H,$]),[P,D]=A.useState(()=>E?"preview":r?w?"history":"review":"editor"),O=A.useRef(null),q=A.useRef(0),[K,U]=A.useState(),z=A.useCallback(te=>{D(te),L&&B(!0)},[L,B]);A.useImperativeHandle(k,()=>({setTab:te=>z(te),openFile:(te,me,Pe)=>{z("editor"),requestAnimationFrame(()=>O.current?.openFile(te,me,Pe))},openPreview:(te,me)=>{q.current+=1,U({id:q.current,source:te,workspaceId:me}),z("preview")}}),[z]);const W=E??K,j=W?.workspaceId&&W.workspaceId!==l?void 0:W,F=A.useCallback(te=>{U(me=>me?.id===te?void 0:me),x?.(te)},[x]),{data:X}=Vo(v??""),Y=A.useMemo(()=>{if(!X?.quickCommands)return[];try{return JSON.parse(X.quickCommands)}catch{return[]}},[X?.quickCommands]),[ee,G]=A.useState([]),Z=A.useRef(void 0);A.useEffect(()=>{g&&g!==Z.current&&(Z.current=g,G(te=>te.includes(g)?te:[...te,g]))},[g]),A.useEffect(()=>{N.some(te=>te.key===P)||D(N[0]?.key??"editor")},[P,N]),A.useEffect(()=>{if(L&&!I)return;const te=P==="review"?"changes":P==="history"?"history":null;if(!l||!g||!te){T(null);return}return T({workspaceId:l,workingDir:g,tab:te}),()=>{T(null)}},[P,I,L,T,g,l]);const ae=!!d&&Ys(b,f).length>1,he=N.find(te=>te.key===P)??N[0],je=he?C(he.label):"",se=o?t.jsx(Oe,{size:"sm",className:"mx-2 mt-2",children:C(u?"项目已删除且本地仓库文件已清理。这里只保留历史视图。":"项目已删除。Workspace 以只读模式展示历史内容。")}):null,Ae=t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[ae&&P!=="subtasks"&&P!=="handoff"&&t.jsx("div",{className:"shrink-0 px-3 py-1.5 border-b border-border/60 bg-muted/40",children:t.jsx(Hu,{workspaces:b,teamRun:f,selectedWorkspaceId:n,onSelectWorkspace:d,buttonClassName:"h-7"})}),t.jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[P==="team-status"&&f&&a,P==="subtasks"&&p,P==="handoff"&&m,P==="editor"&&t.jsx(iu,{ref:O,workingDir:g,readOnly:o}),ee.map(te=>{const me=P==="terminal"&&g===te;return t.jsx("div",{"aria-hidden":!me,className:"absolute inset-0 h-full w-full min-h-0 min-w-0 overflow-hidden",style:{display:me?"block":"none"},children:t.jsx(_c,{cwd:te,workspaceId:me?l:void 0,isVisible:me,quickCommands:Y})},te)}),P==="preview"&&t.jsx(Bu,{workspaceId:l,readOnly:o,navigationRequest:j,onNavigationRequestHandled:F}),P==="review"&&t.jsx(xu,{projectId:v,workingDir:g,workspaceId:l,branchName:y?.branchName,targetBranch:y?.targetBranch,commitMessage:y?.commitMessage,canRunGitOperations:y?.canRunGitOperations,onRefreshCommitMessage:y?.onRefreshCommitMessage,onConflict:y?.onConflict,onResolveConflicts:y?.onResolveConflicts}),P==="history"&&t.jsx(Eu,{workingDir:g})]})]});return L?t.jsxs("div",{className:Q("flex h-full w-full min-w-0 bg-background",i),children:[t.jsx("div",{className:"flex h-full w-12 shrink-0 flex-col items-center gap-1 border-l border-border bg-muted/35 px-1.5 py-2",children:N.map(te=>t.jsx(Uu,{active:I&&P===te.key,onClick:()=>z(te.key),icon:te.icon,label:C(te.label)},te.key))}),I&&t.jsxs("div",{className:"flex h-full min-w-0 flex-1 flex-col border-l border-border bg-background",style:{minWidth:S},children:[se,t.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between gap-3 border-b border-border bg-background px-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-sm font-semibold text-foreground",children:[t.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-lg border border-border bg-muted/35 text-muted-foreground",children:he?.icon}),t.jsx("span",{className:"truncate",children:je})]}),t.jsx("button",{type:"button",onClick:()=>B(!1),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",title:C("收起"),"aria-label":C("收起"),children:t.jsx(Ta,{size:15})})]}),Ae]})]}):t.jsxs("div",{className:Q("flex h-full w-full min-w-0 flex-col bg-background",i),children:[o&&se,t.jsx("div",{className:"flex items-center overflow-x-auto scrollbar-app-thin px-2 pt-2 border-b border-border bg-muted shrink-0 gap-1 select-none",children:N.map(te=>t.jsx($u,{active:P===te.key,onClick:()=>z(te.key),icon:te.icon,label:C(te.label)},te.key))}),Ae]})}),qu=3e3;function Wr(e,i){const s=new Map(e.map(l=>[l.workspaceId,l]));for(const l of i){const g=s.get(l.workspaceId);(!g||l.updatedAt>=g.updatedAt)&&s.set(l.workspaceId,l)}return[...s.values()]}function Vf(e){const i=De(),s=A.useRef({version:0,values:new Map}),[l,g]=A.useState(0),{data:v=[]}=Ee({queryKey:ie.workspaces.setupProgress(e??""),enabled:!!e,refetchOnMount:"always",refetchInterval:u=>u.state.data?.some(f=>f.status==="running")?3e3:!1,queryFn:async({signal:u})=>{const f=s.current.version,a=await oe.get(`/tasks/${e}/setup-progress`,{signal:u}),p=[...s.current.values.values()].filter(m=>m.version>f&&m.progress.taskId===e).map(m=>m.progress);return Wr(a,p)}});A.useEffect(()=>{if(!e)return;const u=be.connect(),f=ie.workspaces.setupProgress(e),a=m=>{if(m.taskId!==e)return;const y=s.current.values.get(m.workspaceId);y&&y.progress.updatedAt>m.updatedAt||(s.current.values.set(m.workspaceId,{version:++s.current.version,progress:m}),i.setQueryData(f,b=>Wr(b??[],[m])))},p=()=>{i.invalidateQueries({queryKey:f})};return u.on(Le.WORKSPACE_SETUP_PROGRESS,a),u.on("connect",p),()=>{u.off(Le.WORKSPACE_SETUP_PROGRESS,a),u.off("connect",p)}},[e,i]);const w=[...v].sort((u,f)=>f.updatedAt-u.updatedAt),r=w.find(u=>u.status==="running")??w.find(u=>u.status!=="running"&&u.updatedAt>l),o=r?.status!=="running"?r?.updatedAt??null:null;return A.useEffect(()=>{if(o===null)return;const u=setTimeout(()=>g(o),qu);return()=>clearTimeout(u)},[o]),r??null}function Gf({isOpen:e,onClose:i,onStarted:s,taskId:l,projectId:g,taskTitle:v,taskDescription:w,taskPrompt:r,projectIsGitRepo:o=!0,projectWorktreeReady:u=!0,projectGitReason:f}){const{t:a}=re(),[p,m]=A.useState(""),[y,b]=A.useState(""),[n,d]=A.useState(He.WORKTREE),[c,h]=A.useState(null),[_,S]=A.useState("idle"),[k,E]=A.useState(null),x=De(),C=Go(l),T=Fo(),L=Qo(),{data:R,isLoading:M}=Ws(),I=A.useMemo(()=>R?.filter(ui),[R]),B=c?.isGitRepo??o,H=c?.worktreeReady??u,$=c?.reason??f,N=B!==!1&&H!==!1;A.useEffect(()=>{if(!e||!I)return;const G=I.find(Z=>!ht(Z));m(Z=>Z&&I.some(ae=>ae.provider.id===Z)?Z:G?.provider.id??"")},[e,I]),A.useEffect(()=>{if(e){const G=[v];w&&G.push(w),b(r?.trim()||G.join(`
63
63
 
64
- `)),h(null),d(o!==!1&&u!==!1?He.WORKTREE:He.MAIN_DIRECTORY),S("idle"),E(null)}},[e,o,u,l,v,w,i]),A.useEffect(()=>{N||d(He.MAIN_DIRECTORY)},[N]);const P=async()=>{if(!g||L.isPending)return;const G=await L.mutateAsync({id:g});h(G),G.worktreeReady&&d(He.WORKTREE)},D=_!=="idle",O=async()=>{if(!p||!y.trim())return;const G=I?.find(Z=>Z.provider.id===p);if(!(!G||ht(G))){E(null);try{await Zn(l,{providerId:p,prompt:y.trim(),workspaceKind:N?n:He.MAIN_DIRECTORY},{createWorkspace:Z=>C.mutateAsync({clientSubmissionId:Z,workspaceKind:N?n:He.MAIN_DIRECTORY}),startSession:Z=>T.mutateAsync(Z),onStep:S}),await x.invalidateQueries({queryKey:ie.workspaces.list(l)}),S("idle"),s?.(),r()}catch(Z){S("idle"),E(Z instanceof Error?Z.message:a("启动失败,请重试"))}}},q={idle:a("启动"),"creating-workspace":a("创建工作空间..."),"creating-session":a("创建会话..."),"starting-session":a("启动 Agent...")},K=(I??[]).map(G=>{const Z=G.provider,ae=ht(G),he=!ae,je=Z.executionPermission?a("Required permission: {mode}",{mode:a(Jo[Z.executionPermission])}):void 0;return{value:Z.id,label:he?Z.name:`${Z.name}${a(" (不可用)")}`,description:[je,ae&&a(ae)].filter(Boolean).join(" · "),icon:t.jsx(Gt,{agentType:Z.agentType,className:"size-4"}),disabled:!he}}),U=I?.find(G=>G.provider.id===p),z=U?ht(U):void 0,W=!!I?.length&&I.every(G=>!!ht(G)),j=!M&&!I?.length,F=a("工作树隔离改动,支持 TeamRun、Merge、Rebase 和冲突解决。"),X=a("本地模式会直接修改项目主目录,不会自动提交,也不能使用 Merge、Rebase 或冲突解决。"),Y=a($==="NO_HEAD"?"已检测到 Git,但需要先提交一次才能使用工作树模式。":"非 Git 项目只能使用本地模式。"),ee=[{value:He.WORKTREE,label:a("工作树模式"),description:F,disabled:!N},{value:He.MAIN_DIRECTORY,label:a("本地模式"),description:X}];return t.jsx(At,{isOpen:e,onClose:D?()=>{}:r,title:a("启动 Agent"),action:t.jsxs(t.Fragment,{children:[t.jsx(ge,{variant:"outline",onClick:r,disabled:D,children:a("取消")}),t.jsx(ge,{onClick:O,disabled:D||!U||!y.trim()||!!z,children:q[_]})]}),children:t.jsxs("div",{className:"space-y-5",children:[t.jsx("div",{children:t.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-foreground/80 mb-2",children:a("Agent")}),t.jsx(Xe,{value:p,onChange:m,options:K,placeholder:a(M?"加载中...":"选择 Agent"),disabled:D||M}),z?t.jsx("p",{role:"alert",className:"mt-2 break-words text-xs leading-snug text-destructive-ink",children:a(z)}):null,W&&!U?t.jsxs("div",{role:"alert",className:"mt-2 space-y-1 break-words text-xs leading-snug text-destructive-ink",children:[t.jsx("p",{children:a("No available Provider for this session.")}),t.jsx("ul",{className:"space-y-1",children:I.map(G=>t.jsxs("li",{children:[G.provider.name,": ",a(ht(G))]},G.provider.id))})]}):null,j?t.jsx("p",{role:"alert",className:"mt-2 text-xs text-destructive-ink",children:a("No available Provider for this session.")}):null]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-foreground/80 mb-2",children:a("模式")}),N?t.jsx(Xe,{value:n,onChange:G=>d(G),options:ee,disabled:D}):t.jsx(mo,{side:"bottom",className:"w-full",content:Y,children:t.jsxs("div",{tabIndex:0,"aria-label":Y,className:"rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[t.jsx(Xe,{value:n,onChange:G=>d(G),options:ee,disabled:!0}),t.jsx("button",{type:"button",onClick:P,disabled:D||L.isPending,className:"mt-2 text-xs text-muted-foreground transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",children:L.isPending?a("检测中..."):a("重新检测 Git 状态")})]})})]})]})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-foreground/80 mb-2",children:a("任务描述")}),t.jsx("textarea",{value:y,onChange:G=>b(G.target.value),rows:5,disabled:D,placeholder:a("描述你想让 Agent 完成的任务..."),className:"w-full px-3 py-2 border border-border rounded-lg text-sm text-foreground placeholder:text-muted-foreground/70 focus:outline-none focus:ring-1 focus:ring-ring/60 focus:border-ring resize-none disabled:opacity-50 disabled:bg-muted/50"})]}),k&&t.jsx("div",{className:"text-sm text-destructive-ink bg-destructive/10 border border-destructive/25 rounded-lg px-3 py-2",children:k})]})})}function Qf(e){const r=e?.tokenUsage;if(!(!r||typeof r.totalTokens!="number"))return r}function Ku(e,r,s){const l=e?.providerId??s?.providerId??null,g=l?r?.find(o=>o.provider.id===l)?.provider:null,v=g?.name??l??e?.agentType??s?.agentType??null;if(!v)return null;const w=e?.agentType??g?.agentType??s?.agentType??null,i=l&&g?.name&&l!==g.name?`${g.name} (${l})`:v;return{label:v,title:i,agentType:w}}function Zf({session:e,providers:r,usage:s,compact:l=!1,providerIdFallback:g,agentTypeFallback:v,tokenTooltipSide:w="top"}){const{t:i}=re(),o=Ku(e,r,{providerId:g,agentType:v});return!o&&!s?null:t.jsxs("div",{className:`flex shrink-0 items-center ${l?"gap-1":"gap-2"}`,children:[o&&t.jsxs("div",{className:`flex shrink-0 items-center rounded-lg text-muted-foreground ${l?"max-w-[130px] min-w-[82px] gap-1 px-1.5 py-1 text-xs":"max-w-[220px] min-w-[110px] gap-1.5 px-2 py-1.5 text-xs"}`,title:`${i("Provider")}: ${o.title}`,children:[t.jsx(Gt,{agentType:o.agentType,className:l?"size-3":"size-3.5"}),t.jsx("span",{className:"min-w-0 truncate",children:Xn(o.label,l?12:18)})]}),t.jsx(ko,{usage:s,tooltipSide:w})]})}function wn(e){return e.length>0?e.map(r=>`- ${r}`).join(`
65
- `):"- 未获取到冲突文件列表"}function Cn(e){if(!e)return[];const r=[];return e.workspaceId&&r.push(`- Workspace: \`${e.workspaceId}\``),e.worktreePath&&r.push(`- Worktree: \`${e.worktreePath}\``),e.sourceWorkspaceId&&r.push(`- Source workspace: \`${e.sourceWorkspaceId}\``),e.targetWorkspaceId&&r.push(`- Target workspace: \`${e.targetWorkspaceId}\``),e.sourceWorktreePath&&r.push(`- Source worktree: \`${e.sourceWorktreePath}\``),e.targetWorktreePath&&r.push(`- Target worktree: \`${e.targetWorktreePath}\``),e.operation&&e.operation!=="idle"&&r.push(`- Git 状态: \`${e.operation}\``),e.mergeStrategy&&r.push(`- Merge strategy: \`${e.mergeStrategy}\``),e.mergeAborted&&r.push("- Merge state: conflict detected and already aborted by Agent Tower"),r}function Xu(e,r){if(!r?.mergeAborted)return["1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git commit` 完成合并"];const s=r.mergeStrategy==="squash"?`git merge --squash --no-commit ${e}`:`git merge --no-ff ${e}`,l=r.mergeStrategy==="squash"?"`git commit`":"`git merge --continue` 或 `git commit`";return["1. 注意:Agent Tower 检测到 merge 冲突后已经执行 abort,当前不要假设存在冲突标记或 `MERGE_HEAD`","2. 切换到 Target worktree / Target branch 上下文,确认工作区干净",`3. 重新执行 \`${s}\` 复现冲突`,"4. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","5. 对每个已解决的文件执行 `git add <file>`",`6. 执行 ${l} 完成合并`]}function Yu(e){if(!e.mergeAborted)return"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 merge 提交,然后说明处理结果。";const r=e.targetWorktreePath?`目标 worktree \`${e.targetWorktreePath}\``:`目标分支 \`${e.targetBranch}\``,s=e.mergeStrategy==="squash"?`git merge --squash --no-commit ${e.sourceBranch}`:`git merge --no-ff ${e.sourceBranch}`;return`Agent Tower 已在检测到冲突后 abort 了 merge;请在${r}中确认工作区干净,重新执行 \`${s}\` 复现冲突,解决后完成提交并汇报验证结果。`}function Vu(e,r,s,l,g){const v=wn(s),w=Cn(g);return l===kt.REBASE?["## Rebase 冲突解决","",`在将分支 \`${e}\` rebase 到 \`${r}\` 时发生了冲突。`,...w.length>0?["","### 上下文",...w]:[],"","### 冲突文件",v,"","### 解决步骤","1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git rebase --continue` 继续 rebase 流程"].join(`
66
- `):["## Merge 冲突解决","",`在将分支 \`${e}\` 合并到 \`${r}\` 时发生了冲突。`,...w.length>0?["","### 上下文",...w]:[],"","### 冲突文件",v,"","### 解决步骤",...Xu(e,g)].join(`
67
- `)}function Gu(e){const r=e.conflictOp===kt.REBASE?"Rebase":"Merge",s=wn(e.conflictedFiles),l=[...Cn(e),`- Source branch: \`${e.sourceBranch}\``,`- Target branch: \`${e.targetBranch}\``,`- Conflict type: \`${e.conflictOp}\``];return[`## 请求处理 ${r} 冲突`,"",`用户点击了“AI 辅助解决”,请在对应 workspace 中处理当前 ${r} 冲突,并在 Team Room 汇报处理结果和验证情况。`,"","### 上下文",...l,"","### 冲突文件",s,"","### 用户意图",e.conflictOp===kt.REBASE?"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 `git rebase --continue`,然后说明处理结果。":Yu(e)].join(`
68
- `)}function Qu(e){if(e.teamRunId)return{type:"team_room",message:Gu(e)};const r=e.currentSessionId||e.selectedSessionId;return r?{type:"session",sessionId:r,message:Vu(e.sourceBranch,e.targetBranch,e.conflictedFiles,e.conflictOp,e)}:{type:"none"}}function Jf({open:e,onOpenChange:r,workspaceId:s,resolutionContextToken:l,conflictOp:g,conflictedFiles:v,sourceBranch:w,targetBranch:i,operation:o,worktreePath:u,mergeAborted:f,mergeStrategy:a,sourceWorkspaceId:p,targetWorkspaceId:m,sourceWorktreePath:y,targetWorktreePath:b,sessions:n,currentSessionId:d,teamRunId:c}){const{t:h}=re(),[_,S]=A.useState(),[k,E]=A.useState(""),[x,C]=A.useState(!1),[T,L]=A.useState(""),R=A.useRef(!0);A.useEffect(()=>(R.current=!0,()=>{R.current=!1}),[]);const M=Ho(),I=Yn(c??""),B=Zo(),H=!!c,$=ei(l),N=$?ti($.actor).find(j=>j.operationId===$.operationId):void 0,P=ci(l),D=P||N?.receiverSessionId||d||T,O=H?I.isPending:M.isPending,q=()=>{const j=Qu({workspaceId:s,worktreePath:u,operation:o,mergeAborted:f,mergeStrategy:a,sourceWorkspaceId:p,targetWorkspaceId:m,sourceWorktreePath:y,targetWorktreePath:b,sourceBranch:w,targetBranch:i,conflictedFiles:v,conflictOp:g,teamRunId:c,currentSessionId:D,selectedSessionId:T});if(j.type==="team_room"){I.mutate({content:j.message,kind:"chat"},{onSuccess:()=>{ke.success(h("已受理,等待发送到 Team Room")),r(!1)}});return}if(j.type!=="session")return;const F=_&&_.workspaceId===s&&_.original===l?_.token:l;tr({conflictOp:g,conflictedFiles:v,sourceBranch:w,targetBranch:i,mergeAborted:f,mergeStrategy:a,sourceWorkspaceId:p??s,targetWorkspaceId:m,sourceWorktreePath:y,targetWorktreePath:b,resolutionContextToken:F},j.sessionId),M.mutate({id:j.sessionId,message:j.message,systemAction:"resolve_conflicts",resolutionContextToken:F},{onSuccess:()=>{R.current&&(ri(F),r(!1))},onError:X=>{R.current&&E(X instanceof Error?X.message:String(X))}})},K=()=>{B.mutate({workspaceId:s},{onSuccess:()=>r(!1)})},U=g==="REBASE"?"Rebase":"Merge",z=!H&&!d&&!P&&!N?.receiverSessionId&&n.length>0,W=H||!!D;return t.jsx(At,{isOpen:e,onClose:()=>r(!1),title:h("解决 {opLabel} 冲突",{opLabel:U}),action:t.jsxs(t.Fragment,{children:[t.jsx(ce,{variant:"secondary",onClick:K,disabled:!!(b&&!m&&y!==b),children:h("在 IDE 中打开")}),t.jsx(ce,{variant:"primary",onClick:q,disabled:!W,loading:O,children:h(O?"发送中...":"AI 辅助解决")})]}),children:t.jsxs("div",{className:"space-y-4",children:[!H&&t.jsxs("div",{className:"space-y-2 text-sm",children:[k&&t.jsx("p",{role:"alert",className:"text-red-700",children:k}),t.jsx("p",{children:h("重新核验仅读取 Git,不自动发送。现场变化(包括部分 stage)可能无法继续 AI 恢复;请保留成果,在实际目标手工继续,或确认后明确中止并重做原操作。")}),t.jsxs("p",{children:[h("实际冲突目标目录"),":",t.jsx("code",{children:b??u})]}),(si()||xo())&&t.jsx("p",{role:"alert",children:h("浏览器存储不可用或资料损坏;本页仅在内存中保留,刷新后可能无法恢复。请先保存操作资料。")}),N?.expiresAt&&t.jsxs("p",{children:[h("恢复截止时间"),":",new Date(N.expiresAt).toLocaleString()]}),P&&t.jsx("p",{children:h("结果未知或待重试的原提交将先使用原 Session、UUID 和原请求核对;明确未受理后才使用新凭据。")}),t.jsx(ce,{variant:"secondary",disabled:x||O,onClick:async()=>{C(!0);try{const j=p??s,F=l?await oe.post(`/workspaces/${j}/conflict-context`,{resolutionContextToken:l}):await oe.get(`/workspaces/${j}/git-status`);if(!R.current)return;if(!F.resolutionContextToken)throw new Error(h("没有可核验的当前冲突。请求尚未受理;请保留原操作资料,确认 Git 状态后明确重新执行原操作。刷新或重试发送不会执行 Git。"));S({original:l,workspaceId:s,token:F.resolutionContextToken}),tr({conflictOp:g,conflictedFiles:v,sourceBranch:w,targetBranch:i,mergeAborted:f,mergeStrategy:a,sourceWorkspaceId:j,targetWorkspaceId:m,sourceWorktreePath:y,targetWorktreePath:b,resolutionContextToken:F.resolutionContextToken},D),E("")}catch(j){R.current&&E(j instanceof Error?j.message:String(j))}finally{R.current&&C(!1)}},children:h("只读核验当前冲突")})]}),t.jsxs("div",{children:[t.jsx("h4",{className:"text-[13px] font-medium text-foreground mb-1.5",children:h("冲突文件({count})",{count:v.length})}),t.jsx("div",{className:"max-h-40 overflow-y-auto rounded-lg border border-border/60 bg-foreground/[0.025]",children:v.map(j=>t.jsx("div",{className:"px-3 py-1.5 text-xs font-mono break-all text-foreground/85 border-b border-border/60 last:border-b-0",children:j},j))})]}),H&&t.jsx(Oe,{tone:"info",children:h("TeamRun 模式下会把处理冲突请求发送到 Team Room,由团队调度处理。")}),z&&t.jsx(mi,{label:h("选择 Session(AI 辅助解决)"),children:t.jsx(ea,{value:T,onValueChange:L,placeholder:h("选择一个 Session..."),options:n.map(j=>({value:j.id,label:`${j.agentType} — ${j.status}`}))})}),!H&&!D&&n.length===0&&t.jsx("p",{className:"text-sm text-muted-foreground",children:h("没有可用的 Session,请在 IDE 中手动解决冲突。")})]})})}function em({recovery:e,onRecover:r}){const{t:s}=re(),[l,g]=A.useState(()=>Date.now());A.useEffect(()=>{const o=setInterval(()=>g(Date.now()),3e4);return()=>clearInterval(o)},[]);const{drafts:v,storageUnavailable:w,identityError:i}=e;return t.jsxs("div",{className:"space-y-2 px-4 text-sm",children:[w&&t.jsx("p",{role:"alert",children:s("浏览器存储不可用或资料损坏;本页仅在内存中保留,刷新后可能无法恢复。请先保存操作资料。")}),i&&t.jsx("p",{role:"alert",children:s("无法确认当前身份,暂不展示已保存的冲突资料。")}),v.map(o=>t.jsxs("div",{className:"rounded border p-2 space-y-1",children:[t.jsx("p",{children:s("已保留原冲突资料;关闭弹窗后可在此重新打开。仅当前身份和本标签页可恢复,关闭标签页或清理浏览器数据会删除资料。")}),t.jsx("p",{children:o.expiresAt&&o.expiresAt<=l?s("恢复证明已过期;保留成果,在实际目标手工继续,或确认后明确中止并重做。已提交但结果未知的请求仍可核对原 UUID。"):`${s("恢复截止时间")}:${o.expiresAt?new Date(o.expiresAt).toLocaleString():s("未知")}`}),t.jsx(ge,{variant:"outline",onClick:()=>r(o.details),children:s("恢复上次冲突资料")}),t.jsx(ge,{variant:"ghost",onClick:()=>ri(o.details.resolutionContextToken),children:s("清理本地操作资料")}),t.jsx("p",{className:"text-xs text-muted-foreground",children:s("清理不会取消服务端已受理请求;结果未知时请先核对原提交。")})]},o.operationId))]})}function tm(e,r=!0){const[,s]=A.useState(0),l=Ei({mutationKey:ie.accessAuth.identityChange})>0,g=Ee({queryKey:ie.accessAuth.conflictRecoveryIdentity,queryFn:({signal:a})=>oe.get("/conflict-recovery-identity",{signal:a}),enabled:r&&!l,staleTime:0,gcTime:0,retry:!1}),v=r&&!l&&g.isSuccess&&!g.isFetching?g.data.actor:void 0,[w,i]=A.useState({actor:v,enabled:r});(w.actor!==v||w.enabled!==r)&&i({actor:v,enabled:r}),A.useEffect(()=>{const a=()=>s(p=>p+1);return window.addEventListener(sr,a),()=>window.removeEventListener(sr,a)},[]);const o=v?ti(v).filter(a=>e.includes(a.details.sourceWorkspaceId??"")):[],u=w.enabled===r&&(!r||v&&w.actor===v)?w.details??null:null;return{drafts:o,actor:v,pendingConflictDetails:u,openDialog:a=>{let p=rr(a);if(r){if(!v||(ei(p.resolutionContextToken)?.actor??v)!==v)return;const m=p.sourceWorkspaceId;if(!m||!e.includes(m))return;const y=So(v,m),b=o.find(n=>n.details.sourceWorkspaceId===m&&ci(n.details.resolutionContextToken));y?p=rr({conflictOp:p.conflictOp,conflictedFiles:[],resolutionContextToken:y.token}):b&&(p=b.details)}i({actor:v,enabled:r,details:p})},closeDialog:()=>i({actor:v,enabled:r}),storageUnavailable:si(),identityError:r&&g.isError}}function Zu(e){return[...e?.uncommitted??[],...e?.committed??[]].reduce((s,l)=>({files:s.files+1,additions:s.additions+(l.additions??0),deletions:s.deletions+(l.deletions??0)}),{files:0,additions:0,deletions:0})}function $r(e,r,s,l){const g=gn(e);if(g){s(g);return}l(e instanceof Error?e.message:r)}function sm({projectId:e,workspaceId:r,branchName:s,targetBranch:l,commitMessage:g,changes:v,gitStatus:w,isGitStatusLoading:i,canRunGitOperations:o,onOpenChanges:u,onRefreshCommitMessage:f,onConflict:a,className:p}){const{t:m}=re(),y=yi(),b=wi(),n=Ci(),[d,c]=A.useState(!1),[h,_]=A.useState(null),S=Gs(r,d),k=(S.data??[]).filter(fn),E=A.useMemo(()=>Zu(v),[v]),x=E.additions+E.deletions,C=E.files>0&&x>0,T=(w?.conflictedFiles.length??0)>0,L=!!(w&&w.operation!=="idle"),R=!!(w&&(w.hasUncommittedChanges||w.untrackedCount>0)),M=(w?.uncommittedCount??0)+(w?.untrackedCount??0),I=(w?.behind??0)>0,B=(w?.ahead??0)>0,H=i||!w&&o,$=!!(o&&r&&w&&I&&!T&&!L&&!R),N=!!(o&&r&&w&&B&&!I&&!T&&!L&&!R),P=!!(o&&r&&w&&!T&&!L&&!R);if(A.useEffect(()=>{d&&f?.()},[d,f]),!C)return null;const D=T?m("冲突"):w?.operation==="rebase"?m("变基中"):w?.operation==="merge"?m("合并中"):M>0?m("{count} 未提交",{count:M}):I?m("落后 {count}",{count:w?.behind??0}):m(B?"可合并":"已是最新"),O=m("{files} 个文件 · {lines} 行",{files:E.files,lines:x}),q=()=>{$&&(_(null),y.mutate(r,{onError:W=>{$r(W,m("更新失败,请稍后重试"),j=>a(j),_)}}))},K=()=>{P&&(_(null),c(!0))},U=(W,j)=>{_(null),b.mutate({id:r,commitMessage:W,stopActiveServices:j},{onSuccess:()=>c(!1),onError:F=>{if(mn(F)){_(m("后台服务仍在运行,请确认停止服务后再提交。"));return}$r(F,m("提交失败,请稍后重试"),X=>{c(!1),a(X)},_)}})},z=()=>{b.isPending||(c(!1),_(null))};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:Q("space-y-1",p),children:[t.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg bg-muted/25 px-2 py-1.5",children:[t.jsxs("button",{type:"button",onClick:u,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-1.5 py-0.5 text-left transition-colors hover:bg-muted/55 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40","aria-label":m("查看变更详情"),children:[t.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-background/70 text-muted-foreground",children:t.jsx(qs,{size:13})}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:O}),t.jsx(Jr,{additions:E.additions,deletions:E.deletions,className:"hidden sm:inline-flex"}),T&&t.jsx(Tt,{size:13,className:"shrink-0 text-warning"}),t.jsxs("span",{className:"hidden min-w-0 basis-0 grow max-w-fit items-center gap-1 text-[11px] text-muted-foreground md:flex",children:[t.jsx("span",{className:"truncate font-mono",children:s}),t.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground/70",children:"→"}),t.jsx("span",{className:"truncate font-mono",children:l})]}),t.jsx(Wt,{className:"bg-background/75",children:D})]}),t.jsx(Je,{size:15,className:"shrink-0 text-muted-foreground/70"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[L&&t.jsx(ce,{variant:"secondary",size:"sm",className:"hidden sm:inline-flex",onClick:()=>n.mutate(r),loading:n.isPending,children:n.isPending?m("正在撤销..."):m("撤销操作")}),t.jsx("span",{title:m(I?"同步更新":"已是最新"),className:Q("inline-flex",(!$||H)&&"cursor-not-allowed"),children:t.jsxs(ce,{variant:"secondary",size:"sm",onClick:q,disabled:!$||H,loading:y.isPending,children:[!y.isPending&&t.jsx(_t,{}),y.isPending?m("正在同步..."):m("更新")]})}),t.jsx("span",{title:N?m("合并到 {target}",{target:l}):m("提交变更"),className:Q("inline-flex",(!P||H)&&"cursor-not-allowed"),children:t.jsxs(ce,{variant:"primary",size:"sm",onClick:K,disabled:!P||H,loading:b.isPending,children:[!b.isPending&&t.jsx(Us,{}),b.isPending?m("正在提交..."):m("合并")]})})]})]}),h&&t.jsx(Oe,{tone:"danger",size:"sm",children:h})]}),t.jsx(pn,{projectId:e,workspaceId:r,canMerge:N,isOpen:d,onClose:z,onBaseBranchSaved:u,branchName:s,targetBranch:l,commitMessage:g,isPending:b.isPending,activeServices:k,isCheckingServices:S.isLoading,serviceCheckFailed:S.isError,error:h,onConfirm:U})]})}const Ur=["creating-workspace","creating-session","starting-session"];function rm({state:e,setupProgress:r,sessionStarted:s=!1,onRetry:l,compact:g=!1}){const{t:v}=re(),[w,i]=A.useState(!1),o=e?.status==="failed",u=r?.status==="failed",f=o||u,a=e?Ur.indexOf(e.status):Ur.length,p=[v("Preparing workspace"),v("Creating session"),v("Starting agent")],m=(e?.setupScript??"").split(`
69
- `).map(n=>n.trim()).filter(Boolean),y=e||s?p.map((n,d)=>({label:n,status:o?"pending":d<a?"completed":d===a?"active":"pending"})):[];(r||m.length>0)&&y.push({label:r?.status==="running"?v("Running setup ({current}/{total})",{current:r.currentIndex??0,total:r.totalCommands}):r?.status==="completed"?v("Setup complete"):r?.status==="failed"?v("Setup failed"):v("Run setup script"),status:r?.status==="running"?"active":r?.status??"pending",description:r?.currentCommand||m.join(`
70
- `)});const b=!!r?.output?.trim();return!e&&!r?null:t.jsxs("div",{className:`${g?"my-2 mb-4":"my-3 mb-6"} mx-auto w-full max-w-2xl rounded-xl border ${f?"border-destructive/30 bg-destructive/[0.03]":"border-border/70 bg-background"} px-4 py-3 text-left shadow-raised`,role:f?"alert":"status","aria-live":f?"assertive":"polite",children:[f&&(e?.error||r?.error||o)?t.jsx("p",{className:"mb-2 break-words text-xs text-destructive-ink",children:e?.error||r?.error||v("Agent start failed")}):null,t.jsx("div",{className:"space-y-2",children:y.map(({label:n,status:d,description:c})=>{const h=d==="completed",_=d==="active";return t.jsxs("div",{className:`flex items-start gap-2 text-sm ${d==="failed"?"text-destructive-ink":h||_?"text-info-ink":"text-muted-foreground"}`,children:[h?t.jsx(Vn,{className:"h-4 w-4 shrink-0"}):_?t.jsx(Fs,{className:"h-4 w-4 shrink-0 animate-spin motion-reduce:animate-none"}):d==="failed"?t.jsx(Zr,{className:"h-4 w-4 shrink-0"}):t.jsx(la,{className:"h-4 w-4 shrink-0"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{children:n}),c&&t.jsx("code",{className:"mt-1 block whitespace-pre-wrap break-all rounded-md bg-muted/35 px-2.5 py-2 text-xs leading-relaxed text-muted-foreground",children:c})]})]},n)})}),(b||o)&&t.jsxs("div",{className:"mt-3 flex items-center justify-between gap-3 border-t border-border/50 pt-2",children:[b?t.jsxs("button",{type:"button",onClick:()=>i(n=>!n),className:"inline-flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground","aria-expanded":w,"aria-controls":"task-start-progress-details",children:[w?t.jsx(Ke,{className:"h-3.5 w-3.5"}):t.jsx(Je,{className:"h-3.5 w-3.5"}),v(w?"Hide setup output":"View setup output")]}):t.jsx("span",{}),o&&l?t.jsx(ge,{size:"sm",variant:"outline",onClick:l,children:v("Retry start")}):null]}),w&&t.jsx("div",{id:"task-start-progress-details",className:"mt-2 rounded-md bg-muted/35 px-2.5 py-2 text-xs leading-relaxed text-muted-foreground",children:t.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono",children:r?.output??""})})]})}function Ju({agentType:e,workingDir:r}){return Ee({queryKey:ie.system.skillCatalog(e,r),queryFn:async()=>(await oe.get("/system/skill-catalog",{params:{agentType:String(e),...r?{workingDir:r}:{}}})).commands,enabled:e===ii.CODEX,staleTime:3e4})}function ef(e){const r=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,s=e.key==="Tab"&&!e.shiftKey;return r||s}function im({agentType:e,workingDir:r,input:s,setInput:l,textareaRef:g,minHeight:v,maxHeight:w}){const[i,o]=A.useState(0),{data:u=[]}=Ju({agentType:e,workingDir:r}),a=A.useMemo(()=>e===ii.CODEX?nr(s):null,[e,s])?.query??null,p=A.useMemo(()=>a===null?[]:zo(u,a),[a,u]),m=A.useCallback(()=>{const n=g.current;n&&(n.style.height="auto",n.style.height=`${Math.max(v,Math.min(n.scrollHeight,w))}px`)},[w,v,g]);A.useEffect(()=>{o(0)},[e,a]),A.useEffect(()=>{i<p.length||o(0)},[p.length,i]);const y=A.useCallback(n=>{const d=nr(s);if(!d)return;const c=`${s.slice(0,d.replaceStart)}${n.command} `;l(c),requestAnimationFrame(()=>{const h=g.current;h&&(m(),h.focus(),h.setSelectionRange(c.length,c.length))})},[s,m,l,g]),b=A.useCallback(n=>a===null||p.length===0?!1:n.key==="ArrowDown"?(n.preventDefault(),o(d=>(d+1)%p.length),!0):n.key==="ArrowUp"?(n.preventDefault(),o(d=>(d-1+p.length)%p.length),!0):ef(n)?(n.preventDefault(),y(p[i]??p[0]),!0):!1,[y,p,a,i]);return{allSkills:u,query:a,filteredSkills:p,selectedIndex:i,setSelectedIndex:o,applySkill:y,handleKeyDown:b}}const Cs=200,tf=180;function nm({taskId:e,title:r,readOnly:s=!1,onTitleChange:l,className:g,titleClassName:v,compact:w=!1}){const{t:i}=re(),[o,u]=A.useState(!1),[f,a]=A.useState(r),[p,m]=A.useState(!1),y=A.useRef(null),b=A.useRef(null),n=Gn();A.useEffect(()=>{o||a(r)},[r,o]),A.useEffect(()=>{o&&y.current&&(y.current.focus(),y.current.select())},[o]),A.useEffect(()=>{if(!o)return;const C=T=>{b.current&&!b.current.contains(T.target)&&h()};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[o,f]);const d=A.useCallback(()=>{s||(u(!0),a(r))},[s,r]),c=A.useCallback(()=>{u(!1),a(r)},[r]),h=A.useCallback(async()=>{const C=f.trim();if(!C){a(r),u(!1);return}if(C===r){u(!1);return}try{await n.mutateAsync({id:e,title:C}),l?.(C),u(!1)}catch(T){console.error("Failed to update task title:",T),a(r)}},[f,r,e,n,l]),_=A.useCallback(C=>{C.key==="Enter"&&!C.shiftKey?(C.preventDefault(),h()):C.key==="Escape"&&(C.preventDefault(),c())},[h,c]),S=A.useCallback(C=>{const T=C.target.value;T.length<=Cs&&a(T)},[]),k=f.length,E=k>=tf,x=k>=Cs;return o?t.jsxs("div",{ref:b,className:Q("flex flex-col gap-2",g),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{ref:y,type:"text",value:f,onChange:S,onKeyDown:_,disabled:n.isPending,className:Q("flex-1 min-w-0 px-2 py-1 text-[15px] font-semibold bg-background border border-input rounded-md","focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent","disabled:opacity-50 disabled:cursor-not-allowed",w&&"text-base py-0.5",v),placeholder:i("输入任务标题")}),t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.jsx(ge,{size:w?"sm":"default",variant:"ghost",onClick:h,disabled:n.isPending||!f.trim(),className:"h-8 w-8 p-0",children:n.isPending?t.jsx(Fs,{size:16,className:"animate-spin motion-reduce:[animation-duration:2.4s]"}):t.jsx(Et,{size:16})}),t.jsx(ge,{size:w?"sm":"default",variant:"ghost",onClick:c,disabled:n.isPending,className:"h-8 w-8 p-0",children:t.jsx(tt,{size:16})})]})]}),E&&t.jsxs("div",{className:Q("text-xs",x?"text-destructive-ink":"text-muted-foreground"),children:[k," / ",Cs," ",i("字符")]})]}):t.jsxs("div",{ref:b,className:Q("group flex items-center gap-2 min-w-0",g),onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),children:[t.jsx("h2",{onClick:d,className:Q("flex-1 min-w-0 text-[15px] font-semibold text-foreground break-words line-clamp-2",!s&&"cursor-text hover:text-foreground/80 transition-colors",w&&"text-base",v),children:r}),!s&&p&&t.jsx(ge,{size:"sm",variant:"ghost",onClick:d,className:"h-7 w-7 p-0 shrink-0 opacity-60 hover:opacity-100",title:i("编辑标题"),children:t.jsx(ta,{size:14})})]})}function sf(e){return Ee({queryKey:ie.tasks.handoff(e),queryFn:({signal:r})=>oe.get(`/tasks/${encodeURIComponent(e)}/handoff`,{signal:r}),enabled:!!e})}function rf(e){const r=De();return Ct({mutationFn:s=>oe.patch(`/tasks/${encodeURIComponent(e)}/handoff`,s),onMutate:()=>r.cancelQueries({queryKey:ie.tasks.handoff(e)}),onSuccess:s=>{r.setQueryData(ie.tasks.handoff(s.taskId),s)},onSettled:()=>r.invalidateQueries({queryKey:ie.tasks.handoff(e)})})}function qr(e){try{const r=JSON.parse(sessionStorage.getItem(e)??"null");if(r&&typeof r=="object"&&"base"in r&&"content"in r&&typeof r.base=="string"&&typeof r.content=="string")return{base:r.base,content:r.content}}catch{}return null}function om({taskId:e,readOnly:r=!1}){const{t:s}=re(),l=sf(e),g=rf(e),v=`task-handoff-draft:${e}`,[w,i]=A.useState(()=>qr(v)),o=w!==null&&!r;A.useEffect(()=>{try{w?sessionStorage.setItem(v,JSON.stringify(w)):sessionStorage.removeItem(v)}catch{}},[w,v]);const u=async()=>{if(!(!w||g.isPending))try{await g.mutateAsync({oldString:w.base,newString:w.content});try{const m=qr(v);m?.base===w.base&&m.content===w.content&&sessionStorage.removeItem(v)}catch{}i(null)}catch{}};if(l.isPending)return t.jsx("p",{className:"p-4 text-sm text-muted-foreground",children:s("Loading...")});if(!l.data)return t.jsx("div",{className:"p-3",children:t.jsx(Oe,{tone:"danger",action:t.jsx(ce,{variant:"link",size:"sm",onClick:()=>l.refetch(),children:s("Retry")}),children:s("Could not load the handoff note.")})});const f=o&&w.base!==l.data.content,a=g.error instanceof Ze?g.error.details.code:void 0,p=typeof a=="string"&&["HANDOFF_CHANGED","HANDOFF_NOT_EMPTY","HANDOFF_TEXT_NOT_FOUND","HANDOFF_TEXT_AMBIGUOUS"].includes(a);return t.jsxs("section",{className:"flex h-full min-h-0 flex-col","aria-label":s("Handoff note"),children:[t.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-between gap-2 border-b border-border/60 px-3 py-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:s(o?"Markdown":"Progress, decisions, and next steps")}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(Do,{value:o?w.content:l.data.content,display:"text",size:"sm"}),o?t.jsxs(t.Fragment,{children:[t.jsx(ce,{variant:"ghost",size:"sm",disabled:g.isPending,onClick:()=>{i(null),g.reset()},children:s("Cancel")}),t.jsx(ce,{size:"sm",disabled:g.isPending||w.content===w.base,onClick:u,children:g.isPending?s("保存中..."):s("Save")})]}):!r&&t.jsx(ce,{variant:"secondary",size:"sm",onClick:()=>{g.reset(),i({base:l.data.content,content:l.data.content})},children:s("编辑")})]})]}),o&&(f||p)&&t.jsx(Oe,{tone:"warning",size:"sm",className:"mx-3 mt-3",role:"status",children:s("The handoff changed elsewhere. Your draft is preserved. Cancel editing to view the latest note.")}),o&&g.isError&&!p&&t.jsx(Oe,{tone:"danger",size:"sm",className:"mx-3 mt-3",role:"alert",children:s("Could not save the handoff note. Your draft is preserved.")}),o?t.jsx("div",{className:"flex min-h-0 flex-1 p-3",children:t.jsx(pi,{"aria-label":s("Handoff Markdown"),value:w.content,onChange:m=>i({...w,content:m.target.value}),maxLength:Fa,disabled:g.isPending,className:"min-h-0 flex-1 font-mono",placeholder:s("Summarize progress, decisions, verification, open problems, and next steps."),onKeyDown:m=>{(m.metaKey||m.ctrlKey)&&m.key==="Enter"&&(m.preventDefault(),u())}})}):t.jsx("div",{className:"prose prose-sm max-w-none min-h-0 flex-1 overflow-y-auto p-4 dark:prose-invert [overflow-wrap:anywhere]",children:l.data.content?t.jsx(li,{components:po,children:l.data.content}):t.jsx("p",{className:"py-6 text-center text-muted-foreground",children:s("No handoff note yet. Record what has been done and what comes next.")})})]})}export{em as C,vn as D,nm as E,qs as G,Wf as R,Zf as S,zf as T,sm as W,im as a,nu as b,qf as c,jt as d,Kf as e,tm as f,$f as g,Qf as h,Ff as i,rm as j,Yf as k,Xf as l,Hf as m,om as n,Gf as o,Jf as p,ou as q,Uf as r,hn as s,un as t,Vf as u,Hu as v,uu as w,Ui as x};
64
+ `)),h(null),d(o!==!1&&u!==!1?He.WORKTREE:He.MAIN_DIRECTORY),S("idle"),E(null)}},[e,o,u,l,v,w,r]),A.useEffect(()=>{N||d(He.MAIN_DIRECTORY)},[N]);const P=async()=>{if(!g||L.isPending)return;const G=await L.mutateAsync({id:g});h(G),G.worktreeReady&&d(He.WORKTREE)},D=_!=="idle",O=async()=>{if(!p||!y.trim())return;const G=I?.find(Z=>Z.provider.id===p);if(!(!G||ht(G))){E(null);try{await Zn(l,{providerId:p,prompt:y.trim(),workspaceKind:N?n:He.MAIN_DIRECTORY},{createWorkspace:Z=>C.mutateAsync({clientSubmissionId:Z,workspaceKind:N?n:He.MAIN_DIRECTORY}),startSession:Z=>T.mutateAsync(Z),onStep:S}),await x.invalidateQueries({queryKey:ie.workspaces.list(l)}),S("idle"),s?.(),i()}catch(Z){S("idle"),E(Z instanceof Error?Z.message:a("启动失败,请重试"))}}},q={idle:a("启动"),"creating-workspace":a("创建工作空间..."),"creating-session":a("创建会话..."),"starting-session":a("启动 Agent...")},K=(I??[]).map(G=>{const Z=G.provider,ae=ht(G),he=!ae,je=Z.executionPermission?a("Required permission: {mode}",{mode:a(Jo[Z.executionPermission])}):void 0;return{value:Z.id,label:he?Z.name:`${Z.name}${a(" (不可用)")}`,description:[je,ae&&a(ae)].filter(Boolean).join(" · "),icon:t.jsx(Gt,{agentType:Z.agentType,className:"size-4"}),disabled:!he}}),U=I?.find(G=>G.provider.id===p),z=U?ht(U):void 0,W=!!I?.length&&I.every(G=>!!ht(G)),j=!M&&!I?.length,F=a("工作树隔离改动,支持 TeamRun、Merge、Rebase 和冲突解决。"),X=a("本地模式会直接修改项目主目录,不会自动提交,也不能使用 Merge、Rebase 或冲突解决。"),Y=a($==="NO_HEAD"?"已检测到 Git,但需要先提交一次才能使用工作树模式。":"非 Git 项目只能使用本地模式。"),ee=[{value:He.WORKTREE,label:a("工作树模式"),description:F,disabled:!N},{value:He.MAIN_DIRECTORY,label:a("本地模式"),description:X}];return t.jsx(At,{isOpen:e,onClose:D?()=>{}:i,title:a("启动 Agent"),action:t.jsxs(t.Fragment,{children:[t.jsx(ge,{variant:"outline",onClick:i,disabled:D,children:a("取消")}),t.jsx(ge,{onClick:O,disabled:D||!U||!y.trim()||!!z,children:q[_]})]}),children:t.jsxs("div",{className:"space-y-5",children:[t.jsx("div",{children:t.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-foreground/80 mb-2",children:a("Agent")}),t.jsx(Xe,{value:p,onChange:m,options:K,placeholder:a(M?"加载中...":"选择 Agent"),disabled:D||M}),z?t.jsx("p",{role:"alert",className:"mt-2 break-words text-xs leading-snug text-destructive-ink",children:a(z)}):null,W&&!U?t.jsxs("div",{role:"alert",className:"mt-2 space-y-1 break-words text-xs leading-snug text-destructive-ink",children:[t.jsx("p",{children:a("No available Provider for this session.")}),t.jsx("ul",{className:"space-y-1",children:I.map(G=>t.jsxs("li",{children:[G.provider.name,": ",a(ht(G))]},G.provider.id))})]}):null,j?t.jsx("p",{role:"alert",className:"mt-2 text-xs text-destructive-ink",children:a("No available Provider for this session.")}):null]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-foreground/80 mb-2",children:a("模式")}),N?t.jsx(Xe,{value:n,onChange:G=>d(G),options:ee,disabled:D}):t.jsx(mo,{side:"bottom",className:"w-full",content:Y,children:t.jsxs("div",{tabIndex:0,"aria-label":Y,className:"rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[t.jsx(Xe,{value:n,onChange:G=>d(G),options:ee,disabled:!0}),t.jsx("button",{type:"button",onClick:P,disabled:D||L.isPending,className:"mt-2 text-xs text-muted-foreground transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",children:L.isPending?a("检测中..."):a("重新检测 Git 状态")})]})})]})]})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-foreground/80 mb-2",children:a("任务描述")}),t.jsx("textarea",{value:y,onChange:G=>b(G.target.value),rows:5,disabled:D,placeholder:a("描述你想让 Agent 完成的任务..."),className:"w-full px-3 py-2 border border-border rounded-lg text-sm text-foreground placeholder:text-muted-foreground/70 focus:outline-none focus:ring-1 focus:ring-ring/60 focus:border-ring resize-none disabled:opacity-50 disabled:bg-muted/50"})]}),k&&t.jsx("div",{className:"text-sm text-destructive-ink bg-destructive/10 border border-destructive/25 rounded-lg px-3 py-2",children:k})]})})}function Qf(e){const i=e?.tokenUsage;if(!(!i||typeof i.totalTokens!="number"))return i}function Ku(e,i,s){const l=e?.providerId??s?.providerId??null,g=l?i?.find(o=>o.provider.id===l)?.provider:null,v=g?.name??l??e?.agentType??s?.agentType??null;if(!v)return null;const w=e?.agentType??g?.agentType??s?.agentType??null,r=l&&g?.name&&l!==g.name?`${g.name} (${l})`:v;return{label:v,title:r,agentType:w}}function Zf({session:e,providers:i,usage:s,compact:l=!1,providerIdFallback:g,agentTypeFallback:v,tokenTooltipSide:w="top"}){const{t:r}=re(),o=Ku(e,i,{providerId:g,agentType:v});return!o&&!s?null:t.jsxs("div",{className:`flex shrink-0 items-center ${l?"gap-1":"gap-2"}`,children:[o&&t.jsxs("div",{className:`flex shrink-0 items-center rounded-lg text-muted-foreground ${l?"max-w-[130px] min-w-[82px] gap-1 px-1.5 py-1 text-xs":"max-w-[220px] min-w-[110px] gap-1.5 px-2 py-1.5 text-xs"}`,title:`${r("Provider")}: ${o.title}`,children:[t.jsx(Gt,{agentType:o.agentType,className:l?"size-3":"size-3.5"}),t.jsx("span",{className:"min-w-0 truncate",children:Xn(o.label,l?12:18)})]}),t.jsx(ko,{usage:s,tooltipSide:w})]})}function wn(e){return e.length>0?e.map(i=>`- ${i}`).join(`
65
+ `):"- 未获取到冲突文件列表"}function Cn(e){if(!e)return[];const i=[];return e.workspaceId&&i.push(`- Workspace: \`${e.workspaceId}\``),e.worktreePath&&i.push(`- Worktree: \`${e.worktreePath}\``),e.sourceWorkspaceId&&i.push(`- Source workspace: \`${e.sourceWorkspaceId}\``),e.targetWorkspaceId&&i.push(`- Target workspace: \`${e.targetWorkspaceId}\``),e.sourceWorktreePath&&i.push(`- Source worktree: \`${e.sourceWorktreePath}\``),e.targetWorktreePath&&i.push(`- Target worktree: \`${e.targetWorktreePath}\``),e.operation&&e.operation!=="idle"&&i.push(`- Git 状态: \`${e.operation}\``),e.mergeStrategy&&i.push(`- Merge strategy: \`${e.mergeStrategy}\``),e.mergeAborted&&i.push("- Merge state: conflict detected and already aborted by Agent Tower"),i}function Xu(e,i){if(!i?.mergeAborted)return["1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git commit` 完成合并"];const s=i.mergeStrategy==="squash"?`git merge --squash --no-commit ${e}`:`git merge --no-ff ${e}`,l=i.mergeStrategy==="squash"?"`git commit`":"`git merge --continue` 或 `git commit`";return["1. 注意:Agent Tower 检测到 merge 冲突后已经执行 abort,当前不要假设存在冲突标记或 `MERGE_HEAD`","2. 切换到 Target worktree / Target branch 上下文,确认工作区干净",`3. 重新执行 \`${s}\` 复现冲突`,"4. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","5. 对每个已解决的文件执行 `git add <file>`",`6. 执行 ${l} 完成合并`]}function Yu(e){if(!e.mergeAborted)return"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 merge 提交,然后说明处理结果。";const i=e.targetWorktreePath?`目标 worktree \`${e.targetWorktreePath}\``:`目标分支 \`${e.targetBranch}\``,s=e.mergeStrategy==="squash"?`git merge --squash --no-commit ${e.sourceBranch}`:`git merge --no-ff ${e.sourceBranch}`;return`Agent Tower 已在检测到冲突后 abort 了 merge;请在${i}中确认工作区干净,重新执行 \`${s}\` 复现冲突,解决后完成提交并汇报验证结果。`}function Vu(e,i,s,l,g){const v=wn(s),w=Cn(g);return l===kt.REBASE?["## Rebase 冲突解决","",`在将分支 \`${e}\` rebase 到 \`${i}\` 时发生了冲突。`,...w.length>0?["","### 上下文",...w]:[],"","### 冲突文件",v,"","### 解决步骤","1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git rebase --continue` 继续 rebase 流程"].join(`
66
+ `):["## Merge 冲突解决","",`在将分支 \`${e}\` 合并到 \`${i}\` 时发生了冲突。`,...w.length>0?["","### 上下文",...w]:[],"","### 冲突文件",v,"","### 解决步骤",...Xu(e,g)].join(`
67
+ `)}function Gu(e){const i=e.conflictOp===kt.REBASE?"Rebase":"Merge",s=wn(e.conflictedFiles),l=[...Cn(e),`- Source branch: \`${e.sourceBranch}\``,`- Target branch: \`${e.targetBranch}\``,`- Conflict type: \`${e.conflictOp}\``];return[`## 请求处理 ${i} 冲突`,"",`用户点击了“AI 辅助解决”,请在对应 workspace 中处理当前 ${i} 冲突,并在 Team Room 汇报处理结果和验证情况。`,"","### 上下文",...l,"","### 冲突文件",s,"","### 用户意图",e.conflictOp===kt.REBASE?"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 `git rebase --continue`,然后说明处理结果。":Yu(e)].join(`
68
+ `)}function Qu(e){if(e.teamRunId)return{type:"team_room",message:Gu(e)};const i=e.currentSessionId||e.selectedSessionId;return i?{type:"session",sessionId:i,message:Vu(e.sourceBranch,e.targetBranch,e.conflictedFiles,e.conflictOp,e)}:{type:"none"}}function Jf({open:e,onOpenChange:i,workspaceId:s,resolutionContextToken:l,conflictOp:g,conflictedFiles:v,sourceBranch:w,targetBranch:r,operation:o,worktreePath:u,mergeAborted:f,mergeStrategy:a,sourceWorkspaceId:p,targetWorkspaceId:m,sourceWorktreePath:y,targetWorktreePath:b,sessions:n,currentSessionId:d,teamRunId:c}){const{t:h}=re(),[_,S]=A.useState(),[k,E]=A.useState(""),[x,C]=A.useState(!1),[T,L]=A.useState(""),R=A.useRef(!0);A.useEffect(()=>(R.current=!0,()=>{R.current=!1}),[]);const M=Ho(),I=Yn(c??""),B=Zo(),H=!!c,$=ei(l),N=$?ti($.actor).find(j=>j.operationId===$.operationId):void 0,P=ci(l),D=P||N?.receiverSessionId||d||T,O=H?I.isPending:M.isPending,q=()=>{const j=Qu({workspaceId:s,worktreePath:u,operation:o,mergeAborted:f,mergeStrategy:a,sourceWorkspaceId:p,targetWorkspaceId:m,sourceWorktreePath:y,targetWorktreePath:b,sourceBranch:w,targetBranch:r,conflictedFiles:v,conflictOp:g,teamRunId:c,currentSessionId:D,selectedSessionId:T});if(j.type==="team_room"){I.mutate({content:j.message,kind:"chat"},{onSuccess:()=>{ke.success(h("已受理,等待发送到 Team Room")),i(!1)}});return}if(j.type!=="session")return;const F=_&&_.workspaceId===s&&_.original===l?_.token:l;tr({conflictOp:g,conflictedFiles:v,sourceBranch:w,targetBranch:r,mergeAborted:f,mergeStrategy:a,sourceWorkspaceId:p??s,targetWorkspaceId:m,sourceWorktreePath:y,targetWorktreePath:b,resolutionContextToken:F},j.sessionId),M.mutate({id:j.sessionId,message:j.message,systemAction:"resolve_conflicts",resolutionContextToken:F},{onSuccess:()=>{R.current&&(ri(F),i(!1))},onError:X=>{R.current&&E(X instanceof Error?X.message:String(X))}})},K=()=>{B.mutate({workspaceId:s},{onSuccess:()=>i(!1)})},U=g==="REBASE"?"Rebase":"Merge",z=!H&&!d&&!P&&!N?.receiverSessionId&&n.length>0,W=H||!!D;return t.jsx(At,{isOpen:e,onClose:()=>i(!1),title:h("解决 {opLabel} 冲突",{opLabel:U}),action:t.jsxs(t.Fragment,{children:[t.jsx(ce,{variant:"secondary",onClick:K,disabled:!!(b&&!m&&y!==b),children:h("在 IDE 中打开")}),t.jsx(ce,{variant:"primary",onClick:q,disabled:!W,loading:O,children:h(O?"发送中...":"AI 辅助解决")})]}),children:t.jsxs("div",{className:"space-y-4",children:[!H&&t.jsxs("div",{className:"space-y-2 text-sm",children:[k&&t.jsx("p",{role:"alert",className:"text-red-700",children:k}),t.jsx("p",{children:h("重新核验仅读取 Git,不自动发送。现场变化(包括部分 stage)可能无法继续 AI 恢复;请保留成果,在实际目标手工继续,或确认后明确中止并重做原操作。")}),t.jsxs("p",{children:[h("实际冲突目标目录"),":",t.jsx("code",{children:b??u})]}),(si()||xo())&&t.jsx("p",{role:"alert",children:h("浏览器存储不可用或资料损坏;本页仅在内存中保留,刷新后可能无法恢复。请先保存操作资料。")}),N?.expiresAt&&t.jsxs("p",{children:[h("恢复截止时间"),":",new Date(N.expiresAt).toLocaleString()]}),P&&t.jsx("p",{children:h("结果未知或待重试的原提交将先使用原 Session、UUID 和原请求核对;明确未受理后才使用新凭据。")}),t.jsx(ce,{variant:"secondary",disabled:x||O,onClick:async()=>{C(!0);try{const j=p??s,F=l?await oe.post(`/workspaces/${j}/conflict-context`,{resolutionContextToken:l}):await oe.get(`/workspaces/${j}/git-status`);if(!R.current)return;if(!F.resolutionContextToken)throw new Error(h("没有可核验的当前冲突。请求尚未受理;请保留原操作资料,确认 Git 状态后明确重新执行原操作。刷新或重试发送不会执行 Git。"));S({original:l,workspaceId:s,token:F.resolutionContextToken}),tr({conflictOp:g,conflictedFiles:v,sourceBranch:w,targetBranch:r,mergeAborted:f,mergeStrategy:a,sourceWorkspaceId:j,targetWorkspaceId:m,sourceWorktreePath:y,targetWorktreePath:b,resolutionContextToken:F.resolutionContextToken},D),E("")}catch(j){R.current&&E(j instanceof Error?j.message:String(j))}finally{R.current&&C(!1)}},children:h("只读核验当前冲突")})]}),t.jsxs("div",{children:[t.jsx("h4",{className:"text-[13px] font-medium text-foreground mb-1.5",children:h("冲突文件({count})",{count:v.length})}),t.jsx("div",{className:"max-h-40 overflow-y-auto rounded-lg border border-border/60 bg-foreground/[0.025]",children:v.map(j=>t.jsx("div",{className:"px-3 py-1.5 text-xs font-mono break-all text-foreground/85 border-b border-border/60 last:border-b-0",children:j},j))})]}),H&&t.jsx(Oe,{tone:"info",children:h("TeamRun 模式下会把处理冲突请求发送到 Team Room,由团队调度处理。")}),z&&t.jsx(mi,{label:h("选择 Session(AI 辅助解决)"),children:t.jsx(ea,{value:T,onValueChange:L,placeholder:h("选择一个 Session..."),options:n.map(j=>({value:j.id,label:`${j.agentType} — ${j.status}`}))})}),!H&&!D&&n.length===0&&t.jsx("p",{className:"text-sm text-muted-foreground",children:h("没有可用的 Session,请在 IDE 中手动解决冲突。")})]})})}function em({recovery:e,onRecover:i}){const{t:s}=re(),[l,g]=A.useState(()=>Date.now());A.useEffect(()=>{const o=setInterval(()=>g(Date.now()),3e4);return()=>clearInterval(o)},[]);const{drafts:v,storageUnavailable:w,identityError:r}=e;return t.jsxs("div",{className:"space-y-2 px-4 text-sm",children:[w&&t.jsx("p",{role:"alert",children:s("浏览器存储不可用或资料损坏;本页仅在内存中保留,刷新后可能无法恢复。请先保存操作资料。")}),r&&t.jsx("p",{role:"alert",children:s("无法确认当前身份,暂不展示已保存的冲突资料。")}),v.map(o=>t.jsxs("div",{className:"rounded border p-2 space-y-1",children:[t.jsx("p",{children:s("已保留原冲突资料;关闭弹窗后可在此重新打开。仅当前身份和本标签页可恢复,关闭标签页或清理浏览器数据会删除资料。")}),t.jsx("p",{children:o.expiresAt&&o.expiresAt<=l?s("恢复证明已过期;保留成果,在实际目标手工继续,或确认后明确中止并重做。已提交但结果未知的请求仍可核对原 UUID。"):`${s("恢复截止时间")}:${o.expiresAt?new Date(o.expiresAt).toLocaleString():s("未知")}`}),t.jsx(ge,{variant:"outline",onClick:()=>i(o.details),children:s("恢复上次冲突资料")}),t.jsx(ge,{variant:"ghost",onClick:()=>ri(o.details.resolutionContextToken),children:s("清理本地操作资料")}),t.jsx("p",{className:"text-xs text-muted-foreground",children:s("清理不会取消服务端已受理请求;结果未知时请先核对原提交。")})]},o.operationId))]})}function tm(e,i=!0){const[,s]=A.useState(0),l=Ei({mutationKey:ie.accessAuth.identityChange})>0,g=Ee({queryKey:ie.accessAuth.conflictRecoveryIdentity,queryFn:({signal:a})=>oe.get("/conflict-recovery-identity",{signal:a}),enabled:i&&!l,staleTime:0,gcTime:0,retry:!1}),v=i&&!l&&g.isSuccess&&!g.isFetching?g.data.actor:void 0,[w,r]=A.useState({actor:v,enabled:i});(w.actor!==v||w.enabled!==i)&&r({actor:v,enabled:i}),A.useEffect(()=>{const a=()=>s(p=>p+1);return window.addEventListener(sr,a),()=>window.removeEventListener(sr,a)},[]);const o=v?ti(v).filter(a=>e.includes(a.details.sourceWorkspaceId??"")):[],u=w.enabled===i&&(!i||v&&w.actor===v)?w.details??null:null;return{drafts:o,actor:v,pendingConflictDetails:u,openDialog:a=>{let p=rr(a);if(i){if(!v||(ei(p.resolutionContextToken)?.actor??v)!==v)return;const m=p.sourceWorkspaceId;if(!m||!e.includes(m))return;const y=So(v,m),b=o.find(n=>n.details.sourceWorkspaceId===m&&ci(n.details.resolutionContextToken));y?p=rr({conflictOp:p.conflictOp,conflictedFiles:[],resolutionContextToken:y.token}):b&&(p=b.details)}r({actor:v,enabled:i,details:p})},closeDialog:()=>r({actor:v,enabled:i}),storageUnavailable:si(),identityError:i&&g.isError}}function Zu(e){return[...e?.uncommitted??[],...e?.committed??[]].reduce((s,l)=>({files:s.files+1,additions:s.additions+(l.additions??0),deletions:s.deletions+(l.deletions??0)}),{files:0,additions:0,deletions:0})}function $r(e,i,s,l){const g=gn(e);if(g){s(g);return}l(e instanceof Error?e.message:i)}function sm({projectId:e,workspaceId:i,branchName:s,targetBranch:l,commitMessage:g,changes:v,gitStatus:w,isGitStatusLoading:r,canRunGitOperations:o,onOpenChanges:u,onRefreshCommitMessage:f,onConflict:a,className:p}){const{t:m}=re(),y=yi(),b=wi(),n=Ci(),[d,c]=A.useState(!1),[h,_]=A.useState(null),S=Gs(i,d),k=(S.data??[]).filter(fn),E=A.useMemo(()=>Zu(v),[v]),x=E.additions+E.deletions,C=E.files>0&&x>0,T=(w?.conflictedFiles.length??0)>0,L=!!(w&&w.operation!=="idle"),R=!!(w&&(w.hasUncommittedChanges||w.untrackedCount>0)),M=(w?.uncommittedCount??0)+(w?.untrackedCount??0),I=(w?.behind??0)>0,B=(w?.ahead??0)>0,H=r||!w&&o,$=!!(o&&i&&w&&I&&!T&&!L&&!R),N=!!(o&&i&&w&&B&&!I&&!T&&!L&&!R),P=!!(o&&i&&w&&!T&&!L&&!R);if(A.useEffect(()=>{d&&f?.()},[d,f]),!C)return null;const D=T?m("冲突"):w?.operation==="rebase"?m("变基中"):w?.operation==="merge"?m("合并中"):M>0?m("{count} 未提交",{count:M}):I?m("落后 {count}",{count:w?.behind??0}):m(B?"可合并":"已是最新"),O=m("{files} 个文件 · {lines} 行",{files:E.files,lines:x}),q=()=>{$&&(_(null),y.mutate(i,{onError:W=>{$r(W,m("更新失败,请稍后重试"),j=>a(j),_)}}))},K=()=>{P&&(_(null),c(!0))},U=(W,j)=>{_(null),b.mutate({id:i,commitMessage:W,stopActiveServices:j},{onSuccess:()=>c(!1),onError:F=>{if(mn(F)){_(m("后台服务仍在运行,请确认停止服务后再提交。"));return}$r(F,m("提交失败,请稍后重试"),X=>{c(!1),a(X)},_)}})},z=()=>{b.isPending||(c(!1),_(null))};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:Q("space-y-1",p),children:[t.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg bg-muted/25 px-2 py-1.5",children:[t.jsxs("button",{type:"button",onClick:u,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-1.5 py-0.5 text-left transition-colors hover:bg-muted/55 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40","aria-label":m("查看变更详情"),children:[t.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-background/70 text-muted-foreground",children:t.jsx(qs,{size:13})}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:O}),t.jsx(Jr,{additions:E.additions,deletions:E.deletions,className:"hidden sm:inline-flex"}),T&&t.jsx(Tt,{size:13,className:"shrink-0 text-warning"}),t.jsxs("span",{className:"hidden min-w-0 basis-0 grow max-w-fit items-center gap-1 text-[11px] text-muted-foreground md:flex",children:[t.jsx("span",{className:"truncate font-mono",children:s}),t.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground/70",children:"→"}),t.jsx("span",{className:"truncate font-mono",children:l})]}),t.jsx(Wt,{className:"bg-background/75",children:D})]}),t.jsx(Je,{size:15,className:"shrink-0 text-muted-foreground/70"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[L&&t.jsx(ce,{variant:"secondary",size:"sm",className:"hidden sm:inline-flex",onClick:()=>n.mutate(i),loading:n.isPending,children:n.isPending?m("正在撤销..."):m("撤销操作")}),t.jsx("span",{title:m(I?"同步更新":"已是最新"),className:Q("inline-flex",(!$||H)&&"cursor-not-allowed"),children:t.jsxs(ce,{variant:"secondary",size:"sm",onClick:q,disabled:!$||H,loading:y.isPending,children:[!y.isPending&&t.jsx(_t,{}),y.isPending?m("正在同步..."):m("更新")]})}),t.jsx("span",{title:N?m("合并到 {target}",{target:l}):m("提交变更"),className:Q("inline-flex",(!P||H)&&"cursor-not-allowed"),children:t.jsxs(ce,{variant:"primary",size:"sm",onClick:K,disabled:!P||H,loading:b.isPending,children:[!b.isPending&&t.jsx(Us,{}),b.isPending?m("正在提交..."):m("合并")]})})]})]}),h&&t.jsx(Oe,{tone:"danger",size:"sm",children:h})]}),t.jsx(pn,{projectId:e,workspaceId:i,canMerge:N,isOpen:d,onClose:z,onBaseBranchSaved:u,branchName:s,targetBranch:l,commitMessage:g,isPending:b.isPending,activeServices:k,isCheckingServices:S.isLoading,serviceCheckFailed:S.isError,error:h,onConfirm:U})]})}const Ur=["creating-workspace","creating-session","starting-session"];function rm({state:e,setupProgress:i,sessionStarted:s=!1,onRetry:l,compact:g=!1}){const{t:v}=re(),[w,r]=A.useState(!1),o=e?.status==="failed",u=i?.status==="failed",f=o||u,a=e?Ur.indexOf(e.status):Ur.length,p=[v("Preparing workspace"),v("Creating session"),v("Starting agent")],m=(e?.setupScript??"").split(`
69
+ `).map(n=>n.trim()).filter(Boolean),y=e||s?p.map((n,d)=>({label:n,status:o?"pending":d<a?"completed":d===a?"active":"pending"})):[];(i||m.length>0)&&y.push({label:i?.status==="running"?v("Running setup ({current}/{total})",{current:i.currentIndex??0,total:i.totalCommands}):i?.status==="completed"?v("Setup complete"):i?.status==="failed"?v("Setup failed"):v("Run setup script"),status:i?.status==="running"?"active":i?.status??"pending",description:i?.currentCommand||m.join(`
70
+ `)});const b=!!i?.output?.trim();return!e&&!i?null:t.jsxs("div",{className:`${g?"my-2 mb-4":"my-3 mb-6"} mx-auto w-full max-w-2xl rounded-xl border ${f?"border-destructive/30 bg-destructive/[0.03]":"border-border/70 bg-background"} px-4 py-3 text-left shadow-raised`,role:f?"alert":"status","aria-live":f?"assertive":"polite",children:[f&&(e?.error||i?.error||o)?t.jsx("p",{className:"mb-2 break-words text-xs text-destructive-ink",children:e?.error||i?.error||v("Agent start failed")}):null,t.jsx("div",{className:"space-y-2",children:y.map(({label:n,status:d,description:c})=>{const h=d==="completed",_=d==="active";return t.jsxs("div",{className:`flex items-start gap-2 text-sm ${d==="failed"?"text-destructive-ink":h||_?"text-info-ink":"text-muted-foreground"}`,children:[h?t.jsx(Vn,{className:"h-4 w-4 shrink-0"}):_?t.jsx(Fs,{className:"h-4 w-4 shrink-0 animate-spin motion-reduce:animate-none"}):d==="failed"?t.jsx(Zr,{className:"h-4 w-4 shrink-0"}):t.jsx(la,{className:"h-4 w-4 shrink-0"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{children:n}),c&&t.jsx("code",{className:"mt-1 block whitespace-pre-wrap break-all rounded-md bg-muted/35 px-2.5 py-2 text-xs leading-relaxed text-muted-foreground",children:c})]})]},n)})}),(b||o)&&t.jsxs("div",{className:"mt-3 flex items-center justify-between gap-3 border-t border-border/50 pt-2",children:[b?t.jsxs("button",{type:"button",onClick:()=>r(n=>!n),className:"inline-flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground","aria-expanded":w,"aria-controls":"task-start-progress-details",children:[w?t.jsx(Ke,{className:"h-3.5 w-3.5"}):t.jsx(Je,{className:"h-3.5 w-3.5"}),v(w?"Hide setup output":"View setup output")]}):t.jsx("span",{}),o&&l?t.jsx(ge,{size:"sm",variant:"outline",onClick:l,children:v("Retry start")}):null]}),w&&t.jsx("div",{id:"task-start-progress-details",className:"mt-2 rounded-md bg-muted/35 px-2.5 py-2 text-xs leading-relaxed text-muted-foreground",children:t.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono",children:i?.output??""})})]})}function Ju({agentType:e,workingDir:i}){return Ee({queryKey:ie.system.skillCatalog(e,i),queryFn:async()=>(await oe.get("/system/skill-catalog",{params:{agentType:String(e),...i?{workingDir:i}:{}}})).commands,enabled:e===ii.CODEX,staleTime:3e4})}function ef(e){const i=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,s=e.key==="Tab"&&!e.shiftKey;return i||s}function im({agentType:e,workingDir:i,input:s,setInput:l,textareaRef:g,minHeight:v,maxHeight:w}){const[r,o]=A.useState(0),{data:u=[]}=Ju({agentType:e,workingDir:i}),a=A.useMemo(()=>e===ii.CODEX?nr(s):null,[e,s])?.query??null,p=A.useMemo(()=>a===null?[]:zo(u,a),[a,u]),m=A.useCallback(()=>{const n=g.current;n&&(n.style.height="auto",n.style.height=`${Math.max(v,Math.min(n.scrollHeight,w))}px`)},[w,v,g]);A.useEffect(()=>{o(0)},[e,a]),A.useEffect(()=>{r<p.length||o(0)},[p.length,r]);const y=A.useCallback(n=>{const d=nr(s);if(!d)return;const c=`${s.slice(0,d.replaceStart)}${n.command} `;l(c),requestAnimationFrame(()=>{const h=g.current;h&&(m(),h.focus(),h.setSelectionRange(c.length,c.length))})},[s,m,l,g]),b=A.useCallback(n=>a===null||p.length===0?!1:n.key==="ArrowDown"?(n.preventDefault(),o(d=>(d+1)%p.length),!0):n.key==="ArrowUp"?(n.preventDefault(),o(d=>(d-1+p.length)%p.length),!0):ef(n)?(n.preventDefault(),y(p[r]??p[0]),!0):!1,[y,p,a,r]);return{allSkills:u,query:a,filteredSkills:p,selectedIndex:r,setSelectedIndex:o,applySkill:y,handleKeyDown:b}}const Cs=200,tf=180;function nm({taskId:e,title:i,readOnly:s=!1,onTitleChange:l,className:g,titleClassName:v,compact:w=!1}){const{t:r}=re(),[o,u]=A.useState(!1),[f,a]=A.useState(i),[p,m]=A.useState(!1),y=A.useRef(null),b=A.useRef(null),n=Gn();A.useEffect(()=>{o||a(i)},[i,o]),A.useEffect(()=>{o&&y.current&&(y.current.focus(),y.current.select())},[o]),A.useEffect(()=>{if(!o)return;const C=T=>{b.current&&!b.current.contains(T.target)&&h()};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[o,f]);const d=A.useCallback(()=>{s||(u(!0),a(i))},[s,i]),c=A.useCallback(()=>{u(!1),a(i)},[i]),h=A.useCallback(async()=>{const C=f.trim();if(!C){a(i),u(!1);return}if(C===i){u(!1);return}try{await n.mutateAsync({id:e,title:C}),l?.(C),u(!1)}catch(T){console.error("Failed to update task title:",T),a(i)}},[f,i,e,n,l]),_=A.useCallback(C=>{C.key==="Enter"&&!C.shiftKey?(C.preventDefault(),h()):C.key==="Escape"&&(C.preventDefault(),c())},[h,c]),S=A.useCallback(C=>{const T=C.target.value;T.length<=Cs&&a(T)},[]),k=f.length,E=k>=tf,x=k>=Cs;return o?t.jsxs("div",{ref:b,className:Q("flex flex-col gap-2",g),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{ref:y,type:"text",value:f,onChange:S,onKeyDown:_,disabled:n.isPending,className:Q("flex-1 min-w-0 px-2 py-1 text-[15px] font-semibold bg-background border border-input rounded-md","focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent","disabled:opacity-50 disabled:cursor-not-allowed",w&&"text-base py-0.5",v),placeholder:r("输入任务标题")}),t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.jsx(ge,{size:w?"sm":"default",variant:"ghost",onClick:h,disabled:n.isPending||!f.trim(),className:"h-8 w-8 p-0",children:n.isPending?t.jsx(Fs,{size:16,className:"animate-spin motion-reduce:[animation-duration:2.4s]"}):t.jsx(Et,{size:16})}),t.jsx(ge,{size:w?"sm":"default",variant:"ghost",onClick:c,disabled:n.isPending,className:"h-8 w-8 p-0",children:t.jsx(tt,{size:16})})]})]}),E&&t.jsxs("div",{className:Q("text-xs",x?"text-destructive-ink":"text-muted-foreground"),children:[k," / ",Cs," ",r("字符")]})]}):t.jsxs("div",{ref:b,className:Q("group flex items-center gap-2 min-w-0",g),onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),children:[t.jsx("h2",{onClick:d,className:Q("flex-1 min-w-0 text-[15px] font-semibold text-foreground break-words line-clamp-2",!s&&"cursor-text hover:text-foreground/80 transition-colors",w&&"text-base",v),children:i}),!s&&p&&t.jsx(ge,{size:"sm",variant:"ghost",onClick:d,className:"h-7 w-7 p-0 shrink-0 opacity-60 hover:opacity-100",title:r("编辑标题"),children:t.jsx(ta,{size:14})})]})}function sf(e){return Ee({queryKey:ie.tasks.handoff(e),queryFn:({signal:i})=>oe.get(`/tasks/${encodeURIComponent(e)}/handoff`,{signal:i}),enabled:!!e})}function rf(e){const i=De();return Ct({mutationFn:s=>oe.patch(`/tasks/${encodeURIComponent(e)}/handoff`,s),onMutate:()=>i.cancelQueries({queryKey:ie.tasks.handoff(e)}),onSuccess:s=>{i.setQueryData(ie.tasks.handoff(s.taskId),s)},onSettled:()=>i.invalidateQueries({queryKey:ie.tasks.handoff(e)})})}function qr(e){try{const i=JSON.parse(sessionStorage.getItem(e)??"null");if(i&&typeof i=="object"&&"base"in i&&"content"in i&&typeof i.base=="string"&&typeof i.content=="string")return{base:i.base,content:i.content}}catch{}return null}function om({taskId:e,readOnly:i=!1}){const{t:s}=re(),l=sf(e),g=rf(e),v=`task-handoff-draft:${e}`,[w,r]=A.useState(()=>qr(v)),o=w!==null&&!i;A.useEffect(()=>{try{w?sessionStorage.setItem(v,JSON.stringify(w)):sessionStorage.removeItem(v)}catch{}},[w,v]);const u=async()=>{if(!(!w||g.isPending))try{await g.mutateAsync({oldString:w.base,newString:w.content});try{const m=qr(v);m?.base===w.base&&m.content===w.content&&sessionStorage.removeItem(v)}catch{}r(null)}catch{}};if(l.isPending)return t.jsx("p",{className:"p-4 text-sm text-muted-foreground",children:s("Loading...")});if(!l.data)return t.jsx("div",{className:"p-3",children:t.jsx(Oe,{tone:"danger",action:t.jsx(ce,{variant:"link",size:"sm",onClick:()=>l.refetch(),children:s("Retry")}),children:s("Could not load the handoff note.")})});const f=o&&w.base!==l.data.content,a=g.error instanceof Ze?g.error.details.code:void 0,p=typeof a=="string"&&["HANDOFF_CHANGED","HANDOFF_NOT_EMPTY","HANDOFF_TEXT_NOT_FOUND","HANDOFF_TEXT_AMBIGUOUS"].includes(a);return t.jsxs("section",{className:"flex h-full min-h-0 flex-col","aria-label":s("Handoff note"),children:[t.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-between gap-2 border-b border-border/60 px-3 py-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:s(o?"Markdown":"Progress, decisions, and next steps")}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(Do,{value:o?w.content:l.data.content,display:"text",size:"sm"}),o?t.jsxs(t.Fragment,{children:[t.jsx(ce,{variant:"ghost",size:"sm",disabled:g.isPending,onClick:()=>{r(null),g.reset()},children:s("Cancel")}),t.jsx(ce,{size:"sm",disabled:g.isPending||w.content===w.base,onClick:u,children:g.isPending?s("保存中..."):s("Save")})]}):!i&&t.jsx(ce,{variant:"secondary",size:"sm",onClick:()=>{g.reset(),r({base:l.data.content,content:l.data.content})},children:s("编辑")})]})]}),o&&(f||p)&&t.jsx(Oe,{tone:"warning",size:"sm",className:"mx-3 mt-3",role:"status",children:s("The handoff changed elsewhere. Your draft is preserved. Cancel editing to view the latest note.")}),o&&g.isError&&!p&&t.jsx(Oe,{tone:"danger",size:"sm",className:"mx-3 mt-3",role:"alert",children:s("Could not save the handoff note. Your draft is preserved.")}),o?t.jsx("div",{className:"flex min-h-0 flex-1 p-3",children:t.jsx(pi,{"aria-label":s("Handoff Markdown"),value:w.content,onChange:m=>r({...w,content:m.target.value}),maxLength:Fa,disabled:g.isPending,className:"min-h-0 flex-1 font-mono",placeholder:s("Summarize progress, decisions, verification, open problems, and next steps."),onKeyDown:m=>{(m.metaKey||m.ctrlKey)&&m.key==="Enter"&&(m.preventDefault(),u())}})}):t.jsx("div",{className:"prose prose-sm max-w-none min-h-0 flex-1 overflow-y-auto p-4 dark:prose-invert [overflow-wrap:anywhere]",children:l.data.content?t.jsx(li,{components:po,children:l.data.content}):t.jsx("p",{className:"py-6 text-center text-muted-foreground",children:s("No handoff note yet. Record what has been done and what comes next.")})})]})}export{em as C,vn as D,nm as E,qs as G,Wf as R,Zf as S,zf as T,sm as W,im as a,nu as b,qf as c,jt as d,Kf as e,tm as f,$f as g,Qf as h,Ff as i,rm as j,Yf as k,Xf as l,Hf as m,om as n,Gf as o,Jf as p,ou as q,Uf as r,hn as s,un as t,Vf as u,Hu as v,uu as w,Ui as x};