agent-tower 0.6.0-beta.2 → 0.6.0-beta.3

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 (398) hide show
  1. package/dist/app.d.ts.map +1 -1
  2. package/dist/app.js +10 -2
  3. package/dist/app.js.map +1 -1
  4. package/dist/app.test.js +10 -0
  5. package/dist/app.test.js.map +1 -1
  6. package/dist/core/container.d.ts +2 -0
  7. package/dist/core/container.d.ts.map +1 -1
  8. package/dist/core/container.js +9 -1
  9. package/dist/core/container.js.map +1 -1
  10. package/dist/executors/__tests__/codex.executor.test.js +50 -0
  11. package/dist/executors/__tests__/codex.executor.test.js.map +1 -1
  12. package/dist/executors/codex.executor.d.ts +2 -0
  13. package/dist/executors/codex.executor.d.ts.map +1 -1
  14. package/dist/executors/codex.executor.js +8 -0
  15. package/dist/executors/codex.executor.js.map +1 -1
  16. package/dist/executors/execution-env.d.ts +1 -1
  17. package/dist/executors/execution-env.d.ts.map +1 -1
  18. package/dist/executors/execution-env.js +2 -0
  19. package/dist/executors/execution-env.js.map +1 -1
  20. package/dist/mcp/http-client.d.ts +24 -0
  21. package/dist/mcp/http-client.d.ts.map +1 -1
  22. package/dist/mcp/http-client.js +66 -8
  23. package/dist/mcp/http-client.js.map +1 -1
  24. package/dist/mcp/http-client.test.d.ts +2 -0
  25. package/dist/mcp/http-client.test.d.ts.map +1 -0
  26. package/dist/mcp/http-client.test.js +67 -0
  27. package/dist/mcp/http-client.test.js.map +1 -0
  28. package/dist/mcp/index.js +9 -2
  29. package/dist/mcp/index.js.map +1 -1
  30. package/dist/mcp/server.d.ts +1 -0
  31. package/dist/mcp/server.d.ts.map +1 -1
  32. package/dist/mcp/server.js +7 -0
  33. package/dist/mcp/server.js.map +1 -1
  34. package/dist/mcp/tools/__tests__/workspace-services.test.d.ts +2 -0
  35. package/dist/mcp/tools/__tests__/workspace-services.test.d.ts.map +1 -0
  36. package/dist/mcp/tools/__tests__/workspace-services.test.js +84 -0
  37. package/dist/mcp/tools/__tests__/workspace-services.test.js.map +1 -0
  38. package/dist/mcp/tools/workspace-services.d.ts +6 -0
  39. package/dist/mcp/tools/workspace-services.d.ts.map +1 -0
  40. package/dist/mcp/tools/workspace-services.js +102 -0
  41. package/dist/mcp/tools/workspace-services.js.map +1 -0
  42. package/dist/mcp/types.d.ts +55 -2
  43. package/dist/mcp/types.d.ts.map +1 -1
  44. package/dist/mcp/types.js +29 -0
  45. package/dist/mcp/types.js.map +1 -1
  46. package/dist/middleware/__tests__/access-auth.test.js +229 -2
  47. package/dist/middleware/__tests__/access-auth.test.js.map +1 -1
  48. package/dist/middleware/access-auth.d.ts +7 -0
  49. package/dist/middleware/access-auth.d.ts.map +1 -1
  50. package/dist/middleware/access-auth.js +50 -9
  51. package/dist/middleware/access-auth.js.map +1 -1
  52. package/dist/prompts/agent-output-intents.d.ts +2 -0
  53. package/dist/prompts/agent-output-intents.d.ts.map +1 -0
  54. package/dist/prompts/agent-output-intents.js +11 -0
  55. package/dist/prompts/agent-output-intents.js.map +1 -0
  56. package/dist/prompts/agent-output-intents.test.d.ts +2 -0
  57. package/dist/prompts/agent-output-intents.test.d.ts.map +1 -0
  58. package/dist/prompts/agent-output-intents.test.js +12 -0
  59. package/dist/prompts/agent-output-intents.test.js.map +1 -0
  60. package/dist/prompts/workspace-background-service-policy.d.ts +9 -0
  61. package/dist/prompts/workspace-background-service-policy.d.ts.map +1 -0
  62. package/dist/prompts/workspace-background-service-policy.js +17 -0
  63. package/dist/prompts/workspace-background-service-policy.js.map +1 -0
  64. package/dist/prompts/workspace-background-service-policy.test.d.ts +2 -0
  65. package/dist/prompts/workspace-background-service-policy.test.d.ts.map +1 -0
  66. package/dist/prompts/workspace-background-service-policy.test.js +19 -0
  67. package/dist/prompts/workspace-background-service-policy.test.js.map +1 -0
  68. package/dist/routes/__tests__/previews.integration.test.js +1 -0
  69. package/dist/routes/__tests__/previews.integration.test.js.map +1 -1
  70. package/dist/routes/__tests__/previews.test.js +6 -1
  71. package/dist/routes/__tests__/previews.test.js.map +1 -1
  72. package/dist/routes/__tests__/providers.test.js +1 -0
  73. package/dist/routes/__tests__/providers.test.js.map +1 -1
  74. package/dist/routes/__tests__/sessions-visualizations.test.d.ts +2 -0
  75. package/dist/routes/__tests__/sessions-visualizations.test.d.ts.map +1 -0
  76. package/dist/routes/__tests__/sessions-visualizations.test.js +89 -0
  77. package/dist/routes/__tests__/sessions-visualizations.test.js.map +1 -0
  78. package/dist/routes/__tests__/workspace-services.test.d.ts +2 -0
  79. package/dist/routes/__tests__/workspace-services.test.d.ts.map +1 -0
  80. package/dist/routes/__tests__/workspace-services.test.js +148 -0
  81. package/dist/routes/__tests__/workspace-services.test.js.map +1 -0
  82. package/dist/routes/access-auth.d.ts.map +1 -1
  83. package/dist/routes/access-auth.js +24 -11
  84. package/dist/routes/access-auth.js.map +1 -1
  85. package/dist/routes/index.d.ts.map +1 -1
  86. package/dist/routes/index.js +3 -0
  87. package/dist/routes/index.js.map +1 -1
  88. package/dist/routes/previews.d.ts.map +1 -1
  89. package/dist/routes/previews.js +4 -6
  90. package/dist/routes/previews.js.map +1 -1
  91. package/dist/routes/sessions.d.ts.map +1 -1
  92. package/dist/routes/sessions.js +93 -0
  93. package/dist/routes/sessions.js.map +1 -1
  94. package/dist/routes/tasks.d.ts.map +1 -1
  95. package/dist/routes/tasks.js +2 -2
  96. package/dist/routes/tasks.js.map +1 -1
  97. package/dist/routes/workspace-services.d.ts +7 -0
  98. package/dist/routes/workspace-services.d.ts.map +1 -0
  99. package/dist/routes/workspace-services.js +129 -0
  100. package/dist/routes/workspace-services.js.map +1 -0
  101. package/dist/runtime/__tests__/acp-agent-definitions.test.js +43 -0
  102. package/dist/runtime/__tests__/acp-agent-definitions.test.js.map +1 -1
  103. package/dist/runtime/__tests__/acp-driver-lifecycle.test.js +61 -1
  104. package/dist/runtime/__tests__/acp-driver-lifecycle.test.js.map +1 -1
  105. package/dist/runtime/__tests__/acp-driver.test.js +2 -0
  106. package/dist/runtime/__tests__/acp-driver.test.js.map +1 -1
  107. package/dist/runtime/__tests__/acp-process-manager.test.js +40 -1
  108. package/dist/runtime/__tests__/acp-process-manager.test.js.map +1 -1
  109. package/dist/runtime/__tests__/acp-projector.test.js +55 -0
  110. package/dist/runtime/__tests__/acp-projector.test.js.map +1 -1
  111. package/dist/runtime/__tests__/runtime-coordinator.test.js +5 -2
  112. package/dist/runtime/__tests__/runtime-coordinator.test.js.map +1 -1
  113. package/dist/runtime/acp/acp-driver.js +79 -27
  114. package/dist/runtime/acp/acp-driver.js.map +1 -1
  115. package/dist/runtime/acp/agents/codex-frame-normalizer.d.ts +4 -0
  116. package/dist/runtime/acp/agents/codex-frame-normalizer.d.ts.map +1 -0
  117. package/dist/runtime/acp/agents/codex-frame-normalizer.js +51 -0
  118. package/dist/runtime/acp/agents/codex-frame-normalizer.js.map +1 -0
  119. package/dist/runtime/acp/agents/codex.d.ts.map +1 -1
  120. package/dist/runtime/acp/agents/codex.js +21 -0
  121. package/dist/runtime/acp/agents/codex.js.map +1 -1
  122. package/dist/runtime/acp/agents/types.d.ts +4 -0
  123. package/dist/runtime/acp/agents/types.d.ts.map +1 -1
  124. package/dist/runtime/acp/codex-provider-config.d.ts +1 -0
  125. package/dist/runtime/acp/codex-provider-config.d.ts.map +1 -1
  126. package/dist/runtime/acp/codex-provider-config.js +4 -0
  127. package/dist/runtime/acp/codex-provider-config.js.map +1 -1
  128. package/dist/runtime/acp/process-manager.d.ts +3 -0
  129. package/dist/runtime/acp/process-manager.d.ts.map +1 -1
  130. package/dist/runtime/acp/process-manager.js +31 -12
  131. package/dist/runtime/acp/process-manager.js.map +1 -1
  132. package/dist/runtime/acp/projector.d.ts.map +1 -1
  133. package/dist/runtime/acp/projector.js +71 -5
  134. package/dist/runtime/acp/projector.js.map +1 -1
  135. package/dist/runtime/contracts.d.ts +1 -0
  136. package/dist/runtime/contracts.d.ts.map +1 -1
  137. package/dist/runtime/runtime-coordinator.d.ts.map +1 -1
  138. package/dist/runtime/runtime-coordinator.js +1 -0
  139. package/dist/runtime/runtime-coordinator.js.map +1 -1
  140. package/dist/services/__tests__/access-auth.service.test.js +41 -0
  141. package/dist/services/__tests__/access-auth.service.test.js.map +1 -1
  142. package/dist/services/__tests__/agent-artifact.service.test.d.ts +2 -0
  143. package/dist/services/__tests__/agent-artifact.service.test.d.ts.map +1 -0
  144. package/dist/services/__tests__/agent-artifact.service.test.js +133 -0
  145. package/dist/services/__tests__/agent-artifact.service.test.js.map +1 -0
  146. package/dist/services/__tests__/agent-visualization.service.test.d.ts +2 -0
  147. package/dist/services/__tests__/agent-visualization.service.test.d.ts.map +1 -0
  148. package/dist/services/__tests__/agent-visualization.service.test.js +57 -0
  149. package/dist/services/__tests__/agent-visualization.service.test.js.map +1 -0
  150. package/dist/services/__tests__/preview-runtime-manager.test.js +5 -0
  151. package/dist/services/__tests__/preview-runtime-manager.test.js.map +1 -1
  152. package/dist/services/__tests__/project.service.test.js +6 -2
  153. package/dist/services/__tests__/project.service.test.js.map +1 -1
  154. package/dist/services/__tests__/provider-config.service.test.js +32 -0
  155. package/dist/services/__tests__/provider-config.service.test.js.map +1 -1
  156. package/dist/services/__tests__/session-manager.lifecycle.test.js +153 -1
  157. package/dist/services/__tests__/session-manager.lifecycle.test.js.map +1 -1
  158. package/dist/services/__tests__/session-manager.team-run.test.js +18 -5
  159. package/dist/services/__tests__/session-manager.team-run.test.js.map +1 -1
  160. package/dist/services/__tests__/task.service.test.js +16 -3
  161. package/dist/services/__tests__/task.service.test.js.map +1 -1
  162. package/dist/services/__tests__/workspace-background-process-manager.test.d.ts +2 -0
  163. package/dist/services/__tests__/workspace-background-process-manager.test.d.ts.map +1 -0
  164. package/dist/services/__tests__/workspace-background-process-manager.test.js +412 -0
  165. package/dist/services/__tests__/workspace-background-process-manager.test.js.map +1 -0
  166. package/dist/services/__tests__/workspace-background-service.service.test.d.ts +2 -0
  167. package/dist/services/__tests__/workspace-background-service.service.test.d.ts.map +1 -0
  168. package/dist/services/__tests__/workspace-background-service.service.test.js +418 -0
  169. package/dist/services/__tests__/workspace-background-service.service.test.js.map +1 -0
  170. package/dist/services/__tests__/workspace.service.test.js +137 -0
  171. package/dist/services/__tests__/workspace.service.test.js.map +1 -1
  172. package/dist/services/access-auth.service.d.ts +15 -1
  173. package/dist/services/access-auth.service.d.ts.map +1 -1
  174. package/dist/services/access-auth.service.js +75 -15
  175. package/dist/services/access-auth.service.js.map +1 -1
  176. package/dist/services/agent-artifact.service.d.ts +28 -0
  177. package/dist/services/agent-artifact.service.d.ts.map +1 -0
  178. package/dist/services/agent-artifact.service.js +287 -0
  179. package/dist/services/agent-artifact.service.js.map +1 -0
  180. package/dist/services/agent-visualization.service.d.ts +12 -0
  181. package/dist/services/agent-visualization.service.d.ts.map +1 -0
  182. package/dist/services/agent-visualization.service.js +239 -0
  183. package/dist/services/agent-visualization.service.js.map +1 -0
  184. package/dist/services/mcp-config.service.d.ts.map +1 -1
  185. package/dist/services/mcp-config.service.js +8 -1
  186. package/dist/services/mcp-config.service.js.map +1 -1
  187. package/dist/services/mcp-config.service.test.js +14 -0
  188. package/dist/services/mcp-config.service.test.js.map +1 -1
  189. package/dist/services/preview-runtime-manager.d.ts.map +1 -1
  190. package/dist/services/preview-runtime-manager.js +15 -12
  191. package/dist/services/preview-runtime-manager.js.map +1 -1
  192. package/dist/services/project.service.d.ts +4 -1
  193. package/dist/services/project.service.d.ts.map +1 -1
  194. package/dist/services/project.service.js +43 -32
  195. package/dist/services/project.service.js.map +1 -1
  196. package/dist/services/provider-config.service.d.ts.map +1 -1
  197. package/dist/services/provider-config.service.js +11 -0
  198. package/dist/services/provider-config.service.js.map +1 -1
  199. package/dist/services/session-manager.d.ts +34 -32
  200. package/dist/services/session-manager.d.ts.map +1 -1
  201. package/dist/services/session-manager.js +43 -23
  202. package/dist/services/session-manager.js.map +1 -1
  203. package/dist/services/task-cleanup.service.d.ts +4 -1
  204. package/dist/services/task-cleanup.service.d.ts.map +1 -1
  205. package/dist/services/task-cleanup.service.js +13 -1
  206. package/dist/services/task-cleanup.service.js.map +1 -1
  207. package/dist/services/task.service.d.ts +22 -20
  208. package/dist/services/task.service.d.ts.map +1 -1
  209. package/dist/services/task.service.js +21 -8
  210. package/dist/services/task.service.js.map +1 -1
  211. package/dist/services/workspace-background-process-manager.d.ts +66 -0
  212. package/dist/services/workspace-background-process-manager.d.ts.map +1 -0
  213. package/dist/services/workspace-background-process-manager.js +328 -0
  214. package/dist/services/workspace-background-process-manager.js.map +1 -0
  215. package/dist/services/workspace-background-service.service.d.ts +39 -0
  216. package/dist/services/workspace-background-service.service.d.ts.map +1 -0
  217. package/dist/services/workspace-background-service.service.js +520 -0
  218. package/dist/services/workspace-background-service.service.js.map +1 -0
  219. package/dist/services/workspace-lifecycle-barrier.d.ts +10 -0
  220. package/dist/services/workspace-lifecycle-barrier.d.ts.map +1 -0
  221. package/dist/services/workspace-lifecycle-barrier.js +35 -0
  222. package/dist/services/workspace-lifecycle-barrier.js.map +1 -0
  223. package/dist/services/workspace.service.d.ts +42 -36
  224. package/dist/services/workspace.service.d.ts.map +1 -1
  225. package/dist/services/workspace.service.js +100 -39
  226. package/dist/services/workspace.service.js.map +1 -1
  227. package/dist/socket/__tests__/socket-gateway.test.js +23 -0
  228. package/dist/socket/__tests__/socket-gateway.test.js.map +1 -1
  229. package/dist/socket/middleware/__tests__/auth.test.js +3 -3
  230. package/dist/socket/middleware/__tests__/auth.test.js.map +1 -1
  231. package/dist/utils/agent-api-credential.d.ts +11 -0
  232. package/dist/utils/agent-api-credential.d.ts.map +1 -0
  233. package/dist/utils/agent-api-credential.js +40 -0
  234. package/dist/utils/agent-api-credential.js.map +1 -0
  235. package/dist/utils/internal-api-token.d.ts +2 -0
  236. package/dist/utils/internal-api-token.d.ts.map +1 -1
  237. package/dist/utils/internal-api-token.js +2 -0
  238. package/dist/utils/internal-api-token.js.map +1 -1
  239. package/dist/utils/process-launch.d.ts.map +1 -1
  240. package/dist/utils/process-launch.js +156 -22
  241. package/dist/utils/process-launch.js.map +1 -1
  242. package/dist/utils/process-launch.test.js +7 -0
  243. package/dist/utils/process-launch.test.js.map +1 -1
  244. package/dist/utils/unix-process-identity.d.ts +23 -0
  245. package/dist/utils/unix-process-identity.d.ts.map +1 -0
  246. package/dist/utils/unix-process-identity.js +165 -0
  247. package/dist/utils/unix-process-identity.js.map +1 -0
  248. package/dist/web/assets/{AgentDemoPage-XrttOpQW.js → AgentDemoPage-CLemSpf6.js} +1 -1
  249. package/dist/web/assets/{AgentEnvironmentSettingsPage-CAo0bCpZ.js → AgentEnvironmentSettingsPage-CPggaJvZ.js} +1 -1
  250. package/dist/web/assets/{AgentLogo-BCwbooTN.js → AgentLogo-DJFjaRFS.js} +1 -1
  251. package/dist/web/assets/ConversationPage-CB4PoHYi.js +3 -0
  252. package/dist/web/assets/CreateTaskInput-CXWGjX_a.js +1 -0
  253. package/dist/web/assets/{DemoPage-DHMh9-zU.js → DemoPage-djW4NeHW.js} +3 -3
  254. package/dist/web/assets/{GeneralSettingsPage-DvWaqR9O.js → GeneralSettingsPage-0a2VgV74.js} +1 -1
  255. package/dist/web/assets/{Icons-DADUmnB1.js → Icons-tvQ3lNxT.js} +1 -1
  256. package/dist/web/assets/{LoadingPreviewPage-Dk91Ua1W.js → LoadingPreviewPage-D8GpQ-Ic.js} +1 -1
  257. package/dist/web/assets/McpSettingsPage-BxPMmwHH.js +1 -0
  258. package/dist/web/assets/{MemberAvatar-l-WCdlLA.js → MemberAvatar-JbGgXa3r.js} +1 -1
  259. package/dist/web/assets/{NotificationSettingsPage-Byu8b9X3.js → NotificationSettingsPage-BtN0fYTA.js} +1 -1
  260. package/dist/web/assets/{ProfileSettingsPage-BdylqWUj.js → ProfileSettingsPage-CVSHbAtS.js} +1 -1
  261. package/dist/web/assets/ProjectKanbanPage-Dq0pufE1.js +90 -0
  262. package/dist/web/assets/ProjectSettingsPage-CChSA5A4.js +2 -0
  263. package/dist/web/assets/ProviderSettingsPage-giXaDHmU.js +95 -0
  264. package/dist/web/assets/{SettingsMasterDetail-DTGIIGdI.js → SettingsMasterDetail-D-TeBuLx.js} +1 -1
  265. package/dist/web/assets/{TeamSettingsPage-BXuG4Bou.js → TeamSettingsPage-DNLp2l2E.js} +1 -1
  266. package/dist/web/assets/{arc-DrcjdWTE.js → arc-B5sdSA9b.js} +1 -1
  267. package/dist/web/assets/{architectureDiagram-3BPJPVTR-CAoBhXSL.js → architectureDiagram-3BPJPVTR-ClsPKWjN.js} +1 -1
  268. package/dist/web/assets/{arrow-left-CCWDjOmp.js → arrow-left-B7C-fOb5.js} +1 -1
  269. package/dist/web/assets/{blockDiagram-GPEHLZMM-CcTSBbUq.js → blockDiagram-GPEHLZMM-HHViBKvL.js} +1 -1
  270. package/dist/web/assets/{c4Diagram-AAUBKEIU-BuUKdgUg.js → c4Diagram-AAUBKEIU-CRreiVUs.js} +1 -1
  271. package/dist/web/assets/channel-Bhjxgyee.js +1 -0
  272. package/dist/web/assets/check-Dtr-nHO5.js +1 -0
  273. package/dist/web/assets/{chevron-down-BQcW9sFf.js → chevron-down-BZnZAd2n.js} +1 -1
  274. package/dist/web/assets/{chevron-right-pH923eYp.js → chevron-right-nnOI2p8q.js} +1 -1
  275. package/dist/web/assets/{chevron-up-DyQW115F.js → chevron-up-Cl6FGZ8R.js} +1 -1
  276. package/dist/web/assets/{chunk-2J33WTMH-BWNSmQa8.js → chunk-2J33WTMH-_s2AOnis.js} +1 -1
  277. package/dist/web/assets/{chunk-4BX2VUAB-Blldhw0k.js → chunk-4BX2VUAB-Ds1jhNjB.js} +1 -1
  278. package/dist/web/assets/{chunk-55IACEB6-hTffyPXL.js → chunk-55IACEB6-B2SvpbB1.js} +1 -1
  279. package/dist/web/assets/{chunk-727SXJPM-Cd48r7c-.js → chunk-727SXJPM-B6qjWdxn.js} +1 -1
  280. package/dist/web/assets/{chunk-AQP2D5EJ-BdDrOIL7.js → chunk-AQP2D5EJ-myECS-o9.js} +1 -1
  281. package/dist/web/assets/{chunk-FMBD7UC4-6XIvQYVJ.js → chunk-FMBD7UC4-CFDf13jX.js} +1 -1
  282. package/dist/web/assets/{chunk-ND2GUHAM-BJlcb_pB.js → chunk-ND2GUHAM-62aJufBH.js} +1 -1
  283. package/dist/web/assets/{chunk-QZHKN3VN-3TZzFkxK.js → chunk-QZHKN3VN-DEWvzHCx.js} +1 -1
  284. package/dist/web/assets/{circle-alert-oa-BQ5e7.js → circle-alert-BSGJzTSj.js} +1 -1
  285. package/dist/web/assets/classDiagram-4FO5ZUOK-BxnIeW8e.js +1 -0
  286. package/dist/web/assets/classDiagram-v2-Q7XG4LA2-BxnIeW8e.js +1 -0
  287. package/dist/web/assets/{code-block-OCS4YCEC-xJQWFyR7.js → code-block-OCS4YCEC-DWj3hzdw.js} +1 -1
  288. package/dist/web/assets/{confirm-dialog-CRiC3xBd.js → confirm-dialog-oStWxmjS.js} +1 -1
  289. package/dist/web/assets/{cose-bilkent-S5V4N54A-Cjcm-rW_.js → cose-bilkent-S5V4N54A-DNYqhVNu.js} +1 -1
  290. package/dist/web/assets/cssMode-Cn68yhOS.js +1 -0
  291. package/dist/web/assets/{dagre-BM42HDAG-YqubcAJi.js → dagre-BM42HDAG-gQbGUd4s.js} +1 -1
  292. package/dist/web/assets/{diagram-2AECGRRQ-Dk4ayFqg.js → diagram-2AECGRRQ-BeMaPQBR.js} +1 -1
  293. package/dist/web/assets/{diagram-5GNKFQAL-CQ0joYfB.js → diagram-5GNKFQAL-CStJaSd8.js} +1 -1
  294. package/dist/web/assets/{diagram-KO2AKTUF-DmuZzIdW.js → diagram-KO2AKTUF-BmEeaazt.js} +1 -1
  295. package/dist/web/assets/{diagram-LMA3HP47-YTPEfEZy.js → diagram-LMA3HP47-ClNnKUvt.js} +1 -1
  296. package/dist/web/assets/{diagram-OG6HWLK6-DmwRuz8-.js → diagram-OG6HWLK6-C24GKhLk.js} +1 -1
  297. package/dist/web/assets/{erDiagram-TEJ5UH35-LRL_DMXa.js → erDiagram-TEJ5UH35-6Xp8w1WL.js} +1 -1
  298. package/dist/web/assets/{flowDiagram-I6XJVG4X-ELBDyOvk.js → flowDiagram-I6XJVG4X-BCih6e9O.js} +1 -1
  299. package/dist/web/assets/folder-picker-DcY2P8zf.js +1 -0
  300. package/dist/web/assets/{freemarker2-DxJFkRz5.js → freemarker2-C6kMBtOW.js} +1 -1
  301. package/dist/web/assets/{ganttDiagram-6RSMTGT7-D0e9ILuF.js → ganttDiagram-6RSMTGT7-_9GX-BOi.js} +1 -1
  302. package/dist/web/assets/{gitGraphDiagram-PVQCEYII-Ck6OXXw0.js → gitGraphDiagram-PVQCEYII-DEe9VMLq.js} +1 -1
  303. package/dist/web/assets/handlebars-BxZgdhY8.js +1 -0
  304. package/dist/web/assets/html-bhMfD_X9.js +1 -0
  305. package/dist/web/assets/htmlMode-CC7AVUJ4.js +1 -0
  306. package/dist/web/assets/index-018g9RN4.css +1 -0
  307. package/dist/web/assets/{index-D9kBRMR0.js → index-ToY1NCNr.js} +3 -3
  308. package/dist/web/assets/{index-CjdqAcbu.js → index-cl-QFuts.js} +4 -4
  309. package/dist/web/assets/{infoDiagram-5YYISTIA-Cx8be-MV.js → infoDiagram-5YYISTIA-CU3D8SMZ.js} +1 -1
  310. package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-Dlc7akl7.js → ishikawaDiagram-YF4QCWOH-ClffgdSa.js} +1 -1
  311. package/dist/web/assets/javascript-8UIdW5Gd.js +1 -0
  312. package/dist/web/assets/{journeyDiagram-JHISSGLW-BVDSbS9-.js → journeyDiagram-JHISSGLW-Cy7Rr0_y.js} +1 -1
  313. package/dist/web/assets/{jsonMode-B5CJhoWd.js → jsonMode-JLBoaKf1.js} +1 -1
  314. package/dist/web/assets/{kanban-definition-UN3LZRKU-nFR0zB7B.js → kanban-definition-UN3LZRKU-14piuQEq.js} +1 -1
  315. package/dist/web/assets/{layers-Bo4aml98.js → layers-C93epAjs.js} +1 -1
  316. package/dist/web/assets/{linear-BCWZjcpP.js → linear-BtH62ya4.js} +1 -1
  317. package/dist/web/assets/liquid-BntTiwt7.js +1 -0
  318. package/dist/web/assets/{lspLanguageFeatures-Cbk7wEkj.js → lspLanguageFeatures-Dk65AKZD.js} +1 -1
  319. package/dist/web/assets/mdx-ToUKdFio.js +1 -0
  320. package/dist/web/assets/{mermaid-NOHMQCX5-DWQaYVL0.js → mermaid-NOHMQCX5-CPO3gPWp.js} +66 -65
  321. package/dist/web/assets/{message-square-DxbkpGqF.js → message-square-BBENHwpb.js} +1 -1
  322. package/dist/web/assets/{mindmap-definition-RKZ34NQL-LI7W1FIX.js → mindmap-definition-RKZ34NQL-gWYqFXbP.js} +1 -1
  323. package/dist/web/assets/{modal-Cymk-6Df.js → modal-D-sNOVPw.js} +1 -1
  324. package/dist/web/assets/{monaco-Bc-Z2u8N.js → monaco-B9Zd90UG.js} +3 -3
  325. package/dist/web/assets/{pencil-DOL2nlgg.js → pencil-BRPix314.js} +1 -1
  326. package/dist/web/assets/{pieDiagram-4H26LBE5-mgUzAFkk.js → pieDiagram-4H26LBE5-C3cHgEuO.js} +1 -1
  327. package/dist/web/assets/python-BeGIUwrY.js +1 -0
  328. package/dist/web/assets/{quadrantDiagram-W4KKPZXB-CaDF2kqA.js → quadrantDiagram-W4KKPZXB-DZFYp-mp.js} +1 -1
  329. package/dist/web/assets/razor-CnCuqD7W.js +1 -0
  330. package/dist/web/assets/{requirementDiagram-4Y6WPE33-DhmHdr_0.js → requirementDiagram-4Y6WPE33-DSQRXAFH.js} +1 -1
  331. package/dist/web/assets/{sankeyDiagram-5OEKKPKP-B7qnGfue.js → sankeyDiagram-5OEKKPKP-CEXk2v3C.js} +1 -1
  332. package/dist/web/assets/{select-BpKQyMvD.js → select-CGNclv1f.js} +1 -1
  333. package/dist/web/assets/{sequenceDiagram-3UESZ5HK-D2LhPgpM.js → sequenceDiagram-3UESZ5HK-CHVF_25M.js} +1 -1
  334. package/dist/web/assets/server-UA3ZvpjF.js +1 -0
  335. package/dist/web/assets/{stateDiagram-AJRCARHV-ClkO4Gu5.js → stateDiagram-AJRCARHV-TMqBR1_f.js} +1 -1
  336. package/dist/web/assets/stateDiagram-v2-BHNVJYJU-DqCjP1u1.js +1 -0
  337. package/dist/web/assets/{switch-BJ4Ar_OA.js → switch-C7qsQ1x2.js} +1 -1
  338. package/dist/web/assets/{textarea-DjwjAAG8.js → textarea-CDdCks2T.js} +1 -1
  339. package/dist/web/assets/{timeline-definition-PNZ67QCA-DhGIG-GC.js → timeline-definition-PNZ67QCA-CxC3mFt7.js} +1 -1
  340. package/dist/web/assets/{trash-2-R46i6Uus.js → trash-2-Bye7VGcW.js} +1 -1
  341. package/dist/web/assets/{tsMode-CKaqpIrz.js → tsMode-8nvc-x2E.js} +1 -1
  342. package/dist/web/assets/typescript-P7JXXc42.js +1 -0
  343. package/dist/web/assets/{upload-CgWqsmdI.js → upload-wJO5M1ZY.js} +1 -1
  344. package/dist/web/assets/{use-profiles-BlGgvdYm.js → use-profiles-CYJIKesy.js} +1 -1
  345. package/dist/web/assets/{use-projects-Cuv0A0RC.js → use-projects-Ds_YI2En.js} +1 -1
  346. package/dist/web/assets/{use-providers-DLcAY6E1.js → use-providers-B9FaTKyw.js} +1 -1
  347. package/dist/web/assets/{useNormalizedLogs-tfxFAJOF.js → useNormalizedLogs-B8um63GF.js} +1 -1
  348. package/dist/web/assets/{vennDiagram-CIIHVFJN-BngQhsYJ.js → vennDiagram-CIIHVFJN-DX0jm9G-.js} +1 -1
  349. package/dist/web/assets/{wardley-L42UT6IY-BEY6sftT.js → wardley-L42UT6IY-Ce-rqtq2.js} +1 -1
  350. package/dist/web/assets/{wardleyDiagram-YWT4CUSO-IH_Yh-cw.js → wardleyDiagram-YWT4CUSO-Gpxnu2av.js} +1 -1
  351. package/dist/web/assets/xml-1G4iEdpK.js +1 -0
  352. package/dist/web/assets/{xychartDiagram-2RQKCTM6-BdrGFDsr.js → xychartDiagram-2RQKCTM6-COe6opx2.js} +1 -1
  353. package/dist/web/assets/yaml-HqUdsAk3.js +1 -0
  354. package/dist/web/index.html +2 -2
  355. package/node_modules/@agent-tower/shared/dist/agent-download-intent.d.ts +6 -0
  356. package/node_modules/@agent-tower/shared/dist/agent-download-intent.d.ts.map +1 -0
  357. package/node_modules/@agent-tower/shared/dist/agent-download-intent.js +46 -0
  358. package/node_modules/@agent-tower/shared/dist/agent-download-intent.js.map +1 -0
  359. package/node_modules/@agent-tower/shared/dist/index.d.ts +1 -0
  360. package/node_modules/@agent-tower/shared/dist/index.d.ts.map +1 -1
  361. package/node_modules/@agent-tower/shared/dist/index.js +1 -0
  362. package/node_modules/@agent-tower/shared/dist/index.js.map +1 -1
  363. package/node_modules/@agent-tower/shared/dist/provider-capabilities.d.ts +1 -0
  364. package/node_modules/@agent-tower/shared/dist/provider-capabilities.d.ts.map +1 -1
  365. package/node_modules/@agent-tower/shared/dist/provider-capabilities.js +4 -0
  366. package/node_modules/@agent-tower/shared/dist/provider-capabilities.js.map +1 -1
  367. package/node_modules/@agent-tower/shared/dist/types.d.ts +56 -2
  368. package/node_modules/@agent-tower/shared/dist/types.d.ts.map +1 -1
  369. package/node_modules/@agent-tower/shared/dist/types.js.map +1 -1
  370. package/package.json +1 -1
  371. package/prisma/migrations/20260728000000_add_agent_artifacts/migration.sql +23 -0
  372. package/prisma/schema.prisma +48 -0
  373. package/dist/web/assets/ConversationPage-kyHuICil.js +0 -3
  374. package/dist/web/assets/CreateTaskInput-B67vzMJD.js +0 -1
  375. package/dist/web/assets/McpSettingsPage-CH8jFyxp.js +0 -1
  376. package/dist/web/assets/ProjectKanbanPage--cx6wNDR.js +0 -90
  377. package/dist/web/assets/ProjectSettingsPage-6psG0Vfc.js +0 -2
  378. package/dist/web/assets/ProviderSettingsPage-BPEEkhtA.js +0 -93
  379. package/dist/web/assets/channel-Bh_PCZNP.js +0 -1
  380. package/dist/web/assets/check-BN_PVKzE.js +0 -1
  381. package/dist/web/assets/classDiagram-4FO5ZUOK-B0lQFDoP.js +0 -1
  382. package/dist/web/assets/classDiagram-v2-Q7XG4LA2-B0lQFDoP.js +0 -1
  383. package/dist/web/assets/copy-DaoAUKTO.js +0 -1
  384. package/dist/web/assets/cssMode-_D6u4YDd.js +0 -1
  385. package/dist/web/assets/folder-picker-WUhXxIM5.js +0 -1
  386. package/dist/web/assets/handlebars-djdO6ZKR.js +0 -1
  387. package/dist/web/assets/html-CHeBxmFi.js +0 -1
  388. package/dist/web/assets/htmlMode-SZh8FaPi.js +0 -1
  389. package/dist/web/assets/index-CjAJoGg5.css +0 -1
  390. package/dist/web/assets/javascript-l6fV6hf7.js +0 -1
  391. package/dist/web/assets/liquid-DkFOeJ6J.js +0 -1
  392. package/dist/web/assets/mdx-BOPNdexu.js +0 -1
  393. package/dist/web/assets/python-D_wlYLCL.js +0 -1
  394. package/dist/web/assets/razor-DBFVg4JU.js +0 -1
  395. package/dist/web/assets/stateDiagram-v2-BHNVJYJU-YnSeSD_N.js +0 -1
  396. package/dist/web/assets/typescript-DsixnGVt.js +0 -1
  397. package/dist/web/assets/xml-dEcQ1gzo.js +0 -1
  398. package/dist/web/assets/yaml-BfGVqGj4.js +0 -1
@@ -1,90 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/monaco-Bc-Z2u8N.js","assets/index-D9kBRMR0.js","assets/index-CjAJoGg5.css","assets/monaco-Dvl_Svmm.css"])))=>i.map(i=>d[i]);
2
- import{ah as Uc,ai as Qn,aj as qc,ak as Kc,al as Xc,k as He,r as S,am as ae,z as ps,m as Bt,an as _s,n as Ft,p as Ce,o as bt,q as de,u as ce,j as t,a9 as gt,V as ga,W as Yc,l as se,Z as Ds,B as Te,ao as va,ap as xa,aq as _a,af as vs,X as Yt,ar as ln,as as Vc,O as dr,at as Gc,D as Qc,au as Zc,av as Jc,aw as ed,T as ur,t as rt,P as Jt,Q as ct,U as Ns,a5 as Fr,a3 as Ke,ax as hr,ay as td,az as cn,ag as sd,ad as rd,ae as id,aA as ba,aB as dn,aC as ya,aD as Sa,aE as wa,aF as nd,aG as od,a0 as ad,aH as ld,aI as cd,aJ as dd,Y as Zn,a8 as Jn}from"./index-D9kBRMR0.js";import{S as dt,u as un,A as hn,l as ud,F as Ca,m as hd,o as fd,Q as fn,p as md,q as At,W as _t,r as ka,C as ir,t as Ar,v as pd,w as gd,T as vd,h as Nt,b as zr,x as Ea,y as Ht}from"./mermaid-NOHMQCX5-DWQaYVL0.js";import{C as mn}from"./confirm-dialog-CRiC3xBd.js";import{c as ja,a as Na,b as Ra,I as Aa,d as Ta,A as eo,G as Ma}from"./Icons-DADUmnB1.js";import{C as wt}from"./chevron-down-BQcW9sFf.js";import{C as Mt}from"./chevron-right-pH923eYp.js";import{d as pn,S as xd,u as gn,A as nr,c as vn,G as Da,Z as _d,e as xn,T as _n,f as bd,g as bn,h as to,i as yd,b as Pa,j as La,a as Ia,k as Oa,R as Ba,P as Fa,l as Wr,m as Sd,C as so,B as ro}from"./CreateTaskInput-B67vzMJD.js";import{a as wd,F as Cd,b as kd}from"./folder-picker-WUhXxIM5.js";import{M as ti}from"./message-square-DxbkpGqF.js";import{L as Ps}from"./layers-Bo4aml98.js";import{P as yn,u as za,a as Wa,T as Hr}from"./useNormalizedLogs-tfxFAJOF.js";import{u as Bs}from"./use-providers-DLcAY6E1.js";import{A as si}from"./AgentLogo-BCwbooTN.js";import{M as $t}from"./MemberAvatar-l-WCdlLA.js";import{C as Ha}from"./chevron-up-DyQW115F.js";import{C as Vt}from"./check-BN_PVKzE.js";import{M as ns}from"./modal-Cymk-6Df.js";import{S as es}from"./select-BpKQyMvD.js";import{P as ts,T as Sn}from"./trash-2-R46i6Uus.js";import{T as Ed}from"./textarea-DjwjAAG8.js";import{F as $a,e as jd,d as Nd,f as Rd,u as Ad}from"./use-projects-Cuv0A0RC.js";import{U as $r}from"./upload-CgWqsmdI.js";import{A as Ls}from"./arrow-left-CCWDjOmp.js";import{C as io}from"./copy-DaoAUKTO.js";var Td=class extends Uc{constructor(e,s){super(e,s)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:Qn()})}getOptimisticResult(e){return e.behavior=Qn(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,s){const{state:r}=e,o=super.createResult(e,s),{isFetching:g,isRefetching:p,isError:v,isRefetchError:n}=o,i=r.fetchMeta?.fetchMore?.direction,l=v&&i==="forward",d=g&&i==="forward",c=v&&i==="backward",m=g&&i==="backward";return{...o,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Kc(s,r.data),hasPreviousPage:qc(s,r.data),isFetchNextPageError:l,isFetchingNextPage:d,isFetchPreviousPageError:c,isFetchingPreviousPage:m,isRefetchError:n&&!l&&!c,isRefetching:p&&!d&&!m}}};function wn(e,s){return Xc(e,Td)}const Md=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Ua=He("arrow-right",Md);const Dd=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],qa=He("ban",Dd);const Pd=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Ld=He("chevron-left",Pd);const Id=[["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"}]],Od=He("clipboard-paste",Id);const Bd=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Rs=He("clock-3",Bd);const Fd=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],ri=He("code-xml",Fd);const zd=[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],no=He("copy-plus",zd);const Wd=[["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"}]],Hd=He("earth",Wd);const $d=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],Ka=He("ellipsis-vertical",$d);const Ud=[["path",{d:"M14 22h4a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v6",key:"14cnrg"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M5 14a1 1 0 0 0-1 1v2a1 1 0 0 1-1 1 1 1 0 0 1 1 1v2a1 1 0 0 0 1 1",key:"sr0ebq"}],["path",{d:"M9 22a1 1 0 0 0 1-1v-2a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-2a1 1 0 0 0-1-1",key:"w793db"}]],qd=He("file-braces-corner",Ud);const Kd=[["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"}]],Ur=He("file-code-corner",Kd);const Xd=[["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"}]],Yd=He("file-exclamation-point",Xd);const Vd=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],ii=He("folder-open",Vd);const Gd=[["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"}]],Fs=He("git-graph",Gd);const Qd=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],Is=He("history",Qd);const Zd=[["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"}]],Jd=He("maximize",Zd);const eu=[["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"}]],tu=He("panel-left-close",eu);const su=[["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"}]],ru=He("panel-left-open",su);const iu=[["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"}]],nu=He("panel-right-close",iu);const ou=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],qi=He("panel-right-open",ou);const au=[["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"}]],lu=He("pen-line",au);const cu=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],Xt=He("play",cu);const du=[["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"}]],Xa=He("settings-2",du);const uu=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],oo=He("smartphone",uu);const hu=[["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"}]],Tr=He("user-plus",hu);const fu=[["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"}]],mu=He("zoom-in",fu);const pu=[["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"}]],gu=He("zoom-out",pu),ni=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function zs(e){const s=Object.prototype.toString.call(e);return s==="[object Window]"||s==="[object global]"}function Cn(e){return"nodeType"in e}function yt(e){var s,r;return e?zs(e)?e:Cn(e)&&(s=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function kn(e){const{Document:s}=yt(e);return e instanceof s}function fr(e){return zs(e)?!1:e instanceof yt(e).HTMLElement}function Ya(e){return e instanceof yt(e).SVGElement}function Ws(e){return e?zs(e)?e.document:Cn(e)?kn(e)?e:fr(e)||Ya(e)?e.ownerDocument:document:document:document}const Gt=ni?S.useLayoutEffect:S.useEffect;function oi(e){const s=S.useRef(e);return Gt(()=>{s.current=e}),S.useCallback(function(){for(var r=arguments.length,o=new Array(r),g=0;g<r;g++)o[g]=arguments[g];return s.current==null?void 0:s.current(...o)},[])}function vu(){const e=S.useRef(null),s=S.useCallback((o,g)=>{e.current=setInterval(o,g)},[]),r=S.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[s,r]}function or(e,s){s===void 0&&(s=[e]);const r=S.useRef(e);return Gt(()=>{r.current!==e&&(r.current=e)},s),r}function mr(e,s){const r=S.useRef();return S.useMemo(()=>{const o=e(r.current);return r.current=o,o},[...s])}function qr(e){const s=oi(e),r=S.useRef(null),o=S.useCallback(g=>{g!==r.current&&s?.(g,r.current),r.current=g},[]);return[r,o]}function Kr(e){const s=S.useRef();return S.useEffect(()=>{s.current=e},[e]),s.current}let Ci={};function ai(e,s){return S.useMemo(()=>{if(s)return s;const r=Ci[e]==null?0:Ci[e]+1;return Ci[e]=r,e+"-"+r},[e,s])}function Va(e){return function(s){for(var r=arguments.length,o=new Array(r>1?r-1:0),g=1;g<r;g++)o[g-1]=arguments[g];return o.reduce((p,v)=>{const n=Object.entries(v);for(const[i,l]of n){const d=p[i];d!=null&&(p[i]=d+e*l)}return p},{...s})}}const Ms=Va(1),Xr=Va(-1);function xu(e){return"clientX"in e&&"clientY"in e}function En(e){if(!e)return!1;const{KeyboardEvent:s}=yt(e.target);return s&&e instanceof s}function _u(e){if(!e)return!1;const{TouchEvent:s}=yt(e.target);return s&&e instanceof s}function Yr(e){if(_u(e)){if(e.touches&&e.touches.length){const{clientX:s,clientY:r}=e.touches[0];return{x:s,y:r}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:s,clientY:r}=e.changedTouches[0];return{x:s,y:r}}}return xu(e)?{x:e.clientX,y:e.clientY}:null}const ar=Object.freeze({Translate:{toString(e){if(!e)return;const{x:s,y:r}=e;return"translate3d("+(s?Math.round(s):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:s,scaleY:r}=e;return"scaleX("+s+") scaleY("+r+")"}},Transform:{toString(e){if(e)return[ar.Translate.toString(e),ar.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:s,duration:r,easing:o}=e;return s+" "+r+"ms "+o}}}),ao="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function bu(e){return e.matches(ao)?e:e.querySelector(ao)}const yu={display:"none"};function Su(e){let{id:s,value:r}=e;return ae.createElement("div",{id:s,style:yu},r)}function wu(e){let{id:s,announcement:r,ariaLiveType:o="assertive"}=e;const g={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return ae.createElement("div",{id:s,style:g,role:"status","aria-live":o,"aria-atomic":!0},r)}function Cu(){const[e,s]=S.useState("");return{announce:S.useCallback(o=>{o!=null&&s(o)},[]),announcement:e}}const Ga=S.createContext(null);function ku(e){const s=S.useContext(Ga);S.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(e)},[e,s])}function Eu(){const[e]=S.useState(()=>new Set),s=S.useCallback(o=>(e.add(o),()=>e.delete(o)),[e]);return[S.useCallback(o=>{let{type:g,event:p}=o;e.forEach(v=>{var n;return(n=v[g])==null?void 0:n.call(v,p)})},[e]),s]}const ju={draggable:`
3
- To pick up a draggable item, press the space bar.
4
- While dragging, use the arrow keys to move the item.
5
- Press space again to drop the item in its new position, or press escape to cancel.
6
- `},Nu={onDragStart(e){let{active:s}=e;return"Picked up draggable item "+s.id+"."},onDragOver(e){let{active:s,over:r}=e;return r?"Draggable item "+s.id+" was moved over droppable area "+r.id+".":"Draggable item "+s.id+" is no longer over a droppable area."},onDragEnd(e){let{active:s,over:r}=e;return r?"Draggable item "+s.id+" was dropped over droppable area "+r.id:"Draggable item "+s.id+" was dropped."},onDragCancel(e){let{active:s}=e;return"Dragging was cancelled. Draggable item "+s.id+" was dropped."}};function Ru(e){let{announcements:s=Nu,container:r,hiddenTextDescribedById:o,screenReaderInstructions:g=ju}=e;const{announce:p,announcement:v}=Cu(),n=ai("DndLiveRegion"),[i,l]=S.useState(!1);if(S.useEffect(()=>{l(!0)},[]),ku(S.useMemo(()=>({onDragStart(c){let{active:m}=c;p(s.onDragStart({active:m}))},onDragMove(c){let{active:m,over:x}=c;s.onDragMove&&p(s.onDragMove({active:m,over:x}))},onDragOver(c){let{active:m,over:x}=c;p(s.onDragOver({active:m,over:x}))},onDragEnd(c){let{active:m,over:x}=c;p(s.onDragEnd({active:m,over:x}))},onDragCancel(c){let{active:m,over:x}=c;p(s.onDragCancel({active:m,over:x}))}}),[p,s])),!i)return null;const d=ae.createElement(ae.Fragment,null,ae.createElement(Su,{id:o,value:g.draggable}),ae.createElement(wu,{id:n,announcement:v}));return r?ps.createPortal(d,r):d}var ot;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(ot||(ot={}));function Vr(){}function Au(e,s){return S.useMemo(()=>({sensor:e,options:s??{}}),[e,s])}function Tu(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return S.useMemo(()=>[...s].filter(o=>o!=null),[...s])}const Ot=Object.freeze({x:0,y:0});function Mu(e,s){const r=Yr(e);if(!r)return"0 0";const o={x:(r.x-s.left)/s.width*100,y:(r.y-s.top)/s.height*100};return o.x+"% "+o.y+"%"}function Du(e,s){let{data:{value:r}}=e,{data:{value:o}}=s;return o-r}function Pu(e,s){if(!e||e.length===0)return null;const[r]=e;return r[s]}function Lu(e,s){const r=Math.max(s.top,e.top),o=Math.max(s.left,e.left),g=Math.min(s.left+s.width,e.left+e.width),p=Math.min(s.top+s.height,e.top+e.height),v=g-o,n=p-r;if(o<g&&r<p){const i=s.width*s.height,l=e.width*e.height,d=v*n,c=d/(i+l-d);return Number(c.toFixed(4))}return 0}const Iu=e=>{let{collisionRect:s,droppableRects:r,droppableContainers:o}=e;const g=[];for(const p of o){const{id:v}=p,n=r.get(v);if(n){const i=Lu(n,s);i>0&&g.push({id:v,data:{droppableContainer:p,value:i}})}}return g.sort(Du)};function Ou(e,s,r){return{...e,scaleX:s&&r?s.width/r.width:1,scaleY:s&&r?s.height/r.height:1}}function Qa(e,s){return e&&s?{x:e.left-s.left,y:e.top-s.top}:Ot}function Bu(e){return function(r){for(var o=arguments.length,g=new Array(o>1?o-1:0),p=1;p<o;p++)g[p-1]=arguments[p];return g.reduce((v,n)=>({...v,top:v.top+e*n.y,bottom:v.bottom+e*n.y,left:v.left+e*n.x,right:v.right+e*n.x}),{...r})}}const Fu=Bu(1);function Za(e){if(e.startsWith("matrix3d(")){const s=e.slice(9,-1).split(/, /);return{x:+s[12],y:+s[13],scaleX:+s[0],scaleY:+s[5]}}else if(e.startsWith("matrix(")){const s=e.slice(7,-1).split(/, /);return{x:+s[4],y:+s[5],scaleX:+s[0],scaleY:+s[3]}}return null}function zu(e,s,r){const o=Za(s);if(!o)return e;const{scaleX:g,scaleY:p,x:v,y:n}=o,i=e.left-v-(1-g)*parseFloat(r),l=e.top-n-(1-p)*parseFloat(r.slice(r.indexOf(" ")+1)),d=g?e.width/g:e.width,c=p?e.height/p:e.height;return{width:d,height:c,top:l,right:i+d,bottom:l+c,left:i}}const Wu={ignoreTransform:!1};function pr(e,s){s===void 0&&(s=Wu);let r=e.getBoundingClientRect();if(s.ignoreTransform){const{transform:l,transformOrigin:d}=yt(e).getComputedStyle(e);l&&(r=zu(r,l,d))}const{top:o,left:g,width:p,height:v,bottom:n,right:i}=r;return{top:o,left:g,width:p,height:v,bottom:n,right:i}}function lo(e){return pr(e,{ignoreTransform:!0})}function Hu(e){const s=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function $u(e,s){return s===void 0&&(s=yt(e).getComputedStyle(e)),s.position==="fixed"}function Uu(e,s){s===void 0&&(s=yt(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(g=>{const p=s[g];return typeof p=="string"?r.test(p):!1})}function jn(e,s){const r=[];function o(g){if(s!=null&&r.length>=s||!g)return r;if(kn(g)&&g.scrollingElement!=null&&!r.includes(g.scrollingElement))return r.push(g.scrollingElement),r;if(!fr(g)||Ya(g)||r.includes(g))return r;const p=yt(e).getComputedStyle(g);return g!==e&&Uu(g,p)&&r.push(g),$u(g,p)?r:o(g.parentNode)}return e?o(e):r}function Ja(e){const[s]=jn(e,1);return s??null}function ki(e){return!ni||!e?null:zs(e)?e:Cn(e)?kn(e)||e===Ws(e).scrollingElement?window:fr(e)?e:null:null}function el(e){return zs(e)?e.scrollX:e.scrollLeft}function tl(e){return zs(e)?e.scrollY:e.scrollTop}function Ki(e){return{x:el(e),y:tl(e)}}var ut;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(ut||(ut={}));function sl(e){return!ni||!e?!1:e===document.scrollingElement}function rl(e){const s={x:0,y:0},r=sl(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},o={x:e.scrollWidth-r.width,y:e.scrollHeight-r.height},g=e.scrollTop<=s.y,p=e.scrollLeft<=s.x,v=e.scrollTop>=o.y,n=e.scrollLeft>=o.x;return{isTop:g,isLeft:p,isBottom:v,isRight:n,maxScroll:o,minScroll:s}}const qu={x:.2,y:.2};function Ku(e,s,r,o,g){let{top:p,left:v,right:n,bottom:i}=r;o===void 0&&(o=10),g===void 0&&(g=qu);const{isTop:l,isBottom:d,isLeft:c,isRight:m}=rl(e),x={x:0,y:0},w={x:0,y:0},y={height:s.height*g.y,width:s.width*g.x};return!l&&p<=s.top+y.height?(x.y=ut.Backward,w.y=o*Math.abs((s.top+y.height-p)/y.height)):!d&&i>=s.bottom-y.height&&(x.y=ut.Forward,w.y=o*Math.abs((s.bottom-y.height-i)/y.height)),!m&&n>=s.right-y.width?(x.x=ut.Forward,w.x=o*Math.abs((s.right-y.width-n)/y.width)):!c&&v<=s.left+y.width&&(x.x=ut.Backward,w.x=o*Math.abs((s.left+y.width-v)/y.width)),{direction:x,speed:w}}function Xu(e){if(e===document.scrollingElement){const{innerWidth:p,innerHeight:v}=window;return{top:0,left:0,right:p,bottom:v,width:p,height:v}}const{top:s,left:r,right:o,bottom:g}=e.getBoundingClientRect();return{top:s,left:r,right:o,bottom:g,width:e.clientWidth,height:e.clientHeight}}function il(e){return e.reduce((s,r)=>Ms(s,Ki(r)),Ot)}function Yu(e){return e.reduce((s,r)=>s+el(r),0)}function Vu(e){return e.reduce((s,r)=>s+tl(r),0)}function nl(e,s){if(s===void 0&&(s=pr),!e)return;const{top:r,left:o,bottom:g,right:p}=s(e);Ja(e)&&(g<=0||p<=0||r>=window.innerHeight||o>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Gu=[["x",["left","right"],Yu],["y",["top","bottom"],Vu]];class Nn{constructor(s,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const o=jn(r),g=il(o);this.rect={...s},this.width=s.width,this.height=s.height;for(const[p,v,n]of Gu)for(const i of v)Object.defineProperty(this,i,{get:()=>{const l=n(o),d=g[p]-l;return this.rect[i]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class er{constructor(s){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var o;return(o=this.target)==null?void 0:o.removeEventListener(...r)})},this.target=s}add(s,r,o){var g;(g=this.target)==null||g.addEventListener(s,r,o),this.listeners.push([s,r,o])}}function Qu(e){const{EventTarget:s}=yt(e);return e instanceof s?e:Ws(e)}function Ei(e,s){const r=Math.abs(e.x),o=Math.abs(e.y);return typeof s=="number"?Math.sqrt(r**2+o**2)>s:"x"in s&&"y"in s?r>s.x&&o>s.y:"x"in s?r>s.x:"y"in s?o>s.y:!1}var Rt;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Rt||(Rt={}));function co(e){e.preventDefault()}function Zu(e){e.stopPropagation()}var We;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(We||(We={}));const ol={start:[We.Space,We.Enter],cancel:[We.Esc],end:[We.Space,We.Enter,We.Tab]},Ju=(e,s)=>{let{currentCoordinates:r}=s;switch(e.code){case We.Right:return{...r,x:r.x+25};case We.Left:return{...r,x:r.x-25};case We.Down:return{...r,y:r.y+25};case We.Up:return{...r,y:r.y-25}}};class al{constructor(s){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=s;const{event:{target:r}}=s;this.props=s,this.listeners=new er(Ws(r)),this.windowListeners=new er(yt(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Rt.Resize,this.handleCancel),this.windowListeners.add(Rt.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Rt.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,o=s.node.current;o&&nl(o),r(Ot)}handleKeyDown(s){if(En(s)){const{active:r,context:o,options:g}=this.props,{keyboardCodes:p=ol,coordinateGetter:v=Ju,scrollBehavior:n="smooth"}=g,{code:i}=s;if(p.end.includes(i)){this.handleEnd(s);return}if(p.cancel.includes(i)){this.handleCancel(s);return}const{collisionRect:l}=o.current,d=l?{x:l.left,y:l.top}:Ot;this.referenceCoordinates||(this.referenceCoordinates=d);const c=v(s,{active:r,context:o.current,currentCoordinates:d});if(c){const m=Xr(c,d),x={x:0,y:0},{scrollableAncestors:w}=o.current;for(const y of w){const a=s.code,{isTop:h,isRight:u,isLeft:f,isBottom:b,maxScroll:C,minScroll:k}=rl(y),E=Xu(y),_={x:Math.min(a===We.Right?E.right-E.width/2:E.right,Math.max(a===We.Right?E.left:E.left+E.width/2,c.x)),y:Math.min(a===We.Down?E.bottom-E.height/2:E.bottom,Math.max(a===We.Down?E.top:E.top+E.height/2,c.y))},j=a===We.Right&&!u||a===We.Left&&!f,A=a===We.Down&&!b||a===We.Up&&!h;if(j&&_.x!==c.x){const P=y.scrollLeft+m.x,T=a===We.Right&&P<=C.x||a===We.Left&&P>=k.x;if(T&&!m.y){y.scrollTo({left:P,behavior:n});return}T?x.x=y.scrollLeft-P:x.x=a===We.Right?y.scrollLeft-C.x:y.scrollLeft-k.x,x.x&&y.scrollBy({left:-x.x,behavior:n});break}else if(A&&_.y!==c.y){const P=y.scrollTop+m.y,T=a===We.Down&&P<=C.y||a===We.Up&&P>=k.y;if(T&&!m.x){y.scrollTo({top:P,behavior:n});return}T?x.y=y.scrollTop-P:x.y=a===We.Down?y.scrollTop-C.y:y.scrollTop-k.y,x.y&&y.scrollBy({top:-x.y,behavior:n});break}}this.handleMove(s,Ms(Xr(c,this.referenceCoordinates),x))}}}handleMove(s,r){const{onMove:o}=this.props;s.preventDefault(),o(r)}handleEnd(s){const{onEnd:r}=this.props;s.preventDefault(),this.detach(),r()}handleCancel(s){const{onCancel:r}=this.props;s.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}al.activators=[{eventName:"onKeyDown",handler:(e,s,r)=>{let{keyboardCodes:o=ol,onActivation:g}=s,{active:p}=r;const{code:v}=e.nativeEvent;if(o.start.includes(v)){const n=p.activatorNode.current;return n&&e.target!==n?!1:(e.preventDefault(),g?.({event:e.nativeEvent}),!0)}return!1}}];function uo(e){return!!(e&&"distance"in e)}function ho(e){return!!(e&&"delay"in e)}class Rn{constructor(s,r,o){var g;o===void 0&&(o=Qu(s.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=s,this.events=r;const{event:p}=s,{target:v}=p;this.props=s,this.events=r,this.document=Ws(v),this.documentListeners=new er(this.document),this.listeners=new er(o),this.windowListeners=new er(yt(v)),this.initialCoordinates=(g=Yr(p))!=null?g:Ot,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:s,props:{options:{activationConstraint:r,bypassActivationConstraint:o}}}=this;if(this.listeners.add(s.move.name,this.handleMove,{passive:!1}),this.listeners.add(s.end.name,this.handleEnd),s.cancel&&this.listeners.add(s.cancel.name,this.handleCancel),this.windowListeners.add(Rt.Resize,this.handleCancel),this.windowListeners.add(Rt.DragStart,co),this.windowListeners.add(Rt.VisibilityChange,this.handleCancel),this.windowListeners.add(Rt.ContextMenu,co),this.documentListeners.add(Rt.Keydown,this.handleKeydown),r){if(o!=null&&o({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(ho(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(uo(r)){this.handlePending(r);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(s,r){const{active:o,onPending:g}=this.props;g(o,s,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:s}=this,{onStart:r}=this.props;s&&(this.activated=!0,this.documentListeners.add(Rt.Click,Zu,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Rt.SelectionChange,this.removeTextSelection),r(s))}handleMove(s){var r;const{activated:o,initialCoordinates:g,props:p}=this,{onMove:v,options:{activationConstraint:n}}=p;if(!g)return;const i=(r=Yr(s))!=null?r:Ot,l=Xr(g,i);if(!o&&n){if(uo(n)){if(n.tolerance!=null&&Ei(l,n.tolerance))return this.handleCancel();if(Ei(l,n.distance))return this.handleStart()}if(ho(n)&&Ei(l,n.tolerance))return this.handleCancel();this.handlePending(n,l);return}s.cancelable&&s.preventDefault(),v(i)}handleEnd(){const{onAbort:s,onEnd:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleCancel(){const{onAbort:s,onCancel:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleKeydown(s){s.code===We.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const eh={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class An extends Rn{constructor(s){const{event:r}=s,o=Ws(r.target);super(s,eh,o)}}An.activators=[{eventName:"onPointerDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;return!r.isPrimary||r.button!==0?!1:(o?.({event:r}),!0)}}];const th={move:{name:"mousemove"},end:{name:"mouseup"}};var Xi;(function(e){e[e.RightClick=2]="RightClick"})(Xi||(Xi={}));class sh extends Rn{constructor(s){super(s,th,Ws(s.event.target))}}sh.activators=[{eventName:"onMouseDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;return r.button===Xi.RightClick?!1:(o?.({event:r}),!0)}}];const ji={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class rh extends Rn{constructor(s){super(s,ji)}static setup(){return window.addEventListener(ji.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(ji.move.name,s)};function s(){}}}rh.activators=[{eventName:"onTouchStart",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;const{touches:g}=r;return g.length>1?!1:(o?.({event:r}),!0)}}];var tr;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(tr||(tr={}));var Gr;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Gr||(Gr={}));function ih(e){let{acceleration:s,activator:r=tr.Pointer,canScroll:o,draggingRect:g,enabled:p,interval:v=5,order:n=Gr.TreeOrder,pointerCoordinates:i,scrollableAncestors:l,scrollableAncestorRects:d,delta:c,threshold:m}=e;const x=oh({delta:c,disabled:!p}),[w,y]=vu(),a=S.useRef({x:0,y:0}),h=S.useRef({x:0,y:0}),u=S.useMemo(()=>{switch(r){case tr.Pointer:return i?{top:i.y,bottom:i.y,left:i.x,right:i.x}:null;case tr.DraggableRect:return g}},[r,g,i]),f=S.useRef(null),b=S.useCallback(()=>{const k=f.current;if(!k)return;const E=a.current.x*h.current.x,_=a.current.y*h.current.y;k.scrollBy(E,_)},[]),C=S.useMemo(()=>n===Gr.TreeOrder?[...l].reverse():l,[n,l]);S.useEffect(()=>{if(!p||!l.length||!u){y();return}for(const k of C){if(o?.(k)===!1)continue;const E=l.indexOf(k),_=d[E];if(!_)continue;const{direction:j,speed:A}=Ku(k,_,u,s,m);for(const P of["x","y"])x[P][j[P]]||(A[P]=0,j[P]=0);if(A.x>0||A.y>0){y(),f.current=k,w(b,v),a.current=A,h.current=j;return}}a.current={x:0,y:0},h.current={x:0,y:0},y()},[s,b,o,y,p,v,JSON.stringify(u),JSON.stringify(x),w,l,C,d,JSON.stringify(m)])}const nh={x:{[ut.Backward]:!1,[ut.Forward]:!1},y:{[ut.Backward]:!1,[ut.Forward]:!1}};function oh(e){let{delta:s,disabled:r}=e;const o=Kr(s);return mr(g=>{if(r||!o||!g)return nh;const p={x:Math.sign(s.x-o.x),y:Math.sign(s.y-o.y)};return{x:{[ut.Backward]:g.x[ut.Backward]||p.x===-1,[ut.Forward]:g.x[ut.Forward]||p.x===1},y:{[ut.Backward]:g.y[ut.Backward]||p.y===-1,[ut.Forward]:g.y[ut.Forward]||p.y===1}}},[r,s,o])}function ah(e,s){const r=s!=null?e.get(s):void 0,o=r?r.node.current:null;return mr(g=>{var p;return s==null?null:(p=o??g)!=null?p:null},[o,s])}function lh(e,s){return S.useMemo(()=>e.reduce((r,o)=>{const{sensor:g}=o,p=g.activators.map(v=>({eventName:v.eventName,handler:s(v.handler,o)}));return[...r,...p]},[]),[e,s])}var lr;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(lr||(lr={}));var Yi;(function(e){e.Optimized="optimized"})(Yi||(Yi={}));const fo=new Map;function ch(e,s){let{dragging:r,dependencies:o,config:g}=s;const[p,v]=S.useState(null),{frequency:n,measure:i,strategy:l}=g,d=S.useRef(e),c=a(),m=or(c),x=S.useCallback(function(h){h===void 0&&(h=[]),!m.current&&v(u=>u===null?h:u.concat(h.filter(f=>!u.includes(f))))},[m]),w=S.useRef(null),y=mr(h=>{if(c&&!r)return fo;if(!h||h===fo||d.current!==e||p!=null){const u=new Map;for(let f of e){if(!f)continue;if(p&&p.length>0&&!p.includes(f.id)&&f.rect.current){u.set(f.id,f.rect.current);continue}const b=f.node.current,C=b?new Nn(i(b),b):null;f.rect.current=C,C&&u.set(f.id,C)}return u}return h},[e,p,r,c,i]);return S.useEffect(()=>{d.current=e},[e]),S.useEffect(()=>{c||x()},[r,c]),S.useEffect(()=>{p&&p.length>0&&v(null)},[JSON.stringify(p)]),S.useEffect(()=>{c||typeof n!="number"||w.current!==null||(w.current=setTimeout(()=>{x(),w.current=null},n))},[n,c,x,...o]),{droppableRects:y,measureDroppableContainers:x,measuringScheduled:p!=null};function a(){switch(l){case lr.Always:return!1;case lr.BeforeDragging:return r;default:return!r}}}function Tn(e,s){return mr(r=>e?r||(typeof s=="function"?s(e):e):null,[s,e])}function dh(e,s){return Tn(e,s)}function uh(e){let{callback:s,disabled:r}=e;const o=oi(s),g=S.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:p}=window;return new p(o)},[o,r]);return S.useEffect(()=>()=>g?.disconnect(),[g]),g}function li(e){let{callback:s,disabled:r}=e;const o=oi(s),g=S.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:p}=window;return new p(o)},[r]);return S.useEffect(()=>()=>g?.disconnect(),[g]),g}function hh(e){return new Nn(pr(e),e)}function mo(e,s,r){s===void 0&&(s=hh);const[o,g]=S.useState(null);function p(){g(i=>{if(!e)return null;if(e.isConnected===!1){var l;return(l=i??r)!=null?l:null}const d=s(e);return JSON.stringify(i)===JSON.stringify(d)?i:d})}const v=uh({callback(i){if(e)for(const l of i){const{type:d,target:c}=l;if(d==="childList"&&c instanceof HTMLElement&&c.contains(e)){p();break}}}}),n=li({callback:p});return Gt(()=>{p(),e?(n?.observe(e),v?.observe(document.body,{childList:!0,subtree:!0})):(n?.disconnect(),v?.disconnect())},[e]),o}function fh(e){const s=Tn(e);return Qa(e,s)}const po=[];function mh(e){const s=S.useRef(e),r=mr(o=>e?o&&o!==po&&e&&s.current&&e.parentNode===s.current.parentNode?o:jn(e):po,[e]);return S.useEffect(()=>{s.current=e},[e]),r}function ph(e){const[s,r]=S.useState(null),o=S.useRef(e),g=S.useCallback(p=>{const v=ki(p.target);v&&r(n=>n?(n.set(v,Ki(v)),new Map(n)):null)},[]);return S.useEffect(()=>{const p=o.current;if(e!==p){v(p);const n=e.map(i=>{const l=ki(i);return l?(l.addEventListener("scroll",g,{passive:!0}),[l,Ki(l)]):null}).filter(i=>i!=null);r(n.length?new Map(n):null),o.current=e}return()=>{v(e),v(p)};function v(n){n.forEach(i=>{const l=ki(i);l?.removeEventListener("scroll",g)})}},[g,e]),S.useMemo(()=>e.length?s?Array.from(s.values()).reduce((p,v)=>Ms(p,v),Ot):il(e):Ot,[e,s])}function go(e,s){s===void 0&&(s=[]);const r=S.useRef(null);return S.useEffect(()=>{r.current=null},s),S.useEffect(()=>{const o=e!==Ot;o&&!r.current&&(r.current=e),!o&&r.current&&(r.current=null)},[e]),r.current?Xr(e,r.current):Ot}function gh(e){S.useEffect(()=>{if(!ni)return;const s=e.map(r=>{let{sensor:o}=r;return o.setup==null?void 0:o.setup()});return()=>{for(const r of s)r?.()}},e.map(s=>{let{sensor:r}=s;return r}))}function vh(e,s){return S.useMemo(()=>e.reduce((r,o)=>{let{eventName:g,handler:p}=o;return r[g]=v=>{p(v,s)},r},{}),[e,s])}function ll(e){return S.useMemo(()=>e?Hu(e):null,[e])}const vo=[];function xh(e,s){s===void 0&&(s=pr);const[r]=e,o=ll(r?yt(r):null),[g,p]=S.useState(vo);function v(){p(()=>e.length?e.map(i=>sl(i)?o:new Nn(s(i),i)):vo)}const n=li({callback:v});return Gt(()=>{n?.disconnect(),v(),e.forEach(i=>n?.observe(i))},[e]),g}function cl(e){if(!e)return null;if(e.children.length>1)return e;const s=e.children[0];return fr(s)?s:e}function _h(e){let{measure:s}=e;const[r,o]=S.useState(null),g=S.useCallback(l=>{for(const{target:d}of l)if(fr(d)){o(c=>{const m=s(d);return c?{...c,width:m.width,height:m.height}:m});break}},[s]),p=li({callback:g}),v=S.useCallback(l=>{const d=cl(l);p?.disconnect(),d&&p?.observe(d),o(d?s(d):null)},[s,p]),[n,i]=qr(v);return S.useMemo(()=>({nodeRef:n,rect:r,setRef:i}),[r,n,i])}const bh=[{sensor:An,options:{}},{sensor:al,options:{}}],yh={current:{}},Or={draggable:{measure:lo},droppable:{measure:lo,strategy:lr.WhileDragging,frequency:Yi.Optimized},dragOverlay:{measure:pr}};class sr extends Map{get(s){var r;return s!=null&&(r=super.get(s))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(s=>{let{disabled:r}=s;return!r})}getNodeFor(s){var r,o;return(r=(o=this.get(s))==null?void 0:o.node.current)!=null?r:void 0}}const Sh={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new sr,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Vr},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Or,measureDroppableContainers:Vr,windowRect:null,measuringScheduled:!1},dl={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Vr,draggableNodes:new Map,over:null,measureDroppableContainers:Vr},gr=S.createContext(dl),ul=S.createContext(Sh);function wh(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new sr}}}function Ch(e,s){switch(s.type){case ot.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case ot.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:s.coordinates.x-e.draggable.initialCoordinates.x,y:s.coordinates.y-e.draggable.initialCoordinates.y}}};case ot.DragEnd:case ot.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ot.RegisterDroppable:{const{element:r}=s,{id:o}=r,g=new sr(e.droppable.containers);return g.set(o,r),{...e,droppable:{...e.droppable,containers:g}}}case ot.SetDroppableDisabled:{const{id:r,key:o,disabled:g}=s,p=e.droppable.containers.get(r);if(!p||o!==p.key)return e;const v=new sr(e.droppable.containers);return v.set(r,{...p,disabled:g}),{...e,droppable:{...e.droppable,containers:v}}}case ot.UnregisterDroppable:{const{id:r,key:o}=s,g=e.droppable.containers.get(r);if(!g||o!==g.key)return e;const p=new sr(e.droppable.containers);return p.delete(r),{...e,droppable:{...e.droppable,containers:p}}}default:return e}}function kh(e){let{disabled:s}=e;const{active:r,activatorEvent:o,draggableNodes:g}=S.useContext(gr),p=Kr(o),v=Kr(r?.id);return S.useEffect(()=>{if(!s&&!o&&p&&v!=null){if(!En(p)||document.activeElement===p.target)return;const n=g.get(v);if(!n)return;const{activatorNode:i,node:l}=n;if(!i.current&&!l.current)return;requestAnimationFrame(()=>{for(const d of[i.current,l.current]){if(!d)continue;const c=bu(d);if(c){c.focus();break}}})}},[o,s,g,v,p]),null}function hl(e,s){let{transform:r,...o}=s;return e!=null&&e.length?e.reduce((g,p)=>p({transform:g,...o}),r):r}function Eh(e){return S.useMemo(()=>({draggable:{...Or.draggable,...e?.draggable},droppable:{...Or.droppable,...e?.droppable},dragOverlay:{...Or.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function jh(e){let{activeNode:s,measure:r,initialRect:o,config:g=!0}=e;const p=S.useRef(!1),{x:v,y:n}=typeof g=="boolean"?{x:g,y:g}:g;Gt(()=>{if(!v&&!n||!s){p.current=!1;return}if(p.current||!o)return;const l=s?.node.current;if(!l||l.isConnected===!1)return;const d=r(l),c=Qa(d,o);if(v||(c.x=0),n||(c.y=0),p.current=!0,Math.abs(c.x)>0||Math.abs(c.y)>0){const m=Ja(l);m&&m.scrollBy({top:c.y,left:c.x})}},[s,v,n,o,r])}const ci=S.createContext({...Ot,scaleX:1,scaleY:1});var Zt;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Zt||(Zt={}));const Nh=S.memo(function(s){var r,o,g,p;let{id:v,accessibility:n,autoScroll:i=!0,children:l,sensors:d=bh,collisionDetection:c=Iu,measuring:m,modifiers:x,...w}=s;const y=S.useReducer(Ch,void 0,wh),[a,h]=y,[u,f]=Eu(),[b,C]=S.useState(Zt.Uninitialized),k=b===Zt.Initialized,{draggable:{active:E,nodes:_,translate:j},droppable:{containers:A}}=a,P=E!=null?_.get(E):null,T=S.useRef({initial:null,translated:null}),D=S.useMemo(()=>{var me;return E!=null?{id:E,data:(me=P?.data)!=null?me:yh,rect:T}:null},[E,P]),W=S.useRef(null),[I,B]=S.useState(null),[F,R]=S.useState(null),M=or(w,Object.values(w)),L=ai("DndDescribedBy",v),O=S.useMemo(()=>A.getEnabled(),[A]),U=Eh(m),{droppableRects:Y,measureDroppableContainers:z,measuringScheduled:$}=ch(O,{dragging:k,dependencies:[j.x,j.y],config:U.droppable}),q=ah(_,E),N=S.useMemo(()=>F?Yr(F):null,[F]),H=ye(),X=dh(q,U.draggable.measure);jh({activeNode:E!=null?_.get(E):null,config:H.layoutShiftCompensation,initialRect:X,measure:U.draggable.measure});const K=mo(q,U.draggable.measure,X),ne=mo(q?q.parentElement:null),te=S.useRef({activatorEvent:null,active:null,activeNode:q,collisionRect:null,collisions:null,droppableRects:Y,draggableNodes:_,draggingNode:null,draggingNodeRect:null,droppableContainers:A,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),he=A.getNodeFor((r=te.current.over)==null?void 0:r.id),le=_h({measure:U.dragOverlay.measure}),G=(o=le.nodeRef.current)!=null?o:q,pe=k?(g=le.rect)!=null?g:K:null,ie=!!(le.nodeRef.current&&le.rect),Ae=fh(ie?null:K),at=ll(G?yt(G):null),Xe=mh(k?he??q:null),_e=xh(Xe),Ie=hl(x,{transform:{x:j.x-Ae.x,y:j.y-Ae.y,scaleX:1,scaleY:1},activatorEvent:F,active:D,activeNodeRect:K,containerNodeRect:ne,draggingNodeRect:pe,over:te.current.over,overlayNodeRect:le.rect,scrollableAncestors:Xe,scrollableAncestorRects:_e,windowRect:at}),Pe=N?Ms(N,j):null,$e=ph(Xe),Oe=go($e),Ve=go($e,[K]),Ze=Ms(Ie,Oe),Me=pe?Fu(pe,Ie):null,Re=D&&Me?c({active:D,collisionRect:Me,droppableRects:Y,droppableContainers:O,pointerCoordinates:Pe}):null,ve=Pu(Re,"id"),[Fe,ge]=S.useState(null),lt=ie?Ie:Ms(Ie,Ve),Je=Ou(lt,(p=Fe?.rect)!=null?p:null,K),Et=S.useRef(null),J=S.useCallback((me,Se)=>{let{sensor:we,options:xe}=Se;if(W.current==null)return;const ke=_.get(W.current);if(!ke)return;const De=me.nativeEvent,Ee=new we({active:W.current,activeNode:ke,event:De,options:xe,context:te,onAbort(Ge){if(!_.get(Ge))return;const{onDragAbort:et}=M.current,it={id:Ge};et?.(it),u({type:"onDragAbort",event:it})},onPending(Ge,ze,et,it){if(!_.get(Ge))return;const{onDragPending:vt}=M.current,st={id:Ge,constraint:ze,initialCoordinates:et,offset:it};vt?.(st),u({type:"onDragPending",event:st})},onStart(Ge){const ze=W.current;if(ze==null)return;const et=_.get(ze);if(!et)return;const{onDragStart:it}=M.current,Dt={activatorEvent:De,active:{id:ze,data:et.data,rect:T}};ps.unstable_batchedUpdates(()=>{it?.(Dt),C(Zt.Initializing),h({type:ot.DragStart,initialCoordinates:Ge,active:ze}),u({type:"onDragStart",event:Dt}),B(Et.current),R(De)})},onMove(Ge){h({type:ot.DragMove,coordinates:Ge})},onEnd:Ye(ot.DragEnd),onCancel:Ye(ot.DragCancel)});Et.current=Ee;function Ye(Ge){return async function(){const{active:et,collisions:it,over:Dt,scrollAdjustedTranslate:vt}=te.current;let st=null;if(et&&vt){const{cancelDrop:xt}=M.current;st={activatorEvent:De,active:et,collisions:it,delta:vt,over:Dt},Ge===ot.DragEnd&&typeof xt=="function"&&await Promise.resolve(xt(st))&&(Ge=ot.DragCancel)}W.current=null,ps.unstable_batchedUpdates(()=>{h({type:Ge}),C(Zt.Uninitialized),ge(null),B(null),R(null),Et.current=null;const xt=Ge===ot.DragEnd?"onDragEnd":"onDragCancel";if(st){const Ct=M.current[xt];Ct?.(st),u({type:xt,event:st})}})}}},[_]),ue=S.useCallback((me,Se)=>(we,xe)=>{const ke=we.nativeEvent,De=_.get(xe);if(W.current!==null||!De||ke.dndKit||ke.defaultPrevented)return;const Ee={active:De};me(we,Se.options,Ee)===!0&&(ke.dndKit={capturedBy:Se.sensor},W.current=xe,J(we,Se))},[_,J]),V=lh(d,ue);gh(d),Gt(()=>{K&&b===Zt.Initializing&&C(Zt.Initialized)},[K,b]),S.useEffect(()=>{const{onDragMove:me}=M.current,{active:Se,activatorEvent:we,collisions:xe,over:ke}=te.current;if(!Se||!we)return;const De={active:Se,activatorEvent:we,collisions:xe,delta:{x:Ze.x,y:Ze.y},over:ke};ps.unstable_batchedUpdates(()=>{me?.(De),u({type:"onDragMove",event:De})})},[Ze.x,Ze.y]),S.useEffect(()=>{const{active:me,activatorEvent:Se,collisions:we,droppableContainers:xe,scrollAdjustedTranslate:ke}=te.current;if(!me||W.current==null||!Se||!ke)return;const{onDragOver:De}=M.current,Ee=xe.get(ve),Ye=Ee&&Ee.rect.current?{id:Ee.id,rect:Ee.rect.current,data:Ee.data,disabled:Ee.disabled}:null,Ge={active:me,activatorEvent:Se,collisions:we,delta:{x:ke.x,y:ke.y},over:Ye};ps.unstable_batchedUpdates(()=>{ge(Ye),De?.(Ge),u({type:"onDragOver",event:Ge})})},[ve]),Gt(()=>{te.current={activatorEvent:F,active:D,activeNode:q,collisionRect:Me,collisions:Re,droppableRects:Y,draggableNodes:_,draggingNode:G,draggingNodeRect:pe,droppableContainers:A,over:Fe,scrollableAncestors:Xe,scrollAdjustedTranslate:Ze},T.current={initial:pe,translated:Me}},[D,q,Re,Me,_,G,pe,Y,A,Fe,Xe,Ze]),ih({...H,delta:j,draggingRect:Me,pointerCoordinates:Pe,scrollableAncestors:Xe,scrollableAncestorRects:_e});const Z=S.useMemo(()=>({active:D,activeNode:q,activeNodeRect:K,activatorEvent:F,collisions:Re,containerNodeRect:ne,dragOverlay:le,draggableNodes:_,droppableContainers:A,droppableRects:Y,over:Fe,measureDroppableContainers:z,scrollableAncestors:Xe,scrollableAncestorRects:_e,measuringConfiguration:U,measuringScheduled:$,windowRect:at}),[D,q,K,F,Re,ne,le,_,A,Y,Fe,z,Xe,_e,U,$,at]),re=S.useMemo(()=>({activatorEvent:F,activators:V,active:D,activeNodeRect:K,ariaDescribedById:{draggable:L},dispatch:h,draggableNodes:_,over:Fe,measureDroppableContainers:z}),[F,V,D,K,h,L,_,Fe,z]);return ae.createElement(Ga.Provider,{value:f},ae.createElement(gr.Provider,{value:re},ae.createElement(ul.Provider,{value:Z},ae.createElement(ci.Provider,{value:Je},l)),ae.createElement(kh,{disabled:n?.restoreFocus===!1})),ae.createElement(Ru,{...n,hiddenTextDescribedById:L}));function ye(){const me=I?.autoScrollEnabled===!1,Se=typeof i=="object"?i.enabled===!1:i===!1,we=k&&!me&&!Se;return typeof i=="object"?{...i,enabled:we}:{enabled:we}}}),Rh=S.createContext(null),xo="button",Ah="Draggable";function Th(e){let{id:s,data:r,disabled:o=!1,attributes:g}=e;const p=ai(Ah),{activators:v,activatorEvent:n,active:i,activeNodeRect:l,ariaDescribedById:d,draggableNodes:c,over:m}=S.useContext(gr),{role:x=xo,roleDescription:w="draggable",tabIndex:y=0}=g??{},a=i?.id===s,h=S.useContext(a?ci:Rh),[u,f]=qr(),[b,C]=qr(),k=vh(v,s),E=or(r);Gt(()=>(c.set(s,{id:s,key:p,node:u,activatorNode:b,data:E}),()=>{const j=c.get(s);j&&j.key===p&&c.delete(s)}),[c,s]);const _=S.useMemo(()=>({role:x,tabIndex:y,"aria-disabled":o,"aria-pressed":a&&x===xo?!0:void 0,"aria-roledescription":w,"aria-describedby":d.draggable}),[o,x,y,a,w,d.draggable]);return{active:i,activatorEvent:n,activeNodeRect:l,attributes:_,isDragging:a,listeners:o?void 0:k,node:u,over:m,setNodeRef:f,setActivatorNodeRef:C,transform:h}}function Mh(){return S.useContext(ul)}const Dh="Droppable",Ph={timeout:25};function Lh(e){let{data:s,disabled:r=!1,id:o,resizeObserverConfig:g}=e;const p=ai(Dh),{active:v,dispatch:n,over:i,measureDroppableContainers:l}=S.useContext(gr),d=S.useRef({disabled:r}),c=S.useRef(!1),m=S.useRef(null),x=S.useRef(null),{disabled:w,updateMeasurementsFor:y,timeout:a}={...Ph,...g},h=or(y??o),u=S.useCallback(()=>{if(!c.current){c.current=!0;return}x.current!=null&&clearTimeout(x.current),x.current=setTimeout(()=>{l(Array.isArray(h.current)?h.current:[h.current]),x.current=null},a)},[a]),f=li({callback:u,disabled:w||!v}),b=S.useCallback((_,j)=>{f&&(j&&(f.unobserve(j),c.current=!1),_&&f.observe(_))},[f]),[C,k]=qr(b),E=or(s);return S.useEffect(()=>{!f||!C.current||(f.disconnect(),c.current=!1,f.observe(C.current))},[C,f]),S.useEffect(()=>(n({type:ot.RegisterDroppable,element:{id:o,key:p,disabled:r,node:C,rect:m,data:E}}),()=>n({type:ot.UnregisterDroppable,key:p,id:o})),[o]),S.useEffect(()=>{r!==d.current.disabled&&(n({type:ot.SetDroppableDisabled,id:o,key:p,disabled:r}),d.current.disabled=r)},[o,p,r,n]),{active:v,rect:m,isOver:i?.id===o,node:C,over:i,setNodeRef:k}}function Ih(e){let{animation:s,children:r}=e;const[o,g]=S.useState(null),[p,v]=S.useState(null),n=Kr(r);return!r&&!o&&n&&g(n),Gt(()=>{if(!p)return;const i=o?.key,l=o?.props.id;if(i==null||l==null){g(null);return}Promise.resolve(s(l,p)).then(()=>{g(null)})},[s,o,p]),ae.createElement(ae.Fragment,null,r,o?S.cloneElement(o,{ref:v}):null)}const Oh={x:0,y:0,scaleX:1,scaleY:1};function Bh(e){let{children:s}=e;return ae.createElement(gr.Provider,{value:dl},ae.createElement(ci.Provider,{value:Oh},s))}const Fh={position:"fixed",touchAction:"none"},zh=e=>En(e)?"transform 250ms ease":void 0,Wh=S.forwardRef((e,s)=>{let{as:r,activatorEvent:o,adjustScale:g,children:p,className:v,rect:n,style:i,transform:l,transition:d=zh}=e;if(!n)return null;const c=g?l:{...l,scaleX:1,scaleY:1},m={...Fh,width:n.width,height:n.height,top:n.top,left:n.left,transform:ar.Transform.toString(c),transformOrigin:g&&o?Mu(o,n):void 0,transition:typeof d=="function"?d(o):d,...i};return ae.createElement(r,{className:v,style:m,ref:s},p)}),Hh=e=>s=>{let{active:r,dragOverlay:o}=s;const g={},{styles:p,className:v}=e;if(p!=null&&p.active)for(const[n,i]of Object.entries(p.active))i!==void 0&&(g[n]=r.node.style.getPropertyValue(n),r.node.style.setProperty(n,i));if(p!=null&&p.dragOverlay)for(const[n,i]of Object.entries(p.dragOverlay))i!==void 0&&o.node.style.setProperty(n,i);return v!=null&&v.active&&r.node.classList.add(v.active),v!=null&&v.dragOverlay&&o.node.classList.add(v.dragOverlay),function(){for(const[i,l]of Object.entries(g))r.node.style.setProperty(i,l);v!=null&&v.active&&r.node.classList.remove(v.active)}},$h=e=>{let{transform:{initial:s,final:r}}=e;return[{transform:ar.Transform.toString(s)},{transform:ar.Transform.toString(r)}]},Uh={duration:250,easing:"ease",keyframes:$h,sideEffects:Hh({styles:{active:{opacity:"0"}}})};function qh(e){let{config:s,draggableNodes:r,droppableContainers:o,measuringConfiguration:g}=e;return oi((p,v)=>{if(s===null)return;const n=r.get(p);if(!n)return;const i=n.node.current;if(!i)return;const l=cl(v);if(!l)return;const{transform:d}=yt(v).getComputedStyle(v),c=Za(d);if(!c)return;const m=typeof s=="function"?s:Kh(s);return nl(i,g.draggable.measure),m({active:{id:p,data:n.data,node:i,rect:g.draggable.measure(i)},draggableNodes:r,dragOverlay:{node:v,rect:g.dragOverlay.measure(l)},droppableContainers:o,measuringConfiguration:g,transform:c})})}function Kh(e){const{duration:s,easing:r,sideEffects:o,keyframes:g}={...Uh,...e};return p=>{let{active:v,dragOverlay:n,transform:i,...l}=p;if(!s)return;const d={x:n.rect.left-v.rect.left,y:n.rect.top-v.rect.top},c={scaleX:i.scaleX!==1?v.rect.width*i.scaleX/n.rect.width:1,scaleY:i.scaleY!==1?v.rect.height*i.scaleY/n.rect.height:1},m={x:i.x-d.x,y:i.y-d.y,...c},x=g({...l,active:v,dragOverlay:n,transform:{initial:i,final:m}}),[w]=x,y=x[x.length-1];if(JSON.stringify(w)===JSON.stringify(y))return;const a=o?.({active:v,dragOverlay:n,...l}),h=n.node.animate(x,{duration:s,easing:r,fill:"forwards"});return new Promise(u=>{h.onfinish=()=>{a?.(),u()}})}}let _o=0;function Xh(e){return S.useMemo(()=>{if(e!=null)return _o++,_o},[e])}const Yh=ae.memo(e=>{let{adjustScale:s=!1,children:r,dropAnimation:o,style:g,transition:p,modifiers:v,wrapperElement:n="div",className:i,zIndex:l=999}=e;const{activatorEvent:d,active:c,activeNodeRect:m,containerNodeRect:x,draggableNodes:w,droppableContainers:y,dragOverlay:a,over:h,measuringConfiguration:u,scrollableAncestors:f,scrollableAncestorRects:b,windowRect:C}=Mh(),k=S.useContext(ci),E=Xh(c?.id),_=hl(v,{activatorEvent:d,active:c,activeNodeRect:m,containerNodeRect:x,draggingNodeRect:a.rect,over:h,overlayNodeRect:a.rect,scrollableAncestors:f,scrollableAncestorRects:b,transform:k,windowRect:C}),j=Tn(m),A=qh({config:o,draggableNodes:w,droppableContainers:y,measuringConfiguration:u}),P=j?a.setRef:void 0;return ae.createElement(Bh,null,ae.createElement(Ih,{animation:A},c&&E?ae.createElement(Wh,{key:E,id:c.id,ref:P,as:n,activatorEvent:d,adjustScale:s,className:i,transition:p,rect:j,style:{zIndex:l,...g},transform:_},r):null))}),fl=768;function Vh(e){const s=window.matchMedia(`(max-width: ${fl-1}px)`);return s.addEventListener("change",e),()=>s.removeEventListener("change",e)}function Gh(){return window.innerWidth<fl}function Qh(){return!1}function ml(){return S.useSyncExternalStore(Vh,Gh,Qh)}const Zh=1500,Jh=2e3,ef=5e3;function pl(e,s){return e&&s?.workingDir===e&&s.tab==="changes"?Zh:!1}function tf(e,s){return e&&s?.workspaceId===e&&s.tab==="changes"?Jh:!1}function sf(e,s){return e&&s?.workingDir===e&&s.tab==="history"?ef:!1}function Mn(e){return Bt({queryKey:de.workspaces.list(e),queryFn:()=>Ce.get(`/tasks/${e}/workspaces`),enabled:!!e})}function gl(e){const s=bt();return Ft({mutationFn:r=>Ce.post(`/tasks/${e}/workspaces`,r),onSuccess:()=>{s.invalidateQueries({queryKey:de.workspaces.list(e)}),s.invalidateQueries({queryKey:de.tasks.all})}})}function vl(){const e=bt();return Ft({mutationFn:({id:s,commitMessage:r})=>Ce.post(`/workspaces/${s}/merge`,{commitMessage:r}),onSuccess:()=>{e.invalidateQueries({queryKey:de.workspaces.all}),e.invalidateQueries({queryKey:de.tasks.all}),e.invalidateQueries({queryKey:de.git.all})},onError:()=>{e.invalidateQueries({queryKey:de.git.all})}})}function rf(){const e=bt();return Ft({mutationFn:s=>Ce.post(`/workspaces/${s}/reactivate`),onSuccess:()=>{e.invalidateQueries({queryKey:de.workspaces.all}),e.invalidateQueries({queryKey:de.tasks.all})}})}function Dn(){return Ft({mutationFn:({workspaceId:e,editorType:s})=>Ce.post(`/workspaces/${e}/open-editor`,{editorType:s})})}function Pn(e,s={}){const r=_s(g=>g.visibleContext),o=tf(e,r);return Bt({queryKey:de.workspaces.gitStatus(e),queryFn:()=>Ce.get(`/workspaces/${e}/git-status`),enabled:!!e&&(s.enabled??!0),refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1})}function xl(){const e=bt();return Ft({mutationFn:s=>Ce.post(`/workspaces/${s}/rebase`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:de.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:de.git.all})},onError:(s,r)=>{e.invalidateQueries({queryKey:de.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:de.git.all})}})}function Ln(){const e=bt();return Ft({mutationFn:s=>Ce.post(`/workspaces/${s}/abort-operation`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:de.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:de.git.all})}})}function nf(e,s){const r=[];if(!e||e.length===0)return r;const o=e.some(p=>p.status==="ACTIVE");return e.some(p=>p.sessions?.some(v=>v.status===dt.RUNNING||v.status===dt.PENDING))&&r.push(s("正在运行的 Agent 将被停止")),o&&(r.push(s("分支上未合并的变更将丢失")),r.push(s("关联的工作目录(worktree)将被清理"))),r}function In({isOpen:e,onClose:s,onConfirm:r,taskId:o,taskTitle:g,workspaces:p,isLoading:v}){const{t:n}=ce(),{data:i,isLoading:l}=Mn(p===void 0&&e?o:""),d=p??i,c=p===void 0&&e&&l,m=S.useMemo(()=>nf(d,n),[d,n]);return t.jsx(mn,{isOpen:e,onClose:s,onConfirm:r,title:n("删除任务"),description:t.jsxs(t.Fragment,{children:[t.jsx("p",{children:n("确认删除任务「{title}」?此操作不可撤销。",{title:g})}),c?t.jsx("p",{className:"mt-2 text-xs text-neutral-400",children:n("加载中...")}):m.length>0?t.jsx("ul",{className:"mt-2 space-y-1",children:m.map((x,w)=>t.jsxs("li",{className:"flex items-start gap-1.5 text-amber-600",children:[t.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-amber-400"}),t.jsx("span",{children:x})]},w))}):null]}),confirmText:n("删除"),variant:"danger",isLoading:v||c})}const be={Review:"Review",Running:"Running",Pending:"Pending",Done:"Done",Cancelled:"Cancelled"},Vi={[be.Review]:{label:"Review",icon:Ta,iconClass:"text-warning",accentClass:"text-warning"},[be.Running]:{label:"Running",icon:Aa,iconClass:"text-info",accentClass:"text-info"},[be.Pending]:{label:"Pending",icon:Ra,iconClass:"text-muted-foreground",accentClass:"text-muted-foreground"},[be.Done]:{label:"Done",icon:Na,iconClass:"text-success/80",accentClass:"text-success"},[be.Cancelled]:{label:"Cancelled",icon:ja,iconClass:"text-muted-foreground/70",accentClass:"text-muted-foreground/70"}},of=[be.Review,be.Running,be.Pending,be.Done,be.Cancelled],_l=S.createContext(null),af=3e4;function lf(e=af){const[,s]=S.useState(0);S.useEffect(()=>{const r=setInterval(()=>s(o=>o+1),e);return()=>clearInterval(r)},[e])}function cf(e){const s=Math.max(0,Math.floor((Date.now()-new Date(e).getTime())/1e3));return s<60?gt("{count}s ago",{count:s}):s<3600?gt("{count}m ago",{count:Math.floor(s/60)}):s<86400?gt("{count}h ago",{count:Math.floor(s/3600)}):gt("{count}d ago",{count:Math.floor(s/86400)})}function df({task:e,status:s,isSelected:r,project:o,onSelectTask:g,onTaskStatusChange:p,onDeleteTask:v,disableDrag:n}){const{t:i}=ce(),l=S.useContext(_l),d=S.useRef(null),c=!!e.projectArchivedAt,m=c||!!n,{attributes:x,listeners:w,setNodeRef:y,isDragging:a}=Th({id:e.id,data:{task:e,fromStatus:s},disabled:m}),h=S.useCallback(T=>{d.current=T,y(T),l&&(T?l.registry.set(e.id,T):l.registry.delete(e.id))},[y,l,e.id]);S.useEffect(()=>()=>{l?.registry.delete(e.id)},[e.id,l]);const[u,f]=S.useState(null),[b,C]=S.useState(!1),k=S.useRef(null),E=S.useRef(null),_=S.useCallback(T=>{c||!p&&!v||(T.preventDefault(),f({x:T.clientX,y:T.clientY}))},[c,p,v]),j=S.useCallback(()=>{E.current&&(clearTimeout(E.current),E.current=null)},[]),A=S.useCallback(T=>{if(!n||c||!p&&!v)return;const D=T.touches[0];if(!D)return;const{clientX:W,clientY:I}=D;E.current=setTimeout(()=>{E.current=null,f({x:W,y:I})},500)},[n,c,p,v]);S.useEffect(()=>{if(!u)return;const T=D=>{k.current&&!k.current.contains(D.target)&&f(null)};return document.addEventListener("mousedown",T),document.addEventListener("touchstart",T),()=>{document.removeEventListener("mousedown",T),document.removeEventListener("touchstart",T)}},[u]);const P=o?o.name:void 0;return t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:h,onClick:()=>g(e.id),onContextMenu:_,onTouchStart:A,onTouchEnd:j,onTouchMove:j,title:P,"aria-label":P?`${e.title} — ${P}`:e.title,className:`flex items-center gap-2.5 ml-4 mr-2 px-2 py-2 rounded-md text-sm text-left transition-colors group animate-task-enter
7
- ${a?"opacity-30":""}
8
- ${r?"bg-accent":"hover:bg-accent/50"}`,...m?{}:w,...m?{}:x,children:[t.jsx("span",{className:"shrink-0 flex items-center",children:(()=>{const{icon:T,iconClass:D}=Vi[s];return t.jsx(T,{className:`${D} ${s===be.Running?"animate-pulse":""}`})})()}),t.jsx("span",{className:`min-w-0 flex-1 truncate ${r?"text-foreground font-medium":"text-foreground/90"}`,children:e.title}),e.projectArchivedAt&&t.jsx("span",{className:"inline-flex shrink-0 items-center rounded-full bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:e.projectRepoDeletedAt?i("源码已删除"):i("已删除")}),e.updatedAt&&t.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground/50 tabular-nums",children:cf(e.updatedAt)}),o&&t.jsx("span",{className:`shrink-0 w-1.5 h-1.5 rounded-full ${o.color.replace("text-","bg-")}`})]}),u&&t.jsxs("div",{ref:k,className:"fixed z-[100] w-44 bg-popover rounded-lg border border-border shadow-lg py-1 animate-in fade-in zoom-in-95 duration-100",style:{left:u.x,top:u.y},children:[p&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted-foreground/70 uppercase tracking-wider",children:i("Move to")}),of.filter(T=>T!==s).map(T=>{const{icon:D,label:W,accentClass:I}=Vi[T];return t.jsxs("button",{onClick:()=>{p(e.id,T),f(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs hover:bg-accent/50 transition-colors",children:[t.jsx(D,{className:`w-3.5 h-3.5 ${I}`}),t.jsx("span",{className:"text-foreground/80",children:i(W)})]},T)})]}),v&&t.jsxs(t.Fragment,{children:[p&&t.jsx("div",{className:"my-1 border-t border-border/60"}),t.jsxs("button",{onClick:()=>{C(!0),f(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-destructive hover:bg-destructive/10 transition-colors",children:[t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"w-3.5 h-3.5",children:[t.jsx("path",{d:"M3 6h18"}),t.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),t.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]}),t.jsx("span",{children:i("Delete Task")})]})]})]}),t.jsx(In,{isOpen:b,onClose:()=>C(!1),onConfirm:()=>{v?.(e.id),C(!1)},taskId:e.id,taskTitle:e.title})]})}const uf=S.memo(function({title:s,tasks:r,status:o,defaultOpen:g,selectedTaskId:p,onSelectTask:v,projects:n,isDragging:i,dragFromStatus:l,onTaskStatusChange:d,onDeleteTask:c,disableDrag:m}){const{t:x}=ce(),[w,y]=S.useState(g);lf();const a=r.length===0,h=i&&l===o,u=i&&l!==o,{setNodeRef:f,isOver:b}=Lh({id:`group-${o}`,data:{status:o}}),C=o===be.Review,k=x(s),E=i?h&&(w||!0):w;return t.jsxs("div",{className:"mb-2","data-task-group-status":o,children:[t.jsxs("button",{onClick:()=>!i&&y(_=>!_),className:"flex items-center gap-1.5 w-full px-4 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors group/header",children:[t.jsx("span",{className:"flex-1 text-left",children:k}),C&&!a?t.jsx("span",{className:"px-1.5 py-0.5 bg-warning/15 text-warning text-[11px] font-semibold rounded-full animate-hop",children:r.length}):t.jsx("span",{className:"text-[11px] text-muted-foreground/50 font-normal tabular-nums",children:r.length}),t.jsx("span",{className:"text-muted-foreground/50",children:E?t.jsx(wt,{size:12}):t.jsx(Mt,{size:12})})]}),u&&t.jsx("div",{ref:f,className:`mx-2 my-1 flex items-center justify-center rounded-lg border-2 border-dashed transition-all duration-150 h-10
9
- ${b?"border-info bg-info/10 text-info":"border-border bg-muted/30 text-muted-foreground/70"}`,children:t.jsx("span",{className:"text-xs font-medium",children:b?x("Drop into {title}",{title:k}):x("Drop here")})}),E&&!u&&t.jsx("div",{ref:h?void 0:f,className:`flex flex-col mt-0.5 min-h-[40px] rounded-md transition-colors
10
- ${b&&!h?"bg-info/10 ring-1 ring-info/30":""}
11
- ${a&&i?"border border-dashed border-border mx-2":""}`,children:a?t.jsx("span",{className:"text-xs text-muted-foreground/50 py-2 px-4",children:x("No tasks")}):r.map(_=>{const j=p===_.id,A=_.projectId?n.find(P=>P.id===_.projectId):void 0;return t.jsx(df,{task:_,status:o,isSelected:j,project:A,onSelectTask:v,onTaskStatusChange:_.projectArchivedAt?void 0:d,onDeleteTask:_.projectArchivedAt?void 0:c,disableDrag:m},_.id)})})]})}),hf=12,ff=50;function mf({isOpen:e,onClose:s,tasks:r,projects:o,onSelectTask:g}){const{t:p}=ce(),[v,n]=S.useState(""),[i,l]=S.useState(0),d=S.useRef(null);S.useEffect(()=>{e&&(n(""),l(0))},[e]);const c=S.useMemo(()=>{const w=v.trim().toLowerCase();return w?r.filter(y=>y.title.toLowerCase().includes(w)).slice(0,ff):r.slice(0,hf)},[r,v]);S.useEffect(()=>{l(0)},[v]),S.useEffect(()=>{d.current?.children[i]?.scrollIntoView({block:"nearest"})},[i]);const m=S.useCallback(w=>{g(w),s()},[g,s]),x=S.useCallback(w=>{if(w.key==="Escape")w.preventDefault(),s();else if(w.key==="ArrowDown")w.preventDefault(),l(y=>Math.min(y+1,c.length-1));else if(w.key==="ArrowUp")w.preventDefault(),l(y=>Math.max(y-1,0));else if(w.key==="Enter"&&!w.nativeEvent.isComposing){w.preventDefault();const y=c[i];y&&m(y.id)}},[s,c,i,m]);return e?t.jsxs("div",{className:"fixed inset-0 z-90",role:"dialog","aria-modal":"true",children:[t.jsx("div",{className:"absolute inset-0 bg-black/20",onClick:s}),t.jsxs("div",{className:"absolute left-1/2 top-[18vh] w-[min(560px,calc(100vw-2rem))] -translate-x-1/2 bg-popover rounded-xl border border-border shadow-lg overflow-hidden animate-in fade-in zoom-in-95 duration-100",children:[t.jsxs("div",{className:"flex items-center gap-2.5 px-4 border-b border-border/60",children:[t.jsx(pn,{size:15,className:"text-muted-foreground/70 shrink-0"}),t.jsx("input",{value:v,onChange:w=>n(w.target.value),onKeyDown:x,placeholder:p("Search tasks..."),"aria-label":p("Search tasks..."),autoFocus:!0,className:"flex-1 py-3 bg-transparent border-none focus:outline-none text-sm text-foreground placeholder-muted-foreground/60"})]}),c.length>0?t.jsxs(t.Fragment,{children:[!v.trim()&&t.jsx("div",{className:"px-4 pt-2.5 pb-1 text-[11px] font-medium text-muted-foreground/70",children:p("Recent tasks")}),t.jsx("div",{ref:d,className:"max-h-[46vh] overflow-y-auto scrollbar-app-thin pb-1.5 pt-0.5",children:c.map((w,y)=>{const a=o.find(f=>f.id===w.projectId),{icon:h,iconClass:u}=Vi[w.status];return t.jsxs("button",{onClick:()=>m(w.id),onMouseEnter:()=>l(y),className:`w-full flex items-center gap-2.5 px-4 py-2 text-left transition-colors
12
- ${y===i?"bg-accent":""}`,children:[t.jsx(h,{className:`${u} shrink-0`}),t.jsx("span",{className:"flex-1 min-w-0 truncate text-sm text-foreground/90",title:w.title,children:w.title}),a&&t.jsx("span",{className:"shrink-0 max-w-[120px] truncate text-xs text-muted-foreground/70",children:a.name})]},w.id)})})]}):t.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground/70",children:p("No matching tasks")})]})]}):null}const pf=260,gf=220;function vf(e){const s={[be.Review]:[],[be.Running]:[],[be.Pending]:[],[be.Done]:[],[be.Cancelled]:[]};for(const r of e)s[r.status].push(r);return s}const xf=[{status:be.Review,title:"Review",defaultOpen:!0},{status:be.Running,title:"Running",defaultOpen:!0},{status:be.Pending,title:"Pending",defaultOpen:!1},{status:be.Done,title:"Done",defaultOpen:!1},{status:be.Cancelled,title:"Cancelled",defaultOpen:!1}];function bo({tasks:e=[],projects:s=[],selectedTaskId:r,onSelectTask:o,filterProjectId:g,setFilterProjectId:p,width:v=320,onCreateTask:n,onCreateProject:i,isCreateActive:l,onTaskStatusChange:d,onDeleteTask:c}){const{t:m}=ce(),{preserveDesktopSearch:x}=ga(),w=ml(),[y,a]=S.useState(null),[h,u]=S.useState(null),[f,b]=S.useState(!1),C=S.useRef(new Map),k=S.useRef(new Set),E=S.useRef(new Map),_=S.useMemo(()=>({registry:C.current}),[]),j=S.useCallback(L=>{L.remove(),k.current.delete(L)},[]),A=g?e.filter(L=>L.projectId===g):e,P=S.useCallback((L,O)=>{const U=document.querySelector(`[data-task-group-status="${L}"]`);if(!U)return null;const z=(U.querySelector("button")??U).getBoundingClientRect();return z.width===0||z.height===0?null:new DOMRect(z.left+8,z.bottom+4,O.width,O.height)},[]),T=S.useCallback((L,O,U,Y=!1)=>{const z=document.createElement("div");z.setAttribute("aria-hidden","true"),z.innerHTML=U;const $=z.firstElementChild;$&&($.style.cssText="",$.className=$.className.replace(/\bopacity-\S*/g,"").replace(/\banimate-task-enter\b/g,""),$.style.pointerEvents="none",$.style.width=`${L.width}px`,$.style.height=`${L.height}px`,$.style.margin="0",$.style.backgroundColor="var(--sidebar-accent)",$.style.borderRadius="0.375rem",$.style.boxShadow="0 6px 16px rgba(15, 23, 42, 0.10), 0 1px 3px rgba(15, 23, 42, 0.08)",$.style.opacity="0.96",$.style.transition="none",$.setAttribute("tabindex","-1")),Object.assign(z.style,{position:"fixed",left:`${L.left}px`,top:`${L.top}px`,width:`${L.width}px`,height:`${L.height}px`,zIndex:"9999",pointerEvents:"none",overflow:"visible",transformOrigin:"top left",willChange:"transform, opacity"}),document.body.appendChild(z),k.current.add(z);const q=O.left-L.left,N=O.top-L.top;z.animate([{transform:"translate(0, 0)",opacity:.96,offset:0},{transform:`translate(${q}px, ${N}px)`,opacity:Y?.12:.96,offset:1}],{duration:Y?gf:pf,easing:"cubic-bezier(0.2, 0, 0, 1)",fill:"forwards"}).finished.then(()=>j(z),()=>j(z))},[j]);S.useLayoutEffect(()=>{const L=window.matchMedia("(prefers-reduced-motion: reduce)").matches,O=new Map;for(const U of A){const Y=C.current.get(U.id);if(!Y)continue;const z={status:U.status,rect:Y.getBoundingClientRect(),html:Y.outerHTML};if(O.set(U.id,z),L)continue;const $=E.current.get(U.id);if(!$||$.status===U.status)continue;const q=z.rect.left-$.rect.left,N=z.rect.top-$.rect.top;Math.abs(q)<1&&Math.abs(N)<1||T($.rect,z.rect,$.html)}if(!L)for(const[U,Y]of E.current){if(O.has(U))continue;const z=A.find(q=>q.id===U);if(!z||z.status===Y.status)continue;const $=P(z.status,Y.rect);$&&T(Y.rect,$,Y.html,!0)}E.current=O},[A,T,P]),S.useEffect(()=>()=>{for(const L of k.current)L.remove();k.current.clear()},[]);const D=Tu(Au(An,{activationConstraint:{distance:8}})),W=S.useCallback(L=>{const O=L.active.data.current?.task,U=L.active.data.current?.fromStatus;O&&a(O),U&&u(U)},[]),I=S.useCallback(L=>{a(null),u(null);const{active:O,over:U}=L;if(!U)return;const Y=O.data.current?.task,z=O.data.current?.fromStatus,$=U.data.current?.status;!Y||!z||!$||Y.projectArchivedAt||z!==$&&d?.(Y.id,$)},[d]),R=!!!(g?s.find(L=>L.id===g)??null:null)?.archivedAt,M=vf(A);return t.jsxs("div",{className:"h-full flex flex-col flex-shrink-0",style:{width:v},children:[t.jsxs("div",{className:"px-2 pt-2 pb-1 flex-shrink-0",children:[i&&t.jsxs("button",{onClick:i,className:"w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-sm text-foreground/80 hover:bg-accent/50 transition-colors",title:m("New Project"),children:[t.jsx(wd,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:m("New Project")})]}),t.jsxs("button",{onClick:n,disabled:!R,className:`w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-sm transition-colors disabled:opacity-30 disabled:cursor-not-allowed
13
- ${l?"bg-accent text-foreground":"text-foreground/80 hover:bg-accent/50"}`,title:m(R?"New Task":"Deleted projects are read-only"),children:[t.jsx(xd,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:m("New Task")})]}),t.jsxs("button",{onClick:()=>b(!0),className:"w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-sm text-foreground/80 hover:bg-accent/50 transition-colors",title:m("Search"),children:[t.jsx(pn,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:m("Search")})]}),t.jsxs(Yc,{to:x("/conversations"),className:"w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-sm text-foreground/80 hover:bg-accent/50 transition-colors",title:m("对话"),children:[t.jsx(ti,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:m("对话")})]})]}),A.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-6 text-center select-none",children:[t.jsx(Ps,{size:36,className:"text-muted-foreground/40 mb-3",strokeWidth:1.5}),t.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:m("No tasks")}),R&&n?t.jsx("button",{onClick:n,className:"px-3.5 py-1.5 rounded-md bg-brand text-brand-foreground text-xs font-medium hover:bg-brand/90 transition-colors",children:m("New Task")}):null]}):t.jsx(_l.Provider,{value:_,children:t.jsxs(Nh,{sensors:D,onDragStart:W,onDragEnd:I,children:[t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin pt-3 pb-4 relative",children:xf.map(({status:L,title:O,defaultOpen:U})=>t.jsx(uf,{title:O,tasks:M[L],status:L,defaultOpen:U,selectedTaskId:r,onSelectTask:o,projects:s,isDragging:y!==null,dragFromStatus:h,onTaskStatusChange:d,onDeleteTask:c,disableDrag:w},L))}),t.jsx(Yh,{dropAnimation:null,children:y?t.jsx("div",{className:"bg-popover shadow-lg rounded-md border border-border px-4 py-2 text-sm max-w-[280px] opacity-90",children:t.jsx("span",{className:"block truncate font-medium text-foreground/80",title:y.title,children:y.title})}):null})]})}),A.length>0?t.jsxs("div",{className:"px-4 py-3 border-t border-border/60 text-xs text-muted-foreground/70 flex items-center justify-between",children:[t.jsx("span",{children:m("{count} tasks",{count:A.length})}),g?t.jsx("button",{onClick:()=>p(null),className:"hover:text-foreground underline decoration-border underline-offset-2",children:m("Clear filter")}):null]}):t.jsx("div",{className:"px-4 py-3 border-t border-border/60 text-xs text-muted-foreground/70 flex items-center justify-between",children:t.jsx("span",{children:m("{count} tasks",{count:0})})}),t.jsx(mf,{isOpen:f,onClose:()=>b(!1),tasks:A,projects:s,onSelectTask:o})]})}const _f=10,bf=24,bl=_f*bf,yf=8;function Sf(e,s=bl){return e>s+yf}function wf(e,s){return e.includes(s)?e:[...e,s]}function Cf(e,s){return e.filter(r=>r!==s)}function kf(e,s){const r=new Map(s.map(o=>[o.id,o]));return e.map(o=>r.get(o)).filter(o=>!!o).map(o=>({memberId:o.id,label:o.name}))}const di=new Set(["RUNNING","WAITING_ROOM_REPLY","QUEUED","SESSION_ENDED"]);function yo(e){if(!e)return 0;const s=Date.parse(e);return Number.isNaN(s)?0:s}function Ef(e,s=[],r=[]){const o=new Set(r.filter(p=>di.has(p.status)).map(p=>p.workRequestId));return[...e.map(p=>({kind:"message",key:`message:${p.id}`,sortTime:p.createdAt,order:0,message:p})),...s.filter(p=>p.status==="PENDING_APPROVAL").filter(p=>!o.has(p.id)).map(p=>({kind:"pendingApproval",key:`pending-approval:${p.id}`,sortTime:p.updatedAt??p.createdAt,order:1,request:p}))].sort((p,v)=>{const n=yo(p.sortTime)-yo(v.sortTime);return n!==0?n:p.order!==v.order?p.order-v.order:p.key.localeCompare(v.key)})}function jf(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 Nf(e){switch(e){case"FAILED":return"text-red-500";case"RUNNING":case"WAITING_ROOM_REPLY":case"QUEUED":case"SESSION_ENDED":return"text-neutral-500";default:return"text-neutral-500"}}function Rf(e,s){const r=e.reduce((g,p)=>(g[p.status]=(g[p.status]??0)+1,g),{});return[["RUNNING","running"],["QUEUED","queued"],["WAITING_ROOM_REPLY","waiting"],["SESSION_ENDED","ended"]].map(([g,p])=>{const v=r[g];return v?`${v} ${s(p)}`:null}).filter(g=>!!g).join(" · ")}function Af(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(min-width: 768px)").matches}function Tf({status:e}){const{t:s}=ce();return e==="RUNNING"?t.jsxs(t.Fragment,{children:[s("Working"),t.jsxs("span",{className:"active-work-dots","aria-hidden":"true",children:[t.jsx("span",{children:"."}),t.jsx("span",{className:"active-work-dots__second",children:"."}),t.jsx("span",{className:"active-work-dots__third",children:"."})]})]}):t.jsx(t.Fragment,{children:s(jf(e))})}function Mf({invocations:e,memberById:s,workRequestById:r,onViewInvocationSession:o,onStopMember:g,isStopPending:p,stoppingMemberId:v,stopPromptInvocationId:n,onToggleStopConfirm:i}){const{t:l}=ce(),[d,c]=S.useState(Af),m=S.useMemo(()=>e.filter(w=>di.has(w.status)).sort((w,y)=>Date.parse(y.updatedAt??y.createdAt??"")-Date.parse(w.updatedAt??w.createdAt??"")),[e]);if(m.length===0)return null;const x=Rf(m,l);return t.jsxs("div",{className:"border-t border-neutral-200 bg-neutral-50/80",children:[t.jsxs("button",{type:"button",onClick:()=>c(w=>!w),"aria-expanded":d,className:"flex h-8 w-full items-center justify-between gap-3 px-3 text-left text-xs text-neutral-600 transition-colors hover:bg-neutral-100",children:[t.jsxs("span",{className:"min-w-0 truncate",children:[t.jsx("span",{className:"font-medium text-neutral-800",children:l("Active work")}),t.jsx("span",{className:"mx-1.5 text-neutral-300",children:"·"}),t.jsx("span",{children:x})]}),d?t.jsx(wt,{size:15,className:"shrink-0 text-neutral-400"}):t.jsx(Ha,{size:15,className:"shrink-0 text-neutral-400"})]}),d&&t.jsx("div",{className:"max-h-32 overflow-y-auto border-t border-neutral-200",children:m.map(w=>{const y=s.get(w.memberId),a=r.get(w.workRequestId),h=!!(w.sessionId&&o),u=!!y,f=n===w.id,b=p&&v===w.memberId,C=a?.instruction??w.workRequestId;return t.jsxs("div",{className:"border-t border-neutral-100 first:border-t-0",children:[t.jsxs("div",{title:C,className:se("group flex h-8 items-center gap-2 px-3 text-xs text-neutral-700",h?"cursor-pointer hover:bg-white":"cursor-default"),role:h?"button":void 0,tabIndex:h?0:void 0,onClick:()=>w.sessionId&&o?.(w.sessionId),onKeyDown:k=>{!h||!w.sessionId||(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),o?.(w.sessionId))},children:[t.jsx($t,{name:y?.name??l("Agent"),avatar:y?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[t.jsx("span",{className:"truncate font-medium text-neutral-800",children:y?.name??l("Agent")}),t.jsx("span",{className:se("shrink-0",Nf(w.status)),children:t.jsx(Tf,{status:w.status})})]}),h&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),w.sessionId&&o?.(w.sessionId)},onKeyDown:k=>k.stopPropagation(),className:"hidden shrink-0 rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700 group-hover:inline-flex",title:l("View log"),"aria-label":`${l("View log")} ${y?.name??l("Agent")}`,children:t.jsx(qi,{size:13})}),u&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),i(w.id)},onKeyDown:k=>k.stopPropagation(),disabled:b,className:"shrink-0 rounded-md p-1 text-neutral-400 transition-colors hover:bg-red-50 hover:text-red-700 disabled:cursor-not-allowed disabled:opacity-50",title:l("Stop"),"aria-label":`${l("Stop")} ${y?.name??l("Agent")}`,children:t.jsx(Ds,{size:12})})]}),u&&f&&y&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 border-t border-neutral-100 bg-white px-3 py-2",children:[t.jsx("span",{className:"mr-1 text-[11px] text-neutral-600",children:l("Stop running work?")}),t.jsxs(Te,{type:"button",size:"xs",variant:"outline",disabled:b,onClick:()=>g(y.id,!1),children:[t.jsx(Ds,{size:11}),t.jsx("span",{children:l(b?"Stopping":"Stop only")})]}),t.jsxs(Te,{type:"button",size:"xs",variant:"outline",disabled:b,className:"border-red-200 bg-red-50 text-red-700 hover:bg-red-100 hover:text-red-800",onClick:()=>g(y.id,!0),children:[t.jsx(qa,{size:11}),t.jsx("span",{children:l(b?"Stopping":"Stop + clear queue")})]})]})]},w.id)})})]})}const Gi=dr(),Df=240;let So=0;function Pf(e,s){return So+=1,{id:`pending-room-message-${Date.now()}-${So}`,teamRunId:e,senderType:s.senderType??"user",senderId:s.senderId??null,senderInvocationId:s.senderInvocationId??null,kind:s.kind??((s.mentions?.length??0)>0?"work_request":"chat"),visibility:"PUBLIC",content:s.content,mentions:s.mentions??[],workRequestIds:[],artifactRefs:s.artifactRefs??[],attachmentIds:s.attachmentIds??[],createdAt:new Date().toISOString(),pendingStatus:"sending"}}function yl(e){return"pendingStatus"in e}function Lf(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function If(e){return`${e.mimeType.startsWith("image/")?"!":""}[${e.originalName}](${e.storagePath})`}function Qi(e,s){if(s.length===0)return e;const r=new Set(s.map(If));return e.split(`
14
- `).map(o=>{const g=o.match(/^\s*/)?.[0]??"",p=o.trimStart();for(const v of r){if(p===v)return null;if(p.startsWith(`${v} `)||p.startsWith(`${v} `))return`${g}${p.slice(v.length).trimStart()}`}return o}).filter(o=>o!=null).join(`
15
- `).replace(/\n{3,}/g,`
16
-
17
- `).trim()}function Of(e){if(!e)return"";const s=new Date(e);return Number.isNaN(s.getTime())?"":s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Zi(e,s){return e instanceof Error?e.message:s}function Bf(e,s=Df){const r=(e??"").replace(/\s+/g," ").trim();return r.length<=s?r:`${r.slice(0,s-3).trimEnd()}...`}function Ff(e,s){const o=e.slice(0,s).match(/(^|\s)@([^\s@]*)$/);return!o||o.index==null?null:{start:o.index+o[1].length,end:s,query:o[2]??""}}function zf(e,s){const r=s.trim().toLowerCase();return r?[e.name,e.providerId,...e.aliases??[]].some(g=>g.toLowerCase().includes(r)):!0}function wo(e){return e.membershipStatus!=="REMOVED"}function Wf(e,s){return e.label??s.get(e.memberId)?.name??e.memberId}function Hf(e,s){return(e.recipientMemberIds??[]).map(r=>s.get(r)?.name??r)}function $f(e,s){const r=e.mentions??[],o=e.contentPreview??e.content;if(r.length===0)return o;const g=r.map(v=>Wf(v,s)).filter(v=>v&&!o.includes(`@${v}`));if(g.length===0)return o;const p=g.map(v=>`@${v}`).join(" ");return o.trimEnd()?`${o.trimEnd()} ${p}`:p}function Uf(e,s,r){if(e.senderType!=="agent")return null;if(e.senderId&&s.has(e.senderId))return s.get(e.senderId)??null;if(e.senderInvocationId){const o=r.get(e.senderInvocationId);if(o?.memberId&&s.has(o.memberId))return s.get(o.memberId)??null}return null}function qf({content:e,isUser:s,workingDir:r,onOpenWorkspaceFile:o,onOpenPreviewUrl:g}){const p=hd(e),v=S.useMemo(()=>fd({workingDir:r,onOpenWorkspaceFile:o,onOpenPreviewUrl:g}),[g,o,r]);return t.jsx("div",{className:se("team-room-message-markdown prose prose-sm max-w-none break-words [overflow-wrap:anywhere]","prose-p:my-2 prose-p:first:mt-0 prose-p:last:mb-0 prose-p:leading-6","prose-ul:my-2 prose-ol:my-2 prose-li:my-1 prose-li:pl-0 prose-li:leading-6 prose-li:marker:text-neutral-400","prose-blockquote:my-2 prose-blockquote:border-l-2 prose-blockquote:border-neutral-300 prose-blockquote:pl-3 prose-blockquote:text-neutral-600","prose-pre:my-3 prose-pre:max-w-full prose-pre:overflow-x-auto prose-pre:rounded-md prose-pre:border prose-pre:border-neutral-800 prose-pre:bg-neutral-950 prose-pre:p-3 prose-pre:text-xs prose-pre:leading-relaxed prose-pre:shadow-inner","prose-code:break-words prose-code:rounded prose-code:bg-neutral-100 prose-code:px-1 prose-code:py-0.5 prose-code:text-[0.9em] prose-code:font-medium prose-code:text-neutral-800","prose-pre:prose-code:bg-transparent prose-pre:prose-code:p-0 prose-pre:prose-code:text-neutral-100","prose-headings:mb-2 prose-headings:mt-3 prose-headings:font-semibold prose-headings:leading-snug","prose-a:text-blue-600 prose-a:underline-offset-2 hover:prose-a:text-blue-700","prose-hr:my-3 prose-hr:border-neutral-200",s?["text-white prose-strong:text-white prose-headings:text-white prose-blockquote:border-white/30 prose-blockquote:text-neutral-200","prose-code:bg-white/15 prose-code:text-white prose-pre:border-neutral-700 prose-a:text-blue-200 hover:prose-a:text-blue-100 prose-hr:border-white/15"]:"text-neutral-800 prose-strong:text-neutral-900"),children:t.jsx(fn,{components:v,plugins:p,controls:p?md:void 0,children:e})})}function Kf({hasAttachmentIds:e,attachments:s,isLoading:r,onOpenImage:o}){if(!e)return null;if(r&&s.length===0)return t.jsx("div",{className:"mt-3 text-xs text-neutral-400",children:"Loading attachments..."});if(s.length===0)return null;const g=s.filter(v=>v.mimeType.startsWith("image/")),p=new Map(g.map((v,n)=>[v.id,n]));return t.jsx("div",{className:"mt-3 flex flex-wrap gap-2 text-neutral-700",children:s.map(v=>{const n=`${Gi}${v.url}`;if(v.mimeType.startsWith("image/")){const l=p.get(v.id)??0;return t.jsxs("button",{type:"button",onClick:()=>o(g,l),className:"group relative h-24 w-24 overflow-hidden rounded-lg border border-neutral-200 bg-neutral-50 shadow-sm transition-opacity hover:opacity-90",title:v.originalName,children:[t.jsx("img",{src:n,alt:v.originalName,className:"h-full w-full object-cover",loading:"lazy"}),t.jsx("span",{className:"absolute inset-x-0 bottom-0 truncate bg-black/55 px-1.5 py-1 text-left text-[10px] text-white",children:v.originalName})]},v.id)}return t.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"flex max-w-[220px] items-center gap-2 rounded-lg border border-neutral-200 bg-white px-3 py-2 text-xs text-neutral-700 shadow-sm hover:bg-neutral-50",title:v.originalName,children:[t.jsx(Ca,{size:16,className:"shrink-0 text-neutral-400","aria-hidden":!0}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate font-medium",children:v.originalName}),t.jsx("span",{className:"text-neutral-400",children:Lf(v.sizeBytes)})]}),t.jsx(ln,{size:13,className:"shrink-0 text-neutral-400","aria-hidden":!0})]},v.id)})})}function Xf({message:e,content:s,attachmentIds:r,isUser:o,tone:g,onOpenImage:p,workingDir:v,onOpenWorkspaceFile:n,onOpenPreviewUrl:i}){const l=S.useMemo(()=>Array.from(new Set(r??[])),[r]),{data:d=[],isLoading:c}=ud(l),m=d.length>0?Qi(s,d):s;return t.jsxs(t.Fragment,{children:[m.trim()&&t.jsx(Gf,{message:e,content:m,attachments:d,isUser:o,tone:g,workingDir:v,onOpenWorkspaceFile:n,onOpenPreviewUrl:i}),t.jsx(Kf,{hasAttachmentIds:l.length>0,attachments:d,isLoading:c,onOpenImage:p})]})}function Yf({images:e,index:s,onClose:r,onSelect:o}){const g=e[s];if(!g)return null;const p=s>0,v=s<e.length-1;return t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 p-4",role:"dialog","aria-modal":"true",children:[t.jsx("button",{type:"button",onClick:r,className:"absolute right-4 top-4 rounded-full bg-white/10 p-2 text-white transition-colors hover:bg-white/20","aria-label":"Close image preview",children:t.jsx(Yt,{size:20})}),p&&t.jsx("button",{type:"button",onClick:()=>o(s-1),className:"absolute left-4 top-1/2 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20","aria-label":"Previous image",children:t.jsx(Ld,{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:`${Gi}${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-white",children:[t.jsx("span",{className:"max-w-[70vw] truncate",children:g.originalName}),t.jsxs("a",{href:`${Gi}${g.url}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-md bg-white/10 px-2 py-1 text-xs hover:bg-white/20",children:[t.jsx(ln,{size:13,"aria-hidden":!0}),"Open"]})]})]}),v&&t.jsx("button",{type:"button",onClick:()=>o(s+1),className:"absolute right-4 top-1/2 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20","aria-label":"Next image",children:t.jsx(Mt,{size:24,"aria-hidden":!0})})]})}function Vf({draft:e,attachmentMarkdown:s,attachmentIds:r,mentions:o}){const p=[e.trim(),s].filter(Boolean).join(`
18
-
19
- `);return p?{content:p,mentions:o,senderType:"user",...r.length>0?{attachmentIds:r}:{}}:null}function Gf({message:e,content:s,attachments:r,isUser:o,tone:g=o?"user":"agent",workingDir:p,onOpenWorkspaceFile:v,onOpenPreviewUrl:n}){const{t:i}=ce(),l=S.useId(),d=S.useRef(null),[c,m]=S.useState(null),[x,w]=S.useState(!1),[y,a]=S.useState(null),h=Gc(e.teamRunId,e.id,!1),u=h.data?.content,f=u?Qi(u,r):void 0,C=!!(f&&f!==s)?f:s,k=!!(e.isTruncated&&!yl(e)),E=c?.messageId===e.id&&c.content===C&&c.expanded,_=S.useCallback(()=>{const D=d.current;D&&w(Sf(D.scrollHeight))},[]);S.useLayoutEffect(()=>{_();const D=d.current;if(!D)return;const W=window.requestAnimationFrame(_),I=typeof ResizeObserver>"u"?null:new ResizeObserver(_);return I?.observe(D),window.addEventListener("resize",_),()=>{window.cancelAnimationFrame(W),I?.disconnect(),window.removeEventListener("resize",_)}},[C,_]);const j=S.useCallback(async()=>{if(a(null),E){m({messageId:e.id,content:C,expanded:!1});return}if(k&&!u){const D=await h.refetch();if(D.error){a(Zi(D.error,i("Failed to load full message")));return}const W=D.data?.content?Qi(D.data.content,r):C;m({messageId:e.id,content:W,expanded:!0});return}m({messageId:e.id,content:C,expanded:!0})},[r,k,u,h,E,e.id,C,i]),A=(x||k)&&!E,P=x||k,T=h.isFetching;return t.jsxs("div",{className:"relative",children:[t.jsxs("div",{id:l,ref:d,onLoadCapture:_,className:se("relative transition-[max-height] duration-200 ease-out",A?"overflow-hidden":""),style:A?{maxHeight:bl}:void 0,children:[t.jsx(qf,{content:C,isUser:o,workingDir:p,onOpenWorkspaceFile:v,onOpenPreviewUrl:n}),A&&t.jsx("div",{className:se("pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-gradient-to-b from-transparent",g==="system"?"to-amber-50":g==="user"?"to-neutral-900":"to-neutral-100")})]}),P&&t.jsxs("button",{type:"button","aria-expanded":E,"aria-controls":l,"aria-label":i(E?"Collapse message":"Expand full message"),disabled:T,onClick:()=>{j()},className:se("mt-2 inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-300",g==="system"?"bg-amber-100 text-amber-800 hover:bg-amber-200":g==="user"?"bg-white/10 text-neutral-100 hover:bg-white/15 hover:text-white":"bg-neutral-100 text-neutral-600 hover:bg-neutral-200 hover:text-neutral-900",T?"cursor-wait opacity-70":""),children:[E?t.jsx(Ha,{size:13}):t.jsx(wt,{size:13}),t.jsx("span",{children:i(T?"Loading":E?"Collapse message":"Expand full message")})]}),y&&t.jsx("div",{className:se("mt-1 text-xs",g==="user"?"text-red-200":"text-red-600"),children:y})]})}function Sl({senderName:e,avatar:s,createdAt:r,isUser:o,isSystem:g,children:p,headerAddon:v,bubbleClassName:n,isPending:i}){return g?t.jsx("div",{className:"flex justify-center",children:t.jsx("div",{className:"max-w-[min(100%,42rem)] rounded-lg border border-amber-200/80 bg-amber-50 px-3 py-2 text-xs text-amber-900 shadow-sm",children:p})}):t.jsxs("div",{className:se("group flex items-start gap-3",o?"justify-end pl-8 sm:pl-14":"justify-start pr-8 sm:pr-14"),children:[!o&&t.jsx($t,{name:e,avatar:s??null,className:"mt-0.5 h-8 w-8 text-[11px]"}),t.jsxs("div",{className:se("flex min-w-0 max-w-[min(86%,46rem)] flex-col",o?"items-end":"items-start"),children:[t.jsxs("div",{className:se("mb-1.5 flex max-w-full items-center gap-1.5 px-0.5 text-[11px] text-neutral-500",o?"justify-end":"justify-start"),children:[t.jsx("span",{className:"truncate font-semibold text-neutral-700",children:e}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-neutral-300","aria-hidden":!0}),t.jsx(Rs,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"shrink-0",children:Of(r)}),v]}),t.jsx("div",{className:se("max-w-full rounded-lg px-3.5 py-3 text-sm leading-6 transition-colors",o?"rounded-tr-[2px] border border-neutral-900 bg-neutral-900 text-white shadow-sm":"rounded-tl-[2px] bg-neutral-100 text-neutral-900 shadow-sm",n,i?"opacity-70":""),children:p})]}),o&&t.jsx($t,{name:e,avatar:null,className:"mt-0.5 h-8 w-8 border-neutral-300 bg-neutral-900 text-white text-[11px]"})]})}function Qf({provider:e}){return t.jsxs("span",{className:"ml-0.5 inline-flex max-w-[10rem] shrink items-center gap-1 rounded-full bg-neutral-900/5 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-500",children:[t.jsx(si,{agentType:e.agentType,className:"size-2.5"}),t.jsx("span",{className:"truncate",children:e.name})]})}function Zf({message:e,senderName:s,senderMember:r,senderProvider:o,memberById:g,displayContent:p,onOpenImage:v,workingDir:n,onOpenWorkspaceFile:i,onOpenPreviewUrl:l,previewWorkspaceId:d}){const{t:c}=ce(),m=e.senderType==="user",x=e.senderType==="system",w=yl(e)?e.pendingStatus:null,y=e.mentions??[],a=e.workRequestIds?.length??0,h=e.visibility==="PRIVATE",u=S.useCallback(C=>{l?.(C,d)},[l,d]),f=h?Hf(e,g):[],b=t.jsxs(t.Fragment,{children:[!m&&!x&&o&&t.jsx(Qf,{provider:o}),h&&t.jsxs("span",{className:"ml-0.5 inline-flex max-w-[18rem] shrink items-center gap-1 rounded-full bg-sky-50 px-1.5 py-0.5 text-[10px] font-medium leading-none text-sky-700",title:f.join(", "),children:[t.jsx(Vc,{size:10}),t.jsxs("span",{className:"truncate",children:[c("Private"),f.length>0?`: ${f.join(", ")}`:""]})]}),!x&&a>0&&y.length===0&&t.jsxs("span",{className:"ml-0.5 shrink-0 rounded-full bg-neutral-900/8 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-600",children:[c("Work requests"),": ",a]}),w==="sending"&&t.jsx("span",{className:"ml-0.5 shrink-0 rounded-full bg-neutral-900/8 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-500",children:c("发送中...")}),w==="failed"&&t.jsx("span",{className:"ml-0.5 shrink-0 rounded-full bg-red-50 px-1.5 py-0.5 text-[10px] font-medium leading-none text-red-600",children:c("发送失败")})]});return t.jsx(Sl,{senderName:s,avatar:r?.avatar??null,createdAt:e.createdAt,isUser:m,isSystem:x,headerAddon:b,bubbleClassName:m&&w==="failed"?"border-red-200 bg-red-50 text-red-900":void 0,isPending:w==="sending",children:t.jsx(Xf,{message:e,content:p,attachmentIds:e.attachmentIds,isUser:m&&w!=="failed",tone:x?"system":void 0,onOpenImage:v,workingDir:n,onOpenWorkspaceFile:i,onOpenPreviewUrl:l?u:void 0})})}function Jf({request:e,member:s,onApprove:r,onReject:o,isActionPending:g,isApprovePending:p,isRejectPending:v}){const{t:n}=ce();return t.jsx(Sl,{senderName:s?.name??n("Agent"),avatar:s?.avatar??null,createdAt:e.createdAt,bubbleClassName:"border border-amber-200/80 bg-amber-50/80",children:t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-amber-200 bg-amber-50 px-2 py-0.5 text-[11px] font-medium text-amber-700",children:[t.jsx(Rs,{size:11}),n("Pending approval")]}),t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[n("Requester"),": ",n(e.requesterType==="user"?"User":e.requesterType==="system"?"System":"Agent")]})]}),t.jsx("div",{className:"text-sm leading-6 text-neutral-800 [overflow-wrap:anywhere]",children:e.instructionPreview??Bf(e.instruction)}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs(Te,{type:"button",size:"xs",variant:"outline",disabled:g,className:"border-emerald-200 bg-emerald-50 text-emerald-700 hover:bg-emerald-100 hover:text-emerald-800",onClick:r,children:[t.jsx(Vt,{size:12}),t.jsx("span",{children:n(p?"Approving":"Approve")})]}),t.jsxs(Te,{type:"button",size:"xs",variant:"outline",disabled:g,onClick:o,children:[t.jsx(Yt,{size:12}),t.jsx("span",{children:n(v?"Rejecting":"Reject")})]})]})]})})}function wl({teamRun:e,messages:s,readOnly:r,readOnlyMessage:o,onSendMessage:g,onViewInvocationSession:p,changeSummaryBar:v,compactComposer:n,centered:i,workingDir:l,onOpenWorkspaceFile:d,onOpenPreviewUrl:c}){const{t:m}=ce(),x=va(e.id),w=xa(e.id),y=_a(e.id),[a,h]=S.useState(""),[u,f]=S.useState(!1),[b,C]=S.useState(null),[k,E]=S.useState(0),[_,j]=S.useState([]),[A,P]=S.useState(!1),[T,D]=S.useState(null),[W,I]=S.useState([]),[B,F]=S.useState(null),R=S.useRef(null),M=S.useRef(null),{files:L,addFiles:O,removeFile:U,clear:Y,restoreFiles:z,buildMarkdownLinks:$,getDoneAttachments:q,isUploading:N}=un(),H=L.some(V=>V.status==="done"&&V.attachment),[X,K]=S.useState(null),{scrollRef:ne,contentRef:te,isAtBottom:he,scrollToBottom:le}=gn({resize:"smooth",initial:"instant"}),{data:G}=Bs(),pe=S.useMemo(()=>{const V=new Map;for(const Z of G??[])V.set(Z.provider.id,Z.provider);return V},[G]),ie=S.useMemo(()=>new Map((e.members??[]).map(V=>[V.id,V])),[e.members]),Ae=S.useMemo(()=>(e.members??[]).filter(wo),[e.members]),at=S.useMemo(()=>new Map((e.invocations??[]).map(V=>[V.id,V])),[e.invocations]),Xe=S.useMemo(()=>{const V=new Set(s.map(re=>re.id)),Z=W.filter(re=>!V.has(re.id));return[...s,...Z].sort((re,ye)=>{const me=Date.parse(re.createdAt??""),Se=Date.parse(ye.createdAt??"");return(Number.isNaN(me)?0:me)-(Number.isNaN(Se)?0:Se)})},[s,W]),_e=S.useMemo(()=>new Map((e.workRequests??[]).map(V=>[V.id,V])),[e.workRequests]),Ie=S.useMemo(()=>Ef(Xe,e.workRequests??[],e.invocations??[]),[Xe,e.invocations,e.workRequests]),Pe=S.useMemo(()=>(e.invocations??[]).filter(V=>di.has(V.status)),[e.invocations]),$e=S.useMemo(()=>_.map(V=>ie.get(V)).filter(V=>!!V).filter(wo),[ie,_]),Oe=S.useMemo(()=>{const V=b?.query??"";return Ae.filter(Z=>zf(Z,V)).sort((Z,re)=>{const ye=_.includes(Z.id),me=_.includes(re.id);return ye!==me?ye?1:-1:Z.name.localeCompare(re.name)})},[Ae,b?.query,_]),Ve=!r&&(u||!!b)&&Oe.length>0,Ze=S.useCallback((V,Z)=>{if(Z==null){C(null);return}C(Ff(V,Z)),E(0)},[]),Me=S.useCallback(V=>{j(Se=>wf(Se,V.id));const Z=`@${V.name} `;if(b){const Se=`${a.slice(0,b.start)}${Z}${a.slice(b.end)}`,we=b.start+Z.length;h(Se),C(null),f(!1),requestAnimationFrame(()=>{R.current?.focus(),R.current?.setSelectionRange(we,we)});return}const re=a.length===0||/\s$/.test(a)?"":" ",ye=`${a}${re}${Z}`,me=ye.length;h(ye),f(!1),requestAnimationFrame(()=>{R.current?.focus(),R.current?.setSelectionRange(me,me)})},[a,b]),Re=S.useCallback(V=>{j(Z=>Cf(Z,V))},[]),ve=S.useCallback(V=>{const Z=V.target.value;h(Z),D(null);const re=V.target;re.style.height="auto",re.style.height=`${Math.max(n?40:72,Math.min(re.scrollHeight,n?140:240))}px`,f(!1),Ze(Z,re.selectionStart)},[n,Ze]),Fe=S.useCallback(V=>{const Z=V.target.files;Z&&Z.length>0&&(O(Array.from(Z)),D(null)),V.target.value=""},[O]),ge=S.useCallback(V=>{const Z=[];for(const re of V.clipboardData.items)if(re.kind==="file"){const ye=re.getAsFile();ye&&Z.push(ye)}Z.length>0&&(V.preventDefault(),O(Z),D(null))},[O]),lt=S.useCallback(async()=>{if(r||A||N)return;const V=$(),Z=q().map(ke=>ke.id),re=kf(_,Ae),ye=Vf({draft:a,attachmentMarkdown:V,attachmentIds:Z,mentions:re});if(!ye||!a.trim()&&!H)return;const me=Pf(e.id,ye),Se=a,we=_,xe=L;I(ke=>[...ke,me]),h(""),j([]),f(!1),C(null),Y(),R.current&&(R.current.style.height=n?"40px":"72px"),requestAnimationFrame(()=>le()),P(!0),D(null);try{const ke=await g(ye);I(De=>De.filter(Ee=>Ee.id!==me.id)),ke&&typeof ke=="object"&&"id"in ke&&requestAnimationFrame(()=>le())}catch(ke){const De=ke instanceof Error?ke.message:"Failed to send room message";I(Ee=>Ee.map(Ye=>Ye.id===me.id?{...Ye,pendingStatus:"failed",error:De}:Ye)),h(Ee=>Ee.length===0?Se:Ee),j(Ee=>Ee.length===0?we:Ee),z(xe),D(De),requestAnimationFrame(()=>le())}finally{P(!1)}},[Ae,L,$,Y,n,a,q,H,A,N,g,r,z,le,_,e.id]),Je=S.useCallback(V=>{const Z=V.nativeEvent.isComposing||V.nativeEvent.keyCode===229;if(Ve){if(V.key==="ArrowDown"){V.preventDefault(),E(re=>(re+1)%Oe.length);return}if(V.key==="ArrowUp"){V.preventDefault(),E(re=>(re-1+Oe.length)%Oe.length);return}if(V.key==="Enter"&&!Z||V.key==="Tab"){V.preventDefault();const re=Oe[k]??Oe[0];re&&Me(re);return}if(V.key==="Escape"){V.preventDefault(),C(null),f(!1);return}}V.key==="Enter"&&!V.shiftKey&&!V.repeat&&!Z&&(V.preventDefault(),lt())},[Me,lt,k,Oe,Ve]);S.useEffect(()=>{h(""),j([]),f(!1),C(null),D(null),I([]),Y(),F(null),R.current&&(R.current.style.height=n?"40px":"72px")},[Y,n,e.id]);const Et=x.isError?x.error:w.isError?w.error:null,J=x.isPending||w.isPending,ue=S.useCallback((V,Z)=>{y.mutate({memberId:V,cancelQueued:Z},{onSuccess:()=>F(null)})},[y]);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[X&&t.jsx(Yf,{images:X.images,index:X.index,onClose:()=>K(null),onSelect:V=>K(Z=>Z&&{...Z,index:V})}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:ne,className:se("h-full overflow-y-auto scrollbar-app-thin bg-white",n?"px-3 py-3":"px-4 py-4"),children:t.jsxs("div",{ref:te,className:se(n?"space-y-2.5":"space-y-3",i&&"max-w-4xl mx-auto"),children:[Ie.length===0?t.jsxs("div",{className:"flex min-h-[180px] flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-neutral-200 bg-white text-neutral-500",children:[t.jsx(vs,{size:24,className:"text-neutral-400"}),t.jsx("span",{className:"text-sm",children:m("No room messages yet")})]}):Ie.map(V=>{if(V.kind==="pendingApproval"){const xe=V.request,ke=ie.get(xe.targetMemberId),De=x.isPending&&x.variables===xe.id,Ee=w.isPending&&w.variables===xe.id;return t.jsx(Jf,{request:xe,member:ke,onApprove:()=>x.mutate(xe.id),onReject:()=>w.mutate(xe.id),isActionPending:J,isApprovePending:De,isRejectPending:Ee},V.key)}const Z=V.message,re=Uf(Z,ie,at),ye=Z.senderType==="user"?m("你"):Z.senderType==="system"?m("System"):re?.name??m("Agent"),me=$f(Z,ie),Se=re?.providerId?pe.get(re.providerId)??null:null,we=Z.senderInvocationId?at.get(Z.senderInvocationId)?.workspaceId??void 0:void 0;return t.jsx(Zf,{message:Z,senderName:ye,senderMember:re,senderProvider:Se,memberById:ie,displayContent:me,onOpenImage:(xe,ke)=>K({images:xe,index:ke}),workingDir:l,onOpenWorkspaceFile:d,onOpenPreviewUrl:c,previewWorkspaceId:we},V.key)}),Et&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Zi(Et,m("Failed to update work request"))}),y.isError&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Zi(y.error,m("Failed to stop member work"))})]})}),!he&&t.jsxs("button",{type:"button",onClick:()=>le(),className:"absolute bottom-3 left-1/2 z-10 flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-neutral-200 bg-white/90 px-3 py-1.5 text-xs text-neutral-600 shadow-md backdrop-blur-sm hover:bg-white hover:text-neutral-900 transition-colors",children:[t.jsx(nr,{size:14}),t.jsx("span",{children:m("Back to bottom")})]})]}),t.jsx("div",{className:se("shrink-0 border-t border-transparent bg-white",n?"px-3 pb-2 pt-1.5":"px-6 pb-6 pt-2"),children:t.jsxs("div",{className:se(i&&"max-w-4xl mx-auto"),children:[t.jsx(Mf,{invocations:Pe,memberById:ie,workRequestById:_e,onViewInvocationSession:p,onStopMember:ue,isStopPending:y.isPending,stoppingMemberId:y.variables?.memberId??null,stopPromptInvocationId:B,onToggleStopConfirm:V=>F(Z=>Z===V?null:V)}),!r&&v,r?t.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-4 py-3 text-sm text-neutral-500",children:o??m("This project is read-only")}):t.jsxs("div",{className:"relative rounded-xl border border-neutral-200 bg-white shadow-sm transition-all duration-200 hover:shadow-md focus-within:border-neutral-300 focus-within:shadow-md",children:[Ve&&t.jsxs("div",{className:"absolute bottom-full left-3 z-20 mb-2 w-[min(24rem,calc(100vw-3rem))] overflow-hidden rounded-xl border border-neutral-200 bg-white shadow-xl",children:[t.jsx("div",{className:"border-b border-neutral-100 px-3 py-2 text-xs font-medium text-neutral-500",children:m(b?"Mention members":"Team members")}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:Oe.map((V,Z)=>{const re=_.includes(V.id),ye=Z===k;return t.jsxs("button",{type:"button",onMouseEnter:()=>E(Z),onMouseDown:me=>{me.preventDefault(),Me(V)},className:se("flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors",ye?"bg-neutral-100":"hover:bg-neutral-50"),children:[t.jsx($t,{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-neutral-900",children:V.name}),re&&t.jsx("span",{className:"rounded-full bg-neutral-900 px-1.5 py-0.5 text-[10px] font-medium text-white",children:m("selected")})]}),t.jsx("div",{className:"truncate text-xs text-neutral-500",children:[V.providerId,V.id.slice(0,8)].filter(Boolean).join(" · ")})]}),t.jsx(eo,{size:15,className:"text-neutral-400"})]},V.id)})})]}),$e.length>0&&t.jsx("div",{className:"flex flex-wrap items-center gap-1.5 border-b border-neutral-100 px-3 py-2",children:$e.map(V=>t.jsxs("span",{className:"inline-flex max-w-full items-center gap-1.5 rounded-full border border-neutral-200 bg-neutral-50 px-2 py-1 text-xs text-neutral-700",children:[t.jsxs("span",{className:"truncate font-medium",children:["@",V.name]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:V.id.slice(0,8)}),t.jsx("button",{type:"button",onClick:()=>Re(V.id),className:"shrink-0 rounded-full p-0.5 text-neutral-400 transition-colors hover:bg-neutral-200 hover:text-neutral-700",title:m("Remove mention"),"aria-label":`${m("Remove mention")} ${V.name}`,children:t.jsx(Yt,{size:12})})]},V.id))}),t.jsx(hn,{files:L,onRemove:U}),t.jsx("textarea",{ref:R,value:a,rows:n?1:void 0,onChange:ve,onKeyDown:Je,onPaste:ge,onClick:V=>Ze(a,V.currentTarget.selectionStart),onSelect:V=>Ze(a,V.currentTarget.selectionStart),placeholder:m("Message the team room..."),className:se("w-full resize-none border-none bg-transparent text-neutral-900 placeholder-neutral-400 focus:outline-none",n?"px-3 pb-1 pt-2.5 text-[15px] leading-5":"px-4 pb-2 pt-4 text-sm leading-relaxed"),style:n?{minHeight:40,maxHeight:140}:{minHeight:60,maxHeight:220}}),t.jsxs("div",{className:se("flex items-center justify-between",n?"px-2 pb-1.5 pt-0.5":"px-2 pb-2 pt-1"),children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{ref:M,type:"file",multiple:!0,className:"hidden",onChange:Fe}),t.jsx("button",{type:"button",onClick:()=>M.current?.click(),title:m("Upload file"),"aria-label":m("Upload file"),className:"rounded-lg p-2 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",children:t.jsx(yn,{size:18})}),t.jsx("button",{type:"button",onClick:()=>{f(V=>!V),C(null),requestAnimationFrame(()=>R.current?.focus())},disabled:$e.length===0&&Ae.length===0,title:m("Mention members"),"aria-label":m("Mention members"),className:se("rounded-lg transition-colors",n?"p-1.5":"p-2",u?"bg-neutral-100 text-neutral-700":"text-neutral-400 hover:bg-neutral-100 hover:text-neutral-600",$e.length===0&&Ae.length===0?"cursor-not-allowed opacity-50":""),children:t.jsx(eo,{size:n?15:18})}),$e.length>0&&t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[$e.length," ",m("selected")]})]}),t.jsx("button",{type:"button",onClick:()=>{lt()},disabled:r||A||N||!a.trim()&&!H,title:m(N?"Uploading...":A?"发送中...":"发送"),"aria-label":m(N?"Uploading...":A?"发送中...":"发送"),className:se("rounded-lg transition-all duration-200",n?"p-1.5":"p-2",(a.trim()||H)&&!r&&!A&&!N?"bg-neutral-900 text-white shadow-md hover:bg-black":"cursor-not-allowed bg-transparent text-neutral-300",A||N?"opacity-70":""),children:t.jsx(vn,{size:n?15:18})})]}),T&&t.jsx("div",{className:"border-t border-neutral-100 px-3 py-2 text-xs text-red-600",children:T})]})]})})]})}function em(e){return e?e.slice(0,8):""}function Co(e){const s=e?Date.parse(e):0;return Number.isNaN(s)?0:s}function On(e){return e?.workspaceKind===_t.MAIN_DIRECTORY}function Os(e){return e?On(e)?"Project directory":e.branchName:"—"}function ss(e){return e?.workingDir||e?.worktreePath||void 0}function Bn(e,s){if(!e?.length)return[];const r=new Map((s?.members??[]).map(p=>[p.id,p])),o=new Map(e.map(p=>[p.id,p])),g=s?.mainWorkspaceId??null;return e.map(p=>{const v=p.parentWorkspaceId?o.get(p.parentWorkspaceId):void 0,n=p.ownerMemberId?r.get(p.ownerMemberId):void 0,i=!!(g&&p.id===g),l=i?"main":p.parentWorkspaceId?"child":"root",d=n?.name??(p.ownerMemberId?`Member ${em(p.ownerMemberId)}`:void 0),c=On(p)?"Project directory":i?"Main workspace":l==="child"?d?`${d} workspace`:"Child workspace":s?"Root workspace":"Workspace";return{workspace:p,kind:l,roleLabel:i?"Main":l==="child"?"Child":"Root",displayName:c,ownerName:d,parentBranchName:v?Os(v):void 0,isMain:i}}).sort((p,v)=>{const n=l=>l.kind==="main"?0:l.kind==="child"?1:2,i=n(p)-n(v);return i!==0?i:Co(p.workspace.createdAt)-Co(v.workspace.createdAt)})}function Cl(e,s,r){if(e?.length)return r&&e.some(o=>o.id===r)?r:s?.mainWorkspaceId&&e.some(o=>o.id===s.mainWorkspaceId)?s.mainWorkspaceId:e.find(o=>o.status===At.ACTIVE)?.id??e[0]?.id}function kl(e,s){return!e||e.status!==At.ACTIVE||On(e)?!1:!s||e.parentWorkspaceId?!0:!!(s.mainWorkspaceId&&e.id===s.mainWorkspaceId)}function El(e,s,r){return e?.parentWorkspaceId?s?.find(g=>g.id===e.parentWorkspaceId)?.branchName??e.baseBranch??r:r}const Fn={readRoom:!1,postRoomMessage:!1,mentionMembers:!1,stopMemberWork:!1,markReadyForReview:!1,readFiles:!1,writeFiles:!1,runCommands:!1,readDiff:!1,mergeWorkspace:!1},tm=[{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:"合并工作区"}],jl=[{value:"none",label:"无"},{value:"shared",label:"共享"},{value:"dedicated",label:"独占"}],sm=[{value:"MENTION_ONLY",label:"仅提及"},{value:"USER_MESSAGES",label:"所有用户消息"}],Nl=[{value:"new_per_request",label:"每次新会话"},{value:"resume_last",label:"复用上次会话"}],rm=[{value:"own_only",label:"仅自己队列"},{value:"team_pending",label:"全队列待处理"}];function Gs(){return{name:"",aliasesText:"",providerId:"",rolePrompt:"",capabilities:{...Fn},workspacePolicy:"none",triggerPolicy:"MENTION_ONLY",sessionPolicy:"new_per_request",queueManagementPolicy:"own_only",avatar:""}}function ks(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...Fn,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function Ni(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...Fn,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function im(e){return Array.from(new Set(e.split(/[\n,]/).map(s=>s.trim()).filter(Boolean)))}function nm(e){return{name:e.name.trim(),aliases:im(e.aliasesText),providerId:e.providerId.trim(),rolePrompt:e.rolePrompt.trim(),capabilities:{...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar.trim()||null}}function ko(e,s){return e instanceof Error?e.message:s}function Eo(e){return e.membershipStatus!=="REMOVED"}function Ji(e){return e.status==="RUNNING"||e.status==="WAITING_ROOM_REPLY"||e.status==="SESSION_ENDED"||e.status==="QUEUED"}function jo(e){return Ji(e)?"bg-emerald-500":e.status==="FAILED"?"bg-red-500":"bg-neutral-300"}function No(e){return jl.find(s=>s.value===e)?.label??e}function om(e){return Nl.find(s=>s.value===e)?.label??e}function Wt({children:e}){return t.jsx("span",{className:"text-xs font-medium text-neutral-600",children:e})}function Ro({icon:e,title:s,description:r,action:o}){return t.jsxs("div",{className:"flex min-h-[18rem] flex-col items-center justify-center rounded-lg border border-dashed border-neutral-200 bg-white px-6 py-8 text-center",children:[t.jsx("div",{className:"mb-3 flex h-10 w-10 items-center justify-center rounded-full bg-neutral-100 text-neutral-500",children:e}),t.jsx("div",{className:"text-sm font-medium text-neutral-900",children:s}),r?t.jsx("div",{className:"mt-1 max-w-sm text-xs leading-relaxed text-neutral-500",children:r}):null,o?t.jsx("div",{className:"mt-4",children:o}):null]})}function am({isOpen:e,onClose:s,teamRun:r}){const{t:o}=ce(),{data:g=[]}=Qc(),{data:p=[]}=Bs(),v=Zc(r.id),n=Jc(r.id),i=ed(r.id),l=S.useRef(!1),[d,c]=S.useState("edit"),[m,x]=S.useState(null),[w,y]=S.useState(""),[a,h]=S.useState(Gs()),[u,f]=S.useState(null),[b,C]=S.useState(null),k=r.members??[],E=S.useMemo(()=>k.filter(Eo),[k]),_=S.useMemo(()=>b&&Eo(b)&&!E.some(q=>q.id===b.id)?[...E,b]:E,[b,E]),j=m?E.find(q=>q.id===m)??null:null,A=b?.id===m?b:j,P=w?g.find(q=>q.id===w)??null:null,T=v.isPending||n.isPending||i.isPending,D=_.filter(Ji).length,W=S.useMemo(()=>{const q=p.map(({provider:N,availability:H})=>({value:N.id,label:N.name+(H.type==="NOT_FOUND"?o(" (不可用)"):""),icon:t.jsx(si,{agentType:N.agentType,className:"size-4"}),disabled:H.type==="NOT_FOUND"}));return a.providerId&&!q.some(N=>N.value===a.providerId)&&q.unshift({value:a.providerId,label:`${a.providerId}${o(" (不可用)")}`,disabled:!0}),q},[a.providerId,p,o]);S.useEffect(()=>{if(!e){l.current=!1,C(null);return}if(l.current)return;l.current=!0;const q=_[0]??null;c(q?"edit":"add-preset"),x(q?.id??null),y(""),h(q?ks(q):Gs()),f(null)},[_,e]),S.useEffect(()=>{b&&E.some(q=>q.id===b.id)&&C(null)},[b,E]),S.useEffect(()=>{d==="add-preset"&&P&&h(Ni(P))},[d,P]);const I=(q,N)=>{h(H=>({...H,[q]:N}))},B=(q,N)=>{h(H=>({...H,capabilities:{...H.capabilities,[q]:N}}))},F=q=>{c("edit"),x(q.id),y(""),h(ks(q))},R=()=>{c("add-preset"),x(null);const q=P??g[0]??null;y(q?.id??""),h(q?Ni(q):Gs())},M=()=>{c("add-custom"),x(null),y(""),h(Gs())},L=!!(a.name.trim()&&a.providerId.trim()&&a.rolePrompt.trim()),O=d==="add-preset"?!!w:d==="edit"?!!(A&&L):L,U=async()=>{try{if(d==="add-preset"){if(!w)return;const N=await v.mutateAsync({memberPresetId:w});rt.success(o("Member added")),C(N),c("edit"),x(N.id),y(""),h(ks(N));return}const q=nm(a);if(!q.name||!q.providerId||!q.rolePrompt){rt.error(o("Name, provider, and role prompt are required"));return}if(d==="add-custom"){const N=await v.mutateAsync({member:q});rt.success(o("Member added")),C(N),c("edit"),x(N.id),h(ks(N));return}if(A){const N=await n.mutateAsync({memberId:A.id,data:q});rt.success(o("Member updated")),C(H=>H?.id===N.id?N:H),x(N.id),h(ks(N))}}catch(q){rt.error(ko(q,o("Failed to save member")))}},Y=async()=>{if(u)try{if(await i.mutateAsync({memberId:u.id,stopActive:!0,cancelQueued:!0}),m===u.id){const q=_.find(N=>N.id!==u.id)??null;x(q?.id??null),c(q?"edit":"add-preset"),h(q?ks(q):Gs())}C(q=>q?.id===u.id?null:q),f(null),rt.success(o("Member removed"))}catch(q){rt.error(ko(q,o("Failed to remove member")))}},z=()=>t.jsxs("div",{className:"flex min-h-0 flex-col lg:flex-1",children:[t.jsx("div",{className:"border-b border-neutral-100 px-5 py-4",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[t.jsx(Tr,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o("Add member from preset")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:o("Choose a saved preset to add a ready-to-run member snapshot.")})]}),t.jsxs(Te,{type:"button",variant:"outline",size:"sm",onClick:M,disabled:T,children:[t.jsx(no,{size:13}),o("Custom member")]})]})}),t.jsx("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:g.length===0?t.jsx(Ro,{icon:t.jsx(Tr,{size:18}),title:o("No member presets"),description:o("Create a custom member for this TeamRun, or add presets from Team Collaboration Settings."),action:t.jsxs(Te,{type:"button",variant:"outline",size:"sm",onClick:M,disabled:T,children:[t.jsx(ts,{size:13}),o("Custom member")]})}):t.jsx("div",{className:"grid grid-cols-1 gap-2 xl:grid-cols-2",children:g.map(q=>{const N=w===q.id;return t.jsxs("button",{type:"button",onClick:()=>{y(q.id),h(Ni(q))},className:se("flex min-h-[4.25rem] items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors",N?"border-neutral-900 bg-neutral-50 shadow-sm":"border-neutral-200 bg-white hover:border-neutral-300 hover:bg-neutral-50"),children:[t.jsx($t,{name:q.name,avatar:q.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-medium text-neutral-900",children:q.name}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:q.providerId}),t.jsxs("span",{className:"mt-1 block truncate text-[10px] text-neutral-400",children:[o(No(q.workspacePolicy))," · ",o(om(q.sessionPolicy))]})]}),N?t.jsx(Vt,{size:16,className:"shrink-0 text-neutral-900"}):null]},q.id)})})})]}),$=()=>{const q=d==="edit";return q&&!A?t.jsx("div",{className:"p-5",children:t.jsx(Ro,{icon:t.jsx(vs,{size:18}),title:o("Select a member"),description:o("Choose a member on the left to edit its future TeamRun configuration."),action:t.jsxs(Te,{type:"button",variant:"outline",size:"sm",onClick:R,disabled:T,children:[t.jsx(ts,{size:13}),o("Add member")]})})}):t.jsxs("div",{className:"flex min-h-0 flex-col lg:flex-1",children:[t.jsx("div",{className:"border-b border-neutral-100 px-5 py-4",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[q?t.jsx(Xa,{size:15,className:"text-neutral-500"}):t.jsx(ts,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o(q?"Edit member":"Custom member")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:o(q?"Provider, role, workspace, and session changes apply to future work only.":"Create a one-off member snapshot for this TeamRun.")})]}),q&&A?t.jsxs(Te,{type:"button",variant:"outline",size:"sm",onClick:()=>f(A),disabled:T,className:"border-red-200 text-red-700 hover:bg-red-50 hover:text-red-800",children:[t.jsx(Sn,{size:13}),o("Remove")]}):t.jsxs(Te,{type:"button",variant:"outline",size:"sm",onClick:R,disabled:T,children:[t.jsx(Tr,{size:13}),o("Use preset")]})]})}),t.jsxs("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:[q&&A?t.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg border border-neutral-200 bg-neutral-50 px-3 py-2.5",children:[t.jsx($t,{name:A.name,avatar:A.avatar,className:"h-9 w-9 text-xs"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:se("h-2 w-2 shrink-0 rounded-full",jo(A))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:A.name})]}),t.jsxs("div",{className:"mt-0.5 truncate text-xs text-neutral-500",children:[A.providerId," · ",o(No(A.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(Wt,{children:o("Name")}),t.jsx("input",{value:a.name,onChange:N=>I("name",N.target.value),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Wt,{children:o("Aliases")}),t.jsx("input",{value:a.aliasesText,onChange:N=>I("aliasesText",N.target.value),placeholder:o("Comma separated"),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Wt,{children:o("Provider")}),t.jsx(es,{value:a.providerId,onChange:N=>I("providerId",N),options:W})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Wt,{children:o("Avatar")}),t.jsx("input",{value:a.avatar,onChange:N=>I("avatar",N.target.value),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]})]}),t.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Wt,{children:o("Workspace policy")}),t.jsx(es,{value:a.workspacePolicy,onChange:N=>I("workspacePolicy",N),options:jl.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Wt,{children:o("Trigger policy")}),t.jsx(es,{value:a.triggerPolicy,onChange:N=>I("triggerPolicy",N),options:sm.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Wt,{children:o("Session policy")}),t.jsx(es,{value:a.sessionPolicy,onChange:N=>I("sessionPolicy",N),options:Nl.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Wt,{children:o("Queue policy")}),t.jsx(es,{value:a.queueManagementPolicy,onChange:N=>I("queueManagementPolicy",N),options:rm.map(N=>({value:N.value,label:o(N.label)}))})]})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Wt,{children:o("Role prompt")}),t.jsx("textarea",{value:a.rolePrompt,onChange:N=>I("rolePrompt",N.target.value),rows:7,className:"w-full resize-y rounded-lg border border-neutral-200 px-3 py-2 text-sm leading-relaxed outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Wt,{children:o("Capabilities")}),t.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-3",children:tm.map(N=>t.jsxs("label",{className:"flex min-h-9 items-center gap-2 rounded-md border border-neutral-200 bg-white px-2.5 py-2 text-xs text-neutral-700",children:[t.jsx("input",{type:"checkbox",checked:!!a.capabilities[N.key],onChange:H=>B(N.key,H.target.checked)}),t.jsx("span",{className:"min-w-0 truncate",children:o(N.label)})]},N.key))})]})]})]})]})};return t.jsxs(t.Fragment,{children:[t.jsx(ns,{isOpen:e,onClose:T?()=>{}:s,title:o("Manage Team Members"),className:"max-w-6xl",action:t.jsxs(t.Fragment,{children:[t.jsx(Te,{type:"button",variant:"outline",onClick:s,disabled:T,children:o("Close")}),t.jsx(Te,{type:"button",onClick:U,disabled:T||!O,children:o(T?"Processing...":d==="edit"?"Save member":"Add member")})]}),children:t.jsxs("div",{className:"grid min-h-0 grid-cols-1 overflow-visible rounded-lg border border-neutral-200 bg-white lg:h-[min(42rem,calc(100vh-13rem))] lg:min-h-[34rem] lg:grid-cols-[20rem_minmax(0,1fr)] lg:overflow-hidden",children:[t.jsxs("aside",{className:"flex min-h-0 flex-col border-b border-neutral-200 bg-neutral-50/70 lg:border-b-0 lg:border-r",children:[t.jsx("div",{className:"border-b border-neutral-200 px-4 py-4",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[t.jsx(vs,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o("Members")})]}),t.jsxs("div",{className:"mt-1 text-xs text-neutral-500",children:[_.length," ",o("active")," · ",D," ",o("working")]})]}),t.jsx(Te,{type:"button",size:"icon-sm",variant:"outline",onClick:R,disabled:T,title:o("Add member"),children:t.jsx(ts,{size:14})})]})}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-2 lg:min-h-0 lg:max-h-none lg:flex-1",children:_.length===0?t.jsx("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-3 py-5 text-center text-xs text-neutral-400",children:o("No active members")}):t.jsx("div",{className:"space-y-1",children:_.map(q=>{const N=d==="edit"&&m===q.id;return t.jsxs("button",{type:"button",onClick:()=>F(q),className:se("group flex w-full items-center gap-2 rounded-lg border px-2.5 py-2 text-left transition-colors",N?"border-neutral-300 bg-white shadow-sm":"border-transparent hover:border-neutral-200 hover:bg-white"),children:[t.jsx($t,{name:q.name,avatar:q.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:se("h-1.5 w-1.5 shrink-0 rounded-full",jo(q))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:q.name})]}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:q.providerId})]}),t.jsx(lu,{size:13,className:se("shrink-0 text-neutral-300 transition-opacity",N?"opacity-100":"opacity-0 group-hover:opacity-100")})]},q.id)})})}),t.jsx("div",{className:"border-t border-neutral-200 p-2",children:t.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[t.jsxs("button",{type:"button",onClick:R,disabled:T,className:se("inline-flex h-8 items-center justify-center gap-1.5 rounded-md text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",d==="add-preset"?"bg-neutral-900 text-white":"bg-white text-neutral-600 hover:bg-neutral-100"),children:[t.jsx(Tr,{size:12}),o("Preset")]}),t.jsxs("button",{type:"button",onClick:M,disabled:T,className:se("inline-flex h-8 items-center justify-center gap-1.5 rounded-md text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",d==="add-custom"?"bg-neutral-900 text-white":"bg-white text-neutral-600 hover:bg-neutral-100"),children:[t.jsx(no,{size:12}),o("Custom")]})]})})]}),t.jsx("section",{className:"flex min-h-0 min-w-0 flex-col",children:d==="add-preset"?z():$()})]})}),t.jsx(mn,{isOpen:!!u,onClose:()=>f(null),onConfirm:Y,title:o("Remove member"),variant:"danger",isLoading:i.isPending,confirmText:o("Remove"),description:t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{children:u?o("Remove this member from future TeamRun work?"):""}),u&&Ji(u)?t.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-left text-red-700",children:[t.jsx(ur,{size:15,className:"mt-0.5 shrink-0"}),t.jsx("span",{className:"text-sm font-medium",children:o("确认后会停止当前工作并取消队列")})]}):null]})})]})}const lm=[],cm=[],dm=[],um=240;function hm(e){switch(e){case"RUNNING":return"running";case"WAITING":case"WAITING_ROOM_REPLY":return"waiting room reply";case"QUEUED":return"queued";case"SESSION_ENDED":return"session ended";case"PENDING_APPROVAL":return"pending approval";case"REMOVED":return"removed";default:return"idle"}}const Ao={running:0,"waiting room reply":1,queued:2,"session ended":3,"pending approval":4,idle:5,removed:6};function Ri(e){if(!e)return"";const s=new Date(e);return Number.isNaN(s.getTime())?"":s.toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function To(e,s){return e instanceof Error?e.message:s}function fm(e,s=um){const r=(e??"").replace(/\s+/g," ").trim();return r.length<=s?r:`${r.slice(0,s-3).trimEnd()}...`}function Mr(e){return e?e.instructionPreview??fm(e.instruction):""}function mm(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 pm(e){switch(e){case"running":return"border-emerald-200 bg-emerald-50 text-emerald-700";case"waiting room reply":return"border-amber-200 bg-amber-50 text-amber-700";case"queued":case"session ended":return"border-blue-200 bg-blue-50 text-blue-700";case"pending approval":return"border-neutral-200 bg-neutral-50 text-neutral-600";case"removed":return"border-neutral-200 bg-neutral-50 text-neutral-400";case"idle":return"border-neutral-200 bg-white text-neutral-500"}}function gm(e){switch(e){case"running":return"bg-emerald-500";case"waiting room reply":return"bg-amber-500";case"queued":case"session ended":return"bg-blue-500";case"pending approval":return"bg-neutral-400";case"removed":return"bg-neutral-300";case"idle":return"bg-neutral-300"}}function vm(e){switch(e){case"user":return"User";case"agent":return"Agent";case"system":return"System"}}function xm(e){switch(e){case"RUNNING":return"border-emerald-200 bg-emerald-50 text-emerald-700";case"WAITING_ROOM_REPLY":return"border-amber-200 bg-amber-50 text-amber-700";case"QUEUED":case"SESSION_ENDED":return"border-blue-200 bg-blue-50 text-blue-700";case"COMPLETED":return"border-neutral-200 bg-neutral-50 text-neutral-700";case"FAILED":return"border-red-200 bg-red-50 text-red-700";case"CANCELLED":return"border-neutral-200 bg-white text-neutral-500"}}function _m(e){switch(e){case At.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case At.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case At.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case At.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function bm(e){switch(e){case"Main":return"border-indigo-200 bg-indigo-50 text-indigo-700";case"Child":return"border-cyan-200 bg-cyan-50 text-cyan-700";default:return"border-neutral-200 bg-neutral-50 text-neutral-600"}}function ym(e){return[...e].sort((s,r)=>Date.parse(r.updatedAt??r.createdAt??"")-Date.parse(s.updatedAt??s.createdAt??""))}function Sm(e,s){return s.find(r=>r.memberId===e.id&&di.has(r.status))}function Rl({teamRun:e,workspaces:s,selectedWorkspaceId:r,onSelectWorkspace:o,onViewInvocationSession:g}){const{t:p}=ce(),v=va(e.id),n=xa(e.id),i=_a(e.id),[l,d]=S.useState(null),[c,m]=S.useState(null),[x,w]=S.useState(!1),[y,a]=S.useState(!1),h=e.members??lm,u=S.useMemo(()=>h.filter(I=>I.membershipStatus!=="REMOVED"),[h]),f=e.workRequests??cm,b=e.invocations??dm,C=S.useMemo(()=>Bn(s,e),[e,s]),k=S.useMemo(()=>new Map(f.map(I=>[I.id,I])),[f]),E=S.useMemo(()=>[...f].filter(I=>I.status==="PENDING_APPROVAL").sort((I,B)=>Date.parse(B.updatedAt??B.createdAt??"")-Date.parse(I.updatedAt??I.createdAt??"")),[f]),_=S.useMemo(()=>[...f].filter(I=>I.status==="QUEUED").sort((I,B)=>Date.parse(B.updatedAt??B.createdAt??"")-Date.parse(I.updatedAt??I.createdAt??"")),[f]),j=S.useMemo(()=>[...h].map(I=>({member:I,status:hm(I.status)})).sort((I,B)=>Ao[I.status]-Ao[B.status]),[h]),A=v.isError?v.error:n.isError?n.error:null,P=v.isPending||n.isPending,T=C.find(I=>I.workspace.id===r),D=e.messages??[],W=j.filter(({status:I})=>I==="running"||I==="waiting room reply").length;return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[t.jsx(am,{isOpen:y,onClose:()=>a(!1),teamRun:e}),t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-neutral-200 px-4 py-3 shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(Ps,{size:14,className:"text-neutral-500 shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:p("Team Status")})]}),t.jsxs("div",{className:"flex items-center gap-1.5 rounded-full border border-neutral-200 bg-neutral-50 px-2 py-0.5 text-[10px] font-medium text-neutral-500",children:[t.jsx("span",{children:p("Team mode")}),t.jsx("span",{className:"text-neutral-700",children:e.mode})]})]}),t.jsxs("div",{className:"flex items-center gap-3 border-b border-neutral-100 px-4 py-1.5 shrink-0 text-[10px] text-neutral-500",children:[t.jsxs("span",{className:"inline-flex items-center gap-1",title:p("Messages"),children:[t.jsx(ti,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:D.length})]}),t.jsxs("span",{className:"inline-flex items-center gap-1",title:p("Members"),children:[t.jsx(vs,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:W>0?`${W}/${u.length}`:u.length}),W>0&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500"})]}),_.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1",title:p("Queue"),children:[t.jsx(Rs,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:_.length})]}),E.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-600",title:p("Pending approval"),children:[t.jsx(Rs,{size:11}),t.jsx("span",{className:"tabular-nums",children:E.length})]})]}),t.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-app-thin px-4 py-3 space-y-3",children:[E.length>0&&t.jsxs("section",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-amber-600",children:[t.jsx(Rs,{size:13}),t.jsx("span",{children:p("Pending approval")}),t.jsx("span",{className:"ml-auto rounded-full bg-amber-100 px-1.5 py-0.5 text-[10px] font-semibold text-amber-700",children:E.length})]}),t.jsx("div",{className:"space-y-1.5",children:E.map(I=>{const B=h.find(M=>M.id===I.targetMemberId),F=v.isPending&&v.variables===I.id,R=n.isPending&&n.variables===I.id;return t.jsxs("div",{className:"rounded-md border border-amber-200 bg-amber-50/50 px-3 py-2",children:[t.jsx("div",{className:"flex items-start justify-between gap-2",children:t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx($t,{name:B?.name??"Agent",avatar:B?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:B?.name??I.targetMemberId})]}),t.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-neutral-600 line-clamp-2",children:Mr(I)})]})}),t.jsxs("div",{className:"mt-1.5 flex items-center gap-x-2 text-[10px] text-neutral-400",children:[t.jsx("span",{children:p(vm(I.requesterType))}),t.jsx("span",{children:Ri(I.createdAt)})]}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>v.mutate(I.id),disabled:P,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-emerald-200 bg-emerald-50 px-2 text-[11px] font-medium text-emerald-700 transition-colors hover:bg-emerald-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Vt,{size:11}),t.jsx("span",{className:"truncate",children:p(F?"Approving":"Approve")})]}),t.jsxs("button",{type:"button",onClick:()=>n.mutate(I.id),disabled:P,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-neutral-200 bg-neutral-50 px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Yt,{size:11}),t.jsx("span",{className:"truncate",children:p(R?"Rejecting":"Reject")})]})]})]},I.id)})}),A&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:To(A,p("Failed to update work request"))})]}),t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[t.jsx(vs,{size:13}),t.jsx("span",{children:p("Members")}),t.jsx("span",{className:"ml-auto text-[10px] font-normal text-neutral-400",children:u.length}),t.jsx("button",{type:"button",onClick:()=>a(!0),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700",title:p("Manage Team Members"),"aria-label":p("Manage Team Members"),children:t.jsx(Xa,{size:13})})]}),h.length===0?t.jsx("div",{className:"py-3 text-center text-xs text-neutral-400",children:p("No members")}):t.jsx("div",{className:"space-y-px rounded-md border border-neutral-200 overflow-hidden",children:j.map(({member:I,status:B})=>{const F=Sm(I,b),R=ym(b.filter($=>$.memberId===I.id)),M=F?k.get(F.workRequestId):void 0,L=c===I.id,O=B==="running"||B==="waiting room reply",U=O&&!!F,Y=l===I.id,z=i.isPending&&i.variables?.memberId===I.id;return t.jsxs("div",{className:se("bg-white",L&&"bg-neutral-50/50"),children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[t.jsx($t,{name:I.name,avatar:I.avatar,className:"h-6 w-6 text-[10px] shrink-0"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:se("h-1.5 w-1.5 shrink-0 rounded-full",gm(B))}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:I.name}),t.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",pm(B)),children:p(mm(B))})]}),O&&M?.instruction&&t.jsx("div",{className:"mt-0.5 truncate pl-3 text-[10px] text-neutral-500",children:Mr(M)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[U&&t.jsx("button",{type:"button",onClick:()=>d(Y?null:I.id),disabled:i.isPending,className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-red-50 hover:text-red-600 disabled:cursor-not-allowed disabled:opacity-50",title:p("Stop"),"aria-label":p("Stop"),children:t.jsx(Ds,{size:12})}),F?.sessionId&&g&&t.jsx("button",{type:"button",onClick:()=>g(F.sessionId),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700",title:p("View log"),"aria-label":p("View log"),children:t.jsx(qi,{size:12})}),t.jsx("button",{type:"button",onClick:()=>m(L?null:I.id),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",title:p("Details"),"aria-label":p("Details"),"aria-expanded":L,children:L?t.jsx(wt,{size:13}):t.jsx(Mt,{size:13})})]})]}),U&&Y&&t.jsxs("div",{className:"mx-3 mb-2 rounded-md border border-neutral-200 bg-neutral-50 p-2",children:[t.jsx("div",{className:"mb-1.5 text-[11px] text-neutral-600",children:p("Stop running work?")}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{i.mutate({memberId:I.id,cancelQueued:!1},{onSuccess:()=>d(null)})},disabled:i.isPending,className:"inline-flex h-6 items-center gap-1 rounded-md border border-neutral-200 bg-white px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Ds,{size:10}),t.jsx("span",{children:z&&i.variables?.cancelQueued===!1?p("Stopping"):p("Stop only")})]}),t.jsxs("button",{type:"button",onClick:()=>{i.mutate({memberId:I.id,cancelQueued:!0},{onSuccess:()=>d(null)})},disabled:i.isPending,className:"inline-flex h-6 items-center gap-1 rounded-md border border-red-200 bg-red-50 px-2 text-[11px] font-medium text-red-700 transition-colors hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(qa,{size:10}),t.jsx("span",{children:z&&i.variables?.cancelQueued===!0?p("Stopping"):p("Stop + clear queue")})]})]})]}),L&&t.jsxs("div",{className:"border-t border-neutral-100 px-3 py-2",children:[t.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-1.5 text-[10px] text-neutral-400",children:[t.jsx("span",{children:I.providerId}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:I.workspacePolicy}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:I.sessionPolicy==="resume_last"?p("Resume last session"):p("New session per request")})]}),t.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-[11px] font-medium text-neutral-500",children:p("Invocation history")}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:R.length})]}),R.length===0?t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:p("No invocations yet")}):t.jsx("div",{className:"space-y-1",children:R.map($=>{const q=k.get($.workRequestId),N=!!($.sessionId&&g);return t.jsx("div",{className:"rounded-md border border-neutral-100 bg-white px-2.5 py-1.5",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:se("rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",xm($.status)),children:$.status}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:Ri($.updatedAt??$.createdAt)})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:Mr(q)||$.workRequestId})]}),N&&t.jsxs("button",{type:"button",onClick:()=>$.sessionId&&g?.($.sessionId),className:"inline-flex h-5 shrink-0 items-center gap-1 rounded border border-neutral-200 bg-white px-1.5 text-[10px] font-medium text-neutral-600 transition-colors hover:bg-neutral-100",title:p("View log"),"aria-label":p("View log"),children:[t.jsx(qi,{size:10}),t.jsx("span",{children:p("Log")})]})]})},$.id)})})]}),j[j.length-1]?.member.id!==I.id&&!L&&t.jsx("div",{className:"mx-3 border-b border-neutral-100"})]},I.id)})}),i.isError&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:To(i.error,p("Failed to stop member work"))})]}),_.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[t.jsx(Rs,{size:13}),t.jsx("span",{children:p("Queue")}),t.jsx("span",{className:"ml-auto rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-semibold text-neutral-600",children:_.length})]}),t.jsx("div",{className:"space-y-1",children:_.map(I=>{const B=h.find(F=>F.id===I.targetMemberId);return t.jsx("div",{className:"rounded-md border border-neutral-200 bg-white px-3 py-2",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx($t,{name:B?.name??"Agent",avatar:B?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:B?.name??I.targetMemberId})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:Mr(I)})]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:Ri(I.createdAt)})]})},I.id)})})]}),C.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>w(I=>!I),className:"flex w-full items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500 transition-colors hover:text-neutral-700","aria-expanded":x,"aria-label":p("Workspaces"),children:[t.jsx(Ps,{size:13}),t.jsx("span",{children:p("Workspaces")}),t.jsxs("span",{className:"ml-auto flex items-center gap-1.5",children:[T&&t.jsx("span",{className:"max-w-[120px] truncate font-mono text-[10px] font-normal text-neutral-400",children:Os(T.workspace)}),t.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-semibold text-neutral-600",children:C.length}),x?t.jsx(wt,{size:13,className:"text-neutral-400"}):t.jsx(Mt,{size:13,className:"text-neutral-400"})]})]}),x&&t.jsx("div",{className:"space-y-1.5",children:C.map(I=>{const B=r===I.workspace.id;return t.jsx("div",{className:se("rounded-md border bg-white px-3 py-2",B?"border-neutral-400 shadow-sm":"border-neutral-200"),children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:p(I.displayName)}),t.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",bm(I.roleLabel)),children:p(I.roleLabel)}),t.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",_m(I.workspace.status)),children:I.workspace.status})]}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] text-neutral-500",children:Os(I.workspace)}),t.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[I.ownerName&&t.jsxs("span",{children:[p("Owner"),": ",I.ownerName]}),I.parentBranchName&&t.jsxs("span",{children:[p("Parent"),": ",I.parentBranchName]})]})]}),t.jsxs("button",{type:"button",onClick:()=>o?.(I.workspace.id),disabled:!o||B,className:"inline-flex h-6 shrink-0 items-center gap-1 rounded-md border border-neutral-200 bg-neutral-50 px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",title:p("View workspace"),children:[B?t.jsx(Vt,{size:11}):t.jsx(Da,{size:11}),t.jsx("span",{children:p(B?"Selected":"Select")})]})]})},I.workspace.id)})})]}),E.length===0&&_.length===0&&j.every(({status:I})=>I==="idle")&&t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:p("All members idle")})]})]})}var Ai={exports:{}},Mo;function wm(){return Mo||(Mo=1,(function(e,s){(function(r,o){e.exports=o()})(self,(()=>(()=>{var r={4567:function(v,n,i){var l=this&&this.__decorate||function(f,b,C,k){var E,_=arguments.length,j=_<3?b:k===null?k=Object.getOwnPropertyDescriptor(b,C):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(f,b,C,k);else for(var A=f.length-1;A>=0;A--)(E=f[A])&&(j=(_<3?E(j):_>3?E(b,C,j):E(b,C))||j);return _>3&&j&&Object.defineProperty(b,C,j),j},d=this&&this.__param||function(f,b){return function(C,k){b(C,k,f)}};Object.defineProperty(n,"__esModule",{value:!0}),n.AccessibilityManager=void 0;const c=i(9042),m=i(6114),x=i(9924),w=i(844),y=i(5596),a=i(4725),h=i(3656);let u=n.AccessibilityManager=class extends w.Disposable{constructor(f,b){super(),this._terminal=f,this._renderService=b,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=document.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=document.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let C=0;C<this._terminal.rows;C++)this._rowElements[C]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[C]);if(this._topBoundaryFocusListener=C=>this._handleBoundaryFocus(C,0),this._bottomBoundaryFocusListener=C=>this._handleBoundaryFocus(C,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=document.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new x.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((C=>this._handleResize(C.rows)))),this.register(this._terminal.onRender((C=>this._refreshRows(C.start,C.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((C=>this._handleChar(C)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
20
- `)))),this.register(this._terminal.onA11yTab((C=>this._handleTab(C)))),this.register(this._terminal.onKey((C=>this._handleKey(C.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this._screenDprMonitor=new y.ScreenDprMonitor(window),this.register(this._screenDprMonitor),this._screenDprMonitor.setListener((()=>this._refreshRowsDimensions())),this.register((0,h.addDisposableDomListener)(window,"resize",(()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,w.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(f){for(let b=0;b<f;b++)this._handleChar(" ")}_handleChar(f){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==f&&(this._charsToAnnounce+=f):this._charsToAnnounce+=f,f===`
21
- `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=c.tooMuchOutput)),m.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,m.isMac&&this._liveRegion.remove()}_handleKey(f){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(f)||this._charsToConsume.push(f)}_refreshRows(f,b){this._liveRegionDebouncer.refresh(f,b,this._terminal.rows)}_renderRows(f,b){const C=this._terminal.buffer,k=C.lines.length.toString();for(let E=f;E<=b;E++){const _=C.translateBufferLineToString(C.ydisp+E,!0),j=(C.ydisp+E+1).toString(),A=this._rowElements[E];A&&(_.length===0?A.innerText=" ":A.textContent=_,A.setAttribute("aria-posinset",j),A.setAttribute("aria-setsize",k))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(f,b){const C=f.target,k=this._rowElements[b===0?1:this._rowElements.length-2];if(C.getAttribute("aria-posinset")===(b===0?"1":`${this._terminal.buffer.lines.length}`)||f.relatedTarget!==k)return;let E,_;if(b===0?(E=C,_=this._rowElements.pop(),this._rowContainer.removeChild(_)):(E=this._rowElements.shift(),_=C,this._rowContainer.removeChild(E)),E.removeEventListener("focus",this._topBoundaryFocusListener),_.removeEventListener("focus",this._bottomBoundaryFocusListener),b===0){const j=this._createAccessibilityTreeNode();this._rowElements.unshift(j),this._rowContainer.insertAdjacentElement("afterbegin",j)}else{const j=this._createAccessibilityTreeNode();this._rowElements.push(j),this._rowContainer.appendChild(j)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(b===0?-1:1),this._rowElements[b===0?1:this._rowElements.length-2].focus(),f.preventDefault(),f.stopImmediatePropagation()}_handleResize(f){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let b=this._rowContainer.children.length;b<this._terminal.rows;b++)this._rowElements[b]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[b]);for(;this._rowElements.length>f;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const f=document.createElement("div");return f.setAttribute("role","listitem"),f.tabIndex=-1,this._refreshRowDimensions(f),f}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let f=0;f<this._terminal.rows;f++)this._refreshRowDimensions(this._rowElements[f])}}_refreshRowDimensions(f){f.style.height=`${this._renderService.dimensions.css.cell.height}px`}};n.AccessibilityManager=u=l([d(1,a.IRenderService)],u)},3614:(v,n)=>{function i(m){return m.replace(/\r?\n/g,"\r")}function l(m,x){return x?"\x1B[200~"+m+"\x1B[201~":m}function d(m,x,w,y){m=l(m=i(m),w.decPrivateModes.bracketedPasteMode&&y.rawOptions.ignoreBracketedPasteMode!==!0),w.triggerDataEvent(m,!0),x.value=""}function c(m,x,w){const y=w.getBoundingClientRect(),a=m.clientX-y.left-10,h=m.clientY-y.top-10;x.style.width="20px",x.style.height="20px",x.style.left=`${a}px`,x.style.top=`${h}px`,x.style.zIndex="1000",x.focus()}Object.defineProperty(n,"__esModule",{value:!0}),n.rightClickHandler=n.moveTextAreaUnderMouseCursor=n.paste=n.handlePasteEvent=n.copyHandler=n.bracketTextForPaste=n.prepareTextForTerminal=void 0,n.prepareTextForTerminal=i,n.bracketTextForPaste=l,n.copyHandler=function(m,x){m.clipboardData&&m.clipboardData.setData("text/plain",x.selectionText),m.preventDefault()},n.handlePasteEvent=function(m,x,w,y){m.stopPropagation(),m.clipboardData&&d(m.clipboardData.getData("text/plain"),x,w,y)},n.paste=d,n.moveTextAreaUnderMouseCursor=c,n.rightClickHandler=function(m,x,w,y,a){c(m,x,w),a&&y.rightClickSelect(m),x.value=y.selectionText,x.select()}},7239:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ColorContrastCache=void 0;const l=i(1505);n.ColorContrastCache=class{constructor(){this._color=new l.TwoKeyMap,this._css=new l.TwoKeyMap}setCss(d,c,m){this._css.set(d,c,m)}getCss(d,c){return this._css.get(d,c)}setColor(d,c,m){this._color.set(d,c,m)}getColor(d,c){return this._color.get(d,c)}clear(){this._color.clear(),this._css.clear()}}},3656:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.addDisposableDomListener=void 0,n.addDisposableDomListener=function(i,l,d,c){i.addEventListener(l,d,c);let m=!1;return{dispose:()=>{m||(m=!0,i.removeEventListener(l,d,c))}}}},6465:function(v,n,i){var l=this&&this.__decorate||function(a,h,u,f){var b,C=arguments.length,k=C<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,u):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,u,f);else for(var E=a.length-1;E>=0;E--)(b=a[E])&&(k=(C<3?b(k):C>3?b(h,u,k):b(h,u))||k);return C>3&&k&&Object.defineProperty(h,u,k),k},d=this&&this.__param||function(a,h){return function(u,f){h(u,f,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.Linkifier2=void 0;const c=i(3656),m=i(8460),x=i(844),w=i(2585);let y=n.Linkifier2=class extends x.Disposable{get currentLink(){return this._currentLink}constructor(a){super(),this._bufferService=a,this._linkProviders=[],this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new m.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new m.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,x.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,x.toDisposable)((()=>{this._lastMouseEvent=void 0}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0})))}registerLinkProvider(a){return this._linkProviders.push(a),{dispose:()=>{const h=this._linkProviders.indexOf(a);h!==-1&&this._linkProviders.splice(h,1)}}}attachToDom(a,h,u){this._element=a,this._mouseService=h,this._renderService=u,this.register((0,c.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,c.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,c.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,c.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(a){if(this._lastMouseEvent=a,!this._element||!this._mouseService)return;const h=this._positionFromMouseEvent(a,this._element,this._mouseService);if(!h)return;this._isMouseOut=!1;const u=a.composedPath();for(let f=0;f<u.length;f++){const b=u[f];if(b.classList.contains("xterm"))break;if(b.classList.contains("xterm-hover"))return}this._lastBufferCell&&h.x===this._lastBufferCell.x&&h.y===this._lastBufferCell.y||(this._handleHover(h),this._lastBufferCell=h)}_handleHover(a){if(this._activeLine!==a.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(a,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,a)||(this._clearCurrentLink(),this._askForLink(a,!0))}_askForLink(a,h){var u,f;this._activeProviderReplies&&h||((u=this._activeProviderReplies)===null||u===void 0||u.forEach((C=>{C?.forEach((k=>{k.link.dispose&&k.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=a.y);let b=!1;for(const[C,k]of this._linkProviders.entries())h?!((f=this._activeProviderReplies)===null||f===void 0)&&f.get(C)&&(b=this._checkLinkProviderResult(C,a,b)):k.provideLinks(a.y,(E=>{var _,j;if(this._isMouseOut)return;const A=E?.map((P=>({link:P})));(_=this._activeProviderReplies)===null||_===void 0||_.set(C,A),b=this._checkLinkProviderResult(C,a,b),((j=this._activeProviderReplies)===null||j===void 0?void 0:j.size)===this._linkProviders.length&&this._removeIntersectingLinks(a.y,this._activeProviderReplies)}))}_removeIntersectingLinks(a,h){const u=new Set;for(let f=0;f<h.size;f++){const b=h.get(f);if(b)for(let C=0;C<b.length;C++){const k=b[C],E=k.link.range.start.y<a?0:k.link.range.start.x,_=k.link.range.end.y>a?this._bufferService.cols:k.link.range.end.x;for(let j=E;j<=_;j++){if(u.has(j)){b.splice(C--,1);break}u.add(j)}}}}_checkLinkProviderResult(a,h,u){var f;if(!this._activeProviderReplies)return u;const b=this._activeProviderReplies.get(a);let C=!1;for(let k=0;k<a;k++)this._activeProviderReplies.has(k)&&!this._activeProviderReplies.get(k)||(C=!0);if(!C&&b){const k=b.find((E=>this._linkAtPosition(E.link,h)));k&&(u=!0,this._handleNewLink(k))}if(this._activeProviderReplies.size===this._linkProviders.length&&!u)for(let k=0;k<this._activeProviderReplies.size;k++){const E=(f=this._activeProviderReplies.get(k))===null||f===void 0?void 0:f.find((_=>this._linkAtPosition(_.link,h)));if(E){u=!0,this._handleNewLink(E);break}}return u}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(a){if(!this._element||!this._mouseService||!this._currentLink)return;const h=this._positionFromMouseEvent(a,this._element,this._mouseService);h&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,h)&&this._currentLink.link.activate(a,this._currentLink.link.text)}_clearCurrentLink(a,h){this._element&&this._currentLink&&this._lastMouseEvent&&(!a||!h||this._currentLink.link.range.start.y>=a&&this._currentLink.link.range.end.y<=h)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,x.disposeArray)(this._linkCacheDisposables))}_handleNewLink(a){if(!this._element||!this._lastMouseEvent||!this._mouseService)return;const h=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);h&&this._linkAtPosition(a.link,h)&&(this._currentLink=a,this._currentLink.state={decorations:{underline:a.link.decorations===void 0||a.link.decorations.underline,pointerCursor:a.link.decorations===void 0||a.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,a.link,this._lastMouseEvent),a.link.decorations={},Object.defineProperties(a.link.decorations,{pointerCursor:{get:()=>{var u,f;return(f=(u=this._currentLink)===null||u===void 0?void 0:u.state)===null||f===void 0?void 0:f.decorations.pointerCursor},set:u=>{var f,b;!((f=this._currentLink)===null||f===void 0)&&f.state&&this._currentLink.state.decorations.pointerCursor!==u&&(this._currentLink.state.decorations.pointerCursor=u,this._currentLink.state.isHovered&&((b=this._element)===null||b===void 0||b.classList.toggle("xterm-cursor-pointer",u)))}},underline:{get:()=>{var u,f;return(f=(u=this._currentLink)===null||u===void 0?void 0:u.state)===null||f===void 0?void 0:f.decorations.underline},set:u=>{var f,b,C;!((f=this._currentLink)===null||f===void 0)&&f.state&&((C=(b=this._currentLink)===null||b===void 0?void 0:b.state)===null||C===void 0?void 0:C.decorations.underline)!==u&&(this._currentLink.state.decorations.underline=u,this._currentLink.state.isHovered&&this._fireUnderlineEvent(a.link,u))}}}),this._renderService&&this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((u=>{if(!this._currentLink)return;const f=u.start===0?0:u.start+1+this._bufferService.buffer.ydisp,b=this._bufferService.buffer.ydisp+1+u.end;if(this._currentLink.link.range.start.y>=f&&this._currentLink.link.range.end.y<=b&&(this._clearCurrentLink(f,b),this._lastMouseEvent&&this._element)){const C=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);C&&this._askForLink(C,!1)}}))))}_linkHover(a,h,u){var f;!((f=this._currentLink)===null||f===void 0)&&f.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(h,!0),this._currentLink.state.decorations.pointerCursor&&a.classList.add("xterm-cursor-pointer")),h.hover&&h.hover(u,h.text)}_fireUnderlineEvent(a,h){const u=a.range,f=this._bufferService.buffer.ydisp,b=this._createLinkUnderlineEvent(u.start.x-1,u.start.y-f-1,u.end.x,u.end.y-f-1,void 0);(h?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(b)}_linkLeave(a,h,u){var f;!((f=this._currentLink)===null||f===void 0)&&f.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(h,!1),this._currentLink.state.decorations.pointerCursor&&a.classList.remove("xterm-cursor-pointer")),h.leave&&h.leave(u,h.text)}_linkAtPosition(a,h){const u=a.range.start.y*this._bufferService.cols+a.range.start.x,f=a.range.end.y*this._bufferService.cols+a.range.end.x,b=h.y*this._bufferService.cols+h.x;return u<=b&&b<=f}_positionFromMouseEvent(a,h,u){const f=u.getCoords(a,h,this._bufferService.cols,this._bufferService.rows);if(f)return{x:f[0],y:f[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(a,h,u,f,b){return{x1:a,y1:h,x2:u,y2:f,cols:this._bufferService.cols,fg:b}}};n.Linkifier2=y=l([d(0,w.IBufferService)],y)},9042:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.tooMuchOutput=n.promptLabel=void 0,n.promptLabel="Terminal input",n.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(v,n,i){var l=this&&this.__decorate||function(y,a,h,u){var f,b=arguments.length,C=b<3?a:u===null?u=Object.getOwnPropertyDescriptor(a,h):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(y,a,h,u);else for(var k=y.length-1;k>=0;k--)(f=y[k])&&(C=(b<3?f(C):b>3?f(a,h,C):f(a,h))||C);return b>3&&C&&Object.defineProperty(a,h,C),C},d=this&&this.__param||function(y,a){return function(h,u){a(h,u,y)}};Object.defineProperty(n,"__esModule",{value:!0}),n.OscLinkProvider=void 0;const c=i(511),m=i(2585);let x=n.OscLinkProvider=class{constructor(y,a,h){this._bufferService=y,this._optionsService=a,this._oscLinkService=h}provideLinks(y,a){var h;const u=this._bufferService.buffer.lines.get(y-1);if(!u)return void a(void 0);const f=[],b=this._optionsService.rawOptions.linkHandler,C=new c.CellData,k=u.getTrimmedLength();let E=-1,_=-1,j=!1;for(let A=0;A<k;A++)if(_!==-1||u.hasContent(A)){if(u.loadCell(A,C),C.hasExtendedAttrs()&&C.extended.urlId){if(_===-1){_=A,E=C.extended.urlId;continue}j=C.extended.urlId!==E}else _!==-1&&(j=!0);if(j||_!==-1&&A===k-1){const P=(h=this._oscLinkService.getLinkData(E))===null||h===void 0?void 0:h.uri;if(P){const T={start:{x:_+1,y},end:{x:A+(j||A!==k-1?0:1),y}};let D=!1;if(!b?.allowNonHttpProtocols)try{const W=new URL(P);["http:","https:"].includes(W.protocol)||(D=!0)}catch{D=!0}D||f.push({text:P,range:T,activate:(W,I)=>b?b.activate(W,I,T):w(0,I),hover:(W,I)=>{var B;return(B=b?.hover)===null||B===void 0?void 0:B.call(b,W,I,T)},leave:(W,I)=>{var B;return(B=b?.leave)===null||B===void 0?void 0:B.call(b,W,I,T)}})}j=!1,C.hasExtendedAttrs()&&C.extended.urlId?(_=A,E=C.extended.urlId):(_=-1,E=-1)}}a(f)}};function w(y,a){if(confirm(`Do you want to navigate to ${a}?
22
-
23
- WARNING: This link could potentially be dangerous`)){const h=window.open();if(h){try{h.opener=null}catch{}h.location.href=a}else console.warn("Opening link blocked as opener could not be cleared")}}n.OscLinkProvider=x=l([d(0,m.IBufferService),d(1,m.IOptionsService),d(2,m.IOscLinkService)],x)},6193:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.RenderDebouncer=void 0,n.RenderDebouncer=class{constructor(i,l){this._parentWindow=i,this._renderCallback=l,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._parentWindow.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(i){return this._refreshCallbacks.push(i),this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(i,l,d){this._rowCount=d,i=i!==void 0?i:0,l=l!==void 0?l:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,i):i,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,l):l,this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return void this._runRefreshCallbacks();const i=Math.max(this._rowStart,0),l=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(i,l),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const i of this._refreshCallbacks)i(0);this._refreshCallbacks=[]}}},5596:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ScreenDprMonitor=void 0;const l=i(844);class d extends l.Disposable{constructor(m){super(),this._parentWindow=m,this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this.register((0,l.toDisposable)((()=>{this.clearListener()})))}setListener(m){this._listener&&this.clearListener(),this._listener=m,this._outerListener=()=>{this._listener&&(this._listener(this._parentWindow.devicePixelRatio,this._currentDevicePixelRatio),this._updateDpr())},this._updateDpr()}_updateDpr(){var m;this._outerListener&&((m=this._resolutionMediaMatchList)===null||m===void 0||m.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._listener&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._listener=void 0,this._outerListener=void 0)}}n.ScreenDprMonitor=d},3236:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Terminal=void 0;const l=i(3614),d=i(3656),c=i(6465),m=i(9042),x=i(3730),w=i(1680),y=i(3107),a=i(5744),h=i(2950),u=i(1296),f=i(428),b=i(4269),C=i(5114),k=i(8934),E=i(3230),_=i(9312),j=i(4725),A=i(6731),P=i(8055),T=i(8969),D=i(8460),W=i(844),I=i(6114),B=i(8437),F=i(2584),R=i(7399),M=i(5941),L=i(9074),O=i(2585),U=i(5435),Y=i(4567),z=typeof window<"u"?window.document:null;class $ extends T.CoreTerminal{get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}constructor(N={}){super(N),this.browser=I,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new W.MutableDisposable),this._onCursorMove=this.register(new D.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new D.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new D.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new D.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new D.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new D.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new D.EventEmitter),this._onBlur=this.register(new D.EventEmitter),this._onA11yCharEmitter=this.register(new D.EventEmitter),this._onA11yTabEmitter=this.register(new D.EventEmitter),this._onWillOpen=this.register(new D.EventEmitter),this._setup(),this.linkifier2=this.register(this._instantiationService.createInstance(c.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(x.OscLinkProvider)),this._decorationService=this._instantiationService.createInstance(L.DecorationService),this._instantiationService.setService(O.IDecorationService,this._decorationService),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((H,X)=>this.refresh(H,X)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((H=>this._reportWindowsOptions(H)))),this.register(this._inputHandler.onColor((H=>this._handleColorEvent(H)))),this.register((0,D.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,D.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,D.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,D.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((H=>this._afterResize(H.cols,H.rows)))),this.register((0,W.toDisposable)((()=>{var H,X;this._customKeyEventHandler=void 0,(X=(H=this.element)===null||H===void 0?void 0:H.parentNode)===null||X===void 0||X.removeChild(this.element)})))}_handleColorEvent(N){if(this._themeService)for(const H of N){let X,K="";switch(H.index){case 256:X="foreground",K="10";break;case 257:X="background",K="11";break;case 258:X="cursor",K="12";break;default:X="ansi",K="4;"+H.index}switch(H.type){case 0:const ne=P.color.toColorRGB(X==="ansi"?this._themeService.colors.ansi[H.index]:this._themeService.colors[X]);this.coreService.triggerDataEvent(`${F.C0.ESC}]${K};${(0,M.toRgbString)(ne)}${F.C1_ESCAPED.ST}`);break;case 1:if(X==="ansi")this._themeService.modifyColors((te=>te.ansi[H.index]=P.rgba.toColor(...H.color)));else{const te=X;this._themeService.modifyColors((he=>he[te]=P.rgba.toColor(...H.color)))}break;case 2:this._themeService.restoreColor(H.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(N){N?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(Y.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(N){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(F.C0.ESC+"[I"),this.updateCursorStyle(N),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var N;return(N=this.textarea)===null||N===void 0?void 0:N.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(F.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;const N=this.buffer.ybase+this.buffer.y,H=this.buffer.lines.get(N);if(!H)return;const X=Math.min(this.buffer.x,this.cols-1),K=this._renderService.dimensions.css.cell.height,ne=H.getWidth(X),te=this._renderService.dimensions.css.cell.width*ne,he=this.buffer.y*this._renderService.dimensions.css.cell.height,le=X*this._renderService.dimensions.css.cell.width;this.textarea.style.left=le+"px",this.textarea.style.top=he+"px",this.textarea.style.width=te+"px",this.textarea.style.height=K+"px",this.textarea.style.lineHeight=K+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,d.addDisposableDomListener)(this.element,"copy",(H=>{this.hasSelection()&&(0,l.copyHandler)(H,this._selectionService)})));const N=H=>(0,l.handlePasteEvent)(H,this.textarea,this.coreService,this.optionsService);this.register((0,d.addDisposableDomListener)(this.textarea,"paste",N)),this.register((0,d.addDisposableDomListener)(this.element,"paste",N)),I.isFirefox?this.register((0,d.addDisposableDomListener)(this.element,"mousedown",(H=>{H.button===2&&(0,l.rightClickHandler)(H,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,d.addDisposableDomListener)(this.element,"contextmenu",(H=>{(0,l.rightClickHandler)(H,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),I.isLinux&&this.register((0,d.addDisposableDomListener)(this.element,"auxclick",(H=>{H.button===1&&(0,l.moveTextAreaUnderMouseCursor)(H,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,d.addDisposableDomListener)(this.textarea,"keyup",(N=>this._keyUp(N)),!0)),this.register((0,d.addDisposableDomListener)(this.textarea,"keydown",(N=>this._keyDown(N)),!0)),this.register((0,d.addDisposableDomListener)(this.textarea,"keypress",(N=>this._keyPress(N)),!0)),this.register((0,d.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,d.addDisposableDomListener)(this.textarea,"compositionupdate",(N=>this._compositionHelper.compositionupdate(N)))),this.register((0,d.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,d.addDisposableDomListener)(this.textarea,"input",(N=>this._inputEvent(N)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(N){var H;if(!N)throw new Error("Terminal requires a parent element.");N.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this._document=N.ownerDocument,this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),N.appendChild(this.element);const X=z.createDocumentFragment();this._viewportElement=z.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),X.appendChild(this._viewportElement),this._viewportScrollArea=z.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=z.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=z.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),X.appendChild(this.screenElement),this.textarea=z.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",m.promptLabel),I.isChromeOS||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._coreBrowserService=this._instantiationService.createInstance(C.CoreBrowserService,this.textarea,(H=this._document.defaultView)!==null&&H!==void 0?H:window),this._instantiationService.setService(j.ICoreBrowserService,this._coreBrowserService),this.register((0,d.addDisposableDomListener)(this.textarea,"focus",(K=>this._handleTextAreaFocus(K)))),this.register((0,d.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(f.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(j.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(A.ThemeService),this._instantiationService.setService(j.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(b.CharacterJoinerService),this._instantiationService.setService(j.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(E.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(j.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((K=>this._onRender.fire(K)))),this.onResize((K=>this._renderService.resize(K.cols,K.rows))),this._compositionView=z.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(h.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this.element.appendChild(X);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._mouseService=this._instantiationService.createInstance(k.MouseService),this._instantiationService.setService(j.IMouseService,this._mouseService),this.viewport=this._instantiationService.createInstance(w.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((K=>this.scrollLines(K.amount,K.suppressScrollEvent,1))),this.register(this._inputHandler.onRequestSyncScrollBar((()=>this.viewport.syncScrollArea()))),this.register(this.viewport),this.register(this.onCursorMove((()=>{this._renderService.handleCursorMove(),this._syncTextArea()}))),this.register(this.onResize((()=>this._renderService.handleResize(this.cols,this.rows)))),this.register(this.onBlur((()=>this._renderService.handleBlur()))),this.register(this.onFocus((()=>this._renderService.handleFocus()))),this.register(this._renderService.onDimensionsChange((()=>this.viewport.syncScrollArea()))),this._selectionService=this.register(this._instantiationService.createInstance(_.SelectionService,this.element,this.screenElement,this.linkifier2)),this._instantiationService.setService(j.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((K=>this.scrollLines(K.amount,K.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((K=>this._renderService.handleSelectionChanged(K.start,K.end,K.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((K=>{this.textarea.value=K,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((K=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,d.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.linkifier2.attachToDom(this.screenElement,this._mouseService,this._renderService),this.register(this._instantiationService.createInstance(y.BufferDecorationRenderer,this.screenElement)),this.register((0,d.addDisposableDomListener)(this.element,"mousedown",(K=>this._selectionService.handleMouseDown(K)))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(Y.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(K=>this._handleScreenReaderModeOptionChange(K)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(a.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(K=>{!this._overviewRulerRenderer&&K&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(a.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(u.DomRenderer,this.element,this.screenElement,this._viewportElement,this.linkifier2)}bindMouse(){const N=this,H=this.element;function X(te){const he=N._mouseService.getMouseReportCoords(te,N.screenElement);if(!he)return!1;let le,G;switch(te.overrideType||te.type){case"mousemove":G=32,te.buttons===void 0?(le=3,te.button!==void 0&&(le=te.button<3?te.button:3)):le=1&te.buttons?0:4&te.buttons?1:2&te.buttons?2:3;break;case"mouseup":G=0,le=te.button<3?te.button:3;break;case"mousedown":G=1,le=te.button<3?te.button:3;break;case"wheel":if(N.viewport.getLinesScrolled(te)===0)return!1;G=te.deltaY<0?0:1,le=4;break;default:return!1}return!(G===void 0||le===void 0||le>4)&&N.coreMouseService.triggerMouseEvent({col:he.col,row:he.row,x:he.x,y:he.y,button:le,action:G,ctrl:te.ctrlKey,alt:te.altKey,shift:te.shiftKey})}const K={mouseup:null,wheel:null,mousedrag:null,mousemove:null},ne={mouseup:te=>(X(te),te.buttons||(this._document.removeEventListener("mouseup",K.mouseup),K.mousedrag&&this._document.removeEventListener("mousemove",K.mousedrag)),this.cancel(te)),wheel:te=>(X(te),this.cancel(te,!0)),mousedrag:te=>{te.buttons&&X(te)},mousemove:te=>{te.buttons||X(te)}};this.register(this.coreMouseService.onProtocolChange((te=>{te?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(te)),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&te?K.mousemove||(H.addEventListener("mousemove",ne.mousemove),K.mousemove=ne.mousemove):(H.removeEventListener("mousemove",K.mousemove),K.mousemove=null),16&te?K.wheel||(H.addEventListener("wheel",ne.wheel,{passive:!1}),K.wheel=ne.wheel):(H.removeEventListener("wheel",K.wheel),K.wheel=null),2&te?K.mouseup||(H.addEventListener("mouseup",ne.mouseup),K.mouseup=ne.mouseup):(this._document.removeEventListener("mouseup",K.mouseup),H.removeEventListener("mouseup",K.mouseup),K.mouseup=null),4&te?K.mousedrag||(K.mousedrag=ne.mousedrag):(this._document.removeEventListener("mousemove",K.mousedrag),K.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,d.addDisposableDomListener)(H,"mousedown",(te=>{if(te.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(te))return X(te),K.mouseup&&this._document.addEventListener("mouseup",K.mouseup),K.mousedrag&&this._document.addEventListener("mousemove",K.mousedrag),this.cancel(te)}))),this.register((0,d.addDisposableDomListener)(H,"wheel",(te=>{if(!K.wheel){if(!this.buffer.hasScrollback){const he=this.viewport.getLinesScrolled(te);if(he===0)return;const le=F.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(te.deltaY<0?"A":"B");let G="";for(let pe=0;pe<Math.abs(he);pe++)G+=le;return this.coreService.triggerDataEvent(G,!0),this.cancel(te,!0)}return this.viewport.handleWheel(te)?this.cancel(te):void 0}}),{passive:!1})),this.register((0,d.addDisposableDomListener)(H,"touchstart",(te=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(te),this.cancel(te)}),{passive:!0})),this.register((0,d.addDisposableDomListener)(H,"touchmove",(te=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(te)?void 0:this.cancel(te)}),{passive:!1}))}refresh(N,H){var X;(X=this._renderService)===null||X===void 0||X.refreshRows(N,H)}updateCursorStyle(N){var H;!((H=this._selectionService)===null||H===void 0)&&H.shouldColumnSelect(N)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(N,H,X=0){var K;X===1?(super.scrollLines(N,H,X),this.refresh(0,this.rows-1)):(K=this.viewport)===null||K===void 0||K.scrollLines(N)}paste(N){(0,l.paste)(N,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(N){this._customKeyEventHandler=N}registerLinkProvider(N){return this.linkifier2.registerLinkProvider(N)}registerCharacterJoiner(N){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const H=this._characterJoinerService.register(N);return this.refresh(0,this.rows-1),H}deregisterCharacterJoiner(N){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(N)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(N){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+N)}registerDecoration(N){return this._decorationService.registerDecoration(N)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(N,H,X){this._selectionService.setSelection(N,H,X)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var N;(N=this._selectionService)===null||N===void 0||N.clearSelection()}selectAll(){var N;(N=this._selectionService)===null||N===void 0||N.selectAll()}selectLines(N,H){var X;(X=this._selectionService)===null||X===void 0||X.selectLines(N,H)}_keyDown(N){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1)return!1;const H=this.browser.isMac&&this.options.macOptionIsMeta&&N.altKey;if(!H&&!this._compositionHelper.keydown(N))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;H||N.key!=="Dead"&&N.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const X=(0,R.evaluateKeyboardEvent)(N,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(N),X.type===3||X.type===2){const K=this.rows-1;return this.scrollLines(X.type===2?-K:K),this.cancel(N,!0)}return X.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,N)||(X.cancel&&this.cancel(N,!0),!X.key||!!(N.key&&!N.ctrlKey&&!N.altKey&&!N.metaKey&&N.key.length===1&&N.key.charCodeAt(0)>=65&&N.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(X.key!==F.C0.ETX&&X.key!==F.C0.CR||(this.textarea.value=""),this._onKey.fire({key:X.key,domEvent:N}),this._showCursor(),this.coreService.triggerDataEvent(X.key,!0),!this.optionsService.rawOptions.screenReaderMode||N.altKey||N.ctrlKey?this.cancel(N,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(N,H){const X=N.isMac&&!this.options.macOptionIsMeta&&H.altKey&&!H.ctrlKey&&!H.metaKey||N.isWindows&&H.altKey&&H.ctrlKey&&!H.metaKey||N.isWindows&&H.getModifierState("AltGraph");return H.type==="keypress"?X:X&&(!H.keyCode||H.keyCode>47)}_keyUp(N){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1||((function(H){return H.keyCode===16||H.keyCode===17||H.keyCode===18})(N)||this.focus(),this.updateCursorStyle(N),this._keyPressHandled=!1)}_keyPress(N){let H;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1)return!1;if(this.cancel(N),N.charCode)H=N.charCode;else if(N.which===null||N.which===void 0)H=N.keyCode;else{if(N.which===0||N.charCode===0)return!1;H=N.which}return!(!H||(N.altKey||N.ctrlKey||N.metaKey)&&!this._isThirdLevelShift(this.browser,N)||(H=String.fromCharCode(H),this._onKey.fire({key:H,domEvent:N}),this._showCursor(),this.coreService.triggerDataEvent(H,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(N){if(N.data&&N.inputType==="insertText"&&(!N.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const H=N.data;return this.coreService.triggerDataEvent(H,!0),this.cancel(N),!0}return!1}resize(N,H){N!==this.cols||H!==this.rows?super.resize(N,H):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(N,H){var X,K;(X=this._charSizeService)===null||X===void 0||X.measure(),(K=this.viewport)===null||K===void 0||K.syncScrollArea(!0)}clear(){var N;if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let H=1;H<this.rows;H++)this.buffer.lines.push(this.buffer.getBlankLine(B.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(N=this.viewport)===null||N===void 0||N.reset(),this.refresh(0,this.rows-1)}}reset(){var N,H;this.options.rows=this.rows,this.options.cols=this.cols;const X=this._customKeyEventHandler;this._setup(),super.reset(),(N=this._selectionService)===null||N===void 0||N.reset(),this._decorationService.reset(),(H=this.viewport)===null||H===void 0||H.reset(),this._customKeyEventHandler=X,this.refresh(0,this.rows-1)}clearTextureAtlas(){var N;(N=this._renderService)===null||N===void 0||N.clearTextureAtlas()}_reportFocus(){var N;!((N=this.element)===null||N===void 0)&&N.classList.contains("focus")?this.coreService.triggerDataEvent(F.C0.ESC+"[I"):this.coreService.triggerDataEvent(F.C0.ESC+"[O")}_reportWindowsOptions(N){if(this._renderService)switch(N){case U.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const H=this._renderService.dimensions.css.canvas.width.toFixed(0),X=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${F.C0.ESC}[4;${X};${H}t`);break;case U.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const K=this._renderService.dimensions.css.cell.width.toFixed(0),ne=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${F.C0.ESC}[6;${ne};${K}t`)}}cancel(N,H){if(this.options.cancelEvents||H)return N.preventDefault(),N.stopPropagation(),!1}}n.Terminal=$},9924:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.TimeBasedDebouncer=void 0,n.TimeBasedDebouncer=class{constructor(i,l=1e3){this._renderCallback=i,this._debounceThresholdMS=l,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(i,l,d){this._rowCount=d,i=i!==void 0?i:0,l=l!==void 0?l:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,i):i,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,l):l;const c=Date.now();if(c-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=c,this._innerRefresh();else if(!this._additionalRefreshRequested){const m=c-this._lastRefreshMs,x=this._debounceThresholdMS-m;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),x)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const i=Math.max(this._rowStart,0),l=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(i,l)}}},1680:function(v,n,i){var l=this&&this.__decorate||function(h,u,f,b){var C,k=arguments.length,E=k<3?u:b===null?b=Object.getOwnPropertyDescriptor(u,f):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(h,u,f,b);else for(var _=h.length-1;_>=0;_--)(C=h[_])&&(E=(k<3?C(E):k>3?C(u,f,E):C(u,f))||E);return k>3&&E&&Object.defineProperty(u,f,E),E},d=this&&this.__param||function(h,u){return function(f,b){u(f,b,h)}};Object.defineProperty(n,"__esModule",{value:!0}),n.Viewport=void 0;const c=i(3656),m=i(4725),x=i(8460),w=i(844),y=i(2585);let a=n.Viewport=class extends w.Disposable{constructor(h,u,f,b,C,k,E,_){super(),this._viewportElement=h,this._scrollArea=u,this._bufferService=f,this._optionsService=b,this._charSizeService=C,this._renderService=k,this._coreBrowserService=E,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new x.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,c.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((j=>this._activeBuffer=j.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((j=>this._renderDimensions=j))),this._handleThemeChange(_.colors),this.register(_.onChangeColors((j=>this._handleThemeChange(j)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(h){this._viewportElement.style.backgroundColor=h.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame((()=>this.syncScrollArea()))}_refresh(h){if(h)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderService.dimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderService.dimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;const u=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderService.dimensions.css.canvas.height);this._lastRecordedBufferHeight!==u&&(this._lastRecordedBufferHeight=u,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const h=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==h&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=h),this._refreshAnimationFrame=null}syncScrollArea(h=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(h);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(h)}_handleScroll(h){if(this._lastScrollTop=this._viewportElement.scrollTop,!this._viewportElement.offsetParent)return;if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._onRequestScrollLines.fire({amount:0,suppressScrollEvent:!0});const u=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:u,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const h=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(h*(this._smoothScrollState.target-this._smoothScrollState.origin)),h<1?this._coreBrowserService.window.requestAnimationFrame((()=>this._smoothScroll())):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(h,u){const f=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(u<0&&this._viewportElement.scrollTop!==0||u>0&&f<this._lastRecordedBufferHeight)||(h.cancelable&&h.preventDefault(),!1)}handleWheel(h){const u=this._getPixelsScrolled(h);return u!==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+u:this._smoothScrollState.target+=u,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=u,this._bubbleScroll(h,u))}scrollLines(h){if(h!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const u=h*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+u,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:h,suppressScrollEvent:!1})}_getPixelsScrolled(h){if(h.deltaY===0||h.shiftKey)return 0;let u=this._applyScrollModifier(h.deltaY,h);return h.deltaMode===WheelEvent.DOM_DELTA_LINE?u*=this._currentRowHeight:h.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(u*=this._currentRowHeight*this._bufferService.rows),u}getBufferElements(h,u){var f;let b,C="";const k=[],E=u??this._bufferService.buffer.lines.length,_=this._bufferService.buffer.lines;for(let j=h;j<E;j++){const A=_.get(j);if(!A)continue;const P=(f=_.get(j+1))===null||f===void 0?void 0:f.isWrapped;if(C+=A.translateToString(!P),!P||j===_.length-1){const T=document.createElement("div");T.textContent=C,k.push(T),C.length>0&&(b=T),C=""}}return{bufferElements:k,cursorElement:b}}getLinesScrolled(h){if(h.deltaY===0||h.shiftKey)return 0;let u=this._applyScrollModifier(h.deltaY,h);return h.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(u/=this._currentRowHeight+0,this._wheelPartialScroll+=u,u=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):h.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(u*=this._bufferService.rows),u}_applyScrollModifier(h,u){const f=this._optionsService.rawOptions.fastScrollModifier;return f==="alt"&&u.altKey||f==="ctrl"&&u.ctrlKey||f==="shift"&&u.shiftKey?h*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:h*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(h){this._lastTouchY=h.touches[0].pageY}handleTouchMove(h){const u=this._lastTouchY-h.touches[0].pageY;return this._lastTouchY=h.touches[0].pageY,u!==0&&(this._viewportElement.scrollTop+=u,this._bubbleScroll(h,u))}};n.Viewport=a=l([d(2,y.IBufferService),d(3,y.IOptionsService),d(4,m.ICharSizeService),d(5,m.IRenderService),d(6,m.ICoreBrowserService),d(7,m.IThemeService)],a)},3107:function(v,n,i){var l=this&&this.__decorate||function(a,h,u,f){var b,C=arguments.length,k=C<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,u):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,u,f);else for(var E=a.length-1;E>=0;E--)(b=a[E])&&(k=(C<3?b(k):C>3?b(h,u,k):b(h,u))||k);return C>3&&k&&Object.defineProperty(h,u,k),k},d=this&&this.__param||function(a,h){return function(u,f){h(u,f,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.BufferDecorationRenderer=void 0;const c=i(3656),m=i(4725),x=i(844),w=i(2585);let y=n.BufferDecorationRenderer=class extends x.Disposable{constructor(a,h,u,f){super(),this._screenElement=a,this._bufferService=h,this._decorationService=u,this._renderService=f,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this.register(this._renderService.onRenderedViewportChange((()=>this._doRefreshDecorations()))),this.register(this._renderService.onDimensionsChange((()=>{this._dimensionsChanged=!0,this._queueRefresh()}))),this.register((0,c.addDisposableDomListener)(window,"resize",(()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt}))),this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh()))),this.register(this._decorationService.onDecorationRemoved((b=>this._removeDecoration(b)))),this.register((0,x.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(const a of this._decorationService.decorations)this._renderDecoration(a);this._dimensionsChanged=!1}_renderDecoration(a){this._refreshStyle(a),this._dimensionsChanged&&this._refreshXPosition(a)}_createElement(a){var h,u;const f=document.createElement("div");f.classList.add("xterm-decoration"),f.classList.toggle("xterm-decoration-top-layer",((h=a?.options)===null||h===void 0?void 0:h.layer)==="top"),f.style.width=`${Math.round((a.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,f.style.height=(a.options.height||1)*this._renderService.dimensions.css.cell.height+"px",f.style.top=(a.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",f.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const b=(u=a.options.x)!==null&&u!==void 0?u:0;return b&&b>this._bufferService.cols&&(f.style.display="none"),this._refreshXPosition(a,f),f}_refreshStyle(a){const h=a.marker.line-this._bufferService.buffers.active.ydisp;if(h<0||h>=this._bufferService.rows)a.element&&(a.element.style.display="none",a.onRenderEmitter.fire(a.element));else{let u=this._decorationElements.get(a);u||(u=this._createElement(a),a.element=u,this._decorationElements.set(a,u),this._container.appendChild(u),a.onDispose((()=>{this._decorationElements.delete(a),u.remove()}))),u.style.top=h*this._renderService.dimensions.css.cell.height+"px",u.style.display=this._altBufferIsActive?"none":"block",a.onRenderEmitter.fire(u)}}_refreshXPosition(a,h=a.element){var u;if(!h)return;const f=(u=a.options.x)!==null&&u!==void 0?u:0;(a.options.anchor||"left")==="right"?h.style.right=f?f*this._renderService.dimensions.css.cell.width+"px":"":h.style.left=f?f*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(a){var h;(h=this._decorationElements.get(a))===null||h===void 0||h.remove(),this._decorationElements.delete(a),a.dispose()}};n.BufferDecorationRenderer=y=l([d(1,w.IBufferService),d(2,w.IDecorationService),d(3,m.IRenderService)],y)},5871:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ColorZoneStore=void 0,n.ColorZoneStore=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(i){if(i.options.overviewRulerOptions){for(const l of this._zones)if(l.color===i.options.overviewRulerOptions.color&&l.position===i.options.overviewRulerOptions.position){if(this._lineIntersectsZone(l,i.marker.line))return;if(this._lineAdjacentToZone(l,i.marker.line,i.options.overviewRulerOptions.position))return void this._addLineToZone(l,i.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=i.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=i.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=i.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=i.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:i.options.overviewRulerOptions.color,position:i.options.overviewRulerOptions.position,startBufferLine:i.marker.line,endBufferLine:i.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(i){this._linePadding=i}_lineIntersectsZone(i,l){return l>=i.startBufferLine&&l<=i.endBufferLine}_lineAdjacentToZone(i,l,d){return l>=i.startBufferLine-this._linePadding[d||"full"]&&l<=i.endBufferLine+this._linePadding[d||"full"]}_addLineToZone(i,l){i.startBufferLine=Math.min(i.startBufferLine,l),i.endBufferLine=Math.max(i.endBufferLine,l)}}},5744:function(v,n,i){var l=this&&this.__decorate||function(b,C,k,E){var _,j=arguments.length,A=j<3?C:E===null?E=Object.getOwnPropertyDescriptor(C,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(b,C,k,E);else for(var P=b.length-1;P>=0;P--)(_=b[P])&&(A=(j<3?_(A):j>3?_(C,k,A):_(C,k))||A);return j>3&&A&&Object.defineProperty(C,k,A),A},d=this&&this.__param||function(b,C){return function(k,E){C(k,E,b)}};Object.defineProperty(n,"__esModule",{value:!0}),n.OverviewRulerRenderer=void 0;const c=i(5871),m=i(3656),x=i(4725),w=i(844),y=i(2585),a={full:0,left:0,center:0,right:0},h={full:0,left:0,center:0,right:0},u={full:0,left:0,center:0,right:0};let f=n.OverviewRulerRenderer=class extends w.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(b,C,k,E,_,j,A){var P;super(),this._viewportElement=b,this._screenElement=C,this._bufferService=k,this._decorationService=E,this._renderService=_,this._optionsService=j,this._coreBrowseService=A,this._colorZoneStore=new c.ColorZoneStore,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=document.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(P=this._viewportElement.parentElement)===null||P===void 0||P.insertBefore(this._canvas,this._viewportElement);const T=this._canvas.getContext("2d");if(!T)throw new Error("Ctx cannot be null");this._ctx=T,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,w.toDisposable)((()=>{var D;(D=this._canvas)===null||D===void 0||D.remove()})))}_registerDecorationListeners(){this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh(void 0,!0)))),this.register(this._decorationService.onDecorationRemoved((()=>this._queueRefresh(void 0,!0))))}_registerBufferChangeListeners(){this.register(this._renderService.onRenderedViewportChange((()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"}))),this.register(this._bufferService.onScroll((()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})))}_registerDimensionChangeListeners(){this.register(this._renderService.onRender((()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)}))),this.register(this._optionsService.onSpecificOptionChange("overviewRulerWidth",(()=>this._queueRefresh(!0)))),this.register((0,m.addDisposableDomListener)(this._coreBrowseService.window,"resize",(()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){const b=Math.floor(this._canvas.width/3),C=Math.ceil(this._canvas.width/3);h.full=this._canvas.width,h.left=b,h.center=C,h.right=b,this._refreshDrawHeightConstants(),u.full=0,u.left=0,u.center=h.left,u.right=h.left+h.center}_refreshDrawHeightConstants(){a.full=Math.round(2*this._coreBrowseService.dpr);const b=this._canvas.height/this._bufferService.buffer.lines.length,C=Math.round(Math.max(Math.min(b,12),6)*this._coreBrowseService.dpr);a.left=C,a.center=C,a.right=C}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*a.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowseService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowseService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(const C of this._decorationService.decorations)this._colorZoneStore.addDecoration(C);this._ctx.lineWidth=1;const b=this._colorZoneStore.zones;for(const C of b)C.position!=="full"&&this._renderColorZone(C);for(const C of b)C.position==="full"&&this._renderColorZone(C);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(b){this._ctx.fillStyle=b.color,this._ctx.fillRect(u[b.position||"full"],Math.round((this._canvas.height-1)*(b.startBufferLine/this._bufferService.buffers.active.lines.length)-a[b.position||"full"]/2),h[b.position||"full"],Math.round((this._canvas.height-1)*((b.endBufferLine-b.startBufferLine)/this._bufferService.buffers.active.lines.length)+a[b.position||"full"]))}_queueRefresh(b,C){this._shouldUpdateDimensions=b||this._shouldUpdateDimensions,this._shouldUpdateAnchor=C||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowseService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};n.OverviewRulerRenderer=f=l([d(2,y.IBufferService),d(3,y.IDecorationService),d(4,x.IRenderService),d(5,y.IOptionsService),d(6,x.ICoreBrowserService)],f)},2950:function(v,n,i){var l=this&&this.__decorate||function(y,a,h,u){var f,b=arguments.length,C=b<3?a:u===null?u=Object.getOwnPropertyDescriptor(a,h):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(y,a,h,u);else for(var k=y.length-1;k>=0;k--)(f=y[k])&&(C=(b<3?f(C):b>3?f(a,h,C):f(a,h))||C);return b>3&&C&&Object.defineProperty(a,h,C),C},d=this&&this.__param||function(y,a){return function(h,u){a(h,u,y)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CompositionHelper=void 0;const c=i(4725),m=i(2585),x=i(2584);let w=n.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(y,a,h,u,f,b){this._textarea=y,this._compositionView=a,this._bufferService=h,this._optionsService=u,this._coreService=f,this._renderService=b,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(y){this._compositionView.textContent=y.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(y){if(this._isComposing||this._isSendingComposition){if(y.keyCode===229||y.keyCode===16||y.keyCode===17||y.keyCode===18)return!1;this._finalizeComposition(!1)}return y.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(y){if(this._compositionView.classList.remove("active"),this._isComposing=!1,y){const a={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let h;this._isSendingComposition=!1,a.start+=this._dataAlreadySent.length,h=this._isComposing?this._textarea.value.substring(a.start,a.end):this._textarea.value.substring(a.start),h.length>0&&this._coreService.triggerDataEvent(h,!0)}}),0)}else{this._isSendingComposition=!1;const a=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(a,!0)}}_handleAnyTextareaChanges(){const y=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const a=this._textarea.value,h=a.replace(y,"");this._dataAlreadySent=h,a.length>y.length?this._coreService.triggerDataEvent(h,!0):a.length<y.length?this._coreService.triggerDataEvent(`${x.C0.DEL}`,!0):a.length===y.length&&a!==y&&this._coreService.triggerDataEvent(a,!0)}}),0)}updateCompositionElements(y){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const a=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),h=this._renderService.dimensions.css.cell.height,u=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,f=a*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=f+"px",this._compositionView.style.top=u+"px",this._compositionView.style.height=h+"px",this._compositionView.style.lineHeight=h+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const b=this._compositionView.getBoundingClientRect();this._textarea.style.left=f+"px",this._textarea.style.top=u+"px",this._textarea.style.width=Math.max(b.width,1)+"px",this._textarea.style.height=Math.max(b.height,1)+"px",this._textarea.style.lineHeight=b.height+"px"}y||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};n.CompositionHelper=w=l([d(2,m.IBufferService),d(3,m.IOptionsService),d(4,m.ICoreService),d(5,c.IRenderService)],w)},9806:(v,n)=>{function i(l,d,c){const m=c.getBoundingClientRect(),x=l.getComputedStyle(c),w=parseInt(x.getPropertyValue("padding-left")),y=parseInt(x.getPropertyValue("padding-top"));return[d.clientX-m.left-w,d.clientY-m.top-y]}Object.defineProperty(n,"__esModule",{value:!0}),n.getCoords=n.getCoordsRelativeToElement=void 0,n.getCoordsRelativeToElement=i,n.getCoords=function(l,d,c,m,x,w,y,a,h){if(!w)return;const u=i(l,d,c);return u?(u[0]=Math.ceil((u[0]+(h?y/2:0))/y),u[1]=Math.ceil(u[1]/a),u[0]=Math.min(Math.max(u[0],1),m+(h?1:0)),u[1]=Math.min(Math.max(u[1],1),x),u):void 0}},9504:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.moveToCellSequence=void 0;const l=i(2584);function d(a,h,u,f){const b=a-c(a,u),C=h-c(h,u),k=Math.abs(b-C)-(function(E,_,j){let A=0;const P=E-c(E,j),T=_-c(_,j);for(let D=0;D<Math.abs(P-T);D++){const W=m(E,_)==="A"?-1:1,I=j.buffer.lines.get(P+W*D);I?.isWrapped&&A++}return A})(a,h,u);return y(k,w(m(a,h),f))}function c(a,h){let u=0,f=h.buffer.lines.get(a),b=f?.isWrapped;for(;b&&a>=0&&a<h.rows;)u++,f=h.buffer.lines.get(--a),b=f?.isWrapped;return u}function m(a,h){return a>h?"A":"B"}function x(a,h,u,f,b,C){let k=a,E=h,_="";for(;k!==u||E!==f;)k+=b?1:-1,b&&k>C.cols-1?(_+=C.buffer.translateBufferLineToString(E,!1,a,k),k=0,a=0,E++):!b&&k<0&&(_+=C.buffer.translateBufferLineToString(E,!1,0,a+1),k=C.cols-1,a=k,E--);return _+C.buffer.translateBufferLineToString(E,!1,a,k)}function w(a,h){const u=h?"O":"[";return l.C0.ESC+u+a}function y(a,h){a=Math.floor(a);let u="";for(let f=0;f<a;f++)u+=h;return u}n.moveToCellSequence=function(a,h,u,f){const b=u.buffer.x,C=u.buffer.y;if(!u.buffer.hasScrollback)return(function(_,j,A,P,T,D){return d(j,P,T,D).length===0?"":y(x(_,j,_,j-c(j,T),!1,T).length,w("D",D))})(b,C,0,h,u,f)+d(C,h,u,f)+(function(_,j,A,P,T,D){let W;W=d(j,P,T,D).length>0?P-c(P,T):j;const I=P,B=(function(F,R,M,L,O,U){let Y;return Y=d(M,L,O,U).length>0?L-c(L,O):R,F<M&&Y<=L||F>=M&&Y<L?"C":"D"})(_,j,A,P,T,D);return y(x(_,W,A,I,B==="C",T).length,w(B,D))})(b,C,a,h,u,f);let k;if(C===h)return k=b>a?"D":"C",y(Math.abs(b-a),w(k,f));k=C>h?"D":"C";const E=Math.abs(C-h);return y((function(_,j){return j.cols-_})(C>h?a:b,u)+(E-1)*u.cols+1+((C>h?b:a)-1),w(k,f))}},1296:function(v,n,i){var l=this&&this.__decorate||function(T,D,W,I){var B,F=arguments.length,R=F<3?D:I===null?I=Object.getOwnPropertyDescriptor(D,W):I;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(T,D,W,I);else for(var M=T.length-1;M>=0;M--)(B=T[M])&&(R=(F<3?B(R):F>3?B(D,W,R):B(D,W))||R);return F>3&&R&&Object.defineProperty(D,W,R),R},d=this&&this.__param||function(T,D){return function(W,I){D(W,I,T)}};Object.defineProperty(n,"__esModule",{value:!0}),n.DomRenderer=void 0;const c=i(3787),m=i(2550),x=i(2223),w=i(6171),y=i(4725),a=i(8055),h=i(8460),u=i(844),f=i(2585),b="xterm-dom-renderer-owner-",C="xterm-rows",k="xterm-fg-",E="xterm-bg-",_="xterm-focus",j="xterm-selection";let A=1,P=n.DomRenderer=class extends u.Disposable{constructor(T,D,W,I,B,F,R,M,L,O){super(),this._element=T,this._screenElement=D,this._viewportElement=W,this._linkifier2=I,this._charSizeService=F,this._optionsService=R,this._bufferService=M,this._coreBrowserService=L,this._themeService=O,this._terminalClass=A++,this._rowElements=[],this.onRequestRedraw=this.register(new h.EventEmitter).event,this._rowContainer=document.createElement("div"),this._rowContainer.classList.add(C),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=document.createElement("div"),this._selectionContainer.classList.add(j),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,w.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((U=>this._injectCss(U)))),this._injectCss(this._themeService.colors),this._rowFactory=B.createInstance(c.DomRendererRowFactory,document),this._element.classList.add(b+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((U=>this._handleLinkHover(U)))),this.register(this._linkifier2.onHideLinkUnderline((U=>this._handleLinkLeave(U)))),this.register((0,u.toDisposable)((()=>{this._element.classList.remove(b+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new m.WidthCache(document),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){const T=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*T,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*T),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/T),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/T),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(const W of this._rowElements)W.style.width=`${this.dimensions.css.canvas.width}px`,W.style.height=`${this.dimensions.css.cell.height}px`,W.style.lineHeight=`${this.dimensions.css.cell.height}px`,W.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const D=`${this._terminalSelector} .${C} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=D,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(T){this._themeStyleElement||(this._themeStyleElement=document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let D=`${this._terminalSelector} .${C} { color: ${T.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;D+=`${this._terminalSelector} .${C} .xterm-dim { color: ${a.color.multiplyOpacity(T.foreground,.5).css};}`,D+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`,D+="@keyframes blink_box_shadow_"+this._terminalClass+" { 50% { border-bottom-style: hidden; }}",D+="@keyframes blink_block_"+this._terminalClass+` { 0% { background-color: ${T.cursor.css}; color: ${T.cursorAccent.css}; } 50% { background-color: inherit; color: ${T.cursor.css}; }}`,D+=`${this._terminalSelector} .${C}.${_} .xterm-cursor.xterm-cursor-blink:not(.xterm-cursor-block) { animation: blink_box_shadow_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${C}.${_} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: blink_block_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-block { background-color: ${T.cursor.css}; color: ${T.cursorAccent.css};}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${T.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${T.cursor.css} inset;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${T.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,D+=`${this._terminalSelector} .${j} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${j} div { position: absolute; background-color: ${T.selectionBackgroundOpaque.css};}${this._terminalSelector} .${j} div { position: absolute; background-color: ${T.selectionInactiveBackgroundOpaque.css};}`;for(const[W,I]of T.ansi.entries())D+=`${this._terminalSelector} .${k}${W} { color: ${I.css}; }${this._terminalSelector} .${k}${W}.xterm-dim { color: ${a.color.multiplyOpacity(I,.5).css}; }${this._terminalSelector} .${E}${W} { background-color: ${I.css}; }`;D+=`${this._terminalSelector} .${k}${x.INVERTED_DEFAULT_COLOR} { color: ${a.color.opaque(T.background).css}; }${this._terminalSelector} .${k}${x.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${a.color.multiplyOpacity(a.color.opaque(T.background),.5).css}; }${this._terminalSelector} .${E}${x.INVERTED_DEFAULT_COLOR} { background-color: ${T.foreground.css}; }`,this._themeStyleElement.textContent=D}_setDefaultSpacing(){const T=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${T}px`,this._rowFactory.defaultSpacing=T}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(T,D){for(let W=this._rowElements.length;W<=D;W++){const I=document.createElement("div");this._rowContainer.appendChild(I),this._rowElements.push(I)}for(;this._rowElements.length>D;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(T,D){this._refreshRowElements(T,D),this._updateDimensions()}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(_)}handleFocus(){this._rowContainer.classList.add(_),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(T,D,W){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(T,D,W),this.renderRows(0,this._bufferService.rows-1),!T||!D)return;const I=T[1]-this._bufferService.buffer.ydisp,B=D[1]-this._bufferService.buffer.ydisp,F=Math.max(I,0),R=Math.min(B,this._bufferService.rows-1);if(F>=this._bufferService.rows||R<0)return;const M=document.createDocumentFragment();if(W){const L=T[0]>D[0];M.appendChild(this._createSelectionElement(F,L?D[0]:T[0],L?T[0]:D[0],R-F+1))}else{const L=I===F?T[0]:0,O=F===B?D[0]:this._bufferService.cols;M.appendChild(this._createSelectionElement(F,L,O));const U=R-F-1;if(M.appendChild(this._createSelectionElement(F+1,0,this._bufferService.cols,U)),F!==R){const Y=B===R?D[0]:this._bufferService.cols;M.appendChild(this._createSelectionElement(R,0,Y))}}this._selectionContainer.appendChild(M)}_createSelectionElement(T,D,W,I=1){const B=document.createElement("div");return B.style.height=I*this.dimensions.css.cell.height+"px",B.style.top=T*this.dimensions.css.cell.height+"px",B.style.left=D*this.dimensions.css.cell.width+"px",B.style.width=this.dimensions.css.cell.width*(W-D)+"px",B}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(const T of this._rowElements)T.replaceChildren()}renderRows(T,D){const W=this._bufferService.buffer,I=W.ybase+W.y,B=Math.min(W.x,this._bufferService.cols-1),F=this._optionsService.rawOptions.cursorBlink,R=this._optionsService.rawOptions.cursorStyle,M=this._optionsService.rawOptions.cursorInactiveStyle;for(let L=T;L<=D;L++){const O=L+W.ydisp,U=this._rowElements[L],Y=W.lines.get(O);if(!U||!Y)break;U.replaceChildren(...this._rowFactory.createRow(Y,O,O===I,R,M,B,F,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${b}${this._terminalClass}`}_handleLinkHover(T){this._setCellUnderline(T.x1,T.x2,T.y1,T.y2,T.cols,!0)}_handleLinkLeave(T){this._setCellUnderline(T.x1,T.x2,T.y1,T.y2,T.cols,!1)}_setCellUnderline(T,D,W,I,B,F){W<0&&(T=0),I<0&&(D=0);const R=this._bufferService.rows-1;W=Math.max(Math.min(W,R),0),I=Math.max(Math.min(I,R),0),B=Math.min(B,this._bufferService.cols);const M=this._bufferService.buffer,L=M.ybase+M.y,O=Math.min(M.x,B-1),U=this._optionsService.rawOptions.cursorBlink,Y=this._optionsService.rawOptions.cursorStyle,z=this._optionsService.rawOptions.cursorInactiveStyle;for(let $=W;$<=I;++$){const q=$+M.ydisp,N=this._rowElements[$],H=M.lines.get(q);if(!N||!H)break;N.replaceChildren(...this._rowFactory.createRow(H,q,q===L,Y,z,O,U,this.dimensions.css.cell.width,this._widthCache,F?$===W?T:0:-1,F?($===I?D:B)-1:-1))}}};n.DomRenderer=P=l([d(4,f.IInstantiationService),d(5,y.ICharSizeService),d(6,f.IOptionsService),d(7,f.IBufferService),d(8,y.ICoreBrowserService),d(9,y.IThemeService)],P)},3787:function(v,n,i){var l=this&&this.__decorate||function(k,E,_,j){var A,P=arguments.length,T=P<3?E:j===null?j=Object.getOwnPropertyDescriptor(E,_):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(k,E,_,j);else for(var D=k.length-1;D>=0;D--)(A=k[D])&&(T=(P<3?A(T):P>3?A(E,_,T):A(E,_))||T);return P>3&&T&&Object.defineProperty(E,_,T),T},d=this&&this.__param||function(k,E){return function(_,j){E(_,j,k)}};Object.defineProperty(n,"__esModule",{value:!0}),n.DomRendererRowFactory=void 0;const c=i(2223),m=i(643),x=i(511),w=i(2585),y=i(8055),a=i(4725),h=i(4269),u=i(6171),f=i(3734);let b=n.DomRendererRowFactory=class{constructor(k,E,_,j,A,P,T){this._document=k,this._characterJoinerService=E,this._optionsService=_,this._coreBrowserService=j,this._coreService=A,this._decorationService=P,this._themeService=T,this._workCell=new x.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(k,E,_){this._selectionStart=k,this._selectionEnd=E,this._columnSelectMode=_}createRow(k,E,_,j,A,P,T,D,W,I,B){const F=[],R=this._characterJoinerService.getJoinedCharacters(E),M=this._themeService.colors;let L,O=k.getNoBgTrimmedLength();_&&O<P+1&&(O=P+1);let U=0,Y="",z=0,$=0,q=0,N=!1,H=0,X=!1,K=0;const ne=[],te=I!==-1&&B!==-1;for(let he=0;he<O;he++){k.loadCell(he,this._workCell);let le=this._workCell.getWidth();if(le===0)continue;let G=!1,pe=he,ie=this._workCell;if(R.length>0&&he===R[0][0]){G=!0;const ge=R.shift();ie=new h.JoinedCellData(this._workCell,k.translateToString(!0,ge[0],ge[1]),ge[1]-ge[0]),pe=ge[1]-1,le=ie.getWidth()}const Ae=this._isCellInSelection(he,E),at=_&&he===P,Xe=te&&he>=I&&he<=B;let _e=!1;this._decorationService.forEachDecorationAtCell(he,E,void 0,(ge=>{_e=!0}));let Ie=ie.getChars()||m.WHITESPACE_CELL_CHAR;if(Ie===" "&&(ie.isUnderline()||ie.isOverline())&&(Ie=" "),K=le*D-W.get(Ie,ie.isBold(),ie.isItalic()),L){if(U&&(Ae&&X||!Ae&&!X&&ie.bg===z)&&(Ae&&X&&M.selectionForeground||ie.fg===$)&&ie.extended.ext===q&&Xe===N&&K===H&&!at&&!G&&!_e){Y+=Ie,U++;continue}U&&(L.textContent=Y),L=this._document.createElement("span"),U=0,Y=""}else L=this._document.createElement("span");if(z=ie.bg,$=ie.fg,q=ie.extended.ext,N=Xe,H=K,X=Ae,G&&P>=he&&P<=pe&&(P=he),!this._coreService.isCursorHidden&&at){if(ne.push("xterm-cursor"),this._coreBrowserService.isFocused)T&&ne.push("xterm-cursor-blink"),ne.push(j==="bar"?"xterm-cursor-bar":j==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(A)switch(A){case"outline":ne.push("xterm-cursor-outline");break;case"block":ne.push("xterm-cursor-block");break;case"bar":ne.push("xterm-cursor-bar");break;case"underline":ne.push("xterm-cursor-underline")}}if(ie.isBold()&&ne.push("xterm-bold"),ie.isItalic()&&ne.push("xterm-italic"),ie.isDim()&&ne.push("xterm-dim"),Y=ie.isInvisible()?m.WHITESPACE_CELL_CHAR:ie.getChars()||m.WHITESPACE_CELL_CHAR,ie.isUnderline()&&(ne.push(`xterm-underline-${ie.extended.underlineStyle}`),Y===" "&&(Y=" "),!ie.isUnderlineColorDefault()))if(ie.isUnderlineColorRGB())L.style.textDecorationColor=`rgb(${f.AttributeData.toColorRGB(ie.getUnderlineColor()).join(",")})`;else{let ge=ie.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&ie.isBold()&&ge<8&&(ge+=8),L.style.textDecorationColor=M.ansi[ge].css}ie.isOverline()&&(ne.push("xterm-overline"),Y===" "&&(Y=" ")),ie.isStrikethrough()&&ne.push("xterm-strikethrough"),Xe&&(L.style.textDecoration="underline");let Pe=ie.getFgColor(),$e=ie.getFgColorMode(),Oe=ie.getBgColor(),Ve=ie.getBgColorMode();const Ze=!!ie.isInverse();if(Ze){const ge=Pe;Pe=Oe,Oe=ge;const lt=$e;$e=Ve,Ve=lt}let Me,Re,ve,Fe=!1;switch(this._decorationService.forEachDecorationAtCell(he,E,void 0,(ge=>{ge.options.layer!=="top"&&Fe||(ge.backgroundColorRGB&&(Ve=50331648,Oe=ge.backgroundColorRGB.rgba>>8&16777215,Me=ge.backgroundColorRGB),ge.foregroundColorRGB&&($e=50331648,Pe=ge.foregroundColorRGB.rgba>>8&16777215,Re=ge.foregroundColorRGB),Fe=ge.options.layer==="top")})),!Fe&&Ae&&(Me=this._coreBrowserService.isFocused?M.selectionBackgroundOpaque:M.selectionInactiveBackgroundOpaque,Oe=Me.rgba>>8&16777215,Ve=50331648,Fe=!0,M.selectionForeground&&($e=50331648,Pe=M.selectionForeground.rgba>>8&16777215,Re=M.selectionForeground)),Fe&&ne.push("xterm-decoration-top"),Ve){case 16777216:case 33554432:ve=M.ansi[Oe],ne.push(`xterm-bg-${Oe}`);break;case 50331648:ve=y.rgba.toColor(Oe>>16,Oe>>8&255,255&Oe),this._addStyle(L,`background-color:#${C((Oe>>>0).toString(16),"0",6)}`);break;default:Ze?(ve=M.foreground,ne.push(`xterm-bg-${c.INVERTED_DEFAULT_COLOR}`)):ve=M.background}switch(Me||ie.isDim()&&(Me=y.color.multiplyOpacity(ve,.5)),$e){case 16777216:case 33554432:ie.isBold()&&Pe<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Pe+=8),this._applyMinimumContrast(L,ve,M.ansi[Pe],ie,Me,void 0)||ne.push(`xterm-fg-${Pe}`);break;case 50331648:const ge=y.rgba.toColor(Pe>>16&255,Pe>>8&255,255&Pe);this._applyMinimumContrast(L,ve,ge,ie,Me,Re)||this._addStyle(L,`color:#${C(Pe.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(L,ve,M.foreground,ie,Me,void 0)||Ze&&ne.push(`xterm-fg-${c.INVERTED_DEFAULT_COLOR}`)}ne.length&&(L.className=ne.join(" "),ne.length=0),at||G||_e?L.textContent=Y:U++,K!==this.defaultSpacing&&(L.style.letterSpacing=`${K}px`),F.push(L),he=pe}return L&&U&&(L.textContent=Y),F}_applyMinimumContrast(k,E,_,j,A,P){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,u.excludeFromContrastRatioDemands)(j.getCode()))return!1;const T=this._getContrastCache(j);let D;if(A||P||(D=T.getColor(E.rgba,_.rgba)),D===void 0){const W=this._optionsService.rawOptions.minimumContrastRatio/(j.isDim()?2:1);D=y.color.ensureContrastRatio(A||E,P||_,W),T.setColor((A||E).rgba,(P||_).rgba,D??null)}return!!D&&(this._addStyle(k,`color:${D.css}`),!0)}_getContrastCache(k){return k.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(k,E){k.setAttribute("style",`${k.getAttribute("style")||""}${E};`)}_isCellInSelection(k,E){const _=this._selectionStart,j=this._selectionEnd;return!(!_||!j)&&(this._columnSelectMode?_[0]<=j[0]?k>=_[0]&&E>=_[1]&&k<j[0]&&E<=j[1]:k<_[0]&&E>=_[1]&&k>=j[0]&&E<=j[1]:E>_[1]&&E<j[1]||_[1]===j[1]&&E===_[1]&&k>=_[0]&&k<j[0]||_[1]<j[1]&&E===j[1]&&k<j[0]||_[1]<j[1]&&E===_[1]&&k>=_[0])}};function C(k,E,_){for(;k.length<_;)k=E+k;return k}n.DomRendererRowFactory=b=l([d(1,a.ICharacterJoinerService),d(2,w.IOptionsService),d(3,a.ICoreBrowserService),d(4,w.ICoreService),d(5,w.IDecorationService),d(6,a.IThemeService)],b)},2550:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.WidthCache=void 0,n.WidthCache=class{constructor(i){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=i.createElement("div"),this._container.style.position="absolute",this._container.style.top="-50000px",this._container.style.width="50000px",this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";const l=i.createElement("span"),d=i.createElement("span");d.style.fontWeight="bold";const c=i.createElement("span");c.style.fontStyle="italic";const m=i.createElement("span");m.style.fontWeight="bold",m.style.fontStyle="italic",this._measureElements=[l,d,c,m],this._container.appendChild(l),this._container.appendChild(d),this._container.appendChild(c),this._container.appendChild(m),i.body.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(i,l,d,c){i===this._font&&l===this._fontSize&&d===this._weight&&c===this._weightBold||(this._font=i,this._fontSize=l,this._weight=d,this._weightBold=c,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${d}`,this._measureElements[1].style.fontWeight=`${c}`,this._measureElements[2].style.fontWeight=`${d}`,this._measureElements[3].style.fontWeight=`${c}`,this.clear())}get(i,l,d){let c=0;if(!l&&!d&&i.length===1&&(c=i.charCodeAt(0))<256)return this._flat[c]!==-9999?this._flat[c]:this._flat[c]=this._measure(i,0);let m=i;l&&(m+="B"),d&&(m+="I");let x=this._holey.get(m);if(x===void 0){let w=0;l&&(w|=1),d&&(w|=2),x=this._measure(i,w),this._holey.set(m,x)}return x}_measure(i,l){const d=this._measureElements[l];return d.textContent=i.repeat(32),d.offsetWidth/32}}},2223:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.TEXT_BASELINE=n.DIM_OPACITY=n.INVERTED_DEFAULT_COLOR=void 0;const l=i(6114);n.INVERTED_DEFAULT_COLOR=257,n.DIM_OPACITY=.5,n.TEXT_BASELINE=l.isFirefox||l.isLegacyEdge?"bottom":"ideographic"},6171:(v,n)=>{function i(l){return 57508<=l&&l<=57558}Object.defineProperty(n,"__esModule",{value:!0}),n.createRenderDimensions=n.excludeFromContrastRatioDemands=n.isRestrictedPowerlineGlyph=n.isPowerlineGlyph=n.throwIfFalsy=void 0,n.throwIfFalsy=function(l){if(!l)throw new Error("value must not be falsy");return l},n.isPowerlineGlyph=i,n.isRestrictedPowerlineGlyph=function(l){return 57520<=l&&l<=57527},n.excludeFromContrastRatioDemands=function(l){return i(l)||(function(d){return 9472<=d&&d<=9631})(l)},n.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}}},456:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.SelectionModel=void 0,n.SelectionModel=class{constructor(i){this._bufferService=i,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){const i=this.selectionStart[0]+this.selectionStartLength;return i>this._bufferService.cols?i%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)-1]:[i%this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)]:[i,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const i=this.selectionStart[0]+this.selectionStartLength;return i>this._bufferService.cols?[i%this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)]:[Math.max(i,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const i=this.selectionStart,l=this.selectionEnd;return!(!i||!l)&&(i[1]>l[1]||i[1]===l[1]&&i[0]>l[0])}handleTrim(i){return this.selectionStart&&(this.selectionStart[1]-=i),this.selectionEnd&&(this.selectionEnd[1]-=i),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(v,n,i){var l=this&&this.__decorate||function(a,h,u,f){var b,C=arguments.length,k=C<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,u):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,u,f);else for(var E=a.length-1;E>=0;E--)(b=a[E])&&(k=(C<3?b(k):C>3?b(h,u,k):b(h,u))||k);return C>3&&k&&Object.defineProperty(h,u,k),k},d=this&&this.__param||function(a,h){return function(u,f){h(u,f,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CharSizeService=void 0;const c=i(2585),m=i(8460),x=i(844);let w=n.CharSizeService=class extends x.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(a,h,u){super(),this._optionsService=u,this.width=0,this.height=0,this._onCharSizeChange=this.register(new m.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event,this._measureStrategy=new y(a,h,this._optionsService),this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const a=this._measureStrategy.measure();a.width===this.width&&a.height===this.height||(this.width=a.width,this.height=a.height,this._onCharSizeChange.fire())}};n.CharSizeService=w=l([d(2,c.IOptionsService)],w);class y{constructor(h,u,f){this._document=h,this._parentElement=u,this._optionsService=f,this._result={width:0,height:0},this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`;const h={height:Number(this._measureElement.offsetHeight),width:Number(this._measureElement.offsetWidth)};return h.width!==0&&h.height!==0&&(this._result.width=h.width/32,this._result.height=Math.ceil(h.height)),this._result}}},4269:function(v,n,i){var l=this&&this.__decorate||function(h,u,f,b){var C,k=arguments.length,E=k<3?u:b===null?b=Object.getOwnPropertyDescriptor(u,f):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(h,u,f,b);else for(var _=h.length-1;_>=0;_--)(C=h[_])&&(E=(k<3?C(E):k>3?C(u,f,E):C(u,f))||E);return k>3&&E&&Object.defineProperty(u,f,E),E},d=this&&this.__param||function(h,u){return function(f,b){u(f,b,h)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CharacterJoinerService=n.JoinedCellData=void 0;const c=i(3734),m=i(643),x=i(511),w=i(2585);class y extends c.AttributeData{constructor(u,f,b){super(),this.content=0,this.combinedData="",this.fg=u.fg,this.bg=u.bg,this.combinedData=f,this._width=b}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(u){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}n.JoinedCellData=y;let a=n.CharacterJoinerService=class Al{constructor(u){this._bufferService=u,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new x.CellData}register(u){const f={id:this._nextCharacterJoinerId++,handler:u};return this._characterJoiners.push(f),f.id}deregister(u){for(let f=0;f<this._characterJoiners.length;f++)if(this._characterJoiners[f].id===u)return this._characterJoiners.splice(f,1),!0;return!1}getJoinedCharacters(u){if(this._characterJoiners.length===0)return[];const f=this._bufferService.buffer.lines.get(u);if(!f||f.length===0)return[];const b=[],C=f.translateToString(!0);let k=0,E=0,_=0,j=f.getFg(0),A=f.getBg(0);for(let P=0;P<f.getTrimmedLength();P++)if(f.loadCell(P,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==j||this._workCell.bg!==A){if(P-k>1){const T=this._getJoinedRanges(C,_,E,f,k);for(let D=0;D<T.length;D++)b.push(T[D])}k=P,_=E,j=this._workCell.fg,A=this._workCell.bg}E+=this._workCell.getChars().length||m.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-k>1){const P=this._getJoinedRanges(C,_,E,f,k);for(let T=0;T<P.length;T++)b.push(P[T])}return b}_getJoinedRanges(u,f,b,C,k){const E=u.substring(f,b);let _=[];try{_=this._characterJoiners[0].handler(E)}catch(j){console.error(j)}for(let j=1;j<this._characterJoiners.length;j++)try{const A=this._characterJoiners[j].handler(E);for(let P=0;P<A.length;P++)Al._mergeRanges(_,A[P])}catch(A){console.error(A)}return this._stringRangesToCellRanges(_,C,k),_}_stringRangesToCellRanges(u,f,b){let C=0,k=!1,E=0,_=u[C];if(_){for(let j=b;j<this._bufferService.cols;j++){const A=f.getWidth(j),P=f.getString(j).length||m.WHITESPACE_CELL_CHAR.length;if(A!==0){if(!k&&_[0]<=E&&(_[0]=j,k=!0),_[1]<=E){if(_[1]=j,_=u[++C],!_)break;_[0]<=E?(_[0]=j,k=!0):k=!1}E+=P}}_&&(_[1]=this._bufferService.cols)}}static _mergeRanges(u,f){let b=!1;for(let C=0;C<u.length;C++){const k=u[C];if(b){if(f[1]<=k[0])return u[C-1][1]=f[1],u;if(f[1]<=k[1])return u[C-1][1]=Math.max(f[1],k[1]),u.splice(C,1),u;u.splice(C,1),C--}else{if(f[1]<=k[0])return u.splice(C,0,f),u;if(f[1]<=k[1])return k[0]=Math.min(f[0],k[0]),u;f[0]<k[1]&&(k[0]=Math.min(f[0],k[0]),b=!0)}}return b?u[u.length-1][1]=f[1]:u.push(f),u}};n.CharacterJoinerService=a=l([d(0,w.IBufferService)],a)},5114:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CoreBrowserService=void 0,n.CoreBrowserService=class{constructor(i,l){this._textarea=i,this.window=l,this._isFocused=!1,this._cachedIsFocused=void 0,this._textarea.addEventListener("focus",(()=>this._isFocused=!0)),this._textarea.addEventListener("blur",(()=>this._isFocused=!1))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask((()=>this._cachedIsFocused=void 0))),this._cachedIsFocused}}},8934:function(v,n,i){var l=this&&this.__decorate||function(w,y,a,h){var u,f=arguments.length,b=f<3?y:h===null?h=Object.getOwnPropertyDescriptor(y,a):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(w,y,a,h);else for(var C=w.length-1;C>=0;C--)(u=w[C])&&(b=(f<3?u(b):f>3?u(y,a,b):u(y,a))||b);return f>3&&b&&Object.defineProperty(y,a,b),b},d=this&&this.__param||function(w,y){return function(a,h){y(a,h,w)}};Object.defineProperty(n,"__esModule",{value:!0}),n.MouseService=void 0;const c=i(4725),m=i(9806);let x=n.MouseService=class{constructor(w,y){this._renderService=w,this._charSizeService=y}getCoords(w,y,a,h,u){return(0,m.getCoords)(window,w,y,a,h,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,u)}getMouseReportCoords(w,y){const a=(0,m.getCoordsRelativeToElement)(window,w,y);if(this._charSizeService.hasValidSize)return a[0]=Math.min(Math.max(a[0],0),this._renderService.dimensions.css.canvas.width-1),a[1]=Math.min(Math.max(a[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(a[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(a[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(a[0]),y:Math.floor(a[1])}}};n.MouseService=x=l([d(0,c.IRenderService),d(1,c.ICharSizeService)],x)},3230:function(v,n,i){var l=this&&this.__decorate||function(b,C,k,E){var _,j=arguments.length,A=j<3?C:E===null?E=Object.getOwnPropertyDescriptor(C,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(b,C,k,E);else for(var P=b.length-1;P>=0;P--)(_=b[P])&&(A=(j<3?_(A):j>3?_(C,k,A):_(C,k))||A);return j>3&&A&&Object.defineProperty(C,k,A),A},d=this&&this.__param||function(b,C){return function(k,E){C(k,E,b)}};Object.defineProperty(n,"__esModule",{value:!0}),n.RenderService=void 0;const c=i(3656),m=i(6193),x=i(5596),w=i(4725),y=i(8460),a=i(844),h=i(7226),u=i(2585);let f=n.RenderService=class extends a.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(b,C,k,E,_,j,A,P){if(super(),this._rowCount=b,this._charSizeService=E,this._renderer=this.register(new a.MutableDisposable),this._pausedResizeTask=new h.DebouncedIdleTask,this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this.register(new y.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new y.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new y.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new y.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new m.RenderDebouncer(A.window,((T,D)=>this._renderRows(T,D))),this.register(this._renderDebouncer),this._screenDprMonitor=new x.ScreenDprMonitor(A.window),this._screenDprMonitor.setListener((()=>this.handleDevicePixelRatioChange())),this.register(this._screenDprMonitor),this.register(j.onResize((()=>this._fullRefresh()))),this.register(j.buffers.onBufferActivate((()=>{var T;return(T=this._renderer.value)===null||T===void 0?void 0:T.clear()}))),this.register(k.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(_.onDecorationRegistered((()=>this._fullRefresh()))),this.register(_.onDecorationRemoved((()=>this._fullRefresh()))),this.register(k.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio"],(()=>{this.clear(),this.handleResize(j.cols,j.rows),this._fullRefresh()}))),this.register(k.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(j.buffer.y,j.buffer.y,!0)))),this.register((0,c.addDisposableDomListener)(A.window,"resize",(()=>this.handleDevicePixelRatioChange()))),this.register(P.onChangeColors((()=>this._fullRefresh()))),"IntersectionObserver"in A.window){const T=new A.window.IntersectionObserver((D=>this._handleIntersectionChange(D[D.length-1])),{threshold:0});T.observe(C),this.register({dispose:()=>T.disconnect()})}}_handleIntersectionChange(b){this._isPaused=b.isIntersecting===void 0?b.intersectionRatio===0:!b.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(b,C,k=!1){this._isPaused?this._needsFullRefresh=!0:(k||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(b,C,this._rowCount))}_renderRows(b,C){this._renderer.value&&(b=Math.min(b,this._rowCount-1),C=Math.min(C,this._rowCount-1),this._renderer.value.renderRows(b,C),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:b,end:C}),this._onRender.fire({start:b,end:C}),this._isNextRenderRedrawOnly=!0)}resize(b,C){this._rowCount=C,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(b){this._renderer.value=b,this._renderer.value.onRequestRedraw((C=>this.refreshRows(C.start,C.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh()}addRefreshCallback(b){return this._renderDebouncer.addRefreshCallback(b)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var b,C;this._renderer.value&&((C=(b=this._renderer.value).clearTextureAtlas)===null||C===void 0||C.call(b),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(b,C){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value.handleResize(b,C))):this._renderer.value.handleResize(b,C),this._fullRefresh())}handleCharSizeChanged(){var b;(b=this._renderer.value)===null||b===void 0||b.handleCharSizeChanged()}handleBlur(){var b;(b=this._renderer.value)===null||b===void 0||b.handleBlur()}handleFocus(){var b;(b=this._renderer.value)===null||b===void 0||b.handleFocus()}handleSelectionChanged(b,C,k){var E;this._selectionState.start=b,this._selectionState.end=C,this._selectionState.columnSelectMode=k,(E=this._renderer.value)===null||E===void 0||E.handleSelectionChanged(b,C,k)}handleCursorMove(){var b;(b=this._renderer.value)===null||b===void 0||b.handleCursorMove()}clear(){var b;(b=this._renderer.value)===null||b===void 0||b.clear()}};n.RenderService=f=l([d(2,u.IOptionsService),d(3,w.ICharSizeService),d(4,u.IDecorationService),d(5,u.IBufferService),d(6,w.ICoreBrowserService),d(7,w.IThemeService)],f)},9312:function(v,n,i){var l=this&&this.__decorate||function(_,j,A,P){var T,D=arguments.length,W=D<3?j:P===null?P=Object.getOwnPropertyDescriptor(j,A):P;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")W=Reflect.decorate(_,j,A,P);else for(var I=_.length-1;I>=0;I--)(T=_[I])&&(W=(D<3?T(W):D>3?T(j,A,W):T(j,A))||W);return D>3&&W&&Object.defineProperty(j,A,W),W},d=this&&this.__param||function(_,j){return function(A,P){j(A,P,_)}};Object.defineProperty(n,"__esModule",{value:!0}),n.SelectionService=void 0;const c=i(9806),m=i(9504),x=i(456),w=i(4725),y=i(8460),a=i(844),h=i(6114),u=i(4841),f=i(511),b=i(2585),C=" ",k=new RegExp(C,"g");let E=n.SelectionService=class extends a.Disposable{constructor(_,j,A,P,T,D,W,I,B){super(),this._element=_,this._screenElement=j,this._linkifier=A,this._bufferService=P,this._coreService=T,this._mouseService=D,this._optionsService=W,this._renderService=I,this._coreBrowserService=B,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new f.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new y.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new y.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new y.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new y.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=F=>this._handleMouseMove(F),this._mouseUpListener=F=>this._handleMouseUp(F),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((F=>this._handleTrim(F))),this.register(this._bufferService.buffers.onBufferActivate((F=>this._handleBufferActivate(F)))),this.enable(),this._model=new x.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,a.toDisposable)((()=>{this._removeMouseDownListeners()})))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){const _=this._model.finalSelectionStart,j=this._model.finalSelectionEnd;return!(!_||!j||_[0]===j[0]&&_[1]===j[1])}get selectionText(){const _=this._model.finalSelectionStart,j=this._model.finalSelectionEnd;if(!_||!j)return"";const A=this._bufferService.buffer,P=[];if(this._activeSelectionMode===3){if(_[0]===j[0])return"";const T=_[0]<j[0]?_[0]:j[0],D=_[0]<j[0]?j[0]:_[0];for(let W=_[1];W<=j[1];W++){const I=A.translateBufferLineToString(W,!0,T,D);P.push(I)}}else{const T=_[1]===j[1]?j[0]:void 0;P.push(A.translateBufferLineToString(_[1],!0,_[0],T));for(let D=_[1]+1;D<=j[1]-1;D++){const W=A.lines.get(D),I=A.translateBufferLineToString(D,!0);W?.isWrapped?P[P.length-1]+=I:P.push(I)}if(_[1]!==j[1]){const D=A.lines.get(j[1]),W=A.translateBufferLineToString(j[1],!0,0,j[0]);D&&D.isWrapped?P[P.length-1]+=W:P.push(W)}}return P.map((T=>T.replace(k," "))).join(h.isWindows?`\r
24
- `:`
25
- `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(_){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),h.isLinux&&_&&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(_){const j=this._getMouseBufferCoords(_),A=this._model.finalSelectionStart,P=this._model.finalSelectionEnd;return!!(A&&P&&j)&&this._areCoordsInSelection(j,A,P)}isCellInSelection(_,j){const A=this._model.finalSelectionStart,P=this._model.finalSelectionEnd;return!(!A||!P)&&this._areCoordsInSelection([_,j],A,P)}_areCoordsInSelection(_,j,A){return _[1]>j[1]&&_[1]<A[1]||j[1]===A[1]&&_[1]===j[1]&&_[0]>=j[0]&&_[0]<A[0]||j[1]<A[1]&&_[1]===A[1]&&_[0]<A[0]||j[1]<A[1]&&_[1]===j[1]&&_[0]>=j[0]}_selectWordAtCursor(_,j){var A,P;const T=(P=(A=this._linkifier.currentLink)===null||A===void 0?void 0:A.link)===null||P===void 0?void 0:P.range;if(T)return this._model.selectionStart=[T.start.x-1,T.start.y-1],this._model.selectionStartLength=(0,u.getRangeLength)(T,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const D=this._getMouseBufferCoords(_);return!!D&&(this._selectWordAt(D,j),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(_,j){this._model.clearSelection(),_=Math.max(_,0),j=Math.min(j,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,_],this._model.selectionEnd=[this._bufferService.cols,j],this.refresh(),this._onSelectionChange.fire()}_handleTrim(_){this._model.handleTrim(_)&&this.refresh()}_getMouseBufferCoords(_){const j=this._mouseService.getCoords(_,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(j)return j[0]--,j[1]--,j[1]+=this._bufferService.buffer.ydisp,j}_getMouseEventScrollAmount(_){let j=(0,c.getCoordsRelativeToElement)(this._coreBrowserService.window,_,this._screenElement)[1];const A=this._renderService.dimensions.css.canvas.height;return j>=0&&j<=A?0:(j>A&&(j-=A),j=Math.min(Math.max(j,-50),50),j/=50,j/Math.abs(j)+Math.round(14*j))}shouldForceSelection(_){return h.isMac?_.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:_.shiftKey}handleMouseDown(_){if(this._mouseDownTimeStamp=_.timeStamp,(_.button!==2||!this.hasSelection)&&_.button===0){if(!this._enabled){if(!this.shouldForceSelection(_))return;_.stopPropagation()}_.preventDefault(),this._dragScrollAmount=0,this._enabled&&_.shiftKey?this._handleIncrementalClick(_):_.detail===1?this._handleSingleClick(_):_.detail===2?this._handleDoubleClick(_):_.detail===3&&this._handleTripleClick(_),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(_){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(_))}_handleSingleClick(_){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(_)?3:0,this._model.selectionStart=this._getMouseBufferCoords(_),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const j=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);j&&j.length!==this._model.selectionStart[0]&&j.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(_){this._selectWordAtCursor(_,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(_){const j=this._getMouseBufferCoords(_);j&&(this._activeSelectionMode=2,this._selectLineAt(j[1]))}shouldColumnSelect(_){return _.altKey&&!(h.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(_){if(_.stopImmediatePropagation(),!this._model.selectionStart)return;const j=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(_),!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(_),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const A=this._bufferService.buffer;if(this._model.selectionEnd[1]<A.lines.length){const P=A.lines.get(this._model.selectionEnd[1]);P&&P.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]++}j&&j[0]===this._model.selectionEnd[0]&&j[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});const _=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(_.ydisp+this._bufferService.rows,_.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=_.ydisp),this.refresh()}}_handleMouseUp(_){const j=_.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&j<500&&_.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const A=this._mouseService.getCoords(_,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(A&&A[0]!==void 0&&A[1]!==void 0){const P=(0,m.moveToCellSequence)(A[0]-1,A[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(P,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const _=this._model.finalSelectionStart,j=this._model.finalSelectionEnd,A=!(!_||!j||_[0]===j[0]&&_[1]===j[1]);A?_&&j&&(this._oldSelectionStart&&this._oldSelectionEnd&&_[0]===this._oldSelectionStart[0]&&_[1]===this._oldSelectionStart[1]&&j[0]===this._oldSelectionEnd[0]&&j[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(_,j,A)):this._oldHasSelection&&this._fireOnSelectionChange(_,j,A)}_fireOnSelectionChange(_,j,A){this._oldSelectionStart=_,this._oldSelectionEnd=j,this._oldHasSelection=A,this._onSelectionChange.fire()}_handleBufferActivate(_){this.clearSelection(),this._trimListener.dispose(),this._trimListener=_.activeBuffer.lines.onTrim((j=>this._handleTrim(j)))}_convertViewportColToCharacterIndex(_,j){let A=j;for(let P=0;j>=P;P++){const T=_.loadCell(P,this._workCell).getChars().length;this._workCell.getWidth()===0?A--:T>1&&j!==P&&(A+=T-1)}return A}setSelection(_,j,A){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[_,j],this._model.selectionStartLength=A,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(_){this._isClickInSelection(_)||(this._selectWordAtCursor(_,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(_,j,A=!0,P=!0){if(_[0]>=this._bufferService.cols)return;const T=this._bufferService.buffer,D=T.lines.get(_[1]);if(!D)return;const W=T.translateBufferLineToString(_[1],!1);let I=this._convertViewportColToCharacterIndex(D,_[0]),B=I;const F=_[0]-I;let R=0,M=0,L=0,O=0;if(W.charAt(I)===" "){for(;I>0&&W.charAt(I-1)===" ";)I--;for(;B<W.length&&W.charAt(B+1)===" ";)B++}else{let z=_[0],$=_[0];D.getWidth(z)===0&&(R++,z--),D.getWidth($)===2&&(M++,$++);const q=D.getString($).length;for(q>1&&(O+=q-1,B+=q-1);z>0&&I>0&&!this._isCharWordSeparator(D.loadCell(z-1,this._workCell));){D.loadCell(z-1,this._workCell);const N=this._workCell.getChars().length;this._workCell.getWidth()===0?(R++,z--):N>1&&(L+=N-1,I-=N-1),I--,z--}for(;$<D.length&&B+1<W.length&&!this._isCharWordSeparator(D.loadCell($+1,this._workCell));){D.loadCell($+1,this._workCell);const N=this._workCell.getChars().length;this._workCell.getWidth()===2?(M++,$++):N>1&&(O+=N-1,B+=N-1),B++,$++}}B++;let U=I+F-R+L,Y=Math.min(this._bufferService.cols,B-I+R+M-L-O);if(j||W.slice(I,B).trim()!==""){if(A&&U===0&&D.getCodePoint(0)!==32){const z=T.lines.get(_[1]-1);if(z&&D.isWrapped&&z.getCodePoint(this._bufferService.cols-1)!==32){const $=this._getWordAt([this._bufferService.cols-1,_[1]-1],!1,!0,!1);if($){const q=this._bufferService.cols-$.start;U-=q,Y+=q}}}if(P&&U+Y===this._bufferService.cols&&D.getCodePoint(this._bufferService.cols-1)!==32){const z=T.lines.get(_[1]+1);if(z?.isWrapped&&z.getCodePoint(0)!==32){const $=this._getWordAt([0,_[1]+1],!1,!1,!0);$&&(Y+=$.length)}}return{start:U,length:Y}}}_selectWordAt(_,j){const A=this._getWordAt(_,j);if(A){for(;A.start<0;)A.start+=this._bufferService.cols,_[1]--;this._model.selectionStart=[A.start,_[1]],this._model.selectionStartLength=A.length}}_selectToWordAt(_){const j=this._getWordAt(_,!0);if(j){let A=_[1];for(;j.start<0;)j.start+=this._bufferService.cols,A--;if(!this._model.areSelectionValuesReversed())for(;j.start+j.length>this._bufferService.cols;)j.length-=this._bufferService.cols,A++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?j.start:j.start+j.length,A]}}_isCharWordSeparator(_){return _.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(_.getChars())>=0}_selectLineAt(_){const j=this._bufferService.buffer.getWrappedRangeForLine(_),A={start:{x:0,y:j.first},end:{x:this._bufferService.cols-1,y:j.last}};this._model.selectionStart=[0,j.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,u.getRangeLength)(A,this._bufferService.cols)}};n.SelectionService=E=l([d(3,b.IBufferService),d(4,b.ICoreService),d(5,w.IMouseService),d(6,b.IOptionsService),d(7,w.IRenderService),d(8,w.ICoreBrowserService)],E)},4725:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.IThemeService=n.ICharacterJoinerService=n.ISelectionService=n.IRenderService=n.IMouseService=n.ICoreBrowserService=n.ICharSizeService=void 0;const l=i(8343);n.ICharSizeService=(0,l.createDecorator)("CharSizeService"),n.ICoreBrowserService=(0,l.createDecorator)("CoreBrowserService"),n.IMouseService=(0,l.createDecorator)("MouseService"),n.IRenderService=(0,l.createDecorator)("RenderService"),n.ISelectionService=(0,l.createDecorator)("SelectionService"),n.ICharacterJoinerService=(0,l.createDecorator)("CharacterJoinerService"),n.IThemeService=(0,l.createDecorator)("ThemeService")},6731:function(v,n,i){var l=this&&this.__decorate||function(E,_,j,A){var P,T=arguments.length,D=T<3?_:A===null?A=Object.getOwnPropertyDescriptor(_,j):A;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(E,_,j,A);else for(var W=E.length-1;W>=0;W--)(P=E[W])&&(D=(T<3?P(D):T>3?P(_,j,D):P(_,j))||D);return T>3&&D&&Object.defineProperty(_,j,D),D},d=this&&this.__param||function(E,_){return function(j,A){_(j,A,E)}};Object.defineProperty(n,"__esModule",{value:!0}),n.ThemeService=n.DEFAULT_ANSI_COLORS=void 0;const c=i(7239),m=i(8055),x=i(8460),w=i(844),y=i(2585),a=m.css.toColor("#ffffff"),h=m.css.toColor("#000000"),u=m.css.toColor("#ffffff"),f=m.css.toColor("#000000"),b={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};n.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const E=[m.css.toColor("#2e3436"),m.css.toColor("#cc0000"),m.css.toColor("#4e9a06"),m.css.toColor("#c4a000"),m.css.toColor("#3465a4"),m.css.toColor("#75507b"),m.css.toColor("#06989a"),m.css.toColor("#d3d7cf"),m.css.toColor("#555753"),m.css.toColor("#ef2929"),m.css.toColor("#8ae234"),m.css.toColor("#fce94f"),m.css.toColor("#729fcf"),m.css.toColor("#ad7fa8"),m.css.toColor("#34e2e2"),m.css.toColor("#eeeeec")],_=[0,95,135,175,215,255];for(let j=0;j<216;j++){const A=_[j/36%6|0],P=_[j/6%6|0],T=_[j%6];E.push({css:m.channels.toCss(A,P,T),rgba:m.channels.toRgba(A,P,T)})}for(let j=0;j<24;j++){const A=8+10*j;E.push({css:m.channels.toCss(A,A,A),rgba:m.channels.toRgba(A,A,A)})}return E})());let C=n.ThemeService=class extends w.Disposable{get colors(){return this._colors}constructor(E){super(),this._optionsService=E,this._contrastCache=new c.ColorContrastCache,this._halfContrastCache=new c.ColorContrastCache,this._onChangeColors=this.register(new x.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:a,background:h,cursor:u,cursorAccent:f,selectionForeground:void 0,selectionBackgroundTransparent:b,selectionBackgroundOpaque:m.color.blend(h,b),selectionInactiveBackgroundTransparent:b,selectionInactiveBackgroundOpaque:m.color.blend(h,b),ansi:n.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this.register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",(()=>this._contrastCache.clear()))),this.register(this._optionsService.onSpecificOptionChange("theme",(()=>this._setTheme(this._optionsService.rawOptions.theme))))}_setTheme(E={}){const _=this._colors;if(_.foreground=k(E.foreground,a),_.background=k(E.background,h),_.cursor=k(E.cursor,u),_.cursorAccent=k(E.cursorAccent,f),_.selectionBackgroundTransparent=k(E.selectionBackground,b),_.selectionBackgroundOpaque=m.color.blend(_.background,_.selectionBackgroundTransparent),_.selectionInactiveBackgroundTransparent=k(E.selectionInactiveBackground,_.selectionBackgroundTransparent),_.selectionInactiveBackgroundOpaque=m.color.blend(_.background,_.selectionInactiveBackgroundTransparent),_.selectionForeground=E.selectionForeground?k(E.selectionForeground,m.NULL_COLOR):void 0,_.selectionForeground===m.NULL_COLOR&&(_.selectionForeground=void 0),m.color.isOpaque(_.selectionBackgroundTransparent)&&(_.selectionBackgroundTransparent=m.color.opacity(_.selectionBackgroundTransparent,.3)),m.color.isOpaque(_.selectionInactiveBackgroundTransparent)&&(_.selectionInactiveBackgroundTransparent=m.color.opacity(_.selectionInactiveBackgroundTransparent,.3)),_.ansi=n.DEFAULT_ANSI_COLORS.slice(),_.ansi[0]=k(E.black,n.DEFAULT_ANSI_COLORS[0]),_.ansi[1]=k(E.red,n.DEFAULT_ANSI_COLORS[1]),_.ansi[2]=k(E.green,n.DEFAULT_ANSI_COLORS[2]),_.ansi[3]=k(E.yellow,n.DEFAULT_ANSI_COLORS[3]),_.ansi[4]=k(E.blue,n.DEFAULT_ANSI_COLORS[4]),_.ansi[5]=k(E.magenta,n.DEFAULT_ANSI_COLORS[5]),_.ansi[6]=k(E.cyan,n.DEFAULT_ANSI_COLORS[6]),_.ansi[7]=k(E.white,n.DEFAULT_ANSI_COLORS[7]),_.ansi[8]=k(E.brightBlack,n.DEFAULT_ANSI_COLORS[8]),_.ansi[9]=k(E.brightRed,n.DEFAULT_ANSI_COLORS[9]),_.ansi[10]=k(E.brightGreen,n.DEFAULT_ANSI_COLORS[10]),_.ansi[11]=k(E.brightYellow,n.DEFAULT_ANSI_COLORS[11]),_.ansi[12]=k(E.brightBlue,n.DEFAULT_ANSI_COLORS[12]),_.ansi[13]=k(E.brightMagenta,n.DEFAULT_ANSI_COLORS[13]),_.ansi[14]=k(E.brightCyan,n.DEFAULT_ANSI_COLORS[14]),_.ansi[15]=k(E.brightWhite,n.DEFAULT_ANSI_COLORS[15]),E.extendedAnsi){const j=Math.min(_.ansi.length-16,E.extendedAnsi.length);for(let A=0;A<j;A++)_.ansi[A+16]=k(E.extendedAnsi[A],n.DEFAULT_ANSI_COLORS[A+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 _=0;_<this._restoreColors.ansi.length;++_)this._colors.ansi[_]=this._restoreColors.ansi[_]}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,_){if(E!==void 0)try{return m.css.toColor(E)}catch{}return _}n.ThemeService=C=l([d(0,y.IOptionsService)],C)},6349:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CircularList=void 0;const l=i(8460),d=i(844);class c extends d.Disposable{constructor(x){super(),this._maxLength=x,this.onDeleteEmitter=this.register(new l.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new l.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new l.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(x){if(this._maxLength===x)return;const w=new Array(x);for(let y=0;y<Math.min(x,this.length);y++)w[y]=this._array[this._getCyclicIndex(y)];this._array=w,this._maxLength=x,this._startIndex=0}get length(){return this._length}set length(x){if(x>this._length)for(let w=this._length;w<x;w++)this._array[w]=void 0;this._length=x}get(x){return this._array[this._getCyclicIndex(x)]}set(x,w){this._array[this._getCyclicIndex(x)]=w}push(x){this._array[this._getCyclicIndex(this._length)]=x,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(x,w,...y){if(w){for(let a=x;a<this._length-w;a++)this._array[this._getCyclicIndex(a)]=this._array[this._getCyclicIndex(a+w)];this._length-=w,this.onDeleteEmitter.fire({index:x,amount:w})}for(let a=this._length-1;a>=x;a--)this._array[this._getCyclicIndex(a+y.length)]=this._array[this._getCyclicIndex(a)];for(let a=0;a<y.length;a++)this._array[this._getCyclicIndex(x+a)]=y[a];if(y.length&&this.onInsertEmitter.fire({index:x,amount:y.length}),this._length+y.length>this._maxLength){const a=this._length+y.length-this._maxLength;this._startIndex+=a,this._length=this._maxLength,this.onTrimEmitter.fire(a)}else this._length+=y.length}trimStart(x){x>this._length&&(x=this._length),this._startIndex+=x,this._length-=x,this.onTrimEmitter.fire(x)}shiftElements(x,w,y){if(!(w<=0)){if(x<0||x>=this._length)throw new Error("start argument out of range");if(x+y<0)throw new Error("Cannot shift elements in list beyond index 0");if(y>0){for(let h=w-1;h>=0;h--)this.set(x+h+y,this.get(x+h));const a=x+w+y-this._length;if(a>0)for(this._length+=a;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let a=0;a<w;a++)this.set(x+a+y,this.get(x+a))}}_getCyclicIndex(x){return(this._startIndex+x)%this._maxLength}}n.CircularList=c},1439:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.clone=void 0,n.clone=function i(l,d=5){if(typeof l!="object")return l;const c=Array.isArray(l)?[]:{};for(const m in l)c[m]=d<=1?l[m]:l[m]&&i(l[m],d-1);return c}},8055:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.contrastRatio=n.toPaddedHex=n.rgba=n.rgb=n.css=n.color=n.channels=n.NULL_COLOR=void 0;const l=i(6114);let d=0,c=0,m=0,x=0;var w,y,a,h,u;function f(C){const k=C.toString(16);return k.length<2?"0"+k:k}function b(C,k){return C<k?(k+.05)/(C+.05):(C+.05)/(k+.05)}n.NULL_COLOR={css:"#00000000",rgba:0},(function(C){C.toCss=function(k,E,_,j){return j!==void 0?`#${f(k)}${f(E)}${f(_)}${f(j)}`:`#${f(k)}${f(E)}${f(_)}`},C.toRgba=function(k,E,_,j=255){return(k<<24|E<<16|_<<8|j)>>>0}})(w||(n.channels=w={})),(function(C){function k(E,_){return x=Math.round(255*_),[d,c,m]=u.toChannels(E.rgba),{css:w.toCss(d,c,m,x),rgba:w.toRgba(d,c,m,x)}}C.blend=function(E,_){if(x=(255&_.rgba)/255,x===1)return{css:_.css,rgba:_.rgba};const j=_.rgba>>24&255,A=_.rgba>>16&255,P=_.rgba>>8&255,T=E.rgba>>24&255,D=E.rgba>>16&255,W=E.rgba>>8&255;return d=T+Math.round((j-T)*x),c=D+Math.round((A-D)*x),m=W+Math.round((P-W)*x),{css:w.toCss(d,c,m),rgba:w.toRgba(d,c,m)}},C.isOpaque=function(E){return(255&E.rgba)==255},C.ensureContrastRatio=function(E,_,j){const A=u.ensureContrastRatio(E.rgba,_.rgba,j);if(A)return u.toColor(A>>24&255,A>>16&255,A>>8&255)},C.opaque=function(E){const _=(255|E.rgba)>>>0;return[d,c,m]=u.toChannels(_),{css:w.toCss(d,c,m),rgba:_}},C.opacity=k,C.multiplyOpacity=function(E,_){return x=255&E.rgba,k(E,x*_/255)},C.toColorRGB=function(E){return[E.rgba>>24&255,E.rgba>>16&255,E.rgba>>8&255]}})(y||(n.color=y={})),(function(C){let k,E;if(!l.isNode){const _=document.createElement("canvas");_.width=1,_.height=1;const j=_.getContext("2d",{willReadFrequently:!0});j&&(k=j,k.globalCompositeOperation="copy",E=k.createLinearGradient(0,0,1,1))}C.toColor=function(_){if(_.match(/#[\da-f]{3,8}/i))switch(_.length){case 4:return d=parseInt(_.slice(1,2).repeat(2),16),c=parseInt(_.slice(2,3).repeat(2),16),m=parseInt(_.slice(3,4).repeat(2),16),u.toColor(d,c,m);case 5:return d=parseInt(_.slice(1,2).repeat(2),16),c=parseInt(_.slice(2,3).repeat(2),16),m=parseInt(_.slice(3,4).repeat(2),16),x=parseInt(_.slice(4,5).repeat(2),16),u.toColor(d,c,m,x);case 7:return{css:_,rgba:(parseInt(_.slice(1),16)<<8|255)>>>0};case 9:return{css:_,rgba:parseInt(_.slice(1),16)>>>0}}const j=_.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(j)return d=parseInt(j[1]),c=parseInt(j[2]),m=parseInt(j[3]),x=Math.round(255*(j[5]===void 0?1:parseFloat(j[5]))),u.toColor(d,c,m,x);if(!k||!E)throw new Error("css.toColor: Unsupported css format");if(k.fillStyle=E,k.fillStyle=_,typeof k.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(k.fillRect(0,0,1,1),[d,c,m,x]=k.getImageData(0,0,1,1).data,x!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:w.toRgba(d,c,m,x),css:_}}})(a||(n.css=a={})),(function(C){function k(E,_,j){const A=E/255,P=_/255,T=j/255;return .2126*(A<=.03928?A/12.92:Math.pow((A+.055)/1.055,2.4))+.7152*(P<=.03928?P/12.92:Math.pow((P+.055)/1.055,2.4))+.0722*(T<=.03928?T/12.92:Math.pow((T+.055)/1.055,2.4))}C.relativeLuminance=function(E){return k(E>>16&255,E>>8&255,255&E)},C.relativeLuminance2=k})(h||(n.rgb=h={})),(function(C){function k(_,j,A){const P=_>>24&255,T=_>>16&255,D=_>>8&255;let W=j>>24&255,I=j>>16&255,B=j>>8&255,F=b(h.relativeLuminance2(W,I,B),h.relativeLuminance2(P,T,D));for(;F<A&&(W>0||I>0||B>0);)W-=Math.max(0,Math.ceil(.1*W)),I-=Math.max(0,Math.ceil(.1*I)),B-=Math.max(0,Math.ceil(.1*B)),F=b(h.relativeLuminance2(W,I,B),h.relativeLuminance2(P,T,D));return(W<<24|I<<16|B<<8|255)>>>0}function E(_,j,A){const P=_>>24&255,T=_>>16&255,D=_>>8&255;let W=j>>24&255,I=j>>16&255,B=j>>8&255,F=b(h.relativeLuminance2(W,I,B),h.relativeLuminance2(P,T,D));for(;F<A&&(W<255||I<255||B<255);)W=Math.min(255,W+Math.ceil(.1*(255-W))),I=Math.min(255,I+Math.ceil(.1*(255-I))),B=Math.min(255,B+Math.ceil(.1*(255-B))),F=b(h.relativeLuminance2(W,I,B),h.relativeLuminance2(P,T,D));return(W<<24|I<<16|B<<8|255)>>>0}C.ensureContrastRatio=function(_,j,A){const P=h.relativeLuminance(_>>8),T=h.relativeLuminance(j>>8);if(b(P,T)<A){if(T<P){const I=k(_,j,A),B=b(P,h.relativeLuminance(I>>8));if(B<A){const F=E(_,j,A);return B>b(P,h.relativeLuminance(F>>8))?I:F}return I}const D=E(_,j,A),W=b(P,h.relativeLuminance(D>>8));if(W<A){const I=k(_,j,A);return W>b(P,h.relativeLuminance(I>>8))?D:I}return D}},C.reduceLuminance=k,C.increaseLuminance=E,C.toChannels=function(_){return[_>>24&255,_>>16&255,_>>8&255,255&_]},C.toColor=function(_,j,A,P){return{css:w.toCss(_,j,A,P),rgba:w.toRgba(_,j,A,P)}}})(u||(n.rgba=u={})),n.toPaddedHex=f,n.contrastRatio=b},8969:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CoreTerminal=void 0;const l=i(844),d=i(2585),c=i(4348),m=i(7866),x=i(744),w=i(7302),y=i(6975),a=i(8460),h=i(1753),u=i(1480),f=i(7994),b=i(9282),C=i(5435),k=i(5981),E=i(2660);let _=!1;class j extends l.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new a.EventEmitter),this._onScroll.event((P=>{var T;(T=this._onScrollApi)===null||T===void 0||T.fire(P.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(P){for(const T in P)this.optionsService.options[T]=P[T]}constructor(P){super(),this._windowsWrappingHeuristics=this.register(new l.MutableDisposable),this._onBinary=this.register(new a.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new a.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new a.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new a.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new a.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new a.EventEmitter),this._instantiationService=new c.InstantiationService,this.optionsService=this.register(new w.OptionsService(P)),this._instantiationService.setService(d.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(x.BufferService)),this._instantiationService.setService(d.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(m.LogService)),this._instantiationService.setService(d.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(y.CoreService)),this._instantiationService.setService(d.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(h.CoreMouseService)),this._instantiationService.setService(d.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(u.UnicodeService)),this._instantiationService.setService(d.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(f.CharsetService),this._instantiationService.setService(d.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(E.OscLinkService),this._instantiationService.setService(d.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new C.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,a.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,a.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,a.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,a.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom((()=>this.scrollToBottom()))),this.register(this.coreService.onUserInput((()=>this._writeBuffer.handleUserInput()))),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],(()=>this._handleWindowsPtyOptionChange()))),this.register(this._bufferService.onScroll((T=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this.register(this._inputHandler.onScroll((T=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new k.WriteBuffer(((T,D)=>this._inputHandler.parse(T,D)))),this.register((0,a.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(P,T){this._writeBuffer.write(P,T)}writeSync(P,T){this._logService.logLevel<=d.LogLevelEnum.WARN&&!_&&(this._logService.warn("writeSync is unreliable and will be removed soon."),_=!0),this._writeBuffer.writeSync(P,T)}resize(P,T){isNaN(P)||isNaN(T)||(P=Math.max(P,x.MINIMUM_COLS),T=Math.max(T,x.MINIMUM_ROWS),this._bufferService.resize(P,T))}scroll(P,T=!1){this._bufferService.scroll(P,T)}scrollLines(P,T,D){this._bufferService.scrollLines(P,T,D)}scrollPages(P){this.scrollLines(P*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(P){const T=P-this._bufferService.buffer.ydisp;T!==0&&this.scrollLines(T)}registerEscHandler(P,T){return this._inputHandler.registerEscHandler(P,T)}registerDcsHandler(P,T){return this._inputHandler.registerDcsHandler(P,T)}registerCsiHandler(P,T){return this._inputHandler.registerCsiHandler(P,T)}registerOscHandler(P,T){return this._inputHandler.registerOscHandler(P,T)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let P=!1;const T=this.optionsService.rawOptions.windowsPty;T&&T.buildNumber!==void 0&&T.buildNumber!==void 0?P=T.backend==="conpty"&&T.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(P=!0),P?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const P=[];P.push(this.onLineFeed(b.updateWindowsModeWrappedState.bind(null,this._bufferService))),P.push(this.registerCsiHandler({final:"H"},(()=>((0,b.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,l.toDisposable)((()=>{for(const T of P)T.dispose()}))}}}n.CoreTerminal=j},8460:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.forwardEvent=n.EventEmitter=void 0,n.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=i=>(this._listeners.push(i),{dispose:()=>{if(!this._disposed){for(let l=0;l<this._listeners.length;l++)if(this._listeners[l]===i)return void this._listeners.splice(l,1)}}})),this._event}fire(i,l){const d=[];for(let c=0;c<this._listeners.length;c++)d.push(this._listeners[c]);for(let c=0;c<d.length;c++)d[c].call(void 0,i,l)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},n.forwardEvent=function(i,l){return i((d=>l.fire(d)))}},5435:function(v,n,i){var l=this&&this.__decorate||function(F,R,M,L){var O,U=arguments.length,Y=U<3?R:L===null?L=Object.getOwnPropertyDescriptor(R,M):L;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")Y=Reflect.decorate(F,R,M,L);else for(var z=F.length-1;z>=0;z--)(O=F[z])&&(Y=(U<3?O(Y):U>3?O(R,M,Y):O(R,M))||Y);return U>3&&Y&&Object.defineProperty(R,M,Y),Y},d=this&&this.__param||function(F,R){return function(M,L){R(M,L,F)}};Object.defineProperty(n,"__esModule",{value:!0}),n.InputHandler=n.WindowsOptionsReportType=void 0;const c=i(2584),m=i(7116),x=i(2015),w=i(844),y=i(482),a=i(8437),h=i(8460),u=i(643),f=i(511),b=i(3734),C=i(2585),k=i(6242),E=i(6351),_=i(5941),j={"(":0,")":1,"*":2,"+":3,"-":1,".":2},A=131072;function P(F,R){if(F>24)return R.setWinLines||!1;switch(F){case 1:return!!R.restoreWin;case 2:return!!R.minimizeWin;case 3:return!!R.setWinPosition;case 4:return!!R.setWinSizePixels;case 5:return!!R.raiseWin;case 6:return!!R.lowerWin;case 7:return!!R.refreshWin;case 8:return!!R.setWinSizeChars;case 9:return!!R.maximizeWin;case 10:return!!R.fullscreenWin;case 11:return!!R.getWinState;case 13:return!!R.getWinPosition;case 14:return!!R.getWinSizePixels;case 15:return!!R.getScreenSizePixels;case 16:return!!R.getCellSizePixels;case 18:return!!R.getWinSizeChars;case 19:return!!R.getScreenSizeChars;case 20:return!!R.getIconTitle;case 21:return!!R.getWinTitle;case 22:return!!R.pushTitle;case 23:return!!R.popTitle;case 24:return!!R.setWinLines}return!1}var T;(function(F){F[F.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",F[F.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(T||(n.WindowsOptionsReportType=T={}));let D=0;class W extends w.Disposable{getAttrData(){return this._curAttrData}constructor(R,M,L,O,U,Y,z,$,q=new x.EscapeSequenceParser){super(),this._bufferService=R,this._charsetService=M,this._coreService=L,this._logService=O,this._optionsService=U,this._oscLinkService=Y,this._coreMouseService=z,this._unicodeService=$,this._parser=q,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new y.StringToUtf32,this._utf8Decoder=new y.Utf8ToUtf32,this._workCell=new f.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=a.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=a.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new h.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new h.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new h.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new h.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new h.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new h.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new h.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new h.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new h.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new h.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new h.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new h.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new h.EventEmitter),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this.register(this._parser),this._dirtyRowTracker=new I(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((N=>this._activeBuffer=N.activeBuffer))),this._parser.setCsiHandlerFallback(((N,H)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(N),params:H.toArray()})})),this._parser.setEscHandlerFallback((N=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(N)})})),this._parser.setExecuteHandlerFallback((N=>{this._logService.debug("Unknown EXECUTE code: ",{code:N})})),this._parser.setOscHandlerFallback(((N,H,X)=>{this._logService.debug("Unknown OSC code: ",{identifier:N,action:H,data:X})})),this._parser.setDcsHandlerFallback(((N,H,X)=>{H==="HOOK"&&(X=X.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(N),action:H,payload:X})})),this._parser.setPrintHandler(((N,H,X)=>this.print(N,H,X))),this._parser.registerCsiHandler({final:"@"},(N=>this.insertChars(N))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(N=>this.scrollLeft(N))),this._parser.registerCsiHandler({final:"A"},(N=>this.cursorUp(N))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(N=>this.scrollRight(N))),this._parser.registerCsiHandler({final:"B"},(N=>this.cursorDown(N))),this._parser.registerCsiHandler({final:"C"},(N=>this.cursorForward(N))),this._parser.registerCsiHandler({final:"D"},(N=>this.cursorBackward(N))),this._parser.registerCsiHandler({final:"E"},(N=>this.cursorNextLine(N))),this._parser.registerCsiHandler({final:"F"},(N=>this.cursorPrecedingLine(N))),this._parser.registerCsiHandler({final:"G"},(N=>this.cursorCharAbsolute(N))),this._parser.registerCsiHandler({final:"H"},(N=>this.cursorPosition(N))),this._parser.registerCsiHandler({final:"I"},(N=>this.cursorForwardTab(N))),this._parser.registerCsiHandler({final:"J"},(N=>this.eraseInDisplay(N,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(N=>this.eraseInDisplay(N,!0))),this._parser.registerCsiHandler({final:"K"},(N=>this.eraseInLine(N,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(N=>this.eraseInLine(N,!0))),this._parser.registerCsiHandler({final:"L"},(N=>this.insertLines(N))),this._parser.registerCsiHandler({final:"M"},(N=>this.deleteLines(N))),this._parser.registerCsiHandler({final:"P"},(N=>this.deleteChars(N))),this._parser.registerCsiHandler({final:"S"},(N=>this.scrollUp(N))),this._parser.registerCsiHandler({final:"T"},(N=>this.scrollDown(N))),this._parser.registerCsiHandler({final:"X"},(N=>this.eraseChars(N))),this._parser.registerCsiHandler({final:"Z"},(N=>this.cursorBackwardTab(N))),this._parser.registerCsiHandler({final:"`"},(N=>this.charPosAbsolute(N))),this._parser.registerCsiHandler({final:"a"},(N=>this.hPositionRelative(N))),this._parser.registerCsiHandler({final:"b"},(N=>this.repeatPrecedingCharacter(N))),this._parser.registerCsiHandler({final:"c"},(N=>this.sendDeviceAttributesPrimary(N))),this._parser.registerCsiHandler({prefix:">",final:"c"},(N=>this.sendDeviceAttributesSecondary(N))),this._parser.registerCsiHandler({final:"d"},(N=>this.linePosAbsolute(N))),this._parser.registerCsiHandler({final:"e"},(N=>this.vPositionRelative(N))),this._parser.registerCsiHandler({final:"f"},(N=>this.hVPosition(N))),this._parser.registerCsiHandler({final:"g"},(N=>this.tabClear(N))),this._parser.registerCsiHandler({final:"h"},(N=>this.setMode(N))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(N=>this.setModePrivate(N))),this._parser.registerCsiHandler({final:"l"},(N=>this.resetMode(N))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(N=>this.resetModePrivate(N))),this._parser.registerCsiHandler({final:"m"},(N=>this.charAttributes(N))),this._parser.registerCsiHandler({final:"n"},(N=>this.deviceStatus(N))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(N=>this.deviceStatusPrivate(N))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(N=>this.softReset(N))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(N=>this.setCursorStyle(N))),this._parser.registerCsiHandler({final:"r"},(N=>this.setScrollRegion(N))),this._parser.registerCsiHandler({final:"s"},(N=>this.saveCursor(N))),this._parser.registerCsiHandler({final:"t"},(N=>this.windowOptions(N))),this._parser.registerCsiHandler({final:"u"},(N=>this.restoreCursor(N))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(N=>this.insertColumns(N))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(N=>this.deleteColumns(N))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(N=>this.selectProtected(N))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(N=>this.requestMode(N,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(N=>this.requestMode(N,!1))),this._parser.setExecuteHandler(c.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(c.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(c.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(c.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(c.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(c.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(c.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(c.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(c.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new k.OscHandler((N=>(this.setTitle(N),this.setIconName(N),!0)))),this._parser.registerOscHandler(1,new k.OscHandler((N=>this.setIconName(N)))),this._parser.registerOscHandler(2,new k.OscHandler((N=>this.setTitle(N)))),this._parser.registerOscHandler(4,new k.OscHandler((N=>this.setOrReportIndexedColor(N)))),this._parser.registerOscHandler(8,new k.OscHandler((N=>this.setHyperlink(N)))),this._parser.registerOscHandler(10,new k.OscHandler((N=>this.setOrReportFgColor(N)))),this._parser.registerOscHandler(11,new k.OscHandler((N=>this.setOrReportBgColor(N)))),this._parser.registerOscHandler(12,new k.OscHandler((N=>this.setOrReportCursorColor(N)))),this._parser.registerOscHandler(104,new k.OscHandler((N=>this.restoreIndexedColor(N)))),this._parser.registerOscHandler(110,new k.OscHandler((N=>this.restoreFgColor(N)))),this._parser.registerOscHandler(111,new k.OscHandler((N=>this.restoreBgColor(N)))),this._parser.registerOscHandler(112,new k.OscHandler((N=>this.restoreCursorColor(N)))),this._parser.registerEscHandler({final:"7"},(()=>this.saveCursor())),this._parser.registerEscHandler({final:"8"},(()=>this.restoreCursor())),this._parser.registerEscHandler({final:"D"},(()=>this.index())),this._parser.registerEscHandler({final:"E"},(()=>this.nextLine())),this._parser.registerEscHandler({final:"H"},(()=>this.tabSet())),this._parser.registerEscHandler({final:"M"},(()=>this.reverseIndex())),this._parser.registerEscHandler({final:"="},(()=>this.keypadApplicationMode())),this._parser.registerEscHandler({final:">"},(()=>this.keypadNumericMode())),this._parser.registerEscHandler({final:"c"},(()=>this.fullReset())),this._parser.registerEscHandler({final:"n"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"o"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"|"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"}"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"~"},(()=>this.setgLevel(1))),this._parser.registerEscHandler({intermediates:"%",final:"@"},(()=>this.selectDefaultCharset())),this._parser.registerEscHandler({intermediates:"%",final:"G"},(()=>this.selectDefaultCharset()));for(const N in m.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:N},(()=>this.selectCharset("("+N))),this._parser.registerEscHandler({intermediates:")",final:N},(()=>this.selectCharset(")"+N))),this._parser.registerEscHandler({intermediates:"*",final:N},(()=>this.selectCharset("*"+N))),this._parser.registerEscHandler({intermediates:"+",final:N},(()=>this.selectCharset("+"+N))),this._parser.registerEscHandler({intermediates:"-",final:N},(()=>this.selectCharset("-"+N))),this._parser.registerEscHandler({intermediates:".",final:N},(()=>this.selectCharset("."+N))),this._parser.registerEscHandler({intermediates:"/",final:N},(()=>this.selectCharset("/"+N)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((N=>(this._logService.error("Parsing error: ",N),N))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new E.DcsHandler(((N,H)=>this.requestStatusString(N,H))))}_preserveStack(R,M,L,O){this._parseStack.paused=!0,this._parseStack.cursorStartX=R,this._parseStack.cursorStartY=M,this._parseStack.decodedLength=L,this._parseStack.position=O}_logSlowResolvingAsync(R){this._logService.logLevel<=C.LogLevelEnum.WARN&&Promise.race([R,new Promise(((M,L)=>setTimeout((()=>L("#SLOW_TIMEOUT")),5e3)))]).catch((M=>{if(M!=="#SLOW_TIMEOUT")throw M;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(R,M){let L,O=this._activeBuffer.x,U=this._activeBuffer.y,Y=0;const z=this._parseStack.paused;if(z){if(L=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,M))return this._logSlowResolvingAsync(L),L;O=this._parseStack.cursorStartX,U=this._parseStack.cursorStartY,this._parseStack.paused=!1,R.length>A&&(Y=this._parseStack.position+A)}if(this._logService.logLevel<=C.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof R=="string"?` "${R}"`:` "${Array.prototype.map.call(R,($=>String.fromCharCode($))).join("")}"`),typeof R=="string"?R.split("").map(($=>$.charCodeAt(0))):R),this._parseBuffer.length<R.length&&this._parseBuffer.length<A&&(this._parseBuffer=new Uint32Array(Math.min(R.length,A))),z||this._dirtyRowTracker.clearRange(),R.length>A)for(let $=Y;$<R.length;$+=A){const q=$+A<R.length?$+A:R.length,N=typeof R=="string"?this._stringDecoder.decode(R.substring($,q),this._parseBuffer):this._utf8Decoder.decode(R.subarray($,q),this._parseBuffer);if(L=this._parser.parse(this._parseBuffer,N))return this._preserveStack(O,U,N,$),this._logSlowResolvingAsync(L),L}else if(!z){const $=typeof R=="string"?this._stringDecoder.decode(R,this._parseBuffer):this._utf8Decoder.decode(R,this._parseBuffer);if(L=this._parser.parse(this._parseBuffer,$))return this._preserveStack(O,U,$,0),this._logSlowResolvingAsync(L),L}this._activeBuffer.x===O&&this._activeBuffer.y===U||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowTracker.start,this._dirtyRowTracker.end)}print(R,M,L){let O,U;const Y=this._charsetService.charset,z=this._optionsService.rawOptions.screenReaderMode,$=this._bufferService.cols,q=this._coreService.decPrivateModes.wraparound,N=this._coreService.modes.insertMode,H=this._curAttrData;let X=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&L-M>0&&X.getWidth(this._activeBuffer.x-1)===2&&X.setCellFromCodePoint(this._activeBuffer.x-1,0,1,H.fg,H.bg,H.extended);for(let K=M;K<L;++K){if(O=R[K],U=this._unicodeService.wcwidth(O),O<127&&Y){const ne=Y[String.fromCharCode(O)];ne&&(O=ne.charCodeAt(0))}if(z&&this._onA11yChar.fire((0,y.stringFromCodePoint)(O)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),U||!this._activeBuffer.x){if(this._activeBuffer.x+U-1>=$){if(q){for(;this._activeBuffer.x<$;)X.setCellFromCodePoint(this._activeBuffer.x++,0,1,H.fg,H.bg,H.extended);this._activeBuffer.x=0,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),X=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)}else if(this._activeBuffer.x=$-1,U===2)continue}if(N&&(X.insertCells(this._activeBuffer.x,U,this._activeBuffer.getNullCell(H),H),X.getWidth($-1)===2&&X.setCellFromCodePoint($-1,u.NULL_CELL_CODE,u.NULL_CELL_WIDTH,H.fg,H.bg,H.extended)),X.setCellFromCodePoint(this._activeBuffer.x++,O,U,H.fg,H.bg,H.extended),U>0)for(;--U;)X.setCellFromCodePoint(this._activeBuffer.x++,0,0,H.fg,H.bg,H.extended)}else X.getWidth(this._activeBuffer.x-1)?X.addCodepointToCell(this._activeBuffer.x-1,O):X.addCodepointToCell(this._activeBuffer.x-2,O)}L-M>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<$&&L-M>0&&X.getWidth(this._activeBuffer.x)===0&&!X.hasContent(this._activeBuffer.x)&&X.setCellFromCodePoint(this._activeBuffer.x,0,1,H.fg,H.bg,H.extended),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(R,M){return R.final!=="t"||R.prefix||R.intermediates?this._parser.registerCsiHandler(R,M):this._parser.registerCsiHandler(R,(L=>!P(L.params[0],this._optionsService.rawOptions.windowOptions)||M(L)))}registerDcsHandler(R,M){return this._parser.registerDcsHandler(R,new E.DcsHandler(M))}registerEscHandler(R,M){return this._parser.registerEscHandler(R,M)}registerOscHandler(R,M){return this._parser.registerOscHandler(R,new k.OscHandler(M))}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 R;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&&(!((R=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))===null||R===void 0)&&R.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);M.hasWidth(this._activeBuffer.x)&&!M.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const R=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-R),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(R=this._bufferService.cols-1){this._activeBuffer.x=Math.min(R,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(R,M){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=R,this._activeBuffer.y=this._activeBuffer.scrollTop+M):(this._activeBuffer.x=R,this._activeBuffer.y=M),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(R,M){this._restrictCursor(),this._setCursor(this._activeBuffer.x+R,this._activeBuffer.y+M)}cursorUp(R){const M=this._activeBuffer.y-this._activeBuffer.scrollTop;return M>=0?this._moveCursor(0,-Math.min(M,R.params[0]||1)):this._moveCursor(0,-(R.params[0]||1)),!0}cursorDown(R){const M=this._activeBuffer.scrollBottom-this._activeBuffer.y;return M>=0?this._moveCursor(0,Math.min(M,R.params[0]||1)):this._moveCursor(0,R.params[0]||1),!0}cursorForward(R){return this._moveCursor(R.params[0]||1,0),!0}cursorBackward(R){return this._moveCursor(-(R.params[0]||1),0),!0}cursorNextLine(R){return this.cursorDown(R),this._activeBuffer.x=0,!0}cursorPrecedingLine(R){return this.cursorUp(R),this._activeBuffer.x=0,!0}cursorCharAbsolute(R){return this._setCursor((R.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(R){return this._setCursor(R.length>=2?(R.params[1]||1)-1:0,(R.params[0]||1)-1),!0}charPosAbsolute(R){return this._setCursor((R.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(R){return this._moveCursor(R.params[0]||1,0),!0}linePosAbsolute(R){return this._setCursor(this._activeBuffer.x,(R.params[0]||1)-1),!0}vPositionRelative(R){return this._moveCursor(0,R.params[0]||1),!0}hVPosition(R){return this.cursorPosition(R),!0}tabClear(R){const M=R.params[0];return M===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:M===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(R){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let M=R.params[0]||1;for(;M--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(R){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let M=R.params[0]||1;for(;M--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(R){const M=R.params[0];return M===1&&(this._curAttrData.bg|=536870912),M!==2&&M!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(R,M,L,O=!1,U=!1){const Y=this._activeBuffer.lines.get(this._activeBuffer.ybase+R);Y.replaceCells(M,L,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),U),O&&(Y.isWrapped=!1)}_resetBufferLine(R,M=!1){const L=this._activeBuffer.lines.get(this._activeBuffer.ybase+R);L&&(L.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),M),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+R),L.isWrapped=!1)}eraseInDisplay(R,M=!1){let L;switch(this._restrictCursor(this._bufferService.cols),R.params[0]){case 0:for(L=this._activeBuffer.y,this._dirtyRowTracker.markDirty(L),this._eraseInBufferLine(L++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,M);L<this._bufferService.rows;L++)this._resetBufferLine(L,M);this._dirtyRowTracker.markDirty(L);break;case 1:for(L=this._activeBuffer.y,this._dirtyRowTracker.markDirty(L),this._eraseInBufferLine(L,0,this._activeBuffer.x+1,!0,M),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(L+1).isWrapped=!1);L--;)this._resetBufferLine(L,M);this._dirtyRowTracker.markDirty(0);break;case 2:for(L=this._bufferService.rows,this._dirtyRowTracker.markDirty(L-1);L--;)this._resetBufferLine(L,M);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(R,M=!1){switch(this._restrictCursor(this._bufferService.cols),R.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,M);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,M);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,M)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(R){this._restrictCursor();let M=R.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const L=this._activeBuffer.ybase+this._activeBuffer.y,O=this._bufferService.rows-1-this._activeBuffer.scrollBottom,U=this._bufferService.rows-1+this._activeBuffer.ybase-O+1;for(;M--;)this._activeBuffer.lines.splice(U-1,1),this._activeBuffer.lines.splice(L,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(R){this._restrictCursor();let M=R.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const L=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;M--;)this._activeBuffer.lines.splice(L,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(R){this._restrictCursor();const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return M&&(M.insertCells(this._activeBuffer.x,R.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(R){this._restrictCursor();const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return M&&(M.deleteCells(this._activeBuffer.x,R.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(R){let M=R.params[0]||1;for(;M--;)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(R){let M=R.params[0]||1;for(;M--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(a.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(R){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=R.params[0]||1;for(let L=this._activeBuffer.scrollTop;L<=this._activeBuffer.scrollBottom;++L){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+L);O.deleteCells(0,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(R){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=R.params[0]||1;for(let L=this._activeBuffer.scrollTop;L<=this._activeBuffer.scrollBottom;++L){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+L);O.insertCells(0,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(R){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=R.params[0]||1;for(let L=this._activeBuffer.scrollTop;L<=this._activeBuffer.scrollBottom;++L){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+L);O.insertCells(this._activeBuffer.x,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(R){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=R.params[0]||1;for(let L=this._activeBuffer.scrollTop;L<=this._activeBuffer.scrollBottom;++L){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+L);O.deleteCells(this._activeBuffer.x,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(R){this._restrictCursor();const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return M&&(M.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(R.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(R){if(!this._parser.precedingCodepoint)return!0;const M=R.params[0]||1,L=new Uint32Array(M);for(let O=0;O<M;++O)L[O]=this._parser.precedingCodepoint;return this.print(L,0,L.length),!0}sendDeviceAttributesPrimary(R){return R.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(c.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(c.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(R){return R.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(c.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(c.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(R.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(c.C0.ESC+"[>83;40003;0c")),!0}_is(R){return(this._optionsService.rawOptions.termName+"").indexOf(R)===0}setMode(R){for(let M=0;M<R.length;M++)switch(R.params[M]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(R){for(let M=0;M<R.length;M++)switch(R.params[M]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,m.DEFAULT_CHARSET),this._charsetService.setgCharset(1,m.DEFAULT_CHARSET),this._charsetService.setgCharset(2,m.DEFAULT_CHARSET),this._charsetService.setgCharset(3,m.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(R){for(let M=0;M<R.length;M++)switch(R.params[M]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(R){for(let M=0;M<R.length;M++)switch(R.params[M]){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(),R.params[M]===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(R,M){const L=this._coreService.decPrivateModes,{activeProtocol:O,activeEncoding:U}=this._coreMouseService,Y=this._coreService,{buffers:z,cols:$}=this._bufferService,{active:q,alt:N}=z,H=this._optionsService.rawOptions,X=he=>he?1:2,K=R.params[0];return ne=K,te=M?K===2?4:K===4?X(Y.modes.insertMode):K===12?3:K===20?X(H.convertEol):0:K===1?X(L.applicationCursorKeys):K===3?H.windowOptions.setWinLines?$===80?2:$===132?1:0:0:K===6?X(L.origin):K===7?X(L.wraparound):K===8?3:K===9?X(O==="X10"):K===12?X(H.cursorBlink):K===25?X(!Y.isCursorHidden):K===45?X(L.reverseWraparound):K===66?X(L.applicationKeypad):K===67?4:K===1e3?X(O==="VT200"):K===1002?X(O==="DRAG"):K===1003?X(O==="ANY"):K===1004?X(L.sendFocus):K===1005?4:K===1006?X(U==="SGR"):K===1015?4:K===1016?X(U==="SGR_PIXELS"):K===1048?1:K===47||K===1047||K===1049?X(q===N):K===2004?X(L.bracketedPasteMode):0,Y.triggerDataEvent(`${c.C0.ESC}[${M?"":"?"}${ne};${te}$y`),!0;var ne,te}_updateAttrColor(R,M,L,O,U){return M===2?(R|=50331648,R&=-16777216,R|=b.AttributeData.fromColorRGB([L,O,U])):M===5&&(R&=-50331904,R|=33554432|255&L),R}_extractColor(R,M,L){const O=[0,0,-1,0,0,0];let U=0,Y=0;do{if(O[Y+U]=R.params[M+Y],R.hasSubParams(M+Y)){const z=R.getSubParams(M+Y);let $=0;do O[1]===5&&(U=1),O[Y+$+1+U]=z[$];while(++$<z.length&&$+Y+1+U<O.length);break}if(O[1]===5&&Y+U>=2||O[1]===2&&Y+U>=5)break;O[1]&&(U=1)}while(++Y+M<R.length&&Y+U<O.length);for(let z=2;z<O.length;++z)O[z]===-1&&(O[z]=0);switch(O[0]){case 38:L.fg=this._updateAttrColor(L.fg,O[1],O[3],O[4],O[5]);break;case 48:L.bg=this._updateAttrColor(L.bg,O[1],O[3],O[4],O[5]);break;case 58:L.extended=L.extended.clone(),L.extended.underlineColor=this._updateAttrColor(L.extended.underlineColor,O[1],O[3],O[4],O[5])}return Y}_processUnderline(R,M){M.extended=M.extended.clone(),(!~R||R>5)&&(R=1),M.extended.underlineStyle=R,M.fg|=268435456,R===0&&(M.fg&=-268435457),M.updateExtended()}_processSGR0(R){R.fg=a.DEFAULT_ATTR_DATA.fg,R.bg=a.DEFAULT_ATTR_DATA.bg,R.extended=R.extended.clone(),R.extended.underlineStyle=0,R.extended.underlineColor&=-67108864,R.updateExtended()}charAttributes(R){if(R.length===1&&R.params[0]===0)return this._processSGR0(this._curAttrData),!0;const M=R.length;let L;const O=this._curAttrData;for(let U=0;U<M;U++)L=R.params[U],L>=30&&L<=37?(O.fg&=-50331904,O.fg|=16777216|L-30):L>=40&&L<=47?(O.bg&=-50331904,O.bg|=16777216|L-40):L>=90&&L<=97?(O.fg&=-50331904,O.fg|=16777224|L-90):L>=100&&L<=107?(O.bg&=-50331904,O.bg|=16777224|L-100):L===0?this._processSGR0(O):L===1?O.fg|=134217728:L===3?O.bg|=67108864:L===4?(O.fg|=268435456,this._processUnderline(R.hasSubParams(U)?R.getSubParams(U)[0]:1,O)):L===5?O.fg|=536870912:L===7?O.fg|=67108864:L===8?O.fg|=1073741824:L===9?O.fg|=2147483648:L===2?O.bg|=134217728:L===21?this._processUnderline(2,O):L===22?(O.fg&=-134217729,O.bg&=-134217729):L===23?O.bg&=-67108865:L===24?(O.fg&=-268435457,this._processUnderline(0,O)):L===25?O.fg&=-536870913:L===27?O.fg&=-67108865:L===28?O.fg&=-1073741825:L===29?O.fg&=2147483647:L===39?(O.fg&=-67108864,O.fg|=16777215&a.DEFAULT_ATTR_DATA.fg):L===49?(O.bg&=-67108864,O.bg|=16777215&a.DEFAULT_ATTR_DATA.bg):L===38||L===48||L===58?U+=this._extractColor(R,U,O):L===53?O.bg|=1073741824:L===55?O.bg&=-1073741825:L===59?(O.extended=O.extended.clone(),O.extended.underlineColor=-1,O.updateExtended()):L===100?(O.fg&=-67108864,O.fg|=16777215&a.DEFAULT_ATTR_DATA.fg,O.bg&=-67108864,O.bg|=16777215&a.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",L);return!0}deviceStatus(R){switch(R.params[0]){case 5:this._coreService.triggerDataEvent(`${c.C0.ESC}[0n`);break;case 6:const M=this._activeBuffer.y+1,L=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${c.C0.ESC}[${M};${L}R`)}return!0}deviceStatusPrivate(R){if(R.params[0]===6){const M=this._activeBuffer.y+1,L=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${c.C0.ESC}[?${M};${L}R`)}return!0}softReset(R){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=a.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(R){const M=R.params[0]||1;switch(M){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 L=M%2==1;return this._optionsService.options.cursorBlink=L,!0}setScrollRegion(R){const M=R.params[0]||1;let L;return(R.length<2||(L=R.params[1])>this._bufferService.rows||L===0)&&(L=this._bufferService.rows),L>M&&(this._activeBuffer.scrollTop=M-1,this._activeBuffer.scrollBottom=L-1,this._setCursor(0,0)),!0}windowOptions(R){if(!P(R.params[0],this._optionsService.rawOptions.windowOptions))return!0;const M=R.length>1?R.params[1]:0;switch(R.params[0]){case 14:M!==2&&this._onRequestWindowsOptionsReport.fire(T.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(T.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${c.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:M!==0&&M!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),M!==0&&M!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:M!==0&&M!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),M!==0&&M!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(R){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(R){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(R){return this._windowTitle=R,this._onTitleChange.fire(R),!0}setIconName(R){return this._iconName=R,!0}setOrReportIndexedColor(R){const M=[],L=R.split(";");for(;L.length>1;){const O=L.shift(),U=L.shift();if(/^\d+$/.exec(O)){const Y=parseInt(O);if(B(Y))if(U==="?")M.push({type:0,index:Y});else{const z=(0,_.parseColor)(U);z&&M.push({type:1,index:Y,color:z})}}}return M.length&&this._onColor.fire(M),!0}setHyperlink(R){const M=R.split(";");return!(M.length<2)&&(M[1]?this._createHyperlink(M[0],M[1]):!M[0]&&this._finishHyperlink())}_createHyperlink(R,M){this._getCurrentLinkId()&&this._finishHyperlink();const L=R.split(":");let O;const U=L.findIndex((Y=>Y.startsWith("id=")));return U!==-1&&(O=L[U].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:O,uri:M}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(R,M){const L=R.split(";");for(let O=0;O<L.length&&!(M>=this._specialColors.length);++O,++M)if(L[O]==="?")this._onColor.fire([{type:0,index:this._specialColors[M]}]);else{const U=(0,_.parseColor)(L[O]);U&&this._onColor.fire([{type:1,index:this._specialColors[M],color:U}])}return!0}setOrReportFgColor(R){return this._setOrReportSpecialColor(R,0)}setOrReportBgColor(R){return this._setOrReportSpecialColor(R,1)}setOrReportCursorColor(R){return this._setOrReportSpecialColor(R,2)}restoreIndexedColor(R){if(!R)return this._onColor.fire([{type:2}]),!0;const M=[],L=R.split(";");for(let O=0;O<L.length;++O)if(/^\d+$/.exec(L[O])){const U=parseInt(L[O]);B(U)&&M.push({type:2,index:U})}return M.length&&this._onColor.fire(M),!0}restoreFgColor(R){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(R){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(R){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,m.DEFAULT_CHARSET),!0}selectCharset(R){return R.length!==2?(this.selectDefaultCharset(),!0):(R[0]==="/"||this._charsetService.setgCharset(j[R[0]],m.CHARSETS[R[1]]||m.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 R=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,R,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=a.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=a.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(R){return this._charsetService.setgLevel(R),!0}screenAlignmentPattern(){const R=new f.CellData;R.content=4194373,R.fg=this._curAttrData.fg,R.bg=this._curAttrData.bg,this._setCursor(0,0);for(let M=0;M<this._bufferService.rows;++M){const L=this._activeBuffer.ybase+this._activeBuffer.y+M,O=this._activeBuffer.lines.get(L);O&&(O.fill(R),O.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(R,M){const L=this._bufferService.buffer,O=this._optionsService.rawOptions;return(U=>(this._coreService.triggerDataEvent(`${c.C0.ESC}${U}${c.C0.ESC}\\`),!0))(R==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:R==='"p'?'P1$r61;1"p':R==="r"?`P1$r${L.scrollTop+1};${L.scrollBottom+1}r`:R==="m"?"P1$r0m":R===" q"?`P1$r${{block:2,underline:4,bar:6}[O.cursorStyle]-(O.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(R,M){this._dirtyRowTracker.markRangeDirty(R,M)}}n.InputHandler=W;let I=class{constructor(F){this._bufferService=F,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(F){F<this.start?this.start=F:F>this.end&&(this.end=F)}markRangeDirty(F,R){F>R&&(D=F,F=R,R=D),F<this.start&&(this.start=F),R>this.end&&(this.end=R)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function B(F){return 0<=F&&F<256}I=l([d(0,C.IBufferService)],I)},844:(v,n)=>{function i(l){for(const d of l)d.dispose();l.length=0}Object.defineProperty(n,"__esModule",{value:!0}),n.getDisposeArrayDisposable=n.disposeArray=n.toDisposable=n.MutableDisposable=n.Disposable=void 0,n.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const l of this._disposables)l.dispose();this._disposables.length=0}register(l){return this._disposables.push(l),l}unregister(l){const d=this._disposables.indexOf(l);d!==-1&&this._disposables.splice(d,1)}},n.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(l){var d;this._isDisposed||l===this._value||((d=this._value)===null||d===void 0||d.dispose(),this._value=l)}clear(){this.value=void 0}dispose(){var l;this._isDisposed=!0,(l=this._value)===null||l===void 0||l.dispose(),this._value=void 0}},n.toDisposable=function(l){return{dispose:l}},n.disposeArray=i,n.getDisposeArrayDisposable=function(l){return{dispose:()=>i(l)}}},1505:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.FourKeyMap=n.TwoKeyMap=void 0;class i{constructor(){this._data={}}set(d,c,m){this._data[d]||(this._data[d]={}),this._data[d][c]=m}get(d,c){return this._data[d]?this._data[d][c]:void 0}clear(){this._data={}}}n.TwoKeyMap=i,n.FourKeyMap=class{constructor(){this._data=new i}set(l,d,c,m,x){this._data.get(l,d)||this._data.set(l,d,new i),this._data.get(l,d).set(c,m,x)}get(l,d,c,m){var x;return(x=this._data.get(l,d))===null||x===void 0?void 0:x.get(c,m)}clear(){this._data.clear()}}},6114:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.isChromeOS=n.isLinux=n.isWindows=n.isIphone=n.isIpad=n.isMac=n.getSafariVersion=n.isSafari=n.isLegacyEdge=n.isFirefox=n.isNode=void 0,n.isNode=typeof navigator>"u";const i=n.isNode?"node":navigator.userAgent,l=n.isNode?"node":navigator.platform;n.isFirefox=i.includes("Firefox"),n.isLegacyEdge=i.includes("Edge"),n.isSafari=/^((?!chrome|android).)*safari/i.test(i),n.getSafariVersion=function(){if(!n.isSafari)return 0;const d=i.match(/Version\/(\d+)/);return d===null||d.length<2?0:parseInt(d[1])},n.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(l),n.isIpad=l==="iPad",n.isIphone=l==="iPhone",n.isWindows=["Windows","Win16","Win32","WinCE"].includes(l),n.isLinux=l.indexOf("Linux")>=0,n.isChromeOS=/\bCrOS\b/.test(i)},6106:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.SortedList=void 0;let i=0;n.SortedList=class{constructor(l){this._getKey=l,this._array=[]}clear(){this._array.length=0}insert(l){this._array.length!==0?(i=this._search(this._getKey(l)),this._array.splice(i,0,l)):this._array.push(l)}delete(l){if(this._array.length===0)return!1;const d=this._getKey(l);if(d===void 0||(i=this._search(d),i===-1)||this._getKey(this._array[i])!==d)return!1;do if(this._array[i]===l)return this._array.splice(i,1),!0;while(++i<this._array.length&&this._getKey(this._array[i])===d);return!1}*getKeyIterator(l){if(this._array.length!==0&&(i=this._search(l),!(i<0||i>=this._array.length)&&this._getKey(this._array[i])===l))do yield this._array[i];while(++i<this._array.length&&this._getKey(this._array[i])===l)}forEachByKey(l,d){if(this._array.length!==0&&(i=this._search(l),!(i<0||i>=this._array.length)&&this._getKey(this._array[i])===l))do d(this._array[i]);while(++i<this._array.length&&this._getKey(this._array[i])===l)}values(){return[...this._array].values()}_search(l){let d=0,c=this._array.length-1;for(;c>=d;){let m=d+c>>1;const x=this._getKey(this._array[m]);if(x>l)c=m-1;else{if(!(x<l)){for(;m>0&&this._getKey(this._array[m-1])===l;)m--;return m}d=m+1}}return d}}},7226:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DebouncedIdleTask=n.IdleTaskQueue=n.PriorityTaskQueue=void 0;const l=i(6114);class d{constructor(){this._tasks=[],this._i=0}enqueue(x){this._tasks.push(x),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(x){this._idleCallback=void 0;let w=0,y=0,a=x.timeRemaining(),h=0;for(;this._i<this._tasks.length;){if(w=Date.now(),this._tasks[this._i]()||this._i++,w=Math.max(1,Date.now()-w),y=Math.max(w,y),h=x.timeRemaining(),1.5*y>h)return a-w<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(a-w))}ms`),void this._start();a=h}this.clear()}}class c extends d{_requestCallback(x){return setTimeout((()=>x(this._createDeadline(16))))}_cancelCallback(x){clearTimeout(x)}_createDeadline(x){const w=Date.now()+x;return{timeRemaining:()=>Math.max(0,w-Date.now())}}}n.PriorityTaskQueue=c,n.IdleTaskQueue=!l.isNode&&"requestIdleCallback"in window?class extends d{_requestCallback(m){return requestIdleCallback(m)}_cancelCallback(m){cancelIdleCallback(m)}}:c,n.DebouncedIdleTask=class{constructor(){this._queue=new n.IdleTaskQueue}set(m){this._queue.clear(),this._queue.enqueue(m)}flush(){this._queue.flush()}}},9282:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.updateWindowsModeWrappedState=void 0;const l=i(643);n.updateWindowsModeWrappedState=function(d){const c=d.buffer.lines.get(d.buffer.ybase+d.buffer.y-1),m=c?.get(d.cols-1),x=d.buffer.lines.get(d.buffer.ybase+d.buffer.y);x&&m&&(x.isWrapped=m[l.CHAR_DATA_CODE_INDEX]!==l.NULL_CELL_CODE&&m[l.CHAR_DATA_CODE_INDEX]!==l.WHITESPACE_CELL_CODE)}},3734:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ExtendedAttrs=n.AttributeData=void 0;class i{constructor(){this.fg=0,this.bg=0,this.extended=new l}static toColorRGB(c){return[c>>>16&255,c>>>8&255,255&c]}static fromColorRGB(c){return(255&c[0])<<16|(255&c[1])<<8|255&c[2]}clone(){const c=new i;return c.fg=this.fg,c.bg=this.bg,c.extended=this.extended.clone(),c}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}}n.AttributeData=i;class l{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(c){this._ext=c}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(c){this._ext&=-469762049,this._ext|=c<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(c){this._ext&=-67108864,this._ext|=67108863&c}get urlId(){return this._urlId}set urlId(c){this._urlId=c}constructor(c=0,m=0){this._ext=0,this._urlId=0,this._ext=c,this._urlId=m}clone(){return new l(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}n.ExtendedAttrs=l},9092:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Buffer=n.MAX_BUFFER_SIZE=void 0;const l=i(6349),d=i(7226),c=i(3734),m=i(8437),x=i(4634),w=i(511),y=i(643),a=i(4863),h=i(7116);n.MAX_BUFFER_SIZE=4294967295,n.Buffer=class{constructor(u,f,b){this._hasScrollback=u,this._optionsService=f,this._bufferService=b,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=m.DEFAULT_ATTR_DATA.clone(),this.savedCharset=h.DEFAULT_CHARSET,this.markers=[],this._nullCell=w.CellData.fromCharData([0,y.NULL_CELL_CHAR,y.NULL_CELL_WIDTH,y.NULL_CELL_CODE]),this._whitespaceCell=w.CellData.fromCharData([0,y.WHITESPACE_CELL_CHAR,y.WHITESPACE_CELL_WIDTH,y.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new d.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new l.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(u){return u?(this._nullCell.fg=u.fg,this._nullCell.bg=u.bg,this._nullCell.extended=u.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new c.ExtendedAttrs),this._nullCell}getWhitespaceCell(u){return u?(this._whitespaceCell.fg=u.fg,this._whitespaceCell.bg=u.bg,this._whitespaceCell.extended=u.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new c.ExtendedAttrs),this._whitespaceCell}getBlankLine(u,f){return new m.BufferLine(this._bufferService.cols,this.getNullCell(u),f)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const u=this.ybase+this.y-this.ydisp;return u>=0&&u<this._rows}_getCorrectBufferLength(u){if(!this._hasScrollback)return u;const f=u+this._optionsService.rawOptions.scrollback;return f>n.MAX_BUFFER_SIZE?n.MAX_BUFFER_SIZE:f}fillViewportRows(u){if(this.lines.length===0){u===void 0&&(u=m.DEFAULT_ATTR_DATA);let f=this._rows;for(;f--;)this.lines.push(this.getBlankLine(u))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new l.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(u,f){const b=this.getNullCell(m.DEFAULT_ATTR_DATA);let C=0;const k=this._getCorrectBufferLength(f);if(k>this.lines.maxLength&&(this.lines.maxLength=k),this.lines.length>0){if(this._cols<u)for(let _=0;_<this.lines.length;_++)C+=+this.lines.get(_).resize(u,b);let E=0;if(this._rows<f)for(let _=this._rows;_<f;_++)this.lines.length<f+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new m.BufferLine(u,b)):this.ybase>0&&this.lines.length<=this.ybase+this.y+E+1?(this.ybase--,E++,this.ydisp>0&&this.ydisp--):this.lines.push(new m.BufferLine(u,b)));else for(let _=this._rows;_>f;_--)this.lines.length>f+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(k<this.lines.maxLength){const _=this.lines.length-k;_>0&&(this.lines.trimStart(_),this.ybase=Math.max(this.ybase-_,0),this.ydisp=Math.max(this.ydisp-_,0),this.savedY=Math.max(this.savedY-_,0)),this.lines.maxLength=k}this.x=Math.min(this.x,u-1),this.y=Math.min(this.y,f-1),E&&(this.y+=E),this.savedX=Math.min(this.savedX,u-1),this.scrollTop=0}if(this.scrollBottom=f-1,this._isReflowEnabled&&(this._reflow(u,f),this._cols>u))for(let E=0;E<this.lines.length;E++)C+=+this.lines.get(E).resize(u,b);this._cols=u,this._rows=f,this._memoryCleanupQueue.clear(),C>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let u=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,u=!1);let f=0;for(;this._memoryCleanupPosition<this.lines.length;)if(f+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),f>100)return!0;return u}get _isReflowEnabled(){const u=this._optionsService.rawOptions.windowsPty;return u&&u.buildNumber?this._hasScrollback&&u.backend==="conpty"&&u.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(u,f){this._cols!==u&&(u>this._cols?this._reflowLarger(u,f):this._reflowSmaller(u,f))}_reflowLarger(u,f){const b=(0,x.reflowLargerGetLinesToRemove)(this.lines,this._cols,u,this.ybase+this.y,this.getNullCell(m.DEFAULT_ATTR_DATA));if(b.length>0){const C=(0,x.reflowLargerCreateNewLayout)(this.lines,b);(0,x.reflowLargerApplyNewLayout)(this.lines,C.layout),this._reflowLargerAdjustViewport(u,f,C.countRemoved)}}_reflowLargerAdjustViewport(u,f,b){const C=this.getNullCell(m.DEFAULT_ATTR_DATA);let k=b;for(;k-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<f&&this.lines.push(new m.BufferLine(u,C))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-b,0)}_reflowSmaller(u,f){const b=this.getNullCell(m.DEFAULT_ATTR_DATA),C=[];let k=0;for(let E=this.lines.length-1;E>=0;E--){let _=this.lines.get(E);if(!_||!_.isWrapped&&_.getTrimmedLength()<=u)continue;const j=[_];for(;_.isWrapped&&E>0;)_=this.lines.get(--E),j.unshift(_);const A=this.ybase+this.y;if(A>=E&&A<E+j.length)continue;const P=j[j.length-1].getTrimmedLength(),T=(0,x.reflowSmallerGetNewLineLengths)(j,this._cols,u),D=T.length-j.length;let W;W=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+D):Math.max(0,this.lines.length-this.lines.maxLength+D);const I=[];for(let O=0;O<D;O++){const U=this.getBlankLine(m.DEFAULT_ATTR_DATA,!0);I.push(U)}I.length>0&&(C.push({start:E+j.length+k,newLines:I}),k+=I.length),j.push(...I);let B=T.length-1,F=T[B];F===0&&(B--,F=T[B]);let R=j.length-D-1,M=P;for(;R>=0;){const O=Math.min(M,F);if(j[B]===void 0)break;if(j[B].copyCellsFrom(j[R],M-O,F-O,O,!0),F-=O,F===0&&(B--,F=T[B]),M-=O,M===0){R--;const U=Math.max(R,0);M=(0,x.getWrappedLineTrimmedLength)(j,U,this._cols)}}for(let O=0;O<j.length;O++)T[O]<u&&j[O].setCell(T[O],b);let L=D-W;for(;L-- >0;)this.ybase===0?this.y<f-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+k)-f&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+D,this.ybase+f-1)}if(C.length>0){const E=[],_=[];for(let B=0;B<this.lines.length;B++)_.push(this.lines.get(B));const j=this.lines.length;let A=j-1,P=0,T=C[P];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+k);let D=0;for(let B=Math.min(this.lines.maxLength-1,j+k-1);B>=0;B--)if(T&&T.start>A+D){for(let F=T.newLines.length-1;F>=0;F--)this.lines.set(B--,T.newLines[F]);B++,E.push({index:A+1,amount:T.newLines.length}),D+=T.newLines.length,T=C[++P]}else this.lines.set(B,_[A--]);let W=0;for(let B=E.length-1;B>=0;B--)E[B].index+=W,this.lines.onInsertEmitter.fire(E[B]),W+=E[B].amount;const I=Math.max(0,j+k-this.lines.maxLength);I>0&&this.lines.onTrimEmitter.fire(I)}}translateBufferLineToString(u,f,b=0,C){const k=this.lines.get(u);return k?k.translateToString(f,b,C):""}getWrappedRangeForLine(u){let f=u,b=u;for(;f>0&&this.lines.get(f).isWrapped;)f--;for(;b+1<this.lines.length&&this.lines.get(b+1).isWrapped;)b++;return{first:f,last:b}}setupTabStops(u){for(u!=null?this.tabs[u]||(u=this.prevStop(u)):(this.tabs={},u=0);u<this._cols;u+=this._optionsService.rawOptions.tabStopWidth)this.tabs[u]=!0}prevStop(u){for(u==null&&(u=this.x);!this.tabs[--u]&&u>0;);return u>=this._cols?this._cols-1:u<0?0:u}nextStop(u){for(u==null&&(u=this.x);!this.tabs[++u]&&u<this._cols;);return u>=this._cols?this._cols-1:u<0?0:u}clearMarkers(u){this._isClearing=!0;for(let f=0;f<this.markers.length;f++)this.markers[f].line===u&&(this.markers[f].dispose(),this.markers.splice(f--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let u=0;u<this.markers.length;u++)this.markers[u].dispose(),this.markers.splice(u--,1);this._isClearing=!1}addMarker(u){const f=new a.Marker(u);return this.markers.push(f),f.register(this.lines.onTrim((b=>{f.line-=b,f.line<0&&f.dispose()}))),f.register(this.lines.onInsert((b=>{f.line>=b.index&&(f.line+=b.amount)}))),f.register(this.lines.onDelete((b=>{f.line>=b.index&&f.line<b.index+b.amount&&f.dispose(),f.line>b.index&&(f.line-=b.amount)}))),f.register(f.onDispose((()=>this._removeMarker(f)))),f}_removeMarker(u){this._isClearing||this.markers.splice(this.markers.indexOf(u),1)}}},8437:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferLine=n.DEFAULT_ATTR_DATA=void 0;const l=i(3734),d=i(511),c=i(643),m=i(482);n.DEFAULT_ATTR_DATA=Object.freeze(new l.AttributeData);let x=0;class w{constructor(a,h,u=!1){this.isWrapped=u,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*a);const f=h||d.CellData.fromCharData([0,c.NULL_CELL_CHAR,c.NULL_CELL_WIDTH,c.NULL_CELL_CODE]);for(let b=0;b<a;++b)this.setCell(b,f);this.length=a}get(a){const h=this._data[3*a+0],u=2097151&h;return[this._data[3*a+1],2097152&h?this._combined[a]:u?(0,m.stringFromCodePoint)(u):"",h>>22,2097152&h?this._combined[a].charCodeAt(this._combined[a].length-1):u]}set(a,h){this._data[3*a+1]=h[c.CHAR_DATA_ATTR_INDEX],h[c.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[a]=h[1],this._data[3*a+0]=2097152|a|h[c.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*a+0]=h[c.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|h[c.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(a){return this._data[3*a+0]>>22}hasWidth(a){return 12582912&this._data[3*a+0]}getFg(a){return this._data[3*a+1]}getBg(a){return this._data[3*a+2]}hasContent(a){return 4194303&this._data[3*a+0]}getCodePoint(a){const h=this._data[3*a+0];return 2097152&h?this._combined[a].charCodeAt(this._combined[a].length-1):2097151&h}isCombined(a){return 2097152&this._data[3*a+0]}getString(a){const h=this._data[3*a+0];return 2097152&h?this._combined[a]:2097151&h?(0,m.stringFromCodePoint)(2097151&h):""}isProtected(a){return 536870912&this._data[3*a+2]}loadCell(a,h){return x=3*a,h.content=this._data[x+0],h.fg=this._data[x+1],h.bg=this._data[x+2],2097152&h.content&&(h.combinedData=this._combined[a]),268435456&h.bg&&(h.extended=this._extendedAttrs[a]),h}setCell(a,h){2097152&h.content&&(this._combined[a]=h.combinedData),268435456&h.bg&&(this._extendedAttrs[a]=h.extended),this._data[3*a+0]=h.content,this._data[3*a+1]=h.fg,this._data[3*a+2]=h.bg}setCellFromCodePoint(a,h,u,f,b,C){268435456&b&&(this._extendedAttrs[a]=C),this._data[3*a+0]=h|u<<22,this._data[3*a+1]=f,this._data[3*a+2]=b}addCodepointToCell(a,h){let u=this._data[3*a+0];2097152&u?this._combined[a]+=(0,m.stringFromCodePoint)(h):(2097151&u?(this._combined[a]=(0,m.stringFromCodePoint)(2097151&u)+(0,m.stringFromCodePoint)(h),u&=-2097152,u|=2097152):u=h|4194304,this._data[3*a+0]=u)}insertCells(a,h,u,f){if((a%=this.length)&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs),h<this.length-a){const b=new d.CellData;for(let C=this.length-a-h-1;C>=0;--C)this.setCell(a+h+C,this.loadCell(a+C,b));for(let C=0;C<h;++C)this.setCell(a+C,u)}else for(let b=a;b<this.length;++b)this.setCell(b,u);this.getWidth(this.length-1)===2&&this.setCellFromCodePoint(this.length-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs)}deleteCells(a,h,u,f){if(a%=this.length,h<this.length-a){const b=new d.CellData;for(let C=0;C<this.length-a-h;++C)this.setCell(a+C,this.loadCell(a+h+C,b));for(let C=this.length-h;C<this.length;++C)this.setCell(C,u)}else for(let b=a;b<this.length;++b)this.setCell(b,u);a&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs),this.getWidth(a)!==0||this.hasContent(a)||this.setCellFromCodePoint(a,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs)}replaceCells(a,h,u,f,b=!1){if(b)for(a&&this.getWidth(a-1)===2&&!this.isProtected(a-1)&&this.setCellFromCodePoint(a-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs),h<this.length&&this.getWidth(h-1)===2&&!this.isProtected(h)&&this.setCellFromCodePoint(h,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs);a<h&&a<this.length;)this.isProtected(a)||this.setCell(a,u),a++;else for(a&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs),h<this.length&&this.getWidth(h-1)===2&&this.setCellFromCodePoint(h,0,1,f?.fg||0,f?.bg||0,f?.extended||new l.ExtendedAttrs);a<h&&a<this.length;)this.setCell(a++,u)}resize(a,h){if(a===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const u=3*a;if(a>this.length){if(this._data.buffer.byteLength>=4*u)this._data=new Uint32Array(this._data.buffer,0,u);else{const f=new Uint32Array(u);f.set(this._data),this._data=f}for(let f=this.length;f<a;++f)this.setCell(f,h)}else{this._data=this._data.subarray(0,u);const f=Object.keys(this._combined);for(let C=0;C<f.length;C++){const k=parseInt(f[C],10);k>=a&&delete this._combined[k]}const b=Object.keys(this._extendedAttrs);for(let C=0;C<b.length;C++){const k=parseInt(b[C],10);k>=a&&delete this._extendedAttrs[k]}}return this.length=a,4*u*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const a=new Uint32Array(this._data.length);return a.set(this._data),this._data=a,1}return 0}fill(a,h=!1){if(h)for(let u=0;u<this.length;++u)this.isProtected(u)||this.setCell(u,a);else{this._combined={},this._extendedAttrs={};for(let u=0;u<this.length;++u)this.setCell(u,a)}}copyFrom(a){this.length!==a.length?this._data=new Uint32Array(a._data):this._data.set(a._data),this.length=a.length,this._combined={};for(const h in a._combined)this._combined[h]=a._combined[h];this._extendedAttrs={};for(const h in a._extendedAttrs)this._extendedAttrs[h]=a._extendedAttrs[h];this.isWrapped=a.isWrapped}clone(){const a=new w(0);a._data=new Uint32Array(this._data),a.length=this.length;for(const h in this._combined)a._combined[h]=this._combined[h];for(const h in this._extendedAttrs)a._extendedAttrs[h]=this._extendedAttrs[h];return a.isWrapped=this.isWrapped,a}getTrimmedLength(){for(let a=this.length-1;a>=0;--a)if(4194303&this._data[3*a+0])return a+(this._data[3*a+0]>>22);return 0}getNoBgTrimmedLength(){for(let a=this.length-1;a>=0;--a)if(4194303&this._data[3*a+0]||50331648&this._data[3*a+2])return a+(this._data[3*a+0]>>22);return 0}copyCellsFrom(a,h,u,f,b){const C=a._data;if(b)for(let E=f-1;E>=0;E--){for(let _=0;_<3;_++)this._data[3*(u+E)+_]=C[3*(h+E)+_];268435456&C[3*(h+E)+2]&&(this._extendedAttrs[u+E]=a._extendedAttrs[h+E])}else for(let E=0;E<f;E++){for(let _=0;_<3;_++)this._data[3*(u+E)+_]=C[3*(h+E)+_];268435456&C[3*(h+E)+2]&&(this._extendedAttrs[u+E]=a._extendedAttrs[h+E])}const k=Object.keys(a._combined);for(let E=0;E<k.length;E++){const _=parseInt(k[E],10);_>=h&&(this._combined[_-h+u]=a._combined[_])}}translateToString(a=!1,h=0,u=this.length){a&&(u=Math.min(u,this.getTrimmedLength()));let f="";for(;h<u;){const b=this._data[3*h+0],C=2097151&b;f+=2097152&b?this._combined[h]:C?(0,m.stringFromCodePoint)(C):c.WHITESPACE_CELL_CHAR,h+=b>>22||1}return f}}n.BufferLine=w},4841:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.getRangeLength=void 0,n.getRangeLength=function(i,l){if(i.start.y>i.end.y)throw new Error(`Buffer range end (${i.end.x}, ${i.end.y}) cannot be before start (${i.start.x}, ${i.start.y})`);return l*(i.end.y-i.start.y)+(i.end.x-i.start.x+1)}},4634:(v,n)=>{function i(l,d,c){if(d===l.length-1)return l[d].getTrimmedLength();const m=!l[d].hasContent(c-1)&&l[d].getWidth(c-1)===1,x=l[d+1].getWidth(0)===2;return m&&x?c-1:c}Object.defineProperty(n,"__esModule",{value:!0}),n.getWrappedLineTrimmedLength=n.reflowSmallerGetNewLineLengths=n.reflowLargerApplyNewLayout=n.reflowLargerCreateNewLayout=n.reflowLargerGetLinesToRemove=void 0,n.reflowLargerGetLinesToRemove=function(l,d,c,m,x){const w=[];for(let y=0;y<l.length-1;y++){let a=y,h=l.get(++a);if(!h.isWrapped)continue;const u=[l.get(y)];for(;a<l.length&&h.isWrapped;)u.push(h),h=l.get(++a);if(m>=y&&m<a){y+=u.length-1;continue}let f=0,b=i(u,f,d),C=1,k=0;for(;C<u.length;){const _=i(u,C,d),j=_-k,A=c-b,P=Math.min(j,A);u[f].copyCellsFrom(u[C],k,b,P,!1),b+=P,b===c&&(f++,b=0),k+=P,k===_&&(C++,k=0),b===0&&f!==0&&u[f-1].getWidth(c-1)===2&&(u[f].copyCellsFrom(u[f-1],c-1,b++,1,!1),u[f-1].setCell(c-1,x))}u[f].replaceCells(b,c,x);let E=0;for(let _=u.length-1;_>0&&(_>f||u[_].getTrimmedLength()===0);_--)E++;E>0&&(w.push(y+u.length-E),w.push(E)),y+=u.length-1}return w},n.reflowLargerCreateNewLayout=function(l,d){const c=[];let m=0,x=d[m],w=0;for(let y=0;y<l.length;y++)if(x===y){const a=d[++m];l.onDeleteEmitter.fire({index:y-w,amount:a}),y+=a-1,w+=a,x=d[++m]}else c.push(y);return{layout:c,countRemoved:w}},n.reflowLargerApplyNewLayout=function(l,d){const c=[];for(let m=0;m<d.length;m++)c.push(l.get(d[m]));for(let m=0;m<c.length;m++)l.set(m,c[m]);l.length=d.length},n.reflowSmallerGetNewLineLengths=function(l,d,c){const m=[],x=l.map(((h,u)=>i(l,u,d))).reduce(((h,u)=>h+u));let w=0,y=0,a=0;for(;a<x;){if(x-a<c){m.push(x-a);break}w+=c;const h=i(l,y,d);w>h&&(w-=h,y++);const u=l[y].getWidth(w-1)===2;u&&w--;const f=u?c-1:c;m.push(f),a+=f}return m},n.getWrappedLineTrimmedLength=i},5295:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferSet=void 0;const l=i(8460),d=i(844),c=i(9092);class m extends d.Disposable{constructor(w,y){super(),this._optionsService=w,this._bufferService=y,this._onBufferActivate=this.register(new l.EventEmitter),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.resize(this._bufferService.cols,this._bufferService.rows)))),this.register(this._optionsService.onSpecificOptionChange("tabStopWidth",(()=>this.setupTabStops())))}reset(){this._normal=new c.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new c.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(w){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(w),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(w,y){this._normal.resize(w,y),this._alt.resize(w,y),this.setupTabStops(w)}setupTabStops(w){this._normal.setupTabStops(w),this._alt.setupTabStops(w)}}n.BufferSet=m},511:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CellData=void 0;const l=i(482),d=i(643),c=i(3734);class m extends c.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new c.ExtendedAttrs,this.combinedData=""}static fromCharData(w){const y=new m;return y.setFromCharData(w),y}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,l.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(w){this.fg=w[d.CHAR_DATA_ATTR_INDEX],this.bg=0;let y=!1;if(w[d.CHAR_DATA_CHAR_INDEX].length>2)y=!0;else if(w[d.CHAR_DATA_CHAR_INDEX].length===2){const a=w[d.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=a&&a<=56319){const h=w[d.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=h&&h<=57343?this.content=1024*(a-55296)+h-56320+65536|w[d.CHAR_DATA_WIDTH_INDEX]<<22:y=!0}else y=!0}else this.content=w[d.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|w[d.CHAR_DATA_WIDTH_INDEX]<<22;y&&(this.combinedData=w[d.CHAR_DATA_CHAR_INDEX],this.content=2097152|w[d.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}n.CellData=m},643:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.WHITESPACE_CELL_CODE=n.WHITESPACE_CELL_WIDTH=n.WHITESPACE_CELL_CHAR=n.NULL_CELL_CODE=n.NULL_CELL_WIDTH=n.NULL_CELL_CHAR=n.CHAR_DATA_CODE_INDEX=n.CHAR_DATA_WIDTH_INDEX=n.CHAR_DATA_CHAR_INDEX=n.CHAR_DATA_ATTR_INDEX=n.DEFAULT_EXT=n.DEFAULT_ATTR=n.DEFAULT_COLOR=void 0,n.DEFAULT_COLOR=0,n.DEFAULT_ATTR=256|n.DEFAULT_COLOR<<9,n.DEFAULT_EXT=0,n.CHAR_DATA_ATTR_INDEX=0,n.CHAR_DATA_CHAR_INDEX=1,n.CHAR_DATA_WIDTH_INDEX=2,n.CHAR_DATA_CODE_INDEX=3,n.NULL_CELL_CHAR="",n.NULL_CELL_WIDTH=1,n.NULL_CELL_CODE=0,n.WHITESPACE_CELL_CHAR=" ",n.WHITESPACE_CELL_WIDTH=1,n.WHITESPACE_CELL_CODE=32},4863:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Marker=void 0;const l=i(8460),d=i(844);class c{get id(){return this._id}constructor(x){this.line=x,this.isDisposed=!1,this._disposables=[],this._id=c._nextId++,this._onDispose=this.register(new l.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,d.disposeArray)(this._disposables),this._disposables.length=0)}register(x){return this._disposables.push(x),x}}n.Marker=c,c._nextId=1},7116:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DEFAULT_CHARSET=n.CHARSETS=void 0,n.CHARSETS={},n.DEFAULT_CHARSET=n.CHARSETS.B,n.CHARSETS[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},n.CHARSETS.A={"#":"£"},n.CHARSETS.B=void 0,n.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},n.CHARSETS.C=n.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},n.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},n.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},n.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},n.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},n.CHARSETS.E=n.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},n.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},n.CHARSETS.H=n.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},n.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(v,n)=>{var i,l,d;Object.defineProperty(n,"__esModule",{value:!0}),n.C1_ESCAPED=n.C1=n.C0=void 0,(function(c){c.NUL="\0",c.SOH="",c.STX="",c.ETX="",c.EOT="",c.ENQ="",c.ACK="",c.BEL="\x07",c.BS="\b",c.HT=" ",c.LF=`
26
- `,c.VT="\v",c.FF="\f",c.CR="\r",c.SO="",c.SI="",c.DLE="",c.DC1="",c.DC2="",c.DC3="",c.DC4="",c.NAK="",c.SYN="",c.ETB="",c.CAN="",c.EM="",c.SUB="",c.ESC="\x1B",c.FS="",c.GS="",c.RS="",c.US="",c.SP=" ",c.DEL=""})(i||(n.C0=i={})),(function(c){c.PAD="€",c.HOP="",c.BPH="‚",c.NBH="ƒ",c.IND="„",c.NEL="…",c.SSA="†",c.ESA="‡",c.HTS="ˆ",c.HTJ="‰",c.VTS="Š",c.PLD="‹",c.PLU="Œ",c.RI="",c.SS2="Ž",c.SS3="",c.DCS="",c.PU1="‘",c.PU2="’",c.STS="“",c.CCH="”",c.MW="•",c.SPA="–",c.EPA="—",c.SOS="˜",c.SGCI="™",c.SCI="š",c.CSI="›",c.ST="œ",c.OSC="",c.PM="ž",c.APC="Ÿ"})(l||(n.C1=l={})),(function(c){c.ST=`${i.ESC}\\`})(d||(n.C1_ESCAPED=d={}))},7399:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.evaluateKeyboardEvent=void 0;const l=i(2584),d={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};n.evaluateKeyboardEvent=function(c,m,x,w){const y={type:0,cancel:!1,key:void 0},a=(c.shiftKey?1:0)|(c.altKey?2:0)|(c.ctrlKey?4:0)|(c.metaKey?8:0);switch(c.keyCode){case 0:c.key==="UIKeyInputUpArrow"?y.key=m?l.C0.ESC+"OA":l.C0.ESC+"[A":c.key==="UIKeyInputLeftArrow"?y.key=m?l.C0.ESC+"OD":l.C0.ESC+"[D":c.key==="UIKeyInputRightArrow"?y.key=m?l.C0.ESC+"OC":l.C0.ESC+"[C":c.key==="UIKeyInputDownArrow"&&(y.key=m?l.C0.ESC+"OB":l.C0.ESC+"[B");break;case 8:if(c.altKey){y.key=l.C0.ESC+l.C0.DEL;break}y.key=l.C0.DEL;break;case 9:if(c.shiftKey){y.key=l.C0.ESC+"[Z";break}y.key=l.C0.HT,y.cancel=!0;break;case 13:y.key=c.altKey?l.C0.ESC+l.C0.CR:l.C0.CR,y.cancel=!0;break;case 27:y.key=l.C0.ESC,c.altKey&&(y.key=l.C0.ESC+l.C0.ESC),y.cancel=!0;break;case 37:if(c.metaKey)break;a?(y.key=l.C0.ESC+"[1;"+(a+1)+"D",y.key===l.C0.ESC+"[1;3D"&&(y.key=l.C0.ESC+(x?"b":"[1;5D"))):y.key=m?l.C0.ESC+"OD":l.C0.ESC+"[D";break;case 39:if(c.metaKey)break;a?(y.key=l.C0.ESC+"[1;"+(a+1)+"C",y.key===l.C0.ESC+"[1;3C"&&(y.key=l.C0.ESC+(x?"f":"[1;5C"))):y.key=m?l.C0.ESC+"OC":l.C0.ESC+"[C";break;case 38:if(c.metaKey)break;a?(y.key=l.C0.ESC+"[1;"+(a+1)+"A",x||y.key!==l.C0.ESC+"[1;3A"||(y.key=l.C0.ESC+"[1;5A")):y.key=m?l.C0.ESC+"OA":l.C0.ESC+"[A";break;case 40:if(c.metaKey)break;a?(y.key=l.C0.ESC+"[1;"+(a+1)+"B",x||y.key!==l.C0.ESC+"[1;3B"||(y.key=l.C0.ESC+"[1;5B")):y.key=m?l.C0.ESC+"OB":l.C0.ESC+"[B";break;case 45:c.shiftKey||c.ctrlKey||(y.key=l.C0.ESC+"[2~");break;case 46:y.key=a?l.C0.ESC+"[3;"+(a+1)+"~":l.C0.ESC+"[3~";break;case 36:y.key=a?l.C0.ESC+"[1;"+(a+1)+"H":m?l.C0.ESC+"OH":l.C0.ESC+"[H";break;case 35:y.key=a?l.C0.ESC+"[1;"+(a+1)+"F":m?l.C0.ESC+"OF":l.C0.ESC+"[F";break;case 33:c.shiftKey?y.type=2:c.ctrlKey?y.key=l.C0.ESC+"[5;"+(a+1)+"~":y.key=l.C0.ESC+"[5~";break;case 34:c.shiftKey?y.type=3:c.ctrlKey?y.key=l.C0.ESC+"[6;"+(a+1)+"~":y.key=l.C0.ESC+"[6~";break;case 112:y.key=a?l.C0.ESC+"[1;"+(a+1)+"P":l.C0.ESC+"OP";break;case 113:y.key=a?l.C0.ESC+"[1;"+(a+1)+"Q":l.C0.ESC+"OQ";break;case 114:y.key=a?l.C0.ESC+"[1;"+(a+1)+"R":l.C0.ESC+"OR";break;case 115:y.key=a?l.C0.ESC+"[1;"+(a+1)+"S":l.C0.ESC+"OS";break;case 116:y.key=a?l.C0.ESC+"[15;"+(a+1)+"~":l.C0.ESC+"[15~";break;case 117:y.key=a?l.C0.ESC+"[17;"+(a+1)+"~":l.C0.ESC+"[17~";break;case 118:y.key=a?l.C0.ESC+"[18;"+(a+1)+"~":l.C0.ESC+"[18~";break;case 119:y.key=a?l.C0.ESC+"[19;"+(a+1)+"~":l.C0.ESC+"[19~";break;case 120:y.key=a?l.C0.ESC+"[20;"+(a+1)+"~":l.C0.ESC+"[20~";break;case 121:y.key=a?l.C0.ESC+"[21;"+(a+1)+"~":l.C0.ESC+"[21~";break;case 122:y.key=a?l.C0.ESC+"[23;"+(a+1)+"~":l.C0.ESC+"[23~";break;case 123:y.key=a?l.C0.ESC+"[24;"+(a+1)+"~":l.C0.ESC+"[24~";break;default:if(!c.ctrlKey||c.shiftKey||c.altKey||c.metaKey)if(x&&!w||!c.altKey||c.metaKey)!x||c.altKey||c.ctrlKey||c.shiftKey||!c.metaKey?c.key&&!c.ctrlKey&&!c.altKey&&!c.metaKey&&c.keyCode>=48&&c.key.length===1?y.key=c.key:c.key&&c.ctrlKey&&(c.key==="_"&&(y.key=l.C0.US),c.key==="@"&&(y.key=l.C0.NUL)):c.keyCode===65&&(y.type=1);else{const h=d[c.keyCode],u=h?.[c.shiftKey?1:0];if(u)y.key=l.C0.ESC+u;else if(c.keyCode>=65&&c.keyCode<=90){const f=c.ctrlKey?c.keyCode-64:c.keyCode+32;let b=String.fromCharCode(f);c.shiftKey&&(b=b.toUpperCase()),y.key=l.C0.ESC+b}else if(c.keyCode===32)y.key=l.C0.ESC+(c.ctrlKey?l.C0.NUL:" ");else if(c.key==="Dead"&&c.code.startsWith("Key")){let f=c.code.slice(3,4);c.shiftKey||(f=f.toLowerCase()),y.key=l.C0.ESC+f,y.cancel=!0}}else c.keyCode>=65&&c.keyCode<=90?y.key=String.fromCharCode(c.keyCode-64):c.keyCode===32?y.key=l.C0.NUL:c.keyCode>=51&&c.keyCode<=55?y.key=String.fromCharCode(c.keyCode-51+27):c.keyCode===56?y.key=l.C0.DEL:c.keyCode===219?y.key=l.C0.ESC:c.keyCode===220?y.key=l.C0.FS:c.keyCode===221&&(y.key=l.C0.GS)}return y}},482:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Utf8ToUtf32=n.StringToUtf32=n.utf32ToString=n.stringFromCodePoint=void 0,n.stringFromCodePoint=function(i){return i>65535?(i-=65536,String.fromCharCode(55296+(i>>10))+String.fromCharCode(i%1024+56320)):String.fromCharCode(i)},n.utf32ToString=function(i,l=0,d=i.length){let c="";for(let m=l;m<d;++m){let x=i[m];x>65535?(x-=65536,c+=String.fromCharCode(55296+(x>>10))+String.fromCharCode(x%1024+56320)):c+=String.fromCharCode(x)}return c},n.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(i,l){const d=i.length;if(!d)return 0;let c=0,m=0;if(this._interim){const x=i.charCodeAt(m++);56320<=x&&x<=57343?l[c++]=1024*(this._interim-55296)+x-56320+65536:(l[c++]=this._interim,l[c++]=x),this._interim=0}for(let x=m;x<d;++x){const w=i.charCodeAt(x);if(55296<=w&&w<=56319){if(++x>=d)return this._interim=w,c;const y=i.charCodeAt(x);56320<=y&&y<=57343?l[c++]=1024*(w-55296)+y-56320+65536:(l[c++]=w,l[c++]=y)}else w!==65279&&(l[c++]=w)}return c}},n.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(i,l){const d=i.length;if(!d)return 0;let c,m,x,w,y=0,a=0,h=0;if(this.interim[0]){let b=!1,C=this.interim[0];C&=(224&C)==192?31:(240&C)==224?15:7;let k,E=0;for(;(k=63&this.interim[++E])&&E<4;)C<<=6,C|=k;const _=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,j=_-E;for(;h<j;){if(h>=d)return 0;if(k=i[h++],(192&k)!=128){h--,b=!0;break}this.interim[E++]=k,C<<=6,C|=63&k}b||(_===2?C<128?h--:l[y++]=C:_===3?C<2048||C>=55296&&C<=57343||C===65279||(l[y++]=C):C<65536||C>1114111||(l[y++]=C)),this.interim.fill(0)}const u=d-4;let f=h;for(;f<d;){for(;!(!(f<u)||128&(c=i[f])||128&(m=i[f+1])||128&(x=i[f+2])||128&(w=i[f+3]));)l[y++]=c,l[y++]=m,l[y++]=x,l[y++]=w,f+=4;if(c=i[f++],c<128)l[y++]=c;else if((224&c)==192){if(f>=d)return this.interim[0]=c,y;if(m=i[f++],(192&m)!=128){f--;continue}if(a=(31&c)<<6|63&m,a<128){f--;continue}l[y++]=a}else if((240&c)==224){if(f>=d)return this.interim[0]=c,y;if(m=i[f++],(192&m)!=128){f--;continue}if(f>=d)return this.interim[0]=c,this.interim[1]=m,y;if(x=i[f++],(192&x)!=128){f--;continue}if(a=(15&c)<<12|(63&m)<<6|63&x,a<2048||a>=55296&&a<=57343||a===65279)continue;l[y++]=a}else if((248&c)==240){if(f>=d)return this.interim[0]=c,y;if(m=i[f++],(192&m)!=128){f--;continue}if(f>=d)return this.interim[0]=c,this.interim[1]=m,y;if(x=i[f++],(192&x)!=128){f--;continue}if(f>=d)return this.interim[0]=c,this.interim[1]=m,this.interim[2]=x,y;if(w=i[f++],(192&w)!=128){f--;continue}if(a=(7&c)<<18|(63&m)<<12|(63&x)<<6|63&w,a<65536||a>1114111)continue;l[y++]=a}}return y}}},225:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.UnicodeV6=void 0;const i=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],l=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]];let d;n.UnicodeV6=class{constructor(){if(this.version="6",!d){d=new Uint8Array(65536),d.fill(1),d[0]=0,d.fill(0,1,32),d.fill(0,127,160),d.fill(2,4352,4448),d[9001]=2,d[9002]=2,d.fill(2,11904,42192),d[12351]=1,d.fill(2,44032,55204),d.fill(2,63744,64256),d.fill(2,65040,65050),d.fill(2,65072,65136),d.fill(2,65280,65377),d.fill(2,65504,65511);for(let c=0;c<i.length;++c)d.fill(0,i[c][0],i[c][1]+1)}}wcwidth(c){return c<32?0:c<127?1:c<65536?d[c]:(function(m,x){let w,y=0,a=x.length-1;if(m<x[0][0]||m>x[a][1])return!1;for(;a>=y;)if(w=y+a>>1,m>x[w][1])y=w+1;else{if(!(m<x[w][0]))return!0;a=w-1}return!1})(c,l)?0:c>=131072&&c<=196605||c>=196608&&c<=262141?2:1}}},5981:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.WriteBuffer=void 0;const l=i(8460),d=i(844);class c extends d.Disposable{constructor(x){super(),this._action=x,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new l.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(x,w){if(w!==void 0&&this._syncCalls>w)return void(this._syncCalls=0);if(this._pendingData+=x.length,this._writeBuffer.push(x),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let y;for(this._isSyncWriting=!0;y=this._writeBuffer.shift();){this._action(y);const a=this._callbacks.shift();a&&a()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(x,w){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=x.length,this._writeBuffer.push(x),this._callbacks.push(w),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=x.length,this._writeBuffer.push(x),this._callbacks.push(w)}_innerWrite(x=0,w=!0){const y=x||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const a=this._writeBuffer[this._bufferOffset],h=this._action(a,w);if(h){const f=b=>Date.now()-y>=12?setTimeout((()=>this._innerWrite(0,b))):this._innerWrite(y,b);return void h.catch((b=>(queueMicrotask((()=>{throw b})),Promise.resolve(!1)))).then(f)}const u=this._callbacks[this._bufferOffset];if(u&&u(),this._bufferOffset++,this._pendingData-=a.length,Date.now()-y>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((()=>this._innerWrite()))):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}n.WriteBuffer=c},5941:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.toRgbString=n.parseColor=void 0;const i=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,l=/^[\da-f]+$/;function d(c,m){const x=c.toString(16),w=x.length<2?"0"+x:x;switch(m){case 4:return x[0];case 8:return w;case 12:return(w+w).slice(0,3);default:return w+w}}n.parseColor=function(c){if(!c)return;let m=c.toLowerCase();if(m.indexOf("rgb:")===0){m=m.slice(4);const x=i.exec(m);if(x){const w=x[1]?15:x[4]?255:x[7]?4095:65535;return[Math.round(parseInt(x[1]||x[4]||x[7]||x[10],16)/w*255),Math.round(parseInt(x[2]||x[5]||x[8]||x[11],16)/w*255),Math.round(parseInt(x[3]||x[6]||x[9]||x[12],16)/w*255)]}}else if(m.indexOf("#")===0&&(m=m.slice(1),l.exec(m)&&[3,6,9,12].includes(m.length))){const x=m.length/3,w=[0,0,0];for(let y=0;y<3;++y){const a=parseInt(m.slice(x*y,x*y+x),16);w[y]=x===1?a<<4:x===2?a:x===3?a>>4:a>>8}return w}},n.toRgbString=function(c,m=16){const[x,w,y]=c;return`rgb:${d(x,m)}/${d(w,m)}/${d(y,m)}`}},5770:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.PAYLOAD_LIMIT=void 0,n.PAYLOAD_LIMIT=1e7},6351:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DcsHandler=n.DcsParser=void 0;const l=i(482),d=i(8742),c=i(5770),m=[];n.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=m,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=m}registerHandler(w,y){this._handlers[w]===void 0&&(this._handlers[w]=[]);const a=this._handlers[w];return a.push(y),{dispose:()=>{const h=a.indexOf(y);h!==-1&&a.splice(h,1)}}}clearHandler(w){this._handlers[w]&&delete this._handlers[w]}setHandlerFallback(w){this._handlerFb=w}reset(){if(this._active.length)for(let w=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;w>=0;--w)this._active[w].unhook(!1);this._stack.paused=!1,this._active=m,this._ident=0}hook(w,y){if(this.reset(),this._ident=w,this._active=this._handlers[w]||m,this._active.length)for(let a=this._active.length-1;a>=0;a--)this._active[a].hook(y);else this._handlerFb(this._ident,"HOOK",y)}put(w,y,a){if(this._active.length)for(let h=this._active.length-1;h>=0;h--)this._active[h].put(w,y,a);else this._handlerFb(this._ident,"PUT",(0,l.utf32ToString)(w,y,a))}unhook(w,y=!0){if(this._active.length){let a=!1,h=this._active.length-1,u=!1;if(this._stack.paused&&(h=this._stack.loopPosition-1,a=y,u=this._stack.fallThrough,this._stack.paused=!1),!u&&a===!1){for(;h>=0&&(a=this._active[h].unhook(w),a!==!0);h--)if(a instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=h,this._stack.fallThrough=!1,a;h--}for(;h>=0;h--)if(a=this._active[h].unhook(!1),a instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=h,this._stack.fallThrough=!0,a}else this._handlerFb(this._ident,"UNHOOK",w);this._active=m,this._ident=0}};const x=new d.Params;x.addParam(0),n.DcsHandler=class{constructor(w){this._handler=w,this._data="",this._params=x,this._hitLimit=!1}hook(w){this._params=w.length>1||w.params[0]?w.clone():x,this._data="",this._hitLimit=!1}put(w,y,a){this._hitLimit||(this._data+=(0,l.utf32ToString)(w,y,a),this._data.length>c.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(w){let y=!1;if(this._hitLimit)y=!1;else if(w&&(y=this._handler(this._data,this._params),y instanceof Promise))return y.then((a=>(this._params=x,this._data="",this._hitLimit=!1,a)));return this._params=x,this._data="",this._hitLimit=!1,y}}},2015:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.EscapeSequenceParser=n.VT500_TRANSITION_TABLE=n.TransitionTable=void 0;const l=i(844),d=i(8742),c=i(6242),m=i(6351);class x{constructor(h){this.table=new Uint8Array(h)}setDefault(h,u){this.table.fill(h<<4|u)}add(h,u,f,b){this.table[u<<8|h]=f<<4|b}addMany(h,u,f,b){for(let C=0;C<h.length;C++)this.table[u<<8|h[C]]=f<<4|b}}n.TransitionTable=x;const w=160;n.VT500_TRANSITION_TABLE=(function(){const a=new x(4095),h=Array.apply(null,Array(256)).map(((E,_)=>_)),u=(E,_)=>h.slice(E,_),f=u(32,127),b=u(0,24);b.push(25),b.push.apply(b,u(28,32));const C=u(0,14);let k;for(k in a.setDefault(1,0),a.addMany(f,0,2,0),C)a.addMany([24,26,153,154],k,3,0),a.addMany(u(128,144),k,3,0),a.addMany(u(144,152),k,3,0),a.add(156,k,0,0),a.add(27,k,11,1),a.add(157,k,4,8),a.addMany([152,158,159],k,0,7),a.add(155,k,11,3),a.add(144,k,11,9);return a.addMany(b,0,3,0),a.addMany(b,1,3,1),a.add(127,1,0,1),a.addMany(b,8,0,8),a.addMany(b,3,3,3),a.add(127,3,0,3),a.addMany(b,4,3,4),a.add(127,4,0,4),a.addMany(b,6,3,6),a.addMany(b,5,3,5),a.add(127,5,0,5),a.addMany(b,2,3,2),a.add(127,2,0,2),a.add(93,1,4,8),a.addMany(f,8,5,8),a.add(127,8,5,8),a.addMany([156,27,24,26,7],8,6,0),a.addMany(u(28,32),8,0,8),a.addMany([88,94,95],1,0,7),a.addMany(f,7,0,7),a.addMany(b,7,0,7),a.add(156,7,0,0),a.add(127,7,0,7),a.add(91,1,11,3),a.addMany(u(64,127),3,7,0),a.addMany(u(48,60),3,8,4),a.addMany([60,61,62,63],3,9,4),a.addMany(u(48,60),4,8,4),a.addMany(u(64,127),4,7,0),a.addMany([60,61,62,63],4,0,6),a.addMany(u(32,64),6,0,6),a.add(127,6,0,6),a.addMany(u(64,127),6,0,0),a.addMany(u(32,48),3,9,5),a.addMany(u(32,48),5,9,5),a.addMany(u(48,64),5,0,6),a.addMany(u(64,127),5,7,0),a.addMany(u(32,48),4,9,5),a.addMany(u(32,48),1,9,2),a.addMany(u(32,48),2,9,2),a.addMany(u(48,127),2,10,0),a.addMany(u(48,80),1,10,0),a.addMany(u(81,88),1,10,0),a.addMany([89,90,92],1,10,0),a.addMany(u(96,127),1,10,0),a.add(80,1,11,9),a.addMany(b,9,0,9),a.add(127,9,0,9),a.addMany(u(28,32),9,0,9),a.addMany(u(32,48),9,9,12),a.addMany(u(48,60),9,8,10),a.addMany([60,61,62,63],9,9,10),a.addMany(b,11,0,11),a.addMany(u(32,128),11,0,11),a.addMany(u(28,32),11,0,11),a.addMany(b,10,0,10),a.add(127,10,0,10),a.addMany(u(28,32),10,0,10),a.addMany(u(48,60),10,8,10),a.addMany([60,61,62,63],10,0,11),a.addMany(u(32,48),10,9,12),a.addMany(b,12,0,12),a.add(127,12,0,12),a.addMany(u(28,32),12,0,12),a.addMany(u(32,48),12,9,12),a.addMany(u(48,64),12,0,11),a.addMany(u(64,127),12,12,13),a.addMany(u(64,127),10,12,13),a.addMany(u(64,127),9,12,13),a.addMany(b,13,13,13),a.addMany(f,13,13,13),a.add(127,13,0,13),a.addMany([27,156,24,26],13,14,0),a.add(w,0,2,0),a.add(w,8,5,8),a.add(w,6,0,6),a.add(w,11,0,11),a.add(w,13,13,13),a})();class y extends l.Disposable{constructor(h=n.VT500_TRANSITION_TABLE){super(),this._transitions=h,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new d.Params,this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._printHandlerFb=(u,f,b)=>{},this._executeHandlerFb=u=>{},this._csiHandlerFb=(u,f)=>{},this._escHandlerFb=u=>{},this._errorHandlerFb=u=>u,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,l.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new c.OscParser),this._dcsParser=this.register(new m.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(h,u=[64,126]){let f=0;if(h.prefix){if(h.prefix.length>1)throw new Error("only one byte as prefix supported");if(f=h.prefix.charCodeAt(0),f&&60>f||f>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(h.intermediates){if(h.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let C=0;C<h.intermediates.length;++C){const k=h.intermediates.charCodeAt(C);if(32>k||k>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");f<<=8,f|=k}}if(h.final.length!==1)throw new Error("final must be a single byte");const b=h.final.charCodeAt(0);if(u[0]>b||b>u[1])throw new Error(`final must be in range ${u[0]} .. ${u[1]}`);return f<<=8,f|=b,f}identToString(h){const u=[];for(;h;)u.push(String.fromCharCode(255&h)),h>>=8;return u.reverse().join("")}setPrintHandler(h){this._printHandler=h}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(h,u){const f=this._identifier(h,[48,126]);this._escHandlers[f]===void 0&&(this._escHandlers[f]=[]);const b=this._escHandlers[f];return b.push(u),{dispose:()=>{const C=b.indexOf(u);C!==-1&&b.splice(C,1)}}}clearEscHandler(h){this._escHandlers[this._identifier(h,[48,126])]&&delete this._escHandlers[this._identifier(h,[48,126])]}setEscHandlerFallback(h){this._escHandlerFb=h}setExecuteHandler(h,u){this._executeHandlers[h.charCodeAt(0)]=u}clearExecuteHandler(h){this._executeHandlers[h.charCodeAt(0)]&&delete this._executeHandlers[h.charCodeAt(0)]}setExecuteHandlerFallback(h){this._executeHandlerFb=h}registerCsiHandler(h,u){const f=this._identifier(h);this._csiHandlers[f]===void 0&&(this._csiHandlers[f]=[]);const b=this._csiHandlers[f];return b.push(u),{dispose:()=>{const C=b.indexOf(u);C!==-1&&b.splice(C,1)}}}clearCsiHandler(h){this._csiHandlers[this._identifier(h)]&&delete this._csiHandlers[this._identifier(h)]}setCsiHandlerFallback(h){this._csiHandlerFb=h}registerDcsHandler(h,u){return this._dcsParser.registerHandler(this._identifier(h),u)}clearDcsHandler(h){this._dcsParser.clearHandler(this._identifier(h))}setDcsHandlerFallback(h){this._dcsParser.setHandlerFallback(h)}registerOscHandler(h,u){return this._oscParser.registerHandler(h,u)}clearOscHandler(h){this._oscParser.clearHandler(h)}setOscHandlerFallback(h){this._oscParser.setHandlerFallback(h)}setErrorHandler(h){this._errorHandler=h}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(h,u,f,b,C){this._parseStack.state=h,this._parseStack.handlers=u,this._parseStack.handlerPos=f,this._parseStack.transition=b,this._parseStack.chunkPos=C}parse(h,u,f){let b,C=0,k=0,E=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,E=this._parseStack.chunkPos+1;else{if(f===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const _=this._parseStack.handlers;let j=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(f===!1&&j>-1){for(;j>=0&&(b=_[j](this._params),b!==!0);j--)if(b instanceof Promise)return this._parseStack.handlerPos=j,b}this._parseStack.handlers=[];break;case 4:if(f===!1&&j>-1){for(;j>=0&&(b=_[j](),b!==!0);j--)if(b instanceof Promise)return this._parseStack.handlerPos=j,b}this._parseStack.handlers=[];break;case 6:if(C=h[this._parseStack.chunkPos],b=this._dcsParser.unhook(C!==24&&C!==26,f),b)return b;C===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(C=h[this._parseStack.chunkPos],b=this._oscParser.end(C!==24&&C!==26,f),b)return b;C===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,E=this._parseStack.chunkPos+1,this.precedingCodepoint=0,this.currentState=15&this._parseStack.transition}for(let _=E;_<u;++_){switch(C=h[_],k=this._transitions.table[this.currentState<<8|(C<160?C:w)],k>>4){case 2:for(let D=_+1;;++D){if(D>=u||(C=h[D])<32||C>126&&C<w){this._printHandler(h,_,D),_=D-1;break}if(++D>=u||(C=h[D])<32||C>126&&C<w){this._printHandler(h,_,D),_=D-1;break}if(++D>=u||(C=h[D])<32||C>126&&C<w){this._printHandler(h,_,D),_=D-1;break}if(++D>=u||(C=h[D])<32||C>126&&C<w){this._printHandler(h,_,D),_=D-1;break}}break;case 3:this._executeHandlers[C]?this._executeHandlers[C]():this._executeHandlerFb(C),this.precedingCodepoint=0;break;case 0:break;case 1:if(this._errorHandler({position:_,code:C,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const j=this._csiHandlers[this._collect<<8|C];let A=j?j.length-1:-1;for(;A>=0&&(b=j[A](this._params),b!==!0);A--)if(b instanceof Promise)return this._preserveStack(3,j,A,k,_),b;A<0&&this._csiHandlerFb(this._collect<<8|C,this._params),this.precedingCodepoint=0;break;case 8:do switch(C){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(C-48)}while(++_<u&&(C=h[_])>47&&C<60);_--;break;case 9:this._collect<<=8,this._collect|=C;break;case 10:const P=this._escHandlers[this._collect<<8|C];let T=P?P.length-1:-1;for(;T>=0&&(b=P[T](),b!==!0);T--)if(b instanceof Promise)return this._preserveStack(4,P,T,k,_),b;T<0&&this._escHandlerFb(this._collect<<8|C),this.precedingCodepoint=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|C,this._params);break;case 13:for(let D=_+1;;++D)if(D>=u||(C=h[D])===24||C===26||C===27||C>127&&C<w){this._dcsParser.put(h,_,D),_=D-1;break}break;case 14:if(b=this._dcsParser.unhook(C!==24&&C!==26),b)return this._preserveStack(6,[],0,k,_),b;C===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0;break;case 4:this._oscParser.start();break;case 5:for(let D=_+1;;D++)if(D>=u||(C=h[D])<32||C>127&&C<w){this._oscParser.put(h,_,D),_=D-1;break}break;case 6:if(b=this._oscParser.end(C!==24&&C!==26),b)return this._preserveStack(5,[],0,k,_),b;C===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0}this.currentState=15&k}}}n.EscapeSequenceParser=y},6242:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.OscHandler=n.OscParser=void 0;const l=i(5770),d=i(482),c=[];n.OscParser=class{constructor(){this._state=0,this._active=c,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(m,x){this._handlers[m]===void 0&&(this._handlers[m]=[]);const w=this._handlers[m];return w.push(x),{dispose:()=>{const y=w.indexOf(x);y!==-1&&w.splice(y,1)}}}clearHandler(m){this._handlers[m]&&delete this._handlers[m]}setHandlerFallback(m){this._handlerFb=m}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=c}reset(){if(this._state===2)for(let m=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;m>=0;--m)this._active[m].end(!1);this._stack.paused=!1,this._active=c,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||c,this._active.length)for(let m=this._active.length-1;m>=0;m--)this._active[m].start();else this._handlerFb(this._id,"START")}_put(m,x,w){if(this._active.length)for(let y=this._active.length-1;y>=0;y--)this._active[y].put(m,x,w);else this._handlerFb(this._id,"PUT",(0,d.utf32ToString)(m,x,w))}start(){this.reset(),this._state=1}put(m,x,w){if(this._state!==3){if(this._state===1)for(;x<w;){const y=m[x++];if(y===59){this._state=2,this._start();break}if(y<48||57<y)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+y-48}this._state===2&&w-x>0&&this._put(m,x,w)}}end(m,x=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let w=!1,y=this._active.length-1,a=!1;if(this._stack.paused&&(y=this._stack.loopPosition-1,w=x,a=this._stack.fallThrough,this._stack.paused=!1),!a&&w===!1){for(;y>=0&&(w=this._active[y].end(m),w!==!0);y--)if(w instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=y,this._stack.fallThrough=!1,w;y--}for(;y>=0;y--)if(w=this._active[y].end(!1),w instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=y,this._stack.fallThrough=!0,w}else this._handlerFb(this._id,"END",m);this._active=c,this._id=-1,this._state=0}}},n.OscHandler=class{constructor(m){this._handler=m,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(m,x,w){this._hitLimit||(this._data+=(0,d.utf32ToString)(m,x,w),this._data.length>l.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(m){let x=!1;if(this._hitLimit)x=!1;else if(m&&(x=this._handler(this._data),x instanceof Promise))return x.then((w=>(this._data="",this._hitLimit=!1,w)));return this._data="",this._hitLimit=!1,x}}},8742:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.Params=void 0;const i=2147483647;class l{static fromArray(c){const m=new l;if(!c.length)return m;for(let x=Array.isArray(c[0])?1:0;x<c.length;++x){const w=c[x];if(Array.isArray(w))for(let y=0;y<w.length;++y)m.addSubParam(w[y]);else m.addParam(w)}return m}constructor(c=32,m=32){if(this.maxLength=c,this.maxSubParamsLength=m,m>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(c),this.length=0,this._subParams=new Int32Array(m),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(c),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const c=new l(this.maxLength,this.maxSubParamsLength);return c.params.set(this.params),c.length=this.length,c._subParams.set(this._subParams),c._subParamsLength=this._subParamsLength,c._subParamsIdx.set(this._subParamsIdx),c._rejectDigits=this._rejectDigits,c._rejectSubDigits=this._rejectSubDigits,c._digitIsSub=this._digitIsSub,c}toArray(){const c=[];for(let m=0;m<this.length;++m){c.push(this.params[m]);const x=this._subParamsIdx[m]>>8,w=255&this._subParamsIdx[m];w-x>0&&c.push(Array.prototype.slice.call(this._subParams,x,w))}return c}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(c){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(c<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=c>i?i:c}}addSubParam(c){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(c<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=c>i?i:c,this._subParamsIdx[this.length-1]++}}hasSubParams(c){return(255&this._subParamsIdx[c])-(this._subParamsIdx[c]>>8)>0}getSubParams(c){const m=this._subParamsIdx[c]>>8,x=255&this._subParamsIdx[c];return x-m>0?this._subParams.subarray(m,x):null}getSubParamsAll(){const c={};for(let m=0;m<this.length;++m){const x=this._subParamsIdx[m]>>8,w=255&this._subParamsIdx[m];w-x>0&&(c[m]=this._subParams.slice(x,w))}return c}addDigit(c){let m;if(this._rejectDigits||!(m=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const x=this._digitIsSub?this._subParams:this.params,w=x[m-1];x[m-1]=~w?Math.min(10*w+c,i):c}}n.Params=l},5741:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.AddonManager=void 0,n.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let i=this._addons.length-1;i>=0;i--)this._addons[i].instance.dispose()}loadAddon(i,l){const d={instance:l,dispose:l.dispose,isDisposed:!1};this._addons.push(d),l.dispose=()=>this._wrappedAddonDispose(d),l.activate(i)}_wrappedAddonDispose(i){if(i.isDisposed)return;let l=-1;for(let d=0;d<this._addons.length;d++)if(this._addons[d]===i){l=d;break}if(l===-1)throw new Error("Could not dispose an addon that has not been loaded");i.isDisposed=!0,i.dispose.apply(i.instance),this._addons.splice(l,1)}}},8771:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferApiView=void 0;const l=i(3785),d=i(511);n.BufferApiView=class{constructor(c,m){this._buffer=c,this.type=m}init(c){return this._buffer=c,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(c){const m=this._buffer.lines.get(c);if(m)return new l.BufferLineApiView(m)}getNullCell(){return new d.CellData}}},3785:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferLineApiView=void 0;const l=i(511);n.BufferLineApiView=class{constructor(d){this._line=d}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(d,c){if(!(d<0||d>=this._line.length))return c?(this._line.loadCell(d,c),c):this._line.loadCell(d,new l.CellData)}translateToString(d,c,m){return this._line.translateToString(d,c,m)}}},8285:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.BufferNamespaceApi=void 0;const l=i(8771),d=i(8460),c=i(844);class m extends c.Disposable{constructor(w){super(),this._core=w,this._onBufferChange=this.register(new d.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new l.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new l.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate((()=>this._onBufferChange.fire(this.active)))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}n.BufferNamespaceApi=m},7975:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ParserApi=void 0,n.ParserApi=class{constructor(i){this._core=i}registerCsiHandler(i,l){return this._core.registerCsiHandler(i,(d=>l(d.toArray())))}addCsiHandler(i,l){return this.registerCsiHandler(i,l)}registerDcsHandler(i,l){return this._core.registerDcsHandler(i,((d,c)=>l(d,c.toArray())))}addDcsHandler(i,l){return this.registerDcsHandler(i,l)}registerEscHandler(i,l){return this._core.registerEscHandler(i,l)}addEscHandler(i,l){return this.registerEscHandler(i,l)}registerOscHandler(i,l){return this._core.registerOscHandler(i,l)}addOscHandler(i,l){return this.registerOscHandler(i,l)}}},7090:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.UnicodeApi=void 0,n.UnicodeApi=class{constructor(i){this._core=i}register(i){this._core.unicodeService.register(i)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(i){this._core.unicodeService.activeVersion=i}}},744:function(v,n,i){var l=this&&this.__decorate||function(a,h,u,f){var b,C=arguments.length,k=C<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,u):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,u,f);else for(var E=a.length-1;E>=0;E--)(b=a[E])&&(k=(C<3?b(k):C>3?b(h,u,k):b(h,u))||k);return C>3&&k&&Object.defineProperty(h,u,k),k},d=this&&this.__param||function(a,h){return function(u,f){h(u,f,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.BufferService=n.MINIMUM_ROWS=n.MINIMUM_COLS=void 0;const c=i(8460),m=i(844),x=i(5295),w=i(2585);n.MINIMUM_COLS=2,n.MINIMUM_ROWS=1;let y=n.BufferService=class extends m.Disposable{get buffer(){return this.buffers.active}constructor(a){super(),this.isUserScrolling=!1,this._onResize=this.register(new c.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new c.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(a.rawOptions.cols||0,n.MINIMUM_COLS),this.rows=Math.max(a.rawOptions.rows||0,n.MINIMUM_ROWS),this.buffers=this.register(new x.BufferSet(a,this))}resize(a,h){this.cols=a,this.rows=h,this.buffers.resize(a,h),this._onResize.fire({cols:a,rows:h})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(a,h=!1){const u=this.buffer;let f;f=this._cachedBlankLine,f&&f.length===this.cols&&f.getFg(0)===a.fg&&f.getBg(0)===a.bg||(f=u.getBlankLine(a,h),this._cachedBlankLine=f),f.isWrapped=h;const b=u.ybase+u.scrollTop,C=u.ybase+u.scrollBottom;if(u.scrollTop===0){const k=u.lines.isFull;C===u.lines.length-1?k?u.lines.recycle().copyFrom(f):u.lines.push(f.clone()):u.lines.splice(C+1,0,f.clone()),k?this.isUserScrolling&&(u.ydisp=Math.max(u.ydisp-1,0)):(u.ybase++,this.isUserScrolling||u.ydisp++)}else{const k=C-b+1;u.lines.shiftElements(b+1,k-1,-1),u.lines.set(C,f.clone())}this.isUserScrolling||(u.ydisp=u.ybase),this._onScroll.fire(u.ydisp)}scrollLines(a,h,u){const f=this.buffer;if(a<0){if(f.ydisp===0)return;this.isUserScrolling=!0}else a+f.ydisp>=f.ybase&&(this.isUserScrolling=!1);const b=f.ydisp;f.ydisp=Math.max(Math.min(f.ydisp+a,f.ybase),0),b!==f.ydisp&&(h||this._onScroll.fire(f.ydisp))}};n.BufferService=y=l([d(0,w.IOptionsService)],y)},7994:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.CharsetService=void 0,n.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(i){this.glevel=i,this.charset=this._charsets[i]}setgCharset(i,l){this._charsets[i]=l,this.glevel===i&&(this.charset=l)}}},1753:function(v,n,i){var l=this&&this.__decorate||function(f,b,C,k){var E,_=arguments.length,j=_<3?b:k===null?k=Object.getOwnPropertyDescriptor(b,C):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(f,b,C,k);else for(var A=f.length-1;A>=0;A--)(E=f[A])&&(j=(_<3?E(j):_>3?E(b,C,j):E(b,C))||j);return _>3&&j&&Object.defineProperty(b,C,j),j},d=this&&this.__param||function(f,b){return function(C,k){b(C,k,f)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CoreMouseService=void 0;const c=i(2585),m=i(8460),x=i(844),w={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:f=>f.button!==4&&f.action===1&&(f.ctrl=!1,f.alt=!1,f.shift=!1,!0)},VT200:{events:19,restrict:f=>f.action!==32},DRAG:{events:23,restrict:f=>f.action!==32||f.button!==3},ANY:{events:31,restrict:f=>!0}};function y(f,b){let C=(f.ctrl?16:0)|(f.shift?4:0)|(f.alt?8:0);return f.button===4?(C|=64,C|=f.action):(C|=3&f.button,4&f.button&&(C|=64),8&f.button&&(C|=128),f.action===32?C|=32:f.action!==0||b||(C|=3)),C}const a=String.fromCharCode,h={DEFAULT:f=>{const b=[y(f,!1)+32,f.col+32,f.row+32];return b[0]>255||b[1]>255||b[2]>255?"":`\x1B[M${a(b[0])}${a(b[1])}${a(b[2])}`},SGR:f=>{const b=f.action===0&&f.button!==4?"m":"M";return`\x1B[<${y(f,!0)};${f.col};${f.row}${b}`},SGR_PIXELS:f=>{const b=f.action===0&&f.button!==4?"m":"M";return`\x1B[<${y(f,!0)};${f.x};${f.y}${b}`}};let u=n.CoreMouseService=class extends x.Disposable{constructor(f,b){super(),this._bufferService=f,this._coreService=b,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new m.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const C of Object.keys(w))this.addProtocol(C,w[C]);for(const C of Object.keys(h))this.addEncoding(C,h[C]);this.reset()}addProtocol(f,b){this._protocols[f]=b}addEncoding(f,b){this._encodings[f]=b}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(f){if(!this._protocols[f])throw new Error(`unknown protocol "${f}"`);this._activeProtocol=f,this._onProtocolChange.fire(this._protocols[f].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(f){if(!this._encodings[f])throw new Error(`unknown encoding "${f}"`);this._activeEncoding=f}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(f){if(f.col<0||f.col>=this._bufferService.cols||f.row<0||f.row>=this._bufferService.rows||f.button===4&&f.action===32||f.button===3&&f.action!==32||f.button!==4&&(f.action===2||f.action===3)||(f.col++,f.row++,f.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,f,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(f))return!1;const b=this._encodings[this._activeEncoding](f);return b&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(b):this._coreService.triggerDataEvent(b,!0)),this._lastEvent=f,!0}explainEvents(f){return{down:!!(1&f),up:!!(2&f),drag:!!(4&f),move:!!(8&f),wheel:!!(16&f)}}_equalEvents(f,b,C){if(C){if(f.x!==b.x||f.y!==b.y)return!1}else if(f.col!==b.col||f.row!==b.row)return!1;return f.button===b.button&&f.action===b.action&&f.ctrl===b.ctrl&&f.alt===b.alt&&f.shift===b.shift}};n.CoreMouseService=u=l([d(0,c.IBufferService),d(1,c.ICoreService)],u)},6975:function(v,n,i){var l=this&&this.__decorate||function(u,f,b,C){var k,E=arguments.length,_=E<3?f:C===null?C=Object.getOwnPropertyDescriptor(f,b):C;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")_=Reflect.decorate(u,f,b,C);else for(var j=u.length-1;j>=0;j--)(k=u[j])&&(_=(E<3?k(_):E>3?k(f,b,_):k(f,b))||_);return E>3&&_&&Object.defineProperty(f,b,_),_},d=this&&this.__param||function(u,f){return function(b,C){f(b,C,u)}};Object.defineProperty(n,"__esModule",{value:!0}),n.CoreService=void 0;const c=i(1439),m=i(8460),x=i(844),w=i(2585),y=Object.freeze({insertMode:!1}),a=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let h=n.CoreService=class extends x.Disposable{constructor(u,f,b){super(),this._bufferService=u,this._logService=f,this._optionsService=b,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new m.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new m.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new m.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new m.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,c.clone)(y),this.decPrivateModes=(0,c.clone)(a)}reset(){this.modes=(0,c.clone)(y),this.decPrivateModes=(0,c.clone)(a)}triggerDataEvent(u,f=!1){if(this._optionsService.rawOptions.disableStdin)return;const b=this._bufferService.buffer;f&&this._optionsService.rawOptions.scrollOnUserInput&&b.ybase!==b.ydisp&&this._onRequestScrollToBottom.fire(),f&&this._onUserInput.fire(),this._logService.debug(`sending data "${u}"`,(()=>u.split("").map((C=>C.charCodeAt(0))))),this._onData.fire(u)}triggerBinaryEvent(u){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${u}"`,(()=>u.split("").map((f=>f.charCodeAt(0))))),this._onBinary.fire(u))}};n.CoreService=h=l([d(0,w.IBufferService),d(1,w.ILogService),d(2,w.IOptionsService)],h)},9074:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.DecorationService=void 0;const l=i(8055),d=i(8460),c=i(844),m=i(6106);let x=0,w=0;class y extends c.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new m.SortedList((u=>u?.marker.line)),this._onDecorationRegistered=this.register(new d.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new d.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,c.toDisposable)((()=>this.reset())))}registerDecoration(u){if(u.marker.isDisposed)return;const f=new a(u);if(f){const b=f.marker.onDispose((()=>f.dispose()));f.onDispose((()=>{f&&(this._decorations.delete(f)&&this._onDecorationRemoved.fire(f),b.dispose())})),this._decorations.insert(f),this._onDecorationRegistered.fire(f)}return f}reset(){for(const u of this._decorations.values())u.dispose();this._decorations.clear()}*getDecorationsAtCell(u,f,b){var C,k,E;let _=0,j=0;for(const A of this._decorations.getKeyIterator(f))_=(C=A.options.x)!==null&&C!==void 0?C:0,j=_+((k=A.options.width)!==null&&k!==void 0?k:1),u>=_&&u<j&&(!b||((E=A.options.layer)!==null&&E!==void 0?E:"bottom")===b)&&(yield A)}forEachDecorationAtCell(u,f,b,C){this._decorations.forEachByKey(f,(k=>{var E,_,j;x=(E=k.options.x)!==null&&E!==void 0?E:0,w=x+((_=k.options.width)!==null&&_!==void 0?_:1),u>=x&&u<w&&(!b||((j=k.options.layer)!==null&&j!==void 0?j:"bottom")===b)&&C(k)}))}}n.DecorationService=y;class a extends c.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=l.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=l.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(u){super(),this.options=u,this.onRenderEmitter=this.register(new d.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new d.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=u.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.InstantiationService=n.ServiceCollection=void 0;const l=i(2585),d=i(8343);class c{constructor(...x){this._entries=new Map;for(const[w,y]of x)this.set(w,y)}set(x,w){const y=this._entries.get(x);return this._entries.set(x,w),y}forEach(x){for(const[w,y]of this._entries.entries())x(w,y)}has(x){return this._entries.has(x)}get(x){return this._entries.get(x)}}n.ServiceCollection=c,n.InstantiationService=class{constructor(){this._services=new c,this._services.set(l.IInstantiationService,this)}setService(m,x){this._services.set(m,x)}getService(m){return this._services.get(m)}createInstance(m,...x){const w=(0,d.getServiceDependencies)(m).sort(((h,u)=>h.index-u.index)),y=[];for(const h of w){const u=this._services.get(h.id);if(!u)throw new Error(`[createInstance] ${m.name} depends on UNKNOWN service ${h.id}.`);y.push(u)}const a=w.length>0?w[0].index:x.length;if(x.length!==a)throw new Error(`[createInstance] First service dependency of ${m.name} at position ${a+1} conflicts with ${x.length} static arguments`);return new m(...x,...y)}}},7866:function(v,n,i){var l=this&&this.__decorate||function(a,h,u,f){var b,C=arguments.length,k=C<3?h:f===null?f=Object.getOwnPropertyDescriptor(h,u):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,h,u,f);else for(var E=a.length-1;E>=0;E--)(b=a[E])&&(k=(C<3?b(k):C>3?b(h,u,k):b(h,u))||k);return C>3&&k&&Object.defineProperty(h,u,k),k},d=this&&this.__param||function(a,h){return function(u,f){h(u,f,a)}};Object.defineProperty(n,"__esModule",{value:!0}),n.traceCall=n.setTraceLogger=n.LogService=void 0;const c=i(844),m=i(2585),x={trace:m.LogLevelEnum.TRACE,debug:m.LogLevelEnum.DEBUG,info:m.LogLevelEnum.INFO,warn:m.LogLevelEnum.WARN,error:m.LogLevelEnum.ERROR,off:m.LogLevelEnum.OFF};let w,y=n.LogService=class extends c.Disposable{get logLevel(){return this._logLevel}constructor(a){super(),this._optionsService=a,this._logLevel=m.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),w=this}_updateLogLevel(){this._logLevel=x[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(a){for(let h=0;h<a.length;h++)typeof a[h]=="function"&&(a[h]=a[h]())}_log(a,h,u){this._evalLazyOptionalParams(u),a.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+h,...u)}trace(a,...h){var u,f;this._logLevel<=m.LogLevelEnum.TRACE&&this._log((f=(u=this._optionsService.options.logger)===null||u===void 0?void 0:u.trace.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.log,a,h)}debug(a,...h){var u,f;this._logLevel<=m.LogLevelEnum.DEBUG&&this._log((f=(u=this._optionsService.options.logger)===null||u===void 0?void 0:u.debug.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.log,a,h)}info(a,...h){var u,f;this._logLevel<=m.LogLevelEnum.INFO&&this._log((f=(u=this._optionsService.options.logger)===null||u===void 0?void 0:u.info.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.info,a,h)}warn(a,...h){var u,f;this._logLevel<=m.LogLevelEnum.WARN&&this._log((f=(u=this._optionsService.options.logger)===null||u===void 0?void 0:u.warn.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.warn,a,h)}error(a,...h){var u,f;this._logLevel<=m.LogLevelEnum.ERROR&&this._log((f=(u=this._optionsService.options.logger)===null||u===void 0?void 0:u.error.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.error,a,h)}};n.LogService=y=l([d(0,m.IOptionsService)],y),n.setTraceLogger=function(a){w=a},n.traceCall=function(a,h,u){if(typeof u.value!="function")throw new Error("not supported");const f=u.value;u.value=function(...b){if(w.logLevel!==m.LogLevelEnum.TRACE)return f.apply(this,b);w.trace(`GlyphRenderer#${f.name}(${b.map((k=>JSON.stringify(k))).join(", ")})`);const C=f.apply(this,b);return w.trace(`GlyphRenderer#${f.name} return`,C),C}}},7302:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.OptionsService=n.DEFAULT_OPTIONS=void 0;const l=i(8460),d=i(844),c=i(6114);n.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rightClickSelectsWord:c.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const m=["normal","bold","100","200","300","400","500","600","700","800","900"];class x extends d.Disposable{constructor(y){super(),this._onOptionChange=this.register(new l.EventEmitter),this.onOptionChange=this._onOptionChange.event;const a=Object.assign({},n.DEFAULT_OPTIONS);for(const h in y)if(h in a)try{const u=y[h];a[h]=this._sanitizeAndValidateOption(h,u)}catch(u){console.error(u)}this.rawOptions=a,this.options=Object.assign({},a),this._setupOptions()}onSpecificOptionChange(y,a){return this.onOptionChange((h=>{h===y&&a(this.rawOptions[y])}))}onMultipleOptionChange(y,a){return this.onOptionChange((h=>{y.indexOf(h)!==-1&&a()}))}_setupOptions(){const y=h=>{if(!(h in n.DEFAULT_OPTIONS))throw new Error(`No option with key "${h}"`);return this.rawOptions[h]},a=(h,u)=>{if(!(h in n.DEFAULT_OPTIONS))throw new Error(`No option with key "${h}"`);u=this._sanitizeAndValidateOption(h,u),this.rawOptions[h]!==u&&(this.rawOptions[h]=u,this._onOptionChange.fire(h))};for(const h in this.rawOptions){const u={get:y.bind(this,h),set:a.bind(this,h)};Object.defineProperty(this.options,h,u)}}_sanitizeAndValidateOption(y,a){switch(y){case"cursorStyle":if(a||(a=n.DEFAULT_OPTIONS[y]),!(function(h){return h==="block"||h==="underline"||h==="bar"})(a))throw new Error(`"${a}" is not a valid value for ${y}`);break;case"wordSeparator":a||(a=n.DEFAULT_OPTIONS[y]);break;case"fontWeight":case"fontWeightBold":if(typeof a=="number"&&1<=a&&a<=1e3)break;a=m.includes(a)?a:n.DEFAULT_OPTIONS[y];break;case"cursorWidth":a=Math.floor(a);case"lineHeight":case"tabStopWidth":if(a<1)throw new Error(`${y} cannot be less than 1, value: ${a}`);break;case"minimumContrastRatio":a=Math.max(1,Math.min(21,Math.round(10*a)/10));break;case"scrollback":if((a=Math.min(a,4294967295))<0)throw new Error(`${y} cannot be less than 0, value: ${a}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(a<=0)throw new Error(`${y} cannot be less than or equal to 0, value: ${a}`);break;case"rows":case"cols":if(!a&&a!==0)throw new Error(`${y} must be numeric, value: ${a}`);break;case"windowsPty":a=a??{}}return a}}n.OptionsService=x},2660:function(v,n,i){var l=this&&this.__decorate||function(x,w,y,a){var h,u=arguments.length,f=u<3?w:a===null?a=Object.getOwnPropertyDescriptor(w,y):a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")f=Reflect.decorate(x,w,y,a);else for(var b=x.length-1;b>=0;b--)(h=x[b])&&(f=(u<3?h(f):u>3?h(w,y,f):h(w,y))||f);return u>3&&f&&Object.defineProperty(w,y,f),f},d=this&&this.__param||function(x,w){return function(y,a){w(y,a,x)}};Object.defineProperty(n,"__esModule",{value:!0}),n.OscLinkService=void 0;const c=i(2585);let m=n.OscLinkService=class{constructor(x){this._bufferService=x,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(x){const w=this._bufferService.buffer;if(x.id===void 0){const b=w.addMarker(w.ybase+w.y),C={data:x,id:this._nextId++,lines:[b]};return b.onDispose((()=>this._removeMarkerFromLink(C,b))),this._dataByLinkId.set(C.id,C),C.id}const y=x,a=this._getEntryIdKey(y),h=this._entriesWithId.get(a);if(h)return this.addLineToLink(h.id,w.ybase+w.y),h.id;const u=w.addMarker(w.ybase+w.y),f={id:this._nextId++,key:this._getEntryIdKey(y),data:y,lines:[u]};return u.onDispose((()=>this._removeMarkerFromLink(f,u))),this._entriesWithId.set(f.key,f),this._dataByLinkId.set(f.id,f),f.id}addLineToLink(x,w){const y=this._dataByLinkId.get(x);if(y&&y.lines.every((a=>a.line!==w))){const a=this._bufferService.buffer.addMarker(w);y.lines.push(a),a.onDispose((()=>this._removeMarkerFromLink(y,a)))}}getLinkData(x){var w;return(w=this._dataByLinkId.get(x))===null||w===void 0?void 0:w.data}_getEntryIdKey(x){return`${x.id};;${x.uri}`}_removeMarkerFromLink(x,w){const y=x.lines.indexOf(w);y!==-1&&(x.lines.splice(y,1),x.lines.length===0&&(x.data.id!==void 0&&this._entriesWithId.delete(x.key),this._dataByLinkId.delete(x.id)))}};n.OscLinkService=m=l([d(0,c.IBufferService)],m)},8343:(v,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.createDecorator=n.getServiceDependencies=n.serviceRegistry=void 0;const i="di$target",l="di$dependencies";n.serviceRegistry=new Map,n.getServiceDependencies=function(d){return d[l]||[]},n.createDecorator=function(d){if(n.serviceRegistry.has(d))return n.serviceRegistry.get(d);const c=function(m,x,w){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(y,a,h){a[i]===a?a[l].push({id:y,index:h}):(a[l]=[{id:y,index:h}],a[i]=a)})(c,m,w)};return c.toString=()=>d,n.serviceRegistry.set(d,c),c}},2585:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.IDecorationService=n.IUnicodeService=n.IOscLinkService=n.IOptionsService=n.ILogService=n.LogLevelEnum=n.IInstantiationService=n.ICharsetService=n.ICoreService=n.ICoreMouseService=n.IBufferService=void 0;const l=i(8343);var d;n.IBufferService=(0,l.createDecorator)("BufferService"),n.ICoreMouseService=(0,l.createDecorator)("CoreMouseService"),n.ICoreService=(0,l.createDecorator)("CoreService"),n.ICharsetService=(0,l.createDecorator)("CharsetService"),n.IInstantiationService=(0,l.createDecorator)("InstantiationService"),(function(c){c[c.TRACE=0]="TRACE",c[c.DEBUG=1]="DEBUG",c[c.INFO=2]="INFO",c[c.WARN=3]="WARN",c[c.ERROR=4]="ERROR",c[c.OFF=5]="OFF"})(d||(n.LogLevelEnum=d={})),n.ILogService=(0,l.createDecorator)("LogService"),n.IOptionsService=(0,l.createDecorator)("OptionsService"),n.IOscLinkService=(0,l.createDecorator)("OscLinkService"),n.IUnicodeService=(0,l.createDecorator)("UnicodeService"),n.IDecorationService=(0,l.createDecorator)("DecorationService")},1480:(v,n,i)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.UnicodeService=void 0;const l=i(8460),d=i(225);n.UnicodeService=class{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new l.EventEmitter,this.onChange=this._onChange.event;const c=new d.UnicodeV6;this.register(c),this._active=c.version,this._activeProvider=c}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(c){if(!this._providers[c])throw new Error(`unknown Unicode version "${c}"`);this._active=c,this._activeProvider=this._providers[c],this._onChange.fire(c)}register(c){this._providers[c.version]=c}wcwidth(c){return this._activeProvider.wcwidth(c)}getStringCellWidth(c){let m=0;const x=c.length;for(let w=0;w<x;++w){let y=c.charCodeAt(w);if(55296<=y&&y<=56319){if(++w>=x)return m+this.wcwidth(y);const a=c.charCodeAt(w);56320<=a&&a<=57343?y=1024*(y-55296)+a-56320+65536:m+=this.wcwidth(a)}m+=this.wcwidth(y)}return m}}}},o={};function g(v){var n=o[v];if(n!==void 0)return n.exports;var i=o[v]={exports:{}};return r[v].call(i.exports,i,i.exports,g),i.exports}var p={};return(()=>{var v=p;Object.defineProperty(v,"__esModule",{value:!0}),v.Terminal=void 0;const n=g(9042),i=g(3236),l=g(844),d=g(5741),c=g(8285),m=g(7975),x=g(7090),w=["cols","rows"];class y extends l.Disposable{constructor(h){super(),this._core=this.register(new i.Terminal(h)),this._addonManager=this.register(new d.AddonManager),this._publicOptions=Object.assign({},this._core.options);const u=b=>this._core.options[b],f=(b,C)=>{this._checkReadonlyOptions(b),this._core.options[b]=C};for(const b in this._core.options){const C={get:u.bind(this,b),set:f.bind(this,b)};Object.defineProperty(this._publicOptions,b,C)}}_checkReadonlyOptions(h){if(w.includes(h))throw new Error(`Option "${h}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new m.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new x.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this.register(new c.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const h=this._core.coreService.decPrivateModes;let u="none";switch(this._core.coreMouseService.activeProtocol){case"X10":u="x10";break;case"VT200":u="vt200";break;case"DRAG":u="drag";break;case"ANY":u="any"}return{applicationCursorKeysMode:h.applicationCursorKeys,applicationKeypadMode:h.applicationKeypad,bracketedPasteMode:h.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:u,originMode:h.origin,reverseWraparoundMode:h.reverseWraparound,sendFocusMode:h.sendFocus,wraparoundMode:h.wraparound}}get options(){return this._publicOptions}set options(h){for(const u in h)this._publicOptions[u]=h[u]}blur(){this._core.blur()}focus(){this._core.focus()}resize(h,u){this._verifyIntegers(h,u),this._core.resize(h,u)}open(h){this._core.open(h)}attachCustomKeyEventHandler(h){this._core.attachCustomKeyEventHandler(h)}registerLinkProvider(h){return this._core.registerLinkProvider(h)}registerCharacterJoiner(h){return this._checkProposedApi(),this._core.registerCharacterJoiner(h)}deregisterCharacterJoiner(h){this._checkProposedApi(),this._core.deregisterCharacterJoiner(h)}registerMarker(h=0){return this._verifyIntegers(h),this._core.registerMarker(h)}registerDecoration(h){var u,f,b;return this._checkProposedApi(),this._verifyPositiveIntegers((u=h.x)!==null&&u!==void 0?u:0,(f=h.width)!==null&&f!==void 0?f:0,(b=h.height)!==null&&b!==void 0?b:0),this._core.registerDecoration(h)}hasSelection(){return this._core.hasSelection()}select(h,u,f){this._verifyIntegers(h,u,f),this._core.select(h,u,f)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(h,u){this._verifyIntegers(h,u),this._core.selectLines(h,u)}dispose(){super.dispose()}scrollLines(h){this._verifyIntegers(h),this._core.scrollLines(h)}scrollPages(h){this._verifyIntegers(h),this._core.scrollPages(h)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(h){this._verifyIntegers(h),this._core.scrollToLine(h)}clear(){this._core.clear()}write(h,u){this._core.write(h,u)}writeln(h,u){this._core.write(h),this._core.write(`\r
27
- `,u)}paste(h){this._core.paste(h)}refresh(h,u){this._verifyIntegers(h,u),this._core.refresh(h,u)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(h){this._addonManager.loadAddon(this,h)}static get strings(){return n}_verifyIntegers(...h){for(const u of h)if(u===1/0||isNaN(u)||u%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...h){for(const u of h)if(u&&(u===1/0||isNaN(u)||u%1!=0||u<0))throw new Error("This API only accepts positive integers")}}v.Terminal=y})(),p})()))})(Ai)),Ai.exports}var Cm=wm();var km=2,Em=1,jm=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let s=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(s._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let s=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,r=window.getComputedStyle(this._terminal.element.parentElement),o=parseInt(r.getPropertyValue("height")),g=Math.max(0,parseInt(r.getPropertyValue("width"))),p=window.getComputedStyle(this._terminal.element),v={top:parseInt(p.getPropertyValue("padding-top")),bottom:parseInt(p.getPropertyValue("padding-bottom")),right:parseInt(p.getPropertyValue("padding-right")),left:parseInt(p.getPropertyValue("padding-left"))},n=v.top+v.bottom,i=v.right+v.left,l=o-n,d=g-i-s;return{cols:Math.max(km,Math.floor(d/e.css.cell.width)),rows:Math.max(Em,Math.floor(l/e.css.cell.height))}}};function Nm(e={}){const{cwd:s,cols:r,rows:o,onOutput:g,onExit:p}=e,[v,n]=S.useState(null),[i,l]=S.useState(()=>Jt.isConnected()),[d,c]=S.useState(!1),[m,x]=S.useState(!1),[w,y]=S.useState(!1),a=S.useRef({onOutput:g,onExit:p});a.current={onOutput:g,onExit:p};const h=S.useRef(null);h.current=v,S.useEffect(()=>{if(!v)return;const k=Jt.getSocket(),E=()=>{l(!0),c(!1),n(null),y(!0)},_=()=>{l(!1),c(!1)},j=D=>{D.terminalId===v&&a.current.onOutput?.(D.data)},A=D=>{D.terminalId===v&&(c(!1),a.current.onExit?.(D.exitCode),n(null))},P=D=>{D.terminalId===v&&c(!0)},T=D=>{D.terminalId===v&&c(!1)};return k.on("connect",E),k.on("disconnect",_),k.on(ct.TERMINAL_STDOUT,j),k.on(ct.TERMINAL_EXIT,A),k.on(ct.TERMINAL_SUBSCRIBED,P),k.on(ct.TERMINAL_UNSUBSCRIBED,T),l(k.connected),k.connected&&k.emit(Ns.SUBSCRIBE,{topic:"terminal",id:v},D=>{D.success&&c(!0)}),()=>{k.off("connect",E),k.off("disconnect",_),k.off(ct.TERMINAL_STDOUT,j),k.off(ct.TERMINAL_EXIT,A),k.off(ct.TERMINAL_SUBSCRIBED,P),k.off(ct.TERMINAL_UNSUBSCRIBED,T),k.emit(Ns.UNSUBSCRIBE,{topic:"terminal",id:v})}},[v]);const u=S.useCallback(async()=>{const k=Jt.getSocket();if(!k.connected)return null;x(!0);try{const E=await Ce.post("/terminals",{socketId:k.id,cwd:s,cols:r,rows:o});return n(E.terminalId),y(!1),E.terminalId}catch(E){return console.error("[useStandaloneTerminal] Failed to create terminal:",E),null}finally{x(!1)}},[s,r,o]),f=S.useCallback(async()=>{const k=h.current;if(k){try{await Ce.delete(`/terminals/${k}`)}catch(E){console.error("[useStandaloneTerminal] Failed to destroy terminal:",E)}n(null),c(!1)}},[]),b=S.useCallback(k=>{const E=h.current;if(!E)return;Jt.getSocket().emit(Ns.TERMINAL_INPUT,{terminalId:E,data:k})},[]),C=S.useCallback((k,E)=>{const _=h.current;if(!_)return;Jt.getSocket().emit(Ns.TERMINAL_RESIZE,{terminalId:_,cols:k,rows:E})},[]);return S.useEffect(()=>()=>{const k=h.current;k&&Ce.delete(`/terminals/${k}`).catch(()=>{})},[]),{terminalId:v,isConnected:i,isAttached:d,isCreating:m,needsRecreate:w,create:u,destroy:f,sendInput:b,resize:C}}function Rm({terminalRef:e,xtermRef:s,fitAddonRef:r,isVisible:o=!0,onResize:g}){const p=S.useRef(null),v=S.useRef(null),n=S.useRef(0),i=S.useCallback(()=>{p.current!=null&&(window.clearTimeout(p.current),p.current=null),v.current!=null&&(window.cancelAnimationFrame(v.current),v.current=null)},[]),l=S.useCallback(()=>{const m=r.current,x=s.current,w=e.current;if(!m||!x||!w||w.clientWidth<=0||w.clientHeight<=0)return!1;try{return m.fit(),x.cols>0&&x.rows>0&&g(x.cols,x.rows),!0}catch{return!1}},[r,g,e,s]),d=S.useCallback((m=6)=>{i();const x=n.current+1;n.current=x;let w=0;const y=()=>{n.current===x&&(v.current=window.requestAnimationFrame(()=>{if(v.current=null,n.current!==x)return;const a=l(),h=w<2;w<m&&(!a||h)&&(w+=1,p.current=window.setTimeout(y,50))}))};y()},[i,l]),c=S.useCallback(()=>{n.current+=1,i()},[i]);return S.useEffect(()=>c,[c]),S.useEffect(()=>{o&&d(8)},[o,d]),S.useEffect(()=>{const m=e.current;if(!m)return;if(typeof ResizeObserver>"u"){d(8);return}const x=new ResizeObserver(()=>{d(4)});return x.observe(m),m.parentElement&&x.observe(m.parentElement),d(8),()=>{x.disconnect()}},[d,e]),{fitNow:l,scheduleFit:d}}const Am={background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#d4d4d4",selectionBackground:"#264f78",black:"#1e1e1e",red:"#f44747",green:"#6a9955",yellow:"#d7ba7d",blue:"#569cd6",magenta:"#c586c0",cyan:"#4ec9b0",white:"#d4d4d4",brightBlack:"#808080",brightRed:"#f44747",brightGreen:"#6a9955",brightYellow:"#d7ba7d",brightBlue:"#569cd6",brightMagenta:"#c586c0",brightCyan:"#4ec9b0",brightWhite:"#ffffff"},Tm=ae.memo(function({cwd:s,isVisible:r=!0,onExit:o,onReady:g}){const p=S.useRef(null),v=S.useRef(null),n=S.useRef(null),i=S.useRef(!1),{terminalId:l,isAttached:d,needsRecreate:c,create:m,sendInput:x,resize:w}=Nm({cwd:s,onOutput:S.useCallback(h=>{v.current?.write(h)},[]),onExit:S.useCallback(h=>{v.current?.writeln(`\r
28
- \x1B[90m[Process exited with code ${h}]\x1B[0m`),o?.(h)},[o])}),{scheduleFit:y}=Rm({terminalRef:p,xtermRef:v,fitAddonRef:n,isVisible:r,onResize:w}),a=S.useCallback(h=>{v.current?.paste(h)},[]);return S.useEffect(()=>{r||v.current?.blur()},[r]),S.useEffect(()=>{if(!c)return;const h=v.current;h&&h.writeln(`\r
29
- \x1B[33m[Terminal disconnected — reconnecting...]\x1B[0m`),m()},[c,m]),S.useLayoutEffect(()=>{if(!p.current)return;const h=new Cm.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, 'Courier New', monospace",lineHeight:1.4,theme:Am,scrollback:5e3,convertEol:!0}),u=new jm;return h.loadAddon(u),h.open(p.current),v.current=h,n.current=u,y(8),()=>{h.dispose(),v.current=null,n.current=null}},[y]),S.useEffect(()=>{i.current||(i.current=!0,m())},[m]),S.useEffect(()=>{const h=v.current;if(!h||!d)return;const u=h.onData(f=>{x(f)});return()=>u.dispose()},[x,d]),S.useEffect(()=>{d&&(y(4),g?.({sendInput:x,paste:a}))},[d,g,a,y,x]),t.jsxs("div",{className:"relative flex h-full w-full min-h-0 min-w-0 flex-col overflow-hidden bg-[#1e1e1e]",children:[!l&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-neutral-500 text-xs z-10 bg-[#1e1e1e]",children:"Starting terminal..."}),t.jsx("div",{ref:p,className:"terminal-xterm-host flex-1 min-h-0 min-w-0 w-full overflow-hidden"})]})}),Mm=ae.memo(function({commands:s,onSelect:r}){const{t:o}=ce(),[g,p]=S.useState(!1),v=S.useRef(null),n=S.useRef(null);return S.useEffect(()=>{if(!g)return;const i=l=>{v.current&&!v.current.contains(l.target)&&n.current&&!n.current.contains(l.target)&&p(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[g]),s.length===0?null:t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-px h-4 bg-[#444] mx-1 shrink-0"}),t.jsxs("div",{className:"relative",children:[t.jsxs("button",{ref:n,onClick:()=>p(!g),className:`flex items-center gap-1.5 px-2.5 py-1 mx-1 rounded text-[11px] font-medium transition-colors shrink-0 ${g?"bg-amber-500/20 text-amber-300":"bg-amber-500/10 text-amber-400/80 hover:bg-amber-500/20 hover:text-amber-300"}`,children:[t.jsx(_d,{size:12}),t.jsx("span",{children:o("快捷命令")}),t.jsx(wt,{size:10,className:`transition-transform ${g?"rotate-180":""}`})]}),g&&t.jsx("div",{ref:v,className:"absolute right-0 top-full mt-1 w-72 bg-[#2d2d2d] border border-[#444] rounded-lg shadow-xl z-[100] overflow-hidden",children:t.jsx("div",{className:"max-h-[240px] overflow-y-auto",children:s.map((i,l)=>t.jsxs("button",{onClick:()=>{r(i.command),p(!1)},className:"w-full flex items-start gap-2.5 px-3 py-2 hover:bg-[#383838] transition-colors text-left group",children:[t.jsx(Xt,{size:12,className:"text-green-500 mt-0.5 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-[12px] font-medium text-neutral-200",children:i.name}),t.jsx("div",{className:"text-[11px] font-mono text-neutral-500 truncate",children:i.command})]})]},l))})})]})]})});let Ti=0;function Do(){return Ti+=1,{id:`shell-${Ti}`,order:Ti}}const Dm=ae.memo(function({cwd:s,isVisible:r=!0,quickCommands:o=[]}){const{t:g}=ce(),[p,v]=S.useState(()=>[Do()]),[n,i]=S.useState(()=>p[0].id),[l,d]=S.useState(()=>new Set),[c,m]=S.useState(!1),[x,w]=S.useState(!1),[y,a]=S.useState(""),[h,u]=S.useState(null),f=S.useRef(new Map),b=S.useCallback(B=>{f.current.delete(B),d(F=>{if(!F.has(B))return F;const R=new Set(F);return R.delete(B),R})},[]),C=S.useCallback(()=>{const B=Do();v(F=>[...F,B]),i(B.id)},[]),k=S.useCallback((B,F)=>{F.stopPropagation(),b(B),v(R=>{const M=R.filter(L=>L.id!==B);return B===n&&M.length>0&&i(M[M.length-1].id),M})},[n,b]),E=S.useCallback(B=>{b(B),v(F=>{const R=F.filter(M=>M.id!==B);return B===n&&R.length>0&&i(R[R.length-1].id),R})},[n,b]),_=S.useCallback((B,F)=>{f.current.set(B,F),d(R=>{if(R.has(B))return R;const M=new Set(R);return M.add(B),M})},[]),j=S.useCallback(B=>{const F=f.current.get(n);F&&F.sendInput(B+"\r")},[n]),A=S.useCallback((B,F="")=>{u(B),a(F),w(!0)},[]),P=S.useCallback((B,F)=>{const R=f.current.get(B);return R?(R.paste(F),rt.success(g("Pasted into terminal")),!0):(rt.error(g("Terminal is not ready")),!1)},[g]),T=S.useCallback(async()=>{if(!f.current.has(n)){rt.error(g("Terminal is not ready"));return}const B=navigator.clipboard;if(!B?.readText){A(n);return}m(!0);try{const F=await B.readText();if(!F||F.includes(`
30
- `)||F.includes("\r")){A(n,F);return}P(n,F)}catch{A(n)}finally{m(!1)}},[n,A,P,g]),D=S.useCallback(()=>{!y||!h||!P(h,y)||(w(!1),a(""),u(null))},[y,P,h]),W=S.useCallback(()=>{w(!1),a(""),u(null)},[]),I=l.has(n);return t.jsxs("div",{className:"flex h-full w-full min-h-0 min-w-0 flex-col overflow-hidden bg-[#1e1e1e]",children:[t.jsxs("div",{className:"flex items-center bg-[#252526] border-b border-[#333] shrink-0 select-none",children:[t.jsx("div",{className:"flex items-center overflow-x-auto scrollbar-app-thin flex-1 min-w-0",children:p.map(B=>t.jsxs("button",{onClick:()=>i(B.id),className:se("flex items-center gap-1.5 px-3 py-1.5 text-[11px] border-r border-[#333] whitespace-nowrap group transition-colors",B.id===n?"bg-[#1e1e1e] text-neutral-200":"bg-[#2d2d2d] text-neutral-500 hover:text-neutral-300"),children:[t.jsx(Fr,{size:11,className:"shrink-0"}),t.jsx("span",{children:g("Shell {count}",{count:B.order})}),p.length>1&&t.jsx("span",{onClick:F=>k(B.id,F),className:"ml-1 p-0.5 rounded hover:bg-[#444] opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:t.jsx(Yt,{size:10})})]},B.id))}),p.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"mx-0.5 block h-5 w-px shrink-0 bg-[#3a3a3a] md:hidden","aria-hidden":"true"}),t.jsx("button",{type:"button",onClick:T,disabled:!I||c,className:"flex h-11 w-11 shrink-0 items-center justify-center text-neutral-400 transition-colors hover:bg-[#333] hover:text-neutral-100 active:bg-[#3a3a3a] disabled:cursor-not-allowed disabled:opacity-40 md:hidden",title:g("Paste into terminal"),"aria-label":g("Paste into terminal"),children:c?t.jsx(Ke,{size:18,className:"animate-spin"}):t.jsx(Od,{size:18})})]}),t.jsx("button",{type:"button",onClick:C,className:"flex h-11 w-11 shrink-0 items-center justify-center text-neutral-500 transition-colors hover:bg-[#333] hover:text-neutral-300 active:bg-[#3a3a3a] md:h-auto md:w-auto md:px-2 md:py-1.5",title:g("New Terminal"),"aria-label":g("New Terminal"),children:t.jsx(ts,{size:14})}),o.length>0&&t.jsx(Mm,{commands:o,onSelect:j})]}),t.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden relative",children:p.length===0?t.jsx("div",{className:"flex-1 flex items-center justify-center h-full text-neutral-500",children:t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(Fr,{size:28}),t.jsx("span",{className:"text-xs",children:g("No terminals open")}),t.jsx("button",{onClick:C,className:"mt-1 px-3 py-1 text-xs bg-[#333] hover:bg-[#444] rounded transition-colors text-neutral-300",children:g("New Terminal")})]})}):p.map(B=>t.jsx("div",{"aria-hidden":B.id!==n,className:se("absolute inset-0 h-full w-full min-h-0 min-w-0 overflow-hidden",B.id===n?"visible pointer-events-auto":"invisible pointer-events-none"),children:t.jsx(Tm,{cwd:s,isVisible:r&&B.id===n,onExit:()=>E(B.id),onReady:F=>_(B.id,F)})},B.id))}),t.jsx(ns,{isOpen:x,onClose:W,title:g("Paste into terminal"),className:"fixed inset-x-0 bottom-0 max-h-[70dvh] max-w-none rounded-b-none rounded-t-lg border-x-0 border-b-0 sm:relative sm:inset-auto sm:max-w-lg sm:rounded-lg sm:border",action:t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:W,className:"min-h-11 px-4 text-sm font-medium text-neutral-600 transition-colors hover:text-neutral-900",children:g("Cancel")}),t.jsx("button",{type:"button",onClick:D,disabled:!y,className:"min-h-11 rounded-md bg-neutral-900 px-4 text-sm font-medium text-white transition-colors hover:bg-black disabled:cursor-not-allowed disabled:opacity-40",children:g("Paste")})]}),children:t.jsx(Ed,{autoFocus:!0,value:y,onChange:B=>a(B.target.value),placeholder:g("Paste terminal input here"),"aria-label":g("Terminal paste content"),className:"min-h-32 resize-none bg-white font-mono"})})]})});function Po(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,o=Array(s);r<s;r++)o[r]=e[r];return o}function Pm(e){if(Array.isArray(e))return e}function Lm(e,s,r){return(s=Hm(s))in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function Im(e,s){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o,g,p,v,n=[],i=!0,l=!1;try{if(p=(r=r.call(e)).next,s!==0)for(;!(i=(o=p.call(r)).done)&&(n.push(o.value),n.length!==s);i=!0);}catch(d){l=!0,g=d}finally{try{if(!i&&r.return!=null&&(v=r.return(),Object(v)!==v))return}finally{if(l)throw g}}return n}}function Om(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
31
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Lo(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);s&&(o=o.filter(function(g){return Object.getOwnPropertyDescriptor(e,g).enumerable})),r.push.apply(r,o)}return r}function Io(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Lo(Object(r),!0).forEach(function(o){Lm(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Lo(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function Bm(e,s){if(e==null)return{};var r,o,g=Fm(e,s);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(e);for(o=0;o<p.length;o++)r=p[o],s.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(g[r]=e[r])}return g}function Fm(e,s){if(e==null)return{};var r={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(s.indexOf(o)!==-1)continue;r[o]=e[o]}return r}function zm(e,s){return Pm(e)||Im(e,s)||$m(e,s)||Om()}function Wm(e,s){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var o=r.call(e,s);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}function Hm(e){var s=Wm(e,"string");return typeof s=="symbol"?s:s+""}function $m(e,s){if(e){if(typeof e=="string")return Po(e,s);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Po(e,s):void 0}}function Um(e,s,r){return s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function Oo(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);s&&(o=o.filter(function(g){return Object.getOwnPropertyDescriptor(e,g).enumerable})),r.push.apply(r,o)}return r}function Bo(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Oo(Object(r),!0).forEach(function(o){Um(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Oo(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function qm(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return function(o){return s.reduceRight(function(g,p){return p(g)},o)}}function Js(e){return function s(){for(var r=this,o=arguments.length,g=new Array(o),p=0;p<o;p++)g[p]=arguments[p];return g.length>=e.length?e.apply(this,g):function(){for(var v=arguments.length,n=new Array(v),i=0;i<v;i++)n[i]=arguments[i];return s.apply(r,[].concat(g,n))}}}function Qr(e){return{}.toString.call(e).includes("Object")}function Km(e){return!Object.keys(e).length}function cr(e){return typeof e=="function"}function Xm(e,s){return Object.prototype.hasOwnProperty.call(e,s)}function Ym(e,s){return Qr(s)||rs("changeType"),Object.keys(s).some(function(r){return!Xm(e,r)})&&rs("changeField"),s}function Vm(e){cr(e)||rs("selectorType")}function Gm(e){cr(e)||Qr(e)||rs("handlerType"),Qr(e)&&Object.values(e).some(function(s){return!cr(s)})&&rs("handlersType")}function Qm(e){e||rs("initialIsRequired"),Qr(e)||rs("initialType"),Km(e)&&rs("initialContent")}function Zm(e,s){throw new Error(e[s]||e.default)}var Jm={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},rs=Js(Zm)(Jm),Dr={changes:Ym,selector:Vm,handler:Gm,initial:Qm};function ep(e){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Dr.initial(e),Dr.handler(s);var r={current:e},o=Js(rp)(r,s),g=Js(sp)(r),p=Js(Dr.changes)(e),v=Js(tp)(r);function n(){var l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(d){return d};return Dr.selector(l),l(r.current)}function i(l){qm(o,g,p,v)(l)}return[n,i]}function tp(e,s){return cr(s)?s(e.current):s}function sp(e,s){return e.current=Bo(Bo({},e.current),s),s}function rp(e,s,r){return cr(s)?s(e.current):Object.keys(r).forEach(function(o){var g;return(g=s[o])===null||g===void 0?void 0:g.call(s,e.current[o])}),r}var ip={create:ep},np={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function op(e){return function s(){for(var r=this,o=arguments.length,g=new Array(o),p=0;p<o;p++)g[p]=arguments[p];return g.length>=e.length?e.apply(this,g):function(){for(var v=arguments.length,n=new Array(v),i=0;i<v;i++)n[i]=arguments[i];return s.apply(r,[].concat(g,n))}}}function ap(e){return{}.toString.call(e).includes("Object")}function lp(e){return e||Fo("configIsRequired"),ap(e)||Fo("configType"),e.urls?(cp(),{paths:{vs:e.urls.monacoBase}}):e}function cp(){console.warn(Tl.deprecation)}function dp(e,s){throw new Error(e[s]||e.default)}var Tl={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
32
- You are using deprecated way of configuration.
33
-
34
- Instead of using
35
- monaco.config({ urls: { monacoBase: '...' } })
36
- use
37
- monaco.config({ paths: { vs: '...' } })
38
-
39
- For more please check the link https://github.com/suren-atoyan/monaco-loader#config
40
- `},Fo=op(dp)(Tl),up={config:lp},hp=function(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return function(g){return r.reduceRight(function(p,v){return v(p)},g)}};function Ml(e,s){return Object.keys(s).forEach(function(r){s[r]instanceof Object&&e[r]&&Object.assign(s[r],Ml(e[r],s[r]))}),Io(Io({},e),s)}var fp={type:"cancelation",msg:"operation is manually canceled"};function Mi(e){var s=!1,r=new Promise(function(o,g){e.then(function(p){return s?g(fp):o(p)}),e.catch(g)});return r.cancel=function(){return s=!0},r}var mp=["monaco"],pp=ip.create({config:np,isInitialized:!1,resolve:null,reject:null,monaco:null}),Dl=zm(pp,2),vr=Dl[0],ui=Dl[1];function gp(e){var s=up.config(e),r=s.monaco,o=Bm(s,mp);ui(function(g){return{config:Ml(g.config,o),monaco:r}})}function vp(){var e=vr(function(s){var r=s.monaco,o=s.isInitialized,g=s.resolve;return{monaco:r,isInitialized:o,resolve:g}});if(!e.isInitialized){if(ui({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),Mi(Di);if(window.monaco&&window.monaco.editor)return Pl(window.monaco),e.resolve(window.monaco),Mi(Di);hp(xp,bp)(yp)}return Mi(Di)}function xp(e){return document.body.appendChild(e)}function _p(e){var s=document.createElement("script");return e&&(s.src=e),s}function bp(e){var s=vr(function(o){var g=o.config,p=o.reject;return{config:g,reject:p}}),r=_p("".concat(s.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=s.reject,r}function yp(){var e=vr(function(r){var o=r.config,g=r.resolve,p=r.reject;return{config:o,resolve:g,reject:p}}),s=window.require;s.config(e.config),s(["vs/editor/editor.main"],function(r){var o=r.m||r;Pl(o),e.resolve(o)},function(r){e.reject(r)})}function Pl(e){vr().monaco||ui({monaco:e})}function Sp(){return vr(function(e){var s=e.monaco;return s})}var Di=new Promise(function(e,s){return ui({resolve:e,reject:s})}),Ll={config:gp,init:vp,__getMonacoInstance:Sp},wp={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},Pi=wp,Cp={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},kp=Cp;function Ep({children:e}){return ae.createElement("div",{style:kp.container},e)}var jp=Ep,Np=jp;function Rp({width:e,height:s,isEditorReady:r,loading:o,_ref:g,className:p,wrapperProps:v}){return ae.createElement("section",{style:{...Pi.wrapper,width:e,height:s},...v},!r&&ae.createElement(Np,null,o),ae.createElement("div",{ref:g,style:{...Pi.fullWidth,...!r&&Pi.hide},className:p}))}var Ap=Rp,Il=S.memo(Ap);function Tp(e){S.useEffect(e,[])}var Ol=Tp;function Mp(e,s,r=!0){let o=S.useRef(!0);S.useEffect(o.current||!r?()=>{o.current=!1}:e,s)}var kt=Mp;function rr(){}function As(e,s,r,o){return Dp(e,o)||Pp(e,s,r,o)}function Dp(e,s){return e.editor.getModel(Bl(e,s))}function Pp(e,s,r,o){return e.editor.createModel(s,r,o?Bl(e,o):void 0)}function Bl(e,s){return e.Uri.parse(s)}function Lp({original:e,modified:s,language:r,originalLanguage:o,modifiedLanguage:g,originalModelPath:p,modifiedModelPath:v,keepCurrentOriginalModel:n=!1,keepCurrentModifiedModel:i=!1,theme:l="light",loading:d="Loading...",options:c={},height:m="100%",width:x="100%",className:w,wrapperProps:y={},beforeMount:a=rr,onMount:h=rr}){let[u,f]=S.useState(!1),[b,C]=S.useState(!0),k=S.useRef(null),E=S.useRef(null),_=S.useRef(null),j=S.useRef(h),A=S.useRef(a),P=S.useRef(!1);Ol(()=>{let I=Ll.init();return I.then(B=>(E.current=B)&&C(!1)).catch(B=>B?.type!=="cancelation"&&console.error("Monaco initialization: error:",B)),()=>k.current?W():I.cancel()}),kt(()=>{if(k.current&&E.current){let I=k.current.getOriginalEditor(),B=As(E.current,e||"",o||r||"text",p||"");B!==I.getModel()&&I.setModel(B)}},[p],u),kt(()=>{if(k.current&&E.current){let I=k.current.getModifiedEditor(),B=As(E.current,s||"",g||r||"text",v||"");B!==I.getModel()&&I.setModel(B)}},[v],u),kt(()=>{let I=k.current.getModifiedEditor();I.getOption(E.current.editor.EditorOption.readOnly)?I.setValue(s||""):s!==I.getValue()&&(I.executeEdits("",[{range:I.getModel().getFullModelRange(),text:s||"",forceMoveMarkers:!0}]),I.pushUndoStop())},[s],u),kt(()=>{k.current?.getModel()?.original.setValue(e||"")},[e],u),kt(()=>{let{original:I,modified:B}=k.current.getModel();E.current.editor.setModelLanguage(I,o||r||"text"),E.current.editor.setModelLanguage(B,g||r||"text")},[r,o,g],u),kt(()=>{E.current?.editor.setTheme(l)},[l],u),kt(()=>{k.current?.updateOptions(c)},[c],u);let T=S.useCallback(()=>{if(!E.current)return;A.current(E.current);let I=As(E.current,e||"",o||r||"text",p||""),B=As(E.current,s||"",g||r||"text",v||"");k.current?.setModel({original:I,modified:B})},[r,s,g,e,o,p,v]),D=S.useCallback(()=>{!P.current&&_.current&&(k.current=E.current.editor.createDiffEditor(_.current,{automaticLayout:!0,...c}),T(),E.current?.editor.setTheme(l),f(!0),P.current=!0)},[c,l,T]);S.useEffect(()=>{u&&j.current(k.current,E.current)},[u]),S.useEffect(()=>{!b&&!u&&D()},[b,u,D]);function W(){let I=k.current?.getModel();n||I?.original?.dispose(),i||I?.modified?.dispose(),k.current?.dispose()}return ae.createElement(Il,{width:x,height:m,isEditorReady:u,loading:d,_ref:_,className:w,wrapperProps:y})}var Ip=Lp;S.memo(Ip);function Op(e){let s=S.useRef();return S.useEffect(()=>{s.current=e},[e]),s.current}var Bp=Op,Pr=new Map;function Fp({defaultValue:e,defaultLanguage:s,defaultPath:r,value:o,language:g,path:p,theme:v="light",line:n,loading:i="Loading...",options:l={},overrideServices:d={},saveViewState:c=!0,keepCurrentModel:m=!1,width:x="100%",height:w="100%",className:y,wrapperProps:a={},beforeMount:h=rr,onMount:u=rr,onChange:f,onValidate:b=rr}){let[C,k]=S.useState(!1),[E,_]=S.useState(!0),j=S.useRef(null),A=S.useRef(null),P=S.useRef(null),T=S.useRef(u),D=S.useRef(h),W=S.useRef(),I=S.useRef(o),B=Bp(p),F=S.useRef(!1),R=S.useRef(!1);Ol(()=>{let O=Ll.init();return O.then(U=>(j.current=U)&&_(!1)).catch(U=>U?.type!=="cancelation"&&console.error("Monaco initialization: error:",U)),()=>A.current?L():O.cancel()}),kt(()=>{let O=As(j.current,e||o||"",s||g||"",p||r||"");O!==A.current?.getModel()&&(c&&Pr.set(B,A.current?.saveViewState()),A.current?.setModel(O),c&&A.current?.restoreViewState(Pr.get(p)))},[p],C),kt(()=>{A.current?.updateOptions(l)},[l],C),kt(()=>{!A.current||o===void 0||(A.current.getOption(j.current.editor.EditorOption.readOnly)?A.current.setValue(o):o!==A.current.getValue()&&(R.current=!0,A.current.executeEdits("",[{range:A.current.getModel().getFullModelRange(),text:o,forceMoveMarkers:!0}]),A.current.pushUndoStop(),R.current=!1))},[o],C),kt(()=>{let O=A.current?.getModel();O&&g&&j.current?.editor.setModelLanguage(O,g)},[g],C),kt(()=>{n!==void 0&&A.current?.revealLine(n)},[n],C),kt(()=>{j.current?.editor.setTheme(v)},[v],C);let M=S.useCallback(()=>{if(!(!P.current||!j.current)&&!F.current){D.current(j.current);let O=p||r,U=As(j.current,o||e||"",s||g||"",O||"");A.current=j.current?.editor.create(P.current,{model:U,automaticLayout:!0,...l},d),c&&A.current.restoreViewState(Pr.get(O)),j.current.editor.setTheme(v),n!==void 0&&A.current.revealLine(n),k(!0),F.current=!0}},[e,s,r,o,g,p,l,d,c,v,n]);S.useEffect(()=>{C&&T.current(A.current,j.current)},[C]),S.useEffect(()=>{!E&&!C&&M()},[E,C,M]),I.current=o,S.useEffect(()=>{C&&f&&(W.current?.dispose(),W.current=A.current?.onDidChangeModelContent(O=>{R.current||f(A.current.getValue(),O)}))},[C,f]),S.useEffect(()=>{if(C){let O=j.current.editor.onDidChangeMarkers(U=>{let Y=A.current.getModel()?.uri;if(Y&&U.find(z=>z.path===Y.path)){let z=j.current.editor.getModelMarkers({resource:Y});b?.(z)}});return()=>{O?.dispose()}}return()=>{}},[C,b]);function L(){W.current?.dispose(),m?c&&Pr.set(p,A.current.saveViewState()):A.current.getModel()?.dispose(),A.current.dispose()}return ae.createElement(Il,{width:x,height:w,isEditorReady:C,loading:i,_ref:P,className:y,wrapperProps:a})}var zp=Fp,Wp=S.memo(zp),Hp=Wp,Tt=function(e,s){return Number(e.toFixed(s))},$p=function(e,s){return typeof e=="number"?e:s},Qe=function(e,s,r){r&&typeof r=="function"&&r(e,s)},Up=function(e){return-Math.cos(e*Math.PI)/2+.5},qp=function(e){return e},Kp=function(e){return e*e},Xp=function(e){return e*(2-e)},Yp=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},Vp=function(e){return e*e*e},Gp=function(e){return--e*e*e+1},Qp=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},Zp=function(e){return e*e*e*e},Jp=function(e){return 1- --e*e*e*e},eg=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},tg=function(e){return e*e*e*e*e},sg=function(e){return 1+--e*e*e*e*e},rg=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},Fl={easeOut:Up,linear:qp,easeInQuad:Kp,easeOutQuad:Xp,easeInOutQuad:Yp,easeInCubic:Vp,easeOutCubic:Gp,easeInOutCubic:Qp,easeInQuart:Zp,easeOutQuart:Jp,easeInOutQuart:eg,easeInQuint:tg,easeOutQuint:sg,easeInOutQuint:rg},zl=function(e){typeof e=="number"&&cancelAnimationFrame(e)},It=function(e){e.mounted&&(zl(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function Wl(e,s,r,o){if(e.mounted){var g=new Date().getTime(),p=1;It(e),e.animation=function(){if(!e.mounted)return zl(e.animation);var v=new Date().getTime()-g,n=v/r,i=Fl[s],l=i(n);v>=r?(o(p),e.animation=null):e.animation&&(o(l),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function ig(e){var s=e.scale,r=e.positionX,o=e.positionY;return!(Number.isNaN(s)||Number.isNaN(r)||Number.isNaN(o))}function as(e,s,r,o){var g=ig(s);if(!(!e.mounted||!g)){var p=e.setTransformState,v=e.transformState,n=v.scale,i=v.positionX,l=v.positionY,d=s.scale-n,c=s.positionX-i,m=s.positionY-l;r===0?p(s.scale,s.positionX,s.positionY):Wl(e,o,r,function(x){var w=n+d*x,y=i+c*x,a=l+m*x;p(w,y,a)})}}function ng(e,s,r){var o=e.offsetWidth,g=e.offsetHeight,p=s.offsetWidth,v=s.offsetHeight,n=p*r,i=v*r,l=o-n,d=g-i;return{wrapperWidth:o,wrapperHeight:g,newContentWidth:n,newDiffWidth:l,newContentHeight:i,newDiffHeight:d}}var og=function(e,s,r,o,g,p,v){var n=e>s?r*(v?1:.5):0,i=o>g?p*(v?1:.5):0,l=e-s-n,d=n,c=o-g-i,m=i;return{minPositionX:l,maxPositionX:d,minPositionY:c,maxPositionY:m}},zn=function(e,s){var r=e.wrapperComponent,o=e.contentComponent,g=e.setup.centerZoomedOut;if(!r||!o)throw new Error("Components are not mounted");var p=ng(r,o,s),v=p.wrapperWidth,n=p.wrapperHeight,i=p.newContentWidth,l=p.newDiffWidth,d=p.newContentHeight,c=p.newDiffHeight,m=og(v,i,l,n,d,c,!!g);return m},en=function(e,s,r,o){return o?e<s?Tt(s,2):e>r?Tt(r,2):Tt(e,2):Tt(e,2)},gs=function(e,s){var r=zn(e,s);return e.bounds=r,r};function xr(e,s,r,o,g,p,v){var n=r.minPositionX,i=r.minPositionY,l=r.maxPositionX,d=r.maxPositionY,c=0,m=0;v&&(c=g,m=p);var x=en(e,n-c,l+c,o),w=en(s,i-m,d+m,o);return{x,y:w}}function hi(e,s,r,o,g,p){var v=e.transformState,n=v.scale,i=v.positionX,l=v.positionY,d=o-n;if(typeof s!="number"||typeof r!="number")return console.error("Mouse X and Y position were not provided!"),{x:i,y:l};var c=i-s*d,m=l-r*d,x=xr(c,m,g,p,0,0,null);return x}function _r(e,s,r,o,g){var p=g?o:0,v=s-p;return!Number.isNaN(r)&&e>=r?r:!Number.isNaN(s)&&e<=v?v:e}var zo=function(e,s){var r=e.setup.panning.excluded,o=e.isInitialized,g=e.wrapperComponent,p=s.target,v="shadowRoot"in p&&"composedPath"in s,n=v?s.composedPath().some(function(d){return d instanceof Element?g?.contains(d):!1}):g?.contains(p),i=o&&p&&n;if(!i)return!1;var l=fi(p,r);return!l},Wo=function(e){var s=e.isInitialized,r=e.isPanning,o=e.setup,g=o.panning.disabled,p=s&&r&&!g;return!!p},ag=function(e,s){var r=e.transformState,o=r.positionX,g=r.positionY;e.isPanning=!0;var p=s.clientX,v=s.clientY;e.startCoords={x:p-o,y:v-g}},lg=function(e,s){var r=s.touches,o=e.transformState,g=o.positionX,p=o.positionY;e.isPanning=!0;var v=r.length===1;if(v){var n=r[0].clientX,i=r[0].clientY;e.startCoords={x:n-g,y:i-p}}};function cg(e){var s=e.transformState,r=s.positionX,o=s.positionY,g=s.scale,p=e.setup,v=p.disabled,n=p.limitToBounds,i=p.centerZoomedOut,l=e.wrapperComponent;if(!(v||!l||!e.bounds)){var d=e.bounds,c=d.maxPositionX,m=d.minPositionX,x=d.maxPositionY,w=d.minPositionY,y=r>c||r<m,a=o>x||o<w,h=r>c?l.offsetWidth:e.setup.minPositionX||0,u=o>x?l.offsetHeight:e.setup.minPositionY||0,f=hi(e,h,u,g,e.bounds,n||i),b=f.x,C=f.y;return{scale:g,positionX:y?b:r,positionY:a?C:o}}}function Hl(e,s,r,o,g){var p=e.setup.limitToBounds,v=e.wrapperComponent,n=e.bounds,i=e.transformState,l=i.scale,d=i.positionX,c=i.positionY;if(!(v===null||n===null||s===d&&r===c)){var m=xr(s,r,n,p,o,g,v),x=m.x,w=m.y;e.setTransformState(l,x,w)}}var dg=function(e,s,r){var o=e.startCoords,g=e.transformState,p=e.setup.panning,v=p.lockAxisX,n=p.lockAxisY,i=g.positionX,l=g.positionY;if(!o)return{x:i,y:l};var d=s-o.x,c=r-o.y,m=v?i:d,x=n?l:c;return{x:m,y:x}},os=function(e,s){var r=e.setup,o=e.transformState,g=o.scale,p=r.minScale,v=r.disablePadding;return s>0&&g>=p&&!v?s:0},ug=function(e){var s=e.mounted,r=e.setup,o=r.disabled,g=r.velocityAnimation,p=e.transformState.scale,v=g.disabled,n=!v||p>1||!o||s;return!!n},hg=function(e){var s=e.mounted,r=e.velocity,o=e.bounds,g=e.setup,p=g.disabled,v=g.velocityAnimation,n=e.transformState.scale,i=v.disabled,l=!i||n>1||!p||s;return!(!l||!r||!o)};function fg(e,s){var r=e.setup.velocityAnimation,o=r.equalToMove,g=r.animationTime,p=r.sensitivity;return o?g*s*p:g}function Ho(e,s,r,o,g,p,v,n,i,l){if(g){if(s>v&&r>v){var d=v+(e-v)*l;return d>i?i:d<v?v:d}if(s<p&&r<p){var d=p+(e-p)*l;return d<n?n:d>p?p:d}}return o?s:en(e,p,v,g)}function mg(e,s){var r=1;return s?Math.min(r,e.offsetWidth/window.innerWidth):r}function pg(e,s){var r=ug(e);if(r){var o=e.lastMousePosition,g=e.velocityTime,p=e.setup,v=e.wrapperComponent,n=p.velocityAnimation.equalToMove,i=Date.now();if(o&&g&&v){var l=mg(v,n),d=s.x-o.x,c=s.y-o.y,m=d/l,x=c/l,w=i-g,y=d*d+c*c,a=Math.sqrt(y)/w;e.velocity={velocityX:m,velocityY:x,total:a}}e.lastMousePosition=s,e.velocityTime=i}}function gg(e){var s=e.velocity,r=e.bounds,o=e.setup,g=e.wrapperComponent,p=hg(e);if(!(!p||!s||!r||!g)){var v=s.velocityX,n=s.velocityY,i=s.total,l=r.maxPositionX,d=r.minPositionX,c=r.maxPositionY,m=r.minPositionY,x=o.limitToBounds,w=o.alignmentAnimation,y=o.zoomAnimation,a=o.panning,h=a.lockAxisY,u=a.lockAxisX,f=y.animationType,b=w.sizeX,C=w.sizeY,k=w.velocityAlignmentTime,E=k,_=fg(e,i),j=Math.max(_,E),A=os(e,b),P=os(e,C),T=A*g.offsetWidth/100,D=P*g.offsetHeight/100,W=l+T,I=d-T,B=c+D,F=m-D,R=e.transformState,M=new Date().getTime();Wl(e,f,j,function(L){var O=e.transformState,U=O.scale,Y=O.positionX,z=O.positionY,$=new Date().getTime()-M,q=$/E,N=Fl[w.animationType],H=1-N(Math.min(1,q)),X=1-L,K=Y+v*X,ne=z+n*X,te=Ho(K,R.positionX,Y,u,x,d,l,I,W,H),he=Ho(ne,R.positionY,z,h,x,m,c,F,B,H);(Y!==K||z!==ne)&&e.setTransformState(U,te,he)})}}function $o(e,s){var r=e.transformState.scale;It(e),gs(e,r),window.TouchEvent!==void 0&&s instanceof TouchEvent?lg(e,s):ag(e,s)}function Wn(e,s){var r=e.transformState.scale,o=e.setup,g=o.minScale,p=o.alignmentAnimation,v=p.disabled,n=p.sizeX,i=p.sizeY,l=p.animationTime,d=p.animationType,c=v||r<g||!n&&!i;if(!c){var m=cg(e);m&&as(e,m,s??l,d)}}function Uo(e,s,r){var o=e.startCoords,g=e.setup,p=g.alignmentAnimation,v=p.sizeX,n=p.sizeY;if(o){var i=dg(e,s,r),l=i.x,d=i.y,c=os(e,v),m=os(e,n);pg(e,{x:l,y:d}),Hl(e,l,d,c,m)}}function vg(e){if(e.isPanning){var s=e.setup.panning.velocityDisabled,r=e.velocity,o=e.wrapperComponent,g=e.contentComponent;e.isPanning=!1,e.animate=!1,e.animation=null;var p=o?.getBoundingClientRect(),v=g?.getBoundingClientRect(),n=p?.width||0,i=p?.height||0,l=v?.width||0,d=v?.height||0,c=n<l||i<d,m=!s&&r&&r?.total>.1&&c;m?gg(e):Wn(e)}}function Hn(e,s,r,o){var g=e.setup,p=g.minScale,v=g.maxScale,n=g.limitToBounds,i=_r(Tt(s,2),p,v,0,!1),l=gs(e,i),d=hi(e,r,o,i,l,n),c=d.x,m=d.y;return{scale:i,positionX:c,positionY:m}}function $l(e,s,r){var o=e.transformState.scale,g=e.wrapperComponent,p=e.setup,v=p.minScale,n=p.limitToBounds,i=p.zoomAnimation,l=i.disabled,d=i.animationTime,c=i.animationType,m=l||o>=v;if((o>=1||n)&&Wn(e),!(m||!g||!e.mounted)){var x=s||g.offsetWidth/2,w=r||g.offsetHeight/2,y=Hn(e,v,x,w);y&&as(e,y,d,c)}}var is=function(){return is=Object.assign||function(s){for(var r,o=1,g=arguments.length;o<g;o++){r=arguments[o];for(var p in r)Object.prototype.hasOwnProperty.call(r,p)&&(s[p]=r[p])}return s},is.apply(this,arguments)};function qo(e,s,r){for(var o=0,g=s.length,p;o<g;o++)(p||!(o in s))&&(p||(p=Array.prototype.slice.call(s,0,o)),p[o]=s[o]);return e.concat(p||Array.prototype.slice.call(s))}var Lr={scale:1,positionX:0,positionY:0},Qs={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}},tn={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},Ul=function(e){var s,r,o,g;return{previousScale:(s=e.initialScale)!==null&&s!==void 0?s:Lr.scale,scale:(r=e.initialScale)!==null&&r!==void 0?r:Lr.scale,positionX:(o=e.initialPositionX)!==null&&o!==void 0?o:Lr.positionX,positionY:(g=e.initialPositionY)!==null&&g!==void 0?g:Lr.positionY}},Ko=function(e){var s=is({},Qs);return Object.keys(e).forEach(function(r){var o=typeof e[r]<"u",g=typeof Qs[r]<"u";if(g&&o){var p=Object.prototype.toString.call(Qs[r]),v=p==="[object Object]",n=p==="[object Array]";v?s[r]=is(is({},Qs[r]),e[r]):n?s[r]=qo(qo([],Qs[r],!0),e[r]):s[r]=e[r]}}),s},ql=function(e,s,r){var o=e.transformState.scale,g=e.wrapperComponent,p=e.setup,v=p.maxScale,n=p.minScale,i=p.zoomAnimation,l=p.smooth,d=i.size;if(!g)throw new Error("Wrapper is not mounted");var c=l?o*Math.exp(s*r):o+s*r,m=_r(Tt(c,3),n,v,d,!1);return m};function Kl(e,s,r,o,g){var p=e.wrapperComponent,v=e.transformState,n=v.scale,i=v.positionX,l=v.positionY;if(!p)return console.error("No WrapperComponent found");var d=p.offsetWidth,c=p.offsetHeight,m=(d/2-i)/n,x=(c/2-l)/n,w=ql(e,s,r),y=Hn(e,w,m,x);if(!y)return console.error("Error during zoom event. New transformation state was not calculated.");as(e,y,o,g)}function Xl(e,s,r,o){var g=e.setup,p=e.wrapperComponent,v=g.limitToBounds,n=Ul(e.props),i=e.transformState,l=i.scale,d=i.positionX,c=i.positionY;if(p){var m=zn(e,n.scale),x=xr(n.positionX,n.positionY,m,v,0,0,p),w={scale:n.scale,positionX:x.x,positionY:x.y};l===n.scale&&d===n.positionX&&c===n.positionY||(o?.(),as(e,w,s,r))}}function xg(e,s,r,o){var g=e.getBoundingClientRect(),p=s.getBoundingClientRect(),v=r.getBoundingClientRect(),n=p.x*o.scale,i=p.y*o.scale;return{x:(g.x-v.x+n)/o.scale,y:(g.y-v.y+i)/o.scale}}function _g(e,s,r){var o=e.wrapperComponent,g=e.contentComponent,p=e.transformState,v=e.setup,n=v.limitToBounds,i=v.minScale,l=v.maxScale;if(!o||!g)return p;var d=o.getBoundingClientRect(),c=s.getBoundingClientRect(),m=xg(s,o,g,p),x=m.x,w=m.y,y=c.width/p.scale,a=c.height/p.scale,h=o.offsetWidth/y,u=o.offsetHeight/a,f=_r(r||Math.min(h,u),i,l,0,!1),b=(d.width-y*f)/2,C=(d.height-a*f)/2,k=(d.left-x)*f+b,E=(d.top-w)*f+C,_=zn(e,f),j=xr(k,E,_,n,0,0,o),A=j.x,P=j.y;return{positionX:A,positionY:P,scale:f}}var bg=function(e){return function(s,r,o){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),Kl(e,1,s,r,o)}},yg=function(e){return function(s,r,o){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),Kl(e,-1,s,r,o)}},Sg=function(e){return function(s,r,o,g,p){g===void 0&&(g=300),p===void 0&&(p="easeOut");var v=e.transformState,n=v.positionX,i=v.positionY,l=v.scale,d=e.wrapperComponent,c=e.contentComponent,m=e.setup.disabled;if(!(m||!d||!c)){var x={positionX:Number.isNaN(s)?n:s,positionY:Number.isNaN(r)?i:r,scale:Number.isNaN(o)?l:o};as(e,x,g,p)}}},wg=function(e){return function(s,r){s===void 0&&(s=200),r===void 0&&(r="easeOut"),Xl(e,s,r)}},Cg=function(e){return function(s,r,o){r===void 0&&(r=200),o===void 0&&(o="easeOut");var g=e.transformState,p=e.wrapperComponent,v=e.contentComponent;if(p&&v){var n=Yl(s||g.scale,p,v);as(e,n,r,o)}}},kg=function(e){return function(s,r,o,g){o===void 0&&(o=600),g===void 0&&(g="easeOut"),It(e);var p=e.wrapperComponent,v=typeof s=="string"?document.getElementById(s):s;if(p&&v&&p.contains(v)){var n=_g(e,v,r);as(e,n,o,g)}}},Zr=function(e){return{instance:e,zoomIn:bg(e),zoomOut:yg(e),setTransform:Sg(e),resetTransform:wg(e),centerView:Cg(e),zoomToElement:kg(e)}},sn=function(e){return{instance:e,state:e.transformState}},qe=function(e){var s={};return Object.assign(s,sn(e)),Object.assign(s,Zr(e)),s},Li=!1;function Ii(){try{var e={get passive(){return Li=!0,!1}};return e}catch{return Li=!1,Li}}var Ir=".".concat(tn.wrapperClass),fi=function(e,s){return s.some(function(r){return e.matches("".concat(Ir," ").concat(r,", ").concat(Ir," .").concat(r,", ").concat(Ir," ").concat(r," *, ").concat(Ir," .").concat(r," *"))})},rn=function(e){e&&clearTimeout(e)},Eg=function(e,s,r){return"translate(".concat(e,"px, ").concat(s,"px) scale(").concat(r,")")},Yl=function(e,s,r){var o=r.offsetWidth*e,g=r.offsetHeight*e,p=(s.offsetWidth-o)/2,v=(s.offsetHeight-g)/2;return{scale:e,positionX:p,positionY:v}};function jg(e){return function(s){e.forEach(function(r){typeof r=="function"?r(s):r!=null&&(r.current=s)})}}var Ng=function(e,s){var r=e.setup.wheel,o=r.disabled,g=r.wheelDisabled,p=r.touchPadDisabled,v=r.excluded,n=e.isInitialized,i=e.isPanning,l=s.target,d=n&&!i&&!o&&l;if(!d||g&&!s.ctrlKey||p&&s.ctrlKey)return!1;var c=fi(l,v);return!c},Rg=function(e){return e?e.deltaY<0?1:-1:0};function Ag(e,s){var r=Rg(e),o=$p(s,r);return o}function Vl(e,s,r){var o=s.getBoundingClientRect(),g=0,p=0;if("clientX"in e)g=(e.clientX-o.left)/r,p=(e.clientY-o.top)/r;else{var v=e.touches[0];g=(v.clientX-o.left)/r,p=(v.clientY-o.top)/r}return(Number.isNaN(g)||Number.isNaN(p))&&console.error("No mouse or touch offset found"),{x:g,y:p}}var Tg=function(e,s,r,o,g){var p=e.transformState.scale,v=e.wrapperComponent,n=e.setup,i=n.maxScale,l=n.minScale,d=n.zoomAnimation,c=n.disablePadding,m=d.size,x=d.disabled;if(!v)throw new Error("Wrapper is not mounted");var w=p+s*r,y=o?!1:!x,a=_r(Tt(w,3),l,i,m,y&&!c);return a},Mg=function(e,s){var r=e.previousWheelEvent,o=e.transformState.scale,g=e.setup,p=g.maxScale,v=g.minScale;return r?o<p||o>v||Math.sign(r.deltaY)!==Math.sign(s.deltaY)||r.deltaY>0&&r.deltaY<s.deltaY||r.deltaY<0&&r.deltaY>s.deltaY||Math.sign(r.deltaY)!==Math.sign(s.deltaY):!1},Dg=function(e,s){var r=e.setup.pinch,o=r.disabled,g=r.excluded,p=e.isInitialized,v=s.target,n=p&&!o&&v;if(!n)return!1;var i=fi(v,g);return!i},Pg=function(e){var s=e.setup.pinch.disabled,r=e.isInitialized,o=e.pinchStartDistance,g=r&&!s&&o;return!!g},Lg=function(e,s,r){var o=r.getBoundingClientRect(),g=e.touches,p=Tt(g[0].clientX-o.left,5),v=Tt(g[0].clientY-o.top,5),n=Tt(g[1].clientX-o.left,5),i=Tt(g[1].clientY-o.top,5);return{x:(p+n)/2/s,y:(v+i)/2/s}},Gl=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))},Ig=function(e,s){var r=e.pinchStartScale,o=e.pinchStartDistance,g=e.setup,p=g.maxScale,v=g.minScale,n=g.zoomAnimation,i=g.disablePadding,l=n.size,d=n.disabled;if(!r||o===null||!s)throw new Error("Pinch touches distance was not provided");if(s<0)return e.transformState.scale;var c=s/o,m=c*r;return _r(Tt(m,2),v,p,l,!d&&!i)},Og=160,Bg=100,Fg=function(e,s){var r=e.props,o=r.onWheelStart,g=r.onZoomStart;e.wheelStopEventTimer||(It(e),Qe(qe(e),s,o),Qe(qe(e),s,g))},zg=function(e,s){var r=e.props,o=r.onWheel,g=r.onZoom,p=e.contentComponent,v=e.setup,n=e.transformState,i=n.scale,l=v.limitToBounds,d=v.centerZoomedOut,c=v.zoomAnimation,m=v.wheel,x=v.disablePadding,w=v.smooth,y=c.size,a=c.disabled,h=m.step,u=m.smoothStep;if(!p)throw new Error("Component not mounted");s.preventDefault(),s.stopPropagation();var f=Ag(s,null),b=w?u*Math.abs(s.deltaY):h,C=Tg(e,f,b,!s.ctrlKey);if(i!==C){var k=gs(e,C),E=Vl(s,p,i),_=a||y===0||d||x,j=l&&_,A=hi(e,E.x,E.y,C,k,j),P=A.x,T=A.y;e.previousWheelEvent=s,e.setTransformState(C,P,T),Qe(qe(e),s,o),Qe(qe(e),s,g)}},Wg=function(e,s){var r=e.props,o=r.onWheelStop,g=r.onZoomStop;rn(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&($l(e,s.x,s.y),e.wheelAnimationTimer=null)},Bg);var p=Mg(e,s);p&&(rn(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,Qe(qe(e),s,o),Qe(qe(e),s,g))},Og))},Ql=function(e){for(var s=0,r=0,o=0;o<2;o+=1)s+=e.touches[o].clientX,r+=e.touches[o].clientY;var g=s/2,p=r/2;return{x:g,y:p}},Hg=function(e,s){var r=Gl(s);e.pinchStartDistance=r,e.lastDistance=r,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var o=Ql(s);e.pinchLastCenterX=o.x,e.pinchLastCenterY=o.y,It(e)},$g=function(e,s){var r=e.contentComponent,o=e.pinchStartDistance,g=e.wrapperComponent,p=e.transformState.scale,v=e.setup,n=v.limitToBounds,i=v.centerZoomedOut,l=v.zoomAnimation,d=v.alignmentAnimation,c=l.disabled,m=l.size;if(!(o===null||!r)){var x=Lg(s,p,r);if(!(!Number.isFinite(x.x)||!Number.isFinite(x.y))){var w=Gl(s),y=Ig(e,w),a=Ql(s),h=a.x-(e.pinchLastCenterX||0),u=a.y-(e.pinchLastCenterY||0);if(!(y===p&&h===0&&u===0)){e.pinchLastCenterX=a.x,e.pinchLastCenterY=a.y;var f=gs(e,y),b=c||m===0||i,C=n&&b,k=hi(e,x.x,x.y,y,f,C),E=k.x,_=k.y;e.pinchMidpoint=x,e.lastDistance=w;var j=d.sizeX,A=d.sizeY,P=os(e,j),T=os(e,A),D=E+h,W=_+u,I=xr(D,W,f,n,P,T,g),B=I.x,F=I.y;e.setTransformState(y,B,F)}}}},Ug=function(e){var s=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,$l(e,s?.x,s?.y)},Zl=function(e,s){var r=e.props.onZoomStop,o=e.setup.doubleClick.animationTime;rn(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,Qe(qe(e),s,r)},o)},qg=function(e,s){var r=e.props,o=r.onZoomStart,g=r.onZoom,p=e.setup.doubleClick,v=p.animationTime,n=p.animationType;Qe(qe(e),s,o),Xl(e,v,n,function(){return Qe(qe(e),s,g)}),Zl(e,s)};function Kg(e,s){return e==="toggle"?s===1?1:-1:e==="zoomOut"?-1:1}function Xg(e,s){var r=e.setup,o=e.doubleClickStopEventTimer,g=e.transformState,p=e.contentComponent,v=g.scale,n=e.props,i=n.onZoomStart,l=n.onZoom,d=r.doubleClick,c=d.disabled,m=d.mode,x=d.step,w=d.animationTime,y=d.animationType;if(!c&&!o){if(m==="reset")return qg(e,s);if(!p)return console.error("No ContentComponent found");var a=Kg(m,e.transformState.scale),h=ql(e,a,x);if(v!==h){Qe(qe(e),s,i);var u=Vl(s,p,v),f=Hn(e,h,u.x,u.y);if(!f)return console.error("Error during zoom event. New transformation state was not calculated.");Qe(qe(e),s,l),as(e,f,w,y),Zl(e,s)}}}var Yg=function(e,s){var r=e.isInitialized,o=e.setup,g=e.wrapperComponent,p=o.doubleClick,v=p.disabled,n=p.excluded,i=s.target,l=g?.contains(i),d=r&&i&&l&&!v;if(!d)return!1;var c=fi(i,n);return!c},Vg=(function(){function e(s){var r=this;this.mounted=!0,this.pinchLastCenterX=null,this.pinchLastCenterY=null,this.onChangeCallbacks=new Set,this.onInitCallbacks=new Set,this.wrapperComponent=null,this.contentComponent=null,this.isInitialized=!1,this.bounds=null,this.previousWheelEvent=null,this.wheelStopEventTimer=null,this.wheelAnimationTimer=null,this.isPanning=!1,this.isWheelPanning=!1,this.startCoords=null,this.lastTouch=null,this.distance=null,this.lastDistance=null,this.pinchStartDistance=null,this.pinchStartScale=null,this.pinchMidpoint=null,this.doubleClickStopEventTimer=null,this.velocity=null,this.velocityTime=null,this.lastMousePosition=null,this.animate=!1,this.animation=null,this.maxBounds=null,this.pressedKeys={},this.mount=function(){r.initializeWindowEvents()},this.unmount=function(){r.cleanupWindowEvents()},this.update=function(o){r.props=o,gs(r,r.transformState.scale),r.setup=Ko(o)},this.initializeWindowEvents=function(){var o,g,p=Ii(),v=(o=r.wrapperComponent)===null||o===void 0?void 0:o.ownerDocument,n=v?.defaultView;(g=r.wrapperComponent)===null||g===void 0||g.addEventListener("wheel",r.onWheelPanning,p),n?.addEventListener("mousedown",r.onPanningStart,p),n?.addEventListener("mousemove",r.onPanning,p),n?.addEventListener("mouseup",r.onPanningStop,p),v?.addEventListener("mouseleave",r.clearPanning,p),n?.addEventListener("keyup",r.setKeyUnPressed,p),n?.addEventListener("keydown",r.setKeyPressed,p)},this.cleanupWindowEvents=function(){var o,g,p=Ii(),v=(o=r.wrapperComponent)===null||o===void 0?void 0:o.ownerDocument,n=v?.defaultView;n?.removeEventListener("mousedown",r.onPanningStart,p),n?.removeEventListener("mousemove",r.onPanning,p),n?.removeEventListener("mouseup",r.onPanningStop,p),v?.removeEventListener("mouseleave",r.clearPanning,p),n?.removeEventListener("keyup",r.setKeyUnPressed,p),n?.removeEventListener("keydown",r.setKeyPressed,p),document.removeEventListener("mouseleave",r.clearPanning,p),It(r),(g=r.observer)===null||g===void 0||g.disconnect()},this.handleInitializeWrapperEvents=function(o){var g=Ii();o.addEventListener("wheel",r.onWheelZoom,g),o.addEventListener("dblclick",r.onDoubleClick,g),o.addEventListener("touchstart",r.onTouchPanningStart,g),o.addEventListener("touchmove",r.onTouchPanning,g),o.addEventListener("touchend",r.onTouchPanningStop,g)},this.handleInitialize=function(o,g){var p=!1,v=r.setup.centerOnInit,n=function(i,l){for(var d=0,c=i;d<c.length;d++){var m=c[d];if(m.target===l)return!0}return!1};r.applyTransformation(),r.onInitCallbacks.forEach(function(i){i(qe(r))}),r.observer=new ResizeObserver(function(i){if(n(i,o)||n(i,g))if(v&&!p){var l=g.offsetWidth,d=g.offsetHeight;(l>0||d>0)&&(p=!0,r.setCenter())}else It(r),gs(r,r.transformState.scale),Wn(r,0)}),r.observer.observe(o),r.observer.observe(g)},this.onWheelZoom=function(o){var g=r.setup.disabled;if(!g){var p=Ng(r,o);if(p){var v=r.isPressingKeys(r.setup.wheel.activationKeys);v&&(Fg(r,o),zg(r,o),Wg(r,o))}}},this.onWheelPanning=function(o){var g=r.setup,p=g.disabled,v=g.wheel,n=g.panning;if(!(!r.wrapperComponent||!r.contentComponent||p||!v.wheelDisabled||n.disabled||!n.wheelPanning||o.ctrlKey)){o.preventDefault(),o.stopPropagation();var i=r.transformState,l=i.positionX,d=i.positionY,c=l-o.deltaX,m=d-o.deltaY,x=n.lockAxisX?l:c,w=n.lockAxisY?d:m,y=r.setup.alignmentAnimation,a=y.sizeX,h=y.sizeY,u=os(r,a),f=os(r,h);x===l&&w===d||Hl(r,x,w,u,f)}},this.onPanningStart=function(o){var g=r.setup.disabled,p=r.props.onPanningStart;if(!g){var v=zo(r,o);if(v){var n=r.isPressingKeys(r.setup.panning.activationKeys);n&&(o.button===0&&!r.setup.panning.allowLeftClickPan||o.button===1&&!r.setup.panning.allowMiddleClickPan||o.button===2&&!r.setup.panning.allowRightClickPan||(o.preventDefault(),o.stopPropagation(),It(r),$o(r,o),Qe(qe(r),o,p)))}}},this.onPanning=function(o){var g=r.setup.disabled,p=r.props.onPanning;if(!g){var v=Wo(r);if(v){var n=r.isPressingKeys(r.setup.panning.activationKeys);n&&(o.preventDefault(),o.stopPropagation(),Uo(r,o.clientX,o.clientY),Qe(qe(r),o,p))}}},this.onPanningStop=function(o){var g=r.props.onPanningStop;r.isPanning&&(vg(r),Qe(qe(r),o,g))},this.onPinchStart=function(o){var g=r.setup.disabled,p=r.props,v=p.onPinchingStart,n=p.onZoomStart;if(!g){var i=Dg(r,o);i&&(Hg(r,o),It(r),Qe(qe(r),o,v),Qe(qe(r),o,n))}},this.onPinch=function(o){var g=r.setup.disabled,p=r.props,v=p.onPinching,n=p.onZoom;if(!g){var i=Pg(r);i&&(o.preventDefault(),o.stopPropagation(),$g(r,o),Qe(qe(r),o,v),Qe(qe(r),o,n))}},this.onPinchStop=function(o){var g=r.props,p=g.onPinchingStop,v=g.onZoomStop;r.pinchStartScale&&(Ug(r),Qe(qe(r),o,p),Qe(qe(r),o,v))},this.onTouchPanningStart=function(o){var g=r.setup.disabled,p=r.props.onPanningStart;if(!g){var v=zo(r,o);if(v){var n=r.lastTouch&&+new Date-r.lastTouch<200&&o.touches.length===1;if(!n){r.lastTouch=+new Date,It(r);var i=o.touches,l=i.length===1,d=i.length===2;l&&(It(r),$o(r,o),Qe(qe(r),o,p)),d&&r.onPinchStart(o)}}}},this.onTouchPanning=function(o){var g=r.setup.disabled,p=r.props.onPanning;if(r.isPanning&&o.touches.length===1){if(g)return;var v=Wo(r);if(!v)return;o.preventDefault(),o.stopPropagation();var n=o.touches[0];Uo(r,n.clientX,n.clientY),Qe(qe(r),o,p)}else o.touches.length>1&&r.onPinch(o)},this.onTouchPanningStop=function(o){r.onPanningStop(o),r.onPinchStop(o)},this.onDoubleClick=function(o){var g=r.setup.disabled;if(!g){var p=Yg(r,o);p&&Xg(r,o)}},this.clearPanning=function(o){r.isPanning&&r.onPanningStop(o)},this.setKeyPressed=function(o){r.pressedKeys[o.key]=!0},this.setKeyUnPressed=function(o){r.pressedKeys[o.key]=!1},this.isPressingKeys=function(o){return o.length?!!o.find(function(g){return r.pressedKeys[g]}):!0},this.setTransformState=function(o,g,p){var v=r.props.onTransformed;if(!Number.isNaN(o)&&!Number.isNaN(g)&&!Number.isNaN(p)){o!==r.transformState.scale&&(r.transformState.previousScale=r.transformState.scale,r.transformState.scale=o),r.transformState.positionX=g,r.transformState.positionY=p,r.applyTransformation();var n=qe(r);r.onChangeCallbacks.forEach(function(i){return i(n)}),Qe(n,{scale:o,positionX:g,positionY:p},v)}else console.error("Detected NaN set state values")},this.setCenter=function(){if(r.wrapperComponent&&r.contentComponent){var o=Yl(r.transformState.scale,r.wrapperComponent,r.contentComponent);r.setTransformState(o.scale,o.positionX,o.positionY)}},this.handleTransformStyles=function(o,g,p){return r.props.customTransform?r.props.customTransform(o,g,p):Eg(o,g,p)},this.applyTransformation=function(){if(!(!r.mounted||!r.contentComponent)){var o=r.transformState,g=o.scale,p=o.positionX,v=o.positionY,n=r.handleTransformStyles(p,v,g);r.contentComponent.style.transform=n}},this.getContext=function(){return qe(r)},this.onChange=function(o){return r.onChangeCallbacks.has(o)||r.onChangeCallbacks.add(o),function(){r.onChangeCallbacks.delete(o)}},this.onInit=function(o){return r.onInitCallbacks.has(o)||r.onInitCallbacks.add(o),function(){r.onInitCallbacks.delete(o)}},this.init=function(o,g){r.cleanupWindowEvents(),r.wrapperComponent=o,r.contentComponent=g,gs(r,r.transformState.scale),r.handleInitializeWrapperEvents(o),r.handleInitialize(o,g),r.initializeWindowEvents(),r.isInitialized=!0;var p=qe(r);Qe(p,void 0,r.props.onInit)},this.props=s,this.setup=Ko(this.props),this.transformState=Ul(this.props)}return e})(),mi=ae.createContext(null),Gg=function(e,s){return typeof e=="function"?e(s):e},Qg=ae.forwardRef(function(e,s){var r=S.useRef(new Vg(e)).current,o=Gg(e.children,Zr(r));return S.useImperativeHandle(s,function(){return Zr(r)},[r]),S.useEffect(function(){r.update(e)},[r,e]),ae.createElement(mi.Provider,{value:r},o)});ae.forwardRef(function(e,s){var r=S.useRef(null),o=S.useContext(mi);return S.useEffect(function(){return o.onChange(function(g){if(r.current){var p=0,v=0;r.current.style.transform=o.handleTransformStyles(p,v,1/g.instance.transformState.scale)}})},[o]),ae.createElement("div",is({},e,{ref:jg([r,s])}))});function Zg(e,s){s===void 0&&(s={});var r=s.insertAt;if(!(typeof document>"u")){var o=document.head||document.getElementsByTagName("head")[0],g=document.createElement("style");g.type="text/css",r==="top"&&o.firstChild?o.insertBefore(g,o.firstChild):o.appendChild(g),g.styleSheet?g.styleSheet.cssText=e:g.appendChild(document.createTextNode(e))}}var Jg=`.transform-component-module_wrapper__SPB86 {
41
- position: relative;
42
- width: -moz-fit-content;
43
- width: fit-content;
44
- height: -moz-fit-content;
45
- height: fit-content;
46
- overflow: hidden;
47
- -webkit-touch-callout: none; /* iOS Safari */
48
- -webkit-user-select: none; /* Safari */
49
- -khtml-user-select: none; /* Konqueror HTML */
50
- -moz-user-select: none; /* Firefox */
51
- -ms-user-select: none; /* Internet Explorer/Edge */
52
- user-select: none;
53
- margin: 0;
54
- padding: 0;
55
- transform: translate3d(0, 0, 0);
56
- }
57
- .transform-component-module_content__FBWxo {
58
- display: flex;
59
- flex-wrap: wrap;
60
- width: -moz-fit-content;
61
- width: fit-content;
62
- height: -moz-fit-content;
63
- height: fit-content;
64
- margin: 0;
65
- padding: 0;
66
- transform-origin: 0% 0%;
67
- }
68
- .transform-component-module_content__FBWxo img {
69
- pointer-events: none;
70
- }
71
- `,Xo={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};Zg(Jg);var ev=function(e){var s=e.children,r=e.wrapperClass,o=r===void 0?"":r,g=e.contentClass,p=g===void 0?"":g,v=e.wrapperStyle,n=e.contentStyle,i=e.wrapperProps,l=i===void 0?{}:i,d=e.contentProps,c=d===void 0?{}:d,m=S.useContext(mi),x=m.init,w=m.cleanupWindowEvents,y=S.useRef(null),a=S.useRef(null);return S.useEffect(function(){var h=y.current,u=a.current;return h!==null&&u!==null&&x&&x?.(h,u),function(){w?.()}},[]),ae.createElement("div",is({},l,{ref:y,className:"".concat(tn.wrapperClass," ").concat(Xo.wrapper," ").concat(o),style:v}),ae.createElement("div",is({},c,{ref:a,className:"".concat(tn.contentClass," ").concat(Xo.content," ").concat(p),style:n}),s))},Jl=function(){var e=S.useContext(mi);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},tv=function(){var e=Jl();return Zr(e)};function sv(e){var s=Jl(),r=S.useState(e(sn(s))),o=r[0],g=r[1];return S.useEffect(function(){var p=!0,v=s.onChange(function(n){p&&g(e(sn(n.instance)))});return function(){v(),p=!1}},[e,s]),o}function rv(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 iv(e,s){return Bt({queryKey:de.files.tree(e||"",s),queryFn:()=>Ce.get("/files/tree",{params:{workingDir:e||"",path:s}}),enabled:!!e})}function nv(e,s){return Bt({queryKey:de.files.content(e||"",s||""),queryFn:()=>Ce.get("/files/read",{params:{workingDir:e||"",path:s||""}}),enabled:!!e&&!!s})}function ov(e){const s=bt();return S.useCallback(()=>{e&&s.invalidateQueries({queryKey:["files","tree",e]})},[s,e])}function av(){const e=bt();return Ft({mutationFn:s=>Ce.post("/files/write",s),onSuccess:(s,r)=>{const o=de.files.content(r.workingDir,r.path),g=e.getQueryData(o);e.setQueryData(o,{content:r.content,language:g?.language||rv(r.path)})}})}function lv(e,s){return e==="/"?`/${s}`:`${e}/${s}`}function cv(e,s){return e==="/"?s:`${e.slice(1)}/${s}`}const dv=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function uv(e){if(e.type==="directory")return null;const s=e.name.split(".").pop()?.toLowerCase();return s&&dv.has(s)?ka:s==="ts"||s==="tsx"||s==="js"||s==="jsx"?Ur:s==="json"?qd:s==="md"||s==="mdx"||s==="txt"?Ca:Cd}const Yo=({depth:e,active:s,onClick:r,leftIcon:o,rightIcon:g,label:p})=>t.jsxs("button",{type:"button",onClick:r,className:se("w-full flex items-center gap-2 rounded px-2 py-1 text-left text-xs hover:bg-neutral-100",s&&"bg-neutral-100 text-neutral-900"),style:{paddingLeft:8+e*14},children:[t.jsx("span",{className:"shrink-0",children:g}),t.jsx("span",{className:"shrink-0 text-neutral-500",children:o}),t.jsx("span",{className:"truncate text-neutral-700",children:p})]}),ec=({workingDir:e,path:s,depth:r,expanded:o,toggleDir:g,onFileSelect:p,selectedFilePath:v})=>{const{t:n}=ce(),{data:i,isLoading:l,isError:d}=iv(e,s),c=S.useMemo(()=>i?.items??[],[i?.items]);return l?t.jsx("div",{className:"text-xs text-neutral-400 px-2 py-1",style:{paddingLeft:8+r*14},children:n("Loading...")}):d?t.jsx("div",{className:"text-xs text-red-600 px-2 py-1",style:{paddingLeft:8+r*14},children:n("Failed to load")}):t.jsx("div",{className:"space-y-0.5",children:c.map(m=>{if(m.type==="directory"){const h=lv(s,m.name),u=o.has(h);return t.jsxs("div",{children:[t.jsx(Yo,{depth:r,onClick:()=>g(h),rightIcon:u?t.jsx(wt,{size:14,className:"text-neutral-400"}):t.jsx(Mt,{size:14,className:"text-neutral-400"}),leftIcon:u?t.jsx(ii,{size:14,className:"text-amber-500"}):t.jsx($a,{size:14,className:"text-amber-500"}),label:m.name}),u&&t.jsx(ec,{workingDir:e,path:h,depth:r+1,expanded:o,toggleDir:g,onFileSelect:p,selectedFilePath:v})]},h)}const x=cv(s,m.name),w=uv(m),y=v===x,a=w===ka;return t.jsx(Yo,{depth:r,active:y,onClick:()=>p(x),rightIcon:t.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:w?t.jsx(w,{size:14,className:a?"text-emerald-600":"text-sky-600"}):null,label:m.name},x)})})},hv=({workingDir:e,className:s,onFileSelect:r,selectedFilePath:o,onCollapse:g})=>{const{t:p}=ce(),[v,n]=S.useState(()=>new Set),i=ov(e),l=S.useCallback(d=>{n(c=>{const m=new Set(c);return m.has(d)?m.delete(d):m.add(d),m})},[]);return t.jsxs("div",{className:se("h-full flex flex-col",s),children:[t.jsxs("div",{className:"px-3 py-2 border-b border-neutral-200 bg-neutral-50/80 flex items-center justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[11px] font-semibold text-neutral-600 uppercase tracking-wider",children:p("Files")}),t.jsx("div",{className:"text-[11px] text-neutral-400 truncate",children:e||p("No working directory")})]}),t.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e&&t.jsx("button",{type:"button",onClick:i,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:p("Refresh file tree"),children:t.jsx(hr,{size:13})}),g&&t.jsx("button",{type:"button",onClick:g,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:p("Collapse file tree"),children:t.jsx(tu,{size:13})})]})]}),t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin p-2",children:e?t.jsx(ec,{workingDir:e,path:"/",depth:0,expanded:v,toggleDir:l,onFileSelect:r,selectedFilePath:o}):t.jsx("div",{className:"text-xs text-neutral-500 px-2 py-2",children:p("No workspace selected.")})})]})},fv=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function mv(e){const s=e.split(".").pop()?.toLowerCase();return s?fv.has(s):!1}function pv(e,s){const r=dr(),o=new URLSearchParams({workingDir:e,path:s});return`${r}/files/image?${o.toString()}`}const gv=({filePath:e})=>{const{t:s}=ce(),{zoomIn:r,zoomOut:o,centerView:g}=tv(),p=sv(n=>n.state.scale),v=Math.round(p*100);return t.jsxs("div",{className:"flex items-center gap-1 px-3 py-1.5 border-b border-neutral-200 bg-neutral-50/80 shrink-0",children:[t.jsx("button",{type:"button",onClick:()=>o(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:s("Zoom out"),children:t.jsx(gu,{size:14})}),t.jsxs("button",{type:"button",onClick:()=>g(1),className:"px-1.5 py-0.5 rounded hover:bg-neutral-200 text-[11px] text-neutral-600 tabular-nums min-w-[40px] text-center transition-colors",title:s("Reset zoom"),children:[v,"%"]}),t.jsx("button",{type:"button",onClick:()=>r(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:s("Zoom in"),children:t.jsx(mu,{size:14})}),t.jsx("button",{type:"button",onClick:()=>g(1),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors ml-1",title:s("Fit to view"),children:t.jsx(Jd,{size:13})}),t.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},vv=({workingDir:e,filePath:s})=>{const{t:r}=ce(),[o,g]=S.useState(!1),p=pv(e,s);return o?t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:r("Failed to load image.")}):t.jsx(Qg,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx(gv,{filePath:s}),t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden bg-[repeating-conic-gradient(#f3f3f3_0%_25%,#fff_0%_50%)] bg-[length:16px_16px]",children:t.jsx(ev,{wrapperStyle:{width:"100%",height:"100%"},contentStyle:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx("img",{src:p,alt:s,className:"max-w-full max-h-full object-contain rounded shadow-sm",draggable:!1,onError:()=>g(!0)})})})]})})};function xv(e){const s=e.split("/");return s[s.length-1]||e}function _v(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 bv=({active:e,name:s,isDirty:r,onClick:o,onClose:g})=>{const{t:p}=ce();return t.jsxs("button",{type:"button",onClick:o,className:se("group flex items-center gap-2 px-3 py-2 rounded-t-md border-t border-x -mb-px min-w-[120px] max-w-[240px]",e?"bg-white border-neutral-200 text-neutral-900":"bg-neutral-100/60 border-transparent text-neutral-500 hover:text-neutral-700 hover:bg-neutral-100"),children:[t.jsx("span",{className:se("w-2 h-2 rounded-full",r?"bg-amber-500":"bg-transparent")}),t.jsx("span",{className:"truncate flex-1 text-left text-xs",children:s}),t.jsx("span",{onClick:g,className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-neutral-200 rounded transition-all shrink-0","aria-label":p("Close tab"),title:p("Close"),children:t.jsx(Yt,{size:12})})]})},yv=ae.forwardRef(function({workingDir:s,className:r,readOnly:o=!1},g){const{t:p}=ce(),[v,n]=S.useState([]),[i,l]=S.useState(null),[d,c]=S.useState(!1),[m,x]=S.useState(!1),[w,y]=S.useState(0),[a,h]=S.useState(null),u=S.useRef(null),f=av();S.useEffect(()=>{let z=!1;return td(async()=>{const{preloadMonaco:$}=await import("./monaco-Bc-Z2u8N.js").then(q=>q.m);return{preloadMonaco:$}},__vite__mapDeps([0,1,2,3])).then(({preloadMonaco:$})=>$()).then(()=>{z||c(!0)}).catch(()=>{z||x(!0)}),()=>{z=!0}},[]);const[b,C]=S.useState(280),[k,E]=S.useState(!1),[_,j]=S.useState(!1),A=S.useRef(280),P=S.useCallback(()=>{E(z=>(z?C(A.current):A.current=b,!z))},[b]),T=S.useCallback(z=>{z.preventDefault(),j(!0);const $=z.clientX,q=b,N=X=>{const K=X.clientX-$,ne=Math.min(480,Math.max(160,q+K));C(ne)},H=()=>{j(!1),document.removeEventListener("mousemove",N),document.removeEventListener("mouseup",H)};document.addEventListener("mousemove",N),document.addEventListener("mouseup",H)},[b]);S.useEffect(()=>{n([]),l(null),h(null)},[s]);const D=S.useMemo(()=>v.find(z=>z.path===i)||null,[v,i]),{data:W,isFetching:I,isError:B,error:F}=nv(s,D?.isImage?null:i);S.useEffect(()=>{!i||!W||n(z=>z.map($=>$.path!==i||$.isDirty||$.loaded?$:{...$,language:W.language||$.language,content:W.content,savedContent:W.content,isDirty:!1,loaded:!0}))},[i,W]);const R=S.useCallback((z,$,q)=>{n(N=>{if(N.find(K=>K.path===z))return N;const X=mv(z);return[...N,{path:z,name:xv(z),language:_v(z),content:"",savedContent:"",isDirty:!1,loaded:X,isImage:X}]}),l(z),h($?{path:z,line:$,column:q}:null)},[]);ae.useImperativeHandle(g,()=>({openFile:R}),[R]);const M=S.useCallback(z=>{n($=>{const q=$.filter(N=>N.path!==z);return l(N=>N!==z?N:q.length?q[q.length-1].path:null),q})},[]),L=S.useCallback(z=>{n($=>$.map(q=>{if(q.path!==i)return q;const N=z!==q.savedContent;return{...q,content:z,isDirty:N}}))},[i]),O=S.useCallback(async()=>{o||!s||!D||(await f.mutateAsync({workingDir:s,path:D.path,content:D.content}),n(z=>z.map($=>$.path===D.path?{...$,savedContent:$.content,isDirty:!1,loaded:!0}:$)))},[D,o,f,s]),U=S.useRef(()=>{});S.useEffect(()=>{U.current=()=>{O().catch(()=>{})}},[O]),S.useEffect(()=>{const z=$=>{o||($.metaKey||$.ctrlKey)&&$.key.toLowerCase()==="s"&&($.preventDefault(),U.current())};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[o]);const Y=S.useCallback((z,$)=>{u.current=z,y(q=>q+1),z.addCommand($.KeyMod.CtrlCmd|$.KeyCode.KeyS,()=>{U.current()})},[]);return S.useEffect(()=>{if(!a||a.path!==i||!D?.loaded)return;const z=u.current,$=z?.getModel();if(!z||!$)return;const q=Math.min(a.line,$.getLineCount()),N=Math.min(a.column??1,$.getLineMaxColumn(q)),H={lineNumber:q,column:N};z.setPosition(H),z.revealPositionInCenter(H),z.focus(),h(null)},[i,D?.loaded,w,a]),t.jsxs("div",{className:se("flex h-full overflow-hidden bg-white",r),style:_?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsx("div",{className:"border-r border-neutral-200 bg-white shrink-0 overflow-hidden relative",style:{width:k?36:b,transition:_?"none":"width 0.15s ease"},children:k?t.jsx("div",{className:"h-full flex items-start pt-2 justify-center",children:t.jsx("button",{type:"button",onClick:P,className:"p-1.5 rounded hover:bg-neutral-100 text-neutral-500 hover:text-neutral-700 transition-colors",title:p("Expand file tree"),children:t.jsx(ru,{size:16})})}):t.jsx(t.Fragment,{children:t.jsx(hv,{workingDir:s,onFileSelect:R,selectedFilePath:D?.path||null,onCollapse:P},s||"no-working-dir")})}),!k&&t.jsx("div",{onMouseDown:T,className:se("w-1 shrink-0 cursor-col-resize transition-colors",_?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),t.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1 px-2 pt-2 border-b border-neutral-200 bg-neutral-100/80 overflow-x-auto shrink-0",children:[v.length===0?t.jsx("div",{className:"px-2 pb-2 text-xs text-neutral-500",children:p("No open files")}):v.map(z=>t.jsx(bv,{active:z.path===i,name:z.name,isDirty:z.isDirty,onClick:()=>l(z.path),onClose:$=>{$.stopPropagation(),M(z.path)}},z.path)),t.jsxs("div",{className:"ml-auto flex items-center gap-2 pb-2 pr-1",children:[o&&t.jsx("span",{className:"text-[11px] text-neutral-400",children:p("Read-only")}),f.isPending&&t.jsxs("span",{className:"flex items-center gap-2 text-xs text-neutral-500",children:[t.jsx(Ke,{size:14,className:"animate-spin"}),p("Saving")]}),D?.isDirty&&!f.isPending&&t.jsx("span",{className:"text-[11px] text-amber-600",children:p("Unsaved")})]})]}),t.jsx("div",{className:"flex-1 min-h-0 relative",children:s?D?D.isImage?t.jsx(vv,{workingDir:s,filePath:D.path}):m?t.jsx("div",{className:"h-full flex items-center justify-center text-red-600 text-sm",children:p("Failed to load editor.")}):d?t.jsxs(t.Fragment,{children:[t.jsx(Hp,{path:D.path,value:D.content,language:D.language,theme:"vs-light",height:"100%",onChange:o?void 0:z=>L(z??""),onMount:Y,options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",automaticLayout:!0,readOnly:o}}),I&&!D.loaded&&t.jsx("div",{className:"absolute inset-0 bg-white/60 flex items-center justify-center",children:t.jsxs("div",{className:"flex items-center gap-2 text-xs text-neutral-600",children:[t.jsx(Ke,{size:14,className:"animate-spin"}),p("Loading file...")]})}),B&&t.jsxs("div",{className:"absolute bottom-2 left-2 right-2 text-xs text-red-700 bg-red-50 border border-red-200 rounded px-2 py-1",children:[p("Failed to load file"),F instanceof Error?`: ${F.message}`:""]})]}):t.jsxs("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:[t.jsx(Ke,{size:14,className:"animate-spin mr-2"}),p("Loading editor...")]}):t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:p("Select a file from the tree to open.")}):t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:p("No workspace selected.")})})]})]})});function pi(e,s={}){const r=_s(g=>g.visibleContext),o=pl(e,r);return Bt({queryKey:de.git.changes(e||""),queryFn:()=>Ce.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e&&(s.enabled??!0),refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1})}function tc(e,s,r){const o=_s(p=>p.visibleContext),g=pl(e,o);return Bt({queryKey:de.git.diff(e||"",s||"",r),queryFn:()=>Ce.get("/git/diff",{params:{workingDir:e||"",path:s||"",type:r}}),enabled:!!e&&!!s,refetchInterval:g,refetchIntervalInBackground:!1,refetchOnWindowFocus:g?"always":!1,refetchOnReconnect:g?"always":!1})}function $n(e,s){return Bt({queryKey:de.git.commitFiles(e||"",s||""),queryFn:()=>Ce.get("/git/commit-files",{params:{workingDir:e||"",hash:s||""}}),enabled:!!e&&!!s})}function Un(e,s,r){return Bt({queryKey:de.git.commitDiff(e||"",s||"",r||""),queryFn:()=>Ce.get("/git/commit-diff",{params:{workingDir:e||"",hash:s||"",path:r||""}}),enabled:!!e&&!!s&&!!r})}function sc({isOpen:e,onClose:s,branchName:r,targetBranch:o,commitMessage:g,isPending:p,error:v,onConfirm:n}){const{t:i}=ce(),[l,d]=S.useState(""),[c,m]=S.useState(!1);S.useEffect(()=>{e&&(m(!1),d(g??""))},[e]),S.useEffect(()=>{c||!e||d(g??"")},[g,c,e]);const x=()=>{p||s()};return t.jsx(ns,{isOpen:e,onClose:x,title:i("提交变更"),className:"max-w-md",action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:x,disabled:p,className:"px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:i("取消")}),t.jsx("button",{onClick:()=>n(l.trim()||void 0),disabled:p,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium text-primary-foreground bg-primary hover:bg-primary/90 rounded-md transition-colors disabled:opacity-50",children:p?t.jsxs(t.Fragment,{children:[t.jsx(Ke,{size:14,className:"animate-spin"}),i("正在提交...")]}):t.jsxs(t.Fragment,{children:[t.jsx($r,{size:14}),i("确认提交")]})})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-muted font-mono text-xs text-muted-foreground",children:r}),t.jsx(Ua,{size:14,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-muted font-mono text-xs text-muted-foreground",children:o})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-foreground mb-1.5",children:i("提交消息")}),t.jsx("textarea",{value:l,onChange:w=>{m(!0),d(w.target.value)},placeholder:i("请描述本次修改的内容"),rows:4,className:"w-full px-3 py-2 rounded-md border border-input text-sm font-mono text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2 focus:ring-ring/30 focus:border-ring resize-none"}),t.jsx("p",{className:"mt-1.5 text-[11px] text-muted-foreground/70 leading-relaxed",children:i("建议以 feat、fix、docs、refactor、chore 开头,保持提交记录清晰。feat 新增功能,fix 修复问题,docs 文档更新,refactor 代码重构,chore 日常维护。")}),!l.trim()&&t.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground/70",children:i("留空将使用默认消息")})]}),v&&t.jsx("div",{className:"px-3 py-2 rounded-md bg-red-50 border border-red-200 text-sm text-red-700",children:v})]})})}function Es(e,s){const r=e[s];return typeof r=="string"&&r.length>0?r:void 0}function rc(e){if(!(e instanceof cn)||e.status!==409)return;const s=e.details;if(s.code!=="MERGE_CONFLICT"||s.conflictOp!==ir.REBASE&&s.conflictOp!==ir.MERGE||!Array.isArray(s.conflictedFiles)||!s.conflictedFiles.every(o=>typeof o=="string"))return;const r=s.mergeStrategy==="squash"||s.mergeStrategy==="no_ff"?s.mergeStrategy:void 0;return{conflictOp:s.conflictOp,conflictedFiles:s.conflictedFiles,mergeAborted:typeof s.mergeAborted=="boolean"?s.mergeAborted:void 0,mergeStrategy:r,sourceBranch:Es(s,"sourceBranch"),targetBranch:Es(s,"targetBranch"),sourceWorktreePath:Es(s,"sourceWorktreePath"),targetWorktreePath:Es(s,"targetWorktreePath"),sourceWorkspaceId:Es(s,"sourceWorkspaceId"),targetWorkspaceId:Es(s,"targetWorkspaceId")}}function Vo(e,s,r,o){const g=rc(e);if(g){r(g);return}o(e instanceof Error?e.message:s)}function ic({workspaceId:e,branchName:s,targetBranch:r,commitMessage:o,committedFileCount:g,onRefreshCommitMessage:p,onConflict:v,onResolveConflicts:n}){const{t:i}=ce(),{data:l,isLoading:d}=Pn(e),c=xl(),m=vl(),x=Ln(),[w,y]=S.useState(!1),[a,h]=S.useState(null);if(S.useEffect(()=>{w&&p?.()},[w,p]),d||!l)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground/70 border-b border-border/60",children:[t.jsx(Ke,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:i("正在检查工作区状态...")})]});const u=l.conflictedFiles.length>0,f=l.operation!=="idle",b=l.hasUncommittedChanges||l.untrackedCount>0,C=l.uncommittedCount+l.untrackedCount,k=!u&&!f&&!b,E=l.operation==="idle"&&l.ahead===0&&l.behind===0&&!b&&!u,_=()=>{h(null),c.mutate(e,{onError:T=>{Vo(T,i("更新失败,请稍后重试"),D=>v(D),h)}})},j=()=>{h(null),y(!0)},A=T=>{h(null),m.mutate({id:e,commitMessage:T},{onSuccess:()=>y(!1),onError:D=>{Vo(D,i("提交失败,请稍后重试"),W=>{y(!1),v(W)},h)}})},P=()=>{m.isPending||(y(!1),h(null))};return E?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground/70 border-b border-border/60",children:[t.jsx(sd,{size:13}),t.jsx("span",{className:"text-xs",children:i("当前分支还没有任何变更")})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"border-b border-border bg-background",children:t.jsxs("div",{className:"px-3 py-2",children:[a&&t.jsx("div",{className:"mb-2 px-2.5 py-1.5 rounded-md bg-red-50 border border-red-200 text-[11px] text-red-700",children:a}),b&&t.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2.5 py-1.5 rounded-md bg-amber-50 border border-amber-200 text-[11px] text-amber-800",children:[t.jsx(Yd,{size:12,className:"shrink-0"}),t.jsx("span",{children:i("{count} 个本地改动未处理,需要先整理后再继续",{count:C})})]}),u&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-amber-700",children:[t.jsx(ur,{size:13,className:"shrink-0"}),t.jsx("span",{children:i("{count} 个文件存在冲突,需要处理后继续",{count:l.conflictedFiles.length})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[t.jsx("button",{onClick:n,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-amber-800 bg-amber-100 hover:bg-amber-200 border border-amber-200 transition-colors",children:i("处理冲突")}),t.jsx("button",{onClick:()=>x.mutate(e),disabled:x.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs text-muted-foreground hover:bg-muted border border-border transition-colors disabled:opacity-50",children:x.isPending?i("正在撤销..."):i("撤销操作")})]})]}),f&&!u&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-info",children:[t.jsx(Ke,{size:13,className:"animate-spin shrink-0"}),t.jsx("span",{children:l.operation==="rebase"?i("正在同步源分支更新..."):i("正在提交变更...")})]}),t.jsxs("button",{onClick:()=>x.mutate(e),disabled:x.isPending,className:"flex items-center gap-1.5 ml-auto px-2.5 py-1 rounded-md text-xs text-muted-foreground hover:bg-muted border border-border transition-colors disabled:opacity-50",children:[t.jsx(rd,{size:12}),x.isPending?i("正在撤销..."):i("撤销操作")]})]}),!u&&!f&&(l.behind>0||l.ahead>0)&&t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[l.behind>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:i("源分支 {branch} 有 {count} 个更新",{branch:r,count:l.behind})}),t.jsxs("button",{onClick:_,disabled:!k||c.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-primary-foreground bg-primary hover:bg-primary/90 transition-colors disabled:opacity-50",children:[t.jsx(hr,{size:12}),c.isPending?i("正在同步..."):i("同步更新")]})]}),l.ahead>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:i("{count} 个文件变更,可以安全提交",{count:g??l.ahead})}),l.behind===0&&!b?t.jsxs("button",{onClick:j,disabled:m.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-primary-foreground bg-primary hover:bg-primary/90 transition-colors disabled:opacity-50",children:[t.jsx($r,{size:12}),i("提交变更")]}):t.jsxs("button",{disabled:!0,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs text-muted-foreground/60 bg-muted/60 border border-border cursor-not-allowed",title:i(b?"需要先处理本地改动":"需要先同步源分支更新"),children:[t.jsx($r,{size:12}),i("提交变更")]})]})]})]})}),t.jsx(sc,{isOpen:w,onClose:P,branchName:s,targetBranch:r,commitMessage:o,isPending:m.isPending,error:a,onConfirm:A})]})}const Oi=50,Bi=400,Go={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"},Qo={M:"bg-amber-500",A:"bg-emerald-500",D:"bg-red-500",R:"bg-blue-500"};function nc(e){const s=e.split("/");return s[s.length-1]||e}function Sv(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function wv(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?gt("{count}s ago",{count:r}):r<3600?gt("{count}m ago",{count:Math.floor(r/60)}):r<86400?gt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?gt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function Br(e,s){return e.kind==="working"?`${e.diffType}:${s}`:`${e.hash}:${s}`}const nn=({additions:e,deletions:s,className:r})=>e===void 0&&s===void 0?null:t.jsxs("span",{className:se("flex items-center gap-1 font-mono text-[11px] shrink-0",r),children:[e!==void 0&&e>0&&t.jsxs("span",{className:"text-emerald-600",children:["+",e]}),s!==void 0&&s>0&&t.jsxs("span",{className:"text-red-600",children:["-",s]}),(e??0)===0&&(s??0)===0&&t.jsx("span",{className:"text-muted-foreground/60",children:"0"})]}),Cv=({line:e,lineNum:s})=>{let r="",o="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?r="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?r="bg-destructive/10":e.startsWith("@@")?(r="bg-info/5",o="text-info"):(e.startsWith("diff ")||e.startsWith("index "))&&(o="text-muted-foreground/70"),t.jsxs("div",{className:se("flex",r),children:[t.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-muted-foreground/60 select-none border-r border-border/60",children:s}),t.jsx("span",{className:se("pl-2 whitespace-pre",o),children:e})]})},oc=({diff:e})=>{const{t:s}=ce(),[r,o]=S.useState(!1),g=S.useMemo(()=>e.split(`
72
- `),[e]);if(!e.trim())return t.jsx("div",{className:"py-6 text-center text-muted-foreground/70 text-xs",children:s("没有可显示的差异内容")});const p=!r&&g.length>Bi,v=p?g.slice(0,Bi):g;return t.jsxs("div",{className:"overflow-x-auto scrollbar-app-thin font-mono text-xs leading-5",children:[v.map((n,i)=>t.jsx(Cv,{line:n,lineNum:i+1},i)),p&&t.jsx("button",{type:"button",onClick:()=>o(!0),className:"w-full py-2 text-xs text-info hover:bg-info/5 transition-colors",children:s("还有 {count} 行变更被折叠,点击展开全部",{count:g.length-Bi})})]})},kv=({workingDir:e,path:s,diffType:r,enabled:o})=>{const{t:g}=ce(),{data:p,isLoading:v,isError:n}=tc(e,o?s:null,r);return!o||v?t.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[t.jsx(Ke,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:g("正在加载差异...")})]}):n?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:g("差异加载失败")}):t.jsx(oc,{diff:p?.diff||""})},Ev=({workingDir:e,hash:s,path:r,enabled:o})=>{const{t:g}=ce(),{data:p,isLoading:v,isError:n}=Un(e,o?s:null,o?r:null);return!o||v?t.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[t.jsx(Ke,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:g("正在加载差异...")})]}):n?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:g("差异加载失败")}):t.jsx(oc,{diff:p?.diff||""})},Fi=({entry:e,source:s,workingDir:r,flash:o,registerNode:g})=>{const[p,v]=S.useState(!1),[n,i]=S.useState(!1),l=S.useRef(null),d=Br(s,e.path);S.useEffect(()=>(g(d,l.current),()=>g(d,null)),[d,g]),S.useEffect(()=>{const x=l.current;if(!x||n)return;const w=new IntersectionObserver(y=>{y.some(a=>a.isIntersecting)&&(i(!0),w.disconnect())},{rootMargin:"300px 0px"});return w.observe(x),()=>w.disconnect()},[n]);const c=Go[e.status]||Go.M,m=Sv(e.path);return t.jsxs("div",{ref:l,"data-card-key":d,className:se("rounded-md border border-border bg-background overflow-hidden transition-shadow",o&&"ring-2 ring-info/40"),children:[t.jsxs("button",{type:"button",onClick:()=>v(x=>!x),className:"w-full flex items-center gap-2 px-3 py-2 bg-muted/40 hover:bg-muted/70 transition-colors text-left",children:[p?t.jsx(Mt,{size:13,className:"text-muted-foreground/70 shrink-0"}):t.jsx(wt,{size:13,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:se("w-4 h-4 flex items-center justify-center text-[11px] font-semibold border rounded-sm shrink-0",c),children:e.status}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:nc(e.path)}),m&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate",children:m}),t.jsx("span",{className:"ml-auto"}),t.jsx(nn,{additions:e.additions,deletions:e.deletions})]}),!p&&t.jsx("div",{className:"border-t border-border/60",children:s.kind==="working"?t.jsx(kv,{workingDir:r,path:e.path,diffType:s.diffType,enabled:n}):t.jsx(Ev,{workingDir:r,hash:s.hash,path:e.path,enabled:n})})]})};function jv(e){const s={name:"",path:"",dirs:new Map,files:[]};for(const r of e){const o=r.path.split("/");let g=s;for(let p=0;p<o.length-1;p++){const v=o[p];g.dirs.has(v)||g.dirs.set(v,{name:v,path:g.path?`${g.path}/${v}`:v,dirs:new Map,files:[]}),g=g.dirs.get(v)}g.files.push(r)}return ac(s)}function ac(e){const s=new Map;for(const r of e.dirs.values()){let o=ac(r);for(;o.dirs.size===1&&o.files.length===0;){const g=[...o.dirs.values()][0];o={...g,name:`${o.name}/${g.name}`}}s.set(o.name,o)}return{...e,dirs:s}}const Nv=({dir:e,depth:s,activeKey:r,onSelect:o})=>{const[g,p]=S.useState(!0);return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>p(v=>!v),className:"flex items-center gap-1.5 w-full px-2 py-1 rounded-sm hover:bg-muted/60 text-left",style:{paddingLeft:8+s*12},children:[g?t.jsx(ii,{size:12,className:"text-muted-foreground/70 shrink-0"}):t.jsx($a,{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(lc,{node:e,depth:s+1,activeKey:r,onSelect:o})]})},lc=({node:e,depth:s,activeKey:r,onSelect:o})=>t.jsxs(t.Fragment,{children:[[...e.dirs.values()].sort((g,p)=>g.name.localeCompare(p.name)).map(g=>t.jsx(Nv,{dir:g,depth:s,activeKey:r,onSelect:o},g.path)),e.files.slice().sort((g,p)=>g.path.localeCompare(p.path)).map(g=>{const p=r===g.cardKey;return t.jsxs("button",{type:"button",onClick:()=>o(g),className:se("flex items-center gap-1.5 w-full px-2 py-1 rounded-sm text-left",p?"bg-muted":"hover:bg-muted/60"),style:{paddingLeft:8+s*12},title:g.path,children:[t.jsx("span",{className:se("w-1.5 h-1.5 rounded-full shrink-0",Qo[g.status]||Qo.M)}),t.jsx("span",{className:se("text-xs truncate",p?"text-foreground font-medium":"text-foreground/90"),children:nc(g.path)})]},g.cardKey)})]}),Rv=({workingDir:e,selectedHash:s,onSelectCommit:r})=>{const{t:o}=ce(),{data:g,isLoading:p,fetchNextPage:v,hasNextPage:n,isFetchingNextPage:i}=wn({queryKey:de.git.log(e),queryFn:({pageParam:d=0})=>Ce.get("/git/log",{params:{workingDir:e,limit:String(Oi),skip:String(d)}}),initialPageParam:0,getNextPageParam:(d,c)=>d.commits.length<Oi?void 0:c.length*Oi}),l=g?.pages.flatMap(d=>d.commits)||[];return p?t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 text-muted-foreground/70 text-[11px]",children:[t.jsx(Ke,{size:11,className:"animate-spin"}),t.jsx("span",{children:o("正在加载提交记录...")})]}):l.length===0?t.jsx("div",{className:"px-3 py-2 text-[11px] text-muted-foreground/60",children:o("暂无提交记录")}):t.jsxs("div",{className:"space-y-px px-1.5 pb-1.5",children:[l.map(d=>{const c=s===d.hash;return t.jsxs("button",{type:"button",onClick:()=>r(d),className:se("flex items-start gap-1.5 w-full px-1.5 py-1 rounded-sm text-left group",c?"bg-muted":"hover:bg-muted/60"),title:d.message,children:[t.jsx("span",{className:se("w-1.5 h-1.5 rounded-full mt-1.5 shrink-0 transition-colors",c?"bg-brand":"bg-border group-hover:bg-muted-foreground/60")}),t.jsxs("span",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:se("block text-xs truncate",c?"text-foreground font-medium":"text-foreground/90"),children:d.message}),t.jsxs("span",{className:"block text-[11px] text-muted-foreground/70 truncate",children:[t.jsx("span",{className:"font-mono",children:d.shortHash})," · ",d.author," · ",wv(d.timestamp)]})]})]},d.hash)}),n&&t.jsx("button",{type:"button",onClick:()=>v(),disabled:i,className:"w-full py-1.5 text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted/60 rounded-sm transition-colors flex items-center justify-center gap-1.5",children:i?t.jsxs(t.Fragment,{children:[t.jsx(Ke,{size:11,className:"animate-spin"})," ",o("正在加载...")]}):o("加载更多提交")})]})},Av=({workingDir:e,workspaceId:s,branchName:r,targetBranch:o,commitMessage:g,canRunGitOperations:p,onRefreshCommitMessage:v,onConflict:n,onResolveConflicts:i})=>{const{t:l}=ce(),[d,c]=S.useState({kind:"overview"}),[m,x]=S.useState(""),[w,y]=S.useState(null),[a,h]=S.useState(null),{data:u,isLoading:f,isError:b}=pi(e),C=d.kind==="commit"?d.commit.hash:null,{data:k,isLoading:E}=$n(e,C),_=S.useRef(new Map),j=S.useRef(null),A=S.useRef(null),P=S.useCallback((z,$)=>{$?_.current.set(z,$):_.current.delete(z)},[]),{uncommitted:T,committed:D,commitFiles:W}=S.useMemo(()=>{const z=N=>!m.trim()||N.path.toLowerCase().includes(m.trim().toLowerCase());if(d.kind==="commit"){const N={kind:"commit",hash:d.commit.hash},H=(k?.files||[]).filter(z).map(X=>({...X,cardKey:Br(N,X.path)}));return{uncommitted:[],committed:[],commitFiles:H}}const $=(u?.uncommitted||[]).filter(z).map(N=>({...N,cardKey:Br({kind:"working",diffType:"uncommitted"},N.path)})),q=(u?.committed||[]).filter(z).map(N=>({...N,cardKey:Br({kind:"working",diffType:"committed"},N.path)}));return{uncommitted:$,committed:q,commitFiles:[]}},[d,u,k,m]),I=d.kind==="commit"?W:[...T,...D],B=S.useMemo(()=>jv(I),[I]),F=S.useMemo(()=>{let z=0,$=0;for(const q of I)z+=q.additions??0,$+=q.deletions??0;return{additions:z,deletions:$,files:I.length}},[I]),R=S.useCallback(()=>{const z=j.current;if(!z)return;const $=z.getBoundingClientRect().top;let q=null,N=Number.NEGATIVE_INFINITY;for(const[H,X]of _.current){const K=X.getBoundingClientRect().top-$;K<=48&&K>N&&(N=K,q=H)}if(!q){let H=null,X=Number.POSITIVE_INFINITY;for(const[K,ne]of _.current){const te=ne.getBoundingClientRect().top-$;te<X&&(X=te,H=K)}q=H}y(q)},[]);S.useEffect(()=>{const z=j.current;if(!z)return;let $=0;const q=()=>{cancelAnimationFrame($),$=requestAnimationFrame(R)};return z.addEventListener("scroll",q,{passive:!0}),()=>{z.removeEventListener("scroll",q),cancelAnimationFrame($)}},[R]);const M=S.useCallback(z=>{const $=_.current.get(z.cardKey);$&&($.scrollIntoView({behavior:"smooth",block:"start"}),y(z.cardKey),h(z.cardKey),A.current&&clearTimeout(A.current),A.current=setTimeout(()=>h(null),1200))},[]),L=S.useCallback(z=>{c($=>$.kind==="commit"&&$.commit.hash===z.hash?{kind:"overview"}:{kind:"commit",commit:z}),x(""),y(null),j.current?.scrollTo({top:0})},[]),O=S.useCallback(()=>{c({kind:"overview"}),x(""),y(null),j.current?.scrollTo({top:0})},[]);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm bg-background h-full",children:l("未选择工作区")});const U=p&&s&&r&&o,Y=d.kind==="commit"?E:f;return t.jsxs("div",{className:"flex h-full w-full min-w-0 flex-col bg-background",children:[U&&n&&i&&t.jsx(ic,{workspaceId:s,branchName:r,targetBranch:o,commitMessage:g,committedFileCount:u?.committed?.length,onRefreshCommitMessage:v,onConflict:n,onResolveConflicts:i}),t.jsx("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border/60 shrink-0 min-h-[37px]",children:d.kind==="overview"?t.jsxs(t.Fragment,{children:[t.jsx(Fs,{size:14,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:l("代码审查")}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:l("{count} 个文件",{count:F.files})}),t.jsx(nn,{additions:F.additions,deletions:F.deletions}),r&&o&&t.jsxs("span",{className:"ml-auto flex items-center gap-1 text-[11px] text-muted-foreground/70 font-mono truncate",children:[t.jsx("span",{className:"truncate",children:r}),t.jsx(Ls,{size:10,className:"rotate-180 shrink-0"}),t.jsx("span",{className:"truncate",children:o})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",onClick:O,className:"flex items-center gap-1 px-1.5 py-0.5 -ml-1.5 rounded-sm text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors shrink-0",children:[t.jsx(Ls,{size:12}),l("全部变更")]}),t.jsx("span",{className:"text-muted-foreground/40 text-xs",children:"/"}),t.jsx("span",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:d.commit.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate",children:d.commit.message}),t.jsx(nn,{className:"ml-auto",additions:F.additions,deletions:F.deletions})]})}),t.jsxs("div",{className:"flex flex-1 min-h-0",children:[t.jsx("div",{ref:j,className:"flex-1 min-w-0 overflow-y-auto scrollbar-app-thin",children:Y?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"}),t.jsxs("div",{className:"p-3 space-y-2",children:[t.jsx("div",{className:"h-3 w-2/3 bg-muted animate-pulse rounded-sm"}),t.jsx("div",{className:"h-3 w-1/2 bg-muted animate-pulse rounded-sm"}),t.jsx("div",{className:"h-3 w-3/4 bg-muted animate-pulse rounded-sm"})]})]},z))}):b&&d.kind==="overview"?t.jsx("div",{className:"flex-1 flex items-center justify-center py-16 text-destructive text-sm",children:l("变更加载失败")}):I.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted-foreground/60",children:[t.jsx(Ur,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:m.trim()?l("没有匹配筛选条件的文件"):d.kind==="commit"?l("该提交没有文件变更"):l("没有待审查的变更")})]}):d.kind==="commit"?t.jsx("div",{className:"p-3 space-y-3",children:W.map(z=>t.jsx(Fi,{entry:z,source:{kind:"commit",hash:d.commit.hash},workingDir:e,flash:a===z.cardKey,registerNode:P},z.cardKey))}):t.jsxs("div",{className:"p-3 space-y-4",children:[T.length>0&&t.jsxs("section",{children:[t.jsxs("div",{className:"sticky top-0 z-10 -mx-3 px-5 py-1.5 bg-background/95 backdrop-blur-sm",children:[t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:l("未提交")}),t.jsx("span",{className:"ml-2 text-[11px] text-muted-foreground/70",children:T.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:T.map(z=>t.jsx(Fi,{entry:z,source:{kind:"working",diffType:"uncommitted"},workingDir:e,flash:a===z.cardKey,registerNode:P},z.cardKey))})]}),D.length>0&&t.jsxs("section",{children:[t.jsxs("div",{className:"sticky top-0 z-10 -mx-3 px-5 py-1.5 bg-background/95 backdrop-blur-sm",children:[t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:l("已提交")}),t.jsx("span",{className:"ml-2 text-[11px] text-muted-foreground/70",children:D.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:D.map(z=>t.jsx(Fi,{entry:z,source:{kind:"working",diffType:"committed"},workingDir:e,flash:a===z.cardKey,registerNode:P},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.jsxs("div",{className:"relative",children:[t.jsx(pn,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground/60"}),t.jsx("input",{value:m,onChange:z=>x(z.target.value),placeholder:l("筛选文件..."),className:"w-full pl-6.5 pr-2 py-1.5 rounded-md border border-input bg-background text-xs text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2 focus:ring-ring/30 focus:border-ring"})]})}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin px-1.5 pb-1.5 min-h-0",children:I.length===0?t.jsx("div",{className:"px-2 py-3 text-[11px] text-muted-foreground/60",children:m.trim()?l("无匹配文件"):l("暂无变更文件")}):t.jsx(lc,{node:B,depth:0,activeKey:w,onSelect:M})}),t.jsxs("div",{className:"shrink-0 border-t border-border/60 max-h-[40%] flex flex-col min-h-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 shrink-0",children:[t.jsx(Is,{size:12,className:"text-muted-foreground"}),t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:l("提交记录")})]}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin min-h-0",children:t.jsx(Rv,{workingDir:e,selectedHash:C,onSelectCommit:L})})]})]})]})]})},zi=50,Zo={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"};function Tv(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?gt("{count}s ago",{count:r}):r<3600?gt("{count}m ago",{count:Math.floor(r/60)}):r<86400?gt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?gt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function Mv(e){const s=e.split("/");return s[s.length-1]||e}function Dv(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}const Pv=({line:e,lineNum:s})=>{let r="",o="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?r="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?r="bg-destructive/10":e.startsWith("@@")?(r="bg-info/5",o="text-info"):(e.startsWith("diff ")||e.startsWith("index "))&&(o="text-muted-foreground/70"),t.jsxs("div",{className:se("flex",r),children:[t.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-muted-foreground/60 select-none border-r border-border/60",children:s}),t.jsx("span",{className:se("pl-2 whitespace-pre",o),children:e})]})},Lv=({workingDir:e,hash:s,filePath:r})=>{const{t:o}=ce(),{data:g,isLoading:p,isError:v}=Un(e,s,r);if(p)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:[t.jsx(Ke,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(v)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive text-xs",children:o("Failed to load diff.")});const n=g?.diff||"";if(!n.trim())return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground/70 text-xs",children:o("No diff content available.")});const i=n.split(`
73
- `);return t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin font-mono text-xs leading-5",children:i.map((l,d)=>t.jsx(Pv,{line:l,lineNum:d+1},d))})},Iv=({workingDir:e,hash:s,selectedPath:r,onSelectFile:o})=>{const{t:g}=ce(),{data:p,isLoading:v}=$n(e,s);if(v)return t.jsxs("div",{className:"pl-7 py-1 text-xs text-muted-foreground/70 flex items-center gap-1",children:[t.jsx(Ke,{size:12,className:"animate-spin"}),t.jsx("span",{children:g("Loading...")})]});const n=p?.files||[];return n.length===0?t.jsx("div",{className:"pl-7 py-1 text-xs text-muted-foreground/70",children:g("No files changed")}):t.jsx("div",{className:"pl-7 pb-1 space-y-0.5",children:n.map(i=>{const l=Zo[i.status]||Zo.M,d=Dv(i.path);return t.jsxs("button",{type:"button",onClick:c=>{c.stopPropagation(),o(i.path)},className:se("flex items-center gap-2 px-1.5 py-1 rounded-sm cursor-pointer w-full text-left",r===i.path?"bg-muted":"hover:bg-muted/60"),children:[t.jsx("span",{className:se("w-4 h-4 flex items-center justify-center text-[11px] font-semibold border rounded-sm shrink-0",l),children:i.status}),t.jsx("span",{className:"text-xs text-foreground truncate",children:Mv(i.path)}),d&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate ml-auto shrink-0",children:d})]},i.path)})})},Ov=({workingDir:e})=>{const{t:s}=ce(),r=_s(E=>E.visibleContext),o=sf(e,r),{data:g,isLoading:p,isError:v,fetchNextPage:n,hasNextPage:i,isFetchingNextPage:l}=wn({queryKey:de.git.log(e||""),queryFn:({pageParam:E=0})=>Ce.get("/git/log",{params:{workingDir:e||"",limit:String(zi),skip:String(E)}}),initialPageParam:0,getNextPageParam:(E,_)=>E.commits.length<zi?void 0:_.length*zi,enabled:!!e,refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1}),d=g?.pages.flatMap(E=>E.commits)||[],[c,m]=S.useState(null),[x,w]=S.useState(null),[y,a]=S.useState(280),[h,u]=S.useState(!1),f=S.useCallback(E=>{E.preventDefault(),u(!0);const _=E.clientX,j=y,A=T=>{const D=Math.min(480,Math.max(180,j+(T.clientX-_)));a(D)},P=()=>{u(!1),document.removeEventListener("mousemove",A),document.removeEventListener("mouseup",P)};document.addEventListener("mousemove",A),document.addEventListener("mouseup",P)},[y]),b=E=>{c===E?(m(null),w(null)):(m(E),w(null))},C=S.useRef(null);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm bg-background h-full",children:s("No workspace selected.")});if(p)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground bg-background h-full",children:[t.jsx(Ke,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading history...")})]});if(v)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive text-sm bg-background h-full",children:s("Failed to load history.")});if(d.length===0)return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-12 text-muted-foreground/60 bg-background h-full",children:[t.jsx(Is,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:s("No commit history")})]});const k=d.find(E=>E.hash===c);return t.jsxs("div",{className:"flex h-full bg-background",style:h?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsxs("div",{className:"border-r border-border flex flex-col shrink-0",style:{width:y},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(Is,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:s("History")}),t.jsx("span",{className:"text-[11px] bg-muted px-1.5 py-0.5 rounded-full text-muted-foreground",children:d.length})]})}),t.jsxs("div",{ref:C,className:"flex-1 overflow-auto scrollbar-app-thin p-1.5",children:[d.map(E=>{const _=c===E.hash;return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>b(E.hash),className:se("flex items-start gap-2 px-2 py-1.5 rounded-sm cursor-pointer w-full text-left group",_?"bg-muted":"hover:bg-muted/60"),children:[t.jsx("div",{className:"flex flex-col items-center shrink-0 pt-1",children:t.jsx("div",{className:se("w-2 h-2 rounded-full shrink-0 transition-colors",_?"bg-brand":"bg-border group-hover:bg-muted-foreground/60")})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:E.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate flex-1",children:E.message}),t.jsx(Mt,{size:12,className:se("shrink-0 text-muted-foreground/70 transition-transform",_&&"rotate-90")})]}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:E.author}),t.jsx("span",{className:"text-[11px] text-muted-foreground/70",children:Tv(E.timestamp)})]})]})]}),_&&t.jsxs(t.Fragment,{children:[E.body&&t.jsx("div",{className:"pl-7 pr-2 py-1.5 text-[11px] text-muted-foreground whitespace-pre-wrap leading-5 border-l-2 border-border ml-3",children:E.body}),t.jsx(Iv,{workingDir:e,hash:E.hash,selectedPath:x,onSelectFile:w})]})]},E.hash)}),i&&t.jsx("button",{type:"button",onClick:()=>n(),disabled:l,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:l?t.jsxs(t.Fragment,{children:[t.jsx(Ke,{size:12,className:"animate-spin"})," ",s("Loading...")]}):s("Load more")})]})]}),t.jsx("div",{onMouseDown:f,className:se("w-1 shrink-0 cursor-col-resize transition-colors",h?"bg-info/60":"bg-transparent hover:bg-info/30")}),t.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:x&&c?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"px-3 py-2 border-b border-border/60 flex items-center gap-2 shrink-0",children:[t.jsx(Ur,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:x}),t.jsxs("span",{className:"text-[11px] text-muted-foreground/70",children:["(",k?.shortHash,")"]})]}),t.jsx(Lv,{workingDir:e,hash:c,filePath:x})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground/60",children:t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(Ur,{size:28}),t.jsx("span",{className:"text-xs",children:s(c?"Select a file to view diff":"Select a commit to view changes")})]})})})]})},Jo=dr();function Bv(e){if(!Jo)return e;try{const s=new URL(Jo);return new URL(e,s.origin).toString()}catch{return e}}function cc(e){return{...e,viewUrl:e.viewUrl?Bv(e.viewUrl):null}}function Fv(e){return Bt({queryKey:de.previews.status(e??""),queryFn:async()=>{const s=await Ce.get(`/previews/${e}/status`);return cc(s)},enabled:!!e,refetchOnWindowFocus:!1})}function zv(e){const s=bt();return Ft({mutationFn:async r=>{const o=await Ce.put(`/previews/${e}/config`,{target:r});return cc(o)},onSuccess:r=>{e&&(s.setQueryData(de.previews.status(e),r),s.invalidateQueries({queryKey:de.workspaces.all}))}})}function Wv(){return window.location.protocol==="https:"?"remote":"local"}function Hv(e,s){const[r,o]=S.useState(null),[g,p]=S.useState(!1),[v,n]=S.useState(null),[i,l]=S.useState(0);return S.useEffect(()=>{if(!e||!s?.ready||!s.target){o(null),p(!1),n(null);return}let d=!1,c=null,m=null;o(null);const x=y=>{Ce.delete(`/previews/${e}/sessions/${y}`).catch(()=>{})};return(async()=>{p(!0),n(null);try{const y={mode:Wv(),localHostname:window.location.hostname},a=await Ce.post(`/previews/${e}/sessions`,y);if(d){x(a.id);return}c=a.id,o(a),m=window.setInterval(async()=>{if(c)try{const h=await Ce.post(`/previews/${e}/sessions/${c}/heartbeat`);d||(o(h),n(null))}catch(h){!d&&h instanceof cn&&h.status===404?l(u=>u+1):d||n(h instanceof Error?h:new Error("Preview session heartbeat failed"))}},3e4)}catch(y){d||(o(null),n(y instanceof Error?y:new Error("Failed to open preview session")))}finally{d||p(!1)}})(),()=>{d=!0,m!==null&&window.clearInterval(m),c&&x(c)}},[i,s?.ready,s?.target,e]),{session:r,isOpening:g,error:v,retry:()=>l(d=>d+1)}}const $v="agent-tower-preview",Uv="agent-tower-preview-host";function qv(){return"3000, localhost:3000, http://127.0.0.1:5173"}function Kv(e){if(!e)return null;try{return new URL(e).origin}catch{return null}}function Xv(e){return t.jsx(Yv,{...e},e.workspaceId??"no-workspace")}function Yv({workspaceId:e,readOnly:s,navigationRequest:r,onNavigationRequestHandled:o}){const{t:g}=ce(),{data:p,isLoading:v,refetch:n,isFetching:i}=Fv(e),l=zv(e),{session:d,isOpening:c,error:m,retry:x}=Hv(e,p),w=S.useRef(null),y=S.useRef(null),a=S.useRef(null),h=S.useRef(null),u=S.useRef(null),f=S.useRef(null),[b,C]=S.useState(0),[k,E]=S.useState({target:null,address:"",iframeSrc:null,isFrameLoading:!1}),_=Kv(d?.viewUrl),j=p&&k.target!==p.target?{target:p.target,address:p.target??"",iframeSrc:null,isFrameLoading:!1}:p&&!p.ready&&k.iframeSrc?{...k,iframeSrc:null,isFrameLoading:!1}:k,A=S.useCallback(F=>{E(R=>({...p&&R.target!==p.target?{target:p.target,address:p.target??"",iframeSrc:null,isFrameLoading:!1}:R,...F}))},[p]);S.useEffect(()=>{if(!d||d.target!==p?.target)return;const F=u.current!==_;u.current=_,E(R=>{const M=r&&f.current!==r.id?Ar(r.url,d.target,d.viewUrl):null;if(!F&&R.iframeSrc&&R.target===d.target&&M?.kind!=="proxy")return R;let L=R.iframeSrc;if(M?.kind==="proxy")L=M.url;else if(!L||R.target!==d.target||F){const U=a.current;if(U)L=pd(d.viewUrl,U);else{const Y=Ar(R.address||d.target,d.target,d.viewUrl);L=Y?.kind==="proxy"?Y.url:d.viewUrl}}a.current=null;const O=h.current;return O&&!O.closed&&L&&O.location.replace(L),h.current=null,{target:d.target,address:M?.kind==="proxy"?r?.url??R.address:R.address||d.target,iframeSrc:L,isFrameLoading:!!L}})},[r,d,_,p?.target]),S.useEffect(()=>()=>{h.current?.close()},[]);const P=S.useCallback(async(F,R=!1)=>{const M=Ar(F,p?.target??null,d?.viewUrl??null);if(!M||!e)return;if(M.kind==="proxy"){if(R){window.open(M.url,"_blank","noopener,noreferrer");return}E({target:p?.target??null,address:F,iframeSrc:M.url,isFrameLoading:!0});return}if(s)return;const L=R?window.open("about:blank","_blank"):null;L&&(L.opener=null);try{a.current=M.path,h.current=L;const O=await l.mutateAsync(M.target);E({target:O.target,address:F.trim(),iframeSrc:null,isFrameLoading:!!O.ready}),C(U=>U+1),rt.success(g("Preview target saved")),O.ready||(h.current?.close(),h.current=null)}catch(O){h.current?.close(),h.current=null,a.current=null;const U=O instanceof Error?O.message:g("Failed to save preview target");rt.error(U)}},[d?.viewUrl,s,p?.target,g,l,e]);S.useEffect(()=>{if(!r||v||f.current===r.id)return;const F=window.setTimeout(()=>{f.current=r.id,o?.(r.id),P(r.url)},0);return()=>window.clearTimeout(F)},[v,P,r,o]),S.useEffect(()=>{const F=R=>{if(R.source!==w.current?.contentWindow)return;const M=R.data;if(!(!M||M.source!==$v)){if(M.type==="location"&&typeof M.href=="string"){const L=gd(p?.target??null,d?.viewUrl??null,M.href,window.location.href);L&&document.activeElement!==y.current&&A({target:p?.target??j.target,address:L,isFrameLoading:!1});return}M.type==="navigate-loopback"&&typeof M.href=="string"&&P(M.href,M.newTab===!0)}};return window.addEventListener("message",F),()=>window.removeEventListener("message",F)},[j.target,P,A,d?.viewUrl,p?.target]);const T=F=>{w.current?.contentWindow?.postMessage({source:Uv,action:F},"*")},D=F=>{F.preventDefault(),P(j.address)},W=async()=>{const F=await n();if(!F.data?.ready){A({target:F.data?.target??j.target,iframeSrc:null,isFrameLoading:!1});return}if(!d||!j.iframeSrc){x();return}A({isFrameLoading:!0}),T("reload")},I=()=>{if(!d?.viewUrl)return;const F=Ar(j.address||d.target,d.target,d.viewUrl),R=F?.kind==="proxy"?F.url:d.viewUrl;window.open(R,"_blank","noopener,noreferrer")};if(!e)return t.jsx("div",{className:"h-full flex items-center justify-center bg-white text-sm text-neutral-500",children:g("No active workspace.")});const B=v||i||l.isPending||c;return t.jsxs("div",{className:"h-full flex flex-col bg-white",children:[t.jsxs("div",{className:"shrink-0 border-b border-neutral-200 bg-neutral-50 px-2 py-2",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(Te,{type:"button",size:"icon-sm",variant:"ghost",onClick:()=>T("back"),disabled:!j.iframeSrc,title:g("Back"),"aria-label":g("Back"),children:t.jsx(Ls,{})}),t.jsx(Te,{type:"button",size:"icon-sm",variant:"ghost",onClick:()=>T("forward"),disabled:!j.iframeSrc,title:g("Forward"),"aria-label":g("Forward"),children:t.jsx(Ua,{})}),t.jsx(Te,{type:"button",size:"icon-sm",variant:"ghost",onClick:j.isFrameLoading?()=>{T("stop"),A({isFrameLoading:!1})}:W,disabled:!j.isFrameLoading&&i,title:j.isFrameLoading?g("Stop loading"):g("Refresh preview"),"aria-label":j.isFrameLoading?g("Stop loading"):g("Refresh preview"),children:j.isFrameLoading?t.jsx(Yt,{}):i?t.jsx(Ke,{className:"animate-spin"}):t.jsx(hr,{})}),t.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:D,children:[t.jsx(Hd,{className:"pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-neutral-400"}),t.jsx("input",{ref:y,value:j.address,onChange:F=>A({address:F.target.value}),onKeyDown:F=>{F.key==="Enter"&&F.nativeEvent.isComposing&&F.preventDefault()},disabled:s||l.isPending,placeholder:qv(),"aria-label":g("Preview address"),className:"h-8 w-full min-w-0 rounded-md border border-neutral-200 bg-white pl-8 pr-2.5 text-xs text-neutral-800 outline-none transition-colors placeholder:text-neutral-400 focus:border-neutral-400 disabled:bg-neutral-100 disabled:text-neutral-400"})]}),t.jsx(Te,{type:"button",size:"icon-sm",variant:"ghost",onClick:I,disabled:!j.iframeSrc,title:g("Open preview in new tab"),"aria-label":g("Open preview in new tab"),children:t.jsx(ln,{})})]}),t.jsxs("div",{className:"mt-1 flex min-h-4 items-center justify-between gap-2 px-1 text-[11px] leading-4",children:[t.jsx("span",{className:"truncate text-neutral-500",children:B?g("Checking preview target..."):m?m.message:p?.ready?`${g("Proxying")} ${p.target}`:p?.configured?`${g("Preview target is not reachable")}${p.error?`: ${p.error}`:""}`:g("Enter a local preview URL on the Agent Tower machine.")}),t.jsx("span",{className:"shrink-0 text-neutral-400",children:g("Loopback only")})]})]}),t.jsx("div",{className:"relative flex-1 min-h-0 bg-white",children:j.iframeSrc?t.jsx("iframe",{ref:w,src:j.iframeSrc,title:g("Preview"),className:"absolute inset-0 h-full w-full border-0 bg-white",sandbox:"allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts",allow:"clipboard-read; clipboard-write; fullscreen",onLoad:()=>A({isFrameLoading:!1})},b):t.jsx("div",{className:"absolute inset-0 flex items-center justify-center px-4 text-center text-sm text-neutral-500",children:p?.configured?p.ready&&c?g("Checking preview target..."):g("Start the preview server, then refresh."):g("Configure a local preview target to display it here.")})})]})}function Vv(e){switch(e){case At.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case At.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case At.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case At.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function ea(e){switch(e){case"Main":return"border-indigo-200 bg-indigo-50 text-indigo-700";case"Child":return"border-cyan-200 bg-cyan-50 text-cyan-700";default:return"border-neutral-200 bg-neutral-50 text-neutral-600"}}function Gv(e){return e.length<=34?e:`...${e.slice(-31)}`}function dc({workspaces:e,teamRun:s,selectedWorkspaceId:r,onSelectWorkspace:o,disabled:g,className:p,buttonClassName:v}){const{t:n}=ce(),[i,l]=S.useState(!1),d=S.useRef(null),c=S.useMemo(()=>Bn(e,s),[e,s]),m=c.find(x=>x.workspace.id===r)??c[0];return S.useEffect(()=>{if(!i)return;const x=w=>{d.current&&!d.current.contains(w.target)&&l(!1)};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[i]),c.length<=1?null:t.jsxs("div",{ref:d,className:se("relative",p),children:[t.jsxs("button",{type:"button",onClick:()=>l(x=>!x),disabled:g,className:se("inline-flex h-8 max-w-[340px] items-center gap-2 rounded-md border border-neutral-200 bg-white px-2.5 text-left text-xs text-neutral-700 transition-colors hover:border-neutral-300 hover:bg-neutral-50 disabled:cursor-not-allowed disabled:opacity-50",v),title:n("Workspace"),children:[t.jsx(Ps,{size:14,className:"shrink-0 text-neutral-500"}),t.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",ea(m.roleLabel)),children:n(m.roleLabel)}),t.jsx("span",{className:"min-w-0 truncate font-medium text-neutral-900",children:n(m.displayName)}),t.jsx("span",{className:"min-w-0 truncate font-mono text-[11px] text-neutral-500",children:Gv(Os(m.workspace))}),t.jsx(wt,{size:13,className:se("shrink-0 text-neutral-400 transition-transform",i&&"rotate-180")})]}),i&&t.jsx("div",{className:"absolute left-0 top-full z-50 mt-2 w-[420px] max-w-[calc(100vw-2rem)] rounded-lg border border-neutral-200 bg-white py-1.5 shadow-lg",children:c.map(x=>{const w=x.workspace.id===m.workspace.id;return t.jsxs("button",{type:"button",onClick:()=>{o(x.workspace.id),l(!1)},className:se("flex w-full items-start gap-2 px-3 py-2 text-left transition-colors hover:bg-neutral-50",w&&"bg-neutral-50"),children:[t.jsx("div",{className:"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-md border border-neutral-200 bg-white text-neutral-500",children:w?t.jsx(Vt,{size:13}):t.jsx(Da,{size:13})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:n(x.displayName)}),t.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",ea(x.roleLabel)),children:n(x.roleLabel)}),t.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",Vv(x.workspace.status)),children:x.workspace.status})]}),t.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-neutral-500",children:Os(x.workspace)}),t.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[x.ownerName&&t.jsxs("span",{children:[n("Owner"),": ",x.ownerName]}),x.parentBranchName&&t.jsxs("span",{children:[n("Parent"),": ",x.parentBranchName]}),t.jsx("span",{children:x.workspace.id.slice(0,8)})]})]})]},x.workspace.id)})})]})}const Qv=[{key:"review",label:"Changes",icon:t.jsx(Fs,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(ri,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(Fr,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(Ma,{size:14})}],Zv=[{key:"history",label:"History",icon:t.jsx(Is,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(ri,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(Fr,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(Ma,{size:14})}],Jv=({active:e,onClick:s,icon:r,label:o})=>t.jsxs("button",{type:"button",onClick:s,className:se("flex shrink-0 items-center gap-2 px-4 py-2 text-xs font-medium transition-all rounded-t-md border-t border-x -mb-px whitespace-nowrap",e?"bg-white border-neutral-200 text-neutral-900 shadow-[0_-2px_6px_rgba(0,0,0,0.02)] z-10":"bg-transparent border-transparent text-neutral-500 hover:text-neutral-700 hover:bg-neutral-200/50"),children:[r,t.jsx("span",{children:o})]}),e0=({active:e,onClick:s,icon:r,label:o})=>t.jsx("button",{type:"button",onClick:s,title:o,"aria-label":o,"aria-pressed":e,className:se("flex h-9 w-9 items-center justify-center rounded-lg border text-muted-foreground transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",e?"border-neutral-900 bg-neutral-900 text-white shadow-sm":"border-transparent hover:border-border hover:bg-background hover:text-foreground"),children:r}),uc=ae.memo(function({className:s,sessionId:r,workspaceId:o,workingDir:g,projectId:p,hideChanges:v,gitAvailable:n=!0,readOnly:i,repoDeleted:l,teamRun:d,teamStatus:c,gitProps:m,workspaces:x,selectedWorkspaceId:w,onSelectWorkspace:y,variant:a="tabs",expanded:h,onExpandedChange:u,minContentWidth:f=520,tabRef:b,previewRequest:C,onPreviewRequestHandled:k}){const{t:E}=ce(),_=_s(G=>G.setVisibleContext),j=a==="rail",[A,P]=S.useState(!1),T=j?h??A:!0,D=S.useCallback(G=>{h===void 0&&P(G),u?.(G)},[h,u]),W=S.useMemo(()=>{const G=v?Zv:Qv,pe=n?G:G.filter(Ae=>Ae.key!=="review"&&Ae.key!=="history"),ie=i?pe.filter(Ae=>Ae.key!=="terminal"):pe;return d?[{key:"team-status",label:"Team Status",icon:t.jsx(vs,{size:14})},...ie]:ie},[n,v,i,d]),[I,B]=S.useState(()=>C?"preview":n?v?"history":"review":"editor"),F=S.useRef(null),R=S.useRef(0),[M,L]=S.useState(),O=S.useCallback(G=>{B(G),j&&D(!0)},[j,D]);S.useImperativeHandle(b,()=>({setTab:G=>O(G),openFile:(G,pe,ie)=>{O("editor"),requestAnimationFrame(()=>F.current?.openFile(G,pe,ie))},openPreview:(G,pe)=>{R.current+=1,L({id:R.current,url:G,workspaceId:pe}),O("preview")}}),[O]);const U=C??M,Y=U?.workspaceId&&U.workspaceId!==o?void 0:U,z=S.useCallback(G=>{L(pe=>pe?.id===G?void 0:pe),k?.(G)},[k]),{data:$}=jd(p??""),q=S.useMemo(()=>{if(!$?.quickCommands)return[];try{return JSON.parse($.quickCommands)}catch{return[]}},[$?.quickCommands]),[N,H]=S.useState([]),X=S.useRef(void 0);S.useEffect(()=>{g&&g!==X.current&&(X.current=g,H(G=>G.includes(g)?G:[...G,g]))},[g]),S.useEffect(()=>{W.some(G=>G.key===I)||B(W[0]?.key??"editor")},[I,W]),S.useEffect(()=>{if(j&&!T)return;const G=I==="review"?"changes":I==="history"?"history":null;if(!o||!g||!G){_(null);return}return _({workspaceId:o,workingDir:g,tab:G}),()=>{_(null)}},[I,T,j,_,g,o]);const K=!!y&&Bn(x,d).length>1,ne=W.find(G=>G.key===I)??W[0],te=ne?E(ne.label):"",he=i?t.jsx("div",{className:"mx-2 mt-2 rounded-lg border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:E(l?"项目已删除且本地仓库文件已清理。这里只保留历史视图。":"项目已删除。Workspace 以只读模式展示历史内容。")}):null,le=t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[K&&t.jsx("div",{className:"shrink-0 px-3 py-1.5 border-b border-neutral-100 bg-neutral-50/60",children:t.jsx(dc,{workspaces:x,teamRun:d,selectedWorkspaceId:w,onSelectWorkspace:y,buttonClassName:"h-7 text-[11px]"})}),t.jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[I==="team-status"&&d&&c,I==="editor"&&t.jsx(yv,{ref:F,workingDir:g,readOnly:i}),N.map(G=>{const pe=I==="terminal"&&g===G;return t.jsx("div",{"aria-hidden":!pe,className:"absolute inset-0 h-full w-full min-h-0 min-w-0 overflow-hidden",style:{display:pe?"block":"none"},children:t.jsx(Dm,{cwd:G,isVisible:pe,quickCommands:q})},G)}),I==="preview"&&t.jsx(Xv,{workspaceId:o,readOnly:i,navigationRequest:Y,onNavigationRequestHandled:z}),I==="review"&&t.jsx(Av,{workingDir:g,workspaceId:o,branchName:m?.branchName,targetBranch:m?.targetBranch,commitMessage:m?.commitMessage,canRunGitOperations:m?.canRunGitOperations,onRefreshCommitMessage:m?.onRefreshCommitMessage,onConflict:m?.onConflict,onResolveConflicts:m?.onResolveConflicts}),I==="history"&&t.jsx(Ov,{workingDir:g})]})]});return j?t.jsxs("div",{className:se("flex h-full w-full min-w-0 bg-white",s),children:[t.jsx("div",{className:"flex h-full w-12 shrink-0 flex-col items-center gap-1 border-l border-border bg-muted/35 px-1.5 py-2",children:W.map(G=>t.jsx(e0,{active:T&&I===G.key,onClick:()=>O(G.key),icon:G.icon,label:E(G.label)},G.key))}),T&&t.jsxs("div",{className:"flex h-full min-w-0 flex-1 flex-col border-l border-border bg-background",style:{minWidth:f},children:[he,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:ne?.icon}),t.jsx("span",{className:"truncate",children:te})]}),t.jsx("button",{type:"button",onClick:()=>D(!1),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",title:E("收起"),"aria-label":E("收起"),children:t.jsx(nu,{size:15})})]}),le]})]}):t.jsxs("div",{className:se("flex h-full w-full min-w-0 flex-col bg-white",s),children:[i&&he,t.jsx("div",{className:"flex items-center overflow-x-auto scrollbar-app-thin px-2 pt-2 border-b border-neutral-200 bg-neutral-100/80 shrink-0 gap-1 select-none",children:W.map(G=>t.jsx(Jv,{active:I===G.key,onClick:()=>O(G.key),icon:G.icon,label:E(G.label)},G.key))}),le]})}),ta=1500,t0=3e3;function s0(e){const[s,r]=S.useState(null),o=S.useRef(0),g=S.useRef(null),p=S.useRef(null);return S.useEffect(()=>{if(!e)return;const v=()=>{p.current&&(clearTimeout(p.current),p.current=null)},n=Jt.connect(),i=d=>{r(d),p.current=setTimeout(()=>r(null),t0)},l=d=>{if(d.taskId!==e)return;const c={status:d.status,currentCommand:d.currentCommand,currentIndex:d.currentIndex,totalCommands:d.totalCommands,error:d.error};if(d.status==="running"){v(),g.current=null,o.current===0&&(o.current=Date.now()),r(c);return}const m=o.current>0?Date.now()-o.current:0,x=ta-m;o.current===0?(o.current=Date.now(),r({status:"running",totalCommands:d.totalCommands,currentIndex:d.totalCommands}),g.current=c,p.current=setTimeout(()=>i(c),ta)):x>0?(g.current=c,v(),p.current=setTimeout(()=>i(c),x)):i(c)};return n.on(ct.WORKSPACE_SETUP_PROGRESS,l),()=>{n.off(ct.WORKSPACE_SETUP_PROGRESS,l),v(),o.current=0,g.current=null}},[e]),s}function hc({isOpen:e,onClose:s,onStarted:r,taskId:o,projectId:g,taskTitle:p,taskDescription:v,taskPrompt:n,projectIsGitRepo:i=!0,projectWorktreeReady:l=!0,projectGitReason:d}){const{t:c}=ce(),[m,x]=S.useState(""),[w,y]=S.useState(""),[a,h]=S.useState(_t.WORKTREE),[u,f]=S.useState(null),[b,C]=S.useState("idle"),[k,E]=S.useState(null),_=bt(),j=gl(o),A=xn(),P=Nd(),{data:T,isLoading:D}=Bs(),W=u?.isGitRepo??i,I=u?.worktreeReady??l,B=u?.reason??d,F=W!==!1&&I!==!1;S.useEffect(()=>{if(!e||!T)return;const N=T.find(H=>H.availability.type!=="NOT_FOUND");N&&x(N.provider.id)},[e,T]),S.useEffect(()=>{if(e){const N=[p];v&&N.push(v),y(n?.trim()||N.join(`
74
-
75
- `)),f(null),h(i!==!1&&l!==!1?_t.WORKTREE:_t.MAIN_DIRECTORY),C("idle"),E(null)}},[e,i,l,o,p,v,n]),S.useEffect(()=>{F||h(_t.MAIN_DIRECTORY)},[F]);const R=async()=>{if(!g||P.isPending)return;const N=await P.mutateAsync({id:g});f(N),N.worktreeReady&&h(_t.WORKTREE)},M=b!=="idle",L=async()=>{if(!(!m||!w.trim())){E(null);try{C("creating-workspace");const N=await j.mutateAsync({workspaceKind:F?a:_t.MAIN_DIRECTORY});C("creating-session");const H=await Ce.post(`/workspaces/${N.id}/sessions`,{providerId:m,prompt:w.trim()});C("starting-session"),await A.mutateAsync(H.id),await _.invalidateQueries({queryKey:de.workspaces.list(o)}),C("idle"),r?.(),s()}catch(N){C("idle"),E(N instanceof Error?N.message:c("启动失败,请重试"))}}},O={idle:c("启动"),"creating-workspace":c("创建工作空间..."),"creating-session":c("创建会话..."),"starting-session":c("启动 Agent...")},U=(T??[]).map(({provider:N,availability:H})=>{const X=H.type!=="NOT_FOUND";return{value:N.id,label:X?N.name:`${N.name}${c(" (不可用)")}`,icon:t.jsx(si,{agentType:N.agentType,className:"size-4"}),disabled:!X}}),Y=c("工作树隔离改动,支持 TeamRun、Merge、Rebase 和冲突解决。"),z=c("本地模式会直接修改项目主目录,不会自动提交,也不能使用 Merge、Rebase 或冲突解决。"),$=c(B==="NO_HEAD"?"已检测到 Git,但需要先提交一次才能使用工作树模式。":"非 Git 项目只能使用本地模式。"),q=[{value:_t.WORKTREE,label:c("工作树模式"),description:Y,disabled:!F},{value:_t.MAIN_DIRECTORY,label:c("本地模式"),description:z}];return t.jsx(ns,{isOpen:e,onClose:M?()=>{}:s,title:c("启动 Agent"),action:t.jsxs(t.Fragment,{children:[t.jsx(Te,{variant:"outline",onClick:s,disabled:M,children:c("取消")}),t.jsx(Te,{onClick:L,disabled:M||!m||!w.trim(),children:O[b]})]}),children:t.jsxs("div",{className:"space-y-5",children:[t.jsx("div",{children:t.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:c("Agent")}),t.jsx(es,{value:m,onChange:x,options:U,placeholder:c(D?"加载中...":"选择 Agent"),disabled:M||D})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:c("模式")}),F?t.jsx(es,{value:a,onChange:N=>h(N),options:q,disabled:M}):t.jsx(vd,{side:"bottom",className:"w-full",content:$,children:t.jsxs("div",{tabIndex:0,"aria-label":$,className:"rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[t.jsx(es,{value:a,onChange:N=>h(N),options:q,disabled:!0}),t.jsx("button",{type:"button",onClick:R,disabled:M||P.isPending,className:"mt-2 text-xs text-muted-foreground transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",children:P.isPending?c("检测中..."):c("重新检测 Git 状态")})]})})]})]})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:c("任务描述")}),t.jsx("textarea",{value:w,onChange:N=>y(N.target.value),rows:5,disabled:M,placeholder:c("描述你想让 Agent 完成的任务..."),className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm text-neutral-900 placeholder-neutral-400 focus:outline-none focus:ring-1 focus:ring-neutral-300 focus:border-neutral-300 resize-none disabled:opacity-50 disabled:bg-neutral-50"})]}),k&&t.jsx("div",{className:"text-sm text-red-600 bg-red-50 border border-red-100 rounded-lg px-3 py-2",children:k})]})})}function fc(e){const s=e?.tokenUsage;if(!(!s||typeof s.totalTokens!="number"))return s}function r0(e,s,r){const o=e?.providerId??r?.providerId??null,g=o?s?.find(i=>i.provider.id===o)?.provider:null,p=g?.name??o??e?.agentType??r?.agentType??null;if(!p)return null;const v=e?.agentType??g?.agentType??r?.agentType??null,n=o&&g?.name&&o!==g.name?`${g.name} (${o})`:p;return{label:p,title:n,agentType:v}}function mc({session:e,providers:s,usage:r,compact:o=!1,providerIdFallback:g,agentTypeFallback:p,tokenTooltipSide:v="top"}){const{t:n}=ce(),i=r0(e,s,{providerId:g,agentType:p});return!i&&!r?null:t.jsxs("div",{className:`flex shrink-0 items-center ${o?"gap-1":"gap-2"}`,children:[i&&t.jsxs("div",{className:`flex shrink-0 items-center rounded-lg text-neutral-500 ${o?"max-w-[130px] min-w-[82px] gap-1 px-1.5 py-1 text-[11px]":"max-w-[220px] min-w-[110px] gap-1.5 px-2 py-1.5 text-xs"}`,title:`${n("Provider")}: ${i.title}`,children:[t.jsx(si,{agentType:i.agentType,className:o?"size-3":"size-3.5"}),t.jsx("span",{className:"min-w-0 truncate",children:id(i.label,o?12:18)})]}),t.jsx(_n,{usage:r,tooltipSide:v})]})}function i0({isOpen:e,onClose:s,taskId:r}){const{t:o}=ce(),[g,p]=S.useState("AUTO"),[v,n]=S.useState(null),[i,l]=S.useState([]),[d,c]=S.useState(null),m=ba();S.useEffect(()=>{e&&(p("AUTO"),n(null),l([]),c(null))},[e]);const x=m.isPending,w=!!v||i.length>0,y=async()=>{if(!x){if(!v&&i.length===0){c(o("请选择至少一个团队模板或成员预设。"));return}c(null);try{await m.mutateAsync({taskId:r,mode:g,...v?{teamTemplateId:v}:{},...i.length>0?{memberPresetIds:i}:{}}),s()}catch(h){if(h instanceof cn&&h.status===409){c(o("该任务已经存在 TeamRun。请刷新后再试。"));return}c(h instanceof Error?h.message:o("创建 TeamRun 失败"))}}},a=x||!w;return t.jsxs(ns,{isOpen:e,onClose:x?()=>{}:s,title:o("创建 TeamRun"),className:"max-w-5xl",action:t.jsxs(t.Fragment,{children:[t.jsx(Te,{type:"button",variant:"outline",onClick:s,disabled:x,children:o("取消")}),t.jsx(Te,{type:"button",onClick:y,disabled:a,children:o(x?"处理中...":"创建 TeamRun")})]}),children:[t.jsx(bd,{mode:g,setMode:p,selectedTemplateId:v,setSelectedTemplateId:n,selectedMemberPresetIds:i,setSelectedMemberPresetIds:l,disabled:x}),d&&t.jsx("div",{role:"alert",className:"rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700",children:d})]})}function n0({workspaceId:e,gitStatus:s,onResolve:r}){const{t:o}=ce(),g=Ln();if(s.operation==="idle"||s.conflictedFiles.length===0)return null;const p=s.operation==="rebase"?"Rebase":"Merge";return t.jsxs("div",{className:"mx-6 mt-3 flex items-center gap-3 rounded-lg border border-warning/25 bg-warning/[0.06] px-4 py-2.5",children:[t.jsx(ur,{size:15,className:"text-warning shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:[t.jsxs("span",{className:"text-sm font-medium text-foreground",children:[p," ",o("冲突")]}),t.jsxs("span",{className:"inline-flex items-center rounded-full bg-warning/15 px-2 py-0.5 text-xs font-semibold text-warning tabular-nums",children:[s.conflictedFiles.length," ",o("个文件")]})]}),t.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[t.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>g.mutate(e),disabled:g.isPending,className:"text-muted-foreground hover:text-foreground",children:o("中止操作")}),t.jsx(Te,{size:"sm",onClick:r,children:o("解决冲突")})]})]})}function pc(e){return e.length>0?e.map(s=>`- ${s}`).join(`
76
- `):"- 未获取到冲突文件列表"}function gc(e){if(!e)return[];const s=[];return e.workspaceId&&s.push(`- Workspace: \`${e.workspaceId}\``),e.worktreePath&&s.push(`- Worktree: \`${e.worktreePath}\``),e.sourceWorkspaceId&&s.push(`- Source workspace: \`${e.sourceWorkspaceId}\``),e.targetWorkspaceId&&s.push(`- Target workspace: \`${e.targetWorkspaceId}\``),e.sourceWorktreePath&&s.push(`- Source worktree: \`${e.sourceWorktreePath}\``),e.targetWorktreePath&&s.push(`- Target worktree: \`${e.targetWorktreePath}\``),e.operation&&e.operation!=="idle"&&s.push(`- Git 状态: \`${e.operation}\``),e.mergeStrategy&&s.push(`- Merge strategy: \`${e.mergeStrategy}\``),e.mergeAborted&&s.push("- Merge state: conflict detected and already aborted by Agent Tower"),s}function o0(e,s){if(!s?.mergeAborted)return["1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git commit` 完成合并"];const r=s.mergeStrategy==="squash"?`git merge --squash --no-commit ${e}`:`git merge --no-ff ${e}`,o=s.mergeStrategy==="squash"?"`git commit`":"`git merge --continue` 或 `git commit`";return["1. 注意:Agent Tower 检测到 merge 冲突后已经执行 abort,当前不要假设存在冲突标记或 `MERGE_HEAD`","2. 切换到 Target worktree / Target branch 上下文,确认工作区干净",`3. 重新执行 \`${r}\` 复现冲突`,"4. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","5. 对每个已解决的文件执行 `git add <file>`",`6. 执行 ${o} 完成合并`]}function a0(e){if(!e.mergeAborted)return"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 merge 提交,然后说明处理结果。";const s=e.targetWorktreePath?`目标 worktree \`${e.targetWorktreePath}\``:`目标分支 \`${e.targetBranch}\``,r=e.mergeStrategy==="squash"?`git merge --squash --no-commit ${e.sourceBranch}`:`git merge --no-ff ${e.sourceBranch}`;return`Agent Tower 已在检测到冲突后 abort 了 merge;请在${s}中确认工作区干净,重新执行 \`${r}\` 复现冲突,解决后完成提交并汇报验证结果。`}function l0(e,s,r,o,g){const p=pc(r),v=gc(g);return o===ir.REBASE?["## Rebase 冲突解决","",`在将分支 \`${e}\` rebase 到 \`${s}\` 时发生了冲突。`,...v.length>0?["","### 上下文",...v]:[],"","### 冲突文件",p,"","### 解决步骤","1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git rebase --continue` 继续 rebase 流程"].join(`
77
- `):["## Merge 冲突解决","",`在将分支 \`${e}\` 合并到 \`${s}\` 时发生了冲突。`,...v.length>0?["","### 上下文",...v]:[],"","### 冲突文件",p,"","### 解决步骤",...o0(e,g)].join(`
78
- `)}function c0(e){const s=e.conflictOp===ir.REBASE?"Rebase":"Merge",r=pc(e.conflictedFiles),o=[...gc(e),`- Source branch: \`${e.sourceBranch}\``,`- Target branch: \`${e.targetBranch}\``,`- Conflict type: \`${e.conflictOp}\``];return[`## 请求处理 ${s} 冲突`,"",`用户点击了“AI 辅助解决”,请在对应 workspace 中处理当前 ${s} 冲突,并在 Team Room 汇报处理结果和验证情况。`,"","### 上下文",...o,"","### 冲突文件",r,"","### 用户意图",e.conflictOp===ir.REBASE?"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 `git rebase --continue`,然后说明处理结果。":a0(e)].join(`
79
- `)}function d0(e){if(e.teamRunId)return{type:"team_room",message:c0(e)};const s=e.currentSessionId||e.selectedSessionId;return s?{type:"session",sessionId:s,message:l0(e.sourceBranch,e.targetBranch,e.conflictedFiles,e.conflictOp,e)}:{type:"none"}}function vc({open:e,onOpenChange:s,workspaceId:r,conflictOp:o,conflictedFiles:g,sourceBranch:p,targetBranch:v,operation:n,worktreePath:i,mergeAborted:l,mergeStrategy:d,sourceWorkspaceId:c,targetWorkspaceId:m,sourceWorktreePath:x,targetWorktreePath:w,sessions:y,currentSessionId:a,teamRunId:h}){const{t:u}=ce(),[f,b]=S.useState(""),C=bn(),k=dn(h??""),E=Dn(),_=!!h,j=a||f,A=_?k.isPending:C.isPending,P=()=>{const B=d0({workspaceId:r,worktreePath:i,operation:n,mergeAborted:l,mergeStrategy:d,sourceWorkspaceId:c,targetWorkspaceId:m,sourceWorktreePath:x,targetWorktreePath:w,sourceBranch:p,targetBranch:v,conflictedFiles:g,conflictOp:o,teamRunId:h,currentSessionId:a,selectedSessionId:f});if(B.type==="team_room"){k.mutate({content:B.message,kind:"chat"},{onSuccess:()=>{rt.success(u("已发送到 Team Room")),s(!1)}});return}B.type==="session"&&C.mutate({id:B.sessionId,message:B.message},{onSuccess:()=>s(!1)})},T=()=>{E.mutate({workspaceId:r},{onSuccess:()=>s(!1)})},D=o==="REBASE"?"Rebase":"Merge",W=!_&&!a&&y.length>0,I=_||!!j;return t.jsx(ns,{isOpen:e,onClose:()=>s(!1),title:u("解决 {opLabel} 冲突",{opLabel:D}),action:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Te,{variant:"outline",onClick:T,children:u("在 IDE 中打开")}),t.jsx(Te,{onClick:P,disabled:!I||A,children:u(A?"发送中...":"AI 辅助解决")})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:u("冲突文件({count})",{count:g.length})}),t.jsx("div",{className:"max-h-40 overflow-y-auto rounded-md border border-neutral-200 bg-neutral-50",children:g.map(B=>t.jsx("div",{className:"px-3 py-1.5 text-xs font-mono text-neutral-700 border-b border-neutral-100 last:border-b-0",children:B},B))})]}),_&&t.jsx("div",{className:"rounded-md border border-blue-100 bg-blue-50 px-3 py-2 text-sm text-blue-800",children:u("TeamRun 模式下会把处理冲突请求发送到 Team Room,由团队调度处理。")}),W&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:u("选择 Session(AI 辅助解决)")}),t.jsxs("select",{value:f,onChange:B=>b(B.target.value),className:"w-full px-3 py-2 text-sm border border-neutral-200 rounded-md bg-white focus:outline-none focus:ring-2 focus:ring-neutral-300",children:[t.jsx("option",{value:"",children:u("选择一个 Session...")}),y.map(B=>t.jsxs("option",{value:B.id,children:[B.agentType," — ",B.status]},B.id))]})]}),!_&&!j&&y.length===0&&t.jsx("p",{className:"text-sm text-neutral-500",children:u("没有可用的 Session,请在 IDE 中手动解决冲突。")})]})})}function u0(e){return[...e?.uncommitted??[],...e?.committed??[]].reduce((r,o)=>({files:r.files+1,additions:r.additions+(o.additions??0),deletions:r.deletions+(o.deletions??0)}),{files:0,additions:0,deletions:0})}function sa(e,s,r,o){const g=rc(e);if(g){r(g);return}o(e instanceof Error?e.message:s)}function xc({workspaceId:e,branchName:s,targetBranch:r,commitMessage:o,changes:g,gitStatus:p,isGitStatusLoading:v,canRunGitOperations:n,onOpenChanges:i,onRefreshCommitMessage:l,onConflict:d,className:c}){const{t:m}=ce(),x=xl(),w=vl(),y=Ln(),[a,h]=S.useState(!1),[u,f]=S.useState(null),b=S.useMemo(()=>u0(g),[g]),C=b.additions+b.deletions,k=b.files>0&&C>0,E=(p?.conflictedFiles.length??0)>0,_=!!(p&&p.operation!=="idle"),j=!!(p&&(p.hasUncommittedChanges||p.untrackedCount>0)),A=(p?.uncommittedCount??0)+(p?.untrackedCount??0),P=(p?.behind??0)>0,T=(p?.ahead??0)>0,D=v||!p&&n,W=!!(n&&e&&p&&P&&!E&&!_&&!j),I=!!(n&&e&&p&&T&&!P&&!E&&!_&&!j);if(S.useEffect(()=>{a&&l?.()},[a,l]),!k)return null;const B=E?m("冲突"):p?.operation==="rebase"?m("变基中"):p?.operation==="merge"?m("合并中"):A>0?m("{count} 未提交",{count:A}):P?m("落后 {count}",{count:p?.behind??0}):m(T?"可合并":"已是最新"),F=m("{files} 个文件 · {lines} 行",{files:b.files,lines:C}),R=()=>{W&&(f(null),x.mutate(e,{onError:U=>{sa(U,m("更新失败,请稍后重试"),Y=>d(Y),f)}}))},M=()=>{I&&(f(null),h(!0))},L=U=>{f(null),w.mutate({id:e,commitMessage:U},{onSuccess:()=>h(!1),onError:Y=>{sa(Y,m("提交失败,请稍后重试"),z=>{h(!1),d(z)},f)}})},O=()=>{w.isPending||(h(!1),f(null))};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:se("space-y-1",c),children:[t.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg bg-muted/25 px-2 py-1.5",children:[t.jsxs("button",{type:"button",onClick:i,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-1.5 py-0.5 text-left transition-colors hover:bg-muted/55 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40","aria-label":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(Fs,{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:F}),t.jsxs("span",{className:"hidden shrink-0 items-center gap-1 font-mono text-[11px] sm:inline-flex",children:[b.additions>0&&t.jsxs("span",{className:"text-success",children:["+",b.additions]}),b.deletions>0&&t.jsxs("span",{className:"text-destructive",children:["-",b.deletions]})]}),E&&t.jsx(ur,{size:13,className:"shrink-0 text-amber-600"}),t.jsxs("span",{className:"hidden min-w-0 items-center gap-1 text-[11px] text-muted-foreground md:flex",children:[t.jsx("span",{className:"truncate font-mono",children:s}),t.jsx("span",{className:"text-muted-foreground/40",children:"→"}),t.jsx("span",{className:"truncate font-mono",children:r})]}),t.jsx("span",{className:"shrink-0 rounded-full bg-background/75 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:B})]}),t.jsx(Mt,{size:15,className:"shrink-0 text-muted-foreground/60"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[_&&t.jsx("button",{type:"button",onClick:()=>y.mutate(e),disabled:y.isPending,className:"hidden h-7 items-center rounded-md border border-border/70 bg-background px-2 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50 sm:inline-flex",children:y.isPending?m("正在撤销..."):m("撤销操作")}),t.jsxs("button",{type:"button",onClick:R,disabled:!W||x.isPending||D,className:"inline-flex h-7 items-center gap-1.5 rounded-md border border-border/70 bg-background px-2 text-xs font-medium text-foreground/80 transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-45",title:m(P?"同步更新":"已是最新"),children:[x.isPending?t.jsx(Ke,{size:12,className:"animate-spin"}):t.jsx(hr,{size:12}),t.jsx("span",{children:x.isPending?m("正在同步..."):m("更新")})]}),t.jsxs("button",{type:"button",onClick:M,disabled:!I||w.isPending||D,className:"inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-2 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:bg-muted disabled:text-muted-foreground",title:I?m("合并到 {target}",{target:r}):m("提交变更"),children:[w.isPending?t.jsx(Ke,{size:12,className:"animate-spin"}):t.jsx($r,{size:12}),t.jsx("span",{children:w.isPending?m("正在提交..."):m("合并")})]})]})]}),u&&t.jsx("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-1.5 text-xs text-destructive",children:u})]}),t.jsx(sc,{isOpen:a,onClose:O,branchName:s,targetBranch:r,commitMessage:o,isPending:w.isPending,error:u,onConfirm:L})]})}function h0({agentType:e,workingDir:s}){return Bt({queryKey:de.system.skillCatalog(e,s),queryFn:async()=>(await Ce.get("/system/skill-catalog",{params:{agentType:String(e),...s?{workingDir:s}:{}}})).commands,enabled:e===Nt.CODEX,staleTime:3e4})}function f0(e){const s=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,r=e.key==="Tab"&&!e.shiftKey;return s||r}function _c({agentType:e,workingDir:s,input:r,setInput:o,textareaRef:g,minHeight:p,maxHeight:v}){const[n,i]=S.useState(0),{data:l=[]}=h0({agentType:e,workingDir:s}),c=S.useMemo(()=>e===Nt.CODEX?to(r):null,[e,r])?.query??null,m=S.useMemo(()=>c===null?[]:yd(l,c),[c,l]),x=S.useCallback(()=>{const a=g.current;a&&(a.style.height="auto",a.style.height=`${Math.max(p,Math.min(a.scrollHeight,v))}px`)},[v,p,g]);S.useEffect(()=>{i(0)},[e,c]),S.useEffect(()=>{n<m.length||i(0)},[m.length,n]);const w=S.useCallback(a=>{const h=to(r);if(!h)return;const u=`${r.slice(0,h.replaceStart)}${a.command} `;o(u),requestAnimationFrame(()=>{const f=g.current;f&&(x(),f.focus(),f.setSelectionRange(u.length,u.length))})},[r,x,o,g]),y=S.useCallback(a=>c===null||m.length===0?!1:a.key==="ArrowDown"?(a.preventDefault(),i(h=>(h+1)%m.length),!0):a.key==="ArrowUp"?(a.preventDefault(),i(h=>(h-1+m.length)%m.length),!0):f0(a)?(a.preventDefault(),w(m[n]??m[0]),!0):!1,[w,m,c,n]);return{allSkills:l,query:c,filteredSkills:m,selectedIndex:n,setSelectedIndex:i,applySkill:w,handleKeyDown:y}}const m0=dr(),p0=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${m0}/attachments/by-path?path=${encodeURIComponent(e)}`:e,js=520,Wi=48,g0=4,v0=420;function x0(){const{t:e}=ce();return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-background text-muted-foreground/70 select-none",children:[t.jsx("div",{className:"w-16 h-16 bg-muted/50 rounded-2xl border border-border/60 flex items-center justify-center mb-6",children:t.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-muted-foreground/50",children:[t.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"currentColor"}),t.jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),t.jsx("h3",{className:"text-foreground font-medium mb-2 text-lg",children:"Agent Tower"}),t.jsx("p",{className:"text-sm max-w-sm text-center text-muted-foreground leading-relaxed",children:e("Select a task from the sidebar to view logs, monitor execution, or interact with an agent.")})]})}const ra=[{status:be.Review,className:"bg-warning/10 text-warning",hoverClass:"hover:bg-warning/15",icon:t.jsx(Ta,{className:"w-3 h-3"})},{status:be.Running,className:"bg-info/10 text-info",hoverClass:"hover:bg-info/15",icon:t.jsx(Aa,{className:"w-3 h-3"})},{status:be.Pending,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-muted",icon:t.jsx(Ra,{className:"w-3 h-3"})},{status:be.Done,className:"bg-success/10 text-success",hoverClass:"hover:bg-success/15",icon:t.jsx(Na,{className:"w-3 h-3"})},{status:be.Cancelled,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-border",icon:t.jsx(ja,{className:"w-3 h-3"})}];function _0({status:e,onChangeStatus:s}){const{t:r}=ce(),[o,g]=S.useState(!1),p=S.useRef(null);S.useEffect(()=>{if(!o)return;const n=i=>{p.current&&!p.current.contains(i.target)&&g(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[o]);const v=ra.find(n=>n.status===e);return t.jsxs("div",{className:"relative",ref:p,children:[t.jsxs("button",{onClick:()=>s&&g(n=>!n),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium transition-colors ${v.className} ${s?"cursor-pointer hover:opacity-80":""}`,children:[v.icon,t.jsx("span",{children:r(e)}),s&&t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",className:`ml-0.5 transition-transform ${o?"rotate-180":""}`,children:t.jsx("path",{d:"M2 3.5L5 6.5L8 3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})]}),o&&t.jsx("div",{className:"absolute right-0 top-full mt-2 w-40 bg-background rounded-lg border border-border shadow-lg z-50 py-1 animate-in fade-in zoom-in-95 duration-100",children:ra.filter(n=>n.status!==e).map(n=>t.jsxs("button",{onClick:()=>{s?.(n.status),g(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-xs font-medium transition-colors ${n.hoverClass}`,children:[t.jsx("span",{className:n.className.split(" ").find(i=>i.startsWith("text-")),children:n.icon}),t.jsx("span",{className:"text-foreground/80",children:r(n.status)})]},n.status))})]})}function ia({state:e,onRetry:s}){const{t:r}=ce(),o=e.status==="creating-workspace"?r("Creating Workspace..."):e.status==="creating-session"?r("Creating Session..."):e.status==="starting-session"?r("Starting Agent..."):r("启动 Agent 失败");return e.status==="failed"?t.jsxs("div",{className:"mb-6 max-w-sm rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-2 text-left",children:[t.jsx("p",{className:"text-sm font-medium text-destructive",children:o}),e.error?t.jsx("p",{className:"mt-1 text-xs text-destructive/80 break-words",children:e.error}):null,s?t.jsxs(Te,{size:"sm",variant:"outline",className:"mt-3",onClick:s,children:[t.jsx(Xt,{size:14,className:"mr-1.5"}),r("重试启动 Agent")]}):null]}):t.jsxs("div",{className:"mb-6 flex items-center gap-2 rounded-full border border-border bg-muted/30 px-3 py-1.5 text-sm text-muted-foreground",children:[t.jsxs("svg",{className:"h-3.5 w-3.5 animate-spin shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:o})]})}function b0({task:e,onDeleteTask:s,isDeleting:r,onTaskStatusChange:o,autoStartState:g,onAutoStartRecovered:p}){const{t:v}=ce(),[n,i]=S.useState(""),[l,d]=S.useState(!1),[c,m]=S.useState(!1),[x,w]=S.useState(!1),[y,a]=S.useState(!1),[h,u]=S.useState(!1),[f,b]=S.useState(!1),[C,k]=S.useState(null),E=S.useRef(null),[_,j]=S.useState(!1),[A,P]=S.useState(null),[T,D]=S.useState(void 0),[W,I]=S.useState(!1),B=S.useRef(null),F=S.useRef(null),R=S.useRef(null),M=S.useRef(null),{scrollRef:L,contentRef:O,isAtBottom:U,scrollToBottom:Y,stopScroll:z}=gn({resize:"smooth",initial:"instant"}),[$,q]=S.useState(!1),[N,H]=S.useState(js),[X,K]=S.useState(!1),ne=S.useRef(0),te=S.useRef(js),he=S.useRef(null),le=S.useCallback((Q,oe,Be)=>{E.current?.openFile(Q,oe,Be)},[]),{data:G,isLoading:pe}=Mn(e?.id??""),ie=s0(e?.id),{data:Ae}=ya(e?.id??""),{data:at}=Sa(Ae?.id??""),Xe=dn(Ae?.id??""),_e=Ae??null,Ie=!!_e,Pe=e?.isGitRepo!==!1&&e?.worktreeReady!==!1,$e=Ae===null&&Pe,Oe=!!(e?.id&&Ae===null),{data:Ve,isLoading:Ze}=wa(e?.id??"",Oe);S.useEffect(()=>{I(!1),P(null),D(void 0)},[e?.id]);const Me=S.useMemo(()=>Cl(G,_e,T),[T,_e,G]);S.useEffect(()=>{T&&!G?.some(Q=>Q.id===T)&&D(void 0)},[T,G]);const Re=S.useMemo(()=>G?.find(Q=>Q.id===Me),[Me,G]),ve=Re?.status===At.ACTIVE?Re.id:void 0,Fe=Pe&&kl(Re,_e);S.useEffect(()=>{if(!W||!G)return;G.some(oe=>oe.status==="ACTIVE"&&oe.sessions&&oe.sessions.length>0)&&I(!1)},[G,W]);const ge=S.useMemo(()=>{if(W||!G)return null;const Q=mt=>{const wi=mt.createdAt,Vs=mt.endedAt??mt.startedAt??wi;if(!Vs)return 0;const Cs=Date.parse(Vs);return Number.isNaN(Cs)?0:Cs},oe=(mt,wi)=>{const Vs=mt.filter(Cs=>wi.includes(Cs.status));return Vs.length===0?null:Vs.sort((Cs,$c)=>Q($c)-Q(Cs))[0]??null},Be=G.filter(mt=>mt.status==="ACTIVE"&&Array.isArray(mt.sessions)).flatMap(mt=>mt.sessions??[]),ht=oe(Be,[dt.RUNNING])??oe(Be,[dt.PENDING])??oe(Be,[dt.COMPLETED,dt.FAILED,dt.CANCELLED]);if(ht)return ht;const ft=G.filter(mt=>(mt.status==="MERGED"||mt.status==="ABANDONED"||mt.status==="HIBERNATED")&&Array.isArray(mt.sessions)).flatMap(mt=>mt.sessions??[]);return oe(ft,[dt.COMPLETED,dt.FAILED,dt.CANCELLED])},[G,W]),lt=ge?.id??"",Je=Ie?A??"":lt,Et=S.useMemo(()=>{if(!A||!G)return null;for(const Q of G){const oe=Q.sessions?.find(Be=>Be.id===A);if(oe)return oe}return null},[A,G]),J=S.useMemo(()=>{if(!A||!_e?.invocations)return null;const Q=_e.invocations.filter(oe=>oe.sessionId===A);return Q.length===0?null:Q.sort((oe,Be)=>{const ht=Date.parse(oe.updatedAt??oe.createdAt??""),ft=Date.parse(Be.updatedAt??Be.createdAt??"");return(Number.isNaN(ft)?0:ft)-(Number.isNaN(ht)?0:ht)})[0]??null},[A,_e?.invocations]),ue=S.useMemo(()=>!J?.memberId||!_e?.members?null:_e.members.find(Q=>Q.id===J.memberId)??null,[J?.memberId,_e?.members]),V=A?Et:ge??null,Z=S.useMemo(()=>{if(V?.workspaceId)return V.workspaceId;if(!(!V||!G))return G.find(Q=>Q.sessions?.some(oe=>oe.id===V.id))?.id},[V,G]),re=S.useCallback((Q,oe)=>{const ht=(oe&&G?.some(ft=>ft.id===oe)?oe:void 0)??Z??Me??void 0;ht&&D(ht),E.current?.openPreview(Q,ht)},[Z,Me,G]),ye=S.useCallback(Q=>{re(Q,Z)},[Z,re]),{isActive:me,isCancelling:Se}=Pa(V?.id??"",V?.status),we=!!e?.projectArchivedAt,xe=!!e?.projectRepoDeletedAt,ke=v(xe?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),{data:De}=Bs(),[Ee,Ye]=S.useState(null);S.useEffect(()=>{Ye(ge?.providerId??null)},[ge?.providerId]);const Ge=S.useMemo(()=>!ge||!G?!1:!G.some(oe=>oe.status==="ACTIVE"&&oe.sessions?.some(Be=>Be.id===ge.id)),[ge,G]),ze=S.useMemo(()=>{if(!(!G||W)){if(Re)return ss(Re);for(const Q of G)if(Q.status==="ACTIVE"&&ss(Q))return ss(Q);return ss(G[0])}},[W,Re,G]),et=La({agentType:ge?.agentType,workingDir:ze,input:n,setInput:i,textareaRef:R,minHeight:60,maxHeight:300}),it=_c({agentType:ge?.agentType,workingDir:ze,input:n,setInput:i,textareaRef:R,minHeight:60,maxHeight:300}),Dt=_s(Q=>Q.setVisibleContext),vt=!!(Fe&&ve&&ze&&!we),{data:st,isLoading:xt}=Pn(ve??"",{enabled:vt}),{data:Ct}=pi(ze,{enabled:vt});S.useEffect(()=>{if(!($||!vt||!ve||!ze))return Dt({workspaceId:ve,workingDir:ze,tab:"changes"}),()=>{Dt(null)}},[$,ve,Dt,vt,ze]);const bs=Re?.sessions??[],ys=Os(Re),Hs=Re?.commitMessage,ls=S.useMemo(()=>El(Re,G,e?.mainBranch??""),[Re,e?.mainBranch,G]),pt=S.useMemo(()=>st?.conflictOp&&st.conflictedFiles.length>0?{conflictOp:st.conflictOp,conflictedFiles:st.conflictedFiles}:C,[st?.conflictOp,st?.conflictedFiles,C]),$s=pt?.targetWorkspaceId??ve,br=pt?.targetWorktreePath??Re?.worktreePath,yr=pt?.sourceBranch??ys,cs=pt?.targetBranch??ls,nt=bt(),Ut=S.useCallback(async()=>e?.id?nt.fetchQuery({queryKey:de.tasks.body(e.id),queryFn:()=>Ce.get(`/tasks/${e.id}/body`)}):null,[nt,e?.id]),ds=S.useCallback(()=>e?.id?nt.invalidateQueries({queryKey:de.workspaces.list(e.id)}):Promise.resolve(),[e?.id,nt]);S.useEffect(()=>{if(!_)return;const Q=oe=>{F.current&&!F.current.contains(oe.target)&&j(!1)};return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[_]);const Sr=bn(),us=Dn(),wr=nd(),Us=gl(e?.id??""),qs=xn(),qt=rf(),zt=S.useMemo(()=>!G||G.some(oe=>oe.status==="ACTIVE")?null:G.find(oe=>oe.status==="HIBERNATED")??null,[G]),Ks=S.useRef(null);S.useEffect(()=>{zt&&Ks.current!==zt.id&&(qt.isPending||(Ks.current=zt.id,qt.mutate(zt.id,{onSettled:()=>{Ks.current=null}})))},[zt,qt]);const Cr=S.useCallback(async()=>{if(!e?.id)return;const Q=ge?.providerId??De?.find(oe=>oe.availability.type!=="NOT_FOUND")?.provider.id;if(Q){a(!1),u(!0);try{const Be=(await Ut())?.prompt??e.title;await wr.mutateAsync(e.id),I(!0);const ht=await Us.mutateAsync({workspaceKind:Pe?void 0:_t.MAIN_DIRECTORY}),ft=await Ce.post(`/workspaces/${ht.id}/sessions`,{providerId:Q,prompt:Be});await qs.mutateAsync(ft.id),await nt.invalidateQueries({queryKey:de.workspaces.list(e.id)})}catch(oe){console.error("[retry] failed:",oe),I(!1)}finally{u(!1)}}},[e?.id,e?.title,Pe,ge?.providerId,De,Ut,wr,Us,qs,nt]),Ss=S.useCallback(async()=>{e?.id&&(await Ut(),d(!0))},[Ut,e?.id]),Xs=S.useCallback(()=>{Re?.id&&us.mutate({workspaceId:Re.id})},[us,Re?.id]),kr=S.useCallback(()=>{!e?.id||!s||(s(e.id),w(!1))},[e?.id,s]),Er=S.useCallback(Q=>{P(Q),requestAnimationFrame(()=>{Y()})},[Y]),gi=S.useCallback(()=>{P(null)},[]),hs=S.useCallback(Q=>{k(Q??null),b(!0)},[]),vi=S.useCallback(Q=>Xe.mutateAsync(Q),[Xe]),Qt=S.useCallback(()=>{nt.invalidateQueries({queryKey:od.all})},[nt]),{isConnected:Ys,isLoadingSnapshot:jr,isOutputActive:Nr,lastExitAt:Rr,logs:fs,entries:ms,attach:ee}=za({sessionId:Je,sessionStatus:V?.status,sessionStartedAt:V?.startedAt??V?.createdAt,sessionEndedAt:V?.endedAt??(me?null:V?.updatedAt),onExit:S.useCallback(()=>{nt.invalidateQueries({queryKey:["workspaces"]})},[nt])});S.useEffect(()=>{if(!e?.id)return;const Q=Jt.connect();Q.emit(Ns.SUBSCRIBE,{topic:"task",id:e.id});const oe=ft=>{ft.taskId===e.id&&(nt.invalidateQueries({queryKey:["tasks"]}),Qt())},Be=ft=>{ft.taskId===e.id&&(nt.invalidateQueries({queryKey:de.workspaces.list(e.id)}),Qt())},ht=ft=>{ft.taskId===e.id&&(nt.invalidateQueries({queryKey:de.workspaces.list(e.id)}),Qt())};return Q.on(ct.TASK_UPDATED,oe),Q.on(ct.WORKSPACE_COMMIT_MESSAGE_UPDATED,Be),Q.on(ct.WORKSPACE_HIBERNATED,ht),()=>{Q.off(ct.TASK_UPDATED,oe),Q.off(ct.WORKSPACE_COMMIT_MESSAGE_UPDATED,Be),Q.off(ct.WORKSPACE_HIBERNATED,ht),Q.emit(Ns.UNSUBSCRIBE,{topic:"task",id:e.id})}},[e?.id,nt,Qt]),S.useEffect(()=>{if(!Je)return;const Q=Jt.connect(),oe=Be=>{Be.sessionId===Je&&(nt.invalidateQueries({queryKey:["workspaces"]}),Qt())};return Q.on(ct.SESSION_COMPLETED,oe),()=>{Q.off(ct.SESSION_COMPLETED,oe)}},[Je,nt,Qt]);const{todos:fe}=Wa(ms),{files:Ue,addFiles:Ne,removeFile:St,clear:Pt,buildMarkdownLinks:Le,hasFiles:jt,isUploading:Lt}=un(),ws=S.useMemo(()=>fc(V),[V?.tokenUsage]),Kn=Ia(fs,ws);S.useEffect(()=>{Je&&Ys&&ee()},[Je,Ys,ee]);const Xn=S.useRef(e?.id);S.useEffect(()=>{if(Xn.current!==e?.id&&L.current){const Q=L.current;requestAnimationFrame(()=>{Q.scrollTop=Q.scrollHeight})}Xn.current=e?.id},[e?.id,L]);const xi=Oa(),_i=S.useRef(!1),Yn=S.useCallback(async()=>{if(!n.trim()&&!jt||!Je||_i.current||Lt)return;_i.current=!0;const Q=Le(),oe=[n.trim(),Q].filter(Boolean).join(`
80
-
81
- `);i(""),Pt(),R.current&&(R.current.style.height="60px"),Sr.mutate({id:Je,message:oe,providerId:Ee??void 0},{onSuccess:()=>{ee()},onSettled:()=>{_i.current=!1}})},[n,Je,Sr,ee,jt,Lt,Le,Pt,Ee]),Pc=S.useCallback(async()=>{Je&&(await xi.mutateAsync(Je),nt.invalidateQueries({queryKey:["workspaces"]}))},[Je,xi,nt]),Lc=S.useCallback(Q=>{const oe=Q.target.files;oe&&oe.length>0&&Ne(Array.from(oe)),Q.target.value=""},[Ne]),Ic=S.useCallback(Q=>{const oe=Q.clipboardData.items,Be=[];for(const ht of oe)if(ht.kind==="file"){const ft=ht.getAsFile();ft&&Be.push(ft)}Be.length>0&&(Q.preventDefault(),Ne(Be))},[Ne]),[Vn,bi]=S.useState(!1),Oc=S.useCallback(Q=>{Q.preventDefault(),bi(!0)},[]),Bc=S.useCallback(Q=>{Q.preventDefault(),bi(!1)},[]),Fc=S.useCallback(Q=>{Q.preventDefault(),bi(!1);const oe=Q.dataTransfer.files;oe.length>0&&Ne(Array.from(oe))},[Ne]),Kt=S.useCallback(Q=>{const oe=he.current?.getBoundingClientRect().width??(typeof window<"u"?window.innerWidth:void 0),Be=oe?Math.max(js,oe-Wi-g0-v0):js;return Math.max(js,Math.min(Math.round(Q),Be))},[]),yi=S.useCallback(Q=>{const oe=Q.clientX-ne.current;H(Kt(te.current-oe))},[Kt]),Si=S.useCallback(()=>{K(!1),document.body.style.cursor="",document.body.style.userSelect=""},[]);S.useEffect(()=>{if(X)return document.addEventListener("mousemove",yi),document.addEventListener("mouseup",Si),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",yi),document.removeEventListener("mouseup",Si),document.body.style.cursor="",document.body.style.userSelect=""}},[Si,yi,X]);const zc=S.useCallback(Q=>{Q.preventDefault(),ne.current=Q.clientX,te.current=N,K(!0)},[N]);S.useEffect(()=>{!$||X||H(Q=>Kt(Q))},[Kt,$,X]),S.useEffect(()=>{if(!$)return;const Q=()=>{H(oe=>Kt(oe))};return window.addEventListener("resize",Q),()=>window.removeEventListener("resize",Q)},[Kt,$]);const Wc=S.useCallback(()=>{H(Q=>Kt(Q)),q(!0),requestAnimationFrame(()=>{E.current?.setTab("review")})},[Kt]),Hc=S.useCallback(Q=>{i(Q.target.value);const oe=Q.target;oe.style.height="auto";const Be=oe.scrollHeight;oe.style.height=`${Math.max(60,Math.min(Be,300))}px`},[]),Gn=vt&&ve?t.jsx(xc,{workspaceId:ve,branchName:ys,targetBranch:ls,commitMessage:Hs,changes:Ct,gitStatus:st,isGitStatusLoading:xt,canRunGitOperations:Fe,onOpenChanges:Wc,onRefreshCommitMessage:ds,onConflict:hs,className:"mb-1.5"}):null;return e?t.jsxs("div",{className:"flex-1 flex flex-col h-full bg-background relative overflow-hidden",children:[t.jsxs("div",{className:"px-6 py-3 flex items-center justify-between border-b border-border/60 bg-background z-20 flex-shrink-0",children:[t.jsxs("div",{className:"flex flex-col min-w-0 flex-1 mr-4",children:[t.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${e.projectColor.replace("text-","bg-")}`}),t.jsx("span",{className:"text-xs text-muted-foreground truncate",children:e.projectName}),e.projectArchivedAt&&t.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground shrink-0",children:e.projectRepoDeletedAt?v("源码已删除"):v("已删除")}),t.jsx("span",{className:"text-muted-foreground/40 text-xs",children:"/"}),t.jsx("span",{className:"text-xs text-muted-foreground/70 font-mono truncate",children:e.branch})]}),t.jsx("h2",{className:"text-lg font-semibold text-foreground break-words line-clamp-2",children:e.title})]}),t.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[t.jsx(_0,{status:e.status,onChangeStatus:!we&&o?Q=>o(e.id,Q):void 0}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:Xs,disabled:!ze||we,className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground/70 hover:text-foreground hover:bg-muted transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:v("Open in IDE"),children:t.jsx(ri,{size:16})}),(s||$e)&&!we&&t.jsxs("div",{className:"relative",ref:F,children:[t.jsx("button",{onClick:()=>j(Q=>!Q),className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground/70 hover:text-foreground hover:bg-muted transition-colors",title:v("More actions"),children:t.jsx(Ka,{size:16})}),_&&t.jsxs("div",{className:"absolute right-0 top-full mt-2 w-44 bg-background rounded-lg border border-border shadow-lg z-50 py-1",children:[$e&&t.jsxs("button",{onClick:()=>{m(!0),j(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50 transition-colors",children:[t.jsx(ts,{size:15}),t.jsx("span",{children:v("创建 TeamRun")})]}),t.jsxs("button",{onClick:()=>{a(!0),j(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50 transition-colors",children:[t.jsx(ad,{size:15}),t.jsx("span",{children:v("重新开始")})]}),s&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"my-1 border-t border-border/60"}),t.jsxs("button",{onClick:()=>{w(!0),j(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-destructive hover:bg-destructive/10 transition-colors",children:[t.jsx(Sn,{size:15}),t.jsx("span",{children:v("删除任务")})]})]})]})]})]})]})]}),Fe&&ve&&st&&t.jsx(n0,{workspaceId:ve,gitStatus:st,onResolve:()=>hs()}),t.jsxs("div",{ref:he,className:"flex-1 flex overflow-hidden",children:[t.jsx("div",{className:"flex min-w-0 flex-1 flex-col bg-background relative",children:Ie&&_e?A?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-border px-4 py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-xs font-semibold text-foreground",children:v("Invocation details")}),t.jsx("div",{className:"truncate text-[11px] text-muted-foreground",children:A})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(mc,{session:V,providers:De,usage:Kn,providerIdFallback:ue?.providerId,agentTypeFallback:V?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Te,{type:"button",size:"sm",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-border/70 bg-background/60 px-2 text-xs font-medium text-muted-foreground hover:border-muted-foreground/40 hover:bg-muted hover:text-foreground",onClick:gi,children:[t.jsx(Ls,{size:13}),t.jsx("span",{children:v("Team room")})]})]})]}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:L,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsx("div",{ref:O,className:"w-full max-w-4xl mx-auto",children:jr?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:v("Loading logs...")})]}):fs.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:v(me?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(zr,{logs:fs,isOutputActive:Nr,lastExitAt:Rr,onUserToggleDetails:z,workingDir:ze,onOpenWorkspaceFile:le,onOpenPreviewUrl:ye})})}),!U&&t.jsxs("button",{onClick:()=>Y(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-background/90 backdrop-blur-sm border border-border rounded-full shadow-md text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-all","aria-label":v("Scroll to bottom"),children:[t.jsx(nr,{size:14}),t.jsx("span",{children:v("回到底部")})]})]}),fe.length>0&&t.jsx("div",{className:"px-6 pt-2 pb-1 bg-background flex-shrink-0 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx(Hr,{todos:fe})})})]}):t.jsx(wl,{teamRun:_e,messages:at??_e.messages??[],readOnly:we,readOnlyMessage:ke,onSendMessage:vi,onViewInvocationSession:Er,changeSummaryBar:Gn,centered:!0,workingDir:ze,onOpenWorkspaceFile:le,onOpenPreviewUrl:re}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:L,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsxs("div",{ref:O,className:"w-full min-w-0 max-w-4xl mx-auto",children:[(Ze||Ve?.body)&&t.jsx("div",{className:"mb-4 pb-4 border-b border-border/60 min-w-0",children:Ze?t.jsx("p",{className:"text-sm text-muted-foreground/70 italic",children:v("Loading...")}):Ve?.body?t.jsx("div",{className:"text-sm text-muted-foreground leading-relaxed prose prose-sm max-w-none break-words overflow-hidden",children:t.jsx(fn,{urlTransform:p0,components:Ea,children:Ve.body})}):null}),ie&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-muted-foreground/70 text-sm",children:[ie.status==="running"&&t.jsxs(t.Fragment,{children:[t.jsxs("svg",{className:"animate-spin h-3.5 w-3.5 shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:v("Setup ({current}/{total}): {command}",{current:ie.currentIndex,total:ie.totalCommands,command:ie.currentCommand})})]}),ie.status==="completed"&&t.jsx("span",{className:"text-success",children:v("Setup 完成")}),ie.status==="failed"&&t.jsx("span",{className:"text-destructive/80",children:v("Setup 失败: {error}",{error:ie.error})})]}),!we&&g&&(pe||lt)?t.jsx("div",{className:"flex justify-center py-3",children:t.jsx(ia,{state:g,onRetry:g.status==="failed"?Ss:void 0})}):null,pe?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:v("Loading...")})]}):lt?jr?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:v("Loading logs...")})]}):fs.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:v(me?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(zr,{logs:fs,isOutputActive:Nr,lastExitAt:Rr,onUserToggleDetails:z,workingDir:ze,onOpenWorkspaceFile:le,onOpenPreviewUrl:ye}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[t.jsx("div",{className:"w-14 h-14 bg-muted/50 rounded-2xl border border-border/60 flex items-center justify-center mb-5",children:t.jsx(Xt,{size:24,className:"text-muted-foreground/70 ml-0.5"})}),t.jsx("h3",{className:"text-base font-medium text-foreground mb-1.5",children:v(we?"项目为只读历史":"尚未启动 Agent")}),t.jsx("p",{className:"text-sm text-muted-foreground mb-6 max-w-xs",children:we?ke:v("选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。")}),!we&&g?t.jsx(ia,{state:g}):null,!we&&t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[t.jsxs(Te,{onClick:Ss,disabled:!!(g&&g.status!=="failed"),children:[t.jsx(Xt,{size:16,className:"mr-1.5"}),g?.status==="failed"?v("重试启动 Agent"):v("启动 Agent")]}),$e&&t.jsxs(Te,{variant:"outline",onClick:()=>m(!0),children:[t.jsx(ts,{size:16,className:"mr-1.5"}),v("创建 TeamRun")]})]})]})]})}),!U&&t.jsxs("button",{onClick:()=>Y(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-background/90 backdrop-blur-sm border border-border rounded-full shadow-md text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-all","aria-label":v("Scroll to bottom"),children:[t.jsx(nr,{size:14}),t.jsx("span",{children:v("回到底部")})]})]}),fe.length>0&&t.jsx("div",{className:"px-6 pt-2 pb-1 bg-background flex-shrink-0 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx(Hr,{todos:fe})})}),we?t.jsx("div",{className:"p-6 pt-3 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx("div",{className:"bg-muted/50 rounded-xl border border-border px-4 py-3 text-sm text-muted-foreground",children:ke})})}):Ge?t.jsx("div",{className:"p-6 pt-3 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsxs("div",{className:"flex items-center justify-between bg-muted/50 rounded-xl border border-border px-4 py-3",children:[t.jsx("span",{className:"text-sm text-muted-foreground",children:v("代码已合并,以上为历史沟通记录")}),t.jsxs(Te,{size:"sm",onClick:Ss,children:[t.jsx(Xt,{size:14,className:"mr-1.5"}),v("启动新 Agent")]})]})})}):t.jsxs("div",{className:"p-6 pt-2 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-transparent",onDragOver:Oc,onDragLeave:Bc,onDrop:Fc,children:[t.jsxs("div",{className:"max-w-4xl mx-auto",children:[Gn,Je?t.jsx(Ba,{sessionId:Je}):null,t.jsxs("div",{ref:B,className:`relative bg-background rounded-xl border hover:border-ring/40 focus-within:border-ring/60 transition-colors duration-200 ${Vn?"border-info bg-info/5":"border-border"}`,children:[t.jsx(hn,{files:Ue,onRemove:St}),t.jsx("textarea",{ref:R,value:n,onChange:Hc,onPaste:Ic,onKeyDown:Q=>{it.handleKeyDown(Q)||et.handleKeyDown(Q)||Q.key==="Enter"&&!Q.shiftKey&&!Q.repeat&&!Q.nativeEvent.isComposing&&Q.nativeEvent.keyCode!==229&&(Q.preventDefault(),Yn())},rows:1,placeholder:v(Vn?"Drop files here...":lt&&!me?"Continue conversation...":"Message Agent..."),className:"w-full px-4 pt-4 pb-2 bg-transparent border-none focus:outline-none resize-none text-sm text-foreground placeholder-muted-foreground/70 leading-relaxed",style:{minHeight:"60px",maxHeight:"300px"}}),t.jsx("input",{ref:M,type:"file",multiple:!0,className:"hidden",onChange:Lc}),t.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[t.jsx("div",{className:"flex items-center gap-1",children:t.jsx("button",{onClick:()=>M.current?.click(),className:"p-2 text-muted-foreground/70 hover:text-muted-foreground hover:bg-muted rounded-lg transition-colors",title:v("Upload file"),children:t.jsx(yn,{size:18})})}),t.jsxs("div",{className:"flex items-center gap-2",children:[ge&&De&&t.jsx(Fa,{providers:De,currentProviderId:Ee,agentType:ge.agentType,runtimeType:ge.runtimeType,onSelect:Ye}),t.jsx(_n,{usage:Kn}),me&&!n.trim()&&!jt?t.jsx("button",{onClick:Pc,disabled:xi.isPending||Se,className:"p-2 rounded-lg transition-all duration-200 bg-destructive text-white hover:bg-destructive/90 disabled:opacity-50",children:t.jsx(Ds,{size:14})}):t.jsx("button",{onClick:Yn,disabled:!n.trim()&&!jt||Lt,className:`p-2 rounded-lg transition-all duration-200 ${(n.trim()||jt)&&!Lt?"bg-primary text-primary-foreground hover:bg-primary/90":"bg-transparent text-muted-foreground/50 cursor-not-allowed"}`,children:t.jsx(vn,{size:18})})]})]})]})]}),t.jsx(Wr,{open:et.query!==null,anchorRef:B,commands:et.filteredCommands,selectedIndex:et.selectedIndex,query:et.query??"",hasCatalog:et.allCommands.length>0,onSelect:et.applyCommand}),t.jsx(Wr,{open:it.query!==null,anchorRef:B,commands:it.filteredSkills,selectedIndex:it.selectedIndex,query:it.query??"",hasCatalog:it.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",onSelect:it.applySkill})]})]})}),$&&t.jsx("div",{className:"w-1 cursor-col-resize hover:bg-border active:bg-ring/40 transition-colors z-50 -ml-[2px] flex-shrink-0 h-full",onMouseDown:zc,role:"separator","aria-orientation":"vertical","aria-label":v("调整工作区宽度")}),t.jsx("div",{className:"flex h-full flex-shrink-0 bg-background",style:{width:$?Wi+N:Wi},children:t.jsx(uc,{sessionId:lt||void 0,workspaceId:Me,workingDir:ze,projectId:e.projectId,readOnly:we,repoDeleted:xe,teamRun:_e,teamStatus:_e?t.jsx(Rl,{teamRun:_e,workspaces:G,selectedWorkspaceId:Me,onSelectWorkspace:D,onViewInvocationSession:Er}):void 0,workspaces:G,selectedWorkspaceId:Me,onSelectWorkspace:D,variant:"rail",expanded:$,onExpandedChange:Q=>{Q&&H(oe=>Kt(oe)),q(Q)},minContentWidth:js,tabRef:E,gitAvailable:Pe,gitProps:Fe&&ve?{branchName:ys,targetBranch:ls,commitMessage:Hs,canRunGitOperations:!0,onRefreshCommitMessage:ds,onConflict:hs,onResolveConflicts:()=>hs()}:void 0})})]}),!we&&t.jsx(hc,{isOpen:l,onClose:()=>d(!1),taskId:e.id,projectId:e.projectId,taskTitle:Ve?.title??e.title,taskDescription:Ve?.body??"",taskPrompt:Ve?.prompt,projectIsGitRepo:e.isGitRepo,projectWorktreeReady:e.worktreeReady,projectGitReason:e.reason,onStarted:()=>p?.(e.id)}),$e&&!we&&t.jsx(i0,{isOpen:c,onClose:()=>m(!1),taskId:e.id}),Fe&&$s&&pt&&t.jsx(vc,{open:f,onOpenChange:Q=>{b(Q),Q||k(null)},workspaceId:$s,conflictOp:pt.conflictOp,conflictedFiles:pt.conflictedFiles,sourceBranch:yr,targetBranch:cs,operation:st?.operation,worktreePath:br,mergeAborted:pt.mergeAborted,mergeStrategy:pt.mergeStrategy,sourceWorkspaceId:pt.sourceWorkspaceId,targetWorkspaceId:pt.targetWorkspaceId,sourceWorktreePath:pt.sourceWorktreePath,targetWorktreePath:pt.targetWorktreePath,sessions:bs,currentSessionId:Ie?void 0:lt,teamRunId:_e?.id}),t.jsx(mn,{isOpen:y,onClose:()=>a(!1),onConfirm:Cr,title:v("重新开始任务"),description:t.jsx("p",{children:v("将归档当前工作区并自动在新 Worktree 中重新启动 Agent,旧工作区内容保留供参考。")}),confirmText:v("确认重试"),variant:"default",isLoading:h}),t.jsx(In,{isOpen:x,onClose:()=>w(!1),onConfirm:kr,taskId:e.id,taskTitle:e.title,workspaces:G,isLoading:r})]}):t.jsx(x0,{})}function qn(e){switch(e){case Ht.TODO:return be.Pending;case Ht.IN_PROGRESS:return be.Running;case Ht.IN_REVIEW:return be.Review;case Ht.DONE:return be.Done;case Ht.CANCELLED:return be.Cancelled}}function y0(e){switch(e){case be.Pending:return Ht.TODO;case be.Running:return Ht.IN_PROGRESS;case be.Review:return Ht.IN_REVIEW;case be.Done:return Ht.DONE;case be.Cancelled:return Ht.CANCELLED}}function S0(e){switch(e){case Nt.CLAUDE_CODE:return"Claude Code";case Nt.GEMINI_CLI:return"Gemini CLI";case Nt.CURSOR_AGENT:return"Cursor Agent";case Nt.CODEX:return"Codex";case Nt.QWEN_CODE:return"Qwen Code";case Nt.KIRO_CLI:return"Kiro CLI";case Nt.OPENCODE:return"OpenCode";case Nt.PI_CODING_AGENT:return"Pi Coding Agent";case Nt.GROK_BUILD:return"Grok Build";case Nt.MINION_CODE:return"Minion Code"}}const Jr=["text-indigo-600","text-emerald-600","text-rose-600","text-amber-600","text-cyan-600","text-violet-600","text-teal-600","text-pink-600"];function bc(e,s){let r=0;for(let o=0;o<e.length;o++)r=(r<<5)-r+e.charCodeAt(o)|0;return Math.abs(r)%s}function w0(e){return{id:e.id,name:e.name,color:e.color||Jr[bc(e.name,Jr.length)],isGitRepo:e.isGitRepo,worktreeReady:e.worktreeReady,reason:e.reason,archivedAt:e.archivedAt??null,repoDeletedAt:e.repoDeletedAt??null}}function C0(e,s){const r=e.preferredWorkspace?e.preferredWorkspace.workspaceKind===_t.MAIN_DIRECTORY?"Project directory":e.preferredWorkspace.branchName:"—";return{id:e.id,projectId:e.projectId,title:e.title,status:qn(e.status),agent:e.latestAgentType?S0(e.latestAgentType):"—",branch:r,description:"",updatedAt:new Date(e.updatedAt).toISOString(),isGitRepo:s?.isGitRepo,worktreeReady:s?.worktreeReady,reason:s?.reason,projectArchivedAt:s?.archivedAt??null,projectRepoDeletedAt:s?.repoDeletedAt??null}}function k0(e,s){const r=e.preferredWorkspace?e.preferredWorkspace.workspaceKind===_t.MAIN_DIRECTORY?"Project directory":e.preferredWorkspace.branchName:"—";return{id:e.id,projectId:s.id,projectName:s.name,projectColor:s.color||Jr[bc(s.name,Jr.length)],title:e.title,status:qn(e.status),branch:r,mainBranch:s.mainBranch??"main",description:"",isGitRepo:s.isGitRepo,worktreeReady:s.worktreeReady,reason:s.reason,projectArchivedAt:s.archivedAt??null,projectRepoDeletedAt:s.repoDeletedAt??null}}const na={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"};function E0(e){const s=e.split("/");return s[s.length-1]||e}function j0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function N0({workingDir:e,filePath:s,type:r}){const{t:o}=ce(),{data:g,isLoading:p,isError:v}=tc(e,s,r);if(p)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[t.jsx(Ke,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(v)return t.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:o("Failed to load diff.")});const n=g?.diff||"";if(!n.trim())return t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:o("No diff content available.")});const i=n.split(`
82
- `);return t.jsx("div",{className:"overflow-x-auto scrollbar-app-thin bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:i.map((l,d)=>{let c="",m="text-neutral-400";return l.startsWith("+")&&!l.startsWith("+++")?(c="bg-emerald-950/40",m="text-emerald-400"):l.startsWith("-")&&!l.startsWith("---")?(c="bg-red-950/40",m="text-red-400"):l.startsWith("@@")&&(c="bg-blue-950/30",m="text-blue-400"),t.jsx("div",{className:se("px-3 whitespace-pre",c,m),children:l},d)})})}function R0({entry:e,type:s,workingDir:r}){const[o,g]=S.useState(!1),p=na[e.status]||na.M,v=j0(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>g(n=>!n),className:se("flex items-center gap-2.5 w-full px-4 py-3 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("span",{className:se("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",p),children:e.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:E0(e.path)}),v&&t.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:v})]}),t.jsx("span",{className:"text-neutral-400 shrink-0",children:o?t.jsx(wt,{size:14}):t.jsx(Mt,{size:14})})]}),o&&t.jsx(N0,{workingDir:r,filePath:e.path,type:s})]})}function oa({title:e,entries:s,type:r,workingDir:o,defaultOpen:g}){const{t:p}=ce(),[v,n]=S.useState(g);return s.length===0?null:t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>n(i=>!i),className:"flex items-center gap-2 w-full px-4 py-2.5 active:bg-neutral-50",children:[t.jsx("span",{className:"text-neutral-400",children:v?t.jsx(wt,{size:14}):t.jsx(Mt,{size:14})}),t.jsx("span",{className:"text-xs font-semibold text-neutral-500 uppercase tracking-wider",children:p(e)}),t.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:s.length})]}),v&&t.jsx("div",{className:"divide-y divide-neutral-100",children:s.map(i=>t.jsx(R0,{entry:i,type:r,workingDir:o},`${r}:${i.path}`))})]})}function A0({workingDir:e}){const{t:s}=ce(),{data:r,isLoading:o,isError:g}=pi(e);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:s("No workspace selected.")});if(o)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[t.jsx(Ke,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading changes...")})]});if(g)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:s("Failed to load changes.")});const p=r?.uncommitted||[],v=r?.committed||[];return p.length+v.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[t.jsx(Fs,{size:28,className:"mb-3"}),t.jsx("span",{className:"text-sm",children:s("No pending changes")})]}):t.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin overscroll-y-contain",children:[t.jsx(oa,{title:"Uncommitted",entries:p,type:"uncommitted",workingDir:e,defaultOpen:!0}),t.jsx(oa,{title:"Committed",entries:v,type:"committed",workingDir:e,defaultOpen:!1})]})}const Hi=50,aa={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"};function T0(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?gt("{count}s ago",{count:r}):r<3600?gt("{count}m ago",{count:Math.floor(r/60)}):r<86400?gt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?gt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function M0(e){const s=e.split("/");return s[s.length-1]||e}function D0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function P0({workingDir:e,hash:s,filePath:r}){const{t:o}=ce(),{data:g,isLoading:p,isError:v}=Un(e,s,r);if(p)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[t.jsx(Ke,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(v)return t.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:o("Failed to load diff.")});const n=g?.diff||"";if(!n.trim())return t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:o("No diff content available.")});const i=n.split(`
83
- `);return t.jsx("div",{className:"overflow-x-auto scrollbar-app-thin bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:i.map((l,d)=>{let c="",m="text-neutral-400";return l.startsWith("+")&&!l.startsWith("+++")?(c="bg-emerald-950/40",m="text-emerald-400"):l.startsWith("-")&&!l.startsWith("---")?(c="bg-red-950/40",m="text-red-400"):l.startsWith("@@")&&(c="bg-blue-950/30",m="text-blue-400"),t.jsx("div",{className:se("px-3 whitespace-pre",c,m),children:l},d)})})}function L0({entry:e,workingDir:s,hash:r}){const[o,g]=S.useState(!1),p=aa[e.status]||aa.M,v=D0(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>g(n=>!n),className:se("flex items-center gap-2.5 w-full px-4 py-2.5 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("span",{className:se("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",p),children:e.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:M0(e.path)}),v&&t.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:v})]}),t.jsx("span",{className:"text-neutral-400 shrink-0",children:o?t.jsx(wt,{size:14}):t.jsx(Mt,{size:14})})]}),o&&t.jsx(P0,{workingDir:s,hash:r,filePath:e.path})]})}function I0({commit:e,workingDir:s}){const{t:r}=ce(),[o,g]=S.useState(!1),{data:p,isLoading:v}=$n(s,o?e.hash:null),n=p?.files||[];return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>g(i=>!i),className:se("flex items-start gap-3 w-full px-4 py-3 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("div",{className:"flex flex-col items-center shrink-0 pt-0.5",children:t.jsx("div",{className:se("w-2.5 h-2.5 rounded-full shrink-0",o?"bg-blue-500":"bg-neutral-300")})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs font-mono text-blue-600 shrink-0",children:e.shortHash}),t.jsx("span",{className:"text-sm text-neutral-900 truncate flex-1",children:e.message})]}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsx("span",{className:"text-[11px] text-neutral-500 truncate",children:e.author}),t.jsx("span",{className:"text-[11px] text-neutral-400",children:T0(e.timestamp)})]})]}),t.jsx("span",{className:"text-neutral-400 shrink-0 pt-0.5",children:o?t.jsx(wt,{size:14}):t.jsx(Mt,{size:14})})]}),o&&t.jsxs("div",{className:"pl-4 border-l-2 border-blue-100 ml-[22px]",children:[e.body&&t.jsx("div",{className:"px-3 py-2 text-xs text-neutral-600 whitespace-pre-wrap leading-4",children:e.body}),v?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-neutral-400",children:[t.jsx(Ke,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:r("Loading files...")})]}):n.length===0?t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:r("No files changed")}):t.jsx("div",{className:"divide-y divide-neutral-100",children:n.map(i=>t.jsx(L0,{entry:i,workingDir:s,hash:e.hash},i.path))})]})]})}function O0({workingDir:e}){const{t:s}=ce(),{data:r,isLoading:o,isError:g,fetchNextPage:p,hasNextPage:v,isFetchingNextPage:n}=wn({queryKey:de.git.log(e||""),queryFn:({pageParam:l=0})=>Ce.get("/git/log",{params:{workingDir:e||"",limit:String(Hi),skip:String(l)}}),initialPageParam:0,getNextPageParam:(l,d)=>l.commits.length<Hi?void 0:d.length*Hi,enabled:!!e}),i=r?.pages.flatMap(l=>l.commits)||[];return e?o?t.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[t.jsx(Ke,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading history...")})]}):g?t.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:s("Failed to load history.")}):i.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[t.jsx(Is,{size:28,className:"mb-3"}),t.jsx("span",{className:"text-sm",children:s("No commit history")})]}):t.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin overscroll-y-contain",children:[t.jsx("div",{className:"divide-y divide-neutral-100",children:i.map(l=>t.jsx(I0,{commit:l,workingDir:e},l.hash))}),v&&t.jsx("button",{type:"button",onClick:()=>p(),disabled:n,className:"w-full py-4 text-sm text-neutral-500 active:text-neutral-700 active:bg-neutral-50 flex items-center justify-center gap-2",children:n?t.jsxs(t.Fragment,{children:[t.jsx(Ke,{size:14,className:"animate-spin"})," ",s("Loading...")]}):s("Load more")})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:s("No workspace selected.")})}const B0=dr(),F0=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${B0}/attachments/by-path?path=${encodeURIComponent(e)}`:e;function z0({status:e}){const s={[be.Running]:"bg-blue-500",[be.Review]:"bg-amber-500",[be.Pending]:"bg-neutral-400",[be.Done]:"bg-emerald-500",[be.Cancelled]:"bg-neutral-400"};return t.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${s[e]}`})}const W0=[{key:"chat",label:"Chat",icon:ti},{key:"changes",label:"Changes",icon:Fs},{key:"history",label:"History",icon:Is},{key:"workspace",label:"Workspace",icon:ii}],H0=[{key:"chat",label:"Team room",icon:ti},{key:"team-status",label:"Team Status",icon:vs},{key:"changes",label:"Changes",icon:Fs},{key:"workspace",label:"Workspace",icon:ii}];function la({state:e,onRetry:s}){const{t:r}=ce(),o=e.status==="creating-workspace"?r("Creating Workspace..."):e.status==="creating-session"?r("Creating Session..."):e.status==="starting-session"?r("Starting Agent..."):r("启动 Agent 失败");return e.status==="failed"?t.jsxs("div",{className:"mb-5 w-full max-w-[280px] rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-left",children:[t.jsx("p",{className:"text-xs font-medium text-red-600",children:o}),e.error?t.jsx("p",{className:"mt-1 text-[11px] text-red-500 break-words",children:e.error}):null,s?t.jsxs(Te,{size:"sm",variant:"outline",className:"mt-3",onClick:s,children:[t.jsx(Xt,{size:14,className:"mr-1.5"}),r("重试启动 Agent")]}):null]}):t.jsxs("div",{className:"mb-5 flex items-center gap-2 rounded-full border border-neutral-200 bg-neutral-50 px-3 py-1.5 text-xs text-neutral-500",children:[t.jsxs("svg",{className:"h-3.5 w-3.5 animate-spin shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:o})]})}function $0({task:e,onBack:s,onDeleteTask:r,isDeleting:o,autoStartState:g,onAutoStartRecovered:p}){const{t:v}=ce(),n=_s(ee=>ee.setVisibleContext),[i,l]=S.useState("chat"),[d,c]=S.useState(""),[m,x]=S.useState(!1),[w,y]=S.useState(!1),[a,h]=S.useState(!1),[u,f]=S.useState(null),[b,C]=S.useState(void 0),k=S.useRef(0),[E,_]=S.useState(),j=S.useRef(null),A=S.useRef(null),P=S.useRef(null),T=S.useRef(null),{scrollRef:D,contentRef:W,isAtBottom:I,scrollToBottom:B,stopScroll:F}=gn({resize:"smooth",initial:"instant"}),R=bt();S.useEffect(()=>{if(!a)return;const ee=fe=>{A.current&&!A.current.contains(fe.target)&&h(!1)};return document.addEventListener("mousedown",ee),()=>document.removeEventListener("mousedown",ee)},[a]);const{data:M,isLoading:L}=Mn(e.id),{data:O}=ya(e.id),{data:U}=Sa(O?.id??""),Y=dn(O?.id??""),z=O??null,$=e.isGitRepo!==!1&&e.worktreeReady!==!1,q=S.useMemo(()=>(z?H0:W0).filter(ee=>$||ee.key!=="changes"&&ee.key!=="history"),[$,z]),N=O===null,{data:H,isLoading:X}=wa(e.id,N),K=!!e.projectArchivedAt,ne=!!e.projectRepoDeletedAt,te=v(ne?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。");S.useEffect(()=>{C(void 0),f(null),_(void 0)},[e.id]),S.useEffect(()=>{z&&i==="history"&&l("chat"),!z&&i==="team-status"&&l("chat"),q.some(ee=>ee.key===i)||l("chat")},[i,q,z]);const he=S.useMemo(()=>Cl(M,z,b),[b,z,M]);S.useEffect(()=>{b&&!M?.some(ee=>ee.id===b)&&C(void 0)},[b,M]);const le=S.useMemo(()=>M?.find(ee=>ee.id===he),[he,M]),G=S.useMemo(()=>{if(M){if(le)return ss(le);for(const ee of M)if(ee.status==="ACTIVE"&&ss(ee))return ss(ee);return ss(M[0])}},[le,M]),pe=le?.status===At.ACTIVE?le.id:void 0,ie=$&&kl(le,z),Ae=le?.branchName??"",at=le?.commitMessage,Xe=S.useMemo(()=>El(le,M,e?.mainBranch??""),[le,e?.mainBranch,M]),_e=!!(ie&&pe&&G&&!K),{data:Ie,isLoading:Pe}=Pn(pe??"",{enabled:_e}),{data:$e}=pi(G,{enabled:_e}),Oe=$e?.committed?.length,[Ve,Ze]=S.useState(!1),[Me,Re]=S.useState(null);S.useEffect(()=>{const ee=$&&(i==="changes"||i==="chat"&&_e)?"changes":$&&i==="history"?"history":null;if(!pe||!G||!ee){n(null);return}return n({workspaceId:pe,workingDir:G,tab:ee}),()=>{n(null)}},[i,$,pe,n,_e,G]);const ve=S.useMemo(()=>Ie?.conflictOp&&Ie.conflictedFiles.length>0?{conflictOp:Ie.conflictOp,conflictedFiles:Ie.conflictedFiles}:Me,[Ie?.conflictOp,Ie?.conflictedFiles,Me]),Fe=ve?.targetWorkspaceId??pe,ge=ve?.targetWorktreePath??le?.worktreePath,lt=ve?.sourceBranch??Ae,Je=ve?.targetBranch??Xe,Et=le?.sessions??[],J=S.useCallback(ee=>{Re(ee??null),Ze(!0)},[]),ue=S.useCallback(()=>e?.id?R.invalidateQueries({queryKey:de.workspaces.list(e.id)}):Promise.resolve(),[e?.id,R]),V=S.useCallback(async()=>R.fetchQuery({queryKey:de.tasks.body(e.id),queryFn:()=>Ce.get(`/tasks/${e.id}/body`)}),[R,e.id]),Z=S.useMemo(()=>{if(!M)return null;const ee=M.filter(Le=>Le.status==="ACTIVE"&&Array.isArray(Le.sessions)).flatMap(Le=>Le.sessions??[]),fe=Le=>{const jt=Le.createdAt,Lt=Le.endedAt??Le.startedAt??jt;if(!Lt)return 0;const ws=Date.parse(Lt);return Number.isNaN(ws)?0:ws},Ue=Le=>{const jt=ee.filter(Lt=>Le.includes(Lt.status));return jt.length===0?null:jt.sort((Lt,ws)=>fe(ws)-fe(Lt))[0]??null},Ne=Ue([dt.RUNNING])??Ue([dt.PENDING])??Ue([dt.COMPLETED,dt.FAILED,dt.CANCELLED]);if(Ne)return Ne;const Pt=M.filter(Le=>(Le.status==="ABANDONED"||Le.status==="MERGED"||Le.status==="HIBERNATED")&&Array.isArray(Le.sessions)).flatMap(Le=>Le.sessions??[]).filter(Le=>[dt.COMPLETED,dt.FAILED,dt.CANCELLED].includes(Le.status));return Pt.length===0?null:Pt.sort((Le,jt)=>fe(jt)-fe(Le))[0]??null},[M]),re=Z?.id??"",ye=z?u??"":re,me=S.useMemo(()=>{if(!u||!M)return null;for(const ee of M){const fe=ee.sessions?.find(Ue=>Ue.id===u);if(fe)return fe}return null},[u,M]),Se=S.useMemo(()=>{if(!u||!z?.invocations)return null;const ee=z.invocations.filter(fe=>fe.sessionId===u);return ee.length===0?null:ee.sort((fe,Ue)=>{const Ne=Date.parse(fe.updatedAt??fe.createdAt??""),St=Date.parse(Ue.updatedAt??Ue.createdAt??"");return(Number.isNaN(St)?0:St)-(Number.isNaN(Ne)?0:Ne)})[0]??null},[u,z?.invocations]),we=S.useMemo(()=>!Se?.memberId||!z?.members?null:z.members.find(ee=>ee.id===Se.memberId)??null,[Se?.memberId,z?.members]),xe=u?me:Z??null,ke=S.useMemo(()=>{if(xe?.workspaceId)return xe.workspaceId;if(!(!xe||!M))return M.find(ee=>ee.sessions?.some(fe=>fe.id===xe.id))?.id},[xe,M]),De=S.useCallback((ee,fe)=>{const Ne=(fe&&M?.some(St=>St.id===fe)?fe:void 0)??ke??he??void 0;Ne&&C(Ne),k.current+=1,_({id:k.current,url:ee,workspaceId:Ne}),l("workspace")},[ke,he,M]),Ee=S.useCallback(ee=>{De(ee,ke)},[ke,De]),{isActive:Ye,isCancelling:Ge}=Pa(xe?.id??"",xe?.status),ze=S.useMemo(()=>!Z||!M?!1:!M.some(fe=>fe.status==="ACTIVE"&&fe.sessions?.some(Ue=>Ue.id===Z.id)),[Z,M]),{data:et}=Bs(),[it,Dt]=S.useState(null),vt=it?.sessionId===re?it.providerId:Z?.providerId??null,st=S.useCallback(ee=>{Dt({sessionId:re,providerId:ee})},[re]),xt=La({agentType:Z?.agentType,workingDir:G,input:d,setInput:c,textareaRef:P,minHeight:40,maxHeight:140}),Ct=_c({agentType:Z?.agentType,workingDir:G,input:d,setInput:c,textareaRef:P,minHeight:40,maxHeight:140}),bs=G&&le?le.id:void 0,ys=bn(),Hs=Dn(),ls=Oa(),{isConnected:pt,isLoadingSnapshot:$s,isOutputActive:br,lastExitAt:yr,logs:cs,entries:nt,attach:Ut}=za({sessionId:ye,sessionStatus:xe?.status,sessionStartedAt:xe?.startedAt??xe?.createdAt,sessionEndedAt:xe?.endedAt??(Ye?null:xe?.updatedAt),onExit:S.useCallback(()=>{R.invalidateQueries({queryKey:["workspaces"]})},[R])}),{todos:ds}=Wa(nt),{files:Sr,addFiles:us,removeFile:wr,clear:Us,buildMarkdownLinks:qs,hasFiles:qt,isUploading:zt}=un(),Ks=S.useMemo(()=>fc(xe),[xe?.tokenUsage]),Cr=Ia(cs,Ks);S.useEffect(()=>{ye&&pt&&Ut()},[ye,pt,Ut]);const Ss=S.useRef(null);S.useEffect(()=>{if(Ss.current!==e.id&&D.current){const ee=D.current;requestAnimationFrame(()=>{ee.scrollTop=ee.scrollHeight})}Ss.current=e.id},[e.id,D]);const Xs=S.useRef(!1),kr=S.useCallback(async()=>{if(!d.trim()&&!qt||!re||Xs.current||zt)return;Xs.current=!0;const ee=qs(),fe=[d.trim(),ee].filter(Boolean).join(`
84
-
85
- `);c(""),Us(),P.current&&(P.current.style.height="40px"),ys.mutate({id:re,message:fe,providerId:vt??void 0},{onSuccess:()=>Ut(),onSettled:()=>{Xs.current=!1}})},[d,re,ys,Ut,qt,zt,qs,Us,vt]),Er=S.useCallback(async()=>{re&&(await ls.mutateAsync(re),R.invalidateQueries({queryKey:["workspaces"]}))},[re,ls,R]),gi=S.useCallback(ee=>Y.mutateAsync(ee),[Y]),hs=S.useCallback(ee=>{f(ee),l("chat"),requestAnimationFrame(()=>{B()})},[B]),vi=S.useCallback(()=>{f(null)},[]),Qt=S.useCallback(()=>{l("changes")},[]),Ys=_e&&pe?t.jsx(xc,{workspaceId:pe,branchName:Ae,targetBranch:Xe,commitMessage:at,changes:$e,gitStatus:Ie,isGitStatusLoading:Pe,canRunGitOperations:ie,onOpenChanges:Qt,onRefreshCommitMessage:ue,onConflict:J,className:"mb-2"}):null,jr=S.useCallback(ee=>{const fe=ee.target.files;fe&&fe.length>0&&us(Array.from(fe)),ee.target.value=""},[us]),Nr=S.useCallback(ee=>{const fe=ee.clipboardData.items,Ue=[];for(const Ne of fe)if(Ne.kind==="file"){const St=Ne.getAsFile();St&&Ue.push(St)}Ue.length>0&&(ee.preventDefault(),us(Ue))},[us]),Rr=S.useCallback(ee=>{c(ee.target.value);const fe=ee.target;fe.style.height="auto",fe.style.height=`${Math.max(40,Math.min(fe.scrollHeight,140))}px`},[]),fs=S.useCallback(()=>{bs&&Hs.mutate({workspaceId:bs})},[Hs,bs]),ms=S.useRef(null);return S.useEffect(()=>{const ee=window.visualViewport;if(!ee)return;let fe=!1;const Ue=()=>{ms.current&&(ms.current.style.height=`${ee.height}px`,ms.current.style.top=`${ee.offsetTop}px`)},Ne=()=>Ue(),St=()=>{fe||Ue()},Pt=()=>{fe=!0},Le=()=>{fe=!1,requestAnimationFrame(Ue)};return ee.addEventListener("resize",Ne),ee.addEventListener("scroll",St),document.addEventListener("touchstart",Pt,{passive:!0}),document.addEventListener("touchend",Le,{passive:!0}),document.addEventListener("touchcancel",Le,{passive:!0}),()=>{ee.removeEventListener("resize",Ne),ee.removeEventListener("scroll",St),document.removeEventListener("touchstart",Pt),document.removeEventListener("touchend",Le),document.removeEventListener("touchcancel",Le)}},[]),S.useEffect(()=>{const ee=ms.current;if(!ee)return;const fe=Ue=>{let Ne=Ue.target;for(;Ne&&Ne!==ee;){if(Ne.tagName==="TEXTAREA"){if(Ne.scrollHeight>Ne.clientHeight)return;Ne=Ne.parentElement;continue}const Pt=window.getComputedStyle(Ne).overflowY;if((Pt==="auto"||Pt==="scroll")&&Ne.scrollHeight>Ne.clientHeight)return;Ne=Ne.parentElement}Ue.preventDefault()};return ee.addEventListener("touchmove",fe,{passive:!1}),()=>ee.removeEventListener("touchmove",fe)},[]),t.jsxs("div",{ref:ms,className:"fixed inset-x-0 top-0 flex flex-col h-dvh bg-white overflow-hidden overscroll-none",children:[t.jsxs("header",{className:"shrink-0 bg-white border-b border-neutral-200 z-20",children:[t.jsxs("div",{className:"flex items-center h-11 px-2.5 gap-1.5",children:[t.jsx("button",{onClick:s,className:"p-1.5 -ml-0.5 text-neutral-600 active:text-neutral-900",children:t.jsx(Ls,{size:18})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("h1",{className:"text-[13px] font-bold text-neutral-900 truncate leading-tight",children:e.title}),t.jsxs("div",{className:"flex min-w-0 items-center gap-1 text-[11px] text-neutral-500 leading-tight",children:[t.jsx("span",{className:`truncate font-medium ${e.projectColor}`,children:e.projectName}),e.projectArchivedAt&&t.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?v("源码已删除"):v("已删除")}),t.jsx("span",{className:"text-neutral-300",children:"/"}),t.jsx("span",{className:"font-mono truncate",children:e.branch})]})]}),t.jsx(z0,{status:e.status}),t.jsx("button",{onClick:fs,disabled:!bs||K,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:t.jsx(ri,{size:16})}),r&&!K&&t.jsxs("div",{className:"relative",ref:A,children:[t.jsx("button",{onClick:()=>h(ee=>!ee),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:t.jsx(Ka,{size:16})}),a&&t.jsx("div",{className:"absolute right-0 top-full mt-1 w-40 bg-white rounded-lg border border-neutral-200 shadow-lg z-50 py-1",children:t.jsxs("button",{onClick:()=>{y(!0),h(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 active:bg-red-50",children:[t.jsx(Sn,{size:15}),t.jsx("span",{children:v("删除任务")})]})})]})]}),t.jsx("div",{className:"flex border-t border-neutral-100",children:q.map(({key:ee,label:fe,icon:Ue})=>t.jsxs("button",{onClick:()=>l(ee),className:`flex min-w-0 flex-1 items-center justify-center gap-1 px-1 py-2 text-[11px] font-medium transition-colors ${i===ee?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[t.jsx(Ue,{size:13,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:v(fe)})]},ee))})]}),i==="chat"&&(z?t.jsx("main",{className:"flex-1 min-h-0 overflow-hidden",children:u?t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[t.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-neutral-200 px-3 py-2.5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-xs font-semibold text-neutral-900",children:v("Invocation details")}),t.jsx("div",{className:"truncate text-[11px] text-neutral-500",children:u})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.jsx(mc,{session:xe,providers:et,usage:Cr,compact:!0,providerIdFallback:we?.providerId,agentTypeFallback:xe?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Te,{type:"button",size:"xs",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-neutral-200/70 bg-white/60 px-1.5 text-[11px] font-medium text-neutral-500 hover:border-neutral-300 hover:bg-neutral-100 hover:text-neutral-900 active:bg-neutral-100",onClick:vi,children:[t.jsx(Ls,{size:12}),t.jsx("span",{children:v("Team room")})]})]})]}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:D,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:t.jsx("div",{ref:W,children:$s?t.jsx($i,{label:v("Loading logs...")}):cs.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:v(Ye?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(zr,{logs:cs,isOutputActive:br,lastExitAt:yr,onUserToggleDetails:F,onOpenPreviewUrl:Ee})})}),!I&&t.jsxs("button",{onClick:()=>B(),className:"absolute bottom-2 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1 px-2.5 py-1 bg-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-[11px] text-neutral-600 active:bg-white transition-all","aria-label":v("Scroll to bottom"),children:[t.jsx(nr,{size:12}),t.jsx("span",{children:v("回到底部")})]})]}),ds.length>0&&t.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:t.jsx(Hr,{todos:ds,compact:!0})})]}):t.jsx(wl,{teamRun:z,messages:U??z.messages??[],readOnly:K,readOnlyMessage:te,onSendMessage:gi,onViewInvocationSession:hs,changeSummaryBar:Ys,compactComposer:!0,workingDir:G,onOpenPreviewUrl:De})}):t.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:D,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:t.jsxs("div",{ref:W,children:[t.jsx("div",{className:"mb-3 pb-2 border-b border-neutral-100",children:X?t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:v("Loading...")}):H?.body?t.jsx("div",{className:"text-[13px] text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:t.jsx(fn,{urlTransform:F0,components:Ea,children:H.body})}):t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),!K&&g&&(L||re)?t.jsx("div",{className:"flex justify-center py-2",children:t.jsx(la,{state:g,onRetry:g.status==="failed"?async()=>{await V(),x(!0)}:void 0})}):null,L?t.jsx($i,{label:"Loading..."}):re?$s?t.jsx($i,{label:"Loading logs..."}):cs.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:Ye?"Waiting for agent output...":"No logs recorded."}):t.jsx(zr,{logs:cs,isOutputActive:br,lastExitAt:yr,onUserToggleDetails:F,onOpenPreviewUrl:Ee}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[t.jsx("div",{className:"w-12 h-12 bg-neutral-50 rounded-xl border border-neutral-100 flex items-center justify-center mb-4",children:t.jsx(Xt,{size:20,className:"text-neutral-400 ml-0.5"})}),t.jsx("h3",{className:"text-sm font-medium text-neutral-900 mb-1",children:v("尚未启动 Agent")}),t.jsx("p",{className:"text-xs text-neutral-500 mb-5 max-w-[240px]",children:K?te:v("选择一个 Agent 来执行此任务")}),!K&&g?t.jsx(la,{state:g}):null,!K&&t.jsxs(Te,{onClick:async()=>{await V(),x(!0)},disabled:!!(g&&g.status!=="failed"),children:[t.jsx(Xt,{size:16,className:"mr-1.5"}),g?.status==="failed"?v("重试启动 Agent"):v("启动 Agent")]})]})]})}),!I&&t.jsxs("button",{onClick:()=>B(),className:"absolute bottom-2 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1 px-2.5 py-1 bg-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-[11px] text-neutral-600 active:bg-white transition-all","aria-label":"Scroll to bottom",children:[t.jsx(nr,{size:12}),t.jsx("span",{children:v("回到底部")})]})]}),ds.length>0&&t.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:t.jsx(Hr,{todos:ds,compact:!0})}),K?t.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:t.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:te})}):ze?t.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:t.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2",children:[t.jsx("span",{className:"text-xs text-neutral-500",children:v("代码已合并,以上为历史沟通记录")}),t.jsxs(Te,{size:"sm",onClick:async()=>{await V(),x(!0)},children:[t.jsx(Xt,{size:14,className:"mr-1.5"}),v("启动新 Agent")]})]})}):re&&t.jsxs("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:[Ys,t.jsx(Ba,{sessionId:ye||re,compact:!0}),t.jsxs("div",{ref:j,className:"relative bg-white rounded-xl border border-neutral-200 shadow-sm focus-within:border-neutral-300",children:[t.jsx(hn,{files:Sr,onRemove:wr}),t.jsx("textarea",{ref:P,value:d,onChange:Rr,onPaste:Nr,onKeyDown:ee=>{Ct.handleKeyDown(ee)||xt.handleKeyDown(ee)||ee.key==="Enter"&&!ee.shiftKey&&!ee.repeat&&!ee.nativeEvent.isComposing&&ee.nativeEvent.keyCode!==229&&(ee.preventDefault(),kr())},rows:1,placeholder:Ye?"Message Agent...":"Continue conversation...",className:"w-full px-3 pt-2.5 pb-1 bg-transparent border-none focus:outline-none resize-none text-[15px] text-neutral-900 placeholder-neutral-400",style:{minHeight:40,maxHeight:140}}),t.jsx("input",{ref:T,type:"file",multiple:!0,className:"hidden",onChange:jr}),t.jsxs("div",{className:"flex items-center justify-between px-2 pb-1.5",children:[t.jsx("div",{className:"flex items-center gap-0.5",children:t.jsx("button",{onClick:()=>T.current?.click(),className:"p-1 text-neutral-400 active:text-neutral-600 rounded-lg",children:t.jsx(yn,{size:15})})}),t.jsxs("div",{className:"flex items-center gap-1",children:[Z&&et&&t.jsx(Fa,{providers:et,currentProviderId:vt,agentType:Z.agentType,runtimeType:Z.runtimeType,onSelect:st}),t.jsx(_n,{usage:Cr}),Ye&&!d.trim()&&!qt?t.jsx("button",{onClick:Er,disabled:ls.isPending||Ge,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:t.jsx(Ds,{size:12})}):t.jsx("button",{onClick:kr,disabled:!d.trim()&&!qt||zt,className:`p-1.5 rounded-lg transition-colors ${(d.trim()||qt)&&!zt?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:t.jsx(vn,{size:15})})]})]})]}),t.jsx(Wr,{open:xt.query!==null,anchorRef:j,commands:xt.filteredCommands,selectedIndex:xt.selectedIndex,query:xt.query??"",hasCatalog:xt.allCommands.length>0,compact:!0,onSelect:xt.applyCommand}),t.jsx(Wr,{open:Ct.query!==null,anchorRef:j,commands:Ct.filteredSkills,selectedIndex:Ct.selectedIndex,query:Ct.query??"",hasCatalog:Ct.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",compact:!0,onSelect:Ct.applySkill})]})]})),i==="team-status"&&z&&t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:t.jsx(Rl,{teamRun:z,workspaces:M,selectedWorkspaceId:he,onSelectWorkspace:C,onViewInvocationSession:hs})}),i==="changes"&&$&&t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[M&&M.length>1&&t.jsx("div",{className:"shrink-0 border-b border-neutral-100 bg-white px-3 py-2",children:t.jsx(dc,{workspaces:M,teamRun:z,selectedWorkspaceId:he,onSelectWorkspace:C,className:"w-full",buttonClassName:"w-full max-w-none min-w-0 justify-start"})}),ie&&pe&&t.jsx("div",{className:"shrink-0",children:t.jsx(ic,{workspaceId:pe,branchName:Ae,targetBranch:Xe,commitMessage:at,committedFileCount:Oe,onRefreshCommitMessage:ue,onConflict:J,onResolveConflicts:()=>J()})}),t.jsx(A0,{workingDir:G})]}),i==="history"&&t.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:t.jsx(O0,{workingDir:G})}),i==="workspace"&&t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(uc,{sessionId:re||void 0,workspaceId:he,workingDir:G,projectId:e.projectId,className:"h-full",hideChanges:!0,gitAvailable:$,readOnly:K,repoDeleted:ne,previewRequest:E,onPreviewRequestHandled:ee=>{_(fe=>fe?.id===ee?void 0:fe)}})}),!K&&t.jsx(hc,{isOpen:m,onClose:()=>x(!1),taskId:e.id,projectId:e.projectId,taskTitle:H?.title??e.title,taskDescription:H?.body??"",taskPrompt:H?.prompt,projectIsGitRepo:e.isGitRepo,projectWorktreeReady:e.worktreeReady,projectGitReason:e.reason,onStarted:()=>p?.(e.id)}),t.jsx(In,{isOpen:w,onClose:()=>y(!1),onConfirm:()=>{r?.(e.id),y(!1)},taskId:e.id,taskTitle:e.title,workspaces:M,isLoading:o}),Ve&&ve&&Fe&&t.jsx(vc,{open:Ve,onOpenChange:ee=>{Ze(ee),ee||Re(null)},workspaceId:Fe,conflictOp:ve.conflictOp,conflictedFiles:ve.conflictedFiles,sourceBranch:lt,targetBranch:Je,operation:Ie?.operation,worktreePath:ge,mergeAborted:ve.mergeAborted,mergeStrategy:ve.mergeStrategy,sourceWorkspaceId:ve.sourceWorkspaceId,targetWorkspaceId:ve.targetWorkspaceId,sourceWorktreePath:ve.sourceWorktreePath,targetWorktreePath:ve.targetWorktreePath,sessions:Et,currentSessionId:z?void 0:re,teamRunId:z?.id})]})}function $i({label:e}){return t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:e})]})}var U0=Object.defineProperty,ei=Object.getOwnPropertySymbols,yc=Object.prototype.hasOwnProperty,Sc=Object.prototype.propertyIsEnumerable,ca=(e,s,r)=>s in e?U0(e,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[s]=r,on=(e,s)=>{for(var r in s||(s={}))yc.call(s,r)&&ca(e,r,s[r]);if(ei)for(var r of ei(s))Sc.call(s,r)&&ca(e,r,s[r]);return e},an=(e,s)=>{var r={};for(var o in e)yc.call(e,o)&&s.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&ei)for(var o of ei(e))s.indexOf(o)<0&&Sc.call(e,o)&&(r[o]=e[o]);return r};var xs;(e=>{const s=class je{constructor(i,l,d,c){if(this.version=i,this.errorCorrectionLevel=l,this.modules=[],this.isFunction=[],i<je.MIN_VERSION||i>je.MAX_VERSION)throw new RangeError("Version value out of range");if(c<-1||c>7)throw new RangeError("Mask value out of range");this.size=i*4+17;let m=[];for(let w=0;w<this.size;w++)m.push(!1);for(let w=0;w<this.size;w++)this.modules.push(m.slice()),this.isFunction.push(m.slice());this.drawFunctionPatterns();const x=this.addEccAndInterleave(d);if(this.drawCodewords(x),c==-1){let w=1e9;for(let y=0;y<8;y++){this.applyMask(y),this.drawFormatBits(y);const a=this.getPenaltyScore();a<w&&(c=y,w=a),this.applyMask(y)}}g(0<=c&&c<=7),this.mask=c,this.applyMask(c),this.drawFormatBits(c),this.isFunction=[]}static encodeText(i,l){const d=e.QrSegment.makeSegments(i);return je.encodeSegments(d,l)}static encodeBinary(i,l){const d=e.QrSegment.makeBytes(i);return je.encodeSegments([d],l)}static encodeSegments(i,l,d=1,c=40,m=-1,x=!0){if(!(je.MIN_VERSION<=d&&d<=c&&c<=je.MAX_VERSION)||m<-1||m>7)throw new RangeError("Invalid value");let w,y;for(w=d;;w++){const f=je.getNumDataCodewords(w,l)*8,b=v.getTotalBits(i,w);if(b<=f){y=b;break}if(w>=c)throw new RangeError("Data too long")}for(const f of[je.Ecc.MEDIUM,je.Ecc.QUARTILE,je.Ecc.HIGH])x&&y<=je.getNumDataCodewords(w,f)*8&&(l=f);let a=[];for(const f of i){r(f.mode.modeBits,4,a),r(f.numChars,f.mode.numCharCountBits(w),a);for(const b of f.getData())a.push(b)}g(a.length==y);const h=je.getNumDataCodewords(w,l)*8;g(a.length<=h),r(0,Math.min(4,h-a.length),a),r(0,(8-a.length%8)%8,a),g(a.length%8==0);for(let f=236;a.length<h;f^=253)r(f,8,a);let u=[];for(;u.length*8<a.length;)u.push(0);return a.forEach((f,b)=>u[b>>>3]|=f<<7-(b&7)),new je(w,l,u,m)}getModule(i,l){return 0<=i&&i<this.size&&0<=l&&l<this.size&&this.modules[l][i]}getModules(){return this.modules}drawFunctionPatterns(){for(let d=0;d<this.size;d++)this.setFunctionModule(6,d,d%2==0),this.setFunctionModule(d,6,d%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const i=this.getAlignmentPatternPositions(),l=i.length;for(let d=0;d<l;d++)for(let c=0;c<l;c++)d==0&&c==0||d==0&&c==l-1||d==l-1&&c==0||this.drawAlignmentPattern(i[d],i[c]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(i){const l=this.errorCorrectionLevel.formatBits<<3|i;let d=l;for(let m=0;m<10;m++)d=d<<1^(d>>>9)*1335;const c=(l<<10|d)^21522;g(c>>>15==0);for(let m=0;m<=5;m++)this.setFunctionModule(8,m,o(c,m));this.setFunctionModule(8,7,o(c,6)),this.setFunctionModule(8,8,o(c,7)),this.setFunctionModule(7,8,o(c,8));for(let m=9;m<15;m++)this.setFunctionModule(14-m,8,o(c,m));for(let m=0;m<8;m++)this.setFunctionModule(this.size-1-m,8,o(c,m));for(let m=8;m<15;m++)this.setFunctionModule(8,this.size-15+m,o(c,m));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let i=this.version;for(let d=0;d<12;d++)i=i<<1^(i>>>11)*7973;const l=this.version<<12|i;g(l>>>18==0);for(let d=0;d<18;d++){const c=o(l,d),m=this.size-11+d%3,x=Math.floor(d/3);this.setFunctionModule(m,x,c),this.setFunctionModule(x,m,c)}}drawFinderPattern(i,l){for(let d=-4;d<=4;d++)for(let c=-4;c<=4;c++){const m=Math.max(Math.abs(c),Math.abs(d)),x=i+c,w=l+d;0<=x&&x<this.size&&0<=w&&w<this.size&&this.setFunctionModule(x,w,m!=2&&m!=4)}}drawAlignmentPattern(i,l){for(let d=-2;d<=2;d++)for(let c=-2;c<=2;c++)this.setFunctionModule(i+c,l+d,Math.max(Math.abs(c),Math.abs(d))!=1)}setFunctionModule(i,l,d){this.modules[l][i]=d,this.isFunction[l][i]=!0}addEccAndInterleave(i){const l=this.version,d=this.errorCorrectionLevel;if(i.length!=je.getNumDataCodewords(l,d))throw new RangeError("Invalid argument");const c=je.NUM_ERROR_CORRECTION_BLOCKS[d.ordinal][l],m=je.ECC_CODEWORDS_PER_BLOCK[d.ordinal][l],x=Math.floor(je.getNumRawDataModules(l)/8),w=c-x%c,y=Math.floor(x/c);let a=[];const h=je.reedSolomonComputeDivisor(m);for(let f=0,b=0;f<c;f++){let C=i.slice(b,b+y-m+(f<w?0:1));b+=C.length;const k=je.reedSolomonComputeRemainder(C,h);f<w&&C.push(0),a.push(C.concat(k))}let u=[];for(let f=0;f<a[0].length;f++)a.forEach((b,C)=>{(f!=y-m||C>=w)&&u.push(b[f])});return g(u.length==x),u}drawCodewords(i){if(i.length!=Math.floor(je.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let l=0;for(let d=this.size-1;d>=1;d-=2){d==6&&(d=5);for(let c=0;c<this.size;c++)for(let m=0;m<2;m++){const x=d-m,y=(d+1&2)==0?this.size-1-c:c;!this.isFunction[y][x]&&l<i.length*8&&(this.modules[y][x]=o(i[l>>>3],7-(l&7)),l++)}}g(l==i.length*8)}applyMask(i){if(i<0||i>7)throw new RangeError("Mask value out of range");for(let l=0;l<this.size;l++)for(let d=0;d<this.size;d++){let c;switch(i){case 0:c=(d+l)%2==0;break;case 1:c=l%2==0;break;case 2:c=d%3==0;break;case 3:c=(d+l)%3==0;break;case 4:c=(Math.floor(d/3)+Math.floor(l/2))%2==0;break;case 5:c=d*l%2+d*l%3==0;break;case 6:c=(d*l%2+d*l%3)%2==0;break;case 7:c=((d+l)%2+d*l%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[l][d]&&c&&(this.modules[l][d]=!this.modules[l][d])}}getPenaltyScore(){let i=0;for(let m=0;m<this.size;m++){let x=!1,w=0,y=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[m][a]==x?(w++,w==5?i+=je.PENALTY_N1:w>5&&i++):(this.finderPenaltyAddHistory(w,y),x||(i+=this.finderPenaltyCountPatterns(y)*je.PENALTY_N3),x=this.modules[m][a],w=1);i+=this.finderPenaltyTerminateAndCount(x,w,y)*je.PENALTY_N3}for(let m=0;m<this.size;m++){let x=!1,w=0,y=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][m]==x?(w++,w==5?i+=je.PENALTY_N1:w>5&&i++):(this.finderPenaltyAddHistory(w,y),x||(i+=this.finderPenaltyCountPatterns(y)*je.PENALTY_N3),x=this.modules[a][m],w=1);i+=this.finderPenaltyTerminateAndCount(x,w,y)*je.PENALTY_N3}for(let m=0;m<this.size-1;m++)for(let x=0;x<this.size-1;x++){const w=this.modules[m][x];w==this.modules[m][x+1]&&w==this.modules[m+1][x]&&w==this.modules[m+1][x+1]&&(i+=je.PENALTY_N2)}let l=0;for(const m of this.modules)l=m.reduce((x,w)=>x+(w?1:0),l);const d=this.size*this.size,c=Math.ceil(Math.abs(l*20-d*10)/d)-1;return g(0<=c&&c<=9),i+=c*je.PENALTY_N4,g(0<=i&&i<=2568888),i}getAlignmentPatternPositions(){if(this.version==1)return[];{const i=Math.floor(this.version/7)+2,l=this.version==32?26:Math.ceil((this.version*4+4)/(i*2-2))*2;let d=[6];for(let c=this.size-7;d.length<i;c-=l)d.splice(1,0,c);return d}}static getNumRawDataModules(i){if(i<je.MIN_VERSION||i>je.MAX_VERSION)throw new RangeError("Version number out of range");let l=(16*i+128)*i+64;if(i>=2){const d=Math.floor(i/7)+2;l-=(25*d-10)*d-55,i>=7&&(l-=36)}return g(208<=l&&l<=29648),l}static getNumDataCodewords(i,l){return Math.floor(je.getNumRawDataModules(i)/8)-je.ECC_CODEWORDS_PER_BLOCK[l.ordinal][i]*je.NUM_ERROR_CORRECTION_BLOCKS[l.ordinal][i]}static reedSolomonComputeDivisor(i){if(i<1||i>255)throw new RangeError("Degree out of range");let l=[];for(let c=0;c<i-1;c++)l.push(0);l.push(1);let d=1;for(let c=0;c<i;c++){for(let m=0;m<l.length;m++)l[m]=je.reedSolomonMultiply(l[m],d),m+1<l.length&&(l[m]^=l[m+1]);d=je.reedSolomonMultiply(d,2)}return l}static reedSolomonComputeRemainder(i,l){let d=l.map(c=>0);for(const c of i){const m=c^d.shift();d.push(0),l.forEach((x,w)=>d[w]^=je.reedSolomonMultiply(x,m))}return d}static reedSolomonMultiply(i,l){if(i>>>8||l>>>8)throw new RangeError("Byte out of range");let d=0;for(let c=7;c>=0;c--)d=d<<1^(d>>>7)*285,d^=(l>>>c&1)*i;return g(d>>>8==0),d}finderPenaltyCountPatterns(i){const l=i[1];g(l<=this.size*3);const d=l>0&&i[2]==l&&i[3]==l*3&&i[4]==l&&i[5]==l;return(d&&i[0]>=l*4&&i[6]>=l?1:0)+(d&&i[6]>=l*4&&i[0]>=l?1:0)}finderPenaltyTerminateAndCount(i,l,d){return i&&(this.finderPenaltyAddHistory(l,d),l=0),l+=this.size,this.finderPenaltyAddHistory(l,d),this.finderPenaltyCountPatterns(d)}finderPenaltyAddHistory(i,l){l[0]==0&&(i+=this.size),l.pop(),l.unshift(i)}};s.MIN_VERSION=1,s.MAX_VERSION=40,s.PENALTY_N1=3,s.PENALTY_N2=3,s.PENALTY_N3=40,s.PENALTY_N4=10,s.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],s.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=s;function r(n,i,l){if(i<0||i>31||n>>>i)throw new RangeError("Value out of range");for(let d=i-1;d>=0;d--)l.push(n>>>d&1)}function o(n,i){return(n>>>i&1)!=0}function g(n){if(!n)throw new Error("Assertion error")}const p=class tt{constructor(i,l,d){if(this.mode=i,this.numChars=l,this.bitData=d,l<0)throw new RangeError("Invalid argument");this.bitData=d.slice()}static makeBytes(i){let l=[];for(const d of i)r(d,8,l);return new tt(tt.Mode.BYTE,i.length,l)}static makeNumeric(i){if(!tt.isNumeric(i))throw new RangeError("String contains non-numeric characters");let l=[];for(let d=0;d<i.length;){const c=Math.min(i.length-d,3);r(parseInt(i.substring(d,d+c),10),c*3+1,l),d+=c}return new tt(tt.Mode.NUMERIC,i.length,l)}static makeAlphanumeric(i){if(!tt.isAlphanumeric(i))throw new RangeError("String contains unencodable characters in alphanumeric mode");let l=[],d;for(d=0;d+2<=i.length;d+=2){let c=tt.ALPHANUMERIC_CHARSET.indexOf(i.charAt(d))*45;c+=tt.ALPHANUMERIC_CHARSET.indexOf(i.charAt(d+1)),r(c,11,l)}return d<i.length&&r(tt.ALPHANUMERIC_CHARSET.indexOf(i.charAt(d)),6,l),new tt(tt.Mode.ALPHANUMERIC,i.length,l)}static makeSegments(i){return i==""?[]:tt.isNumeric(i)?[tt.makeNumeric(i)]:tt.isAlphanumeric(i)?[tt.makeAlphanumeric(i)]:[tt.makeBytes(tt.toUtf8ByteArray(i))]}static makeEci(i){let l=[];if(i<0)throw new RangeError("ECI assignment value out of range");if(i<128)r(i,8,l);else if(i<16384)r(2,2,l),r(i,14,l);else if(i<1e6)r(6,3,l),r(i,21,l);else throw new RangeError("ECI assignment value out of range");return new tt(tt.Mode.ECI,0,l)}static isNumeric(i){return tt.NUMERIC_REGEX.test(i)}static isAlphanumeric(i){return tt.ALPHANUMERIC_REGEX.test(i)}getData(){return this.bitData.slice()}static getTotalBits(i,l){let d=0;for(const c of i){const m=c.mode.numCharCountBits(l);if(c.numChars>=1<<m)return 1/0;d+=4+m+c.bitData.length}return d}static toUtf8ByteArray(i){i=encodeURI(i);let l=[];for(let d=0;d<i.length;d++)i.charAt(d)!="%"?l.push(i.charCodeAt(d)):(l.push(parseInt(i.substring(d+1,d+3),16)),d+=2);return l}};p.NUMERIC_REGEX=/^[0-9]*$/,p.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,p.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let v=p;e.QrSegment=p})(xs||(xs={}));(e=>{(s=>{const r=class{constructor(g,p){this.ordinal=g,this.formatBits=p}};r.LOW=new r(0,1),r.MEDIUM=new r(1,0),r.QUARTILE=new r(2,3),r.HIGH=new r(3,2),s.Ecc=r})(e.QrCode||(e.QrCode={}))})(xs||(xs={}));(e=>{(s=>{const r=class{constructor(g,p){this.modeBits=g,this.numBitsCharCount=p}numCharCountBits(g){return this.numBitsCharCount[Math.floor((g+7)/17)]}};r.NUMERIC=new r(1,[10,12,14]),r.ALPHANUMERIC=new r(2,[9,11,13]),r.BYTE=new r(4,[8,16,16]),r.KANJI=new r(8,[8,10,12]),r.ECI=new r(7,[0,0,0]),s.Mode=r})(e.QrSegment||(e.QrSegment={}))})(xs||(xs={}));var Ts=xs;var q0={L:Ts.QrCode.Ecc.LOW,M:Ts.QrCode.Ecc.MEDIUM,Q:Ts.QrCode.Ecc.QUARTILE,H:Ts.QrCode.Ecc.HIGH},wc=128,Cc="L",kc="#FFFFFF",Ec="#000000",jc=!1,Nc=1,K0=4,X0=0,Y0=.1;function Rc(e,s=0){const r=[];return e.forEach(function(o,g){let p=null;o.forEach(function(v,n){if(!v&&p!==null){r.push(`M${p+s} ${g+s}h${n-p}v1H${p+s}z`),p=null;return}if(n===o.length-1){if(!v)return;p===null?r.push(`M${n+s},${g+s} h1v1H${n+s}z`):r.push(`M${p+s},${g+s} h${n+1-p}v1H${p+s}z`);return}v&&p===null&&(p=n)})}),r.join("")}function Ac(e,s){return e.slice().map((r,o)=>o<s.y||o>=s.y+s.h?r:r.map((g,p)=>p<s.x||p>=s.x+s.w?g:!1))}function V0(e,s,r,o){if(o==null)return null;const g=e.length+r*2,p=Math.floor(s*Y0),v=g/s,n=(o.width||p)*v,i=(o.height||p)*v,l=o.x==null?e.length/2-n/2:o.x*v,d=o.y==null?e.length/2-i/2:o.y*v,c=o.opacity==null?1:o.opacity;let m=null;if(o.excavate){let w=Math.floor(l),y=Math.floor(d),a=Math.ceil(n+l-w),h=Math.ceil(i+d-y);m={x:w,y,w:a,h}}const x=o.crossOrigin;return{x:l,y:d,h:i,w:n,excavation:m,opacity:c,crossOrigin:x}}function G0(e,s){return s!=null?Math.max(Math.floor(s),0):e?K0:X0}function Tc({value:e,level:s,minVersion:r,includeMargin:o,marginSize:g,imageSettings:p,size:v,boostLevel:n}){let i=ae.useMemo(()=>{const w=(Array.isArray(e)?e:[e]).reduce((y,a)=>(y.push(...Ts.QrSegment.makeSegments(a)),y),[]);return Ts.QrCode.encodeSegments(w,q0[s],r,void 0,void 0,n)},[e,s,r,n]);const{cells:l,margin:d,numCells:c,calculatedImageSettings:m}=ae.useMemo(()=>{let x=i.getModules();const w=G0(o,g),y=x.length+w*2,a=V0(x,v,w,p);return{cells:x,margin:w,numCells:y,calculatedImageSettings:a}},[i,v,p,o,g]);return{qrcode:i,margin:d,cells:l,numCells:c,calculatedImageSettings:m}}var Q0=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),Z0=ae.forwardRef(function(s,r){const o=s,{value:g,size:p=wc,level:v=Cc,bgColor:n=kc,fgColor:i=Ec,includeMargin:l=jc,minVersion:d=Nc,boostLevel:c,marginSize:m,imageSettings:x}=o,y=an(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:a}=y,h=an(y,["style"]),u=x?.src,f=ae.useRef(null),b=ae.useRef(null),C=ae.useCallback(W=>{f.current=W,typeof r=="function"?r(W):r&&(r.current=W)},[r]),[k,E]=ae.useState(!1),{margin:_,cells:j,numCells:A,calculatedImageSettings:P}=Tc({value:g,level:v,minVersion:d,boostLevel:c,includeMargin:l,marginSize:m,imageSettings:x,size:p});ae.useEffect(()=>{if(f.current!=null){const W=f.current,I=W.getContext("2d");if(!I)return;let B=j;const F=b.current,R=P!=null&&F!==null&&F.complete&&F.naturalHeight!==0&&F.naturalWidth!==0;R&&P.excavation!=null&&(B=Ac(j,P.excavation));const M=window.devicePixelRatio||1;W.height=W.width=p*M;const L=p/A*M;I.scale(L,L),I.fillStyle=n,I.fillRect(0,0,A,A),I.fillStyle=i,Q0?I.fill(new Path2D(Rc(B,_))):j.forEach(function(O,U){O.forEach(function(Y,z){Y&&I.fillRect(z+_,U+_,1,1)})}),P&&(I.globalAlpha=P.opacity),R&&I.drawImage(F,P.x+_,P.y+_,P.w,P.h)}}),ae.useEffect(()=>{E(!1)},[u]);const T=on({height:p,width:p},a);let D=null;return u!=null&&(D=ae.createElement("img",{src:u,key:u,style:{display:"none"},onLoad:()=>{E(!0)},ref:b,crossOrigin:P?.crossOrigin})),ae.createElement(ae.Fragment,null,ae.createElement("canvas",on({style:T,height:p,width:p,ref:C,role:"img"},h)),D)});Z0.displayName="QRCodeCanvas";var Mc=ae.forwardRef(function(s,r){const o=s,{value:g,size:p=wc,level:v=Cc,bgColor:n=kc,fgColor:i=Ec,includeMargin:l=jc,minVersion:d=Nc,boostLevel:c,title:m,marginSize:x,imageSettings:w}=o,y=an(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:a,cells:h,numCells:u,calculatedImageSettings:f}=Tc({value:g,level:v,minVersion:d,boostLevel:c,includeMargin:l,marginSize:x,imageSettings:w,size:p});let b=h,C=null;w!=null&&f!=null&&(f.excavation!=null&&(b=Ac(h,f.excavation)),C=ae.createElement("image",{href:w.src,height:f.h,width:f.w,x:f.x+a,y:f.y+a,preserveAspectRatio:"none",opacity:f.opacity,crossOrigin:f.crossOrigin}));const k=Rc(b,a);return ae.createElement("svg",on({height:p,width:p,viewBox:`0 0 ${u} ${u}`,ref:r,role:"img"},y),!!m&&ae.createElement("title",null,m),ae.createElement("path",{fill:n,d:`M0,0 h${u}v${u}H0z`,shapeRendering:"crispEdges"}),ae.createElement("path",{fill:i,d:k,shapeRendering:"crispEdges"}),C)});Mc.displayName="QRCodeSVG";function Dc(){return parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10)}function J0(){return Bt({queryKey:de.tunnel.status,queryFn:()=>Ce.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?5e3:!1})}function ex(){const e=bt();return Ft({mutationFn:()=>Ce.post("/tunnel/start",{port:Dc()}),onSuccess:()=>{e.invalidateQueries({queryKey:de.tunnel.status})}})}function tx(){const e=bt();return Ft({mutationFn:()=>Ce.post("/tunnel/regenerate",{port:Dc()}),onSuccess:()=>{e.invalidateQueries({queryKey:de.tunnel.status})}})}function sx(){const e=bt();return Ft({mutationFn:()=>Ce.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:de.tunnel.status})}})}function rx(e){if(!e||e.status==="stopped")return{button:"text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100",dot:"",label:"Use Agent Tower on your phone",icon:"idle"};switch(e.status){case"healthy":case"checking":return{button:"text-emerald-600 hover:bg-emerald-50",dot:"bg-emerald-500",label:e.status==="healthy"?"Tunnel healthy":"Checking tunnel health",icon:"ok"};case"degraded":case"localUnhealthy":case"linkReplaced":return{button:"text-amber-600 hover:bg-amber-50",dot:"bg-amber-500",label:"Tunnel needs attention",icon:"warn"};case"exited":case"error":return{button:"text-red-600 hover:bg-red-50",dot:"bg-red-500",label:"Tunnel unavailable",icon:"error"};case"starting":return{button:"text-amber-600 hover:bg-amber-50",dot:"bg-amber-500",label:"Tunnel starting",icon:"loading"}}}function ix(e){if(!e||e.status==="stopped")return"Tunnel is off";switch(e.status){case"healthy":return"Tunnel healthy";case"checking":return"Checking tunnel health";case"degraded":return"Observing original link";case"localUnhealthy":return"Local service unavailable";case"exited":return"Tunnel process exited";case"error":return"Tunnel error";case"linkReplaced":return"New link generated";case"starting":return"Tunnel starting"}}function nx(e){if(!e||e.status==="stopped")return"Start a temporary Quick Tunnel when you need to share this Agent Tower session.";switch(e.status){case"healthy":return"The Cloudflare tunnel is running and the local Agent Tower health check passed.";case"checking":return"The Cloudflare tunnel is running. Agent Tower is waiting for the first local health check.";case"degraded":return"The original public URL is currently unreachable. Agent Tower is watching for it to recover and will not generate a new link automatically.";case"localUnhealthy":return"The local Agent Tower target is not responding, so the tunnel cannot be considered healthy.";case"exited":return"The tunnel process has exited. The old Quick Tunnel link is unlikely to recover.";case"error":return"The tunnel reported an error. Check the diagnostics before generating a new link.";case"linkReplaced":return"A new Quick Tunnel link was generated. The old link and token are no longer valid.";case"starting":return"Agent Tower is asking Cloudflare Quick Tunnel for a temporary public URL."}}function da(e){if(!e)return"Never";const s=new Date(e).getTime();if(!Number.isFinite(s))return e;const r=Math.max(0,Math.round((Date.now()-s)/1e3));if(r<60)return`${r}s ago`;const o=Math.round(r/60);if(o<60)return`${o}m ago`;const g=Math.round(o/60);return g<24?`${g}h ago`:`${Math.round(g/24)}d ago`}function Zs(e){const s=e?.trim();return s||null}function ox(e){if(!e)return"";const s=[Zs(e.lastLocalError),Zs(e.lastRemoteError),Zs(e.lastError)].filter(g=>g!==null),r=Zs(e.lastProcessOutput),o=!!r&&(e.status==="error"||e.status==="exited"||!!Zs(e.lastError));return r&&o&&s.push(r),s.join(`
86
- `)}function ua(){const{t:e}=ce(),{data:s}=J0(),r=ex(),o=sx(),g=tx(),[p,v]=S.useState(!1),[n,i]=S.useState(null),l=S.useRef(null),[d,c]=S.useState({top:0,right:0}),[m,x]=S.useState(!1),[w,y]=S.useState(!1),a=s?.status!==void 0&&s.status!=="stopped",h=r.isPending||s?.status==="starting",u=g.isPending,f=s?.shareableUrl,b=s?.token,C=rx(s),k=ix(s),E=ox(s);S.useEffect(()=>{if(p&&l.current){const W=l.current.getBoundingClientRect();c({top:W.bottom+8,right:window.innerWidth-W.right})}},[p]);const _=S.useCallback(()=>{v(!0)},[a]),j=S.useCallback(()=>{r.mutate(void 0,{onSuccess:()=>v(!0)})},[r]),A=S.useCallback(()=>{f&&(navigator.clipboard.writeText(f),i("url"),setTimeout(()=>i(null),2e3))},[f]),P=S.useCallback(()=>{b&&(navigator.clipboard.writeText(b),i("token"),setTimeout(()=>i(null),2e3))},[b]),T=S.useCallback(()=>{o.mutate(),v(!1),x(!1),y(!1)},[o]),D=S.useCallback(()=>{g.mutate(void 0,{onSuccess:()=>{y(!1),v(!0)}})},[g]);return t.jsxs("div",{className:"relative",children:[t.jsx("button",{ref:l,onClick:_,disabled:h,className:`p-1.5 rounded-md transition-colors ${C.button}`,title:e(C.label),children:h?t.jsx(Ke,{size:16,className:"animate-spin"}):C.icon==="warn"?t.jsx(ur,{size:16}):t.jsx(oo,{size:16})}),a&&!h&&t.jsx("span",{className:`absolute top-0.5 right-0.5 w-2 h-2 ${C.dot} rounded-full`}),p&&!a&&ps.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>v(!1)}),t.jsxs("div",{className:"fixed z-[101] w-80 max-w-[calc(100vw-1rem)] bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:d.top,right:d.right},children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"mt-0.5 flex size-7 items-center justify-center rounded-md bg-neutral-100 text-neutral-700",children:t.jsx(oo,{size:16})}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-neutral-900",children:e("Use Agent Tower on your phone")}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:e("After enabling the tunnel, you can scan a QR code with your phone to visit this Agent Tower instance, assign tasks, and check agent status.")})]})]}),t.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(Yt,{size:14})})]}),t.jsxs("button",{onClick:j,disabled:h,className:"mt-3 w-full px-3 py-2 text-xs font-medium text-white bg-neutral-900 hover:bg-neutral-800 rounded-md transition-colors disabled:opacity-50 flex items-center justify-center gap-1.5",children:[h&&t.jsx(Ke,{size:13,className:"animate-spin"}),e(h?"Starting tunnel...":"Enable phone access")]})]})]}),document.body),p&&a&&ps.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>v(!1)}),t.jsxs("div",{className:"fixed z-[101] w-96 max-w-[calc(100vw-1rem)] bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:d.top,right:d.right},children:[t.jsxs("div",{className:"flex items-start justify-between mb-2",children:[t.jsxs("div",{children:[t.jsxs("span",{className:`text-xs font-medium flex items-center gap-1.5 ${s?.status==="healthy"||s?.status==="checking"?"text-emerald-600":s?.status==="exited"||s?.status==="error"?"text-red-600":"text-amber-600"}`,children:[t.jsx("span",{className:`w-1.5 h-1.5 ${C.dot} rounded-full inline-block`}),e(k)]}),t.jsx("p",{className:"mt-1 text-xs text-neutral-500 leading-relaxed",children:e(nx(s))})]}),t.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(Yt,{size:14})})]}),b&&t.jsxs("div",{className:"flex items-center gap-1.5 mb-2 px-2 py-1 bg-neutral-50 rounded text-xs text-neutral-700",children:[t.jsx(Sd,{size:12}),t.jsx("span",{children:e("Token protected")})]}),f&&t.jsx("div",{className:"flex justify-center py-3",children:t.jsx(Mc,{value:f,size:160})}),f||s?.url?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{readOnly:!0,value:f??s?.url??"",className:"flex-1 min-w-0 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-700 select-all",onFocus:W=>W.target.select()}),t.jsx("button",{onClick:A,disabled:!f,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors disabled:opacity-40",title:e("Copy shareable link"),children:n==="url"?t.jsx(Vt,{size:14,className:"text-emerald-500"}):t.jsx(io,{size:14})})]}):t.jsx("div",{className:"rounded-md border border-neutral-200 bg-neutral-50 px-2 py-1.5 text-xs text-neutral-500",children:e("No tunnel link available")}),t.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-xs",children:[t.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[t.jsx("div",{className:"text-neutral-500",children:e("Last checked")}),t.jsx("div",{className:"mt-0.5 text-neutral-800",children:da(s?.lastCheckedAt)})]}),t.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[t.jsx("div",{className:"text-neutral-500",children:e("Last healthy")}),t.jsx("div",{className:"mt-0.5 text-neutral-800",children:da(s?.lastHealthyAt)})]})]}),E&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800 whitespace-pre-wrap break-words max-h-28 overflow-auto",children:E}),s?.status==="degraded"&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800",children:e("Agent Tower is keeping the same URL and waiting for Cloudflare Quick Tunnel to recover.")}),s?.status==="linkReplaced"&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800",children:e("The previous tunnel link and token are no longer valid.")}),b&&t.jsxs("div",{className:"mt-2",children:[t.jsx("button",{onClick:()=>x(!m),className:"text-xs text-neutral-500 hover:text-neutral-700 transition-colors",children:e(m?"Hide token":"Show token")}),m&&t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.jsx("code",{className:"flex-1 min-w-0 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-600 break-all",children:b}),t.jsx("button",{onClick:P,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors shrink-0",title:e("Copy token"),children:n==="token"?t.jsx(Vt,{size:14,className:"text-emerald-500"}):t.jsx(io,{size:14})})]})]}),w&&t.jsxs("div",{className:"mt-3 rounded-md border border-red-200 bg-red-50 p-2 text-xs text-red-700",children:[t.jsx("div",{children:e("Generating a new link will invalidate the current link. People using the old URL must receive the new one.")}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsx("button",{onClick:()=>y(!1),className:"flex-1 px-2 py-1 rounded-md bg-white text-neutral-700 border border-neutral-200 hover:bg-neutral-50",children:e("Cancel")}),t.jsx("button",{onClick:D,disabled:u,className:"flex-1 px-2 py-1 rounded-md bg-red-600 text-white hover:bg-red-700 disabled:opacity-50",children:e(u?"Generating...":"Regenerate link")})]})]}),!w&&t.jsxs("button",{onClick:()=>y(!0),disabled:u||s?.canRegenerate===!1,className:"mt-3 w-full px-3 py-1.5 text-xs text-amber-700 hover:bg-amber-50 rounded-md transition-colors disabled:opacity-40 flex items-center justify-center gap-1.5",children:[t.jsx(hr,{size:13}),e("Regenerate link")]}),t.jsx("button",{onClick:T,disabled:o.isPending,className:"mt-2 w-full px-3 py-1.5 text-xs text-red-600 hover:bg-red-50 rounded-md transition-colors",children:o.isPending?e("Stopping..."):e("Stop Tunnel")})]})]}),document.body)]})}function Ui({isOpen:e,onClose:s}){const{t:r}=ce(),o=Rd(),[g,p]=S.useState(""),[v,n]=S.useState(""),[i,l]=S.useState(null),[d,c]=S.useState(!1),[m,x]=S.useState(!1),w=g.trim(),y=v.trim(),a=d||o.isPending,h=S.useMemo(()=>!!(w&&y&&!a),[w,y,a]),u=S.useCallback(()=>{p(""),n(""),l(null),x(!1)},[]),f=S.useCallback(()=>{a||(u(),s())},[a,s,u]);S.useEffect(()=>{e||u()},[e,u]);const b=S.useCallback(async _=>{try{await o.mutateAsync({name:w,repoPath:y,initEmptyRepo:_}),u(),s()}catch(j){const A=j instanceof Error?j.message:r("Failed to create project");l(A),rt.error(A)}},[o,s,u,r,w,y]),C=S.useCallback(async()=>{if(!(!w||!y||a)){l(null),c(!0);try{const _=await Ce.get("/filesystem/validate",{params:{path:y}});if(!_.valid){l(_.error??r("Selected path is not a valid directory"));return}if(_.isGitRepo){await b(!1);return}if(_.reason==="no_git"&&_.isEmpty){x(!0);return}if(_.reason==="no_git"){await b(!1);return}await b(!1)}catch(_){l(_ instanceof Error?_.message:r("Could not check project path"))}finally{c(!1)}}},[b,a,r,w,y]),k=S.useCallback(()=>{x(!1),b(!1)},[b]),E=S.useCallback(()=>{x(!1),b(!0)},[b]);return t.jsxs(t.Fragment,{children:[t.jsx(ns,{isOpen:e,onClose:f,title:r("Create New Project"),action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:f,disabled:a,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:r("Cancel")}),t.jsx("button",{onClick:C,disabled:!h,className:`px-4 py-2 text-sm font-medium rounded-lg transition-all ${h?"bg-neutral-900 text-white hover:bg-black":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:d?r("Checking..."):o.isPending?r("Creating..."):r("Create Project")})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Project Name")}),t.jsx("input",{type:"text",value:g,onChange:_=>p(_.target.value),placeholder:r("e.g., Agent Tower"),disabled:a,className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:border-neutral-400 transition-colors disabled:bg-neutral-50 disabled:text-neutral-400",autoFocus:!0})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Project Path")}),t.jsx(kd,{value:v,onChange:n,validationMode:"directory"})]}),i&&t.jsx("p",{className:"text-xs text-red-500 leading-relaxed",children:i})]})}),t.jsx(ns,{isOpen:m,onClose:()=>{o.isPending||x(!1)},title:r("Initialize Git repository?"),action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>x(!1),disabled:o.isPending,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:r("Cancel")}),t.jsx("button",{onClick:k,disabled:o.isPending,className:"px-4 py-2 text-sm font-medium rounded-lg border border-neutral-200 text-neutral-700 hover:bg-neutral-50 transition-colors disabled:opacity-50",children:r("Create Local Project")}),t.jsx("button",{onClick:E,disabled:o.isPending,className:"px-4 py-2 text-sm font-medium rounded-lg bg-neutral-900 text-white hover:bg-black transition-colors disabled:opacity-50",children:o.isPending?r("Creating..."):r("Initialize and Create")})]}),children:t.jsxs("div",{className:"space-y-3 text-sm text-neutral-600 leading-relaxed",children:[t.jsx("p",{children:r("This directory is empty and does not have Git version control yet. Agent Tower can initialize Git and create the initial commit before creating the project.")}),t.jsx("p",{children:r("You can also create it as a local project now. Local projects only support local Solo tasks until Git is initialized.")})]})})]})}function ha(e){if(!e)return 0;const s=Date.parse(e);return Number.isNaN(s)?0:s}function ax(e){return e.map((s,r)=>({project:s,index:r,activityTime:ha(s.lastActivityAt??s.createdAt),createdTime:ha(s.createdAt)})).sort((s,r)=>{const o=r.activityTime-s.activityTime;if(o!==0)return o;const g=r.createdTime-s.createdTime;return g!==0?g:s.index-r.index}).map(({project:s})=>s)}function fa({projects:e,filterProjectId:s,setFilterProjectId:r,onCreateProject:o,className:g}){const{t:p}=ce(),[v,n]=S.useState(!1),i=e.filter(d=>!d.archivedAt),l=s?e.find(d=>d.id===s)??null:null;return t.jsxs("div",{className:se("relative flex items-center min-w-0",g),children:[t.jsx("span",{className:"mx-1.5 text-muted-foreground/40 select-none",children:"/"}),t.jsxs("button",{onClick:()=>n(d=>!d),className:"flex items-center gap-1.5 px-2 py-1 rounded-md text-sm text-foreground/90 hover:bg-accent transition-colors min-w-0",children:[l?t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${l.color.replace("text-","bg-")}`}):t.jsx(Ps,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"truncate max-w-[200px] font-medium",children:l?l.name:p("All Projects")}),t.jsx(wt,{size:13,className:`text-muted-foreground/70 shrink-0 transition-transform duration-200 ${v?"rotate-180":""}`})]}),v?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>n(!1)}),t.jsxs("div",{className:"absolute left-4 top-full mt-1.5 w-60 bg-popover border border-border rounded-lg shadow-lg shadow-black/5 z-40 py-1 animate-in fade-in zoom-in-95 duration-100 origin-top-left",children:[t.jsxs("button",{onClick:()=>{r(null),n(!1)},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 hover:bg-accent/50 transition-colors",children:[t.jsx(Ps,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:`flex-1 truncate ${s===null?"text-foreground font-medium":"text-muted-foreground"}`,children:p("All Projects")}),s===null?t.jsx(Vt,{size:14,className:"text-foreground shrink-0"}):null]}),t.jsx("div",{className:"h-px bg-border/60 my-1 mx-2"}),t.jsx("div",{className:"max-h-[40vh] overflow-y-auto scrollbar-app-thin",children:i.map(d=>{const c=s===d.id;return t.jsxs("button",{onClick:()=>{r(d.id),n(!1)},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 hover:bg-accent/50 transition-colors",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${d.color.replace("text-","bg-")}`}),t.jsx("span",{className:`flex-1 truncate ${c?"text-foreground font-medium":"text-muted-foreground"}`,children:d.name}),c?t.jsx(Vt,{size:14,className:"text-foreground shrink-0"}):null]},d.id)})}),t.jsx("div",{className:"h-px bg-border/60 my-1 mx-2"}),t.jsxs("button",{onClick:()=>{n(!1),o()},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 text-muted-foreground hover:text-foreground hover:bg-accent/50 transition-colors",children:[t.jsx(ts,{size:13}),t.jsx("span",{children:p("Create New Project...")})]})]})]}):null]})}function ma(){return t.jsx("div",{className:"px-4 pt-6 space-y-5 animate-pulse","aria-hidden":!0,children:Array.from({length:6}).map((e,s)=>t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("div",{className:"w-4 h-4 rounded-full bg-muted shrink-0 mt-0.5"}),t.jsxs("div",{className:"flex-1 space-y-2",children:[t.jsx("div",{className:"h-3 rounded bg-muted",style:{width:`${70-s%3*12}%`}}),t.jsx("div",{className:"h-2.5 rounded bg-muted/70",style:{width:`${45+s%2*18}%`}})]})]},s))})}const lx=260,cx=600,pa=400,dx=100,ux=1e3;function hx(e){const s=e.workspaces?.find(o=>o.status==="ACTIVE")??e.workspaces?.[0],r=s?.sessions?.at(-1);return{id:e.id,projectId:e.projectId,title:e.titlePreview??e.title,status:e.status,...s?{preferredWorkspace:{...s.workspaceKind===_t.MAIN_DIRECTORY?{workspaceKind:_t.MAIN_DIRECTORY}:{},branchName:s.branchName}}:{},...r?{latestAgentType:r.agentType}:{},...e.workspaces?.some(o=>o.sessions?.some(g=>g.status==="RUNNING"||g.status==="PENDING"))?{hasRunningSession:!0}:{},updatedAt:e.updatedAt?new Date(e.updatedAt).getTime():Date.now()}}function fx(){const{t:e,locale:s}=ce(),[r,o]=S.useState(null),[g,p]=S.useState(null),[v,n]=S.useState(pa),[i,l]=S.useState(!1),[d,c]=S.useState("idle"),[m,x]=S.useState({}),w=S.useRef(!1),y=S.useRef(0),a=S.useRef(pa),h=S.useRef(null),u=bt(),{data:f,isLoading:b}=Bs(),{data:C,isLoading:k}=Ad({limit:dx}),E=S.useMemo(()=>C?.data??[],[C?.data]),_=g&&E.some(J=>J.id===g)?g:null,{data:j,isLoading:A}=ld({..._?{projectId:_}:{},limit:ux}),P=S.useMemo(()=>j?.data??[],[j?.data]),[T,D]=S.useState([]),W=S.useMemo(()=>{if(T.length===0)return P;const J=new Set(P.map(ue=>ue.id));return[...T.filter(ue=>!J.has(ue.id)),...P]},[P,T]),[I,B]=S.useState(null),F=S.useMemo(()=>r&&W.some(J=>J.id===r)?r:I&&r===I?I:null,[r,W,I]);S.useEffect(()=>{I&&W.some(J=>J.id===I)&&B(null)},[I,W]),S.useEffect(()=>{if(T.length===0)return;const J=new Set(P.map(ue=>ue.id));T.some(ue=>J.has(ue.id))&&D(ue=>ue.filter(V=>!J.has(V.id)))},[P,T]);const R=S.useMemo(()=>ax(E),[E]),M=S.useMemo(()=>R.map(w0),[R]),L=S.useMemo(()=>R.filter(J=>!J.archivedAt),[R]),O=S.useMemo(()=>{if(!f)return[];const J=localStorage.getItem("providerUsageCount"),ue=J?JSON.parse(J):{};return[...f].sort((V,Z)=>{const re=V.availability.type!=="NOT_FOUND",ye=Z.availability.type!=="NOT_FOUND";if(re!==ye)return re?-1:1;const me=ue[V.provider.id]??0;return(ue[Z.provider.id]??0)-me})},[f]),U=S.useMemo(()=>W.map(J=>C0(J,E.find(ue=>ue.id===J.projectId))),[E,W]),Y=S.useMemo(()=>{if(!F)return null;const J=W.find(V=>V.id===F);if(!J)return null;const ue=E.find(V=>V.id===J.projectId);if(!ue){const V=J.preferredWorkspace?J.preferredWorkspace.workspaceKind===_t.MAIN_DIRECTORY?"Project directory":J.preferredWorkspace.branchName:"—";return{id:J.id,projectId:J.projectId,projectName:"Unknown",projectColor:"text-muted-foreground",title:J.title,status:qn(J.status),branch:V,mainBranch:"main",description:"",isGitRepo:!1,worktreeReady:!1,reason:"NO_GIT",projectArchivedAt:null,projectRepoDeletedAt:null}}return k0(J,ue)},[F,W,E]),z=ba(),$=cd(),q=dd(),N=xn(),H=S.useCallback(J=>{const ue=hx(J);D(V=>V.some(Z=>Z.id===J.id)?V.map(Z=>Z.id===J.id?ue:Z):[ue,...V]),u.setQueryData(de.tasks.detail(J.id),J),B(J.id),o(J.id)},[u]),X=S.useCallback((J,ue,V)=>{const Z=J.id,re=[J.title,J.description].filter(Boolean).join(`
87
-
88
- `);x(ye=>({...ye,[Z]:{status:"creating-workspace"}})),(async()=>{try{const ye=await Ce.post(`/tasks/${Z}/workspaces`,{workspaceKind:V});x(Se=>({...Se,[Z]:{status:"creating-session"}}));const me=await Ce.post(`/workspaces/${ye.id}/sessions`,{providerId:ue,prompt:re});x(Se=>({...Se,[Z]:{status:"starting-session"}})),await N.mutateAsync(me.id),await u.invalidateQueries({queryKey:de.workspaces.list(Z)}),await u.invalidateQueries({queryKey:de.tasks.all}),x(Se=>{const{[Z]:we,...xe}=Se;return xe})}catch(ye){const me=ye instanceof Error?ye.message:e("启动 Agent 失败");x(Se=>({...Se,[Z]:{status:"failed",error:me}})),rt.error(e("任务已创建,但启动 Agent 失败,可在详情中重试")),u.invalidateQueries({queryKey:de.workspaces.list(Z)}),u.invalidateQueries({queryKey:de.tasks.all})}})()},[u,N,e]),K=S.useCallback(J=>{x(ue=>{const{[J]:V,...Z}=ue;return Z}),u.invalidateQueries({queryKey:de.workspaces.list(J)}),u.invalidateQueries({queryKey:de.tasks.all})},[u]),ne=S.useCallback(J=>{$.mutate(J,{onSuccess:()=>{F===J&&o(null),x(ue=>{const{[J]:V,...Z}=ue;return Z}),D(ue=>ue.filter(V=>V.id!==J)),u.invalidateQueries({queryKey:de.tasks.all})},onError:()=>{rt.error(e("删除任务失败"))}})},[$,F,u,e]),te=S.useCallback((J,ue)=>{q.mutate({id:J,status:y0(ue)},{onError:()=>{rt.error(e("状态变更失败,该操作不被允许"))}})},[q,e]),he=S.useCallback(J=>{J.preventDefault(),w.current=!0,y.current=J.clientX,a.current=v,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[v]);S.useEffect(()=>{const J=V=>{if(!w.current)return;const Z=V.clientX-y.current,re=Math.max(lx,Math.min(cx,a.current+Z));n(re)},ue=()=>{w.current&&(w.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",J),document.addEventListener("mouseup",ue),()=>{document.removeEventListener("mousemove",J),document.removeEventListener("mouseup",ue)}},[]);const le=S.useCallback(()=>{l(!0)},[]),G=S.useCallback(()=>{if(L.length===0){rt.error(e("没有可用项目,请先创建或恢复项目"));return}o(null)},[L,e]),pe=S.useCallback(()=>{l(!1)},[]),ie=S.useCallback(async J=>{const{title:ue,description:V,projectId:Z,providerId:re,mode:ye,workspaceMode:me,teamRunMode:Se,teamTemplateId:we,memberPresetIds:xe,attachmentLinks:ke}=J,De=[V,ke].filter(Boolean).join(`
89
-
90
- `);let Ee=null;try{if(c("creating-task"),Ee=await Ce.post(`/projects/${Z}/tasks`,{title:ue,description:De||void 0}),localStorage.setItem("lastSelectedProjectId",Z),ye==="SOLO"&&re){localStorage.setItem("lastSelectedProviderId",re);const Ge=localStorage.getItem("providerUsageCount"),ze=Ge?JSON.parse(Ge):{};ze[re]=(ze[re]??0)+1,localStorage.setItem("providerUsageCount",JSON.stringify(ze))}ye==="TEAM"?(c("creating-teamrun"),await z.mutateAsync({taskId:Ee.id,mode:Se,...we?{teamTemplateId:we}:{},...xe.length>0?{memberPresetIds:xe}:{}})):re&&X(Ee,re,me),_&&Z!==_&&p(null),H(Ee),c("idle"),u.invalidateQueries({queryKey:de.tasks.all}),u.invalidateQueries({queryKey:de.projects.all})}catch(Ye){if(c("idle"),Ee&&ye==="TEAM"){try{await $.mutateAsync(Ee.id)}catch{}throw rt.error(e("TeamRun 创建失败,请检查团队配置后重试")),Ye}else if(Ee)_&&Z!==_&&p(null),H(Ee),u.invalidateQueries({queryKey:de.tasks.all}),u.invalidateQueries({queryKey:de.projects.all});else throw rt.error(Ye instanceof Error?Ye.message:e("Failed to create task")),Ye}},[L,z,X,$,u,e,_,H]),Ae=k||A,at=S.useMemo(()=>L.map(J=>({id:J.id,name:J.name,color:M.find(ue=>ue.id===J.id)?.color,repoPath:J.repoPath,isGitRepo:J.isGitRepo,worktreeReady:J.worktreeReady,reason:J.reason})),[L,M]),Xe=S.useMemo(()=>O.map(({provider:J,availability:ue})=>({id:J.id,name:J.name,agentType:J.agentType,available:ue.type!=="NOT_FOUND"})),[O]),_e=S.useMemo(()=>{if(_&&L.find(ue=>ue.id===_))return _;const J=localStorage.getItem("lastSelectedProjectId");return J&&L.find(ue=>ue.id===J)?J:L[0]?.id??""},[L,_]),[Ie,Pe]=S.useState(_e);S.useEffect(()=>{Pe(_e)},[_e]);const $e=S.useMemo(()=>L.find(J=>J.id===Ie)?.name??L.find(J=>J.id===_e)?.name??e("Project"),[L,Ie,_e,e]),Oe=s==="zh-CN"?`你需要在 ${$e} 中做点什么?`:`What do you need to do in ${$e}?`,Ve=S.useMemo(()=>{const J=localStorage.getItem("lastSelectedProviderId");return J&&O.find(V=>V.provider.id===J&&V.availability.type!=="NOT_FOUND")?J:O.find(V=>V.availability.type!=="NOT_FOUND")?.provider.id??""},[O]),Ze=ml(),[Me,Re]=S.useState(!1),{usesIntegratedTitlebar:ve,desktopPlatform:Fe,hasMacTrafficLights:ge}=ga(),lt=ve&&Fe==="win32",Je=S.useCallback(()=>{if(L.length===0){rt.error(e("没有可用项目,请先创建或恢复项目"));return}Re(!0)},[L,e]),Et=S.useCallback(async J=>{await ie(J),Re(!1)},[ie]);return Ze?Me?t.jsxs("div",{className:"flex flex-col h-dvh bg-background overflow-hidden text-sm",children:[t.jsx("header",{className:"h-12 border-b border-border/60 flex items-center px-4 shrink-0",children:t.jsx("button",{onClick:()=>Re(!1),className:"text-sm text-muted-foreground active:text-foreground",children:e("Cancel")})}),t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-4 pb-[8vh]",children:[t.jsx("h1",{className:"max-w-full text-center text-[20px] font-medium tracking-tight leading-snug text-foreground mb-5 break-words",children:Oe}),t.jsx(so,{projects:at,providers:Xe,isProvidersLoading:b,onSubmit:Et,defaultProjectId:_e,defaultProviderId:Ve,onProjectChange:Pe,createStep:d})]})]}):F&&Y?t.jsxs(t.Fragment,{children:[t.jsx($0,{task:Y,onBack:()=>o(null),onDeleteTask:Y.projectArchivedAt?void 0:ne,isDeleting:$.isPending,autoStartState:m[Y.id]??null,onAutoStartRecovered:K}),t.jsx(Ui,{isOpen:i,onClose:pe})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-col h-dvh bg-sidebar overflow-hidden text-sm",children:[t.jsxs("header",{className:"h-12 bg-sidebar flex items-center px-4 justify-between shrink-0 z-20",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(ro,{}),t.jsx(fa,{projects:M,filterProjectId:_,setFilterProjectId:p,onCreateProject:le})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(ua,{}),t.jsx("button",{onClick:()=>Jn.getState().openSettings(),className:"p-1.5 text-muted-foreground/70 active:text-foreground rounded-md",children:t.jsx(Zn,{size:16})})]})]}),Ae&&U.length===0?t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(ma,{})}):t.jsx(bo,{tasks:U,projects:M,selectedTaskId:null,onSelectTask:o,filterProjectId:_,setFilterProjectId:p,width:"100%",onCreateTask:Je,onCreateProject:le,onTaskStatusChange:te})]}),t.jsx(Ui,{isOpen:i,onClose:pe})]}):t.jsxs("div",{ref:h,className:"flex flex-col h-screen bg-sidebar overflow-hidden text-sm",children:[t.jsxs("header",{className:se("h-12 bg-sidebar flex items-center px-4 justify-between flex-shrink-0 z-20 relative",ve&&"app-region-drag",lt&&"pr-[150px]"),children:[t.jsxs("div",{className:se("flex items-center gap-2 min-w-0",ge&&"pl-[72px]"),children:[t.jsx(ro,{}),t.jsx(fa,{projects:M,filterProjectId:_,setFilterProjectId:p,onCreateProject:le,className:ve?"app-region-no-drag":void 0})]}),t.jsxs("div",{className:se("flex items-center gap-1",ve&&"app-region-no-drag"),children:[t.jsx("div",{className:ve?"app-region-no-drag":void 0,children:t.jsx(ua,{})}),t.jsx("button",{onClick:()=>Jn.getState().openSettings(),className:se("p-1.5 text-muted-foreground/70 hover:text-foreground hover:bg-accent rounded-md transition-colors",ve&&"app-region-no-drag"),children:t.jsx(Zn,{size:16})})]})]}),t.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[Ae&&U.length===0?t.jsx("div",{className:"h-full overflow-hidden flex-shrink-0",style:{width:v},children:t.jsx(ma,{})}):t.jsx(bo,{tasks:U,projects:M,selectedTaskId:F,onSelectTask:o,filterProjectId:_,setFilterProjectId:p,width:v,onCreateTask:G,onCreateProject:le,isCreateActive:!F,onTaskStatusChange:te,onDeleteTask:ne}),t.jsx("div",{onMouseDown:he,className:"w-1 cursor-col-resize hover:bg-border active:bg-ring/40 transition-colors z-50 -ml-[2px] flex-shrink-0 h-full",title:e("Drag to resize")}),t.jsx("div",{className:"flex-1 flex min-w-0 mb-2 mr-2 rounded-xl border border-border/50 bg-background overflow-hidden",children:F&&Y?t.jsx(b0,{task:Y,onDeleteTask:Y.projectArchivedAt?void 0:ne,isDeleting:$.isPending,onTaskStatusChange:Y.projectArchivedAt?void 0:te,autoStartState:m[Y.id]??null,onAutoStartRecovered:K}):F&&!Y?t.jsx("div",{className:"flex-1 flex items-center justify-center bg-background min-w-0",children:t.jsx("span",{className:"text-sm text-muted-foreground/70",children:e("Loading...")})}):t.jsx("div",{className:"flex-1 flex flex-col items-center justify-center bg-background min-w-0 px-8 pb-[10vh]",children:t.jsxs("div",{className:"w-full max-w-2xl flex flex-col items-center animate-[fadeInUp_0.5s_cubic-bezier(0.16,1,0.3,1)]",children:[t.jsx("h1",{className:"max-w-full text-center text-[26px] font-medium tracking-tight leading-snug text-foreground mb-6 break-words",children:Oe}),t.jsx(so,{projects:at,providers:Xe,isProvidersLoading:b,onSubmit:ie,defaultProjectId:_e,defaultProviderId:Ve,onProjectChange:Pe,createStep:d})]})})})]}),t.jsx(Ui,{isOpen:i,onClose:pe})]})}const zx=Object.freeze(Object.defineProperty({__proto__:null,ProjectKanbanPage:fx},Symbol.toStringTag,{value:"Module"}));export{zx as P,Ll as l};